@arcgis/common-components 4.29.0-beta.42 → 4.29.0-beta.44

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 (128) hide show
  1. package/dist/arcgis-common-components/arcgis-common-components.esm.js +1 -1
  2. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ar.json +78 -0
  3. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.bg.json +78 -0
  4. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.bs.json +78 -0
  5. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ca.json +78 -0
  6. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.cs.json +78 -0
  7. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.da.json +78 -0
  8. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.de.json +78 -0
  9. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.el.json +78 -0
  10. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.en.json +78 -0
  11. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.es.json +78 -0
  12. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.et.json +78 -0
  13. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.fi.json +78 -0
  14. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.fr.json +78 -0
  15. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.he.json +78 -0
  16. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.hr.json +78 -0
  17. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.hu.json +78 -0
  18. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.id.json +78 -0
  19. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.it.json +78 -0
  20. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ja.json +78 -0
  21. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ko.json +78 -0
  22. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.lt.json +78 -0
  23. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.lv.json +78 -0
  24. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.nb.json +78 -0
  25. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.nl.json +78 -0
  26. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.pl.json +78 -0
  27. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.pt-BR.json +78 -0
  28. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.pt-PT.json +78 -0
  29. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ro.json +78 -0
  30. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ru.json +78 -0
  31. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sk.json +78 -0
  32. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sl.json +78 -0
  33. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sr.json +78 -0
  34. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sv.json +78 -0
  35. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.th.json +78 -0
  36. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.tr.json +78 -0
  37. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.uk.json +78 -0
  38. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.vi.json +78 -0
  39. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.zh-CN.json +78 -0
  40. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.zh-HK.json +78 -0
  41. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.zh-TW.json +78 -0
  42. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ar.json +17 -0
  43. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.bg.json +17 -0
  44. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.bs.json +17 -0
  45. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ca.json +17 -0
  46. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.cs.json +17 -0
  47. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.da.json +17 -0
  48. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.de.json +17 -0
  49. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.el.json +17 -0
  50. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.en.json +17 -0
  51. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.es.json +17 -0
  52. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.et.json +17 -0
  53. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.fi.json +17 -0
  54. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.fr.json +17 -0
  55. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.he.json +17 -0
  56. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.hr.json +17 -0
  57. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.hu.json +17 -0
  58. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.id.json +17 -0
  59. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.it.json +17 -0
  60. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ja.json +17 -0
  61. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ko.json +17 -0
  62. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.lt.json +17 -0
  63. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.lv.json +17 -0
  64. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.nb.json +17 -0
  65. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.nl.json +17 -0
  66. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.pl.json +17 -0
  67. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.pt-BR.json +17 -0
  68. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.pt-PT.json +17 -0
  69. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ro.json +17 -0
  70. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ru.json +17 -0
  71. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sk.json +17 -0
  72. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sl.json +17 -0
  73. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sr.json +17 -0
  74. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sv.json +17 -0
  75. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.th.json +17 -0
  76. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.tr.json +17 -0
  77. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.uk.json +17 -0
  78. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.vi.json +17 -0
  79. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.zh-CN.json +17 -0
  80. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.zh-HK.json +17 -0
  81. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.zh-TW.json +17 -0
  82. package/dist/arcgis-common-components/p-0a9f9233.entry.js +1 -0
  83. package/dist/arcgis-common-components/p-19ebc914.js +1 -0
  84. package/dist/arcgis-common-components/p-20e63d91.entry.js +1 -0
  85. package/dist/arcgis-common-components/p-b23318c8.js +1 -0
  86. package/dist/arcgis-common-components/{p-d868f293.entry.js → p-b98229f1.entry.js} +1 -1
  87. package/dist/arcgis-common-components/p-bc099d11.entry.js +1 -0
  88. package/dist/arcgis-common-components/p-f27af39c.js +2 -0
  89. package/dist/cjs/arcgis-api-key.cjs.entry.js +2 -2
  90. package/dist/cjs/arcgis-common-components.cjs.js +2 -2
  91. package/dist/cjs/arcgis-field-info.cjs.entry.js +1021 -0
  92. package/dist/cjs/arcgis-field-pick-list.cjs.entry.js +258 -0
  93. package/dist/cjs/arcgis-identity.cjs.entry.js +2 -2
  94. package/dist/cjs/{index-9962d715.js → index-81d57760.js} +40 -0
  95. package/dist/cjs/{index-693a0aa8.js → index-ab5f2576.js} +870 -4
  96. package/dist/cjs/index-f8bf4df6.js +7 -0
  97. package/dist/cjs/loader.cjs.js +2 -2
  98. package/dist/components/arcgis-field-info.d.ts +11 -0
  99. package/dist/components/arcgis-field-info.js +6 -0
  100. package/dist/components/arcgis-field-pick-list.d.ts +11 -0
  101. package/dist/components/arcgis-field-pick-list.js +314 -0
  102. package/dist/components/arcgis-identity.js +1 -1
  103. package/dist/components/field-info.js +1048 -0
  104. package/dist/components/index2.js +36 -1
  105. package/dist/esm/arcgis-api-key.entry.js +2 -2
  106. package/dist/esm/arcgis-common-components.js +3 -3
  107. package/dist/esm/arcgis-field-info.entry.js +1017 -0
  108. package/dist/esm/arcgis-field-pick-list.entry.js +254 -0
  109. package/dist/esm/arcgis-identity.entry.js +2 -2
  110. package/dist/esm/{index-00709df9.js → index-74897166.js} +867 -5
  111. package/dist/esm/index-877e3851.js +75 -0
  112. package/dist/esm/index-e7244815.js +3 -0
  113. package/dist/esm/loader.js +3 -3
  114. package/dist/types/components/field-info/field-info.d.ts +68 -0
  115. package/dist/types/components/field-info/t9n-types.d.ts +82 -0
  116. package/dist/types/components/field-info/utils/basic.d.ts +44 -0
  117. package/dist/types/components/field-info/utils/feature.d.ts +17 -0
  118. package/dist/types/components/field-info/utils/field.d.ts +25 -0
  119. package/dist/types/components/field-info/utils/index.d.ts +3 -0
  120. package/dist/types/components/field-pick-list/field-pick-list.d.ts +122 -0
  121. package/dist/types/components/field-pick-list/t9n-types.d.ts +17 -0
  122. package/dist/types/components/field-pick-list/utils/types.d.ts +25 -0
  123. package/dist/types/components.d.ts +270 -0
  124. package/package.json +9 -9
  125. package/dist/arcgis-common-components/p-02d347bb.entry.js +0 -1
  126. package/dist/arcgis-common-components/p-2a7fe37a.js +0 -2
  127. package/dist/arcgis-common-components/p-5d6c7dd8.js +0 -1
  128. package/dist/esm/index-2ba2e62a.js +0 -40
