Compare commits

...

809 Commits

Author SHA1 Message Date
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
orangemug
1d48ab7ecf 1.7.0 2020-04-23 21:12:38 +01:00
Orange Mug
d85ed36e70 Merge pull request #663 from nspringer-trimble/patch-1
Fix for desktop build
2020-04-22 20:30:00 +01:00
Nick Springer
b554f4427b Fix for desktop build 2020-04-21 09:17:30 -04:00
orangemug
184bfeeaf8 1.7.0-beta4 2020-04-20 13:13:36 +01:00
orangemug
e45f8d960d Added space for beta tag in logo/version header 2020-04-20 13:12:48 +01:00
Orange Mug
1fede3af3a Merge pull request #661 from orangemug/fix/issue-660-v2
Added JSON linting back into <SourceTypeEditor/>
2020-04-20 13:09:29 +01:00
orangemug
5ad74048bd Added JSON linting back into <SourceTypeEditor/> 2020-04-20 11:07:08 +01:00
orangemug
a0a91474de 1.7.0-beta3 2020-04-19 08:45:18 +01:00
Orange Mug
c3670701e5 Merge pull request #606 from orangemug/fix/issue-591
Added style formatting into the api store
2020-04-19 08:38:37 +01:00
Orange Mug
86923330d9 Merge pull request #658 from pathmapper/feature_id_inspect
Add feature id to FeaturePropertyPopup
2020-04-19 08:00:00 +01:00
pathmapper
4517148e5a Add underscore to label 2020-04-18 11:43:52 +02:00
pathmapper
0433d66f45 Add feature id to FeaturePropertyPopup 2020-04-18 11:25:54 +02:00
Orange Mug
0c592bacab Merge pull request #650 from orangemug/fix/issue-647
Fixed crash raised in issue #647
2020-04-14 21:15:59 +01:00
Orange Mug
d98637cb12 Merge pull request #645 from orangemug/feature/add-support-for-identity-functions
Add support for identity functions
2020-04-14 09:12:35 +01:00
orangemug
1070209cb5 Another attempt and maputnik inspect crashing issue. 2020-04-14 09:11:09 +01:00
orangemug
b6189f77c4 Added icons to buttons. 2020-04-14 08:31:55 +01:00
Orange Mug
25322a3952 Merge pull request #655 from orangemug/fix/issue-653
Added missing inline error for 'source' field
2020-04-13 10:57:01 +01:00
Orange Mug
5943c6f282 Merge pull request #654 from orangemug/fix/issue-649
Fixed default values for <FontInput/>
2020-04-13 10:56:47 +01:00
orangemug
090a26bb40 Added missing inline error for 'source' field. 2020-04-13 09:10:30 +01:00
orangemug
af03b010a4 Fixed default values for <FontInput/> 2020-04-13 08:53:33 +01:00
orangemug
578a920b6d Fixed crash raised in issue #647 2020-04-13 08:39:23 +01:00
pathmapper
0858a16ffc Merge pull request #644 from orangemug/fix/remove-heavy-thunderforest-tiles
Remove notes from thunderforest sources
2020-04-12 21:04:35 +02:00
orangemug
7cfe0563bc Added support for identity functions. 2020-04-12 16:25:32 +01:00
orangemug
ee72389534 Remove mentions of 'heavy' from thunderforest tiles. 2020-04-12 12:14:56 +01:00
pathmapper
8f722c59de Merge pull request #642 from pathmapper/upgrade_thunderforest
Upgrade Thunderforest tilesets from v1 to v2
2020-04-11 15:48:03 +02:00
pathmapper
94d2e958eb Add version to titles 2020-04-10 18:23:31 +02:00
pathmapper
d931c7cb38 Upgrade Thunderforest tilesets 2020-04-10 18:13:23 +02:00
orangemug
6da83c4670 1.7.0-beta2 2020-04-06 16:57:02 +01:00
Orange Mug
d26af16003 Merge pull request #639 from orangemug/fix/only-scroll-layer-list-if-item-not-in-view
Only scroll to selected item in <LayerList/> if not already in view.
2020-04-06 16:55:26 +01:00
Orange Mug
d75b86c927 Merge pull request #638 from orangemug/maintenance/update-deps-20200406
Update all deps
2020-04-06 16:54:06 +01:00
orangemug
a0cd087ccc Revert webdriverio version updates. 2020-04-06 15:47:12 +01:00
orangemug
313b639a5f Only scroll to selected item in <LayerList/> if not already in view. 2020-04-06 15:30:16 +01:00
orangemug
93c45d5340 Update all deps. 2020-04-06 15:14:21 +01:00
Orange Mug
3be6cb5926 Merge pull request #637 from orangemug/fix/console-errors-2020-04-06
Fix a bunch of errors/warnings from the console
2020-04-06 15:06:39 +01:00
Orange Mug
9d151fdc1f Merge pull request #636 from pathmapper/promote_beta
Promote v1.7.0-beta in readme
2020-04-06 14:32:29 +01:00
orangemug
44d1a7a6b0 {arrayMove} will no longer be included in 'react-sortable-hoc', move to array-move. 2020-04-06 14:18:41 +01:00
pathmapper
0e5676eae0 Promote v1.7.0-beta in readme 2020-04-06 15:14:42 +02:00
orangemug
b8739915b2 Lots of smaller fixes found in the console logs during testing. 2020-04-06 13:59:08 +01:00
Orange Mug
a1dedd1aa6 Merge pull request #634 from orangemug/fix/issue-630
Scroll selected <LayerListItem/> into view
2020-04-06 13:11:53 +01:00
Orange Mug
33b4a40c35 Merge pull request #635 from orangemug/fix/issue-633
Fixes for <NumberInput/>
2020-04-06 13:10:48 +01:00
orangemug
a624909819 Reset dirtyValue on resetValue 2020-04-06 10:40:30 +01:00
orangemug
d5d387f349 Removed placeholder on range (doesn't work) in favour 'default' value merged into 'value'. 2020-04-06 10:24:31 +01:00
orangemug
c58ae0f895 Fix <NumberInput/> to allow for decimal numbers. 2020-04-06 09:55:07 +01:00
orangemug
c9e360d675 Fix layer selection via <FeatureLayerPopup/> 2020-04-06 08:47:13 +01:00
orangemug
75ece350bd Merge remote-tracking branch 'upstream/master' into fix/issue-630 2020-04-04 15:48:52 +01:00
Orange Mug
45680151ef Merge pull request #632 from orangemug/fix/color-popup-swatch
Fix color in <FeatureLayerPopup/>
2020-04-04 15:48:35 +01:00
orangemug
87bae82b17 Merge remote-tracking branch 'upstream/master' into fix/issue-630 2020-04-04 15:44:29 +01:00
orangemug
fcad636f85 Scroll selected <LayerListItem/> into view 2020-04-04 15:41:35 +01:00
orangemug
bac8495b3c Made <FeatureLayerPopup/> swatch simplier because colors from features are already evaluated 2020-04-04 10:45:11 +01:00
orangemug
df98cb9c7b Fix layer color swatch in <FeatureLayerPopup/> 2020-04-04 10:21:58 +01:00
Orange Mug
34c3015b42 Merge pull request #625 from orangemug/fix/invalid-style-with-duplicate-layer-ids
Fix UI when loading invalid style with duplicate layer ids
2020-03-30 20:38:25 +01:00
orangemug
7d51ea9b25 1.7.0-beta 2020-03-30 17:44:26 +01:00
orangemug
ca7bf9f4a7 Fixed lint errors. 2020-03-30 09:57:14 +01:00
orangemug
61ba399e1c Duplicate layer ids now show errors inline. 2020-03-30 09:47:46 +01:00
orangemug
b5c09a4f17 Merge remote-tracking branch 'upstream/master' into fix/invalid-style-with-duplicate-layer-ids 2020-03-30 08:52:37 +01:00
Orange Mug
fcfc7ab874 Merge pull request #626 from orangemug/fix/issue-321-accessible-layer-groups
Moved to using react-accessible-accordion for <LayerEditorGroup/>
2020-03-29 16:12:33 +01:00
pathmapper
a0bc4744a2 Merge pull request #627 from orangemug/fix/make-scrollbar-wider
Wider scrollbar
2020-03-29 13:55:55 +02:00
orangemug
e6e4c928f3 Make the scrollbar wider so it's easier to grab with the mouse pointer. 2020-03-29 07:40:43 +01:00
orangemug
00388e03b8 Moved to using react-accessible-accordion for <LayerEditorGroup/> 2020-03-28 12:53:46 +00:00
orangemug
6f83839a4c Added missing file. 2020-03-28 11:06:45 +00:00
orangemug
74b47e7e74 Fix UI when loading invalid style with duplicate layer ids.
Also fix for throwing error when 2 layers exist with empty strings as ids.
2020-03-28 10:58:47 +00:00
Orange Mug
f70d078ec6 Merge pull request #624 from orangemug/maintenance/update-deps-20200328
Update dependencies
2020-03-28 09:49:59 +00:00
orangemug
1d8131fb85 Update dependencies. 2020-03-28 08:33:57 +00:00
Orange Mug
8c82db9162 Merge pull request #620 from orangemug/feature/ui-errors-and-expressions
Added support for expressions and UI errors
2020-03-27 17:51:02 +00:00
orangemug
f23f60807a Tidy 2020-03-16 10:17:04 +00:00
orangemug
8f581956e8 Revert jsonlint 2020-03-08 19:00:36 +00:00
orangemug
87fb0f6a5c Updated lockfile. 2020-03-08 18:44:04 +00:00
orangemug
1c953bc296 Remove old hack 'src/vendor/codemirror/addon/lint/json-lint' 2020-03-08 18:43:46 +00:00
orangemug
ce976991d4 Added inline errors to the code-mirror editors based on field spec. 2020-03-08 18:38:32 +00:00
orangemug
be7642976b Can't use object as react-dom key. 2020-02-25 09:27:29 +00:00
orangemug
a5b226d9f3 Fixed lint error. 2020-02-25 09:25:52 +00:00
orangemug
1b3d8b5b79 Added JSON error to expression editor 2020-02-25 09:20:14 +00:00
orangemug
97a61afc24 Merge remote-tracking branch 'upstream/master' into feature/ui-errors-and-expressions 2020-02-23 13:34:05 +00:00
Orange Mug
d1f6bc95db Merge pull request #621 from orangemug/fix/CheckboxInput-props-error
Added default to <CheckboxInput/> value to fix warning in console.
2020-02-23 13:24:16 +00:00
orangemug
10b03c4e00 Also fixed invalid DOM nesting warning. 2020-02-22 18:47:46 +00:00
Orange Mug
449d8e7665 Merge pull request #617 from orangemug/fix/map-controls-and-improve-zoom-styling
Improved map control zoom styling
2020-02-22 18:41:05 +00:00
orangemug
4b8800e8ac Added default to <CheckboxInput/> value to fix warning in console. 2020-02-22 18:39:24 +00:00
orangemug
874c6460f6 Merge remote-tracking branch 'upstream/master' into fix/map-controls-and-improve-zoom-styling 2020-02-22 17:59:24 +00:00
orangemug
55cb86f721 Disabled survey modal on first visit to website. 2020-02-22 17:52:20 +00:00
orangemug
a30017fd2c Inline survey modal image 2020-02-22 17:50:14 +00:00
orangemug
3b5ba6c59e Fixed lint errors. 2020-02-22 13:15:55 +00:00
orangemug
a693f6db4e Added infobox for old style filters to allow you to switch to the filter editor. 2020-02-22 11:54:59 +00:00
Orange Mug
5be7e0c7ec Merge pull request #619 from orangemug/maintenance/update-deps-20200217-v2
Update all the deps
2020-02-22 08:57:07 +00:00
orangemug
7c6b3c0d80 Bumped deps. 2020-02-21 09:07:25 +00:00
orangemug
e5e03be382 Fixed missing command update to appveyor.yml 2020-02-21 08:46:46 +00:00
orangemug
0d35106cc8 Tidy test scripts. 2020-02-21 08:06:01 +00:00
orangemug
5710edcff7 Fixed invalid lockfile. 2020-02-18 21:42:25 +00:00
orangemug
2cc7c63bb1 Updated to new webdriverio config api, and fixed failing tests. 2020-02-18 21:39:11 +00:00
orangemug
ba9d21c045 Merge remote-tracking branch 'upstream/master' into maintenance/update-deps-20200217-v2 2020-02-18 19:10:20 +00:00
orangemug
4ef6ecb7eb Moved from magnify icon to 'zoom:' label. Also increased contrast on compass arrow. 2020-02-18 18:50:30 +00:00
orangemug
52e8b21b3d Tidy function. 2020-02-18 08:06:36 +00:00
Orange Mug
c6ba4f66e2 Merge pull request #618 from orangemug/feature/improve-loader
Added improved loader with maputnik logo
2020-02-18 07:50:56 +00:00
orangemug
5a47a96f09 Update all the deps 2020-02-17 19:38:59 +00:00
orangemug
ae878f6000 Added missing plugin from production. 2020-02-17 19:03:19 +00:00
orangemug
aebfe62a8e Fixed image path. 2020-02-17 18:55:28 +00:00
orangemug
6be3543616 Added improved loader. 2020-02-17 18:52:16 +00:00
orangemug
0f6708d9d4 Improved zoom styling and fixed zoom in/out button styling. 2020-02-17 15:39:54 +00:00
orangemug
0705522a24 Fixed width issue with expression error UI. 2020-02-17 13:44:05 +00:00
orangemug
35098111ac Include missing errors from expressions UI. 2020-02-17 13:41:11 +00:00
orangemug
39333953d7 Only show 'switch to layer' button if layer not already selected. 2020-02-17 13:24:14 +00:00
orangemug
adea3d0f13 Added ability to switch to layer from global error panel. 2020-02-17 13:19:26 +00:00
orangemug
d1cb2690fc Fixed lint errors. 2020-02-17 11:55:16 +00:00
orangemug
3ffdcc9639 Added the ability to convert from data/zoom function to expression 2020-02-17 11:52:40 +00:00
orangemug
793b5d15ad Fixed lint errors 2020-02-17 11:30:48 +00:00
orangemug
cff32696cc Better handling of undo history for expressions. 2020-02-17 11:29:05 +00:00
orangemug
029eff9317 Added margin-left to function errors to line up with values. 2020-02-16 22:02:05 +00:00
orangemug
b7d08dfaa6 Fixed data function display issues. 2020-02-16 21:56:03 +00:00
orangemug
94089836bf Fixed lint errors. 2020-02-16 21:30:27 +00:00
orangemug
ff8a8fb749 Added errors to filter functions 2020-02-16 21:25:41 +00:00
orangemug
1300951a29 Removed height from '.maputnik-layout-bottom' to allow it to expand. 2020-02-16 20:31:51 +00:00
orangemug
3cb1ed9403 Made function to check if expression/function more robust. 2020-02-16 20:25:43 +00:00
orangemug
a5ac1cc93d Guard against errors producing dirty map state. 2020-02-16 18:22:21 +00:00
orangemug
29a0ef0d1c Change to always attempt rendering of map state, even if broken, allowing the user to fix style issues step-by-step. 2020-02-16 18:11:47 +00:00
orangemug
26907f7014 Fix button style in disabled state as reported by @pathmapper 2020-02-16 17:34:23 +00:00
orangemug
3ac06c7cb1 Merge remote-tracking branch 'upstream/master' into feature/ui-errors-and-expressions 2020-02-10 15:57:25 +00:00
Orange Mug
f268f09ca2 Merge pull request #616 from orangemug/fix/error-bar-width
Fixed overflowing error bar
2020-02-10 15:50:53 +00:00
orangemug
f4c18fd91b Fixed error bar from overflowing. 2020-02-09 17:23:50 +00:00
orangemug
0567b098ec Fixed undo button disabled state for expressions. 2020-02-09 16:48:52 +00:00
orangemug
dc6006fd6d Fixed lint errors. 2020-02-09 16:36:17 +00:00
orangemug
109261ba00 Fixed filter defaults and removed auto-migrate. 2020-02-09 16:33:47 +00:00
orangemug
b539644b2b Added expression support for filters. 2020-02-09 15:08:24 +00:00
orangemug
be36eec93d Added 'undo' alongside 'trash' button 2020-02-08 10:38:31 +00:00
pathmapper
fe5066a2a4 Merge pull request #614 from orangemug/fix/map-container-background-color
Make background map container white to match html page default
2020-02-02 17:59:35 +01:00
Orange Mug
642e5c0b29 Merge pull request #613 from orangemug/fix/brackets-color-clash-with-cursor
Changed bracket matching color
2020-02-02 15:26:39 +00:00
orangemug
97bdc93a39 Fixed lint error. 2020-02-02 11:56:51 +00:00
orangemug
c770b440c2 Make background map container white to match html page default. 2020-02-02 11:47:37 +00:00
orangemug
7559985a2e Changed bracket matching color so it doesn't clash with cursor. 2020-02-02 11:32:58 +00:00
orangemug
532bbecb47 Only disable <LayerTypeBlock/> in <LayerEditor/> 2020-02-02 08:05:01 +00:00
orangemug
8ed67e98ce Fixed lint errors 2020-02-02 07:44:20 +00:00
orangemug
5792c632f9 hopefulMapStyle -> dirtyMapStyle 2020-02-01 17:55:26 +00:00
orangemug
3e2927e6a4 Fixed undo/redo 2020-02-01 17:53:01 +00:00
orangemug
f09cc25a3b Merge remote-tracking branch 'upstream/master' into feature/ui-errors-and-expressions 2020-02-01 17:36:59 +00:00
orangemug
c5c3e93aff Better support for expressions
- Expression editing state
 - CodeMirror JSON editor
 - Improved styling
2020-02-01 17:07:52 +00:00
Orange Mug
cc371d6a70 Merge pull request #612 from orangemug/fix/color-field-name-is-not-required
'name' is not a required property of <ColorField />
2020-01-30 09:47:06 +00:00
Orange Mug
1b17e8fa0a Merge pull request #610 from orangemug/fix/issue-609
Fix for stuck/unchanging pop-up in Inspect view
2020-01-30 09:22:43 +00:00
Orange Mug
bc4706de83 Merge pull request #607 from orangemug/fix/issue-567-better-solution-for-tooltips
Inline property documentation and SDK docs
2020-01-30 09:21:10 +00:00
orangemug
0f22eb83d3 'name' is not a required property of <ColorField /> 2020-01-30 09:18:23 +00:00
orangemug
a8cbe19f09 Added style_renderer to field-spec-additional 2020-01-30 08:54:08 +00:00
orangemug
c714e23d79 'id' is not guaranteed to be unique, see <https://github.com/maputnik/editor/pull/610/files#r372521304> 2020-01-30 08:46:26 +00:00
orangemug
5b3d579f87 Fix to fallback to index for unique feature key in <FeaturePropertyPopup /> 2020-01-29 08:44:27 +00:00
orangemug
725b752e35 Added initial expression work and UI errors. 2020-01-29 08:22:03 +00:00
orangemug
223721a65d Code review fixes
- Added docs to export modal
 - Fixed 'source type' doc in data sources modal
2020-01-27 08:49:44 +00:00
orangemug
9b4d924dff Fix to ignore modified styleSpec. 2020-01-24 17:46:43 +00:00
orangemug
b31537e063 Added property values to docs 2020-01-24 09:04:32 +00:00
Orange Mug
63ed8c1de3 Merge pull request #605 from orangemug/maintenance/update-deps-2020-01-19
Updated deps
2020-01-23 08:50:01 +00:00
Orange Mug
7aa0298f7c Merge pull request #603 from orangemug/feature/add-image-and-video-sources
Added ability to add image/video sources
2020-01-23 08:49:37 +00:00
orangemug
62f3cbe8fb Lint fixes. 2020-01-23 08:42:20 +00:00
orangemug
30facc885f Tidy inline docs and added sdk support table. 2020-01-23 08:33:12 +00:00
orangemug
17aa88e3b6 Merge remote-tracking branch 'upstream/master' into fix/issue-567-better-solution-for-tooltips 2020-01-22 08:57:45 +00:00
Orange Mug
5b9af07ebc Merge pull request #604 from orangemug/feature/issue-82
Link to OSM from debug panel
2020-01-19 20:11:30 +00:00
orangemug
6b45dc8b4d Added style formatting into apistore 2020-01-19 20:05:11 +00:00
orangemug
0009c74948 Fixes lat/lon precision and center change via zoom without pan. 2020-01-19 19:09:04 +00:00
Orange Mug
8911f83ef3 Merge pull request #522 from orangemug/feature/add-range-slider
Add range input for minZoom/maxZoom
2020-01-19 18:54:07 +00:00
orangemug
2fafafe0dc Updated deps 2020-01-19 16:39:41 +00:00
orangemug
27e6675d26 Fix replacing of access tokens in MapboxGl. 2020-01-19 16:30:27 +00:00
orangemug
4269e4573c Fixed lint errors. 2020-01-19 16:00:29 +00:00
orangemug
096e2b6aec Fixed image/video coord labels. 2020-01-19 15:48:11 +00:00
orangemug
33e04b3527 Added ability to add/edit image and video sources 2020-01-19 14:40:35 +00:00
orangemug
79fa2b3508 Feature to update current map view in OSM 2020-01-19 13:37:56 +00:00
orangemug
d5ef412300 Safari fixes. 2020-01-19 11:53:27 +00:00
orangemug
0726a494be Only set dirtyValue on valid change. 2020-01-19 11:41:37 +00:00
orangemug
926969b921 Always change via step from keyboard. 2020-01-19 11:28:03 +00:00
orangemug
59e070f463 Merge remote-tracking branch 'upstream/master' into feature/add-range-slider 2020-01-19 11:06:39 +00:00
orangemug
2ccd1d227e rangeValue -> dirtyValue 2020-01-19 11:06:24 +00:00
orangemug
655877f67e Fixed another bug with change events for <NumberInput/> and added range input keyboard support. Remove logging as react props/state is enough for debugging. 2020-01-19 10:30:08 +00:00
Orange Mug
6c240d53e4 Merge pull request #601 from orangemug/fix/issue-588
Added new fieldSpec.type 'resolvedImage'
2020-01-19 09:59:41 +00:00
Orange Mug
f89f8ed4ea Merge pull request #587 from pathmapper/matchingbrackets_addon
Add matchbrackets addon to JSON editor
2020-01-19 09:48:08 +00:00
Orange Mug
6123b464de Merge pull request #600 from orangemug/fix/issue-589
Fix feature selection in <FeatureLayerPopup />
2020-01-19 09:46:57 +00:00
Orange Mug
49dba02e8f Merge branch 'master' into matchingbrackets_addon 2020-01-19 08:29:25 +00:00
pathmapper
fb49a3abe5 Merge pull request #602 from orangemug/fix/issue-565
Update react-collapse
2020-01-19 08:54:28 +01:00
orangemug
c88f9ab5dc Believed fix for race condition in setting dirtyValue 2020-01-19 07:37:49 +00:00
orangemug
d886b14d09 Fix to set "editing: false" in blur/pointerup 2020-01-19 07:15:50 +00:00
orangemug
bd1204a7a5 Added react-collapse transition, required for react-collapse@^5 2020-01-18 22:11:02 +00:00
orangemug
9cadda0236 Update react-collapse which was needlessly updating and causing scroll position jump. 2020-01-18 22:03:29 +00:00
orangemug
90ea6323c1 Added new fieldSpec.type 'resolvedImage' 2020-01-18 20:57:59 +00:00
orangemug
51f2cfac16 Fix feature selection in <FeatureLayerPopup /> 2020-01-18 20:42:38 +00:00
Orange Mug
4dbb423ac2 Merge pull request #599 from pathmapper/update_omt_styles
Update OMT styles for v3.11
2020-01-15 10:06:58 +00:00
Orange Mug
a3ee1cc27e Merge pull request #595 from pathmapper/maxzoom
Increase maximum zoom level of the map to 24
2020-01-15 10:06:20 +00:00
pathmapper
fea0798349 Update OMT styles for v3.11 2020-01-14 10:28:32 +01:00
pathmapper
bd8abffa28 Merge pull request #597 from pathmapper/appveyor_vs_2019
Update appveyor to "Visual Studio 2019"
2020-01-13 09:39:48 +01:00
pathmapper
a5f3a43cde Merge pull request #596 from pathmapper/remove_node_v8
Remove node v8 from test runners
2020-01-13 09:39:28 +01:00
pathmapper
6c5dc7e06b Update appveyor to "Visual Studio 2019" 2020-01-11 10:26:07 +01:00
pathmapper
b1c8a12e88 Remove node v8 from appveyor 2020-01-11 09:39:09 +01:00
pathmapper
401c6971f4 Remove node v8 from circleci 2020-01-11 09:38:20 +01:00
pathmapper
7e5a5ce077 Set map maxZoom to 24 2020-01-10 14:06:17 +01:00
pathmapper
6b245c9894 Improve matchingbrackets and cursor visibility 2019-10-30 12:24:25 +01:00
pathmapper
b963fe9619 Add matchbrackets addon 2019-10-29 10:52:06 +01:00
Orange Mug
673887d93b Merge pull request #582 from orangemug/fix/add-source-errors
Add open modal and source http/https errors
2019-10-28 18:19:21 +00:00
Orange Mug
06898429fd Merge pull request #584 from orangemug/fix/issue-576
A hack fix for blocked popup
2019-10-28 18:18:33 +00:00
pathmapper
0196ba4eb4 Merge pull request #585 from orangemug/fix/issue-403
Update map style even if inspectModeEnabled=true
2019-10-28 06:38:49 +01:00
orangemug
ef81534a17 Update map style even if inspectModeEnabled=true 2019-10-27 20:04:57 +00:00
orangemug
a958ec943b Lint fix. 2019-10-27 19:16:13 +00:00
orangemug
4e3b395b3d A hack fix for blocked popup. 2019-10-27 19:11:34 +00:00
Orange Mug
5e7fd4f93c Update src/components/inputs/UrlInput.jsx
CORs -> CORS

Co-Authored-By: pathmapper <pathmapper@posteo.de>
2019-10-27 19:07:49 +00:00
orangemug
25cad5bb25 Added to GeoJSON url. 2019-10-27 18:58:22 +00:00
orangemug
f9c230414e Fix width of modal. 2019-10-27 18:54:40 +00:00
orangemug
866f8d034a Switched to <UrlInput/> for glyphs and sprites 2019-10-27 18:45:49 +00:00
pathmapper
be6aa559fb Merge pull request #583 from orangemug/feature/make-osm-liberty-the-default
Make osm-liberty the default style
2019-10-27 19:38:11 +01:00
orangemug
a560176d83 Add even more logging. 2019-10-27 18:15:54 +00:00
Orange Mug
4644e78fd2 Merge pull request #579 from orangemug/fix/function-field-fixes
Function field fixes
2019-10-27 17:58:06 +00:00
orangemug
237cc16b97 Make osm-liberty the default style. 2019-10-27 17:46:34 +00:00
orangemug
dffa54afb0 Removed more old styleUrlElement refs 2019-10-27 17:42:45 +00:00
orangemug
225e5c48e4 Fixed lint error. 2019-10-27 17:38:57 +00:00
orangemug
2e017d252a Added <UrlInput/> to open modal. 2019-10-27 17:36:20 +00:00
orangemug
e728e5f7e4 Exposed onInput in <UrlInput/> 2019-10-27 17:35:56 +00:00
orangemug
f0371b41b1 Also validate on constructor 2019-10-27 17:27:50 +00:00
orangemug
a51442921a Fix font-size inline with the rest of the UI. 2019-10-27 17:19:03 +00:00
orangemug
f39fb34f36 Protocol logic and lint fixes. 2019-10-27 17:15:17 +00:00
orangemug
566201fb45 Added UrlInput component to tidy things up a little. 2019-10-27 17:08:23 +00:00
orangemug
88841b56e7 Added another fix attempt and yet more logging. 2019-10-27 15:56:22 +00:00
orangemug
5aa0b4e7d9 More logging additional attempt at fixes. 2019-10-27 11:01:33 +00:00
Orange Mug
f19fc4a8a1 Merge pull request #581 from orangemug/fix/issue-535-data-field-ordering
Fix zoom ordering for data property fields
2019-10-27 10:18:34 +00:00
orangemug
cd162309a8 Added hopeful fix + logging. 2019-10-27 10:15:11 +00:00
orangemug
aead867e27 Incorrectly checking for falsey when should be checking for presence. 2019-10-27 10:05:05 +00:00
orangemug
663f295623 Added default protocol and stub in error. 2019-10-27 10:00:22 +00:00
orangemug
c588164190 console.log map errors. 2019-10-26 18:27:11 +01:00
orangemug
d61d0a5795 Fix test for range slider. 2019-10-26 18:09:07 +01:00
orangemug
dddd604f7b Removed left over conflict markers and set default. 2019-10-26 17:41:56 +01:00
orangemug
ea3b9a20c5 Merge remote-tracking branch 'upstream/master' into feature/add-range-slider 2019-10-26 17:22:52 +01:00
Orange Mug
7415b8af08 Merge pull request #580 from pathmapper/update_mb_deps
Update mbgl and style-spec
2019-10-26 17:19:04 +01:00
orangemug
d06e053d34 Fix zoom ordering for data property fields. 2019-10-26 17:15:25 +01:00
pathmapper
7075a8b05e Update mbgl and style-spec 2019-10-26 07:10:30 +02:00
orangemug
4cbcf14588 Make up defaults from function field if we can't find one from the spec. 2019-10-25 22:54:08 +01:00
orangemug
ca202d7701 Use <EnumInput/> for enums again 2019-10-25 22:48:37 +01:00
Orange Mug
8dfc16e7ee Merge pull request #577 from fredj/del_btn_style
Simplify and fix vertical alignment of the delete button
2019-10-25 22:15:23 +01:00
Frederic Junod
fbf5cec670 Simplify and fix vertical alignment
Use the same css as the `maputnik-make-data-function` and `maputnik-make-zoom-function` buttons.
2019-10-25 13:16:09 +02:00
Orange Mug
14d4383f8a Merge pull request #575 from snodnipper/feature/zoomstack-v2
set OS Zoomstack endpoints to v2
2019-10-24 17:58:54 +01:00
Oliver Snowden
58bdd39f9e set OS Zoomstack endpoints to v2 2019-10-25 00:24:55 +08:00
Orange Mug
ab9ab7acc7 Merge pull request #574 from fredj/GitHub_sponsor
Activate sponsor button in GitHub
2019-10-24 16:02:16 +01:00
Frederic Junod
be39fd2ec8 Activate sponsor button in GitHub
See: https://help.github.com/en/github/building-a-strong-community/displaying-a-sponsor-button-in-your-repository
2019-10-24 16:51:45 +02:00
pathmapper
3c0185da27 Merge pull request #573 from pathmapper/node_13
Add node v13 to test runners
2019-10-24 05:59:12 +02:00
pathmapper
b37b7276fb Add node v13 to test runners 2019-10-23 11:10:05 +02:00
Orange Mug
c45cf2f0c8 Merge pull request #563 from orangemug/feature/more-root-property-support
Added support for more root level properties
2019-10-21 10:18:37 +01:00
Orange Mug
1f03fdbb50 Merge pull request #571 from orangemug/fix/map-perf-improvement
Remove shouldComponentUpdate from <MapboxGlMap/>
2019-10-20 12:50:33 +01:00
orangemug
f3b8c5362a Remove shouldComponentUpdate because mapbox-gl will do the diff for us, so updates will no longer diff twice. 2019-10-20 12:25:43 +01:00
Orange Mug
c9a5dd01be Merge pull request #570 from orangemug/feature/issue-559-add-raw-geojson-as-source
Add support for raw GeoJSON as source
2019-10-20 12:23:37 +01:00
orangemug
0fa4d40e92 Remove duplicate import rule. 2019-10-20 11:21:38 +01:00
orangemug
8a6e64c8c2 Merge remote-tracking branch 'upstream/master' into feature/issue-559-add-raw-geojson-as-source 2019-10-20 11:19:34 +01:00
orangemug
72b6dd1ae9 Fix lint errors. 2019-10-20 11:12:54 +01:00
orangemug
ee525631fa Fixes for codemirror in sources modal
- Allows for max height
 - Override GeoJSON data when changing type
2019-10-20 11:09:20 +01:00
pathmapper
ee9e055af3 Merge pull request #562 from orangemug/feature/json-editor-perf-improvements
react-codemirror2 -> codemirror directly
2019-10-19 21:56:59 +02:00
pathmapper
b214c6ac7e Merge pull request #566 from orangemug/feature/add-profiling-build
Added profiling build to CI
2019-10-19 21:55:20 +02:00
orangemug
eb75020861 Merge branch 'feature/json-editor-perf-improvements' into fix/issue-567-better-solution-for-tooltips 2019-10-19 16:56:45 +01:00
orangemug
a44e757e31 Initial work for new help text implementation. 2019-10-19 14:43:27 +01:00
orangemug
9ac908948d Changed label/content styling for input blocks. 2019-10-19 13:12:09 +01:00
orangemug
19e82e5890 Added support for raw GeoJSON 2019-10-19 13:11:29 +01:00
orangemug
bf84fd24ee Moved profiling to wdio-steps 2019-10-19 12:33:54 +01:00
orangemug
affeb7c751 Fixed lint errors. 2019-10-19 12:21:38 +01:00
orangemug
9743361e0d Added back in 'light position' and 'center' with fixes for <ArrayInput/>
This also improves the usage of *-translate which uses the <ArrayInput/>
2019-10-19 12:16:56 +01:00
orangemug
ab16120af2 Added invalid style to inputs 2019-10-19 12:07:08 +01:00
orangemug
37e5ba0fff Remove 'center' and 'light position', as they weren't working properly. 2019-10-16 22:36:41 +01:00
orangemug
0aa0dad7fb Remove undefined root properties. 2019-10-16 22:31:29 +01:00
orangemug
2910efde6e Allow removal of light/transition properties. 2019-10-16 21:58:24 +01:00
orangemug
eac7656786 <NumberInput/> unsetting fix. 2019-10-16 21:57:29 +01:00
Orange Mug
be3175beae Merge pull request #569 from fredj/layer-type-test-issue
Fix the layer type test in LayerEditor component
2019-10-16 19:21:03 +01:00
Frederic Junod
26de95a263 Fix the layer type test in LayerEditor component
`LayerSourceLayerBlock` was always included
2019-10-16 15:36:25 +02:00
orangemug
d0a47bd122 Added support for transition root property 2019-10-16 10:15:46 +01:00
orangemug
8c760bb810 Added default support to <EnumInput/> 2019-10-16 10:12:59 +01:00
orangemug
c27deefdef Added profiling build to CI 2019-10-16 09:56:26 +01:00
orangemug
392a845460 Moved "Style Renderer" options to bottom of list. 2019-10-16 08:24:25 +01:00
orangemug
e7622c2080 Added root level light property support. 2019-10-16 08:17:25 +01:00
orangemug
3a558412ba Merge remote-tracking branch 'upstream/master' into feature/added-light-property-support 2019-10-16 08:16:28 +01:00
Orange Mug
95e205943a Merge pull request #564 from orangemug/fix/typo-in-export
Fixed typo in export
2019-10-16 08:14:21 +01:00
orangemug
eb8686325c Fixed typo in export. 2019-10-16 08:13:37 +01:00
orangemug
1f77e156e6 Added support for root level properties
- center
 - zoom
 - bearing
 - pitch
2019-10-16 07:38:50 +01:00
orangemug
92ee50a4a4 Added default support to <ArrayInput/> 2019-10-16 07:36:30 +01:00
orangemug
ef23f01e67 Removed react-codemirror2 as we no longer use it 2019-10-16 06:49:11 +01:00
orangemug
22b6a4a2bf Added max-width to allow overfow scroll on JSONEditor 2019-10-16 06:46:30 +01:00
Orange Mug
201ecac156 Merge pull request #561 from fredj/ol_attribution_color
Set a color for the OpenLayers attribution control
2019-10-15 17:37:47 +01:00
orangemug
563a78ed42 Moved away from react-codemirror2 to interacting with codemirror directly. 2019-10-15 17:34:36 +01:00
Frederic Junod
47acc2640b Set a color for the OpenLayers attribution control 2019-10-15 14:37:04 +02:00
Orange Mug
f088788246 Merge pull request #557 from orangemug/feature/perf-improvements
LayerList performance improvements
2019-10-15 09:35:56 +01:00
Orange Mug
e219dcd332 Merge pull request #556 from orangemug/feature/add-new-mgljs-features
Added new features from the mapbox-gl spec
2019-10-14 10:04:42 +01:00
orangemug
b8829d9a5c Remove *-sort-key until we support expressions. 2019-10-14 09:22:21 +01:00
pathmapper
2c83c976c6 Merge pull request #558 from pathmapper/liberty_thumbnail
Update thumbnail source for OSM Liberty
2019-10-14 06:59:58 +02:00
orangemug
d63782ddf2 Remove react warnings. 2019-10-13 18:03:58 +01:00
orangemug
3eabcbec72 Fix <NumberInput/> to allow for empty value (reset value) 2019-10-13 18:00:32 +01:00
orangemug
00ab303e44 Stop LayerEditor using same DOM elements for different layers. 2019-10-13 17:59:11 +01:00
pathmapper
38bf12701e Update thumbnail source for OSM Liberty 2019-10-13 17:30:43 +02:00
orangemug
e4ec1d155a Added mapbox-gl features 'text-variable-anchor' and 'text-radial-offset' 2019-10-13 13:32:42 +01:00
orangemug
361f083687 Merge remote-tracking branch 'upstream/master' into feature/add-new-mgljs-features 2019-10-13 12:40:56 +01:00
orangemug
c1a59200e2 1.6.1 2019-10-13 12:02:26 +01:00
orangemug
6e0432ff5e Added back in minifcation. 2019-10-13 11:43:23 +01:00
orangemug
1c83de08c1 Fixed lint errors. 2019-10-12 12:08:25 +01:00
orangemug
0af828543b Disable minify 2019-10-12 12:06:33 +01:00
Orange Mug
369cc23a30 Merge pull request #553 from orangemug/maintenance/update-deps-20191009
Update dependencies
2019-10-12 11:56:38 +01:00
orangemug
db56ad8b2e Remove duplicate formatColor call. 2019-10-12 10:16:46 +01:00
orangemug
7fa17d81ac Some perf improvements when updating the layers list, also throttled color picker. 2019-10-12 10:10:33 +01:00
orangemug
019c6a0086 Merge remote-tracking branch 'origin/maintenance/update-deps-20191009' into maintenance/update-deps-20191009 2019-10-12 09:10:42 +01:00
orangemug
c1bee74b57 Switched back from using yarn to npm for lockfiles. 2019-10-12 09:09:39 +01:00
Orange Mug
b794279304 Bumped mapbox-gl to 1.4.1
Co-Authored-By: pathmapper <pathmapper@posteo.de>
2019-10-12 07:08:30 +01:00
Orange Mug
935dfa1704 Merge pull request #555 from pathmapper/update_omt_styles
Update OMT styles
2019-10-12 07:03:17 +01:00
pathmapper
bda7a0e659 Update OMT styles 2019-10-11 16:13:08 +02:00
orangemug
8d1cc340b8 Added new features text-writing-mode and *-sort-key 2019-10-10 08:52:36 +01:00
orangemug
338c6b59a8 Lock deps in package.json 2019-10-09 22:06:59 +01:00
orangemug
021f8ab400 Update all the dependencies 2019-10-09 19:51:57 +01:00
Orange Mug
f305db9e3e Merge pull request #551 from pathmapper/update_readme
Remove 1.6-beta from readme
2019-10-08 21:25:02 +01:00
pathmapper
e916b25594 Remove 1.6-beta from readme 2019-10-08 21:59:34 +02:00
orangemug
5f1e212759 1.6.0 2019-10-08 18:28:56 +01:00
pathmapper
2b7db498ef Merge pull request #548 from pathmapper/popup_scroll
Make popups scrollable
2019-09-17 10:00:29 +02:00
pathmapper
e6464790f6 Merge pull request #549 from pathmapper/beta_readme
Add 1.6.0-beta to readme
2019-08-22 10:55:31 +02:00
pathmapper
13ddf9f754 Link 1.6 beta from readme 2019-08-22 10:26:53 +02:00
pathmapper
30edb881ed Ensure popup is fully visible 2019-08-21 14:41:14 +02:00
pathmapper
b30bbdc248 Calculate popup height depending on viewport 2019-08-10 10:37:39 +02:00
pathmapper
824616f6bd Make popups scrollable 2019-08-09 15:55:52 +02: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
orangemug
109198a524 1.6.0-beta 2019-08-02 18:08:21 +02:00
pathmapper
920e4fe630 Merge pull request #545 from pathmapper/navcontrols
Fix css and increase color contrast for navcontrols
2019-08-01 14:21:51 +02:00
pathmapper
5e143e0a8e Fix css and increase color contrast 2019-08-01 13:59:34 +02:00
pathmapper
57f803d52c Merge pull request #544 from pathmapper/update_styles
Update available styles
2019-07-30 14:19:38 +02:00
pathmapper
c55d342c7e Remove empty line 2019-07-30 13:58:18 +02:00
pathmapper
e9065635cd Add toner and move empty style 2019-07-30 13:51:05 +02:00
pathmapper
6057721249 Merge pull request #543 from pathmapper/update_mb_dependencies
Update mapbox dependencies to current version
2019-07-30 10:51:04 +02:00
pathmapper
975487d271 Use visualizePitch option 2019-07-30 08:10:56 +02:00
pathmapper
46b2fd5978 Update mapbox dependencies to current version 2019-07-30 06:45:21 +02:00
pathmapper
f61313449f Merge pull request #542 from pathmapper/update_maptiler_key
Update Maptiler key
2019-07-29 20:35:07 +02:00
pathmapper
366ad4d7df Update Maptiler key
Provided by @klokan via e-mail
2019-07-29 18:21:42 +02:00
pathmapper
b5cfb44cf0 Merge pull request #512 from JesseCrocker/local-port
Add support for connecting to a local server on port other than 8000
2019-07-29 17:16:36 +02:00
pathmapper
050cc9cea9 Merge pull request #539 from pathmapper/update_mbgl
Update mapbox-gl and style spec to latest release
2019-07-17 09:41:58 +02:00
pathmapper
b2f194eeee Update mapbox-gl to 1.1.1 2019-07-17 09:18:47 +02:00
pathmapper
97b0b8541d Update mapbox-gl and style spec 2019-07-02 11:04:44 +02:00
Orange Mug
b5eb74fe20 Merge pull request #532 from pathmapper/fix_issue_471
Remove UNSAFE_componentWillUpdate
2019-06-28 16:42:08 +01:00
pathmapper
0500172d42 Update layer types 2019-06-23 09:55:32 +02:00
pathmapper
0e7bd98485 Use componentDidUpdate 2019-06-23 09:53:52 +02:00
Orange Mug
ff0ece5149 Merge pull request #531 from orangemug/fix/issue-509
Ability to delete properties completely
2019-06-21 17:42:09 +01:00
orangemug
db9ad86ac2 Filter empty strings in <FontInput/> 2019-06-21 08:05:09 +01:00
orangemug
a066710bfb Always put an empty field and the end of the FontInput and remove blank fields if empty 2019-06-21 07:58:43 +01:00
orangemug
52740483b6 Merge remote-tracking branch 'upstream/master' into fix/issue-509 2019-06-20 20:40:22 +01:00
orangemug
518a624e20 Updated to mapbox-gl 1.1.0-beta.1 2019-06-20 20:37:26 +01:00
pathmapper
4ba71c8bd5 Remove UNSAFE_componentWillUpdate 2019-06-20 09:52:54 +02:00
orangemug
ceeb628784 Added ability to delete color value. 2019-06-19 20:44:27 +01:00
orangemug
2ec6a90dc3 Allow removal of properties. 2019-06-19 20:34:28 +01:00
Orange Mug
4e37d834ed Merge pull request #530 from pathmapper/remove_node11
Remove node v11 from test runners
2019-06-17 09:03:28 +01:00
pathmapper
a7922d894d Remove node v11 from test runners 2019-06-17 09:05:39 +02:00
pathmapper
eeda3296ab Merge pull request #514 from pathmapper/node_v12_test_runners
Add node v12 to test runners
2019-06-17 06:49:30 +02:00
pathmapper
acd26e0162 Update only if wanted version is not available 2019-06-16 22:03:37 +02:00
pathmapper
fbf828e202 Merge branch 'master' into node_v12_test_runners 2019-06-16 21:21:33 +02:00
pathmapper
af9015f529 Merge pull request #526 from pathmapper/update_wdio
Update WebdriverIO to v5
2019-06-16 11:53:09 +02:00
Orange Mug
7a172b2022 Merge pull request #528 from pathmapper/renderer_metadata
Set default renderer if undefined
2019-06-16 10:03:37 +01:00
pathmapper
a609dc4029 Set default renderer if undefined 2019-06-16 05:27:53 +02:00
pathmapper
92bfee4bcc Use number input again for min/max-zoom tests 2019-06-13 07:18:35 +02:00
pathmapper
559d4618d1 Update wdio dependencies 2019-06-13 07:05:02 +02:00
pathmapper
5c391ee287 Update selenium-standalone used for testing and move wdio-steps to node active LTS 2019-06-08 18:34:03 +02:00
pathmapper
db74cfeb2a Update express and is-docker dependencies 2019-06-08 18:10:54 +02:00
pathmapper
726b825e4c Update mocha dependency 2019-06-08 17:55:08 +02:00
pathmapper
84d56b2606 Skip "upload" test for the open modal 2019-06-08 17:16:51 +02:00
pathmapper
e9a8b094a2 Update tests for WebdriverIO v5 2019-06-08 07:19:18 +02:00
pathmapper
924b14621a Update wdio.conf.js 2019-06-08 07:04:41 +02:00
pathmapper
b072e3a98c Update wdio and selenium dependencies 2019-06-08 06:59:47 +02:00
Orange Mug
827bd5fa24 Merge pull request #524 from orangemug/feature/ol-improvements
Further OpenLayers improvements
2019-06-01 17:39:40 +01:00
orangemug
9e0410afe6 Fix to reset map state on renderer change. 2019-06-01 08:28:22 +01:00
orangemug
ef08a9347e Disable debugToolbox by default. 2019-05-29 19:18:24 +01:00
orangemug
9b732540a6 Remove commented out code. 2019-05-29 19:16:17 +01:00
orangemug
24c52074b8 Fixed lint errors. 2019-05-29 18:59:26 +01:00
orangemug
cb6c6e0d9f Remove projection code for now. 2019-05-29 18:54:32 +01:00
orangemug
884dc6fa49 Fixed typos. 2019-05-29 18:28:47 +01:00
orangemug
efe42021f1 Some more openlayers improvments as well as initial work for projection support 2019-05-29 17:37:55 +01:00
pathmapper
470277c253 Merge pull request #523 from orangemug/feature/update-ol-plus-stability-fixes
Update openlayers + stability fixes
2019-05-22 09:47:13 +02:00
orangemug
c1cab38c7a Merge remote-tracking branch 'upstream/master' into feature/update-ol-plus-stability-fixes 2019-05-22 07:51:13 +01:00
orangemug
1cf36ddb08 Updated ol-mapbox-style/ol, added throttle to ol map update and fix to clear layers. 2019-05-22 07:32:06 +01:00
orangemug
1fec89b69e Moved back to data-wd-key approach and fixed tests 2019-05-21 19:07:28 +01:00
orangemug
911549aca3 Moved data-wd-key onto element 2019-05-21 18:54:09 +01:00
orangemug
41329ec2f8 Fixes for firefox, this makes the range input only update on pointerup 2019-05-21 18:42:19 +01:00
orangemug
15cdfbc980 Changed default of step 0.01 -> 1 2019-05-20 11:28:27 +01:00
orangemug
5053058c32 Fixed default values for range slider. 2019-05-20 11:21:23 +01:00
orangemug
8a8cfad303 Merge remote-tracking branch 'upstream/master' into feature/add-range-slider 2019-05-20 10:20:55 +01:00
Orange Mug
cc3c17078d Merge pull request #517 from orangemug/fix/editing-of-number-and-string-inputs
Fix for string/number inputs when inputting invalid of intermediate values
2019-05-20 10:15:25 +01:00
pathmapper
47965d5f57 Merge pull request #518 from orangemug/fix/color-accessibility-ua-switch
Toggle color accessibility based on user agent
2019-05-19 19:58:42 +02:00
Orange Mug
c947d9e3ed Merge pull request #516 from orangemug/fix/prevent-default-browser-undo-redo
Prevent native browser undo/redo when handled by app
2019-05-19 18:52:14 +01:00
Orange Mug
8318180e96 Merge pull request #519 from orangemug/feature/debug-modal
Added semi-hidden debug modal
2019-05-19 18:51:43 +01:00
orangemug
87daf6fb76 Fixes because I was incorrectly assuming mgljs only 2019-05-19 10:09:44 +01:00
pathmapper
5d254ac2ff Merge pull request #520 from orangemug/fix/color-filters-with-ol
Layout issues in accessibility color filters with the openlayers renderer
2019-05-19 10:04:16 +02:00
orangemug
482f322d9f Fixed layout issues in accessibilty color filters with the openlayers renderer
Also updated ol & ol-mapbox-style
2019-05-19 06:25:28 +01:00
orangemug
b1d097a40f Merge remote-tracking branch 'upstream/master' into feature/add-range-slider 2019-05-19 06:04:21 +01:00
Orange Mug
da456b08fe Merge pull request #444 from orangemug/feature/issue-433
Added color swatch to <FeatureLayerPopup/>
2019-05-18 19:15:27 +01:00
orangemug
2776ac3ce0 Added back in onOpenToggle 2019-05-18 19:06:54 +01:00
orangemug
eb2fc4c715 Fixed prop-type name. 2019-05-18 19:02:51 +01:00
orangemug
d2ffc3a0b1 Added semi-hidden debug modal and removed all this url param awkwardness 2019-05-18 18:54:10 +01:00
orangemug
40a9978f31 Removed console.log 2019-05-18 18:23:02 +01:00
orangemug
22688933b3 Toggle color accessibility based on user agent
It's only supported in chrome and firefox and we can't feature detect this.
2019-05-18 18:19:23 +01:00
orangemug
7cf01f0c12 Merge remote-tracking branch 'upstream/master' into feature/issue-433 2019-05-18 17:33:31 +01:00
orangemug
1e87765f95 Tidy and added fallback (exception) color. 2019-05-18 17:29:59 +01:00
orangemug
cc8fe4e02e Fix for buggy string/number inputs when inputting invalid of intermediate values 2019-05-18 15:56:14 +01:00
orangemug
979fc98e70 Prevent native browser undo/redo when handled by app 2019-05-18 15:47:51 +01:00
pathmapper
c3c0c35d8a Merge pull request #513 from pathmapper/update_readme
Update readme
2019-05-05 15:13:47 +02:00
pathmapper
f9913cad63 Use jsDelivr for Maputnik logo and sponsor images
To make them appear on https://hub.docker.com/r/maputnik/editor/.
2019-05-05 09:14:11 +02:00
pathmapper
0ed64f94e8 Fix link devDependencies 2019-05-05 08:58:34 +02:00
pathmapper
1deecd4e2a Update node-sass 2019-05-05 08:48:25 +02:00
pathmapper
e0e9201b46 Add node v12 to appveyor 2019-05-05 07:57:41 +02:00
pathmapper
362c7b437e Add node v12 to circleci 2019-05-05 07:47:50 +02:00
Jesse Crocker
efd0b547e9 Fix this being undefined 2019-04-16 09:19:36 -06:00
Jesse Crocker
afbaaa66bc Add support for using a port other than 8000 2019-04-16 08:23:21 -06:00
pathmapper
de8c687dfb Merge pull request #483 from sk1p/popup-cleanup
Various cleanups regarding popups and inspect mode
2019-04-16 07:29:19 +02:00
pathmapper
1bb079f078 Merge pull request #501 from pathmapper/issue_484
Fix JSON-editor
2019-04-16 07:05:43 +02:00
pathmapper
b35322522f Merge pull request #499 from pathmapper/scrollbar-ff
Firefox scrollbar styling
2019-04-15 07:48:15 +02:00
pathmapper
6a605571e0 Firefox scrollbar styling 2019-04-15 07:14:10 +02:00
pathmapper
c4ec77c911 Merge pull request #511 from pathmapper/update_stylelint
Update stylelint and remove node 6 from test-runners
2019-04-15 06:39:26 +02:00
pathmapper
f7643cee7e Fix appveyor lint-styles 2019-04-14 10:05:15 +02:00
pathmapper
cd95202dcc Update stylelint and remove node 6 from test-runners 2019-04-14 09:35:58 +02:00
pathmapper
facba3998b Merge pull request #510 from lukaswelte/master
Update mapbox dependencies to current version
2019-04-11 09:24:54 +02:00
Lukas Welte
1f9cc2ce33 Update mapbox dependencies to current version 2019-04-10 14:09:44 +02:00
pathmapper
ad505378ab Merge pull request #508 from pathmapper/master
Change Maptiler URLs
2019-04-08 10:13:16 +02:00
pathmapper
fb7b30c81d Add backwards compability for tilehosting URLs 2019-04-06 12:00:48 +02:00
pathmapper
cb3f93c67d Change Maptiler URLs 2019-04-03 09:51:43 +02:00
pathmapper
76cb5a6b7c Merge pull request #505 from maputnik/revert-504-readme_images
Revert "Readme: Use absolute URLs for logo and sponsor images"
2019-03-11 20:45:15 +01:00
pathmapper
990e47cb24 Revert "Readme: Use absolute URLs for logo and sponsor images" 2019-03-11 20:07:08 +01:00
pathmapper
8be7465428 Merge pull request #504 from pathmapper/readme_images
Use absolute URLs for logo and sponsor images
2019-03-11 19:31:14 +01:00
pathmapper
e2b7a6a517 Use absolute URLs for logo and sponsor images 2019-03-11 14:47:47 +01:00
pathmapper
284e00b665 Merge pull request #500 from pathmapper/appveyor_lint-styles
Appveyor add again lint-styles
2019-03-11 10:26:31 +01:00
pathmapper
1fbfa8428b Remove unused argument 2019-03-07 13:47:53 +01:00
pathmapper
b13b89c7ce Fix JSON-editor 2019-03-07 13:06:02 +01:00
pathmapper
3fa31e2a2e Merge pull request #485 from sk1p/icon-input-value-type
IconInput value type should be string, not array
2019-03-06 07:22:23 +01:00
pathmapper
0e7d2d8ff5 Appveyor lint-styles 2019-03-05 13:43:34 +01:00
pathmapper
2def3820dd Merge pull request #498 from pathmapper/node10-slim_for_docker
Use node:10-slim for Docker
2019-03-01 17:42:13 +01:00
pathmapper
e1a489f318 Use node:10-slim for Docker 2019-02-27 13:50:27 +01:00
pathmapper
760839eb83 Merge pull request #497 from pathmapper/externally-accessible-dev-server
How to start externally accessible dev server
2019-02-15 19:51:30 +01:00
pathmapper
7136d2dea3 How to start externally accessible dev server 2019-02-15 19:25:14 +01:00
pathmapper
21f4d26b50 Merge pull request #482 from sk1p/type-formatted-hotfix
Use StringInput for 'formatted' field type
2019-02-11 12:50:38 +01:00
pathmapper
627ea268c9 Merge pull request #495 from maputnik/fix/popup-tip-border-color
Fix/popup tip border color
2019-02-10 19:09:24 +01:00
pathmapper
65f77db4d6 Merge pull request #494 from pathmapper/fix-docker
Fix Docker
2019-02-10 10:11:12 +01:00
pathmapper
03b4f1eb8d Update Dockerfile 2019-02-10 07:58:37 +01:00
pathmapper
82d1fc0a8b Merge pull request #492 from pathmapper/pathmapper-readme-cli
Adding information regarding CLI
2019-02-09 14:36:38 +01:00
pathmapper
3b16de5df4 Adding information regarding CLI again 2019-02-09 14:15:23 +01:00
pathmapper
94d4070653 Merge pull request #490 from pathmapper/pathmapper-warning_docker
Dockerfile fix warning
2019-01-31 09:05:03 +01:00
pathmapper
d856a1cd8e Dockerfile fix warning 2019-01-29 14:14:28 +01:00
pathmapper
7c1d0f7bee Merge pull request #480 from pathmapper/update_status_badge
Update status badge: travis -> circleci
2019-01-22 14:46:36 +01:00
pathmapper
d02036321f Merge pull request #486 from fredj/spelling
Correct some spelling mistake in README
2019-01-22 14:44:45 +01:00
Frederic Junod
1edadcc6bb Correct some spelling mistake in README 2019-01-18 16:30:36 +01:00
Alexander Clausen
aa92091d2d IconInput value type should be string, not array 2019-01-06 18:07:38 +01:00
Alexander Clausen
14e0385575 Reflect current view in dropdown
Useful if the view is toggled between inspect and map via keyboard
shortcut.
2019-01-06 06:20:03 +01:00
Alexander Clausen
6cf861d44e Keep inspect mode consistent across renderer changes
If you were in inspect mode, switched to open layers, and back to
MapboxGlMap, the state in MapboxGlMap and MapboxInspect diverged,
meaning MapboxGlMap thought it was in inspect mode, while MapboxInspect
had inspector mode disabled.
2019-01-06 06:02:10 +01:00
Alexander Clausen
1375240bfa For better debuggability, actually keep one popup node around 2019-01-06 06:01:04 +01:00
Alexander Clausen
8f391d7d52 Cleanup popup nodes
Before, the component instances used for rendering popup content were
kept around, slowly leaking memory. This could be observed using react
developer tools.
2019-01-06 05:49:03 +01:00
Alexander Clausen
84654e81af MapboxGlMap: remove unused state variables 2019-01-06 05:39:19 +01:00
Alexander Clausen
7ff0524bb7 Allow inspect mode to count properly
Example: https://maputnik.github.io/editor/#12.86/54.38618/9.76697
2019-01-06 05:35:43 +01:00
Alexander Clausen
06c3c92fd6 Ensure key uniqueness in FeaturePropertyPopup 2019-01-06 05:35:11 +01:00
Alexander Clausen
4c2941e9b6 Use StringInput for 'formatted' field type 2019-01-05 22:38:58 +01:00
pathmapper
ed7a25646e Use master branch 2019-01-05 08:16:22 +01:00
pathmapper
8c821176cf Update status badge: travis -> circleci 2019-01-04 20:31:01 +01:00
Orange Mug
98ded98583 Merge pull request #476 from pathmapper/fix_issue_404
Use access token for fetchSources
2019-01-04 14:34:26 +00:00
Orange Mug
10ae69e41f Merge pull request #479 from maputnik/revert-465-source_layer_list
Revert "Use replaceAccessTokens in onStyleChanged"
2019-01-04 14:33:35 +00:00
Orange Mug
04531b4305 Revert "Use replaceAccessTokens in onStyleChanged" 2019-01-04 14:32:41 +00:00
Orange Mug
7ab4b2481c Merge pull request #477 from pathmapper/update_OMT_styles
Update OMT styles for v3.9
2019-01-04 14:31:37 +00:00
Orange Mug
6fa88e6869 Merge pull request #468 from meetar/shouldComponentUpdate-patch
shouldComponentUpdate hack
2019-01-04 14:31:14 +00:00
Orange Mug
5b90c31645 Merge pull request #465 from pathmapper/source_layer_list
Use replaceAccessTokens in onStyleChanged
2019-01-04 14:29:55 +00:00
pathmapper
5eba11faee Update OMT styles for v3.9 2018-12-19 10:57:06 +01:00
pathmapper
54b4fc473c Use access token for fetchSources 2018-11-27 13:51:26 +01:00
Orange Mug
fe8595cdc9 Merge pull request #474 from pathmapper/empty_style
Update empty-style URL
2018-11-26 10:48:07 +00:00
Orange Mug
2565a89474 Merge pull request #475 from pathmapper/rtl_blob
Set MIME type for RTL blob
2018-11-26 10:47:42 +00:00
pathmapper
92b970377d Set MIME type for RTL blob 2018-11-25 08:13:21 +01:00
pathmapper
dd3a550ec3 Update empty-style URL 2018-11-24 20:15:05 +01:00
Orange Mug
7d5d9e2d82 Merge pull request #470 from pathmapper/node_v11
Add node v11 to test runners and fix Appveyor
2018-11-19 11:42:52 +00:00
pathmapper
9daa71befc Bump node-sass 2018-11-18 19:23:06 +01:00
pathmapper
f10a2d28df Use Visual Studio 2015 for Appveyor 2018-11-18 11:05:29 +01:00
Orange Mug
d52c6c70bb Merge pull request #469 from morlay/master
make docker simpler
2018-11-17 15:34:18 +00:00
Orange Mug
6e2f46a0da Merge pull request #464 from pathmapper/fix-wobbling
Fix layer list wobbling
2018-11-17 15:18:41 +00:00
Orange Mug
2d6f91d0cd Merge pull request #447 from orangemug/fix/lock-logo-size-in-survey-popup
Fix the size of the logo in the survey modal
2018-11-17 15:17:51 +00:00
pathmapper
f409079d93 Bump wdio-mocha-framework 2018-11-17 13:48:17 +01:00
pathmapper
7004259867 Use previous VS image 2018-11-17 12:19:15 +01:00
pathmapper
f3128cb6d2 Add node v11 to test runners 2018-11-17 11:08:55 +01:00
Morlay
1dfd4d8d48 make docker simpler 2018-11-14 14:48:08 +08:00
Peter Richardson
2f30eb6cbe rm build 2018-11-12 20:50:20 -08:00
Peter Richardson
cf45c04069 add shouldComponentUpdate
checks for differences in props and state - addresses https://github.com/maputnik/editor/issues/467
2018-11-12 20:47:24 -08:00
Peter Richardson
05d149bcfa added build 2018-11-12 16:35:18 -08:00
pathmapper
3acbc3291c Remove duplicated line 2018-11-05 21:08:34 +01:00
pathmapper
24aa2fd5fa Use replaceAccessToken onStyleChanged 2018-11-05 08:17:21 +01:00
pathmapper
cc7d7a56f5 Fix wobbling 2018-11-04 10:38:58 +01:00
Orange Mug
da17646b8d Merge pull request #463 from pathmapper/color-contrast
Increase color contrast (fixes #318)
2018-11-04 09:08:30 +00:00
pathmapper
f9233a1e31 Increase color contrast 2018-11-03 18:01:34 +01:00
Orange Mug
c94f536e5a Merge pull request #459 from orangemug/feature/layer-list-ui-handle
Make whole layer label draggable
2018-11-02 20:48:14 +00:00
orangemug
b712e7f184 Merge remote-tracking branch 'upstream/master' into feature/layer-list-ui-handle
Conflicts:
	src/styles/_layer.scss
2018-11-02 17:57:42 +00:00
Orange Mug
b8ab802de5 Merge pull request #461 from pathmapper/helper
Style layer which is dragged
2018-11-02 17:55:44 +00:00
pathmapper
a74eb2989c Add helper class and style the helper 2018-11-02 14:25:31 +01:00
orangemug
3a0fc6eeac Fixed typo 2018-11-02 08:54:20 +00:00
Orange Mug
0f0684e701 Merge pull request #458 from pathmapper/debug
Add 'show-overdraw-inspector' query parameter
2018-11-02 08:50:20 +00:00
orangemug
e9b5bfb572 Remove old code. 2018-11-02 08:34:56 +00:00
orangemug
b456b59c44 Fix to allow high precision on text input and integer on range. 2018-11-02 08:28:51 +00:00
pathmapper
59ad91fdf8 Add 'show-overdraw-inspector' query parameter 2018-11-02 09:07:01 +01:00
orangemug
e18d304313 Changed min/max zoom range step from 0.1 -> 1 2018-11-01 18:28:58 +00:00
orangemug
5de5281b49 Prevent title resize. 2018-11-01 18:26:21 +00:00
orangemug
fe0df2a4ef Make range step configurable 2018-11-01 08:28:49 +00:00
orangemug
deec7894dd Make the whole layer label draggable 2018-11-01 08:12:40 +00:00
Orange Mug
c9a0c0400e Merge pull request #455 from pathmapper/autocomplete_z-index
Add z-index to autocomplete
2018-10-31 18:21:15 +00:00
pathmapper
419e62f69b Add z-index to autocomplete 2018-10-31 18:53:15 +01:00
Orange Mug
9ffbe3a7a2 Merge pull request #453 from orangemug/fix/more-menu-icon-size
Increase more-menu icon size, broken by react-icons update
2018-10-31 13:44:48 +00:00
orangemug
c8e548e3be Increase more-menu icon size, broken by react-icons update 2018-10-31 08:19:12 +00:00
Orange Mug
b9160bd333 Merge pull request #451 from pathmapper/firefox_select
Improve select styling
2018-10-31 08:05:22 +00:00
Orange Mug
8ad8b4cdea Merge pull request #450 from pathmapper/activate_renderer-test
Update tests for style settings modal
2018-10-31 08:03:18 +00:00
Orange Mug
c51c40a20e Merge pull request #448 from orangemug/fix/shortcut-fixes
Shortcut fixes
2018-10-31 08:02:13 +00:00
Orange Mug
2ccb1a8e0a Merge pull request #446 from pathmapper/fix-445
Remove node v9 from appveyor and update readme
2018-10-31 08:00:48 +00:00
pathmapper
008bb75c04 Remove border for select select 2018-10-30 22:12:52 +01:00
orangemug
a51fdb8435 Merge remote-tracking branch 'upstream/master' into feature/add-range-slider 2018-10-30 20:35:55 +00:00
orangemug
cdd5d27908 Added range slider to <NumberInput /> 2018-10-30 20:35:22 +00:00
orangemug
82d3c934c8 Merge remote-tracking branch 'upstream/master' into fix/lock-logo-size-in-survey-popup 2018-10-30 20:26:17 +00:00
orangemug
f2f0270936 Use KeyboardEvent.key rather than keyCode in attempt to support more keyboard layouts. 2018-10-30 20:12:48 +00:00
pathmapper
00f646d489 Update test runners and readme 2018-10-30 21:08:42 +01:00
Orange Mug
90a02df45c Merge pull request #449 from orangemug/fix/popup-tip-border-color
Fixes for 'mapboxgl-popup-tip' border color.
2018-10-30 19:57:52 +00:00
Orange Mug
ad40a15a77 Merge pull request #443 from pathmapper/style-parameter
Warning when style parameter is used
2018-10-30 19:50:26 +00:00
Orange Mug
d6809cb504 Merge pull request #409 from orangemug/fix/color-accessibility-styling-issue
Added hacks to fix styling issue
2018-10-30 19:46:41 +00:00
pathmapper
ff8d3055b4 Add test for TF access token 2018-10-30 20:37:56 +01:00
orangemug
1f81449e3c Added a visible drag handle. 2018-10-30 19:32:20 +00:00
pathmapper
c59e0cb046 Activate renderer test 2018-10-30 20:06:52 +01:00
pathmapper
2d1675c181 Fixes for code review comments 2018-10-29 17:35:12 +01:00
orangemug
48ebca6236 Fix the size of the logo in the survey modal so it doesn't cause a visual jump when it loads. 2018-10-29 13:12:01 +00:00
orangemug
bce8e8b807 Shortcut fixes
- Allow shortcuts to trigger from the shortcut modal
 - Fix inspect/map toggle shortcut
2018-10-29 13:07:49 +00:00
pathmapper
1f4dfa7603 Update readme (Node versions and CLI) 2018-10-29 13:56:09 +01:00
pathmapper
c23af0063d Add node v11 to the test runners 2018-10-29 13:42:01 +01:00
pathmapper
9f6250c489 Update tests 2018-10-29 11:16:27 +01:00
orangemug
cf6c6f1c17 Fixes for 'mapboxgl-popup-tip' border color. 2018-10-27 14:41:50 +01:00
orangemug
c6163b6ba2 Added missing css for popup changes 2018-10-27 14:14:20 +01:00
orangemug
7121a680b4 Add missing prop type 2018-10-27 14:08:23 +01:00
orangemug
cf391031f0 Added color swatch to <FeatureLayerPopup/> 2018-10-27 14:04:13 +01:00
pathmapper
9cac5305cd Warning when style parameter is used 2018-10-25 19:37:39 +02:00
pathmapper
b0adb8cd3d Remove style querystring parameter 2018-10-25 19:34:19 +02:00
Orange Mug
3d2a1d5d19 Merge pull request #439 from orangemug/feature/style-spec-additions
Style spec additions
2018-10-24 19:13:53 +01:00
Orange Mug
3c93c41de1 Merge pull request #442 from pathmapper/export-style-name
Use style name for export filename if available
2018-10-24 08:36:22 +01:00
Orange Mug
4baed5d8ab Merge pull request #441 from pathmapper/image_property
Move image property
2018-10-24 08:32:47 +01:00
pathmapper
f17b02b1fe Slugify result in lower case 2018-10-23 13:31:38 +02:00
pathmapper
3c72d07a88 Export stylename if available 2018-10-23 13:04:23 +02:00
orangemug
7495c0dfcf Added support for 'fill-extrusion-vertical-gradient' and 'symbol-z-order'
Also updated @mapbox/mapbox-gl-style-spec
2018-10-22 22:29:23 +01:00
Orange Mug
b0c877d4ae Merge pull request #418 from orangemug/fix/modal-exit-apply-changes
Delay modal close until blur events have triggered
2018-10-22 16:32:39 +01:00
Orange Mug
e1fd0f8014 Merge pull request #438 from pathmapper/top_issues
Create .topissuesrc
2018-10-21 11:48:21 +01:00
pathmapper
cb2198b661 Move image property 2018-10-21 11:28:05 +02:00
pathmapper
68beeeb599 Create .topissuesrc 2018-10-20 18:35:35 +02:00
orangemug
218ce148d5 Delay modal close until blur events have triggered. 2018-10-19 08:39:07 +01:00
Orange Mug
d0cafb06ee Merge pull request #414 from pathmapper/osm-libety_gh-pages
Use GitHub Pages for OSM Liberty
2018-10-17 13:06:13 +01:00
Orange Mug
5671a58704 Merge pull request #415 from pathmapper/pathmapper-update_empty-style
Update Empty Style
2018-10-17 13:05:19 +01:00
pathmapper
9cf74ca405 Update empty-style.json 2018-10-17 13:16:10 +02:00
pathmapper
1c6e3648eb Use GitHub Pages for OSM Liberty 2018-10-16 07:32:25 +02:00
Orange Mug
b3a4628a79 Merge pull request #413 from pathmapper/rawgit_shutdown
rawgit.com -> jsDelivr
2018-10-15 15:03:31 +01:00
pathmapper
941cc37c87 rawgit.com -> jsDelivr 2018-10-13 09:13:34 +02:00
Orange Mug
906d7ac3d5 Merge pull request #411 from orangemug/fix/autocomplete-only-autocomplete-strings
Stop autocomplete crashing the editor
2018-10-12 19:24:35 +01:00
orangemug
588b18d10e Only render strings in the autocomplete menu.
Expression objects were making there way into this menu which was crashing the editor.
2018-10-11 21:39:52 +01:00
Orange Mug
90024c5ec7 Merge pull request #408 from orangemug/maintenance/update-deps-2018-10-06
Updated dependencies
2018-10-10 15:15:26 +01:00
orangemug
889005de6c Set default value of autocomplete shouldItemRender value param as sometimes it's undefined 2018-10-09 21:11:47 +01:00
orangemug
843d3df8bc Fixed react-icons size/position. 2018-10-09 20:58:14 +01:00
orangemug
825b9044b9 Tidy naming. 2018-10-09 20:48:10 +01:00
orangemug
92a1be83b6 Moved babel config back out into .babelrc
This is due to .babelrc being used for other tooling.
2018-10-09 20:45:03 +01:00
orangemug
36e35eb208 Tidy webpack configs. 2018-10-09 20:43:35 +01:00
orangemug
2fcdb47fe5 Moved babel config, removed uglifyJs and decorators plugins 2018-10-09 20:14:16 +01:00
orangemug
012e4b670e Updated mapbox-gl and react-sortable-hoc usage 2018-10-08 09:32:21 +01:00
orangemug
492cc244d8 Added hacks to fix styling issue
See <https://github.com/maputnik/editor/pull/392#issuecomment-427595172>
2018-10-06 22:14:59 +01:00
orangemug
d17d6b43c0 Fixed merge issue. 2018-10-06 21:57:24 +01:00
orangemug
1bf10cd6d6 Merge remote-tracking branch 'upstream/master' into maintenance/update-deps-2018-10-06
Conflicts:
	src/components/App.jsx
	src/components/Toolbar.jsx
2018-10-06 21:39:26 +01:00
orangemug
b0cd9140be Updated remaining deps. 2018-10-06 21:21:42 +01:00
orangemug
cc6196969f Updated lockfile 2018-10-06 21:07:48 +01:00
orangemug
802a7eb1be Updated babel/webpack 2018-10-06 21:05:33 +01:00
Orange Mug
a666f86be0 Merge pull request #397 from orangemug/feature/ol-experimental-support
Added back in experimental OpenLayers support
2018-10-06 16:59:13 +01:00
Orange Mug
44fad76d45 Merge pull request #392 from orangemug/feature/color-accessibility-ui
Color accessibility UI
2018-10-06 16:58:32 +01:00
orangemug
c8d23a534e Updated some dev deps 2018-10-06 16:44:23 +01:00
orangemug
cf3650c8cd Updated react-icons 2018-10-06 16:38:08 +01:00
orangemug
1a8349f821 Updated deps with no API changes. 2018-10-06 16:01:34 +01:00
orangemug
855771a6b6 npm is getting confused about the lockfile. This now works locally from fresh install 2018-10-06 15:13:25 +01:00
orangemug
b711168e44 Move package-lock.json fixes... :/ 2018-10-06 15:00:34 +01:00
orangemug
4134919dde Added missing key attribute to <option/> 2018-10-06 14:44:12 +01:00
orangemug
158153e366 Revert package-lock.json update and build against node:10 2018-10-06 14:42:33 +01:00
orangemug
6b890d162a Merge remote-tracking branch 'upstream/master' into feature/ol-experimental-support 2018-10-06 14:06:10 +01:00
orangemug
1525807d06 setValue -> selectByValue 2018-10-06 13:59:50 +01:00
orangemug
a356bfd601 Switch from react-aria-menubutton to <select/> 2018-10-06 13:54:02 +01:00
Orange Mug
e6d2a6d5ff Merge pull request #384 from orangemug/feature/os-open-zoomstack
OS Open Zoomstack
2018-10-06 13:25:23 +01:00
Orange Mug
c8a004422f Merge pull request #406 from emuanalytics/bug/#380
Fix for Issue #380
2018-10-06 13:18:31 +01:00
Orange Mug
df457fc7bf Merge pull request #407 from pathmapper/get-name
Get name from package.json
2018-10-04 18:15:42 +01:00
pathmapper
6e03f1f077 get name from package.json 2018-10-04 16:42:39 +02:00
Robin Summerhill
4c13350c14 Issue #380 - fix for data functions 2018-10-03 20:11:53 +01:00
Orange Mug
63a2495c68 Merge pull request #405 from pathmapper/update-tilehosting
Update tilehosting URL
2018-10-01 21:21:24 +01:00
pathmapper
f9de73e18a Update tilehosting URL 2018-10-01 10:13:00 +02:00
Orange Mug
e6e2be61f0 Merge pull request #398 from orangemug/fix/load-url-error
Show error if style fails to load and disabled button if input is empty
2018-09-26 18:35:51 +01:00
Gregory Wolanski
060f7aa42c Merge pull request #400 from orangemug/feature/make-layer-visibility-always-shown
Make layer visibility icon shown when hidden
2018-09-24 22:19:07 +02:00
orangemug
8b0ae178b8 Added in thumbnails 2018-09-24 21:17:41 +01:00
orangemug
6b94e9b78b Merge remote-tracking branch 'upstream/master' into feature/os-open-zoomstack
Conflicts:
	src/config/styles.json
2018-09-24 21:14:55 +01:00
orangemug
b171bf3127 Fixes for code review comments. 2018-09-24 21:01:37 +01:00
orangemug
0c6a179cec Switch to using styleUrl for disabling button 2018-09-24 20:58:43 +01:00
Orange Mug
aa50785c12 Merge pull request #399 from orangemug/fix/added-default-prop
Added default isActive prop to Collapse component
2018-09-24 20:44:04 +01:00
orangemug
252403b1e3 Added classBlockModifier to <LayerAction/> and switched to only displaying icons for hidden layers 2018-09-24 20:40:51 +01:00
orangemug
bc1d0de057 Added default isActive prop to Collapse component 2018-09-24 16:55:53 +01:00
orangemug
4a0b9fd0de Added missing prop type 2018-09-24 15:13:35 +01:00
orangemug
e8777e1857 Updated package-lock.json 2018-09-24 15:10:00 +01:00
orangemug
94a2a16330 Updated ol* versions 2018-09-24 14:51:25 +01:00
orangemug
004d135d93 Show error if style fails to load and disabled button if input is empty 2018-09-24 14:41:09 +01:00
orangemug
0973dcee8a Added back in experimental OpenLayers support 2018-09-24 14:05:53 +01:00
Orange Mug
c908f7dcd0 Merge pull request #394 from orangemug/fix/request-abort-and-oerlapping-modals
Fix overlapping modals & request canceling
2018-09-23 22:28:39 +01:00
orangemug
b7fd889fcd Removed signal from fetch as not supported in all browsers. 2018-09-23 21:00:17 +01:00
orangemug
35600c253d Revert react-aria-modal 2018-09-23 20:43:34 +01:00
orangemug
673465af77 Use AbortController in activeRequest 2018-09-23 19:53:32 +01:00
orangemug
cc5d0dc4fe Merge remote-tracking branch 'upstream/master' into fix/request-abort-and-oerlapping-modals 2018-09-23 19:45:47 +01:00
orangemug
e6da977c48 Prevented overlapping modals in react tree and fixed request canceling. 2018-09-23 19:40:50 +01:00
orangemug
e4aa016713 Fixed lint errors 2018-09-23 14:50:29 +01:00
orangemug
8b67499a64 Removed external svg from filter command. 2018-09-23 14:48:19 +01:00
orangemug
bcdc7c6811 Improved color accessibility UI 2018-09-23 14:39:02 +01:00
orangemug
8f07a79a49 Merge remote-tracking branch 'upstream/master' into feature/color-accessibility-ui
Conflicts:
	src/components/App.jsx
	src/styles/_components.scss
2018-09-23 11:39:15 +01:00
orangemug
cdcf16196c Merge remote-tracking branch 'upstream/master' into feature/make-layer-visibility-always-shown
Conflicts:
	src/components/layers/LayerListItem.jsx
2018-09-23 09:07:02 +01:00
orangemug
a0ed6a379b Always show layer visibility toggle in layer list 2018-09-23 09:05:08 +01:00
Orange Mug
7ffb44f604 Merge pull request #391 from orangemug/maintenance/remove-mapbox-for-now
Remove mapbox for the time being
2018-09-22 18:28:00 +01:00
Orange Mug
225d0388ce Merge pull request #386 from orangemug/fix/showTileBoundaries-error
Added guard to map object
2018-09-22 16:15:00 +01:00
Orange Mug
0468db8cc2 Merge pull request #390 from orangemug/fix/switch-visibility-icons
Switch visibility icons
2018-09-22 15:51:10 +01:00
Orange Mug
695f612110 Merge pull request #389 from orangemug/maintenance/remove-travis
Remove travis CI
2018-09-22 15:50:49 +01:00
Orange Mug
9c07852b87 Merge pull request #388 from orangemug/fix/glyph-key-replace
Fix glyph key replace
2018-09-22 15:50:12 +01:00
orangemug
9ef198fb86 Merge remote-tracking branch 'upstream/master' into maintenance/remove-mapbox-for-now 2018-09-22 14:19:44 +01:00
orangemug
fd34e31462 Merge remote-tracking branch 'upstream/master' into fix/showTileBoundaries-error 2018-09-22 14:17:16 +01:00
orangemug
8eb49427fd Merge remote-tracking branch 'upstream/master' into fix/switch-visibility-icons 2018-09-22 14:15:43 +01:00
orangemug
ebafb3c3dd Merge remote-tracking branch 'upstream/master' into maintenance/remove-travis 2018-09-22 14:14:12 +01:00
orangemug
09c6154949 Merge remote-tracking branch 'upstream/master' into fix/glyph-key-replace 2018-09-22 14:12:39 +01:00
Orange Mug
53c8661cd3 Merge pull request #358 from orangemug/fix/remove-componentWillUpdate
Remove UNSAFE_componentWillReceiveProps
2018-09-22 14:11:58 +01:00
orangemug
3d5eec897e Try moving to 'Visual Studio 2017' image 2018-09-22 13:44:41 +01:00
orangemug
3763ec3737 Remove mapbox until we have a valid access token. 2018-09-22 13:18:52 +01:00
orangemug
f1216795d2 Swap layer visibility icons. 2018-09-22 13:12:36 +01:00
orangemug
0ac70df00f Remove travis as we now have CircleCI. 2018-09-22 13:06:56 +01:00
orangemug
7d0a985f1d Only replace glyphs key if a replacement exists. 2018-09-22 13:04:12 +01:00
orangemug
c5ff67b6e0 Appveyor nodejs -v6 +v10 2018-09-22 12:50:40 +01:00
orangemug
db6b9ac176 Added OS Open Zoomstack and styles 2018-09-20 19:26:53 +01:00
orangemug
77475af3c6 Added guard to map object 2018-09-20 19:16:23 +01:00
Orange Mug
805133d10c Merge pull request #383 from pathmapper/master
Access token labels OMT -> MapTiler
2018-09-15 10:03:21 +01:00
pathmapper
fff8fb72c5 Access token labels OMT - MapTiler 2018-09-14 09:08:04 +02:00
Orange Mug
e02b18cea3 Merge pull request #378 from pathmapper/patch-1
fix typo
2018-09-13 08:52:12 +01:00
pathmapper
b8e9307ce2 fix typo 2018-09-11 13:52:39 +02:00
orangemug
00b22eb902 OpenLayers removed in previous PR. 2018-09-10 15:11:06 +01:00
orangemug
be954143c3 Switch to setTimeout(fn, 0) 2018-09-10 15:09:34 +01:00
orangemug
b314642586 Rollback to setImmediate 2018-09-10 14:55:45 +01:00
orangemug
b5fc315b37 setImmediate -> process.nextTick 2018-09-10 14:51:22 +01:00
orangemug
26ff9f63bb Merge remote-tracking branch 'upstream/master' into fix/remove-componentWillUpdate
Conflicts:
	src/components/map/MapboxGlMap.jsx
	src/components/modals/ExportModal.jsx
2018-09-10 14:46:52 +01:00
Orange Mug
7e5fb4d42f Merge pull request #364 from orangemug/maintenance/reduce-bundle-size-v2
Reduce bundle size
2018-09-10 14:12:03 +01:00
Orange Mug
762bb786be Merge pull request #365 from orangemug/feature/added-no-webgl-error
Added no WebGL error message to MapboxGL map component
2018-09-10 14:09:09 +01:00
Orange Mug
cec87765fc Merge pull request #366 from loicgasser/maintenance/transform-class-properties-and-arrow-func
Take advantage of transform-class-properties and use arrow functions
2018-09-10 14:08:46 +01:00
orangemug
b966fae926 1.5.0 2018-09-10 13:18:21 +01:00
Loïc Gasser
a4b4d077fa Fix .babelrc 2018-08-23 00:18:39 -04:00
Loïc Gasser
bc2ec4d0b7 Remove unused imports 2018-08-23 00:18:39 -04:00
Loïc Gasser
e4de101553 Take advantage of transform-class-properties and use arrow functions instead of bind 2018-08-23 00:18:37 -04:00
orangemug
6207416b32 Added no WebGL error message to MapboxGL map component 2018-08-22 22:05:46 +01:00
orangemug
f0202241f4 Remove old base64 loader. 2018-08-22 18:51:58 +01:00
orangemug
0e8c94af1e Remove logging. 2018-08-22 18:51:42 +01:00
orangemug
922ee616ec Reduce bundle size
- Use the browsers fetch rather than the request module
 - base64-loader -> raw-loader
 - Remove ol3 because it's been broken for a while
 - Removed old GitHub gist support as it's no longer functional
 - Removed Mousetrap as we were only using a small part of the functionality
 - Moved to single js file to make things simplier
2018-08-22 09:36:34 +01:00
orangemug
409f81f0d8 More componentWillUpdate transition fixes. 2018-08-07 20:13:45 +01:00
orangemug
1aa90bef37 Removed componentWillUpdate 2018-08-06 22:27:03 +01:00
orangemug
85a28999fb Initial color accessibility UI 2018-06-18 20:28:24 +01:00
255 changed files with 55048 additions and 17578 deletions

View File

@@ -1,11 +1,19 @@
{
"presets": ["env", "react"],
"plugins": ["transform-object-rest-spread", "transform-class-properties"],
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"static-fs",
"react-hot-loader/babel",
"@babel/plugin-proposal-class-properties",
"@babel/transform-runtime"
],
"env": {
"test": {
"plugins": [
["istanbul", {
exclude: ["node_modules/**", "test/**"]
"exclude": ["node_modules/**", "test/**"]
}]
]
}

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
- run: npm run lint-styles
- 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 lint
- run: npm run lint-styles
- 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-v6:
docker:
- image: node:6
working_directory: ~/repo-linux-node-v6
steps: *build-steps
build-linux-node-v8:
docker:
- image: node:8
- image: selenium/standalone-chrome:3.8.1
working_directory: ~/repo-linux-node-v8
steps: *wdio-steps
build-linux-node-v10:
docker:
- image: node:10
working_directory: ~/repo-linux-node-v10
steps: *build-steps
build-osx-node-v6:
macos:
xcode: "9.0"
dependencies:
override:
- brew install node@6
working_directory: ~/repo-osx-node-v6
steps: *build-steps
build-osx-node-v8:
macos:
xcode: "9.0"
dependencies:
override:
- brew install node@8
working_directory: ~/repo-osx-node-v8
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
workflows:
version: 2
build:
jobs:
- build-linux-node-v6
- build-linux-node-v8
- build-linux-node-v10
- build-osx-node-v6
- build-osx-node-v8
- build-osx-node-v10

4
.codesandbox/ci.json Normal file
View File

@@ -0,0 +1,4 @@
{
"packages": [],
"sandboxes": ["/"]
}

45
.dockerignore Normal file
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

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
custom: "https://maputnik.github.io/donate"

27
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
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
.github/ISSUE_TEMPLATE/other-issue.md vendored Normal file
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) -->

193
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,193 @@
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@v2
- 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: [16.x]
steps:
- uses: actions/checkout@v2
- 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: [16.x]
steps:
- uses: actions/checkout@v2
- 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@v2
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/
# build and test the editor
test_selenium_standalone:
name: "test/standalone-${{ matrix.browser }} (${{ 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: [16]
browser: [chrome, firefox]
container:
image: node:${{ matrix.node-version }}
options: --network-alias testhost
services:
selenium:
# geckodriver-0.31 seems to have problems as of 2022 May 1
image: selenium/standalone-${{ matrix.browser == 'firefox' && 'firefox:99.0-geckodriver-0.30-20220427' || matrix.browser }}
ports:
- 4444:4444
options: --shm-size=2gb
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: BROWSER=${{ matrix.browser }} TEST_NETWORK=testhost DOCKER_HOST=selenium npm run test
- if: ${{ matrix.browser == 'chrome' }}
run: ./node_modules/.bin/istanbul report --include build/coverage/coverage.json --dir build/coverage html lcov
- if: ${{ matrix.browser == 'chrome' }}
name: artifacts/coverage
uses: actions/upload-artifact@v1
with:
name: coverage
path: build/coverage
- name: artifacts/screenshots
uses: actions/upload-artifact@v1
with:
name: screenshots-${{ matrix.browser }}
path: build/screenshots

28
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,28 @@
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@v2
- 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

24
.storybook/main.js Normal file
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
.storybook/manager.js Normal file
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,
});

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',
});

