@deck.gl/carto 8.7.0-alpha.3 → 8.7.0-beta.1

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 (54) hide show
  1. package/dist/dist.dev.js +29663 -10643
  2. package/dist/es5/api/index.js +9 -9
  3. package/dist/es5/api/layer-map.js +98 -72
  4. package/dist/es5/api/layer-map.js.map +1 -1
  5. package/dist/es5/api/maps-api-common.js +13 -9
  6. package/dist/es5/api/maps-api-common.js.map +1 -1
  7. package/dist/es5/api/maps-client.js +157 -98
  8. package/dist/es5/api/maps-client.js.map +1 -1
  9. package/dist/es5/api/maps-v3-client.js +535 -312
  10. package/dist/es5/api/maps-v3-client.js.map +1 -1
  11. package/dist/es5/api/parseMap.js +103 -101
  12. package/dist/es5/api/parseMap.js.map +1 -1
  13. package/dist/es5/basemap.js +1 -1
  14. package/dist/es5/basemap.js.map +1 -1
  15. package/dist/es5/config.js +25 -18
  16. package/dist/es5/config.js.map +1 -1
  17. package/dist/es5/index.js +15 -15
  18. package/dist/es5/layers/carto-dynamic-tile-layer.js +166 -0
  19. package/dist/es5/layers/carto-dynamic-tile-layer.js.map +1 -0
  20. package/dist/es5/layers/carto-layer.js +215 -129
  21. package/dist/es5/layers/carto-layer.js.map +1 -1
  22. package/dist/es5/style/color-bins-style.js +15 -12
  23. package/dist/es5/style/color-bins-style.js.map +1 -1
  24. package/dist/es5/style/color-categories-style.js +43 -16
  25. package/dist/es5/style/color-categories-style.js.map +1 -1
  26. package/dist/es5/style/color-continuous-style.js +15 -12
  27. package/dist/es5/style/color-continuous-style.js.map +1 -1
  28. package/dist/es5/style/palette.js +23 -13
  29. package/dist/es5/style/palette.js.map +1 -1
  30. package/dist/es5/style/utils.js +13 -6
  31. package/dist/es5/style/utils.js.map +1 -1
  32. package/dist/esm/api/layer-map.js +8 -1
  33. package/dist/esm/api/layer-map.js.map +1 -1
  34. package/dist/esm/api/maps-v3-client.js +29 -17
  35. package/dist/esm/api/maps-v3-client.js.map +1 -1
  36. package/dist/esm/api/parseMap.js +31 -26
  37. package/dist/esm/api/parseMap.js.map +1 -1
  38. package/dist/esm/layers/carto-dynamic-tile-layer.js +97 -0
  39. package/dist/esm/layers/carto-dynamic-tile-layer.js.map +1 -0
  40. package/dist/esm/layers/carto-layer.js +8 -1
  41. package/dist/esm/layers/carto-layer.js.map +1 -1
  42. package/dist/esm/style/color-bins-style.js +1 -1
  43. package/dist/esm/style/color-bins-style.js.map +1 -1
  44. package/dist/esm/style/color-continuous-style.js +1 -1
  45. package/dist/esm/style/color-continuous-style.js.map +1 -1
  46. package/dist.min.js +4 -4
  47. package/package.json +8 -7
  48. package/src/api/layer-map.js +13 -1
  49. package/src/api/maps-v3-client.js +35 -18
  50. package/src/api/parseMap.js +23 -19
  51. package/src/layers/carto-dynamic-tile-layer.js +86 -0
  52. package/src/layers/carto-layer.js +10 -4
  53. package/src/style/color-bins-style.js +1 -1
  54. package/src/style/color-continuous-style.js +1 -1
@@ -1,12 +1,36 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.default = void 0;
7
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
+
16
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+
18
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
+
20
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
+
22
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
23
+
24
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
25
+
26
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
27
+
28
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
29
+
8
30
  var _core = require("@deck.gl/core");
9
31
 
32
+ var _cartoDynamicTileLayer = _interopRequireDefault(require("./carto-dynamic-tile-layer"));
33
+
10
34
  var _geoLayers = require("@deck.gl/geo-layers");
11
35
 
12
36
  var _layers = require("@deck.gl/layers");
@@ -17,12 +41,22 @@ var _mapsApiCommon = require("../api/maps-api-common");
17
41
 
18
42
  var _config = require("../config");
19
43
 
