@esri/solutions-components 0.3.9 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. package/dist/assets/t9n/public-notification/resources.json +0 -2
  2. package/dist/assets/t9n/public-notification/resources_en.json +0 -2
  3. package/dist/cjs/buffer-tools_6.cjs.entry.js +5 -2
  4. package/dist/cjs/calcite-input-message_5.cjs.entry.js +1342 -18
  5. package/dist/cjs/{calcite-input-message.calcite-notice.map-select-tools.pdf-download.refine-selection-cd8ad61e.js → downloadUtils-27dbd8b9.js} +205 -1337
  6. package/dist/cjs/{index.es-e89ba2a1.js → index.es-40d341ed.js} +3 -13
  7. package/dist/cjs/layer-table.cjs.entry.js +5 -15
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/public-notification.cjs.entry.js +23 -2
  10. package/dist/cjs/solutions-components.cjs.js +1 -1
  11. package/dist/collection/components/layer-table/layer-table.js +4 -16
  12. package/dist/collection/components/map-search/map-search.js +1 -1
  13. package/dist/collection/components/map-select-tools/map-select-tools.js +73 -17
  14. package/dist/collection/components/pdf-download/pdf-download.js +9 -76
  15. package/dist/collection/components/public-notification/public-notification.js +45 -3
  16. package/dist/collection/components/refine-selection/refine-selection.js +1 -1
  17. package/dist/collection/components/refine-selection-tools/refine-selection-tools.js +13 -5
  18. package/dist/collection/demos/buffer-tools.html +1 -1
  19. package/dist/collection/utils/csvUtils.js +4 -0
  20. package/dist/collection/utils/csvUtils.ts +7 -0
  21. package/dist/collection/utils/downloadUtils.js +181 -0
  22. package/dist/collection/utils/downloadUtils.ts +235 -0
  23. package/dist/collection/utils/interfaces.ts +8 -1
  24. package/dist/collection/utils/pdfUtils.js +7 -0
  25. package/dist/collection/utils/pdfUtils.ts +13 -2
  26. package/dist/components/downloadUtils.js +2279 -0
  27. package/dist/components/index.es.js +1 -1
  28. package/dist/components/layer-table.js +5 -16
  29. package/dist/components/map-layer-picker2.js +1 -1
  30. package/dist/components/map-search.js +1 -1
  31. package/dist/components/map-select-tools2.js +69 -19
  32. package/dist/components/pdf-download2.js +10 -2124
  33. package/dist/components/public-notification.js +24 -3
  34. package/dist/components/queryUtils.js +1 -1
  35. package/dist/components/refine-selection-tools2.js +6 -3
  36. package/dist/components/refine-selection2.js +1 -1
  37. package/dist/esm/buffer-tools_6.entry.js +6 -3
  38. package/dist/esm/calcite-combobox_3.entry.js +1 -1
  39. package/dist/esm/calcite-input-message_5.entry.js +1341 -13
  40. package/dist/esm/{calcite-input-message.calcite-notice.map-select-tools.pdf-download.refine-selection-ddd74bd6.js → downloadUtils-76e38a94.js} +206 -1335
  41. package/dist/esm/{index.es-8edafdb2.js → index.es-489f4f08.js} +2 -12
  42. package/dist/esm/layer-table.entry.js +6 -16
  43. package/dist/esm/loader.js +1 -1
  44. package/dist/esm/{mapViewUtils-63e118f8.js → mapViewUtils-02696ab6.js} +1 -1
  45. package/dist/esm/public-notification.entry.js +24 -3
  46. package/dist/esm/solutions-components.js +1 -1
  47. package/dist/solutions-components/demos/buffer-tools.html +1 -1
  48. package/dist/solutions-components/{p-cc2e20c8.js → p-1bfd07e3.js} +1 -1
  49. package/dist/solutions-components/{p-117174e8.entry.js → p-335fce8c.entry.js} +1 -1
  50. package/dist/solutions-components/p-4ef94c6b.entry.js +6 -0
  51. package/dist/solutions-components/p-5d27b47d.entry.js +17 -0
  52. package/dist/solutions-components/p-92cb569a.entry.js +6 -0
  53. package/dist/solutions-components/{p-2a96314a.entry.js → p-a3b60bc9.entry.js} +2 -2
  54. package/dist/solutions-components/{p-98884f44.js → p-bff8aa4e.js} +3 -3
  55. package/dist/solutions-components/p-caa7e7a7.js +437 -0
  56. package/dist/solutions-components/solutions-components.esm.js +1 -1
  57. package/dist/solutions-components/utils/csvUtils.ts +7 -0
  58. package/dist/solutions-components/utils/downloadUtils.ts +235 -0
  59. package/dist/solutions-components/utils/interfaces.ts +8 -1
  60. package/dist/solutions-components/utils/pdfUtils.ts +13 -2
  61. package/dist/types/components/json-editor/assets/monaco-editor/monaco.d.ts +8262 -0
  62. package/dist/types/components/map-select-tools/map-select-tools.d.ts +19 -1
  63. package/dist/types/components/pdf-download/pdf-download.d.ts +0 -18
  64. package/dist/types/components/public-notification/public-notification.d.ts +10 -0
  65. package/dist/types/components/refine-selection-tools/refine-selection-tools.d.ts +2 -2
  66. package/dist/types/components.d.ts +6 -2
  67. package/dist/types/preact.d.ts +2 -1
  68. package/dist/types/utils/downloadUtils.d.ts +40 -0
  69. package/dist/types/utils/interfaces.d.ts +6 -2
  70. package/dist/types/utils/pdfUtils.d.ts +3 -1
  71. package/package.json +1 -1
  72. package/dist/cjs/csvUtils-3a56c6d8.js +0 -54
  73. package/dist/components/csvUtils.js +0 -52
  74. package/dist/esm/csvUtils-23b5418f.js +0 -52
  75. package/dist/solutions-components/p-15f9b0a0.entry.js +0 -6
  76. package/dist/solutions-components/p-238db156.js +0 -416
  77. package/dist/solutions-components/p-3069e3b7.js +0 -21
  78. package/dist/solutions-components/p-6d28f991.entry.js +0 -6
  79. package/dist/solutions-components/p-c5341977.entry.js +0 -6