15
.topissuesrc Normal file
View File

@@ -0,0 +1,15 @@
{
"labels": {
"bug": 5,
"maintenance": 3,
"mentioned in the 1st survey": 2
},
"reactions": {
"+1": 2,
"-1": -1,
"laugh": 1,
"hooray": 2,
"confused": 1,
"heart": 2
}
}

View File

@@ -1,22 +0,0 @@
language: node_js
matrix:
include:
- os: osx
node_js: "6"
- os: osx
node_js: "8"
- os: osx
node_js: "9"
install:
- npm install
script:
- mkdir public
- node --stack_size=100000 $(which npm) run build
- npm run lint
- npm run lint-styles
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8

View File

@@ -1,15 +1,22 @@
FROM nodesource/xenial:6.1.0
FROM node:10 as builder
WORKDIR /maputnik
EXPOSE 8888
# Only copy package.json to prevent npm install from running on every build
COPY package.json package-lock.json ./
RUN npm install
ENV HOME /maputnik
RUN mkdir ${HOME}
COPY . ${HOME}/
WORKDIR ${HOME}
RUN npm install -d --dev
# Build maputnik
# TODO: we should also do a npm run test here (needs more dependencies)
COPY . .
RUN npm run build
CMD npm run start -- --host 0.0.0.0
#---------------------------------------------------------------------------
# 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

