@deck.gl/carto 8.7.0-alpha.3 → 8.7.0-alpha.7

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 (37) hide show
  1. package/dist/dist.dev.js +2385 -2436
  2. package/dist/es5/api/index.js +9 -9
  3. package/dist/es5/api/layer-map.js +82 -71
  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 +528 -312
  10. package/dist/es5/api/maps-v3-client.js.map +1 -1
  11. package/dist/es5/api/parseMap.js +88 -92
  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-layer.js +207 -129
  19. package/dist/es5/layers/carto-layer.js.map +1 -1
  20. package/dist/es5/style/color-bins-style.js +15 -12
  21. package/dist/es5/style/color-bins-style.js.map +1 -1
  22. package/dist/es5/style/color-categories-style.js +43 -16
  23. package/dist/es5/style/color-categories-style.js.map +1 -1
  24. package/dist/es5/style/color-continuous-style.js +15 -12
  25. package/dist/es5/style/color-continuous-style.js.map +1 -1
  26. package/dist/es5/style/palette.js +23 -13
  27. package/dist/es5/style/palette.js.map +1 -1
  28. package/dist/es5/style/utils.js +13 -6
  29. package/dist/es5/style/utils.js.map +1 -1
  30. package/dist/esm/style/color-bins-style.js +1 -1
  31. package/dist/esm/style/color-bins-style.js.map +1 -1
  32. package/dist/esm/style/color-continuous-style.js +1 -1
  33. package/dist/esm/style/color-continuous-style.js.map +1 -1
  34. package/dist.min.js +4 -4
  35. package/package.json +7 -7
  36. package/src/style/color-bins-style.js +1 -1
  37. package/src/style/color-continuous-style.js +1 -1