@@ -0,0 +1,235 @@
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
+ //#region Declarations
18
+
19
+ import { exportCSV } from "./csvUtils";
20
+ import { ILabel, exportPDF } from "./pdfUtils";
21
+ import { loadModules } from "./loadModules";
22
+ import { queryFeaturesByID } from "./queryUtils";
23
+
24
+ export { ILabel } from "./pdfUtils";
25
+
26
+ //#endregion
27
+ //#region Public functions
28
+
29
+ /**
30
+ * Downloads csv of mailing labels for the provided list of ids
31
+ *
32
+ * @param layer Layer providing features and attributes for download
33
+ * @param ids List of ids to download
34
+ * @param formatUsingLayerPopup When true, the layer's popup is used to choose attributes for each column; when false,
35
+ * all attributes are exported
36
+ * @param removeDuplicates When true a single label is generated when multiple featues have a shared address value
37
+ * @param addColumnTitle Indicates if column headings should be included in output
38
+ * @returns Promise resolving when function is done
39
+ */
40
+ export async function downloadCSV(
41
+ layer: __esri.FeatureLayer,
42
+ ids: number[],
43
+ formatUsingLayerPopup: boolean,
44
+ removeDuplicates = false,
45
+ addColumnTitle = false
46
+ ): Promise<void> {
47
+ const labels = await _prepareLabels(layer, ids, removeDuplicates, formatUsingLayerPopup, addColumnTitle);
48
+
49
+ exportCSV(labels);
50
+
51
+ return Promise.resolve();
52
+ }
53
+
54
+ /**
55
+ * Downloads csv of mailing labels for the provided list of ids
56
+ *
57
+ * @param layer Layer providing features and attributes for download
58
+ * @param ids List of ids to download
59
+ * @param removeDuplicates When true a single label is generated when multiple featues have a shared address value
60
+ * @param labelPageDescription Provides PDF page layout info
61
+ * @returns Promise resolving when function is done
62
+ */
63
+ export async function downloadPDF(
64
+ layer: __esri.FeatureLayer,
65
+ ids: number[],
66
+ removeDuplicates: boolean,
67
+ labelPageDescription: ILabel
68
+ ): Promise<void> {
69
+ const labels = await _prepareLabels(layer, ids, removeDuplicates);
70
+
71
+ exportPDF(labels, labelPageDescription);
72
+
73
+ return Promise.resolve();
74
+ }
75
+
76
+ //#endregion
77
+ //#region Private functions
78
+
79
+ /**
80
+ * Converts a set of fieldInfos into template lines.
81
+ *
82
+ * @param fieldInfos Layer's fieldInfos structure
83
+ * @return Label spec
84
+ */
85
+ function _convertPopupFieldsToLabelSpec(
86
+ fieldInfos: __esri.FieldInfo[]
87
+ ): string[] {
88
+ const labelSpec: string[] = [];
89
+
90
+ // Every visible attribute is used
91
+ fieldInfos.forEach(
92
+ fieldInfo => {
93
+ if (fieldInfo.visible) {
94
+ labelSpec.push(`{${fieldInfo.fieldName}}`);
95
+ }
96
+ }
97
+ );
98
+
99
+ return labelSpec;
100
+ };
101
+
102
+ /**
103
+ * Converts the text of a custom popup into a multiline label specification; conversion splits text into
104
+ * lines on <br>s, and removes HTML tags. It does not handle Arcade and related records.
105
+ *
106
+ * @param popupInfo Layer's popupInfo structure containing description, fieldInfos, and expressionInfos, e.g.,
107
+ * "<div style='text-align: left;'>{NAME}<br />{STREET}<br />{CITY}, {STATE} {ZIP} <br /></div>"
108
+ * @return Label spec
109
+ */
110
+ function _convertPopupTextToLabelSpec(
111
+ popupInfo: string
112
+ ): string[] {
113
+ // Replace <br>, <br/> with |
114
+ popupInfo = popupInfo.replace(/<br\s*\/?>/gi, "|");
115
+
116
+ // Remove remaining HTML tags, replace 0xA0 that popup uses for spaces, replace some char representations,
117
+ // and split the label back into individual lines
118
+ let labelSpec = popupInfo
119
+ .replace(/<[\s.]*[^<>]*\/?>/gi, "")
120
+ .replace(/\xA0/gi, " ")
121
+ .replace(/&lt;/gi, "<")
122
+ .replace(/&gt;/gi, ">")
123
+ .replace(/&nbsp;/gi, " ")
124
+ .split("|");
125
+
126
+ // Trim lines and remove empties
127
+ labelSpec = labelSpec.map(line => line.trim()).filter(line => line.length > 0);
128
+
129
+ return labelSpec;
130
+ };
131
+
132
+ /**
133
+ * Creates labels from items.
134
+ *
135
+ * @param layer Layer from which to fetch features
136
+ * @param ids List of ids to download
137
+ * @param removeDuplicates When true a single label is generated when multiple featues have a shared address value
138
+ * @param formatUsingLayerPopup When true, the layer's popup is used to choose attributes for each column; when false,
139
+ * all attributes are exported
140
+ * @param includeHeaderNames Add the label format at the front of the list of generated labels
141
+ * @returns Promise resolving when function is done
142
+ */
143
+ async function _prepareLabels(
144
+ layer: __esri.FeatureLayer,
145
+ ids: number[],
146
+ removeDuplicates = true,
147
+ formatUsingLayerPopup = true,
148
+ includeHeaderNames = false
149
+ ): Promise<string[][]> {
150
+ const [intl] = await loadModules([
151
+ "esri/intl"
152
+ ]);
153
+
154
+ // Get the attributes of the features to export
155
+ const featureSet = await queryFeaturesByID(ids, layer);
156
+ const featuresAttrs = featureSet.features.map(f => f.attributes);
157
+
158
+ // Get the label formatting, if any
159
+ let labelFormat: string[];
160
+ if (layer.popupEnabled) {
161
+ // What data fields are used in the labels?
162
+ // Example labelFormat: ['{NAME}', '{STREET}', '{CITY}, {STATE} {ZIP}']
163
+ if (formatUsingLayerPopup && layer.popupTemplate?.content[0]?.type === "fields") {
164
+ labelFormat = _convertPopupFieldsToLabelSpec(layer.popupTemplate.fieldInfos);
165
+
166
+ } else if (formatUsingLayerPopup && layer.popupTemplate?.content[0]?.type === "text") {
167
+ labelFormat = _convertPopupTextToLabelSpec(layer.popupTemplate.content[0].text);
168
+
169
+ }
170
+ }
171
+
172
+ // Apply the label format
173
+ let labels: string[][];
174
+ // eslint-disable-next-line unicorn/prefer-ternary
175
+ if (labelFormat) {
176
+ // Convert attributes into an array of labels
177
+ labels = featuresAttrs.map(
178
+ featureAttributes => {
179
+ const label: string[] = [];
180
+ labelFormat.forEach(
181
+ labelLineTemplate => {
182
+ const labelLine = intl.substitute(labelLineTemplate, featureAttributes).trim();
183
+ if (labelLine.length > 0) {
184
+ label.push(labelLine);
185
+ }
186
+ }
187
+ )
188
+ return label;
189
+ }
190
+ )
191
+ // Remove empty labels
192
+ .filter(label => label.length > 0);
193
+
194
+ } else {
195
+ // Export all attributes
196
+ labels = featuresAttrs.map(
197
+ featureAttributes => {
198
+ return Object.values(featureAttributes).map(
199
+ attribute => `${attribute}`
200
+ );
201
+ }
202
+ );
203
+ }
204
+
205
+ // Remove duplicates
206
+ if (removeDuplicates) {
207
+ const labelsAsStrings: string[] = labels.map(label => JSON.stringify(label));
208
+ const uniqueLabels = new Set(labelsAsStrings);
209
+ labels = Array.from(uniqueLabels,
210
+ labelString => JSON.parse(labelString)
211
+ );
212
+ }
213
+
214
+ // Add header names
215
+ if (includeHeaderNames) {
216
+ let headerNames = [];
217
+
218
+ if (labelFormat) {
219
+ headerNames = labelFormat.map(labelFormatLine => labelFormatLine.replace(/\{/g, "").replace(/\}/g, ""));
220
+
221
+ } else {
222
+ Object.keys(featuresAttrs[0]).forEach(k => {
223
+ if (featuresAttrs[0].hasOwnProperty(k)) {
224
+ headerNames.push(k);
225
+ }
226
+ });
227
+ }
228
+
229
+ labels.unshift(headerNames);
230
+ }
231
+
232
+ return Promise.resolve(labels);
233
+ }
234
+
235
+ //#endregion
@@ -108,7 +108,7 @@ export interface ISearchConfiguration {
108
108
  sources: Array<ILocatorSourceConfigItem | ILayerSourceConfigItem>;
109
109
  }