View File

@@ -1,32 +1,30 @@
# Maputnik
<img width="200" alt="Maputnik logo" src="https://cdn.jsdelivr.net/gh/maputnik/design/logos/logo-color.png" />
[![Build Status](https://travis-ci.org/maputnik/editor.svg?branch=master)][travis]
[![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]
[travis]: https://travis-ci.org/maputnik/editor
[appveyor]: https://ci.appveyor.com/project/lukasmartinelli/editor
[dm-prod]: https://david-dm.org/maputnik/editor
[dm-dev]: https://david-dm.org/maputnik/editor#info=devDependencies
[license]: https://tldrlegal.com/license/mit-license
<img width="200" align="right" alt="Maputnik" src="src/img/maputnik.png" />
[github-action-ci]: https://github.com/maputnik/editor/actions?query=workflow%3Aci
[license]: https://tldrlegal.com/license/mit-license
A free and open visual editor for the [Mapbox GL styles](https://www.mapbox.com/mapbox-gl-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: 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 independance 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!
@@ -40,10 +38,7 @@ The documentation can be found in the [Wiki](https://github.com/maputnik/editor/
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/).
We ensure building and developing Maputnik works with
- Linux, OSX and Windows
- Node >4
We ensure building and developing Maputnik works with the [current active LTS Node.js version and above](https://github.com/nodejs/Release#release-schedule).
Install the deps, start the dev server and open the web browser on `http://localhost:8888/`.
@@ -51,15 +46,21 @@ 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
```
The build process will watch for changes to the filesystem, rebuild and autoreload the editor. However note this from the webpack-dev-server docs
If you want Maputnik to be accessible externally use the [`--host` option](https://webpack.js.org/configuration/dev-server/#devserverhost):
> webpack uses the file system to get notified of file changes. In some cases this does not work. For example, when using Network File System (NFS). Vagrant also has a lot of problems with this.
Snippet from <https://webpack.js.org/configuration/dev-server/#devserver-watchoptions->
```bash
# start externally accessible dev server
npm run start -- --host 0.0.0.0
```
To enable polling add `export WEBPACK_DEV_SERVER_POLLING=1` to your enviroment.
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/):
> webpack uses the file system to get notified of file changes. In some cases this does not work. For example, when using Network File System (NFS). Vagrant also has a lot of problems with this. ([snippet source](https://webpack.js.org/configuration/dev-server/#devserverwatchoptions-))
To enable polling add `export WEBPACK_DEV_SERVER_POLLING=1` to your environment.
```
npm run build
@@ -75,26 +76,18 @@ npm run lint-styles
## Tests
For testing we use [webdriverio](http://webdriver.io) and [selenium-standalone](https://github.com/vvo/selenium-standalone)
For testing we use [webdriverio](https://webdriver.io) and [selenium-standalone](https://github.com/webdriverio/selenium-standalone).
[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.
[selenium-standalone](https://github.com/webdriverio/selenium-standalone) starts a server that will launch browsers on your local machine. You need to have Java installed on your machine as well as *chrome* or *firefox*.
Now open and 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
```
Now start the standalone server
or *firefox*:
```
./node_modules/.bin/selenium-standalone start
```
Then open another terminal and run
```
npm test
BROWSER=firefox npm run test
```
After some time you should see a browser launch which will be automated by the test runner.
@@ -102,7 +95,7 @@ After some time you should see a browser launch which will be automated by the t
## 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
@@ -115,13 +108,13 @@ Thanks to the supporters of the **[Kickstarter campaign](https://www.kickstarter
- [Terranodo](http://terranodo.io/)
<a href="https://getwemap.com/">
<img width="33%" alt="Wemap" style="display:inline" src="media/sponsors/wemap.jpg" />
<img width="33%" alt="Wemap" style="display:inline" src="https://cdn.jsdelivr.net/gh/maputnik/editor@1.5.0/media/sponsors/wemap.jpg" />
</a>
<a href="http://terranodo.io/">
<img width="33%" alt="Terranodo" style="display:inline" src="media/sponsors/terranodo.png" />
<img width="33%" alt="Terranodo" style="display:inline" src="https://cdn.jsdelivr.net/gh/maputnik/editor@1.5.0/media/sponsors/terranodo.png" />
</a>
<a href="https://www.orbiconinformatik.dk/">
<img width="32%" alt="Terranodo" style="display:inline" src="media/sponsors/orbicon_informatik.png" />
<img width="32%" alt="Terranodo" style="display:inline" src="https://cdn.jsdelivr.net/gh/maputnik/editor@1.5.0/media/sponsors/orbicon_informatik.png" />
</a>
<br/>
@@ -133,13 +126,13 @@ Thanks to the supporters of the **[Kickstarter campaign](https://www.kickstarter
- [Dreipol](https://www.dreipol.ch/)
<a href="https://www.klokantech.com/">
<img width="18%" alt="Klokan Technologies" style="display:inline-block" src="media/sponsors/klokantech.png" />
<img width="18%" alt="Klokan Technologies" style="display:inline-block" src="https://cdn.jsdelivr.net/gh/maputnik/editor@1.5.0/media/sponsors/klokantech.png" />
</a>
<a href="http://www.geofabrik.de/">
<img width="18%" alt="Geofabrik" style="display:inline-block" src="media/sponsors/geofabrik.png" />
<img width="18%" alt="Geofabrik" style="display:inline-block" src="https://cdn.jsdelivr.net/gh/maputnik/editor@1.5.0/media/sponsors/geofabrik.png" />
</a>
<a href="https://www.dreipol.ch/">
<img width="18%" alt="Dreipol" style="display:inline-block" src="media/sponsors/dreipol.png" />
<img width="18%" alt="Dreipol" style="display:inline-block" src="https://cdn.jsdelivr.net/gh/maputnik/editor@1.5.0/media/sponsors/dreipol.png" />
</a>
<br/>
@@ -162,6 +155,6 @@ 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 a independent style editor for the
**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.
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.

View File

@@ -1,17 +0,0 @@
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "9"
platform:
- x86
- x64
install:
- ps: Install-Product node $env:nodejs_version
- md public
- npm install --global --production windows-build-tools
- npm install
build_script:
- npm run build
test_script:
- npm run lint

View File

@@ -3,60 +3,45 @@ 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: 'local',
path: '/wd/hub',
specs: [
'./test/functional/index.js'
],
exclude: [
],
maxInstances: 10,
capabilities: [{
maxInstances: 5,
browserName: 'chrome'
}],
sync: true,
logLevel: 'verbose',
coloredLogs: true,
capabilities: [
{
maxInstances: 5,
browserName: (process.env.BROWSER || 'chrome'),
}
],
// geckodriver-0.31 seems to have problems as of 2022 May 1
services: process.env.DOCKER_HOST ? [] : [ ['selenium-standalone', { drivers: { firefox: '0.30.0', chrome: 'latest' } } ] ],
logLevel: 'info',
bail: 0,
screenshotPath: SCREENSHOT_PATH,
// Note: This is here because @orangemug currently runs Maputnik inside a docker container.
host: process.env.DOCKER_HOST || "0.0.0.0",
baseUrl: 'http://localhost',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
hostname: process.env.DOCKER_HOST || "0.0.0.0",
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
// Because we don't know how long the initial build will take...
timeout: 4*60*1000
timeout: 4*60*1000,
},
onPrepare: function (config, capabilities) {
return new Promise(function(resolve, reject) {
var compiler = webpack(webpackConfig);
server = new WebpackDevServer(compiler, {
stats: {
colors: true
}
});
server.listen(testConfig.port, (isDocker() ? "0.0.0.0" : "localhost"), function(err) {
if(err) {
reject(err);
}
else {
resolve();
}
});
})
onPrepare: async function (config, capabilities) {
webpackConfig.devServer.host = testConfig.testNetwork;
webpackConfig.devServer.port = testConfig.port;
const compiler = webpack(webpackConfig);
server = new WebpackDevServer(webpackConfig.devServer, compiler);
await server.start();
},
onComplete: function(exitCode) {
server.close()
onComplete: async function (exitCode, config, capabilities) {
await server.stop();
}
}

View File

@@ -1,8 +1,8 @@
"use strict";
var webpack = require('webpack');
var path = require('path');
var loaders = require('./webpack.loaders');
var rules = require('./webpack.rules');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var HtmlWebpackInlineSVGPlugin = require('html-webpack-inline-svg-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
const HOST = process.env.HOST || "127.0.0.1";
@@ -10,6 +10,7 @@ const PORT = process.env.PORT || "8888";
module.exports = {
target: 'web',
mode: 'development',
entry: [
`webpack-dev-server/client?http://${HOST}:${PORT}`,
`webpack/hot/only-dev-server`,
@@ -27,7 +28,7 @@ module.exports = {
noParse: [
/mapbox-gl\/dist\/mapbox-gl.js/
],
loaders: loaders
rules: rules
},
node: {
fs: "empty",
@@ -35,36 +36,39 @@ 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'
}),
new CopyWebpackPlugin([
{
from: './src/manifest.json',
to: 'manifest.json'
}
])
new HtmlWebpackInlineSVGPlugin({
runPreEmit: true,
}),
new CopyWebpackPlugin({
patterns: [
{
from: './src/manifest.json',
to: 'manifest.json'
}
]
})
]
};

View File

@@ -1,55 +0,0 @@
module.exports = [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components|public)/,
loaders: ['react-hot-loader/webpack']
},
// HACK: This is a massive hack and reaches into the mapbox-gl private API.
// We have to include this for access to `normalizeSourceURL`. We should
// remove this ASAP, see <https://github.com/mapbox/mapbox-gl-js/issues/2416>
{
test: /.*node_modules[\/\\]mapbox-gl[\/\\]src[\/\\]util[\/\\].*\.js/,
loader: 'babel-loader',
query: {
presets: ['env', 'react', 'flow'],
plugins: ['transform-runtime', 'transform-decorators-legacy', 'transform-class-properties'],
}
},
{
test: /\.jsx?$/,
// Note: These modules aren't ES5 therefore we much compile them.
exclude: /(.*node_modules(?![\/\\](@mapbox[\/\\]mapbox-gl-style-spec|ol|mapbox-to-ol-style))|bower_components|public)/,
loader: 'babel-loader',
query: {
presets: ['env', 'react'],
plugins: ['transform-runtime', 'transform-decorators-legacy', 'transform-class-properties'],
}
},
{
test: /\.(eot|ttf|woff|woff2)$/,
loader: 'file-loader?name=fonts/[name].[ext]'
},
{
test: /\.ico$/,
loader: 'file-loader?name=[name].[ext]'
},
{
test: /\.(svg|gif|jpg|png)$/,
loader: 'file-loader?name=img/[name].[ext]'
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /[\/\\](node_modules|global|src)[\/\\].*\.scss$/,
loaders: ["style-loader", "css-loader", "sass-loader"]
},
{
test: /[\/\\](node_modules|global|src)[\/\\].*\.css$/,
loaders: [
'style-loader?sourceMap',
'css-loader'
]
}
];

View File

@@ -1,43 +1,23 @@
var webpack = require('webpack');
var path = require('path');
var loaders = require('./webpack.loaders');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var rules = require('./webpack.rules');
var HtmlWebpackPlugin = require('html-webpack-plugin');
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 UglifyJsPlugin = require('uglifyjs-webpack-plugin');
var OUTPATH = artifacts.pathSync("/build");
module.exports = {
entry: {
app: './src/index.jsx',
vendor: [
'file-saver',
'mapbox-gl/dist/mapbox-gl.js',
"lodash.clonedeep",
"lodash.throttle",
'color',
'react',
"react-dom",
"react-color",
"react-file-reader-input",
"react-collapse",
"react-height",
"react-icon-base",
"react-motion",
"react-sortable-hoc",
"request",
//TODO: Icons raise multi vendor errors?
//"react-icons",
]
},
output: {
path: OUTPATH,
filename: '[name].[chunkhash].js',
chunkFilename: '[chunkhash].js'
filename: '[name].[contenthash].js',
chunkFilename: '[contenthash].js'
},
resolve: {
extensions: ['.js', '.jsx']
@@ -46,7 +26,7 @@ module.exports = {
noParse: [
/mapbox-gl\/dist\/mapbox-gl.js/
],
loaders
rules: rules
},
node: {
fs: "empty",
@@ -55,27 +35,27 @@ module.exports = {
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: '[chunkhash].vendor.js' }),
new WebpackCleanupPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new UglifyJsPlugin(),
new ExtractTextPlugin('[contenthash].css', {
allChunks: true
}),
new HtmlWebpackPlugin({
template: './src/template.html',
title: 'Maputnik'
}),
new CopyWebpackPlugin([
{
from: './src/manifest.json',
to: 'manifest.json'
}
]),
new HtmlWebpackInlineSVGPlugin({
runPreEmit: true,
}),
new CopyWebpackPlugin({
patterns: [
{
from: './src/manifest.json',
to: 'manifest.json'
}
]
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
defaultSizes: 'gzip',

View File

@@ -0,0 +1,20 @@
const webpackProdConfig = require('./webpack.production.config');
const artifacts = require("../test/artifacts");
const OUTPATH = artifacts.pathSync("/profiling");
module.exports = {
...webpackProdConfig,
output: {
...webpackProdConfig.output,
path: OUTPATH,
},
resolve: {
...webpackProdConfig.resolve,
alias: {
...webpackProdConfig.resolve.alias,
'react-dom$': 'react-dom/profiling',
'scheduler/tracing': 'scheduler/tracing-profiling',
}
}
};

44
config/webpack.rules.js Normal file
View File

@@ -0,0 +1,44 @@
const path = require("path");
module.exports = [
{
test: /\.jsx?$/,
exclude: [
path.resolve(__dirname, '../node_modules')
],
use: 'babel-loader'
},
{
test: /\.(eot|ttf|woff|woff2)$/,
use: 'file-loader?name=fonts/[name].[ext]'
},
{
test: /\.ico$/,
use: 'file-loader?name=[name].[ext]'
},
{
test: /\.(gif|jpg|png)$/,
use: 'file-loader?name=img/[name].[ext]'
},
{
test: /\.svg$/,
use: [
'svg-inline-loader'
]
},
{
test: /[\/\\](node_modules|global|src)[\/\\].*\.scss$/,
use: [
'style-loader',
"css-loader",
"sass-loader"
]
},
{
test: /[\/\\](node_modules|global|src)[\/\\].*\.css$/,
use: [
'style-loader',
'css-loader'
]
}
];

56380
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,22 @@
{
"name": "maputnik",
"version": "1.5.0-beta3",
"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",
"stats": "webpack --config config/webpack.production.config.js --progress=profile --json > stats.json",
"build": "webpack --config config/webpack.production.config.js --progress=profile --color",
"profiling-build": "webpack --config config/webpack.profiling.config.js --progress=profile --color",
"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",
"lint": "eslint --ext js --ext jsx {src,test}",
"lint-styles": "stylelint 'src/styles/*.scss'",
"nsp": "nsp check --reporter summary"
"start": "webpack-dev-server --progress=profile --color --config config/webpack.config.js",
"start-prod": "webpack-dev-server --progress=profile --color --config config/webpack.production.config.js",
"start-sandbox": "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",
"storybook": "start-storybook -h 0.0.0.0 -p 6006",
"build-storybook": "build-storybook -o build/storybook"
},
"repository": {
"type": "git",
@@ -21,44 +26,50 @@
"license": "MIT",
"homepage": "https://github.com/maputnik/editor#readme",
"dependencies": {
"@mapbox/mapbox-gl-rtl-text": "^0.2.0",
"@mapbox/mapbox-gl-style-spec": "^13.1.0",
"classnames": "^2.2.5",
"codemirror": "^5.37.0",
"color": "^3.0.0",
"file-saver": "^1.3.8",
"github-api": "^3.0.0",
"@babel/runtime": "^7.17.9",
"@mapbox/mapbox-gl-rtl-text": "^0.2.3",
"@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.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": "^0.47.0",
"mapbox-gl-inspect": "^1.3.1",
"maputnik-design": "github:maputnik/design",
"mousetrap": "^1.6.1",
"ol-mapbox-style": "^2.10.1",
"ol": "^4.6.5",
"prop-types": "^15.6.0",
"react": "^16.3.2",
"react-addons-pure-render-mixin": "^15.6.2",
"react-aria-menubutton": "^5.1.1",
"react-aria-modal": "^2.12.1",
"react-autocomplete": "^1.7.2",
"react-codemirror2": "^4.2.1",
"react-collapse": "^4.0.3",
"react-color": "^2.14.1",
"react-copy-to-clipboard": "^5.0.1",
"react-dom": "^16.3.2",
"react-file-reader-input": "^1.1.4",
"react-height": "^3.0.0",
"react-icon-base": "^2.1.1",
"react-icons": "^2.2.7",
"react-motion": "^0.5.2",
"react-sortable-hoc": "^0.6.8",
"reconnecting-websocket": "^3.2.2",
"request": "^2.85.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.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": "^4.3.1",
"react-sortable-hoc": "^2.0.0",
"reconnecting-websocket": "^4.4.0",
"sass": "^1.50.0",
"slugify": "^1.6.5",
"string-hash": "^1.1.3",
"url": "^0.11.0"
},
"jshintConfig": {
@@ -90,7 +101,7 @@
"node": true,
"es6": true
},
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
@@ -99,61 +110,66 @@
"experimentalObjectRestSpread": true,
"jsx": true
}
},
"settings": {
"react": {
"version": "detect"
}
}
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-loader": "7.1.4",
"babel-plugin-istanbul": "^4.1.6",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.26.0",
"babel-runtime": "^6.26.0",
"base64-loader": "^1.0.0",
"copy-webpack-plugin": "^4.5.1",
"cors": "^2.8.4",
"cross-env": "^5.1.4",
"css-loader": "^0.28.11",
"eslint": "^4.19.1",
"eslint-plugin-react": "^7.4.0",
"express": "^4.16.3",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"html-webpack-plugin": "^3.2.0",
"is-docker": "^1.1.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",
"@wdio/cli": "^7.19.3",
"@wdio/local-runner": "^7.19.3",
"@wdio/mocha-framework": "^7.19.3",
"@wdio/selenium-standalone-service": "^7.19.1",
"@wdio/spec-reporter": "^7.19.1",
"babel-loader": "^8.2.4",
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-static-fs": "^3.0.0",
"copy-webpack-plugin": "^6.4.1",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"css-loader": "^5.2.7",
"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": "^1.2.0",
"json-loader": "^0.5.7",
"mkdirp": "^0.5.1",
"mocha": "^5.1.1",
"node-sass": "^4.9.0",
"nsp": "^3.1.0",
"react-hot-loader": "^3.1.1",
"sass-loader": "^7.0.1",
"selenium-standalone": "^6.14.0",
"style-loader": "^0.20.3",
"stylelint": "^9.2.0",
"stylelint-config-recommended-scss": "^3.2.0",
"stylelint-scss": "^3.0.0",
"istanbul-lib-coverage": "^3.2.0",
"mkdirp": "^1.0.4",
"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",
"uglifyjs-webpack-plugin": "^1.2.4",
"uuid": "^3.1.0",
"wdio-mocha-framework": "^0.5.13",
"wdio-phantomjs-service": "^0.2.2",
"wdio-selenium-standalone-service": "0.0.10",
"wdio-spec-reporter": "^0.1.2",
"webdriverio": "^4.12.0",
"webpack": "^3.8.1",
"webpack-bundle-analyzer": "^2.9.0",
"typescript": "^4.6.3",
"uuid": "^8.3.2",
"webdriverio": "^7.19.3",
"webpack": "^4.46.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cleanup-plugin": "^0.5.1",
"webpack-dev-server": "^2.9.4"
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.8.1"
}
}

5
sandbox.config.json Normal file
View File

@@ -0,0 +1,5 @@
{
"container": {
"startScript": "start-sandbox"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -26,9 +26,7 @@ class AppLayout extends React.Component {
return <div className="maputnik-layout">
{this.props.toolbar}
<div className="maputnik-layout-list">
<ScrollContainer>
{this.props.layerList}
</ScrollContainer>
{this.props.layerList}
</div>
<div className="maputnik-layout-drawer">
<ScrollContainer>

View File

@@ -0,0 +1,62 @@
import React from 'react'
import PropTypes from 'prop-types'
import {formatLayerId} from '../util/format';
export default class AppMessagePanel extends React.Component {
static propTypes = {
errors: PropTypes.array,
infos: PropTypes.array,
mapStyle: PropTypes.object,
onLayerSelect: PropTypes.func,
currentLayer: PropTypes.object,
selectedLayerIndex: PropTypes.number,
}
static defaultProps = {
onLayerSelect: () => {},
}
render() {
const {selectedLayerIndex} = this.props;
const errors = this.props.errors.map((error, idx) => {
let content;
if (error.parsed && error.parsed.type === "layer") {
const {parsed} = error;
const {mapStyle, currentLayer} = this.props;
const layerId = mapStyle.layers[parsed.data.index].id;
content = (
<>
Layer <span>{formatLayerId(layerId)}</span>: {parsed.data.message}
{selectedLayerIndex !== parsed.data.index &&
<>
&nbsp;&mdash;&nbsp;
<button
className="maputnik-message-panel__switch-button"
onClick={() => this.props.onLayerSelect(parsed.data.index)}
>
switch to layer
</button>
</>
}
</>
);
}
else {
content = error.message;
}
return <p key={"error-"+idx} className="maputnik-message-panel-error">
{content}
</p>
})
const infos = this.props.infos.map((m, i) => {
return <p key={"info-"+i}>{m}</p>
})
return <div className="maputnik-message-panel">
{errors}
{infos}
</div>
}
}

View File

@@ -0,0 +1,285 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import {detect} from 'detect-browser';
import {MdFileDownload, MdOpenInBrowser, MdSettings, MdLayers, MdHelpOutline, MdFindInPage, MdAssignmentTurnedIn} from 'react-icons/md'
import logoImage from 'maputnik-design/logos/logo-color.svg'
import pkgJson from '../../package.json'
// This is required because of <https://stackoverflow.com/a/49846426>, there isn't another way to detect support that I'm aware of.
const browser = detect();
const colorAccessibilityFiltersEnabled = ['chrome', 'firefox'].indexOf(browser.name) > -1;
class IconText extends React.Component {
static propTypes = {
children: PropTypes.node,
}
render() {
return <span className="maputnik-icon-text">{this.props.children}</span>
}
}
class ToolbarLink extends React.Component {
static propTypes = {
className: PropTypes.string,
children: PropTypes.node,
href: PropTypes.string,
onToggleModal: PropTypes.func,
}
render() {
return <a
className={classnames('maputnik-toolbar-link', this.props.className)}
href={this.props.href}
rel="noopener noreferrer"
target="_blank"
>
{this.props.children}
</a>
}
}
class ToolbarLinkHighlighted extends React.Component {
static propTypes = {
className: PropTypes.string,
children: PropTypes.node,
href: PropTypes.string,
onToggleModal: PropTypes.func
}
render() {
return <a
className={classnames('maputnik-toolbar-link', "maputnik-toolbar-link--highlighted", this.props.className)}
href={this.props.href}
rel="noopener noreferrer"
target="_blank"
>
<span className="maputnik-toolbar-link-wrapper">
{this.props.children}
</span>
</a>
}
}
class ToolbarSelect extends React.Component {
static propTypes = {
children: PropTypes.node,
wdKey: PropTypes.string
}
render() {
return <div
className='maputnik-toolbar-select'
data-wd-key={this.props.wdKey}
>
{this.props.children}
</div>
}
}
class ToolbarAction extends React.Component {
static propTypes = {
children: PropTypes.node,
onClick: PropTypes.func,
wdKey: PropTypes.string
}
render() {
return <button
className='maputnik-toolbar-action'
data-wd-key={this.props.wdKey}
onClick={this.props.onClick}
>
{this.props.children}
</button>
}
}
export default class AppToolbar extends React.Component {
static propTypes = {
mapStyle: PropTypes.object.isRequired,
inspectModeEnabled: PropTypes.bool.isRequired,
onStyleChanged: PropTypes.func.isRequired,
// A new style has been uploaded
onStyleOpen: PropTypes.func.isRequired,
// A dict of source id's and the available source layers
sources: PropTypes.object.isRequired,
children: PropTypes.node,
onToggleModal: PropTypes.func,
onSetMapState: PropTypes.func,
mapState: PropTypes.string,
renderer: PropTypes.string,
}
state = {
isOpen: {
settings: false,
sources: false,
open: false,
add: false,
export: false,
}
}
handleSelection(val) {
this.props.onSetMapState(val);
}
onSkip = (target) => {
if (target === "map") {
document.querySelector(".mapboxgl-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',
},
{
id: "filter-deuteranopia",
group: "color-accessibility",
title: "Deuteranopia filter",
disabled: !colorAccessibilityFiltersEnabled,
},
{
id: "filter-protanopia",
group: "color-accessibility",
title: "Protanopia filter",
disabled: !colorAccessibilityFiltersEnabled,
},
{
id: "filter-tritanopia",
group: "color-accessibility",
title: "Tritanopia filter",
disabled: !colorAccessibilityFiltersEnabled,
},
{
id: "filter-achromatopsia",
group: "color-accessibility",
title: "Achromatopsia filter",
disabled: !colorAccessibilityFiltersEnabled,
},
];
const currentView = views.find((view) => {
return view.id === this.props.mapState;
});
return <nav className='maputnik-toolbar'>
<div className="maputnik-toolbar__inner">
<div
className="maputnik-toolbar-logo-container"
>
{/* 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
className="maputnik-toolbar-logo"
target="blank"
rel="noreferrer noopener"
href="https://github.com/maputnik/editor"
>
<span dangerouslySetInnerHTML={{__html: logoImage}} />
<h1>
<span className="maputnik-toolbar-name">{pkgJson.name}</span>
<span className="maputnik-toolbar-version">v{pkgJson.version}</span>
</h1>
</a>
</div>
<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>
</ToolbarAction>
<ToolbarAction wdKey="nav:export" onClick={this.props.onToggleModal.bind(this, 'export')}>
<MdFileDownload />
<IconText>Export</IconText>
</ToolbarAction>
<ToolbarAction wdKey="nav:sources" onClick={this.props.onToggleModal.bind(this, 'sources')}>
<MdLayers />
<IconText>Data Sources</IconText>
</ToolbarAction>
<ToolbarAction wdKey="nav:settings" onClick={this.props.onToggleModal.bind(this, 'settings')}>
<MdSettings />
<IconText>Style Settings</IconText>
</ToolbarAction>
<ToolbarSelect wdKey="nav:inspect">
<MdFindInPage />
<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"}>
<MdHelpOutline />
<IconText>Help</IconText>
</ToolbarLink>
<ToolbarLinkHighlighted href={"https://gregorywolanski.typeform.com/to/cPgaSY"}>
<MdAssignmentTurnedIn />
<IconText>Take the Maputnik Survey</IconText>
</ToolbarLinkHighlighted>
</div>
</div>
</nav>
}
}

103
src/components/Block.jsx Normal file
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>
}
}

View File

@@ -1,15 +1,19 @@
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
}
static defaultProps = {
isActive: true
}
render() {
if (accessibility.reducedMotionEnabled()) {
return (
@@ -20,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>
)
}
}

View File

@@ -1,7 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import CollapseOpenIcon from 'react-icons/lib/md/arrow-drop-down'
import CollapseCloseIcon from 'react-icons/lib/md/arrow-drop-up'
import {MdArrowDropDown, MdArrowDropUp} from 'react-icons/md'
export default class Collapser extends React.Component {
static propTypes = {
@@ -15,7 +14,7 @@ export default class Collapser extends React.Component {
height: 20,
...this.props.style,
}
return this.props.isCollapsed ? <CollapseCloseIcon style={iconStyle}/> : <CollapseOpenIcon style={iconStyle} />
return this.props.isCollapsed ? <MdArrowDropUp style={iconStyle}/> : <MdArrowDropDown style={iconStyle} />
}
}

83
src/components/Doc.jsx Normal file
View File

@@ -0,0 +1,83 @@
import React from 'react'
import PropTypes from 'prop-types'
export default class Doc extends React.Component {
static propTypes = {
fieldSpec: PropTypes.object.isRequired,
}
render () {
const {fieldSpec} = this.props;
const {doc, values} = fieldSpec;
const sdkSupport = fieldSpec['sdk-support'];
const headers = {
js: "JS",
android: "Android",
ios: "iOS",
macos: "macOS",
};
const renderValues = (
!!values &&
// HACK: Currently we merge additional values into the stylespec, so this is required
// See <https://github.com/maputnik/editor/blob/master/src/components/fields/PropertyGroup.jsx#L16>
!Array.isArray(values)
);
return (
<>
{doc &&
<div className="SpecDoc">
<div className="SpecDoc__doc">{doc}</div>
{renderValues &&
<ul className="SpecDoc__values">
{Object.entries(values).map(([key, value]) => {
return (
<li key={key}>
<code>{JSON.stringify(key)}</code>
<div>{value.doc}</div>
</li>
);
})}
</ul>
}
</div>
}
{sdkSupport &&
<div className="SpecDoc__sdk-support">
<table className="SpecDoc__sdk-support__table">
<thead>
<tr>
<th></th>
{Object.values(headers).map(header => {
return <th key={header}>{header}</th>;
})}
</tr>
</thead>
<tbody>
{Object.entries(sdkSupport).map(([key, supportObj]) => {
return (
<tr key={key}>
<td>{key}</td>
{Object.keys(headers).map(k => {
const value = supportObj[k];
if (supportObj.hasOwnProperty(k)) {
return <td key={k}>{supportObj[k]}</td>;
}
else {
return <td key={k}>no</td>;
}
})}
</tr>
);
})}
</tbody>
</table>
</div>
}
</>
);
}
}

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>
}
}

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>
}
}

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>
}
}

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>
}
}

View File

@@ -1,29 +1,31 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import Block from './Block'
import InputString from './InputString'
class MetadataBlock extends React.Component {
export default class FieldComment extends React.Component {
static propTypes = {
value: PropTypes.string,
onChange: PropTypes.func.isRequired,
}
render() {
return <InputBlock
const fieldSpec = {
doc: "Comments for the current layer. This is non-standard and not in the spec."
};
return <Block
label={"Comments"}
doc={"Comments for the current layer. This is non-standard and not in the spec."}
fieldSpec={fieldSpec}
data-wd-key="layer-comment"
>
<StringInput
<InputString
multi={true}
value={this.props.value}
onChange={this.props.onChange}
default="Comment..."
/>
</InputBlock>
</Block>
}
}
export default MetadataBlock

View File

@@ -0,0 +1,63 @@
import React from 'react'
import PropTypes from 'prop-types'
import {MdInfoOutline, MdHighlightOff} from 'react-icons/md'
export default class FieldDocLabel extends React.Component {
static propTypes = {
label: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]).isRequired,
fieldSpec: PropTypes.object,
onToggleDoc: PropTypes.func,
}
constructor (props) {
super(props);
this.state = {
open: false,
}
}
onToggleDoc = (open) => {
this.setState({
open,
}, () => {
if (this.props.onToggleDoc) {
this.props.onToggleDoc(this.state.open);
}
});
}
render() {
const {label, fieldSpec} = this.props;
const {doc} = fieldSpec || {};
if (doc) {
return <label className="maputnik-doc-wrapper">
<div className="maputnik-doc-target">
{label}
{'\xa0'}
<button
aria-label={this.state.open ? "close property documentation" : "open property documentation"}
className={`maputnik-doc-button maputnik-doc-button--${this.state.open ? 'open' : 'closed'}`}
onClick={() => this.onToggleDoc(!this.state.open)}
>
{this.state.open ? <MdHighlightOff /> : <MdInfoOutline />}
</button>
</div>
</label>
}
else if (label) {
return <label className="maputnik-doc-wrapper">
<div className="maputnik-doc-target">
{label}
</div>
</label>
}
else {
<div />
}
}
}

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>
}
}

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>
}
}

View File

@@ -0,0 +1,410 @@
import React from 'react'
import PropTypes from 'prop-types'
import SpecProperty from './_SpecProperty'
import DataProperty from './_DataProperty'
import ZoomProperty from './_ZoomProperty'
import ExpressionProperty from './_ExpressionProperty'
import {function as styleFunction} from '@maplibre/maplibre-gl-style-spec';
import {findDefaultFromSpec} from '../util/spec-helper';
function isLiteralExpression (value) {
return (Array.isArray(value) && value.length === 2 && value[0] === "literal");
}
function isGetExpression (value) {
return (
Array.isArray(value) &&
value.length === 2 &&
value[0] === "get"
);
}
function isZoomField(value) {
return (
typeof(value) === 'object' &&
value.stops &&
typeof(value.property) === 'undefined' &&
Array.isArray(value.stops) &&
value.stops.length > 1 &&
value.stops.every(stop => {
return (
Array.isArray(stop) &&
stop.length === 2
);
})
);
}
function isIdentityProperty (value) {
return (
typeof(value) === 'object' &&
value.type === "identity" &&
value.hasOwnProperty("property")
);
}
function isDataStopProperty (value) {
return (
typeof(value) === 'object' &&
value.stops &&
typeof(value.property) !== 'undefined' &&
value.stops.length > 1 &&
Array.isArray(value.stops) &&
value.stops.every(stop => {
return (
Array.isArray(stop) &&
stop.length === 2 &&
typeof(stop[0]) === 'object'
);
})
);
}
function isDataField(value) {
return (
isIdentityProperty(value) ||
isDataStopProperty(value)
);
}
function isPrimative (value) {
const valid = ["string", "boolean", "number"];
return valid.includes(typeof(value));
}
function isArrayOfPrimatives (values) {
if (Array.isArray(values)) {
return values.every(isPrimative);
}
return false;
}
function getDataType (value, fieldSpec={}) {
if (value === undefined) {
return "value";
}
else if (isPrimative(value)) {
return "value";
}
else if (fieldSpec.type === "array" && isArrayOfPrimatives(value)) {
return "value";
}
else if (isZoomField(value)) {
return "zoom_function";
}
else if (isDataField(value)) {
return "data_function";
}
else {
return "expression";
}
}
/** Supports displaying spec field for zoom function objects
* https://www.mapbox.com/mapbox-gl-style-spec/#types-function-zoom-property
*/
export default class FieldFunction extends React.Component {
static propTypes = {
onChange: PropTypes.func.isRequired,
fieldName: PropTypes.string.isRequired,
fieldType: PropTypes.string.isRequired,
fieldSpec: PropTypes.object.isRequired,
errors: PropTypes.object,
value: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string,
PropTypes.number,
PropTypes.bool,
PropTypes.array
]),
}
constructor (props) {
super();
this.state = {
dataType: getDataType(props.value, props.fieldSpec),
isEditing: false,
}
}
static getDerivedStateFromProps(props, state) {
// Because otherwise when editing values we end up accidentally changing field type.
if (state.isEditing) {
return {};
}
else {
return {
isEditing: false,
dataType: getDataType(props.value, props.fieldSpec)
};
}
}
getFieldFunctionType(fieldSpec) {
if (fieldSpec.expression.interpolated) {
return "exponential"
}
if (fieldSpec.type === "number") {
return "interval"
}
return "categorical"
}
addStop = () => {
const stops = this.props.value.stops.slice(0)
const lastStop = stops[stops.length - 1]
if (typeof lastStop[0] === "object") {
stops.push([
{zoom: lastStop[0].zoom + 1, value: lastStop[0].value},
lastStop[1]
])
}
else {
stops.push([lastStop[0] + 1, lastStop[1]])
}
const changedValue = {
...this.props.value,
stops: stops,
}
this.props.onChange(this.props.fieldName, changedValue)
}
deleteExpression = () => {
const {fieldSpec, fieldName} = this.props;
this.props.onChange(fieldName, fieldSpec.default);
this.setState({
dataType: "value",
});
}
deleteStop = (stopIdx) => {
const stops = this.props.value.stops.slice(0)
stops.splice(stopIdx, 1)
let changedValue = {
...this.props.value,
stops: stops,
}
if(stops.length === 1) {
changedValue = stops[0][1]
}
this.props.onChange(this.props.fieldName, changedValue)
}
makeZoomFunction = () => {
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)
}
undoExpression = () => {
const {value, fieldName} = this.props;
if (isGetExpression(value)) {
this.props.onChange(fieldName, {
"type": "identity",
"property": value[1]
});
this.setState({
dataType: "value",
});
}
else if (isLiteralExpression(value)) {
this.props.onChange(fieldName, value[1]);
this.setState({
dataType: "value",
});
}
}
canUndo = () => {
const {value, fieldSpec} = this.props;
return (
isGetExpression(value) ||
isLiteralExpression(value) ||
isPrimative(value) ||
(Array.isArray(value) && fieldSpec.type === "array")
);
}
makeExpression = () => {
const {value, fieldSpec} = this.props;
let expression;
if (typeof(value) === "object" && 'stops' in value) {
expression = styleFunction.convertFunction(value, fieldSpec);
}
else if (isIdentityProperty(value)) {
expression = ["get", value.property];
}
else {
expression = ["literal", value || this.props.fieldSpec.default];
}
this.props.onChange(this.props.fieldName, expression);
}
makeDataFunction = () => {
const functionType = this.getFieldFunctionType(this.props.fieldSpec);
const stopValue = functionType === 'categorical' ? '' : 0;
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)
}
onMarkEditing = () => {
this.setState({isEditing: true});
}
onUnmarkEditing = () => {
this.setState({isEditing: false});
}
render() {
const {dataType} = this.state;
const propClass = this.props.fieldSpec.default === this.props.value ? "maputnik-default-property" : "maputnik-modified-property"
let specField;
if (dataType === "expression") {
specField = (
<ExpressionProperty
errors={this.props.errors}
onChange={this.props.onChange.bind(this, this.props.fieldName)}
canUndo={this.canUndo}
onUndo={this.undoExpression}
onDelete={this.deleteExpression}
fieldType={this.props.fieldType}
fieldName={this.props.fieldName}
fieldSpec={this.props.fieldSpec}
value={this.props.value}
onFocus={this.onMarkEditing}
onBlur={this.onUnmarkEditing}
/>
);
}
else if (dataType === "zoom_function") {
specField = (
<ZoomProperty
errors={this.props.errors}
onChange={this.props.onChange.bind(this)}
fieldType={this.props.fieldType}
fieldName={this.props.fieldName}
fieldSpec={this.props.fieldSpec}
value={this.props.value}
onDeleteStop={this.deleteStop}
onAddStop={this.addStop}
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}
onChange={this.props.onChange.bind(this)}
fieldType={this.props.fieldType}
fieldName={this.props.fieldName}
fieldSpec={this.props.fieldSpec}
value={this.props.value}
onDeleteStop={this.deleteStop}
onAddStop={this.addStop}
onChangeToZoomFunction={this.makeZoomFunction}
onExpressionClick={this.makeExpression}
/>
)
}
else {
specField = (
<SpecProperty
errors={this.props.errors}
onChange={this.props.onChange.bind(this)}
fieldType={this.props.fieldType}
fieldName={this.props.fieldName}
fieldSpec={this.props.fieldSpec}
value={this.props.value}
onZoomClick={this.makeZoomFunction}
onDataClick={this.makeDataFunction}
onExpressionClick={this.makeExpression}
/>
)
}
return <div className={propClass} data-wd-key={"spec-field:"+this.props.fieldName}>
{specField}
</div>
}
}

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>
}
}

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} />
}
}

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>
}
}

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>
}
}

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>
}
}

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>
}
}

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>
}
}

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>
}
}

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>
}
}

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>
}
}

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>
}
}

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>
);
}
}

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>
}
}

