@arcgis/common-components 4.29.0-beta.5 → 4.29.0-beta.51

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 (137) hide show
  1. package/README.md +1 -1
  2. package/dist/arcgis-common-components/arcgis-common-components.esm.js +1 -1
  3. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ar.json +78 -0
  4. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.bg.json +78 -0
  5. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.bs.json +78 -0
  6. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ca.json +78 -0
  7. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.cs.json +78 -0
  8. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.da.json +78 -0
  9. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.de.json +78 -0
  10. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.el.json +78 -0
  11. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.en.json +78 -0
  12. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.es.json +78 -0
  13. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.et.json +78 -0
  14. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.fi.json +78 -0
  15. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.fr.json +78 -0
  16. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.he.json +78 -0
  17. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.hr.json +78 -0
  18. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.hu.json +78 -0
  19. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.id.json +78 -0
  20. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.it.json +78 -0
  21. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ja.json +78 -0
  22. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ko.json +78 -0
  23. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.lt.json +78 -0
  24. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.lv.json +78 -0
  25. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.nb.json +78 -0
  26. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.nl.json +78 -0
  27. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.pl.json +78 -0
  28. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.pt-BR.json +78 -0
  29. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.pt-PT.json +78 -0
  30. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ro.json +78 -0
  31. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ru.json +78 -0
  32. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sk.json +78 -0
  33. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sl.json +78 -0
  34. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sr.json +78 -0
  35. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sv.json +78 -0
  36. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.th.json +78 -0
  37. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.tr.json +78 -0
  38. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.uk.json +78 -0
  39. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.vi.json +78 -0
  40. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.zh-CN.json +78 -0
  41. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.zh-HK.json +78 -0
  42. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.zh-TW.json +78 -0
  43. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ar.json +17 -0
  44. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.bg.json +17 -0
  45. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.bs.json +17 -0
  46. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ca.json +17 -0
  47. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.cs.json +17 -0
  48. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.da.json +17 -0
  49. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.de.json +17 -0
  50. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.el.json +17 -0
  51. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.en.json +17 -0
  52. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.es.json +17 -0
  53. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.et.json +17 -0
  54. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.fi.json +17 -0
  55. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.fr.json +17 -0
  56. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.he.json +17 -0
  57. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.hr.json +17 -0
  58. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.hu.json +17 -0
  59. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.id.json +17 -0
  60. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.it.json +17 -0
  61. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ja.json +17 -0
  62. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ko.json +17 -0
  63. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.lt.json +17 -0
  64. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.lv.json +17 -0
  65. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.nb.json +17 -0
  66. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.nl.json +17 -0
  67. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.pl.json +17 -0
  68. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.pt-BR.json +17 -0
  69. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.pt-PT.json +17 -0
  70. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ro.json +17 -0
  71. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ru.json +17 -0
  72. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sk.json +17 -0
  73. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sl.json +17 -0
  74. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sr.json +17 -0
  75. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sv.json +17 -0
  76. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.th.json +17 -0
  77. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.tr.json +17 -0
  78. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.uk.json +17 -0
  79. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.vi.json +17 -0
  80. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.zh-CN.json +17 -0
  81. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.zh-HK.json +17 -0
  82. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.zh-TW.json +17 -0
  83. package/dist/arcgis-common-components/p-6c7d2684.js +1 -0
  84. package/dist/arcgis-common-components/p-7318a1d1.entry.js +1 -0
  85. package/dist/arcgis-common-components/p-a91ab432.js +2 -0
  86. package/dist/arcgis-common-components/p-efab92a8.entry.js +1 -0
  87. package/dist/cjs/arcgis-common-components.cjs.js +3 -3
  88. package/dist/cjs/arcgis-field-info.cjs.entry.js +1025 -0
  89. package/dist/cjs/arcgis-field-pick-list.cjs.entry.js +245 -0
  90. package/dist/cjs/index-5ec7f592.js +90 -0
  91. package/dist/cjs/index-e0422bc8.js +1887 -0
  92. package/dist/cjs/loader.cjs.js +3 -12
  93. package/dist/components/{arcgis-api-key.d.ts → arcgis-field-info.d.ts} +4 -4
  94. package/dist/components/arcgis-field-info.js +6 -0
  95. package/dist/components/{arcgis-identity.d.ts → arcgis-field-pick-list.d.ts} +4 -4
  96. package/dist/components/arcgis-field-pick-list.js +301 -0
  97. package/dist/components/field-info.js +1108 -0
  98. package/dist/components/index.d.ts +5 -4
  99. package/dist/components/index.js +1 -3
  100. package/dist/esm/arcgis-common-components.js +4 -4
  101. package/dist/esm/arcgis-field-info.entry.js +1021 -0
  102. package/dist/esm/arcgis-field-pick-list.entry.js +241 -0
  103. package/dist/esm/index-0c129ec4.js +1856 -0
  104. package/dist/esm/index-ba4fe890.js +59 -0
  105. package/dist/esm/loader.js +4 -13
  106. package/dist/loader/index.d.ts +2 -2
  107. package/dist/types/components/field-info/field-info.d.ts +68 -0
  108. package/dist/types/components/field-info/t9n-types.d.ts +82 -0
  109. package/dist/types/components/field-info/utils/basic.d.ts +44 -0
  110. package/dist/types/components/field-info/utils/feature.d.ts +17 -0
  111. package/dist/types/components/field-info/utils/field.d.ts +25 -0
  112. package/dist/types/components/field-info/utils/index.d.ts +3 -0
  113. package/dist/types/components/field-pick-list/field-pick-list.d.ts +122 -0
  114. package/dist/types/components/field-pick-list/t9n-types.d.ts +17 -0
  115. package/dist/types/components/field-pick-list/utils/types.d.ts +25 -0
  116. package/dist/types/components.d.ts +258 -49
  117. package/dist/types/stencil-public-runtime.d.ts +61 -17
  118. package/package.json +24 -26
  119. package/dist/arcgis-common-components/p-3768a3bb.entry.js +0 -1
  120. package/dist/arcgis-common-components/p-84fccaad.entry.js +0 -1
  121. package/dist/arcgis-common-components/p-9625972e.js +0 -1
  122. package/dist/arcgis-common-components/p-b0c98bba.js +0 -2
  123. package/dist/cjs/arcgis-api-key.cjs.entry.js +0 -51
  124. package/dist/cjs/arcgis-identity.cjs.entry.js +0 -139
  125. package/dist/cjs/index-e8c59179.js +0 -858
  126. package/dist/cjs/index-f1a937af.js +0 -65
  127. package/dist/components/arcgis-api-key.js +0 -67
  128. package/dist/components/arcgis-identity.js +0 -165
  129. package/dist/components/index2.js +0 -40
  130. package/dist/esm/arcgis-api-key.entry.js +0 -47
  131. package/dist/esm/arcgis-identity.entry.js +0 -135
  132. package/dist/esm/index-1f7e8e45.js +0 -831
  133. package/dist/esm/index-71b437b1.js +0 -40
  134. package/dist/esm/polyfills/css-shim.js +0 -1
  135. package/dist/types/components/arcgis-api-key/arcgis-api-key.d.ts +0 -9
  136. package/dist/types/components/arcgis-identity/arcgis-identity.d.ts +0 -31
  137. package/dist/types/components/types.d.ts +0 -10
