@esri/solutions-components 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. package/dist/assets/arcgis-pdf-creator/PDFCreator.js +6 -3
  2. package/dist/assets/arcgis-pdf-creator/PDFCreator_jsPDF.js +1 -1
  3. package/dist/assets/arcgis-pdf-creator/PDFCreator_pdf_lib.js +1 -1
  4. package/dist/assets/arcgis-pdf-creator/PDFLabels.js +54 -3
  5. package/dist/assets/arcgis-pdf-creator/grid.js +1 -1
  6. package/dist/assets/data/images/grid.png +0 -0
  7. package/dist/assets/data/images/horizontal.png +0 -0
  8. package/dist/assets/data/images/vertical.png +0 -0
  9. package/dist/assets/t9n/crowdsource-manager/resources.json +7 -1
  10. package/dist/assets/t9n/crowdsource-manager/resources_en.json +7 -1
  11. package/dist/cjs/buffer-tools_6.cjs.entry.js +85 -85
  12. package/dist/cjs/{calcite-block_2.cjs.entry.js → calcite-action-bar_4.cjs.entry.js} +307 -18
  13. package/dist/cjs/{calcite-action.cjs.entry.js → calcite-action_2.cjs.entry.js} +84 -1
  14. package/dist/cjs/{calcite-combobox_3.cjs.entry.js → calcite-chip_4.cjs.entry.js} +187 -61
  15. package/dist/cjs/{calcite-dropdown-group_4.cjs.entry.js → calcite-dropdown_5.cjs.entry.js} +467 -1
  16. package/dist/cjs/calcite-input-message_5.cjs.entry.js +283 -283
  17. package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
  18. package/dist/cjs/{calcite-action-bar_2.cjs.entry.js → calcite-tooltip.cjs.entry.js} +2 -208
  19. package/dist/cjs/crowdsource-manager.cjs.entry.js +88 -14
  20. package/dist/cjs/{downloadUtils-b85476e8.js → downloadUtils-9359e9ff.js} +1218 -1127
  21. package/dist/cjs/{index.es-3ba50626.js → index.es-9c0d0ed6.js} +10682 -10682
  22. package/dist/cjs/{interfaces-17c631bf.js → interfaces-cac36920.js} +6 -0
  23. package/dist/cjs/layer-table_2.cjs.entry.js +512 -0
  24. package/dist/cjs/loader.cjs.js +30 -30
  25. package/dist/cjs/{mapViewUtils-df63bfa4.js → mapViewUtils-090f4d4d.js} +24 -24
  26. package/dist/cjs/public-notification.cjs.entry.js +69 -49
  27. package/dist/cjs/solution-configuration.cjs.entry.js +2 -2
  28. package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
  29. package/dist/cjs/{solution-store-b86759b2.js → solution-store-d28c332e.js} +1 -1
  30. package/dist/cjs/solutions-components.cjs.js +31 -31
  31. package/dist/collection/assets/arcgis-pdf-creator/PDFCreator.js +6 -3
  32. package/dist/collection/assets/arcgis-pdf-creator/PDFCreator_jsPDF.js +1 -1
  33. package/dist/collection/assets/arcgis-pdf-creator/PDFCreator_pdf_lib.js +1 -1
  34. package/dist/collection/assets/arcgis-pdf-creator/PDFLabels.js +54 -3
  35. package/dist/collection/assets/arcgis-pdf-creator/grid.js +1 -1
  36. package/dist/collection/components/crowdsource-manager/crowdsource-manager.css +122 -0
  37. package/dist/collection/components/crowdsource-manager/crowdsource-manager.js +130 -14
  38. package/dist/collection/components/layer-table/layer-table.css +2 -70
  39. package/dist/collection/components/layer-table/layer-table.js +66 -106
  40. package/dist/collection/components/map-card/map-card.css +4 -7
  41. package/dist/collection/components/map-card/map-card.js +44 -10
  42. package/dist/collection/components/map-draw-tools/map-draw-tools.js +1 -1
  43. package/dist/collection/components/map-select-tools/map-select-tools.js +1 -1
  44. package/dist/collection/components/public-notification/public-notification.js +45 -27
  45. package/dist/collection/components/refine-selection-tools/refine-selection-tools.js +1 -1
  46. package/dist/collection/demos/crowdsource-manager.html +14 -41
  47. package/dist/collection/utils/csvDownload.js +41 -0
  48. package/dist/collection/utils/csvDownload.ts +42 -0
  49. package/dist/collection/utils/csvUtils.js +6 -23
  50. package/dist/collection/utils/csvUtils.ts +8 -27
  51. package/dist/collection/utils/downloadUtils.js +30 -14
  52. package/dist/collection/utils/downloadUtils.ts +36 -14
  53. package/dist/collection/utils/interfaces.js +6 -0
  54. package/dist/collection/utils/interfaces.ts +6 -0
  55. package/dist/collection/utils/pdfUtils.js +9 -6
  56. package/dist/collection/utils/pdfUtils.ts +13 -8
  57. package/dist/collection/utils/test/csvUtils.spec.tsx +56 -0
  58. package/dist/collection/utils/test/downloadUtils.spec.tsx +133 -0
  59. package/dist/components/crowdsource-manager.js +293 -17
  60. package/dist/components/downloadUtils.js +133 -42
  61. package/dist/components/interfaces3.js +7 -1
  62. package/dist/components/layer-table.js +1 -443
  63. package/dist/components/layer-table2.js +429 -0
  64. package/dist/components/map-card.js +1 -339
  65. package/dist/{esm/map-card.entry.js → components/map-card2.js} +118 -22
  66. package/dist/components/map-draw-tools2.js +16 -16
  67. package/dist/components/map-layer-picker2.js +1 -1
  68. package/dist/components/map-select-tools2.js +38 -38
  69. package/dist/components/public-notification.js +102 -82
  70. package/dist/components/queryUtils.js +10 -10
  71. package/dist/components/refine-selection-tools2.js +3 -3
  72. package/dist/components/refine-selection2.js +1 -1
  73. package/dist/components/solution-resource-item2.js +1 -1
  74. package/dist/components/solution-store.js +1 -1
  75. package/dist/esm/buffer-tools_6.entry.js +76 -76
  76. package/dist/esm/{calcite-block_2.entry.js → calcite-action-bar_4.entry.js} +307 -20
  77. package/dist/esm/{calcite-action.entry.js → calcite-action_2.entry.js} +84 -2
  78. package/dist/esm/{calcite-combobox_3.entry.js → calcite-chip_4.entry.js} +181 -56
  79. package/dist/esm/{calcite-dropdown-group_4.entry.js → calcite-dropdown_5.entry.js} +468 -3
  80. package/dist/esm/calcite-input-message_5.entry.js +275 -275
  81. package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
  82. package/dist/esm/{calcite-action-bar_2.entry.js → calcite-tooltip.entry.js} +4 -209
  83. package/dist/esm/crowdsource-manager.entry.js +88 -14
  84. package/dist/esm/{downloadUtils-f278742f.js → downloadUtils-a8f139c5.js} +1214 -1123
  85. package/dist/esm/{index.es-6f3a1143.js → index.es-a75412ff.js} +10596 -10596
  86. package/dist/esm/{interfaces-d0d83efa.js → interfaces-cd4054e5.js} +7 -1
  87. package/dist/esm/layer-table_2.entry.js +507 -0
  88. package/dist/esm/loader.js +26 -26
  89. package/dist/esm/{mapViewUtils-bd1809f0.js → mapViewUtils-8ffcd36d.js} +12 -12
  90. package/dist/esm/public-notification.entry.js +65 -45
  91. package/dist/esm/solution-configuration.entry.js +2 -2
  92. package/dist/esm/solution-contents_3.entry.js +2 -2
  93. package/dist/esm/{solution-store-477288ac.js → solution-store-1b67f2c8.js} +1 -1
  94. package/dist/esm/solutions-components.js +26 -26
  95. package/dist/solutions-components/demos/crowdsource-manager.html +14 -41
  96. package/dist/solutions-components/{p-dd11eeb2.js → p-1395b0ef.js} +1 -1
  97. package/dist/solutions-components/{p-cbac29fb.entry.js → p-1affd711.entry.js} +18 -18
  98. package/dist/solutions-components/p-30de8da1.entry.js +17 -0
  99. package/dist/solutions-components/{p-91cad71e.entry.js → p-439c878d.entry.js} +3 -9
  100. package/dist/solutions-components/{p-03e2c6fd.js → p-765a27f3.js} +60 -60
  101. package/dist/solutions-components/p-813a04c3.entry.js +6 -0
  102. package/dist/solutions-components/{p-9e8a371f.entry.js → p-874b39a7.entry.js} +3 -3
  103. package/dist/solutions-components/p-8cece97f.js +21 -0
  104. package/dist/solutions-components/{p-dd0241fb.entry.js → p-97aa7211.entry.js} +1 -1
  105. package/dist/solutions-components/{p-0e459cc7.entry.js → p-a955a3e6.entry.js} +10 -4
  106. package/dist/solutions-components/{p-40c12650.js → p-bb64bd47.js} +453 -437
  107. package/dist/solutions-components/{p-70e1d4d8.entry.js → p-c392dd95.entry.js} +17 -17
  108. package/dist/solutions-components/p-ca386a72.entry.js +6 -0
  109. package/dist/solutions-components/p-d47d74a6.entry.js +23 -0
  110. package/dist/solutions-components/p-db846ee2.entry.js +11 -0
  111. package/dist/solutions-components/{p-88e5a76d.js → p-dc53c9c1.js} +36 -36
  112. package/dist/solutions-components/p-e1c93241.entry.js +6 -0
  113. package/dist/solutions-components/{p-4cbaf0f1.entry.js → p-e6d235d6.entry.js} +1 -1
  114. package/dist/solutions-components/solutions-components.esm.js +6 -6
  115. package/dist/solutions-components/utils/csvDownload.ts +42 -0
  116. package/dist/solutions-components/utils/csvUtils.ts +8 -27
  117. package/dist/solutions-components/utils/downloadUtils.ts +36 -14
  118. package/dist/solutions-components/utils/interfaces.ts +6 -0
  119. package/dist/solutions-components/utils/pdfUtils.ts +13 -8
  120. package/dist/solutions-components/utils/test/csvUtils.spec.tsx +56 -0
  121. package/dist/solutions-components/utils/test/downloadUtils.spec.tsx +133 -0
  122. package/dist/types/components/crowdsource-manager/crowdsource-manager.d.ts +39 -0
  123. package/dist/types/components/layer-table/layer-table.d.ts +35 -48
  124. package/dist/types/components/map-card/map-card.d.ts +10 -6
  125. package/dist/types/components/public-notification/public-notification.d.ts +18 -6
  126. package/dist/types/components.d.ts +1621 -1601
  127. package/dist/types/preact.d.ts +2 -1
  128. package/dist/types/utils/csvDownload.d.ts +24 -0
  129. package/dist/types/utils/csvUtils.d.ts +2 -1
  130. package/dist/types/utils/downloadUtils.d.ts +25 -0
  131. package/dist/types/utils/interfaces.d.ts +5 -0
  132. package/dist/types/utils/pdfUtils.d.ts +2 -1
  133. package/package.json +4 -4
  134. package/dist/cjs/calcite-chip.cjs.entry.js +0 -142
  135. package/dist/cjs/calcite-dropdown.cjs.entry.js +0 -481
  136. package/dist/cjs/calcite-handle.cjs.entry.js +0 -99
  137. package/dist/cjs/calcite-loader.cjs.entry.js +0 -95
  138. package/dist/cjs/layer-table.cjs.entry.js +0 -317
  139. package/dist/cjs/map-card.cjs.entry.js +0 -252
  140. package/dist/esm/calcite-chip.entry.js +0 -138
  141. package/dist/esm/calcite-dropdown.entry.js +0 -477
  142. package/dist/esm/calcite-handle.entry.js +0 -95
  143. package/dist/esm/calcite-loader.entry.js +0 -91
  144. package/dist/esm/layer-table.entry.js +0 -313
  145. package/dist/solutions-components/p-045d3988.entry.js +0 -12
  146. package/dist/solutions-components/p-11132485.entry.js +0 -11
  147. package/dist/solutions-components/p-15b43c29.entry.js +0 -11
  148. package/dist/solutions-components/p-5034aabc.entry.js +0 -11
  149. package/dist/solutions-components/p-6f012424.entry.js +0 -6
  150. package/dist/solutions-components/p-7fd10eb3.entry.js +0 -11
  151. package/dist/solutions-components/p-a57ef371.entry.js +0 -6
  152. package/dist/solutions-components/p-bc39f296.entry.js +0 -6
  153. package/dist/solutions-components/p-c93d8e80.entry.js +0 -6
  154. package/dist/solutions-components/p-dbc9a5a8.js +0 -21
  155. package/dist/solutions-components/p-f5c70be2.entry.js +0 -6
  156. package/dist/solutions-components/p-f6b17cc6.entry.js +0 -11