View File

@@ -0,0 +1,310 @@
import React from 'react'
import PropTypes from 'prop-types'
import { combiningFilterOps } from '../libs/filterops.js'
import {mdiTableRowPlusAfter} from '@mdi/js';
import {isEqual} from 'lodash';
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 InputButton from './InputButton'
import Doc from './Doc'
import ExpressionProperty from './_ExpressionProperty';
import {mdiFunctionVariant} from '@mdi/js';
function combiningFilter (props) {
let filter = props.filter || ['all'];
if (!Array.isArray(filter)) {
return filter;
}
let combiningOp = filter[0];
let filters = filter.slice(1);
if(combiningFilterOps.indexOf(combiningOp) < 0) {
combiningOp = 'all';
filters = [filter.slice(0)];
}
return [combiningOp, ...filters];
}
function migrateFilter (filter) {
return migrate(createStyleFromFilter(filter)).layers[0].filter;
}
function createStyleFromFilter (filter) {
return {
"id": "tmp",
"version": 8,
"name": "Empty Style",
"metadata": {"maputnik:renderer": "mbgljs"},
"sources": {
"tmp": {
"type": "geojson",
"data": {}
}
},
"sprite": "",
"glyphs": "https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf",
"layers": [
{
id: "tmp",
type: "fill",
source: "tmp",
filter: filter,
},
],
};
}
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.length === 1 && FILTER_OPS.includes(filter[0])) {
return true;
}
const expression = convertFilter(filter);
return !isEqual(expression, filter);
}
function hasCombiningFilter(filter) {
return combiningFilterOps.indexOf(filter[0]) >= 0
}
function hasNestedCombiningFilter(filter) {
if(hasCombiningFilter(filter)) {
const combinedFilters = filter.slice(1)
return filter.slice(1).map(f => hasCombiningFilter(f)).filter(f => f == true).length > 0
}
return false
}
export default class FilterEditor extends React.Component {
static propTypes = {
/** Properties of the vector layer and the available fields */
properties: PropTypes.object,
filter: PropTypes.array,
errors: PropTypes.object,
onChange: PropTypes.func.isRequired,
}
static defaultProps = {
filter: ["all"],
}
constructor (props) {
super();
this.state = {
showDoc: false,
displaySimpleFilter: checkIfSimpleFilter(combiningFilter(props)),
};
}
// Convert filter to combining filter
onFilterPartChanged(filterIdx, newPart) {
const newFilter = combiningFilter(this.props).slice(0)
newFilter[filterIdx] = newPart
this.props.onChange(newFilter)
}
deleteFilterItem(filterIdx) {
const newFilter = combiningFilter(this.props).slice(0)
newFilter.splice(filterIdx + 1, 1)
this.props.onChange(newFilter)
}
addFilterItem = () => {
const newFilterItem = combiningFilter(this.props).slice(0)
newFilterItem.push(['==', 'name', ''])
this.props.onChange(newFilterItem)
}
onToggleDoc = (val) => {
this.setState({
showDoc: val
});
}
makeFilter = () => {
this.setState({
displaySimpleFilter: true,
})
}
makeExpression = () => {
let filter = combiningFilter(this.props);
this.props.onChange(migrateFilter(filter));
this.setState({
displaySimpleFilter: false,
})
}
static getDerivedStateFromProps (props, currentState) {
const {filter} = props;
const displaySimpleFilter = checkIfSimpleFilter(combiningFilter(props));
// Upgrade but never downgrade
if (!displaySimpleFilter && currentState.displaySimpleFilter === true) {
return {
displaySimpleFilter: false,
valueIsSimpleFilter: false,
};
}
else if (displaySimpleFilter && currentState.displaySimpleFilter === false) {
return {
valueIsSimpleFilter: true,
}
}
else {
return {
valueIsSimpleFilter: false,
};
}
}
render() {
const {errors} = this.props;
const {displaySimpleFilter} = this.state;
const fieldSpec={
doc: latest.layer.filter.doc + " Combine multiple filters together by using a compound filter."
};
const defaultFilter = ["all"];
const isNestedCombiningFilter = displaySimpleFilter && hasNestedCombiningFilter(combiningFilter(this.props));
if (isNestedCombiningFilter) {
return <div className="maputnik-filter-editor-unsupported">
<p>
Nested filters are not supported.
</p>
<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
</InputButton>
</div>
}
else if (displaySimpleFilter) {
const filter = combiningFilter(this.props);
let combiningOp = filter[0];
let filters = filter.slice(1)
const actions = (
<div>
<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>
</InputButton>
</div>
);
const editorBlocks = filters.map((f, idx) => {
const error = errors[`filter[${idx+1}]`];
return (
<div key={`block-${idx}`}>
<FilterEditorBlock key={idx} onDelete={this.deleteFilterItem.bind(this, idx)}>
<SingleFilterEditor
properties={this.props.properties}
filter={f}
onChange={this.onFilterPartChanged.bind(this, idx + 1)}
/>
</FilterEditorBlock>
{error &&
<div key="error" className="maputnik-inline-error">{error.message}</div>
}
</div>
);
})
return (
<>
<Block
key="top"
fieldSpec={fieldSpec}
label={"Filter"}
action={actions}
>
<InputSelect
value={combiningOp}
onChange={this.onFilterPartChanged.bind(this, 0)}
options={[["all", "every filter matches"], ["none", "no filter matches"], ["any", "any filter matches"]]}
/>
</Block>
{editorBlocks}
<div
key="buttons"
className="maputnik-filter-editor-add-wrapper"
>
<InputButton
data-wd-key="layer-filter-button"
className="maputnik-add-filter"
onClick={this.addFilterItem}
>
<svg style={{width:"14px", height:"14px", verticalAlign: "text-bottom"}} viewBox="0 0 24 24">
<path fill="currentColor" d={mdiTableRowPlusAfter} />
</svg> Add filter
</InputButton>
</div>
<div
key="doc"
className="maputnik-doc-inline"
style={{display: this.state.showDoc ? '' : 'none'}}
>
<Doc fieldSpec={fieldSpec} />
</div>
</>
);
}
else {
let {filter} = this.props;
return (
<>
<ExpressionProperty
onDelete={() => {
this.setState({displaySimpleFilter: true});
this.props.onChange(defaultFilter);
}}
fieldName="filter"
fieldSpec={fieldSpec}
value={filter}
errors={errors}
onChange={this.props.onChange}
/>
{this.state.valueIsSimpleFilter &&
<div className="maputnik-expr-infobox">
You&apos;ve entered a old style filter,{' '}
<button
onClick={this.makeFilter}
className="maputnik-expr-infobox__button"
>
switch to filter editor
</button>
</div>
}
</>
);
}
}
}

