@esri/solutions-components 0.6.16 → 0.6.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/t9n/map-tools/resources.json +2 -1
  3. package/dist/assets/t9n/map-tools/resources_en.json +2 -1
  4. package/dist/assets/t9n/solution-spatial-ref/resources.json +0 -1
  5. package/dist/assets/t9n/solution-spatial-ref/resources_en.json +0 -1
  6. package/dist/assets/t9n/solution-spatial-ref/resources_fr.json +6 -0
  7. package/dist/assets/t9n/solution-spatial-ref/resources_he.json +6 -0
  8. package/dist/assets/t9n/spatial-ref/resources.json +3 -0
  9. package/dist/assets/t9n/spatial-ref/resources_en.json +3 -0
  10. package/dist/assets/t9n/spatial-ref/resources_fr.json +3 -0
  11. package/dist/assets/t9n/spatial-ref/resources_he.json +3 -0
  12. package/dist/cjs/{basemap-gallery_6.cjs.entry.js → basemap-gallery_7.cjs.entry.js} +124 -3
  13. package/dist/cjs/{calcite-tree_3.cjs.entry.js → calcite-checkbox_3.cjs.entry.js} +123 -319
  14. package/dist/cjs/calcite-combobox_6.cjs.entry.js +1 -1
  15. package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +4 -3
  16. package/dist/cjs/card-manager_3.cjs.entry.js +10 -7
  17. package/dist/{collection/components/basemap-gallery/test/basemap-gallery.e2e.js → cjs/common-13719149.js} +17 -9
  18. package/dist/cjs/crowdsource-manager.cjs.entry.js +12 -7
  19. package/dist/cjs/{downloadUtils-34a515ad.js → downloadUtils-121fd7ff.js} +2 -2
  20. package/dist/cjs/edit-card_2.cjs.entry.js +4 -3
  21. package/dist/cjs/{index.es-0ba11065.js → index.es-5c0c137a.js} +2 -2
  22. package/dist/cjs/loader.cjs.js +1 -1
  23. package/dist/cjs/map-select-tools_3.cjs.entry.js +2 -2
  24. package/dist/cjs/{mapViewUtils-a2884698.js → mapViewUtils-786a219b.js} +32 -19
  25. package/dist/cjs/public-notification.cjs.entry.js +2 -2
  26. package/dist/cjs/solution-configuration.cjs.entry.js +2 -1
  27. package/dist/cjs/solution-contents_3.cjs.entry.js +21 -21256
  28. package/dist/cjs/solution-item-icon.cjs.entry.js +327 -0
  29. package/dist/cjs/{solution-store-c443e657.js → solution-resource-f9e3b289.js} +2 -1698
  30. package/dist/cjs/solution-store-2414dd8a.js +1707 -0
  31. package/dist/cjs/solutions-components.cjs.js +1 -1
  32. package/dist/cjs/spatial-ref.cjs.entry.js +21293 -0
  33. package/dist/collection/collection-manifest.json +2 -0
  34. package/dist/collection/components/card-manager/card-manager.js +1 -1
  35. package/dist/collection/components/crowdsource-manager/crowdsource-manager.css +17 -2
  36. package/dist/collection/components/crowdsource-manager/crowdsource-manager.js +47 -6
  37. package/dist/collection/components/edit-card/edit-card.css +0 -8
  38. package/dist/collection/components/floor-filter/floor-filter.css +19 -0
  39. package/dist/collection/components/floor-filter/floor-filter.js +163 -0
  40. package/dist/collection/components/info-card/info-card.js +3 -2
  41. package/dist/collection/components/layer-table/layer-table.css +8 -0
  42. package/dist/collection/components/layer-table/layer-table.js +18 -2
  43. package/dist/collection/components/map-card/map-card.js +19 -1
  44. package/dist/collection/components/map-picker/map-picker.css +0 -4
  45. package/dist/collection/components/map-picker/map-picker.js +1 -1
  46. package/dist/collection/components/map-tools/map-tools.js +54 -1
  47. package/dist/collection/components/solution-spatial-ref/solution-spatial-ref.css +1 -7
  48. package/dist/collection/components/solution-spatial-ref/solution-spatial-ref.js +37 -291
  49. package/dist/collection/components/solution-spatial-ref/test/solution-spatial-ref.e2e.js +24 -12
  50. package/dist/collection/components/solution-spatial-ref/test/solution-spatial-ref.spec.js +32 -128
  51. package/dist/collection/components/spatial-ref/spatial-ref.css +20 -0
  52. package/dist/collection/components/spatial-ref/spatial-ref.js +445 -0
  53. package/dist/collection/components/spatial-ref/test/spatial-ref.e2e.js +71 -0
  54. package/dist/collection/components/spatial-ref/test/spatial-ref.spec.js +158 -0
  55. package/dist/collection/demos/crowdsource-manager.html +4 -0
  56. package/dist/collection/demos/solution-spatial-ref.html +9 -16
  57. package/dist/collection/demos/spatial-ref.html +53 -0
  58. package/dist/collection/utils/mapViewUtils.js +32 -19
  59. package/dist/collection/utils/mapViewUtils.ts +43 -20
  60. package/dist/collection/utils/{templates.e2e.js → test/templates.e2e.js} +2 -2
  61. package/dist/collection/utils/{templates.e2e.ts → test/templates.e2e.ts} +2 -2
  62. package/dist/components/card-manager2.js +1 -1
  63. package/dist/components/crowdsource-manager.js +86 -73
  64. package/dist/components/edit-card2.js +1 -1
  65. package/dist/components/floor-filter.d.ts +11 -0
  66. package/dist/components/floor-filter.js +11 -0
  67. package/dist/components/floor-filter2.js +115 -0
  68. package/dist/components/info-card2.js +3 -2
  69. package/dist/components/layer-table2.js +5 -3
  70. package/dist/components/map-card2.js +45 -37
  71. package/dist/components/map-picker2.js +2 -2
  72. package/dist/components/map-tools2.js +52 -11
  73. package/dist/components/mapViewUtils.js +32 -19
  74. package/dist/components/solution-configuration.js +79 -72
  75. package/dist/components/solution-resource-item2.js +2 -1
  76. package/dist/components/solution-resource.js +1836 -0
  77. package/dist/components/solution-spatial-ref2.js +41 -21277
  78. package/dist/components/solution-store.js +2 -1830
  79. package/dist/components/spatial-ref.d.ts +11 -0
  80. package/dist/components/spatial-ref.js +11 -0
  81. package/dist/components/spatial-ref2.js +21374 -0
  82. package/dist/esm/{basemap-gallery_6.entry.js → basemap-gallery_7.entry.js} +124 -4
  83. package/dist/esm/{calcite-tree_3.entry.js → calcite-checkbox_3.entry.js} +125 -321
  84. package/dist/esm/calcite-combobox_6.entry.js +1 -1
  85. package/dist/esm/calcite-shell-panel_14.entry.js +2 -1
  86. package/dist/esm/card-manager_3.entry.js +10 -7
  87. package/dist/{collection/components/layer-table/test/layer-table.e2e.js → esm/common-e4a8e353.js} +15 -9
  88. package/dist/esm/crowdsource-manager.entry.js +12 -7
  89. package/dist/esm/{downloadUtils-ac67a786.js → downloadUtils-287994b1.js} +2 -2
  90. package/dist/esm/edit-card_2.entry.js +4 -3
  91. package/dist/esm/{index.es-f553598f.js → index.es-a3f8409f.js} +2 -2
  92. package/dist/esm/loader.js +1 -1
  93. package/dist/esm/map-select-tools_3.entry.js +2 -2
  94. package/dist/esm/{mapViewUtils-8141d8c1.js → mapViewUtils-8bfabd80.js} +32 -19
  95. package/dist/esm/public-notification.entry.js +2 -2
  96. package/dist/esm/solution-configuration.entry.js +2 -1
  97. package/dist/esm/solution-contents_3.entry.js +20 -21255
  98. package/dist/esm/solution-item-icon.entry.js +323 -0
  99. package/dist/esm/{solution-store-b29d50f7.js → solution-resource-be35d35b.js} +1 -1697
  100. package/dist/esm/solution-store-e734626a.js +1704 -0
  101. package/dist/esm/solutions-components.js +1 -1
  102. package/dist/esm/spatial-ref.entry.js +21289 -0
  103. package/dist/solutions-components/demos/crowdsource-manager.html +4 -0
  104. package/dist/solutions-components/demos/solution-spatial-ref.html +9 -16
  105. package/dist/solutions-components/demos/spatial-ref.html +53 -0
  106. package/dist/solutions-components/{p-64d29ba2.entry.js → p-0bc27ba7.entry.js} +2 -2
  107. package/dist/{collection/components/map-card/test/map-card.e2e.js → solutions-components/p-1b228f97.js} +2 -10
  108. package/dist/solutions-components/{p-9f11a403.entry.js → p-3c5c1487.entry.js} +1 -1
  109. package/dist/solutions-components/{p-a26711e8.js → p-469c8f8a.js} +1 -1
  110. package/dist/solutions-components/p-53bc5fc1.js +36 -0
  111. package/dist/solutions-components/p-5b8c8942.entry.js +21 -0
  112. package/dist/solutions-components/p-63c6fc29.entry.js +6 -0
  113. package/dist/solutions-components/p-64945b43.entry.js +18 -0
  114. package/dist/solutions-components/{p-c8d0ce92.js → p-698c6a56.js} +2 -2
  115. package/dist/solutions-components/{p-b9d29f30.entry.js → p-734cb206.entry.js} +1 -1
  116. package/dist/solutions-components/p-770bff06.entry.js +6 -0
  117. package/dist/solutions-components/p-7741dbab.entry.js +6 -0
  118. package/dist/solutions-components/p-80465067.entry.js +6 -0
  119. package/dist/solutions-components/p-846df994.entry.js +6 -0
  120. package/dist/solutions-components/p-b3f8d2cb.js +192 -0
  121. package/dist/solutions-components/p-c26d8b36.entry.js +6 -0
  122. package/dist/solutions-components/{p-57cf6784.entry.js → p-d22be647.entry.js} +1 -1
  123. package/dist/solutions-components/{p-4d942b0f.entry.js → p-f35147d5.entry.js} +1 -1
  124. package/dist/solutions-components/p-ff0d7712.js +44 -0
  125. package/dist/solutions-components/solutions-components.esm.js +1 -1
  126. package/dist/solutions-components/utils/mapViewUtils.ts +43 -20
  127. package/dist/solutions-components/utils/{templates.e2e.ts → test/templates.e2e.ts} +2 -2
  128. package/dist/types/components/crowdsource-manager/crowdsource-manager.d.ts +9 -1
  129. package/dist/types/components/floor-filter/floor-filter.d.ts +61 -0
  130. package/dist/types/components/layer-table/layer-table.d.ts +4 -0
  131. package/dist/types/components/map-card/map-card.d.ts +4 -0
  132. package/dist/types/components/map-tools/map-tools.d.ts +24 -0
  133. package/dist/types/components/solution-spatial-ref/solution-spatial-ref.d.ts +11 -93
  134. package/dist/types/components/spatial-ref/spatial-ref.d.ts +142 -0
  135. package/dist/types/components.d.ts +123 -16
  136. package/dist/types/preact.d.ts +8 -1
  137. package/package.json +6 -6
  138. package/dist/cjs/calcite-checkbox.cjs.entry.js +0 -136
  139. package/dist/collection/components/basemap-gallery/test/basemap-gallery.spec.js +0 -37
  140. package/dist/collection/components/buffer-tools/test/buffer-tools.e2e.js +0 -29
  141. package/dist/collection/components/buffer-tools/test/buffer-tools.spec.js +0 -160
  142. package/dist/collection/components/card-manager/test/card-manager.e2e.js +0 -29
  143. package/dist/collection/components/card-manager/test/card-manager.spec.js +0 -37
  144. package/dist/collection/components/crowdsource-manager/test/crowdsource-manager.e2e.js +0 -29
  145. package/dist/collection/components/crowdsource-manager/test/crowdsource-manager.spec.js +0 -37
  146. package/dist/collection/components/crowdsource-reporter/test/crowdsource-reporter.e2e.js +0 -29
  147. package/dist/collection/components/crowdsource-reporter/test/crowdsource-reporter.spec.js +0 -37
  148. package/dist/collection/components/deduct-calculator/test/deduct-calculator.e2e.js +0 -29
  149. package/dist/collection/components/deduct-calculator/test/deduct-calculator.spec.js +0 -37
  150. package/dist/collection/components/edit-card/test/edit-card.e2e.js +0 -14
  151. package/dist/collection/components/edit-card/test/edit-card.spec.js +0 -22
  152. package/dist/collection/components/info-card/test/info-card.e2e.js +0 -29
  153. package/dist/collection/components/info-card/test/info-card.spec.js +0 -37
  154. package/dist/collection/components/json-editor/test/json-editor.e2e.js +0 -36
  155. package/dist/collection/components/json-editor/test/json-editor.spec.js +0 -65
  156. package/dist/collection/components/layer-table/test/layer-table.spec.js +0 -37
  157. package/dist/collection/components/layout-manager/test/layout-manager.e2e.js +0 -29
  158. package/dist/collection/components/layout-manager/test/layout-manager.spec.js +0 -37
  159. package/dist/collection/components/list-item/test/list-item.e2e.js +0 -29
  160. package/dist/collection/components/list-item/test/list-item.spec.js +0 -37
  161. package/dist/collection/components/map-card/test/map-card.spec.js +0 -37
  162. package/dist/collection/components/map-draw-tools/test/map-draw-tools.e2e.js +0 -29
  163. package/dist/collection/components/map-draw-tools/test/map-draw-tools.spec.js +0 -37
  164. package/dist/collection/components/map-fullscreen/test/map-fullscreen.e2e.js +0 -29
  165. package/dist/collection/components/map-fullscreen/test/map-fullscreen.spec.js +0 -37
  166. package/dist/collection/components/map-layer-picker/test/map-layer-picker.e2e.js +0 -29
  167. package/dist/collection/components/map-layer-picker/test/map-layer-picker.spec.js +0 -114
  168. package/dist/collection/components/map-legend/test/map-legend.e2e.js +0 -14
  169. package/dist/collection/components/map-legend/test/map-legend.spec.js +0 -22
  170. package/dist/collection/components/map-picker/test/map-picker.e2e.js +0 -29
  171. package/dist/collection/components/map-picker/test/map-picker.spec.js +0 -37
  172. package/dist/collection/components/map-search/test/map-search.e2e.js +0 -29
  173. package/dist/collection/components/map-search/test/map-search.spec.js +0 -37
  174. package/dist/collection/components/map-select-tools/test/map-select-tools.e2e.js +0 -29
  175. package/dist/collection/components/map-select-tools/test/map-select-tools.spec.js +0 -366
  176. package/dist/collection/components/map-tools/test/map-tools.e2e.js +0 -29
  177. package/dist/collection/components/map-tools/test/map-tools.spec.js +0 -37
  178. package/dist/collection/components/pci-calculator/test/pci-calculator.e2e.js +0 -29
  179. package/dist/collection/components/pci-calculator/test/pci-calculator.spec.js +0 -37
  180. package/dist/collection/components/pdf-download/test/pdf-download.e2e.js +0 -76
  181. package/dist/collection/components/pdf-download/test/pdf-download.spec.js +0 -107
  182. package/dist/collection/components/public-notification/test/public-notification.spec.js +0 -161
  183. package/dist/collection/components/refine-selection/test/refine-selection.e2e.js +0 -14
  184. package/dist/collection/components/refine-selection/test/refine-selection.spec.js +0 -22
  185. package/dist/collection/components/solution-configuration/test/solution-configuration.e2e.js +0 -36
  186. package/dist/collection/components/solution-configuration/test/solution-configuration.spec.js +0 -119
  187. package/dist/collection/components/solution-contents/test/solution-contents.e2e.js +0 -94
  188. package/dist/collection/components/solution-contents/test/solution-contents.spec.js +0 -143
  189. package/dist/collection/components/solution-item/test/solution-item.e2e.js +0 -36
  190. package/dist/collection/components/solution-item/test/solution-item.spec.js +0 -77
  191. package/dist/collection/components/solution-item-details/test/solution-item-details.e2e.js +0 -36
  192. package/dist/collection/components/solution-item-details/test/solution-item-details.spec.js +0 -142
  193. package/dist/collection/components/solution-item-icon/test/solution-item-icon.e2e.js +0 -29
  194. package/dist/collection/components/solution-item-icon/test/solution-item-icon.spec.js +0 -39
  195. package/dist/collection/components/solution-item-sharing/test/solution-item-sharing.e2e.js +0 -36
  196. package/dist/collection/components/solution-item-sharing/test/solution-item-sharing.spec.js +0 -54
  197. package/dist/collection/components/solution-organization-variables/test/solution-organization-variables.e2e.js +0 -36
  198. package/dist/collection/components/solution-organization-variables/test/solution-organization-variables.spec.js +0 -65
  199. package/dist/collection/components/solution-resource-item/test/solution-resource-item.e2e.js +0 -36
  200. package/dist/collection/components/solution-resource-item/test/solution-resource-item.spec.js +0 -55
  201. package/dist/collection/components/solution-template-data/test/solution-template-data.e2e.js +0 -36
  202. package/dist/collection/components/solution-template-data/test/solution-template-data.spec.js +0 -60
  203. package/dist/collection/components/solution-variables/test/solution-variables.e2e.js +0 -36
  204. package/dist/collection/components/solution-variables/test/solution-variables.spec.js +0 -131
  205. package/dist/esm/calcite-checkbox.entry.js +0 -132
  206. package/dist/solutions-components/p-07d7e11f.entry.js +0 -6
  207. package/dist/solutions-components/p-16362eb4.js +0 -36
  208. package/dist/solutions-components/p-17d176b5.js +0 -230
  209. package/dist/solutions-components/p-1d9a5198.entry.js +0 -37
  210. package/dist/solutions-components/p-3707d9bd.entry.js +0 -6
  211. package/dist/solutions-components/p-4dbe8337.entry.js +0 -6
  212. package/dist/solutions-components/p-5ffaaaf4.entry.js +0 -6
  213. package/dist/solutions-components/p-736e76fb.entry.js +0 -17
  214. package/dist/solutions-components/p-99f1a767.entry.js +0 -6
  215. /package/dist/collection/components/{solution-spatial-ref → spatial-ref}/spatialreferences.js +0 -0
  216. /package/dist/types/components/{solution-spatial-ref → spatial-ref}/spatialreferences.d.ts +0 -0
