@esri/solutions-components 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. package/dist/cjs/calcite-input-text_5.cjs.entry.js +36 -36
  2. package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +1 -1
  3. package/dist/cjs/solution-configuration.cjs.entry.js +1 -1
  4. package/dist/cjs/solution-contents_3.cjs.entry.js +1 -1
  5. package/dist/cjs/{solution-store-70002b57.js → solution-store-ca4639d5.js} +3 -3
  6. package/dist/collection/components/add-record-modal/test/add-record-modal.e2e.js +24 -0
  7. package/dist/collection/components/add-record-modal/test/add-record-modal.spec.js +32 -0
  8. package/dist/collection/components/buffer-tools/test/buffer-tools.e2e.js +24 -0
  9. package/dist/collection/components/buffer-tools/test/buffer-tools.spec.js +157 -0
  10. package/dist/collection/components/card-manager/test/card-manager.e2e.js +24 -0
  11. package/dist/collection/components/card-manager/test/card-manager.spec.js +32 -0
  12. package/dist/collection/components/comment-card/test/comment-card.e2e.js +24 -0
  13. package/dist/collection/components/comment-card/test/comment-card.spec.js +32 -0
  14. package/dist/collection/components/crowdsource-manager/test/crowdsource-manager.e2e.js +24 -0
  15. package/dist/collection/components/crowdsource-manager/test/crowdsource-manager.spec.js +32 -0
  16. package/dist/collection/components/crowdsource-reporter/test/crowdsource-reporter.e2e.js +24 -0
  17. package/dist/collection/components/crowdsource-reporter/test/crowdsource-reporter.spec.js +32 -0
  18. package/dist/collection/components/deduct-calculator/test/deduct-calculator.e2e.js +24 -0
  19. package/dist/collection/components/deduct-calculator/test/deduct-calculator.spec.js +32 -0
  20. package/dist/collection/components/edit-record-modal/test/edit-record-modal.e2e.js +24 -0
  21. package/dist/collection/components/edit-record-modal/test/edit-record-modal.spec.js +32 -0
  22. package/dist/collection/components/info-card/test/info-card.e2e.js +24 -0
  23. package/dist/collection/components/info-card/test/info-card.spec.js +32 -0
  24. package/dist/collection/components/json-editor/test/json-editor.e2e.js +31 -0
  25. package/dist/collection/components/json-editor/test/json-editor.spec.js +60 -0
  26. package/dist/collection/components/layer-table/test/layer-table.e2e.js +24 -0
  27. package/dist/collection/components/layer-table/test/layer-table.spec.js +32 -0
  28. package/dist/collection/components/list-item/test/list-item.e2e.js +24 -0
  29. package/dist/collection/components/list-item/test/list-item.spec.js +32 -0
  30. package/dist/collection/components/map-card/test/map-card.e2e.js +24 -0
  31. package/dist/collection/components/map-card/test/map-card.spec.js +32 -0
  32. package/dist/collection/components/map-draw-tools/test/map-draw-tools.e2e.js +24 -0
  33. package/dist/collection/components/map-draw-tools/test/map-draw-tools.spec.js +32 -0
  34. package/dist/collection/components/map-layer-picker/test/map-layer-picker.e2e.js +24 -0
  35. package/dist/collection/components/map-layer-picker/test/map-layer-picker.spec.js +109 -0
  36. package/dist/collection/components/map-search/test/map-search.e2e.js +24 -0
  37. package/dist/collection/components/map-search/test/map-search.spec.js +53 -0
  38. package/dist/collection/components/map-select-tools/map-select-tools.js +36 -36
  39. package/dist/collection/components/map-select-tools/test/map-select-tools.e2e.js +24 -0
  40. package/dist/collection/components/map-select-tools/test/map-select-tools.spec.js +349 -0
  41. package/dist/collection/components/media-card/test/media-card.e2e.js +24 -0
  42. package/dist/collection/components/media-card/test/media-card.spec.js +32 -0
  43. package/dist/collection/components/pci-calculator/test/pci-calculator.e2e.js +24 -0
  44. package/dist/collection/components/pci-calculator/test/pci-calculator.spec.js +32 -0
  45. package/dist/collection/components/pdf-download/test/pdf-download.e2e.js +71 -0
  46. package/dist/collection/components/pdf-download/test/pdf-download.spec.js +104 -0
  47. package/dist/collection/components/public-notification/test/public-notification.e2e.js +95 -0
  48. package/dist/collection/components/public-notification/test/public-notification.spec.js +149 -0
  49. package/dist/collection/components/refine-selection/refine-selection.css +85 -85
  50. package/dist/collection/components/solution-configuration/test/solution-configuration.e2e.js +31 -0
  51. package/dist/collection/components/solution-configuration/test/solution-configuration.spec.js +114 -0
  52. package/dist/collection/components/solution-contents/test/solution-contents.e2e.js +89 -0
  53. package/dist/collection/components/solution-contents/test/solution-contents.spec.js +138 -0
  54. package/dist/collection/components/solution-item/test/solution-item.e2e.js +31 -0
  55. package/dist/collection/components/solution-item/test/solution-item.spec.js +72 -0
  56. package/dist/collection/components/solution-item-details/test/solution-item-details.e2e.js +31 -0
  57. package/dist/collection/components/solution-item-details/test/solution-item-details.spec.js +137 -0
  58. package/dist/collection/components/solution-item-icon/test/solution-item-icon.e2e.js +24 -0
  59. package/dist/collection/components/solution-item-icon/test/solution-item-icon.spec.js +34 -0
  60. package/dist/collection/components/solution-item-sharing/test/solution-item-sharing.e2e.js +31 -0
  61. package/dist/collection/components/solution-item-sharing/test/solution-item-sharing.spec.js +49 -0
  62. package/dist/collection/components/solution-organization-variables/test/solution-organization-variables.e2e.js +31 -0
  63. package/dist/collection/components/solution-organization-variables/test/solution-organization-variables.spec.js +60 -0
  64. package/dist/collection/components/solution-resource-item/test/solution-resource-item.e2e.js +31 -0
  65. package/dist/collection/components/solution-resource-item/test/solution-resource-item.spec.js +50 -0
  66. package/dist/collection/components/solution-spatial-ref/test/solution-spatial-ref.e2e.js +31 -0
  67. package/dist/collection/components/solution-spatial-ref/test/solution-spatial-ref.spec.js +170 -0
  68. package/dist/collection/components/solution-template-data/test/solution-template-data.e2e.js +31 -0
  69. package/dist/collection/components/solution-template-data/test/solution-template-data.spec.js +55 -0
  70. package/dist/collection/components/solution-variables/test/solution-variables.e2e.js +31 -0
  71. package/dist/collection/components/solution-variables/test/solution-variables.spec.js +126 -0
  72. package/dist/collection/utils/publicNotificationUtils.js +45 -0
  73. package/dist/collection/utils/templates.e2e.js +25 -0
  74. package/dist/collection/utils/test/csvUtils.spec.js +46 -0
  75. package/dist/collection/utils/test/downloadUtils.spec.js +102 -0
  76. package/dist/collection/utils/test/pciUtils.spec.js +297 -0
  77. package/dist/collection/utils/test/solution-store.spec.js +439 -0
  78. package/dist/components/map-select-tools2.js +36 -36
  79. package/dist/components/solution-store.js +3 -3
  80. package/dist/esm/calcite-input-text_5.entry.js +36 -36
  81. package/dist/esm/calcite-shell-panel_14.entry.js +1 -1
  82. package/dist/esm/solution-configuration.entry.js +1 -1
  83. package/dist/esm/solution-contents_3.entry.js +1 -1
  84. package/dist/esm/{solution-store-5d068b07.js → solution-store-70f874f8.js} +3 -3
  85. package/dist/solutions-components/{p-41802f6b.entry.js → p-16dfb254.entry.js} +1 -1
  86. package/dist/solutions-components/{p-4769a2a5.entry.js → p-5ed755a2.entry.js} +1 -1
  87. package/dist/solutions-components/{p-826a814d.js → p-78719506.js} +2 -2
  88. package/dist/solutions-components/{p-9f620303.entry.js → p-b4b19fd3.entry.js} +1 -1
  89. package/dist/solutions-components/{p-24fe6e1c.entry.js → p-d5d5942d.entry.js} +1 -1
  90. package/dist/solutions-components/solutions-components.esm.js +1 -1
  91. package/dist/solutions-components/utils/common.js +291 -0
  92. package/dist/solutions-components/utils/csvDownload.js +36 -0
  93. package/dist/solutions-components/utils/csvUtils.js +32 -0
  94. package/dist/solutions-components/utils/downloadUtils.js +386 -0
  95. package/dist/solutions-components/utils/interfaces.js +56 -0
  96. package/dist/solutions-components/utils/languageUtil.js +85 -0
  97. package/dist/solutions-components/utils/loadModules.js +20 -0
  98. package/dist/solutions-components/utils/locale.js +56 -0
  99. package/dist/solutions-components/utils/mapViewUtils.js +140 -0
  100. package/dist/solutions-components/utils/pciUtils.js +837 -0
  101. package/dist/solutions-components/utils/pdfUtils.js +62 -0
  102. package/dist/solutions-components/utils/publicNotificationStore.js +38 -0
  103. package/dist/solutions-components/utils/publicNotificationUtils.js +45 -0
  104. package/dist/solutions-components/utils/queryUtils.js +148 -0
  105. package/dist/solutions-components/utils/solution-store.js +579 -0
  106. package/dist/solutions-components/utils/templates.e2e.js +25 -0
  107. package/dist/solutions-components/utils/templates.js +341 -0
  108. package/dist/solutions-components/utils/test/csvUtils.spec.js +46 -0
  109. package/dist/solutions-components/utils/test/downloadUtils.spec.js +102 -0
  110. package/dist/solutions-components/utils/test/mocks/jsApi.js +74 -0
  111. package/dist/solutions-components/utils/test/pciUtils.spec.js +297 -0
  112. package/dist/solutions-components/utils/test/solution-store.spec.js +439 -0
  113. package/dist/solutions-components/utils/test/testUtils.js +135 -0
  114. package/dist/solutions-components/utils/types.js +14 -0
  115. package/dist/solutions-components_commit.txt +7 -0
  116. package/package.json +7 -7