20
- const defaultProps = {
44
+ var _excluded = ["type", "data", "clientId", "credentials"];
45
+
46
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
47
+
48
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
49
+
50
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
51
+
52
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
53
+
54
+ var defaultProps = {
21
55
  data: null,
22
56
  type: null,
23
57
  onDataLoad: {
24
58
  type: 'function',
25
- value: data => {},
59
+ value: function value(data) {},
26
60
  compare: false
27
61
  },
28
62
  onDataError: {
@@ -35,6 +69,7 @@ const defaultProps = {
35
69
  credentials: null,
36
70
  connection: null,
37
71
  format: null,
72
+ clientId: null,
38
73
  geoColumn: null,
39
74
  columns: {
40
75
  type: 'array',
@@ -42,159 +77,210 @@ const defaultProps = {
42
77
  }
43
78
  };
44
79
 
45
- class CartoLayer extends _core.CompositeLayer {
46
- initializeState() {
47
- this.state = {
48
- data: null,
49
- apiVersion: null
50
- };
51
- }
80
+ var CartoLayer = function (_CompositeLayer) {
81
+ (0, _inherits2.default)(CartoLayer, _CompositeLayer);
52
82
 
53
- get isLoaded() {
54
- return this.getSubLayers().length > 0 && super.isLoaded;
83
+ var _super = _createSuper(CartoLayer);
84
+
85
+ function CartoLayer() {
86
+ (0, _classCallCheck2.default)(this, CartoLayer);
87
+ return _super.apply(this, arguments);
55
88
  }
56
89
 
57
- _checkProps(props) {
58
- const {
59
- type,
60
- credentials,
61
- connection,
62
- geoColumn,
63
- columns
64
- } = props;
65
- const localCreds = { ...(0, _config.getDefaultCredentials)(),
66
- ...credentials
67
- };
68
- const {
69
- apiVersion
70
- } = localCreds;
90
+ (0, _createClass2.default)(CartoLayer, [{
91
+ key: "initializeState",
92
+ value: function initializeState() {
93
+ this.state = {
94
+ data: null,
95
+ apiVersion: null
96
+ };
97
+ }
98
+ }, {
99
+ key: "isLoaded",
100
+ get: function get() {
101
+ return this.getSubLayers().length > 0 && (0, _get2.default)((0, _getPrototypeOf2.default)(CartoLayer.prototype), "isLoaded", this);
102
+ }
103
+ }, {
104
+ key: "_checkProps",
105
+ value: function _checkProps(props) {
106
+ var type = props.type,
107
+ credentials = props.credentials,
108
+ connection = props.connection,
109
+ geoColumn = props.geoColumn,
110
+ columns = props.columns;
71
111
 
72
- _core.log.assert(Object.values(_api.API_VERSIONS).includes(apiVersion), "Invalid apiVersion ".concat(apiVersion, ". Use API_VERSIONS enum."));
112
+ var localCreds = _objectSpread(_objectSpread({}, (0, _config.getDefaultCredentials)()), credentials);
73
113
 
74
- if (apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2) {
75
- _core.log.assert(type === _mapsApiCommon.MAP_TYPES.QUERY || type === _mapsApiCommon.MAP_TYPES.TILESET, "Invalid type ".concat(type, ". Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ").concat(apiVersion));
114
+ var apiVersion = localCreds.apiVersion;
76
115
 
77
- _core.log.assert(!connection, "Connection prop is not supported for apiVersion ".concat(apiVersion));
116
+ _core.log.assert(Object.values(_api.API_VERSIONS).includes(apiVersion), "Invalid apiVersion ".concat(apiVersion, ". Use API_VERSIONS enum."));
78
117
 
79
- _core.log.assert(!geoColumn, "geoColumn prop is not supported for apiVersion ".concat(apiVersion));
118
+ if (apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2) {
119
+ _core.log.assert(type === _mapsApiCommon.MAP_TYPES.QUERY || type === _mapsApiCommon.MAP_TYPES.TILESET, "Invalid type ".concat(type, ". Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ").concat(apiVersion));
80
120
 
81
- _core.log.assert(!columns, "columns prop is not supported for apiVersion ".concat(apiVersion));
82
- } else if (apiVersion === _api.API_VERSIONS.V3) {
83
- _core.log.assert(connection, 'Missing mandatory connection parameter');
121
+ _core.log.assert(!connection, "Connection prop is not supported for apiVersion ".concat(apiVersion));
84
122
 
85
- _core.log.assert(Object.values(_mapsApiCommon.MAP_TYPES).includes(type), "Invalid type ".concat(type, ". Use MAP_TYPES enum."));
123
+ _core.log.assert(!geoColumn, "geoColumn prop is not supported for apiVersion ".concat(apiVersion));
86
124
 
87
- if (type !== _mapsApiCommon.MAP_TYPES.TABLE) {
88
- _core.log.assert(!geoColumn, "geoColumn prop is only supported for type ".concat(_mapsApiCommon.MAP_TYPES.TABLE));
125
+ _core.log.assert(!columns, "columns prop is not supported for apiVersion ".concat(apiVersion));
126
+ } else if (apiVersion === _api.API_VERSIONS.V3) {
127
+ _core.log.assert(connection, 'Missing mandatory connection parameter');
89
128
 
90
- _core.log.assert(!columns, "columns prop is only supported for type ".concat(_mapsApiCommon.MAP_TYPES.TABLE));
91
- }
129
+ _core.log.assert(Object.values(_mapsApiCommon.MAP_TYPES).includes(type), "Invalid type ".concat(type, ". Use MAP_TYPES enum."));
92
130
 
93
- if (columns) {
94
- _core.log.assert(Array.isArray(columns), 'columns prop must be an Array');
131
+ if (type !== _mapsApiCommon.MAP_TYPES.TABLE) {
132
+ _core.log.assert(!geoColumn, "geoColumn prop is only supported for type ".concat(_mapsApiCommon.MAP_TYPES.TABLE));
133
+
134
+ _core.log.assert(!columns, "columns prop is only supported for type ".concat(_mapsApiCommon.MAP_TYPES.TABLE));
135
+ }
136
+
137
+ if (columns) {
138
+ _core.log.assert(Array.isArray(columns), 'columns prop must be an Array');
139
+ }
95
140
  }
96
141
  }
97
- }
142
+ }, {
143
+ key: "updateState",
144
+ value: function updateState(_ref) {
145
+ var props = _ref.props,
146
+ oldProps = _ref.oldProps,
147
+ changeFlags = _ref.changeFlags;
98
148
 
99
- updateState({
100
- props,
101
- oldProps,
102
- changeFlags
103
- }) {
104
- this._checkProps(props);
149
+ this._checkProps(props);
105
150
 
106
- const shouldUpdateData = changeFlags.dataChanged || props.connection !== oldProps.connection || props.geoColumn !== oldProps.geoColumn || JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) || props.type !== oldProps.type || JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials);
151
+ var shouldUpdateData = changeFlags.dataChanged || props.connection !== oldProps.connection || props.geoColumn !== oldProps.geoColumn || JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) || props.type !== oldProps.type || JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials);
107
152
 
108
- if (shouldUpdateData) {
109
- this.setState({
110
- data: null,
111
- apiVersion: null
112
- });
153
+ if (shouldUpdateData) {
154
+ this.setState({
155
+ data: null,
156
+ apiVersion: null
157
+ });
113
158
 
114
- this._updateData();
159
+ this._updateData();
160
+ }
115
161
  }
116
- }
117
-
118
- async _updateData() {
119
- try {
120
- const {
121
- type,
122
- data: source,
123
- credentials,
124
- ...rest
125
- } = this.props;
126
- const localConfig = { ...(0, _config.getDefaultCredentials)(),
127
- ...credentials
128
- };
129
- const {
130
- apiVersion
131
- } = localConfig;
132
- let result;
133
-
134
- if (apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2) {
135
- result = {
136
- data: await (0, _api.getDataV2)({
137
- type,
138
- source,
139
- credentials
140
- })
141
- };
142
- } else {
143
- result = await (0, _api.fetchLayerData)({
144
- type,
145
- source,
146
- credentials,
147
- ...rest
148
- });
162
+ }, {
163
+ key: "_updateData",
164
+ value: function () {
165
+ var _updateData2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
166
+ var _this$props, type, source, clientId, credentials, rest, localConfig, apiVersion, result;
167
+
168
+ return _regenerator.default.wrap(function _callee$(_context) {
169
+ while (1) {
170
+ switch (_context.prev = _context.next) {
171
+ case 0:
172
+ _context.prev = 0;
173
+ _this$props = this.props, type = _this$props.type, source = _this$props.data, clientId = _this$props.clientId, credentials = _this$props.credentials, rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
174
+ localConfig = _objectSpread(_objectSpread({}, (0, _config.getDefaultCredentials)()), credentials);
175
+ apiVersion = localConfig.apiVersion;
176
+
177
+ if (!(apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2)) {
178
+ _context.next = 11;
179
+ break;
180
+ }
181
+
182
+ _context.next = 7;
183
+ return (0, _api.getDataV2)({
184
+ type: type,
185
+ source: source,
186
+ credentials: credentials
187
+ });
188
+
189
+ case 7:
190
+ _context.t0 = _context.sent;
191
+ result = {
192
+ data: _context.t0
193
+ };
194
+ _context.next = 14;
195
+ break;
196
+
197
+ case 11:
198
+ _context.next = 13;
199
+ return (0, _api.fetchLayerData)(_objectSpread({
200
+ type: type,
201
+ source: source,
202
+ clientId: clientId,
203
+ credentials: credentials
204
+ }, rest));
205
+
206
+ case 13:
207
+ result = _context.sent;
208
+
209
+ case 14:
210
+ this.setState(_objectSpread(_objectSpread({}, result), {}, {
211
+ apiVersion: apiVersion
212
+ }));
213
+ this.props.onDataLoad(result.data);
214
+ _context.next = 25;
215
+ break;
216
+
217
+ case 18:
218
+ _context.prev = 18;
219
+ _context.t1 = _context["catch"](0);
220
+
221
+ if (!this.props.onDataError) {
222
+ _context.next = 24;
223
+ break;
224
+ }
225
+
226
+ this.props.onDataError(_context.t1);
227
+ _context.next = 25;
228
+ break;
229
+
230
+ case 24:
231
+ throw _context.t1;
232
+
233
+ case 25:
234
+ case "end":
235
+ return _context.stop();
236
+ }
237
+ }
238
+ }, _callee, this, [[0, 18]]);
239
+ }));
240
+
241
+ function _updateData() {
242
+ return _updateData2.apply(this, arguments);
149
243
  }
150
244
 
151
- this.setState({ ...result,
152
- apiVersion
153
- });
154
- this.props.onDataLoad(result.data);
155
- } catch (err) {
156
- if (this.props.onDataError) {
157
- this.props.onDataError(err);
245
+ return _updateData;
246
+ }()
247
+ }, {
248
+ key: "renderLayers",
249
+ value: function renderLayers() {
250
+ var _this$state = this.state,
251
+ data = _this$state.data,
252
+ format = _this$state.format,
253
+ apiVersion = _this$state.apiVersion;
254
+ if (!data) return null;
255
+ var _this$props2 = this.props,
256
+ type = _this$props2.type,
257
+ updateTriggers = _this$props2.updateTriggers;
258
+ var layer;
259
+
260
+ if (apiVersion === _api.API_VERSIONS.V3 && type === _mapsApiCommon.MAP_TYPES.TABLE && format === _mapsApiCommon.FORMATS.TILEJSON) {
261
+ layer = _cartoDynamicTileLayer.default;
262
+ } else if (apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2 || format === _mapsApiCommon.FORMATS.TILEJSON) {
263
+ layer = _geoLayers.MVTLayer;
158
264
  } else {
159
- throw err;
265
+ layer = _layers.GeoJsonLayer;
160
266
  }
161
- }
162
- }
163
267
 
164
- renderLayers() {
165
- const {
166
- data,
167
- format,
168
- apiVersion
169
- } = this.state;
170
- if (!data) return null;
171
- const {
172
- updateTriggers
173
- } = this.props;
174
- let layer;
175
-
176
- if (apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2 || format === _mapsApiCommon.FORMATS.TILEJSON) {
177
- layer = _geoLayers.MVTLayer;
178
- } else {
179
- layer = _layers.GeoJsonLayer;
180
- }
268
+ var uniqueIdProperty = defaultProps.uniqueIdProperty;
181
269
 
182
- const {
183
- uniqueIdProperty
184
- } = defaultProps;
185
- const props = {
186
- uniqueIdProperty,
187
- ...this.props
188
- };
189
- delete props.data;
190
- return new layer(props, this.getSubLayerProps({
191
- id: "carto-".concat(layer.layerName),
192
- data,
193
- updateTriggers
194
- }));
195
- }
270
+ var props = _objectSpread({
271
+ uniqueIdProperty: uniqueIdProperty
272
+ }, this.props);
196
273
 
197
- }
274
+ delete props.data;
275
+ return new layer(props, this.getSubLayerProps({
276
+ id: "carto-".concat(layer.layerName),
277
+ data: data,
278
+ updateTriggers: updateTriggers
279
+ }));
280
+ }
281
+ }]);
282
+ return CartoLayer;
283
+ }(_core.CompositeLayer);
198
284
 
199
285
  exports.default = CartoLayer;
200
286
  CartoLayer.layerName = 'CartoLayer';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/layers/carto-layer.js"],"names":["defaultProps","data","type","onDataLoad","value","compare","onDataError","optional","uniqueIdProperty","credentials","connection","format","geoColumn","columns","CartoLayer","CompositeLayer","initializeState","state","apiVersion","isLoaded","getSubLayers","length","_checkProps","props","localCreds","log","assert","Object","values","API_VERSIONS","includes","V1","V2","MAP_TYPES","QUERY","TILESET","V3","TABLE","Array","isArray","updateState","oldProps","changeFlags","shouldUpdateData","dataChanged","JSON","stringify","setState","_updateData","source","rest","localConfig","result","err","renderLayers","updateTriggers","layer","FORMATS","TILEJSON","MVTLayer","GeoJsonLayer","getSubLayerProps","id","layerName"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,YAAY,GAAG;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAInBC,EAAAA,IAAI,EAAE,IAJa;AAKnBC,EAAAA,UAAU,EAAE;AAACD,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAEH,IAAI,IAAI,CAAE,CAApC;AAAsCI,IAAAA,OAAO,EAAE;AAA/C,GALO;AAMnBC,EAAAA,WAAW,EAAE;AAACJ,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,IAA1B;AAAgCC,IAAAA,OAAO,EAAE,KAAzC;AAAgDE,IAAAA,QAAQ,EAAE;AAA1D,GANM;AAOnBC,EAAAA,gBAAgB,EAAE,YAPC;AAUnBC,EAAAA,WAAW,EAAE,IAVM;AAgBnBC,EAAAA,UAAU,EAAE,IAhBO;AAmBnBC,EAAAA,MAAM,EAAE,IAnBW;AAsBnBC,EAAAA,SAAS,EAAE,IAtBQ;AAyBnBC,EAAAA,OAAO,EAAE;AAACX,IAAAA,IAAI,EAAE,OAAP;AAAgBE,IAAAA,KAAK,EAAE;AAAvB;AAzBU,CAArB;;AA4Be,MAAMU,UAAN,SAAyBC,oBAAzB,CAAwC;AACrDC,EAAAA,eAAe,GAAG;AAChB,SAAKC,KAAL,GAAa;AACXhB,MAAAA,IAAI,EAAE,IADK;AAEXiB,MAAAA,UAAU,EAAE;AAFD,KAAb;AAID;;AAEW,MAARC,QAAQ,GAAG;AACb,WAAO,KAAKC,YAAL,GAAoBC,MAApB,GAA6B,CAA7B,IAAkC,MAAMF,QAA/C;AACD;;AAEDG,EAAAA,WAAW,CAACC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d;AACA,WAAOA,KAAK,CAACtB,IAAb;AAGA,WAAO,IAAIuD,KAAJ,CACLjC,KADK,EAEL,KAAKsC,gBAAL,CAAsB;AACpBC,MAAAA,EAAE,kBAAWN,KAAK,CAACO,SAAjB,CADkB;AAEpB9D,MAAAA,IAFoB;AAGpBsD,MAAAA;AAHoB,KAAtB,CAFK,CAAP;AAQD;;AAtHoD;;;AAyHvDzC,UAAU,CAACiD,SAAX,GAAuB,YAAvB;AACAjD,UAAU,CAACd,YAAX,GAA0BA,YAA1B","sourcesContent":["import {CompositeLayer, log} from '@deck.gl/core';\nimport {MVTLayer} from '@deck.gl/geo-layers';\nimport {GeoJsonLayer} from '@deck.gl/layers';\nimport {fetchLayerData, getDataV2, API_VERSIONS} from '../api';\nimport {FORMATS, MAP_TYPES} from '../api/maps-api-common';\nimport {getDefaultCredentials} from '../config';\n\nconst defaultProps = {\n // (String, required): data resource to load. table name, sql query or tileset name.\n data: null,\n // (Enum (MAP_TYPES), required)\n type: null,\n onDataLoad: {type: 'function', value: data => {}, compare: false},\n onDataError: {type: 'function', value: null, compare: false, optional: true},\n uniqueIdProperty: 'cartodb_id',\n\n // override carto credentials for the layer, set to null to read from default\n credentials: null,\n\n /*********************/\n /* API v3 PARAMETERS */\n /**********************/\n // (String, required): connection name at CARTO platform\n connection: null,\n\n // (String, optional): format of data\n format: null,\n\n // (String, optional): name of the `geo_column` in the CARTO platform. Use this override the default column ('geom'), from which the geometry information should be fetched.\n geoColumn: null,\n\n // (Array<String>, optional): names of columns to fetch. By default, all columns are fetched.\n columns: {type: 'array', value: null}\n};\n\nexport default class CartoLayer extends CompositeLayer {\n initializeState() {\n this.state = {\n data: null,\n apiVersion: null\n };\n }\n\n get isLoaded() {\n return this.getSubLayers().length > 0 && super.isLoaded;\n }\n\n _checkProps(props) {\n const {type, credentials, connection, geoColumn, columns} = props;\n const localCreds = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localCreds;\n\n log.assert(\n Object.values(API_VERSIONS).includes(apiVersion),\n `Invalid apiVersion ${apiVersion}. Use API_VERSIONS enum.`\n );\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n log.assert(\n type === MAP_TYPES.QUERY || type === MAP_TYPES.TILESET,\n `Invalid type ${type}. Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ${apiVersion}`\n );\n log.assert(!connection, `Connection prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!geoColumn, `geoColumn prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!columns, `columns prop is not supported for apiVersion ${apiVersion}`);\n } else if (apiVersion === API_VERSIONS.V3) {\n log.assert(connection, 'Missing mandatory connection parameter');\n log.assert(\n Object.values(MAP_TYPES).includes(type),\n `Invalid type ${type}. Use MAP_TYPES enum.`\n );\n if (type !== MAP_TYPES.TABLE) {\n log.assert(!geoColumn, `geoColumn prop is only supported for type ${MAP_TYPES.TABLE}`);\n log.assert(!columns, `columns prop is only supported for type ${MAP_TYPES.TABLE}`);\n }\n if (columns) {\n log.assert(Array.isArray(columns), 'columns prop must be an Array');\n }\n }\n }\n\n updateState({props, oldProps, changeFlags}) {\n this._checkProps(props);\n const shouldUpdateData =\n changeFlags.dataChanged ||\n props.connection !== oldProps.connection ||\n props.geoColumn !== oldProps.geoColumn ||\n JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||\n props.type !== oldProps.type ||\n JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials);\n\n if (shouldUpdateData) {\n this.setState({data: null, apiVersion: null});\n this._updateData();\n }\n }\n\n async _updateData() {\n try {\n const {type, data: source, credentials, ...rest} = this.props;\n const localConfig = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localConfig;\n\n let result;\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n result = {data: await getDataV2({type, source, credentials})};\n } else {\n result = await fetchLayerData({type, source, credentials, ...rest});\n }\n\n this.setState({...result, apiVersion});\n this.props.onDataLoad(result.data);\n } catch (err) {\n if (this.props.onDataError) {\n this.props.onDataError(err);\n } else {\n throw err;\n }\n }\n }\n\n renderLayers() {\n const {data, format, apiVersion} = this.state;\n\n if (!data) return null;\n\n const {updateTriggers} = this.props;\n\n let layer;\n\n if (\n apiVersion === API_VERSIONS.V1 ||\n apiVersion === API_VERSIONS.V2 ||\n format === FORMATS.TILEJSON\n ) {\n layer = MVTLayer;\n } else {\n layer = GeoJsonLayer;\n }\n\n const {uniqueIdProperty} = defaultProps;\n const props = {uniqueIdProperty, ...this.props};\n delete props.data;\n\n // eslint-disable-next-line new-cap\n return new layer(\n props,\n this.getSubLayerProps({\n id: `carto-${layer.layerName}`,\n data,\n updateTriggers\n })\n );\n }\n}\n\nCartoLayer.layerName = 'CartoLayer';\nCartoLayer.defaultProps = defaultProps;\n"],"file":"carto-layer.js"}
1
+ {"version":3,"sources":["../../../src/layers/carto-layer.js"],"names":["defaultProps","data","type","onDataLoad","value","compare","onDataError","optional","uniqueIdProperty","credentials","connection","format","clientId","geoColumn","columns","CartoLayer","state","apiVersion","getSubLayers","length","props","localCreds","log","assert","Object","values","API_VERSIONS","includes","V1","V2","MAP_TYPES","QUERY","TILESET","V3","TABLE","Array","isArray","oldProps","changeFlags","_checkProps","shouldUpdateData","dataChanged","JSON","stringify","setState","_updateData","source","rest","localConfig","result","updateTriggers","layer","FORMATS","TILEJSON","CartoDynamicTileLayer","MVTLayer","GeoJsonLayer","getSubLayerProps","id","layerName","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,YAAY,GAAG;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAInBC,EAAAA,IAAI,EAAE,IAJa;AAKnBC,EAAAA,UAAU,EAAE;AAACD,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,eAAAH,IAAI,EAAI,CAAE,CAApC;AAAsC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BAAP,GAA2BR,YAA3B,CAAOQ,gBAAP;;AACA,UAAMY,KAAK;AAAIZ,QAAAA,gBAAgB,EAAhBA;AAAJ,SAAyB,KAAKY,KAA9B,CAAX;;AACA,aAAOA,KAAK,CAACnB,IAAb;AAGA,aAAO,IAAIkD,KAAJ,CACL/B,KADK,EAEL,KAAKqC,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,kBAAWP,KAAK,CAACQ,SAAjB,CADkB;AAEpB1D,QAAAA,IAAI,EAAJA,IAFoB;AAGpBiD,QAAAA,cAAc,EAAdA;AAHoB,OAAtB,CAFK,CAAP;AAQD;;;EAxHqCU,oB;;;AA2HxC7C,UAAU,CAAC4C,SAAX,GAAuB,YAAvB;AACA5C,UAAU,CAACf,YAAX,GAA0BA,YAA1B","sourcesContent":["import {CompositeLayer, log} from '@deck.gl/core';\nimport CartoDynamicTileLayer from './carto-dynamic-tile-layer';\nimport {MVTLayer} from '@deck.gl/geo-layers';\nimport {GeoJsonLayer} from '@deck.gl/layers';\nimport {fetchLayerData, getDataV2, API_VERSIONS} from '../api';\nimport {FORMATS, MAP_TYPES} from '../api/maps-api-common';\nimport {getDefaultCredentials} from '../config';\n\nconst defaultProps = {\n // (String, required): data resource to load. table name, sql query or tileset name.\n data: null,\n // (Enum (MAP_TYPES), required)\n type: null,\n onDataLoad: {type: 'function', value: data => {}, compare: false},\n onDataError: {type: 'function', value: null, compare: false, optional: true},\n uniqueIdProperty: 'cartodb_id',\n\n // override carto credentials for the layer, set to null to read from default\n credentials: null,\n\n /*********************/\n /* API v3 PARAMETERS */\n /**********************/\n // (String, required): connection name at CARTO platform\n connection: null,\n\n // (String, optional): format of data\n format: null,\n\n // (String, optional): clientId identifier used for internal tracing, place here a string to identify the client who is doing the request.\n clientId: null,\n\n // (String, optional): name of the `geo_column` in the CARTO platform. Use this override the default column ('geom'), from which the geometry information should be fetched.\n geoColumn: null,\n\n // (Array<String>, optional): names of columns to fetch. By default, all columns are fetched.\n columns: {type: 'array', value: null}\n};\n\nexport default class CartoLayer extends CompositeLayer {\n initializeState() {\n this.state = {\n data: null,\n apiVersion: null\n };\n }\n\n get isLoaded() {\n return this.getSubLayers().length > 0 && super.isLoaded;\n }\n\n _checkProps(props) {\n const {type, credentials, connection, geoColumn, columns} = props;\n const localCreds = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localCreds;\n\n log.assert(\n Object.values(API_VERSIONS).includes(apiVersion),\n `Invalid apiVersion ${apiVersion}. Use API_VERSIONS enum.`\n );\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n log.assert(\n type === MAP_TYPES.QUERY || type === MAP_TYPES.TILESET,\n `Invalid type ${type}. Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ${apiVersion}`\n );\n log.assert(!connection, `Connection prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!geoColumn, `geoColumn prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!columns, `columns prop is not supported for apiVersion ${apiVersion}`);\n } else if (apiVersion === API_VERSIONS.V3) {\n log.assert(connection, 'Missing mandatory connection parameter');\n log.assert(\n Object.values(MAP_TYPES).includes(type),\n `Invalid type ${type}. Use MAP_TYPES enum.`\n );\n if (type !== MAP_TYPES.TABLE) {\n log.assert(!geoColumn, `geoColumn prop is only supported for type ${MAP_TYPES.TABLE}`);\n log.assert(!columns, `columns prop is only supported for type ${MAP_TYPES.TABLE}`);\n }\n if (columns) {\n log.assert(Array.isArray(columns), 'columns prop must be an Array');\n }\n }\n }\n\n updateState({props, oldProps, changeFlags}) {\n this._checkProps(props);\n const shouldUpdateData =\n changeFlags.dataChanged ||\n props.connection !== oldProps.connection ||\n props.geoColumn !== oldProps.geoColumn ||\n JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||\n props.type !== oldProps.type ||\n JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials);\n\n if (shouldUpdateData) {\n this.setState({data: null, apiVersion: null});\n this._updateData();\n }\n }\n\n async _updateData() {\n try {\n const {type, data: source, clientId, credentials, ...rest} = this.props;\n const localConfig = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localConfig;\n\n let result;\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n result = {data: await getDataV2({type, source, credentials})};\n } else {\n result = await fetchLayerData({type, source, clientId, credentials, ...rest});\n }\n\n this.setState({...result, apiVersion});\n this.props.onDataLoad(result.data);\n } catch (err) {\n if (this.props.onDataError) {\n this.props.onDataError(err);\n } else {\n throw err;\n }\n }\n }\n\n renderLayers() {\n const {data, format, apiVersion} = this.state;\n\n if (!data) return null;\n\n const {type, updateTriggers} = this.props;\n\n let layer;\n\n if (apiVersion === API_VERSIONS.V3 && type === MAP_TYPES.TABLE && format === FORMATS.TILEJSON) {\n layer = CartoDynamicTileLayer;\n } else if (\n apiVersion === API_VERSIONS.V1 ||\n apiVersion === API_VERSIONS.V2 ||\n format === FORMATS.TILEJSON\n ) {\n layer = MVTLayer;\n } else {\n layer = GeoJsonLayer;\n }\n\n const {uniqueIdProperty} = defaultProps;\n const props = {uniqueIdProperty, ...this.props};\n delete props.data;\n\n // eslint-disable-next-line new-cap\n return new layer(\n props,\n this.getSubLayerProps({\n id: `carto-${layer.layerName}`,\n data,\n updateTriggers\n })\n );\n }\n}\n\nCartoLayer.layerName = 'CartoLayer';\nCartoLayer.defaultProps = defaultProps;\n"],"file":"carto-layer.js"}
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -11,21 +13,22 @@ var _palette = _interopRequireWildcard(require("./palette"));
11
13
 
12
14
  var _utils = require("./utils");
13
15
 
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
17
 
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
19
 
18
- function colorBins({
19
- attr,
20
- domain,
21
- colors = _palette.DEFAULT_PALETTE,
22
- nullColor = _palette.NULL_COLOR
23
- }) {
20
+ function colorBins(_ref) {
21
+ var attr = _ref.attr,
22
+ domain = _ref.domain,
23
+ _ref$colors = _ref.colors,
24
+ colors = _ref$colors === void 0 ? _palette.DEFAULT_PALETTE : _ref$colors,
25
+ _ref$nullColor = _ref.nullColor,
26
+ nullColor = _ref$nullColor === void 0 ? _palette.NULL_COLOR : _ref$nullColor;
24
27
  (0, _utils.assert)(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
25
- const palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length) : colors;
26
- const color = (0, _d3Scale.scaleThreshold)().domain(domain).range(palette);
27
- return d => {
28
- const value = (0, _utils.getAttrValue)(attr, d);
28
+ var palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length + 1) : colors;
29
+ var color = (0, _d3Scale.scaleThreshold)().domain(domain).range(palette);
30
+ return function (d) {
31
+ var value = (0, _utils.getAttrValue)(attr, d);
29
32
  return Number.isFinite(value) ? color(value) : nullColor;
30
33
  };
31
34
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-bins-style.js"],"names":["colorBins","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAEe,SAASA,SAAT,CAAmB;AAChCC,EAAAA,IADgC;AAEhCC,EAAAA,MAFgC;AAGhCC,EAAAA,MAAM,GAAGC,wBAHuB;AAIhCC,EAAAA,SAAS,GAAGC;AAJoB,CAAnB,EAKZ;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,QAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACQ,MAA1B,CAA7B,GAAiEP,MAAjF;AAEA,QAAMQ,KAAK,GAAG,+BAAiBT,MAAjB,CAAwBA,MAAxB,EAAgCU,KAAhC,CAAsCH,OAAtC,CAAd;AAEA,SAAOI,CAAC,IAAI;AACV,UAAMC,KAAK,GAAG,yBAAab,IAAb,EAAmBY,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCT,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleThreshold} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorBins({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n const color = scaleThreshold().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-bins-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-bins-style.js"],"names":["colorBins","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;;;AAEe,SAASA,SAAT,OAKZ;AAAA,MAJDC,IAIC,QAJDA,IAIC;AAAA,MAHDC,MAGC,QAHDA,MAGC;AAAA,yBAFDC,MAEC;AAAA,MAFDA,MAEC,4BAFQC,wBAER;AAAA,4BADDC,SACC;AAAA,MADDA,SACC,+BADWC,mBACX;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,MAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACQ,MAAP,GAAgB,CAAnC,CAA7B,GAAqEP,MAArF;AAEA,MAAMQ,KAAK,GAAG,+BAAiBT,MAAjB,CAAwBA,MAAxB,EAAgCU,KAAhC,CAAsCH,OAAtC,CAAd;AAEA,SAAO,UAAAI,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAab,IAAb,EAAmBY,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCT,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleThreshold} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorBins({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length + 1) : colors;\n\n const color = scaleThreshold().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-bins-style.js"}
@@ -1,35 +1,62 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
3
7
  Object.defineProperty(exports, "__esModule", {
4
8
  value: true
5
9
  });
6
10
  exports.default = colorCategories;
7
11
 
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
8
14
  var _palette = _interopRequireWildcard(require("./palette"));
9
15
 
10
16
  var _utils = require("./utils");
11
17
 
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
19
 
14
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
21
 
16
- function colorCategories({
17
- attr,
18
- domain,
19
- colors = _palette.DEFAULT_PALETTE,
20
- nullColor = _palette.NULL_COLOR,
21
- othersColor = _palette.OTHERS_COLOR
22
- }) {
23
- (0, _utils.assert)(Array.isArray(domain), 'Expected "domain" to be an array of numbers or strings');
24
- const colorsByCategory = {};
25
- const palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length) : colors;
22
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
26
23
 
27
- for (const [i, c] of domain.entries()) {
28
- colorsByCategory[c] = palette[i];
24
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
+
26
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
27
+
28
+ function colorCategories(_ref) {
29
+ var attr = _ref.attr,
30
+ domain = _ref.domain,
31
+ _ref$colors = _ref.colors,
32
+ colors = _ref$colors === void 0 ? _palette.DEFAULT_PALETTE : _ref$colors,
33
+ _ref$nullColor = _ref.nullColor,
34
+ nullColor = _ref$nullColor === void 0 ? _palette.NULL_COLOR : _ref$nullColor,
35
+ _ref$othersColor = _ref.othersColor,
36
+ othersColor = _ref$othersColor === void 0 ? _palette.OTHERS_COLOR : _ref$othersColor;
37
+ (0, _utils.assert)(Array.isArray(domain), 'Expected "domain" to be an array of numbers or strings');
38
+ var colorsByCategory = {};
39
+ var palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length) : colors;
40
+
41
+ var _iterator = _createForOfIteratorHelper(domain.entries()),
42
+ _step;
43
+
44
+ try {
45
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
46
+ var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
47
+ i = _step$value[0],
48
+ c = _step$value[1];
49
+
50
+ colorsByCategory[c] = palette[i];
51
+ }
52
+ } catch (err) {
53
+ _iterator.e(err);
54
+ } finally {
55
+ _iterator.f();
29
56
  }
30
57
 
31
- return d => {
32
- const value = (0, _utils.getAttrValue)(attr, d);
58
+ return function (d) {
59
+ var value = (0, _utils.getAttrValue)(attr, d);
33
60
  return Number.isFinite(value) || typeof value === 'string' ? colorsByCategory[value] || othersColor : nullColor;
34
61
  };
35
62
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-categories-style.js"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","i","c","entries","d","value","Number","isFinite"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEe,SAASA,eAAT,CAAyB;AACtCC,EAAAA,IADsC;AAEtCC,EAAAA,MAFsC;AAGtCC,EAAAA,MAAM,GAAGC,wBAH6B;AAItCC,EAAAA,SAAS,GAAGC,mBAJ0B;AAKtCC,EAAAA,WAAW,GAAGC;AALwB,CAAzB,EAMZ;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcR,MAAd,CAAP,EAA8B,wDAA9B;AAEA,QAAMS,gBAAgB,GAAG,EAAzB;AACA,QAAMC,OAAO,GAAG,OAAOT,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACW,MAA1B,CAA7B,GAAiEV,MAAjF;;AAEA,OAAK,MAAM,CAACW,CAAD,EAAIC,CAAJ,CAAX,IAAqBb,MAAM,CAACc,OAAP,EAArB,EAAuC;AACrCL,IAAAA,gBAAgB,CAACI,CAAD,CAAhB,GAAsBH,OAAO,CAACE,CAAD,CAA7B;AACD;;AAED,SAAOG,CAAC,IAAI;AACV,UAAMC,KAAK,GAAG,yBAAajB,IAAb,EAAmBgB,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,KAA0B,OAAOA,KAAP,KAAiB,QAA3C,GACHP,gBAAgB,CAACO,KAAD,CAAhB,IAA2BX,WADxB,GAEHF,SAFJ;AAGD,GALD;AAMD","sourcesContent":["import getPalette, {DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorCategories({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR,\n othersColor = OTHERS_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers or strings');\n\n const colorsByCategory = {};\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n for (const [i, c] of domain.entries()) {\n colorsByCategory[c] = palette[i];\n }\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) || typeof value === 'string'\n ? colorsByCategory[value] || othersColor\n : nullColor;\n };\n}\n"],"file":"color-categories-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-categories-style.js"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","entries","i","c","d","value","Number","isFinite"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;;;;;;;;;;;AAEe,SAASA,eAAT,OAMZ;AAAA,MALDC,IAKC,QALDA,IAKC;AAAA,MAJDC,MAIC,QAJDA,MAIC;AAAA,yBAHDC,MAGC;AAAA,MAHDA,MAGC,4BAHQC,wBAGR;AAAA,4BAFDC,SAEC;AAAA,MAFDA,SAEC,+BAFWC,mBAEX;AAAA,8BADDC,WACC;AAAA,MADDA,WACC,iCADaC,qBACb;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcR,MAAd,CAAP,EAA8B,wDAA9B;AAEA,MAAMS,gBAAgB,GAAG,EAAzB;AACA,MAAMC,OAAO,GAAG,OAAOT,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACW,MAA1B,CAA7B,GAAiEV,MAAjF;;AAJC,6CAMoBD,MAAM,CAACY,OAAP,EANpB;AAAA;;AAAA;AAMD,wDAAuC;AAAA;AAAA,UAA3BC,CAA2B;AAAA,UAAxBC,CAAwB;;AACrCL,MAAAA,gBAAgB,CAACK,CAAD,CAAhB,GAAsBJ,OAAO,CAACG,CAAD,CAA7B;AACD;AARA;AAAA;AAAA;AAAA;AAAA;;AAUD,SAAO,UAAAE,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAajB,IAAb,EAAmBgB,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,KAA0B,OAAOA,KAAP,KAAiB,QAA3C,GACHP,gBAAgB,CAACO,KAAD,CAAhB,IAA2BX,WADxB,GAEHF,SAFJ;AAGD,GALD;AAMD","sourcesContent":["import getPalette, {DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorCategories({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR,\n othersColor = OTHERS_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers or strings');\n\n const colorsByCategory = {};\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n for (const [i, c] of domain.entries()) {\n colorsByCategory[c] = palette[i];\n }\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) || typeof value === 'string'\n ? colorsByCategory[value] || othersColor\n : nullColor;\n };\n}\n"],"file":"color-categories-style.js"}