View File

@@ -1,9 +1,9 @@
import React from 'react'
import PropTypes from 'prop-types'
import Button from '../Button'
import DeleteIcon from 'react-icons/lib/md/delete'
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"
>
<DeleteIcon />
</Button>
<MdDelete />
</InputButton>
</div>
<div className="maputnik-filter-editor-block-content">
{this.props.children}
@@ -26,4 +27,3 @@ class FilterEditorBlock extends React.Component {
}
}
export default FilterEditorBlock

View File

@@ -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}>

View File

@@ -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}>

View File

@@ -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}>

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} />
}
}
}

View File

@@ -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}>

View File

@@ -0,0 +1,11 @@
import React from 'react'
import {MdPriorityHigh} from 'react-icons/md'
export default class IconMissing extends React.Component {
render() {
return (
<MdPriorityHigh {...this.props} />
)
}
}

View File

@@ -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}>

View File

@@ -0,0 +1,113 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputString from './InputString'
import InputNumber from './InputNumber'
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 = {
value: [],
default: [],
}
constructor (props) {
super(props);
this.state = {
value: this.props.value.slice(0),
// This is so we can compare changes in getDerivedStateFromProps
initialPropsValue: this.props.value.slice(0),
};
}
static getDerivedStateFromProps(props, state) {
const value = [];
const initialPropsValue = state.initialPropsValue.slice(0);
Array(props.length).fill(null).map((_, i) => {
if (props.value[i] === state.initialPropsValue[i]) {
value[i] = state.value[i];
}
else {
value[i] = state.value[i];
initialPropsValue[i] = state.value[i];
}
})
return {
value,
initialPropsValue,
};
}
isComplete (value) {
return Array(this.props.length).fill(null).every((_, i) => {
const val = value[i]
return !(val === undefined || val === "");
});
}
changeValue(idx, newValue) {
const value = this.state.value.slice(0);
value[idx] = newValue;
this.setState({
value,
}, () => {
if (this.isComplete(value)) {
this.props.onChange(value);
}
else {
// Unset until complete
this.props.onChange(undefined);
}
});
}
render() {
const {value} = this.state;
const containsValues = (
value.length > 0 &&
!value.every(val => {
return (val === "" || val === undefined)
})
);
const inputs = Array(this.props.length).fill(null).map((_, i) => {
if(this.props.type === 'number') {
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 <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>
)
}
}

View File

@@ -6,12 +6,17 @@ 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 = {
maxHeight: MAX_HEIGHT
}
static defaultProps = {
@@ -19,13 +24,6 @@ class AutocompleteInput extends React.Component {
options: [],
}
constructor(props) {
super(props);
this.state = {
maxHeight: MAX_HEIGHT
};
}
calcMaxHeight() {
if(this.props.keepMenuWithinWindowBounds) {
const maxHeight = window.innerHeight - this.autocompleteMenuEl.getBoundingClientRect().top;
@@ -38,6 +36,7 @@ class AutocompleteInput extends React.Component {
}
}
}
componentDidMount() {
this.calcMaxHeight();
}
@@ -46,6 +45,10 @@ class AutocompleteInput extends React.Component {
this.calcMaxHeight();
}
onChange (v) {
this.props.onChange(v === "" ? undefined : v);
}
render() {
return <div
ref={(el) => {
@@ -56,23 +59,27 @@ class AutocompleteInput extends React.Component {
menuStyle={{
position: "fixed",
overflow: "auto",
maxHeight: this.state.maxHeight
maxHeight: this.state.maxHeight,
zIndex: '998'
}}
wrapperProps={{
className: "maputnik-autocomplete",
style: null
}}
inputProps={{
'aria-label': this.props['aria-label'],
className: "maputnik-string",
spellCheck: false
}}
value={this.props.value}
items={this.props.options}
getItemValue={(item) => item[0]}
onSelect={v => this.props.onChange(v)}
onChange={(e, v) => this.props.onChange(v)}
shouldItemRender={(item, value) => {
return item[0].toLowerCase().indexOf(value.toLowerCase()) > -1
onSelect={v => this.onChange(v)}
onChange={(e, v) => this.onChange(v)}
shouldItemRender={(item, value="") => {
if (typeof(value) === "string") {
return item[0].toLowerCase().indexOf(value.toLowerCase()) > -1
}
}}
renderItem={(item, isHighlighted) => (
<div
@@ -90,4 +97,4 @@ class AutocompleteInput extends React.Component {
}
}
export default AutocompleteInput

View File

@@ -2,26 +2,34 @@ 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,
onClick: PropTypes.func,
style: PropTypes.object,
className: PropTypes.string,
children: PropTypes.node
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"]}
className={classnames("maputnik-button", this.props.className)}
data-wd-key={this.props["data-wd-key"]}
style={this.props.style}>
style={this.props.style}
>
{this.props.children}
</button>
}
}
export default Button

View File

@@ -1,20 +1,29 @@
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.isRequired,
value: PropTypes.bool,
style: PropTypes.object,
onChange: PropTypes.func,
}
static defaultProps = {
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">
@@ -24,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

View File

@@ -2,6 +2,7 @@ import React from 'react'
import Color from 'color'
import ChromePicker from 'react-color/lib/components/chrome/Chrome'
import PropTypes from 'prop-types'
import lodash from 'lodash';
function formatColor(color) {
const rgb = color.rgb
@@ -9,27 +10,34 @@ 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.isRequired,
name: PropTypes.string,
value: PropTypes.string,
doc: PropTypes.string,
style: PropTypes.object,
default: PropTypes.string,
'aria-label': PropTypes.string,
}
constructor(props) {
super(props)
this.state = {
pickerOpened: false,
}
state = {
pickerOpened: false
}
constructor () {
super();
this.onChangeNoCheck = lodash.throttle(this.onChangeNoCheck, 1000/30);
}
onChangeNoCheck (v) {
this.props.onChange(v);
}
//TODO: I much rather would do this with absolute positioning
//but I am too stupid to get it to work together with fixed position
//and scrollbars so I have to fallback to JavaScript
calcPickerOffset() {
calcPickerOffset = () => {
const elem = this.colorInput
if(elem) {
const pos = elem.getBoundingClientRect()
@@ -45,7 +53,7 @@ class ColorField extends React.Component {
}
}
togglePicker() {
togglePicker = () => {
this.setState({ pickerOpened: !this.state.pickerOpened })
}
@@ -60,6 +68,10 @@ class ColorField extends React.Component {
}
}
onChange (v) {
this.props.onChange(v === "" ? undefined : v);
}
render() {
const offset = this.calcPickerOffset()
var currentColor = this.color.object()
@@ -81,11 +93,11 @@ class ColorField extends React.Component {
}}>
<ChromePicker
color={currentColor}
onChange={c => this.props.onChange(formatColor(c))}
onChange={c => this.onChangeNoCheck(formatColor(c))}
/>
<div
className="maputnik-color-picker-offset"
onClick={this.togglePicker.bind(this)}
onClick={this.togglePicker}
style={{
zIndex: -1,
position: 'fixed',
@@ -105,18 +117,19 @@ 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.bind(this)}
onClick={this.togglePicker}
style={this.props.style}
name={this.props.name}
placeholder={this.props.default}
value={this.props.value ? this.props.value : ""}
onChange={(e) => this.props.onChange(e.target.value)}
onChange={(e) => this.onChange(e.target.value)}
/>
</div>
}
}
export default ColorField

View File

@@ -0,0 +1,141 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputString from './InputString'
import InputNumber from './InputNumber'
import InputButton from './InputButton'
import {MdDelete} from 'react-icons/md'
import FieldDocLabel from './FieldDocLabel'
import InputEnum from './InputEnum'
import capitalize from 'lodash.capitalize'
import InputUrl from './InputUrl'
export default class FieldDynamicArray extends React.Component {
static propTypes = {
value: PropTypes.array,
type: PropTypes.string,
default: PropTypes.array,
onChange: PropTypes.func,
style: PropTypes.object,
fieldSpec: PropTypes.object,
'aria-label': PropTypes.string,
}
changeValue(idx, newValue) {
const values = this.values.slice(0)
values[idx] = newValue
this.props.onChange(values)
}
get values() {
return this.props.value || this.props.default || []
}
addValue = () => {
const values = this.values.slice(0)
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];
values.push(defaultValue);
} else {
values.push("")
}
this.props.onChange(values)
}
deleteValue(valueIdx) {
const values = this.values.slice(0)
values.splice(valueIdx, 1)
this.props.onChange(values.length > 0 ? values : undefined);
}
render() {
const inputs = this.values.map((v, i) => {
const deleteValueBtn= <DeleteValueInputButton onClick={this.deleteValue.bind(this, i)} />
let input;
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 = <InputEnum
options={options}
value={v}
onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/>
}
else {
input = <InputString
value={v}
onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/>
}
return <div
style={this.props.style}
key={i}
className="maputnik-array-block"
>
<div className="maputnik-array-block-action">
{deleteValueBtn}
</div>
<div className="maputnik-array-block-content">
{input}
</div>
</div>
})
return (
<div className="maputnik-array">
{inputs}
<InputButton
className="maputnik-array-add-value"
onClick={this.addValue}
>
Add value
</InputButton>
</div>
);
}
}
class DeleteValueInputButton extends React.Component {
static propTypes = {
onClick: PropTypes.func,
}
render() {
return <InputButton
className="maputnik-delete-stop"
onClick={this.props.onClick}
title="Remove array item"
>
<FieldDocLabel
label={<MdDelete />}
doc={"Remove array item."}
/>
</InputButton>
}
}

View File

@@ -0,0 +1,49 @@
import React from 'react'
import PropTypes from 'prop-types'
import InputSelect from './InputSelect'
import InputMultiInput from './InputMultiInput'
function optionsLabelLength(options) {
let sum = 0;
options.forEach(([_, label]) => {
sum += label.length
})
return sum
}
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, name, label} = this.props;
if(options.length <= 3 && optionsLabelLength(options) <= 20) {
return <InputMultiInput
name={name}
options={options}
value={value || this.props.default}
onChange={onChange}
aria-label={this.props['aria-label'] || label}
/>
} else {
return <InputSelect
options={options}
value={value || this.props.default}
onChange={onChange}
aria-label={this.props['aria-label'] || label}
/>
}
}
}

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>
);
}
}

View File