110
110
 
111
- interface ISearchSourceConfigItem {
111
+ export interface ISearchSourceConfigItem {
112
112
  maxResults: number;
113
113
  maxSuggestions: number;
114
114
  minSuggestCharacters: number;
@@ -387,6 +387,13 @@ export interface ISelectionSet {
387
387
  refineIds: IRefineIds;
388
388
  redoStack?: IRefineOperation[];
389
389
  undoStack?: IRefineOperation[];
390
+ //skipGeomQuery?: boolean;
391
+ skipGeomOIDs?: number[];
392
+ }
393
+
394
+ export interface IRefineSelectionEvent {
395
+ graphics: __esri.Graphic[];
396
+ useOIDs: boolean;
390
397
  }
391
398
 
392
399
  export interface IRefineIds {
@@ -18,9 +18,13 @@
18
18
  * See the License for the specific language governing permissions and
19
19
  * limitations under the License.
20
20
  */
21
+ //#region Declarations
21
22
  import * as PDFCreator_jsPDF from "../assets/arcgis-pdf-creator/PDFCreator_jsPDF";
22
23
  import * as PDFLabels from "../assets/arcgis-pdf-creator/PDFLabels";
23
24
  import { getAssetPath } from "@stencil/core";
25
+ export { ILabel } from "../assets/arcgis-pdf-creator/PDFLabels";
26
+ //#endregion
27
+ //#region Public functions
24
28
  /**
25
29
  * Exports a PDF of labels.
26
30
  *
@@ -30,6 +34,8 @@ import { getAssetPath } from "@stencil/core";
30
34
  export function exportPDF(labels, labelPageDescription) {
31
35
  _downloadPDFFile(labels, labelPageDescription, `notify-${Date.now().toString()}`);
32
36
  }
37
+ //#endregion
38
+ //#region Private functions
33
39
  /**
34
40
  * Downloads the PDF file.
35
41
  *
@@ -51,3 +57,4 @@ function _downloadPDFFile(labels, labelPageDescription, fileTitle) {
51
57
  });
52
58
  });
53
59
  }
60
+ //#endregion
@@ -14,9 +14,15 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ //#region Declarations
18
+
17
19
  import * as PDFCreator_jsPDF from "../assets/arcgis-pdf-creator/PDFCreator_jsPDF";
18
20
  import * as PDFLabels from "../assets/arcgis-pdf-creator/PDFLabels";
19
21
  import { getAssetPath } from "@stencil/core";
22
+ export { ILabel } from "../assets/arcgis-pdf-creator/PDFLabels";
23
+
24
+ //#endregion
25
+ //#region Public functions
20
26
 
21
27
  /**
22
28
  * Exports a PDF of labels.
@@ -26,11 +32,14 @@ import { getAssetPath } from "@stencil/core";
26
32
  */
27
33
  export function exportPDF(
28
34
  labels: string[][],
29
- labelPageDescription: any
35
+ labelPageDescription: PDFLabels.ILabel
30
36
  ): void {
31
37
  _downloadPDFFile(labels, labelPageDescription, `notify-${Date.now().toString()}`);
32
38
  }
33
39
 
40
+ //#endregion
41
+ //#region Private functions
42
+
34
43
  /**
35
44
  * Downloads the PDF file.
36
45
  *
@@ -40,7 +49,7 @@ export function exportPDF(
40
49
  */
41
50
  function _downloadPDFFile(
42
51
  labels: string[][],
43
- labelPageDescription: any,
52
+ labelPageDescription: PDFLabels.ILabel,
44
53
  fileTitle: string
45
54
  ): void {
46
55
  const pdfLib = new PDFCreator_jsPDF.PDFCreator_jsPDF();
@@ -69,3 +78,5 @@ function _downloadPDFFile(
69
78
  );
70
79
 
71
80
  }
81
+
82
+ //#endregion