@@ -0,0 +1,1017 @@
1
+ import { r as registerInstance, c as createEvent, a as getAssetPath, h, H as Host, g as getElement, F as Fragment } from './index-74897166.js';
2
+ import { d as importCoreLang, i as importConfig, a as importIntl, e as importRestSupportQuery, f as importSmartMappingStatisticsSummaryStatistics, g as importSmartMappingStatisticsUniqueValues, b as importCoreReactiveUtils } from './index-877e3851.js';
3
+ import { F, U } from './index-e7244815.js';
4
+
5
+ var Status;
6
+ (function (Status) {
7
+ Status["MISSING"] = "missing";
8
+ Status["IN_PROGRESS"] = "inProgress";
9
+ Status["SUCCESS"] = "success";
10
+ Status["FAILED"] = "failed";
11
+ })(Status || (Status = {}));
12
+ var SimpleFieldTypes;
13
+ (function (SimpleFieldTypes) {
14
+ SimpleFieldTypes["NUMBER"] = "number";
15
+ SimpleFieldTypes["STRING"] = "string";
16
+ SimpleFieldTypes["DATE"] = "date";
17
+ SimpleFieldTypes["DATE_ONLY"] = "date-only";
18
+ SimpleFieldTypes["TIME_ONLY"] = "time-only";
19
+ SimpleFieldTypes["TIMESTAMP_OFFSET"] = "timestamp-offset";
20
+ SimpleFieldTypes["OID"] = "oid";
21
+ SimpleFieldTypes["GUID"] = "guid";
22
+ SimpleFieldTypes["UNKNOWN"] = "unknown";
23
+ })(SimpleFieldTypes || (SimpleFieldTypes = {}));
24
+ /**
25
+ * Returns true if the value is defined
26
+ * @param value - value to check
27
+ */
28
+ function isDefined(value) {
29
+ return value !== undefined && value !== null;
30
+ }
31
+ /**
32
+ * Returns the URL used for queries.
33
+ * E.g. SceneLayers need to use the FeatureLayer URL for queries.
34
+ * @param value - value to check
35
+ */
36
+ function getQueryURL(layer) {
37
+ if (layer.type === "scene") {
38
+ return layer.associatedLayer?.url;
39
+ }
40
+ return layer.url;
41
+ }
42
+
43
+ /**
44
+ * Returns additional field information from layer
45
+ * @param props - properties containing layer and fieldName
46
+ */
47
+ function getFieldInfo(props) {
48
+ const { layer, fieldName } = props;
49
+ let fieldInfo = undefined;
50
+ const { popupTemplate } = layer;
51
+ const popupFieldInfos = popupTemplate ? popupTemplate.fieldInfos : [];
52
+ (layer.type === "imagery-tile"
53
+ ? layer.rasterFields
54
+ : layer.type === "imagery" && layer.rasterFields?.length
55
+ ? layer.rasterFields
56
+ : layer.fields)
57
+ .filter((layerField) => layerField.name === fieldName)
58
+ .forEach((layerField) => {
59
+ const list = popupFieldInfos
60
+ ? popupFieldInfos.filter((fInfo) => fInfo.fieldName === layerField.name)
61
+ : null;
62
+ const label = list?.length ? list[0].label : null;
63
+ if (/^raster.(item|service)pixelvalue/i.test(fieldName)) {
64
+ // e.g. "Raster.ServicePixelValue" | "Raster.ItemPixelValue" | "Raster.ServicePixelValue.Raw"
65
+ // layer.rasterFields reports them as type "string"
66
+ layerField.type = "double";
67
+ }
68
+ const featureFilterField = {
69
+ layerField: layerField,
70
+ label: label || layerField.alias || layerField.name
71
+ };
72
+ featureFilterField.codedValues = getCodedValues(fieldName, props);
73
+ _getSimpleFieldType(featureFilterField);
74
+ if (featureFilterField.simpleFieldType) {
75
+ fieldInfo = featureFilterField;
76
+ } // else can't use field
77
+ });
78
+ return fieldInfo;
79
+ }
80
+ /**
81
+ * Returns feature count in layer
82
+ * @param props - properties containing layer and fieldName
83
+ */
84
+ async function getFeatureCount(props) {
85
+ props.statisticsStatus = Status.IN_PROGRESS;
86
+ const { layer, view } = props;
87
+ if (layer.type === "imagery" || layer.type === "imagery-tile" || layer.type === "stream") {
88
+ throw new Error("could not get feature count");
89
+ }
90
+ try {
91
+ return await getFeatureCountCommon(layer, view);
92
+ }
93
+ catch (error) {
94
+ return;
95
+ }
96
+ }
97
+ /**
98
+ * Returns summary statistics
99
+ * @param props - properties containing layer and fieldName
100
+ */
101
+ async function getStatistics(props) {
102
+ const { layer, view, fieldName, fieldInfo, modules } = props;
103
+ if (layer.type === "imagery" || layer.type === "imagery-tile") {
104
+ throw new Error("could not get statistics for ImageryLayer/ImageryTileLayer");
105
+ }
106
+ if (!fieldInfo ||
107
+ fieldInfo.layerField.type === "oid" ||
108
+ fieldInfo.layerField.type === "guid" ||
109
+ fieldInfo.layerField.type === "global-id") {
110
+ const count = await getFeatureCount(props);
111
+ return Promise.resolve({ totalCount: count, nullcount: 0 } /*StatisticsResult*/);
112
+ }
113
+ try {
114
+ const result = await modules.summaryStatistics({
115
+ layer,
116
+ view,
117
+ field: fieldName
118
+ });
119
+ if (!isDefined(result.count)) {
120
+ // statistics is unusable
121
+ throw new Error("could not get statistics");
122
+ }
123
+ // if we hit maxRecordCount other stats values are probably not correct either
124
+ const hitMaxRecordCount = "sourceJSON" in layer && layer.sourceJSON.maxRecordCount === result.count;
125
+ // count only contains features with a value (!= null)
126
+ if (isDefined(result.nullcount) && !hitMaxRecordCount) {
127
+ // we can add the feature count without null and the count of nulls
128
+ const stats /*StatisticsResult*/ = { ...result, totalCount: result.count + result.nullcount };
129
+ return stats;
130
+ }
131
+ else {
132
+ // we want the total feature count
133
+ // happens e.g. for SceneLayers with older stats cache
134
+ const count = await getFeatureCount(props);
135
+ const stats = { ...result, totalCount: count };
136
+ return stats;
137
+ }
138
+ }
139
+ catch (error) {
140
+ throw new Error("could not get statistics");
141
+ }
142
+ }
143
+ /**
144
+ * Returns unique values
145
+ * @param props - properties containing layer and fieldName
146
+ */
147
+ async function getUniqueValues(props) {
148
+ const { layer, view, fieldName, modules } = props;
149
+ if (layer.type === "imagery" || layer.type === "imagery-tile") {
150
+ throw new Error("could not get unique values for ImageryLayer/ImageryTileLayer");
151
+ }
152
+ if (layer.type === "feature" && !layer.url) {
153
+ layer.outFields = ["*"];
154
+ }
155
+ try {
156
+ const result = await modules.uniqueValues({
157
+ layer,
158
+ view,
159
+ field: fieldName
160
+ });
161
+ return result;
162
+ }
163
+ catch (error) {
164
+ throw new Error("could not get unique values");
165
+ }
166
+ }
167
+ function _getSimpleFieldType(featureFilterField) {
168
+ switch (featureFilterField.layerField.type) {
169
+ case "string":
170
+ featureFilterField.simpleFieldType = SimpleFieldTypes.STRING;
171
+ break;
172
+ case "date":
173
+ featureFilterField.simpleFieldType = SimpleFieldTypes.DATE;
174
+ break;
175
+ case "timestamp-offset":
176
+ featureFilterField.simpleFieldType = SimpleFieldTypes.TIMESTAMP_OFFSET;
177
+ break;
178
+ case "date-only":
179
+ featureFilterField.simpleFieldType = SimpleFieldTypes.DATE_ONLY;
180
+ break;
181
+ case "time-only":
182
+ featureFilterField.simpleFieldType = SimpleFieldTypes.TIME_ONLY;
183
+ break;
184
+ case "oid":
185
+ featureFilterField.simpleFieldType = SimpleFieldTypes.OID;
186
+ break;
187
+ case "guid":
188
+ case "global-id":
189
+ featureFilterField.simpleFieldType = SimpleFieldTypes.GUID;
190
+ break;
191
+ case "small-integer":
192
+ case "big-integer":
193
+ case "integer":
194
+ case "single":
195
+ case "double":
196
+ case "long":
197
+ featureFilterField.simpleFieldType = SimpleFieldTypes.NUMBER;
198
+ break;
199
+ }
200
+ }
201
+ function getCodedValues(fieldName, props) {
202
+ const { layer, modules } = props;
203
+ if (layer.type !== "feature") {
204
+ return;
205
+ }
206
+ const typeIdField = layer.typeIdField;
207
+ const types = layer.types;
208
+ let fieldDomains = undefined;
209
+ const field = layer.fields.find((field) => field.name === fieldName);
210
+ const fieldDomain = field.domain;
211
+ if (typeIdField && types) {
212
+ // layer has types
213
+ if (typeIdField === fieldName) {
214
+ // this is the field with the types
215
+ fieldDomains = types.map((type) => {
216
+ // fake coded Values
217
+ return {
218
+ code: type.id,
219
+ name: type.name
220
+ };
221
+ });
222
+ }
223
+ else {
224
+ // field does not have types; look farther inside the types
225
+ fieldDomains = [];
226
+ types.forEach((type) => {
227
+ if (!type.domains || !type.domains[fieldName] || type.domains[fieldName].type === "inherited") {
228
+ const domain = fieldDomain;
229
+ if (domain?.codedValues) {
230
+ domain.codedValues.forEach(async (codedValue) => {
231
+ let found = false;
232
+ fieldDomains.forEach((codedVal) => {
233
+ if (codedVal.code === codedValue.code) {
234
+ found = true;
235
+ if (`, ${codedVal.name},`.indexOf(`, ${codedValue.name},`) === -1) {
236
+ codedVal.name += `, ${codedValue.name}`;
237
+ }
238
+ }
239
+ });
240
+ if (!found) {
241
+ fieldDomains.push(modules.esriLang.clone(codedValue));
242
+ }
243
+ });
244
+ }
245
+ }
246
+ else if (type.domains?.[fieldName]?.codedValues) {
247
+ type.domains[fieldName].codedValues.forEach(async (codedValue) => {
248
+ let found = false;
249
+ fieldDomains.forEach((codedVal) => {
250
+ if (codedVal.code === codedValue.code) {
251
+ found = true;
252
+ if (`, ${codedVal.name},`.indexOf(`, ${codedValue.name},`) === -1) {
253
+ codedVal.name += `, ${codedValue.name}`;
254
+ }
255
+ }
256
+ });
257
+ if (!found) {
258
+ fieldDomains.push(modules.esriLang.clone(codedValue));
259
+ }
260
+ });
261
+ }
262
+ });
263
+ }
264
+ if (!fieldDomains?.length && fieldDomain?.codedValues) {
265
+ fieldDomains = modules.esriLang.clone(fieldDomain.codedValues);
266
+ }
267
+ }
268
+ else if (fieldDomain?.codedValues) {
269
+ // domains directly on the layer field
270
+ fieldDomains = field.domain.codedValues;
271
+ }
272
+ return fieldDomains?.length ? fieldDomains : null;
273
+ }
274
+
275
+ /**
276
+ * Returns up to 5 features from the layer to get sample data
277
+ * @param props - properties containing layer and view
278
+ */
279
+ async function getOneFeature(props) {
280
+ const { view, layer } = props;
281
+ if (layer.type === "imagery" || layer.type === "imagery-tile") {
282
+ throw new Error("could not get feature");
283
+ }
284
+ if ((layer.type === "feature" && !layer.url) || layer.type === "wfs") {
285
+ // feature collection or wfs
286
+ const query = layer.createQuery();
287
+ query.start = 0;
288
+ query.num = 5;
289
+ query.outFields = ["*"];
290
+ const result = await layer.queryFeatures(query);
291
+ if (result.features?.length) {
292
+ return result;
293
+ }
294
+ else {
295
+ throw new Error("could not get feature");
296
+ }
297
+ }
298
+ else {
299
+ // service
300
+ if (!view) {
301
+ // get feature from service directly
302
+ return _queryOneFeature(props);
303
+ }
304
+ const layerView = (await view.whenLayerView(layer));
305
+ const hasAllFields = layerView.availableFields.length === layer.fields.length;
306
+ if (hasAllFields || (["stream", "ogc-feature"].indexOf(layer.type) > -1 && layerView.availableFields.length > 0)) {
307
+ // features on client have all fields
308
+ // or we can't make a server query, so we take what we can get
309
+ const query = layer.createQuery();
310
+ query.start = 0;
311
+ query.num = 5;
312
+ query.outFields = ["*"];
313
+ const result = await layerView.queryFeatures(query);
314
+ if (result.features?.length) {
315
+ // client side features
316
+ return result;
317
+ }
318
+ else {
319
+ // get feature from service
320
+ return _queryOneFeature(props);
321
+ }
322
+ }
323
+ else {
324
+ // get feature from service
325
+ return _queryOneFeature(props);
326
+ }
327
+ }
328
+ }
329
+ async function _queryOneFeature(props) {
330
+ const { layer, modules } = props;
331
+ if (["imagery", "imagery-tile", "stream", "ogc-feature"].indexOf(layer.type) > -1) {
332
+ throw new Error("cannot get feature from service");
333
+ }
334
+ const query = new modules.Query({
335
+ where: "1=1",
336
+ outFields: ["*"],
337
+ returnGeometry: false
338
+ });
339
+ return layer.queryFeatures(query);
340
+ }
341
+ /**
342
+ * Returns feature count of layer
343
+ * @param layer - FeatureLayer | WFSLayer | OGCFeatureLayer | StreamLayer | CSVLayer
344
+ * @param mapView - View
345
+ */
346
+ async function getFeatureCountCommon(layer, view) {
347
+ if (layer.type === "feature" && !layer.url) {
348
+ return getFeatureCountForCollection(layer);
349
+ }
350
+ else if (layer.type === "feature" ||
351
+ layer.type === "csv" ||
352
+ layer.type === "scene" ||
353
+ layer.type === "wfs" ||
354
+ layer.type === "geojson") {
355
+ return await layer.queryFeatureCount();
356
+ }
357
+ else if (view && (layer.type === "stream" || layer.type === "ogc-feature")) {
358
+ return getFeatureCountFromView(layer, view);
359
+ }
360
+ return undefined;
361
+ }
362
+ /**
363
+ * Returns feature count of feature collection layer
364
+ * @param layer - FeatureLayer
365
+ */
366
+ async function getFeatureCountForCollection(layer) {
367
+ const query = layer.createQuery();
368
+ query.outFields = ["*"];
369
+ const result = await layer.queryFeatures(query);
370
+ if (result.features?.length) {
371
+ return result.features.length;
372
+ }
373
+ else {
374
+ throw new Error("could not get feature count");
375
+ }
376
+ }
377
+ /**
378
+ * Returns feature count of feature collection layer
379
+ * @param layer - StreamLayer | OGCFeatureLayer
380
+ */
381
+ async function getFeatureCountFromView(layer, view) {
382
+ // we can only get the features from the map
383
+ const layerView = (await view.whenLayerView(layer));
384
+ return layerView.queryFeatureCount();
385
+ }
386
+
387
+ const fieldInfoScss = ":host{height:100%}.container{padding:6px;background-color:white}.title{font-weight:bold;padding:5px 0}.missing{color:#a9a9a9}.data{color:#a9a9a9}.count{white-space:nowrap}.section{padding:6px 0}.statistics-row{border-top:1px solid #e0e0e0;padding:6px 0;display:flex;justify-content:space-between}.statistics-row-top-values{border-top:1px solid #e0e0e0;padding:20px 0 6px 0;display:flex;justify-content:space-between}";
388
+
389
+ const ArcgisFieldInfo = class {
390
+ constructor(hostRef) {
391
+ registerInstance(this, hostRef);
392
+ this.arcgisFieldInfoComplete = createEvent(this, "arcgisFieldInfoComplete", 7);
393
+ this.view = undefined;
394
+ this.layer = undefined;
395
+ this.fieldName = undefined;
396
+ this.hideStatistics = false;
397
+ this.oneFeatureResponse = undefined;
398
+ this.oneFeatureResponseStatus = Status.MISSING;
399
+ this.statistics = undefined;
400
+ this.statisticsStatus = Status.MISSING;
401
+ this.uniqueValues = undefined;
402
+ this.uniqueValuesStatus = Status.MISSING;
403
+ this._lang = "";
404
+ this._t9nLocale = "";
405
+ this._t9nStrings = undefined;
406
+ }
407
+ //--------------------------------------------------------------------------
408
+ //
409
+ // Lifecycle
410
+ //
411
+ //--------------------------------------------------------------------------
412
+ async componentWillLoad() {
413
+ await F(this, getAssetPath("./assets"));
414
+ const esriLang = await importCoreLang();
415
+ const esriConfig = await importConfig();
416
+ const intl = await importIntl();
417
+ const Query = await importRestSupportQuery();
418
+ const summaryStatistics = await importSmartMappingStatisticsSummaryStatistics();
419
+ const uniqueValues = await importSmartMappingStatisticsUniqueValues();
420
+ const { view, layer, fieldName, hideStatistics } = this;
421
+ let sublayerFL;
422
+ if (layer.declaredClass === "esri.layers.support.Sublayer") {
423
+ // need to create a FeatureLayer
424
+ const sublayer = layer;
425
+ const { whenOnce } = await importCoreReactiveUtils();
426
+ view && (await whenOnce(() => !view.updating));
427
+ sublayerFL = await sublayer.createFeatureLayer();
428
+ await sublayerFL.load();
429
+ }
430
+ this.props = {
431
+ view,
432
+ layer: sublayerFL || layer,
433
+ fieldName,
434
+ hideStatistics,
435
+ modules: { esriLang, esriConfig, intl, Query, summaryStatistics, uniqueValues }
436
+ };
437
+ // required for initial load
438
+ this.props.fieldInfo = getFieldInfo(this.props);
439
+ // we don't know if the SceneLayer has an associated FL
440
+ // don't prompt for a login if it's not accessible
441
+ if (layer.type === "scene") {
442
+ esriConfig.request.interceptors?.push({
443
+ urls: getQueryURL(layer) + "/" + layer.layerId,
444
+ before: function (params) {
445
+ params.requestOptions.authMode = "no-prompt";
446
+ }
447
+ });
448
+ }
449
+ this.oneFeatureResponseStatus = Status.IN_PROGRESS;
450
+ try {
451
+ const result = await getOneFeature(this.props);
452
+ this.oneFeatureResponse = result;
453
+ this.oneFeatureResponseStatus = Status.SUCCESS;
454
+ }
455
+ catch (error) {
456
+ this.oneFeatureResponseStatus = Status.FAILED;
457
+ }
458
+ if (layer.type === "stream") {
459
+ this.uniqueValuesStatus = Status.FAILED;
460
+ this.statisticsStatus = Status.FAILED;
461
+ return;
462
+ }
463
+ if (hideStatistics) {
464
+ this.uniqueValuesStatus = Status.FAILED;
465
+ }
466
+ else {
467
+ this.uniqueValuesStatus = Status.IN_PROGRESS;
468
+ try {
469
+ const uniqueValues = await getUniqueValues(this.props);
470
+ this.uniqueValues = uniqueValues;
471
+ if (uniqueValues?.uniqueValueInfos?.length) {
472
+ this.uniqueValuesStatus = Status.SUCCESS;
473
+ }
474
+ else {
475
+ this.uniqueValuesStatus = Status.FAILED;
476
+ }
477
+ }
478
+ catch (error) {
479
+ this.uniqueValuesStatus = Status.FAILED;
480
+ }
481
+ }
482
+ if (hideStatistics) {
483
+ this.statisticsStatus = Status.FAILED;
484
+ }
485
+ else {
486
+ this.statisticsStatus = Status.IN_PROGRESS;
487
+ try {
488
+ const statistics = await getStatistics(this.props);
489
+ if (!isDefined(statistics.totalCount) &&
490
+ isDefined(statistics.count) &&
491
+ this.uniqueValuesStatus === Status.SUCCESS) {
492
+ // take null values count from unique values and add with non-null count from statistics
493
+ const infos = this.uniqueValues.uniqueValueInfos;
494
+ for (let i = 0; i < infos.length; i++) {
495
+ const info = infos[i];
496
+ if (info.value === null) {
497
+ statistics.totalCount = info.count + statistics.count;
498
+ break;
499
+ }
500
+ }
501
+ if (!isDefined(statistics.totalCount)) {
502
+ // no null values
503
+ statistics.totalCount = statistics.count;
504
+ }
505
+ }
506
+ this.statistics = statistics;
507
+ this.statisticsStatus = Status.SUCCESS;
508
+ }
509
+ catch (error) {
510
+ this.statisticsStatus = Status.FAILED;
511
+ }
512
+ }
513
+ }
514
+ async componentDidLoad() {
515
+ // once component is visible make other calls
516
+ const { props } = this;
517
+ const { modules } = props;
518
+ modules.intl.setLocale(this._lang);
519
+ // modules.intl.setLocale(this.locale) not returning the correct formatting for e.g. it-ch
520
+ }
521
+ disconnectedCallback() {
522
+ U(this);
523
+ }
524
+ // --------------------------------------------------------------------------
525
+ //
526
+ // Render Methods
527
+ //
528
+ //--------------------------------------------------------------------------
529
+ render() {
530
+ const { props } = this;
531
+ const { fieldInfo } = props;
532
+ if (!fieldInfo) {
533
+ return h(Fragment, null);
534
+ }
535
+ return (h(Host, null, h("div", { class: "container" }, this.renderFieldType(), this.renderFieldAlias(), this.renderFieldDescription(), this.renderFieldValueType(), this.renderFieldSampleValue(), this.renderFieldFormat(), this.renderFieldStatistics())));
536
+ }
537
+ renderFieldType() {
538
+ const { _t9nStrings, props } = this;
539
+ const { fieldInfo } = props;
540
+ const fieldType = this._getFieldTypeLabel(fieldInfo.layerField.type);
541
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldType), h("div", null, fieldType)));
542
+ }
543
+ renderFieldAlias() {
544
+ const { _t9nStrings, props } = this;
545
+ const { fieldInfo } = props;
546
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldAlias), h("div", null, fieldInfo.label)));
547
+ }
548
+ renderFieldDescription() {
549
+ const { _t9nStrings, props } = this;
550
+ const { layer } = props;
551
+ if (layer.type !== "feature") {
552
+ return h(Fragment, null);
553
+ }
554
+ const { fieldInfo } = props;
555
+ const description = fieldInfo.layerField.description;
556
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDescription), h("div", { class: {
557
+ missing: !description
558
+ } }, description || _t9nStrings.fieldDescriptionNotSet)));
559
+ }
560
+ renderFieldValueType() {
561
+ const { _t9nStrings, props } = this;
562
+ const { layer } = props;
563
+ if (layer.type !== "feature") {
564
+ return h(Fragment, null);
565
+ }
566
+ const { fieldInfo } = props;
567
+ const fieldValueType = this._getFieldValueTypeCamelCase(fieldInfo);
568
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldValueType), h("div", { class: !fieldValueType ? "missing" : "" }, fieldValueType
569
+ ? _t9nStrings.fieldValueTypes[fieldValueType]
570
+ : _t9nStrings.fieldValueTypeNotSet)));
571
+ }
572
+ renderFieldSampleValue() {
573
+ const { oneFeatureResponse, oneFeatureResponseStatus, statisticsStatus, statistics, uniqueValuesStatus, uniqueValues, _t9nStrings, props } = this;
574
+ const { layer, fieldName, fieldInfo } = props;
575
+ const { statistics: statStrings } = _t9nStrings;
576
+ let value;
577
+ if (["imagery", "imagery-tile"].indexOf(layer.type) > -1) {
578
+ return h(Fragment, null);
579
+ }
580
+ if (layer.type !== "stream" &&
581
+ [SimpleFieldTypes.STRING, SimpleFieldTypes.OID, SimpleFieldTypes.GUID].indexOf(this._getStatisticsType(fieldInfo)) > -1 &&
582
+ uniqueValuesStatus !== Status.FAILED) {
583
+ // we show top values
584
+ return h(Fragment, null);
585
+ }
586
+ if (oneFeatureResponseStatus === Status.SUCCESS) {
587
+ // find first valid value entry
588
+ oneFeatureResponse.features.forEach((feature) => {
589
+ if (value === undefined || (value === null && feature.attributes[fieldName] !== null)) {
590
+ value = feature.attributes[fieldName];
591
+ }
592
+ });
593
+ }
594
+ else if (statisticsStatus === Status.SUCCESS) {
595
+ // use statistics min value
596
+ value = statistics.min;
597
+ }
598
+ else if (uniqueValuesStatus === Status.SUCCESS) {
599
+ // use a non-null value
600
+ value = uniqueValues.uniqueValueInfos?.[0]?.value || uniqueValues.uniqueValueInfos?.[1]?.value;
601
+ }
602
+ const codedValues = fieldInfo.codedValues;
603
+ if (isDefined(value)) {
604
+ if (codedValues) {
605
+ value = codedValues.find((codedValue) => value === codedValue.code)?.name || value;
606
+ }
607
+ else {
608
+ value = this._getDisplayString(value);
609
+ }
610
+ }
611
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldSampleValue), h("div", { class: (oneFeatureResponseStatus === Status.FAILED &&
612
+ statisticsStatus === Status.FAILED &&
613
+ uniqueValuesStatus === Status.FAILED) ||
614
+ !isDefined(value)
615
+ ? "missing"
616
+ : "" }, oneFeatureResponseStatus === Status.SUCCESS ||
617
+ statisticsStatus === Status.SUCCESS ||
618
+ uniqueValuesStatus === Status.SUCCESS
619
+ ? !isDefined(value)
620
+ ? statStrings.allNulls
621
+ : `${value}`
622
+ : oneFeatureResponseStatus === Status.FAILED &&
623
+ statisticsStatus === Status.FAILED &&
624
+ uniqueValuesStatus === Status.FAILED
625
+ ? _t9nStrings.fieldSampleNotAvailable
626
+ : _t9nStrings.fieldSampleRetrieving)));
627
+ }
628
+ renderFieldFormat() {
629
+ const { _t9nStrings, props } = this;
630
+ const { fieldName, fieldInfo, layer } = props;
631
+ if (["single", "double", "long"].indexOf(fieldInfo.layerField.type) === -1) {
632
+ return h(Fragment, null);
633
+ }
634
+ const popupTemplate = layer.popupTemplate;
635
+ if (popupTemplate?.fieldInfos) {
636
+ const popFieldInfos = popupTemplate.fieldInfos?.filter((fieldInfo) => fieldInfo.fieldName === fieldName);
637
+ if (popFieldInfos?.length) {
638
+ const popFieldInfo = popFieldInfos[0];
639
+ if (isDefined(popFieldInfo?.format?.places)) {
640
+ const num = popFieldInfo.format.places;
641
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), h("div", null, _t9nStrings.fieldNumDecimalPlaces.replace("${number}", num.toString()))));
642
+ }
643
+ }
644
+ }
645
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), h("div", { class: "missing" }, _t9nStrings.fieldDecimalPlacesNotAvailable)));
646
+ }
647
+ renderFieldStatistics() {
648
+ const { statisticsStatus, uniqueValuesStatus, hideStatistics, _t9nStrings, props } = this;
649
+ const { layer, fieldInfo } = props;
650
+ if (hideStatistics) {
651
+ this.arcgisFieldInfoComplete.emit();
652
+ return h(Fragment, null);
653
+ }
654
+ if (["stream", "imagery", "imagery-tile"].indexOf(layer.type) > -1 ||
655
+ ["long"].indexOf(fieldInfo.layerField.type) > -1) {
656
+ // can't get statistics
657
+ this.arcgisFieldInfoComplete.emit();
658
+ return h(Fragment, null);
659
+ }
660
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldStatistics), !statisticsStatus || statisticsStatus === Status.MISSING || statisticsStatus === Status.IN_PROGRESS ? (h("div", { key: "field-info-statistics-content", class: "missing" }, _t9nStrings.fieldStatisticsRetrieving)) : statisticsStatus === Status.FAILED && uniqueValuesStatus !== Status.SUCCESS ? (this.renderNoStatistics()) : (h("div", { key: "field-info-statistics-content", ref: () => this.arcgisFieldInfoComplete.emit() }, this.renderStatistics()))));
661
+ }
662
+ renderNoStatistics() {
663
+ const { _t9nStrings } = this;
664
+ return (h("div", { key: "field-info-statistics-content", ref: () => this.arcgisFieldInfoComplete.emit(), class: "missing" }, _t9nStrings.fieldStatisticsNotAvailable));
665
+ }
666
+ renderStatistics() {
667
+ const { props } = this;
668
+ const { fieldInfo } = props;
669
+ switch (this._getStatisticsType(fieldInfo)) {
670
+ case SimpleFieldTypes.NUMBER:
671
+ return this.renderNumberStatistics();
672
+ case SimpleFieldTypes.STRING:
673
+ case SimpleFieldTypes.OID:
674
+ case SimpleFieldTypes.GUID:
675
+ return this.renderStringStatistics();
676
+ case SimpleFieldTypes.DATE:
677
+ case SimpleFieldTypes.DATE_ONLY:
678
+ case SimpleFieldTypes.TIME_ONLY:
679
+ case SimpleFieldTypes.TIMESTAMP_OFFSET:
680
+ return this.renderDateStatistics();
681
+ default:
682
+ return h(Fragment, null);
683
+ }
684
+ }
685
+ renderNumberStatistics() {
686
+ const { statistics, _t9nStrings } = this;
687
+ if (!statistics) {
688
+ return this.renderNoStatistics();
689
+ }
690
+ const { statistics: statStrings } = _t9nStrings;
691
+ return (h("div", null, h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfValues), h("div", { class: "data" }, this._printNumValue(statistics.totalCount))), isDefined(statistics.sum) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.sumOfValues), h("div", { class: "data" }, this._printNumValue(statistics.sum)))) : null, isDefined(statistics.min) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.minimum), h("div", { class: "data" }, this._printNumValue(statistics.min)))) : null, isDefined(statistics.max) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.maximum), h("div", { class: "data" }, this._printNumValue(statistics.max)))) : null, isDefined(statistics.avg) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.average), h("div", { class: "data" }, this._printNumValue(statistics.avg)))) : null, isDefined(statistics.stddev) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.standardDeviation), h("div", { class: "data" }, this._printNumValue(statistics.stddev)))) : null, this.renderNullValues()));
692
+ }
693
+ renderStringStatistics() {
694
+ const { statistics, uniqueValuesStatus, _t9nStrings } = this;
695
+ const { statistics: statStrings } = _t9nStrings;
696
+ return (h("div", null, h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfValues), uniqueValuesStatus !== Status.SUCCESS ? (h("div", { class: "missing" }, "--")) : (h("div", { class: "data" }, this._printNumValue(statistics?.totalCount)))), this.renderNullValues(), this.renderTopValues()));
697
+ }
698
+ renderDateStatistics() {
699
+ // TODO UTC offset
700
+ const { statistics, view, props, _t9nStrings } = this;
701
+ const { fieldInfo } = props;
702
+ if (!statistics) {
703
+ return this.renderNoStatistics();
704
+ }
705
+ const { statistics: statStrings } = _t9nStrings;
706
+ const dateRange = statistics.max - statistics.min;
707
+ const years = Math.floor(dateRange / 31536000000);
708
+ let months = Math.floor((dateRange - years * 31536000000) / 2628000000);
709
+ let days = Math.ceil((dateRange - months * 2628000000) / 86400000);
710
+ if (days >= 30) {
711
+ months += 1;
712
+ days = 0;
713
+ }
714
+ let timeSpan = years === 1
715
+ ? statStrings.timeSpanOptions.year
716
+ : years > 1
717
+ ? statStrings.timeSpanOptions.years.replace("${years}", years.toString())
718
+ : "";
719
+ timeSpan += years > 0 && (months > 0 || days > 0) ? ", " : "";
720
+ timeSpan +=
721
+ months === 1
722
+ ? statStrings.timeSpanOptions.month
723
+ : months > 1
724
+ ? statStrings.timeSpanOptions.months.replace("${months}", months.toString())
725
+ : "";
726
+ timeSpan += months > 0 && days > 0 ? ", " : "";
727
+ timeSpan +=
728
+ days === 1
729
+ ? statStrings.timeSpanOptions.day
730
+ : days > 1
731
+ ? statStrings.timeSpanOptions.days.replace("${days}", days.toString())
732
+ : "";
733
+ const showStats = fieldInfo.simpleFieldType !== SimpleFieldTypes.TIMESTAMP_OFFSET ||
734
+ !view ||
735
+ view.timeZone !== "unknown";
736
+ const isTimeOnly = fieldInfo.simpleFieldType === SimpleFieldTypes.TIME_ONLY;
737
+ return (h("div", null, h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfValues), h("div", { class: "data" }, this._printNumValue(statistics?.totalCount))), showStats && isDefined(statistics.min) ? (h("div", { class: "statistics-row" }, h("div", null, isTimeOnly ? statStrings.minimumTime : statStrings.minimumDate), h("div", { class: "data" }, `${this._getDisplayString(statistics.min)}`))) : null, showStats && isDefined(statistics.max) ? (h("div", { class: "statistics-row" }, h("div", null, isTimeOnly ? statStrings.maximumTime : statStrings.maximumDate), h("div", { class: "data" }, `${this._getDisplayString(statistics.max)}`))) : null, showStats && isDefined(statistics.avg) ? (h("div", { class: "statistics-row" }, h("div", null, isTimeOnly ? statStrings.averageTime : statStrings.averageDate), h("div", { class: "data" }, `${this._getDisplayString(statistics.avg)}`))) : null, showStats && !isTimeOnly && isDefined(statistics.min) && isDefined(statistics.max) && dateRange > 0 ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.timespan), h("div", { class: "data" }, timeSpan))) : null, this.renderNullValues()));
738
+ }
739
+ renderTopValues() {
740
+ const { uniqueValues, uniqueValuesStatus, _t9nStrings, props } = this;
741
+ const { fieldInfo } = props;
742
+ const { statistics: statStrings } = _t9nStrings;
743
+ if (uniqueValues?.uniqueValueInfos?.length) {
744
+ const infos = uniqueValues.uniqueValueInfos;
745
+ infos.sort((a, b) => (a.count < b.count ? 1 : a.count > b.count ? -1 : 0));
746
+ const codedValues = fieldInfo.codedValues;
747
+ const values = infos
748
+ .filter((info) => info.value !== null)
749
+ .filter((info, idx) => info && idx < 10)
750
+ .map((info) => {
751
+ let value = info.value;
752
+ if (codedValues) {
753
+ codedValues.forEach((codeValue) => {
754
+ if (value === codeValue.code) {
755
+ value = codeValue.name;
756
+ }
757
+ });
758
+ }
759
+ else {
760
+ value = this._getDisplayString(value);
761
+ }
762
+ return (h("div", { class: "statistics-row" }, h("div", { class: "data" }, `${value}`), h("div", { class: `$"data" $"count"` }, this._printNumValue(info.count))));
763
+ });
764
+ if (!values.length) {
765
+ return h(Fragment, null);
766
+ }
767
+ return (h("div", null, h("div", { class: "statistics-row-top-values" }, h("div", null, infos.length > 10 ? statStrings.topTenValues : statStrings.topValues), h("div", null, statStrings.count)), values));
768
+ }
769
+ else {
770
+ return (h("div", null, h("div", { class: "statistics-row-top-values" }, h("div", null, statStrings.topValues), h("div", null, statStrings.count)), h("div", { class: "statistics-row" }, h("div", { class: "missing" }, uniqueValuesStatus === Status.FAILED
771
+ ? _t9nStrings.fieldUniqueValuesNotAvailable
772
+ : _t9nStrings.fieldSampleRetrieving))));
773
+ }
774
+ }
775
+ renderNullValues() {
776
+ const { statistics, uniqueValues, _t9nStrings } = this;
777
+ const { statistics: statStrings } = _t9nStrings;
778
+ let count = statistics?.nullcount;
779
+ if (!isDefined(count) && uniqueValues) {
780
+ const infos = uniqueValues.uniqueValueInfos;
781
+ for (let i = 0; i < infos.length; i++) {
782
+ const info = infos[i];
783
+ if (info.value === null) {
784
+ count = info.count;
785
+ break;
786
+ }
787
+ }
788
+ }
789
+ return (h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfNulls), !isDefined(count) ? (h("div", { class: "missing" }, "--")) : (h("div", { class: "data" }, `${new Number(count).toLocaleString()}`))));
790
+ }
791
+ // --------------------------------------------------------------------------
792
+ //
793
+ // Private methods
794
+ //
795
+ // --------------------------------------------------------------------------
796
+ _getFieldTypeLabel(fieldType) {
797
+ const { _t9nStrings } = this;
798
+ const fieldTypes = _t9nStrings.fieldTypes;
799
+ switch (fieldType) {
800
+ case "small-integer":
801
+ return fieldTypes.smallInteger;
802
+ case "big-integer":
803
+ return fieldTypes.bigInteger;
804
+ case "integer":
805
+ return fieldTypes.integer;
806
+ case "single":
807
+ return fieldTypes.single;
808
+ case "double":
809
+ return fieldTypes.double;
810
+ case "long":
811
+ return fieldTypes.long;
812
+ case "string":
813
+ return fieldTypes.string;
814
+ case "date":
815
+ return fieldTypes.date;
816
+ case "date-only":
817
+ return fieldTypes.dateOnly;
818
+ case "time-only":
819
+ return fieldTypes.timeOnly;
820
+ case "timestamp-offset":
821
+ return fieldTypes.timestampOffset;
822
+ case "oid":
823
+ return fieldTypes.oid;
824
+ case "guid":
825
+ return fieldTypes.guid;
826
+ case "global-id":
827
+ return fieldTypes.globalId;
828
+ default:
829
+ return fieldTypes.string;
830
+ }
831
+ }
832
+ _getStatisticsType(fieldInfo) {
833
+ // "count-or-amount","percentage-or-ratio","measurement","unique-identifier","coordinate","binary"
834
+ // "name-or-title","type-or-category","description","location-or-place-name","ordered-or-ranked","date-and-time"
835
+ switch (fieldInfo.layerField.type) {
836
+ case "small-integer":
837
+ case "big-integer":
838
+ case "integer":
839
+ case "single":
840
+ case "double": {
841
+ if (fieldInfo.codedValues) {
842
+ return SimpleFieldTypes.STRING;
843
+ }
844
+ switch (fieldInfo.layerField.valueType) {
845
+ case "name-or-title":
846
+ case "type-or-category":
847
+ case "description":
848
+ case "location-or-place-name":
849
+ case "ordered-or-ranked":
850
+ case "binary":
851
+ //case "date-and-time":
852
+ return SimpleFieldTypes.STRING;
853
+ default:
854
+ return SimpleFieldTypes.NUMBER;
855
+ }
856
+ }
857
+ case "string":
858
+ return SimpleFieldTypes.STRING;
859
+ case "date":
860
+ return SimpleFieldTypes.DATE;
861
+ case "timestamp-offset":
862
+ return SimpleFieldTypes.TIMESTAMP_OFFSET;
863
+ case "date-only":
864
+ return SimpleFieldTypes.DATE_ONLY;
865
+ case "time-only":
866
+ return SimpleFieldTypes.TIME_ONLY;
867
+ default:
868
+ return SimpleFieldTypes.STRING;
869
+ }
870
+ }
871
+ _getFieldValueTypeCamelCase(field) {
872
+ switch (field.layerField.valueType) {
873
+ case "count-or-amount":
874
+ return "countOrAmount";
875
+ case "percentage-or-ratio":
876
+ return "percentageOrRatio";
877
+ case "unique-identifier":
878
+ return "uniqueIdentifier";
879
+ case "name-or-title":
880
+ return "nameOrTitle";
881
+ case "type-or-category":
882
+ return "typeOrCategory";
883
+ case "location-or-place-name":
884
+ return "locationOrPlaceName";
885
+ case "ordered-or-ranked":
886
+ return "orderedOrRanked";
887
+ case "date-and-time":
888
+ return "dateAndTime";
889
+ default:
890
+ return field.layerField.valueType;
891
+ }
892
+ }
893
+ _getDisplayString(value) {
894
+ const { props } = this;
895
+ const { fieldInfo } = props;
896
+ switch (fieldInfo.simpleFieldType) {
897
+ case SimpleFieldTypes.DATE:
898
+ return this._getDateString(value);
899
+ case SimpleFieldTypes.TIMESTAMP_OFFSET:
900
+ return this._getTimestampOffsetString(value);
901
+ case SimpleFieldTypes.DATE_ONLY:
902
+ return this._getDateOnlyString(value);
903
+ case SimpleFieldTypes.TIME_ONLY:
904
+ return this._getTimeOnlyString(value);
905
+ case SimpleFieldTypes.NUMBER:
906
+ return this._getNumberString(value);
907
+ case SimpleFieldTypes.GUID:
908
+ return this._getGuidString(value);
909
+ default:
910
+ // string, oid, global-id
911
+ return `${value}`;
912
+ }
913
+ }
914
+ _getDateString(value) {
915
+ const { modules, view } = this.props;
916
+ if (view && view.timeZone === "unknown") {
917
+ return modules.intl.formatDate(value, {
918
+ ...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
919
+ timeZone: "utc",
920
+ timeZoneName: "shortOffset"
921
+ });
922
+ }
923
+ else {
924
+ // known issues with formatting it-CH
925
+ return modules.intl.formatDate(value, {
926
+ ...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
927
+ timeZone: view?.timeZone || "system"
928
+ });
929
+ }
930
+ }
931
+ _getTimestampOffsetString(value) {
932
+ /*
933
+ const timestamp = "2023-03-19T16:00:00.123-01:00";
934
+ console.log("timestamp", timestamp);
935
+ console.log(
936
+ "local Time",
937
+ intl.formatTimestamp(timestamp, intl.convertDateFormatToIntlOptions("short-date-short-time"))
938
+ );
939
+ console.log(
940
+ "mapView Time (except unknown)",
941
+ intl.formatTimestamp(timestamp, {
942
+ ...intl.convertDateFormatToIntlOptions("short-date-short-time"),
943
+ timeZone: view.timeZone,
944
+ })
945
+ );
946
+ console.log(
947
+ "UTC Time (mapView time unknown)",
948
+ intl.formatTimestamp(timestamp, {
949
+ ...intl.convertDateFormatToIntlOptions("short-date-short-time"),
950
+ timeZone: "utc",
951
+ timeZoneName: "shortOffset"
952
+ })
953
+ );
954
+ console.log(
955
+ "Raw",
956
+ intl.formatTimestamp(timestamp, {
957
+ ...intl.convertDateFormatToIntlOptions("short-date-short-time"),
958
+ timeZoneName: "shortOffset"
959
+ })
960
+ );
961
+ */
962
+ const { modules, view } = this.props;
963
+ if (typeof value === "string") {
964
+ // raw value from layer
965
+ if (view && view.timeZone === "unknown") {
966
+ return modules.intl.formatTimestamp(value, {
967
+ ...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
968
+ timeZone: "utc",
969
+ timeZoneName: "shortOffset"
970
+ });
971
+ }
972
+ else {
973
+ return modules.intl.formatTimestamp(value, {
974
+ ...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
975
+ timeZone: view?.timeZone || "system"
976
+ });
977
+ }
978
+ }
979
+ else {
980
+ // e.g. UNIX timestamp from statistics call
981
+ return this._getDateString(value);
982
+ }
983
+ }
984
+ _getDateOnlyString(value) {
985
+ const { props } = this;
986
+ const { modules } = props;
987
+ return modules.intl.formatDateOnly(value, modules.intl.convertDateFormatToIntlOptions("short-date"));
988
+ }
989
+ _getTimeOnlyString(value) {
990
+ const { props } = this;
991
+ const { modules } = props;
992
+ if (typeof value === "string") {
993
+ return modules.intl.formatTimeOnly(value, modules.intl.convertDateFormatToIntlOptions("short-date-long-time"));
994
+ }
995
+ else {
996
+ // UNIX timestamp
997
+ return modules.intl.formatDate(value, {
998
+ ...modules.intl.convertDateFormatToIntlOptions("long-time"),
999
+ timeZone: "utc"
1000
+ });
1001
+ }
1002
+ }
1003
+ _getGuidString(value) {
1004
+ return value.startsWith("{") ? value : `{${value}}`;
1005
+ }
1006
+ _getNumberString(value) {
1007
+ return this.props.modules.intl.formatNumber(value);
1008
+ }
1009
+ _printNumValue(value) {
1010
+ return isDefined(value) ? this._getNumberString(Math.round(value * 100) / 100) : `--`;
1011
+ }
1012
+ static get assetsDirs() { return ["assets"]; }
1013
+ get _hostElement() { return getElement(this); }
1014
+ };
1015
+ ArcgisFieldInfo.style = fieldInfoScss;
1016
+
1017
+ export { ArcgisFieldInfo as arcgis_field_info };