@@ -0,0 +1,174 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames';
import Block from './Block'
import FieldString from './FieldString'
import CodeMirror from 'codemirror';
import 'codemirror/mode/javascript/javascript'
import 'codemirror/addon/lint/lint'
import 'codemirror/addon/edit/matchbrackets'
import 'codemirror/lib/codemirror.css'
import 'codemirror/addon/lint/lint.css'
import jsonlint from 'jsonlint'
import stringifyPretty from 'json-stringify-pretty-compact'
import '../util/codemirror-mgl';
export default class InputJson extends React.Component {
static propTypes = {
layer: PropTypes.any.isRequired,
maxHeight: PropTypes.number,
onChange: PropTypes.func,
lineNumbers: PropTypes.bool,
lineWrapping: PropTypes.bool,
getValue: PropTypes.func,
gutters: PropTypes.array,
className: PropTypes.string,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
onJSONValid: PropTypes.func,
onJSONInvalid: PropTypes.func,
mode: PropTypes.object,
lint: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.object,
]),
}
static defaultProps = {
lineNumbers: true,
lineWrapping: false,
gutters: ["CodeMirror-lint-markers"],
getValue: (data) => {
return stringifyPretty(data, {indent: 2, maxLength: 40});
},
onFocus: () => {},
onBlur: () => {},
onJSONInvalid: () => {},
onJSONValid: () => {},
}
constructor(props) {
super(props);
this._keyEvent = "keyboard";
this.state = {
isEditing: false,
showMessage: false,
prevValue: this.props.getValue(this.props.layer),
};
}
componentDidMount () {
this._doc = CodeMirror(this._el, {
value: this.props.getValue(this.props.layer),
mode: this.props.mode || {
name: "mgl",
},
lineWrapping: this.props.lineWrapping,
tabSize: 2,
theme: 'maputnik',
viewportMargin: Infinity,
lineNumbers: this.props.lineNumbers,
lint: this.props.lint || {
context: "layer"
},
matchBrackets: true,
gutters: this.props.gutters,
scrollbarStyle: "null",
});
this._doc.on('change', this.onChange);
this._doc.on('focus', this.onFocus);
this._doc.on('blur', this.onBlur);
}
onPointerDown = (cm, e) => {
this._keyEvent = "pointer";
}
onFocus = (cm, e) => {
this.props.onFocus();
this.setState({
isEditing: true,
showMessage: (this._keyEvent === "keyboard"),
});
}
onBlur = () => {
this._keyEvent = "keyboard";
this.props.onBlur();
this.setState({
isEditing: false,
showMessage: false,
});
}
componentWillUnMount () {
this._doc.off('change', this.onChange);
this._doc.off('focus', this.onFocus);
this._doc.off('blur', this.onBlur);
}
componentDidUpdate(prevProps) {
if (!this.state.isEditing && prevProps.layer !== this.props.layer) {
this._cancelNextChange = true;
this._doc.setValue(
this.props.getValue(this.props.layer),
)
}
}
onChange = (e) => {
if (this._cancelNextChange) {
this._cancelNextChange = false;
this.setState({
prevValue: this._doc.getValue(),
})
return;
}
const newCode = this._doc.getValue();
if (this.state.prevValue !== newCode) {
let parsedLayer, err;
try {
parsedLayer = JSON.parse(newCode);
} catch(_err) {
err = _err;
console.warn(_err)
}
if (err) {
this.props.onJSONInvalid();
}
else {
this.props.onChange(parsedLayer)
this.props.onJSONValid();
}
}
this.setState({
prevValue: newCode,
});
}
render() {
const {showMessage} = this.state;
const style = {};
if (this.props.maxHeight) {
style.maxHeight = this.props.maxHeight;
}
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>
}
}

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>
}
}

View File

@@ -0,0 +1,234 @@
import React from 'react'
import PropTypes from 'prop-types'
let IDX = 0;
export default class InputNumber extends React.Component {
static propTypes = {
value: PropTypes.number,
default: PropTypes.number,
min: PropTypes.number,
max: PropTypes.number,
onChange: PropTypes.func,
allowRange: PropTypes.bool,
rangeStep: PropTypes.number,
wdKey: PropTypes.string,
required: PropTypes.bool,
"aria-label": PropTypes.string,
}
static defaultProps = {
rangeStep: 1
}
constructor(props) {
super(props)
this.state = {
uuid: IDX++,
editing: false,
value: props.value,
dirtyValue: props.value,
}
}
static getDerivedStateFromProps(props, state) {
if (!state.editing && props.value !== state.value) {
return {
value: props.value,
dirtyValue: props.value,
};
}
return null;
}
changeValue(newValue) {
const value = (newValue === "" || newValue === undefined) ?
undefined :
parseFloat(newValue);
const hasChanged = this.props.value !== value;
if(this.isValid(value) && hasChanged) {
this.props.onChange(value)
this.setState({
value: newValue,
});
}
else if (!this.isValid(value) && hasChanged) {
this.setState({
value: undefined,
});
}
this.setState({
dirtyValue: newValue === "" ? undefined : newValue,
})
}
isValid(v) {
if (v === undefined) {
return true;
}
const value = parseFloat(v)
if(isNaN(value)) {
return false
}
if(!isNaN(this.props.min) && value < this.props.min) {
return false
}
if(!isNaN(this.props.max) && value > this.props.max) {
return false
}
return true
}
resetValue = () => {
this.setState({editing: false});
// Reset explicitly to default value if value has been cleared
if(this.state.value === "") {
return;
}
// If set value is invalid fall back to the last valid value from props or at last resort the default value
if (!this.isValid(this.state.value)) {
if(this.isValid(this.props.value)) {
this.changeValue(this.props.value)
this.setState({dirtyValue: this.props.value});
} else {
this.changeValue(undefined);
this.setState({dirtyValue: undefined});
}
}
}
onChangeRange = (e) => {
let value = parseFloat(e.target.value, 10);
const step = this.props.rangeStep;
let dirtyValue = value;
if(step) {
// Can't do this with the <input/> range step attribute else we won't be able to set a high precision value via the text input.
const snap = value % step;
// Round up/down to step
if (this._keyboardEvent) {
// If it's keyboard event we might get a low positive/negative value,
// for example we might go from 13 to 13.23, however because we know
// that came from a keyboard event we always want to increase by a
// single step value.
if (value < this.state.dirtyValue) {
value = this.state.value - step;
}
else {
value = this.state.value + step
}
dirtyValue = value;
}
else {
if (snap < step/2) {
value = value - snap;
}
else {
value = value + (step - snap);
};
}
}
this._keyboardEvent = false;
// Clamp between min/max
value = Math.max(this.props.min, Math.min(this.props.max, value));
this.setState({value, dirtyValue});
this.props.onChange(value);
}
render() {
if(
this.props.hasOwnProperty("min") && this.props.hasOwnProperty("max") &&
this.props.min !== undefined && this.props.max !== undefined &&
this.props.allowRange
) {
const value = this.state.editing ? this.state.dirtyValue : this.state.value;
const defaultValue = this.props.default === undefined ? "" : this.props.default;
let inputValue;
if (this.state.editingRange) {
inputValue = this.state.value;
}
else {
inputValue = value;
}
return <div className="maputnik-number-container">
<input
className="maputnik-number-range"
key="range"
type="range"
max={this.props.max}
min={this.props.min}
step="any"
spellCheck="false"
value={value === undefined ? defaultValue : value}
onChange={this.onChangeRange}
onKeyDown={() => {
this._keyboardEvent = true;
}}
onPointerDown={() => {
this.setState({editing: true, editingRange: true});
}}
onPointerUp={() => {
// Safari doesn't get onBlur event
this.setState({editing: false, editingRange: false});
}}
onBlur={() => {
this.setState({
editing: false,
editingRange: false,
dirtyValue: this.state.value,
});
}}
/>
<input
key="text"
type="text"
spellCheck="false"
className="maputnik-number"
placeholder={this.props.default}
value={inputValue === undefined ? "" : inputValue}
onFocus={e => {
this.setState({editing: true});
}}
onChange={e => {
this.changeValue(e.target.value);
}}
onBlur={e => {
this.setState({editing: false});
this.resetValue()
}}
/>
</div>
}
else {
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}
value={value === undefined ? "" : value}
onChange={e => this.changeValue(e.target.value)}
onFocus={() => {
this.setState({editing: true});
}}
onBlur={this.resetValue}
required={this.props.required}
/>
}
}
}

View File

@@ -1,13 +1,15 @@
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,
options: PropTypes.array.isRequired,
style: PropTypes.object,
onChange: PropTypes.func.isRequired,
title: PropTypes.string,
'aria-label': PropTypes.string,
}
@@ -21,12 +23,14 @@ class SelectInput extends React.Component {
className="maputnik-select"
data-wd-key={this.props["data-wd-key"]}
style={this.props.style}
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

View File

@@ -1,17 +1,17 @@
import React from 'react'
import PropTypes from 'prop-types'
import color from 'color'
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 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']
@@ -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,54 +77,51 @@ export default class SpecField extends React.Component {
case 'enum':
const options = Object.keys(this.props.fieldSpec.values).map(v => [v, capitalize(v)])
if(options.length <= 3 && optionsLabelLength(options) <= 20) {
return <MultiButtonInput
{...commonProps}
options={options}
/>
} else {
return <SelectInput
{...commonProps}
options={options}
/>
}
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}
/>
}
@@ -129,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>
);
}

View File

@@ -0,0 +1,95 @@
import React from 'react'
import PropTypes from 'prop-types'
export default class InputString extends React.Component {
static propTypes = {
"data-wd-key": PropTypes.string,
value: PropTypes.string,
style: PropTypes.object,
default: PropTypes.string,
onChange: PropTypes.func,
onInput: PropTypes.func,
multi: PropTypes.bool,
required: PropTypes.bool,
disabled: PropTypes.bool,
spellCheck: PropTypes.bool,
'aria-label': PropTypes.string,
}
static defaultProps = {
onInput: () => {},
}
constructor(props) {
super(props)
this.state = {
editing: false,
value: props.value || ''
}
}
static getDerivedStateFromProps(props, state) {
if (!state.editing) {
return {
value: props.value
};
}
return {};
}
render() {
let tag;
let classes;
if(!!this.props.multi) {
tag = "textarea"
classes = [
"maputnik-string",
"maputnik-string--multi"
]
}
else {
tag = "input"
classes = [
"maputnik-string"
]
}
if(!!this.props.disabled) {
classes.push("maputnik-string--disabled");
}
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,
className: classes.join(" "),
style: this.props.style,
value: this.state.value === undefined ? "" : this.state.value,
placeholder: this.props.default,
onChange: e => {
this.setState({
editing: true,
value: e.target.value
}, () => {
this.props.onInput(this.state.value);
});
},
onBlur: () => {
if(this.state.value!==this.props.value) {
this.setState({editing: false});
this.props.onChange(this.state.value);
}
},
onKeyDown: (e) => {
if (e.keyCode === 13) {
this.props.onChange(this.state.value);
}
},
required: this.props.required,
});
}
}

103
src/components/InputUrl.jsx Normal file
View File

@@ -0,0 +1,103 @@
import React, {Fragment} from 'react'
import PropTypes from 'prop-types'
import InputString from './InputString'
import SmallError from './SmallError'
function validate (url) {
if (url === "") {
return;
}
let error;
const getProtocol = (url) => {
try {
const urlObj = new URL(url);
return urlObj.protocol;
}
catch (err) {
return undefined;
}
};
const protocol = getProtocol(url);
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:"
) {
error = (
<SmallError>
CORS policy won&apos;t allow fetching resources served over http from https, use a <code>https://</code> domain
</SmallError>
);
}
return error;
}
export default class FieldUrl extends React.Component {
static propTypes = {
"data-wd-key": PropTypes.string,
value: PropTypes.string,
style: PropTypes.object,
default: PropTypes.string,
onChange: PropTypes.func,
onInput: PropTypes.func,
multi: PropTypes.bool,
required: PropTypes.bool,
'aria-label': PropTypes.string,
}
static defaultProps = {
onInput: () => {},
}
constructor (props) {
super(props);
this.state = {
error: validate(props.value)
};
}
onInput = (url) => {
this.setState({
error: validate(url)
});
this.props.onInput(url);
}
onChange = (url) => {
this.setState({
error: validate(url)
});
this.props.onChange(url);
}
render () {
return (
<div>
<InputString
{...this.props}
onInput={this.onInput}
onChange={this.onChange}
aria-label={this.props['aria-label']}
/>
{this.state.error}
</div>
);
}
}

View File

