@esri/solutions-components 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/assets/t9n/map-select-tools/resources.json +1 -1
  2. package/dist/assets/t9n/map-select-tools/resources_en.json +1 -1
  3. package/dist/assets/t9n/public-notification/resources.json +5 -3
  4. package/dist/assets/t9n/public-notification/resources_en.json +5 -3
  5. package/dist/assets/t9n/refine-selection/resources.json +3 -3
  6. package/dist/assets/t9n/refine-selection/resources_en.json +3 -3
  7. package/dist/cjs/calcite-input-message_5.cjs.entry.js +8 -6
  8. package/dist/cjs/{downloadUtils-27dbd8b9.js → downloadUtils-99981c6b.js} +88 -15
  9. package/dist/cjs/{index.es-40d341ed.js → index.es-53f3bc97.js} +1 -1
  10. package/dist/cjs/layer-table.cjs.entry.js +2 -2
  11. package/dist/cjs/public-notification.cjs.entry.js +24 -9
  12. package/dist/collection/components/layer-table/layer-table.js +1 -1
  13. package/dist/collection/components/map-select-tools/map-select-tools.js +1 -1
  14. package/dist/collection/components/pdf-download/pdf-download.js +26 -6
  15. package/dist/collection/components/public-notification/public-notification.js +24 -9
  16. package/dist/collection/utils/downloadUtils.js +87 -14
  17. package/dist/collection/utils/downloadUtils.ts +123 -14
  18. package/dist/components/downloadUtils.js +87 -14
  19. package/dist/components/layer-table.js +1 -1
  20. package/dist/components/map-select-tools2.js +1 -1
  21. package/dist/components/pdf-download2.js +6 -4
  22. package/dist/components/public-notification.js +24 -9
  23. package/dist/esm/calcite-input-message_5.entry.js +8 -6
  24. package/dist/esm/{downloadUtils-76e38a94.js → downloadUtils-4bb47330.js} +88 -15
  25. package/dist/esm/{index.es-489f4f08.js → index.es-4424d2f7.js} +1 -1
  26. package/dist/esm/layer-table.entry.js +2 -2
  27. package/dist/esm/public-notification.entry.js +24 -9
  28. package/dist/solutions-components/{p-caa7e7a7.js → p-0aed9b0d.js} +11 -11
  29. package/dist/solutions-components/{p-5d27b47d.entry.js → p-0d3b0fa0.entry.js} +2 -2
  30. package/dist/solutions-components/{p-bff8aa4e.js → p-50117f71.js} +1 -1
  31. package/dist/solutions-components/p-5e4dfbe4.entry.js +6 -0
  32. package/dist/solutions-components/{p-92cb569a.entry.js → p-ec7f7804.entry.js} +1 -1
  33. package/dist/solutions-components/solutions-components.esm.js +1 -1
  34. package/dist/solutions-components/utils/downloadUtils.ts +123 -14
  35. package/dist/types/components/map-select-tools/map-select-tools.d.ts +1 -1
  36. package/dist/types/components/pdf-download/pdf-download.d.ts +4 -2
  37. package/dist/types/components/public-notification/public-notification.d.ts +9 -1
  38. package/dist/types/components.d.ts +4 -2
  39. package/dist/types/utils/downloadUtils.d.ts +4 -2
  40. package/package.json +1 -1
  41. package/dist/solutions-components/p-4ef94c6b.entry.js +0 -6
