Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot] b7f9753ff7 chore(deps-dev): Bump vite from 7.3.2 to 8.1.3
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 7.3.2 to 8.1.3.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v8.1.3/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 8.1.3
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-10 18:21:07 +00:00
120 changed files with 1416 additions and 2708 deletions
+12 -11
View File
@@ -21,9 +21,9 @@ jobs:
os: [ ubuntu-latest, windows-latest, macos-latest ] os: [ ubuntu-latest, windows-latest, macos-latest ]
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: { persist-credentials: false } with: { persist-credentials: false }
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
- run: npm ci - run: npm ci
@@ -41,9 +41,9 @@ jobs:
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: { persist-credentials: false } with: { persist-credentials: false }
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
- run: npm ci - run: npm ci
@@ -56,7 +56,7 @@ jobs:
# Build and upload desktop CLI artifacts # Build and upload desktop CLI artifacts
- name: Set up Go - name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with: with:
go-version: ^1.23.x go-version: ^1.23.x
cache-dependency-path: desktop/go.sum cache-dependency-path: desktop/go.sum
@@ -90,12 +90,13 @@ jobs:
contents: read contents: read
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: { persist-credentials: false } with: { persist-credentials: false }
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
- run: npm ci - run: npm ci
- run: npx playwright install --with-deps chromium
- run: npm run test-unit-ci - run: npm run test-unit-ci
- name: Upload coverage reports to Codecov - name: Upload coverage reports to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
@@ -111,9 +112,9 @@ jobs:
contents: read contents: read
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: { persist-credentials: false } with: { persist-credentials: false }
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
- run: npm ci - run: npm ci
@@ -139,9 +140,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: { persist-credentials: false } with: { persist-credentials: false }
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
- run: npm ci - run: npm ci
+3 -3
View File
@@ -38,11 +38,11 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 uses: github/codeql-action/init@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file. # If you wish to specify custom queries, you can do so here or in a config file.
@@ -67,4 +67,4 @@ jobs:
# make release # make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@e0647621c2984b5ed2f768cb892365bf2a616ad1 # v4.37.2 uses: github/codeql-action/analyze@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
+2 -2
View File
@@ -16,13 +16,13 @@ jobs:
run: run:
shell: bash shell: bash
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: with:
fetch-depth: 0 fetch-depth: 0
ref: main ref: main
- name: Use Node.js from nvmrc - name: Use Node.js from nvmrc
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
+4 -4
View File
@@ -12,11 +12,11 @@ jobs:
contents: write contents: write
if: ${{ github.event_name == 'push' }} if: ${{ github.event_name == 'push' }}
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: { persist-credentials: false } with: { persist-credentials: false }
- name: Use Node.js from nvmrc - name: Use Node.js from nvmrc
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
@@ -45,11 +45,11 @@ jobs:
steps: steps:
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1 uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- run: docker build -t ghcr.io/maplibre/maputnik:main . - run: docker build -t ghcr.io/maplibre/maputnik:main .
- run: docker push ghcr.io/maplibre/maputnik:main - run: docker push ghcr.io/maplibre/maputnik:main
+5 -5
View File
@@ -15,14 +15,14 @@ jobs:
permissions: permissions:
contents: read contents: read
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: with:
fetch-depth: 0 fetch-depth: 0
ref: main ref: main
persist-credentials: false persist-credentials: false
- name: Use Node.js from nvmrc - name: Use Node.js from nvmrc
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
@@ -42,19 +42,19 @@ jobs:
run: run:
shell: bash shell: bash
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: with:
fetch-depth: 0 fetch-depth: 0
ref: main ref: main
- name: Use Node.js from nvmrc - name: Use Node.js from nvmrc
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org" registry-url: "https://registry.npmjs.org"
- name: Set up Go for desktop build - name: Set up Go for desktop build
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with: with:
go-version: ^1.23.x go-version: ^1.23.x
cache-dependency-path: desktop/go.sum cache-dependency-path: desktop/go.sum
+1 -104
View File
@@ -36,7 +36,7 @@ Then run the end-to-end tests (Playwright starts the dev server automatically):
npm run test npm run test
``` ```
Run the unit tests with Vitest: Run the unit and component tests with Vitest:
``` ```
npm run test-unit npm run test-unit
@@ -45,106 +45,3 @@ npm run test-unit
## Pull Requests ## Pull Requests
- Pull requests should update `CHANGELOG.md` with a short description of the change. - Pull requests should update `CHANGELOG.md` with a short description of the change.
## Testing
### Prefer end-to-end tests
Most of this codebase is React components, and they are only reachable from an
end-to-end test. E2E coverage is the primary signal.
Reach for a unit test only for pure logic that e2e cannot cheaply reach (parsers,
sorting, watchers, stores). Before writing one, check whether e2e already covers
the file — a unit test that duplicates existing e2e coverage adds test code and
almost no coverage:
```
npx nyc report --reporter=text --include="src/libs/style.ts"
```
Do **not** merge the Vitest (v8) and e2e (istanbul) coverage reports locally. They
produce conflicting statement maps for the same files and the combined percentage
is meaningless. Codecov merges the two uploads server-side; that is the number to
trust. Locally, read them separately:
- e2e: `npx playwright test` then `npx nyc report --reporter=text-summary` (reads `.nyc_output/`)
- unit: `npx vitest run --coverage` (writes `coverage/`)
### E2E layering
Three layers, and the boundaries matter:
- `e2e/playwright-helper.ts` — generic, app-agnostic browser actions. **The only
file allowed to import `@playwright/test`** (besides `e2e/utils/fixtures.ts`).
- `e2e/maputnik-driver.ts` — domain actions (layers, filters, functions, the
style). Knows nothing about `page` or Playwright.
- `e2e/modal-driver.ts` — actions scoped to a modal, exposed as `when.modal.*`.
Specs get a driver at describe scope and assert fluently:
```ts
describe("layer editor", () => {
const { given, get, when, then } = new MaputnikDriver();
...
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ layers: [{ id, type: "fill" }] });
});
```
New UI interactions belong in a driver, not inline in a spec.
### Writing assertions
- `shouldDeepNestedInclude` is a recursive partial match (`toMatchObject`): nested
objects are matched as subsets, arrays and primitives must match exactly
(including array length).
- Assert against the whole style, not an extracted slice. Avoid
`get.styleFromLocalStorage().then(style => style.layers.find(...))` — it moves
test logic into the test. Compare the real object instead.
- `Query.then()` is lazy and returns a new `Query`, **not** a Promise. `await
get.styleFromLocalStorage()` hangs forever. Use `.get()` to await it directly,
or pass the Query to `then(...)`.
### One behaviour per test
If a test needs comments narrating "and now this…", it is several tests. Split it,
and hoist the shared setup into a nested `describe` + `beforeEach`.
### Test ids
Test ids use the `data-wd-key` attribute and are read via `get.elementByTestId`.
The `Input*` components already accept `data-wd-key` and render it on the real
`<input>`; the `Field*` wrappers forward it through their `{...props}` spread. So
passing `data-wd-key` to a `Field*` component is usually enough. Do **not** also
add it to `Block`/`Fieldset` — the id then matches two elements and locators fail
in strict mode.
Note `InputNumber` renders `<key>-text` and `<key>-range` when `allowRange` is set,
and `<key>` otherwise.
### Input commit semantics (common source of "the value didn't save")
- `InputString` only fires its `onChange` on **blur** or **Enter**. Typing alone
fires `onInput`. A driver that calls `fill()` must then call `blur()`, or the
value never reaches the style.
- `InputNumber` commits on every change; no blur needed.
- The autocomplete inputs (layer source, add-layer source) are controlled
downshift comboboxes. Keystroke typing is dropped/reordered — `{selectall}` then
typing `raster` yields `"exampleaster"`. Use `fill()`, which dispatches a single
input event, then pick from the filtered menu.
- CodeMirror auto-closes brackets and quotes, and types over its own closers, so
inserting a well-formed JSON fragment stays well-formed. To break JSON on
purpose, insert a bare word.
### Fixtures
Style fixtures live in `e2e/fixtures/`. A new one must be registered in two places
in `maputnik-driver.ts`: the list in `given.setupMockBackedResponses` and the
`styleFileByKey` map in `when.setStyle`.
### Verify a new test can fail
A test that passes for the wrong reason is worse than no test. After writing one,
mutate the expected value and confirm it fails. This has caught real mistakes
(e.g. a driver that never committed its input, so the assertion was matching a
value written by the *previous* step).
-60
View File
@@ -1,60 +0,0 @@
import { test, expect, describe, beforeEach } from "./utils/fixtures";
import { MaputnikDriver } from "./maputnik-driver";
import tokens from "../src/config/tokens.json" with { type: "json" };
describe("access tokens", () => {
const { given, when } = new MaputnikDriver();
const tileJson = {
tilejson: "2.2.0",
tiles: ["https://example.local/{z}/{x}/{y}.pbf"],
minzoom: 0,
maxzoom: 14,
};
beforeEach(async () => {
await given.setupMockBackedResponses();
});
test("uses the thunderforest token for a thunderforest source", async () => {
await given.interceptAndMockResponse({
method: "GET",
url: /tile\.thunderforest\.com\/.*/,
response: tileJson,
alias: "thunderforest",
});
await when.setStyle("access_tokens");
const request = await when.waitForResponse("thunderforest");
expect(request.url()).toContain(`apikey=${tokens.thunderforest}`);
});
test("uses the locationiq token for a locationiq source", async () => {
await given.interceptAndMockResponse({
method: "GET",
url: /tiles\.locationiq\.com\/.*/,
response: tileJson,
alias: "locationiq",
});
await when.setStyle("access_tokens");
const request = await when.waitForResponse("locationiq");
expect(request.url()).toContain(`key=${tokens.locationiq}`);
});
test("appends the stadia token as a query parameter", async () => {
await given.interceptAndMockResponse({
method: "GET",
url: /tiles\.stadiamaps\.com\/.*/,
response: tileJson,
alias: "stadia",
});
await when.setStyle("access_tokens");
const request = await when.waitForResponse("stadia");
expect(request.url()).toContain("?api_key=stadia-test-token");
});
});
-22
View File
@@ -1,22 +0,0 @@
{
"version": 8,
"name": "Access token style",
"metadata": {
"maputnik:stadia_access_token": "stadia-test-token"
},
"sources": {
"thunderforest_transport": {
"type": "vector",
"url": "https://tile.thunderforest.com/thunderforest.transport-v2.json?apikey={key}"
},
"stadia_outdoors": {
"type": "vector",
"url": "https://tiles.stadiamaps.com/data/openmaptiles.json"
},
"locationiq": {
"type": "vector",
"url": "https://tiles.locationiq.com/v3/pbf/tiles.json?key={key}"
}
},
"layers": []
}
+9 -367
View File
@@ -25,18 +25,7 @@ describe("layer editor", () => {
return id; return id;
} }
test("expand/collapse", async () => { test.skip("expand/collapse", () => {});
const bgId = await createBackground();
await when.click("layer-list-item:background:" + bgId);
await then(get.elementByTestId("layer-editor.layer-id.input")).shouldBeVisible();
await when.toggleGroupInLayerEditor("Layer");
await then(get.elementByTestId("layer-editor.layer-id.input")).shouldNotBeVisible();
await when.toggleGroupInLayerEditor("Layer");
await then(get.elementByTestId("layer-editor.layer-id.input")).shouldBeVisible();
});
test("id", async () => { test("id", async () => {
const bgId = await createBackground(); const bgId = await createBackground();
@@ -87,14 +76,6 @@ describe("layer editor", () => {
layers: [{ id: "background:" + bgId, type: "background", minzoom: 1 }], layers: [{ id: "background:" + bgId, type: "background", minzoom: 1 }],
}); });
}); });
test("the range slider adjusts min-zoom", async () => {
await when.focus("min-zoom.input-range");
await when.typeKeys("{rightarrow}");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id: "background:" + bgId, type: "background", minzoom: 2 }],
});
});
}); });
describe("max-zoom", () => { describe("max-zoom", () => {
@@ -164,13 +145,6 @@ describe("layer editor", () => {
layers: [{ id: "background:" + bgId, type: "background" }], layers: [{ id: "background:" + bgId, type: "background" }],
}); });
}); });
test("typing a hex value updates the paint color", async () => {
await when.setColorValue("background-color", "#ff0000");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id: "background:" + bgId, type: "background", paint: { "background-color": "#ff0000" } }],
});
});
}); });
describe("opacity", () => { describe("opacity", () => {
@@ -192,287 +166,8 @@ describe("layer editor", () => {
}); });
describe("filter", () => { describe("filter", () => {
let id: string; test.skip("expand/collapse", () => {});
test.skip("compound filter", () => {});
beforeEach(async () => {
id = await when.modal.fillLayers({ type: "fill", layer: "example" });
await when.addFilter();
});
test("should add a filter item", async () => {
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, type: "fill", source: "example", filter: ["all", ["==", "name", ""]] }],
});
});
test("should change the filter operator", async () => {
await when.selectFilterOperator("!=");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, filter: ["all", ["!=", "name", ""]] }],
});
});
test("should extend the compound filter with a second item", async () => {
await when.addFilter();
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, filter: ["all", ["==", "name", ""], ["==", "name", ""]] }],
});
});
test("should change the combining operator", async () => {
await when.selectFilterCombiningOperator("any");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, filter: ["any", ["==", "name", ""]] }],
});
});
test("should delete a filter item", async () => {
await when.addFilter();
await when.deleteFilterItem();
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, filter: ["all", ["==", "name", ""]] }],
});
});
describe("when converted to an expression", () => {
beforeEach(async () => {
await when.convertFilterToExpression();
});
test("should migrate the filter to an expression", async () => {
// A single-item "all" collapses to the bare comparison when migrated.
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, filter: ["==", ["get", "name"], ""] }],
});
});
test("should restore the default filter when the expression is deleted", async () => {
await when.deleteFilterExpression();
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, filter: ["all"] }],
});
});
});
});
describe("functions", () => {
let id: string;
describe("zoom function", () => {
beforeEach(async () => {
id = await when.modal.fillLayers({ type: "circle", layer: "example" });
await when.makeZoomFunction("circle-radius");
});
test("should convert the property to a zoom function", async () => {
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [
{ id, type: "circle", source: "example", paint: { "circle-radius": { stops: [[6, 5], [10, 5]] } } },
],
});
});
test("should add a stop", async () => {
await when.addFunctionStop("circle-radius");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-radius": { stops: [[6, 5], [10, 5], [11, 5]] } } }],
});
});
test("should delete the first stop", async () => {
// A function needs more than two stops, otherwise deleting one collapses
// it back into a plain value.
await when.addFunctionStop("circle-radius");
await when.deleteFunctionStop("circle-radius");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-radius": { stops: [[10, 5], [11, 5]] } } }],
});
});
test("should set the base", async () => {
await when.setFunctionBase("circle-radius", "2");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-radius": { base: 2, stops: [[6, 5], [10, 5]] } } }],
});
});
test("should edit the zoom of a stop", async () => {
await when.setFunctionStopValue("circle-radius", "Zoom", 0, "3");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-radius": { stops: [[3, 5], [10, 5]] } } }],
});
});
test("should edit the output value of a stop", async () => {
await when.setFunctionStopValue("circle-radius", "Output value", 0, "9");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-radius": { stops: [[6, 9], [10, 5]] } } }],
});
});
test("should convert to an expression", async () => {
await when.makeExpression("circle-radius");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-radius": ["interpolate", ["linear"], ["zoom"], 6, 5, 10, 5] } }],
});
});
describe("when converted to a data function", () => {
beforeEach(async () => {
// Any non-interpolate scale turns the zoom function into a data one.
await when.selectFunctionType("circle-radius", "categorical");
});
test("should carry the stops over as zoom/value pairs", async () => {
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [
{
id,
paint: {
"circle-radius": {
property: "",
type: "exponential",
stops: [[{ zoom: 6, value: 0 }, 5], [{ zoom: 10, value: 0 }, 5]],
},
},
},
],
});
});
test("should convert back to a zoom function", async () => {
await when.selectFunctionType("circle-radius", "interpolate");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-radius": { stops: [[6, 5], [10, 5]] } } }],
});
});
});
});
describe("data function", () => {
beforeEach(async () => {
id = await when.modal.fillLayers({ type: "circle", layer: "example" });
await when.setValue("spec-field-input:circle-blur", "1");
await when.makeDataFunction("circle-blur");
});
test("should convert the property to a data function", async () => {
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [
{
id,
type: "circle",
source: "example",
paint: {
"circle-blur": {
property: "",
type: "exponential",
stops: [[{ zoom: 6, value: 0 }, 1], [{ zoom: 10, value: 0 }, 1]],
},
},
},
],
});
});
test("should add a stop", async () => {
await when.addFunctionStop("circle-blur");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [
{
id,
paint: {
"circle-blur": {
stops: [[{ zoom: 6, value: 0 }, 1], [{ zoom: 10, value: 0 }, 1], [{ zoom: 11, value: 0 }, 1]],
},
},
},
],
});
});
test("should delete the first stop", async () => {
await when.addFunctionStop("circle-blur");
await when.deleteFunctionStop("circle-blur");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [
{
id,
paint: {
"circle-blur": {
stops: [[{ zoom: 10, value: 0 }, 1], [{ zoom: 11, value: 0 }, 1]],
},
},
},
],
});
});
test("should set the property", async () => {
await when.setFunctionProperty("circle-blur", "myprop");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-blur": { property: "myprop" } } }],
});
});
test("should set the default", async () => {
await when.setFunctionDefault("circle-blur", "0.5");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-blur": { default: 0.5 } } }],
});
});
test("should edit the input value of a stop", async () => {
await when.setFunctionStopValue("circle-blur", "Input value", 0, "7");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [
{
id,
paint: {
"circle-blur": {
stops: [[{ zoom: 6, value: 7 }, 1], [{ zoom: 10, value: 0 }, 1]],
},
},
},
],
});
});
test("should change the function type", async () => {
await when.selectFunctionType("circle-blur", "categorical");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-blur": { type: "categorical" } } }],
});
});
});
describe("expression", () => {
beforeEach(async () => {
id = await when.modal.fillLayers({ type: "circle", layer: "example" });
await when.setValue("spec-field-input:circle-blur", "1");
await when.makeExpression("circle-blur");
});
test("should wrap the property value in a literal expression", async () => {
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-blur": ["literal", 1] } }],
});
});
test("should restore the plain value when reverted", async () => {
await when.undoExpression("circle-blur");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-blur": 1 } }],
});
});
test("should fall back to the spec default when deleted", async () => {
await when.deleteExpression("circle-blur");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, paint: { "circle-blur": 0 } }],
});
});
});
}); });
describe("layout", () => { describe("layout", () => {
@@ -488,43 +183,10 @@ describe("layer editor", () => {
}); });
describe("paint", () => { describe("paint", () => {
let id: string; test.skip("expand/collapse", () => {});
test.skip("color", () => {});
beforeEach(async () => { test.skip("pattern", () => {});
id = await when.modal.fillLayers({ type: "fill", layer: "example" }); test.skip("opacity", () => {});
});
test("expand/collapse", async () => {
await then(get.elementByTestId("spec-field:fill-color")).shouldBeVisible();
await when.toggleGroupInLayerEditor("Paint properties");
await then(get.elementByTestId("spec-field:fill-color")).shouldNotBeVisible();
await when.toggleGroupInLayerEditor("Paint properties");
await then(get.elementByTestId("spec-field:fill-color")).shouldBeVisible();
});
test("color", async () => {
await when.setColorValue("fill-color", "#ff0000");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, type: "fill", source: "example", paint: { "fill-color": "#ff0000" } }],
});
});
test("pattern", async () => {
await when.setStringValue("fill-pattern", "some-pattern");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, type: "fill", source: "example", paint: { "fill-pattern": "some-pattern" } }],
});
});
test("opacity", async () => {
await when.setValue("spec-field-input:fill-opacity", "0.4");
await when.click("layer-editor.layer-id");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, type: "fill", source: "example", paint: { "fill-opacity": 0.4 } }],
});
});
}); });
describe("json-editor", () => { describe("json-editor", () => {
@@ -544,28 +206,8 @@ describe("layer editor", () => {
await then(get.element(".cm-lint-marker-error")).shouldExist(); await then(get.element(".cm-lint-marker-error")).shouldExist();
}); });
test("expand/collapse", async () => { test.skip("expand/collapse", () => {});
const bgId = await createBackground(); test.skip("modify", () => {});
await when.click("layer-list-item:background:" + bgId);
await then(get.element(".cm-content")).shouldBeVisible();
await when.toggleGroupInLayerEditor("JSON Editor");
await then(get.element(".cm-content")).shouldNotBeVisible();
await when.toggleGroupInLayerEditor("JSON Editor");
await then(get.element(".cm-content")).shouldBeVisible();
});
test("modify", async () => {
const bgId = await createBackground();
await when.click("layer-list-item:background:" + bgId);
await when.appendToJsonEditorLine('"background"', ',\n"minzoom": 5');
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id: "background:" + bgId, type: "background", minzoom: 5 }],
});
});
test("parse error", async () => { test("parse error", async () => {
const bgId = await createBackground(); const bgId = await createBackground();
+3 -16
View File
@@ -97,15 +97,7 @@ describe("layers list", () => {
}); });
}); });
test("modify", async () => { test.skip("modify", () => {});
const id = await when.modal.fillLayers({ type: "background" });
await when.click("layer-list-item:" + id);
await when.setValue("spec-field-input:background-opacity", "0.4");
await when.click("layer-editor.layer-id");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, type: "background", paint: { "background-opacity": 0.4 } }],
});
});
}); });
describe("fill", () => { describe("fill", () => {
@@ -116,13 +108,8 @@ describe("layers list", () => {
}); });
}); });
test("change source", async () => { // TODO: Change source
const id = await when.modal.fillLayers({ type: "fill", layer: "example" }); test.skip("change source", () => {});
await when.changeLayerSource("raster");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
layers: [{ id, type: "fill", source: "raster" }],
});
});
}); });
describe("line", () => { describe("line", () => {
+1 -167
View File
@@ -38,7 +38,6 @@ export class MaputnikDriver {
"example-style-with-fonts.json", "example-style-with-fonts.json",
"example-style-with-zoom-7-and-center-0-51.json", "example-style-with-zoom-7-and-center-0-51.json",
"example-style-with-zoom-5-and-center-50-50.json", "example-style-with-zoom-5-and-center-50-50.json",
"access-token-style.json",
]; ];
for (const fixture of styleFixtures) { for (const fixture of styleFixtures) {
await this.helper.given.interceptAndMockResponse({ await this.helper.given.interceptAndMockResponse({
@@ -72,7 +71,6 @@ export class MaputnikDriver {
| "rectangles" | "rectangles"
| "font" | "font"
| "zoom_7_center_0_51" | "zoom_7_center_0_51"
| "access_tokens"
| "", | "",
zoom?: number zoom?: number
) => { ) => {
@@ -84,7 +82,6 @@ export class MaputnikDriver {
rectangles: "rectangles-style.json", rectangles: "rectangles-style.json",
font: "example-style-with-fonts.json", font: "example-style-with-fonts.json",
zoom_7_center_0_51: "example-style-with-zoom-7-and-center-0-51.json", zoom_7_center_0_51: "example-style-with-zoom-7-and-center-0-51.json",
access_tokens: "access-token-style.json",
}; };
const url = new URL(baseUrl); const url = new URL(baseUrl);
@@ -110,13 +107,7 @@ export class MaputnikDriver {
}, },
chooseExampleFile: async () => { chooseExampleFile: async () => {
await this.helper.when.openFileByFixture("example-style.json", "modal:open.dropzone"); await this.helper.when.openFileByFixture("example-style.json", "modal:open.dropzone", "modal:open.file.input");
await this.helper.when.wait(200);
},
/** Picks the example style through the browser's native file chooser. */
chooseExampleFileFromPicker: async () => {
await this.helper.when.chooseFileFromPicker("example-style.json", "modal:open.dropzone");
await this.helper.when.wait(200); await this.helper.when.wait(200);
}, },
@@ -137,22 +128,6 @@ export class MaputnikDriver {
await this.helper.get.element(".maputnik-layer-editor-group__button").nth(index).click(); await this.helper.get.element(".maputnik-layer-editor-group__button").nth(index).click();
}, },
/** Expands/collapses a layer-editor group by its title, e.g. "Paint properties". */
toggleGroupInLayerEditor: async (title: string) => {
await this.helper.when.click("layer-editor-group:" + title);
},
/**
* Picks a source for the selected layer from the source autocomplete.
* The autocomplete is a controlled (downshift) input, so the value has to be
* filled rather than typed key by key, then chosen from the filtered menu.
*/
changeLayerSource: async (sourceId: string) => {
const input = this.helper.get.elementByTestId("layer-editor.layer-source").locator("input");
await input.fill(sourceId);
await this.helper.get.element(".maputnik-autocomplete-menu-item").first().click();
},
appendTextInJsonEditor: async (text: string) => { appendTextInJsonEditor: async (text: string) => {
await this.helper.get.element(".cm-line").first().click(); await this.helper.get.element(".cm-line").first().click();
// Move to the very start of the document so the inserted text breaks the // Move to the very start of the document so the inserted text breaks the
@@ -183,147 +158,6 @@ export class MaputnikDriver {
await this.helper.when.typeText(value); await this.helper.when.typeText(value);
}, },
makeZoomFunction: async (fieldName: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.scrollIntoViewIfNeeded();
await container.locator(".maputnik-make-zoom-function").last().click({ force: true });
},
makeDataFunction: async (fieldName: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.scrollIntoViewIfNeeded();
await container.locator(".maputnik-make-data-function").click({ force: true });
},
addFunctionStop: async (fieldName: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.locator(".maputnik-add-stop").first().click({ force: true });
},
deleteFunctionStop: async (fieldName: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.locator(".maputnik-delete-stop").first().click({ force: true });
},
/** Turns the property into a raw style expression. */
makeExpression: async (fieldName: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.scrollIntoViewIfNeeded();
// In the plain spec field the expression button shares the zoom-function
// class and comes first; inside a function editor it has its own test id.
const inFunctionEditor = container.locator("[data-wd-key='convert-to-expression']");
const button =
(await inFunctionEditor.count()) > 0
? inFunctionEditor
: container.locator(".maputnik-make-zoom-function").first();
await button.click({ force: true });
},
/** Reverts an expression back to a plain value. */
undoExpression: async (fieldName: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.locator("[data-wd-key='undo-expression']").click({ force: true });
},
/** Removes an expression, restoring the property's spec default. */
deleteExpression: async (fieldName: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.locator("[data-wd-key='delete-expression']").click({ force: true });
},
/** Picks the function scale (categorical/interval/exponential/identity/interpolate). */
selectFunctionType: async (fieldName: string, type: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.locator("[data-wd-key='function-type'] select").selectOption(type);
},
/** Sets the "Base" input of a zoom/data function. */
setFunctionBase: async (fieldName: string, value: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.locator("[data-wd-key='function-base'] input").fill(value);
},
/**
* Sets the data property a data function keys off of. This is an InputString,
* which only commits its value on blur, so typing alone is not enough.
*/
setFunctionProperty: async (fieldName: string, value: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
const input = container.locator("[data-wd-key='function-property'] input");
await input.fill(value);
await input.blur();
},
/** Sets the fallback value used when a feature has no matching stop. */
setFunctionDefault: async (fieldName: string, value: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.locator("[data-wd-key='function-default'] input").fill(value);
},
/** Edits one cell of a function's stop table ("Zoom", "Input value" or "Output value"). */
setFunctionStopValue: async (fieldName: string, column: string, index: number, value: string) => {
const container = this.helper.get.elementByTestId("spec-field-container:" + fieldName);
await container.locator(`[aria-label="${column}"]`).nth(index).fill(value);
},
addFilter: async () => {
const button = this.helper.get.elementByTestId("layer-filter-button");
await button.scrollIntoViewIfNeeded();
await button.click({ force: true });
},
selectFilterOperator: async (value: string) => {
await this.helper.get.element(".maputnik-filter-editor-operator select").first().selectOption(value);
},
/** Chooses how the filter items combine: all / none / any. */
selectFilterCombiningOperator: async (value: string) => {
await this.helper.when.selectWithin("filter-combining-operator", value);
},
deleteFilterItem: async (index = 0) => {
await this.helper.get
.element(".maputnik-filter-editor-block-action .maputnik-icon-button")
.nth(index)
.click();
},
/** Converts the simple filter editor into a raw expression editor. */
convertFilterToExpression: async () => {
await this.helper.when.click("filter-convert-to-expression");
},
/**
* Deletes the filter expression, restoring the simple filter editor.
* The filter group precedes the paint group, so its button comes first.
*/
deleteFilterExpression: async () => {
await this.helper.get.element("[data-wd-key='delete-expression']").first().click();
},
setColorValue: async (fieldName: string, value: string) => {
const input = this.helper.get.elementByTestId("spec-field:" + fieldName).locator(".maputnik-color");
await input.fill(value);
},
/** Sets a plain string spec field (e.g. a pattern), which has no dedicated input test id. */
setStringValue: async (fieldName: string, value: string) => {
const input = this.helper.get.elementByTestId("spec-field:" + fieldName).locator("input.maputnik-string");
await input.fill(value);
await input.blur();
},
/**
* Appends text to the end of the JSON editor line holding `lineText`.
* CodeMirror types over its own auto-inserted closing quotes/brackets, so a
* well-formed fragment stays well-formed.
*/
appendToJsonEditorLine: async (lineText: string, text: string) => {
await this.helper.when.clickByText(lineText);
await this.helper.when.typeKeys("{end}");
await this.helper.when.typeText(text);
},
waitForExampleFileResponse: () => this.helper.when.waitForResponse("example-style.json"), waitForExampleFileResponse: () => this.helper.when.waitForResponse("example-style.json"),
/** Fill localStorage until we get a QuotaExceededError. */ /** Fill localStorage until we get a QuotaExceededError. */
-40
View File
@@ -34,45 +34,5 @@ export class ModalDriver {
close: async (key: string) => { close: async (key: string) => {
await this.helper.when.click(key + ".close-modal"); await this.helper.when.click(key + ".close-modal");
}, },
/**
* Adds a source of the given type from the sources modal, keeping whatever
* defaults that type's editor prefills.
*/
addSource: async (sourceId: string, sourceType: string) => {
const { when } = this.helper;
await when.setValue("modal:sources.add.source_id", sourceId);
await when.select("modal:sources.add.source_type", sourceType);
await when.click("modal:sources.add.add_source");
await when.wait(200);
},
/** Adds one of the predefined public sources listed in the sources modal. */
addPublicSource: async (index = 0) => {
await this.helper.get.element(".maputnik-public-source-select").nth(index).click();
},
deleteFirstActiveSource: async () => {
await this.helper.get.element(".maputnik-active-source-type-editor-header-delete").first().click();
},
/** Fills one number box of a coordinate pair in the image/video source editor. */
setCoordinateValue: async (index: number, value: string) => {
const input = this.helper.get
.elementByTestId("modal:sources")
.locator(".maputnik-array input")
.nth(index);
await input.fill(value);
await input.blur();
},
exportCreateHtml: async () => {
await this.helper.get.element(".maputnik-modal-export-buttons button").last().click();
},
exportSaveStyle: async () => {
await this.helper.stubSaveFilePicker();
await this.helper.get.element(".maputnik-modal-export-buttons button").first().click();
},
}; };
} }
+26 -198
View File
@@ -43,16 +43,6 @@ describe("modals", () => {
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude(get.responseBody("example-style.json")); await then(get.styleFromLocalStorage()).shouldDeepNestedInclude(get.responseBody("example-style.json"));
}); });
}); });
describe("without the File System Access API", () => {
test("upload via the file chooser", async () => {
await given.noFileSystemAccessApi();
await when.setStyle("");
await when.click("nav:open");
await when.chooseExampleFileFromPicker();
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude(get.fixture("example-style.json"));
});
});
}); });
describe("shortcuts", () => { describe("shortcuts", () => {
@@ -74,15 +64,8 @@ describe("modals", () => {
await then(get.elementByTestId("modal:export")).shouldNotExist(); await then(get.elementByTestId("modal:export")).shouldNotExist();
}); });
test("download HTML and save the style", async () => { // TODO: Work out how to download a file and check the contents
// Generate the standalone HTML export (triggers a file download). test.skip("download", () => {});
await when.modal.exportCreateHtml();
await then(get.elementByTestId("modal:export")).shouldExist();
// Saving the style closes the export modal.
await when.modal.exportSaveStyle();
await then(get.elementByTestId("modal:export")).shouldNotExist();
});
}); });
describe("sources", () => { describe("sources", () => {
@@ -91,27 +74,8 @@ describe("modals", () => {
await when.click("nav:sources"); await when.click("nav:sources");
}); });
test("active sources are listed and can be deleted", async () => { test.skip("active sources", () => {});
await when.setStyle("both"); test.skip("public source", () => {});
await when.click("nav:sources");
const before = Object.keys(get.fixture("geojson-raster-style.json").sources).length;
await when.modal.deleteFirstActiveSource();
await then(
get.styleFromLocalStorage().then((style) => Object.keys(style.sources).length)
).shouldEqual(before - 1);
});
test("public source", async () => {
await when.modal.addPublicSource();
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
openmaptiles: {
type: "vector",
url: `https://api.maptiler.com/tiles/v3-openmaptiles/tiles.json?key=${tokens.openmaptiles}`,
},
},
});
});
test("add new source", async () => { test("add new source", async () => {
const sourceId = "n1z2v3r"; const sourceId = "n1z2v3r";
@@ -120,8 +84,8 @@ describe("modals", () => {
await when.select("modal:sources.add.scheme_type", "tms"); await when.select("modal:sources.add.scheme_type", "tms");
await when.click("modal:sources.add.add_source"); await when.click("modal:sources.add.add_source");
await when.wait(200); await when.wait(200);
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ await then(get.styleFromLocalStorage().then((style) => style.sources[sourceId])).shouldInclude({
sources: { [sourceId]: { scheme: "tms" } }, scheme: "tms",
}); });
}); });
@@ -154,110 +118,8 @@ describe("modals", () => {
await when.setValue("modal:sources.add.tile_size", "128"); await when.setValue("modal:sources.add.tile_size", "128");
await when.click("modal:sources.add.add_source"); await when.click("modal:sources.add.add_source");
await when.wait(200); await when.wait(200);
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ await then(get.styleFromLocalStorage().then((style) => style.sources[sourceId])).shouldInclude({
sources: { [sourceId]: { tileSize: 128 } }, tileSize: 128,
});
});
test("add new geojson url source", async () => {
await when.modal.addSource("geojsonurl", "geojson_url");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
geojsonurl: { type: "geojson", data: "http://localhost:3000/geojson.json" },
},
});
});
test("add new geojson json source", async () => {
await when.modal.addSource("geojsonjson", "geojson_json");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
geojsonjson: { type: "geojson", cluster: false, data: "" },
},
});
});
test("add new tilejson vector source", async () => {
await when.modal.addSource("tilejsonvector", "tilejson_vector");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
tilejsonvector: { type: "vector", url: "http://localhost:3000/tilejson.json" },
},
});
});
test("add new tilejson raster source", async () => {
await when.modal.addSource("tilejsonraster", "tilejson_raster");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
tilejsonraster: { type: "raster", url: "http://localhost:3000/tilejson.json" },
},
});
});
test("add new tilejson raster-dem source", async () => {
await when.modal.addSource("tilejsonrasterdem", "tilejson_raster-dem");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
tilejsonrasterdem: { type: "raster-dem", url: "http://localhost:3000/tilejson.json" },
},
});
});
test("add new tile xyz raster-dem source", async () => {
await when.modal.addSource("tilexyzrasterdem", "tilexyz_raster-dem");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
tilexyzrasterdem: {
type: "raster-dem",
tiles: ["http://localhost:3000/{x}/{y}/{z}.png"],
minzoom: 0,
maxzoom: 14,
tileSize: 512,
},
},
});
});
test("add new image source", async () => {
await when.modal.addSource("imagesource", "image");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
imagesource: {
type: "image",
url: "http://localhost:3000/image.png",
coordinates: [[0, 0], [0, 0], [0, 0], [0, 0]],
},
},
});
});
test("add new video source", async () => {
await when.modal.addSource("videosource", "video");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
videosource: {
type: "video",
urls: ["http://localhost:3000/movie.mp4"],
coordinates: [[0, 0], [0, 0], [0, 0], [0, 0]],
},
},
});
});
test("edit the corner coordinates of an image source", async () => {
const sourceId = "imagecoords";
await when.setValue("modal:sources.add.source_id", sourceId);
await when.select("modal:sources.add.source_type", "image");
// The first corner is the first two number boxes of the coordinate arrays.
await when.modal.setCoordinateValue(0, "1");
await when.modal.setCoordinateValue(1, "2");
await when.click("modal:sources.add.add_source");
await when.wait(200);
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sources: {
[sourceId]: { type: "image", coordinates: [[1, 2], [0, 0], [0, 0], [0, 0]] },
},
}); });
}); });
}); });
@@ -342,8 +204,8 @@ describe("modals", () => {
const apiKey = "testing123"; const apiKey = "testing123";
await when.setValue("modal:settings.maputnik:openmaptiles_access_token", apiKey); await when.setValue("modal:settings.maputnik:openmaptiles_access_token", apiKey);
await when.click("modal:settings.name"); await when.click("modal:settings.name");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ await then(get.styleFromLocalStorage().then((style) => style.metadata)).shouldInclude({
metadata: { "maputnik:openmaptiles_access_token": apiKey }, "maputnik:openmaptiles_access_token": apiKey,
}); });
}); });
@@ -351,8 +213,8 @@ describe("modals", () => {
const apiKey = "testing123"; const apiKey = "testing123";
await when.setValue("modal:settings.maputnik:thunderforest_access_token", apiKey); await when.setValue("modal:settings.maputnik:thunderforest_access_token", apiKey);
await when.click("modal:settings.name"); await when.click("modal:settings.name");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ await then(get.styleFromLocalStorage().then((style) => style.metadata)).shouldInclude({
metadata: { "maputnik:thunderforest_access_token": apiKey }, "maputnik:thunderforest_access_token": apiKey,
}); });
}); });
@@ -360,8 +222,8 @@ describe("modals", () => {
const apiKey = "testing123"; const apiKey = "testing123";
await when.setValue("modal:settings.maputnik:stadia_access_token", apiKey); await when.setValue("modal:settings.maputnik:stadia_access_token", apiKey);
await when.click("modal:settings.name"); await when.click("modal:settings.name");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ await then(get.styleFromLocalStorage().then((style) => style.metadata)).shouldInclude({
metadata: { "maputnik:stadia_access_token": apiKey }, "maputnik:stadia_access_token": apiKey,
}); });
}); });
@@ -369,67 +231,29 @@ describe("modals", () => {
const apiKey = "testing123"; const apiKey = "testing123";
await when.setValue("modal:settings.maputnik:locationiq_access_token", apiKey); await when.setValue("modal:settings.maputnik:locationiq_access_token", apiKey);
await when.click("modal:settings.name"); await when.click("modal:settings.name");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ await then(get.styleFromLocalStorage().then((style) => style.metadata)).shouldInclude({
metadata: { "maputnik:locationiq_access_token": apiKey }, "maputnik:locationiq_access_token": apiKey,
});
});
test("map view defaults", async () => {
await when.setValue("modal:settings.zoom", "4");
await when.setValue("modal:settings.bearing", "12");
await when.setValue("modal:settings.pitch", "30");
await when.click("modal:settings.name");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
zoom: 4,
bearing: 12,
pitch: 30,
});
});
test("light intensity", async () => {
await when.setValue("modal:settings.light-intensity", "0.7");
await when.click("modal:settings.name");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
light: { intensity: 0.7 },
});
});
test("terrain source and exaggeration", async () => {
await when.setValue("modal:settings.maputnik:terrain_source", "terrain");
await when.setValue("modal:settings.terrain-exaggeration", "1.5");
await when.click("modal:settings.name");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
terrain: { source: "terrain", exaggeration: 1.5 },
});
});
test("transition delay and duration", async () => {
await when.setValue("modal:settings.transition-delay", "100");
await when.setValue("modal:settings.transition-duration", "500");
await when.click("modal:settings.name");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
transition: { delay: 100, duration: 500 },
}); });
}); });
test("style projection mercator", async () => { test("style projection mercator", async () => {
await when.select("modal:settings.projection", "mercator"); await when.select("modal:settings.projection", "mercator");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ await then(get.styleFromLocalStorage().then((style) => style.projection)).shouldInclude({
projection: { type: "mercator" }, type: "mercator",
}); });
}); });
test("style projection globe", async () => { test("style projection globe", async () => {
await when.select("modal:settings.projection", "globe"); await when.select("modal:settings.projection", "globe");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ await then(get.styleFromLocalStorage().then((style) => style.projection)).shouldInclude({
projection: { type: "globe" }, type: "globe",
}); });
}); });
test("style projection vertical-perspective", async () => { test("style projection vertical-perspective", async () => {
await when.select("modal:settings.projection", "vertical-perspective"); await when.select("modal:settings.projection", "vertical-perspective");
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ await then(get.styleFromLocalStorage().then((style) => style.projection)).shouldInclude({
projection: { type: "vertical-perspective" }, type: "vertical-perspective",
}); });
}); });
@@ -487,6 +311,10 @@ describe("modals", () => {
}); });
}); });
describe("sources placeholder", () => {
test.skip("toggle", () => {});
});
describe("global state", () => { describe("global state", () => {
beforeEach(async () => { beforeEach(async () => {
await when.click("nav:global-state"); await when.click("nav:global-state");
+22 -61
View File
@@ -62,12 +62,11 @@ function isLocator(target: unknown): target is Locator {
); );
} }
/** /** Asserts that every top-level key in `expected` deep-equals its counterpart in `actual`. */
* Asserts that `actual` recursively contains everything in `expected`: nested function assertDeepNestedInclude(actual: any, expected: Record<string, unknown>): void {
* objects are matched as subsets, while arrays and primitives must match exactly. for (const key of Object.keys(expected)) {
*/ expect(actual?.[key], `property "${key}"`).toEqual(expected[key]);
function assertDeepNestedInclude(actual: any, expected: Record<string, unknown> | unknown[]): void { }
expect(actual).toMatchObject(expected);
} }
/** /**
@@ -131,7 +130,7 @@ export class Assertable<T> {
} }
}); });
shouldDeepNestedInclude = (value: Record<string, unknown> | unknown[]) => shouldDeepNestedInclude = (value: Record<string, unknown>) =>
this.assertValue((actual) => assertDeepNestedInclude(actual, value)); this.assertValue((actual) => assertDeepNestedInclude(actual, value));
} }
@@ -145,8 +144,6 @@ async function typeSequence(page: Page, text: string): Promise<void> {
del: "Delete", del: "Delete",
tab: "Tab", tab: "Tab",
home: "Home", home: "Home",
end: "End",
rightarrow: "ArrowRight",
}; };
for (let i = 0; i < tokens.length; i++) { for (let i = 0; i < tokens.length; i++) {
@@ -205,31 +202,10 @@ export class PlaywrightHelper {
return new Query<T>(getter); return new Query<T>(getter);
} }
/** Stubs the File System Access "save" picker so file saves complete headlessly. */
public stubSaveFilePicker(): Promise<void> {
return this.page.evaluate(() => {
(window as any).showSaveFilePicker = async () => ({
createWritable: async () => ({ write: async () => {}, close: async () => {} }),
});
});
}
/** Entry point for fluent assertions over a Locator or a value/Query. */ /** Entry point for fluent assertions over a Locator or a value/Query. */
public then = <T>(target: T): Assertable<T> => new Assertable(target); public then = <T>(target: T): Assertable<T> => new Assertable(target);
public given = { public given = {
/**
* Removes the File System Access API so the app falls back to a plain
* <input type="file">, the way Firefox and Safari behave. Must be called
* before the page under test is loaded.
*/
noFileSystemAccessApi: async () => {
await this.page.addInitScript(() => {
delete (window as any).showOpenFilePicker;
delete (window as any).showSaveFilePicker;
});
},
intercept: async (pattern: RegExp, alias: string, _method = "GET") => { intercept: async (pattern: RegExp, alias: string, _method = "GET") => {
this.recordedRequests.set(alias, []); this.recordedRequests.set(alias, []);
await this.page.route(pattern, (route) => { await this.page.route(pattern, (route) => {
@@ -357,38 +333,23 @@ export class PlaywrightHelper {
await this.page.mouse.up(); await this.page.mouse.up();
}, },
/** openFileByFixture: async (fixture: string, buttonTestId: string, inputTestId: string) => {
* Opens a fixture through the File System Access API, which raises no
* "filechooser" event and so has to be stubbed. For the <input type="file">
* fallback that browsers without the API use, see chooseFileFromPicker.
*/
openFileByFixture: async (fixture: string, buttonTestId: string) => {
const content = JSON.stringify(this.readFixture(fixture)); const content = JSON.stringify(this.readFixture(fixture));
await this.page.evaluate((fileContent) => { const hasPicker = await this.page.evaluate(() => "showOpenFilePicker" in window);
(window as any).showOpenFilePicker = async () => [ if (hasPicker) {
{ getFile: async () => ({ text: async () => fileContent }) }, await this.page.evaluate((fileContent) => {
]; (window as any).showOpenFilePicker = async () => [
}, content); { getFile: async () => ({ text: async () => fileContent }) },
await this.testId(buttonTestId).click(); ];
}, }, content);
await this.testId(buttonTestId).click();
/** } else {
* Clicks a control that opens the browser's native file chooser and answers await this.testId(inputTestId).setInputFiles({
* it with a fixture. Only works on the <input type="file"> path — the File name: fixture,
* System Access API does not raise a "filechooser" event, so pair this with mimeType: "application/json",
* given.noFileSystemAccessApi(). buffer: Buffer.from(content),
*/ });
chooseFileFromPicker: async (fixture: string, triggerTestId: string) => { }
const content = JSON.stringify(this.readFixture(fixture));
const [fileChooser] = await Promise.all([
this.page.waitForEvent("filechooser"),
this.testId(triggerTestId).click(),
]);
await fileChooser.setFiles({
name: fixture,
mimeType: "application/json",
buffer: Buffer.from(content),
});
}, },
dropFileByFixture: async (fixture: string, dropzoneTestId: string) => { dropFileByFixture: async (fixture: string, dropzoneTestId: string) => {
+1 -3
View File
@@ -34,9 +34,7 @@ export default defineConfig({
rules: { rules: {
"react-refresh/only-export-components": [ "react-refresh/only-export-components": [
"warn", "warn",
// Many components are exported as withTranslation()(Component); without { allowConstantExport: true }
// this the rule cannot tell the HOC's result is still a component.
{ allowConstantExport: true, extraHOCs: ["withTranslation"] }
], ],
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [
+845 -931
View File
File diff suppressed because it is too large Load Diff
+13 -10
View File
@@ -37,7 +37,7 @@
"@mapbox/mapbox-gl-rtl-text": "^0.4.0", "@mapbox/mapbox-gl-rtl-text": "^0.4.0",
"@maplibre/maplibre-gl-geocoder": "^1.9.4", "@maplibre/maplibre-gl-geocoder": "^1.9.4",
"@maplibre/maplibre-gl-inspect": "^1.8.2", "@maplibre/maplibre-gl-inspect": "^1.8.2",
"@maplibre/maplibre-gl-style-spec": "^26.2.1", "@maplibre/maplibre-gl-style-spec": "^25.0.2",
"array-move": "^4.0.0", "array-move": "^4.0.0",
"buffer": "^6.0.3", "buffer": "^6.0.3",
"classnames": "^2.5.1", "classnames": "^2.5.1",
@@ -47,7 +47,7 @@
"downshift": "^9.4.0", "downshift": "^9.4.0",
"events": "^3.3.0", "events": "^3.3.0",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"i18next": "^26.3.6", "i18next": "^26.3.4",
"i18next-browser-languagedetector": "^8.2.1", "i18next-browser-languagedetector": "^8.2.1",
"i18next-resources-to-backend": "^1.2.1", "i18next-resources-to-backend": "^1.2.1",
"json-stringify-pretty-compact": "^4.0.0", "json-stringify-pretty-compact": "^4.0.0",
@@ -124,27 +124,30 @@
"@types/string-hash": "^1.1.3", "@types/string-hash": "^1.1.3",
"@types/wicg-file-system-access": "^2023.10.7", "@types/wicg-file-system-access": "^2023.10.7",
"@vitejs/plugin-react": "5.2", "@vitejs/plugin-react": "5.2",
"@vitest/browser": "^4.1.10",
"@vitest/browser-playwright": "^4.1.10",
"@vitest/coverage-v8": "^4.1.10", "@vitest/coverage-v8": "^4.1.10",
"cors": "^2.8.6", "cors": "^2.8.6",
"eslint": "^10.7.0", "eslint": "^10.6.0",
"eslint-plugin-react": "^7.37.5", "eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-react-refresh": "^0.5.3", "eslint-plugin-react-refresh": "^0.5.3",
"i18next-cli": "^1.67.1", "i18next-cli": "^1.65.0",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"istanbul-lib-coverage": "^3.2.2", "istanbul-lib-coverage": "^3.2.2",
"nyc": "^18.0.0", "nyc": "^18.0.0",
"postcss": "^8.5.22", "postcss": "^8.5.16",
"react-hot-loader": "^4.13.1", "react-hot-loader": "^4.13.1",
"sass": "^1.101.7", "sass": "^1.101.0",
"stylelint": "^17.14.1", "stylelint": "^17.14.0",
"stylelint-config-recommended-scss": "^17.0.1", "stylelint-config-recommended-scss": "^17.0.1",
"stylelint-scss": "^7.2.0", "stylelint-scss": "^7.2.0",
"typescript": "^6.0.3", "typescript": "^6.0.3",
"typescript-eslint": "^8.65.0", "typescript-eslint": "^8.62.1",
"uuid": "^14.0.1", "uuid": "^14.0.1",
"vite": "^7.3.2", "vite": "^8.1.3",
"vite-plugin-istanbul": "^9.0.1", "vite-plugin-istanbul": "^9.0.1",
"vitest": "^4.1.10" "vitest": "^4.1.10",
"vitest-browser-react": "^2.2.0"
} }
} }
+23 -23
View File
@@ -11,29 +11,29 @@ import {type Map, type LayerSpecification, type StyleSpecification, type Validat
import {validateStyleMin} from "@maplibre/maplibre-gl-style-spec"; import {validateStyleMin} from "@maplibre/maplibre-gl-style-spec";
import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json"; import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import { MapMaplibreGl } from "./MapMaplibreGl"; import MapMaplibreGl from "./MapMaplibreGl";
import { MapOpenLayers } from "./MapOpenLayers"; import MapOpenLayers from "./MapOpenLayers";
import { CodeEditor } from "./CodeEditor"; import CodeEditor from "./CodeEditor";
import { LayerList } from "./LayerList"; import LayerList from "./LayerList";
import { LayerEditor } from "./LayerEditor"; import LayerEditor from "./LayerEditor";
import { AppToolbar, type MapState } from "./AppToolbar"; import AppToolbar, { type MapState } from "./AppToolbar";
import { AppLayout } from "./AppLayout"; import AppLayout from "./AppLayout";
import { AppMessagePanel as MessagePanel } from "./AppMessagePanel"; import MessagePanel from "./AppMessagePanel";
import { ModalSettings } from "./modals/ModalSettings"; import ModalSettings from "./modals/ModalSettings";
import { ModalExport } from "./modals/ModalExport"; import ModalExport from "./modals/ModalExport";
import { ModalSources } from "./modals/ModalSources"; import ModalSources from "./modals/ModalSources";
import { ModalOpen } from "./modals/ModalOpen"; import ModalOpen from "./modals/ModalOpen";
import { ModalShortcuts } from "./modals/ModalShortcuts"; import ModalShortcuts from "./modals/ModalShortcuts";
import { ModalDebug } from "./modals/ModalDebug"; import ModalDebug from "./modals/ModalDebug";
import { ModalGlobalState } from "./modals/ModalGlobalState"; import ModalGlobalState from "./modals/ModalGlobalState";
import {downloadGlyphsMetadata, downloadSpriteMetadata} from "../libs/metadata"; import {downloadGlyphsMetadata, downloadSpriteMetadata} from "../libs/metadata";
import { emptyStyle, getAccessToken, replaceAccessTokens } from "../libs/style"; import style from "../libs/style";
import { undoMessages, redoMessages } from "../libs/diffmessage"; import { undoMessages, redoMessages } from "../libs/diffmessage";
import { createStyleStore, type IStyleStore } from "../libs/store/style-store-factory"; import { createStyleStore, type IStyleStore } from "../libs/store/style-store-factory";
import { RevisionStore } from "../libs/revisions"; import { RevisionStore } from "../libs/revisions";
import { LayerWatcher } from "../libs/layerwatcher"; import LayerWatcher from "../libs/layerwatcher";
import tokens from "../config/tokens.json"; import tokens from "../config/tokens.json";
import isEqual from "lodash.isequal"; import isEqual from "lodash.isequal";
import { type MapOptions } from "maplibre-gl"; import { type MapOptions } from "maplibre-gl";
@@ -48,19 +48,19 @@ function setFetchAccessToken(url: string, mapStyle: StyleSpecification) {
const matchesThunderforest = url.match(/\.thunderforest\.com/); const matchesThunderforest = url.match(/\.thunderforest\.com/);
const matchesLocationIQ = url.match(/\.locationiq\.com/); const matchesLocationIQ = url.match(/\.locationiq\.com/);
if (matchesTilehosting || matchesMaptiler) { if (matchesTilehosting || matchesMaptiler) {
const accessToken = getAccessToken("openmaptiles", mapStyle, {allowFallback: true}); const accessToken = style.getAccessToken("openmaptiles", mapStyle, {allowFallback: true});
if (accessToken) { if (accessToken) {
return url.replace("{key}", accessToken); return url.replace("{key}", accessToken);
} }
} }
else if (matchesThunderforest) { else if (matchesThunderforest) {
const accessToken = getAccessToken("thunderforest", mapStyle, {allowFallback: true}); const accessToken = style.getAccessToken("thunderforest", mapStyle, {allowFallback: true});
if (accessToken) { if (accessToken) {
return url.replace("{key}", accessToken); return url.replace("{key}", accessToken);
} }
} }
else if (matchesLocationIQ) { else if (matchesLocationIQ) {
const accessToken = getAccessToken("locationiq", mapStyle, {allowFallback: true}); const accessToken = style.getAccessToken("locationiq", mapStyle, {allowFallback: true});
if (accessToken) { if (accessToken) {
return url.replace("{key}", accessToken); return url.replace("{key}", accessToken);
} }
@@ -123,7 +123,7 @@ type AppState = {
fileHandle: FileSystemFileHandle | null fileHandle: FileSystemFileHandle | null
}; };
export class App extends React.Component<any, AppState> { export default class App extends React.Component<any, AppState> {
revisionStore: RevisionStore; revisionStore: RevisionStore;
styleStore: IStyleStore | null = null; styleStore: IStyleStore | null = null;
layerWatcher: LayerWatcher; layerWatcher: LayerWatcher;
@@ -137,7 +137,7 @@ export class App extends React.Component<any, AppState> {
this.state = { this.state = {
errors: [], errors: [],
infos: [], infos: [],
mapStyle: emptyStyle, mapStyle: style.emptyStyle,
selectedLayerIndex: 0, selectedLayerIndex: 0,
sources: {}, sources: {},
vectorLayers: {}, vectorLayers: {},
@@ -698,7 +698,7 @@ export class App extends React.Component<any, AppState> {
mapStyle: (dirtyMapStyle || mapStyle), mapStyle: (dirtyMapStyle || mapStyle),
mapView: this.state.mapView, mapView: this.state.mapView,
replaceAccessTokens: (mapStyle: StyleSpecification) => { replaceAccessTokens: (mapStyle: StyleSpecification) => {
return replaceAccessTokens(mapStyle, { return style.replaceAccessTokens(mapStyle, {
allowFallback: true allowFallback: true
}); });
}, },
+3 -2
View File
@@ -1,5 +1,5 @@
import React from "react"; import React from "react";
import { ScrollContainer } from "./ScrollContainer"; import ScrollContainer from "./ScrollContainer";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { IconContext } from "react-icons"; import { IconContext } from "react-icons";
@@ -50,4 +50,5 @@ class AppLayoutInternal extends React.Component<AppLayoutInternalProps> {
} }
} }
export const AppLayout = withTranslation()(AppLayoutInternal); const AppLayout = withTranslation()(AppLayoutInternal);
export default AppLayout;
+2 -1
View File
@@ -61,4 +61,5 @@ class AppMessagePanelInternal extends React.Component<AppMessagePanelInternalPro
} }
} }
export const AppMessagePanel = withTranslation()(AppMessagePanelInternal); const AppMessagePanel = withTranslation()(AppMessagePanelInternal);
export default AppMessagePanel;
+2 -1
View File
@@ -306,4 +306,5 @@ class AppToolbarInternal extends React.Component<AppToolbarInternalProps> {
} }
} }
export const AppToolbar = withTranslation()(AppToolbarInternal); const AppToolbar = withTranslation()(AppToolbarInternal);
export default AppToolbar;
+3 -3
View File
@@ -1,7 +1,7 @@
import React, {type CSSProperties, type PropsWithChildren, type SyntheticEvent} from "react"; import React, {type CSSProperties, type PropsWithChildren, type SyntheticEvent} from "react";
import classnames from "classnames"; import classnames from "classnames";
import { FieldDocLabel } from "./FieldDocLabel"; import FieldDocLabel from "./FieldDocLabel";
import { Doc } from "./Doc"; import Doc from "./Doc";
export type BlockProps = PropsWithChildren & { export type BlockProps = PropsWithChildren & {
"data-wd-key"?: string "data-wd-key"?: string
@@ -19,7 +19,7 @@ type BlockState = {
}; };
/** Wrap a component with a label */ /** Wrap a component with a label */
export class Block extends React.Component<BlockProps, BlockState> { export default class Block extends React.Component<BlockProps, BlockState> {
_blockEl: HTMLDivElement | null = null; _blockEl: HTMLDivElement | null = null;
constructor (props: BlockProps) { constructor (props: BlockProps) {
+4 -2
View File
@@ -1,4 +1,4 @@
import { InputJson } from "./InputJson"; import InputJson from "./InputJson";
import React from "react"; import React from "react";
import { withTranslation, type WithTranslation } from "react-i18next"; import { withTranslation, type WithTranslation } from "react-i18next";
import { type StyleSpecification } from "maplibre-gl"; import { type StyleSpecification } from "maplibre-gl";
@@ -24,4 +24,6 @@ const CodeEditorInternal: React.FC<CodeEditorProps> = (props) => {
</>; </>;
}; };
export const CodeEditor = withTranslation()(CodeEditorInternal); const CodeEditor = withTranslation()(CodeEditorInternal);
export default CodeEditor;
+1 -1
View File
@@ -9,7 +9,7 @@ type CollapseProps = {
}; };
export class Collapse extends React.Component<CollapseProps> { export default class Collapse extends React.Component<CollapseProps> {
static defaultProps = { static defaultProps = {
isActive: true isActive: true
}; };
+1 -1
View File
@@ -6,7 +6,7 @@ type CollapserProps = {
style?: object style?: object
}; };
export class Collapser extends React.Component<CollapserProps> { export default class Collapser extends React.Component<CollapserProps> {
render() { render() {
const iconStyle = { const iconStyle = {
width: 20, width: 20,
+1 -1
View File
@@ -23,7 +23,7 @@ type DocProps = {
} }
}; };
export class Doc extends React.Component<DocProps> { export default class Doc extends React.Component<DocProps> {
render () { render () {
const {fieldSpec} = this.props; const {fieldSpec} = this.props;
+5 -3
View File
@@ -1,5 +1,5 @@
import { InputArray, type InputArrayProps } from "./InputArray"; import InputArray, { type InputArrayProps } from "./InputArray";
import { Fieldset } from "./Fieldset"; import Fieldset from "./Fieldset";
type FieldArrayProps = InputArrayProps & { type FieldArrayProps = InputArrayProps & {
name?: string name?: string
@@ -8,10 +8,12 @@ type FieldArrayProps = InputArrayProps & {
} }
}; };
export const FieldArray: React.FC<FieldArrayProps> = (props) => { const FieldArray: React.FC<FieldArrayProps> = (props) => {
return ( return (
<Fieldset label={props.label} fieldSpec={props.fieldSpec}> <Fieldset label={props.label} fieldSpec={props.fieldSpec}>
<InputArray {...props} /> <InputArray {...props} />
</Fieldset> </Fieldset>
); );
}; };
export default FieldArray;
+5 -3
View File
@@ -1,5 +1,5 @@
import { Block } from "./Block"; import Block from "./Block";
import { InputAutocomplete, type InputAutocompleteProps } from "./InputAutocomplete"; import InputAutocomplete, { type InputAutocompleteProps } from "./InputAutocomplete";
type FieldAutocompleteProps = InputAutocompleteProps & { type FieldAutocompleteProps = InputAutocompleteProps & {
@@ -7,10 +7,12 @@ type FieldAutocompleteProps = InputAutocompleteProps & {
}; };
export const FieldAutocomplete: React.FC<FieldAutocompleteProps> = (props) => { const FieldAutocomplete: React.FC<FieldAutocompleteProps> = (props) => {
return ( return (
<Block label={props.label}> <Block label={props.label}>
<InputAutocomplete {...props} /> <InputAutocomplete {...props} />
</Block> </Block>
); );
}; };
export default FieldAutocomplete;
+5 -3
View File
@@ -1,5 +1,5 @@
import { Block } from "./Block"; import Block from "./Block";
import { InputCheckbox, type InputCheckboxProps } from "./InputCheckbox"; import InputCheckbox, {type InputCheckboxProps} from "./InputCheckbox";
type FieldCheckboxProps = InputCheckboxProps & { type FieldCheckboxProps = InputCheckboxProps & {
@@ -7,10 +7,12 @@ type FieldCheckboxProps = InputCheckboxProps & {
}; };
export const FieldCheckbox: React.FC<FieldCheckboxProps> = (props) => { const FieldCheckbox: React.FC<FieldCheckboxProps> = (props) => {
return ( return (
<Block label={props.label}> <Block label={props.label}>
<InputCheckbox {...props} /> <InputCheckbox {...props} />
</Block> </Block>
); );
}; };
export default FieldCheckbox;
+5 -3
View File
@@ -1,5 +1,5 @@
import { Block } from "./Block"; import Block from "./Block";
import { InputColor, type InputColorProps } from "./InputColor"; import InputColor, {type InputColorProps} from "./InputColor";
type FieldColorProps = InputColorProps & { type FieldColorProps = InputColorProps & {
@@ -10,10 +10,12 @@ type FieldColorProps = InputColorProps & {
}; };
export const FieldColor: React.FC<FieldColorProps> = (props) => { const FieldColor: React.FC<FieldColorProps> = (props) => {
return ( return (
<Block label={props.label} fieldSpec={props.fieldSpec}> <Block label={props.label} fieldSpec={props.fieldSpec}>
<InputColor {...props} /> <InputColor {...props} />
</Block> </Block>
); );
}; };
export default FieldColor;
+4 -3
View File
@@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { Block } from "./Block"; import Block from "./Block";
import { InputString } from "./InputString"; import InputString from "./InputString";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
type FieldCommentInternalProps = { type FieldCommentInternalProps = {
@@ -36,4 +36,5 @@ const FieldCommentInternal: React.FC<FieldCommentInternalProps> = (props) => {
); );
}; };
export const FieldComment = withTranslation()(FieldCommentInternal); const FieldComment = withTranslation()(FieldCommentInternal);
export default FieldComment;
+3 -1
View File
@@ -10,7 +10,7 @@ type FieldDocLabelProps = {
}; };
export const FieldDocLabel: React.FC<FieldDocLabelProps> = (props) => { const FieldDocLabel: React.FC<FieldDocLabelProps> = (props) => {
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
const onToggleDoc = (state: boolean) => { const onToggleDoc = (state: boolean) => {
@@ -49,3 +49,5 @@ export const FieldDocLabel: React.FC<FieldDocLabelProps> = (props) => {
} }
return <div />; return <div />;
}; };
export default FieldDocLabel;
+6 -7
View File
@@ -1,17 +1,16 @@
import { InputDynamicArray, type InputDynamicArrayProps } from "./InputDynamicArray"; import InputDynamicArray, {type InputDynamicArrayProps} from "./InputDynamicArray";
import { Fieldset } from "./Fieldset"; import Fieldset from "./Fieldset";
type FieldDynamicArrayProps = InputDynamicArrayProps & { type FieldDynamicArrayProps = InputDynamicArrayProps & {
name?: string; name?: string
fieldSpec?: {
value?: string;
}
}; };
export const FieldDynamicArray: React.FC<FieldDynamicArrayProps> = (props) => { const FieldDynamicArray: React.FC<FieldDynamicArrayProps> = (props) => {
return ( return (
<Fieldset label={props.label}> <Fieldset label={props.label}>
<InputDynamicArray {...props} /> <InputDynamicArray {...props} />
</Fieldset> </Fieldset>
); );
}; };
export default FieldDynamicArray;
+5 -3
View File
@@ -1,5 +1,5 @@
import { InputEnum, type InputEnumProps } from "./InputEnum"; import InputEnum, {type InputEnumProps} from "./InputEnum";
import { Fieldset } from "./Fieldset"; import Fieldset from "./Fieldset";
type FieldEnumProps = InputEnumProps & { type FieldEnumProps = InputEnumProps & {
@@ -10,10 +10,12 @@ type FieldEnumProps = InputEnumProps & {
}; };
export const FieldEnum: React.FC<FieldEnumProps> = (props) => { const FieldEnum: React.FC<FieldEnumProps> = (props) => {
return ( return (
<Fieldset label={props.label} fieldSpec={props.fieldSpec}> <Fieldset label={props.label} fieldSpec={props.fieldSpec}>
<InputEnum {...props} /> <InputEnum {...props} />
</Fieldset> </Fieldset>
); );
}; };
export default FieldEnum;
+7 -5
View File
@@ -1,9 +1,9 @@
import React from "react"; import React from "react";
import { SpecProperty } from "./SpecProperty"; import SpecProperty from "./_SpecProperty";
import { DataProperty, type Stop } from "./DataProperty"; import DataProperty, { type Stop } from "./_DataProperty";
import { ZoomProperty } from "./ZoomProperty"; import ZoomProperty from "./_ZoomProperty";
import { ExpressionProperty } from "./ExpressionProperty"; import ExpressionProperty from "./_ExpressionProperty";
import {function as styleFunction} from "@maplibre/maplibre-gl-style-spec"; import {function as styleFunction} from "@maplibre/maplibre-gl-style-spec";
import {findDefaultFromSpec} from "../libs/spec-helper"; import {findDefaultFromSpec} from "../libs/spec-helper";
import { type MappedLayerErrors } from "../libs/definitions"; import { type MappedLayerErrors } from "../libs/definitions";
@@ -128,7 +128,7 @@ type FieldFunctionProps = {
/** Supports displaying spec field for zoom function objects /** Supports displaying spec field for zoom function objects
* https://www.mapbox.com/mapbox-gl-style-spec/#types-function-zoom-property * https://www.mapbox.com/mapbox-gl-style-spec/#types-function-zoom-property
*/ */
export const FieldFunction: React.FC<FieldFunctionProps> = (props) => { const FieldFunction: React.FC<FieldFunctionProps> = (props) => {
const [dataType, setDataType] = React.useState( const [dataType, setDataType] = React.useState(
getDataType(props.value, props.fieldSpec) getDataType(props.value, props.fieldSpec)
); );
@@ -402,3 +402,5 @@ export const FieldFunction: React.FC<FieldFunctionProps> = (props) => {
</div> </div>
); );
}; };
export default FieldFunction;
+5 -3
View File
@@ -1,7 +1,7 @@
import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json"; import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import { Block } from "./Block"; import Block from "./Block";
import { InputString } from "./InputString"; import InputString from "./InputString";
type FieldIdProps = { type FieldIdProps = {
value: string value: string
@@ -10,7 +10,7 @@ type FieldIdProps = {
error?: {message: string} error?: {message: string}
}; };
export const FieldId: React.FC<FieldIdProps> = (props) => { const FieldId: React.FC<FieldIdProps> = (props) => {
return ( return (
<Block label="ID" fieldSpec={latest.layer.id} <Block label="ID" fieldSpec={latest.layer.id}
data-wd-key={props.wdKey} data-wd-key={props.wdKey}
@@ -24,3 +24,5 @@ export const FieldId: React.FC<FieldIdProps> = (props) => {
</Block> </Block>
); );
}; };
export default FieldId;
+4 -2
View File
@@ -1,9 +1,11 @@
import { InputJson, type InputJsonProps } from "./InputJson"; import InputJson, {type InputJsonProps} from "./InputJson";
type FieldJsonProps = InputJsonProps & {}; type FieldJsonProps = InputJsonProps & {};
export const FieldJson: React.FC<FieldJsonProps> = (props) => { const FieldJson: React.FC<FieldJsonProps> = (props) => {
return <InputJson {...props} />; return <InputJson {...props} />;
}; };
export default FieldJson;
+4 -3
View File
@@ -1,8 +1,8 @@
import React from "react"; import React from "react";
import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json"; import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import { Block } from "./Block"; import Block from "./Block";
import { InputNumber } from "./InputNumber"; import InputNumber from "./InputNumber";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
type FieldMaxZoomInternalProps = { type FieldMaxZoomInternalProps = {
@@ -31,4 +31,5 @@ const FieldMaxZoomInternal: React.FC<FieldMaxZoomInternalProps> = (props) => {
); );
}; };
export const FieldMaxZoom = withTranslation()(FieldMaxZoomInternal); const FieldMaxZoom = withTranslation()(FieldMaxZoomInternal);
export default FieldMaxZoom;
+4 -3
View File
@@ -1,8 +1,8 @@
import React from "react"; import React from "react";
import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json"; import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import { Block } from "./Block"; import Block from "./Block";
import { InputNumber } from "./InputNumber"; import InputNumber from "./InputNumber";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
type FieldMinZoomInternalProps = { type FieldMinZoomInternalProps = {
@@ -31,4 +31,5 @@ const FieldMinZoomInternal: React.FC<FieldMinZoomInternalProps> = (props) => {
); );
}; };
export const FieldMinZoom = withTranslation()(FieldMinZoomInternal); const FieldMinZoom = withTranslation()(FieldMinZoomInternal);
export default FieldMinZoom;
+5 -3
View File
@@ -1,5 +1,5 @@
import { InputMultiInput, type InputMultiInputProps } from "./InputMultiInput"; import InputMultiInput, {type InputMultiInputProps} from "./InputMultiInput";
import { Fieldset } from "./Fieldset"; import Fieldset from "./Fieldset";
type FieldMultiInputProps = InputMultiInputProps & { type FieldMultiInputProps = InputMultiInputProps & {
@@ -7,10 +7,12 @@ type FieldMultiInputProps = InputMultiInputProps & {
}; };
export const FieldMultiInput: React.FC<FieldMultiInputProps> = (props) => { const FieldMultiInput: React.FC<FieldMultiInputProps> = (props) => {
return ( return (
<Fieldset label={props.label}> <Fieldset label={props.label}>
<InputMultiInput {...props} /> <InputMultiInput {...props} />
</Fieldset> </Fieldset>
); );
}; };
export default FieldMultiInput;
+5 -3
View File
@@ -1,5 +1,5 @@
import { InputNumber, type InputNumberProps } from "./InputNumber"; import InputNumber, {type InputNumberProps} from "./InputNumber";
import { Block } from "./Block"; import Block from "./Block";
type FieldNumberProps = InputNumberProps & { type FieldNumberProps = InputNumberProps & {
@@ -10,10 +10,12 @@ type FieldNumberProps = InputNumberProps & {
}; };
export const FieldNumber: React.FC<FieldNumberProps> = (props) => { const FieldNumber: React.FC<FieldNumberProps> = (props) => {
return ( return (
<Block label={props.label} fieldSpec={props.fieldSpec}> <Block label={props.label} fieldSpec={props.fieldSpec}>
<InputNumber {...props} /> <InputNumber {...props} />
</Block> </Block>
); );
}; };
export default FieldNumber;
+5 -3
View File
@@ -1,5 +1,5 @@
import { Block } from "./Block"; import Block from "./Block";
import { InputSelect, type InputSelectProps } from "./InputSelect"; import InputSelect, {type InputSelectProps} from "./InputSelect";
type FieldSelectProps = InputSelectProps & { type FieldSelectProps = InputSelectProps & {
@@ -10,10 +10,12 @@ type FieldSelectProps = InputSelectProps & {
}; };
export const FieldSelect: React.FC<FieldSelectProps> = (props) => { const FieldSelect: React.FC<FieldSelectProps> = (props) => {
return ( return (
<Block label={props.label} fieldSpec={props.fieldSpec}> <Block label={props.label} fieldSpec={props.fieldSpec}>
<InputSelect {...props} /> <InputSelect {...props} />
</Block> </Block>
); );
}; };
export default FieldSelect;
+4 -3
View File
@@ -1,8 +1,8 @@
import React from "react"; import React from "react";
import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json"; import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import { Block } from "./Block"; import Block from "./Block";
import { InputAutocomplete } from "./InputAutocomplete"; import InputAutocomplete from "./InputAutocomplete";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
type FieldSourceInternalProps = { type FieldSourceInternalProps = {
@@ -38,4 +38,5 @@ const FieldSourceInternal: React.FC<FieldSourceInternalProps> = ({
}; };
export const FieldSource = withTranslation()(FieldSourceInternal); const FieldSource = withTranslation()(FieldSourceInternal);
export default FieldSource;
+4 -3
View File
@@ -1,8 +1,8 @@
import React from "react"; import React from "react";
import {latest} from "@maplibre/maplibre-gl-style-spec"; import {latest} from "@maplibre/maplibre-gl-style-spec";
import { Block } from "./Block"; import Block from "./Block";
import { InputAutocomplete } from "./InputAutocomplete"; import InputAutocomplete from "./InputAutocomplete";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
type FieldSourceLayerInternalProps = { type FieldSourceLayerInternalProps = {
@@ -35,4 +35,5 @@ const FieldSourceLayerInternal: React.FC<FieldSourceLayerInternalProps> = ({
); );
}; };
export const FieldSourceLayer = withTranslation()(FieldSourceLayerInternal); const FieldSourceLayer = withTranslation()(FieldSourceLayerInternal);
export default FieldSourceLayer;
+6 -4
View File
@@ -1,6 +1,6 @@
import { Block, type BlockProps } from "./Block"; import Block, { type BlockProps } from "./Block";
import { InputSpec, type FieldSpecType, type InputSpecProps } from "./InputSpec"; import InputSpec, { type FieldSpecType, type InputSpecProps } from "./InputSpec";
import { Fieldset, type FieldsetProps } from "./Fieldset"; import Fieldset, { type FieldsetProps } from "./Fieldset";
function getElementFromType(fieldSpec: { type?: FieldSpecType, values?: unknown[] }): typeof Fieldset | typeof Block { function getElementFromType(fieldSpec: { type?: FieldSpecType, values?: unknown[] }): typeof Fieldset | typeof Block {
switch(fieldSpec.type) { switch(fieldSpec.type) {
@@ -36,7 +36,7 @@ function getElementFromType(fieldSpec: { type?: FieldSpecType, values?: unknown[
export type FieldSpecProps = InputSpecProps & BlockProps & FieldsetProps; export type FieldSpecProps = InputSpecProps & BlockProps & FieldsetProps;
export const FieldSpec: React.FC<FieldSpecProps> = (props) => { const FieldSpec: React.FC<FieldSpecProps> = (props) => {
const TypeBlock = getElementFromType(props.fieldSpec!); const TypeBlock = getElementFromType(props.fieldSpec!);
return ( return (
@@ -45,3 +45,5 @@ export const FieldSpec: React.FC<FieldSpecProps> = (props) => {
</TypeBlock> </TypeBlock>
); );
}; };
export default FieldSpec;
+5 -3
View File
@@ -1,5 +1,5 @@
import { Block } from "./Block"; import Block from "./Block";
import { InputString, type InputStringProps } from "./InputString"; import InputString, {type InputStringProps} from "./InputString";
type FieldStringProps = InputStringProps & { type FieldStringProps = InputStringProps & {
name?: string name?: string
@@ -9,10 +9,12 @@ type FieldStringProps = InputStringProps & {
} }
}; };
export const FieldString: React.FC<FieldStringProps> = (props) => { const FieldString: React.FC<FieldStringProps> = (props) => {
return ( return (
<Block label={props.label} fieldSpec={props.fieldSpec}> <Block label={props.label} fieldSpec={props.fieldSpec}>
<InputString {...props} /> <InputString {...props} />
</Block> </Block>
); );
}; };
export default FieldString;
+5 -4
View File
@@ -1,8 +1,8 @@
import React from "react"; import React from "react";
import {v8} from "@maplibre/maplibre-gl-style-spec"; import {v8} from "@maplibre/maplibre-gl-style-spec";
import { Block } from "./Block"; import Block from "./Block";
import { InputSelect } from "./InputSelect"; import InputSelect from "./InputSelect";
import { InputString } from "./InputString"; import InputString from "./InputString";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { startCase } from "lodash"; import { startCase } from "lodash";
@@ -43,4 +43,5 @@ const FieldTypeInternal: React.FC<FieldTypeInternalProps> = ({
); );
}; };
export const FieldType = withTranslation()(FieldTypeInternal); const FieldType = withTranslation()(FieldTypeInternal);
export default FieldType;
+5 -3
View File
@@ -1,5 +1,5 @@
import { InputUrl, type FieldUrlProps as InputUrlProps } from "./InputUrl"; import InputUrl, {type FieldUrlProps as InputUrlProps} from "./InputUrl";
import { Block } from "./Block"; import Block from "./Block";
type FieldUrlProps = InputUrlProps & { type FieldUrlProps = InputUrlProps & {
@@ -10,10 +10,12 @@ type FieldUrlProps = InputUrlProps & {
}; };
export const FieldUrl: React.FC<FieldUrlProps> = (props) => { const FieldUrl: React.FC<FieldUrlProps> = (props) => {
return ( return (
<Block label={props.label} fieldSpec={props.fieldSpec}> <Block label={props.label} fieldSpec={props.fieldSpec}>
<InputUrl {...props} /> <InputUrl {...props} />
</Block> </Block>
); );
}; };
export default FieldUrl;
+6 -4
View File
@@ -1,8 +1,8 @@
import React, { type PropsWithChildren, type ReactElement } from "react"; import React, { type PropsWithChildren, type ReactElement } from "react";
import classnames from "classnames"; import classnames from "classnames";
import { FieldDocLabel } from "./FieldDocLabel"; import FieldDocLabel from "./FieldDocLabel";
import { Doc } from "./Doc"; import Doc from "./Doc";
import { generateUniqueId } from "../libs/document-uid"; import generateUniqueId from "../libs/document-uid";
export type FieldsetProps = PropsWithChildren & { export type FieldsetProps = PropsWithChildren & {
label?: string, label?: string,
@@ -12,7 +12,7 @@ export type FieldsetProps = PropsWithChildren & {
}; };
export const Fieldset: React.FC<FieldsetProps> = (props) => { const Fieldset: React.FC<FieldsetProps> = (props) => {
const [showDoc, setShowDoc] = React.useState(false); const [showDoc, setShowDoc] = React.useState(false);
const labelId = React.useRef(generateUniqueId("fieldset_label_")); const labelId = React.useRef(generateUniqueId("fieldset_label_"));
@@ -49,3 +49,5 @@ export const Fieldset: React.FC<FieldsetProps> = (props) => {
</div> </div>
); );
}; };
export default Fieldset;
+9 -10
View File
@@ -7,13 +7,13 @@ import {migrate, convertFilter} from "@maplibre/maplibre-gl-style-spec";
import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json"; import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import {combiningFilterOps} from "../libs/filterops"; import {combiningFilterOps} from "../libs/filterops";
import { InputSelect } from "./InputSelect"; import InputSelect from "./InputSelect";
import { Block } from "./Block"; import Block from "./Block";
import { SingleFilterEditor } from "./SingleFilterEditor"; import SingleFilterEditor from "./SingleFilterEditor";
import { FilterEditorBlock } from "./FilterEditorBlock"; import FilterEditorBlock from "./FilterEditorBlock";
import { InputButton } from "./InputButton"; import InputButton from "./InputButton";
import { Doc } from "./Doc"; import Doc from "./Doc";
import { ExpressionProperty } from "./ExpressionProperty"; import ExpressionProperty from "./_ExpressionProperty";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import type { MappedLayerErrors, StyleSpecificationWithId } from "../libs/definitions"; import type { MappedLayerErrors, StyleSpecificationWithId } from "../libs/definitions";
@@ -215,7 +215,6 @@ class FilterEditorInternal extends React.Component<FilterEditorInternalProps, Fi
onClick={this.makeExpression} onClick={this.makeExpression}
title={t("Convert to expression")} title={t("Convert to expression")}
className="maputnik-make-zoom-function" className="maputnik-make-zoom-function"
data-wd-key="filter-convert-to-expression"
> >
<TbMathFunction /> <TbMathFunction />
</InputButton> </InputButton>
@@ -249,7 +248,6 @@ class FilterEditorInternal extends React.Component<FilterEditorInternalProps, Fi
fieldSpec={fieldSpec} fieldSpec={fieldSpec}
label={t("Filter")} label={t("Filter")}
action={actions} action={actions}
data-wd-key="filter-combining-operator"
> >
<InputSelect <InputSelect
value={combiningOp} value={combiningOp}
@@ -318,4 +316,5 @@ class FilterEditorInternal extends React.Component<FilterEditorInternalProps, Fi
} }
} }
export const FilterEditor = withTranslation()(FilterEditorInternal); const FilterEditor = withTranslation()(FilterEditorInternal);
export default FilterEditor;
+3 -2
View File
@@ -1,5 +1,5 @@
import React, { type PropsWithChildren } from "react"; import React, { type PropsWithChildren } from "react";
import { InputButton } from "./InputButton"; import InputButton from "./InputButton";
import {MdDelete} from "react-icons/md"; import {MdDelete} from "react-icons/md";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
@@ -27,4 +27,5 @@ class FilterEditorBlockInternal extends React.Component<FilterEditorBlockInterna
} }
} }
export const FilterEditorBlock = withTranslation()(FilterEditorBlockInternal); const FilterEditorBlock = withTranslation()(FilterEditorBlockInternal);
export default FilterEditorBlock;
+3 -1
View File
@@ -13,7 +13,7 @@ type IconLayerProps = {
className?: string className?: string
}; };
export const IconLayer: React.FC<IconLayerProps> = (props) => { const IconLayer: React.FC<IconLayerProps> = (props) => {
const iconProps = { style: props.style }; const iconProps = { style: props.style };
switch(props.type) { switch(props.type) {
case "fill-extrusion": return <IoMdCube {...iconProps} />; case "fill-extrusion": return <IoMdCube {...iconProps} />;
@@ -29,3 +29,5 @@ export const IconLayer: React.FC<IconLayerProps> = (props) => {
default: return <MdPriorityHigh {...iconProps} />; default: return <MdPriorityHigh {...iconProps} />;
} }
}; };
export default IconLayer;
+3 -3
View File
@@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { InputString } from "./InputString"; import InputString from "./InputString";
import { InputNumber } from "./InputNumber"; import InputNumber from "./InputNumber";
export type InputArrayProps = { export type InputArrayProps = {
value: (string | number | undefined)[] value: (string | number | undefined)[]
@@ -17,7 +17,7 @@ type InputArrayState = {
initialPropsValue: unknown[] initialPropsValue: unknown[]
}; };
export class InputArray extends React.Component<InputArrayProps, InputArrayState> { export default class InputArray extends React.Component<InputArrayProps, InputArrayState> {
static defaultProps = { static defaultProps = {
value: [], value: [],
default: [], default: [],
@@ -0,0 +1,24 @@
import { expect, test } from "vitest";
import { render } from "vitest-browser-react";
import { page } from "vitest/browser";
import InputAutocomplete from "./InputAutocomplete";
const fruits = ["apple", "banana", "cherry"];
test("filters options when typing", async () => {
render(<InputAutocomplete aria-label="Fruit" options={fruits.map((f) => [f, f])} />);
const input = page.getByLabelText("Fruit");
await input.click();
const menuItems = page.getByRole("option");
await expect.element(menuItems.first()).toBeVisible();
expect(menuItems.all()).toHaveLength(3);
await input.fill("ch");
await expect.element(page.getByText("cherry")).toBeVisible();
expect(page.getByRole("option").all()).toHaveLength(1);
await page.getByText("cherry").click();
await expect.element(input).toHaveValue("cherry");
});
+1 -1
View File
@@ -11,7 +11,7 @@ export type InputAutocompleteProps = {
"aria-label"?: string "aria-label"?: string
}; };
export function InputAutocomplete({ export default function InputAutocomplete({
value, value,
options = [], options = [],
onChange = () => {}, onChange = () => {},
+1 -1
View File
@@ -14,7 +14,7 @@ type InputButtonProps = {
title?: string title?: string
}; };
export class InputButton extends React.Component<InputButtonProps> { export default class InputButton extends React.Component<InputButtonProps> {
render() { render() {
return <button return <button
id={this.props.id} id={this.props.id}
+1 -1
View File
@@ -6,7 +6,7 @@ export type InputCheckboxProps = {
onChange(...args: unknown[]): unknown onChange(...args: unknown[]): unknown
}; };
export class InputCheckbox extends React.Component<InputCheckboxProps> { export default class InputCheckbox extends React.Component<InputCheckboxProps> {
static defaultProps = { static defaultProps = {
value: false, value: false,
}; };
+1 -1
View File
@@ -20,7 +20,7 @@ export type InputColorProps = {
}; };
/*** Number fields with support for min, max and units and documentation*/ /*** Number fields with support for min, max and units and documentation*/
export class InputColor extends React.Component<InputColorProps> { export default class InputColor extends React.Component<InputColorProps> {
state = { state = {
pickerOpened: false pickerOpened: false
}; };
+10 -8
View File
@@ -3,13 +3,13 @@ import capitalize from "lodash.capitalize";
import {MdDelete} from "react-icons/md"; import {MdDelete} from "react-icons/md";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { InputString } from "./InputString"; import InputString from "./InputString";
import { InputNumber } from "./InputNumber"; import InputNumber from "./InputNumber";
import { InputButton } from "./InputButton"; import InputButton from "./InputButton";
import { FieldDocLabel } from "./FieldDocLabel"; import FieldDocLabel from "./FieldDocLabel";
import { InputEnum } from "./InputEnum"; import InputEnum from "./InputEnum";
import { InputUrl } from "./InputUrl"; import InputUrl from "./InputUrl";
import { InputColor } from "./InputColor"; import InputColor from "./InputColor";
export type InputDynamicArrayProps = { export type InputDynamicArrayProps = {
@@ -141,7 +141,9 @@ class InputDynamicArrayInternal extends React.Component<InputDynamicArrayInterna
} }
} }
export const InputDynamicArray = withTranslation()(InputDynamicArrayInternal); const InputDynamicArray = withTranslation()(InputDynamicArrayInternal);
export default InputDynamicArray;
type DeleteValueInputButtonProps = { type DeleteValueInputButtonProps = {
onClick?(...args: unknown[]): unknown onClick?(...args: unknown[]): unknown
} & WithTranslation; } & WithTranslation;
+3 -3
View File
@@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { InputSelect } from "./InputSelect"; import InputSelect from "./InputSelect";
import { InputMultiInput } from "./InputMultiInput"; import InputMultiInput from "./InputMultiInput";
function optionsLabelLength(options: any[]) { function optionsLabelLength(options: any[]) {
@@ -25,7 +25,7 @@ export type InputEnumProps = {
}; };
export class InputEnum extends React.Component<InputEnumProps> { export default class InputEnum extends React.Component<InputEnumProps> {
render() { render() {
const {options, value, onChange, name, label} = this.props; const {options, value, onChange, name, label} = this.props;
+2 -2
View File
@@ -1,5 +1,5 @@
import React from "react"; import React from "react";
import { InputAutocomplete } from "./InputAutocomplete"; import InputAutocomplete from "./InputAutocomplete";
export type InputFontProps = { export type InputFontProps = {
name: string name: string
@@ -11,7 +11,7 @@ export type InputFontProps = {
"aria-label"?: string "aria-label"?: string
}; };
export class InputFont extends React.Component<InputFontProps> { export default class InputFont extends React.Component<InputFontProps> {
static defaultProps = { static defaultProps = {
fonts: [] fonts: []
}; };
+2 -1
View File
@@ -135,4 +135,5 @@ class InputJsonInternal extends React.Component<InputJsonInternalProps, InputJso
} }
} }
export const InputJson = withTranslation()(InputJsonInternal); const InputJson = withTranslation()(InputJsonInternal);
export default InputJson;
+1 -1
View File
@@ -9,7 +9,7 @@ export type InputMultiInputProps = {
"aria-label"?: string "aria-label"?: string
}; };
export class InputMultiInput extends React.Component<InputMultiInputProps> { export default class InputMultiInput extends React.Component<InputMultiInputProps> {
render() { render() {
let options = this.props.options; let options = this.props.options;
if(options.length > 0 && !Array.isArray(options[0])) { if(options.length > 0 && !Array.isArray(options[0])) {
+2 -2
View File
@@ -1,5 +1,5 @@
import React, { type BaseSyntheticEvent } from "react"; import React, { type BaseSyntheticEvent } from "react";
import { generateUniqueId } from "../libs/document-uid"; import generateUniqueId from "../libs/document-uid";
export type InputNumberProps = { export type InputNumberProps = {
value?: number value?: number
@@ -25,7 +25,7 @@ type InputNumberState = {
dirtyValue?: number | string | undefined dirtyValue?: number | string | undefined
}; };
export class InputNumber extends React.Component<InputNumberProps, InputNumberState> { export default class InputNumber extends React.Component<InputNumberProps, InputNumberState> {
static defaultProps = { static defaultProps = {
rangeStep: 1 rangeStep: 1
}; };
+1 -1
View File
@@ -10,7 +10,7 @@ export type InputSelectProps = {
"aria-label"?: string "aria-label"?: string
}; };
export class InputSelect extends React.Component<InputSelectProps> { export default class InputSelect extends React.Component<InputSelectProps> {
render() { render() {
let options = this.props.options; let options = this.props.options;
if(options.length > 0 && !Array.isArray(options[0])) { if(options.length > 0 && !Array.isArray(options[0])) {
+10 -10
View File
@@ -1,14 +1,14 @@
import React, { type ReactElement } from "react"; import React, { type ReactElement } from "react";
import { InputColor, type InputColorProps } from "./InputColor"; import InputColor, { type InputColorProps } from "./InputColor";
import { InputNumber, type InputNumberProps } from "./InputNumber"; import InputNumber, { type InputNumberProps } from "./InputNumber";
import { InputCheckbox, type InputCheckboxProps } from "./InputCheckbox"; import InputCheckbox, { type InputCheckboxProps } from "./InputCheckbox";
import { InputString, type InputStringProps } from "./InputString"; import InputString, { type InputStringProps } from "./InputString";
import { InputArray, type InputArrayProps } from "./InputArray"; import InputArray, { type InputArrayProps } from "./InputArray";
import { InputDynamicArray, type InputDynamicArrayProps } from "./InputDynamicArray"; import InputDynamicArray, { type InputDynamicArrayProps } from "./InputDynamicArray";
import { InputFont, type InputFontProps } from "./InputFont"; import InputFont, { type InputFontProps } from "./InputFont";
import { InputAutocomplete, type InputAutocompleteProps } from "./InputAutocomplete"; import InputAutocomplete, { type InputAutocompleteProps } from "./InputAutocomplete";
import { InputEnum, type InputEnumProps } from "./InputEnum"; import InputEnum, { type InputEnumProps } from "./InputEnum";
import capitalize from "lodash.capitalize"; import capitalize from "lodash.capitalize";
const iconProperties = ["background-pattern", "fill-pattern", "line-pattern", "fill-extrusion-pattern", "icon-image"]; const iconProperties = ["background-pattern", "fill-pattern", "line-pattern", "fill-extrusion-pattern", "icon-image"];
@@ -38,7 +38,7 @@ export type InputSpecProps = {
/** Display any field from the Maplibre GL style spec and /** Display any field from the Maplibre GL style spec and
* choose the correct field component based on the @{fieldSpec} * choose the correct field component based on the @{fieldSpec}
* to display @{value}. */ * to display @{value}. */
export class InputSpec extends React.Component<InputSpecProps> { export default class InputSpec extends React.Component<InputSpecProps> {
childNodes() { childNodes() {
const commonProps = { const commonProps = {
+1 -1
View File
@@ -20,7 +20,7 @@ type InputStringState = {
value?: string value?: string
}; };
export class InputString extends React.Component<InputStringProps, InputStringState> { export default class InputString extends React.Component<InputStringProps, InputStringState> {
static defaultProps = { static defaultProps = {
onInput: () => {}, onInput: () => {},
}; };
+4 -3
View File
@@ -1,6 +1,6 @@
import React, { type JSX } from "react"; import React, { type JSX } from "react";
import { InputString } from "./InputString"; import InputString from "./InputString";
import { SmallError } from "./SmallError"; import SmallError from "./SmallError";
import { Trans, type WithTranslation, withTranslation } from "react-i18next"; import { Trans, type WithTranslation, withTranslation } from "react-i18next";
import { type TFunction } from "i18next"; import { type TFunction } from "i18next";
import { ErrorType, validate } from "../libs/urlopen"; import { ErrorType, validate } from "../libs/urlopen";
@@ -91,4 +91,5 @@ class InputUrlInternal extends React.Component<InputUrlInternalProps, InputUrlSt
} }
} }
export const InputUrl = withTranslation()(InputUrlInternal); const InputUrl = withTranslation()(InputUrlInternal);
export default InputUrl;
+17 -17
View File
@@ -6,17 +6,17 @@ import { IconContext } from "react-icons";
import { type BackgroundLayerSpecification, type LayerSpecification, type SourceSpecification } from "maplibre-gl"; import { type BackgroundLayerSpecification, type LayerSpecification, type SourceSpecification } from "maplibre-gl";
import { v8 } from "@maplibre/maplibre-gl-style-spec"; import { v8 } from "@maplibre/maplibre-gl-style-spec";
import { FieldJson } from "./FieldJson"; import FieldJson from "./FieldJson";
import { FilterEditor } from "./FilterEditor"; import FilterEditor from "./FilterEditor";
import { PropertyGroup } from "./PropertyGroup"; import PropertyGroup from "./PropertyGroup";
import { LayerEditorGroup } from "./LayerEditorGroup"; import LayerEditorGroup from "./LayerEditorGroup";
import { FieldType } from "./FieldType"; import FieldType from "./FieldType";
import { FieldId } from "./FieldId"; import FieldId from "./FieldId";
import { FieldMinZoom } from "./FieldMinZoom"; import FieldMinZoom from "./FieldMinZoom";
import { FieldMaxZoom } from "./FieldMaxZoom"; import FieldMaxZoom from "./FieldMaxZoom";
import { FieldComment } from "./FieldComment"; import FieldComment from "./FieldComment";
import { FieldSource } from "./FieldSource"; import FieldSource from "./FieldSource";
import { FieldSourceLayer } from "./FieldSourceLayer"; import FieldSourceLayer from "./FieldSourceLayer";
import { changeType, changeProperty } from "../libs/layer"; import { changeType, changeProperty } from "../libs/layer";
import { formatLayerId } from "../libs/format"; import { formatLayerId } from "../libs/format";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
@@ -74,20 +74,20 @@ function getLayoutForType(type: LayerSpecification["type"], t: TFunction): Maput
return getLayoutForSymbolType(t); return getLayoutForSymbolType(t);
} }
const groups: MaputnikLayoutGroup[] = []; const groups: MaputnikLayoutGroup[] = [];
if (Object.keys(v8["paint_" + type as keyof typeof v8]).length > 0) { if (Object.keys(v8["paint_" + type]).length > 0) {
groups.push({ groups.push({
title: t("Paint properties"), title: t("Paint properties"),
id: "Paint_properties", id: "Paint_properties",
type: "properties", type: "properties",
fields: Object.keys(v8["paint_" + type as keyof typeof v8]), fields: Object.keys(v8["paint_" + type]),
}); });
} }
if (Object.keys(v8["layout_" + type as keyof typeof v8]).length > 0) { if (Object.keys(v8["layout_" + type]).length > 0) {
groups.push({ groups.push({
title: t("Layout properties"), title: t("Layout properties"),
id: "Layout_properties", id: "Layout_properties",
type: "properties", type: "properties",
fields: Object.keys(v8["layout_" + type as keyof typeof v8]) fields: Object.keys(v8["layout_" + type])
}); });
} }
return groups; return groups;
@@ -230,7 +230,6 @@ class LayerEditorInternal extends React.Component<LayerEditorInternalProps, Laye
)} )}
/> />
{this.props.layer.type !== "background" && <FieldSource {this.props.layer.type !== "background" && <FieldSource
wdKey="layer-editor.layer-source"
error={errorData.source} error={errorData.source}
sourceIds={Object.keys(this.props.sources!)} sourceIds={Object.keys(this.props.sources!)}
value={this.props.layer.source} value={this.props.layer.source}
@@ -420,4 +419,5 @@ class LayerEditorInternal extends React.Component<LayerEditorInternalProps, Laye
} }
} }
export const LayerEditor = withTranslation()(LayerEditorInternal); const LayerEditor = withTranslation()(LayerEditorInternal);
export default LayerEditor;
+1 -1
View File
@@ -18,7 +18,7 @@ type LayerEditorGroupProps = {
}; };
export class LayerEditorGroup extends React.Component<LayerEditorGroupProps> { export default class LayerEditorGroup extends React.Component<LayerEditorGroupProps> {
render() { render() {
return <AccordionItem uuid={this.props.id}> return <AccordionItem uuid={this.props.id}>
<AccordionItemHeading className="maputnik-layer-editor-group" <AccordionItemHeading className="maputnik-layer-editor-group"
+7 -5
View File
@@ -14,12 +14,12 @@ import {
verticalListSortingStrategy, verticalListSortingStrategy,
} from "@dnd-kit/sortable"; } from "@dnd-kit/sortable";
import { LayerListGroup } from "./LayerListGroup"; import LayerListGroup from "./LayerListGroup";
import { LayerListItem } from "./LayerListItem"; import LayerListItem from "./LayerListItem";
import { ModalAdd } from "./modals/ModalAdd"; import ModalAdd from "./modals/ModalAdd";
import type {LayerSpecification, SourceSpecification} from "maplibre-gl"; import type {LayerSpecification, SourceSpecification} from "maplibre-gl";
import { generateUniqueId } from "../libs/document-uid"; import generateUniqueId from "../libs/document-uid";
import { findClosestCommonPrefix, layerPrefix } from "../libs/layer"; import { findClosestCommonPrefix, layerPrefix } from "../libs/layer";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { type MappedError, type OnMoveLayerCallback } from "../libs/definitions"; import { type MappedError, type OnMoveLayerCallback } from "../libs/definitions";
@@ -336,7 +336,7 @@ type LayerListProps = LayerListContainerProps & {
onMoveLayer: OnMoveLayerCallback onMoveLayer: OnMoveLayerCallback
}; };
export const LayerList: React.FC<LayerListProps> = (props) => { const LayerList: React.FC<LayerListProps> = (props) => {
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } })); const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
const handleDragEnd = (event: DragEndEvent) => { const handleDragEnd = (event: DragEndEvent) => {
@@ -361,3 +361,5 @@ export const LayerList: React.FC<LayerListProps> = (props) => {
</DndContext> </DndContext>
); );
}; };
export default LayerList;
+2 -2
View File
@@ -1,5 +1,5 @@
import React from "react"; import React from "react";
import { Collapser } from "./Collapser"; import Collapser from "./Collapser";
type LayerListGroupProps = { type LayerListGroupProps = {
title: string title: string
@@ -9,7 +9,7 @@ type LayerListGroupProps = {
"aria-controls"?: string "aria-controls"?: string
}; };
export class LayerListGroup extends React.Component<LayerListGroupProps> { export default class LayerListGroup extends React.Component<LayerListGroupProps> {
render() { render() {
return <li className="maputnik-layer-list-group"> return <li className="maputnik-layer-list-group">
<div className="maputnik-layer-list-group-header" <div className="maputnik-layer-list-group-header"
+4 -2
View File
@@ -5,7 +5,7 @@ import { IconContext } from "react-icons";
import { useSortable } from "@dnd-kit/sortable"; import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities"; import { CSS } from "@dnd-kit/utilities";
import { IconLayer } from "./IconLayer"; import IconLayer from "./IconLayer";
import type { VisibilitySpecification } from "maplibre-gl"; import type { VisibilitySpecification } from "maplibre-gl";
@@ -87,7 +87,7 @@ type LayerListItemProps = {
onLayerVisibilityToggle?(...args: unknown[]): unknown onLayerVisibilityToggle?(...args: unknown[]): unknown
}; };
export const LayerListItem = React.forwardRef<HTMLLIElement, LayerListItemProps>((props, ref) => { const LayerListItem = React.forwardRef<HTMLLIElement, LayerListItemProps>((props, ref) => {
const { const {
isSelected = false, isSelected = false,
visibility = "visible", visibility = "visible",
@@ -162,3 +162,5 @@ export const LayerListItem = React.forwardRef<HTMLLIElement, LayerListItemProps>
</li> </li>
</IconContext.Provider>; </IconContext.Provider>;
}); });
export default LayerListItem;
+5 -4
View File
@@ -3,10 +3,10 @@ import {createRoot} from "react-dom/client";
import MapLibreGl, {type LayerSpecification, type LngLat, type Map, type MapOptions, type SourceSpecification, type StyleSpecification} from "maplibre-gl"; import MapLibreGl, {type LayerSpecification, type LngLat, type Map, type MapOptions, type SourceSpecification, type StyleSpecification} from "maplibre-gl";
import MaplibreInspect from "@maplibre/maplibre-gl-inspect"; import MaplibreInspect from "@maplibre/maplibre-gl-inspect";
import colors from "@maplibre/maplibre-gl-inspect/lib/colors"; import colors from "@maplibre/maplibre-gl-inspect/lib/colors";
import { FeatureLayerPopup as MapMaplibreGlLayerPopup } from "./MapMaplibreGlLayerPopup"; import MapMaplibreGlLayerPopup from "./MapMaplibreGlLayerPopup";
import { FeaturePropertyPopup as MapMaplibreGlFeaturePropertyPopup, type InspectFeature } from "./MapMaplibreGlFeaturePropertyPopup"; import MapMaplibreGlFeaturePropertyPopup, { type InspectFeature } from "./MapMaplibreGlFeaturePropertyPopup";
import Color from "color"; import Color from "color";
import { ZoomControl } from "../libs/zoomcontrol"; import ZoomControl from "../libs/zoomcontrol";
import { type HighlightedLayer, colorHighlightedLayer } from "../libs/highlight"; import { type HighlightedLayer, colorHighlightedLayer } from "../libs/highlight";
import "maplibre-gl/dist/maplibre-gl.css"; import "maplibre-gl/dist/maplibre-gl.css";
import "../maplibregl.css"; import "../maplibregl.css";
@@ -322,4 +322,5 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,
} }
} }
export const MapMaplibreGl = withTranslation()(MapMaplibreGlInternal); const MapMaplibreGl = withTranslation()(MapMaplibreGlInternal);
export default MapMaplibreGl;
@@ -63,7 +63,7 @@ type FeaturePropertyPopupProps = {
features: InspectFeature[] features: InspectFeature[]
}; };
export class FeaturePropertyPopup extends React.Component<FeaturePropertyPopupProps> { class FeaturePropertyPopup extends React.Component<FeaturePropertyPopupProps> {
render() { render() {
const features = removeDuplicatedFeatures(this.props.features); const features = removeDuplicatedFeatures(this.props.features);
return <div className="maputnik-feature-property-popup" dir="ltr" data-wd-key="feature-property-popup"> return <div className="maputnik-feature-property-popup" dir="ltr" data-wd-key="feature-property-popup">
@@ -75,3 +75,6 @@ export class FeaturePropertyPopup extends React.Component<FeaturePropertyPopupPr
</div>; </div>;
} }
} }
export default FeaturePropertyPopup;
+5 -2
View File
@@ -1,5 +1,5 @@
import React from "react"; import React from "react";
import { IconLayer } from "./IconLayer"; import IconLayer from "./IconLayer";
import type {InspectFeature} from "./MapMaplibreGlFeaturePropertyPopup"; import type {InspectFeature} from "./MapMaplibreGlFeaturePropertyPopup";
function groupFeaturesBySourceLayer(features: InspectFeature[]) { function groupFeaturesBySourceLayer(features: InspectFeature[]) {
@@ -32,7 +32,7 @@ type FeatureLayerPopupProps = {
zoom?: number zoom?: number
}; };
export class FeatureLayerPopup extends React.Component<FeatureLayerPopupProps> { class FeatureLayerPopup extends React.Component<FeatureLayerPopupProps> {
_getFeatureColor(feature: InspectFeature, _zoom?: number) { _getFeatureColor(feature: InspectFeature, _zoom?: number) {
// Guard because openlayers won't have this // Guard because openlayers won't have this
if (!feature.layer.paint) { if (!feature.layer.paint) {
@@ -109,3 +109,6 @@ export class FeatureLayerPopup extends React.Component<FeatureLayerPopupProps> {
</div>; </div>;
} }
} }
export default FeatureLayerPopup;
+3 -2
View File
@@ -2,7 +2,7 @@ import React from "react";
import {throttle} from "lodash"; import {throttle} from "lodash";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { FeatureLayerPopup as MapMaplibreGlLayerPopup } from "./MapMaplibreGlLayerPopup"; import MapMaplibreGlLayerPopup from "./MapMaplibreGlLayerPopup";
import "ol/ol.css"; import "ol/ol.css";
//@ts-ignore //@ts-ignore
@@ -204,4 +204,5 @@ class MapOpenLayersInternal extends React.Component<MapOpenLayersInternalProps,
} }
} }
export const MapOpenLayers = withTranslation()(MapOpenLayersInternal); const MapOpenLayers = withTranslation()(MapOpenLayersInternal);
export default MapOpenLayers;
+2 -2
View File
@@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { FieldFunction } from "./FieldFunction"; import FieldFunction from "./FieldFunction";
import type {LayerSpecification} from "maplibre-gl"; import type {LayerSpecification} from "maplibre-gl";
import { type MappedLayerErrors } from "../libs/definitions"; import { type MappedLayerErrors } from "../libs/definitions";
@@ -40,7 +40,7 @@ type PropertyGroupProps = {
errors?: MappedLayerErrors errors?: MappedLayerErrors
}; };
export class PropertyGroup extends React.Component<PropertyGroupProps> { export default class PropertyGroup extends React.Component<PropertyGroupProps> {
onPropertyChange = (property: string, newValue: any) => { onPropertyChange = (property: string, newValue: any) => {
const group = getGroupName(this.props.spec, this.props.layer.type, property); const group = getGroupName(this.props.spec, this.props.layer.type, property);
this.props.onChange(group ,property, newValue); this.props.onChange(group ,property, newValue);
+1 -1
View File
@@ -4,7 +4,7 @@ type ScrollContainerProps = {
children?: React.ReactNode children?: React.ReactNode
}; };
export class ScrollContainer extends React.Component<ScrollContainerProps> { export default class ScrollContainer extends React.Component<ScrollContainerProps> {
render() { render() {
return <div className="maputnik-scroll-container"> return <div className="maputnik-scroll-container">
{this.props.children} {this.props.children}
+4 -4
View File
@@ -1,9 +1,9 @@
import React from "react"; import React from "react";
import {otherFilterOps} from "../libs/filterops"; import {otherFilterOps} from "../libs/filterops";
import { InputString } from "./InputString"; import InputString from "./InputString";
import { InputAutocomplete } from "./InputAutocomplete"; import InputAutocomplete from "./InputAutocomplete";
import { InputSelect } from "./InputSelect"; import InputSelect from "./InputSelect";
function tryParseInt(v: string | number) { function tryParseInt(v: string | number) {
if (v === "") return v; if (v === "") return v;
@@ -40,7 +40,7 @@ type SingleFilterEditorProps = {
properties?: {[key: string]: string} properties?: {[key: string]: string}
}; };
export class SingleFilterEditor extends React.Component<SingleFilterEditorProps> { export default class SingleFilterEditor extends React.Component<SingleFilterEditorProps> {
static defaultProps = { static defaultProps = {
properties: {}, properties: {},
}; };
+2 -1
View File
@@ -18,4 +18,5 @@ class SmallErrorInternal extends React.Component<SmallErrorInternalProps> {
} }
} }
export const SmallError = withTranslation()(SmallErrorInternal); const SmallError = withTranslation()(SmallErrorInternal);
export default SmallError;
@@ -3,19 +3,19 @@ import {PiListPlusBold} from "react-icons/pi";
import {TbMathFunction} from "react-icons/tb"; import {TbMathFunction} from "react-icons/tb";
import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json"; import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import { InputButton } from "./InputButton"; import InputButton from "./InputButton";
import { InputSpec } from "./InputSpec"; import InputSpec from "./InputSpec";
import { InputNumber } from "./InputNumber"; import InputNumber from "./InputNumber";
import { InputString } from "./InputString"; import InputString from "./InputString";
import { InputSelect } from "./InputSelect"; import InputSelect from "./InputSelect";
import { Block } from "./Block"; import Block from "./Block";
import { generateUniqueId as docUid } from "../libs/document-uid"; import docUid from "../libs/document-uid";
import { sortNumerically } from "../libs/sort-numerically"; import sortNumerically from "../libs/sort-numerically";
import {findDefaultFromSpec} from "../libs/spec-helper"; import {findDefaultFromSpec} from "../libs/spec-helper";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { labelFromFieldName } from "../libs/label-from-field-name"; import labelFromFieldName from "../libs/label-from-field-name";
import { DeleteStopButton } from "./DeleteStopButton"; import DeleteStopButton from "./_DeleteStopButton";
import { type MappedLayerErrors } from "../libs/definitions"; import { type MappedLayerErrors } from "../libs/definitions";
@@ -289,7 +289,6 @@ class DataPropertyInternal extends React.Component<DataPropertyInternalProps, Da
<Block <Block
label={t("Function")} label={t("Function")}
key="function" key="function"
data-wd-key="function-type"
> >
<div className="maputnik-data-spec-property-input"> <div className="maputnik-data-spec-property-input">
<InputSelect <InputSelect
@@ -304,7 +303,6 @@ class DataPropertyInternal extends React.Component<DataPropertyInternalProps, Da
<Block <Block
label={t("Base")} label={t("Base")}
key="base" key="base"
data-wd-key="function-base"
> >
<div className="maputnik-data-spec-property-input"> <div className="maputnik-data-spec-property-input">
<InputSpec <InputSpec
@@ -319,7 +317,6 @@ class DataPropertyInternal extends React.Component<DataPropertyInternalProps, Da
<Block <Block
label={"Property"} label={"Property"}
key="property" key="property"
data-wd-key="function-property"
> >
<div className="maputnik-data-spec-property-input"> <div className="maputnik-data-spec-property-input">
<InputString <InputString
@@ -333,7 +330,6 @@ class DataPropertyInternal extends React.Component<DataPropertyInternalProps, Da
<Block <Block
label={t("Default")} label={t("Default")}
key="default" key="default"
data-wd-key="function-default"
> >
<InputSpec <InputSpec
fieldName={this.props.fieldName} fieldName={this.props.fieldName}
@@ -372,7 +368,6 @@ class DataPropertyInternal extends React.Component<DataPropertyInternalProps, Da
} }
<InputButton <InputButton
className="maputnik-add-stop" className="maputnik-add-stop"
data-wd-key="convert-to-expression"
onClick={this.props.onExpressionClick?.bind(this)} onClick={this.props.onExpressionClick?.bind(this)}
> >
<TbMathFunction style={{ verticalAlign: "text-bottom" }} /> <TbMathFunction style={{ verticalAlign: "text-bottom" }} />
@@ -385,4 +380,5 @@ class DataPropertyInternal extends React.Component<DataPropertyInternalProps, Da
} }
} }
export const DataProperty = withTranslation()(DataPropertyInternal); const DataProperty = withTranslation()(DataPropertyInternal);
export default DataProperty;
@@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { InputButton } from "./InputButton"; import InputButton from "./InputButton";
import {MdDelete} from "react-icons/md"; import {MdDelete} from "react-icons/md";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
@@ -23,4 +23,5 @@ class DeleteStopButtonInternal extends React.Component<DeleteStopButtonInternalP
} }
} }
export const DeleteStopButton = withTranslation()(DeleteStopButtonInternal); const DeleteStopButton = withTranslation()(DeleteStopButtonInternal);
export default DeleteStopButton;
@@ -2,10 +2,10 @@ import React from "react";
import {MdDelete, MdUndo} from "react-icons/md"; import {MdDelete, MdUndo} from "react-icons/md";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { Block } from "./Block"; import Block from "./Block";
import { InputButton } from "./InputButton"; import InputButton from "./InputButton";
import { labelFromFieldName } from "../libs/label-from-field-name"; import labelFromFieldName from "../libs/label-from-field-name";
import { FieldJson } from "./FieldJson"; import FieldJson from "./FieldJson";
import type { StylePropertySpecification } from "maplibre-gl"; import type { StylePropertySpecification } from "maplibre-gl";
import { type MappedLayerErrors } from "../libs/definitions"; import { type MappedLayerErrors } from "../libs/definitions";
@@ -50,7 +50,6 @@ class ExpressionPropertyInternal extends React.Component<ExpressionPropertyInter
onClick={this.props.onUndo} onClick={this.props.onUndo}
disabled={undoDisabled} disabled={undoDisabled}
className="maputnik-delete-stop" className="maputnik-delete-stop"
data-wd-key="undo-expression"
title={t("Revert from expression")} title={t("Revert from expression")}
> >
<MdUndo /> <MdUndo />
@@ -60,7 +59,6 @@ class ExpressionPropertyInternal extends React.Component<ExpressionPropertyInter
key="delete_action" key="delete_action"
onClick={this.props.onDelete} onClick={this.props.onDelete}
className="maputnik-delete-stop" className="maputnik-delete-stop"
data-wd-key="delete-expression"
title={t("Delete expression")} title={t("Delete expression")}
> >
<MdDelete /> <MdDelete />
@@ -92,4 +90,5 @@ class ExpressionPropertyInternal extends React.Component<ExpressionPropertyInter
} }
} }
export const ExpressionProperty = withTranslation()(ExpressionPropertyInternal); const ExpressionProperty = withTranslation()(ExpressionPropertyInternal);
export default ExpressionProperty;
@@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { InputButton } from "./InputButton"; import InputButton from "./InputButton";
import {MdFunctions, MdInsertChart} from "react-icons/md"; import {MdFunctions, MdInsertChart} from "react-icons/md";
import { TbMathFunction } from "react-icons/tb"; import { TbMathFunction } from "react-icons/tb";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
@@ -67,4 +67,5 @@ class FunctionInputButtonsInternal extends React.Component<FunctionInputButtonsI
} }
} }
export const FunctionInputButtons = withTranslation()(FunctionInputButtonsInternal); const FunctionInputButtons = withTranslation()(FunctionInputButtonsInternal);
export default FunctionInputButtons;
@@ -1,9 +1,9 @@
import React from "react"; import React from "react";
import { FieldSpec, type FieldSpecProps } from "./FieldSpec"; import FieldSpec, {type FieldSpecProps} from "./FieldSpec";
import { FunctionInputButtons as FunctionButtons } from "./FunctionButtons"; import FunctionButtons from "./_FunctionButtons";
import { labelFromFieldName } from "../libs/label-from-field-name"; import labelFromFieldName from "../libs/label-from-field-name";
type SpecPropertyProps = FieldSpecProps & { type SpecPropertyProps = FieldSpecProps & {
@@ -19,7 +19,7 @@ type SpecPropertyProps = FieldSpecProps & {
}; };
export class SpecProperty extends React.Component<SpecPropertyProps> { export default class SpecProperty extends React.Component<SpecPropertyProps> {
static defaultProps = { static defaultProps = {
errors: {}, errors: {},
}; };
@@ -4,17 +4,17 @@ import { TbMathFunction } from "react-icons/tb";
import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json"; import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { InputButton } from "./InputButton"; import InputButton from "./InputButton";
import { InputSpec } from "./InputSpec"; import InputSpec from "./InputSpec";
import { InputNumber } from "./InputNumber"; import InputNumber from "./InputNumber";
import { InputSelect } from "./InputSelect"; import InputSelect from "./InputSelect";
import { Block } from "./Block"; import Block from "./Block";
import { DeleteStopButton } from "./DeleteStopButton"; import DeleteStopButton from "./_DeleteStopButton";
import { labelFromFieldName } from "../libs/label-from-field-name"; import labelFromFieldName from "../libs/label-from-field-name";
import { generateUniqueId as docUid } from "../libs/document-uid"; import docUid from "../libs/document-uid";
import { sortNumerically } from "../libs/sort-numerically"; import sortNumerically from "../libs/sort-numerically";
import { type MappedLayerErrors } from "../libs/definitions"; import { type MappedLayerErrors } from "../libs/definitions";
@@ -194,7 +194,6 @@ class ZoomPropertyInternal extends React.Component<ZoomPropertyInternalProps, Zo
<div className="maputnik-data-fieldset-inner"> <div className="maputnik-data-fieldset-inner">
<Block <Block
label={t("Function")} label={t("Function")}
data-wd-key="function-type"
> >
<div className="maputnik-data-spec-property-input"> <div className="maputnik-data-spec-property-input">
<InputSelect <InputSelect
@@ -207,7 +206,6 @@ class ZoomPropertyInternal extends React.Component<ZoomPropertyInternalProps, Zo
</Block> </Block>
<Block <Block
label={t("Base")} label={t("Base")}
data-wd-key="function-base"
> >
<div className="maputnik-data-spec-property-input"> <div className="maputnik-data-spec-property-input">
<InputSpec <InputSpec
@@ -242,7 +240,6 @@ class ZoomPropertyInternal extends React.Component<ZoomPropertyInternalProps, Zo
</InputButton> </InputButton>
<InputButton <InputButton
className="maputnik-add-stop" className="maputnik-add-stop"
data-wd-key="convert-to-expression"
onClick={this.props.onExpressionClick?.bind(this)} onClick={this.props.onExpressionClick?.bind(this)}
> >
<TbMathFunction style={{ verticalAlign: "text-bottom" }} /> <TbMathFunction style={{ verticalAlign: "text-bottom" }} />
@@ -267,4 +264,5 @@ class ZoomPropertyInternal extends React.Component<ZoomPropertyInternalProps, Zo
} }
} }
export const ZoomProperty = withTranslation()(ZoomPropertyInternal); const ZoomProperty = withTranslation()(ZoomPropertyInternal);
export default ZoomProperty;
+2 -1
View File
@@ -67,4 +67,5 @@ class ModalInternal extends React.Component<ModalInternalProps> {
} }
} }
export const Modal = withTranslation()(ModalInternal); const Modal = withTranslation()(ModalInternal);
export default Modal;
+8 -7
View File
@@ -2,12 +2,12 @@ import React from "react";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import type {LayerSpecification, SourceSpecification} from "maplibre-gl"; import type {LayerSpecification, SourceSpecification} from "maplibre-gl";
import { InputButton } from "../InputButton"; import InputButton from "../InputButton";
import { Modal } from "./Modal"; import Modal from "./Modal";
import { FieldType } from "../FieldType"; import FieldType from "../FieldType";
import { FieldId } from "../FieldId"; import FieldId from "../FieldId";
import { FieldSource } from "../FieldSource"; import FieldSource from "../FieldSource";
import { FieldSourceLayer } from "../FieldSourceLayer"; import FieldSourceLayer from "../FieldSourceLayer";
import { NON_SOURCE_LAYERS } from "../../libs/non-source-layers"; import { NON_SOURCE_LAYERS } from "../../libs/non-source-layers";
type ModalAddInternalProps = { type ModalAddInternalProps = {
@@ -192,4 +192,5 @@ class ModalAddInternal extends React.Component<ModalAddInternalProps, ModalAddSt
} }
} }
export const ModalAdd = withTranslation()(ModalAddInternal); const ModalAdd = withTranslation()(ModalAddInternal);
export default ModalAdd;
+3 -2
View File
@@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { Trans, type WithTranslation, withTranslation } from "react-i18next"; import { Trans, type WithTranslation, withTranslation } from "react-i18next";
import { Modal } from "./Modal"; import Modal from "./Modal";
type ModalDebugInternalProps = { type ModalDebugInternalProps = {
@@ -79,4 +79,5 @@ class ModalDebugInternal extends React.Component<ModalDebugInternalProps> {
} }
} }
export const ModalDebug = withTranslation()(ModalDebugInternal); const ModalDebug = withTranslation()(ModalDebugInternal);
export default ModalDebug;
+9 -8
View File
@@ -6,11 +6,11 @@ import {format} from "@maplibre/maplibre-gl-style-spec";
import {MdMap, MdSave} from "react-icons/md"; import {MdMap, MdSave} from "react-icons/md";
import {type WithTranslation, withTranslation} from "react-i18next"; import {type WithTranslation, withTranslation} from "react-i18next";
import { FieldString } from "../FieldString"; import FieldString from "../FieldString";
import { InputButton } from "../InputButton"; import InputButton from "../InputButton";
import { Modal } from "./Modal"; import Modal from "./Modal";
import { replaceAccessTokens, stripAccessTokens } from "../../libs/style"; import style from "../../libs/style";
import { spec as fieldSpecAdditional } from "../../libs/field-spec-additional"; import fieldSpecAdditional from "../../libs/field-spec-additional";
import type {OnStyleChangedCallback, StyleSpecificationWithId} from "../../libs/definitions"; import type {OnStyleChangedCallback, StyleSpecificationWithId} from "../../libs/definitions";
@@ -32,8 +32,8 @@ class ModalExportInternal extends React.Component<ModalExportInternalProps> {
tokenizedStyle() { tokenizedStyle() {
return format( return format(
stripAccessTokens( style.stripAccessTokens(
replaceAccessTokens(this.props.mapStyle) style.replaceAccessTokens(this.props.mapStyle)
) )
); );
} }
@@ -217,4 +217,5 @@ class ModalExportInternal extends React.Component<ModalExportInternalProps> {
} }
} }
export const ModalExport = withTranslation()(ModalExportInternal); const ModalExport = withTranslation()(ModalExportInternal);
export default ModalExport;
+6 -5
View File
@@ -3,13 +3,13 @@ import { withTranslation, type WithTranslation } from "react-i18next";
import { MdDelete } from "react-icons/md"; import { MdDelete } from "react-icons/md";
import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json"; import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import { Modal } from "./Modal"; import Modal from "./Modal";
import { FieldString } from "../FieldString"; import FieldString from "../FieldString";
import { InputButton } from "../InputButton"; import InputButton from "../InputButton";
import { PiListPlusBold } from "react-icons/pi"; import { PiListPlusBold } from "react-icons/pi";
import { type StyleSpecificationWithId } from "../../libs/definitions"; import { type StyleSpecificationWithId } from "../../libs/definitions";
import { type SchemaSpecification } from "maplibre-gl"; import { type SchemaSpecification } from "maplibre-gl";
import { Doc } from "../Doc"; import Doc from "../Doc";
type ModalGlobalStateInternalProps = { type ModalGlobalStateInternalProps = {
mapStyle: StyleSpecificationWithId; mapStyle: StyleSpecificationWithId;
@@ -151,4 +151,5 @@ const ModalGlobalStateInternal: React.FC<ModalGlobalStateInternalProps> = (props
); );
}; };
export const ModalGlobalState = withTranslation()(ModalGlobalStateInternal); const ModalGlobalState = withTranslation()(ModalGlobalStateInternal);
export default ModalGlobalState;
+4 -3
View File
@@ -1,8 +1,8 @@
import React from "react"; import React from "react";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { InputButton } from "../InputButton"; import InputButton from "../InputButton";
import { Modal } from "./Modal"; import Modal from "./Modal";
type ModalLoadingInternalProps = { type ModalLoadingInternalProps = {
@@ -35,4 +35,5 @@ class ModalLoadingInternal extends React.Component<ModalLoadingInternalProps> {
} }
} }
export const ModalLoading = withTranslation()(ModalLoadingInternal); const ModalLoading = withTranslation()(ModalLoadingInternal);
export default ModalLoading;
+10 -9
View File
@@ -3,12 +3,12 @@ import { MdFileUpload } from "react-icons/md";
import { MdAddCircleOutline } from "react-icons/md"; import { MdAddCircleOutline } from "react-icons/md";
import { Trans, type WithTranslation, withTranslation } from "react-i18next"; import { Trans, type WithTranslation, withTranslation } from "react-i18next";
import { ModalLoading } from "./ModalLoading"; import ModalLoading from "./ModalLoading";
import { Modal } from "./Modal"; import Modal from "./Modal";
import { InputButton } from "../InputButton"; import InputButton from "../InputButton";
import { InputUrl } from "../InputUrl"; import InputUrl from "../InputUrl";
import { ensureStyleValidity } from "../../libs/style"; import style from "../../libs/style";
import publicStyles from "../../config/styles.json"; import publicStyles from "../../config/styles.json";
type PublicStyleProps = { type PublicStyleProps = {
@@ -109,7 +109,7 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
activeRequestUrl: null activeRequestUrl: null
}); });
const mapStyle = ensureStyleValidity(body); const mapStyle = style.ensureStyleValidity(body);
console.log("Loaded style ", mapStyle.id); console.log("Loaded style ", mapStyle.id);
this.props.onStyleOpen(mapStyle); this.props.onStyleOpen(mapStyle);
this.onOpenToggle(); this.onOpenToggle();
@@ -165,7 +165,7 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
}); });
return; return;
} }
mapStyle = ensureStyleValidity(mapStyle); mapStyle = style.ensureStyleValidity(mapStyle);
this.props.onStyleOpen(mapStyle, fileHandle); this.props.onStyleOpen(mapStyle, fileHandle);
this.onOpenToggle(); this.onOpenToggle();
@@ -193,7 +193,7 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
}); });
return; return;
} }
mapStyle = ensureStyleValidity(mapStyle); mapStyle = style.ensureStyleValidity(mapStyle);
this.props.onStyleOpen(mapStyle); this.props.onStyleOpen(mapStyle);
this.onOpenToggle(); this.onOpenToggle();
}; };
@@ -364,4 +364,5 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
} }
} }
export const ModalOpen = withTranslation()(ModalOpenInternal); const ModalOpen = withTranslation()(ModalOpenInternal);
export default ModalOpen;
+13 -19
View File
@@ -3,17 +3,17 @@ import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import type {LightSpecification, ProjectionSpecification, StyleSpecification, TerrainSpecification, TransitionSpecification} from "maplibre-gl"; import type {LightSpecification, ProjectionSpecification, StyleSpecification, TerrainSpecification, TransitionSpecification} from "maplibre-gl";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { FieldArray } from "../FieldArray"; import FieldArray from "../FieldArray";
import { FieldNumber } from "../FieldNumber"; import FieldNumber from "../FieldNumber";
import { FieldString } from "../FieldString"; import FieldString from "../FieldString";
import { FieldUrl } from "../FieldUrl"; import FieldUrl from "../FieldUrl";
import { FieldSelect } from "../FieldSelect"; import FieldSelect from "../FieldSelect";
import { FieldEnum } from "../FieldEnum"; import FieldEnum from "../FieldEnum";
import { FieldColor } from "../FieldColor"; import FieldColor from "../FieldColor";
import { Modal } from "./Modal"; import Modal from "./Modal";
import { FieldJson } from "../FieldJson"; import FieldJson from "../FieldJson";
import { Block } from "../Block"; import Block from "../Block";
import { spec as fieldSpecAdditional } from "../../libs/field-spec-additional"; import fieldSpecAdditional from "../../libs/field-spec-additional";
import type {OnStyleChangedCallback, StyleSpecificationWithId} from "../../libs/definitions"; import type {OnStyleChangedCallback, StyleSpecificationWithId} from "../../libs/definitions";
type ModalSettingsInternalProps = { type ModalSettingsInternalProps = {
@@ -206,7 +206,6 @@ class ModalSettingsInternal extends React.Component<ModalSettingsInternalProps>
<FieldNumber <FieldNumber
label={t("Zoom")} label={t("Zoom")}
data-wd-key="modal:settings.zoom"
fieldSpec={latest.$root.zoom} fieldSpec={latest.$root.zoom}
value={mapStyle.zoom} value={mapStyle.zoom}
default={0} default={0}
@@ -215,7 +214,6 @@ class ModalSettingsInternal extends React.Component<ModalSettingsInternalProps>
<FieldNumber <FieldNumber
label={t("Bearing")} label={t("Bearing")}
data-wd-key="modal:settings.bearing"
fieldSpec={latest.$root.bearing} fieldSpec={latest.$root.bearing}
value={mapStyle.bearing} value={mapStyle.bearing}
default={latest.$root.bearing.default} default={latest.$root.bearing.default}
@@ -224,7 +222,6 @@ class ModalSettingsInternal extends React.Component<ModalSettingsInternalProps>
<FieldNumber <FieldNumber
label={t("Pitch")} label={t("Pitch")}
data-wd-key="modal:settings.pitch"
fieldSpec={latest.$root.pitch} fieldSpec={latest.$root.pitch}
value={mapStyle.pitch} value={mapStyle.pitch}
default={latest.$root.pitch.default} default={latest.$root.pitch.default}
@@ -251,7 +248,6 @@ class ModalSettingsInternal extends React.Component<ModalSettingsInternalProps>
<FieldNumber <FieldNumber
label={t("Light intensity")} label={t("Light intensity")}
data-wd-key="modal:settings.light-intensity"
fieldSpec={latest.light.intensity} fieldSpec={latest.light.intensity}
value={light.intensity as number} value={light.intensity as number}
default={latest.light.intensity.default} default={latest.light.intensity.default}
@@ -278,7 +274,6 @@ class ModalSettingsInternal extends React.Component<ModalSettingsInternalProps>
<FieldNumber <FieldNumber
label={t("Terrain exaggeration")} label={t("Terrain exaggeration")}
data-wd-key="modal:settings.terrain-exaggeration"
fieldSpec={latest.terrain.exaggeration} fieldSpec={latest.terrain.exaggeration}
value={terrain.exaggeration} value={terrain.exaggeration}
default={latest.terrain.exaggeration.default} default={latest.terrain.exaggeration.default}
@@ -287,7 +282,6 @@ class ModalSettingsInternal extends React.Component<ModalSettingsInternalProps>
<FieldNumber <FieldNumber
label={t("Transition delay")} label={t("Transition delay")}
data-wd-key="modal:settings.transition-delay"
fieldSpec={latest.transition.delay} fieldSpec={latest.transition.delay}
value={transition.delay} value={transition.delay}
default={latest.transition.delay.default} default={latest.transition.delay.default}
@@ -296,7 +290,6 @@ class ModalSettingsInternal extends React.Component<ModalSettingsInternalProps>
<FieldNumber <FieldNumber
label={t("Transition duration")} label={t("Transition duration")}
data-wd-key="modal:settings.transition-duration"
fieldSpec={latest.transition.duration} fieldSpec={latest.transition.duration}
value={transition.duration} value={transition.duration}
default={latest.transition.duration.default} default={latest.transition.duration.default}
@@ -332,4 +325,5 @@ class ModalSettingsInternal extends React.Component<ModalSettingsInternalProps>
} }
} }
export const ModalSettings = withTranslation()(ModalSettingsInternal); const ModalSettings = withTranslation()(ModalSettingsInternal);
export default ModalSettings;
+3 -2
View File
@@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { Trans, type WithTranslation, withTranslation } from "react-i18next"; import { Trans, type WithTranslation, withTranslation } from "react-i18next";
import { Modal } from "./Modal"; import Modal from "./Modal";
type ModalShortcutsInternalProps = { type ModalShortcutsInternalProps = {
@@ -134,4 +134,5 @@ class ModalShortcutsInternal extends React.Component<ModalShortcutsInternalProps
} }
} }
export const ModalShortcuts = withTranslation()(ModalShortcutsInternal); const ModalShortcuts = withTranslation()(ModalShortcutsInternal);
export default ModalShortcuts;
+9 -8
View File
@@ -4,13 +4,13 @@ import latest from "@maplibre/maplibre-gl-style-spec/dist/latest.json";
import type {GeoJSONSourceSpecification, RasterDEMSourceSpecification, RasterSourceSpecification, SourceSpecification, VectorSourceSpecification} from "maplibre-gl"; import type {GeoJSONSourceSpecification, RasterDEMSourceSpecification, RasterSourceSpecification, SourceSpecification, VectorSourceSpecification} from "maplibre-gl";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { Modal } from "./Modal"; import Modal from "./Modal";
import { InputButton } from "../InputButton"; import InputButton from "../InputButton";
import { FieldString } from "../FieldString"; import FieldString from "../FieldString";
import { FieldSelect } from "../FieldSelect"; import FieldSelect from "../FieldSelect";
import { ModalSourcesTypeEditor, type EditorMode } from "./ModalSourcesTypeEditor"; import ModalSourcesTypeEditor, { type EditorMode } from "./ModalSourcesTypeEditor";
import { generateId } from "../../libs/style"; import style from "../../libs/style";
import { deleteSource, addSource, changeSource } from "../../libs/source"; import { deleteSource, addSource, changeSource } from "../../libs/source";
import publicSources from "../../config/tilesets.json"; import publicSources from "../../config/tilesets.json";
import { type OnStyleChangedCallback, type StyleSpecificationWithId } from "../../libs/definitions"; import { type OnStyleChangedCallback, type StyleSpecificationWithId } from "../../libs/definitions";
@@ -121,7 +121,7 @@ class AddSource extends React.Component<AddSourceProps, AddSourceState> {
super(props); super(props);
this.state = { this.state = {
mode: "tilejson_vector", mode: "tilejson_vector",
sourceId: generateId(), sourceId: style.generateId(),
source: this.defaultSource("tilejson_vector"), source: this.defaultSource("tilejson_vector"),
}; };
} }
@@ -343,4 +343,5 @@ class ModalSourcesInternal extends React.Component<ModalSourcesInternalProps> {
} }
} }
export const ModalSources = withTranslation()(ModalSourcesInternal); const ModalSources = withTranslation()(ModalSourcesInternal);
export default ModalSources;
@@ -3,14 +3,14 @@ import {latest} from "@maplibre/maplibre-gl-style-spec";
import { type WithTranslation, withTranslation } from "react-i18next"; import { type WithTranslation, withTranslation } from "react-i18next";
import { type TFunction } from "i18next"; import { type TFunction } from "i18next";
import { Block } from "../Block"; import Block from "../Block";
import { FieldUrl } from "../FieldUrl"; import FieldUrl from "../FieldUrl";
import { FieldNumber } from "../FieldNumber"; import FieldNumber from "../FieldNumber";
import { FieldSelect } from "../FieldSelect"; import FieldSelect from "../FieldSelect";
import { FieldDynamicArray } from "../FieldDynamicArray"; import FieldDynamicArray from "../FieldDynamicArray";
import { FieldArray } from "../FieldArray"; import FieldArray from "../FieldArray";
import { FieldJson } from "../FieldJson"; import FieldJson from "../FieldJson";
import { FieldCheckbox } from "../FieldCheckbox"; import FieldCheckbox from "../FieldCheckbox";
export type EditorMode = "video" | "image" | "tilejson_vector" | "tile_raster" | "tilejson_raster" | "tilexyz_raster-dem" | "tilejson_raster-dem" | "pmtiles_vector" | "tile_vector" | "geojson_url" | "geojson_json" | null; export type EditorMode = "video" | "image" | "tilejson_vector" | "tile_raster" | "tilejson_raster" | "tilexyz_raster-dem" | "tilejson_raster-dem" | "pmtiles_vector" | "tile_vector" | "geojson_url" | "geojson_json" | null;
@@ -375,4 +375,5 @@ class ModalSourcesTypeEditorInternal extends React.Component<ModalSourcesTypeEdi
} }
} }
export const ModalSourcesTypeEditor = withTranslation()(ModalSourcesTypeEditorInternal); const ModalSourcesTypeEditor = withTranslation()(ModalSourcesTypeEditorInternal);
export default ModalSourcesTypeEditor;
+1 -1
View File
@@ -42,4 +42,4 @@ i18n
} }
}); });
export { i18n }; export default i18n;
+1 -1
View File
@@ -4,7 +4,7 @@ import { createRoot } from "react-dom/client";
import "./favicon.ico"; import "./favicon.ico";
import "./styles/index.scss"; import "./styles/index.scss";
import "./i18n"; import "./i18n";
import { App } from "./components/App"; import App from "./components/App";
const root = createRoot(document.querySelector("#app")); const root = createRoot(document.querySelector("#app"));
root.render( root.render(

Some files were not shown because too many files have changed in this diff Show More