@@ -2,26 +2,29 @@ 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 MoreVertIcon from 'react-icons/lib/md/more-vert'
import {MdMoreVert} from 'react-icons/md'
import InputBlock from '../inputs/InputBlock'
import MultiButtonInput from '../inputs/MultiButtonInput'
import { changeType, changeProperty } from '../libs/layer'
import layout from '../config/layout.json'
import {formatLayerId} from '../util/format';
import { changeType, changeProperty } from '../../libs/layer'
import layout from '../../config/layout.json'
function getLayoutForType (type) {
return layout[type] ? layout[type] : layout.invalid;
}
function layoutGroups(layerType) {
const layerGroup = {
@@ -36,7 +39,9 @@ function layoutGroups(layerType) {
title: 'JSON Editor',
type: 'jsoneditor'
}
return [layerGroup, filterGroup].concat(layout[layerType].groups).concat([editorGroup])
return [layerGroup, filterGroup]
.concat(getLayoutForType(layerType).groups)
.concat([editorGroup])
}
/** Layer editor supporting multiple types of layers. */
@@ -55,6 +60,7 @@ export default class LayerEditor extends React.Component {
isFirstLayer: PropTypes.bool,
isLastLayer: PropTypes.bool,
layerIndex: PropTypes.number,
errors: PropTypes.array,
}
static defaultProps = {
@@ -79,18 +85,18 @@ export default class LayerEditor extends React.Component {
this.state = { editorGroups }
}
UNSAFE_componentWillReceiveProps(nextProps) {
const additionalGroups = { ...this.state.editorGroups }
static getDerivedStateFromProps(props, state) {
const additionalGroups = { ...state.editorGroups }
layout[nextProps.layer.type].groups.forEach(group => {
getLayoutForType(props.layer.type).groups.forEach(group => {
if(!(group.title in additionalGroups)) {
additionalGroups[group.title] = true
}
})
this.setState({
return {
editorGroups: additionalGroups
})
};
}
getChildContext () {
@@ -103,7 +109,10 @@ export default class LayerEditor extends React.Component {
}
changeProperty(group, property, newValue) {
this.props.onLayerChanged(changeProperty(this.props.layer, group, property, newValue))
this.props.onLayerChanged(
this.props.layerIndex,
changeProperty(this.props.layer, group, property, newValue)
)
}
onGroupToggle(groupTitle, active) {
@@ -121,6 +130,20 @@ export default class LayerEditor extends React.Component {
if(this.props.layer.metadata) {
comment = this.props.layer.metadata['maputnik:comment']
}
const {errors, layerIndex} = this.props;
const errorData = {};
errors.forEach(error => {
if (
error.parsed &&
error.parsed.type === "layer" &&
error.parsed.data.index == layerIndex
) {
errorData[error.parsed.data.key] = {
message: error.parsed.data.message
};
}
})
let sourceLayerIds;
if(this.props.sources.hasOwnProperty(this.props.layer.source)) {
@@ -129,37 +152,48 @@ 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"
onChange={newId => this.props.onLayerIdChange(this.props.layer.id, newId)}
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}
onChange={newType => this.props.onLayerChanged(changeType(this.props.layer, newType))}
onChange={newType => this.props.onLayerChanged(
this.props.layerIndex,
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}
onChange={v => this.changeProperty(null, 'source', v)}
/>
}
{['background', 'raster', 'hillshade', 'heatmap'].indexOf(this.state.type) < 0 &&
<LayerSourceLayerBlock
{['background', 'raster', 'hillshade', 'heatmap'].indexOf(this.props.layer.type) < 0 &&
<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)}
/>
@@ -167,22 +201,31 @@ export default class LayerEditor extends React.Component {
case 'filter': return <div>
<div className="maputnik-filter-editor-wrapper">
<FilterEditor
errors={errorData}
filter={this.props.layer.filter}
properties={this.props.vectorLayers[this.props.layer['source-layer']]}
onChange={f => this.changeProperty(null, 'filter', f)}
/>
</div>
</div>
case 'properties': return <PropertyGroup
layer={this.props.layer}
groupFields={fields}
spec={this.props.spec}
onChange={this.changeProperty.bind(this)}
/>
case 'jsoneditor': return <JSONEditor
layer={this.props.layer}
onChange={this.props.onLayerChanged}
/>
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
);
}}
/>
}
}
@@ -194,12 +237,16 @@ export default class LayerEditor extends React.Component {
}
render() {
const groupIds = [];
const layerType = this.props.layer.type
const groups = layoutGroups(layerType).filter(group => {
return !(layerType === 'background' && group.type === 'source')
}).map(group => {
const groupId = group.title.replace(/ /g, "_");
groupIds.push(groupId);
return <LayerEditorGroup
data-wd-key={group.title}
id={groupId}
key={group.title}
title={group.title}
isActive={this.state.editorGroups[group.title]}
@@ -214,15 +261,15 @@ export default class LayerEditor extends React.Component {
const items = {
delete: {
text: "Delete",
handler: () => this.props.onLayerDestroy(this.props.layer.id)
handler: () => this.props.onLayerDestroy(this.props.layerIndex)
},
duplicate: {
text: "Duplicate",
handler: () => this.props.onLayerCopy(this.props.layer.id)
handler: () => this.props.onLayerCopy(this.props.layerIndex)
},
hide: {
text: (layout.visibility === "none") ? "Show" : "Hide",
handler: () => this.props.onLayerVisibilityToggle(this.props.layer.id)
handler: () => this.props.onLayerVisibilityToggle(this.props.layerIndex)
},
moveLayerUp: {
text: "Move layer up",
@@ -243,12 +290,14 @@ 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">
Layer: {this.props.layer.id}
Layer: {formatLayerId(this.props.layer.id)}
</h2>
<div className="layer-header__info">
<Wrapper
@@ -256,8 +305,8 @@ export default class LayerEditor extends React.Component {
onSelection={handleSelection}
closeOnSelection={false}
>
<Button className='more-menu__button'>
<MoreVertIcon className="more-menu__button__svg" />
<Button id="skip-target-layer-editor" className='more-menu__button' title="Layer options">
<MdMoreVert className="more-menu__button__svg" />
</Button>
<Menu>
<ul className="more-menu__menu">
@@ -276,7 +325,13 @@ export default class LayerEditor extends React.Component {
</div>
</header>
{groups}
</div>
<Accordion
allowMultipleExpanded={true}
allowZeroExpanded={true}
preExpanded={groupIds}
>
{groups}
</Accordion>
</section>
}
}

View File

@@ -0,0 +1,51 @@
import React from 'react'
import PropTypes from 'prop-types'
import Icon from '@mdi/react'
import {
mdiMenuDown,
mdiMenuUp
} from '@mdi/js';
import {
AccordionItem,
AccordionItemHeading,
AccordionItemButton,
AccordionItemPanel,
} from 'react-accessible-accordion';
export default class LayerEditorGroup extends React.Component {
static propTypes = {
"id": PropTypes.string,
"data-wd-key": PropTypes.string,
title: PropTypes.string.isRequired,
isActive: PropTypes.bool.isRequired,
children: PropTypes.element.isRequired,
onActiveToggle: PropTypes.func.isRequired
}
render() {
return <AccordionItem uuid={this.props.id}>
<AccordionItemHeading className="maputnik-layer-editor-group"
data-wd-key={"layer-editor-group:"+this.props["data-wd-key"]}
onClick={e => this.props.onActiveToggle(!this.props.isActive)}
>
<AccordionItemButton className="maputnik-layer-editor-group__button">
<span style={{flexGrow: 1}}>{this.props.title}</span>
<Icon
path={mdiMenuUp}
size={1}
className="maputnik-layer-editor-group__button__icon maputnik-layer-editor-group__button__icon--up"
/>
<Icon
path={mdiMenuDown}
size={1}
className="maputnik-layer-editor-group__button__icon maputnik-layer-editor-group__button__icon--down"
/>
</AccordionItemButton>
</AccordionItemHeading>
<AccordionItemPanel>
{this.props.children}
</AccordionItemPanel>
</AccordionItem>
}
}

View File

@@ -1,15 +1,13 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import lodash from 'lodash';
import Button from '../Button'
import LayerListGroup from './LayerListGroup'
import LayerListItem from './LayerListItem'
import AddIcon from 'react-icons/lib/md/add-circle-outline'
import AddModal from '../modals/AddModal'
import ModalAdd from './ModalAdd'
import style from '../../libs/style.js'
import {SortableContainer, SortableHandle} from 'react-sortable-hoc';
import {SortableContainer} from 'react-sortable-hoc';
const layerListPropTypes = {
layers: PropTypes.array.isRequired,
@@ -37,8 +35,9 @@ function findClosestCommonPrefix(layers, idx) {
return closestIdx
}
let UID = 0;
// List of collapsible layer editors
@SortableContainer
class LayerListContainer extends React.Component {
static propTypes = {...layerListPropTypes}
static defaultProps = {
@@ -46,10 +45,15 @@ class LayerListContainer extends React.Component {
}
constructor(props) {
super(props)
super(props);
this.selectedItemRef = React.createRef();
this.scrollContainerRef = React.createRef();
this.state = {
collapsedGroups: {},
areAllGroupsExpanded: false,
keys: {
add: UID++,
},
isOpen: {
add: false,
}
@@ -58,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]
@@ -65,7 +73,7 @@ class LayerListContainer extends React.Component {
})
}
toggleLayers() {
toggleLayers = () => {
let idx=0
let newGroups=[]
@@ -73,12 +81,12 @@ class LayerListContainer extends React.Component {
this.groupedLayers().forEach(layers => {
const groupPrefix = layerPrefix(layers[0].id)
const lookupKey = [groupPrefix, idx].join('-')
if (layers.length > 1) {
newGroups[lookupKey] = this.state.areAllGroupsExpanded
}
layers.forEach((layer) => {
idx += 1
})
@@ -92,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)
@@ -123,16 +140,83 @@ class LayerListContainer extends React.Component {
return collapsed === undefined ? true : collapsed
}
shouldComponentUpdate (nextProps, nextState) {
// Always update on state change
if (this.state !== nextState) {
return true;
}
// This component tree only requires id and visibility from the layers
// objects
function getRequiredProps (layer) {
const out = {
id: layer.id,
};
if (layer.layout) {
out.layout = {
visibility: layer.layout.visibility
};
}
return out;
}
const layersEqual = lodash.isEqual(
nextProps.layers.map(getRequiredProps),
this.props.layers.map(getRequiredProps),
);
function withoutLayers (props) {
const out = {
...props
};
delete out['layers'];
return out;
}
// Compare the props without layers because we've already compared them
// efficiently above.
const propsEqual = lodash.isEqual(
withoutLayers(this.props),
withoutLayers(nextProps)
);
const propsChanged = !(layersEqual && propsEqual);
return propsChanged;
}
componentDidUpdate (prevProps) {
if (prevProps.selectedLayerIndex !== this.props.selectedLayerIndex) {
const selectedItemNode = this.selectedItemRef.current;
if (selectedItemNode && selectedItemNode.node) {
const target = selectedItemNode.node;
const options = {
root: this.scrollContainerRef.current,
threshold: 1.0
}
const observer = new IntersectionObserver(entries => {
observer.unobserve(target);
if (entries.length > 0 && entries[0].intersectionRatio < 1) {
target.scrollIntoView();
}
}, options);
observer.observe(target);
}
}
}
render() {
const listItems = []
let idx = 0
this.groupedLayers().forEach(layers => {
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('-')}
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}
onActiveToggle={this.toggleLayerGroup.bind(this, groupPrefix, idx)}
@@ -143,14 +227,30 @@ class LayerListContainer extends React.Component {
layers.forEach((layer, idxInGroup) => {
const groupIdx = findClosestCommonPrefix(this.props.layers, idx)
const layerError = this.props.errors.find(error => {
return (
error.parsed &&
error.parsed.type === "layer" &&
error.parsed.data.index == idx
);
});
const additionalProps = {};
if (idx === this.props.selectedLayerIndex) {
additionalProps.ref = this.selectedItemRef;
}
const listItem = <LayerListItem
className={classnames({
'maputnik-layer-list-item-collapsed': layers.length > 1 && this.isCollapsed(groupPrefix, groupIdx) && idx !== this.props.selectedLayerIndex,
'maputnik-layer-list-item-group-last': idxInGroup == layers.length - 1 && layers.length > 1
'maputnik-layer-list-item-group-last': idxInGroup == layers.length - 1 && layers.length > 1,
'maputnik-layer-list-item--error': !!layerError
})}
index={idx}
key={layer.id}
key={layer.key}
id={layer.key}
layerId={layer.id}
layerIndex={idx}
layerType={layer.type}
visibility={(layer.layout || {}).visibility}
isSelected={idx === this.props.selectedLayerIndex}
@@ -158,14 +258,21 @@ class LayerListContainer extends React.Component {
onLayerDestroy={this.props.onLayerDestroy.bind(this)}
onLayerCopy={this.props.onLayerCopy.bind(this)}
onLayerVisibilityToggle={this.props.onLayerVisibilityToggle.bind(this)}
{...additionalProps}
/>
listItems.push(listItem)
idx += 1
})
})
return <div className="maputnik-layer-list">
<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}
@@ -178,8 +285,8 @@ class LayerListContainer extends React.Component {
<div className="maputnik-default-property">
<div className="maputnik-multibutton">
<button
id="skip-menu"
onClick={this.toggleLayers.bind(this)}
id="skip-target-layer-list"
onClick={this.toggleLayers}
className="maputnik-button">
{this.state.areAllGroupsExpanded === true ? "Collapse" : "Expand"}
</button>
@@ -196,21 +303,30 @@ 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>
}
}
const LayerListContainerSortable = SortableContainer((props) => <LayerListContainer {...props} />)
export default class LayerList extends React.Component {
static propTypes = {...layerListPropTypes}
render() {
return <LayerListContainer
return <LayerListContainerSortable
{...this.props}
helperClass='sortableHelper'
onSortEnd={this.props.onMoveLayer.bind(this)}
useDragHandle={true}
shouldCancelStart={() => false}
/>
}
}

View File

@@ -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 }}

View File

@@ -1,66 +1,71 @@
import React from 'react'
import PropTypes from 'prop-types'
import Color from 'color'
import classnames from 'classnames'
import CopyIcon from 'react-icons/lib/md/content-copy'
import VisibilityIcon from 'react-icons/lib/md/visibility'
import VisibilityOffIcon from 'react-icons/lib/md/visibility-off'
import DeleteIcon from 'react-icons/lib/md/delete'
import {MdContentCopy, MdVisibility, MdVisibilityOff, MdDelete} from 'react-icons/md'
import LayerIcon from '../icons/LayerIcon'
import LayerEditor from './LayerEditor'
import IconLayer from './IconLayer'
import {SortableElement, SortableHandle} from 'react-sortable-hoc'
@SortableHandle
class LayerTypeDragHandle extends React.Component {
static propTypes = LayerIcon.propTypes
render() {
return <LayerIcon
{...this.props}
style={{
cursor: 'move',
width: 14,
height: 14,
paddingRight: 3,
}}
const DraggableLabel = SortableHandle((props) => {
return <div className="maputnik-layer-list-item-handle">
<IconLayer
className="layer-handle__icon"
type={props.layerType}
/>
}
}
<button className="maputnik-layer-list-item-id">
{props.layerId}
</button>
</div>
});
class IconAction extends React.Component {
static propTypes = {
action: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired,
wdKey: PropTypes.string
wdKey: PropTypes.string,
classBlockName: PropTypes.string,
classBlockModifier: PropTypes.string,
}
renderIcon() {
switch(this.props.action) {
case 'duplicate': return <CopyIcon />
case 'show': return <VisibilityIcon />
case 'hide': return <VisibilityOffIcon />
case 'delete': return <DeleteIcon />
case 'duplicate': return <MdContentCopy />
case 'show': return <MdVisibility />
case 'hide': return <MdVisibilityOff />
case 'delete': return <MdDelete />
}
}
render() {
const {classBlockName, classBlockModifier} = this.props;
let classAdditions = '';
if (classBlockName) {
classAdditions = `maputnik-layer-list-icon-action__${classBlockName}`;
if (classBlockModifier) {
classAdditions += ` maputnik-layer-list-icon-action__${classBlockName}--${classBlockModifier}`;
}
}
return <button
tabIndex="-1"
title={this.props.action}
className="maputnik-layer-list-icon-action"
className={`maputnik-layer-list-icon-action ${classAdditions}`}
data-wd-key={this.props.wdKey}
onClick={this.props.onClick}
aria-hidden="true"
>
{this.renderIcon()}
</button>
}
}
@SortableElement
class LayerListItem extends React.Component {
static propTypes = {
layerIndex: PropTypes.number.isRequired,
layerId: PropTypes.string.isRequired,
layerType: PropTypes.string.isRequired,
isSelected: PropTypes.bool,
@@ -92,35 +97,43 @@ class LayerListItem extends React.Component {
}
render() {
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.layerId)}
onClick={e => this.props.onLayerSelect(this.props.layerIndex)}
data-wd-key={"layer-list-item:"+this.props.layerId}
className={classnames({
"maputnik-layer-list-item": true,
"maputnik-layer-list-item-selected": this.props.isSelected,
[this.props.className]: true,
})}>
<LayerTypeDragHandle type={this.props.layerType} />
<span className="maputnik-layer-list-item-id">{this.props.layerId}</span>
<DraggableLabel {...this.props} />
<span style={{flexGrow: 1}} />
<IconAction
wdKey={"layer-list-item:"+this.props.layerId+":delete"}
action={'delete'}
onClick={e => this.props.onLayerDestroy(this.props.layerId)}
classBlockName="delete"
onClick={e => this.props.onLayerDestroy(this.props.layerIndex)}
/>
<IconAction
wdKey={"layer-list-item:"+this.props.layerId+":copy"}
action={'duplicate'}
onClick={e => this.props.onLayerCopy(this.props.layerId)}
classBlockName="duplicate"
onClick={e => this.props.onLayerCopy(this.props.layerIndex)}
/>
<IconAction
wdKey={"layer-list-item:"+this.props.layerId+":toggle-visibility"}
action={this.props.visibility === 'visible' ? 'hide' : 'show'}
onClick={e => this.props.onLayerVisibilityToggle(this.props.layerId)}
action={visibilityAction}
classBlockName="visibility"
classBlockModifier={visibilityAction}
onClick={e => this.props.onLayerVisibilityToggle(this.props.layerIndex)}
/>
</li>
}
}
export default LayerListItem;
const LayerListItemSortable = SortableElement((props) => <LayerListItem {...props} />);
export default LayerListItemSortable;

View File

@@ -0,0 +1,247 @@
import React from 'react'
import PropTypes from 'prop-types'
import ReactDOM from 'react-dom'
import MapLibreGl from 'maplibre-gl'
import MapboxInspect from 'mapbox-gl-inspect'
import MapMapboxGlLayerPopup from './MapMapboxGlLayerPopup'
import MapMapboxGlFeaturePropertyPopup from './MapMapboxGlFeaturePropertyPopup'
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 'maplibre-gl/dist/maplibre-gl.css'
import '../mapboxgl.css'
import '../libs/mapbox-rtl'
const IS_SUPPORTED = MapLibreGl.supported();
function renderPopup(popup, mountNode) {
ReactDOM.render(popup, mountNode);
return mountNode;
}
function buildInspectStyle(originalMapStyle, coloredLayers, highlightedLayer) {
const backgroundLayer = {
"id": "background",
"type": "background",
"paint": {
"background-color": '#1c1f24',
}
}
const layer = colorHighlightedLayer(highlightedLayer)
if(layer) {
coloredLayers.push(layer)
}
const sources = {}
Object.keys(originalMapStyle.sources).forEach(sourceId => {
const source = originalMapStyle.sources[sourceId]
if(source.type !== 'raster' && source.type !== 'raster-dem') {
sources[sourceId] = source
}
})
const inspectStyle = {
...originalMapStyle,
sources: sources,
layers: [backgroundLayer].concat(coloredLayers)
}
return inspectStyle
}
export default class MapMapboxGl extends React.Component {
static propTypes = {
onDataChange: PropTypes.func,
onLayerSelect: PropTypes.func.isRequired,
mapStyle: PropTypes.object.isRequired,
inspectModeEnabled: PropTypes.bool.isRequired,
highlightedLayer: PropTypes.object,
options: PropTypes.object,
replaceAccessTokens: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
}
static defaultProps = {
onMapLoaded: () => {},
onDataChange: () => {},
onLayerSelect: () => {},
onChange: () => {},
mapboxAccessToken: tokens.mapbox,
options: {},
}
constructor(props) {
super(props)
this.state = {
map: null,
inspect: null,
}
}
updateMapFromProps(props) {
if(!IS_SUPPORTED) return;
if(!this.state.map) return
//Mapbox 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),
{diff: true}
)
}
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;
this.updateMapFromProps(this.props);
if(this.state.inspect && this.props.inspectModeEnabled !== this.state.inspect._showInspectMap) {
// HACK: Fix for <https://github.com/maputnik/editor/issues/576>, while we wait for a proper fix.
// eslint-disable-next-line
this.state.inspect._popupBlocked = false;
this.state.inspect.toggleInspector()
}
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
// mapbox-gl-inspect.
try {
this.state.inspect.render();
} catch(err) {
console.error("FIXME: Caught error", err);
}
}
map.showTileBoundaries = this.props.options.showTileBoundaries;
map.showCollisionBoxes = this.props.options.showCollisionBoxes;
map.showOverdrawInspector = this.props.options.showOverdrawInspector;
}
}
componentDidMount() {
if(!IS_SUPPORTED) return;
const mapOpts = {
...this.props.options,
container: this.container,
style: this.props.mapStyle,
hash: true,
maxZoom: 24
}
const map = new MapLibreGl.Map(mapOpts);
const mapViewChange = () => {
const center = map.getCenter();
const zoom = map.getZoom();
this.props.onChange({center, zoom});
}
mapViewChange();
map.showTileBoundaries = mapOpts.showTileBoundaries;
map.showCollisionBoxes = mapOpts.showCollisionBoxes;
map.showOverdrawInspector = mapOpts.showOverdrawInspector;
const zoomControl = new ZoomControl;
map.addControl(zoomControl, 'top-right');
const nav = new MapLibreGl.NavigationControl({visualizePitch:true});
map.addControl(nav, 'top-right');
const tmpNode = document.createElement('div');
const inspect = new MapboxInspect({
popup: new MapLibreGl.Popup({
closeOnClick: false
}),
showMapPopup: true,
showMapPopupOnHover: false,
showInspectMapPopupOnHover: true,
showInspectButton: false,
blockHoverPopupOnClick: true,
assignLayerColor: (layerId, alpha) => {
return Color(colors.brightColor(layerId, alpha)).desaturate(0.5).string()
},
buildInspectStyle: (originalMapStyle, coloredLayers) => buildInspectStyle(originalMapStyle, coloredLayers, this.props.highlightedLayer),
renderPopup: features => {
if(this.props.inspectModeEnabled) {
return renderPopup(<MapMapboxGlFeaturePropertyPopup features={features} />, tmpNode);
} else {
return renderPopup(<MapMapboxGlLayerPopup features={features} onLayerSelect={this.onLayerSelectById} zoom={this.state.zoom} />, tmpNode);
}
}
})
map.addControl(inspect)
map.on("style.load", () => {
this.setState({
map,
inspect,
zoom: map.getZoom()
});
})
map.on("data", e => {
if(e.dataType !== 'tile') return
this.props.onDataChange({
map: this.state.map
})
})
map.on("error", e => {
console.log("ERROR", e);
})
map.on("zoom", e => {
this.setState({
zoom: map.getZoom()
});
});
map.on("dragend", mapViewChange);
map.on("zoomend", mapViewChange);
}
onLayerSelectById = (id) => {
const index = this.props.mapStyle.layers.findIndex(layer => layer.id === id);
this.props.onLayerSelect(index);
}
render() {
if(IS_SUPPORTED) {
return <div
className="maputnik-map__map"
role="region"
aria-label="Map view"
ref={x => this.container = x}
></div>
}
else {
return <div
className="maputnik-map maputnik-map--error"
>
<div className="maputnik-map__error-message">
Error: Cannot load MapboxGL, WebGL is either unsupported or disabled
</div>
</div>
}
}
}

View File

@@ -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,18 +15,25 @@ 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 renderFeature(feature) {
return <div key={feature.id}>
<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>
function renderFeatureId(feature) {
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']}: {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>
}
@@ -36,14 +43,14 @@ function removeDuplicatedFeatures(features) {
features.forEach(feature => {
const featureIndex = uniqueFeatures.findIndex(feature2 => {
return feature.layer['source-layer'] === feature2.layer['source-layer']
return feature.layer['source-layer'] === feature2.layer['source-layer']
&& JSON.stringify(feature.properties) === JSON.stringify(feature2.properties)
})
if(featureIndex === -1) {
uniqueFeatures.push(feature)
} else {
if(uniqueFeatures[featureIndex].hasOwnProperty('counter')) {
if(uniqueFeatures[featureIndex].hasOwnProperty('inspectModeCounter')) {
uniqueFeatures[featureIndex].inspectModeCounter++
} else {
uniqueFeatures[featureIndex].inspectModeCounter = 2

View File

@@ -0,0 +1,123 @@
import React from 'react'
import PropTypes from 'prop-types'
import IconLayer from './IconLayer'
import {latest} from '@maplibre/maplibre-gl-style-spec'
function groupFeaturesBySourceLayer(features) {
const sources = {}
let returnedFeatures = {};
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]
} else {
sources[feature.layer['source-layer']] = sources[feature.layer['source-layer']] || []
sources[feature.layer['source-layer']].push(feature)
returnedFeatures[feature.layer.id] = 1
}
})
return sources
}
class FeatureLayerPopup extends React.Component {
static propTypes = {
onLayerSelect: PropTypes.func.isRequired,
features: PropTypes.array,
zoom: PropTypes.number,
}
_getFeatureColor(feature, zoom) {
// Guard because openlayers won't have this
if (!feature.layer.paint) {
return;
}
try {
const paintProps = feature.layer.paint;
let propName;
if(paintProps.hasOwnProperty("text-color") && paintProps["text-color"]) {
propName = "text-color";
}
else if (paintProps.hasOwnProperty("fill-color") && paintProps["fill-color"]) {
propName = "fill-color";
}
else if (paintProps.hasOwnProperty("line-color") && paintProps["line-color"]) {
propName = "line-color";
}
else if (paintProps.hasOwnProperty("fill-extrusion-color") && paintProps["fill-extrusion-color"]) {
propName = "fill-extrusion-color";
}
if(propName) {
const propertySpec = latest["paint_"+feature.layer.type][propName];
let color = feature.layer.paint[propName];
return String(color);
}
else {
// Default color
return "black";
}
}
// This is quite complex, just incase there's an edgecase we're missing
// always return black if we get an unexpected error.
catch (err) {
console.warn("Unable to get feature color, error:", err);
return "black";
}
}
render() {
const sources = groupFeaturesBySourceLayer(this.props.features)
const items = Object.keys(sources).map(vectorLayerId => {
const layers = sources[vectorLayerId].map((feature, idx) => {
const featureColor = this._getFeatureColor(feature, this.props.zoom);
return <div
key={idx}
className="maputnik-popup-layer"
>
<div
className="maputnik-popup-layer__swatch"
style={{background: featureColor}}
></div>
<label
className="maputnik-popup-layer__label"
onClick={() => {
this.props.onLayerSelect(feature.layer.id)
}}
>
{feature.layer.type &&
<IconLayer type={feature.layer.type} style={{
width: 14,
height: 14,
paddingRight: 3
}}/>
}
{feature.layer.id}
{feature.counter && <span> × {feature.counter}</span>}
</label>
</div>
})
return <div key={vectorLayerId}>
<div className="maputnik-popup-layer-id">{vectorLayerId}</div>
{layers}
</div>
})
return <div className="maputnik-feature-layer-popup">
{items}
</div>
}
}
export default FeatureLayerPopup

View File

@@ -0,0 +1,191 @@
import React from 'react'
import {throttle} from 'lodash';
import PropTypes from 'prop-types'
import { loadJSON } from '../libs/urlopen'
import MapMapboxGlLayerPopup from './MapMapboxGlLayerPopup';
import 'ol/ol.css'
import {apply} from 'ol-mapbox-style';
import {Map, View, Proj, Overlay} from 'ol';
import {toLonLat} from 'ol/proj';
import {toStringHDMS} from 'ol/coordinate';
function renderCoords (coords) {
if (!coords || coords.length < 2) {
return null;
}
else {
return <span className="maputnik-coords">
{coords.map((coord) => String(coord).padStart(7, "\u00A0")).join(', ')}
</span>
}
}
export default class MapOpenLayers extends React.Component {
static propTypes = {
onDataChange: PropTypes.func,
mapStyle: PropTypes.object.isRequired,
accessToken: PropTypes.string,
style: PropTypes.object,
onLayerSelect: PropTypes.func.isRequired,
debugToolbox: PropTypes.bool.isRequired,
replaceAccessTokens: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
}
static defaultProps = {
onMapLoaded: () => {},
onDataChange: () => {},
onLayerSelect: () => {},
}
constructor(props) {
super(props);
this.state = {
zoom: 0,
rotation: 0,
cursor: [],
center: [],
};
this.updateStyle = throttle(this._updateStyle.bind(this), 200);
}
_updateStyle(newMapStyle) {
if(!this.map) return;
// See <https://github.com/openlayers/ol-mapbox-style/issues/215#issuecomment-493198815>
this.map.getLayers().clear();
apply(this.map, newMapStyle);
}
componentDidUpdate(prevProps) {
if (this.props.mapStyle !== prevProps.mapStyle) {
this.updateStyle(
this.props.replaceAccessTokens(this.props.mapStyle)
);
}
}
componentDidMount() {
this.overlay = new Overlay({
element: this.popupContainer,
autoPan: true,
autoPanAnimation: {
duration: 250
}
});
const map = new Map({
target: this.container,
overlays: [this.overlay],
view: new View({
zoom: 1,
center: [180, -90],
})
});
map.on('pointermove', (evt) => {
var coords = toLonLat(evt.coordinate);
this.setState({
cursor: [
coords[0].toFixed(2),
coords[1].toFixed(2)
]
})
})
const onMoveEnd = () => {
const zoom = map.getView().getZoom();
const center = toLonLat(map.getView().getCenter());
this.props.onChange({
zoom,
center: {
lng: center[0],
lat: center[1],
},
});
}
onMoveEnd();
map.on('moveend', onMoveEnd);
map.on('postrender', (evt) => {
const center = toLonLat(map.getView().getCenter());
this.setState({
center: [
center[0].toFixed(2),
center[1].toFixed(2),
],
rotation: map.getView().getRotation().toFixed(2),
zoom: map.getView().getZoom().toFixed(2)
});
});
this.map = map;
this.updateStyle(
this.props.replaceAccessTokens(this.props.mapStyle)
);
}
closeOverlay = (e) => {
e.target.blur();
this.overlay.setPosition(undefined);
}
render() {
return <div className="maputnik-ol-container">
<div
ref={x => this.popupContainer = x}
style={{background: "black"}}
className="maputnik-popup"
>
<button
className="mapboxgl-popup-close-button"
onClick={this.closeOverlay}
aria-label="Close popup"
>
×
</button>
<MapMapboxGlLayerPopup
features={this.state.selectedFeatures || []}
onLayerSelect={this.props.onLayerSelect}
/>
</div>
<div className="maputnik-ol-zoom">
Zoom: {this.state.zoom}
</div>
{this.props.debugToolbox &&
<div className="maputnik-ol-debug">
<div>
<label>cursor: </label>
<span>{renderCoords(this.state.cursor)}</span>
</div>
<div>
<label>center: </label>
<span>{renderCoords(this.state.center)}</span>
</div>
<div>
<label>rotation: </label>
<span>{this.state.rotation}</span>
</div>
</div>
}
<div
className="maputnik-ol"
ref={x => this.container = x}
role="region"
aria-label="Map view"
style={{
...this.props.style,
}}>
</div>
</div>
}
}

View File

@@ -1,27 +0,0 @@
import React from 'react'
import PropTypes from 'prop-types'
class MessagePanel extends React.Component {
static propTypes = {
errors: PropTypes.array,
infos: PropTypes.array,
}
render() {
const errors = this.props.errors.map((m, i) => {
return <p key={"error-"+i} className="maputnik-message-panel-error">{m}</p>
})
const infos = this.props.infos.map((m, i) => {
return <p key={"info-"+i}>{m}</p>
})
return <div className="maputnik-message-panel">
{errors}
{infos}
</div>
}
}
export default MessagePanel

View File

@@ -1,10 +1,11 @@
import React from 'react'
import PropTypes from 'prop-types'
import CloseIcon from 'react-icons/lib/md/close'
import {MdClose} from 'react-icons/md'
import AriaModal from 'react-aria-modal'
import classnames from 'classnames';
class Modal extends React.Component {
export default class Modal extends React.Component {
static propTypes = {
"data-wd-key": PropTypes.string,
isOpen: PropTypes.bool.isRequired,
@@ -13,14 +14,22 @@ class Modal extends React.Component {
children: PropTypes.node,
underlayClickExits: PropTypes.bool,
underlayProps: PropTypes.object,
className: PropTypes.string,
}
static defaultProps = {
underlayClickExits: true
}
getApplicationNode() {
return document.getElementById('app');
// See <https://github.com/maputnik/editor/issues/416>
onClose = () => {
if (document.activeElement) {
document.activeElement.blur();
}
setImmediate(() => {
this.props.onOpenToggle(false);
});
}
render() {
@@ -29,22 +38,22 @@ class Modal extends React.Component {
titleText={this.props.title}
underlayClickExits={this.props.underlayClickExits}
underlayProps={this.props.underlayProps}
getApplicationNode={this.getApplicationNode}
data-wd-key={this.props["data-wd-key"]}
verticallyCenter={true}
onExit={() => this.props.onOpenToggle(false)}
onExit={this.onClose}
>
<div className="maputnik-modal"
<div className={classnames("maputnik-modal", this.props.className)}
data-wd-key={this.props["data-wd-key"]}
>
<header className="maputnik-modal-header">
<h1 className="maputnik-modal-header-title">{this.props.title}</h1>
<span className="maputnik-modal-header-space"></span>
<button className="maputnik-modal-header-toggle"
onClick={() => this.props.onOpenToggle(false)}
title="Close modal"
onClick={this.onClose}
data-wd-key={this.props["data-wd-key"]+".close-modal"}
>
<CloseIcon />
<MdClose />
</button>
</header>
<div className="maputnik-modal-scroller">
@@ -59,4 +68,3 @@ class Modal extends React.Component {
}
}
export default Modal

View File

@@ -1,17 +1,16 @@
import React from 'react'
import PropTypes from 'prop-types'
import Button from '../Button'
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import InputButton from './InputButton'
import Modal from './Modal'
import LayerTypeBlock from '../layers/LayerTypeBlock'
import LayerIdBlock from '../layers/LayerIdBlock'
import LayerSourceBlock from '../layers/LayerSourceBlock'
import LayerSourceLayerBlock from '../layers/LayerSourceLayerBlock'
import FieldType from './FieldType'
import FieldId from './FieldId'
import FieldSource from './FieldSource'
import FieldSourceLayer from './FieldSourceLayer'
class AddModal extends React.Component {
export default class ModalAdd extends React.Component {
static propTypes = {
layers: PropTypes.array.isRequired,
onLayersChange: PropTypes.func.isRequired,
@@ -22,7 +21,7 @@ class AddModal extends React.Component {
sources: PropTypes.object.isRequired,
}
addLayer() {
addLayer = () => {
const changedLayers = this.props.layers.slice(0)
const layer = {
id: this.state.id,
@@ -55,10 +54,10 @@ class AddModal extends React.Component {
}
}
UNSAFE_componentWillUpdate(nextProps, nextState) {
componentDidUpdate(prevProps, prevState) {
// Check if source is valid for new type
const oldType = this.state.type;
const newType = nextState.type;
const oldType = prevState.type;
const newType = this.state.type;
const availableSourcesOld = this.getSources(oldType);
const availableSourcesNew = this.getSources(newType);
@@ -66,11 +65,11 @@ class AddModal extends React.Component {
if(
// Type has changed
oldType !== newType
&& this.state.source !== ""
&& prevState.source !== ""
// Was a valid source previously
&& availableSourcesOld.indexOf(this.state.source) > -1
&& availableSourcesOld.indexOf(prevState.source) > -1
// And is not a valid source now
&& availableSourcesNew.indexOf(nextState.source) < 0
&& availableSourcesNew.indexOf(this.state.source) < 0
) {
// Clear the source
this.setState({
@@ -93,10 +92,19 @@ class AddModal extends React.Component {
"line",
"symbol",
"circle",
"fill-extrusion"
"fill-extrusion",
"heatmap"
],
raster: [
"raster"
],
geojson: [
"fill",
"line",
"symbol",
"circle",
"fill-extrusion",
"heatmap"
]
}
@@ -119,22 +127,25 @@ class AddModal extends React.Component {
onOpenToggle={this.props.onOpenToggle}
title={'Add Layer'}
data-wd-key="modal:add-layer"
className="maputnik-add-modal"
>
<div className="maputnik-add-layer">
<LayerIdBlock
<FieldId
label="ID"
fieldSpec={latest.layer.id}
value={this.state.id}
wdKey="add-layer.layer-id"
onChange={v => {
this.setState({ id: v })
}}
/>
<LayerTypeBlock
<FieldType
value={this.state.type}
wdKey="add-layer.layer-type"
onChange={v => this.setState({ type: v })}
/>
{this.state.type !== 'background' &&
<LayerSourceBlock
<FieldSource
sourceIds={sources}
wdKey="add-layer.layer-source-block"
value={this.state.source}
@@ -142,23 +153,22 @@ class AddModal extends React.Component {
/>
}
{['background', 'raster', 'hillshade', 'heatmap'].indexOf(this.state.type) < 0 &&
<LayerSourceLayerBlock
<FieldSourceLayer
isFixed={true}
sourceLayerIds={layers}
value={this.state['source-layer']}
onChange={v => this.setState({ 'source-layer': v })}
/>
}
<Button
<InputButton
className="maputnik-add-layer-button"
onClick={this.addLayer.bind(this)}
onClick={this.addLayer}
data-wd-key="add-layer"
>
Add Layer
</Button>
</InputButton>
</div>
</Modal>
}
}
export default AddModal

View File

@@ -0,0 +1,72 @@
import React from 'react'
import PropTypes from 'prop-types'
import Modal from './Modal'
export default class ModalDebug extends React.Component {
static propTypes = {
isOpen: PropTypes.bool.isRequired,
renderer: PropTypes.string.isRequired,
onChangeMaboxGlDebug: PropTypes.func.isRequired,
onChangeOpenlayersDebug: PropTypes.func.isRequired,
onOpenToggle: PropTypes.func.isRequired,
mapboxGlDebugOptions: PropTypes.object,
openlayersDebugOptions: PropTypes.object,
mapView: PropTypes.object,
}
render() {
const {mapView} = this.props;
const osmZoom = Math.round(mapView.zoom)+1;
const osmLon = Number.parseFloat(mapView.center.lng).toFixed(5);
const osmLat = Number.parseFloat(mapView.center.lat).toFixed(5);
return <Modal
data-wd-key="modal:debug"
isOpen={this.props.isOpen}
onOpenToggle={this.props.onOpenToggle}
title={'Debug'}
>
<section className="maputnik-modal-section maputnik-modal-shortcuts">
<h1>Options</h1>
{this.props.renderer === 'mbgljs' &&
<ul>
{Object.entries(this.props.mapboxGlDebugOptions).map(([key, val]) => {
return <li key={key}>
<label>
<input type="checkbox" checked={val} onClick={(e) => this.props.onChangeMaboxGlDebug(key, e.target.checked)} /> {key}
</label>
</li>
})}
</ul>
}
{this.props.renderer === 'ol' &&
<ul>
{Object.entries(this.props.openlayersDebugOptions).map(([key, val]) => {
return <li key={key}>
<label>
<input type="checkbox" checked={val} onClick={(e) => this.props.onChangeOpenlayersDebug(key, e.target.checked)} /> {key}
</label>
</li>
})}
</ul>
}
</section>
<section className="maputnik-modal-section">
<h1>Links</h1>
<p>
<a
target="_blank"
rel="noopener noreferrer"
href={`https://www.openstreetmap.org/#map=${osmZoom}/${osmLat}/${osmLon}`}
>
Open in OSM
</a> &mdash; Opens the current view on openstreetmap.org
</p>
</section>
</Modal>
}
}

View File

@@ -0,0 +1,162 @@
import React from 'react'
import PropTypes from 'prop-types'
import Slugify from 'slugify'
import { saveAs } from 'file-saver'
import pkgLockJson from '../../package-lock.json'
import {format} from '@maplibre/maplibre-gl-style-spec'
import FieldString from './FieldString'
import FieldCheckbox from './FieldCheckbox'
import InputButton from './InputButton'
import Modal from './Modal'
import {MdFileDownload} from 'react-icons/md'
import style from '../libs/style'
import fieldSpecAdditional from '../libs/field-spec-additional'
const MAPBOX_GL_VERSION = pkgLockJson.dependencies["mapbox-gl"].version;
export default class ModalExport extends React.Component {
static propTypes = {
mapStyle: PropTypes.object.isRequired,
onStyleChanged: PropTypes.func.isRequired,
isOpen: PropTypes.bool.isRequired,
onOpenToggle: PropTypes.func.isRequired,
}
constructor(props) {
super(props);
}
tokenizedStyle () {
return format(
style.stripAccessTokens(
style.replaceAccessTokens(this.props.mapStyle)
)
);
}
exportName () {
if(this.props.mapStyle.name) {
return Slugify(this.props.mapStyle.name, {
replacement: '_',
remove: /[*\-+~.()'"!:]/g,
lower: true
});
} else {
return this.props.mapStyle.id
}
}
downloadHtml() {
const tokenStyle = this.tokenizedStyle();
const htmlTitle = this.props.mapStyle.name || "Map";
const html = `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>${htmlTitle}</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://api.mapbox.com/mapbox-gl-js/v${MAPBOX_GL_VERSION}/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v${MAPBOX_GL_VERSION}/mapbox-gl.css" rel="stylesheet" />
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
mapboxgl.accessToken = 'access_token';
const map = new mapboxgl.Map({
container: 'map',
style: ${tokenStyle},
});
map.addControl(new mapboxgl.NavigationControl());
</script>
</body>
</html>
`;
const blob = new Blob([html], {type: "text/html;charset=utf-8"});
const exportName = this.exportName();
saveAs(blob, exportName + ".html");
}
downloadStyle() {
const tokenStyle = this.tokenizedStyle();
const blob = new Blob([tokenStyle], {type: "application/json;charset=utf-8"});
const exportName = this.exportName();
saveAs(blob, exportName + ".json");
}
changeMetadataProperty(property, value) {
const changedStyle = {
...this.props.mapStyle,
metadata: {
...this.props.mapStyle.metadata,
[property]: value
}
}
this.props.onStyleChanged(changedStyle)
}
render() {
return <Modal
data-wd-key="modal:export"
isOpen={this.props.isOpen}
onOpenToggle={this.props.onOpenToggle}
title={'Export Style'}
className="maputnik-export-modal"
>
<section className="maputnik-modal-section">
<h1>Download Style</h1>
<p>
Download a JSON style to your computer.
</p>
<div>
<FieldString
label={fieldSpecAdditional.maputnik.mapbox_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.mapbox_access_token}
value={(this.props.mapStyle.metadata || {})['maputnik:mapbox_access_token']}
onChange={this.changeMetadataProperty.bind(this, "maputnik:mapbox_access_token")}
/>
<FieldString
label={fieldSpecAdditional.maputnik.maptiler_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.maptiler_access_token}
value={(this.props.mapStyle.metadata || {})['maputnik:openmaptiles_access_token']}
onChange={this.changeMetadataProperty.bind(this, "maputnik:openmaptiles_access_token")}
/>
<FieldString
label={fieldSpecAdditional.maputnik.thunderforest_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.thunderforest_access_token}
value={(this.props.mapStyle.metadata || {})['maputnik:thunderforest_access_token']}
onChange={this.changeMetadataProperty.bind(this, "maputnik:thunderforest_access_token")}
/>
</div>
<div className="maputnik-modal-export-buttons">
<InputButton
onClick={this.downloadStyle.bind(this)}
>
<MdFileDownload />
Download Style
</InputButton>
<InputButton
onClick={this.downloadHtml.bind(this)}
>
<MdFileDownload />
Download HTML
</InputButton>
</div>
</section>
</Modal>
}
}

View File

@@ -1,11 +1,11 @@
import React from 'react'
import PropTypes from 'prop-types'
import Button from '../Button'
import InputButton from './InputButton'
import Modal from './Modal'
class LoadingModal extends React.Component {
export default class ModalLoading extends React.Component {
static propTypes = {
isOpen: PropTypes.bool.isRequired,
onCancel: PropTypes.func.isRequired,
@@ -13,10 +13,6 @@ class LoadingModal extends React.Component {
message: PropTypes.node.isRequired,
}
constructor(props) {
super(props);
}
underlayOnClick(e) {
// This stops click events falling through to underlying modals.
e.stopPropagation();
@@ -24,7 +20,7 @@ class LoadingModal extends React.Component {
render() {
return <Modal
data-wd-key="loading-modal"
data-wd-key="modal:loading"
isOpen={this.props.isOpen}
underlayClickExits={false}
underlayProps={{
@@ -38,12 +34,11 @@ class LoadingModal extends React.Component {
{this.props.message}
</p>
<p className="maputnik-dialog__buttons">
<Button onClick={(e) => this.props.onCancel(e)}>
<InputButton onClick={(e) => this.props.onCancel(e)}>
Cancel
</Button>
</InputButton>
</p>
</Modal>
}
}
export default LoadingModal

View File

@@ -0,0 +1,256 @@
import React from 'react'
import PropTypes from 'prop-types'
import ModalLoading from './ModalLoading'
import Modal from './Modal'
import InputButton from './InputButton'
import FileReaderInput from 'react-file-reader-input'
import InputUrl from './InputUrl'
import {MdFileUpload} from 'react-icons/md'
import {MdAddCircleOutline} from 'react-icons/md'
import style from '../libs/style.js'
import publicStyles from '../config/styles.json'
class PublicStyle extends React.Component {
static propTypes = {
url: PropTypes.string.isRequired,
thumbnailUrl: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
onSelect: PropTypes.func.isRequired,
}
render() {
return <div className="maputnik-public-style">
<InputButton
className="maputnik-public-style-button"
aria-label={this.props.title}
onClick={() => this.props.onSelect(this.props.url)}
>
<div className="maputnik-public-style-header">
<div>{this.props.title}</div>
<span className="maputnik-space" />
<MdAddCircleOutline />
</div>
<div
className="maputnik-public-style-thumbnail"
style={{
backgroundImage: `url(${this.props.thumbnailUrl})`
}}
></div>
</InputButton>
</div>
}
}
export default class ModalOpen extends React.Component {
static propTypes = {
isOpen: PropTypes.bool.isRequired,
onOpenToggle: PropTypes.func.isRequired,
onStyleOpen: PropTypes.func.isRequired,
}
constructor(props) {
super(props);
this.state = {
styleUrl: ""
};
}
clearError() {
this.setState({
error: null
})
}
onCancelActiveRequest(e) {
// Else the click propagates to the underlying modal
if(e) e.stopPropagation();
if(this.state.activeRequest) {
this.state.activeRequest.abort();
this.setState({
activeRequest: null,
activeRequestUrl: null
});
}
}
onStyleSelect = (styleUrl) => {
this.clearError();
let canceled;
const activeRequest = fetch(styleUrl, {
mode: 'cors',
credentials: "same-origin"
})
.then(function(response) {
return response.json();
})
.then((body) => {
if(canceled) {
return;
}
this.setState({
activeRequest: null,
activeRequestUrl: null
});
const mapStyle = style.ensureStyleValidity(body)
console.log('Loaded style ', mapStyle.id)
this.props.onStyleOpen(mapStyle)
this.onOpenToggle()
})
.catch((err) => {
this.setState({
error: `Failed to load: '${styleUrl}'`,
activeRequest: null,
activeRequestUrl: null
});
console.error(err);
console.warn('Could not open the style URL', styleUrl)
})
this.setState({
activeRequest: {
abort: function() {
canceled = true;
}
},
activeRequestUrl: styleUrl
})
}
onSubmitUrl = (e) => {
e.preventDefault();
this.onStyleSelect(this.state.styleUrl);
}
onUpload = (_, files) => {
const [e, file] = files[0];
const reader = new FileReader();
this.clearError();
reader.readAsText(file, "UTF-8");
reader.onload = e => {
let mapStyle;
try {
mapStyle = JSON.parse(e.target.result)
}
catch(err) {
this.setState({
error: err.toString()
});
return;
}
mapStyle = style.ensureStyleValidity(mapStyle)
this.props.onStyleOpen(mapStyle);
this.onOpenToggle();
}
reader.onerror = e => console.log(e.target);
}
onOpenToggle() {
this.setState({
styleUrl: ""
});
this.clearError();
this.props.onOpenToggle();
}
onChangeUrl = (url) => {
this.setState({
styleUrl: url,
});
}
render() {
const styleOptions = publicStyles.map(style => {
return <PublicStyle
key={style.id}
url={style.url}
title={style.title}
thumbnailUrl={style.thumbnail}
onSelect={this.onStyleSelect}
/>
})
let errorElement;
if(this.state.error) {
errorElement = (
<div className="maputnik-modal-error">
{this.state.error}
<a href="#" onClick={() => this.clearError()} className="maputnik-modal-error-close">×</a>
</div>
);
}
return (
<div>
<Modal
data-wd-key="modal:open"
isOpen={this.props.isOpen}
onOpenToggle={() => this.onOpenToggle()}
title={'Open Style'}
>
{errorElement}
<section className="maputnik-modal-section">
<h1>Upload Style</h1>
<p>Upload a JSON style from your computer.</p>
<FileReaderInput onChange={this.onUpload} tabIndex="-1" aria-label="Style file">
<InputButton className="maputnik-upload-button"><MdFileUpload /> Upload</InputButton>
</FileReaderInput>
</section>
<section className="maputnik-modal-section">
<form onSubmit={this.onSubmitUrl}>
<h1>Load from URL</h1>
<p>
Load from a URL. Note that the URL must have <a href="https://enable-cors.org" target="_blank" rel="noopener noreferrer">CORS enabled</a>.
</p>
<InputUrl
aria-label="Style URL"
data-wd-key="modal:open.url.input"
type="text"
className="maputnik-input"
default="Enter URL..."
value={this.state.styleUrl}
onInput={this.onChangeUrl}
onChange={this.onChangeUrl}
/>
<div>
<InputButton
data-wd-key="modal:open.url.button"
type="submit"
className="maputnik-big-button"
disabled={this.state.styleUrl.length < 1}
>Load from URL</InputButton>
</div>
</form>
</section>
<section className="maputnik-modal-section maputnik-modal-section--shrink">
<h1>Gallery Styles</h1>
<p>
Open one of the publicly available styles to start from.
</p>
<div className="maputnik-style-gallery-container">
{styleOptions}
</div>
</section>
</Modal>
<ModalLoading
isOpen={!!this.state.activeRequest}
title={'Loading style'}
onCancel={(e) => this.onCancelActiveRequest(e)}
message={"Loading: "+this.state.activeRequestUrl}
/>
</div>
)
}
}

View File

@@ -0,0 +1,254 @@
import React from 'react'
import PropTypes from 'prop-types'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import Block from './Block'
import FieldArray from './FieldArray'
import FieldNumber from './FieldNumber'
import FieldString from './FieldString'
import FieldUrl from './FieldUrl'
import FieldSelect from './FieldSelect'
import FieldEnum from './FieldEnum'
import FieldColor from './FieldColor'
import Modal from './Modal'
import fieldSpecAdditional from '../libs/field-spec-additional'
export default class ModalSettings extends React.Component {
static propTypes = {
mapStyle: PropTypes.object.isRequired,
onStyleChanged: PropTypes.func.isRequired,
onChangeMetadataProperty: PropTypes.func.isRequired,
isOpen: PropTypes.bool.isRequired,
onOpenToggle: PropTypes.func.isRequired,
}
changeTransitionProperty(property, value) {
const transition = {
...this.props.mapStyle.transition,
}
if (value === undefined) {
delete transition[property];
}
else {
transition[property] = value;
}
this.props.onStyleChanged({
...this.props.mapStyle,
transition,
});
}
changeLightProperty(property, value) {
const light = {
...this.props.mapStyle.light,
}
if (value === undefined) {
delete light[property];
}
else {
light[property] = value;
}
this.props.onStyleChanged({
...this.props.mapStyle,
light,
});
}
changeStyleProperty(property, value) {
const changedStyle = {
...this.props.mapStyle,
};
if (value === undefined) {
delete changedStyle[property];
}
else {
changedStyle[property] = value;
}
this.props.onStyleChanged(changedStyle);
}
render() {
const metadata = this.props.mapStyle.metadata || {}
const {onChangeMetadataProperty, mapStyle} = this.props;
const inputProps = { }
const light = this.props.mapStyle.light || {};
const transition = this.props.mapStyle.transition || {};
return <Modal
data-wd-key="modal:settings"
isOpen={this.props.isOpen}
onOpenToggle={this.props.onOpenToggle}
title={'Style Settings'}
>
<div className="modal:settings">
<FieldString {...inputProps}
label={"Name"}
fieldSpec={latest.$root.name}
data-wd-key="modal:settings.name"
value={this.props.mapStyle.name}
onChange={this.changeStyleProperty.bind(this, "name")}
/>
<FieldString {...inputProps}
label={"Owner"}
fieldSpec={{doc: "Owner ID of the style. Used by Mapbox or future style APIs."}}
data-wd-key="modal:settings.owner"
value={this.props.mapStyle.owner}
onChange={this.changeStyleProperty.bind(this, "owner")}
/>
<FieldUrl {...inputProps}
fieldSpec={latest.$root.sprite}
label="Sprite URL"
data-wd-key="modal:settings.sprite"
value={this.props.mapStyle.sprite}
onChange={this.changeStyleProperty.bind(this, "sprite")}
/>
<FieldUrl {...inputProps}
label="Glyphs URL"
fieldSpec={latest.$root.glyphs}
data-wd-key="modal:settings.glyphs"
value={this.props.mapStyle.glyphs}
onChange={this.changeStyleProperty.bind(this, "glyphs")}
/>
<FieldString {...inputProps}
label={fieldSpecAdditional.maputnik.mapbox_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.mapbox_access_token}
data-wd-key="modal:settings.maputnik:mapbox_access_token"
value={metadata['maputnik:mapbox_access_token']}
onChange={onChangeMetadataProperty.bind(this, "maputnik:mapbox_access_token")}
/>
<FieldString {...inputProps}
label={fieldSpecAdditional.maputnik.maptiler_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.maptiler_access_token}
data-wd-key="modal:settings.maputnik:openmaptiles_access_token"
value={metadata['maputnik:openmaptiles_access_token']}
onChange={onChangeMetadataProperty.bind(this, "maputnik:openmaptiles_access_token")}
/>
<FieldString {...inputProps}
label={fieldSpecAdditional.maputnik.thunderforest_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.thunderforest_access_token}
data-wd-key="modal:settings.maputnik:thunderforest_access_token"
value={metadata['maputnik:thunderforest_access_token']}
onChange={onChangeMetadataProperty.bind(this, "maputnik:thunderforest_access_token")}
/>
<FieldArray
label={"Center"}
fieldSpec={latest.$root.center}
length={2}
type="number"
value={mapStyle.center}
default={latest.$root.center.default || [0, 0]}
onChange={this.changeStyleProperty.bind(this, "center")}
/>
<FieldNumber
{...inputProps}
label={"Zoom"}
fieldSpec={latest.$root.zoom}
value={mapStyle.zoom}
default={latest.$root.zoom.default || 0}
onChange={this.changeStyleProperty.bind(this, "zoom")}
/>
<FieldNumber
{...inputProps}
label={"Bearing"}
fieldSpec={latest.$root.bearing}
value={mapStyle.bearing}
default={latest.$root.bearing.default}
onChange={this.changeStyleProperty.bind(this, "bearing")}
/>
<FieldNumber
{...inputProps}
label={"Pitch"}
fieldSpec={latest.$root.pitch}
value={mapStyle.pitch}
default={latest.$root.pitch.default}
onChange={this.changeStyleProperty.bind(this, "pitch")}
/>
<FieldEnum
{...inputProps}
label={"Light anchor"}
fieldSpec={latest.light.anchor}
name="light-anchor"
value={light.anchor}
options={Object.keys(latest.light.anchor.values)}
default={latest.light.anchor.default}
onChange={this.changeLightProperty.bind(this, "anchor")}
/>
<FieldColor
{...inputProps}
label={"Light color"}
fieldSpec={latest.light.color}
value={light.color}
default={latest.light.color.default}
onChange={this.changeLightProperty.bind(this, "color")}
/>
<FieldNumber
{...inputProps}
label={"Light intensity"}
fieldSpec={latest.light.intensity}
value={light.intensity}
default={latest.light.intensity.default}
onChange={this.changeLightProperty.bind(this, "intensity")}
/>
<FieldArray
{...inputProps}
label={"Light position"}
fieldSpec={latest.light.position}
type="number"
length={latest.light.position.length}
value={light.position}
default={latest.light.position.default}
onChange={this.changeLightProperty.bind(this, "position")}
/>
<FieldNumber
{...inputProps}
label={"Transition delay"}
fieldSpec={latest.transition.delay}
value={transition.delay}
default={latest.transition.delay.default}
onChange={this.changeTransitionProperty.bind(this, "delay")}
/>
<FieldNumber
{...inputProps}
label={"Transition duration"}
fieldSpec={latest.transition.duration}
value={transition.duration}
default={latest.transition.duration.default}
onChange={this.changeTransitionProperty.bind(this, "duration")}
/>
<FieldSelect {...inputProps}
label={fieldSpecAdditional.maputnik.style_renderer.label}
fieldSpec={fieldSpecAdditional.maputnik.style_renderer}
data-wd-key="modal:settings.maputnik:renderer"
options={[
['mbgljs', 'MapboxGL JS'],
['ol', 'Open Layers (experimental)'],
]}
value={metadata['maputnik:renderer'] || 'mbgljs'}
onChange={onChangeMetadataProperty.bind(this, 'maputnik:renderer')}
/>
</div>
</Modal>
}
}

View File

@@ -0,0 +1,132 @@
import React from 'react'
import PropTypes from 'prop-types'
import Modal from './Modal'
export default class ModalShortcuts extends React.Component {
static propTypes = {
isOpen: PropTypes.bool.isRequired,
onOpenToggle: PropTypes.func.isRequired,
}
render() {
const help = [
{
key: <kbd>?</kbd>,
text: "Shortcuts menu"
},
{
key: <kbd>o</kbd>,
text: "Open modal"
},
{
key: <kbd>e</kbd>,
text: "Export modal"
},
{
key: <kbd>d</kbd>,
text: "Data Sources modal"
},
{
key: <kbd>s</kbd>,
text: "Style Settings modal"
},
{
key: <kbd>i</kbd>,
text: "Toggle inspect"
},
{
key: <kbd>m</kbd>,
text: "Focus map"
},
{
key: <kbd>!</kbd>,
text: "Debug modal"
},
]
const mapShortcuts = [
{
key: <kbd>+</kbd>,
text: "Increase the zoom level by 1.",
},
{
key: <><kbd>Shift</kbd> + <kbd>+</kbd></>,
text: "Increase the zoom level by 2.",
},
{
key: <kbd>-</kbd>,
text: "Decrease the zoom level by 1.",
},
{
key: <><kbd>Shift</kbd> + <kbd>-</kbd></>,
text: "Decrease the zoom level by 2.",
},
{
key: <kbd>Up</kbd>,
text: "Pan up by 100 pixels.",
},
{
key: <kbd>Down</kbd>,
text: "Pan down by 100 pixels.",
},
{
key: <kbd>Left</kbd>,
text: "Pan left by 100 pixels.",
},
{
key: <kbd>Right</kbd>,
text: "Pan right by 100 pixels.",
},
{
key: <><kbd>Shift</kbd> + <kbd>Right</kbd></>,
text: "Increase the rotation by 15 degrees.",
},
{
key: <><kbd>Shift</kbd> + <kbd>Left</kbd></>,
text: "Decrease the rotation by 15 degrees."
},
{
key: <><kbd>Shift</kbd> + <kbd>Up</kbd></>,
text: "Increase the pitch by 10 degrees."
},
{
key: <><kbd>Shift</kbd> + <kbd>Down</kbd></>,
text: "Decrease the pitch by 10 degrees."
},
]
return <Modal
data-wd-key="modal:shortcuts"
isOpen={this.props.isOpen}
onOpenToggle={this.props.onOpenToggle}
title={'Shortcuts'}
>
<section className="maputnik-modal-section maputnik-modal-shortcuts">
<p>
Press <code>ESC</code> to lose focus of any active elements, then press one of:
</p>
<dl>
{help.map((item, idx) => {
return <div key={idx} className="maputnik-modal-shortcuts__shortcut">
<dt key={"dt"+idx}>{item.key}</dt>
<dd key={"dd"+idx}>{item.text}</dd>
</div>
})}
</dl>
<p>If the Map is in focused you can use the following shortcuts</p>
<ul>
{mapShortcuts.map((item, idx) => {
return <li key={idx}>
<span>{item.key}</span> {item.text}
</li>
})}
</ul>
</section>
</Modal>
}
}

View File

@@ -1,19 +1,18 @@
import React from 'react'
import PropTypes from 'prop-types'
import * as styleSpec from '@mapbox/mapbox-gl-style-spec/style-spec'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import Modal from './Modal'
import Button from '../Button'
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import SelectInput from '../inputs/SelectInput'
import SourceTypeEditor from '../sources/SourceTypeEditor'
import InputButton from './InputButton'
import Block from './Block'
import FieldString from './FieldString'
import FieldSelect from './FieldSelect'
import ModalSourcesTypeEditor from './ModalSourcesTypeEditor'
import style from '../../libs/style'
import { deleteSource, addSource, changeSource } from '../../libs/source'
import publicSources from '../../config/tilesets.json'
import style from '../libs/style'
import { deleteSource, addSource, changeSource } from '../libs/source'
import publicSources from '../config/tilesets.json'
import AddIcon from 'react-icons/lib/md/add-circle-outline'
import DeleteIcon from 'react-icons/lib/md/delete'
import {MdAddCircleOutline, MdDelete} from 'react-icons/md'
class PublicSource extends React.Component {
static propTypes = {
@@ -25,7 +24,7 @@ class PublicSource extends React.Component {
render() {
return <div className="maputnik-public-source">
<Button
<InputButton
className="maputnik-public-source-select"
onClick={() => this.props.onSelect(this.props.id)}
>
@@ -34,8 +33,8 @@ class PublicSource extends React.Component {
<p className="maputnik-public-source-id">#{this.props.id}</p>
</div>
<span className="maputnik-space" />
<AddIcon />
</Button>
<MdAddCircleOutline />
</InputButton>
</div>
}
}
@@ -53,11 +52,24 @@ function editorMode(source) {
if(source.tiles) return 'tilexyz_vector'
return 'tilejson_vector'
}
if(source.type === 'geojson') return 'geojson'
if(source.type === 'geojson') {
if (typeof(source.data) === "string") {
return 'geojson_url';
}
else {
return 'geojson_json';
}
}
if(source.type === 'image') {
return 'image';
}
if(source.type === 'video') {
return 'video';
}
return null
}
class ActiveSourceTypeEditor extends React.Component {
class ActiveModalSourcesTypeEditor extends React.Component {
static propTypes = {
sourceId: PropTypes.string.isRequired,
source: PropTypes.object.isRequired,
@@ -71,16 +83,17 @@ class ActiveSourceTypeEditor extends React.Component {
<div className="maputnik-active-source-type-editor-header">
<span className="maputnik-active-source-type-editor-header-id">#{this.props.sourceId}</span>
<span className="maputnik-space" />
<Button
<InputButton
aria-label={`Remove '${this.props.sourceId}' source`}
className="maputnik-active-source-type-editor-header-delete"
onClick={()=> this.props.onDelete(this.props.sourceId)}
style={{backgroundColor: 'transparent'}}
>
<DeleteIcon />
</Button>
<MdDelete />
</InputButton>
</div>
<div className="maputnik-active-source-type-editor-content">
<SourceTypeEditor
<ModalSourcesTypeEditor
onChange={this.props.onChange}
mode={editorMode(this.props.source)}
source={this.props.source}
@@ -106,83 +119,135 @@ class AddSource extends React.Component {
defaultSource(mode) {
const source = (this.state || {}).source || {}
const {protocol} = window.location;
switch(mode) {
case 'geojson': return {
case 'geojson_url': return {
type: 'geojson',
data: source.data || 'http://localhost:3000/geojson.json'
data: `${protocol}//localhost:3000/geojson.json`
}
case 'geojson_json': return {
type: 'geojson',
data: {}
}
case 'tilejson_vector': return {
type: 'vector',
url: source.url || 'http://localhost:3000/tilejson.json'
url: source.url || `${protocol}//localhost:3000/tilejson.json`
}
case 'tilexyz_vector': return {
type: 'vector',
tiles: source.tiles || ['http://localhost:3000/{x}/{y}/{z}.pbf'],
tiles: source.tiles || [`${protocol}//localhost:3000/{x}/{y}/{z}.pbf`],
minZoom: source.minzoom || 0,
maxZoom: source.maxzoom || 14
}
case 'tilejson_raster': return {
type: 'raster',
url: source.url || 'http://localhost:3000/tilejson.json'
url: source.url || `${protocol}//localhost:3000/tilejson.json`
}
case 'tilexyz_raster': return {
type: 'raster',
tiles: source.tiles || ['http://localhost:3000/{x}/{y}/{z}.pbf'],
tiles: source.tiles || [`${protocol}//localhost:3000/{x}/{y}/{z}.pbf`],
minzoom: source.minzoom || 0,
maxzoom: source.maxzoom || 14
}
case 'tilejson_raster-dem': return {
type: 'raster-dem',
url: source.url || 'http://localhost:3000/tilejson.json'
url: source.url || `${protocol}//localhost:3000/tilejson.json`
}
case 'tilexyz_raster-dem': return {
type: 'raster-dem',
tiles: source.tiles || ['http://localhost:3000/{x}/{y}/{z}.pbf'],
tiles: source.tiles || [`${protocol}//localhost:3000/{x}/{y}/{z}.pbf`],
minzoom: source.minzoom || 0,
maxzoom: source.maxzoom || 14
}
case 'image': return {
type: 'image',
url: `${protocol}//localhost:3000/image.png`,
coordinates: [
[0,0],
[0,0],
[0,0],
[0,0],
],
}
case 'video': return {
type: 'video',
urls: [
`${protocol}//localhost:3000/movie.mp4`
],
coordinates: [
[0,0],
[0,0],
[0,0],
[0,0],
],
}
default: return {}
}
}
onAdd = () => {
const {source, sourceId} = this.state;
this.props.onAdd(sourceId, source);
}
onChangeSource = (source) => {
this.setState({source});
}
render() {
// Kind of a hack because the type changes, however maputnik has 1..n
// options per type, for example
//
// - 'geojson' - 'GeoJSON (URL)' and 'GeoJSON (JSON)'
// - 'raster' - 'Raster (TileJSON URL)' and 'Raster (XYZ URL)'
//
// So we just ignore the values entirely as they are self explanatory
const sourceTypeFieldSpec = {
doc: latest.source_vector.type.doc
};
return <div className="maputnik-add-source">
<InputBlock label={"Source ID"} doc={"Unique ID that identifies the source and is used in the layer to reference the source."}>
<StringInput
value={this.state.sourceId}
onChange={v => this.setState({ sourceId: v})}
/>
</InputBlock>
<InputBlock label={"Source Type"} doc={styleSpec.latest.source_vector.type.doc}>
<SelectInput
options={[
['geojson', 'GeoJSON'],
['tilejson_vector', 'Vector (TileJSON URL)'],
['tilexyz_vector', 'Vector (XYZ URLs)'],
['tilejson_raster', 'Raster (TileJSON URL)'],
['tilexyz_raster', 'Raster (XYZ URL)'],
['tilejson_raster-dem', 'Raster DEM (TileJSON URL)'],
['tilexyz_raster-dem', 'Raster DEM (XYZ URLs)'],
]}
onChange={mode => this.setState({mode: mode, source: this.defaultSource(mode)})}
value={this.state.mode}
/>
</InputBlock>
<SourceTypeEditor
onChange={src => this.setState({ source: src })}
<FieldString
label={"Source ID"}
fieldSpec={{doc: "Unique ID that identifies the source and is used in the layer to reference the source."}}
value={this.state.sourceId}
onChange={v => this.setState({ sourceId: v})}
/>
<FieldSelect
label={"Source Type"}
fieldSpec={sourceTypeFieldSpec}
options={[
['geojson_json', 'GeoJSON (JSON)'],
['geojson_url', 'GeoJSON (URL)'],
['tilejson_vector', 'Vector (TileJSON URL)'],
['tilexyz_vector', 'Vector (XYZ URLs)'],
['tilejson_raster', 'Raster (TileJSON URL)'],
['tilexyz_raster', 'Raster (XYZ URL)'],
['tilejson_raster-dem', 'Raster DEM (TileJSON URL)'],
['tilexyz_raster-dem', 'Raster DEM (XYZ URLs)'],
['image', 'Image'],
['video', 'Video'],
]}
onChange={mode => this.setState({mode: mode, source: this.defaultSource(mode)})}
value={this.state.mode}
/>
<ModalSourcesTypeEditor
onChange={this.onChangeSource}
mode={this.state.mode}
source={this.state.source}
/>
<Button
<InputButton
className="maputnik-add-source-button"
onClick={() => this.props.onAdd(this.state.sourceId, this.state.source)}>
onClick={this.onAdd}
>
Add Source
</Button>
</InputButton>
</div>
}
}
class SourcesModal extends React.Component {
export default class ModalSources extends React.Component {
static propTypes = {
mapStyle: PropTypes.object.isRequired,
isOpen: PropTypes.bool.isRequired,
@@ -200,7 +265,7 @@ class SourcesModal extends React.Component {
const mapStyle = this.props.mapStyle
const activeSources = Object.keys(mapStyle.sources).map(sourceId => {
const source = mapStyle.sources[sourceId]
return <ActiveSourceTypeEditor
return <ActiveModalSourcesTypeEditor
key={sourceId}
sourceId={sourceId}
source={source}
@@ -222,37 +287,34 @@ class SourcesModal extends React.Component {
const inputProps = { }
return <Modal
data-wd-key="modal:sources"
isOpen={this.props.isOpen}
onOpenToggle={this.props.onOpenToggle}
title={'Sources'}
>
<div className="maputnik-modal-section">
<h4>Active Sources</h4>
<section className="maputnik-modal-section">
<h1>Active Sources</h1>
{activeSources}
</div>
</section>
<div className="maputnik-modal-section">
<h4>Choose Public Source</h4>
<section className="maputnik-modal-section">
<h1>Choose Public Source</h1>
<p>
Add one of the publicly available sources to your style.
</p>
<div className="maputnik-public-sources" style={{maxwidth: 500}}>
{tilesetOptions}
</div>
<p>
<strong>Note:</strong> Some of the tilesets are not optimised for online use, and as a result the file sizes of the tiles can be quite large (heavy) for online vector rendering. Please review any tilesets before use.
</p>
</div>
</section>
<div className="maputnik-modal-section">
<h4>Add New Source</h4>
<section className="maputnik-modal-section">
<h1>Add New Source</h1>
<p>Add a new source to your style. You can only choose the source type and id at creation time!</p>
<AddSource
onAdd={(sourceId, source) => this.props.onStyleChanged(addSource(mapStyle, sourceId, source))}
/>
</div>
</section>
</Modal>
}
}
export default SourcesModal

View File

@@ -0,0 +1,266 @@
import React from 'react'
import PropTypes from 'prop-types'
import {latest} from '@maplibre/maplibre-gl-style-spec'
import Block from './Block'
import FieldUrl from './FieldUrl'
import FieldNumber from './FieldNumber'
import FieldSelect from './FieldSelect'
import FieldDynamicArray from './FieldDynamicArray'
import FieldArray from './FieldArray'
import FieldJson from './FieldJson'
class TileJSONSourceEditor extends React.Component {
static propTypes = {
source: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
children: PropTypes.node,
}
render() {
return <div>
<FieldUrl
label={"TileJSON URL"}
fieldSpec={latest.source_vector.url}
value={this.props.source.url}
onChange={url => this.props.onChange({
...this.props.source,
url: url
})}
/>
{this.props.children}
</div>
}
}
class TileURLSourceEditor extends React.Component {
static propTypes = {
source: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
children: PropTypes.node,
}
changeTileUrls(tiles) {
this.props.onChange({
...this.props.source,
tiles,
})
}
renderTileUrls() {
const tiles = this.props.source.tiles || [];
return <FieldDynamicArray
label={"Tile URL"}
fieldSpec={latest.source_vector.tiles}
type="url"
value={tiles}
onChange={this.changeTileUrls.bind(this)}
/>
}
render() {
return <div>
{this.renderTileUrls()}
<FieldNumber
label={"Min Zoom"}
fieldSpec={latest.source_vector.minzoom}
value={this.props.source.minzoom || 0}
onChange={minzoom => this.props.onChange({
...this.props.source,
minzoom: minzoom
})}
/>
<FieldNumber
label={"Max Zoom"}
fieldSpec={latest.source_vector.maxzoom}
value={this.props.source.maxzoom || 22}
onChange={maxzoom => this.props.onChange({
...this.props.source,
maxzoom: maxzoom
})}
/>
{this.props.children}
</div>
}
}
class ImageSourceEditor extends React.Component {
static propTypes = {
source: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
}
render() {
const changeCoord = (idx, val) => {
const coordinates = this.props.source.coordinates.slice(0);
coordinates[idx] = val;
this.props.onChange({
...this.props.source,
coordinates,
});
}
return <div>
<FieldUrl
label={"Image URL"}
fieldSpec={latest.source_image.url}
value={this.props.source.url}
onChange={url => this.props.onChange({
...this.props.source,
url,
})}
/>
{["top left", "top right", "bottom right", "bottom left"].map((label, idx) => {
return (
<FieldArray
label={`Coord ${label}`}
key={label}
length={2}
type="number"
value={this.props.source.coordinates[idx]}
default={[0, 0]}
onChange={(val) => changeCoord(idx, val)}
/>
);
})}
</div>
}
}
class VideoSourceEditor extends React.Component {
static propTypes = {
source: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
}
render() {
const changeCoord = (idx, val) => {
const coordinates = this.props.source.coordinates.slice(0);
coordinates[idx] = val;
this.props.onChange({
...this.props.source,
coordinates,
});
}
const changeUrls = (urls) => {
this.props.onChange({
...this.props.source,
urls,
});
}
return <div>
<FieldDynamicArray
label={"Video URL"}
fieldSpec={latest.source_video.urls}
type="string"
value={this.props.source.urls}
default={""}
onChange={changeUrls}
/>
{["top left", "top right", "bottom right", "bottom left"].map((label, idx) => {
return (
<FieldArray
label={`Coord ${label}`}
key={label}
length={2}
type="number"
value={this.props.source.coordinates[idx]}
default={[0, 0]}
onChange={val => changeCoord(idx, val)}
/>
);
})}
</div>
}
}
class GeoJSONSourceUrlEditor extends React.Component {
static propTypes = {
source: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
}
render() {
return <FieldUrl
label={"GeoJSON URL"}
fieldSpec={latest.source_geojson.data}
value={this.props.source.data}
onChange={data => this.props.onChange({
...this.props.source,
data: data
})}
/>
}
}
class GeoJSONSourceFieldJsonEditor extends React.Component {
static propTypes = {
source: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
}
render() {
return <Block label={"GeoJSON"} fieldSpec={latest.source_geojson.data}>
<FieldJson
layer={this.props.source.data}
maxHeight={200}
mode={{
name: "javascript",
json: true
}}
lint={true}
onChange={data => {
this.props.onChange({
...this.props.source,
data,
})
}}
/>
</Block>
}
}
export default class ModalSourcesTypeEditor extends React.Component {
static propTypes = {
mode: PropTypes.string.isRequired,
source: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
}
render() {
const commonProps = {
source: this.props.source,
onChange: this.props.onChange,
}
switch(this.props.mode) {
case 'geojson_url': return <GeoJSONSourceUrlEditor {...commonProps} />
case 'geojson_json': return <GeoJSONSourceFieldJsonEditor {...commonProps} />
case 'tilejson_vector': return <TileJSONSourceEditor {...commonProps} />
case 'tilexyz_vector': return <TileURLSourceEditor {...commonProps} />
case 'tilejson_raster': return <TileJSONSourceEditor {...commonProps} />
case 'tilexyz_raster': return <TileURLSourceEditor {...commonProps} />
case 'tilejson_raster-dem': return <TileJSONSourceEditor {...commonProps} />
case 'tilexyz_raster-dem': return <TileURLSourceEditor {...commonProps}>
<FieldSelect
label={"Encoding"}
fieldSpec={latest.source_raster_dem.encoding}
options={Object.keys(latest.source_raster_dem.encoding.values)}
onChange={encoding => this.props.onChange({
...this.props.source,
encoding: encoding
})}
value={this.props.source.encoding || latest.source_raster_dem.encoding.default}
/>
</TileURLSourceEditor>
case 'image': return <ImageSourceEditor {...commonProps} />
case 'video': return <VideoSourceEditor {...commonProps} />
default: return null
}
}
}

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