@@ -18,12 +18,14 @@
18
18
  * See the License for the specific language governing permissions and
19
19
  * limitations under the License.
20
20
  */
21
+ import * as locale from "../../../utils/locale";
22
+ import state from "../../../utils/solution-store";
23
+ import { h } from "@stencil/core";
21
24
  import { newSpecPage } from "@stencil/core/testing";
22
25
  import { SolutionSpatialRef } from "../solution-spatial-ref";
23
- import { h } from "@stencil/core";
24
- import state from "../../../utils/solution-store";
25
- xdescribe('solution-spatial-ref', () => {
26
+ describe('solution-spatial-ref', () => {
26
27
  beforeEach(() => {
28
+ jest.spyOn(locale, 'getLocaleComponentStrings').mockImplementation(() => Promise.resolve([{ "spatialReferencePlaceholder": "Search for spatial reference using name or WKID" }, "en"]));
27
29
  state._testAccess("_emptyTheStore");
28
30
  state.setStoreInfo("spatialReferenceInfo", {
29
31
  enabled: true,
@@ -34,6 +36,9 @@ xdescribe('solution-spatial-ref', () => {
34
36
  spatialReference: undefined
35
37
  });
36
38
  });
39
+ afterEach(() => {
40
+ jest.clearAllMocks();
41
+ });
37
42
  it('renders', async () => {
38
43
  const page = await newSpecPage({
39
44
  components: [SolutionSpatialRef],
@@ -41,135 +46,34 @@ xdescribe('solution-spatial-ref', () => {
41
46
  template: () => (h("solution-spatial-ref", { services: ["Feature Service 1", "Feature Service 2"] }))
42
47
  });
43
48
  expect(page.root).toEqualHtml(`
44
- <solution-spatial-ref default-wkid="102100" locked="">
45
- <label class="switch-label"><calcite-switch scale="m" class="spatial-ref-switch"></calcite-switch>Spatial Reference Parameter</label>
46
- <div id="spatialRefDefn" class="spatial-ref-switch-title">
47
- <calcite-label>Select the spatial reference of the feature layers deployed with the solution.
48
- <label class="spatial-ref-default">
49
- <calcite-input disabled="" placeholder="Search for spatial reference using name or WKID"></calcite-input>
50
- </label>
51
- </calcite-label>
52
- <div class="disabled-div">
53
- <calcite-tree id="calcite-sr-tree" slot="children">
54
- <div class="spatial-ref-container" id="solution-wkid-container">
55
- <calcite-tree-item aria-selected="" id="102100" selected="">
56
- <div>
57
- WGS 1984 Web Mercator Auxiliary Sphere (102100)
58
- </div>
59
- </calcite-tree-item>
60
- </div>
61
- </calcite-tree>
49
+ <solution-spatial-ref default-wkid="102100" locked="" value="102100">
50
+ <div class="spatial-ref">
51
+ <div class="spatial-ref-desc">
52
+ <calcite-label></calcite-label>
62
53
  </div>
63
- <div>
64
- <label class="spatial-ref-item-title">Feature Services</label>
65
- <label class="switch-label"><calcite-switch disabled="" scale="m" switched="" class="spatial-ref-item-switch"></calcite-switch>Feature Service 1</label>
66
- <label class="switch-label"><calcite-switch disabled="" scale="m" class="spatial-ref-item-switch"></calcite-switch>Feature Service 2</label>
54
+ <label class="switch-label">
55
+ <calcite-switch class="spatial-ref-switch" scale="m"></calcite-switch>
56
+ </label>
57
+ <div class="spatial-ref-component" id="spatialRefDefn">
58
+ <calcite-label>
59
+ <label class="spatial-ref-default">
60
+ <spatial-ref defaultwkid="102100" disabled="" value="102100"></spatial-ref>
61
+ </label>
62
+ </calcite-label>
63
+ <div>
64
+ <label class="spatial-ref-item-title"></label>
65
+ <label class="switch-label">
66
+ <calcite-switch checked="" class="spatial-ref-item-switch" disabled="" scale="m"></calcite-switch>
67
+ Feature Service 1
68
+ </label>
69
+ <label class="switch-label">
70
+ <calcite-switch class="spatial-ref-item-switch" disabled="" scale="m"></calcite-switch>
71
+ Feature Service 2
72
+ </label>
73
+ </div>
67
74
  </div>
68
75
  </div>
69
76
  </solution-spatial-ref>
70
77
  `);
71
78
  });
72
- it('creates description for known WKID', async () => {
73
- await newSpecPage({
74
- components: [SolutionSpatialRef],
75
- template: () => (h("solution-spatial-ref", null))
76
- });
77
- const component = document.querySelector('solution-spatial-ref');
78
- component.wkidToDisplay(4326)
79
- .then(result => expect(result).toEqual('GCS WGS 1984 (4326)'));
80
- });
81
- it('creates description for unknown WKID', async () => {
82
- await newSpecPage({
83
- components: [SolutionSpatialRef],
84
- template: () => (h("solution-spatial-ref", null))
85
- });
86
- const component = document.querySelector('solution-spatial-ref');
87
- component.wkidToDisplay(0)
88
- .then(result => expect(result).toEqual('WKID 0'));
89
- });
90
- it('creates description for default component value', async () => {
91
- await newSpecPage({
92
- components: [SolutionSpatialRef],
93
- template: () => (h("solution-spatial-ref", null))
94
- });
95
- const component = document.querySelector('solution-spatial-ref');
96
- component.createSpatialRefDisplay(null)
97
- .then(result => {
98
- expect(result.display).toEqual('WGS 1984 Web Mercator Auxiliary Sphere (102100)');
99
- expect(result.usingWkid).toBeTruthy();
100
- expect(result.wkid).toEqual(102100);
101
- expect(result.wkt).toEqual('');
102
- });
103
- });
104
- it('creates description for WKID component value', async () => {
105
- await newSpecPage({
106
- components: [SolutionSpatialRef],
107
- template: () => (h("solution-spatial-ref", null))
108
- });
109
- const component = document.querySelector('solution-spatial-ref');
110
- component.createSpatialRefDisplay("4151")
111
- .then(result => {
112
- expect(result.display).toEqual('GCS Swiss TRF 1995 (4151)');
113
- expect(result.usingWkid).toBeTruthy();
114
- expect(result.wkid).toEqual(4151);
115
- expect(result.wkt).toEqual('');
116
- });
117
- });
118
- it('creates description for WKT component value', async () => {
119
- await newSpecPage({
120
- components: [SolutionSpatialRef],
121
- template: () => (h("solution-spatial-ref", null))
122
- });
123
- const component = document.querySelector('solution-spatial-ref');
124
- component.createSpatialRefDisplay('PROJCS["Germany_Zone_5",GEOGCS["GCS_Deutsches_Hauptdreiecksnetz",DATUM["D_Deutsches_Hauptdreiecksnetz",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",5500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]')
125
- .then(result => {
126
- expect(result.display).toEqual('PROJCS["Germany_Zone_5",GEOGCS["GCS_Deutsches_Hauptdreiecksnetz",DATUM["D_Deutsches_Hauptdreiecksnetz",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",5500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]');
127
- expect(result.usingWkid).toBeFalsy();
128
- expect(result.wkid).toEqual(0);
129
- expect(result.wkt).toEqual('PROJCS["Germany_Zone_5",GEOGCS["GCS_Deutsches_Hauptdreiecksnetz",DATUM["D_Deutsches_Hauptdreiecksnetz",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",5500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]');
130
- });
131
- });
132
- it('sets default component value', async () => {
133
- await newSpecPage({
134
- components: [SolutionSpatialRef],
135
- template: () => (h("solution-spatial-ref", null))
136
- });
137
- const component = document.querySelector('solution-spatial-ref');
138
- component.getSpatialRef()
139
- .then(result => {
140
- expect(result.display).toEqual('WGS 1984 Web Mercator Auxiliary Sphere (102100)');
141
- expect(result.usingWkid).toBeTruthy();
142
- expect(result.wkid).toEqual(102100);
143
- expect(result.wkt).toEqual('');
144
- });
145
- });
146
- it('sets WKID component value', async () => {
147
- await newSpecPage({
148
- components: [SolutionSpatialRef],
149
- template: () => (h("solution-spatial-ref", { value: "4151" }))
150
- });
151
- const component = document.querySelector('solution-spatial-ref');
152
- component.getSpatialRef()
153
- .then(result => {
154
- expect(result.display).toEqual('GCS Swiss TRF 1995 (4151)');
155
- expect(result.usingWkid).toBeTruthy();
156
- expect(result.wkid).toEqual(4151);
157
- expect(result.wkt).toEqual('');
158
- });
159
- });
160
- it('sets WKT component value', async () => {
161
- const v = `PROJCS["Germany_Zone_5",GEOGCS["GCS_Deutsches_Hauptdreiecksnetz",DATUM["D_Deutsches_Hauptdreiecksnetz",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",5500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]`;
162
- await newSpecPage({
163
- components: [SolutionSpatialRef],
164
- template: () => (h("solution-spatial-ref", { value: v }))
165
- });
166
- const component = document.querySelector('solution-spatial-ref');
167
- component.getSpatialRef()
168
- .then(result => {
169
- expect(result.display).toEqual('PROJCS["Germany_Zone_5",GEOGCS["GCS_Deutsches_Hauptdreiecksnetz",DATUM["D_Deutsches_Hauptdreiecksnetz",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",5500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]');
170
- expect(result.usingWkid).toBeFalsy();
171
- expect(result.wkid).toEqual(0);
172
- expect(result.wkt).toEqual('PROJCS["Germany_Zone_5",GEOGCS["GCS_Deutsches_Hauptdreiecksnetz",DATUM["D_Deutsches_Hauptdreiecksnetz",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",5500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]');
173
- });
174
- });
175
79
  });
@@ -0,0 +1,20 @@
1
+ /** @license
2
+ * Copyright 2022 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ .spatial-ref-container {
17
+ max-height: 200px;
18
+ margin-bottom: 1rem;
19
+ overflow-y: auto;
20
+ }
@@ -0,0 +1,445 @@
1
+ /*!
2
+ * Copyright 2022 Esri
3
+ * Licensed under the Apache License, Version 2.0
4
+ * http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ /** @license
7
+ * Copyright 2022 Esri
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+ import "@esri/calcite-components";
22
+ import { h, Host } from "@stencil/core";
23
+ import { getLocaleComponentStrings } from "../../utils/locale";
24
+ import { nodeListToArray } from "../../utils/common";
25
+ import { wkids } from "./spatialreferences";
26
+ export class SpatialRef {
27
+ valueChanged(newValue) {
28
+ this.spatialReferenceChange.emit({
29
+ oldValue: this.value,
30
+ newValue: newValue
31
+ });
32
+ this._spatialRef = this._createSpatialRefDisplay(newValue);
33
+ const searchBox = document.getElementById("calcite-sr-search");
34
+ if (searchBox) {
35
+ searchBox.value = this._srSearchText = "";
36
+ }
37
+ this._clearSelection();
38
+ }
39
+ //--------------------------------------------------------------------------
40
+ //
41
+ // Lifecycle
42
+ //
43
+ //--------------------------------------------------------------------------
44
+ constructor() {
45
+ this.defaultWkid = 102100;
46
+ this.disabled = false;
47
+ this.value = this.defaultWkid.toString();
48
+ this._spatialRef = undefined;
49
+ this._srSearchText = undefined;
50
+ this._translations = undefined;
51
+ this._spatialRef = this._createSpatialRefDisplay(this.value);
52
+ }
53
+ /**
54
+ * StencilJS: Called once just after the component is first connected to the DOM.
55
+ */
56
+ componentWillLoad() {
57
+ return this._getTranslations();
58
+ }
59
+ /**
60
+ * Renders the component.
61
+ */
62
+ render() {
63
+ return (h(Host, null, h("div", null, h("calcite-input", { disabled: this.disabled, id: "calcite-sr-search", onKeyUp: (evt) => this._searchInputKeyDown(evt), placeholder: this._translations.spatialReferencePlaceholder }), h("calcite-tree", { id: "calcite-sr-tree", slot: "children" }, this._getTreeContent()))));
64
+ }
65
+ //--------------------------------------------------------------------------
66
+ //
67
+ // Public Methods (async)
68
+ //
69
+ //--------------------------------------------------------------------------
70
+ /**
71
+ * Returns the spatial reference description of the supplied value.
72
+ * (Exposes protected method `_createSpatialRefDisplay` for testing.)
73
+ *
74
+ * @param value WKID or WKT or null for default
75
+ * @returns If component is using a WKID, description using WKID; otherwise, the WKT; defaults to 102100
76
+ */
77
+ async createSpatialRefDisplay(value) {
78
+ return this._createSpatialRefDisplay(value);
79
+ }
80
+ /**
81
+ * Returns the current spatial reference description.
82
+ * (Exposes protected variable `spatialRef` for testing.)
83
+ */
84
+ async getSpatialRef() {
85
+ return this._spatialRef;
86
+ }
87
+ /**
88
+ * Converts a WKID into a spatial reference description.
89
+ * (Exposes protected method `_wkidToDisplay` for testing.)
90
+ *
91
+ * @param wkid WKID to look up
92
+ * @returns Description, or "WKID &lt;wkid&gt;" if a description doesn't exist for the WKID
93
+ */
94
+ async wkidToDisplay(wkid) {
95
+ return this._wkidToDisplay(wkid);
96
+ }
97
+ //--------------------------------------------------------------------------
98
+ //
99
+ // Private Methods
100
+ //
101
+ //--------------------------------------------------------------------------
102
+ /**
103
+ * Returns the spatial reference description of the supplied value.
104
+ *
105
+ * @param value WKID or WKT or null for default
106
+ * @returns If component is using a WKID, description using WKID; otherwise, the WKT; defaults to 102100
107
+ */
108
+ _createSpatialRefDisplay(value) {
109
+ let spatialRef;
110
+ if (!value) {
111
+ spatialRef = {
112
+ display: this._wkidToDisplay(this.defaultWkid),
113
+ usingWkid: true,
114
+ wkid: this.defaultWkid,
115
+ wkt: ""
116
+ };
117
+ }
118
+ else {
119
+ const wkid = Number.parseInt(value);
120
+ spatialRef = isNaN(wkid) ? {
121
+ display: value,
122
+ usingWkid: false,
123
+ wkid: 0,
124
+ wkt: value
125
+ } : {
126
+ display: this._wkidToDisplay(wkid),
127
+ usingWkid: true,
128
+ wkid: wkid,
129
+ wkt: ""
130
+ };
131
+ }
132
+ return spatialRef;
133
+ }
134
+ /**
135
+ * Stores the wkid as the components value.
136
+ */
137
+ _setSpatialRef(wkid) {
138
+ if (this.value !== wkid) {
139
+ this.value = wkid;
140
+ }
141
+ }
142
+ /**
143
+ * Converts a WKID into a spatial reference description.
144
+ *
145
+ * @param wkid WKID to look up
146
+ * @returns Description, or "WKID &lt;wkid&gt;" if a description doesn't exist for the WKID
147
+ */
148
+ _wkidToDisplay(wkid) {
149
+ const description = wkids[wkid];
150
+ return description ? description.label + " (" + wkid.toString() + ")" : "WKID " + wkid.toString();
151
+ }
152
+ /**
153
+ * Sets the search text State and cause render; if Enter key, selects the first child.
154
+ *
155
+ * @param event The keyboard event
156
+ */
157
+ _searchInputKeyDown(event) {
158
+ if (event.key === "Enter") {
159
+ this._selectFirstChild();
160
+ }
161
+ else {
162
+ const searchBox = document.getElementById("calcite-sr-search");
163
+ if (searchBox) {
164
+ this._srSearchText = searchBox.value;
165
+ }
166
+ }
167
+ }
168
+ /**
169
+ * Tracks the movement through the list of projections, and selects the one for which Enter is used twice.
170
+ *
171
+ * @param event The keyboard event
172
+ */
173
+ _projListInputKeyDown(event) {
174
+ const highlightedSref = event.target.id;
175
+ if (event.key === "Enter" && this._lastHighlightedSref === highlightedSref) {
176
+ // "Enter" twice on the same projection selects it
177
+ this._clearSelection();
178
+ this._setSpatialRef(this._lastHighlightedSref.toString());
179
+ }
180
+ else {
181
+ // Save the projection in case it's selected a second time
182
+ this._lastHighlightedSref = highlightedSref;
183
+ }
184
+ }
185
+ /**
186
+ * Clear any selected items in the elements tree.
187
+ *
188
+ */
189
+ _clearSelection() {
190
+ const selectedItems = nodeListToArray(this.el.querySelectorAll("calcite-tree-item[selected]"));
191
+ selectedItems.forEach((treeItem) => {
192
+ treeItem.selected = false;
193
+ });
194
+ }
195
+ /**
196
+ * Select the first child from the tree.
197
+ *
198
+ * @param autoFocus Boolean to indicate if focus should also be shifted to the first child.
199
+ *
200
+ */
201
+ _selectFirstChild() {
202
+ const wkidContainer = document.getElementById("solution-wkid-container");
203
+ if (wkidContainer && wkidContainer.firstChild) {
204
+ const firstChild = wkidContainer.firstChild;
205
+ firstChild.selected = true;
206
+ this._setSpatialRef(firstChild.id);
207
+ }
208
+ }
209
+ /**
210
+ * Get the tree items for the current spatial reference search
211
+ *
212
+ */
213
+ _getTreeContent() {
214
+ const id = "solution-wkid-container";
215
+ const containerClass = "spatial-ref-container";
216
+ if (this._srSearchText && this._srSearchText.length > 1) {
217
+ const regEx = new RegExp(`${this._srSearchText}`, 'gi');
218
+ const matches = Object.keys(wkids).filter(wkid => {
219
+ return regEx.test(wkid.toString()) || regEx.test(wkids[wkid].label);
220
+ });
221
+ return matches.length > 0 ? (h("div", { class: containerClass, id: id, onKeyDown: (evt) => this._projListInputKeyDown(evt) }, matches.map((wkid) => this._getTreeItem(wkid, false)))) : (null);
222
+ }
223
+ else {
224
+ return (h("div", { class: containerClass, id: id }, this._getTreeItem(this.value.toString(), true)));
225
+ }
226
+ }
227
+ /**
228
+ * Get the individual spatial reference tree item
229
+ *
230
+ * @param wkid The wkid for the spatial reference that will be displayed.
231
+ * @param selected Should the item be selected by default.
232
+ *
233
+ */
234
+ _getTreeItem(wkid, selected) {
235
+ var _a;
236
+ const label = (_a = wkids[wkid]) === null || _a === void 0 ? void 0 : _a.label;
237
+ return label ?
238
+ (h("calcite-tree-item", { "aria-selected": selected, id: wkid, onClick: () => this._setSpatialRef(wkid), selected: selected }, h("div", null, `${label} (${wkid})`))) : (h("calcite-tree-item", { "aria-selected": selected, id: wkid, onClick: () => this._setSpatialRef(wkid), selected: selected }, h("div", null, `${wkid}`)));
239
+ }
240
+ /**
241
+ * Fetches the component's translations
242
+ *
243
+ * @protected
244
+ */
245
+ async _getTranslations() {
246
+ const translations = await getLocaleComponentStrings(this.el);
247
+ this._translations = translations[0];
248
+ }
249
+ static get is() { return "spatial-ref"; }
250
+ static get originalStyleUrls() {
251
+ return {
252
+ "$": ["spatial-ref.scss"]
253
+ };
254
+ }
255
+ static get styleUrls() {
256
+ return {
257
+ "$": ["spatial-ref.css"]
258
+ };
259
+ }
260
+ static get properties() {
261
+ return {
262
+ "defaultWkid": {
263
+ "type": "number",
264
+ "mutable": true,
265
+ "complexType": {
266
+ "original": "number",
267
+ "resolved": "number",
268
+ "references": {}
269
+ },
270
+ "required": false,
271
+ "optional": false,
272
+ "docs": {
273
+ "tags": [],
274
+ "text": "The wkid that will be used as the default when no user selection has been made."
275
+ },
276
+ "attribute": "default-wkid",
277
+ "reflect": true,
278
+ "defaultValue": "102100"
279
+ },
280
+ "disabled": {
281
+ "type": "boolean",
282
+ "mutable": true,
283
+ "complexType": {
284
+ "original": "boolean",
285
+ "resolved": "boolean",
286
+ "references": {}
287
+ },
288
+ "required": false,
289
+ "optional": false,
290
+ "docs": {
291
+ "tags": [],
292
+ "text": "When true, all are disabled to prevent interaction."
293
+ },
294
+ "attribute": "disabled",
295
+ "reflect": true,
296
+ "defaultValue": "false"
297
+ },
298
+ "value": {
299
+ "type": "string",
300
+ "mutable": true,
301
+ "complexType": {
302
+ "original": "string",
303
+ "resolved": "string",
304
+ "references": {}
305
+ },
306
+ "required": false,
307
+ "optional": false,
308
+ "docs": {
309
+ "tags": [],
310
+ "text": "Contains the public value for this component, which is a wkid or a wkt."
311
+ },
312
+ "attribute": "value",
313
+ "reflect": true,
314
+ "defaultValue": "this.defaultWkid.toString()"
315
+ }
316
+ };
317
+ }
318
+ static get states() {
319
+ return {
320
+ "_spatialRef": {},
321
+ "_srSearchText": {},
322
+ "_translations": {}
323
+ };
324
+ }
325
+ static get events() {
326
+ return [{
327
+ "method": "spatialReferenceChange",
328
+ "name": "spatialReferenceChange",
329
+ "bubbles": true,
330
+ "cancelable": true,
331
+ "composed": true,
332
+ "docs": {
333
+ "tags": [],
334
+ "text": ""
335
+ },
336
+ "complexType": {
337
+ "original": "IValueChange",
338
+ "resolved": "IValueChange",
339
+ "references": {
340
+ "IValueChange": {
341
+ "location": "import",
342
+ "path": "../../utils/interfaces",
343
+ "id": "src/utils/interfaces.ts::IValueChange"
344
+ }
345
+ }
346
+ }
347
+ }];
348
+ }
349
+ static get methods() {
350
+ return {
351
+ "createSpatialRefDisplay": {
352
+ "complexType": {
353
+ "signature": "(value: string) => Promise<ISpatialRefRepresentation>",
354
+ "parameters": [{
355
+ "tags": [{
356
+ "name": "param",
357
+ "text": "value WKID or WKT or null for default"
358
+ }],
359
+ "text": "WKID or WKT or null for default"
360
+ }],
361
+ "references": {
362
+ "Promise": {
363
+ "location": "global",
364
+ "id": "global::Promise"
365
+ },
366
+ "ISpatialRefRepresentation": {
367
+ "location": "import",
368
+ "path": "../../utils/interfaces",
369
+ "id": "src/utils/interfaces.ts::ISpatialRefRepresentation"
370
+ }
371
+ },
372
+ "return": "Promise<ISpatialRefRepresentation>"
373
+ },
374
+ "docs": {
375
+ "text": "Returns the spatial reference description of the supplied value.\r\n(Exposes protected method `_createSpatialRefDisplay` for testing.)",
376
+ "tags": [{
377
+ "name": "param",
378
+ "text": "value WKID or WKT or null for default"
379
+ }, {
380
+ "name": "returns",
381
+ "text": "If component is using a WKID, description using WKID; otherwise, the WKT; defaults to 102100"
382
+ }]
383
+ }
384
+ },
385
+ "getSpatialRef": {
386
+ "complexType": {
387
+ "signature": "() => Promise<ISpatialRefRepresentation>",
388
+ "parameters": [],
389
+ "references": {
390
+ "Promise": {
391
+ "location": "global",
392
+ "id": "global::Promise"
393
+ },
394
+ "ISpatialRefRepresentation": {
395
+ "location": "import",
396
+ "path": "../../utils/interfaces",
397
+ "id": "src/utils/interfaces.ts::ISpatialRefRepresentation"
398
+ }
399
+ },
400
+ "return": "Promise<ISpatialRefRepresentation>"
401
+ },
402
+ "docs": {
403
+ "text": "Returns the current spatial reference description.\r\n(Exposes protected variable `spatialRef` for testing.)",
404
+ "tags": []
405
+ }
406
+ },
407
+ "wkidToDisplay": {
408
+ "complexType": {
409
+ "signature": "(wkid: number) => Promise<string>",
410
+ "parameters": [{
411
+ "tags": [{
412
+ "name": "param",
413
+ "text": "wkid WKID to look up"
414
+ }],
415
+ "text": "WKID to look up"
416
+ }],
417
+ "references": {
418
+ "Promise": {
419
+ "location": "global",
420
+ "id": "global::Promise"
421
+ }
422
+ },
423
+ "return": "Promise<string>"
424
+ },
425
+ "docs": {
426
+ "text": "Converts a WKID into a spatial reference description.\r\n(Exposes protected method `_wkidToDisplay` for testing.)",
427
+ "tags": [{
428
+ "name": "param",
429
+ "text": "wkid WKID to look up"
430
+ }, {
431
+ "name": "returns",
432
+ "text": "Description, or \"WKID &lt;wkid&gt;\" if a description doesn't exist for the WKID"
433
+ }]
434
+ }
435
+ }
436
+ };
437
+ }
438
+ static get elementRef() { return "el"; }
439
+ static get watchers() {
440
+ return [{
441
+ "propName": "value",
442
+ "methodName": "valueChanged"
443
+ }];
444
+ }
445
+ }