@esri/solutions-components 0.4.3 → 0.4.5
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.
- package/dist/assets/t9n/public-notification/resources.json +5 -5
- package/dist/assets/t9n/public-notification/resources_en.json +5 -5
- package/dist/cjs/calcite-input-message_5.cjs.entry.js +1 -17
- package/dist/cjs/{downloadUtils-ae182e3a.js → downloadUtils-d05b069f.js} +91 -42
- package/dist/cjs/{index.es-b71e9071.js → index.es-e47b660c.js} +1 -1
- package/dist/cjs/layer-table.cjs.entry.js +1 -1
- package/dist/cjs/public-notification.cjs.entry.js +3 -11
- package/dist/collection/components/map-select-tools/map-select-tools.js +0 -16
- package/dist/collection/components/public-notification/public-notification.js +3 -11
- package/dist/collection/utils/downloadUtils.js +90 -41
- package/dist/collection/utils/downloadUtils.ts +123 -52
- package/dist/components/downloadUtils.js +90 -41
- package/dist/components/map-select-tools2.js +0 -16
- package/dist/components/public-notification.js +3 -11
- package/dist/esm/calcite-input-message_5.entry.js +1 -17
- package/dist/esm/{downloadUtils-8d64719e.js → downloadUtils-a9b39194.js} +91 -42
- package/dist/esm/{index.es-1d777745.js → index.es-4904465f.js} +1 -1
- package/dist/esm/layer-table.entry.js +1 -1
- package/dist/esm/public-notification.entry.js +3 -11
- package/dist/solutions-components/p-20c73673.entry.js +6 -0
- package/dist/solutions-components/{p-702e1915.js → p-25eb36dc.js} +1 -1
- package/dist/solutions-components/p-59caff67.entry.js +17 -0
- package/dist/solutions-components/{p-048a4c91.entry.js → p-a606221a.entry.js} +1 -1
- package/dist/solutions-components/{p-01215468.js → p-e7b3a4d9.js} +3 -3
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/downloadUtils.ts +123 -52
- package/dist/types/components/json-editor/assets/monaco-editor/monaco.d.ts +8262 -0
- package/package.json +1 -1
- package/dist/solutions-components/p-4bfcd9ea.entry.js +0 -17
- package/dist/solutions-components/p-a99ca396.entry.js +0 -6
@@ -2122,6 +2122,7 @@ function _downloadPDFFile(labels, labelPageDescription, fileTitle) {
|
|
2122
2122
|
* See the License for the specific language governing permissions and
|
2123
2123
|
* limitations under the License.
|
2124
2124
|
*/
|
2125
|
+
const lineSeparatorChar = "|";
|
2125
2126
|
//#endregion
|
2126
2127
|
//#region Public functions
|
2127
2128
|
/**
|
@@ -2154,7 +2155,12 @@ async function downloadCSV(selectionSetNames, layer, ids, formatUsingLayerPopup,
|
|
2154
2155
|
*/
|
2155
2156
|
async function downloadPDF(selectionSetNames, layer, ids, removeDuplicates, labelPageDescription) {
|
2156
2157
|
console.log("downloadPDF using selectionSetNames " + JSON.stringify(selectionSetNames)); //???
|
2157
|
-
|
2158
|
+
let labels = await _prepareLabels(layer, ids, removeDuplicates);
|
2159
|
+
labels =
|
2160
|
+
// Remove empty lines in labels
|
2161
|
+
labels.map(labelLines => labelLines.filter(line => line.length > 0))
|
2162
|
+
// Remove empty labels
|
2163
|
+
.filter(label => label.length > 0);
|
2158
2164
|
exportPDF(labels, labelPageDescription);
|
2159
2165
|
return Promise.resolve();
|
2160
2166
|
}
|
@@ -2165,7 +2171,7 @@ async function downloadPDF(selectionSetNames, layer, ids, removeDuplicates, labe
|
|
2165
2171
|
*
|
2166
2172
|
* @param fieldInfos Layer's fieldInfos structure
|
2167
2173
|
* @param bypassFieldVisiblity Indicates if the configured fieldInfo visibility property should be ignored
|
2168
|
-
* @return Label spec
|
2174
|
+
* @return Label spec with lines separated by `lineSeparatorChar`
|
2169
2175
|
*/
|
2170
2176
|
function _convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity = false) {
|
2171
2177
|
const labelSpec = [];
|
@@ -2175,7 +2181,7 @@ function _convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity = false
|
|
2175
2181
|
labelSpec.push(`{${fieldInfo.fieldName}}`);
|
2176
2182
|
}
|
2177
2183
|
});
|
2178
|
-
return labelSpec;
|
2184
|
+
return labelSpec.join(lineSeparatorChar);
|
2179
2185
|
}
|
2180
2186
|
/**
|
2181
2187
|
* Converts the text of a custom popup into a multiline label specification; conversion splits text into
|
@@ -2183,22 +2189,19 @@ function _convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity = false
|
|
2183
2189
|
*
|
2184
2190
|
* @param popupInfo Layer's popupInfo structure containing description, fieldInfos, and expressionInfos, e.g.,
|
2185
2191
|
* "<div style='text-align: left;'>{NAME}<br />{STREET}<br />{CITY}, {STATE} {ZIP} <br /></div>"
|
2186
|
-
* @return Label spec
|
2192
|
+
* @return Label spec with lines separated by `lineSeparatorChar`
|
2187
2193
|
*/
|
2188
2194
|
function _convertPopupTextToLabelSpec(popupInfo) {
|
2189
|
-
// Replace <br>, <br/> with
|
2190
|
-
popupInfo = popupInfo.replace(/<br\s*\/?>/gi,
|
2191
|
-
// Remove remaining HTML tags, replace 0xA0 that popup uses for spaces, replace some char representations,
|
2195
|
+
// Replace <br>, <br/> with the line separator character
|
2196
|
+
popupInfo = popupInfo.replace(/<br\s*\/?>/gi, lineSeparatorChar);
|
2197
|
+
// Remove remaining HTML tags, replace 0xA0 that popup uses for spaces, and replace some char representations,
|
2192
2198
|
// and split the label back into individual lines
|
2193
|
-
|
2199
|
+
const labelSpec = popupInfo
|
2194
2200
|
.replace(/<[\s.]*[^<>]*\/?>/gi, "")
|
2195
2201
|
.replace(/\xA0/gi, " ")
|
2196
2202
|
.replace(/</gi, "<")
|
2197
2203
|
.replace(/>/gi, ">")
|
2198
|
-
.replace(/ /gi, " ")
|
2199
|
-
.split("|");
|
2200
|
-
// Trim lines and remove empties
|
2201
|
-
labelSpec = labelSpec.map(line => line.trim()).filter(line => line.length > 0);
|
2204
|
+
.replace(/ /gi, " ");
|
2202
2205
|
return labelSpec;
|
2203
2206
|
}
|
2204
2207
|
/**
|
@@ -2217,7 +2220,7 @@ async function _createArcadeExecutors(labelFormat, layer) {
|
|
2217
2220
|
}
|
2218
2221
|
// Are there any Arcade expressions in the label format?
|
2219
2222
|
const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
|
2220
|
-
const arcadeExpressionsMatches = labelFormat.
|
2223
|
+
const arcadeExpressionsMatches = labelFormat.match(arcadeExpressionRegExp);
|
2221
2224
|
if (!arcadeExpressionsMatches) {
|
2222
2225
|
return Promise.resolve(arcadeExecutors);
|
2223
2226
|
}
|
@@ -2244,6 +2247,39 @@ async function _createArcadeExecutors(labelFormat, layer) {
|
|
2244
2247
|
return arcadeExecutors;
|
2245
2248
|
});
|
2246
2249
|
}
|
2250
|
+
/**
|
2251
|
+
* Prepares an attribute's value by applying domain and type information.
|
2252
|
+
*
|
2253
|
+
* @param attributeValue Value of attribute
|
2254
|
+
* @param attributeType Type of attribute
|
2255
|
+
* @param attributeDomain Domain info for attribute, if any
|
2256
|
+
* @return Attribute value modified appropriate to domain and type
|
2257
|
+
*/
|
2258
|
+
function _prepareAttributeValue(attributeValue, attributeType, attributeDomain, intl) {
|
2259
|
+
if (attributeDomain && attributeDomain.type === "coded-value") {
|
2260
|
+
// "coded-value" domain field
|
2261
|
+
const value = attributeDomain.getName(attributeValue);
|
2262
|
+
return value;
|
2263
|
+
}
|
2264
|
+
else {
|
2265
|
+
// Non-domain field or unsupported domain type
|
2266
|
+
let value = attributeValue;
|
2267
|
+
switch (attributeType) {
|
2268
|
+
case "date":
|
2269
|
+
// Format date produces odd characters for the space between the time and the AM/PM text,
|
2270
|
+
// e.g., "12/31/1969, 4:00 PM"
|
2271
|
+
value = intl.formatDate(value).replace(/\xe2\x80\xaf/g, "");
|
2272
|
+
break;
|
2273
|
+
case "double":
|
2274
|
+
case "integer":
|
2275
|
+
case "long":
|
2276
|
+
case "small-integer":
|
2277
|
+
value = intl.formatNumber(value);
|
2278
|
+
break;
|
2279
|
+
}
|
2280
|
+
return value;
|
2281
|
+
}
|
2282
|
+
}
|
2247
2283
|
/**
|
2248
2284
|
* Creates labels from items.
|
2249
2285
|
*
|
@@ -2260,6 +2296,13 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2260
2296
|
const [intl] = await loadModules(["esri/intl"]);
|
2261
2297
|
// Get the features to export
|
2262
2298
|
const featureSet = await queryFeaturesByID(ids, layer);
|
2299
|
+
// Get field data types. Do we have any domain-based fields?
|
2300
|
+
const attributeTypes = {};
|
2301
|
+
const attributeDomains = {};
|
2302
|
+
layer.fields.forEach(field => {
|
2303
|
+
attributeTypes[field.name] = field.type;
|
2304
|
+
attributeDomains[field.name] = field.domain;
|
2305
|
+
});
|
2263
2306
|
// Get the label formatting, if any
|
2264
2307
|
let labelFormat;
|
2265
2308
|
let arcadeExecutors = {};
|
@@ -2273,7 +2316,7 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2273
2316
|
// Can we use the popup title?
|
2274
2317
|
// eslint-disable-next-line unicorn/prefer-ternary
|
2275
2318
|
if (typeof layer.popupTemplate.title === "string") {
|
2276
|
-
labelFormat =
|
2319
|
+
labelFormat = layer.popupTemplate.title;
|
2277
2320
|
// Otherwise revert to using attributes
|
2278
2321
|
}
|
2279
2322
|
else {
|
@@ -2292,35 +2335,43 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2292
2335
|
// eslint-disable-next-line unicorn/prefer-ternary
|
2293
2336
|
if (labelFormat) {
|
2294
2337
|
const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
|
2295
|
-
|
2338
|
+
const attributeRegExp = /\{\w+\}/g;
|
2339
|
+
// Find the label fields that we need to replace with values
|
2340
|
+
const arcadeExpressionMatches = labelFormat.match(arcadeExpressionRegExp);
|
2341
|
+
const attributeMatches = labelFormat.match(attributeRegExp);
|
2342
|
+
// Convert feature attributes into an array of labels
|
2296
2343
|
labels = featureSet.features.map(feature => {
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2344
|
+
let labelPrep = labelFormat;
|
2345
|
+
// Replace Arcade expressions
|
2346
|
+
if (arcadeExpressionMatches) {
|
2347
|
+
arcadeExpressionMatches.forEach((match) => {
|
2348
|
+
const expressionName = match.substring(match.indexOf("/") + 1, match.length - 1);
|
2349
|
+
const value = arcadeExecutors[expressionName].execute({ "$feature": feature });
|
2350
|
+
labelPrep = labelPrep.replace(match, value);
|
2351
|
+
});
|
2352
|
+
}
|
2353
|
+
// Replace non-Arcade fields
|
2354
|
+
if (attributeMatches) {
|
2355
|
+
attributeMatches.forEach((match) => {
|
2356
|
+
const attributeName = match.substring(1, match.length - 1);
|
2357
|
+
const value = _prepareAttributeValue(feature.attributes[attributeName], attributeTypes[attributeName], attributeDomains[attributeName], intl);
|
2358
|
+
labelPrep = labelPrep.replace(match, value);
|
2359
|
+
});
|
2360
|
+
}
|
2361
|
+
// Split label into lines
|
2362
|
+
let label = labelPrep.split(lineSeparatorChar);
|
2363
|
+
// Trim lines
|
2364
|
+
label = label.map(line => line.trim());
|
2315
2365
|
return label;
|
2316
|
-
})
|
2317
|
-
// Remove empty labels
|
2318
|
-
.filter(label => label.length > 0);
|
2366
|
+
});
|
2319
2367
|
}
|
2320
2368
|
else {
|
2321
2369
|
// Export all attributes
|
2322
2370
|
labels = featureSet.features.map(feature => {
|
2323
|
-
return Object.
|
2371
|
+
return Object.keys(feature.attributes).map((attributeName) => {
|
2372
|
+
const value = _prepareAttributeValue(feature.attributes[attributeName], attributeTypes[attributeName], attributeDomains[attributeName], intl);
|
2373
|
+
return `${value}`;
|
2374
|
+
});
|
2324
2375
|
});
|
2325
2376
|
}
|
2326
2377
|
// Remove duplicates
|
@@ -2333,14 +2384,12 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2333
2384
|
if (includeHeaderNames) {
|
2334
2385
|
let headerNames = [];
|
2335
2386
|
if (labelFormat) {
|
2336
|
-
headerNames = labelFormat.
|
2387
|
+
headerNames = labelFormat.replace(/\{/g, "").replace(/\}/g, "").split(lineSeparatorChar);
|
2337
2388
|
}
|
2338
2389
|
else {
|
2339
2390
|
const featuresAttrs = featureSet.features[0].attributes;
|
2340
2391
|
Object.keys(featuresAttrs).forEach(k => {
|
2341
|
-
|
2342
|
-
headerNames.push(k);
|
2343
|
-
}
|
2392
|
+
headerNames.push(k);
|
2344
2393
|
});
|
2345
2394
|
}
|
2346
2395
|
labels.unshift(headerNames);
|
@@ -91,11 +91,6 @@ const MapSelectTools = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
91
91
|
* @returns Promise when complete
|
92
92
|
*/
|
93
93
|
async watchSearchConfigurationHandler(newValue, oldValue) {
|
94
|
-
console.log("watchSearchConfigurationHandler");
|
95
|
-
console.log("newValue");
|
96
|
-
console.log(newValue);
|
97
|
-
console.log("oldValue");
|
98
|
-
console.log(oldValue);
|
99
94
|
if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
|
100
95
|
this._initSearchWidget();
|
101
96
|
}
|
@@ -162,7 +157,6 @@ const MapSelectTools = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
162
157
|
* Handle changes to the search configuration
|
163
158
|
*/
|
164
159
|
searchConfigurationChangeChanged(event) {
|
165
|
-
console.log("searchConfigurationChange listener");
|
166
160
|
this.searchConfiguration = event.detail;
|
167
161
|
}
|
168
162
|
/**
|
@@ -295,16 +289,8 @@ const MapSelectTools = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
295
289
|
* @protected
|
296
290
|
*/
|
297
291
|
_initSearchWidget() {
|
298
|
-
console.log("_initSearchWidget");
|
299
|
-
console.log("this.mapView");
|
300
|
-
console.log(this.mapView);
|
301
|
-
console.log("this._searchElement");
|
302
|
-
console.log(this._searchElement);
|
303
292
|
if (this.mapView && this._searchElement) {
|
304
|
-
console.log("this._getSearchConfig");
|
305
293
|
const searchConfiguration = this._getSearchConfig(this.searchConfiguration, this.mapView);
|
306
|
-
console.log("searchConfiguration");
|
307
|
-
console.log(searchConfiguration);
|
308
294
|
const searchOptions = Object.assign({ view: this.mapView, container: this._searchElement, searchTerm: this._searchTerm }, searchConfiguration);
|
309
295
|
this._searchWidget = new this.Search(searchOptions);
|
310
296
|
this._searchWidget.popupEnabled = false;
|
@@ -344,11 +330,9 @@ const MapSelectTools = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
344
330
|
? view.map.findLayerById(layerSource.layer.id)
|
345
331
|
: null;
|
346
332
|
if (layerFromMap) {
|
347
|
-
console.log("layerFromMap");
|
348
333
|
layerSource.layer = layerFromMap;
|
349
334
|
}
|
350
335
|
else if ((_b = layerSource === null || layerSource === void 0 ? void 0 : layerSource.layer) === null || _b === void 0 ? void 0 : _b.url) {
|
351
|
-
console.log("create new");
|
352
336
|
layerSource.layer = new this.FeatureLayer((_c = layerSource === null || layerSource === void 0 ? void 0 : layerSource.layer) === null || _c === void 0 ? void 0 : _c.url);
|
353
337
|
}
|
354
338
|
}
|
@@ -100,17 +100,9 @@ const PublicNotification$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
100
100
|
* @returns Promise when complete
|
101
101
|
*/
|
102
102
|
async watchSearchConfigurationHandler(newValue, oldValue) {
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
console.log("PN watchSearchConfigurationHandler");
|
107
|
-
console.log("PN newValue");
|
108
|
-
console.log(newValue);
|
109
|
-
console.log("PN oldValue");
|
110
|
-
console.log(oldValue);
|
111
|
-
if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
|
112
|
-
console.log("Emit event from parent");
|
113
|
-
this._searchConfiguration = Object.assign({}, newValue);
|
103
|
+
const s_newValue = JSON.stringify(newValue);
|
104
|
+
if (s_newValue !== JSON.stringify(oldValue)) {
|
105
|
+
this._searchConfiguration = JSON.parse(s_newValue);
|
114
106
|
this.searchConfigurationChange.emit(this._searchConfiguration);
|
115
107
|
}
|
116
108
|
}
|
@@ -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-7bf10e0a.js';
|
15
|
-
import { d as downloadCSV, a as downloadPDF } from './downloadUtils-
|
15
|
+
import { d as downloadCSV, a as downloadPDF } from './downloadUtils-a9b39194.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';
|
@@ -292,11 +292,6 @@ const MapSelectTools = class {
|
|
292
292
|
* @returns Promise when complete
|
293
293
|
*/
|
294
294
|
async watchSearchConfigurationHandler(newValue, oldValue) {
|
295
|
-
console.log("watchSearchConfigurationHandler");
|
296
|
-
console.log("newValue");
|
297
|
-
console.log(newValue);
|
298
|
-
console.log("oldValue");
|
299
|
-
console.log(oldValue);
|
300
295
|
if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
|
301
296
|
this._initSearchWidget();
|
302
297
|
}
|
@@ -363,7 +358,6 @@ const MapSelectTools = class {
|
|
363
358
|
* Handle changes to the search configuration
|
364
359
|
*/
|
365
360
|
searchConfigurationChangeChanged(event) {
|
366
|
-
console.log("searchConfigurationChange listener");
|
367
361
|
this.searchConfiguration = event.detail;
|
368
362
|
}
|
369
363
|
/**
|
@@ -496,16 +490,8 @@ const MapSelectTools = class {
|
|
496
490
|
* @protected
|
497
491
|
*/
|
498
492
|
_initSearchWidget() {
|
499
|
-
console.log("_initSearchWidget");
|
500
|
-
console.log("this.mapView");
|
501
|
-
console.log(this.mapView);
|
502
|
-
console.log("this._searchElement");
|
503
|
-
console.log(this._searchElement);
|
504
493
|
if (this.mapView && this._searchElement) {
|
505
|
-
console.log("this._getSearchConfig");
|
506
494
|
const searchConfiguration = this._getSearchConfig(this.searchConfiguration, this.mapView);
|
507
|
-
console.log("searchConfiguration");
|
508
|
-
console.log(searchConfiguration);
|
509
495
|
const searchOptions = Object.assign({ view: this.mapView, container: this._searchElement, searchTerm: this._searchTerm }, searchConfiguration);
|
510
496
|
this._searchWidget = new this.Search(searchOptions);
|
511
497
|
this._searchWidget.popupEnabled = false;
|
@@ -545,11 +531,9 @@ const MapSelectTools = class {
|
|
545
531
|
? view.map.findLayerById(layerSource.layer.id)
|
546
532
|
: null;
|
547
533
|
if (layerFromMap) {
|
548
|
-
console.log("layerFromMap");
|
549
534
|
layerSource.layer = layerFromMap;
|
550
535
|
}
|
551
536
|
else if ((_b = layerSource === null || layerSource === void 0 ? void 0 : layerSource.layer) === null || _b === void 0 ? void 0 : _b.url) {
|
552
|
-
console.log("create new");
|
553
537
|
layerSource.layer = new this.FeatureLayer((_c = layerSource === null || layerSource === void 0 ? void 0 : layerSource.layer) === null || _c === void 0 ? void 0 : _c.url);
|
554
538
|
}
|
555
539
|
}
|
@@ -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-
|
1083
|
+
function(t){function e(){return (n.canvg?Promise.resolve(n.canvg):import('./index.es-4904465f.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
|
@@ -2122,6 +2122,7 @@ function _downloadPDFFile(labels, labelPageDescription, fileTitle) {
|
|
2122
2122
|
* See the License for the specific language governing permissions and
|
2123
2123
|
* limitations under the License.
|
2124
2124
|
*/
|
2125
|
+
const lineSeparatorChar = "|";
|
2125
2126
|
//#endregion
|
2126
2127
|
//#region Public functions
|
2127
2128
|
/**
|
@@ -2154,7 +2155,12 @@ async function downloadCSV(selectionSetNames, layer, ids, formatUsingLayerPopup,
|
|
2154
2155
|
*/
|
2155
2156
|
async function downloadPDF(selectionSetNames, layer, ids, removeDuplicates, labelPageDescription) {
|
2156
2157
|
console.log("downloadPDF using selectionSetNames " + JSON.stringify(selectionSetNames)); //???
|
2157
|
-
|
2158
|
+
let labels = await _prepareLabels(layer, ids, removeDuplicates);
|
2159
|
+
labels =
|
2160
|
+
// Remove empty lines in labels
|
2161
|
+
labels.map(labelLines => labelLines.filter(line => line.length > 0))
|
2162
|
+
// Remove empty labels
|
2163
|
+
.filter(label => label.length > 0);
|
2158
2164
|
exportPDF(labels, labelPageDescription);
|
2159
2165
|
return Promise.resolve();
|
2160
2166
|
}
|
@@ -2165,7 +2171,7 @@ async function downloadPDF(selectionSetNames, layer, ids, removeDuplicates, labe
|
|
2165
2171
|
*
|
2166
2172
|
* @param fieldInfos Layer's fieldInfos structure
|
2167
2173
|
* @param bypassFieldVisiblity Indicates if the configured fieldInfo visibility property should be ignored
|
2168
|
-
* @return Label spec
|
2174
|
+
* @return Label spec with lines separated by `lineSeparatorChar`
|
2169
2175
|
*/
|
2170
2176
|
function _convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity = false) {
|
2171
2177
|
const labelSpec = [];
|
@@ -2175,7 +2181,7 @@ function _convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity = false
|
|
2175
2181
|
labelSpec.push(`{${fieldInfo.fieldName}}`);
|
2176
2182
|
}
|
2177
2183
|
});
|
2178
|
-
return labelSpec;
|
2184
|
+
return labelSpec.join(lineSeparatorChar);
|
2179
2185
|
}
|
2180
2186
|
/**
|
2181
2187
|
* Converts the text of a custom popup into a multiline label specification; conversion splits text into
|
@@ -2183,22 +2189,19 @@ function _convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity = false
|
|
2183
2189
|
*
|
2184
2190
|
* @param popupInfo Layer's popupInfo structure containing description, fieldInfos, and expressionInfos, e.g.,
|
2185
2191
|
* "<div style='text-align: left;'>{NAME}<br />{STREET}<br />{CITY}, {STATE} {ZIP} <br /></div>"
|
2186
|
-
* @return Label spec
|
2192
|
+
* @return Label spec with lines separated by `lineSeparatorChar`
|
2187
2193
|
*/
|
2188
2194
|
function _convertPopupTextToLabelSpec(popupInfo) {
|
2189
|
-
// Replace <br>, <br/> with
|
2190
|
-
popupInfo = popupInfo.replace(/<br\s*\/?>/gi,
|
2191
|
-
// Remove remaining HTML tags, replace 0xA0 that popup uses for spaces, replace some char representations,
|
2195
|
+
// Replace <br>, <br/> with the line separator character
|
2196
|
+
popupInfo = popupInfo.replace(/<br\s*\/?>/gi, lineSeparatorChar);
|
2197
|
+
// Remove remaining HTML tags, replace 0xA0 that popup uses for spaces, and replace some char representations,
|
2192
2198
|
// and split the label back into individual lines
|
2193
|
-
|
2199
|
+
const labelSpec = popupInfo
|
2194
2200
|
.replace(/<[\s.]*[^<>]*\/?>/gi, "")
|
2195
2201
|
.replace(/\xA0/gi, " ")
|
2196
2202
|
.replace(/</gi, "<")
|
2197
2203
|
.replace(/>/gi, ">")
|
2198
|
-
.replace(/ /gi, " ")
|
2199
|
-
.split("|");
|
2200
|
-
// Trim lines and remove empties
|
2201
|
-
labelSpec = labelSpec.map(line => line.trim()).filter(line => line.length > 0);
|
2204
|
+
.replace(/ /gi, " ");
|
2202
2205
|
return labelSpec;
|
2203
2206
|
}
|
2204
2207
|
/**
|
@@ -2217,7 +2220,7 @@ async function _createArcadeExecutors(labelFormat, layer) {
|
|
2217
2220
|
}
|
2218
2221
|
// Are there any Arcade expressions in the label format?
|
2219
2222
|
const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
|
2220
|
-
const arcadeExpressionsMatches = labelFormat.
|
2223
|
+
const arcadeExpressionsMatches = labelFormat.match(arcadeExpressionRegExp);
|
2221
2224
|
if (!arcadeExpressionsMatches) {
|
2222
2225
|
return Promise.resolve(arcadeExecutors);
|
2223
2226
|
}
|
@@ -2244,6 +2247,39 @@ async function _createArcadeExecutors(labelFormat, layer) {
|
|
2244
2247
|
return arcadeExecutors;
|
2245
2248
|
});
|
2246
2249
|
}
|
2250
|
+
/**
|
2251
|
+
* Prepares an attribute's value by applying domain and type information.
|
2252
|
+
*
|
2253
|
+
* @param attributeValue Value of attribute
|
2254
|
+
* @param attributeType Type of attribute
|
2255
|
+
* @param attributeDomain Domain info for attribute, if any
|
2256
|
+
* @return Attribute value modified appropriate to domain and type
|
2257
|
+
*/
|
2258
|
+
function _prepareAttributeValue(attributeValue, attributeType, attributeDomain, intl) {
|
2259
|
+
if (attributeDomain && attributeDomain.type === "coded-value") {
|
2260
|
+
// "coded-value" domain field
|
2261
|
+
const value = attributeDomain.getName(attributeValue);
|
2262
|
+
return value;
|
2263
|
+
}
|
2264
|
+
else {
|
2265
|
+
// Non-domain field or unsupported domain type
|
2266
|
+
let value = attributeValue;
|
2267
|
+
switch (attributeType) {
|
2268
|
+
case "date":
|
2269
|
+
// Format date produces odd characters for the space between the time and the AM/PM text,
|
2270
|
+
// e.g., "12/31/1969, 4:00 PM"
|
2271
|
+
value = intl.formatDate(value).replace(/\xe2\x80\xaf/g, "");
|
2272
|
+
break;
|
2273
|
+
case "double":
|
2274
|
+
case "integer":
|
2275
|
+
case "long":
|
2276
|
+
case "small-integer":
|
2277
|
+
value = intl.formatNumber(value);
|
2278
|
+
break;
|
2279
|
+
}
|
2280
|
+
return value;
|
2281
|
+
}
|
2282
|
+
}
|
2247
2283
|
/**
|
2248
2284
|
* Creates labels from items.
|
2249
2285
|
*
|
@@ -2260,6 +2296,13 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2260
2296
|
const [intl] = await loadModules(["esri/intl"]);
|
2261
2297
|
// Get the features to export
|
2262
2298
|
const featureSet = await queryFeaturesByID(ids, layer);
|
2299
|
+
// Get field data types. Do we have any domain-based fields?
|
2300
|
+
const attributeTypes = {};
|
2301
|
+
const attributeDomains = {};
|
2302
|
+
layer.fields.forEach(field => {
|
2303
|
+
attributeTypes[field.name] = field.type;
|
2304
|
+
attributeDomains[field.name] = field.domain;
|
2305
|
+
});
|
2263
2306
|
// Get the label formatting, if any
|
2264
2307
|
let labelFormat;
|
2265
2308
|
let arcadeExecutors = {};
|
@@ -2273,7 +2316,7 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2273
2316
|
// Can we use the popup title?
|
2274
2317
|
// eslint-disable-next-line unicorn/prefer-ternary
|
2275
2318
|
if (typeof layer.popupTemplate.title === "string") {
|
2276
|
-
labelFormat =
|
2319
|
+
labelFormat = layer.popupTemplate.title;
|
2277
2320
|
// Otherwise revert to using attributes
|
2278
2321
|
}
|
2279
2322
|
else {
|
@@ -2292,35 +2335,43 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2292
2335
|
// eslint-disable-next-line unicorn/prefer-ternary
|
2293
2336
|
if (labelFormat) {
|
2294
2337
|
const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
|
2295
|
-
|
2338
|
+
const attributeRegExp = /\{\w+\}/g;
|
2339
|
+
// Find the label fields that we need to replace with values
|
2340
|
+
const arcadeExpressionMatches = labelFormat.match(arcadeExpressionRegExp);
|
2341
|
+
const attributeMatches = labelFormat.match(attributeRegExp);
|
2342
|
+
// Convert feature attributes into an array of labels
|
2296
2343
|
labels = featureSet.features.map(feature => {
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2344
|
+
let labelPrep = labelFormat;
|
2345
|
+
// Replace Arcade expressions
|
2346
|
+
if (arcadeExpressionMatches) {
|
2347
|
+
arcadeExpressionMatches.forEach((match) => {
|
2348
|
+
const expressionName = match.substring(match.indexOf("/") + 1, match.length - 1);
|
2349
|
+
const value = arcadeExecutors[expressionName].execute({ "$feature": feature });
|
2350
|
+
labelPrep = labelPrep.replace(match, value);
|
2351
|
+
});
|
2352
|
+
}
|
2353
|
+
// Replace non-Arcade fields
|
2354
|
+
if (attributeMatches) {
|
2355
|
+
attributeMatches.forEach((match) => {
|
2356
|
+
const attributeName = match.substring(1, match.length - 1);
|
2357
|
+
const value = _prepareAttributeValue(feature.attributes[attributeName], attributeTypes[attributeName], attributeDomains[attributeName], intl);
|
2358
|
+
labelPrep = labelPrep.replace(match, value);
|
2359
|
+
});
|
2360
|
+
}
|
2361
|
+
// Split label into lines
|
2362
|
+
let label = labelPrep.split(lineSeparatorChar);
|
2363
|
+
// Trim lines
|
2364
|
+
label = label.map(line => line.trim());
|
2315
2365
|
return label;
|
2316
|
-
})
|
2317
|
-
// Remove empty labels
|
2318
|
-
.filter(label => label.length > 0);
|
2366
|
+
});
|
2319
2367
|
}
|
2320
2368
|
else {
|
2321
2369
|
// Export all attributes
|
2322
2370
|
labels = featureSet.features.map(feature => {
|
2323
|
-
return Object.
|
2371
|
+
return Object.keys(feature.attributes).map((attributeName) => {
|
2372
|
+
const value = _prepareAttributeValue(feature.attributes[attributeName], attributeTypes[attributeName], attributeDomains[attributeName], intl);
|
2373
|
+
return `${value}`;
|
2374
|
+
});
|
2324
2375
|
});
|
2325
2376
|
}
|
2326
2377
|
// Remove duplicates
|
@@ -2333,14 +2384,12 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2333
2384
|
if (includeHeaderNames) {
|
2334
2385
|
let headerNames = [];
|
2335
2386
|
if (labelFormat) {
|
2336
|
-
headerNames = labelFormat.
|
2387
|
+
headerNames = labelFormat.replace(/\{/g, "").replace(/\}/g, "").split(lineSeparatorChar);
|
2337
2388
|
}
|
2338
2389
|
else {
|
2339
2390
|
const featuresAttrs = featureSet.features[0].attributes;
|
2340
2391
|
Object.keys(featuresAttrs).forEach(k => {
|
2341
|
-
|
2342
|
-
headerNames.push(k);
|
2343
|
-
}
|
2392
|
+
headerNames.push(k);
|
2344
2393
|
});
|
2345
2394
|
}
|
2346
2395
|
labels.unshift(headerNames);
|
@@ -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-
|
7
|
+
import { _ as _typeof_1 } from './downloadUtils-a9b39194.js';
|
8
8
|
import './index-c246d90e.js';
|
9
9
|
import './loadModules-b299cd43.js';
|
10
10
|
import './locale-7bf10e0a.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-7bf10e0a.js';
|
8
8
|
import { g as goToSelection, a as getMapLayerView, q as queryAllFeatures } from './mapViewUtils-02696ab6.js';
|
9
|
-
import { d as downloadCSV } from './downloadUtils-
|
9
|
+
import { d as downloadCSV } from './downloadUtils-a9b39194.js';
|
10
10
|
import './_commonjsHelpers-d5f9d613.js';
|
11
11
|
import './interfaces-d0d83efa.js';
|
12
12
|
import './loadModules-b299cd43.js';
|
@@ -65,17 +65,9 @@ const PublicNotification = class {
|
|
65
65
|
* @returns Promise when complete
|
66
66
|
*/
|
67
67
|
async watchSearchConfigurationHandler(newValue, oldValue) {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
console.log("PN watchSearchConfigurationHandler");
|
72
|
-
console.log("PN newValue");
|
73
|
-
console.log(newValue);
|
74
|
-
console.log("PN oldValue");
|
75
|
-
console.log(oldValue);
|
76
|
-
if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
|
77
|
-
console.log("Emit event from parent");
|
78
|
-
this._searchConfiguration = Object.assign({}, newValue);
|
68
|
+
const s_newValue = JSON.stringify(newValue);
|
69
|
+
if (s_newValue !== JSON.stringify(oldValue)) {
|
70
|
+
this._searchConfiguration = JSON.parse(s_newValue);
|
79
71
|
this.searchConfigurationChange.emit(this._searchConfiguration);
|
80
72
|
}
|
81
73
|
}
|