@kepler.gl/utils 3.3.0-alpha.27 → 3.3.0-alpha.28

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.
@@ -0,0 +1,5 @@
1
+ import type { AnnotationPropsPartial, AnnotationReadout, ViewportAnnotationPlacement } from '@kepler.gl/types';
2
+ export declare function normalizeAnnotationViewport(value: unknown): ViewportAnnotationPlacement | undefined;
3
+ export declare function normalizeAnnotationReadout(value: unknown): AnnotationReadout | undefined;
4
+ /** Own caption metadata and discard it when changing back to a geographic annotation. */
5
+ export declare function normalizeAnnotationCaption(config: AnnotationPropsPartial): Pick<AnnotationPropsPartial, 'viewport' | 'readout'>;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.normalizeAnnotationCaption = normalizeAnnotationCaption;
8
+ exports.normalizeAnnotationReadout = normalizeAnnotationReadout;
9
+ exports.normalizeAnnotationViewport = normalizeAnnotationViewport;
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
+ var _constants = require("@kepler.gl/constants");
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // SPDX-License-Identifier: MIT
15
+ // Copyright contributors to the kepler.gl project
16
+ var anchors = new Set(['top-left', 'top', 'top-right', 'left', 'right', 'bottom-left', 'bottom', 'bottom-right']);
17
+ function normalizeAnnotationViewport(value) {
18
+ if (!value || (0, _typeof2["default"])(value) !== 'object') return undefined;
19
+ var _ref = value,
20
+ anchor = _ref.anchor,
21
+ margin = _ref.margin;
22
+ if (!anchors.has(anchor) || !Array.isArray(margin) || margin.length !== 2 || !margin.every(function (item) {
23
+ return Number.isFinite(item) && item >= 0;
24
+ })) return undefined;
25
+ return {
26
+ anchor: anchor,
27
+ margin: [margin[0], margin[1]]
28
+ };
29
+ }
30
+ function normalizeAnnotationReadout(value) {
31
+ if (!value || (0, _typeof2["default"])(value) !== 'object') return undefined;
32
+ var readout = value;
33
+ if (readout.type === 'time' && (readout.format === undefined || typeof readout.format === 'string' && readout.format.length > 0 && readout.format.length <= 128)) {
34
+ return _objectSpread({
35
+ type: 'time'
36
+ }, readout.format !== undefined ? {
37
+ format: readout.format
38
+ } : {});
39
+ }
40
+ if (readout.type === 'count' && typeof readout.dataId === 'string' && readout.dataId.trim()) {
41
+ return {
42
+ type: 'count',
43
+ dataId: readout.dataId
44
+ };
45
+ }
46
+ return undefined;
47
+ }
48
+
49
+ /** Own caption metadata and discard it when changing back to a geographic annotation. */
50
+ function normalizeAnnotationCaption(config) {
51
+ var viewport = config.kind === _constants.AnnotationKind.TEXT ? normalizeAnnotationViewport(config.viewport) : undefined;
52
+ if (!viewport) return {};
53
+ var readout = normalizeAnnotationReadout(config.readout);
54
+ return _objectSpread({
55
+ viewport: viewport
56
+ }, readout ? {
57
+ readout: readout
58
+ } : {});
59
+ }
60
+ //# sourceMappingURL=annotation-caption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation-caption.js","names":["_constants","require","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","anchors","Set","normalizeAnnotationViewport","value","_typeof2","undefined","_ref","anchor","margin","has","Array","isArray","every","item","Number","isFinite","normalizeAnnotationReadout","readout","type","format","dataId","trim","normalizeAnnotationCaption","config","viewport","kind","AnnotationKind","TEXT"],"sources":["../../src/annotation-caption.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {AnnotationKind} from '@kepler.gl/constants';\nimport type {\n AnnotationPropsPartial,\n AnnotationReadout,\n ViewportAnnotationPlacement\n} from '@kepler.gl/types';\n\nconst anchors = new Set([\n 'top-left',\n 'top',\n 'top-right',\n 'left',\n 'right',\n 'bottom-left',\n 'bottom',\n 'bottom-right'\n]);\n\nexport function normalizeAnnotationViewport(\n value: unknown\n): ViewportAnnotationPlacement | undefined {\n if (!value || typeof value !== 'object') return undefined;\n const {anchor, margin} = value as ViewportAnnotationPlacement;\n if (\n !anchors.has(anchor) ||\n !Array.isArray(margin) ||\n margin.length !== 2 ||\n !margin.every(item => Number.isFinite(item) && item >= 0)\n )\n return undefined;\n return {anchor, margin: [margin[0], margin[1]]};\n}\n\nexport function normalizeAnnotationReadout(value: unknown): AnnotationReadout | undefined {\n if (!value || typeof value !== 'object') return undefined;\n const readout = value as AnnotationReadout;\n if (\n readout.type === 'time' &&\n (readout.format === undefined ||\n (typeof readout.format === 'string' &&\n readout.format.length > 0 &&\n readout.format.length <= 128))\n ) {\n return {type: 'time', ...(readout.format !== undefined ? {format: readout.format} : {})};\n }\n if (readout.type === 'count' && typeof readout.dataId === 'string' && readout.dataId.trim()) {\n return {type: 'count', dataId: readout.dataId};\n }\n return undefined;\n}\n\n/** Own caption metadata and discard it when changing back to a geographic annotation. */\nexport function normalizeAnnotationCaption(\n config: AnnotationPropsPartial\n): Pick<AnnotationPropsPartial, 'viewport' | 'readout'> {\n const viewport =\n config.kind === AnnotationKind.TEXT ? normalizeAnnotationViewport(config.viewport) : undefined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MAACc,MAAM,EAAEF,OAAO,CAACE;IAAM,CAAC,GAAG,CAAC,CAAC;EACxF;EACA,IAAIF,OAAO,CAACC,IAAI,KAAK,OAAO,IAAI,OAAOD,OAAO,CAACG,MAAM,KAAK,QAAQ,IAAIH,OAAO,CAACG,MAAM,CAACC,IAAI,CAAC,CAAC,EAAE;IAC3F,OAAO;MAACH,IAAI,EAAE,OAAO;MAAEE,MAAM,EAAEH,OAAO,CAACG;IAAM,CAAC;EAChD;EACA,OAAOf,SAAS;AAClB;;AAEA;AACO,SAASiB,0BAA0BA,CACxCC,MAA8B,EACwB;EACtD,IAAMC,QAAQ,GACZD,MAAM,CAACE,IAAI,KAAKC,yBAAc,CAACC,IAAI,GAAGzB,2BAA2B,CAACqB,MAAM,CAACC,QAAQ,CAAC,GAAGnB,SAAS;EAChG,IAAI,CAACmB,QAAQ,EAAE,OAAO,CAAC,CAAC;EACxB,IAAMP,OAAO,GAAGD,0BAA0B,CAACO,MAAM,CAACN,OAAO,CAAC;EAC1D,OAAAzB,aAAA;IAAQgC,QAAQ,EAARA;EAAQ,GAAMP,OAAO,GAAG;IAACA,OAAO,EAAPA;EAAO,CAAC,GAAG,CAAC,CAAC;AAChD","ignoreList":[]}
@@ -1438,9 +1438,13 @@ function mergeFilterDomain(filter, datasets) {
1438
1438
  }
1439
1439
  var endName = (0, _commonUtils.toArray)(filter.endName)[idx];
1440
1440
  if (endName) {
1441
- var _domainSteps2;
1442
1441
  var endProps = dataset.getColumnFilterProps(endName);
1443
- domainSteps = mergeFilterDomainStep((_domainSteps2 = domainSteps) !== null && _domainSteps2 !== void 0 ? _domainSteps2 : {}, endProps);
1442
+ // All-null ends are open intervals. Their synthetic timestamp domain
1443
+ // does not represent an observation and must not extend the timeline.
1444
+ if (endProps && 'mappedValue' in endProps && Array.isArray(endProps.mappedValue) && endProps.mappedValue.some(Number.isFinite)) {
1445
+ var _domainSteps2;
1446
+ domainSteps = mergeFilterDomainStep((_domainSteps2 = domainSteps) !== null && _domainSteps2 !== void 0 ? _domainSteps2 : {}, endProps);
1447
+ }
1444
1448
  }
1445
1449
  });
1446
1450
  return domainSteps;