@arcgis/common-components 4.29.0-beta.41 → 4.29.0-beta.43

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