@@ -0,0 +1,1021 @@
1
+ import { r as registerInstance, c as createEvent, g as getAssetPath, h, H as Host, a as getElement, F as Fragment } from './index-0c129ec4.js';
2
+ import { F, a as importCoreLang, b as importConfig, i as importIntl, c as importRestSupportQuery, d as importSmartMappingStatisticsSummaryStatistics, e as importSmartMappingStatisticsUniqueValues, f as importCoreReactiveUtils, U } from './index-ba4fe890.js';
3
+
4
+ var Status;
5
+ (function (Status) {
6
+ Status["MISSING"] = "missing";
7
+ Status["IN_PROGRESS"] = "inProgress";
8
+ Status["SUCCESS"] = "success";
9
+ Status["FAILED"] = "failed";
10
+ })(Status || (Status = {}));
11
+ var SimpleFieldTypes;
12
+ (function (SimpleFieldTypes) {
13
+ SimpleFieldTypes["NUMBER"] = "number";
14
+ SimpleFieldTypes["STRING"] = "string";
15
+ SimpleFieldTypes["DATE"] = "date";
16
+ SimpleFieldTypes["DATE_ONLY"] = "date-only";
17
+ SimpleFieldTypes["TIME_ONLY"] = "time-only";
18
+ SimpleFieldTypes["TIMESTAMP_OFFSET"] = "timestamp-offset";
19
+ SimpleFieldTypes["OID"] = "oid";
20
+ SimpleFieldTypes["GUID"] = "guid";
21
+ SimpleFieldTypes["UNKNOWN"] = "unknown";
22
+ })(SimpleFieldTypes || (SimpleFieldTypes = {}));
23
+ /**
24
+ * Returns true if the value is defined
25
+ * @param value - value to check
26
+ */
27
+ function isDefined(value) {
28
+ return value !== undefined && value !== null;
29
+ }
30
+ /**
31
+ * Returns the URL used for queries.
32
+ * E.g. SceneLayers need to use the FeatureLayer URL for queries.
33
+ * @param value - value to check
34
+ */
35
+ function getQueryURL(layer) {
36
+ if (layer.type === "scene") {
37
+ return layer.associatedLayer?.url;
38
+ }
39
+ return layer.url;
40
+ }
41
+
42
+ /**
43
+ * Returns additional field information from layer
44
+ * @param props - properties containing layer and fieldName
45
+ */
46
+ function getFieldInfo(props) {
47
+ const { layer, fieldName } = props;
48
+ let fieldInfo = undefined;
49
+ const { popupTemplate } = layer;
50
+ const popupFieldInfos = popupTemplate ? popupTemplate.fieldInfos : [];
51
+ (layer.type === "imagery-tile"
52
+ ? layer.rasterFields
53
+ : layer.type === "imagery" && layer.rasterFields?.length
54
+ ? layer.rasterFields
55
+ : layer.fields)
56
+ .filter((layerField) => layerField.name === fieldName)
57
+ .forEach((layerField) => {
58
+ const list = popupFieldInfos
59
+ ? popupFieldInfos.filter((fInfo) => fInfo.fieldName === layerField.name)
60
+ : null;
61
+ const label = list?.length ? list[0].label : null;
62
+ if (/^raster.(item|service)pixelvalue/iu.test(fieldName)) {
63
+ // e.g. "Raster.ServicePixelValue" | "Raster.ItemPixelValue" | "Raster.ServicePixelValue.Raw"
64
+ // layer.rasterFields reports them as type "string"
65
+ layerField.type = "double";
66
+ }
67
+ const featureFilterField = {
68
+ layerField,
69
+ label: label || layerField.alias || layerField.name
70
+ };
71
+ featureFilterField.codedValues = getCodedValues(fieldName, props);
72
+ _getSimpleFieldType(featureFilterField);
73
+ if (featureFilterField.simpleFieldType) {
74
+ fieldInfo = featureFilterField;
75
+ } // else can't use field
76
+ });
77
+ return fieldInfo;
78
+ }
79
+ /**
80
+ * Returns feature count in layer
81
+ * @param props - properties containing layer and fieldName
82
+ */
83
+ async function getFeatureCount(props) {
84
+ props.statisticsStatus = Status.IN_PROGRESS;
85
+ const { layer, view } = props;
86
+ if (layer.type === "imagery" || layer.type === "imagery-tile" || layer.type === "stream") {
87
+ throw new Error("could not get feature count");
88
+ }
89
+ try {
90
+ return await getFeatureCountCommon(layer, view);
91
+ }
92
+ catch {
93
+ return;
94
+ }
95
+ }
96
+ /**
97
+ * Returns summary statistics
98
+ * @param props - properties containing layer and fieldName
99
+ */
100
+ async function getStatistics(props) {
101
+ const { layer, view, fieldName, fieldInfo, modules } = props;
102
+ if (layer.type === "imagery" || layer.type === "imagery-tile") {
103
+ throw new Error("could not get statistics for ImageryLayer/ImageryTileLayer");
104
+ }
105
+ if (!fieldInfo ||
106
+ fieldInfo.layerField.type === "oid" ||
107
+ fieldInfo.layerField.type === "guid" ||
108
+ fieldInfo.layerField.type === "global-id") {
109
+ const count = await getFeatureCount(props);
110
+ return Promise.resolve({ totalCount: count, nullcount: 0 } /*StatisticsResult*/);
111
+ }
112
+ try {
113
+ const result = await modules.summaryStatistics({
114
+ layer,
115
+ view,
116
+ field: fieldName
117
+ });
118
+ if (!isDefined(result.count)) {
119
+ // statistics is unusable
120
+ throw new Error("could not get statistics");
121
+ }
122
+ // if we hit maxRecordCount other stats values are probably not correct either
123
+ const hitMaxRecordCount = "sourceJSON" in layer && layer.sourceJSON.maxRecordCount === result.count;
124
+ // count only contains features with a value (!= null)
125
+ if (isDefined(result.nullcount) && !hitMaxRecordCount) {
126
+ // we can add the feature count without null and the count of nulls
127
+ const stats /*StatisticsResult*/ = { ...result, totalCount: result.count + result.nullcount };
128
+ return stats;
129
+ }
130
+ else {
131
+ // we want the total feature count
132
+ // happens e.g. for SceneLayers with older stats cache
133
+ const count = await getFeatureCount(props);
134
+ const stats = { ...result, totalCount: count };
135
+ return stats;
136
+ }
137
+ }
138
+ catch (error) {
139
+ throw new Error("could not get statistics");
140
+ }
141
+ }
142
+ /**
143
+ * Returns unique values
144
+ * @param props - properties containing layer and fieldName
145
+ */
146
+ async function getUniqueValues(props) {
147
+ const { layer, view, fieldName, modules } = props;
148
+ if (layer.type === "imagery" || layer.type === "imagery-tile") {
149
+ throw new Error("could not get unique values for ImageryLayer/ImageryTileLayer");
150
+ }
151
+ if (layer.type === "feature" && !layer.url) {
152
+ layer.outFields = ["*"];
153
+ }
154
+ try {
155
+ const result = await modules.uniqueValues({
156
+ layer,
157
+ view,
158
+ field: fieldName
159
+ });
160
+ return result;
161
+ }
162
+ catch {
163
+ throw new Error("could not get unique values");
164
+ }
165
+ }
166
+ function _getSimpleFieldType(featureFilterField) {
167
+ switch (featureFilterField.layerField.type) {
168
+ case "string":
169
+ featureFilterField.simpleFieldType = SimpleFieldTypes.STRING;
170
+ break;
171
+ case "date":
172
+ featureFilterField.simpleFieldType = SimpleFieldTypes.DATE;
173
+ break;
174
+ case "timestamp-offset":
175
+ featureFilterField.simpleFieldType = SimpleFieldTypes.TIMESTAMP_OFFSET;
176
+ break;
177
+ case "date-only":
178
+ featureFilterField.simpleFieldType = SimpleFieldTypes.DATE_ONLY;
179
+ break;
180
+ case "time-only":
181
+ featureFilterField.simpleFieldType = SimpleFieldTypes.TIME_ONLY;
182
+ break;
183
+ case "oid":
184
+ featureFilterField.simpleFieldType = SimpleFieldTypes.OID;
185
+ break;
186
+ case "guid":
187
+ case "global-id":
188
+ featureFilterField.simpleFieldType = SimpleFieldTypes.GUID;
189
+ break;
190
+ case "small-integer":
191
+ case "big-integer":
192
+ case "integer":
193
+ case "single":
194
+ case "double":
195
+ case "long":
196
+ featureFilterField.simpleFieldType = SimpleFieldTypes.NUMBER;
197
+ break;
198
+ }
199
+ }
200
+ function getCodedValues(fieldName, props) {
201
+ const { layer, modules } = props;
202
+ if (layer.type !== "feature") {
203
+ return;
204
+ }
205
+ const typeIdField = layer.typeIdField;
206
+ const types = layer.types;
207
+ let fieldDomains = undefined;
208
+ const field = layer.fields.find((field) => field.name === fieldName);
209
+ const fieldDomain = field.domain;
210
+ if (typeIdField && types) {
211
+ // layer has types
212
+ if (typeIdField === fieldName) {
213
+ // this is the field with the types
214
+ fieldDomains = types.map((type) =>
215
+ // fake coded Values
216
+ ({
217
+ code: type.id,
218
+ name: type.name
219
+ }));
220
+ }
221
+ else {
222
+ // field does not have types; look farther inside the types
223
+ fieldDomains = [];
224
+ types.forEach((type) => {
225
+ if (!type.domains || !type.domains[fieldName] || type.domains[fieldName].type === "inherited") {
226
+ const domain = fieldDomain;
227
+ if (domain?.codedValues) {
228
+ domain.codedValues.forEach(async (codedValue) => {
229
+ let found = false;
230
+ fieldDomains.forEach((codedVal) => {
231
+ if (codedVal.code === codedValue.code) {
232
+ found = true;
233
+ if (`, ${codedVal.name},`.indexOf(`, ${codedValue.name},`) === -1) {
234
+ codedVal.name += `, ${codedValue.name}`;
235
+ }
236
+ }
237
+ });
238
+ if (!found) {
239
+ fieldDomains.push(modules.esriLang.clone(codedValue));
240
+ }
241
+ });
242
+ }
243
+ }
244
+ else if (type.domains?.[fieldName]?.codedValues) {
245
+ type.domains[fieldName].codedValues.forEach(async (codedValue) => {
246
+ let found = false;
247
+ fieldDomains.forEach((codedVal) => {
248
+ if (codedVal.code === codedValue.code) {
249
+ found = true;
250
+ if (`, ${codedVal.name},`.indexOf(`, ${codedValue.name},`) === -1) {
251
+ codedVal.name += `, ${codedValue.name}`;
252
+ }
253
+ }
254
+ });
255
+ if (!found) {
256
+ fieldDomains.push(modules.esriLang.clone(codedValue));
257
+ }
258
+ });
259
+ }
260
+ });
261
+ }
262
+ if (!fieldDomains?.length && fieldDomain?.codedValues) {
263
+ fieldDomains = modules.esriLang.clone(fieldDomain.codedValues);
264
+ }
265
+ }
266
+ else if (fieldDomain?.codedValues) {
267
+ // domains directly on the layer field
268
+ fieldDomains = field.domain.codedValues;
269
+ }
270
+ return fieldDomains?.length ? fieldDomains : null;
271
+ }
272
+
273
+ /**
274
+ * Returns up to 5 features from the layer to get sample data
275
+ * @param props - properties containing layer and view
276
+ */
277
+ async function getOneFeature(props) {
278
+ const { view, layer } = props;
279
+ if (layer.type === "imagery" || layer.type === "imagery-tile") {
280
+ throw new Error("could not get feature");
281
+ }
282
+ if ((layer.type === "feature" && !layer.url) || layer.type === "wfs") {
283
+ // feature collection or wfs
284
+ const query = layer.createQuery();
285
+ query.start = 0;
286
+ query.num = 5;
287
+ query.outFields = ["*"];
288
+ const result = await layer.queryFeatures(query);
289
+ if (result.features?.length) {
290
+ return result;
291
+ }
292
+ else {
293
+ throw new Error("could not get feature");
294
+ }
295
+ }
296
+ else {
297
+ // service
298
+ if (!view) {
299
+ // get feature from service directly
300
+ return _queryOneFeature(props);
301
+ }
302
+ const layerView = (await view.whenLayerView(layer));
303
+ const hasAllFields = layerView.availableFields.length === layer.fields.length;
304
+ if (hasAllFields || (["stream", "ogc-feature"].indexOf(layer.type) > -1 && layerView.availableFields.length > 0)) {
305
+ // features on client have all fields
306
+ // or we can't make a server query, so we take what we can get
307
+ const query = layer.createQuery();
308
+ query.start = 0;
309
+ query.num = 5;
310
+ query.outFields = ["*"];
311
+ const result = await layerView.queryFeatures(query);
312
+ if (result.features?.length) {
313
+ // client side features
314
+ return result;
315
+ }
316
+ else {
317
+ // get feature from service
318
+ return _queryOneFeature(props);
319
+ }
320
+ }
321
+ else {
322
+ // get feature from service
323
+ return _queryOneFeature(props);
324
+ }
325
+ }
326
+ }
327
+ async function _queryOneFeature(props) {
328
+ const { layer, modules } = props;
329
+ if (["imagery", "imagery-tile", "stream", "ogc-feature"].indexOf(layer.type) > -1) {
330
+ throw new Error("cannot get feature from service");
331
+ }
332
+ const query = new modules.Query({
333
+ where: "1=1",
334
+ outFields: ["*"],
335
+ returnGeometry: false
336
+ });
337
+ return layer.queryFeatures(query);
338
+ }
339
+ /**
340
+ * Returns feature count of layer
341
+ * @param layer - FeatureLayer | WFSLayer | OGCFeatureLayer | StreamLayer | CSVLayer
342
+ * @param mapView - View
343
+ */
344
+ async function getFeatureCountCommon(layer, view) {
345
+ if (layer.type === "feature" && !layer.url) {
346
+ return getFeatureCountForCollection(layer);
347
+ }
348
+ else if (layer.type === "feature" ||
349
+ layer.type === "csv" ||
350
+ layer.type === "scene" ||
351
+ layer.type === "wfs" ||
352
+ layer.type === "geojson") {
353
+ return await layer.queryFeatureCount();
354
+ }
355
+ else if (view && (layer.type === "stream" || layer.type === "ogc-feature")) {
356
+ return getFeatureCountFromView(layer, view);
357
+ }
358
+ return undefined;
359
+ }
360
+ /**
361
+ * Returns feature count of feature collection layer
362
+ * @param layer - FeatureLayer
363
+ */
364
+ async function getFeatureCountForCollection(layer) {
365
+ const query = layer.createQuery();
366
+ query.outFields = ["*"];
367
+ const result = await layer.queryFeatures(query);
368
+ if (result.features?.length) {
369
+ return result.features.length;
370
+ }
371
+ else {
372
+ throw new Error("could not get feature count");
373
+ }
374
+ }
375
+ /**
376
+ * Returns feature count of feature collection layer
377
+ * @param layer - StreamLayer | OGCFeatureLayer
378
+ */
379
+ async function getFeatureCountFromView(layer, view) {
380
+ // we can only get the features from the map
381
+ const layerView = (await view.whenLayerView(layer));
382
+ return layerView.queryFeatureCount();
383
+ }
384
+
385
+ 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}";
386
+
387
+ const ArcgisFieldInfo = class {
388
+ constructor(hostRef) {
389
+ registerInstance(this, hostRef);
390
+ this.arcgisFieldInfoComplete = createEvent(this, "arcgisFieldInfoComplete", 7);
391
+ this.view = undefined;
392
+ this.layer = undefined;
393
+ this.fieldName = undefined;
394
+ this.hideStatistics = false;
395
+ this.oneFeatureResponse = undefined;
396
+ this.oneFeatureResponseStatus = Status.MISSING;
397
+ this.statistics = undefined;
398
+ this.statisticsStatus = Status.MISSING;
399
+ this.uniqueValues = undefined;
400
+ this.uniqueValuesStatus = Status.MISSING;
401
+ this._lang = "";
402
+ this._t9nLocale = "";
403
+ this._t9nStrings = undefined;
404
+ }
405
+ //--------------------------------------------------------------------------
406
+ //
407
+ // Lifecycle
408
+ //
409
+ //--------------------------------------------------------------------------
410
+ async componentWillLoad() {
411
+ await F(this, getAssetPath("./assets"));
412
+ const esriLang = await importCoreLang();
413
+ const esriConfig = await importConfig();
414
+ const intl = await importIntl();
415
+ const Query = await importRestSupportQuery();
416
+ const summaryStatistics = await importSmartMappingStatisticsSummaryStatistics();
417
+ const uniqueValues = await importSmartMappingStatisticsUniqueValues();
418
+ const { view, layer, fieldName, hideStatistics } = this;
419
+ let sublayerFL;
420
+ if (layer.declaredClass === "esri.layers.support.Sublayer") {
421
+ // need to create a FeatureLayer
422
+ const sublayer = layer;
423
+ const { whenOnce } = await importCoreReactiveUtils();
424
+ if (view)
425
+ await whenOnce(() => !view.updating);
426
+ sublayerFL = await sublayer.createFeatureLayer();
427
+ await sublayerFL.load();
428
+ }
429
+ this.props = {
430
+ view,
431
+ layer: sublayerFL || layer,
432
+ fieldName,
433
+ hideStatistics,
434
+ modules: { esriLang, esriConfig, intl, Query, summaryStatistics, uniqueValues }
435
+ };
436
+ // required for initial load
437
+ this.props.fieldInfo = getFieldInfo(this.props);
438
+ // we don't know if the SceneLayer has an associated FL
439
+ // don't prompt for a login if it's not accessible
440
+ if (layer.type === "scene") {
441
+ esriConfig.request.interceptors?.push({
442
+ urls: `${getQueryURL(layer)}/${layer.layerId}`,
443
+ before(params) {
444
+ params.requestOptions.authMode = "no-prompt";
445
+ }
446
+ });
447
+ }
448
+ this.oneFeatureResponseStatus = Status.IN_PROGRESS;
449
+ try {
450
+ const result = await getOneFeature(this.props);
451
+ this.oneFeatureResponse = result;
452
+ this.oneFeatureResponseStatus = Status.SUCCESS;
453
+ }
454
+ catch {
455
+ this.oneFeatureResponseStatus = Status.FAILED;
456
+ }
457
+ if (layer.type === "stream") {
458
+ this.uniqueValuesStatus = Status.FAILED;
459
+ this.statisticsStatus = Status.FAILED;
460
+ return;
461
+ }
462
+ if (hideStatistics) {
463
+ this.uniqueValuesStatus = Status.FAILED;
464
+ }
465
+ else {
466
+ this.uniqueValuesStatus = Status.IN_PROGRESS;
467
+ try {
468
+ const uniqueValues = await getUniqueValues(this.props);
469
+ this.uniqueValues = uniqueValues;
470
+ if (uniqueValues?.uniqueValueInfos?.length) {
471
+ this.uniqueValuesStatus = Status.SUCCESS;
472
+ }
473
+ else {
474
+ this.uniqueValuesStatus = Status.FAILED;
475
+ }
476
+ }
477
+ catch (error) {
478
+ this.uniqueValuesStatus = Status.FAILED;
479
+ }
480
+ }
481
+ if (hideStatistics) {
482
+ this.statisticsStatus = Status.FAILED;
483
+ }
484
+ else {
485
+ this.statisticsStatus = Status.IN_PROGRESS;
486
+ try {
487
+ const statistics = await getStatistics(this.props);
488
+ if (!isDefined(statistics.totalCount) &&
489
+ isDefined(statistics.count) &&
490
+ this.uniqueValuesStatus === Status.SUCCESS) {
491
+ // take null values count from unique values and add with non-null count from statistics
492
+ const infos = this.uniqueValues.uniqueValueInfos;
493
+ for (let i = 0; i < infos.length; i += 1) {
494
+ const info = infos[i];
495
+ if (info.value === null) {
496
+ statistics.totalCount = info.count + statistics.count;
497
+ break;
498
+ }
499
+ }
500
+ if (!isDefined(statistics.totalCount)) {
501
+ // no null values
502
+ statistics.totalCount = statistics.count;
503
+ }
504
+ }
505
+ this.statistics = statistics;
506
+ this.statisticsStatus = Status.SUCCESS;
507
+ }
508
+ catch {
509
+ this.statisticsStatus = Status.FAILED;
510
+ }
511
+ }
512
+ }
513
+ async componentDidLoad() {
514
+ // once component is visible make other calls
515
+ const { props } = this;
516
+ const { modules } = props;
517
+ modules.intl.setLocale(this._lang);
518
+ // modules.intl.setLocale(this.locale) not returning the correct formatting for e.g. it-ch
519
+ }
520
+ disconnectedCallback() {
521
+ U(this);
522
+ }
523
+ // --------------------------------------------------------------------------
524
+ //
525
+ // Render Methods
526
+ //
527
+ //--------------------------------------------------------------------------
528
+ render() {
529
+ const { props } = this;
530
+ const { fieldInfo } = props;
531
+ if (!fieldInfo) {
532
+ return h(Fragment, null);
533
+ }
534
+ return (h(Host, null, h("div", { class: "container" }, this.renderFieldType(), this.renderFieldAlias(), this.renderFieldDescription(), this.renderFieldValueType(), this.renderFieldSampleValue(), this.renderFieldFormat(), this.renderFieldStatistics())));
535
+ }
536
+ renderFieldType() {
537
+ const { _t9nStrings, props } = this;
538
+ const { fieldInfo } = props;
539
+ const fieldType = this._getFieldTypeLabel(fieldInfo.layerField.type);
540
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldType), h("div", null, fieldType)));
541
+ }
542
+ renderFieldAlias() {
543
+ const { _t9nStrings, props } = this;
544
+ const { fieldInfo } = props;
545
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldAlias), h("div", null, fieldInfo.label)));
546
+ }
547
+ renderFieldDescription() {
548
+ const { _t9nStrings, props } = this;
549
+ const { layer } = props;
550
+ if (layer.type !== "feature") {
551
+ return h(Fragment, null);
552
+ }
553
+ const { fieldInfo } = props;
554
+ const description = fieldInfo.layerField.description;
555
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDescription), h("div", { class: {
556
+ missing: !description
557
+ } }, description || _t9nStrings.fieldDescriptionNotSet)));
558
+ }
559
+ renderFieldValueType() {
560
+ const { _t9nStrings, props } = this;
561
+ const { layer } = props;
562
+ if (layer.type !== "feature") {
563
+ return h(Fragment, null);
564
+ }
565
+ const { fieldInfo } = props;
566
+ const fieldValueType = this._getFieldValueTypeCamelCase(fieldInfo);
567
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldValueType), h("div", { class: !fieldValueType ? "missing" : "" }, fieldValueType
568
+ ? _t9nStrings.fieldValueTypes[fieldValueType]
569
+ : _t9nStrings.fieldValueTypeNotSet)));
570
+ }
571
+ renderFieldSampleValue() {
572
+ const { oneFeatureResponse, oneFeatureResponseStatus, statisticsStatus, statistics, uniqueValuesStatus, uniqueValues, _t9nStrings, props } = this;
573
+ const { layer, fieldName, fieldInfo } = props;
574
+ const { statistics: statStrings } = _t9nStrings;
575
+ let value;
576
+ if (["imagery", "imagery-tile"].indexOf(layer.type) > -1) {
577
+ return h(Fragment, null);
578
+ }
579
+ if (layer.type !== "stream" &&
580
+ [SimpleFieldTypes.STRING, SimpleFieldTypes.OID, SimpleFieldTypes.GUID].indexOf(this._getStatisticsType(fieldInfo)) > -1 &&
581
+ uniqueValuesStatus !== Status.FAILED) {
582
+ // we show top values
583
+ return h(Fragment, null);
584
+ }
585
+ if (oneFeatureResponseStatus === Status.SUCCESS) {
586
+ // find first valid value entry
587
+ oneFeatureResponse.features.forEach((feature) => {
588
+ if (value === undefined || (value === null && feature.attributes[fieldName] !== null)) {
589
+ value = feature.attributes[fieldName];
590
+ }
591
+ });
592
+ }
593
+ else if (statisticsStatus === Status.SUCCESS) {
594
+ // use statistics min value
595
+ value = statistics.min;
596
+ }
597
+ else if (uniqueValuesStatus === Status.SUCCESS) {
598
+ // use a non-null value
599
+ value = uniqueValues.uniqueValueInfos?.[0]?.value || uniqueValues.uniqueValueInfos?.[1]?.value;
600
+ }
601
+ const codedValues = fieldInfo.codedValues;
602
+ if (isDefined(value)) {
603
+ if (codedValues) {
604
+ value = codedValues.find((codedValue) => value === codedValue.code)?.name || value;
605
+ }
606
+ else {
607
+ value = this._getDisplayString(value);
608
+ }
609
+ }
610
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldSampleValue), h("div", { class: (oneFeatureResponseStatus === Status.FAILED &&
611
+ statisticsStatus === Status.FAILED &&
612
+ uniqueValuesStatus === Status.FAILED) ||
613
+ !isDefined(value)
614
+ ? "missing"
615
+ : "" }, oneFeatureResponseStatus === Status.SUCCESS ||
616
+ statisticsStatus === Status.SUCCESS ||
617
+ uniqueValuesStatus === Status.SUCCESS
618
+ ? !isDefined(value)
619
+ ? statStrings.allNulls
620
+ : `${value}`
621
+ : oneFeatureResponseStatus === Status.FAILED &&
622
+ statisticsStatus === Status.FAILED &&
623
+ uniqueValuesStatus === Status.FAILED
624
+ ? _t9nStrings.fieldSampleNotAvailable
625
+ : _t9nStrings.fieldSampleRetrieving)));
626
+ }
627
+ renderFieldFormat() {
628
+ const { _t9nStrings, props } = this;
629
+ const { fieldName, fieldInfo, layer } = props;
630
+ if (["single", "double", "long"].indexOf(fieldInfo.layerField.type) === -1) {
631
+ return h(Fragment, null);
632
+ }
633
+ const popupTemplate = layer.popupTemplate;
634
+ if (popupTemplate?.fieldInfos) {
635
+ const popFieldInfos = popupTemplate.fieldInfos?.filter((fieldInfo) => fieldInfo.fieldName === fieldName);
636
+ if (popFieldInfos?.length) {
637
+ const popFieldInfo = popFieldInfos[0];
638
+ if (isDefined(popFieldInfo?.format?.places)) {
639
+ const num = popFieldInfo.format.places;
640
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), h("div", null,
641
+ // eslint-disable-next-line no-template-curly-in-string
642
+ _t9nStrings.fieldNumDecimalPlaces.replace("${number}", num.toString()))));
643
+ }
644
+ }
645
+ }
646
+ return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), h("div", { class: "missing" }, _t9nStrings.fieldDecimalPlacesNotAvailable)));
647
+ }
648
+ renderFieldStatistics() {
649
+ const { statisticsStatus, uniqueValuesStatus, hideStatistics, _t9nStrings, props } = this;
650
+ const { layer, fieldInfo } = props;
651
+ if (hideStatistics) {
652
+ this.arcgisFieldInfoComplete.emit();
653
+ return h(Fragment, null);
654
+ }
655
+ if (["stream", "imagery", "imagery-tile"].indexOf(layer.type) > -1 ||
656
+ ["long"].indexOf(fieldInfo.layerField.type) > -1) {
657
+ // can't get statistics
658
+ this.arcgisFieldInfoComplete.emit();
659
+ return h(Fragment, null);
660
+ }
661
+ 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()))));
662
+ }
663
+ renderNoStatistics() {
664
+ const { _t9nStrings } = this;
665
+ return (h("div", { key: "field-info-statistics-content", ref: () => this.arcgisFieldInfoComplete.emit(), class: "missing" }, _t9nStrings.fieldStatisticsNotAvailable));
666
+ }
667
+ renderStatistics() {
668
+ const { props } = this;
669
+ const { fieldInfo } = props;
670
+ switch (this._getStatisticsType(fieldInfo)) {
671
+ case SimpleFieldTypes.NUMBER:
672
+ return this.renderNumberStatistics();
673
+ case SimpleFieldTypes.STRING:
674
+ case SimpleFieldTypes.OID:
675
+ case SimpleFieldTypes.GUID:
676
+ return this.renderStringStatistics();
677
+ case SimpleFieldTypes.DATE:
678
+ case SimpleFieldTypes.DATE_ONLY:
679
+ case SimpleFieldTypes.TIME_ONLY:
680
+ case SimpleFieldTypes.TIMESTAMP_OFFSET:
681
+ return this.renderDateStatistics();
682
+ default:
683
+ return h(Fragment, null);
684
+ }
685
+ }
686
+ renderNumberStatistics() {
687
+ const { statistics, _t9nStrings } = this;
688
+ if (!statistics) {
689
+ return this.renderNoStatistics();
690
+ }
691
+ const { statistics: statStrings } = _t9nStrings;
692
+ 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()));
693
+ }
694
+ renderStringStatistics() {
695
+ const { statistics, uniqueValuesStatus, _t9nStrings } = this;
696
+ const { statistics: statStrings } = _t9nStrings;
697
+ 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()));
698
+ }
699
+ renderDateStatistics() {
700
+ // TODO UTC offset
701
+ const { statistics, view, props, _t9nStrings } = this;
702
+ const { fieldInfo } = props;
703
+ if (!statistics) {
704
+ return this.renderNoStatistics();
705
+ }
706
+ const { statistics: statStrings } = _t9nStrings;
707
+ const dateRange = statistics.max - statistics.min;
708
+ const years = Math.floor(dateRange / 31536000000);
709
+ let months = Math.floor((dateRange - years * 31536000000) / 2628000000);
710
+ let days = Math.ceil((dateRange - months * 2628000000) / 86400000);
711
+ if (days >= 30) {
712
+ months += 1;
713
+ days = 0;
714
+ }
715
+ let timeSpan = years === 1
716
+ ? statStrings.timeSpanOptions.year
717
+ : years > 1
718
+ ? // eslint-disable-next-line no-template-curly-in-string
719
+ statStrings.timeSpanOptions.years.replace("${years}", years.toString())
720
+ : "";
721
+ timeSpan += years > 0 && (months > 0 || days > 0) ? ", " : "";
722
+ timeSpan +=
723
+ months === 1
724
+ ? statStrings.timeSpanOptions.month
725
+ : months > 1
726
+ ? // eslint-disable-next-line no-template-curly-in-string
727
+ statStrings.timeSpanOptions.months.replace("${months}", months.toString())
728
+ : "";
729
+ timeSpan += months > 0 && days > 0 ? ", " : "";
730
+ timeSpan +=
731
+ days === 1
732
+ ? statStrings.timeSpanOptions.day
733
+ : days > 1
734
+ ? // eslint-disable-next-line no-template-curly-in-string
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 (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()));
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 (h("div", { class: "statistics-row" }, h("div", { class: "data" }, `${value}`), h("div", { class: `$"data" $"count"` }, this._printNumValue(info.count))));
767
+ });
768
+ if (!values.length) {
769
+ return h(Fragment, null);
770
+ }
771
+ 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));
772
+ }
773
+ else {
774
+ 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
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 += 1) {
786
+ const info = infos[i];
787
+ if (info.value === null) {
788
+ count = info.count;
789
+ break;
790
+ }
791
+ }
792
+ }
793
+ return (h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfNulls), !isDefined(count) ? (h("div", { class: "missing" }, "--")) : (h("div", { class: "data" }, `${Number.parseInt(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 getElement(this); }
1018
+ };
1019
+ ArcgisFieldInfo.style = fieldInfoScss;
1020
+
1021
+ export { ArcgisFieldInfo as arcgis_field_info };