package/dist/es5/index.js CHANGED
@@ -7,91 +7,91 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  Object.defineProperty(exports, "getDefaultCredentials", {
9
9
  enumerable: true,
10
- get: function () {
10
+ get: function get() {
11
11
  return _config.getDefaultCredentials;
12
12
  }
13
13
  });
14
14
  Object.defineProperty(exports, "setDefaultCredentials", {
15
15
  enumerable: true,
16
- get: function () {
16
+ get: function get() {
17
17
  return _config.setDefaultCredentials;
18
18
  }
19
19
  });
20
20
  Object.defineProperty(exports, "CartoLayer", {
21
21
  enumerable: true,
22
- get: function () {
22
+ get: function get() {
23
23
  return _cartoLayer.default;
24
24
  }
25
25
  });
26
26
  Object.defineProperty(exports, "BASEMAP", {
27
27
  enumerable: true,
28
- get: function () {
28
+ get: function get() {
29
29
  return _basemap.default;
30
30
  }
31
31
  });
32
32
  Object.defineProperty(exports, "colorBins", {
33
33
  enumerable: true,
34
- get: function () {
34
+ get: function get() {
35
35
  return _colorBinsStyle.default;
36
36
  }
37
37
  });
38
38
  Object.defineProperty(exports, "colorCategories", {
39
39
  enumerable: true,
40
- get: function () {
40
+ get: function get() {
41
41
  return _colorCategoriesStyle.default;
42
42
  }
43
43
  });
44
44
  Object.defineProperty(exports, "colorContinuous", {
45
45
  enumerable: true,
46
- get: function () {
46
+ get: function get() {
47
47
  return _colorContinuousStyle.default;
48
48
  }
49
49
  });
50
50
  Object.defineProperty(exports, "FORMATS", {
51
51
  enumerable: true,
52
- get: function () {
52
+ get: function get() {
53
53
  return _api.FORMATS;
54
54
  }
55
55
  });
56
56
  Object.defineProperty(exports, "MAP_TYPES", {
57
57
  enumerable: true,
58
- get: function () {
58
+ get: function get() {
59
59
  return _api.MAP_TYPES;
60
60
  }
61
61
  });
62
62
  Object.defineProperty(exports, "API_VERSIONS", {
63
63
  enumerable: true,
64
- get: function () {
64
+ get: function get() {
65
65
  return _api.API_VERSIONS;
66
66
  }
67
67
  });
68
68
  Object.defineProperty(exports, "fetchLayerData", {
69
69
  enumerable: true,
70
- get: function () {
70
+ get: function get() {
71
71
  return _api.fetchLayerData;
72
72
  }
73
73
  });
74
74
  Object.defineProperty(exports, "fetchMap", {
75
75
  enumerable: true,
76
- get: function () {
76
+ get: function get() {
77
77
  return _api.fetchMap;
78
78
  }
79
79
  });
80
80
  Object.defineProperty(exports, "_getDataV2", {
81
81
  enumerable: true,
82
- get: function () {
82
+ get: function get() {
83
83
  return _api.getDataV2;
84
84
  }
85
85
  });
86
86
  Object.defineProperty(exports, "getData", {
87
87
  enumerable: true,
88
- get: function () {
88
+ get: function get() {
89
89
  return _api.getData;
90
90
  }
91
91
  });
92
92
  Object.defineProperty(exports, "_mapInstantiation", {
93
93
  enumerable: true,
94
- get: function () {
94
+ get: function get() {
95
95
  return _api.mapInstantiation;
96
96
  }
97
97
  });
@@ -1,10 +1,32 @@
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
 
10
32
  var _geoLayers = require("@deck.gl/geo-layers");
@@ -17,12 +39,22 @@ var _mapsApiCommon = require("../api/maps-api-common");
17
39
 
18
40
  var _config = require("../config");
19
41
 
20
- const defaultProps = {
42
+ var _excluded = ["type", "data", "credentials"];
43
+
44
+ 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; }
45
+
46
+ 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; }
47
+
48
+ 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); }; }
49
+
50
+ 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; } }
51
+
52
+ var defaultProps = {
21
53
  data: null,
22
54
  type: null,
23
55
  onDataLoad: {
24
56
  type: 'function',
25
- value: data => {},
57
+ value: function value(data) {},
26
58
  compare: false
27
59
  },
28
60
  onDataError: {
@@ -42,159 +74,205 @@ const defaultProps = {
42
74
  }
43
75
  };
44
76
 
45
- class CartoLayer extends _core.CompositeLayer {
46
- initializeState() {
47
- this.state = {
48
- data: null,
49
- apiVersion: null
50
- };
51
- }
77
+ var CartoLayer = function (_CompositeLayer) {
78
+ (0, _inherits2.default)(CartoLayer, _CompositeLayer);
52
79
 
53
- get isLoaded() {
54
- return this.getSubLayers().length > 0 && super.isLoaded;
80
+ var _super = _createSuper(CartoLayer);
81
+
82
+ function CartoLayer() {
83
+ (0, _classCallCheck2.default)(this, CartoLayer);
84
+ return _super.apply(this, arguments);
55
85
  }
56
86
 
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;
87
+ (0, _createClass2.default)(CartoLayer, [{
88
+ key: "initializeState",
89
+ value: function initializeState() {
90
+ this.state = {
91
+ data: null,
92
+ apiVersion: null
93
+ };
94
+ }
95
+ }, {
96
+ key: "isLoaded",
97
+ get: function get() {
98
+ return this.getSubLayers().length > 0 && (0, _get2.default)((0, _getPrototypeOf2.default)(CartoLayer.prototype), "isLoaded", this);
99
+ }
100
+ }, {
101
+ key: "_checkProps",
102
+ value: function _checkProps(props) {
103
+ var type = props.type,
104
+ credentials = props.credentials,
105
+ connection = props.connection,
106
+ geoColumn = props.geoColumn,
107
+ columns = props.columns;
108
+
109
+ var localCreds = _objectSpread(_objectSpread({}, (0, _config.getDefaultCredentials)()), credentials);
110
+
111
+ var apiVersion = localCreds.apiVersion;
71
112
 
72
- _core.log.assert(Object.values(_api.API_VERSIONS).includes(apiVersion), "Invalid apiVersion ".concat(apiVersion, ". Use API_VERSIONS enum."));
113
+ _core.log.assert(Object.values(_api.API_VERSIONS).includes(apiVersion), "Invalid apiVersion ".concat(apiVersion, ". Use API_VERSIONS enum."));
73
114
 
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));
115
+ if (apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2) {
116
+ _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));
76
117
 
77
- _core.log.assert(!connection, "Connection prop is not supported for apiVersion ".concat(apiVersion));
118
+ _core.log.assert(!connection, "Connection prop is not supported for apiVersion ".concat(apiVersion));
78
119
 
79
- _core.log.assert(!geoColumn, "geoColumn prop is not supported for apiVersion ".concat(apiVersion));
120
+ _core.log.assert(!geoColumn, "geoColumn prop is not supported for apiVersion ".concat(apiVersion));
80
121
 
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');
122
+ _core.log.assert(!columns, "columns prop is not supported for apiVersion ".concat(apiVersion));
123
+ } else if (apiVersion === _api.API_VERSIONS.V3) {
124
+ _core.log.assert(connection, 'Missing mandatory connection parameter');
84
125
 
85
- _core.log.assert(Object.values(_mapsApiCommon.MAP_TYPES).includes(type), "Invalid type ".concat(type, ". Use MAP_TYPES enum."));
126
+ _core.log.assert(Object.values(_mapsApiCommon.MAP_TYPES).includes(type), "Invalid type ".concat(type, ". Use MAP_TYPES enum."));
86
127
 
87
- if (type !== _mapsApiCommon.MAP_TYPES.TABLE) {
88
- _core.log.assert(!geoColumn, "geoColumn prop is only supported for type ".concat(_mapsApiCommon.MAP_TYPES.TABLE));
128
+ if (type !== _mapsApiCommon.MAP_TYPES.TABLE) {
129
+ _core.log.assert(!geoColumn, "geoColumn prop is only supported for type ".concat(_mapsApiCommon.MAP_TYPES.TABLE));
89
130
 
90
- _core.log.assert(!columns, "columns prop is only supported for type ".concat(_mapsApiCommon.MAP_TYPES.TABLE));
91
- }
131
+ _core.log.assert(!columns, "columns prop is only supported for type ".concat(_mapsApiCommon.MAP_TYPES.TABLE));
132
+ }
92
133
 
93
- if (columns) {
94
- _core.log.assert(Array.isArray(columns), 'columns prop must be an Array');
134
+ if (columns) {
135
+ _core.log.assert(Array.isArray(columns), 'columns prop must be an Array');
136
+ }
95
137
  }
96
138
  }
97
- }
139
+ }, {
140
+ key: "updateState",
141
+ value: function updateState(_ref) {
142
+ var props = _ref.props,
143
+ oldProps = _ref.oldProps,
144
+ changeFlags = _ref.changeFlags;
98
145
 
99
- updateState({
100
- props,
101
- oldProps,
102
- changeFlags
103
- }) {
104
- this._checkProps(props);
146
+ this._checkProps(props);
105
147
 
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);
148
+ 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
149
 
108
- if (shouldUpdateData) {
109
- this.setState({
110
- data: null,
111
- apiVersion: null
112
- });
150
+ if (shouldUpdateData) {
151
+ this.setState({
152
+ data: null,
153
+ apiVersion: null
154
+ });
113
155
 
114
- this._updateData();
156
+ this._updateData();
157
+ }
115
158
  }
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
- });
159
+ }, {
160
+ key: "_updateData",
161
+ value: function () {
162
+ var _updateData2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
163
+ var _this$props, type, source, credentials, rest, localConfig, apiVersion, result;
164
+
165
+ return _regenerator.default.wrap(function _callee$(_context) {
166
+ while (1) {
167
+ switch (_context.prev = _context.next) {
168
+ case 0:
169
+ _context.prev = 0;
170
+ _this$props = this.props, type = _this$props.type, source = _this$props.data, credentials = _this$props.credentials, rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
171
+ localConfig = _objectSpread(_objectSpread({}, (0, _config.getDefaultCredentials)()), credentials);
172
+ apiVersion = localConfig.apiVersion;
173
+
174
+ if (!(apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2)) {
175
+ _context.next = 11;
176
+ break;
177
+ }
178
+
179
+ _context.next = 7;
180
+ return (0, _api.getDataV2)({
181
+ type: type,
182
+ source: source,
183
+ credentials: credentials
184
+ });
185
+
186
+ case 7:
187
+ _context.t0 = _context.sent;
188
+ result = {
189
+ data: _context.t0
190
+ };
191
+ _context.next = 14;
192
+ break;
193
+
194
+ case 11:
195
+ _context.next = 13;
196
+ return (0, _api.fetchLayerData)(_objectSpread({
197
+ type: type,
198
+ source: source,
199
+ credentials: credentials
200
+ }, rest));
201
+
202
+ case 13:
203
+ result = _context.sent;
204
+
205
+ case 14:
206
+ this.setState(_objectSpread(_objectSpread({}, result), {}, {
207
+ apiVersion: apiVersion
208
+ }));
209
+ this.props.onDataLoad(result.data);
210
+ _context.next = 25;
211
+ break;
212
+
213
+ case 18:
214
+ _context.prev = 18;
215
+ _context.t1 = _context["catch"](0);
216
+
217
+ if (!this.props.onDataError) {
218
+ _context.next = 24;
219
+ break;
220
+ }
221
+
222
+ this.props.onDataError(_context.t1);
223
+ _context.next = 25;
224
+ break;
225
+
226
+ case 24:
227
+ throw _context.t1;
228
+
229
+ case 25:
230
+ case "end":
231
+ return _context.stop();
232
+ }
233
+ }
234
+ }, _callee, this, [[0, 18]]);
235
+ }));
236
+
237
+ function _updateData() {
238
+ return _updateData2.apply(this, arguments);
149
239
  }
150
240
 
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);
241
+ return _updateData;
242
+ }()
243
+ }, {
244
+ key: "renderLayers",
245
+ value: function renderLayers() {
246
+ var _this$state = this.state,
247
+ data = _this$state.data,
248
+ format = _this$state.format,
249
+ apiVersion = _this$state.apiVersion;
250
+ if (!data) return null;
251
+ var updateTriggers = this.props.updateTriggers;
252
+ var layer;
253
+
254
+ if (apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2 || format === _mapsApiCommon.FORMATS.TILEJSON) {
255
+ layer = _geoLayers.MVTLayer;
158
256
  } else {
159
- throw err;
257
+ layer = _layers.GeoJsonLayer;
160
258
  }
161
- }
162
- }
163
259
 
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
- }
260
+ var uniqueIdProperty = defaultProps.uniqueIdProperty;
181
261
 
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
- }
262
+ var props = _objectSpread({
263
+ uniqueIdProperty: uniqueIdProperty
264
+ }, this.props);
196
265
 
197
- }
266
+ delete props.data;
267
+ return new layer(props, this.getSubLayerProps({
268
+ id: "carto-".concat(layer.layerName),
269
+ data: data,
270
+ updateTriggers: updateTriggers
271
+ }));
272
+ }
273
+ }]);
274
+ return CartoLayer;
275
+ }(_core.CompositeLayer);
198
276
 