@@ -24,32 +24,19 @@ import { e as queryFeaturesByID } from './queryUtils.js';
24
24
  * limitations under the License.
25
25
  */
26
26
  //#region Public functions
27
- /**
28
- * Export a csv of the attributes from the features that match the provided ids
29
- *
30
- * @param labels Labels to write
31
- */
32
- function exportCSV(labels) {
33
- // Format values to string so it doesn't get tripped up when a value has a comma
34
- // another option could be to export with a different delimiter
35
- const outputLines = labels.map(label => Object.values(label).map(v => `"${v}"`).join(",") + "\r\n");
36
- _downloadCSVFile(outputLines, `notify-${Date.now().toString()}`);
37
- }
38
- //#endregion
39
- //#region Private functions
40
27
  /**
41
28
  * Download the CSV file
42
29
  *
30
+ * @param title Title (without file extension) to use for file; defaults to "export"
43
31
  * @param outputLines Lines of output to write to file
44
- * @param fileTitle Title (without file extension) to use for file; defaults to "export"
45
32
  *
46
33
  * @see {@link https://medium.com/@danny.pule/export-json-to-csv-file-using-javascript-a0b7bc5b00d2}
47
34
  */
48
- function _downloadCSVFile(outputLines, fileTitle) {
35
+ function downloadCSVFile(title, outputLines) {
49
36
  const link = document.createElement("a");
50
37
  if (link.download !== undefined) {
51
38
  link.href = URL.createObjectURL(new Blob(outputLines, { type: "text/csv;charset=utf-8;" }));
52
- link.download = `${fileTitle}.csv` || "export.csv";
39
+ link.download = `${title}.csv` || "export.csv";
53
40
  link.style.visibility = "hidden";
54
41
  document.body.appendChild(link);
55
42
  link.click();
@@ -58,6 +45,37 @@ function _downloadCSVFile(outputLines, fileTitle) {
58
45
  }
59
46
  //#endregion
60
47
 
48
+ /** @license
49
+ * Copyright 2022 Esri
50
+ *
51
+ * Licensed under the Apache License, Version 2.0 (the "License");
52
+ * you may not use this file except in compliance with the License.
53
+ * You may obtain a copy of the License at
54
+ *
55
+ * http://www.apache.org/licenses/LICENSE-2.0
56
+ *
57
+ * Unless required by applicable law or agreed to in writing, software
58
+ * distributed under the License is distributed on an "AS IS" BASIS,
59
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
60
+ * See the License for the specific language governing permissions and
61
+ * limitations under the License.
62
+ */
63
+ //#endregion
64
+ //#region Public functions
65
+ /**
66
+ * Export a csv of the attributes from the features that match the provided ids
67
+ *
68
+ * @param title Title to use for file
69
+ * @param labels Labels to write
70
+ */
71
+ function exportCSV(title, labels) {
72
+ // Format values to string so it doesn't get tripped up when a value has a comma
73
+ // another option could be to export with a different delimiter
74
+ const outputLines = labels.map(label => Object.values(label).map(v => `"${v}"`).join(",") + "\r\n");
75
+ downloadCSVFile(title, outputLines);
76
+ }
77
+ //#endregion
78
+
61
79
  var _typeof_1 = createCommonjsModule(function (module) {
62
80
  function _typeof(obj) {
63
81
  "@babel/helpers - typeof";
@@ -1124,7 +1142,7 @@ function(t){t.__bidiEngine__=t.prototype.__bidiEngine__=function(t){var r,n,i,a,
1124
1142
 
1125
1143
  /* @preserve
1126
1144
  * arcgis-pdf-creator v0.0.1
1127
- * Fri Feb 03 2023 09:47:02 GMT-0800 (Pacific Standard Time)
1145
+ * Tue Mar 21 2023 10:44:29 GMT-0700 (Pacific Daylight Time)
1128
1146
  */
1129
1147
  /** @license
1130
1148
  * Copyright 2022 Esri
@@ -1399,13 +1417,16 @@ class PDFCreator {
1399
1417
  *
1400
1418
  * @param text String to estimate
1401
1419
  * @param fontSize Text size in points
1402
- * @returns Estimated width of text in doc units
1420
+ * @returns Estimated width of text using (points x 1/72 inches/point) * 0.6;
1421
+ * need to override this generalized function with a specific PDF generator;
1422
+ * the 0.6 width:height ratio comes from https://www.fhwa.dot.gov/publications/research/safety/98057/ch03.cfm#width
1403
1423
  *
1404
1424
  * @class PDFCreator
1405
1425
  */
1406
1426
  getTextWidth(text, fontSize) {
1427
+ const ratioWidthToHeight = 0.6;
1407
1428
  // Return a value for testing
1408
- return text.length * fontSize;
1429
+ return text.length * fontSize * this.fontProps.fontResolutionInchesPerPoint * ratioWidthToHeight;
1409
1430
  }
1410
1431
  /**
1411
1432
  * @class PDFCreator
@@ -1513,7 +1534,7 @@ class PDFCreator {
1513
1534
 
1514
1535
  /* @preserve
1515
1536
  * arcgis-pdf-creator v0.0.1
1516
- * Fri Feb 03 2023 09:47:02 GMT-0800 (Pacific Standard Time)
1537
+ * Tue Mar 21 2023 10:44:29 GMT-0700 (Pacific Daylight Time)
1517
1538
  */
1518
1539
 
1519
1540
  /** @license
@@ -1741,7 +1762,7 @@ class PDFCreator_jsPDF extends PDFCreator {
1741
1762
 
1742
1763
  /* @preserve
1743
1764
  * arcgis-pdf-creator v0.0.1
1744
- * Fri Feb 03 2023 09:47:02 GMT-0800 (Pacific Standard Time)
1765
+ * Tue Mar 21 2023 10:44:29 GMT-0700 (Pacific Daylight Time)
1745
1766
  */
1746
1767
  /** @license
1747
1768
  * Copyright 2022 Esri
@@ -1804,7 +1825,7 @@ function drawGridOfBoxes(PDFCreator, options = {
1804
1825
 
1805
1826
  /* @preserve
1806
1827
  * arcgis-pdf-creator v0.0.1
1807
- * Fri Feb 03 2023 09:47:02 GMT-0800 (Pacific Standard Time)
1828
+ * Tue Mar 21 2023 10:44:29 GMT-0700 (Pacific Daylight Time)
1808
1829
  */
1809
1830
 
1810
1831
  /** @license
@@ -1831,12 +1852,13 @@ class PDFLabels {
1831
1852
  * @param labels Array of labels; each label consists of one or more line strings
1832
1853
  * @param labelSpec Properties describing page dimensions of labels sheet
1833
1854
  * @param startingPageNum The 1-based page number to start printing labels into; page is assumed to be blank & to exist
1855
+ * @param heading Line to add at top of label page outside of labels
1834
1856
  * @param progressCallback Callback with percent done in range 0..100
1835
1857
  * @returns Promise which, when resolved, returns the 1-based page number of the last page containing labels
1836
1858
  *
1837
1859
  * @class PDFLabels
1838
1860
  */
1839
- addLabelsToDoc(labels, labelSpec, startingPageNum, progressCallback) {
1861
+ addLabelsToDoc(labels, labelSpec, startingPageNum, heading, progressCallback) {
1840
1862
  return new Promise((resolve) => {
1841
1863
  const labelsPerPageDisplay = labelSpec.numLabelsAcross * labelSpec.numLabelsDown;
1842
1864
  let column;
@@ -1847,6 +1869,9 @@ class PDFLabels {
1847
1869
  // Draw
1848
1870
  let currentPageNum = startingPageNum;
1849
1871
  const topOfFirstLabel = labelSpec.pageProperties.topMargin - this.PDFCreator.pageOptions.topMargin;
1872
+ if (heading) {
1873
+ this._drawSupplementalText(heading, 0, -0.1);
1874
+ }
1850
1875
  for (let iLabel = 0, iNonBlankLabel = 0; iLabel < labels.length; iLabel++) {
1851
1876
  if (progressCallback) {
1852
1877
  progressCallback(Math.round(iLabel / labels.length * 100));
@@ -1862,6 +1887,9 @@ class PDFLabels {
1862
1887
  // Advance to next page
1863
1888
  this.PDFCreator.addPage();
1864
1889
  ++currentPageNum;
1890
+ if (heading) {
1891
+ this._drawSupplementalText(heading, 0, -0.1);
1892
+ }
1865
1893
  }
1866
1894
  // Prep the new page
1867
1895
  column = 0;
@@ -1874,11 +1902,14 @@ class PDFLabels {
1874
1902
  row = 0;
1875
1903
  }
1876
1904
  // Draw the label
1905
+ const minimumFontSize = 4;
1877
1906
  // Temporarily reduce the font size if we have more lines than the label can hold
1878
1907
  let fontPoints = labelSpec.fontSizePx;
1879
1908
  if (labelSpec.maxNumLabelLines < labelLines.length) {
1880
- fontPoints = Math.floor(labelSpec.maxNumLabelLines / labelLines.length * labelSpec.fontSizePx);
1909
+ fontPoints = Math.max(Math.floor(labelSpec.maxNumLabelLines / labelLines.length * labelSpec.fontSizePx), minimumFontSize);
1881
1910
  }
1911
+ // Temporarily reduce the font size farther if label lines are too long
1912
+ fontPoints = this._getFontSizeForOverlongLines(labelLines, maxLabelTextWidth, fontPoints, minimumFontSize);
1882
1913
  // Clip overlong lines; append ellipses to clipped lines
1883
1914
  labelLines = this._clipOverlongLines(labelLines, maxLabelTextWidth, fontPoints);
1884
1915
  const labelLineHeight = this.PDFCreator.fontAscenderDescenderHeight(fontPoints);
@@ -2040,6 +2071,47 @@ class PDFLabels {
2040
2071
  });
2041
2072
  return trimmedLines;
2042
2073
  }
2074
+ /**
2075
+ * Draws supplemental text such as a heading or footer.
2076
+ *
2077
+ * @param text Text to draw
2078
+ * @param left Offset from left edge of document to left edge of text
2079
+ * @param top Offset from top of document to top of text
2080
+ */
2081
+ _drawSupplementalText(text, left, top) {
2082
+ const fontPoints = 6;
2083
+ this.PDFCreator.drawText(text, {
2084
+ left,
2085
+ top,
2086
+ fontPoints,
2087
+ fontColor: "000000"
2088
+ });
2089
+ }
2090
+ /**
2091
+ * Trims a set of text lines to fit within specified bounds.
2092
+ *
2093
+ * @param lines Text lines to be checked
2094
+ * @param maxTextWidth The maximum width permitted for the drawing of the text in doc units
2095
+ * @param preferredFontSize Initial text size in points
2096
+ * @param minimumFontSize The smallest acceptable font size in points
2097
+ * @returns The maximum of `minimumFontSize` and the font size in points that should help all lines
2098
+ * of the label to fit on the label
2099
+ *
2100
+ * @class PDFLabels
2101
+ * @private
2102
+ */
2103
+ _getFontSizeForOverlongLines(lines, maxTextWidth, preferredFontSize, minimumFontSize) {
2104
+ let fontSize = preferredFontSize;
2105
+ lines.forEach(line => {
2106
+ line = line.trim();
2107
+ if (this.PDFCreator.getTextWidth(line, fontSize) > maxTextWidth) {
2108
+ do {
2109
+ --fontSize;
2110
+ } while (this.PDFCreator.getTextWidth(line, fontSize) > maxTextWidth && fontSize > minimumFontSize);
2111
+ }
2112
+ });
2113
+ return fontSize;
2114
+ }
2043
2115
  /**
2044
2116
  * Loads the label formats.
2045
2117
  *
@@ -2076,31 +2148,34 @@ class PDFLabels {
2076
2148
  /**
2077
2149
  * Exports a PDF of labels.
2078
2150
  *
2151
+ * @param title Title to use for file
2079
2152
  * @param labels Labels to write
2080
2153
  * @param labelPageDescription Page format to use for labels
2081
2154
  */
2082
- function exportPDF(labels, labelPageDescription) {
2083
- _downloadPDFFile(labels, labelPageDescription, `notify-${Date.now().toString()}`);
2155
+ function exportPDF(title, labels, labelPageDescription) {
2156
+ downloadPDFFile(title, labels, labelPageDescription);
2084
2157
  }
2085
2158
  //#endregion
2086
2159
  //#region Private functions
2087
2160
  /**
2088
2161
  * Downloads the PDF file.
2089
2162
  *
2163
+ * @param title Title (without file extension) to use for file; defaults to "export"
2090
2164
  * @param labels Labels to write
2091
2165
  * @param labelPageDescription Page format to use for labels
2092
- * @param fileTitle Title (without file extension) to use for file; defaults to "export"
2093
2166
  */
2094
- function _downloadPDFFile(labels, labelPageDescription, fileTitle) {
2167
+ function downloadPDFFile(title, labels, labelPageDescription) {
2095
2168
  const pdfLib = new PDFCreator_jsPDF();
2096
2169
  pdfLib.initialize({
2097
2170
  pageType: "ANSI_A"
2098
- }, getAssetPath(`../assets/arcgis-pdf-creator/`), "en", fileTitle, false)
2171
+ }, getAssetPath(`../assets/arcgis-pdf-creator/`), "en", title)
2099
2172
  .then(() => {
2100
2173
  const labeller = new PDFLabels();
2101
2174
  labeller.initialize(pdfLib)
2102
2175
  .then(async () => {
2103
- await labeller.addLabelsToDoc(labels, labelPageDescription.labelSpec, 1);
2176
+ await labeller.addLabelsToDoc(labels, labelPageDescription.labelSpec, 1, // startingPageNum
2177
+ title // heading
2178
+ );
2104
2179
  pdfLib.save();
2105
2180
  });
2106
2181
  });
@@ -2138,10 +2213,8 @@ const lineSeparatorChar = "|";
2138
2213
  * @returns Promise resolving when function is done
2139
2214
  */
2140
2215
  async function downloadCSV(selectionSetNames, layer, ids, formatUsingLayerPopup, removeDuplicates = false, addColumnTitle = false) {
2141
- console.log("downloadCSV using selectionSetNames " + JSON.stringify(selectionSetNames)); //???
2142
- console.log("downloadCSV removeDuplicates", removeDuplicates); //???
2143
2216
  const labels = await _prepareLabels(layer, ids, removeDuplicates, formatUsingLayerPopup, addColumnTitle);
2144
- exportCSV(labels);
2217
+ exportCSV(_createTitle(selectionSetNames), labels);
2145
2218
  return Promise.resolve();
2146
2219
  }
2147
2220
  /**
@@ -2155,15 +2228,13 @@ async function downloadCSV(selectionSetNames, layer, ids, formatUsingLayerPopup,
2155
2228
  * @returns Promise resolving when function is done
2156
2229
  */
2157
2230
  async function downloadPDF(selectionSetNames, layer, ids, removeDuplicates, labelPageDescription) {
2158
- console.log("downloadPDF using selectionSetNames " + JSON.stringify(selectionSetNames)); //???
2159
- console.log("downloadPDF removeDuplicates", removeDuplicates); //???
2160
2231
  let labels = await _prepareLabels(layer, ids, removeDuplicates);
2161
2232
  labels =
2162
2233
  // Remove empty lines in labels
2163
2234
  labels.map(labelLines => labelLines.filter(line => line.length > 0))
2164
2235
  // Remove empty labels
2165
2236
  .filter(label => label.length > 0);
2166
- exportPDF(labels, labelPageDescription);
2237
+ exportPDF(_createTitle(selectionSetNames), labels, labelPageDescription);
2167
2238
  return Promise.resolve();
2168
2239
  }
2169
2240
  //#endregion
@@ -2200,17 +2271,25 @@ function _convertPopupTextToLabelSpec(popupInfo) {
2200
2271
  popupInfo = popupInfo.replace(/<p[^>]*>/gi, lineSeparatorChar).trim().replace(/^\|/, "");
2201
2272
  // Remove </p>
2202
2273
  popupInfo = popupInfo.replace(/<\/p>/gi, "");
2203
- // Remove \n
2204
- popupInfo = popupInfo.replace(/\n/gi, "");
2205
- // Remove remaining HTML tags, replace 0xA0 that popup uses for spaces, and replace some char representations,
2206
- // and split the label back into individual lines
2207
- const labelSpec = popupInfo
2274
+ // Replace \n with the line separator character
2275
+ popupInfo = popupInfo.replace(/\n/gi, "|");
2276
+ // Remove remaining HTML tags, replace 0xA0 that popup uses for spaces, and replace some char representations
2277
+ let labelSpec = popupInfo
2208
2278
  .replace(/<[\s.]*[^<>]*\/?>/gi, "")
2209
2279
  .replace(/\xA0/gi, " ")
2210
2280
  .replace(/&lt;/gi, "<")
2211
2281
  .replace(/&gt;/gi, ">")
2212
2282
  .replace(/&nbsp;/gi, " ");
2213
- return labelSpec;
2283
+ // Trim each line
2284
+ labelSpec = labelSpec.replace(/\s*\|\s*/g, "|");
2285
+ // Remove empty lines
2286
+ while (labelSpec.match(/\|\|/)) {
2287
+ labelSpec = labelSpec.replace(/\|\|/, "|");
2288
+ }
2289
+ // Remove leading and trailing line feeds
2290
+ labelSpec = labelSpec.replace(/^\|/, "");
2291
+ labelSpec = labelSpec.replace(/\|$/, "");
2292
+ return labelSpec.trim();
2214
2293
  }
2215
2294
  /**
2216
2295
  * Extracts Arcade expressions from the lines of a label format and creates an Arcade executor for each
@@ -2274,6 +2353,18 @@ async function _createArcadeExecutors(labelFormat, layer) {
2274
2353
  return arcadeExecutors;
2275
2354
  });
2276
2355
  }
2356
+ /**
2357
+ * Creates a title from a list of selection set names.
2358
+ *
2359
+ * @param selectionSetNames Names to use in title
2360
+ * @return Title composed of the selectionSetNames separated by commas; if there are no
2361
+ * selection set names supplied, "download" is returned
2362
+ */
2363
+ function _createTitle(selectionSetNames) {
2364
+ // Windows doesn't permit the characters \/:*?"<>|
2365
+ const title = selectionSetNames.length > 0 ? selectionSetNames.join(", ") : "download";
2366
+ return title;
2367
+ }
2277
2368
  /**
2278
2369
  * Prepares an attribute's value by applying domain and type information.
2279
2370
  *
@@ -18,6 +18,12 @@
18
18
  * See the License for the specific language governing permissions and
19
19
  * limitations under the License.
20
20
  */
21
+ var ELayoutMode;
22
+ (function (ELayoutMode) {
23
+ ELayoutMode["GRID"] = "GRID";
24
+ ELayoutMode["HORIZONTAL"] = "HORIZONTAL";
25
+ ELayoutMode["VERTICAL"] = "VERTICAL";
26
+ })(ELayoutMode || (ELayoutMode = {}));
21
27
  /**
22
28
  * Resource update types
23
29
  */
@@ -77,4 +83,4 @@ var EExpandType;
77
83
  EExpandType["COLLAPSE"] = "COLLAPSE";
78
84
  })(EExpandType || (EExpandType = {}));
79
85
 
80
- export { EExpandType as E, EPageType as a, ESketchType as b, EWorkflowType as c, EExportType as d, ESelectionMode as e, ERefineMode as f, ESelectionType as g, EUpdateType as h };
86
+ export { ELayoutMode as E, EPageType as a, ESketchType as b, EWorkflowType as c, EExportType as d, EExpandType as e, ESelectionMode as f, ERefineMode as g, ESelectionType as h, EUpdateType as i };