@@ -0,0 +1,62 @@
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
+ //#region Declarations
17
+ import * as PDFCreator_jsPDF from "../assets/arcgis-pdf-creator/PDFCreator_jsPDF";
18
+ import * as PDFLabels from "../assets/arcgis-pdf-creator/PDFLabels";
19
+ import { getAssetPath } from "@stencil/core";
20
+ export { ILabel } from "../assets/arcgis-pdf-creator/PDFLabels";
21
+ //#endregion
22
+ //#region Public functions
23
+ /**
24
+ * Exports a PDF of labels.
25
+ *
26
+ * @param filename Name to use for file
27
+ * @param labels Labels to write
28
+ * @param labelPageDescription Page format to use for labels
29
+ * @param includeMap When true, the first page of the output is a map showing the selection area
30
+ * @param includeTitle When true, a title is included on every page
31
+ * @param title Title for each page when `includeTitle` is true
32
+ */
33
+ export function exportPDF(filename, labels, labelPageDescription, includeMap = false, includeTitle = false, title = "") {
34
+ downloadPDFFile(filename, labels, labelPageDescription);
35
+ }
36
+ //#endregion
37
+ //#region Private functions
38
+ /**
39
+ * Downloads the PDF file.
40
+ *
41
+ * @param title Title (without file extension) to use for file; defaults to "export"
42
+ * @param labels Labels to write
43
+ * @param labelPageDescription Page format to use for labels
44
+ */
45
+ function downloadPDFFile(title, labels, labelPageDescription) {
46
+ const pdfLib = new PDFCreator_jsPDF.PDFCreator_jsPDF();
47
+ pdfLib.initialize({
48
+ pageType: "ANSI_A"
49
+ }, getAssetPath(`../assets/arcgis-pdf-creator/`), "en", title // filename without ".pdf"
50
+ )
51
+ .then(() => {
52
+ const labeller = new PDFLabels.PDFLabels();
53
+ labeller.initialize(pdfLib)
54
+ .then(async () => {
55
+ await labeller.addLabelsToDoc(labels, labelPageDescription.labelSpec, 1, // startingPageNum
56
+ title // heading
57
+ );
58
+ pdfLib.save();
59
+ });
60
+ });
61
+ }
62
+ //#endregion
@@ -0,0 +1,38 @@
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
+ import { createStore } from "@stencil/store";
17
+ const { state, onChange } = createStore({
18
+ // List of layers added and managed by the component
19
+ managedLayers: [],
20
+ // Handle[]: https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Handles.html#Handle
21
+ highlightHandles: [],
22
+ // ILayerHash title: id lookup to be used across components
23
+ layerNameHash: {},
24
+ // remove all handles
25
+ removeHandles: () => {
26
+ state.highlightHandles.forEach(h => h === null || h === void 0 ? void 0 : h.remove());
27
+ state.highlightHandles = [];
28
+ }
29
+ });
30
+ const managedLayersChangedEvent = new CustomEvent("managedLayersChanged", {
31
+ bubbles: true,
32
+ cancelable: false,
33
+ composed: true
34
+ });
35
+ onChange("managedLayers", () => {
36
+ dispatchEvent(managedLayersChangedEvent);
37
+ });
38
+ export default state;
@@ -0,0 +1,45 @@
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
+ export function getSelectionIds(selectionSets) {
17
+ return Object.keys(selectionSets).reduce((prev, cur) => {
18
+ return [
19
+ ...prev,
20
+ ...selectionSets[cur].download ? selectionSets[cur].selectedIds : []
21
+ ];
22
+ }, []);
23
+ }
24
+ export function getSelectionIdsAndViews(selectionSets) {
25
+ return selectionSets.reduce((prev, cur) => {
26
+ if (Object.keys(prev).indexOf(cur.layerView.layer.id) > -1) {
27
+ prev[cur.layerView.layer.id].ids = [
28
+ ...prev[cur.layerView.layer.id].ids,
29
+ ...cur.selectedIds
30
+ ];
31
+ prev[cur.layerView.layer.id].selectionSetNames.push(cur.label);
32
+ }
33
+ else {
34
+ prev[cur.layerView.layer.id] = {
35
+ ids: cur.selectedIds,
36
+ layerView: cur.layerView,
37
+ selectionSetNames: [cur.label]
38
+ };
39
+ }
40
+ return prev;
41
+ }, {});
42
+ }
43
+ export function getTotal(selectionSets) {
44
+ return [...new Set(getSelectionIds(selectionSets))].length;
45
+ }
@@ -0,0 +1,148 @@
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
+ /**
17
+ * Query the layer for all features
18
+ *
19
+ * @param start zero-based index indicating where to begin retrieving features
20
+ * @param layer the layer to retrieve features from
21
+ * @param graphics stores the features
22
+ *
23
+ * @returns Promise with the featureSet from the layer that match the provided ids
24
+ */
25
+ export async function queryAllFeatures(start, layer, graphics) {
26
+ const num = layer.capabilities.query.maxRecordCount;
27
+ const query = layer.createQuery();
28
+ query.start = start;
29
+ query.num = num;
30
+ // TODO think through this once I'm back on crowdsource...seems like we may want an arg to control this
31
+ query.where = layer.definitionExpression || "1=1";
32
+ const result = await layer.queryFeatures(query);
33
+ graphics = graphics.concat(result.features);
34
+ return result.exceededTransferLimit ?
35
+ queryAllFeatures(start += num, layer, graphics) :
36
+ Promise.resolve(graphics);
37
+ }
38
+ /**
39
+ * Query the layer for OIDs based on any user drawn geometries or buffers
40
+ *
41
+ * @param geometries Array of geometries used for the selection of ids from the layer
42
+ * @param layer the layer to retrieve ids from
43
+ *
44
+ * @returns Promise with the OIDs of features from the layer that interset the provided geometries
45
+ */
46
+ export async function queryObjectIds(geometries, layer) {
47
+ let ids = [];
48
+ const queryDefs = geometries ? geometries.map(g => _intersectQuery(g, layer)) : [Promise.resolve()];
49
+ const results = await Promise.all(queryDefs);
50
+ results.forEach(resultIds => {
51
+ ids = [
52
+ ...ids,
53
+ ...resultIds || []
54
+ ];
55
+ });
56
+ return ids;
57
+ }
58
+ /**
59
+ * Query the layer for features that have the provided OIDs
60
+ *
61
+ * @param ids array of ObjectIDs to be used to query for features in a layer
62
+ * @param layer the layer to retrieve features from
63
+ *
64
+ * @returns Promise with the featureSet from the layer that match the provided ids
65
+ */
66
+ export async function queryFeaturesByID(ids, layer) {
67
+ const q = layer.createQuery();
68
+ q.objectIds = ids;
69
+ return layer.queryFeatures(q);
70
+ }
71
+ /**
72
+ * Query the layer for features that intersect the provided geometry
73
+ *
74
+ * @param start zero-based index indicating where to begin retrieving features
75
+ * @param layer the layer to retrieve features from
76
+ * @param geometry the geometry to apply to the spatial filter
77
+ * @param featuresCollection
78
+ *
79
+ * @returns Promise with the featureSet from the layer that match the provided ids
80
+ */
81
+ export async function queryFeaturesByGeometry(start, layer, geometry, featuresCollection) {
82
+ const num = layer.capabilities.query.maxRecordCount;
83
+ const query = layer.createQuery();
84
+ query.start = start;
85
+ query.num = num;
86
+ query.geometry = geometry;
87
+ const result = await layer.queryFeatures(query);
88
+ featuresCollection[layer.id] = featuresCollection[layer.id].concat(result.features);
89
+ return result.exceededTransferLimit ?
90
+ queryFeaturesByGeometry(start += num, layer, geometry, featuresCollection) :
91
+ Promise.resolve(featuresCollection);
92
+ }
93
+ /**
94
+ * Query the layer for the extent of features with the provided OIDs
95
+ *
96
+ * @param ids array of ObjectIDs to be used to query for features in a layer
97
+ * @param layer the layer to query
98
+ *
99
+ * @returns Promise with the Extent of all features that match the provided ids
100
+ */
101
+ export async function queryExtent(ids, layer) {
102
+ const query = layer.createQuery();
103
+ query.objectIds = ids;
104
+ return layer.queryExtent(query);
105
+ }
106
+ /**
107
+ * Union geometries based on geometry type
108
+ *
109
+ * @param geometries Array of geometries to union
110
+ * @param geometryEngine the geometry engine instance to perform the unions
111
+ *
112
+ * @returns Array of single unioned geometry for each geometry type
113
+ */
114
+ export function getQueryGeoms(geometries, geometryEngine) {
115
+ // sort and union by geom type so we have a single geom for each type to query with
116
+ return [
117
+ ..._unionGeoms(geometries, "polygon", geometryEngine),
118
+ ..._unionGeoms(geometries, "polyline", geometryEngine),
119
+ ..._unionGeoms(geometries, "point", geometryEngine)
120
+ ];
121
+ }
122
+ /**
123
+ * Union geometries based on geometry type
124
+ *
125
+ * @param geometries array of geometries to union
126
+ * @param type the current geometry type to union
127
+ * @param geometryEngine the geometry engine instance to perform the unions
128
+ *
129
+ * @returns Array of single unioned geometry for the provided geometry type
130
+ */
131
+ function _unionGeoms(geometries, type, geometryEngine) {
132
+ const geoms = (geometries === null || geometries === void 0 ? void 0 : geometries.filter(g => g.type === type)) || [];
133
+ return geoms.length <= 1 ? geoms : [geometryEngine.union(geoms)];
134
+ }
135
+ /**
136
+ * Query the layer for ObjectIds of features that intersect the provided geometry
137
+ *
138
+ * @param geometry Geometry used for the selection of ids from the select layer view
139
+ * @param layer the layer to query
140
+ *
141
+ * @returns Promise that will contain the selected ids
142
+ */
143
+ async function _intersectQuery(geometry, layer) {
144
+ const q = layer.createQuery();
145
+ q.spatialRelationship = "intersects";
146
+ q.geometry = geometry;
147
+ return layer.queryObjectIds(q);
148
+ }