199
277
  exports.default = CartoLayer;
200
278
  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,IA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AAI,KAAK9B,KAAL,CAAWjB,WAAf,EAA4B;AAC1B,aAAKiB,KAAL,CAAWjB,WAAX,CAAuB+C,GAAvB;AACD,OAFD,MAEO;AACL,cAAMA,GAAN;AACD;AACF;AACF;;AAEDC,EAAAA,YAAY,GAAG;AACb,UAAM;AAACrD,MAAAA,IAAD;AAAOU,MAAAA,MAAP;AAAeO,MAAAA;AAAf,QAA6B,KAAKD,KAAxC;AAEA,QAAI,CAAChB,IAAL,EAAW,OAAO,IAAP;AAEX,UAAM;AAACsD,MAAAA;AAAD,QAAmB,KAAKhC,KAA9B;AAEA,QAAIiC,KAAJ;;AAEA,QACEtC,UAAU,KAAKW,kBAAaE,EAA5B,IACAb,UAAU,KAAKW,kBAAaG,EAD5B,IAEArB,MAAM,KAAK8C,uBAAQC,QAHrB,EAIE;AACAF,MAAAA,KAAK,GAAGG,mBAAR;AACD,KAND,MAMO;AACLH,MAAAA,KAAK,GAAGI,oBAAR;AACD;;AAED,UAAM;AAACpD,MAAAA;AAAD,QAAqBR,YAA3B;AACA,UAAMuB,KAAK,GAAG;AAACf,MAAAA,gBAAD;AAAmB,SAAG,KAAKe;AAA3B,KAAd;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","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","MVTLayer","GeoJsonLayer","getSubLayerProps","id","layerName","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;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;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;;IA4BqBU,U;;;;;;;;;;;;WACnB,2BAAkB;AAChB,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BK,UAArB,eAAqBA,UAArB;AAEA,UAAI,CAACf,IAAL,EAAW,OAAO,IAAP;AAEX,UAAOgD,cAAP,GAAyB,KAAK9B,KAA9B,CAAO8B,cAAP;AAEA,UAAIC,KAAJ;;AAEA,UACElC,UAAU,KAAKS,kBAAaE,EAA5B,IACAX,UAAU,KAAKS,kBAAaG,EAD5B,IAEAjB,MAAM,KAAKwC,uBAAQC,QAHrB,EAIE;AACAF,QAAAA,KAAK,GAAGG,mBAAR;AACD,OAND,MAMO;AACLH,QAAAA,KAAK,GAAGI,oBAAR;AACD;;AAED,UAAO9C,gBAAP,GAA2BR,YAA3B,CAAOQ,gBAAP;;AACA,UAAMW,KAAK;AAAIX,QAAAA,gBAAgB,EAAhBA;AAAJ,SAAyB,KAAKW,KAA9B,CAAX;;AACA,aAAOA,KAAK,CAAClB,IAAb;AAGA,aAAO,IAAIiD,KAAJ,CACL/B,KADK,EAEL,KAAKoC,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,kBAAWN,KAAK,CAACO,SAAjB,CADkB;AAEpBxD,QAAAA,IAAI,EAAJA,IAFoB;AAGpBgD,QAAAA,cAAc,EAAdA;AAHoB,OAAtB,CAFK,CAAP;AAQD;;;EAtHqCS,oB;;;AAyHxC5C,UAAU,CAAC2C,SAAX,GAAuB,YAAvB;AACA3C,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,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"}