Compare commits

..

193 Commits

Author SHA1 Message Date
dependabot[bot] d6bf0a7a6c Bump loader-utils from 1.4.0 to 1.4.2
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 1.4.0 to 1.4.2.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v1.4.2/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v1.4.0...v1.4.2)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-17 19:50:05 +00:00
Harel M 1df2e36dbb Replace WebDriverIO with Cypress (#831)
This does the following:
1. Moves the WDIO code from javascript to typescript
2. Moves to use files that are `cy.ts` instead of `index.js`
3. Replace e2e to use cypress
4. Introduce back some skipped tests

This is in continue to the conversation here:
https://github.com/HarelM/editor/pull/3

Before:
```
 "spec" Reporter:
------------------------------------------------------------------
[chrome 120.0.6099.71 linux #0-0] Running: chrome (v120.0.6099.71) on linux
[chrome 120.0.6099.71 linux #0-0] Session ID: ee9a87bcfce007ac7721929c6e6234d0
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0] » /test/functional/index.js
[chrome 120.0.6099.71 linux #0-0] maputnik
[chrome 120.0.6099.71 linux #0-0]     history
[chrome 120.0.6099.71 linux #0-0]        - undo/redo
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]     layers
[chrome 120.0.6099.71 linux #0-0]         ops
[chrome 120.0.6099.71 linux #0-0]            ✓ delete
[chrome 120.0.6099.71 linux #0-0]            ✓ duplicate
[chrome 120.0.6099.71 linux #0-0]            ✓ hide
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         background
[chrome 120.0.6099.71 linux #0-0]            ✓ add
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]             modify
[chrome 120.0.6099.71 linux #0-0]                 layer
[chrome 120.0.6099.71 linux #0-0]                    - expand/collapse
[chrome 120.0.6099.71 linux #0-0]                    ✓ id
[chrome 120.0.6099.71 linux #0-0]                    ✓ min-zoom
[chrome 120.0.6099.71 linux #0-0]                    ✓ max-zoom
[chrome 120.0.6099.71 linux #0-0]                    ✓ comments
[chrome 120.0.6099.71 linux #0-0]                    - color
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]                 filter
[chrome 120.0.6099.71 linux #0-0]                    - expand/collapse
[chrome 120.0.6099.71 linux #0-0]                    - compound filter
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]                 paint
[chrome 120.0.6099.71 linux #0-0]                    - expand/collapse
[chrome 120.0.6099.71 linux #0-0]                    - color
[chrome 120.0.6099.71 linux #0-0]                    - pattern
[chrome 120.0.6099.71 linux #0-0]                    - opacity
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]                 json-editor
[chrome 120.0.6099.71 linux #0-0]                    - expand/collapse
[chrome 120.0.6099.71 linux #0-0]                    - modify
[chrome 120.0.6099.71 linux #0-0]                    - parse error
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         fill
[chrome 120.0.6099.71 linux #0-0]            ✓ add
[chrome 120.0.6099.71 linux #0-0]            - change source
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         line
[chrome 120.0.6099.71 linux #0-0]            ✓ add
[chrome 120.0.6099.71 linux #0-0]            - groups
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         symbol
[chrome 120.0.6099.71 linux #0-0]            ✓ add
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         raster
[chrome 120.0.6099.71 linux #0-0]            ✓ add
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         circle
[chrome 120.0.6099.71 linux #0-0]            ✓ add
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         fill extrusion
[chrome 120.0.6099.71 linux #0-0]            ✓ add
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         groups
[chrome 120.0.6099.71 linux #0-0]            ✓ simple
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]     map
[chrome 120.0.6099.71 linux #0-0]         zoom level
[chrome 120.0.6099.71 linux #0-0]            - via url
[chrome 120.0.6099.71 linux #0-0]            - via map controls
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]     modals
[chrome 120.0.6099.71 linux #0-0]         open
[chrome 120.0.6099.71 linux #0-0]            ✓ close
[chrome 120.0.6099.71 linux #0-0]            - upload
[chrome 120.0.6099.71 linux #0-0]            ✓ load from url
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         shortcuts
[chrome 120.0.6099.71 linux #0-0]            ✓ open/close
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         export
[chrome 120.0.6099.71 linux #0-0]            ✓ close
[chrome 120.0.6099.71 linux #0-0]            - download
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         sources
[chrome 120.0.6099.71 linux #0-0]            - active sources
[chrome 120.0.6099.71 linux #0-0]            - public source
[chrome 120.0.6099.71 linux #0-0]            - add new source
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         inspect
[chrome 120.0.6099.71 linux #0-0]            ✓ toggle
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         style settings
[chrome 120.0.6099.71 linux #0-0]            ✓ name
[chrome 120.0.6099.71 linux #0-0]            ✓ owner
[chrome 120.0.6099.71 linux #0-0]            ✓ sprite url
[chrome 120.0.6099.71 linux #0-0]            ✓ glyphs url
[chrome 120.0.6099.71 linux #0-0]            ✓ maptiler access token
[chrome 120.0.6099.71 linux #0-0]            ✓ thunderforest access token
[chrome 120.0.6099.71 linux #0-0]            ✓ style renderer
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]         sources
[chrome 120.0.6099.71 linux #0-0]            - toggle
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]     screenshots
[chrome 120.0.6099.71 linux #0-0]        ✓ front_page
[chrome 120.0.6099.71 linux #0-0]        ✓ open
[chrome 120.0.6099.71 linux #0-0]        ✓ export
[chrome 120.0.6099.71 linux #0-0]        ✓ sources
[chrome 120.0.6099.71 linux #0-0]        ✓ style settings
[chrome 120.0.6099.71 linux #0-0]        ✓ inspect
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]     accessibility
[chrome 120.0.6099.71 linux #0-0]         skip links
[chrome 120.0.6099.71 linux #0-0]            ✓ skip link to layer list
[chrome 120.0.6099.71 linux #0-0]            ✓ skip link to layer editor
[chrome 120.0.6099.71 linux #0-0]            ✓ skip link to map view
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0]     keyboard
[chrome 120.0.6099.71 linux #0-0]         shortcuts
[chrome 120.0.6099.71 linux #0-0]            ✓ ESC should unfocus
[chrome 120.0.6099.71 linux #0-0]            ✓ '?' should show shortcuts modal
[chrome 120.0.6099.71 linux #0-0]            ✓ 'o' should show open modal
[chrome 120.0.6099.71 linux #0-0]            ✓ 'e' should show export modal
[chrome 120.0.6099.71 linux #0-0]            ✓ 'd' should show sources modal
[chrome 120.0.6099.71 linux #0-0]            ✓ 's' should show settings modal
[chrome 120.0.6099.71 linux #0-0]            - 'i' should change map to inspect mode
[chrome 120.0.6099.71 linux #0-0]            ✓ 'm' should focus map
[chrome 120.0.6099.71 linux #0-0]            ✓ '!' should show debug modal
[chrome 120.0.6099.71 linux #0-0]
[chrome 120.0.6099.71 linux #0-0] 44 passing (58.8s)
[chrome 120.0.6099.71 linux #0-0] 23 skipped
```

After:
```
accessibility
    skip links
      - skip link to layer list
      - skip link to layer editor
      - skip link to map view

history
    ✓ undo/redo (4894ms)

keyboard
    shortcuts
      ✓ ESC should unfocus (1912ms)
      ✓ '?' should show shortcuts modal (458ms)
      ✓ 'o' should show open modal (710ms)
      ✓ 'e' should show export modal (692ms)
      ✓ 'd' should show sources modal (588ms)
      ✓ 's' should show settings modal (894ms)
      ✓ 'i' should change map to inspect mode (804ms)
      ✓ 'm' should focus map (837ms)
      ✓ '!' should show debug modal (607ms)

layers
    ops
      ✓ delete (4313ms)
      ✓ duplicate (1780ms)
      ✓ hide (1862ms)
    background
      ✓ add (1675ms)
      modify
        layer
          - expand/collapse
          ✓ id (3735ms)
          ✓ min-zoom (2209ms)
          ✓ max-zoom (2127ms)
          ✓ comments (2515ms)
          ✓ color (2022ms)
        filter
          - expand/collapse
          - compound filter
        paint
          - expand/collapse
          - color
          - pattern
          - opacity
        json-editor
          - expand/collapse
          - modify
          - parse error
    fill
      ✓ add (1831ms)
      - change source
    line
      ✓ add (1844ms)
      ✓ groups (687ms)
    symbol
      ✓ add (2035ms)
    raster
      ✓ add (1814ms)
    circle
      ✓ add (1867ms)
    fill extrusion
      ✓ add (1963ms)
    groups
      ✓ simple (2653ms)

map
    zoom level
      ✓ via url (2279ms)
      ✓ via map controls (733ms)

modals
    open
      ✓ close (2519ms)
      - upload
      ✓ load from url (1557ms)
    shortcuts
      ✓ open/close (1136ms)
    export
      ✓ close (755ms)
      - download
    sources
      - active sources
      - public source
      - add new source
    inspect
      ✓ toggle (1020ms)
    style settings
      ✓ name (1085ms)
      ✓ owner (1060ms)
      ✓ sprite url (1214ms)
      ✓ glyphs url (1553ms)
      ✓ maptiler access token (1111ms)
      ✓ thunderforest access token (1102ms)
      ✓ style renderer (922ms)
    sources
      - toggle



      Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  accessibility.cy.ts                       52ms        3        -        -        3        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  history.cy.ts                            00:06        1        1        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  keyboard.cy.ts                           00:10        9        9        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  layers.cy.ts                             00:39       28       17        -       11        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  map.cy.ts                                00:04        2        2        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  modals.cy.ts                             00:16       18       12        -        6        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        01:18       61       41        -       20        -  
```

---------

Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2023-12-17 21:49:23 +02:00
Birk Skyum 0c46affda9 Add dependabot (#826)
It has a low limit on how many PRs it's allowed to open at a time, so it
should not flood the repo.
2023-12-17 01:16:47 -05:00
Harel M 18f45e932b Use driver pattern for e2e tests (#829)
I've moved all the logic relevant to WBIO into a single file in order to
be able to replace it.
I have tried to upgrade WDIO in order to use the latest version and it
got stuck on my computer.
Furthermore, I was not able to run it locally which made this whole
cycle very long.
After this will be merged I will replace WDIO with cypress.
This doesn't change anything, only moves some code in the tests to a
single file, removes unneeded files and uses the driver pattern, which
will later allow switching the underline WDIO with Cypress.

cc: @nyurik
2023-12-17 01:14:23 -05:00
Yuri Astrakhan 31d56c9fae Bump CI versions (#830) 2023-12-17 00:49:34 -05:00
Birk Skyum b7838ad6e1 Use latest firefox (#825) 2023-10-23 08:06:02 +02:00
Birk Skyum c92fd12854 Bump to node 18 (#824) 2023-10-22 22:11:06 +02:00
Birk Skyum eb55796461 Merge pull request #823 from birkskyum/new-webdriver
Chrome new headless
2023-10-22 20:20:26 +02:00
Yuri Astrakhan 4b97f82980 Revert "Revert "Resolve #821 (#822)""
This reverts commit e4d559f953.
2023-10-21 18:33:48 -04:00
Yuri Astrakhan 5d0b6e3201 Revert "Revert "Added checkbox for cluster attribute (#810)""
This reverts commit 52f949e152.
2023-10-21 18:33:46 -04:00
Birk Skyum 5ab9be9fdb update node version 2023-10-22 00:27:41 +02:00
Birk Skyum 9659d41b83 chrome new headless 2023-10-22 00:20:55 +02:00
Yuri Astrakhan 52f949e152 Revert "Added checkbox for cluster attribute (#810)"
This reverts commit 393f4a38b9.
2023-10-21 18:19:24 -04:00
Yuri Astrakhan e4d559f953 Revert "Resolve #821 (#822)"
This reverts commit 577663f706.
2023-10-21 18:19:21 -04:00
zstadler 577663f706 Resolve #821 (#822)
Please see code analysis at
https://github.com/maputnik/editor/issues/821#issuecomment-1772360990
2023-10-20 11:01:20 -04:00
Eliav-B 393f4a38b9 Added checkbox for cluster attribute (#810)
* Added additional checkbox to set the cluster attribute when adding a GeoJson source

* Fixed default source function in the 'geojson_json' case

---------

Co-authored-by: shimon <ruisuhsh100@gmail.com>
2023-10-20 10:54:40 -04:00
Kevin Schaul 3727c9ad5e 814/remove mapbox references (#816)
Fixes #814

* fix: remove outdated references to mapbox
* docs: fix references in readme
* chore: fix mapbox references in tests
* chore: fix mapbox references in stories, webpack config
* chore: remove empty array
2023-08-28 22:17:49 -04:00
Yuri Astrakhan a99cbc00ba Merge pull request #812 from kevinschaul/switch-to-maplibre-ks
Convert from Mapbox GL to MapLibre
2023-07-18 23:32:11 +02:00
Kevin Schaul fe5f7e8b8c upgrade to setup-go@v3 2023-07-18 15:16:29 -05:00
Kevin Schaul 3ed4b8f2d7 add GOBIN to CI 2023-07-18 11:31:01 -05:00
Kevin Schaul f17c2e8112 reenable go modules in CI 2023-07-18 10:50:48 -05:00
Kevin Schaul 2be447f105 downgrade to node 16 to avoid ssl issue (for now) 2023-07-18 10:10:08 -05:00
Kevin Schaul 2fe6fa2be6 Update workflow to latest desktop, drop old node 2023-07-18 09:52:29 -05:00
Kevin Schaul 83dd21414b Merge branch 'master' into switch-to-maplibre-ks 2023-07-13 14:48:38 -05:00
Kevin Schaul 56d96a248d Remove JSON.stringify in call to validate 2023-07-13 14:43:18 -05:00
Kevin Schaul 5b1ee7296b Fix Buffer is undefined error 2023-07-13 14:35:16 -05:00
Kevin Schaul 8e0546fba4 Get map rendering with maplibre 2023-07-12 16:37:19 -05:00
Yuri Astrakhan 2ff3d08bb0 Merge pull request #796 from maputnik/dependabot/npm_and_yarn/async-2.6.4
Bump async from 2.6.3 to 2.6.4
2022-12-15 15:14:51 -05:00
dependabot[bot] afe7a492a7 Bump async from 2.6.3 to 2.6.4
Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-15 19:54:14 +00:00
Yuri Astrakhan 1f26ab707f Merge pull request #792 from maputnik/dependabot/npm_and_yarn/deep-object-diff-1.1.9
Bump deep-object-diff from 1.1.7 to 1.1.9
2022-12-15 14:53:11 -05:00
Yuri Astrakhan 233191e27c Merge pull request #793 from maputnik/dependabot/npm_and_yarn/loader-utils-1.4.2
Bump loader-utils from 1.4.1 to 1.4.2
2022-12-15 14:52:58 -05:00
Yuri Astrakhan 246f9a191d Merge pull request #795 from maputnik/dependabot/npm_and_yarn/decode-uri-component-0.2.2
Bump decode-uri-component from 0.2.0 to 0.2.2
2022-12-15 14:52:17 -05:00
dependabot[bot] 07f6efe45d Bump decode-uri-component from 0.2.0 to 0.2.2
Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2.
- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases)
- [Commits](https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2)

---
updated-dependencies:
- dependency-name: decode-uri-component
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-07 23:57:21 +00:00
dependabot[bot] ccd0402eea Bump loader-utils from 1.4.1 to 1.4.2
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v1.4.2/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v1.4.1...v1.4.2)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-18 00:36:06 +00:00
dependabot[bot] 8ccee0ba75 Bump deep-object-diff from 1.1.7 to 1.1.9
Bumps [deep-object-diff](https://github.com/mattphillips/deep-object-diff) from 1.1.7 to 1.1.9.
- [Release notes](https://github.com/mattphillips/deep-object-diff/releases)
- [Commits](https://github.com/mattphillips/deep-object-diff/commits)

---
updated-dependencies:
- dependency-name: deep-object-diff
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-16 23:59:29 +00:00
Yuri Astrakhan d6b67be7b2 Merge pull request #780 from maputnik/dependabot/npm_and_yarn/ejs-3.1.7
Bump ejs from 3.1.6 to 3.1.7
2022-11-09 14:52:11 -05:00
Yuri Astrakhan ac56ea4627 Merge pull request #791 from maputnik/dependabot/npm_and_yarn/loader-utils-1.4.1
Bump loader-utils from 1.4.0 to 1.4.1
2022-11-09 14:51:37 -05:00
dependabot[bot] b00cf66ea6 Bump loader-utils from 1.4.0 to 1.4.1
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 1.4.0 to 1.4.1.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v1.4.1/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v1.4.0...v1.4.1)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-09 03:55:59 +00:00
Luke Seelenbinder 8e329a0ff9 Remove missed reference to mapbox-gl.
* Also removes specialized support for Mapbox URLs.
2022-11-01 10:24:05 +01:00
Luke Seelenbinder 74cacd5bdf Initial work to convert from Mapbox GL v1.13 to MapLibre v2.4.0. 2022-10-27 14:02:47 +02:00
pathmapper 7d5fb23130 Merge pull request #782 from maputnik/dependabot/npm_and_yarn/got-11.8.5
Bump got from 11.8.3 to 11.8.5
2022-08-14 09:25:13 +02:00
pathmapper 08bbd55f13 Merge pull request #784 from maputnik/dependabot/npm_and_yarn/terser-4.8.1
Bump terser from 4.8.0 to 4.8.1
2022-08-14 09:25:00 +02:00
dependabot[bot] d6d4930513 Bump terser from 4.8.0 to 4.8.1
Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-21 03:45:50 +00:00
dependabot[bot] 6220e15723 Bump got from 11.8.3 to 11.8.5
Bumps [got](https://github.com/sindresorhus/got) from 11.8.3 to 11.8.5.
- [Release notes](https://github.com/sindresorhus/got/releases)
- [Commits](https://github.com/sindresorhus/got/compare/v11.8.3...v11.8.5)

---
updated-dependencies:
- dependency-name: got
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-23 14:02:05 +00:00
dependabot[bot] 72053a2dba Bump ejs from 3.1.6 to 3.1.7
Bumps [ejs](https://github.com/mde/ejs) from 3.1.6 to 3.1.7.
- [Release notes](https://github.com/mde/ejs/releases)
- [Changelog](https://github.com/mde/ejs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mde/ejs/compare/v3.1.6...v3.1.7)

---
updated-dependencies:
- dependency-name: ejs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-07 04:59:25 +00:00
pathmapper bf27a35ef5 Merge pull request #778 from propheel/feat/updateDependencies
Update dependencies
2022-05-07 06:57:58 +02:00
Filip Proborszcz 4705bf823a Use geckodriver 0.30 for firefox until 0.31 works 2022-05-02 15:13:42 +02:00
Filip Proborszcz a8f6208561 Fix layer drag&drop and init warning 2022-05-01 11:28:15 +02:00
Filip Proborszcz af2629be75 Make layer list sortable again 2022-04-10 22:22:16 +02:00
pathmapper 8bfad6c9fd Merge pull request #777 from maputnik/npm-ci
Use npm ci for workflow
2022-04-09 07:51:55 +02:00
Filip Proborszcz 5c3713da90 Use proper version of array-move 2022-04-08 04:14:58 +02:00
Filip Proborszcz 174eae1cf4 Use selenium standalone service to run tests 2022-04-08 03:37:40 +02:00
Filip Proborszcz d73add77e7 Fixes for breaking changes
- new webpack dev server options
- babel support for async functions in hooks
- new uuid import style
- automatically open browser for testing
2022-04-08 02:23:43 +02:00
Filip Proborszcz ab00c9f426 Many dependency updates
@storybook 6.4.20 blocks most of others like: react 18, webpack 5,
and keeps lots of unnecessary dependencies due to chakra 2 dep.
2022-04-07 17:21:34 +02:00
pathmapper d6ab302815 Use npm ci for workflow
https://docs.npmjs.com/cli/v8/commands/npm-ci
2022-04-07 03:28:47 +02:00
pathmapper f5646f57d1 Merge pull request #776 from propheel/useNode16
Use node 16.x
2022-04-07 03:11:13 +02:00
Filip Proborszcz c77d8f6625 Use shared SHM for Docker image 2022-04-07 00:37:20 +02:00
Filip Proborszcz e34c1ca4be Use node 16.x
It required converting mocha tests code into async since [@wdio/sync is
deprecated](https://webdriver.io/docs/sync-vs-async/) starting with
node v16.
It removed the dependency on fibers and on [node-gyp + python](https://
webdriver.io/docs/sync-vs-async/#common-issues-in-sync-mode) indirectly
though which is a great thing.

Also moved away from node-sass to sass since [node-sass is deprecated]
(https://sass-lang.com/blog/libsass-is-deprecated).
2022-04-06 14:05:15 +02:00
Orange Mug 87745f1fc9 Merge pull request #752 from pathmapper/webpack_stats
Webpack stats
2021-08-06 17:59:46 +01:00
pathmapper 9ba0fd5f39 Remove yarn.lock 2021-08-04 09:44:33 +02:00
pathmapper 70decbb5c1 Change webpack-dev-server info 2021-08-04 09:36:37 +02:00
pathmapper 51fa4a4377 Merge pull request #739 from pathmapper/maputnik_tag
Request using 'maputnik' tag for SE questions
2020-10-10 20:16:33 +02:00
pathmapper fb6f4d73e2 Mention 'maputnik' tag in comment 2020-10-04 12:11:00 +02:00
pathmapper 63b14933ba Merge pull request #729 from orangemug/fix/issue-712-v2
Correctly upgrade old-style filter functions to expressions
2020-09-15 19:10:49 +02:00
Orange Mug a86c31cefa Merge pull request #727 from orangemug/feature/added-html-option-to-export
Added HTML export option to export modal.
2020-09-10 19:20:40 +01:00
orangemug 25e2554412 Another commit to force a rebuild 2020-09-10 18:07:47 +01:00
Orange Mug 34bb3bc0a7 Merge pull request #726 from orangemug/fix/issue-718
Fix to not change layer key while editing layer
2020-09-10 18:06:03 +01:00
orangemug 852243cd52 onChange -> onInput for <FieldId/> component. 2020-09-09 20:22:52 +01:00
Orange Mug 40faf86adf Merge pull request #725 from orangemug/fix/issue-710
Added 'base' to functions
2020-09-09 20:15:18 +01:00
Orange Mug bb69f143b8 Merge pull request #724 from orangemug/fix/issue-707
Remove key/value from style when editing style results in empty array
2020-09-09 20:14:58 +01:00
orangemug bb43200887 Move logic into checkIfSimpleFilter function and added FILTER_OPS check. 2020-09-09 16:12:18 +01:00
orangemug ae3f79f4ad Attempt to correctly upgrade old-style filter functions to expressions. 2020-09-09 15:55:20 +01:00
orangemug 731a315624 Merge remote-tracking branch 'upstream/master' into feature/added-html-option-to-export 2020-09-09 15:12:23 +01:00
orangemug 5e441454d5 Merge remote-tracking branch 'upstream/master' into fix/issue-718 2020-09-09 15:11:52 +01:00
orangemug a55716bbd9 Merge remote-tracking branch 'upstream/master' into fix/issue-710 2020-09-09 15:08:42 +01:00
orangemug 44aea3745e Merge remote-tracking branch 'upstream/master' into fix/issue-707 2020-09-09 15:07:35 +01:00
Orange Mug a572bc02a6 Merge pull request #728 from orangemug/fix/disable-host-check
Disable host check for codesandbox
2020-09-09 15:06:54 +01:00
orangemug 4dee95fa2e Added --disable-host-check 2020-09-09 15:02:14 +01:00
orangemug 381ff6292f Removed disableHostCheck from ./config/webpack.config.js 2020-09-09 14:56:39 +01:00
orangemug c12db1703b Changed start script for codesandbox. 2020-09-09 14:55:51 +01:00
orangemug 2676583833 Added start-sandbox script. 2020-09-09 14:55:12 +01:00
orangemug 6ca2af7f8a Change codesandbox check. 2020-09-09 14:46:09 +01:00
orangemug 553b17822d Try disable host check for codesandbox. 2020-09-09 14:19:06 +01:00
orangemug a6148e5f40 Added HTML export option to export modal. 2020-09-09 14:06:48 +01:00
orangemug 4f77629eb7 Fix to not change layer key while editing layer. 2020-09-08 17:58:33 +01:00
orangemug 9103d9560a Added 'base' to functions. 2020-09-08 16:50:29 +01:00
orangemug 06c63509f7 Remove key/value from style when editing style results in empty array 2020-09-08 16:12:41 +01:00
pathmapper bbe0af6c0e Merge pull request #716 from pathmapper/Use-desktop-v1.0.7
Use desktop v1.0.7 for CI workflow
2020-07-24 19:11:54 +02:00
pathmapper 7455ccc3b7 Use desktop v1.0.7 2020-07-24 18:41:11 +02:00
Orange Mug 8b766777ac Merge pull request #706 from orangemug/fix/input-label-a11y
Improved label accessibility
2020-06-30 10:50:37 +01:00
orangemug 8441abe907 Added padding to 'maputnik-doc-button' and removed cursor from doc label. 2020-06-30 10:30:26 +01:00
orangemug ca56951256 Fix styling in export model 2020-06-30 09:48:55 +01:00
orangemug 5981151b27 Added cursor pointer to SDK docs button 2020-06-30 09:43:24 +01:00
orangemug 21dbc6c4d9 Added back in https://github.com/maputnik/editor link 2020-06-30 09:42:05 +01:00
Orange Mug 6f060c2a0a Merge pull request #708 from pathmapper/update_mb_deps
Update mb-gl
2020-06-30 09:27:02 +01:00
pathmapper 24327541c5 Update mb-gl 2020-06-30 09:16:53 +02:00
orangemug 0d6b9ee9d4 Fixed source modal CSS for new block definitions. 2020-06-29 16:26:28 +01:00
orangemug 3ad487dce7 Removed isRequired from label incase null. 2020-06-29 16:18:04 +01:00
orangemug a46c834874 Fixed data functions. 2020-06-29 16:14:35 +01:00
orangemug 67bdea1827 Re-added info button and SDK docs to fields after refactor. 2020-06-29 16:03:59 +01:00
Orange Mug cc4133aac1 Merge pull request #703 from pathmapper/fix_674
Add again shouldComponentUpdate
2020-06-29 15:41:49 +01:00
orangemug 4a6f58d61c Changed heading sizes for modals. 2020-06-10 20:37:46 +01:00
orangemug e3dc98b76d <h2/> -> <h1/> 2020-06-10 20:37:08 +01:00
orangemug 09373dda44 Fixed changing between zoom/data functions. 2020-06-10 20:26:39 +01:00
orangemug c4b05b62b3 Remove logging. 2020-06-10 19:44:05 +01:00
orangemug 06bccfab10 Fix for checkboxes within non-clickable label 2020-06-10 19:21:29 +01:00
orangemug b83c9a1ad9 Fix block styling issues. 2020-06-10 19:20:18 +01:00
orangemug 0279daf7bd 'getApplicationNode' doesn't appear to be required as the modal is already a dialog 2020-06-10 18:17:25 +01:00
orangemug bfada7cace Added aria-label to things that are otherwise labelled in the UI. 2020-06-10 18:16:43 +01:00
orangemug 6c751fe1c4 Updated maputnik/design to diagnose axe accessibility checker issue with SVGs 2020-06-10 17:18:11 +01:00
orangemug 34299c94ee Fixed some 'axe' accessibility checker issues. 2020-06-10 16:22:13 +01:00
orangemug 5804b3c72a CSS outline fixes for keyboard users. 2020-06-10 13:04:04 +01:00
orangemug 8ae6e9fc61 Fix to ignore click suppression on inputs 2020-06-10 13:02:38 +01:00
orangemug 40579c3e0c Added back in action buttons to input label/fieldset 2020-06-10 10:59:44 +01:00
orangemug f3906c8dd8 A role="navigation" should not be on <ul/> as it changes how screen readers announce them. 2020-06-10 10:25:56 +01:00
orangemug f911ed3522 Fix <InputColor/> issues when trying to close picker. 2020-06-10 10:10:40 +01:00
orangemug 2cc179acc1 Fixed more input accessibility issues, also
- Added searchParams based router for easier testing
 - Added more stories to the storybook
2020-06-09 19:11:07 +01:00
Orange Mug 2912db6e32 Merge pull request #704 from pathmapper/update_omt_styles
Update Basic and Toner styles
2020-06-06 12:32:34 +01:00
pathmapper 70eb3e785a Trigger codesandbox 2020-06-06 12:48:34 +02:00
pathmapper 8f944d9973 Empty Commit to trigger codesanbox again 2020-06-06 12:46:53 +02:00
pathmapper 8faf841f3d Update Basic and Toner 2020-06-06 11:29:24 +02:00
pathmapper d8ba8fcbfb Add again shouldComponentUpdate 2020-06-05 15:11:49 +02:00
orangemug d6f31ec82e Block* -> Field* 2020-06-03 17:11:47 +01:00
Orange Mug b19eacf4f9 Merge pull request #699 from orangemug/maintenance/component-refactor
Tidy of components + added storybook.js
2020-06-03 16:18:04 +01:00
Orange Mug 3d158a791a Merge pull request #698 from pathmapper/issue_668
Integrate desktop builds in ci workflow
2020-06-03 14:53:06 +01:00
pathmapper 04b3b42524 Use desktop version instead of SHA 2020-06-03 15:37:17 +02:00
pathmapper af92aac7ec Remove tests 2020-06-03 13:45:59 +02:00
orangemug 90dfbf37e0 Added 'a11y' and 'source' addons to storybook as well as more stories 2020-06-03 09:52:54 +01:00
pathmapper e21f412933 Update ci.yml 2020-06-03 10:26:44 +02:00
pathmapper da297fe82c Checkout a particular SHA
https://github.com/maputnik/editor/pull/698#issuecomment-636748873
2020-06-03 10:12:32 +02:00
orangemug 624ccb5b00 Tidy of components
- Moved all components into a single directory like nextjs
 - Made component names consistent with each other
 - Made component names consistent with their export class names
 - Added storybook for a few components with the aim to extend this further.
2020-06-01 16:09:32 +01:00
pathmapper 9f0e5641ab Integrate desktop builds in ci workflow 2020-05-31 21:54:53 +02:00
Orange Mug d07b40ccef Merge pull request #696 from orangemug/feature/add-more-functional-tests
Added more webdriver tests
2020-05-31 16:05:28 +01:00
orangemug e0abd8251d Remove temp file 2020-05-31 15:57:23 +01:00
orangemug 324452e714 Disable undo/redo again. 2020-05-31 15:48:20 +01:00
orangemug 8d3ad6b1a1 Added more functional tests. 2020-05-31 15:33:09 +01:00
Orange Mug 3d4cc34a08 Merge pull request #695 from pathmapper/node_14
Add Node 14 to CI workflow
2020-05-28 11:48:59 +01:00
pathmapper ff351716b6 Update node-sass 2020-05-28 12:26:28 +02:00
Orange Mug c963a8cc59 Merge pull request #694 from pathmapper/issue_templates
Point users to https://gis.stackexchange.com/ in issue template
2020-05-28 09:39:53 +01:00
Orange Mug 52ad980aef Merge pull request #693 from pathmapper/update-mb-deps
Update GL JS and Style Spec
2020-05-28 09:38:56 +01:00
pathmapper fb04cce650 Update wdio deps 2020-05-28 08:56:23 +02:00
pathmapper 4b8acb10b0 Add Node 14 2020-05-28 08:39:57 +02:00
pathmapper 86d67389fc Update bug_report.md 2020-05-28 08:30:11 +02:00
pathmapper 9dad53e444 Point users to https://gis.stackexchange.com/ 2020-05-28 08:23:14 +02:00
pathmapper d5afeb14c1 Update bug_report.md 2020-05-28 08:04:15 +02:00
pathmapper 85bb1d4d40 Update MB dependencies 2020-05-28 07:29:55 +02:00
Orange Mug d95e25d185 Merge pull request #692 from orangemug/feature/codesandbox-ci
Added back in codesandbox CI config
2020-05-27 11:12:00 +01:00
Orange Mug a88f2bc0a3 Merge pull request #691 from orangemug/fix/readme-styling
Fixed README styling
2020-05-27 11:11:46 +01:00
orangemug 5a4254d300 Added back in codesandbox CI config. 2020-05-27 10:45:52 +01:00
orangemug 6bfe2aa364 Reordered header items in README. 2020-05-27 10:37:01 +01:00
orangemug 0acd1fec0a Fixed README styling, updated logo and removed broken badges. 2020-05-27 10:32:03 +01:00
pathmapper 3046fedb55 Merge pull request #690 from pathmapper/other_issue_template
Add other issue template
2020-05-27 11:26:23 +02:00
Orange Mug 1574b49b01 Merge pull request #687 from orangemug/feature/github-actions-ci
Added new CI workflow using GitHub actions
2020-05-27 10:20:21 +01:00
pathmapper 4417a2d8f1 Add other issue template 2020-05-27 11:18:27 +02:00
pathmapper 1f34e927e7 Merge pull request #689 from pathmapper/master
Add issue template for bug report
2020-05-27 10:58:00 +02:00
pathmapper 9af6a537ef Update issue templates
Add custom bug report
2020-05-27 10:48:54 +02:00
Orange Mug 6e07142f13 Merge pull request #546 from nyurik/dockerfile
Optimize docker image
2020-05-25 09:41:15 +01:00
orangemug d2853f34a4 Removed meta-demo-comment as it won't work from forked repos 2020-05-25 06:58:57 +01:00
orangemug 7faed0d27e Added firefox tests and fixed docker deploy 2020-05-24 12:56:52 +01:00
Orange Mug 22101f93ad Merge pull request #686 from orangemug/fix/issue-322
Added tip to JSON editor about how to unfocus
2020-05-24 12:04:35 +01:00
orangemug 0661899d54 Fixes for code review comments. 2020-05-24 11:46:47 +01:00
Orange Mug 862ac84464 Merge pull request #683 from orangemug/fix/a11y-issue-320
Fix some accessibility issues
2020-05-24 11:44:41 +01:00
Orange Mug 1e4aadbb6d Merge pull request #684 from orangemug/fix/issue-533
Fix for updating available sources cache when updating style
2020-05-24 11:42:15 +01:00
orangemug ce731e7d6b Added new CI workflow using GitHub actions.
Also

 - Fixed screenshot tests
 - Fixed code coverage
 - Removed appveyor
 - Removed circleci
 - Updated wdio related dependencies
 - Added docker image deploy to the GitHub registry
2020-05-24 11:13:16 +01:00
orangemug 5448cdbe4e Don't remember state when toggling <AddModal/> 2020-05-21 10:07:22 +01:00
orangemug 315a9b82c0 Fixed for initial focus of JSON editor message. 2020-05-21 09:22:42 +01:00
orangemug 9e1c0e4c82 Added aria-hidden to JSON editor message. 2020-05-21 09:20:47 +01:00
orangemug 7db675e0d1 Added ESC note to JSON editor. 2020-05-19 12:21:12 +01:00
orangemug 0aa629164a Fix for updating available sources when updating style. 2020-05-19 10:24:59 +01:00
orangemug c2ec77e869 Fixed lint errors. 2020-05-18 19:41:09 +01:00
orangemug b28407a4a0 Accessibility fixes
- Aria landmarks
 - Title attributes to all icon only buttons
 - <Multibutton/> now internally a radio group
 - Replaced 1 'skip navigation link' with UI group links
 - Added map specific shortcuts to the shortcut menu
 - Hidden layer list actions from tab index
2020-05-18 19:37:49 +01:00
Orange Mug e3e6647e03 Merge pull request #682 from orangemug/fix/issue-681
Fix open modal URL entry to use form submission
2020-05-14 15:32:09 +01:00
orangemug eb0f833d49 Fixed typo. 2020-05-14 13:33:57 +01:00
orangemug c5c1dd12b9 Added missing prop validation 2020-05-14 13:27:43 +01:00
orangemug b7e414a042 Fix URL entry to use form submission and improved errors if protocol isn't present. 2020-05-14 12:13:47 +01:00
Orange Mug 81a6f31803 Merge pull request #680 from pathmapper/mb_styles
Fix token input
2020-05-14 11:49:33 +01:00
pathmapper 65cd050a18 Fix token input 2020-05-05 09:40:43 +02:00
Orange Mug c426dd7349 Merge pull request #673 from pathmapper/update_mb_dependencies
Update MB deps
2020-05-02 09:33:10 +01:00
Orange Mug c5af645546 Merge pull request #675 from nspringer-trimble/feature/inspect-source-name
Add source name to inspect popup
2020-05-02 09:32:07 +01:00
pathmapper 1bf0abfb5a Update MB deps 2020-04-30 09:18:13 +02:00
Nick Springer 18338de21a Add source name to inspect popup 2020-04-27 15:30:07 -04:00
Orange Mug 857117eb71 Merge pull request #666 from orangemug/fix/issue-646
Fix to make layer list header visible at all times
2020-04-26 10:15:33 +01:00
Orange Mug 8d86bca8b3 Merge pull request #671 from pathmapper/update_readme
Remove v1.7.0-beta from readme
2020-04-26 10:02:51 +01:00
orangemug dc4e6a0925 Fix vertical align of view/select in toolbar 2020-04-26 09:58:21 +01:00
pathmapper e9d6119ac6 Remove v1.7.0-beta from readme 2020-04-26 10:58:01 +02:00
orangemug cbdf45c852 Fixed <select/> styling in firefox and improved in chrome. 2020-04-26 09:23:18 +01:00
Orange Mug a191c36f96 Merge pull request #667 from orangemug/fix/issue-656
Support multiple tiles URLs for source
2020-04-25 13:52:30 +01:00
orangemug 0a8d0974ca Fixed field spec for image/video. 2020-04-25 13:31:15 +01:00
orangemug 8e6c54564b Add <DynamicArrayInput/> to source tile urls to support multiple values. 2020-04-25 11:38:13 +01:00
orangemug 4bbe2ce1ea Fix to make layer list header visible at all times.
Also improved scrollbar styling/positioning for toolbar and layers list.
2020-04-25 11:05:34 +01:00
Yuri Astrakhan 2a832955c4 Updated docs, rm creds 2019-08-03 15:02:16 -04:00
Yuri Astrakhan 608b836fe0 fix readme 2019-08-03 12:37:19 -04:00
Yuri Astrakhan de9c4fcc4a Optimize docker image
* Use 2 stage docker building to produce a tiny python3-slim based docker image with just the compilation results.
2019-08-03 12:08:54 -04:00
232 changed files with 42171 additions and 14118 deletions
+2 -1
View File
@@ -6,7 +6,8 @@
"plugins": [
"static-fs",
"react-hot-loader/babel",
"@babel/plugin-proposal-class-properties"
"@babel/plugin-proposal-class-properties",
"@babel/transform-runtime"
],
"env": {
"test": {
-103
View File
@@ -1,103 +0,0 @@
version: 2
templates:
# Test the build **only** no webdriver
build-steps: &build-steps
- checkout
- run:
name: "Create artifacts directory"
command: mkdir /tmp/artifacts
- restore_cache:
key: v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
- run: mkdir -p /tmp/artifacts/logs
- run: npm run build
- run: npm run lint-js
- run: npm run lint-css
- store_artifacts:
path: /tmp/artifacts
destination: /artifacts
# Test in webdriver
wdio-steps: &wdio-steps
- checkout
- run:
name: "Create artifacts directory"
command: mkdir /tmp/artifacts
- restore_cache:
key: v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
- run: mkdir -p /tmp/artifacts/logs
- run: npm run build
- run: npm run profiling-build
- run: npm run lint-js
- run: npm run lint-css
- run: DOCKER_HOST=localhost npm test
- run: ./node_modules/.bin/istanbul report --include /tmp/artifacts/coverage/coverage.json --dir /tmp/artifacts/coverage html lcov
- store_artifacts:
path: /tmp/artifacts
destination: /artifacts
jobs:
build-linux-node-v10:
docker:
- image: node:10
- image: selenium/standalone-chrome:3.141.59
working_directory: ~/repo-linux-node-v10
steps: *wdio-steps
build-linux-node-v12:
docker:
- image: node:12
working_directory: ~/repo-linux-node-v12
steps: *build-steps
build-linux-node-v13:
docker:
- image: node:13
working_directory: ~/repo-linux-node-v13
steps: *build-steps
build-osx-node-v10:
macos:
xcode: "9.0"
dependencies:
override:
- brew install node@10
working_directory: ~/repo-osx-node-v10
steps: *build-steps
build-osx-node-v12:
macos:
xcode: "9.0"
dependencies:
override:
- brew install node@12
working_directory: ~/repo-osx-node-v12
steps: *build-steps
build-osx-node-v13:
macos:
xcode: "9.0"
dependencies:
override:
- brew install node@13
working_directory: ~/repo-osx-node-v13
steps: *build-steps
workflows:
version: 2
build:
jobs:
- build-linux-node-v10
- build-linux-node-v12
- build-linux-node-v13
- build-osx-node-v10
- build-osx-node-v12
- build-osx-node-v13
+4
View File
@@ -0,0 +1,4 @@
{
"packages": [],
"sandboxes": ["/"]
}
+45
View File
@@ -0,0 +1,45 @@
.git
.gitignore
Dockerfile
#
#
# COPIED FROM .gitignore , please keep it in sync
#
#
# Logs
logs
*.log
*.swp
*.swo
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
# Ignore build files
public
/errorShots
/old
/build
+27
View File
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve Maputnik
title: ''
labels: ''
assignees: ''
---
<!-- Thanks for your feedback! Please complete the following information: -->
**Maputnik version**:<!-- e.g v1.7.0, master -->
**Browser**:
**OS**:<!-- (Windows, macOS, Linux) -->
**Description of the bug**:
**Steps to reproduce the behavior**:
1.
2.
3.
**Style file or style URL**:
<!-- If applicable, attach a style file (zip) or provide a style URL. -->
**Screenshots**:
<!-- If applicable, add screenshots to help explain your problem. -->
+11
View File
@@ -0,0 +1,11 @@
---
name: Other issue
about: Feature request or other issue which is no bug report
title: ''
labels: ''
assignees: ''
---
<!-- Thanks for reaching out! If you are having general Maputnik mapping questions, please asking them at https://gis.stackexchange.com/ using the 'maputnik' tag https://gis.stackexchange.com/questions/tagged/maputnik and read https://gis.stackexchange.com/help/how-to-ask before you do so (please keep in mind that you're asking there in a general GIS forum, not a dedicated support channel) -->
+14
View File
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 2
versioning-strategy: increase
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 2
versioning-strategy: increase
+161
View File
@@ -0,0 +1,161 @@
name: ci
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]
jobs:
# post a comment linking to codesandbox with the current branch
# meta-demo-comment:
# name: meta/demo-comment
# runs-on: ubuntu-latest
# if: ${{ github.event_name == 'pull_request' }}
# steps:
# - uses: unsplash/comment-on-pr@v1.2.0
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# msg: "Demo: <https://codesandbox.io/embed/github/${{ github.repository }}/tree/${{ github.head_ref }}?view=preview>"
build-docker:
name: build/docker
runs-on: ${{ matrix.os }}
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- run: docker build -t docker.pkg.github.com/maputnik/editor/editor:master .
# build the editor
build-node:
name: "build/node@${{ matrix.node-version }} (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build
build-artifacts:
name: "build/artifacts (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version: [18.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build
- run: npm run build-storybook
- name: artifacts/editor
uses: actions/upload-artifact@v1
with:
name: editor
path: build/build
- run: npm run profiling-build
- name: artifacts/editor-profiling
uses: actions/upload-artifact@v1
with:
name: editor-profiling
path: build/profiling
- name: artifacts/storybook
uses: actions/upload-artifact@v1
with:
name: storybook
path: build/storybook
# Build and upload desktop CLI artifacts
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^1.19.x
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
repository: maputnik/desktop
ref: master
path: ./src/github.com/maputnik/desktop/
- name: Make
run: cd src/github.com/maputnik/desktop/ && make
- name: Artifacts/linux
uses: actions/upload-artifact@v1
with:
name: maputnik-linux
path: ./src/github.com/maputnik/desktop/bin/linux/
- name: Artifacts/darwin
uses: actions/upload-artifact@v1
with:
name: maputnik-darwin
path: ./src/github.com/maputnik/desktop/bin/darwin/
- name: Artifacts/windows
uses: actions/upload-artifact@v1
with:
name: maputnik-windows
path: ./src/github.com/maputnik/desktop/bin/windows/
cypress-run:
strategy:
fail-fast: false
matrix:
browser: [chrome, firefox]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- run: npm ci
- name: Cypress run
uses: cypress-io/github-action@v6
with:
build: npm run build
start: npm run start
browser: ${{ matrix.browser }}
+27
View File
@@ -0,0 +1,27 @@
name: deploy
on:
push:
branches: [ master ]
push:
tags:
- 'v*'
jobs:
# publish docker to GitHub registry
deploy-docker:
name: deploy/docker
runs-on: ${{ matrix.os }}
if: ${{ github.event_name == 'push' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u orangemug --password-stdin
- run: docker build -t docker.pkg.github.com/maputnik/editor/editor:master .
- run: docker push docker.pkg.github.com/maputnik/editor/editor:master
+1
View File
@@ -33,3 +33,4 @@ public
/errorShots
/old
/build
/cypress/screenshots
+24
View File
@@ -0,0 +1,24 @@
const rules = require('../config/webpack.rules');
module.exports = {
stories: ['../stories/**/*.stories.js'],
addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-a11y/register',
'@storybook/addon-storysource',
],
webpackFinal: async config => {
// do mutation to the config
console.log("config.module", config.module);
return {
...config,
module: {
rules: [
...rules,
]
}
};
},
};
+7
View File
@@ -0,0 +1,7 @@
import { addons } from '@storybook/addons';
import { themes } from '@storybook/theming';
import theme from './maputnik.theme';
addons.setConfig({
theme: theme,
});
+8
View File
@@ -0,0 +1,8 @@
import { create } from '@storybook/theming/create';
export default create({
base: 'light',
brandTitle: 'Maputnik',
brandUrl: 'https://github.com/maputnik/editor',
});
+18 -17
View File
@@ -1,21 +1,22 @@
FROM node:10-slim
FROM node:18 as builder
WORKDIR /maputnik
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
python \
&& rm -rf /var/lib/apt/lists/*
# Only copy package.json to prevent npm install from running on every build
COPY package.json package-lock.json ./
RUN npm install
EXPOSE 8888
ENV HOME /maputnik
RUN mkdir ${HOME}
COPY . ${HOME}/
WORKDIR ${HOME}
RUN npm install -d
# Build maputnik
# TODO: we should also do a npm run test here (needs more dependencies)
COPY . .
RUN npm run build
WORKDIR ${HOME}/build/build
CMD python -m SimpleHTTPServer 8888
#---------------------------------------------------------------------------
# Create a clean python-based image with just the build results
FROM python:3-slim
WORKDIR /maputnik
COPY --from=builder /maputnik/build/build .
EXPOSE 8888
CMD python -m http.server 8888
+31 -37
View File
@@ -1,33 +1,30 @@
# Maputnik
<img width="200" alt="Maputnik logo" src="https://cdn.jsdelivr.net/gh/maputnik/design/logos/logo-color.png" />
[![Build Status](https://circleci.com/gh/maputnik/editor/tree/master.svg?style=shield)][circleci]
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/anelbgv6jdb3qnh9/branch/master?svg=true)][appveyor]
[![Dependency Status](https://david-dm.org/maputnik/editor.svg)][dm-prod]
[![Dev Dependency Status](https://david-dm.org/maputnik/editor/dev-status.svg)][dm-dev]
# Maputnik
[![GitHub CI status](https://github.com/maputnik/editor/workflows/ci/badge.svg)][github-action-ci]
[![License](https://img.shields.io/badge/license-MIT-blue.svg)][license]
[circleci]: https://circleci.com/gh/maputnik/editor/tree/master
[appveyor]: https://ci.appveyor.com/project/lukasmartinelli/editor
[dm-prod]: https://david-dm.org/maputnik/editor
[dm-dev]: https://david-dm.org/maputnik/editor?type=dev
[license]: https://tldrlegal.com/license/mit-license
[github-action-ci]: https://github.com/maputnik/editor/actions?query=workflow%3Aci
[license]: https://tldrlegal.com/license/mit-license
<img width="200" align="right" alt="Maputnik" src="https://cdn.jsdelivr.net/gh/maputnik/editor@1.5.0/src/img/maputnik.png" />
A free and open visual editor for the [Mapbox GL styles](https://www.mapbox.com/mapbox-gl-style-spec/)
A free and open visual editor for the [MapLibre GL styles](https://maplibre.org/maplibre-style-spec/)
targeted at developers and map designers.
## Usage
- :link: Design your maps online at **<https://maputnik.github.io/editor/>** (all in local storage)
- :link: Try out the v1.7.0-beta release at: https://maputnik.github.io/releases/v1.7.0-beta/
- :link: Use the [Maputnik CLI](https://github.com/maputnik/editor/wiki/Maputnik-CLI) for local style development
- In a Docker, run this command and browse to http://localhost:8888, Ctrl+C to stop the server.
Mapbox has built one of the best and most amazing OSS ecosystems. A key component to ensure its longevity and independence is an OSS map designer.
```bash
docker run -it --rm -p 8888:8888 maputnik/editor
```
## Donations
Mapbox has built one of the best and most amazing OSS ecosystems. A key component to ensure its longevity and independence is an OSS map designer.
If you or your organisation has seen value from Maputnik, please consider donating at <https://maputnik.github.io/donate>
## Documentation
The documentation can be found in the [Wiki](https://github.com/maputnik/editor/wiki). You are welcome to collaborate!
@@ -39,7 +36,7 @@ The documentation can be found in the [Wiki](https://github.com/maputnik/editor/
## Develop
Maputnik is written in ES6 and is using [React](https://github.com/facebook/react) and [Mapbox GL JS](https://www.mapbox.com/mapbox-gl-js/api/).
Maputnik is written in ES6 and is using [React](https://github.com/facebook/react) and [MapLibre GL JS](https://maplibre.org/projects/maplibre-gl-js/).
We ensure building and developing Maputnik works with the [current active LTS Node.js version and above](https://github.com/nodejs/Release#release-schedule).
@@ -49,14 +46,14 @@ Install the deps, start the dev server and open the web browser on `http://local
# install dependencies
npm install
# start dev server
npm start
npm run start
```
If you want Maputnik to be accessible externally use the [`--host` option](https://webpack.js.org/configuration/dev-server/#devserverhost):
```bash
# start externally accessible dev server
npm start -- --host 0.0.0.0
npm run start -- --host 0.0.0.0
```
The build process will watch for changes to the filesystem, rebuild and autoreload the editor. However note this from the [webpack-dev-server docs](https://webpack.js.org/configuration/dev-server/):
@@ -79,34 +76,32 @@ npm run lint-styles
## Tests
For testing we use [webdriverio](http://webdriver.io) and [selenium-standalone](https://github.com/vvo/selenium-standalone)
For E2E testing we use [Cypress](https://www.cypress.io/)
[selenium-standalone](https://github.com/vvo/selenium-standalone) starts a server that will launch browsers on your local machine. We use chrome so you **must** have chrome installed on your machine.
[Cypress](https://www.cypress.io/) doesn't starts a server so you'll need to start one manually by running `npm run start`.
Now open a terminal and run the following. This will install the drivers on your local machine
Now open a terminal and run the following using *chrome*:
```
./node_modules/.bin/selenium-standalone install
npm run test
```
or *firefox*:
```
npm run test -- --browser firefox
```
Now start the standalone server
See the following docs for more info: (Launching Browsers)[https://docs.cypress.io/guides/guides/launching-browsers]
You can also see the tests as they run or select which suites to run by executing:
```
./node_modules/.bin/selenium-standalone start
npm run cy:open
```
Then open another terminal and run
```
npm test
```
After some time you should see a browser launch which will be automated by the test runner.
## Related Projects
- [maputnik-dev-server](https://github.com/nycplanning/labs-maputnik-dev-server) - An express.js server that allows for quickly loading the style from any mapboxGL map into mapuntnik.
- [maputnik-dev-server](https://github.com/nycplanning/labs-maputnik-dev-server) - An express.js server that allows for quickly loading the style from any mapboxGL map into mapuntnik.
## Sponsors
@@ -166,6 +161,5 @@ Sina Martinelli, Nicholas Doiron, Neil Cawse, Urs42, Benedikt Groß, Manuel Roth
Maputnik is [licensed under MIT](LICENSE) and is Copyright (c) Lukas Martinelli and contributors.
**Disclaimer** This project is not affiliated with Mapbox or Mapbox Studio. It is an independent style editor for the
open source technology in the Mapbox GL ecosystem.
**Disclaimer** This is an independent style editor.
As contributor please take extra care of not violating any Mapbox trademarks. Do not get inspired by Mapbox Studio and make your own decisions for a good style editor.
-26
View File
@@ -1,26 +0,0 @@
image: Visual Studio 2019
environment:
matrix:
- nodejs_version: "10"
- nodejs_version: "12"
- nodejs_version: "13"
platform:
- x86
- x64
install:
# https://github.com/appveyor/ci/issues/2921#issuecomment-501016533
- ps: |
try {
Install-Product node $env:nodejs_version $env:platform
} catch {
echo "Unable to install node $env:nodejs_version, trying update..."
Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:platform
}
- md public
- npm install --global windows-build-tools
- npm install
build_script:
- npm run build
test_script:
- npm run lint-js
- npm run lint-css
-291
View File
@@ -1,291 +0,0 @@
var webpack = require("webpack");
var WebpackDevServer = require("webpack-dev-server");
var webpackConfig = require("./webpack.config");
var testConfig = require("../test/config/specs");
var artifacts = require("../test/artifacts");
var isDocker = require("is-docker");
var server;
var SCREENSHOT_PATH = artifacts.pathSync("screenshots");
exports.config = {
//
// ====================
// Runner Configuration
// ====================
//
// WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
// on a remote machine).
runner: 'local',
//
// ==================
// Specify Test Files
// ==================
// Define which test specs should run. The pattern is relative to the directory
// from which `wdio` was called. Notice that, if you are calling `wdio` from an
// NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
// directory is where your package.json resides, so `wdio` will be called from there.
//
specs: [
'./test/functional/index.js'
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
//
// ============
// Capabilities
// ============
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
// time. Depending on the number of capabilities, WebdriverIO launches several test
// sessions. Within your capabilities you can overwrite the spec and exclude options in
// order to group specific specs to a specific capability.
//
// First, you can define how many instances should be started at the same time. Let's
// say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
// set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
// files and you set maxInstances to 10, all spec files will get tested at the same time
// and 30 processes will get spawned. The property handles how many capabilities
// from the same test should run tests.
//
maxInstances: 10,
//
// If you have trouble getting all important capabilities together, check out the
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://docs.saucelabs.com/reference/platforms-configurator
//
capabilities: [{
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instances available you can make sure that not more than
// 5 instances get started at a time.
maxInstances: 5,
//
browserName: 'chrome',
// If outputDir is provided WebdriverIO can capture driver session logs
// it is possible to configure which logTypes to include/exclude.
// excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
// excludeDriverLogs: ['bugreport', 'server'],
}],
//
// ===================
// Test Configurations
// ===================
// Define all options that are relevant for the WebdriverIO instance here
//
// Level of logging verbosity: trace | debug | info | warn | error | silent
logLevel: 'info',
//
// Set specific log levels per logger
// loggers:
// - webdriver, webdriverio
// - @wdio/applitools-service, @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service
// - @wdio/mocha-framework, @wdio/jasmine-framework
// - @wdio/local-runner, @wdio/lambda-runner
// - @wdio/sumologic-reporter
// - @wdio/cli, @wdio/config, @wdio/sync, @wdio/utils
// Level of logging verbosity: trace | debug | info | warn | error | silent
// logLevels: {
// webdriver: 'debug',
// '@wdio/applitools-service': 'info'
// },
//
// If you only want to run your tests until a specific amount of tests have failed use
// bail (default is 0 - don't bail, run all tests).
bail: 0,
//
screenshotPath: SCREENSHOT_PATH,
// Note: This is here because @orangemug currently runs Maputnik inside a docker container.
hostname: process.env.DOCKER_HOST || "0.0.0.0",
// Set a base URL in order to shorten url command calls. If your `url` parameter starts
// with `/`, the base url gets prepended, not including the path portion of your baseUrl.
// If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
// gets prepended directly.
baseUrl: 'http://localhost',
//
// Default timeout for all waitFor* commands.
waitforTimeout: 10000,
//
// Default timeout in milliseconds for request
// if Selenium Grid doesn't send response
connectionRetryTimeout: 90000,
//
// Default request retries count
connectionRetryCount: 3,
//
// Test runner services
// Services take over a specific job you don't want to take care of. They enhance
// your test setup with almost no effort. Unlike plugins, they don't add new
// commands. Instead, they hook themselves up into the test process.
//
// Framework you want to run your specs with.
// The following are supported: Mocha, Jasmine, and Cucumber
// see also: https://webdriver.io/docs/frameworks.html
//
// Make sure you have the wdio adapter package for the specific framework installed
// before running any tests.
framework: 'mocha',
//
// The number of times to retry the entire specfile when it fails as a whole
// specFileRetries: 1,
//
// Test reporter for stdout.
// The only one supported by default is 'dot'
// see also: https://webdriver.io/docs/dot-reporter.html
reporters: ['spec'],
//
// Options to be passed to Mocha.
// See the full list at http://mochajs.org/
mochaOpts: {
ui: 'bdd',
// Because we don't know how long the initial build will take...
timeout: 4*60*1000
},
onPrepare: function (config, capabilities) {
return new Promise(function(resolve, reject) {
var compiler = webpack(webpackConfig);
const serverHost = isDocker() ? "0.0.0.0" : "localhost";
server = new WebpackDevServer(compiler, {
host: serverHost,
stats: {
colors: true
}
});
server.listen(testConfig.port, serverHost, function(err) {
if(err) {
reject(err);
}
else {
resolve();
}
});
})
},
onComplete: function(exitCode) {
server.close()
}
//
// =====
// Hooks
// =====
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
// it and to build services around it. You can either apply a single function or an array of
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
// resolved to continue.
/**
* Gets executed once before all workers get launched.
* @param {Object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
*/
// onPrepare: function (config, capabilities) {
// },
/**
* Gets executed just before initialising the webdriver session and test framework. It allows you
* to manipulate configurations depending on the capability or spec.
* @param {Object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that are to be run
*/
// beforeSession: function (config, capabilities, specs) {
// },
/**
* Gets executed before test execution begins. At this point you can access to all global
* variables like `browser`. It is the perfect place to define custom commands.
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that are to be run
*/
// before: function (capabilities, specs) {
// },
/**
* Runs before a WebdriverIO command gets executed.
* @param {String} commandName hook command name
* @param {Array} args arguments that command would receive
*/
// beforeCommand: function (commandName, args) {
// },
/**
* Hook that gets executed before the suite starts
* @param {Object} suite suite details
*/
// beforeSuite: function (suite) {
// },
/**
* Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
* @param {Object} test test details
*/
// beforeTest: function (test) {
// },
/**
* Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
* beforeEach in Mocha)
*/
// beforeHook: function () {
// },
/**
* Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
* afterEach in Mocha)
*/
// afterHook: function () {
// },
/**
* Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
* @param {Object} test test details
*/
// afterTest: function (test) {
// },
/**
* Hook that gets executed after the suite has ended
* @param {Object} suite suite details
*/
// afterSuite: function (suite) {
// },
/**
* Runs after a WebdriverIO command gets executed
* @param {String} commandName hook command name
* @param {Array} args arguments that command would receive
* @param {Number} result 0 - command success, 1 - command error
* @param {Object} error error object if any
*/
// afterCommand: function (commandName, args, result, error) {
// },
/**
* Gets executed after all tests are done. You still have access to all global variables from
* the test.
* @param {Number} result 0 - test pass, 1 - test fail
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that ran
*/
// after: function (result, capabilities, specs) {
// },
/**
* Gets executed right after terminating the webdriver session.
* @param {Object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that ran
*/
// afterSession: function (config, capabilities, specs) {
// },
/**
* Gets executed after all workers got shut down and the process is about to exit. An error
* thrown in the onComplete hook will result in the test run failing.
* @param {Object} exitCode 0 - success, 1 - fail
* @param {Object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
* @param {<Object>} results object containing test results
*/
// onComplete: function(exitCode, config, capabilities, results) {
// },
/**
* Gets executed when a refresh happens.
* @param {String} oldSessionId session ID of the old session
* @param {String} newSessionId session ID of the new session
*/
//onReload: function(oldSessionId, newSessionId) {
//}
}
+18 -22
View File
@@ -1,5 +1,4 @@
"use strict";
var webpack = require('webpack');
var path = require('path');
var rules = require('./webpack.rules');
var HtmlWebpackPlugin = require('html-webpack-plugin');
@@ -26,9 +25,6 @@ module.exports = {
extensions: ['.js', '.jsx']
},
module: {
noParse: [
/mapbox-gl\/dist\/mapbox-gl.js/
],
rules: rules
},
node: {
@@ -37,27 +33,25 @@ module.exports = {
tls: 'empty'
},
devServer: {
contentBase: "./public",
// do not print bundle build stats
noInfo: true,
// enable HMR
hot: true,
// embed the webpack-dev-server runtime into the bundle
inline: true,
// serve index.html in place of 404 responses to allow HTML5 history
historyApiFallback: true,
port: PORT,
host: HOST,
watchOptions: {
// Disabled polling by default as it causes lots of CPU usage and hence drains laptop batteries. To enable polling add WEBPACK_DEV_SERVER_POLLING to your environment
// See <https://webpack.js.org/configuration/watch/#watchoptions-poll> for details
poll: (!!process.env.WEBPACK_DEV_SERVER_POLLING ? true : false),
watch: false
watchFiles: {
options: {
// Disabled polling by default as it causes lots of CPU usage and hence drains laptop batteries. To enable polling add WEBPACK_DEV_SERVER_POLLING to your environment
// See <https://webpack.js.org/configuration/watch/#watchoptions-poll> for details
usePolling: (!!process.env.WEBPACK_DEV_SERVER_POLLING ? true : false),
watch: false
}
}
},
optimization: {
noEmitOnErrors: true,
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
title: 'Maputnik',
template: './src/template.html'
@@ -65,11 +59,13 @@ module.exports = {
new HtmlWebpackInlineSVGPlugin({
runPreEmit: true,
}),
new CopyWebpackPlugin([
{
from: './src/manifest.json',
to: 'manifest.json'
}
])
new CopyWebpackPlugin({
patterns: [
{
from: './src/manifest.json',
to: 'manifest.json'
}
]
})
]
};
+9 -12
View File
@@ -6,16 +6,14 @@ var HtmlWebpackInlineSVGPlugin = require('html-webpack-inline-svg-plugin');
var WebpackCleanupPlugin = require('webpack-cleanup-plugin');
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var CopyWebpackPlugin = require('copy-webpack-plugin');
var artifacts = require("../test/artifacts");
var OUTPATH = artifacts.pathSync("/build");
module.exports = {
entry: {
app: './src/index.jsx',
},
output: {
path: OUTPATH,
path: path.join(__dirname, '..', 'build', 'build'),
filename: '[name].[contenthash].js',
chunkFilename: '[contenthash].js'
},
@@ -23,9 +21,6 @@ module.exports = {
extensions: ['.js', '.jsx']
},
module: {
noParse: [
/mapbox-gl\/dist\/mapbox-gl.js/
],
rules: rules
},
node: {
@@ -48,12 +43,14 @@ module.exports = {
new HtmlWebpackInlineSVGPlugin({
runPreEmit: true,
}),
new CopyWebpackPlugin([
{
from: './src/manifest.json',
to: 'manifest.json'
}
]),
new CopyWebpackPlugin({
patterns: [
{
from: './src/manifest.json',
to: 'manifest.json'
}
]
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
defaultSizes: 'gzip',
+2 -4
View File
@@ -1,13 +1,11 @@
const webpackProdConfig = require('./webpack.production.config');
const artifacts = require("../test/artifacts");
const OUTPATH = artifacts.pathSync("/profiling");
var path = require('path');
module.exports = {
...webpackProdConfig,
output: {
...webpackProdConfig.output,
path: OUTPATH,
path: path.join(__dirname, '..', 'build', 'profiling'),
},
resolve: {
...webpackProdConfig.resolve,
+9
View File
@@ -0,0 +1,9 @@
import { defineConfig } from "cypress";
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
+41
View File
@@ -0,0 +1,41 @@
import driver from "./driver";
describe("accessibility", () => {
// skipped due to the following issue with cypress: https://github.com/cypress-io/cypress/issues/299
describe.skip("skip links", () => {
beforeEach(() => {
driver.beforeEach();
driver.setStyle("layer");
});
it("skip link to layer list", () => {
const selector = driver.getDataAttribute("root:skip:layer-list");
driver.isExists(selector);
driver.typeKeys('{tab}');
driver.isFocused(selector);
driver.click(selector);
driver.isFocused("#skip-target-layer-list");
});
it("skip link to layer editor", () => {
const selector = driver.getDataAttribute("root:skip:layer-editor");
driver.isExists(selector);
driver.typeKeys('{tab}{tab}');
driver.isFocused(selector);
driver.click(selector);
driver.isFocused("#skip-target-layer-editor");
});
it("skip link to map view", () => {
const selector = driver.getDataAttribute("root:skip:map-view");
driver.isExists(selector);
driver.typeKeys('{tab}{tab}{tab}');
driver.isFocused(selector);
driver.click(selector);
driver.isFocused(".maplibregl-canvas");
});
});
})
+170
View File
@@ -0,0 +1,170 @@
import {v1 as uuid} from "uuid";
export default {
isMac() {
return Cypress.platform === "darwin";
},
beforeEach() {
this.setupInterception();
this.setStyle('both');
},
setupInterception() {
cy.intercept('GET', 'http://localhost:8888/example-style.json', { fixture: 'example-style.json' }).as('example-style.json');
cy.intercept('GET', 'http://localhost:8888/example-layer-style.json', { fixture: 'example-layer-style.json' });
cy.intercept('GET', 'http://localhost:8888/geojson-style.json', { fixture: 'geojson-style.json' });
cy.intercept('GET', 'http://localhost:8888/raster-style.json', { fixture: 'raster-style.json' });
cy.intercept('GET', 'http://localhost:8888/geojson-raster-style.json', { fixture: 'geojson-raster-style.json' });
cy.intercept({method: 'GET', url: '*example.local/*' }, []);
cy.intercept({method: 'GET', url: '*example.com/*' }, []);
},
setStyle(styleProperties: 'geojson' | 'raster' | 'both' | 'layer' | '', zoom? : number) {
let url = "?debug";
switch (styleProperties) {
case "geojson":
url += "&style=http://localhost:8888/geojson-style.json";
break;
case "raster":
url += "&style=http://localhost:8888/raster-style.json";
break;
case "both":
url += "&style=http://localhost:8888/geojson-raster-style.json";
break;
case "layer":
url += "&style=http://localhost:8888/example-layer-style.json";
break;
}
if (zoom) {
url += "#" + zoom + "/41.3805/2.1635";
}
cy.visit("http://localhost:8888/" + url);
if (styleProperties) {
cy.on('window:confirm', () => true)
}
cy.get(".maputnik-toolbar-link").should("be.visible");
},
getDataAttribute(key: string, selector?: string) {
return `*[data-wd-key='${key}'] ${selector || ''}`;
},
closeModal(key: string) {
const selector = this.getDataAttribute(key);
this.isDisplayedInViewport(selector);
this.click(this.getDataAttribute(key + ".close-modal"));
this.doesNotExists(selector);
},
openLayersModal() {
cy.get(this.getDataAttribute('layer-list:add-layer')).click();
cy.get(this.getDataAttribute('modal:add-layer')).should('exist');
cy.get(this.getDataAttribute('modal:add-layer')).should('be.visible');
},
getStyleFromWindow(win: Window) {
const styleId = win.localStorage.getItem("maputnik:latest_style");
const styleItem = win.localStorage.getItem(`maputnik:style:${styleId}`)
const obj = JSON.parse(styleItem || "");
return obj;
},
isStyleStoreEqual(getter: (obj:any) => any, styleObj: any) {
cy.window().then((win: any) => {
const obj = this.getStyleFromWindow(win);
assert.deepEqual(getter(obj), styleObj);
});
},
isStyleStoreEqualToExampleFileData() {
cy.window().then((win: any) => {
const obj = this.getStyleFromWindow(win);
cy.fixture('example-style.json').should('deep.equal', obj);
});
},
fillLayersModal(opts: any) {
var type = opts.type;
var layer = opts.layer;
var id;
if(opts.id) {
id = opts.id
}
else {
id = `${type}:${uuid()}`;
}
cy.get(this.getDataAttribute('add-layer.layer-type', "select")).select(type);
cy.get(this.getDataAttribute("add-layer.layer-id", "input")).type(id);
if(layer) {
cy.get(this.getDataAttribute("add-layer.layer-source-block", "input")).type(layer);
}
cy.get(this.getDataAttribute("add-layer")).click();
return id;
},
typeKeys(keys: string) {
cy.get('body').type(keys);
},
click(selector: string) {
cy.get(selector).click();
},
select(selector: string, value: string) {
cy.get(selector).select(value);
},
isSelected(selector: string, value: string) {
cy.get(selector).find(`option[value="${value}"]`).should("be.selected");
},
focus(selector: string) {
cy.get(selector).focus();
},
isFocused(selector: string) {
cy.get(selector).should('have.focus');
},
isDisplayedInViewport(selector: string) {
cy.get(selector).should('be.visible');
},
isNotDisplayedInViewport(selector: string) {
cy.get(selector).should('not.be.visible');
},
setValue(selector: string, text: string) {
cy.get(selector).clear().type(text, {parseSpecialCharSequences: false});
},
isExists(selector: string) {
cy.get(selector).should('exist');
},
doesNotExists(selector: string) {
cy.get(selector).should('not.exist');
},
chooseExampleFile() {
cy.get("input[type='file']").selectFile('cypress/fixtures/example-style.json', {force: true});
},
getExampleFileUrl() {
return "http://localhost:8888/example-style.json";
},
waitForExampleFileRequset() {
cy.wait('@example-style.json');
}
}
+80
View File
@@ -0,0 +1,80 @@
import driver from "./driver";
describe("history", () => {
let undoKeyCombo: string;
let redoKeyCombo: string;
before(() => {
const isMac = driver.isMac();
undoKeyCombo = isMac ? '{meta}z' : '{ctrl}z';
redoKeyCombo = isMac ? '{meta}{shift}z' : '{ctrl}y';
driver.beforeEach();
});
it("undo/redo", () => {
driver.setStyle('geojson');
driver.openLayersModal();
driver.isStyleStoreEqual((a: any) => a.layers, []);
driver.fillLayersModal({
id: "step 1",
type: "background"
})
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": "step 1",
"type": 'background'
}
]);
driver.openLayersModal();
driver.fillLayersModal({
id: "step 2",
type: "background"
})
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": "step 1",
"type": 'background'
},
{
"id": "step 2",
"type": 'background'
}
]);
driver.typeKeys(undoKeyCombo);
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": "step 1",
"type": 'background'
}
]);
driver.typeKeys(undoKeyCombo)
driver.isStyleStoreEqual((a: any) => a.layers, []);
driver.typeKeys(redoKeyCombo)
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": "step 1",
"type": 'background'
}
]);
driver.typeKeys(redoKeyCombo)
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": "step 1",
"type": 'background'
},
{
"id": "step 2",
"type": 'background'
}
]);
});
})
+60
View File
@@ -0,0 +1,60 @@
import driver from "./driver";
describe("keyboard", () => {
describe("shortcuts", () => {
beforeEach(() => {
driver.setupInterception();
driver.setStyle('');
})
it("ESC should unfocus", () => {
const targetSelector = driver.getDataAttribute("nav:inspect") + " select";
driver.focus(targetSelector);
driver.isFocused(targetSelector);
//driver.typeKeys("{esc}");
//driver.isFocused('body');
});
it("'?' should show shortcuts modal", () => {
driver.typeKeys("?");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:shortcuts"));
});
it("'o' should show open modal", () => {
driver.typeKeys("o");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:open"));
});
it("'e' should show export modal", () => {
driver.typeKeys("e");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:export"));
});
it("'d' should show sources modal", () => {
driver.typeKeys("d");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:sources"));
});
it("'s' should show settings modal", () => {
driver.typeKeys("s");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:settings"));
});
it("'i' should change map to inspect mode", () => {
driver.typeKeys("i");
driver.isSelected(driver.getDataAttribute("nav:inspect"), "inspect");
});
it("'m' should focus map", () => {
driver.typeKeys("m");
driver.isFocused(".maplibregl-canvas");
});
it("'!' should show debug modal", () => {
driver.typeKeys("!");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:debug"));
});
});
});
+427
View File
@@ -0,0 +1,427 @@
var assert = require("assert");
import driver from "./driver";
import { v1 as uuid } from 'uuid';
describe("layers", () => {
beforeEach(() => {
driver.beforeEach();
driver.setStyle('both');
driver.openLayersModal();
});
describe("ops", () => {
it("delete", () => {
var id = driver.fillLayersModal({
type: "background"
})
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": 'background'
},
]);
driver.click(driver.getDataAttribute("layer-list-item:"+id+":delete", ""))
driver.isStyleStoreEqual((a: any) => a.layers, []);
});
it("duplicate", () => {
var styleObj;
var id = driver.fillLayersModal({
type: "background"
})
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": 'background'
},
]);
driver.click(driver.getDataAttribute("layer-list-item:"+id+":copy", ""));
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id+"-copy",
"type": "background"
},
{
"id": id,
"type": "background"
},
]);
});
it("hide", () => {
var styleObj;
var id = driver.fillLayersModal({
type: "background"
})
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": 'background'
},
]);
driver.click(driver.getDataAttribute("layer-list-item:"+id+":toggle-visibility", ""));
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": "background",
"layout": {
"visibility": "none"
}
},
]);
driver.click(driver.getDataAttribute("layer-list-item:"+id+":toggle-visibility", ""));
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": "background",
"layout": {
"visibility": "visible"
}
},
]);
})
})
describe('background', () => {
it("add", () => {
var id = driver.fillLayersModal({
type: "background"
})
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": 'background'
}
]);
});
describe("modify", () => {
function createBackground() {
// Setup
var id = uuid();
driver.select(driver.getDataAttribute("add-layer.layer-type", "select"), "background");
driver.setValue(driver.getDataAttribute("add-layer.layer-id", "input"), "background:"+id);
driver.click(driver.getDataAttribute("add-layer"));
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": 'background:'+id,
"type": 'background'
}
]);
return id;
}
// ====> THESE SHOULD BE FROM THE SPEC
describe("layer", () => {
it("expand/collapse");
it("id", () => {
var bgId = createBackground();
driver.click(driver.getDataAttribute("layer-list-item:background:"+bgId));
var id = uuid();
driver.setValue(driver.getDataAttribute("layer-editor.layer-id", "input"), "foobar:"+id)
driver.click(driver.getDataAttribute("min-zoom"));
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": 'foobar:'+id,
"type": 'background'
}
]);
});
it("min-zoom", () => {
var bgId = createBackground();
driver.click(driver.getDataAttribute("layer-list-item:background:"+bgId));
driver.setValue(driver.getDataAttribute("min-zoom", 'input[type="text"]'), "1");
driver.click(driver.getDataAttribute("layer-editor.layer-id", "input"));
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": 'background:'+bgId,
"type": 'background',
"minzoom": 1
}
]);
// AND RESET!
// driver.setValue(driver.getDataAttribute("min-zoom", "input"), "")
// driver.click(driver.getDataAttribute("max-zoom", "input"));
// driver.isStyleStoreEqual((a: any) => a.layers, [
// {
// "id": 'background:'+bgId,
// "type": 'background'
// }
// ]);
});
it("max-zoom", () => {
var bgId = createBackground();
driver.click(driver.getDataAttribute("layer-list-item:background:"+bgId));
driver.setValue(driver.getDataAttribute("max-zoom", 'input[type="text"]'), "1")
driver.click(driver.getDataAttribute("layer-editor.layer-id", "input"));
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": 'background:'+bgId,
"type": 'background',
"maxzoom": 1
}
]);
});
it("comments", () => {
var bgId = createBackground();
var id = uuid();
driver.click(driver.getDataAttribute("layer-list-item:background:"+bgId));
driver.setValue(driver.getDataAttribute("layer-comment", "textarea"), id);
driver.click(driver.getDataAttribute("layer-editor.layer-id", "input"));
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": 'background:'+bgId,
"type": 'background',
metadata: {
'maputnik:comment': id
}
}
]);
// Unset it again.
// TODO: This fails
// driver.setValue(driver.getDataAttribute("layer-comment", "textarea"), "");
// driver.click(driver.getDataAttribute("min-zoom", "input"));
// driver.isStyleStoreEqual((a: any) => a.layers, [
// {
// "id": 'background:'+bgId,
// "type": 'background'
// }
// ]);
});
it("color", () => {
var bgId = createBackground();
driver.click(driver.getDataAttribute("layer-list-item:background:"+bgId));
driver.click(driver.getDataAttribute("spec-field:background-color", "input"));
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": 'background:'+bgId,
"type": 'background'
}
]);
})
})
describe("filter", () => {
it("expand/collapse");
it("compound filter");
})
describe("paint", () => {
it("expand/collapse");
it("color");
it("pattern");
it("opacity");
})
// <=====
describe("json-editor", () => {
it("expand/collapse");
it("modify");
// TODO
it.skip("parse error", () => {
var bgId = createBackground();
driver.click(driver.getDataAttribute("layer-list-item:background:"+bgId));
var errorSelector = ".CodeMirror-lint-marker-error";
driver.doesNotExists(errorSelector);
driver.click(".CodeMirror");
driver.typeKeys("\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013 {");
driver.isExists(errorSelector);
driver.click(driver.getDataAttribute("layer-editor.layer-id"));
});
});
})
});
describe('fill', () => {
it("add", () => {
var id = driver.fillLayersModal({
type: "fill",
layer: "example"
});
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": 'fill',
"source": "example"
}
]);
})
// TODO: Change source
it("change source")
});
describe('line', () => {
it("add", () => {
var id = driver.fillLayersModal({
type: "line",
layer: "example"
});
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": "line",
"source": "example",
}
]);
});
it("groups", () => {
// TODO
// Click each of the layer groups.
})
});
describe('symbol', () => {
it("add", () => {
var id = driver.fillLayersModal({
type: "symbol",
layer: "example"
});
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": "symbol",
"source": "example",
}
]);
});
});
describe('raster', () => {
it("add", () => {
var id = driver.fillLayersModal({
type: "raster",
layer: "raster"
});
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": "raster",
"source": "raster",
}
]);
});
});
describe('circle', () => {
it("add", () => {
var id = driver.fillLayersModal({
type: "circle",
layer: "example"
});
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": "circle",
"source": "example",
}
]);
});
});
describe('fill extrusion', () => {
it("add", () => {
var id = driver.fillLayersModal({
type: "fill-extrusion",
layer: "example"
});
driver.isStyleStoreEqual((a: any) => a.layers, [
{
"id": id,
"type": 'fill-extrusion',
"source": "example"
}
]);
});
});
describe("groups", () => {
it("simple", () => {
driver.setStyle("geojson");
driver.openLayersModal();
driver.fillLayersModal({
id: "foo",
type: "background"
})
driver.openLayersModal();
driver.fillLayersModal({
id: "foo_bar",
type: "background"
})
driver.openLayersModal();
driver.fillLayersModal({
id: "foo_bar_baz",
type: "background"
})
driver.isDisplayedInViewport(driver.getDataAttribute("layer-list-item:foo"));
driver.isNotDisplayedInViewport(driver.getDataAttribute("layer-list-item:foo_bar"));
driver.isNotDisplayedInViewport(driver.getDataAttribute("layer-list-item:foo_bar_baz"));
driver.click(driver.getDataAttribute("layer-list-group:foo-0"));
driver.isDisplayedInViewport(driver.getDataAttribute("layer-list-item:foo"));
driver.isDisplayedInViewport(driver.getDataAttribute("layer-list-item:foo_bar"));
driver.isDisplayedInViewport(driver.getDataAttribute("layer-list-item:foo_bar_baz"));
})
})
});
+25
View File
@@ -0,0 +1,25 @@
import driver from "./driver";
describe("map", () => {
describe("zoom level", () => {
beforeEach(() => {
driver.beforeEach();
});
it("via url", () => {
var zoomLevel = 12.37;
driver.setStyle("geojson", zoomLevel);
driver.isDisplayedInViewport(".maplibregl-ctrl-zoom");
// HM TODO
//driver.getText(".maplibregl-ctrl-zoom") === "Zoom "+(zoomLevel);
})
it("via map controls", () => {
var zoomLevel = 12.37;
driver.setStyle("geojson", zoomLevel);
driver.click(".maplibregl-ctrl-zoom-in");
driver.isDisplayedInViewport(".maplibregl-ctrl-zoom");
// HM TODO
//driver.getText(".maplibregl-ctrl-zoom") === "Zoom "+(zoomLevel + 1);
})
})
})
+137
View File
@@ -0,0 +1,137 @@
import driver from "./driver";
describe("modals", () => {
beforeEach(() => {
driver.beforeEach();
driver.setStyle('');
});
describe("open", () => {
beforeEach(() => {
driver.click(driver.getDataAttribute("nav:open"));
});
it("close", () => {
driver.closeModal("modal:open");
});
it.skip("upload", () => {
// HM: I was not able to make the following choose file actually to select a file and close the modal...
driver.chooseExampleFile();
driver.isStyleStoreEqualToExampleFileData();
});
it("load from url", () => {
var styleFileUrl = driver.getExampleFileUrl();
driver.setValue(driver.getDataAttribute("modal:open.url.input"), styleFileUrl);
driver.click(driver.getDataAttribute("modal:open.url.button"))
driver.waitForExampleFileRequset();
driver.isStyleStoreEqualToExampleFileData();
});
})
describe("shortcuts", () => {
it("open/close", () => {
driver.setStyle('');
driver.typeKeys("?");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:shortcuts"));
driver.closeModal("modal:shortcuts");
});
});
describe("export", () => {
beforeEach(() => {
driver.click(driver.getDataAttribute("nav:export"));
});
it("close", () => {
driver.closeModal("modal:export");
});
// TODO: Work out how to download a file and check the contents
it("download")
})
describe("sources", () => {
it("active sources")
it("public source")
it("add new source")
})
describe("inspect", () => {
it("toggle", () => {
driver.setStyle('geojson');
driver.select(driver.getDataAttribute("nav:inspect", "select"), "inspect");
})
})
describe("style settings", () => {
beforeEach(() => {
driver.click(driver.getDataAttribute("nav:settings"));
});
it("name", () => {
driver.setValue(driver.getDataAttribute("modal:settings.name"), "foobar");
driver.click(driver.getDataAttribute("modal:settings.owner"));
driver.isStyleStoreEqual((obj) => obj.name, "foobar");
})
it("owner", () => {
driver.setValue(driver.getDataAttribute("modal:settings.owner"), "foobar")
driver.click(driver.getDataAttribute("modal:settings.name"));
driver.isStyleStoreEqual((obj) => obj.owner, "foobar");
})
it("sprite url", () => {
driver.setValue(driver.getDataAttribute("modal:settings.sprite"), "http://example.com")
driver.click(driver.getDataAttribute("modal:settings.name"));
driver.isStyleStoreEqual((obj) => obj.sprite, "http://example.com");
})
it("glyphs url", () => {
var glyphsUrl = "http://example.com/{fontstack}/{range}.pbf"
driver.setValue(driver.getDataAttribute("modal:settings.glyphs"), glyphsUrl);
driver.click(driver.getDataAttribute("modal:settings.name"));
driver.isStyleStoreEqual((obj) => obj.glyphs, glyphsUrl);
})
it("maptiler access token", () => {
var apiKey = "testing123";
driver.setValue(driver.getDataAttribute("modal:settings.maputnik:openmaptiles_access_token"), apiKey);
driver.click(driver.getDataAttribute("modal:settings.name"));
driver.isStyleStoreEqual((obj) => obj.metadata["maputnik:openmaptiles_access_token"], apiKey);
})
it("thunderforest access token", () => {
var apiKey = "testing123";
driver.setValue(driver.getDataAttribute("modal:settings.maputnik:thunderforest_access_token"), apiKey);
driver.click(driver.getDataAttribute("modal:settings.name"));
driver.isStyleStoreEqual((obj) => obj.metadata["maputnik:thunderforest_access_token"], apiKey);
})
it("style renderer", () => {
cy.on('uncaught:exception', () => false); // this is due to the fact that this is an invalid style for openlayers
driver.select(driver.getDataAttribute("modal:settings.maputnik:renderer"), "ol");
driver.isSelected(driver.getDataAttribute("modal:settings.maputnik:renderer"), "ol");
driver.click(driver.getDataAttribute("modal:settings.name"));
driver.isStyleStoreEqual((obj) => obj.metadata["maputnik:renderer"], "ol");
})
})
describe("sources", () => {
it("toggle")
})
})
+18
View File
@@ -0,0 +1,18 @@
{
"id": "test-style",
"version": 8,
"name": "Test Style",
"metadata": {
"maputnik:renderer": "mlgljs"
},
"sources": {},
"glyphs": "https://example.local/fonts/{fontstack}/{range}.pbf",
"sprites": "https://example.local/fonts/{fontstack}/{range}.pbf",
"layers": [
{
"id": "background",
"type": "background"
}
]
}
@@ -3,7 +3,7 @@
"version": 8,
"name": "Test Style",
"metadata": {
"maputnik:renderer": "mbgljs"
"maputnik:renderer": "mlgljs"
},
"sources": {},
"glyphs": "https://example.local/fonts/{fontstack}/{range}.pbf",
@@ -0,0 +1,34 @@
{
"id": "test-style",
"version": 8,
"name": "Test Style",
"metadata": {
"maputnik:renderer": "mlgljs"
},
"sources": {
"example": {
"type": "vector",
"data": {
"type": "FeatureCollection",
"features":[{
"type": "Feature",
"properties": {
"name": "Dinagat Islands"
},
"geometry":{
"type": "Point",
"coordinates": [125.6, 10.1]
}
}]
}
},
"raster": {
"tileSize": 256,
"tiles": ["http://localhost/example/{x}/{y}/{z}"],
"type": "raster"
}
},
"glyphs": "https://example.local/fonts/{fontstack}/{range}.pbf",
"sprites": "https://example.local/fonts/{fontstack}/{range}.pbf",
"layers": []
}
+29
View File
@@ -0,0 +1,29 @@
{
"id": "test-style",
"version": 8,
"name": "Test Style",
"metadata": {
"maputnik:renderer": "mlgljs"
},
"sources": {
"example": {
"type": "vector",
"data": {
"type": "FeatureCollection",
"features":[{
"type": "Feature",
"properties": {
"name": "Dinagat Islands"
},
"geometry":{
"type": "Point",
"coordinates": [125.6, 10.1]
}
}]
}
}
},
"glyphs": "https://example.local/fonts/{fontstack}/{range}.pbf",
"sprites": "https://example.local/fonts/{fontstack}/{range}.pbf",
"layers": []
}
+18
View File
@@ -0,0 +1,18 @@
{
"id": "test-style",
"version": 8,
"name": "Test Style",
"metadata": {
"maputnik:renderer": "mlgljs"
},
"sources": {
"raster": {
"tileSize": 256,
"tiles": ["http://localhost/example/{x}/{y}/{z}"],
"type": "raster"
}
},
"glyphs": "https://example.local/fonts/{fontstack}/{range}.pbf",
"sprites": "https://example.local/fonts/{fontstack}/{range}.pbf",
"layers": []
}
+37
View File
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
+20
View File
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
+35299 -10417
View File
File diff suppressed because it is too large Load Diff
+86 -78
View File
@@ -1,18 +1,22 @@
{
"name": "maputnik",
"version": "1.7.0",
"description": "A MapboxGL visual style editor",
"version": "2.0.0-pre.1",
"description": "A MapLibre GL visual style editor",
"main": "''",
"scripts": {
"stats": "webpack --config config/webpack.production.config.js --profile --json > stats.json",
"build": "webpack --config config/webpack.production.config.js --progress --profile --colors",
"profiling-build": "webpack --config config/webpack.profiling.config.js --progress --profile --colors",
"test": "cross-env NODE_ENV=test wdio config/wdio.conf.js",
"test-watch": "cross-env NODE_ENV=test wdio config/wdio.conf.js --watch",
"start": "webpack-dev-server --progress --profile --colors --config config/webpack.config.js",
"stats": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack --config config/webpack.production.config.js --progress=profile --json > stats.json",
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack --config config/webpack.production.config.js --progress=profile --color",
"profiling-build": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack --config config/webpack.profiling.config.js --progress=profile --color",
"test": "cypress run",
"cy:open": "cypress open",
"start": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack-dev-server --progress=profile --color --config config/webpack.config.js",
"start-prod": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack-dev-server --progress=profile --color --config config/webpack.production.config.js",
"start-sandbox": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack-dev-server --disable-host-check --host 0.0.0.0 --progress=profile --color --config config/webpack.production.config.js",
"lint-js": "eslint --ext js --ext jsx src test",
"lint-css": "stylelint \"src/styles/*.scss\"",
"lint": "npm run lint-js && npm run lint-css"
"lint": "npm run lint-js && npm run lint-css",
"storybook": "cross-env NODE_OPTIONS=--openssl-legacy-provider start-storybook -h 0.0.0.0 -p 6006",
"build-storybook": "cross-env NODE_OPTIONS=--openssl-legacy-provider build-storybook -o build/storybook"
},
"repository": {
"type": "git",
@@ -22,47 +26,50 @@
"license": "MIT",
"homepage": "https://github.com/maputnik/editor#readme",
"dependencies": {
"@babel/runtime": "^7.8.4",
"@babel/runtime": "^7.17.9",
"@mapbox/mapbox-gl-rtl-text": "^0.2.3",
"@mapbox/mapbox-gl-style-spec": "^13.12.0",
"@mdi/react": "^1.4.0",
"array-move": "^2.2.1",
"classnames": "^2.2.6",
"codemirror": "^5.52.0",
"color": "^3.1.2",
"detect-browser": "^5.0.0",
"file-saver": "^2.0.2",
"@maplibre/maplibre-gl-style-spec": "^17.0.1",
"@mdi/react": "^1.5.0",
"array-move": "^4.0.0",
"buffer": "^6.0.3",
"classnames": "^2.3.1",
"codemirror": "^5.65.2",
"color": "^4.2.3",
"detect-browser": "^5.3.0",
"file-saver": "^2.0.5",
"json-stringify-pretty-compact": "^3.0.0",
"json-to-ast": "^2.1.0",
"jsonlint": "github:josdejong/jsonlint#85a19d7",
"lodash": "^4.17.15",
"lodash": "^4.17.21",
"lodash.capitalize": "^4.2.1",
"lodash.clamp": "^4.0.3",
"lodash.clonedeep": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.isequal": "^4.5.0",
"lodash.throttle": "^4.1.1",
"mapbox-gl": "^1.9.1",
"mapbox-gl-inspect": "^1.3.1",
"maputnik-design": "github:maputnik/design#f7a2b4d",
"ol": "^6.3.1",
"ol-mapbox-style": "^6.0.1",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-accessible-accordion": "^3.0.1",
"react-aria-menubutton": "^6.3.0",
"react-aria-modal": "^4.0.0",
"maplibre-gl": "^2.4.0",
"maputnik-design": "github:maputnik/design#172b06c",
"ol": "^6.14.1",
"ol-mapbox-style": "^7.1.1",
"prop-types": "^15.8.1",
"react": "^16.0.0",
"react-accessible-accordion": "^4.0.0",
"react-aria-menubutton": "^7.0.3",
"react-aria-modal": "^4.0.1",
"react-autobind": "^1.0.6",
"react-autocomplete": "^1.8.1",
"react-collapse": "^5.0.1",
"react-color": "^2.18.0",
"react-dom": "^16.12.0",
"react-collapse": "^5.1.1",
"react-color": "^2.19.3",
"react-dom": "^16.0.0",
"react-file-reader-input": "^2.0.0",
"react-icon-base": "^2.1.2",
"react-icons": "^3.9.0",
"react-motion": "^0.5.2",
"react-sortable-hoc": "^1.11.0",
"react-icons": "^4.3.1",
"react-sortable-hoc": "^2.0.0",
"reconnecting-websocket": "^4.4.0",
"slugify": "^1.3.6",
"sass": "^1.50.0",
"slugify": "^1.6.5",
"string-hash": "^1.1.3",
"url": "^0.11.0"
},
"jshintConfig": {
@@ -94,7 +101,7 @@
"node": true,
"es6": true
},
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
@@ -111,54 +118,55 @@
}
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.6.3",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.6.3",
"@mdi/js": "^5.0.45",
"@wdio/cli": "^6.0.5",
"@wdio/local-runner": "^6.0.5",
"@wdio/mocha-framework": "^6.0.4",
"@wdio/selenium-standalone-service": "^6.0.4",
"@wdio/spec-reporter": "^6.0.4",
"@wdio/sync": "^6.0.1",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.1.0",
"babel-plugin-istanbul": "^6.0.0",
"@babel/core": "^7.17.9",
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-flow": "^7.16.7",
"@babel/preset-react": "^7.16.7",
"@mdi/js": "^6.6.96",
"@storybook/addon-a11y": "^6.4.20",
"@storybook/addon-actions": "^6.4.20",
"@storybook/addon-links": "^6.4.20",
"@storybook/addon-storysource": "^6.4.20",
"@storybook/addons": "^6.4.20",
"@storybook/react": "^6.4.20",
"@storybook/theming": "^6.4.20",
"@types/cors": "^2.8.17",
"@types/uuid": "^9.0.7",
"babel-loader": "^8.2.4",
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-static-fs": "^3.0.0",
"copy-webpack-plugin": "^5.1.1",
"copy-webpack-plugin": "^6.4.1",
"cors": "^2.8.5",
"cross-env": "^7.0.0",
"css-loader": "^3.4.2",
"eslint": "^6.8.0",
"eslint-plugin-react": "^7.18.3",
"express": "^4.17.1",
"file-loader": "^6.0.0",
"html-webpack-inline-svg-plugin": "^1.3.0",
"html-webpack-plugin": "^3.2.0",
"is-docker": "^2.0.0",
"cross-env": "^7.0.3",
"css-loader": "^5.2.7",
"cypress": "^13.6.1",
"eslint": "^8.12.0",
"eslint-plugin-react": "^7.29.4",
"express": "^4.17.3",
"html-webpack-inline-svg-plugin": "^2.3.0",
"html-webpack-plugin": "^4.5.2",
"istanbul": "^0.4.5",
"istanbul-lib-coverage": "^3.0.0",
"istanbul-lib-coverage": "^3.2.0",
"mkdirp": "^1.0.4",
"mocha": "^7.0.1",
"node-sass": "^4.13.1",
"react-hot-loader": "^4.12.19",
"sass-loader": "^8.0.2",
"selenium-standalone": "^6.17.0",
"style-loader": "^1.1.3",
"stylelint": "^13.3.0",
"stylelint-config-recommended-scss": "^4.2.0",
"stylelint-scss": "^3.14.2",
"mocha": "^9.2.2",
"postcss": "^8.4.12",
"react-hot-loader": "^4.13.0",
"sass-loader": "^10.2.1",
"style-loader": "^2.0.0",
"stylelint": "^14.6.1",
"stylelint-config-recommended-scss": "^6.0.0",
"stylelint-scss": "^4.2.0",
"svg-inline-loader": "^0.8.2",
"transform-loader": "^0.2.4",
"uuid": "^7.0.3",
"webdriverio": "^6.0.5",
"webpack": "^4.41.6",
"webpack-bundle-analyzer": "^3.6.0",
"typescript": "^4.9.5",
"uuid": "^8.3.2",
"webpack": "^4.46.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cleanup-plugin": "^0.5.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.8.1"
}
}
+5
View File
@@ -0,0 +1,5 @@
{
"container": {
"startScript": "start-sandbox"
}
}
+174 -96
View File
@@ -2,29 +2,31 @@ import autoBind from 'react-autobind';
import React from 'react'
import cloneDeep from 'lodash.clonedeep'
import clamp from 'lodash.clamp'
import buffer from 'buffer'
import get from 'lodash.get'
import {unset} from 'lodash'
import arrayMove from 'array-move'
import {arrayMoveMutable} from 'array-move'
import url from 'url'
import hash from "string-hash";
import MapboxGlMap from './map/MapboxGlMap'
import OpenLayersMap from './map/OpenLayersMap'
import LayerList from './layers/LayerList'
import LayerEditor from './layers/LayerEditor'
import Toolbar from './Toolbar'
import MapMaplibreGl from './MapMaplibreGl'
import MapOpenLayers from './MapOpenLayers'
import LayerList from './LayerList'
import LayerEditor from './LayerEditor'
import AppToolbar from './AppToolbar'
import AppLayout from './AppLayout'
import MessagePanel from './MessagePanel'
import MessagePanel from './AppMessagePanel'
import SettingsModal from './modals/SettingsModal'
import ExportModal from './modals/ExportModal'
import SourcesModal from './modals/SourcesModal'
import OpenModal from './modals/OpenModal'
import ShortcutsModal from './modals/ShortcutsModal'
import SurveyModal from './modals/SurveyModal'
import DebugModal from './modals/DebugModal'
import ModalSettings from './ModalSettings'
import ModalExport from './ModalExport'
import ModalSources from './ModalSources'
import ModalOpen from './ModalOpen'
import ModalShortcuts from './ModalShortcuts'
import ModalSurvey from './ModalSurvey'
import ModalDebug from './ModalDebug'
import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata'
import {latest, validate} from '@mapbox/mapbox-gl-style-spec'
import {latest, validate} from '@maplibre/maplibre-gl-style-spec'
import style from '../libs/style'
import { initialStyleUrl, loadStyleUrl, removeStyleQuerystring } from '../libs/urlopen'
import { undoMessages, redoMessages } from '../libs/diffmessage'
@@ -35,23 +37,10 @@ import LayerWatcher from '../libs/layerwatcher'
import tokens from '../config/tokens.json'
import isEqual from 'lodash.isequal'
import Debug from '../libs/debug'
import queryUtil from '../libs/query-util'
import {formatLayerId} from './util/format';
import {formatLayerId} from '../util/format';
import MapboxGl from 'mapbox-gl'
// Similar functionality as <https://github.com/mapbox/mapbox-gl-js/blob/7e30aadf5177486c2cfa14fe1790c60e217b5e56/src/util/mapbox.js>
function normalizeSourceURL (url, apiToken="") {
const matches = url.match(/^mapbox:\/\/(.*)/);
if (matches) {
// mapbox://mapbox.mapbox-streets-v7
return `https://api.mapbox.com/v4/${matches[1]}.json?secure&access_token=${apiToken}`
}
else {
return url;
}
}
// Buffer must be defined globally for @maplibre/maplibre-gl-style-spec validate() function to succeed.
window.Buffer = buffer.Buffer;
function setFetchAccessToken(url, mapStyle) {
const matchesTilehosting = url.match(/\.tilehosting\.com/);
@@ -147,7 +136,7 @@ export default class App extends React.Component {
{
key: "m",
handler: () => {
document.querySelector(".mapboxgl-canvas").focus();
document.querySelector(".maplibregl-canvas").focus();
}
},
{
@@ -189,7 +178,7 @@ export default class App extends React.Component {
console.log('Falling back to local storage for storing styles')
this.styleStore = new StyleStore()
}
this.styleStore.latestStyle(mapStyle => this.onStyleChanged(mapStyle))
this.styleStore.latestStyle(mapStyle => this.onStyleChanged(mapStyle, {initialLoad: true}))
if(Debug.enabled()) {
Debug.set("maputnik", "styleStore", this.styleStore);
@@ -231,7 +220,7 @@ export default class App extends React.Component {
survey: false,
debug: false,
},
mapboxGlDebugOptions: {
maplibreGlDebugOptions: {
showTileBoundaries: false,
showCollisionBoxes: false,
showOverdrawInspector: false,
@@ -301,7 +290,7 @@ export default class App extends React.Component {
// If we're changing renderer reset the map state.
if (
property === 'maputnik:renderer' &&
value !== get(this.state.mapStyle, ['metadata', 'maputnik:renderer'], 'mbgljs')
value !== get(this.state.mapStyle, ['metadata', 'maputnik:renderer'], 'mlgljs')
) {
this.setState({
mapState: 'map'
@@ -322,9 +311,14 @@ export default class App extends React.Component {
opts = {
save: true,
addRevision: true,
initialLoad: false,
...opts,
};
if (opts.initialLoad) {
this.getInitialStateFromUrl(newStyle);
}
const errors = validate(newStyle, latest) || [];
// The validate function doesn't give us errors for duplicate error with
@@ -435,14 +429,16 @@ export default class App extends React.Component {
if (opts.save) {
this.saveStyle(newStyle);
}
this.setState({
mapStyle: newStyle,
dirtyMapStyle: dirtyMapStyle,
errors: mappedErrors,
}, () => {
this.fetchSources();
this.setStateInUrl();
})
this.fetchSources();
}
onUndo = () => {
@@ -478,7 +474,7 @@ export default class App extends React.Component {
}
layers = layers.slice(0);
layers = arrayMove(layers, oldIndex, newIndex);
arrayMoveMutable(layers, oldIndex, newIndex);
this.onLayersChange(layers);
}
@@ -541,7 +537,7 @@ export default class App extends React.Component {
setMapState = (newState) => {
this.setState({
mapState: newState
})
}, this.setStateInUrl);
}
setDefaultValues = (styleObj) => {
@@ -551,7 +547,7 @@ export default class App extends React.Component {
...styleObj,
metadata: {
...styleObj.metadata,
'maputnik:renderer': 'mbgljs'
'maputnik:renderer': 'mlgljs'
}
}
return changedStyle
@@ -566,25 +562,20 @@ export default class App extends React.Component {
}
fetchSources() {
const sourceList = {...this.state.sources};
const sourceList = {};
for(let [key, val] of Object.entries(this.state.mapStyle.sources)) {
if(sourceList.hasOwnProperty(key)) {
continue;
}
if(
!this.state.sources.hasOwnProperty(key) &&
val.type === "vector" &&
val.hasOwnProperty("url")
) {
sourceList[key] = {
type: val.type,
layers: []
};
sourceList[key] = {
type: val.type,
layers: []
};
if(!this.state.sources.hasOwnProperty(key) && val.type === "vector" && val.hasOwnProperty("url")) {
let url = val.url;
try {
url = normalizeSourceURL(url, MapboxGl.accessToken);
} catch(err) {
console.warn("Failed to normalizeSourceURL: ", err);
}
try {
url = setFetchAccessToken(url, this.state.mapStyle)
@@ -595,29 +586,33 @@ export default class App extends React.Component {
fetch(url, {
mode: 'cors',
})
.then((response) => {
return response.json();
})
.then((json) => {
if(!json.hasOwnProperty("vector_layers")) {
return;
}
.then(response => response.json())
.then(json => {
// Create new objects before setState
const sources = Object.assign({}, this.state.sources);
if(!json.hasOwnProperty("vector_layers")) {
return;
}
for(let layer of json.vector_layers) {
sources[key].layers.push(layer.id)
}
// Create new objects before setState
const sources = Object.assign({}, {
[key]: this.state.sources[key],
});
console.debug("Updating source: "+key);
this.setState({
sources: sources
});
})
.catch((err) => {
console.error("Failed to process sources for '%s'", url, err);
})
for(let layer of json.vector_layers) {
sources[key].layers.push(layer.id)
}
console.debug("Updating source: "+key);
this.setState({
sources: sources
});
})
.catch(err => {
console.error("Failed to process sources for '%s'", url, err);
});
}
else {
sourceList[key] = this.state.sources[key] || this.state.mapStyle.sources[key];
}
}
@@ -631,7 +626,7 @@ export default class App extends React.Component {
_getRenderer () {
const metadata = this.state.mapStyle.metadata || {};
return metadata['maputnik:renderer'] || 'mbgljs';
return metadata['maputnik:renderer'] || 'mlgljs';
}
onMapChange = (mapView) => {
@@ -663,16 +658,16 @@ export default class App extends React.Component {
// Check if OL code has been loaded?
if(renderer === 'ol') {
mapElement = <OpenLayersMap
mapElement = <MapOpenLayers
{...mapProps}
onChange={this.onMapChange}
debugToolbox={this.state.openlayersDebugOptions.debugToolbox}
onLayerSelect={this.onLayerSelect}
/>
} else {
mapElement = <MapboxGlMap {...mapProps}
mapElement = <MapMaplibreGl {...mapProps}
onChange={this.onMapChange}
options={this.state.mapboxGlDebugOptions}
options={this.state.maplibreGlDebugOptions}
inspectModeEnabled={this.state.mapState === "inspect"}
highlightedLayer={this.state.mapStyle.layers[this.state.selectedLayerIndex]}
onLayerSelect={this.onLayerSelect} />
@@ -685,15 +680,98 @@ export default class App extends React.Component {
const elementStyle = {};
if (filterName) {
elementStyle.filter = `url('#${filterName}')`;
};
}
return <div style={elementStyle} className="maputnik-map__container">
{mapElement}
</div>
}
setStateInUrl = () => {
const {mapState, mapStyle, isOpen} = this.state;
const {selectedLayerIndex} = this.state;
const url = new URL(location.href);
const hashVal = hash(JSON.stringify(mapStyle));
url.searchParams.set("layer", `${hashVal}~${selectedLayerIndex}`);
const openModals = Object.entries(isOpen)
.map(([key, val]) => (val === true ? key : null))
.filter(val => val !== null);
if (openModals.length > 0) {
url.searchParams.set("modal", openModals.join(","));
}
else {
url.searchParams.delete("modal");
}
if (mapState === "map") {
url.searchParams.delete("view");
}
else if (mapState === "inspect") {
url.searchParams.set("view", "inspect");
}
history.replaceState({selectedLayerIndex}, "Maputnik", url.href);
}
getInitialStateFromUrl = (mapStyle) => {
const url = new URL(location.href);
const modalParam = url.searchParams.get("modal");
if (modalParam && modalParam !== "") {
const modals = modalParam.split(",");
const modalObj = {};
modals.forEach(modalName => {
modalObj[modalName] = true;
});
this.setState({
isOpen: {
...this.state.isOpen,
...modalObj,
}
});
}
const view = url.searchParams.get("view");
if (view && view !== "") {
this.setMapState(view);
}
const path = url.searchParams.get("layer");
if (path) {
try {
const parts = path.split("~");
const [hashVal, selectedLayerIndex] = [
parts[0],
parseInt(parts[1], 10),
];
let valid = true;
if (hashVal !== "-") {
const currentHashVal = hash(JSON.stringify(mapStyle));
if (currentHashVal !== parseInt(hashVal, 10)) {
valid = false;
}
}
if (valid) {
this.setState({
selectedLayerIndex,
selectedLayerOriginalId: mapStyle.layers[selectedLayerIndex].id,
});
}
}
catch (err) {
console.warn(err);
}
}
}
onLayerSelect = (index) => {
this.setState({ selectedLayerIndex: index })
this.setState({
selectedLayerIndex: index,
selectedLayerOriginalId: this.state.mapStyle.layers[index].id,
}, this.setStateInUrl);
}
setModal(modalName, value) {
@@ -706,7 +784,7 @@ export default class App extends React.Component {
...this.state.isOpen,
[modalName]: value
}
})
}, this.setStateInUrl)
}
toggleModal(modalName) {
@@ -722,10 +800,10 @@ export default class App extends React.Component {
});
}
onChangeMaboxGlDebug = (key, value) => {
onChangeMaplibreGlDebug = (key, value) => {
this.setState({
mapboxGlDebugOptions: {
...this.state.mapboxGlDebugOptions,
maplibreGlDebugOptions: {
...this.state.maplibreGlDebugOptions,
[key]: value,
}
});
@@ -736,7 +814,7 @@ export default class App extends React.Component {
const selectedLayer = layers.length > 0 ? layers[this.state.selectedLayerIndex] : null
const metadata = this.state.mapStyle.metadata || {}
const toolbar = <Toolbar
const toolbar = <AppToolbar
renderer={this._getRenderer()}
mapState={this.state.mapState}
mapStyle={this.state.mapStyle}
@@ -762,7 +840,7 @@ export default class App extends React.Component {
/>
const layerEditor = selectedLayer ? <LayerEditor
key={selectedLayer.id}
key={this.state.selectedLayerOriginalId}
layer={selectedLayer}
layerIndex={this.state.selectedLayerIndex}
isFirstLayer={this.state.selectedLayerIndex < 1}
@@ -790,22 +868,22 @@ export default class App extends React.Component {
const modals = <div>
<DebugModal
<ModalDebug
renderer={this._getRenderer()}
mapboxGlDebugOptions={this.state.mapboxGlDebugOptions}
maplibreGlDebugOptions={this.state.maplibreGlDebugOptions}
openlayersDebugOptions={this.state.openlayersDebugOptions}
onChangeMaboxGlDebug={this.onChangeMaboxGlDebug}
onChangeMaplibreGlDebug={this.onChangeMaplibreGlDebug}
onChangeOpenlayersDebug={this.onChangeOpenlayersDebug}
isOpen={this.state.isOpen.debug}
onOpenToggle={this.toggleModal.bind(this, 'debug')}
mapView={this.state.mapView}
/>
<ShortcutsModal
<ModalShortcuts
ref={(el) => this.shortcutEl = el}
isOpen={this.state.isOpen.shortcuts}
onOpenToggle={this.toggleModal.bind(this, 'shortcuts')}
/>
<SettingsModal
<ModalSettings
mapStyle={this.state.mapStyle}
onStyleChanged={this.onStyleChanged}
onChangeMetadataProperty={this.onChangeMetadataProperty}
@@ -813,24 +891,24 @@ export default class App extends React.Component {
onOpenToggle={this.toggleModal.bind(this, 'settings')}
openlayersDebugOptions={this.state.openlayersDebugOptions}
/>
<ExportModal
<ModalExport
mapStyle={this.state.mapStyle}
onStyleChanged={this.onStyleChanged}
isOpen={this.state.isOpen.export}
onOpenToggle={this.toggleModal.bind(this, 'export')}
/>
<OpenModal
<ModalOpen
isOpen={this.state.isOpen.open}
onStyleOpen={this.openStyle}
onOpenToggle={this.toggleModal.bind(this, 'open')}
/>
<SourcesModal
<ModalSources
mapStyle={this.state.mapStyle}
onStyleChanged={this.onStyleChanged}
isOpen={this.state.isOpen.sources}
onOpenToggle={this.toggleModal.bind(this, 'sources')}
/>
<SurveyModal
<ModalSurvey
isOpen={this.state.isOpen.survey}
onOpenToggle={this.toggleModal.bind(this, 'survey')}
/>
@@ -1,8 +1,8 @@
import React from 'react'
import PropTypes from 'prop-types'
import {formatLayerId} from './util/format';
import {formatLayerId} from '../util/format';
class MessagePanel extends React.Component {
export default class AppMessagePanel extends React.Component {
static propTypes = {
errors: PropTypes.array,
infos: PropTypes.array,
@@ -60,5 +60,3 @@ class MessagePanel extends React.Component {
}
}
export default MessagePanel
@@ -101,7 +101,7 @@ class ToolbarAction extends React.Component {
}
}
export default class Toolbar extends React.Component {
export default class AppToolbar extends React.Component {
static propTypes = {
mapStyle: PropTypes.object.isRequired,
inspectModeEnabled: PropTypes.bool.isRequired,
@@ -131,35 +131,51 @@ export default class Toolbar extends React.Component {
this.props.onSetMapState(val);
}
onSkip = (target) => {
if (target === "map") {
document.querySelector(".maplibregl-canvas").focus();
}
else {
const el = document.querySelector("#skip-target-"+target);
el.focus();
}
}
render() {
const views = [
{
id: "map",
group: "general",
title: "Map",
},
{
id: "inspect",
group: "general",
title: "Inspect",
disabled: this.props.renderer !== 'mbgljs',
disabled: this.props.renderer === 'ol',
},
{
id: "filter-deuteranopia",
title: "Map (deuteranopia)",
group: "color-accessibility",
title: "Deuteranopia filter",
disabled: !colorAccessibilityFiltersEnabled,
},
{
id: "filter-protanopia",
title: "Map (protanopia)",
group: "color-accessibility",
title: "Protanopia filter",
disabled: !colorAccessibilityFiltersEnabled,
},
{
id: "filter-tritanopia",
title: "Map (tritanopia)",
group: "color-accessibility",
title: "Tritanopia filter",
disabled: !colorAccessibilityFiltersEnabled,
},
{
id: "filter-achromatopsia",
title: "Map (achromatopsia)",
group: "color-accessibility",
title: "Achromatopsia filter",
disabled: !colorAccessibilityFiltersEnabled,
},
];
@@ -168,19 +184,38 @@ export default class Toolbar extends React.Component {
return view.id === this.props.mapState;
});
return <div className='maputnik-toolbar'>
return <nav className='maputnik-toolbar'>
<div className="maputnik-toolbar__inner">
<div
className="maputnik-toolbar-logo-container"
>
<a className="maputnik-toolbar-skip" href="#skip-menu">
Skip navigation
</a>
{/* Keyboard accessible quick links */}
<button
data-wd-key="root:skip:layer-list"
className="maputnik-toolbar-skip"
onClick={e => this.onSkip("layer-list")}
>
Layers list
</button>
<button
data-wd-key="root:skip:layer-editor"
className="maputnik-toolbar-skip"
onClick={e => this.onSkip("layer-editor")}
>
Layer editor
</button>
<button
data-wd-key="root:skip:map-view"
className="maputnik-toolbar-skip"
onClick={e => this.onSkip("map")}
>
Map view
</button>
<a
href="https://github.com/maputnik/editor"
rel="noopener noreferrer"
target="_blank"
className="maputnik-toolbar-logo"
target="blank"
rel="noreferrer noopener"
href="https://github.com/maputnik/editor"
>
<span dangerouslySetInnerHTML={{__html: logoImage}} />
<h1>
@@ -189,7 +224,7 @@ export default class Toolbar extends React.Component {
</h1>
</a>
</div>
<div className="maputnik-toolbar__actions">
<div className="maputnik-toolbar__actions" role="navigation" aria-label="Toolbar">
<ToolbarAction wdKey="nav:open" onClick={this.props.onToggleModal.bind(this, 'open')}>
<MdOpenInBrowser />
<IconText>Open</IconText>
@@ -209,16 +244,30 @@ export default class Toolbar extends React.Component {
<ToolbarSelect wdKey="nav:inspect">
<MdFindInPage />
<IconText>View </IconText>
<select onChange={(e) => this.handleSelection(e.target.value)} value={currentView.id}>
{views.map((item) => {
return (
<option key={item.id} value={item.id} disabled={item.disabled}>
{item.title}
</option>
);
})}
</select>
<label>View
<select
className="maputnik-select"
onChange={(e) => this.handleSelection(e.target.value)}
value={currentView.id}
>
{views.filter(v => v.group === "general").map((item) => {
return (
<option key={item.id} value={item.id} disabled={item.disabled}>
{item.title}
</option>
);
})}
<optgroup label="Color accessibility">
{views.filter(v => v.group === "color-accessibility").map((item) => {
return (
<option key={item.id} value={item.id} disabled={item.disabled}>
{item.title}
</option>
);
})}
</optgroup>
</select>
</label>
</ToolbarSelect>
<ToolbarLink href={"https://github.com/maputnik/editor/wiki"}>
@@ -231,6 +280,6 @@ export default class Toolbar extends React.Component {
</ToolbarLinkHighlighted>
</div>
</div>
</div>
</nav>
}
}
+103
View File
@@ -0,0 +1,103 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import FieldDocLabel from './FieldDocLabel'
import Doc from './Doc'
/** Wrap a component with a label */
export default class Block extends React.Component {
static propTypes = {
"data-wd-key": PropTypes.string,
label: PropTypes.oneOfType([
PropTypes.string,
PropTypes.element,
]),
action: PropTypes.element,
children: PropTypes.node.isRequired,
style: PropTypes.object,
onChange: PropTypes.func,
fieldSpec: PropTypes.object,
wideMode: PropTypes.bool,
error: PropTypes.array,
}
constructor (props) {
super(props);
this.state = {
showDoc: false,
}
}
onChange(e) {
const value = e.target.value
return this.props.onChange(value === "" ? undefined : value)
}
onToggleDoc = (val) => {
this.setState({
showDoc: val
});
}
/**
* Some fields for example <InputColor/> bind click events inside the element
* to close the picker. This in turn propagates to the <label/> element
* causing the picker to reopen. This causes a scenario where the picker can
* never be closed once open.
*/
onLabelClick = (event) => {
const el = event.nativeEvent.target;
const nativeEvent = event.nativeEvent;
const contains = this._blockEl.contains(el);
if (event.nativeEvent.target.nodeName !== "INPUT" && !contains) {
event.stopPropagation();
}
event.preventDefault();
}
render() {
const errors = [].concat(this.props.error || []);
return <label style={this.props.style}
data-wd-key={this.props["data-wd-key"]}
className={classnames({
"maputnik-input-block": true,
"maputnik-input-block--wide": this.props.wideMode,
"maputnik-action-block": this.props.action
})}
onClick={this.onLabelClick}
>
{this.props.fieldSpec &&
<div className="maputnik-input-block-label">
<FieldDocLabel
label={this.props.label}
onToggleDoc={this.onToggleDoc}
fieldSpec={this.props.fieldSpec}
/>
</div>
}
{!this.props.fieldSpec &&
<div className="maputnik-input-block-label">
{this.props.label}
</div>
}
<div className="maputnik-input-block-action">
{this.props.action}
</div>
<div className="maputnik-input-block-content" ref={el => this._blockEl = el}>
{this.props.children}
</div>
{this.props.fieldSpec &&
<div
className="maputnik-doc-inline"
style={{display: this.state.showDoc ? '' : 'none'}}
>
<Doc fieldSpec={this.props.fieldSpec} />
</div>
}
</label>
}
}
@@ -1,10 +1,10 @@
import React from 'react'
import PropTypes from 'prop-types'
import Collapse from 'react-collapse'
import { Collapse as ReactCollapse } from 'react-collapse'
import accessibility from '../../libs/accessibility'
export default class CollapseAlt extends React.Component {
export default class Collapse extends React.Component {
static propTypes = {
isActive: PropTypes.bool.isRequired,
children: PropTypes.element.isRequired
@@ -24,9 +24,9 @@ export default class CollapseAlt extends React.Component {
}
else {
return (
<Collapse isOpened={this.props.isActive}>
<ReactCollapse isOpened={this.props.isActive}>
{this.props.children}
</Collapse>
</ReactCollapse>
)
}
}
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
export default class SpecDoc extends React.Component {
export default class Doc extends React.Component {
static propTypes = {
fieldSpec: PropTypes.object.isRequired,
}
+21
View File
@@ -0,0 +1,21 @@
import React from 'react'
import PropTypes from 'prop-types'
import Block from './Block'
import InputArray from './InputArray'
import Fieldset from './Fieldset'
export default class FieldArray extends React.Component {
static propTypes = {
...InputArray.propTypes,
name: PropTypes.string,
}
render() {
const {props} = this;
return <Fieldset label={props.label}>
<InputArray {...props} />
</Fieldset>
}
}
+20
View File
@@ -0,0 +1,20 @@
import React from 'react'
import PropTypes from 'prop-types'
import Block from './Block'
import InputAutocomplete from './InputAutocomplete'
export default class FieldAutocomplete extends React.Component {
static propTypes = {
...InputAutocomplete.propTypes,
}
render() {
const {props} = this;
return <Block label={props.label}>
<InputAutocomplete {...props} />
</Block>
}
}
+20
View File
@@ -0,0 +1,20 @@
import React from 'react'
import PropTypes from 'prop-types'
import Block from './Block'
import InputCheckbox from './InputCheckbox'
export default class FieldCheckbox extends React.Component {
static propTypes = {
...InputCheckbox.propTypes,
}
render() {
const {props} = this;
return <Block label={this.props.label}>
<InputCheckbox {...props} />
</Block>
}
}
+20
View File
@@ -0,0 +1,20 @@
import React from 'react'
import PropTypes from 'prop-types'
import Block from './Block'
import InputColor from './InputColor'
export default class FieldColor extends React.Component {
static propTypes = {
...InputColor.propTypes,
}
render() {
const {props} = this;
return <Block label={props.label}>
<InputColor {...props} />
</Block>
}
}
+31
View File
@@ -0,0 +1,31 @@
import React from 'react'
import PropTypes from 'prop-types'
import Block from './Block'
import InputString from './InputString'
export default class FieldComment extends React.Component {
static propTypes = {
value: PropTypes.string,
onChange: PropTypes.func.isRequired,
}
render() {
const fieldSpec = {
doc: "Comments for the current layer. This is non-standard and not in the spec."
};
return <Block
label={"Comments"}
fieldSpec={fieldSpec}
data-wd-key="layer-comment"
>
<InputString
multi={true}
value={this.props.value}
onChange={this.props.onChange}
default="Comment..."
/>
</Block>
}
}
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import {MdInfoOutline, MdHighlightOff} from 'react-icons/md'
export default class DocLabel extends React.Component {
export default class FieldDocLabel extends React.Component {
static propTypes = {
label: PropTypes.oneOfType([
PropTypes.object,
+21
View File
@@ -0,0 +1,21 @@
import React from 'react'
import PropTypes from 'prop-types'
import Block from './Block'
import InputDynamicArray from './InputDynamicArray'
import Fieldset from './Fieldset'
export default class FieldDynamicArray extends React.Component {
static propTypes = {
...InputDynamicArray.propTypes,
name: PropTypes.string,
}
render() {
const {props} = this;
return <Fieldset label={props.label}>
<InputDynamicArray {...props} />
</Fieldset>
}
}
+20
View File
@@ -0,0 +1,20 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputEnum from './InputEnum'
import Block from './Block';
import Fieldset from './Fieldset';
export default class FieldEnum extends React.Component {
static propTypes = {
...InputEnum.propTypes,
}
render() {
const {props} = this;
return <Fieldset label={props.label}>
<InputEnum {...props} />
</Fieldset>
}
}
@@ -5,7 +5,7 @@ import SpecProperty from './_SpecProperty'
import DataProperty from './_DataProperty'
import ZoomProperty from './_ZoomProperty'
import ExpressionProperty from './_ExpressionProperty'
import {function as styleFunction} from '@mapbox/mapbox-gl-style-spec';
import {function as styleFunction} from '@maplibre/maplibre-gl-style-spec';
import {findDefaultFromSpec} from '../util/spec-helper';
@@ -106,7 +106,7 @@ function getDataType (value, fieldSpec={}) {
/** Supports displaying spec field for zoom function objects
* https://www.mapbox.com/mapbox-gl-style-spec/#types-function-zoom-property
*/
export default class FunctionSpecProperty extends React.Component {
export default class FieldFunction extends React.Component {
static propTypes = {
onChange: PropTypes.func.isRequired,
fieldName: PropTypes.string.isRequired,
@@ -200,12 +200,37 @@ export default class FunctionSpecProperty extends React.Component {
}
makeZoomFunction = () => {
const zoomFunc = {
stops: [
[6, this.props.value || findDefaultFromSpec(this.props.fieldSpec)],
[10, this.props.value || findDefaultFromSpec(this.props.fieldSpec)]
]
const {value} = this.props;
let zoomFunc;
if (typeof(value) === "object") {
if (value.stops) {
zoomFunc = {
base: value.base,
stops: value.stops.map(stop => {
return [stop[0].zoom, stop[1] || findDefaultFromSpec(this.props.fieldSpec)];
})
}
}
else {
zoomFunc = {
base: value.base,
stops: [
[6, findDefaultFromSpec(this.props.fieldSpec)],
[10, findDefaultFromSpec(this.props.fieldSpec)]
]
}
}
}
else {
zoomFunc = {
stops: [
[6, value || findDefaultFromSpec(this.props.fieldSpec)],
[10, value || findDefaultFromSpec(this.props.fieldSpec)]
]
}
}
this.props.onChange(this.props.fieldName, zoomFunc)
}
@@ -258,14 +283,44 @@ export default class FunctionSpecProperty extends React.Component {
makeDataFunction = () => {
const functionType = this.getFieldFunctionType(this.props.fieldSpec);
const stopValue = functionType === 'categorical' ? '' : 0;
const dataFunc = {
property: "",
type: functionType,
stops: [
[{zoom: 6, value: stopValue}, this.props.value || findDefaultFromSpec(this.props.fieldSpec)],
[{zoom: 10, value: stopValue}, this.props.value || findDefaultFromSpec(this.props.fieldSpec)]
]
const {value} = this.props;
let dataFunc;
if (typeof(value) === "object") {
if (value.stops) {
dataFunc = {
property: "",
type: functionType,
base: value.base,
stops: value.stops.map(stop => {
return [{zoom: stop[0], value: stopValue}, stop[1] || findDefaultFromSpec(this.props.fieldSpec)];
})
}
}
else {
dataFunc = {
property: "",
type: functionType,
base: value.base,
stops: [
[{zoom: 6, value: stopValue}, findDefaultFromSpec(this.props.fieldSpec)],
[{zoom: 10, value: stopValue}, findDefaultFromSpec(this.props.fieldSpec)]
]
}
}
}
else {
dataFunc = {
property: "",
type: functionType,
base: value.base,
stops: [
[{zoom: 6, value: stopValue}, this.props.value || findDefaultFromSpec(this.props.fieldSpec)],
[{zoom: 10, value: stopValue}, this.props.value || findDefaultFromSpec(this.props.fieldSpec)]
]
}
}
this.props.onChange(this.props.fieldName, dataFunc)
}
@@ -310,11 +365,13 @@ export default class FunctionSpecProperty extends React.Component {
value={this.props.value}
onDeleteStop={this.deleteStop}
onAddStop={this.addStop}
onExpressionClick={this.makeExpression}
onChangeToDataFunction={this.makeDataFunction}
onExpressionClick={this.makeExpression}
/>
)
}
else if (dataType === "data_function") {
// TODO: Rename to FieldFunction **this file** shouldn't be called that
specField = (
<DataProperty
errors={this.props.errors}
@@ -325,7 +382,8 @@ export default class FunctionSpecProperty extends React.Component {
value={this.props.value}
onDeleteStop={this.deleteStop}
onAddStop={this.addStop}
onExpressionClick={this.makeExpression}
onChangeToZoomFunction={this.makeZoomFunction}
onExpressionClick={this.makeExpression}
/>
)
}
@@ -339,8 +397,8 @@ export default class FunctionSpecProperty extends React.Component {
fieldSpec={this.props.fieldSpec}
value={this.props.value}
onZoomClick={this.makeZoomFunction}
onDataClick={this.makeDataFunction}
onExpressionClick={this.makeExpression}
onDataClick={this.makeDataFunction}
onExpressionClick={this.makeExpression}
/>
)
}
+27
View File
@@ -0,0 +1,27 @@
import React from 'react'
import PropTypes from 'prop-types'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import Block from './Block'
import InputString from './InputString'
export default class FieldId extends React.Component {
static propTypes = {
value: PropTypes.string.isRequired,
wdKey: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
error: PropTypes.object,
}
render() {
return <Block label={"ID"} fieldSpec={latest.layer.id}
data-wd-key={this.props.wdKey}
error={this.props.error}
>
<InputString
value={this.props.value}
onInput={this.props.onChange}
/>
</Block>
}
}
+16
View File
@@ -0,0 +1,16 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputJson from './InputJson'
export default class FieldJson extends React.Component {
static propTypes = {
...InputJson.propTypes,
}
render() {
const {props} = this;
return <InputJson {...props} />
}
}
+30
View File
@@ -0,0 +1,30 @@
import React from 'react'
import PropTypes from 'prop-types'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import Block from './Block'
import InputNumber from './InputNumber'
export default class FieldMaxZoom extends React.Component {
static propTypes = {
value: PropTypes.number,
onChange: PropTypes.func.isRequired,
error: PropTypes.object,
}
render() {
return <Block label={"Max Zoom"} fieldSpec={latest.layer.maxzoom}
error={this.props.error}
data-wd-key="max-zoom"
>
<InputNumber
allowRange={true}
value={this.props.value}
onChange={this.props.onChange}
min={latest.layer.maxzoom.minimum}
max={latest.layer.maxzoom.maximum}
default={latest.layer.maxzoom.maximum}
/>
</Block>
}
}
+30
View File
@@ -0,0 +1,30 @@
import React from 'react'
import PropTypes from 'prop-types'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import Block from './Block'
import InputNumber from './InputNumber'
export default class FieldMinZoom extends React.Component {
static propTypes = {
value: PropTypes.number,
onChange: PropTypes.func.isRequired,
error: PropTypes.object,
}
render() {
return <Block label={"Min Zoom"} fieldSpec={latest.layer.minzoom}
error={this.props.error}
data-wd-key="min-zoom"
>
<InputNumber
allowRange={true}
value={this.props.value}
onChange={this.props.onChange}
min={latest.layer.minzoom.minimum}
max={latest.layer.minzoom.maximum}
default={latest.layer.minzoom.minimum}
/>
</Block>
}
}
+21
View File
@@ -0,0 +1,21 @@
import React from 'react'
import PropTypes from 'prop-types'
import Block from './Block'
import InputMultiInput from './InputMultiInput'
import Fieldset from './Fieldset'
export default class FieldMultiInput extends React.Component {
static propTypes = {
...InputMultiInput.propTypes,
}
render() {
const {props} = this;
return <Fieldset label={props.label}>
<InputMultiInput {...props} />
</Fieldset>
}
}
+19
View File
@@ -0,0 +1,19 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputNumber from './InputNumber'
import Block from './Block'
export default class FieldNumber extends React.Component {
static propTypes = {
...InputNumber.propTypes,
}
render() {
const {props} = this;
return <Block label={props.label}>
<InputNumber {...props} />
</Block>
}
}
+20
View File
@@ -0,0 +1,20 @@
import React from 'react'
import PropTypes from 'prop-types'
import Block from './Block'
import InputSelect from './InputSelect'
export default class FieldSelect extends React.Component {
static propTypes = {
...InputSelect.propTypes,
}
render() {
const {props} = this;
return <Block label={props.label}>
<InputSelect {...props}/>
</Block>
}
}
+36
View File
@@ -0,0 +1,36 @@
import React from 'react'
import PropTypes from 'prop-types'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import Block from './Block'
import InputAutocomplete from './InputAutocomplete'
export default class FieldSource extends React.Component {
static propTypes = {
value: PropTypes.string,
wdKey: PropTypes.string,
onChange: PropTypes.func,
sourceIds: PropTypes.array,
error: PropTypes.object,
}
static defaultProps = {
onChange: () => {},
sourceIds: [],
}
render() {
return <Block
label={"Source"}
fieldSpec={latest.layer.source}
error={this.props.error}
data-wd-key={this.props.wdKey}
>
<InputAutocomplete
value={this.props.value}
onChange={this.props.onChange}
options={this.props.sourceIds.map(src => [src, src])}
/>
</Block>
}
}
+34
View File
@@ -0,0 +1,34 @@
import React from 'react'
import PropTypes from 'prop-types'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import Block from './Block'
import InputAutocomplete from './InputAutocomplete'
export default class FieldSourceLayer extends React.Component {
static propTypes = {
value: PropTypes.string,
onChange: PropTypes.func,
sourceLayerIds: PropTypes.array,
isFixed: PropTypes.bool,
}
static defaultProps = {
onChange: () => {},
sourceLayerIds: [],
isFixed: false
}
render() {
return <Block label={"Source Layer"} fieldSpec={latest.layer['source-layer']}
data-wd-key="layer-source-layer"
>
<InputAutocomplete
keepMenuWithinWindowBounds={!!this.props.isFixed}
value={this.props.value}
onChange={this.props.onChange}
options={this.props.sourceLayerIds.map(l => [l, l])}
/>
</Block>
}
}
+20
View File
@@ -0,0 +1,20 @@
import React from 'react'
import PropTypes from 'prop-types'
import Block from './Block'
import InputString from './InputString'
export default class FieldString extends React.Component {
static propTypes = {
...InputString.propTypes,
name: PropTypes.string,
}
render() {
const {props} = this;
return <Block label={props.label}>
<InputString {...props} />
</Block>
}
}
+52
View File
@@ -0,0 +1,52 @@
import React from 'react'
import PropTypes from 'prop-types'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import Block from './Block'
import InputSelect from './InputSelect'
import InputString from './InputString'
export default class FieldType extends React.Component {
static propTypes = {
value: PropTypes.string.isRequired,
wdKey: PropTypes.string,
onChange: PropTypes.func.isRequired,
error: PropTypes.object,
disabled: PropTypes.bool,
}
static defaultProps = {
disabled: false,
}
render() {
return <Block label={"Type"} fieldSpec={latest.layer.type}
data-wd-key={this.props.wdKey}
error={this.props.error}
>
{this.props.disabled &&
<InputString
value={this.props.value}
disabled={true}
/>
}
{!this.props.disabled &&
<InputSelect
options={[
['background', 'Background'],
['fill', 'Fill'],
['line', 'Line'],
['symbol', 'Symbol'],
['raster', 'Raster'],
['circle', 'Circle'],
['fill-extrusion', 'Fill Extrusion'],
['hillshade', 'Hillshade'],
['heatmap', 'Heatmap'],
]}
onChange={this.props.onChange}
value={this.props.value}
/>
}
</Block>
}
}
+22
View File
@@ -0,0 +1,22 @@
import React, {Fragment} from 'react'
import PropTypes from 'prop-types'
import InputUrl from './InputUrl'
import Block from './Block'
export default class FieldUrl extends React.Component {
static propTypes = {
...InputUrl.propTypes,
}
render () {
const {props} = this;
return (
<Block label={this.props.label}>
<InputUrl {...props} />
</Block>
);
}
}
+58
View File
@@ -0,0 +1,58 @@
import React from 'react'
import PropTypes from 'prop-types'
import FieldDocLabel from './FieldDocLabel'
import Doc from './Doc'
let IDX = 0;
export default class Fieldset extends React.Component {
constructor (props) {
super(props);
this._labelId = `fieldset_label_${(IDX++)}`;
this.state = {
showDoc: false,
}
}
onToggleDoc = (val) => {
this.setState({
showDoc: val
});
}
render () {
const {props} = this;
return <div className="maputnik-input-block" role="group" aria-labelledby={this._labelId}>
{this.props.fieldSpec &&
<div className="maputnik-input-block-label">
<FieldDocLabel
label={this.props.label}
onToggleDoc={this.onToggleDoc}
fieldSpec={this.props.fieldSpec}
/>
</div>
}
{!this.props.fieldSpec &&
<div className="maputnik-input-block-label">
{props.label}
</div>
}
<div className="maputnik-input-block-action">
{this.props.action}
</div>
<div className="maputnik-input-block-content">
{props.children}
</div>
{this.props.fieldSpec &&
<div
className="maputnik-doc-inline"
style={{display: this.state.showDoc ? '' : 'none'}}
>
<Doc fieldSpec={this.props.fieldSpec} />
</div>
}
</div>
}
}
@@ -1,17 +1,17 @@
import React from 'react'
import PropTypes from 'prop-types'
import { combiningFilterOps } from '../../libs/filterops.js'
import { combiningFilterOps } from '../libs/filterops.js'
import {mdiTableRowPlusAfter} from '@mdi/js';
import {isEqual} from 'lodash';
import {latest, validate, migrate} from '@mapbox/mapbox-gl-style-spec'
import DocLabel from '../fields/DocLabel'
import SelectInput from '../inputs/SelectInput'
import InputBlock from '../inputs/InputBlock'
import {latest, migrate, convertFilter} from '@maplibre/maplibre-gl-style-spec'
import InputSelect from './InputSelect'
import Block from './Block'
import SingleFilterEditor from './SingleFilterEditor'
import FilterEditorBlock from './FilterEditorBlock'
import Button from '../Button'
import SpecDoc from '../inputs/SpecDoc'
import ExpressionProperty from '../fields/_ExpressionProperty';
import InputButton from './InputButton'
import Doc from './Doc'
import ExpressionProperty from './_ExpressionProperty';
import {mdiFunctionVariant} from '@mdi/js';
@@ -42,7 +42,7 @@ function createStyleFromFilter (filter) {
"id": "tmp",
"version": 8,
"name": "Empty Style",
"metadata": {"maputnik:renderer": "mbgljs"},
"metadata": {"maputnik:renderer": "mlgljs"},
"sources": {
"tmp": {
"type": "geojson",
@@ -62,24 +62,19 @@ function createStyleFromFilter (filter) {
};
}
/**
* This is doing way more work than we need it to, however validating a whole
* style if the only thing that's exported from mapbox-gl-style-spec at the
* moment. Not really an issue though as it take ~0.1ms to calculate.
*/
const FILTER_OPS = [
"all",
"any",
"none"
];
// If we convert a filter that is an expression to an expression it'll remain the same in value
function checkIfSimpleFilter (filter) {
if (!filter || !combiningFilterOps.includes(filter[0])) {
return false;
if (filter.length === 1 && FILTER_OPS.includes(filter[0])) {
return true;
}
// Because "none" isn't supported by the next expression syntax we can test
// with ["none", ...] because it'll return false if it's a new style
// expression.
const moddedFilter = ["none", ...filter.slice(1)];
const tmpStyle = createStyleFromFilter(moddedFilter)
const errors = validate(tmpStyle);
return (errors.length < 1);
const expression = convertFilter(filter);
return !isEqual(expression, filter);
}
function hasCombiningFilter(filter) {
@@ -94,7 +89,7 @@ function hasNestedCombiningFilter(filter) {
return false
}
export default class CombiningFilterEditor extends React.Component {
export default class FilterEditor extends React.Component {
static propTypes = {
/** Properties of the vector layer and the available fields */
properties: PropTypes.object,
@@ -192,14 +187,15 @@ export default class CombiningFilterEditor extends React.Component {
<p>
Nested filters are not supported.
</p>
<Button
<InputButton
onClick={this.makeExpression}
title="Convert to expression"
>
<svg style={{marginRight: "0.2em", width:"14px", height:"14px", verticalAlign: "middle"}} viewBox="0 0 24 24">
<path fill="currentColor" d={mdiFunctionVariant} />
</svg>
Upgrade to expression
</Button>
</InputButton>
</div>
}
else if (displaySimpleFilter) {
@@ -209,14 +205,15 @@ export default class CombiningFilterEditor extends React.Component {
const actions = (
<div>
<Button
<InputButton
onClick={this.makeExpression}
title="Convert to expression"
className="maputnik-make-zoom-function"
>
<svg style={{width:"14px", height:"14px", verticalAlign: "middle"}} viewBox="0 0 24 24">
<path fill="currentColor" d={mdiFunctionVariant} />
</svg>
</Button>
</InputButton>
</div>
);
@@ -242,24 +239,24 @@ export default class CombiningFilterEditor extends React.Component {
return (
<>
<InputBlock
<Block
key="top"
fieldSpec={fieldSpec}
label={"Filter"}
action={actions}
>
<SelectInput
<InputSelect
value={combiningOp}
onChange={this.onFilterPartChanged.bind(this, 0)}
options={[["all", "every filter matches"], ["none", "no filter matches"], ["any", "any filter matches"]]}
/>
</InputBlock>
</Block>
{editorBlocks}
<div
key="buttons"
className="maputnik-filter-editor-add-wrapper"
>
<Button
<InputButton
data-wd-key="layer-filter-button"
className="maputnik-add-filter"
onClick={this.addFilterItem}
@@ -267,14 +264,14 @@ export default class CombiningFilterEditor extends React.Component {
<svg style={{width:"14px", height:"14px", verticalAlign: "text-bottom"}} viewBox="0 0 24 24">
<path fill="currentColor" d={mdiTableRowPlusAfter} />
</svg> Add filter
</Button>
</InputButton>
</div>
<div
key="doc"
className="maputnik-doc-inline"
style={{display: this.state.showDoc ? '' : 'none'}}
>
<SpecDoc fieldSpec={fieldSpec} />
<Doc fieldSpec={fieldSpec} />
</div>
</>
);
@@ -1,9 +1,9 @@
import React from 'react'
import PropTypes from 'prop-types'
import Button from '../Button'
import InputButton from './InputButton'
import {MdDelete} from 'react-icons/md'
class FilterEditorBlock extends React.Component {
export default class FilterEditorBlock extends React.Component {
static propTypes = {
onDelete: PropTypes.func.isRequired,
children: PropTypes.element.isRequired,
@@ -12,12 +12,13 @@ class FilterEditorBlock extends React.Component {
render() {
return <div className="maputnik-filter-editor-block">
<div className="maputnik-filter-editor-block-action">
<Button
<InputButton
className="maputnik-delete-filter"
onClick={this.props.onDelete}
title="Delete filter block"
>
<MdDelete />
</Button>
</InputButton>
</div>
<div className="maputnik-filter-editor-block-content">
{this.props.children}
@@ -26,4 +27,3 @@ class FilterEditorBlock extends React.Component {
}
}
export default FilterEditorBlock
@@ -2,7 +2,7 @@ import React from 'react'
import IconBase from 'react-icon-base'
export default class BackgroundIcon extends React.Component {
export default class IconBackground extends React.Component {
render() {
return (
<IconBase viewBox="0 0 20 20" {...this.props}>
@@ -2,7 +2,7 @@ import React from 'react'
import IconBase from 'react-icon-base'
export default class FillIcon extends React.Component {
export default class IconCircle extends React.Component {
render() {
return (
<IconBase viewBox="0 0 20 20" {...this.props}>
@@ -2,7 +2,7 @@ import React from 'react'
import IconBase from 'react-icon-base'
export default class FillIcon extends React.Component {
export default class IconFill extends React.Component {
render() {
return (
<IconBase viewBox="0 0 20 20" {...this.props}>
+33
View File
@@ -0,0 +1,33 @@
import React from 'react'
import PropTypes from 'prop-types'
import IconLine from './IconLine.jsx'
import IconFill from './IconFill.jsx'
import IconSymbol from './IconSymbol.jsx'
import IconBackground from './IconBackground.jsx'
import IconCircle from './IconCircle.jsx'
import IconMissing from './IconMissing.jsx'
export default class IconLayer extends React.Component {
static propTypes = {
type: PropTypes.string.isRequired,
style: PropTypes.object,
}
render() {
const iconProps = { style: this.props.style }
switch(this.props.type) {
case 'fill-extrusion': return <IconBackground {...iconProps} />
case 'raster': return <IconFill {...iconProps} />
case 'hillshade': return <IconFill {...iconProps} />
case 'heatmap': return <IconFill {...iconProps} />
case 'fill': return <IconFill {...iconProps} />
case 'background': return <IconBackground {...iconProps} />
case 'line': return <IconLine {...iconProps} />
case 'symbol': return <IconSymbol {...iconProps} />
case 'circle': return <IconCircle {...iconProps} />
default: return <IconMissing {...iconProps} />
}
}
}
@@ -2,7 +2,7 @@ import React from 'react'
import IconBase from 'react-icon-base'
export default class FillIcon extends React.Component {
export default class IconLine extends React.Component {
render() {
return (
<IconBase viewBox="0 0 20 20" {...this.props}>
@@ -2,7 +2,7 @@ import React from 'react'
import {MdPriorityHigh} from 'react-icons/md'
export default class MissingIcon extends React.Component {
export default class IconMissing extends React.Component {
render() {
return (
<MdPriorityHigh {...this.props} />
@@ -2,7 +2,7 @@ import React from 'react'
import IconBase from 'react-icon-base'
export default class SymbolIcon extends React.Component {
export default class IconSymbol extends React.Component {
render() {
return (
<IconBase viewBox="0 0 20 20" {...this.props}>
@@ -1,15 +1,16 @@
import React from 'react'
import PropTypes from 'prop-types'
import StringInput from './StringInput'
import NumberInput from './NumberInput'
import InputString from './InputString'
import InputNumber from './InputNumber'
class ArrayInput extends React.Component {
export default class FieldArray extends React.Component {
static propTypes = {
value: PropTypes.array,
type: PropTypes.string,
length: PropTypes.number,
default: PropTypes.array,
onChange: PropTypes.func,
'aria-label': PropTypes.string,
}
static defaultProps = {
@@ -82,28 +83,31 @@ class ArrayInput extends React.Component {
const inputs = Array(this.props.length).fill(null).map((_, i) => {
if(this.props.type === 'number') {
return <NumberInput
return <InputNumber
key={i}
default={containsValues ? undefined : this.props.default[i]}
value={value[i]}
required={containsValues ? true : false}
onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/>
} else {
return <StringInput
return <InputString
key={i}
default={containsValues ? undefined : this.props.default[i]}
value={value[i]}
required={containsValues ? true : false}
onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/>
}
})
return <div className="maputnik-array">
{inputs}
</div>
return (
<div className="maputnik-array">
{inputs}
</div>
)
}
}
export default ArrayInput
@@ -6,12 +6,13 @@ import Autocomplete from 'react-autocomplete'
const MAX_HEIGHT = 140;
class AutocompleteInput extends React.Component {
export default class InputAutocomplete extends React.Component {
static propTypes = {
value: PropTypes.string,
options: PropTypes.array,
onChange: PropTypes.func,
keepMenuWithinWindowBounds: PropTypes.bool
keepMenuWithinWindowBounds: PropTypes.bool,
'aria-label': PropTypes.string,
}
state = {
@@ -66,6 +67,7 @@ class AutocompleteInput extends React.Component {
style: null
}}
inputProps={{
'aria-label': this.props['aria-label'],
className: "maputnik-string",
spellCheck: false
}}
@@ -95,4 +97,4 @@ class AutocompleteInput extends React.Component {
}
}
export default AutocompleteInput
@@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
class Button extends React.Component {
export default class InputButton extends React.Component {
static propTypes = {
"data-wd-key": PropTypes.string,
"aria-label": PropTypes.string,
@@ -11,10 +11,16 @@ class Button extends React.Component {
className: PropTypes.string,
children: PropTypes.node,
disabled: PropTypes.bool,
type: PropTypes.string,
id: PropTypes.string,
title: PropTypes.string,
}
render() {
return <button
id={this.props.id}
title={this.props.title}
type={this.props.type}
onClick={this.props.onClick}
disabled={this.props.disabled}
aria-label={this.props["aria-label"]}
@@ -27,4 +33,3 @@ class Button extends React.Component {
}
}
export default Button
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
class CheckboxInput extends React.Component {
export default class InputCheckbox extends React.Component {
static propTypes = {
value: PropTypes.bool,
style: PropTypes.object,
@@ -12,13 +12,18 @@ class CheckboxInput extends React.Component {
value: false,
}
onChange = () => {
this.props.onChange(!this.props.value);
}
render() {
return <label className="maputnik-checkbox-wrapper">
return <div className="maputnik-checkbox-wrapper">
<input
className="maputnik-checkbox"
type="checkbox"
style={this.props.style}
onChange={e => this.props.onChange(!this.props.value)}
onChange={this.onChange}
onClick={this.onChange}
checked={this.props.value}
/>
<div className="maputnik-checkbox-box">
@@ -28,8 +33,7 @@ class CheckboxInput extends React.Component {
<path d='M1 14 L5 10 L13 18 L27 4 L31 8 L13 26 z' />
</svg>
</div>
</label>
</div>
}
}
export default CheckboxInput
@@ -10,7 +10,7 @@ function formatColor(color) {
}
/*** Number fields with support for min, max and units and documentation*/
class ColorField extends React.Component {
export default class InputColor extends React.Component {
static propTypes = {
onChange: PropTypes.func.isRequired,
name: PropTypes.string,
@@ -18,6 +18,7 @@ class ColorField extends React.Component {
doc: PropTypes.string,
style: PropTypes.object,
default: PropTypes.string,
'aria-label': PropTypes.string,
}
state = {
@@ -116,7 +117,9 @@ class ColorField extends React.Component {
{this.state.pickerOpened && picker}
<div className="maputnik-color-swatch" style={swatchStyle}></div>
<input
aria-label={this.props['aria-label']}
spellCheck="false"
autoComplete="off"
className="maputnik-color"
ref={(input) => this.colorInput = input}
onClick={this.togglePicker}
@@ -130,4 +133,3 @@ class ColorField extends React.Component {
}
}
export default ColorField
@@ -1,15 +1,16 @@
import React from 'react'
import PropTypes from 'prop-types'
import StringInput from './StringInput'
import NumberInput from './NumberInput'
import Button from '../Button'
import InputString from './InputString'
import InputNumber from './InputNumber'
import InputButton from './InputButton'
import {MdDelete} from 'react-icons/md'
import DocLabel from '../fields/DocLabel'
import EnumInput from '../inputs/SelectInput'
import FieldDocLabel from './FieldDocLabel'
import InputEnum from './InputEnum'
import capitalize from 'lodash.capitalize'
import InputUrl from './InputUrl'
class DynamicArrayInput extends React.Component {
export default class FieldDynamicArray extends React.Component {
static propTypes = {
value: PropTypes.array,
type: PropTypes.string,
@@ -17,10 +18,10 @@ class DynamicArrayInput extends React.Component {
onChange: PropTypes.func,
style: PropTypes.object,
fieldSpec: PropTypes.object,
'aria-label': PropTypes.string,
}
changeValue(idx, newValue) {
console.log(idx, newValue)
const values = this.values.slice(0)
values[idx] = newValue
this.props.onChange(values)
@@ -35,6 +36,9 @@ class DynamicArrayInput extends React.Component {
if (this.props.type === 'number') {
values.push(0)
}
else if (this.props.type === 'url') {
values.push("");
}
else if (this.props.type === 'enum') {
const {fieldSpec} = this.props;
const defaultValue = Object.keys(fieldSpec.values)[0];
@@ -50,32 +54,41 @@ class DynamicArrayInput extends React.Component {
const values = this.values.slice(0)
values.splice(valueIdx, 1)
this.props.onChange(values)
this.props.onChange(values.length > 0 ? values : undefined);
}
render() {
const inputs = this.values.map((v, i) => {
const deleteValueBtn= <DeleteValueButton onClick={this.deleteValue.bind(this, i)} />
const deleteValueBtn= <DeleteValueInputButton onClick={this.deleteValue.bind(this, i)} />
let input;
if (this.props.type === 'number') {
input = <NumberInput
if(this.props.type === 'url') {
input = <InputUrl
value={v}
onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/>
}
else if (this.props.type === 'number') {
input = <InputNumber
value={v}
onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/>
}
else if (this.props.type === 'enum') {
const options = Object.keys(this.props.fieldSpec.values).map(v => [v, capitalize(v)]);
input = <EnumInput
input = <InputEnum
options={options}
value={v}
onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/>
}
else {
input = <StringInput
input = <InputString
value={v}
onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/>
}
@@ -93,34 +106,36 @@ class DynamicArrayInput extends React.Component {
</div>
})
return <div className="maputnik-array">
{inputs}
<Button
className="maputnik-array-add-value"
onClick={this.addValue}
>
Add value
</Button>
</div>
return (
<div className="maputnik-array">
{inputs}
<InputButton
className="maputnik-array-add-value"
onClick={this.addValue}
>
Add value
</InputButton>
</div>
);
}
}
class DeleteValueButton extends React.Component {
class DeleteValueInputButton extends React.Component {
static propTypes = {
onClick: PropTypes.func,
}
render() {
return <Button
return <InputButton
className="maputnik-delete-stop"
onClick={this.props.onClick}
title="Remove array item"
>
<DocLabel
<FieldDocLabel
label={<MdDelete />}
doc={"Remove array entry."}
doc={"Remove array item."}
/>
</Button>
</InputButton>
}
}
export default DynamicArrayInput
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import SelectInput from '../inputs/SelectInput'
import MultiButtonInput from '../inputs/MultiButtonInput'
import InputSelect from './InputSelect'
import InputMultiInput from './InputMultiInput'
function optionsLabelLength(options) {
@@ -13,33 +13,37 @@ function optionsLabelLength(options) {
}
class EnumInput extends React.Component {
export default class InputEnum extends React.Component {
static propTypes = {
"data-wd-key": PropTypes.string,
value: PropTypes.string,
style: PropTypes.object,
default: PropTypes.string,
name: PropTypes.string,
onChange: PropTypes.func,
options: PropTypes.array,
'aria-label': PropTypes.string,
}
render() {
const {options, value, onChange} = this.props;
const {options, value, onChange, name, label} = this.props;
if(options.length <= 3 && optionsLabelLength(options) <= 20) {
return <MultiButtonInput
return <InputMultiInput
name={name}
options={options}
value={value || this.props.default}
onChange={onChange}
aria-label={this.props['aria-label'] || label}
/>
} else {
return <SelectInput
return <InputSelect
options={options}
value={value || this.props.default}
onChange={onChange}
aria-label={this.props['aria-label'] || label}
/>
}
}
}
export default EnumInput
+61
View File
@@ -0,0 +1,61 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputAutocomplete from './InputAutocomplete'
export default class FieldFont extends React.Component {
static propTypes = {
value: PropTypes.array,
default: PropTypes.array,
fonts: PropTypes.array,
style: PropTypes.object,
onChange: PropTypes.func.isRequired,
'aria-label': PropTypes.string,
}
static defaultProps = {
fonts: []
}
get values() {
const out = this.props.value || this.props.default || [];
// Always put a "" in the last field to you can keep adding entries
if (out[out.length-1] !== ""){
return out.concat("");
}
else {
return out;
}
}
changeFont(idx, newValue) {
const changedValues = this.values.slice(0)
changedValues[idx] = newValue
const filteredValues = changedValues
.filter(v => v !== undefined)
.filter(v => v !== "")
this.props.onChange(filteredValues);
}
render() {
const inputs = this.values.map((value, i) => {
return <li
key={i}
>
<InputAutocomplete
aria-label={this.props['aria-label'] || this.props.name}
value={value}
options={this.props.fonts.map(f => [f, f])}
onChange={this.changeFont.bind(this, i)}
/>
</li>
})
return (
<ul className="maputnik-font">
{inputs}
</ul>
);
}
}
@@ -2,8 +2,8 @@ import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames';
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import Block from './Block'
import FieldString from './FieldString'
import CodeMirror from 'codemirror';
import 'codemirror/mode/javascript/javascript'
@@ -16,7 +16,7 @@ import stringifyPretty from 'json-stringify-pretty-compact'
import '../util/codemirror-mgl';
class JSONEditor extends React.Component {
export default class InputJson extends React.Component {
static propTypes = {
layer: PropTypes.any.isRequired,
maxHeight: PropTypes.number,
@@ -51,9 +51,11 @@ class JSONEditor extends React.Component {
}
constructor(props) {
super(props)
super(props);
this._keyEvent = "keyboard";
this.state = {
isEditing: false,
showMessage: false,
prevValue: this.props.getValue(this.props.layer),
};
}
@@ -82,17 +84,24 @@ class JSONEditor extends React.Component {
this._doc.on('blur', this.onBlur);
}
onFocus = () => {
onPointerDown = (cm, e) => {
this._keyEvent = "pointer";
}
onFocus = (cm, e) => {
this.props.onFocus();
this.setState({
isEditing: true
isEditing: true,
showMessage: (this._keyEvent === "keyboard"),
});
}
onBlur = () => {
this._keyEvent = "keyboard";
this.props.onBlur();
this.setState({
isEditing: false
isEditing: false,
showMessage: false,
});
}
@@ -145,17 +154,21 @@ class JSONEditor extends React.Component {
}
render() {
const {showMessage} = this.state;
const style = {};
if (this.props.maxHeight) {
style.maxHeight = this.props.maxHeight;
}
return <div
className={classnames("codemirror-container", this.props.className)}
ref={(el) => this._el = el}
style={style}
/>
return <div className="JSONEditor" onPointerDown={this.onPointerDown} aria-hidden="true">
<div className={classnames("JSONEditor__message", {"JSONEditor__message--on": showMessage})}>
Press <kbd>ESC</kbd> to lose focus
</div>
<div
className={classnames("codemirror-container", this.props.className)}
ref={(el) => this._el = el}
style={style}
/>
</div>
}
}
export default JSONEditor
+42
View File
@@ -0,0 +1,42 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import InputButton from './InputButton'
export default class InputMultiInput extends React.Component {
static propTypes = {
name: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
options: PropTypes.array.isRequired,
onChange: PropTypes.func.isRequired,
}
render() {
let options = this.props.options
if(options.length > 0 && !Array.isArray(options[0])) {
options = options.map(v => [v, v])
}
const selectedValue = this.props.value || options[0][0]
const radios = options.map(([val, label])=> {
return <label
key={val}
className={classnames("maputnik-radio-as-button", {"maputnik-button-selected": val === selectedValue})}
>
<input type="radio"
name={this.props.name}
onChange={e => this.props.onChange(val)}
value={val}
checked={val === selectedValue}
/>
{label}
</label>
})
return <fieldset className="maputnik-multibutton" aria-label={this.props['aria-label']}>
{radios}
</fieldset>
}
}
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
let IDX = 0;
class NumberInput extends React.Component {
export default class InputNumber extends React.Component {
static propTypes = {
value: PropTypes.number,
default: PropTypes.number,
@@ -14,6 +14,7 @@ class NumberInput extends React.Component {
rangeStep: PropTypes.number,
wdKey: PropTypes.string,
required: PropTypes.bool,
"aria-label": PropTypes.string,
}
static defaultProps = {
@@ -171,7 +172,6 @@ class NumberInput extends React.Component {
step="any"
spellCheck="false"
value={value === undefined ? defaultValue : value}
aria-hidden="true"
onChange={this.onChangeRange}
onKeyDown={() => {
this._keyboardEvent = true;
@@ -215,6 +215,7 @@ class NumberInput extends React.Component {
const value = this.state.editing ? this.state.dirtyValue : this.state.value;
return <input
aria-label={this.props['aria-label']}
spellCheck="false"
className="maputnik-number"
placeholder={this.props.default}
@@ -230,4 +231,4 @@ class NumberInput extends React.Component {
}
}
export default NumberInput
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
class SelectInput extends React.Component {
export default class InputSelect extends React.Component {
static propTypes = {
value: PropTypes.string.isRequired,
"data-wd-key": PropTypes.string,
@@ -9,6 +9,7 @@ class SelectInput extends React.Component {
style: PropTypes.object,
onChange: PropTypes.func.isRequired,
title: PropTypes.string,
'aria-label': PropTypes.string,
}
@@ -25,10 +26,11 @@ class SelectInput extends React.Component {
title={this.props.title}
value={this.props.value}
onChange={e => this.props.onChange(e.target.value)}
aria-label={this.props['aria-label']}
>
{ options.map(([val, label]) => <option key={val} value={val}>{label}</option>) }
</select>
}
}
export default SelectInput
@@ -1,17 +1,17 @@
import React from 'react'
import PropTypes from 'prop-types'
import ColorField from './ColorField'
import NumberInput from '../inputs/NumberInput'
import CheckboxInput from '../inputs/CheckboxInput'
import StringInput from '../inputs/StringInput'
import SelectInput from '../inputs/SelectInput'
import MultiButtonInput from '../inputs/MultiButtonInput'
import ArrayInput from '../inputs/ArrayInput'
import DynamicArrayInput from '../inputs/DynamicArrayInput'
import FontInput from '../inputs/FontInput'
import IconInput from '../inputs/IconInput'
import EnumInput from '../inputs/EnumInput'
import InputColor from './InputColor'
import InputNumber from './InputNumber'
import InputCheckbox from './InputCheckbox'
import InputString from './InputString'
import InputSelect from './InputSelect'
import InputMultiInput from './InputMultiInput'
import InputArray from './InputArray'
import InputDynamicArray from './InputDynamicArray'
import InputFont from './InputFont'
import InputAutocomplete from './InputAutocomplete'
import InputEnum from './InputEnum'
import capitalize from 'lodash.capitalize'
const iconProperties = ['background-pattern', 'fill-pattern', 'line-pattern', 'fill-extrusion-pattern', 'icon-image']
@@ -32,7 +32,7 @@ function optionsLabelLength(options) {
return sum
}
/** Display any field from the Mapbox GL style spec and
/** Display any field from the Maplibre GL style spec and
* choose the correct field component based on the @{fieldSpec}
* to display @{value}. */
export default class SpecField extends React.Component {
@@ -48,21 +48,27 @@ export default class SpecField extends React.Component {
]),
/** Override the style of the field */
style: PropTypes.object,
'aria-label': PropTypes.string,
}
render() {
const commonProps = {
error: this.props.error,
fieldSpec: this.props.fieldSpec,
label: this.props.label,
action: this.props.action,
style: this.props.style,
value: this.props.value,
default: this.props.fieldSpec.default,
name: this.props.fieldName,
onChange: newValue => this.props.onChange(this.props.fieldName, newValue)
onChange: newValue => this.props.onChange(this.props.fieldName, newValue),
'aria-label': this.props['aria-label'],
}
function childNodes() {
switch(this.props.fieldSpec.type) {
case 'number': return (
<NumberInput
<InputNumber
{...commonProps}
min={this.props.fieldSpec.minimum}
max={this.props.fieldSpec.maximum}
@@ -71,48 +77,49 @@ export default class SpecField extends React.Component {
case 'enum':
const options = Object.keys(this.props.fieldSpec.values).map(v => [v, capitalize(v)])
return <EnumInput
return <InputEnum
{...commonProps}
options={options}
/>
case 'resolvedImage':
case 'formatted':
case 'string':
if(iconProperties.indexOf(this.props.fieldName) >= 0) {
return <IconInput
if (iconProperties.indexOf(this.props.fieldName) >= 0) {
const options = this.props.fieldSpec.values || [];
return <InputAutocomplete
{...commonProps}
icons={this.props.fieldSpec.values}
options={options.map(f => [f, f])}
/>
} else {
return <StringInput
return <InputString
{...commonProps}
/>
}
case 'color': return (
<ColorField
<InputColor
{...commonProps}
/>
)
case 'boolean': return (
<CheckboxInput
<InputCheckbox
{...commonProps}
/>
)
case 'array':
if(this.props.fieldName === 'text-font') {
return <FontInput
return <InputFont
{...commonProps}
fonts={this.props.fieldSpec.values}
/>
} else {
if (this.props.fieldSpec.length) {
return <ArrayInput
return <InputArray
{...commonProps}
type={this.props.fieldSpec.value}
length={this.props.fieldSpec.length}
/>
} else {
return <DynamicArrayInput
return <InputDynamicArray
{...commonProps}
fieldSpec={this.props.fieldSpec}
type={this.props.fieldSpec.value}
@@ -125,7 +132,7 @@ export default class SpecField extends React.Component {
return (
<div data-wd-key={"spec-field:"+this.props.fieldName}>
{childNodes.call(this)}
{childNodes.call(this)}
</div>
);
}
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
class StringInput extends React.Component {
export default class InputString extends React.Component {
static propTypes = {
"data-wd-key": PropTypes.string,
value: PropTypes.string,
@@ -13,6 +13,7 @@ class StringInput extends React.Component {
required: PropTypes.bool,
disabled: PropTypes.bool,
spellCheck: PropTypes.bool,
'aria-label': PropTypes.string,
}
static defaultProps = {
@@ -59,6 +60,7 @@ class StringInput extends React.Component {
}
return React.createElement(tag, {
"aria-label": this.props["aria-label"],
"data-wd-key": this.props["data-wd-key"],
spellCheck: this.props.hasOwnProperty("spellCheck") ? this.props.spellCheck : !(tag === "input"),
disabled: this.props.disabled,
@@ -90,4 +92,4 @@ class StringInput extends React.Component {
}
}
export default StringInput
@@ -1,10 +1,14 @@
import React from 'react'
import React, {Fragment} from 'react'
import PropTypes from 'prop-types'
import StringInput from './StringInput'
import SmallError from '../util/SmallError'
import InputString from './InputString'
import SmallError from './SmallError'
function validate (url) {
if (url === "") {
return;
}
let error;
const getProtocol = (url) => {
try {
@@ -16,7 +20,20 @@ function validate (url) {
}
};
const protocol = getProtocol(url);
if (
const isSsl = window.location.protocol === "https:";
if (!protocol) {
error = (
<SmallError>
Must provide protocol {
isSsl
? <code>https://</code>
: <><code>http://</code> or <code>https://</code></>
}
</SmallError>
);
}
else if (
protocol &&
protocol === "http:" &&
window.location.protocol === "https:"
@@ -31,7 +48,7 @@ function validate (url) {
return error;
}
class UrlInput extends React.Component {
export default class FieldUrl extends React.Component {
static propTypes = {
"data-wd-key": PropTypes.string,
value: PropTypes.string,
@@ -41,6 +58,7 @@ class UrlInput extends React.Component {
onInput: PropTypes.func,
multi: PropTypes.bool,
required: PropTypes.bool,
'aria-label': PropTypes.string,
}
static defaultProps = {
@@ -61,12 +79,21 @@ class UrlInput extends React.Component {
this.props.onInput(url);
}
onChange = (url) => {
this.setState({
error: validate(url)
});
this.props.onChange(url);
}
render () {
return (
<div>
<StringInput
<InputString
{...this.props}
onInput={this.onInput}
onChange={this.onChange}
aria-label={this.props['aria-label']}
/>
{this.state.error}
</div>
@@ -74,4 +101,3 @@ class UrlInput extends React.Component {
}
}
export default UrlInput
@@ -2,23 +2,23 @@ import React from 'react'
import PropTypes from 'prop-types'
import { Wrapper, Button, Menu, MenuItem } from 'react-aria-menubutton'
import JSONEditor from './JSONEditor'
import FilterEditor from '../filter/FilterEditor'
import PropertyGroup from '../fields/PropertyGroup'
import FieldJson from './FieldJson'
import FilterEditor from './FilterEditor'
import PropertyGroup from './PropertyGroup'
import LayerEditorGroup from './LayerEditorGroup'
import LayerTypeBlock from './LayerTypeBlock'
import LayerIdBlock from './LayerIdBlock'
import MinZoomBlock from './MinZoomBlock'
import MaxZoomBlock from './MaxZoomBlock'
import CommentBlock from './CommentBlock'
import LayerSourceBlock from './LayerSourceBlock'
import LayerSourceLayerBlock from './LayerSourceLayerBlock'
import FieldType from './FieldType'
import FieldId from './FieldId'
import FieldMinZoom from './FieldMinZoom'
import FieldMaxZoom from './FieldMaxZoom'
import FieldComment from './FieldComment'
import FieldSource from './FieldSource'
import FieldSourceLayer from './FieldSourceLayer'
import {Accordion} from 'react-accessible-accordion';
import {MdMoreVert} from 'react-icons/md'
import { changeType, changeProperty } from '../../libs/layer'
import layout from '../../config/layout.json'
import { changeType, changeProperty } from '../libs/layer'
import layout from '../config/layout.json'
import {formatLayerId} from '../util/format';
@@ -152,13 +152,13 @@ export default class LayerEditor extends React.Component {
switch(type) {
case 'layer': return <div>
<LayerIdBlock
<FieldId
value={this.props.layer.id}
wdKey="layer-editor.layer-id"
error={errorData.id}
onChange={newId => this.props.onLayerIdChange(this.props.layerIndex, this.props.layer.id, newId)}
/>
<LayerTypeBlock
<FieldType
disabled={true}
error={errorData.type}
value={this.props.layer.type}
@@ -167,7 +167,7 @@ export default class LayerEditor extends React.Component {
changeType(this.props.layer, newType)
)}
/>
{this.props.layer.type !== 'background' && <LayerSourceBlock
{this.props.layer.type !== 'background' && <FieldSource
error={errorData.source}
sourceIds={Object.keys(this.props.sources)}
value={this.props.layer.source}
@@ -175,24 +175,24 @@ export default class LayerEditor extends React.Component {
/>
}
{['background', 'raster', 'hillshade', 'heatmap'].indexOf(this.props.layer.type) < 0 &&
<LayerSourceLayerBlock
<FieldSourceLayer
error={errorData['source-layer']}
sourceLayerIds={sourceLayerIds}
value={this.props.layer['source-layer']}
onChange={v => this.changeProperty(null, 'source-layer', v)}
/>
}
<MinZoomBlock
<FieldMinZoom
error={errorData.minzoom}
value={this.props.layer.minzoom}
onChange={v => this.changeProperty(null, 'minzoom', v)}
/>
<MaxZoomBlock
<FieldMaxZoom
error={errorData.maxzoom}
value={this.props.layer.maxzoom}
onChange={v => this.changeProperty(null, 'maxzoom', v)}
/>
<CommentBlock
<FieldComment
error={errorData.comment}
value={comment}
onChange={v => this.changeProperty('metadata', 'maputnik:comment', v == "" ? undefined : v)}
@@ -208,22 +208,24 @@ export default class LayerEditor extends React.Component {
/>
</div>
</div>
case 'properties': return <PropertyGroup
errors={errorData}
layer={this.props.layer}
groupFields={fields}
spec={this.props.spec}
onChange={this.changeProperty.bind(this)}
/>
case 'jsoneditor': return <JSONEditor
layer={this.props.layer}
onChange={(layer) => {
this.props.onLayerChanged(
this.props.layerIndex,
layer
);
}}
/>
case 'properties':
return <PropertyGroup
errors={errorData}
layer={this.props.layer}
groupFields={fields}
spec={this.props.spec}
onChange={this.changeProperty.bind(this)}
/>
case 'jsoneditor':
return <FieldJson
layer={this.props.layer}
onChange={(layer) => {
this.props.onLayerChanged(
this.props.layerIndex,
layer
);
}}
/>
}
}
@@ -288,8 +290,10 @@ export default class LayerEditor extends React.Component {
items[id].handler();
}
return <div className="maputnik-layer-editor"
>
return <section className="maputnik-layer-editor"
role="main"
aria-label="Layer editor"
>
<header>
<div className="layer-header">
<h2 className="layer-header__title">
@@ -301,7 +305,7 @@ export default class LayerEditor extends React.Component {
onSelection={handleSelection}
closeOnSelection={false}
>
<Button className='more-menu__button'>
<Button id="skip-target-layer-editor" className='more-menu__button' title="Layer options">
<MdMoreVert className="more-menu__button__svg" />
</Button>
<Menu>
@@ -328,6 +332,6 @@ export default class LayerEditor extends React.Component {
>
{groups}
</Accordion>
</div>
</section>
}
}
@@ -5,7 +5,7 @@ import lodash from 'lodash';
import LayerListGroup from './LayerListGroup'
import LayerListItem from './LayerListItem'
import AddModal from '../modals/AddModal'
import ModalAdd from './ModalAdd'
import {SortableContainer} from 'react-sortable-hoc';
@@ -35,6 +35,8 @@ function findClosestCommonPrefix(layers, idx) {
return closestIdx
}
let UID = 0;
// List of collapsible layer editors
class LayerListContainer extends React.Component {
static propTypes = {...layerListPropTypes}
@@ -49,6 +51,9 @@ class LayerListContainer extends React.Component {
this.state = {
collapsedGroups: {},
areAllGroupsExpanded: false,
keys: {
add: UID++,
},
isOpen: {
add: false,
}
@@ -57,6 +62,10 @@ class LayerListContainer extends React.Component {
toggleModal(modalName) {
this.setState({
keys: {
...this.state.keys,
[modalName]: UID++,
},
isOpen: {
...this.state.isOpen,
[modalName]: !this.state.isOpen[modalName]
@@ -91,9 +100,18 @@ class LayerListContainer extends React.Component {
groupedLayers() {
const groups = []
const layerIdCount = new Map();
for (let i = 0; i < this.props.layers.length; i++) {
const origLayer = this.props.layers[i];
const previousLayer = this.props.layers[i-1]
const layer = this.props.layers[i]
layerIdCount.set(origLayer.id,
layerIdCount.has(origLayer.id) ? layerIdCount.get(origLayer.id) + 1 : 0
);
const layer = {
...origLayer,
key: `layers-list-${origLayer.id}-${layerIdCount.get(origLayer.id)}`,
}
if(previousLayer && layerPrefix(previousLayer.id) == layerPrefix(layer.id)) {
const lastGroup = groups[groups.length - 1]
lastGroup.push(layer)
@@ -191,14 +209,13 @@ class LayerListContainer extends React.Component {
const listItems = []
let idx = 0
const layerIdCount = new Map();
const layersByGroup = this.groupedLayers();
layersByGroup.forEach(layers => {
const groupPrefix = layerPrefix(layers[0].id)
if(layers.length > 1) {
const grp = <LayerListGroup
data-wd-key={[groupPrefix, idx].join('-')}
aria-controls={layers.map(l => l.key).join(" ")}
key={`group-${groupPrefix}-${idx}`}
title={groupPrefix}
isActive={!this.isCollapsed(groupPrefix, idx) || idx === this.props.selectedLayerIndex}
@@ -223,10 +240,6 @@ class LayerListContainer extends React.Component {
additionalProps.ref = this.selectedItemRef;
}
layerIdCount.set(layer.id,
layerIdCount.has(layer.id) ? layerIdCount.get(layer.id) + 1 : 0
);
const key = `${layer.id}-${layerIdCount.get(layer.id)}`;
const listItem = <LayerListItem
className={classnames({
'maputnik-layer-list-item-collapsed': layers.length > 1 && this.isCollapsed(groupPrefix, groupIdx) && idx !== this.props.selectedLayerIndex,
@@ -234,7 +247,8 @@ class LayerListContainer extends React.Component {
'maputnik-layer-list-item--error': !!layerError
})}
index={idx}
key={key}
key={layer.key}
id={layer.key}
layerId={layer.id}
layerIndex={idx}
layerType={layer.type}
@@ -251,8 +265,14 @@ class LayerListContainer extends React.Component {
})
})
return <div className="maputnik-layer-list" ref={this.scrollContainerRef}>
<AddModal
return <section
className="maputnik-layer-list"
role="complementary"
aria-label="Layers list"
ref={this.scrollContainerRef}
>
<ModalAdd
key={this.state.keys.add}
layers={this.props.layers}
sources={this.props.sources}
isOpen={this.state.isOpen.add}
@@ -265,7 +285,7 @@ class LayerListContainer extends React.Component {
<div className="maputnik-default-property">
<div className="maputnik-multibutton">
<button
id="skip-menu"
id="skip-target-layer-list"
onClick={this.toggleLayers}
className="maputnik-button">
{this.state.areAllGroupsExpanded === true ? "Collapse" : "Expand"}
@@ -283,10 +303,15 @@ class LayerListContainer extends React.Component {
</div>
</div>
</header>
<ul className="maputnik-layer-list-container">
{listItems}
</ul>
</div>
<div
role="navigation"
aria-label="Layers list"
>
<ul className="maputnik-layer-list-container">
{listItems}
</ul>
</div>
</section>
}
}
@@ -301,6 +326,7 @@ export default class LayerList extends React.Component {
helperClass='sortableHelper'
onSortEnd={this.props.onMoveLayer.bind(this)}
useDragHandle={true}
shouldCancelStart={() => false}
/>
}
}
@@ -7,7 +7,8 @@ export default class LayerListGroup extends React.Component {
title: PropTypes.string.isRequired,
"data-wd-key": PropTypes.string,
isActive: PropTypes.bool.isRequired,
onActiveToggle: PropTypes.func.isRequired
onActiveToggle: PropTypes.func.isRequired,
'aria-controls': PropTypes.string,
}
render() {
@@ -16,7 +17,13 @@ export default class LayerListGroup extends React.Component {
data-wd-key={"layer-list-group:"+this.props["data-wd-key"]}
onClick={e => this.props.onActiveToggle(!this.props.isActive)}
>
<span className="maputnik-layer-list-group-title">{this.props.title}</span>
<button
className="maputnik-layer-list-group-title"
aria-controls={this.props['aria-controls']}
aria-expanded={this.props.isActive}
>
{this.props.title}
</button>
<span className="maputnik-space" />
<Collapser
style={{ height: 14, width: 14 }}
@@ -4,17 +4,19 @@ import classnames from 'classnames'
import {MdContentCopy, MdVisibility, MdVisibilityOff, MdDelete} from 'react-icons/md'
import LayerIcon from '../icons/LayerIcon'
import IconLayer from './IconLayer'
import {SortableElement, SortableHandle} from 'react-sortable-hoc'
const DraggableLabel = SortableHandle((props) => {
return <div className="maputnik-layer-list-item-handle">
<LayerIcon
<IconLayer
className="layer-handle__icon"
type={props.layerType}
/>
<span className="maputnik-layer-list-item-id">{props.layerId}</span>
<button className="maputnik-layer-list-item-id">
{props.layerId}
</button>
</div>
});
@@ -54,6 +56,7 @@ class IconAction extends React.Component {
className={`maputnik-layer-list-icon-action ${classAdditions}`}
data-wd-key={this.props.wdKey}
onClick={this.props.onClick}
aria-hidden="true"
>
{this.renderIcon()}
</button>
@@ -97,6 +100,7 @@ class LayerListItem extends React.Component {
const visibilityAction = this.props.visibility === 'visible' ? 'show' : 'hide';
return <li
id={this.props.id}
key={this.props.layerId}
onClick={e => this.props.onLayerSelect(this.props.layerIndex)}
data-wd-key={"layer-list-item:"+this.props.layerId}
@@ -1,21 +1,21 @@
import React from 'react'
import PropTypes from 'prop-types'
import ReactDOM from 'react-dom'
import MapboxGl from 'mapbox-gl'
import MapLibreGl from 'maplibre-gl'
import MapboxInspect from 'mapbox-gl-inspect'
import FeatureLayerPopup from './FeatureLayerPopup'
import FeaturePropertyPopup from './FeaturePropertyPopup'
import tokens from '../../config/tokens.json'
import MapMaplibreGlLayerPopup from './MapMaplibreGlLayerPopup'
import MapMaplibreGlFeaturePropertyPopup from './MapMaplibreGlFeaturePropertyPopup'
import tokens from '../config/tokens.json'
import colors from 'mapbox-gl-inspect/lib/colors'
import Color from 'color'
import ZoomControl from '../../libs/zoomcontrol'
import { colorHighlightedLayer } from '../../libs/highlight'
import 'mapbox-gl/dist/mapbox-gl.css'
import '../../mapboxgl.css'
import '../../libs/mapbox-rtl'
import ZoomControl from '../libs/zoomcontrol'
import { colorHighlightedLayer } from '../libs/highlight'
import 'maplibre-gl/dist/maplibre-gl.css'
import '../maplibregl.css'
import '../libs/maplibre-rtl'
const IS_SUPPORTED = MapboxGl.supported();
const IS_SUPPORTED = MapLibreGl.supported();
function renderPopup(popup, mountNode) {
ReactDOM.render(popup, mountNode);
@@ -52,7 +52,7 @@ function buildInspectStyle(originalMapStyle, coloredLayers, highlightedLayer) {
return inspectStyle
}
export default class MapboxGlMap extends React.Component {
export default class MapMaplibreGl extends React.Component {
static propTypes = {
onDataChange: PropTypes.func,
onLayerSelect: PropTypes.func.isRequired,
@@ -69,13 +69,11 @@ export default class MapboxGlMap extends React.Component {
onDataChange: () => {},
onLayerSelect: () => {},
onChange: () => {},
mapboxAccessToken: tokens.mapbox,
options: {},
}
constructor(props) {
super(props)
MapboxGl.accessToken = tokens.mapbox
this.state = {
map: null,
inspect: null,
@@ -86,10 +84,8 @@ export default class MapboxGlMap extends React.Component {
if(!IS_SUPPORTED) return;
if(!this.state.map) return
const metadata = props.mapStyle.metadata || {}
MapboxGl.accessToken = metadata['maputnik:mapbox_access_token'] || tokens.mapbox
//Mapbox GL now does diffing natively so we don't need to calculate
//Maplibre GL now does diffing natively so we don't need to calculate
//the necessary operations ourselves!
this.state.map.setStyle(
this.props.replaceAccessTokens(props.mapStyle),
@@ -97,7 +93,17 @@ export default class MapboxGlMap extends React.Component {
)
}
componentDidUpdate(prevProps) {
shouldComponentUpdate(nextProps, nextState) {
let should = false;
try {
should = JSON.stringify(this.props) !== JSON.stringify(nextProps) || JSON.stringify(this.state) !== JSON.stringify(nextState);
} catch(e) {
// no biggie, carry on
}
return should;
}
componentDidUpdate(prevProps, prevState, snapshot) {
if(!IS_SUPPORTED) return;
const map = this.state.map;
@@ -113,7 +119,7 @@ export default class MapboxGlMap extends React.Component {
if (map) {
if (this.props.inspectModeEnabled) {
// HACK: We need to work out why we need to do this and what's causing
// this error. I'm assuming an issue with mapbox-gl update and
// this error. I'm assuming an issue with maplibre-gl update and
// mapbox-gl-inspect.
try {
this.state.inspect.render();
@@ -139,7 +145,7 @@ export default class MapboxGlMap extends React.Component {
maxZoom: 24
}
const map = new MapboxGl.Map(mapOpts);
const map = new MapLibreGl.Map(mapOpts);
const mapViewChange = () => {
const center = map.getCenter();
@@ -155,13 +161,13 @@ export default class MapboxGlMap extends React.Component {
const zoomControl = new ZoomControl;
map.addControl(zoomControl, 'top-right');
const nav = new MapboxGl.NavigationControl({visualizePitch:true});
const nav = new MapLibreGl.NavigationControl({visualizePitch:true});
map.addControl(nav, 'top-right');
const tmpNode = document.createElement('div');
const inspect = new MapboxInspect({
popup: new MapboxGl.Popup({
popup: new MapLibreGl.Popup({
closeOnClick: false
}),
showMapPopup: true,
@@ -175,9 +181,9 @@ export default class MapboxGlMap extends React.Component {
buildInspectStyle: (originalMapStyle, coloredLayers) => buildInspectStyle(originalMapStyle, coloredLayers, this.props.highlightedLayer),
renderPopup: features => {
if(this.props.inspectModeEnabled) {
return renderPopup(<FeaturePropertyPopup features={features} />, tmpNode);
return renderPopup(<MapMaplibreGlFeaturePropertyPopup features={features} />, tmpNode);
} else {
return renderPopup(<FeatureLayerPopup features={features} onLayerSelect={this.onLayerSelectById} zoom={this.state.zoom} />, tmpNode);
return renderPopup(<MapMaplibreGlLayerPopup features={features} onLayerSelect={this.onLayerSelectById} zoom={this.state.zoom} />, tmpNode);
}
}
})
@@ -221,6 +227,8 @@ export default class MapboxGlMap extends React.Component {
if(IS_SUPPORTED) {
return <div
className="maputnik-map__map"
role="region"
aria-label="Map view"
ref={x => this.container = x}
></div>
}
@@ -229,9 +237,10 @@ export default class MapboxGlMap extends React.Component {
className="maputnik-map maputnik-map--error"
>
<div className="maputnik-map__error-message">
Error: Cannot load MapboxGL, WebGL is either unsupported or disabled
Error: Cannot load MaplibreGL, WebGL is either unsupported or disabled
</div>
</div>
}
}
}
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import Block from './Block'
import FieldString from './FieldString'
function displayValue(value) {
if (typeof value === 'undefined' || value === null) return value;
@@ -15,24 +15,24 @@ function displayValue(value) {
function renderProperties(feature) {
return Object.keys(feature.properties).map(propertyName => {
const property = feature.properties[propertyName]
return <InputBlock key={propertyName} label={propertyName}>
<StringInput value={displayValue(property)} style={{backgroundColor: 'transparent'}}/>
</InputBlock>
return <Block key={propertyName} label={propertyName}>
<FieldString value={displayValue(property)} style={{backgroundColor: 'transparent'}}/>
</Block>
})
}
function renderFeatureId(feature) {
return <InputBlock key={"feature-id"} label={"feature_id"}>
<StringInput value={displayValue(feature.id)} style={{backgroundColor: 'transparent'}} />
</InputBlock>
return <Block key={"feature-id"} label={"feature_id"}>
<FieldString value={displayValue(feature.id)} style={{backgroundColor: 'transparent'}} />
</Block>
}
function renderFeature(feature, idx) {
return <div key={`${feature.sourceLayer}-${idx}`}>
<div className="maputnik-popup-layer-id">{feature.layer['source-layer']}{feature.inspectModeCounter && <span> × {feature.inspectModeCounter}</span>}</div>
<InputBlock key={"property-type"} label={"$type"}>
<StringInput value={feature.geometry.type} style={{backgroundColor: 'transparent'}} />
</InputBlock>
<div className="maputnik-popup-layer-id">{feature.layer['source']}: {feature.layer['source-layer']}{feature.inspectModeCounter && <span> × {feature.inspectModeCounter}</span>}</div>
<Block key={"property-type"} label={"$type"}>
<FieldString value={feature.geometry.type} style={{backgroundColor: 'transparent'}} />
</Block>
{renderFeatureId(feature)}
{renderProperties(feature)}
</div>
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import LayerIcon from '../icons/LayerIcon'
import {latest, expression, function as styleFunction} from '@mapbox/mapbox-gl-style-spec'
import IconLayer from './IconLayer'
import {latest} from '@maplibre/maplibre-gl-style-spec'
function groupFeaturesBySourceLayer(features) {
const sources = {}
@@ -11,7 +11,7 @@ function groupFeaturesBySourceLayer(features) {
features.forEach(feature => {
if(returnedFeatures.hasOwnProperty(feature.layer.id)) {
returnedFeatures[feature.layer.id]++
const featureObject = sources[feature.layer['source-layer']].find(f => f.layer.id === feature.layer.id)
featureObject.counter = returnedFeatures[feature.layer.id]
@@ -86,7 +86,7 @@ class FeatureLayerPopup extends React.Component {
className="maputnik-popup-layer"
>
<div
className="maputnik-popup-layer__swatch"
className="maputnik-popup-layer__swatch"
style={{background: featureColor}}
></div>
<label
@@ -95,8 +95,8 @@ class FeatureLayerPopup extends React.Component {
this.props.onLayerSelect(feature.layer.id)
}}
>
{feature.layer.type &&
<LayerIcon type={feature.layer.type} style={{
{feature.layer.type &&
<IconLayer type={feature.layer.type} style={{
width: 14,
height: 14,
paddingRight: 3
@@ -1,9 +1,9 @@
import React from 'react'
import {throttle} from 'lodash';
import PropTypes from 'prop-types'
import { loadJSON } from '../../libs/urlopen'
import { loadJSON } from '../libs/urlopen'
import FeatureLayerPopup from './FeatureLayerPopup';
import MapMaplibreGlLayerPopup from './MapMaplibreGlLayerPopup';
import 'ol/ol.css'
import {apply} from 'ol-mapbox-style';
@@ -24,7 +24,7 @@ function renderCoords (coords) {
}
}
export default class OpenLayersMap extends React.Component {
export default class MapOpenLayers extends React.Component {
static propTypes = {
onDataChange: PropTypes.func,
mapStyle: PropTypes.object.isRequired,
@@ -146,13 +146,13 @@ export default class OpenLayersMap extends React.Component {
className="maputnik-popup"
>
<button
className="mapboxgl-popup-close-button"
className="maplibregl-popup-close-button"
onClick={this.closeOverlay}
aria-label="Close popup"
>
×
</button>
<FeatureLayerPopup
<MapMaplibreGlLayerPopup
features={this.state.selectedFeatures || []}
onLayerSelect={this.props.onLayerSelect}
/>
@@ -179,6 +179,8 @@ export default class OpenLayersMap extends React.Component {
<div
className="maputnik-ol"
ref={x => this.container = x}
role="region"
aria-label="Map view"
style={{
...this.props.style,
}}>

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