@@ -2127,6 +2127,7 @@ function _downloadPDFFile(labels, labelPageDescription, fileTitle) {
2127
2127
  /**
2128
2128
  * Downloads csv of mailing labels for the provided list of ids
2129
2129
  *
2130
+ * @param selectionSetNames Names of the selection sets used to provide ids
2130
2131
  * @param layer Layer providing features and attributes for download
2131
2132
  * @param ids List of ids to download
2132
2133
  * @param formatUsingLayerPopup When true, the layer's popup is used to choose attributes for each column; when false,
@@ -2135,7 +2136,8 @@ function _downloadPDFFile(labels, labelPageDescription, fileTitle) {
2135
2136
  * @param addColumnTitle Indicates if column headings should be included in output
2136
2137
  * @returns Promise resolving when function is done
2137
2138
  */
2138
- async function downloadCSV(layer, ids, formatUsingLayerPopup, removeDuplicates = false, addColumnTitle = false) {
2139
+ async function downloadCSV(selectionSetNames, layer, ids, formatUsingLayerPopup, removeDuplicates = false, addColumnTitle = false) {
2140
+ console.log("downloadCSV using selectionSetNames " + JSON.stringify(selectionSetNames)); //???
2139
2141
  const labels = await _prepareLabels(layer, ids, removeDuplicates, formatUsingLayerPopup, addColumnTitle);
2140
2142
  exportCSV(labels);
2141
2143
  return Promise.resolve();
@@ -2143,13 +2145,15 @@ async function downloadCSV(layer, ids, formatUsingLayerPopup, removeDuplicates =
2143
2145
  /**
2144
2146
  * Downloads csv of mailing labels for the provided list of ids
2145
2147
  *
2148
+ * @param selectionSetNames Names of the selection sets used to provide ids
2146
2149
  * @param layer Layer providing features and attributes for download
2147
2150
  * @param ids List of ids to download
2148
2151
  * @param removeDuplicates When true a single label is generated when multiple featues have a shared address value
2149
2152
  * @param labelPageDescription Provides PDF page layout info
2150
2153
  * @returns Promise resolving when function is done
2151
2154
  */
2152
- async function downloadPDF(layer, ids, removeDuplicates, labelPageDescription) {
2155
+ async function downloadPDF(selectionSetNames, layer, ids, removeDuplicates, labelPageDescription) {
2156
+ console.log("downloadPDF using selectionSetNames " + JSON.stringify(selectionSetNames)); //???
2153
2157
  const labels = await _prepareLabels(layer, ids, removeDuplicates);
2154
2158
  exportPDF(labels, labelPageDescription);
2155
2159
  return Promise.resolve();
@@ -2160,13 +2164,14 @@ async function downloadPDF(layer, ids, removeDuplicates, labelPageDescription) {
2160
2164
  * Converts a set of fieldInfos into template lines.
2161
2165
  *
2162
2166
  * @param fieldInfos Layer's fieldInfos structure
2167
+ * @param bypassFieldVisiblity Indicates if the configured fieldInfo visibility property should be ignored
2163
2168
  * @return Label spec
2164
2169
  */
2165
- function _convertPopupFieldsToLabelSpec(fieldInfos) {
2170
+ function _convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity = false) {
2166
2171
  const labelSpec = [];
2167
2172
  // Every visible attribute is used
2168
2173
  fieldInfos.forEach(fieldInfo => {
2169
- if (fieldInfo.visible) {
2174
+ if (fieldInfo.visible || bypassFieldVisiblity) {
2170
2175
  labelSpec.push(`{${fieldInfo.fieldName}}`);
2171
2176
  }
2172
2177
  });
@@ -2196,6 +2201,49 @@ function _convertPopupTextToLabelSpec(popupInfo) {
2196
2201
  labelSpec = labelSpec.map(line => line.trim()).filter(line => line.length > 0);
2197
2202
  return labelSpec;
2198
2203
  }
2204
+ /**
2205
+ * Extracts Arcade expressions from the lines of a label format and creates an Arcade executor for each
2206
+ * referenced expression name.
2207
+ *
2208
+ * @param labelFormat Label to examine
2209
+ * @param layer Layer from which to fetch features
2210
+ * @return Promise resolving to a set of executors keyed using the expression name
2211
+ */
2212
+ async function _createArcadeExecutors(labelFormat, layer) {
2213
+ const arcadeExecutors = {};
2214
+ // Are any Arcade expressions in the layer?
2215
+ if (!Array.isArray(layer.popupTemplate.expressionInfos) || layer.popupTemplate.expressionInfos.length === 0) {
2216
+ return Promise.resolve(arcadeExecutors);
2217
+ }
2218
+ // Are there any Arcade expressions in the label format?
2219
+ const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
2220
+ const arcadeExpressionsMatches = labelFormat.join("|").match(arcadeExpressionRegExp);
2221
+ if (!arcadeExpressionsMatches) {
2222
+ return Promise.resolve(arcadeExecutors);
2223
+ }
2224
+ // Generate an Arcade executor for each match
2225
+ const [arcade] = await loadModules(["esri/arcade"]);
2226
+ const labelingProfile = arcade.createArcadeProfile("popup");
2227
+ const createArcadeExecutorPromises = {};
2228
+ arcadeExpressionsMatches.forEach((match) => {
2229
+ const expressionName = match.substring(match.indexOf("/") + 1, match.length - 1);
2230
+ (layer.popupTemplate.expressionInfos || []).forEach(expressionInfo => {
2231
+ if (expressionInfo.name === expressionName) {
2232
+ createArcadeExecutorPromises[expressionName] =
2233
+ arcade.createArcadeExecutor(expressionInfo.expression, labelingProfile);
2234
+ }
2235
+ });
2236
+ });
2237
+ const promises = Object.values(createArcadeExecutorPromises);
2238
+ return Promise.all(promises)
2239
+ .then(executors => {
2240
+ const expressionNames = Object.keys(createArcadeExecutorPromises);
2241
+ for (let i = 0; i < expressionNames.length; ++i) {
2242
+ arcadeExecutors[expressionNames[i]] = executors[i].valueOf();
2243
+ }
2244
+ return arcadeExecutors;
2245
+ });
2246
+ }
2199
2247
  /**
2200
2248
  * Creates labels from items.
2201
2249
  *
@@ -2209,33 +2257,57 @@ function _convertPopupTextToLabelSpec(popupInfo) {
2209
2257
  */
2210
2258
  async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLayerPopup = true, includeHeaderNames = false) {
2211
2259
  var _a, _b, _c, _d;
2212
- const [intl] = await loadModules([
2213
- "esri/intl"
2214
- ]);
2215
- // Get the attributes of the features to export
2260
+ const [intl] = await loadModules(["esri/intl"]);
2261
+ // Get the features to export
2216
2262
  const featureSet = await queryFeaturesByID(ids, layer);
2217
- const featuresAttrs = featureSet.features.map(f => f.attributes);
2218
2263
  // Get the label formatting, if any
2219
2264
  let labelFormat;
2265
+ let arcadeExecutors = {};
2220
2266
  if (layer.popupEnabled) {
2221
2267
  // What data fields are used in the labels?
2222
2268
  // Example labelFormat: ['{NAME}', '{STREET}', '{CITY}, {STATE} {ZIP}']
2223
2269
  if (formatUsingLayerPopup && ((_b = (_a = layer.popupTemplate) === null || _a === void 0 ? void 0 : _a.content[0]) === null || _b === void 0 ? void 0 : _b.type) === "fields") {
2224
2270
  labelFormat = _convertPopupFieldsToLabelSpec(layer.popupTemplate.fieldInfos);
2271
+ // If popup is configured with "no attribute information", then no fields will visible
2272
+ if (labelFormat.length === 0) {
2273
+ // Can we use the popup title?
2274
+ // eslint-disable-next-line unicorn/prefer-ternary
2275
+ if (typeof layer.popupTemplate.title === "string") {
2276
+ labelFormat = [layer.popupTemplate.title];
2277
+ // Otherwise revert to using attributes
2278
+ }
2279
+ else {
2280
+ labelFormat = _convertPopupFieldsToLabelSpec(layer.popupTemplate.fieldInfos, true);
2281
+ }
2282
+ }
2225
2283
  }
2226
2284
  else if (formatUsingLayerPopup && ((_d = (_c = layer.popupTemplate) === null || _c === void 0 ? void 0 : _c.content[0]) === null || _d === void 0 ? void 0 : _d.type) === "text") {
2227
2285
  labelFormat = _convertPopupTextToLabelSpec(layer.popupTemplate.content[0].text);
2286
+ // Do we need any Arcade executors?
2287
+ arcadeExecutors = await _createArcadeExecutors(labelFormat, layer);
2228
2288
  }
2229
2289
  }
2230
2290
  // Apply the label format
2231
2291
  let labels;
2232
2292
  // eslint-disable-next-line unicorn/prefer-ternary
2233
2293
  if (labelFormat) {
2294
+ const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
2234
2295
  // Convert attributes into an array of labels
2235
- labels = featuresAttrs.map(featureAttributes => {
2296
+ labels = featureSet.features.map(feature => {
2236
2297
  const label = [];
2237
2298
  labelFormat.forEach(labelLineTemplate => {
2238
- const labelLine = intl.substitute(labelLineTemplate, featureAttributes).trim();
2299
+ let labelLine = labelLineTemplate;
2300
+ // Replace Arcade expressions
2301
+ const arcadeExpressionsMatches = labelLine.match(arcadeExpressionRegExp);
2302
+ if (arcadeExpressionsMatches) {
2303
+ arcadeExpressionsMatches.forEach((match) => {
2304
+ const expressionName = match.substring(match.indexOf("/") + 1, match.length - 1);
2305
+ const replacement = arcadeExecutors[expressionName].execute({ "$feature": feature });
2306
+ labelLine = labelLine.replace(match, replacement);
2307
+ });
2308
+ }
2309
+ // Replace fields; must be done after Arcade check because `substitute` will discard Arcade expressions!
2310
+ labelLine = intl.substitute(labelLine, feature.attributes).trim();
2239
2311
  if (labelLine.length > 0) {
2240
2312
  label.push(labelLine);
2241
2313
  }
@@ -2247,8 +2319,8 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
2247
2319
  }
2248
2320
  else {
2249
2321
  // Export all attributes
2250
- labels = featuresAttrs.map(featureAttributes => {
2251
- return Object.values(featureAttributes).map(attribute => `${attribute}`);
2322
+ labels = featureSet.features.map(feature => {
2323
+ return Object.values(feature.attributes).map(attribute => `${attribute}`);
2252
2324
  });
2253
2325
  }
2254
2326
  // Remove duplicates
@@ -2264,7 +2336,8 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
2264
2336
  headerNames = labelFormat.map(labelFormatLine => labelFormatLine.replace(/\{/g, "").replace(/\}/g, ""));
2265
2337
  }
2266
2338
  else {
2267
- Object.keys(featuresAttrs[0]).forEach(k => {
2339
+ const featuresAttrs = featureSet.features[0].attributes;
2340
+ Object.keys(featuresAttrs).forEach(k => {
2268
2341
  if (featuresAttrs[0].hasOwnProperty(k)) {
2269
2342
  headerNames.push(k);
2270
2343
  }
@@ -237,7 +237,7 @@ const LayerTable$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
237
237
  * @returns a promise that will resolve when the operation is complete
238
238
  */
239
239
  async _exportToCSV() {
240
- return downloadCSV(this._layerView.layer, this._getSelectedIds(), false, // formatUsingLayerPopup
240
+ return downloadCSV([], this._layerView.layer, this._getSelectedIds(), false, // formatUsingLayerPopup
241
241
  false, // removeDuplicates
242
242
  true);
243
243
  }
@@ -538,7 +538,7 @@ const MapSelectTools = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
538
538
  * @param graphics graphics to be used for selection
539
539
  * @param label selection label
540
540
  * @param useOIDs indicates if the OIDs should override the geometry for selection
541
- * @param oids list of IDs to select when useGeoms is false
541
+ * @param oids list of IDs to select when useOIDs is true
542
542
  *
543
543
  * @protected
544
544
  */
@@ -232,24 +232,26 @@ const PdfDownload = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
232
232
  /**
233
233
  * Downloads csv of mailing labels for the provided list of ids
234
234
  *
235
+ * @param selectionSetNames Names of the selection sets used to provide ids
235
236
  * @param ids List of ids to download
236
237
  * @param removeDuplicates When true a single label is generated when multiple featues have a shared address value
237
238
  * @param addColumnTitle Indicates if column headings should be included in output
238
239
  * @returns Promise resolving when function is done
239
240
  */
240
- async downloadCSV(ids, removeDuplicates, addColumnTitle = true) {
241
- return downloadCSV(this.layerView.layer, ids, true, // formatUsingLayerPopup
241
+ async downloadCSV(selectionSetNames, ids, removeDuplicates, addColumnTitle = true) {
242
+ return downloadCSV(selectionSetNames, this.layerView.layer, ids, true, // formatUsingLayerPopup
242
243
  removeDuplicates, addColumnTitle);
243
244
  }
244
245
  /**
245
246
  * Downloads pdf of mailing labels for the provided list of ids
246
247
  *
248
+ * @param selectionSetNames Names of the selection sets used to provide ids
247
249
  * @param ids List of ids to download
248
250
  * @param removeDuplicates When true a single label is generated when multiple featues have a shared address value
249
251
  * @returns Promise resolving when function is done
250
252
  */
251
- async downloadPDF(ids, removeDuplicates) {
252
- return downloadPDF(this.layerView.layer, ids, removeDuplicates, this._labelInfoElement.selectedOption.value);
253
+ async downloadPDF(selectionSetNames, ids, removeDuplicates) {
254
+ return downloadPDF(selectionSetNames, this.layerView.layer, ids, removeDuplicates, this._labelInfoElement.selectedOption.value);
253
255
  }
254
256
  //--------------------------------------------------------------------------
255
257
  //
@@ -109,7 +109,8 @@ const PublicNotification$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
109
109
  console.log(oldValue);
110
110
  if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
111
111
  console.log("Emit event from parent");
112
- this.searchConfigurationChange.emit(newValue);
112
+ this.searchConfiguration = Object.assign({}, newValue);
113
+ this.searchConfigurationChange.emit(this.searchConfiguration);
113
114
  }
114
115
  }
115
116
  /**
@@ -179,8 +180,7 @@ const PublicNotification$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
179
180
  * Renders the component.
180
181
  */
181
182
  render() {
182
- const hasSelections = this._selectionSets.length > 0;
183
- return (h(Host, null, h("calcite-shell", null, h("calcite-action-bar", { class: "border-bottom-1 action-bar-size", "expand-disabled": true, layout: "horizontal", slot: "header" }, this._getActionGroup("list-check", false, EPageType.LIST, this._translations.myLists), this.showRefineSelection ? this._getActionGroup("test-data", !hasSelections, EPageType.REFINE, this._translations.refineSelection) : undefined, this._getActionGroup("file-pdf", !hasSelections, EPageType.PDF, this._translations.downloadPDF), this._getActionGroup("file-csv", !hasSelections, EPageType.CSV, this._translations.downloadCSV)), this._getPage(this._pageType))));
183
+ return (h(Host, null, h("calcite-shell", null, h("calcite-action-bar", { class: "border-bottom-1 action-bar-size", "expand-disabled": true, layout: "horizontal", slot: "header" }, this._getActionGroup("list-check", EPageType.LIST, this._translations.myLists), this.showRefineSelection ? this._getActionGroup("test-data", EPageType.REFINE, this._translations.refineSelection) : undefined, this._getActionGroup("file-pdf", EPageType.PDF, this._translations.downloadPDF), this._getActionGroup("file-csv", EPageType.CSV, this._translations.downloadCSV)), this._getPage(this._pageType))));
184
184
  }
185
185
  //--------------------------------------------------------------------------
186
186
  //
@@ -210,9 +210,9 @@ const PublicNotification$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
210
210
  *
211
211
  * @protected
212
212
  */
213
- _getActionGroup(icon, disabled, pageType, tip) {
213
+ _getActionGroup(icon, pageType, tip) {
214
214
  const groupClass = this.showRefineSelection ? "action-center w-1-4" : "action-center w-1-3";
215
- return (h("calcite-action-group", { class: groupClass, layout: "horizontal" }, h("calcite-action", { active: this._pageType === pageType, alignment: "center", class: "width-full height-full", compact: false, disabled: disabled, icon: icon, id: icon, onClick: () => { this._setPageType(pageType); }, text: "" }), h("calcite-tooltip", { label: "", placement: "bottom", "reference-element": icon }, h("span", null, tip))));
215
+ return (h("calcite-action-group", { class: groupClass, layout: "horizontal" }, h("calcite-action", { active: this._pageType === pageType, alignment: "center", class: "width-full height-full", compact: false, icon: icon, id: icon, onClick: () => { this._setPageType(pageType); }, text: "" }), h("calcite-tooltip", { label: "", placement: "bottom", "reference-element": icon }, h("span", null, tip))));
216
216
  }
217
217
  /**
218
218
  * Navigate to the defined page type
@@ -326,6 +326,16 @@ const PublicNotification$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
326
326
  this._layerSelectionChangeEvt.detail[0] : "";
327
327
  await this._updateAddresseeLayer(id);
328
328
  }
329
+ /**
330
+ * Check if any selection sets exist.
331
+ *
332
+ * @returns true if selection sets exist
333
+ *
334
+ * @protected
335
+ */
336
+ _hasSelections() {
337
+ return this._selectionSets.length > 0;
338
+ }
329
339
  /**
330
340
  * Create the Select page that shows the selection workflows
331
341
  *
@@ -354,7 +364,9 @@ const PublicNotification$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
354
364
  * @protected
355
365
  */
356
366
  _getRefinePage() {
357
- return (h("calcite-panel", null, this._getLabel(this._translations.refineSelection), this._getNotice(this._translations.refineTip, "padding-sides-1"), h("refine-selection", { addresseeLayer: this.addresseeLayer, enabledLayerIds: this.selectionLayerIds, mapView: this.mapView, selectionSets: this._selectionSets })));
367
+ const hasSelections = this._hasSelections();
368
+ return (h("calcite-panel", null, this._getLabel(this._translations.refineSelection), hasSelections ? (h("div", null, this._getNotice(this._translations.refineTip, "padding-sides-1"), h("refine-selection", { addresseeLayer: this.addresseeLayer, enabledLayerIds: this.selectionLayerIds, mapView: this.mapView, selectionSets: this._selectionSets }))) :
369
+ this._getNotice(this._translations.refineTipNoSelections, "padding-sides-1")));
358
370
  }
359
371
  /**
360
372
  * Create the PDF download page that shows the download options
@@ -385,7 +397,8 @@ const PublicNotification$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
385
397
  */
386
398
  _getDownloadPage(type) {
387
399
  const isPdf = type === EExportType.PDF;
388
- return (h("calcite-panel", null, h("div", null, h("div", { class: "padding-top-sides-1" }, h("calcite-label", { class: "font-bold" }, isPdf ? this._translations.downloadPDF : this._translations.downloadCSV), h("calcite-label", null, this._translations.notifications)), this._getSelectionLists(), h("div", { class: "margin-side-1 padding-top-1 border-bottom" }), h("div", { class: "padding-top-sides-1" }, h("calcite-label", { layout: "inline" }, h("calcite-checkbox", { disabled: !this._downloadActive, ref: (el) => { this._removeDuplicates = el; } }), this._translations.removeDuplicate)), h("div", { class: isPdf ? "" : "display-none" }, this._getLabel(this._translations.selectPDFLabelOption, false), h("div", { class: "padding-sides-1" }, h("pdf-download", { disabled: !this._downloadActive, layerView: this.addresseeLayer, ref: (el) => { this._downloadTools = el; } }))), h("div", { class: "padding-1 display-flex" }, h("calcite-button", { disabled: !this._downloadActive, onClick: isPdf ? () => this._downloadPDF() : () => this._downloadCSV(), width: "full" }, isPdf ? this._translations.downloadPDF : this._translations.downloadCSV)))));
400
+ const hasSelections = this._hasSelections();
401
+ return (h("calcite-panel", null, h("div", null, h("div", { class: "padding-top-sides-1" }, h("calcite-label", { class: "font-bold" }, isPdf ? this._translations.downloadPDF : this._translations.downloadCSV)), hasSelections ? (h("div", null, h("calcite-label", null, this._translations.notifications), this._getSelectionLists(), h("div", { class: "margin-side-1 padding-top-1 border-bottom" }), h("div", { class: "padding-top-sides-1" }, h("calcite-label", { layout: "inline" }, h("calcite-checkbox", { disabled: !this._downloadActive, ref: (el) => { this._removeDuplicates = el; } }), this._translations.removeDuplicate)), h("div", { class: isPdf ? "" : "display-none" }, this._getLabel(this._translations.selectPDFLabelOption, false), h("div", { class: "padding-sides-1" }, h("pdf-download", { disabled: !this._downloadActive, layerView: this.addresseeLayer, ref: (el) => { this._downloadTools = el; } }))), h("div", { class: "padding-1 display-flex" }, h("calcite-button", { disabled: !this._downloadActive, onClick: isPdf ? () => this._downloadPDF() : () => this._downloadCSV(), width: "full" }, isPdf ? this._translations.downloadPDF : this._translations.downloadCSV)))) : (this._getNotice(this._translations.downloadNoLists, "padding-sides-1 padding-bottom-1")))));
389
402
  }
390
403
  /**
391
404
  * Create the stacked navigation buttons for a page
@@ -468,7 +481,8 @@ const PublicNotification$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
468
481
  */
469
482
  _downloadPDF() {
470
483
  const ids = getSelectionIds(this._getDownloadSelectionSets());
471
- void this._downloadTools.downloadPDF(ids, this._removeDuplicates.checked);
484
+ const selectionSetNames = this._selectionSets.map(set => set.label);
485
+ void this._downloadTools.downloadPDF(selectionSetNames, ids, this._removeDuplicates.checked);
472
486
  }
473
487
  /**
474
488
  * Download all selection sets as CSV
@@ -477,7 +491,8 @@ const PublicNotification$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
477
491
  */
478
492
  _downloadCSV() {
479
493
  const ids = getSelectionIds(this._getDownloadSelectionSets());
480
- void this._downloadTools.downloadCSV(ids, this._removeDuplicates.checked);
494
+ const selectionSetNames = this._selectionSets.map(set => set.label);
495
+ void this._downloadTools.downloadCSV(selectionSetNames, ids, this._removeDuplicates.checked);
481
496
  }
482
497
  /**
483
498
  * Get all enabled selection sets
@@ -12,7 +12,7 @@ import { g as goToSelection, h as highlightFeatures, d as queryObjectIds, e as g
12
12
  import { E as EWorkflowType, f as ESelectionMode, g as ERefineMode, c as ESketchType } from './interfaces-d0d83efa.js';
13
13
  import { s as state } from './publicNotificationStore-b9daaee4.js';
14
14
  import { g as getLocaleComponentStrings } from './locale-4a87aff1.js';
15
- import { d as downloadCSV, a as downloadPDF } from './downloadUtils-76e38a94.js';
15
+ import { d as downloadCSV, a as downloadPDF } from './downloadUtils-4bb47330.js';
16
16
  import { a as getSelectionIds, g as getTotal } from './publicNotificationUtils-5cb5a607.js';
17
17
  import './resources-436ae282.js';
18
18
  import './guid-15fce7c0.js';
@@ -739,7 +739,7 @@ const MapSelectTools = class {
739
739
  * @param graphics graphics to be used for selection
740
740
  * @param label selection label
741
741
  * @param useOIDs indicates if the OIDs should override the geometry for selection
742
- * @param oids list of IDs to select when useGeoms is false
742
+ * @param oids list of IDs to select when useOIDs is true
743
743
  *
744
744
  * @protected
745
745
  */
@@ -988,24 +988,26 @@ const PdfDownload = class {
988
988
  /**
989
989
  * Downloads csv of mailing labels for the provided list of ids
990
990
  *
991
+ * @param selectionSetNames Names of the selection sets used to provide ids
991
992
  * @param ids List of ids to download
992
993
  * @param removeDuplicates When true a single label is generated when multiple featues have a shared address value
993
994
  * @param addColumnTitle Indicates if column headings should be included in output
994
995
  * @returns Promise resolving when function is done
995
996
  */
996
- async downloadCSV(ids, removeDuplicates, addColumnTitle = true) {
997
- return downloadCSV(this.layerView.layer, ids, true, // formatUsingLayerPopup
997
+ async downloadCSV(selectionSetNames, ids, removeDuplicates, addColumnTitle = true) {
998
+ return downloadCSV(selectionSetNames, this.layerView.layer, ids, true, // formatUsingLayerPopup
998
999
  removeDuplicates, addColumnTitle);
999
1000
  }
1000
1001
  /**
1001
1002
  * Downloads pdf of mailing labels for the provided list of ids
1002
1003
  *
1004
+ * @param selectionSetNames Names of the selection sets used to provide ids
1003
1005
  * @param ids List of ids to download
1004
1006
  * @param removeDuplicates When true a single label is generated when multiple featues have a shared address value
1005
1007
  * @returns Promise resolving when function is done
1006
1008
  */
1007
- async downloadPDF(ids, removeDuplicates) {
1008
- return downloadPDF(this.layerView.layer, ids, removeDuplicates, this._labelInfoElement.selectedOption.value);
1009
+ async downloadPDF(selectionSetNames, ids, removeDuplicates) {
1010
+ return downloadPDF(selectionSetNames, this.layerView.layer, ids, removeDuplicates, this._labelInfoElement.selectedOption.value);
1009
1011
  }
1010
1012
  //--------------------------------------------------------------------------
1011
1013
  //
@@ -1080,7 +1080,7 @@ function(t){var e=function(t){for(var e=t.length,r=new Uint8Array(e),n=0;n<e;n++
1080
1080
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1081
1081
  * ====================================================================
1082
1082
  */
1083
- function(t){function e(){return (n.canvg?Promise.resolve(n.canvg):import('./index.es-489f4f08.js')).catch((function(t){return Promise.reject(new Error("Could not load canvg: "+t))})).then((function(t){return t.default?t.default:t}))}E.API.addSvgAsImage=function(t,r,n,i,o,s,c,u){if(isNaN(r)||isNaN(n))throw a.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(i)||isNaN(o))throw a.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var h=document.createElement("canvas");h.width=i,h.height=o;var l=h.getContext("2d");l.fillStyle="#fff",l.fillRect(0,0,h.width,h.height);var f={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},d=this;return e().then((function(e){return e.fromString(l,t,f)}),(function(){return Promise.reject(new Error("Could not load canvg."))})).then((function(t){return t.render(f)})).then((function(){d.addImage(h.toDataURL("image/jpeg",1),r,n,i,o,c,u);}))};}(),E.API.putTotalPages=function(t){var e,r=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(t,"g"),r=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(t,this.internal.getFont()),"g"),r=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var n=1;n<=this.internal.getNumberOfPages();n++)for(var i=0;i<this.internal.pages[n].length;i++)this.internal.pages[n][i]=this.internal.pages[n][i].replace(e,r);return this},E.API.viewerPreferences=function(e,r){var n;e=e||{},r=r||!1;var i,a,o,s={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},c=Object.keys(s),u=[],h=0,l=0,f=0;function d(t,e){var r,n=!1;for(r=0;r<t.length;r+=1)t[r]===e&&(n=!0);return n}if(void 0===this.internal.viewerpreferences&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(s)),this.internal.viewerpreferences.isSubscribed=!1),n=this.internal.viewerpreferences.configuration,"reset"===e||!0===r){var p=c.length;for(f=0;f<p;f+=1)n[c[f]].value=n[c[f]].defaultValue,n[c[f]].explicitSet=!1;}if("object"===t(e))for(a in e)if(o=e[a],d(c,a)&&void 0!==o){if("boolean"===n[a].type&&"boolean"==typeof o)n[a].value=o;else if("name"===n[a].type&&d(n[a].valueSet,o))n[a].value=o;else if("integer"===n[a].type&&Number.isInteger(o))n[a].value=o;else if("array"===n[a].type){for(h=0;h<o.length;h+=1)if(i=!0,1===o[h].length&&"number"==typeof o[h][0])u.push(String(o[h]-1));else if(o[h].length>1){for(l=0;l<o[h].length;l+=1)"number"!=typeof o[h][l]&&(i=!1);!0===i&&u.push([o[h][0]-1,o[h][1]-1].join(" "));}n[a].value="["+u.join(" ")+"]";}else n[a].value=n[a].defaultValue;n[a].explicitSet=!0;}return !1===this.internal.viewerpreferences.isSubscribed&&(this.internal.events.subscribe("putCatalog",(function(){var t,e=[];for(t in n)!0===n[t].explicitSet&&("name"===n[t].type?e.push("/"+t+" /"+n[t].value):e.push("/"+t+" "+n[t].value));0!==e.length&&this.internal.write("/ViewerPreferences\n<<\n"+e.join("\n")+"\n>>");})),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=n,this},
1083
+ function(t){function e(){return (n.canvg?Promise.resolve(n.canvg):import('./index.es-4424d2f7.js')).catch((function(t){return Promise.reject(new Error("Could not load canvg: "+t))})).then((function(t){return t.default?t.default:t}))}E.API.addSvgAsImage=function(t,r,n,i,o,s,c,u){if(isNaN(r)||isNaN(n))throw a.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(i)||isNaN(o))throw a.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var h=document.createElement("canvas");h.width=i,h.height=o;var l=h.getContext("2d");l.fillStyle="#fff",l.fillRect(0,0,h.width,h.height);var f={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},d=this;return e().then((function(e){return e.fromString(l,t,f)}),(function(){return Promise.reject(new Error("Could not load canvg."))})).then((function(t){return t.render(f)})).then((function(){d.addImage(h.toDataURL("image/jpeg",1),r,n,i,o,c,u);}))};}(),E.API.putTotalPages=function(t){var e,r=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(t,"g"),r=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(t,this.internal.getFont()),"g"),r=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var n=1;n<=this.internal.getNumberOfPages();n++)for(var i=0;i<this.internal.pages[n].length;i++)this.internal.pages[n][i]=this.internal.pages[n][i].replace(e,r);return this},E.API.viewerPreferences=function(e,r){var n;e=e||{},r=r||!1;var i,a,o,s={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},c=Object.keys(s),u=[],h=0,l=0,f=0;function d(t,e){var r,n=!1;for(r=0;r<t.length;r+=1)t[r]===e&&(n=!0);return n}if(void 0===this.internal.viewerpreferences&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(s)),this.internal.viewerpreferences.isSubscribed=!1),n=this.internal.viewerpreferences.configuration,"reset"===e||!0===r){var p=c.length;for(f=0;f<p;f+=1)n[c[f]].value=n[c[f]].defaultValue,n[c[f]].explicitSet=!1;}if("object"===t(e))for(a in e)if(o=e[a],d(c,a)&&void 0!==o){if("boolean"===n[a].type&&"boolean"==typeof o)n[a].value=o;else if("name"===n[a].type&&d(n[a].valueSet,o))n[a].value=o;else if("integer"===n[a].type&&Number.isInteger(o))n[a].value=o;else if("array"===n[a].type){for(h=0;h<o.length;h+=1)if(i=!0,1===o[h].length&&"number"==typeof o[h][0])u.push(String(o[h]-1));else if(o[h].length>1){for(l=0;l<o[h].length;l+=1)"number"!=typeof o[h][l]&&(i=!1);!0===i&&u.push([o[h][0]-1,o[h][1]-1].join(" "));}n[a].value="["+u.join(" ")+"]";}else n[a].value=n[a].defaultValue;n[a].explicitSet=!0;}return !1===this.internal.viewerpreferences.isSubscribed&&(this.internal.events.subscribe("putCatalog",(function(){var t,e=[];for(t in n)!0===n[t].explicitSet&&("name"===n[t].type?e.push("/"+t+" /"+n[t].value):e.push("/"+t+" "+n[t].value));0!==e.length&&this.internal.write("/ViewerPreferences\n<<\n"+e.join("\n")+"\n>>");})),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=n,this},
1084
1084
  /** ====================================================================
1085
1085
  * @license
1086
1086
  * jsPDF XMP metadata plugin
@@ -2127,6 +2127,7 @@ function _downloadPDFFile(labels, labelPageDescription, fileTitle) {
2127
2127
  /**
2128
2128
  * Downloads csv of mailing labels for the provided list of ids
2129
2129
  *
2130
+ * @param selectionSetNames Names of the selection sets used to provide ids
2130
2131
  * @param layer Layer providing features and attributes for download
2131
2132
  * @param ids List of ids to download
2132
2133
  * @param formatUsingLayerPopup When true, the layer's popup is used to choose attributes for each column; when false,
@@ -2135,7 +2136,8 @@ function _downloadPDFFile(labels, labelPageDescription, fileTitle) {
2135
2136
  * @param addColumnTitle Indicates if column headings should be included in output
2136
2137
  * @returns Promise resolving when function is done
2137
2138
  */
2138
- async function downloadCSV(layer, ids, formatUsingLayerPopup, removeDuplicates = false, addColumnTitle = false) {
2139
+ async function downloadCSV(selectionSetNames, layer, ids, formatUsingLayerPopup, removeDuplicates = false, addColumnTitle = false) {
2140
+ console.log("downloadCSV using selectionSetNames " + JSON.stringify(selectionSetNames)); //???
2139
2141
  const labels = await _prepareLabels(layer, ids, removeDuplicates, formatUsingLayerPopup, addColumnTitle);
2140
2142
  exportCSV(labels);
2141
2143
  return Promise.resolve();
@@ -2143,13 +2145,15 @@ async function downloadCSV(layer, ids, formatUsingLayerPopup, removeDuplicates =
2143
2145
  /**
2144
2146
  * Downloads csv of mailing labels for the provided list of ids
2145
2147
  *
2148
+ * @param selectionSetNames Names of the selection sets used to provide ids
2146
2149
  * @param layer Layer providing features and attributes for download
2147
2150
  * @param ids List of ids to download
2148
2151
  * @param removeDuplicates When true a single label is generated when multiple featues have a shared address value
2149
2152
  * @param labelPageDescription Provides PDF page layout info
2150
2153
  * @returns Promise resolving when function is done
2151
2154
  */
2152
- async function downloadPDF(layer, ids, removeDuplicates, labelPageDescription) {
2155
+ async function downloadPDF(selectionSetNames, layer, ids, removeDuplicates, labelPageDescription) {
2156
+ console.log("downloadPDF using selectionSetNames " + JSON.stringify(selectionSetNames)); //???
2153
2157
  const labels = await _prepareLabels(layer, ids, removeDuplicates);
2154
2158
  exportPDF(labels, labelPageDescription);
2155
2159
  return Promise.resolve();
@@ -2160,13 +2164,14 @@ async function downloadPDF(layer, ids, removeDuplicates, labelPageDescription) {
2160
2164
  * Converts a set of fieldInfos into template lines.
2161
2165
  *
2162
2166
  * @param fieldInfos Layer's fieldInfos structure
2167
+ * @param bypassFieldVisiblity Indicates if the configured fieldInfo visibility property should be ignored
2163
2168
  * @return Label spec
2164
2169
  */
2165
- function _convertPopupFieldsToLabelSpec(fieldInfos) {
2170
+ function _convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity = false) {
2166
2171
  const labelSpec = [];
2167
2172
  // Every visible attribute is used
2168
2173
  fieldInfos.forEach(fieldInfo => {
2169
- if (fieldInfo.visible) {
2174
+ if (fieldInfo.visible || bypassFieldVisiblity) {
2170
2175
  labelSpec.push(`{${fieldInfo.fieldName}}`);
2171
2176
  }
2172
2177
  });
@@ -2196,6 +2201,49 @@ function _convertPopupTextToLabelSpec(popupInfo) {
2196
2201
  labelSpec = labelSpec.map(line => line.trim()).filter(line => line.length > 0);
2197
2202
  return labelSpec;
2198
2203
  }
2204
+ /**
2205
+ * Extracts Arcade expressions from the lines of a label format and creates an Arcade executor for each
2206
+ * referenced expression name.
2207
+ *
2208
+ * @param labelFormat Label to examine
2209
+ * @param layer Layer from which to fetch features
2210
+ * @return Promise resolving to a set of executors keyed using the expression name
2211
+ */
2212
+ async function _createArcadeExecutors(labelFormat, layer) {
2213
+ const arcadeExecutors = {};
2214
+ // Are any Arcade expressions in the layer?
2215
+ if (!Array.isArray(layer.popupTemplate.expressionInfos) || layer.popupTemplate.expressionInfos.length === 0) {
2216
+ return Promise.resolve(arcadeExecutors);
2217
+ }
2218
+ // Are there any Arcade expressions in the label format?
2219
+ const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
2220
+ const arcadeExpressionsMatches = labelFormat.join("|").match(arcadeExpressionRegExp);
2221
+ if (!arcadeExpressionsMatches) {
2222
+ return Promise.resolve(arcadeExecutors);
2223
+ }
2224
+ // Generate an Arcade executor for each match
2225
+ const [arcade] = await loadModules(["esri/arcade"]);
2226
+ const labelingProfile = arcade.createArcadeProfile("popup");
2227
+ const createArcadeExecutorPromises = {};
2228
+ arcadeExpressionsMatches.forEach((match) => {
2229
+ const expressionName = match.substring(match.indexOf("/") + 1, match.length - 1);
2230
+ (layer.popupTemplate.expressionInfos || []).forEach(expressionInfo => {
2231
+ if (expressionInfo.name === expressionName) {
2232
+ createArcadeExecutorPromises[expressionName] =
2233
+ arcade.createArcadeExecutor(expressionInfo.expression, labelingProfile);
2234
+ }
2235
+ });
2236
+ });
2237
+ const promises = Object.values(createArcadeExecutorPromises);
2238
+ return Promise.all(promises)
2239
+ .then(executors => {
2240
+ const expressionNames = Object.keys(createArcadeExecutorPromises);
2241
+ for (let i = 0; i < expressionNames.length; ++i) {
2242
+ arcadeExecutors[expressionNames[i]] = executors[i].valueOf();
2243
+ }
2244
+ return arcadeExecutors;
2245
+ });
2246
+ }
2199
2247
  /**
2200
2248
  * Creates labels from items.
2201
2249
  *
@@ -2209,33 +2257,57 @@ function _convertPopupTextToLabelSpec(popupInfo) {
2209
2257
  */
2210
2258
  async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLayerPopup = true, includeHeaderNames = false) {
2211
2259
  var _a, _b, _c, _d;
2212
- const [intl] = await loadModules([
2213
- "esri/intl"
2214
- ]);
2215
- // Get the attributes of the features to export
2260
+ const [intl] = await loadModules(["esri/intl"]);
2261
+ // Get the features to export
2216
2262
  const featureSet = await queryFeaturesByID(ids, layer);
2217
- const featuresAttrs = featureSet.features.map(f => f.attributes);
2218
2263
  // Get the label formatting, if any
2219
2264
  let labelFormat;
2265
+ let arcadeExecutors = {};
2220
2266
  if (layer.popupEnabled) {
2221
2267
  // What data fields are used in the labels?
2222
2268
  // Example labelFormat: ['{NAME}', '{STREET}', '{CITY}, {STATE} {ZIP}']
2223
2269
  if (formatUsingLayerPopup && ((_b = (_a = layer.popupTemplate) === null || _a === void 0 ? void 0 : _a.content[0]) === null || _b === void 0 ? void 0 : _b.type) === "fields") {
2224
2270
  labelFormat = _convertPopupFieldsToLabelSpec(layer.popupTemplate.fieldInfos);
2271
+ // If popup is configured with "no attribute information", then no fields will visible
2272
+ if (labelFormat.length === 0) {
2273
+ // Can we use the popup title?
2274
+ // eslint-disable-next-line unicorn/prefer-ternary
2275
+ if (typeof layer.popupTemplate.title === "string") {
2276
+ labelFormat = [layer.popupTemplate.title];
2277
+ // Otherwise revert to using attributes
2278
+ }
2279
+ else {
2280
+ labelFormat = _convertPopupFieldsToLabelSpec(layer.popupTemplate.fieldInfos, true);
2281
+ }
2282
+ }
2225
2283
  }
2226
2284
  else if (formatUsingLayerPopup && ((_d = (_c = layer.popupTemplate) === null || _c === void 0 ? void 0 : _c.content[0]) === null || _d === void 0 ? void 0 : _d.type) === "text") {
2227
2285
  labelFormat = _convertPopupTextToLabelSpec(layer.popupTemplate.content[0].text);
2286
+ // Do we need any Arcade executors?
2287
+ arcadeExecutors = await _createArcadeExecutors(labelFormat, layer);
2228
2288
  }
2229
2289
  }
2230
2290
  // Apply the label format
2231
2291
  let labels;
2232
2292
  // eslint-disable-next-line unicorn/prefer-ternary
2233
2293
  if (labelFormat) {
2294
+ const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
2234
2295
  // Convert attributes into an array of labels
2235
- labels = featuresAttrs.map(featureAttributes => {
2296
+ labels = featureSet.features.map(feature => {
2236
2297
  const label = [];
2237
2298
  labelFormat.forEach(labelLineTemplate => {
2238
- const labelLine = intl.substitute(labelLineTemplate, featureAttributes).trim();
2299
+ let labelLine = labelLineTemplate;
2300
+ // Replace Arcade expressions
2301
+ const arcadeExpressionsMatches = labelLine.match(arcadeExpressionRegExp);
2302
+ if (arcadeExpressionsMatches) {
2303
+ arcadeExpressionsMatches.forEach((match) => {
2304
+ const expressionName = match.substring(match.indexOf("/") + 1, match.length - 1);
2305
+ const replacement = arcadeExecutors[expressionName].execute({ "$feature": feature });
2306
+ labelLine = labelLine.replace(match, replacement);
2307
+ });
2308
+ }
2309
+ // Replace fields; must be done after Arcade check because `substitute` will discard Arcade expressions!
2310
+ labelLine = intl.substitute(labelLine, feature.attributes).trim();
2239
2311
  if (labelLine.length > 0) {
2240
2312
  label.push(labelLine);
2241
2313
  }
@@ -2247,8 +2319,8 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
2247
2319
  }
2248
2320
  else {
2249
2321
  // Export all attributes
2250
- labels = featuresAttrs.map(featureAttributes => {
2251
- return Object.values(featureAttributes).map(attribute => `${attribute}`);
2322
+ labels = featureSet.features.map(feature => {
2323
+ return Object.values(feature.attributes).map(attribute => `${attribute}`);
2252
2324
  });
2253
2325
  }
2254
2326
  // Remove duplicates
@@ -2264,7 +2336,8 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
2264
2336
  headerNames = labelFormat.map(labelFormatLine => labelFormatLine.replace(/\{/g, "").replace(/\}/g, ""));
2265
2337
  }
2266
2338
  else {
2267
- Object.keys(featuresAttrs[0]).forEach(k => {
2339
+ const featuresAttrs = featureSet.features[0].attributes;
2340
+ Object.keys(featuresAttrs).forEach(k => {
2268
2341
  if (featuresAttrs[0].hasOwnProperty(k)) {
2269
2342
  headerNames.push(k);
2270
2343
  }
@@ -4,7 +4,7 @@
4
4
  * http://www.apache.org/licenses/LICENSE-2.0
5
5
  */
6
6
  import { a as commonjsGlobal, c as createCommonjsModule, g as getDefaultExportFromCjs } from './_commonjsHelpers-d5f9d613.js';
7
- import { _ as _typeof_1 } from './downloadUtils-76e38a94.js';
7
+ import { _ as _typeof_1 } from './downloadUtils-4bb47330.js';
8
8
  import './index-c246d90e.js';
9
9
  import './loadModules-649aedac.js';
10
10
  import './locale-4a87aff1.js';
@@ -6,7 +6,7 @@
6
6
  import { r as registerInstance, h, H as Host, g as getElement } from './index-c246d90e.js';
7
7
  import { g as getLocaleComponentStrings } from './locale-4a87aff1.js';
8
8
  import { g as goToSelection, a as getMapLayerView, q as queryAllFeatures } from './mapViewUtils-02696ab6.js';
9
- import { d as downloadCSV } from './downloadUtils-76e38a94.js';
9
+ import { d as downloadCSV } from './downloadUtils-4bb47330.js';
10
10
  import './_commonjsHelpers-d5f9d613.js';
11
11
  import './interfaces-d0d83efa.js';
12
12
  import './loadModules-649aedac.js';
@@ -218,7 +218,7 @@ const LayerTable = class {
218
218
  * @returns a promise that will resolve when the operation is complete
219
219
  */
220
220
  async _exportToCSV() {
221
- return downloadCSV(this._layerView.layer, this._getSelectedIds(), false, // formatUsingLayerPopup
221
+ return downloadCSV([], this._layerView.layer, this._getSelectedIds(), false, // formatUsingLayerPopup
222
222
  false, // removeDuplicates
223
223
  true);
224
224
  }