@arcgis/common-components 4.29.0-beta.46 → 4.29.0-beta.48

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