@bonlineza/luxity-lib 2.30.0 → 2.30.2
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.
- package/CHANGELOG.md +8 -0
- package/CommunicationPreferences.js +16 -10
- package/GraphQLDropdownSelector.js +51 -42
- package/LuxityGraphQLDropdownSelector.js +51 -42
- package/MaterialSelector.js +51 -42
- package/ModelSelector.js +51 -42
- package/RareStepHeader.js +6 -6
- package/RarestepAddInterests.js +118 -0
- package/RarestepInterests.js +118 -0
- package/ShoeSizeRangeSelector.js +1281 -0
- package/build/bundle.js +174 -51
- package/package.json +1 -1
- package/NotificationOptionsRenderer.js +0 -588
- package/NotificationSection.js +0 -680
- package/Notifications.js +0 -2465
|
@@ -0,0 +1,1281 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('@bonlineza/b-lib/functions'), require('rc-slider'), require('styled-components')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['react', '@bonlineza/b-lib/functions', 'rc-slider', 'styled-components'], factory) :
|
|
4
|
+
(global = global || self, global.ShoeSizeRangeSelector = factory(global.React, global.function, global.rcSlider, global.styled));
|
|
5
|
+
}(this, (function (React, functions, rcSlider, styled) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var React__default = 'default' in React ? React['default'] : React;
|
|
8
|
+
var styled__default = 'default' in styled ? styled['default'] : styled;
|
|
9
|
+
|
|
10
|
+
function _extends() {
|
|
11
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
12
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
13
|
+
var source = arguments[i];
|
|
14
|
+
|
|
15
|
+
for (var key in source) {
|
|
16
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
17
|
+
target[key] = source[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return target;
|
|
23
|
+
};
|
|
24
|
+
return _extends.apply(this, arguments);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
28
|
+
if (source == null) return {};
|
|
29
|
+
var target = {};
|
|
30
|
+
var sourceKeys = Object.keys(source);
|
|
31
|
+
var key, i;
|
|
32
|
+
|
|
33
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
34
|
+
key = sourceKeys[i];
|
|
35
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
36
|
+
target[key] = source[key];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return target;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _objectWithoutProperties(source, excluded) {
|
|
43
|
+
if (source == null) return {};
|
|
44
|
+
|
|
45
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
46
|
+
|
|
47
|
+
var key, i;
|
|
48
|
+
|
|
49
|
+
if (Object.getOwnPropertySymbols) {
|
|
50
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
51
|
+
|
|
52
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
53
|
+
key = sourceSymbolKeys[i];
|
|
54
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
55
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
56
|
+
target[key] = source[key];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _taggedTemplateLiteral(strings, raw) {
|
|
64
|
+
if (!raw) {
|
|
65
|
+
raw = strings.slice(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return Object.freeze(Object.defineProperties(strings, {
|
|
69
|
+
raw: {
|
|
70
|
+
value: Object.freeze(raw)
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function _slicedToArray(arr, i) {
|
|
76
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _arrayWithHoles(arr) {
|
|
80
|
+
if (Array.isArray(arr)) return arr;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _iterableToArrayLimit(arr, i) {
|
|
84
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
85
|
+
|
|
86
|
+
if (_i == null) return;
|
|
87
|
+
var _arr = [];
|
|
88
|
+
var _n = true;
|
|
89
|
+
var _d = false;
|
|
90
|
+
|
|
91
|
+
var _s, _e;
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
95
|
+
_arr.push(_s.value);
|
|
96
|
+
|
|
97
|
+
if (i && _arr.length === i) break;
|
|
98
|
+
}
|
|
99
|
+
} catch (err) {
|
|
100
|
+
_d = true;
|
|
101
|
+
_e = err;
|
|
102
|
+
} finally {
|
|
103
|
+
try {
|
|
104
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
105
|
+
} finally {
|
|
106
|
+
if (_d) throw _e;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return _arr;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
114
|
+
if (!o) return;
|
|
115
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
116
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
117
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
118
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
119
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function _arrayLikeToArray(arr, len) {
|
|
123
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
124
|
+
|
|
125
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
126
|
+
|
|
127
|
+
return arr2;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function _nonIterableRest() {
|
|
131
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var theme = {
|
|
135
|
+
breakpoints: ['40em', '52em', '64em'],
|
|
136
|
+
space: ['0px', '4px', '8px', '16px', '32px', '64px', '128px', '256px', '512px'],
|
|
137
|
+
fontSizes: ['12px', '14px', '16px', '20px', '24px', '32px', '48px', '64px', '72px'],
|
|
138
|
+
marginPaddings: ['0.5rem', '1rem', '1.5rem', '2rem', '2.5rem', '3rem', '3.5rem', '4rem', '4.5rem', '5rem', '5.5rem', '6rem'],
|
|
139
|
+
letterSpacings: ['-0.5px', '0px', '+0.5px'],
|
|
140
|
+
radii: ['0px', '2px', '4px', '8px'],
|
|
141
|
+
borderRadius: '6px',
|
|
142
|
+
colors: {
|
|
143
|
+
primary: '#000',
|
|
144
|
+
base: '#4e4949',
|
|
145
|
+
baseLt: '#817c7c',
|
|
146
|
+
borderColor: '#d8d8d8',
|
|
147
|
+
ntrlMin: '#fff',
|
|
148
|
+
ntrlMinTen: '#e6e6e6',
|
|
149
|
+
gray: '#efefef',
|
|
150
|
+
darkerGray: '#454141'
|
|
151
|
+
},
|
|
152
|
+
rareStepColors: {
|
|
153
|
+
primary: '#202b58',
|
|
154
|
+
secondary: '#ef5c2d',
|
|
155
|
+
ntrlMin: '#ffffff',
|
|
156
|
+
ntrl40: '#f4f4f4',
|
|
157
|
+
ntrl50: '#808080',
|
|
158
|
+
ntrl60: '#e8e8e8',
|
|
159
|
+
ntrl70: '#252525',
|
|
160
|
+
ntrlMax: '#000000'
|
|
161
|
+
},
|
|
162
|
+
rareStepFontWeights: {
|
|
163
|
+
normal: 400,
|
|
164
|
+
medium: 500,
|
|
165
|
+
semiBold: 600,
|
|
166
|
+
bold: 700
|
|
167
|
+
},
|
|
168
|
+
rareStepFontSize: {
|
|
169
|
+
h1: '36px',
|
|
170
|
+
h2: '30px',
|
|
171
|
+
h3: '24px',
|
|
172
|
+
h4: '20px',
|
|
173
|
+
h5: '16px',
|
|
174
|
+
h6: '14px',
|
|
175
|
+
footerTitle: '16px'
|
|
176
|
+
},
|
|
177
|
+
rareStepPageSizes: {
|
|
178
|
+
mobile: '500px',
|
|
179
|
+
tablet: '768px',
|
|
180
|
+
desktop: '992px',
|
|
181
|
+
screenl: '1280px',
|
|
182
|
+
screenxl: '1680px',
|
|
183
|
+
screenxxl: '1920px',
|
|
184
|
+
container: '1600px'
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
var themed = (function (Component) {
|
|
189
|
+
return /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
190
|
+
return /*#__PURE__*/React__default.createElement(styled.ThemeProvider, {
|
|
191
|
+
theme: theme
|
|
192
|
+
}, /*#__PURE__*/React__default.createElement(Component, _extends({}, props, {
|
|
193
|
+
ref: ref
|
|
194
|
+
})));
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
function _extends$1() {
|
|
199
|
+
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
200
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
201
|
+
var source = arguments[i];
|
|
202
|
+
|
|
203
|
+
for (var key in source) {
|
|
204
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
205
|
+
target[key] = source[key];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return target;
|
|
211
|
+
};
|
|
212
|
+
return _extends$1.apply(this, arguments);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function _assertThisInitialized(self) {
|
|
216
|
+
if (self === void 0) {
|
|
217
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return self;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function _setPrototypeOf(o, p) {
|
|
224
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
225
|
+
o.__proto__ = p;
|
|
226
|
+
return o;
|
|
227
|
+
};
|
|
228
|
+
return _setPrototypeOf(o, p);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function _inheritsLoose(subClass, superClass) {
|
|
232
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
233
|
+
subClass.prototype.constructor = subClass;
|
|
234
|
+
_setPrototypeOf(subClass, superClass);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function _getPrototypeOf(o) {
|
|
238
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
239
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
240
|
+
};
|
|
241
|
+
return _getPrototypeOf(o);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function _isNativeFunction(fn) {
|
|
245
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function _isNativeReflectConstruct() {
|
|
249
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
250
|
+
if (Reflect.construct.sham) return false;
|
|
251
|
+
if (typeof Proxy === "function") return true;
|
|
252
|
+
|
|
253
|
+
try {
|
|
254
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
255
|
+
return true;
|
|
256
|
+
} catch (e) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function _construct(Parent, args, Class) {
|
|
262
|
+
if (_isNativeReflectConstruct()) {
|
|
263
|
+
_construct = Reflect.construct.bind();
|
|
264
|
+
} else {
|
|
265
|
+
_construct = function _construct(Parent, args, Class) {
|
|
266
|
+
var a = [null];
|
|
267
|
+
a.push.apply(a, args);
|
|
268
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
269
|
+
var instance = new Constructor();
|
|
270
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
271
|
+
return instance;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return _construct.apply(null, arguments);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function _wrapNativeSuper(Class) {
|
|
279
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
280
|
+
|
|
281
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
282
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
283
|
+
|
|
284
|
+
if (typeof Class !== "function") {
|
|
285
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (typeof _cache !== "undefined") {
|
|
289
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
290
|
+
|
|
291
|
+
_cache.set(Class, Wrapper);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function Wrapper() {
|
|
295
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
299
|
+
constructor: {
|
|
300
|
+
value: Wrapper,
|
|
301
|
+
enumerable: false,
|
|
302
|
+
writable: true,
|
|
303
|
+
configurable: true
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
return _wrapNativeSuper(Class);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// based on https://github.com/styled-components/styled-components/blob/fcf6f3804c57a14dd7984dfab7bc06ee2edca044/src/utils/error.js
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Parse errors.md and turn it into a simple hash of code: message
|
|
316
|
+
* @private
|
|
317
|
+
*/
|
|
318
|
+
var ERRORS = {
|
|
319
|
+
"1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
|
|
320
|
+
"2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
|
|
321
|
+
"3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
|
|
322
|
+
"4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
|
|
323
|
+
"5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
|
|
324
|
+
"6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
|
|
325
|
+
"7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
|
|
326
|
+
"8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
|
|
327
|
+
"9": "Please provide a number of steps to the modularScale helper.\n\n",
|
|
328
|
+
"10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
|
329
|
+
"11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
|
|
330
|
+
"12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
|
|
331
|
+
"13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
|
|
332
|
+
"14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
333
|
+
"15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
334
|
+
"16": "You must provide a template to this method.\n\n",
|
|
335
|
+
"17": "You passed an unsupported selector state to this method.\n\n",
|
|
336
|
+
"18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
|
337
|
+
"19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
|
338
|
+
"20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
|
339
|
+
"21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
340
|
+
"22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
341
|
+
"23": "fontFace expects a name of a font-family.\n\n",
|
|
342
|
+
"24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
|
343
|
+
"25": "fontFace expects localFonts to be an array.\n\n",
|
|
344
|
+
"26": "fontFace expects fileFormats to be an array.\n\n",
|
|
345
|
+
"27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
|
346
|
+
"28": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
|
347
|
+
"29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
|
348
|
+
"30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
349
|
+
"31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
|
|
350
|
+
"32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
|
|
351
|
+
"33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
|
|
352
|
+
"34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
|
353
|
+
"35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
|
354
|
+
"36": "Property must be a string value.\n\n",
|
|
355
|
+
"37": "Syntax Error at %s.\n\n",
|
|
356
|
+
"38": "Formula contains a function that needs parentheses at %s.\n\n",
|
|
357
|
+
"39": "Formula is missing closing parenthesis at %s.\n\n",
|
|
358
|
+
"40": "Formula has too many closing parentheses at %s.\n\n",
|
|
359
|
+
"41": "All values in a formula must have the same unit or be unitless.\n\n",
|
|
360
|
+
"42": "Please provide a number of steps to the modularScale helper.\n\n",
|
|
361
|
+
"43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
|
362
|
+
"44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
|
|
363
|
+
"45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
|
|
364
|
+
"46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
|
|
365
|
+
"47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
|
366
|
+
"48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
|
367
|
+
"49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
|
368
|
+
"50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
|
|
369
|
+
"51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
|
|
370
|
+
"52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
|
371
|
+
"53": "fontFace expects localFonts to be an array.\n\n",
|
|
372
|
+
"54": "fontFace expects fileFormats to be an array.\n\n",
|
|
373
|
+
"55": "fontFace expects a name of a font-family.\n\n",
|
|
374
|
+
"56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
|
|
375
|
+
"57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
|
376
|
+
"58": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
|
377
|
+
"59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
|
378
|
+
"60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
379
|
+
"61": "Property must be a string value.\n\n",
|
|
380
|
+
"62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
|
381
|
+
"63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
|
382
|
+
"64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
|
|
383
|
+
"65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
|
|
384
|
+
"66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
|
|
385
|
+
"67": "You must provide a template to this method.\n\n",
|
|
386
|
+
"68": "You passed an unsupported selector state to this method.\n\n",
|
|
387
|
+
"69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
|
|
388
|
+
"70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
|
|
389
|
+
"71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
390
|
+
"72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
391
|
+
"73": "Please provide a valid CSS variable.\n\n",
|
|
392
|
+
"74": "CSS variable not found.\n\n",
|
|
393
|
+
"75": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n"
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* super basic version of sprintf
|
|
397
|
+
* @private
|
|
398
|
+
*/
|
|
399
|
+
|
|
400
|
+
function format() {
|
|
401
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
402
|
+
args[_key] = arguments[_key];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
var a = args[0];
|
|
406
|
+
var b = [];
|
|
407
|
+
var c;
|
|
408
|
+
|
|
409
|
+
for (c = 1; c < args.length; c += 1) {
|
|
410
|
+
b.push(args[c]);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
b.forEach(function (d) {
|
|
414
|
+
a = a.replace(/%[a-z]/, d);
|
|
415
|
+
});
|
|
416
|
+
return a;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Create an error file out of errors.md for development and a simple web link to the full errors
|
|
420
|
+
* in production mode.
|
|
421
|
+
* @private
|
|
422
|
+
*/
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
var PolishedError = /*#__PURE__*/function (_Error) {
|
|
426
|
+
_inheritsLoose(PolishedError, _Error);
|
|
427
|
+
|
|
428
|
+
function PolishedError(code) {
|
|
429
|
+
var _this;
|
|
430
|
+
|
|
431
|
+
if (process.env.NODE_ENV === 'production') {
|
|
432
|
+
_this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
|
|
433
|
+
} else {
|
|
434
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
435
|
+
args[_key2 - 1] = arguments[_key2];
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
_this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return _assertThisInitialized(_this);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return PolishedError;
|
|
445
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
446
|
+
|
|
447
|
+
function colorToInt(color) {
|
|
448
|
+
return Math.round(color * 255);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function convertToInt(red, green, blue) {
|
|
452
|
+
return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function hslToRgb(hue, saturation, lightness, convert) {
|
|
456
|
+
if (convert === void 0) {
|
|
457
|
+
convert = convertToInt;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (saturation === 0) {
|
|
461
|
+
// achromatic
|
|
462
|
+
return convert(lightness, lightness, lightness);
|
|
463
|
+
} // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
var huePrime = (hue % 360 + 360) % 360 / 60;
|
|
467
|
+
var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
468
|
+
var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
469
|
+
var red = 0;
|
|
470
|
+
var green = 0;
|
|
471
|
+
var blue = 0;
|
|
472
|
+
|
|
473
|
+
if (huePrime >= 0 && huePrime < 1) {
|
|
474
|
+
red = chroma;
|
|
475
|
+
green = secondComponent;
|
|
476
|
+
} else if (huePrime >= 1 && huePrime < 2) {
|
|
477
|
+
red = secondComponent;
|
|
478
|
+
green = chroma;
|
|
479
|
+
} else if (huePrime >= 2 && huePrime < 3) {
|
|
480
|
+
green = chroma;
|
|
481
|
+
blue = secondComponent;
|
|
482
|
+
} else if (huePrime >= 3 && huePrime < 4) {
|
|
483
|
+
green = secondComponent;
|
|
484
|
+
blue = chroma;
|
|
485
|
+
} else if (huePrime >= 4 && huePrime < 5) {
|
|
486
|
+
red = secondComponent;
|
|
487
|
+
blue = chroma;
|
|
488
|
+
} else if (huePrime >= 5 && huePrime < 6) {
|
|
489
|
+
red = chroma;
|
|
490
|
+
blue = secondComponent;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
var lightnessModification = lightness - chroma / 2;
|
|
494
|
+
var finalRed = red + lightnessModification;
|
|
495
|
+
var finalGreen = green + lightnessModification;
|
|
496
|
+
var finalBlue = blue + lightnessModification;
|
|
497
|
+
return convert(finalRed, finalGreen, finalBlue);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
var namedColorMap = {
|
|
501
|
+
aliceblue: 'f0f8ff',
|
|
502
|
+
antiquewhite: 'faebd7',
|
|
503
|
+
aqua: '00ffff',
|
|
504
|
+
aquamarine: '7fffd4',
|
|
505
|
+
azure: 'f0ffff',
|
|
506
|
+
beige: 'f5f5dc',
|
|
507
|
+
bisque: 'ffe4c4',
|
|
508
|
+
black: '000',
|
|
509
|
+
blanchedalmond: 'ffebcd',
|
|
510
|
+
blue: '0000ff',
|
|
511
|
+
blueviolet: '8a2be2',
|
|
512
|
+
brown: 'a52a2a',
|
|
513
|
+
burlywood: 'deb887',
|
|
514
|
+
cadetblue: '5f9ea0',
|
|
515
|
+
chartreuse: '7fff00',
|
|
516
|
+
chocolate: 'd2691e',
|
|
517
|
+
coral: 'ff7f50',
|
|
518
|
+
cornflowerblue: '6495ed',
|
|
519
|
+
cornsilk: 'fff8dc',
|
|
520
|
+
crimson: 'dc143c',
|
|
521
|
+
cyan: '00ffff',
|
|
522
|
+
darkblue: '00008b',
|
|
523
|
+
darkcyan: '008b8b',
|
|
524
|
+
darkgoldenrod: 'b8860b',
|
|
525
|
+
darkgray: 'a9a9a9',
|
|
526
|
+
darkgreen: '006400',
|
|
527
|
+
darkgrey: 'a9a9a9',
|
|
528
|
+
darkkhaki: 'bdb76b',
|
|
529
|
+
darkmagenta: '8b008b',
|
|
530
|
+
darkolivegreen: '556b2f',
|
|
531
|
+
darkorange: 'ff8c00',
|
|
532
|
+
darkorchid: '9932cc',
|
|
533
|
+
darkred: '8b0000',
|
|
534
|
+
darksalmon: 'e9967a',
|
|
535
|
+
darkseagreen: '8fbc8f',
|
|
536
|
+
darkslateblue: '483d8b',
|
|
537
|
+
darkslategray: '2f4f4f',
|
|
538
|
+
darkslategrey: '2f4f4f',
|
|
539
|
+
darkturquoise: '00ced1',
|
|
540
|
+
darkviolet: '9400d3',
|
|
541
|
+
deeppink: 'ff1493',
|
|
542
|
+
deepskyblue: '00bfff',
|
|
543
|
+
dimgray: '696969',
|
|
544
|
+
dimgrey: '696969',
|
|
545
|
+
dodgerblue: '1e90ff',
|
|
546
|
+
firebrick: 'b22222',
|
|
547
|
+
floralwhite: 'fffaf0',
|
|
548
|
+
forestgreen: '228b22',
|
|
549
|
+
fuchsia: 'ff00ff',
|
|
550
|
+
gainsboro: 'dcdcdc',
|
|
551
|
+
ghostwhite: 'f8f8ff',
|
|
552
|
+
gold: 'ffd700',
|
|
553
|
+
goldenrod: 'daa520',
|
|
554
|
+
gray: '808080',
|
|
555
|
+
green: '008000',
|
|
556
|
+
greenyellow: 'adff2f',
|
|
557
|
+
grey: '808080',
|
|
558
|
+
honeydew: 'f0fff0',
|
|
559
|
+
hotpink: 'ff69b4',
|
|
560
|
+
indianred: 'cd5c5c',
|
|
561
|
+
indigo: '4b0082',
|
|
562
|
+
ivory: 'fffff0',
|
|
563
|
+
khaki: 'f0e68c',
|
|
564
|
+
lavender: 'e6e6fa',
|
|
565
|
+
lavenderblush: 'fff0f5',
|
|
566
|
+
lawngreen: '7cfc00',
|
|
567
|
+
lemonchiffon: 'fffacd',
|
|
568
|
+
lightblue: 'add8e6',
|
|
569
|
+
lightcoral: 'f08080',
|
|
570
|
+
lightcyan: 'e0ffff',
|
|
571
|
+
lightgoldenrodyellow: 'fafad2',
|
|
572
|
+
lightgray: 'd3d3d3',
|
|
573
|
+
lightgreen: '90ee90',
|
|
574
|
+
lightgrey: 'd3d3d3',
|
|
575
|
+
lightpink: 'ffb6c1',
|
|
576
|
+
lightsalmon: 'ffa07a',
|
|
577
|
+
lightseagreen: '20b2aa',
|
|
578
|
+
lightskyblue: '87cefa',
|
|
579
|
+
lightslategray: '789',
|
|
580
|
+
lightslategrey: '789',
|
|
581
|
+
lightsteelblue: 'b0c4de',
|
|
582
|
+
lightyellow: 'ffffe0',
|
|
583
|
+
lime: '0f0',
|
|
584
|
+
limegreen: '32cd32',
|
|
585
|
+
linen: 'faf0e6',
|
|
586
|
+
magenta: 'f0f',
|
|
587
|
+
maroon: '800000',
|
|
588
|
+
mediumaquamarine: '66cdaa',
|
|
589
|
+
mediumblue: '0000cd',
|
|
590
|
+
mediumorchid: 'ba55d3',
|
|
591
|
+
mediumpurple: '9370db',
|
|
592
|
+
mediumseagreen: '3cb371',
|
|
593
|
+
mediumslateblue: '7b68ee',
|
|
594
|
+
mediumspringgreen: '00fa9a',
|
|
595
|
+
mediumturquoise: '48d1cc',
|
|
596
|
+
mediumvioletred: 'c71585',
|
|
597
|
+
midnightblue: '191970',
|
|
598
|
+
mintcream: 'f5fffa',
|
|
599
|
+
mistyrose: 'ffe4e1',
|
|
600
|
+
moccasin: 'ffe4b5',
|
|
601
|
+
navajowhite: 'ffdead',
|
|
602
|
+
navy: '000080',
|
|
603
|
+
oldlace: 'fdf5e6',
|
|
604
|
+
olive: '808000',
|
|
605
|
+
olivedrab: '6b8e23',
|
|
606
|
+
orange: 'ffa500',
|
|
607
|
+
orangered: 'ff4500',
|
|
608
|
+
orchid: 'da70d6',
|
|
609
|
+
palegoldenrod: 'eee8aa',
|
|
610
|
+
palegreen: '98fb98',
|
|
611
|
+
paleturquoise: 'afeeee',
|
|
612
|
+
palevioletred: 'db7093',
|
|
613
|
+
papayawhip: 'ffefd5',
|
|
614
|
+
peachpuff: 'ffdab9',
|
|
615
|
+
peru: 'cd853f',
|
|
616
|
+
pink: 'ffc0cb',
|
|
617
|
+
plum: 'dda0dd',
|
|
618
|
+
powderblue: 'b0e0e6',
|
|
619
|
+
purple: '800080',
|
|
620
|
+
rebeccapurple: '639',
|
|
621
|
+
red: 'f00',
|
|
622
|
+
rosybrown: 'bc8f8f',
|
|
623
|
+
royalblue: '4169e1',
|
|
624
|
+
saddlebrown: '8b4513',
|
|
625
|
+
salmon: 'fa8072',
|
|
626
|
+
sandybrown: 'f4a460',
|
|
627
|
+
seagreen: '2e8b57',
|
|
628
|
+
seashell: 'fff5ee',
|
|
629
|
+
sienna: 'a0522d',
|
|
630
|
+
silver: 'c0c0c0',
|
|
631
|
+
skyblue: '87ceeb',
|
|
632
|
+
slateblue: '6a5acd',
|
|
633
|
+
slategray: '708090',
|
|
634
|
+
slategrey: '708090',
|
|
635
|
+
snow: 'fffafa',
|
|
636
|
+
springgreen: '00ff7f',
|
|
637
|
+
steelblue: '4682b4',
|
|
638
|
+
tan: 'd2b48c',
|
|
639
|
+
teal: '008080',
|
|
640
|
+
thistle: 'd8bfd8',
|
|
641
|
+
tomato: 'ff6347',
|
|
642
|
+
turquoise: '40e0d0',
|
|
643
|
+
violet: 'ee82ee',
|
|
644
|
+
wheat: 'f5deb3',
|
|
645
|
+
white: 'fff',
|
|
646
|
+
whitesmoke: 'f5f5f5',
|
|
647
|
+
yellow: 'ff0',
|
|
648
|
+
yellowgreen: '9acd32'
|
|
649
|
+
};
|
|
650
|
+
/**
|
|
651
|
+
* Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
|
|
652
|
+
* @private
|
|
653
|
+
*/
|
|
654
|
+
|
|
655
|
+
function nameToHex(color) {
|
|
656
|
+
if (typeof color !== 'string') return color;
|
|
657
|
+
var normalizedColorName = color.toLowerCase();
|
|
658
|
+
return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
var hexRegex = /^#[a-fA-F0-9]{6}$/;
|
|
662
|
+
var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
|
|
663
|
+
var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
|
|
664
|
+
var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
|
|
665
|
+
var rgbRegex = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
|
|
666
|
+
var rgbaRegex = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
|
|
667
|
+
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
|
|
668
|
+
var hslaRegex = /^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
|
|
669
|
+
/**
|
|
670
|
+
* Returns an RgbColor or RgbaColor object. This utility function is only useful
|
|
671
|
+
* if want to extract a color component. With the color util `toColorString` you
|
|
672
|
+
* can convert a RgbColor or RgbaColor object back to a string.
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* // Assigns `{ red: 255, green: 0, blue: 0 }` to color1
|
|
676
|
+
* const color1 = parseToRgb('rgb(255, 0, 0)');
|
|
677
|
+
* // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
|
|
678
|
+
* const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
|
|
679
|
+
*/
|
|
680
|
+
|
|
681
|
+
function parseToRgb(color) {
|
|
682
|
+
if (typeof color !== 'string') {
|
|
683
|
+
throw new PolishedError(3);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
var normalizedColor = nameToHex(color);
|
|
687
|
+
|
|
688
|
+
if (normalizedColor.match(hexRegex)) {
|
|
689
|
+
return {
|
|
690
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
691
|
+
green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
|
692
|
+
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if (normalizedColor.match(hexRgbaRegex)) {
|
|
697
|
+
var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
|
|
698
|
+
return {
|
|
699
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
700
|
+
green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
|
701
|
+
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
|
|
702
|
+
alpha: alpha
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
if (normalizedColor.match(reducedHexRegex)) {
|
|
707
|
+
return {
|
|
708
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
709
|
+
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
710
|
+
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if (normalizedColor.match(reducedRgbaHexRegex)) {
|
|
715
|
+
var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
|
716
|
+
|
|
717
|
+
return {
|
|
718
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
719
|
+
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
720
|
+
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
|
|
721
|
+
alpha: _alpha
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
var rgbMatched = rgbRegex.exec(normalizedColor);
|
|
726
|
+
|
|
727
|
+
if (rgbMatched) {
|
|
728
|
+
return {
|
|
729
|
+
red: parseInt("" + rgbMatched[1], 10),
|
|
730
|
+
green: parseInt("" + rgbMatched[2], 10),
|
|
731
|
+
blue: parseInt("" + rgbMatched[3], 10)
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
|
|
736
|
+
|
|
737
|
+
if (rgbaMatched) {
|
|
738
|
+
return {
|
|
739
|
+
red: parseInt("" + rgbaMatched[1], 10),
|
|
740
|
+
green: parseInt("" + rgbaMatched[2], 10),
|
|
741
|
+
blue: parseInt("" + rgbaMatched[3], 10),
|
|
742
|
+
alpha: parseFloat("" + rgbaMatched[4])
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
var hslMatched = hslRegex.exec(normalizedColor);
|
|
747
|
+
|
|
748
|
+
if (hslMatched) {
|
|
749
|
+
var hue = parseInt("" + hslMatched[1], 10);
|
|
750
|
+
var saturation = parseInt("" + hslMatched[2], 10) / 100;
|
|
751
|
+
var lightness = parseInt("" + hslMatched[3], 10) / 100;
|
|
752
|
+
var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
|
|
753
|
+
var hslRgbMatched = rgbRegex.exec(rgbColorString);
|
|
754
|
+
|
|
755
|
+
if (!hslRgbMatched) {
|
|
756
|
+
throw new PolishedError(4, normalizedColor, rgbColorString);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
return {
|
|
760
|
+
red: parseInt("" + hslRgbMatched[1], 10),
|
|
761
|
+
green: parseInt("" + hslRgbMatched[2], 10),
|
|
762
|
+
blue: parseInt("" + hslRgbMatched[3], 10)
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
|
|
767
|
+
|
|
768
|
+
if (hslaMatched) {
|
|
769
|
+
var _hue = parseInt("" + hslaMatched[1], 10);
|
|
770
|
+
|
|
771
|
+
var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
|
|
772
|
+
|
|
773
|
+
var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
|
|
774
|
+
|
|
775
|
+
var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
|
|
776
|
+
|
|
777
|
+
var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
|
778
|
+
|
|
779
|
+
if (!_hslRgbMatched) {
|
|
780
|
+
throw new PolishedError(4, normalizedColor, _rgbColorString);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
return {
|
|
784
|
+
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
785
|
+
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
786
|
+
blue: parseInt("" + _hslRgbMatched[3], 10),
|
|
787
|
+
alpha: parseFloat("" + hslaMatched[4])
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
throw new PolishedError(5);
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Reduces hex values if possible e.g. #ff8866 to #f86
|
|
796
|
+
* @private
|
|
797
|
+
*/
|
|
798
|
+
var reduceHexValue = function reduceHexValue(value) {
|
|
799
|
+
if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
|
800
|
+
return "#" + value[1] + value[3] + value[5];
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
return value;
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
function numberToHex(value) {
|
|
807
|
+
var hex = value.toString(16);
|
|
808
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* // Styles as object usage
|
|
816
|
+
* const styles = {
|
|
817
|
+
* background: rgb(255, 205, 100),
|
|
818
|
+
* background: rgb({ red: 255, green: 205, blue: 100 }),
|
|
819
|
+
* }
|
|
820
|
+
*
|
|
821
|
+
* // styled-components usage
|
|
822
|
+
* const div = styled.div`
|
|
823
|
+
* background: ${rgb(255, 205, 100)};
|
|
824
|
+
* background: ${rgb({ red: 255, green: 205, blue: 100 })};
|
|
825
|
+
* `
|
|
826
|
+
*
|
|
827
|
+
* // CSS in JS Output
|
|
828
|
+
*
|
|
829
|
+
* element {
|
|
830
|
+
* background: "#ffcd64";
|
|
831
|
+
* background: "#ffcd64";
|
|
832
|
+
* }
|
|
833
|
+
*/
|
|
834
|
+
function rgb(value, green, blue) {
|
|
835
|
+
if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
|
|
836
|
+
return reduceHexValue("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
|
837
|
+
} else if (typeof value === 'object' && green === undefined && blue === undefined) {
|
|
838
|
+
return reduceHexValue("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
throw new PolishedError(6);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
|
|
846
|
+
*
|
|
847
|
+
* Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
* // Styles as object usage
|
|
851
|
+
* const styles = {
|
|
852
|
+
* background: rgba(255, 205, 100, 0.7),
|
|
853
|
+
* background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
|
|
854
|
+
* background: rgba(255, 205, 100, 1),
|
|
855
|
+
* background: rgba('#ffffff', 0.4),
|
|
856
|
+
* background: rgba('black', 0.7),
|
|
857
|
+
* }
|
|
858
|
+
*
|
|
859
|
+
* // styled-components usage
|
|
860
|
+
* const div = styled.div`
|
|
861
|
+
* background: ${rgba(255, 205, 100, 0.7)};
|
|
862
|
+
* background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
|
|
863
|
+
* background: ${rgba(255, 205, 100, 1)};
|
|
864
|
+
* background: ${rgba('#ffffff', 0.4)};
|
|
865
|
+
* background: ${rgba('black', 0.7)};
|
|
866
|
+
* `
|
|
867
|
+
*
|
|
868
|
+
* // CSS in JS Output
|
|
869
|
+
*
|
|
870
|
+
* element {
|
|
871
|
+
* background: "rgba(255,205,100,0.7)";
|
|
872
|
+
* background: "rgba(255,205,100,0.7)";
|
|
873
|
+
* background: "#ffcd64";
|
|
874
|
+
* background: "rgba(255,255,255,0.4)";
|
|
875
|
+
* background: "rgba(0,0,0,0.7)";
|
|
876
|
+
* }
|
|
877
|
+
*/
|
|
878
|
+
function rgba(firstValue, secondValue, thirdValue, fourthValue) {
|
|
879
|
+
if (typeof firstValue === 'string' && typeof secondValue === 'number') {
|
|
880
|
+
var rgbValue = parseToRgb(firstValue);
|
|
881
|
+
return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
|
|
882
|
+
} else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
|
|
883
|
+
return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
|
|
884
|
+
} else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
|
885
|
+
return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
throw new PolishedError(7);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
|
|
892
|
+
// eslint-disable-next-line no-unused-vars
|
|
893
|
+
// eslint-disable-next-line no-unused-vars
|
|
894
|
+
// eslint-disable-next-line no-redeclare
|
|
895
|
+
function curried(f, length, acc) {
|
|
896
|
+
return function fn() {
|
|
897
|
+
// eslint-disable-next-line prefer-rest-params
|
|
898
|
+
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
|
899
|
+
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
|
900
|
+
};
|
|
901
|
+
} // eslint-disable-next-line no-redeclare
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
function curry(f) {
|
|
905
|
+
// eslint-disable-line no-redeclare
|
|
906
|
+
return curried(f, f.length, []);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function guard(lowerBoundary, upperBoundary, value) {
|
|
910
|
+
return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Decreases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
915
|
+
*
|
|
916
|
+
*
|
|
917
|
+
* @example
|
|
918
|
+
* // Styles as object usage
|
|
919
|
+
* const styles = {
|
|
920
|
+
* background: transparentize(0.1, '#fff');
|
|
921
|
+
* background: transparentize(0.2, 'hsl(0, 0%, 100%)'),
|
|
922
|
+
* background: transparentize('0.5', 'rgba(255, 0, 0, 0.8)'),
|
|
923
|
+
* }
|
|
924
|
+
*
|
|
925
|
+
* // styled-components usage
|
|
926
|
+
* const div = styled.div`
|
|
927
|
+
* background: ${transparentize(0.1, '#fff')};
|
|
928
|
+
* background: ${transparentize(0.2, 'hsl(0, 0%, 100%)')},
|
|
929
|
+
* background: ${transparentize('0.5', 'rgba(255, 0, 0, 0.8)')},
|
|
930
|
+
* `
|
|
931
|
+
*
|
|
932
|
+
* // CSS in JS Output
|
|
933
|
+
*
|
|
934
|
+
* element {
|
|
935
|
+
* background: "rgba(255,255,255,0.9)";
|
|
936
|
+
* background: "rgba(255,255,255,0.8)";
|
|
937
|
+
* background: "rgba(255,0,0,0.3)";
|
|
938
|
+
* }
|
|
939
|
+
*/
|
|
940
|
+
|
|
941
|
+
function transparentize(amount, color) {
|
|
942
|
+
if (color === 'transparent') return color;
|
|
943
|
+
var parsedColor = parseToRgb(color);
|
|
944
|
+
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
945
|
+
|
|
946
|
+
var colorWithAlpha = _extends$1({}, parsedColor, {
|
|
947
|
+
alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
|
|
948
|
+
});
|
|
949
|
+
|
|
950
|
+
return rgba(colorWithAlpha);
|
|
951
|
+
} // prettier-ignore
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
var curriedTransparentize = /*#__PURE__*/curry
|
|
955
|
+
/* ::<number | string, string, string> */
|
|
956
|
+
(transparentize);
|
|
957
|
+
|
|
958
|
+
var _templateObject;
|
|
959
|
+
var baseSliderStyles = styled.css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .rc-slider {\n position: relative;\n height: 14px;\n padding: 5px 0;\n width: 100%;\n border-radius: 6px;\n touch-action: none;\n box-sizing: border-box;\n }\n .rc-slider * {\n box-sizing: border-box;\n }\n .rc-slider-rail {\n position: absolute;\n width: 100%;\n background-color: #e9e9e9;\n height: 4px;\n border-radius: 6px;\n }\n .rc-slider-track {\n position: absolute;\n left: 0;\n height: 4px;\n border-radius: 6px;\n background-color: #abe2fb;\n }\n .rc-slider-handle {\n position: absolute;\n width: 14px;\n height: 14px;\n cursor: pointer;\n margin-top: -5px;\n border-radius: 50%;\n border: solid 2px #96dbfa;\n background-color: #fff;\n -ms-touch-action: pan-x;\n touch-action: pan-x;\n }\n .rc-slider-handle:focus {\n border-color: #57c5f7;\n box-shadow: 0 0 0 5px #96dbfa;\n outline: none;\n }\n .rc-slider-handle-click-focused:focus {\n border-color: #96dbfa;\n box-shadow: unset;\n }\n .rc-slider-handle:hover {\n border-color: #57c5f7;\n }\n .rc-slider-handle:active {\n border-color: #57c5f7;\n box-shadow: 0 0 5px #57c5f7;\n cursor: grabbing;\n }\n .rc-slider-mark {\n position: absolute;\n top: 18px;\n left: 0;\n width: 100%;\n font-size: 12px;\n }\n .rc-slider-mark-text {\n position: absolute;\n display: inline-block;\n vertical-align: middle;\n text-align: center;\n cursor: pointer;\n color: #999;\n }\n .rc-slider-mark-text-active {\n color: #666;\n }\n .rc-slider-step {\n position: absolute;\n width: 100%;\n height: 4px;\n background: transparent;\n }\n .rc-slider-dot {\n position: absolute;\n bottom: -2px;\n margin-left: -4px;\n width: 8px;\n height: 8px;\n border: 2px solid #e9e9e9;\n background-color: #fff;\n cursor: pointer;\n border-radius: 50%;\n vertical-align: middle;\n }\n .rc-slider-dot-active {\n border-color: #96dbfa;\n }\n .rc-slider-dot-reverse {\n margin-left: 0;\n margin-right: -4px;\n }\n .rc-slider-disabled {\n background-color: #e9e9e9;\n }\n .rc-slider-disabled .rc-slider-track {\n background-color: #ccc;\n }\n .rc-slider-disabled .rc-slider-handle,\n .rc-slider-disabled .rc-slider-dot {\n border-color: #ccc;\n box-shadow: none;\n background-color: #fff;\n cursor: not-allowed;\n }\n .rc-slider-disabled .rc-slider-mark-text,\n .rc-slider-disabled .rc-slider-dot {\n cursor: not-allowed !important;\n }\n .rc-slider-vertical {\n width: 14px;\n height: 100%;\n padding: 0 5px;\n }\n .rc-slider-vertical .rc-slider-rail {\n height: 100%;\n width: 4px;\n }\n .rc-slider-vertical .rc-slider-track {\n left: 5px;\n bottom: 0;\n width: 4px;\n }\n .rc-slider-vertical .rc-slider-handle {\n margin-left: -5px;\n -ms-touch-action: pan-y;\n touch-action: pan-y;\n }\n .rc-slider-vertical .rc-slider-mark {\n top: 0;\n left: 18px;\n height: 100%;\n }\n .rc-slider-vertical .rc-slider-step {\n height: 100%;\n width: 4px;\n }\n .rc-slider-vertical .rc-slider-dot {\n left: 2px;\n margin-bottom: -4px;\n }\n .rc-slider-vertical .rc-slider-dot:first-child {\n margin-bottom: -4px;\n }\n .rc-slider-vertical .rc-slider-dot:last-child {\n margin-bottom: -4px;\n }\n .rc-slider-tooltip-zoom-down-enter,\n .rc-slider-tooltip-zoom-down-appear {\n animation-duration: 0.3s;\n animation-fill-mode: both;\n display: block !important;\n animation-play-state: paused;\n }\n .rc-slider-tooltip-zoom-down-leave {\n animation-duration: 0.3s;\n animation-fill-mode: both;\n display: block !important;\n animation-play-state: paused;\n }\n .rc-slider-tooltip-zoom-down-enter.rc-slider-tooltip-zoom-down-enter-active,\n .rc-slider-tooltip-zoom-down-appear.rc-slider-tooltip-zoom-down-appear-active {\n animation-name: rcSliderTooltipZoomDownIn;\n animation-play-state: running;\n }\n .rc-slider-tooltip-zoom-down-leave.rc-slider-tooltip-zoom-down-leave-active {\n animation-name: rcSliderTooltipZoomDownOut;\n animation-play-state: running;\n }\n .rc-slider-tooltip-zoom-down-enter,\n .rc-slider-tooltip-zoom-down-appear {\n transform: scale(0, 0);\n animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);\n }\n .rc-slider-tooltip-zoom-down-leave {\n animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);\n }\n @keyframes rcSliderTooltipZoomDownIn {\n 0% {\n opacity: 0;\n transform-origin: 50% 100%;\n transform: scale(0, 0);\n }\n 100% {\n transform-origin: 50% 100%;\n transform: scale(1, 1);\n }\n }\n @keyframes rcSliderTooltipZoomDownOut {\n 0% {\n transform-origin: 50% 100%;\n transform: scale(1, 1);\n }\n 100% {\n opacity: 0;\n transform-origin: 50% 100%;\n transform: scale(0, 0);\n }\n }\n .rc-slider-tooltip {\n position: absolute;\n left: -9999px;\n top: -9999px;\n visibility: visible;\n box-sizing: border-box;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n }\n .rc-slider-tooltip * {\n box-sizing: border-box;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n }\n .rc-slider-tooltip-hidden {\n display: none;\n }\n .rc-slider-tooltip-placement-top {\n padding: 4px 0 8px 0;\n }\n .rc-slider-tooltip-inner {\n padding: 6px 2px;\n min-width: 24px;\n height: 24px;\n font-size: 12px;\n line-height: 1;\n color: #fff;\n text-align: center;\n text-decoration: none;\n background-color: #6c6c6c;\n border-radius: 6px;\n box-shadow: 0 0 4px #d9d9d9;\n }\n .rc-slider-tooltip-arrow {\n position: absolute;\n width: 0;\n height: 0;\n border-color: transparent;\n border-style: solid;\n }\n .rc-slider-tooltip-placement-top .rc-slider-tooltip-arrow {\n bottom: 4px;\n left: 50%;\n margin-left: -4px;\n border-width: 4px 4px 0;\n border-top-color: #6c6c6c;\n }\n"])));
|
|
960
|
+
|
|
961
|
+
var _templateObject$1, _templateObject2, _templateObject3, _templateObject4;
|
|
962
|
+
var handleDimension = '14px';
|
|
963
|
+
var SliderContainer = styled__default.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n ", ";\n position: relative;\n .rc-slider-handle {\n background-color: ", ";\n border-color: ", ";\n }\n\n .rc-slider {\n margin-bottom: ", ";\n max-width: calc(100% - ", ");\n margin-left: auto;\n margin-right: auto;\n }\n .rc-slider-track {\n background-color: ", ";\n }\n\n .rc-slider-handle {\n height: ", ";\n width: ", ";\n transition: border-color 0.5s ease-in-out, box-shadow 0.5s ease-in-out;\n &:hover,\n &:focus {\n border: ", ";\n box-shadow: 0 0 0 5px\n ", ";\n }\n }\n ", "\n"])), baseSliderStyles, function (props) {
|
|
964
|
+
return props.theme.colors.primary;
|
|
965
|
+
}, function (props) {
|
|
966
|
+
return props.theme.colors.primary;
|
|
967
|
+
}, function (props) {
|
|
968
|
+
return props.theme.marginPaddings[6];
|
|
969
|
+
}, handleDimension, function (props) {
|
|
970
|
+
return props.theme.colors.primary;
|
|
971
|
+
}, handleDimension, handleDimension, function (props) {
|
|
972
|
+
return props.theme.colors.primary;
|
|
973
|
+
}, function (props) {
|
|
974
|
+
return curriedTransparentize(0.8, props.theme.colors.primary);
|
|
975
|
+
}, function (props) {
|
|
976
|
+
return getSliderMarkStyle(props);
|
|
977
|
+
});
|
|
978
|
+
|
|
979
|
+
var getSliderMarkStyle = function getSliderMarkStyle(_ref) {
|
|
980
|
+
var showMarks = _ref.showMarks,
|
|
981
|
+
primary = _ref.theme.colors.primary;
|
|
982
|
+
var visiblityStyle = showMarks ? styled.css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral([""]))) : styled.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .rc-slider-mark-text,\n .rc-slider-dot {\n visibility: hidden;\n }\n "])));
|
|
983
|
+
return styled.css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n .rc-slider-mark-text {\n color: ", ";\n }\n\n .rc-slider-dot {\n border-color: ", ";\n background-color: white;\n }\n ", "\n "])), primary, primary, visiblityStyle);
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
var _templateObject$2;
|
|
987
|
+
var ToolTipWrapper = styled__default.div(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n position: absolute;\n right: auto;\n top: 20px;\n transform: translateX(-50%);\n width: 100px;\n text-align: center;\n"])));
|
|
988
|
+
|
|
989
|
+
var _templateObject$3;
|
|
990
|
+
var Footer = styled__default.div(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n display: flex;\n flex-flow: row nowrap;\n justify-content: flex-end;\n"])));
|
|
991
|
+
|
|
992
|
+
var _excluded = ["dragging", "value", "offset", "index"],
|
|
993
|
+
_excluded2 = ["renderTitleSection", "marks", "defaultMinValue", "defaultMaxValue", "min", "max", "toolTipComponent", "renderFooterSection", "onChange", "children", "identifier", "showMarks"];
|
|
994
|
+
|
|
995
|
+
var _templateObject$4;
|
|
996
|
+
var debounceBuilder = functions.debounced(100);
|
|
997
|
+
var ChildrenWrapper = styled__default.div(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n margin-bottom: ", ";\n"])), function (props) {
|
|
998
|
+
return props.theme.marginPaddings[3];
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
var renderCustomHandle = function renderCustomHandle() {
|
|
1002
|
+
var marks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1003
|
+
var toolTipComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1004
|
+
var handleProps = arguments.length > 2 ? arguments[2] : undefined;
|
|
1005
|
+
|
|
1006
|
+
var dragging = handleProps.dragging,
|
|
1007
|
+
value = handleProps.value,
|
|
1008
|
+
offset = handleProps.offset,
|
|
1009
|
+
index = handleProps.index,
|
|
1010
|
+
restHandleProps = _objectWithoutProperties(handleProps, _excluded);
|
|
1011
|
+
|
|
1012
|
+
var getToolTipProps = function getToolTipProps() {
|
|
1013
|
+
var newProps = {}; // Ensures that Tooltip component does not get ref prop
|
|
1014
|
+
|
|
1015
|
+
Object.keys(handleProps).forEach(function (propName) {
|
|
1016
|
+
if (propName !== 'ref') {
|
|
1017
|
+
newProps[propName] = handleProps[propName];
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
return newProps;
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
var Tooltip = toolTipComponent;
|
|
1024
|
+
return /*#__PURE__*/React__default.createElement(React.Fragment, {
|
|
1025
|
+
key: index
|
|
1026
|
+
}, /*#__PURE__*/React__default.createElement(rcSlider.Handle, _extends({
|
|
1027
|
+
offset: offset,
|
|
1028
|
+
value: value
|
|
1029
|
+
}, restHandleProps, {
|
|
1030
|
+
dragging: dragging.toString()
|
|
1031
|
+
})), toolTipComponent && /*#__PURE__*/React__default.createElement(ToolTipWrapper, {
|
|
1032
|
+
style: {
|
|
1033
|
+
left: "".concat(offset, "%")
|
|
1034
|
+
}
|
|
1035
|
+
}, /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
1036
|
+
marks: marks
|
|
1037
|
+
}, getToolTipProps()))));
|
|
1038
|
+
};
|
|
1039
|
+
/** slider ui component for react */
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
var RangeSlider = function RangeSlider(_ref) {
|
|
1043
|
+
var renderTitleSection = _ref.renderTitleSection,
|
|
1044
|
+
marks = _ref.marks,
|
|
1045
|
+
defaultMinValue = _ref.defaultMinValue,
|
|
1046
|
+
defaultMaxValue = _ref.defaultMaxValue,
|
|
1047
|
+
min = _ref.min,
|
|
1048
|
+
max = _ref.max,
|
|
1049
|
+
toolTipComponent = _ref.toolTipComponent,
|
|
1050
|
+
renderFooterSection = _ref.renderFooterSection,
|
|
1051
|
+
onChange = _ref.onChange,
|
|
1052
|
+
childRenderer = _ref.children,
|
|
1053
|
+
identifier = _ref.identifier,
|
|
1054
|
+
showMarks = _ref.showMarks,
|
|
1055
|
+
restProps = _objectWithoutProperties(_ref, _excluded2);
|
|
1056
|
+
|
|
1057
|
+
var _useState = React.useState(defaultMinValue),
|
|
1058
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1059
|
+
currMinVal = _useState2[0],
|
|
1060
|
+
setMinVal = _useState2[1];
|
|
1061
|
+
|
|
1062
|
+
var _useState3 = React.useState(defaultMaxValue),
|
|
1063
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1064
|
+
currMaxVal = _useState4[0],
|
|
1065
|
+
setMaxVal = _useState4[1];
|
|
1066
|
+
/*
|
|
1067
|
+
*Description variable stores the time that the component renders
|
|
1068
|
+
* the state is used to enforce reenders for the component since the date now
|
|
1069
|
+
* is always changing
|
|
1070
|
+
* */
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
var _useState5 = React.useState(0),
|
|
1074
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1075
|
+
seed = _useState6[0],
|
|
1076
|
+
setSeed = _useState6[1];
|
|
1077
|
+
|
|
1078
|
+
var manuallyChangeMinValue = function manuallyChangeMinValue(val) {
|
|
1079
|
+
setMinVal(val);
|
|
1080
|
+
setSeed(Date.now());
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
var manuallyChangeMaxValue = function manuallyChangeMaxValue(val) {
|
|
1084
|
+
setMaxVal(val);
|
|
1085
|
+
setSeed(Date.now());
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
var prevMinVal = functions.usePrevious(currMinVal);
|
|
1089
|
+
var prevMaxVal = functions.usePrevious(currMaxVal);
|
|
1090
|
+
React.useEffect(function () {
|
|
1091
|
+
manuallyChangeMinValue(min);
|
|
1092
|
+
manuallyChangeMaxValue(max);
|
|
1093
|
+
}, [min, max]);
|
|
1094
|
+
React.useEffect(function () {
|
|
1095
|
+
if (prevMinVal !== currMinVal || prevMaxVal !== currMaxVal) {
|
|
1096
|
+
var value = {
|
|
1097
|
+
min: currMinVal,
|
|
1098
|
+
max: currMaxVal
|
|
1099
|
+
};
|
|
1100
|
+
debounceBuilder(function () {
|
|
1101
|
+
return onChange(value);
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
}, [currMaxVal, currMinVal, onChange, prevMaxVal, prevMinVal]);
|
|
1105
|
+
var actionsObj = {
|
|
1106
|
+
manuallyChangeMinValue: manuallyChangeMinValue,
|
|
1107
|
+
manuallyChangeMaxValue: manuallyChangeMaxValue,
|
|
1108
|
+
currMinVal: currMinVal,
|
|
1109
|
+
currMaxVal: currMaxVal,
|
|
1110
|
+
defaultMinValue: defaultMinValue,
|
|
1111
|
+
defaultMaxValue: defaultMaxValue
|
|
1112
|
+
};
|
|
1113
|
+
return /*#__PURE__*/React__default.createElement(SliderContainer, {
|
|
1114
|
+
"data-qe-id": identifier,
|
|
1115
|
+
showMarks: showMarks
|
|
1116
|
+
}, renderTitleSection(actionsObj), childRenderer && /*#__PURE__*/React__default.createElement(ChildrenWrapper, null, typeof childRenderer === 'function' ? childRenderer(actionsObj) : childRenderer), /*#__PURE__*/React__default.createElement(rcSlider.Range, _extends({
|
|
1117
|
+
seed: seed,
|
|
1118
|
+
min: min,
|
|
1119
|
+
max: max,
|
|
1120
|
+
defaultValue: [defaultMinValue, defaultMaxValue],
|
|
1121
|
+
onChange: function onChange(_ref2) {
|
|
1122
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
1123
|
+
nextMin = _ref3[0],
|
|
1124
|
+
nextMax = _ref3[1];
|
|
1125
|
+
|
|
1126
|
+
setMinVal(nextMin);
|
|
1127
|
+
setMaxVal(nextMax);
|
|
1128
|
+
},
|
|
1129
|
+
value: [currMinVal, currMaxVal],
|
|
1130
|
+
marks: marks,
|
|
1131
|
+
step: functions.isObjectEmpty(marks) ? 1 : null,
|
|
1132
|
+
handle: function handle(props) {
|
|
1133
|
+
return renderCustomHandle(marks, toolTipComponent, props);
|
|
1134
|
+
},
|
|
1135
|
+
allowCross: false
|
|
1136
|
+
}, restProps)), /*#__PURE__*/React__default.createElement(Footer, null, renderFooterSection(actionsObj)));
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
RangeSlider.defaultProps = {
|
|
1140
|
+
renderTitleSection: function renderTitleSection() {
|
|
1141
|
+
return false;
|
|
1142
|
+
},
|
|
1143
|
+
marks: {},
|
|
1144
|
+
toolTipComponent: null,
|
|
1145
|
+
renderFooterSection: function renderFooterSection() {
|
|
1146
|
+
return false;
|
|
1147
|
+
},
|
|
1148
|
+
onChange: function onChange() {
|
|
1149
|
+
return false;
|
|
1150
|
+
},
|
|
1151
|
+
children: null,
|
|
1152
|
+
showMarks: false
|
|
1153
|
+
};
|
|
1154
|
+
var RangeSlider$1 = themed(RangeSlider);
|
|
1155
|
+
|
|
1156
|
+
var media = {
|
|
1157
|
+
xs: '576px',
|
|
1158
|
+
sm: '768px',
|
|
1159
|
+
md: '992px',
|
|
1160
|
+
lg: '1200px'
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
var _templateObject$5;
|
|
1164
|
+
var ShoeSizeInputWrapper = styled__default.div(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteral(["\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n\n input[data-qe-id='masked-input-min'],\n input[data-qe-id='masked-input-max'] {\n flex-basis: 49%;\n border: 1px solid ", ";\n border-radius: 6px;\n background-color: ", ";\n padding: 10px;\n }\n\n @media (max-width: ", ") {\n flex-direction: column;\n input[data-qe-id='masked-input-min'] {\n margin-bottom: 10px;\n }\n input[data-qe-id='masked-input-min'],\n input[data-qe-id='masked-input-max'] {\n flex-basis: 100%;\n }\n }\n"])), function (props) {
|
|
1165
|
+
return props.theme.rareStepColors.primary;
|
|
1166
|
+
}, function (props) {
|
|
1167
|
+
return props.theme.rareStepColors.ntrl40;
|
|
1168
|
+
}, media.xs);
|
|
1169
|
+
|
|
1170
|
+
var debounceBuilder$1 = functions.debounced(50);
|
|
1171
|
+
var shoeSizeType = {
|
|
1172
|
+
Uk: 'Uk',
|
|
1173
|
+
Eu: 'Eu',
|
|
1174
|
+
Us: 'Us'
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1177
|
+
var getMaxShoeSize = function getMaxShoeSize(euShoeSizes, ukShoeSizes, type) {
|
|
1178
|
+
var shoeSizes = ukShoeSizes;
|
|
1179
|
+
|
|
1180
|
+
if (type === (shoeSizeType === null || shoeSizeType === void 0 ? void 0 : shoeSizeType.Eu)) {
|
|
1181
|
+
shoeSizes = euShoeSizes;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
var sizes = shoeSizes.map(function (item) {
|
|
1185
|
+
return parseFloat(item.size);
|
|
1186
|
+
}); // Use the Math.max function to find the maximum size value
|
|
1187
|
+
|
|
1188
|
+
var maxSize = sizes.reduce(function (max, current) {
|
|
1189
|
+
return Math.max(max, current);
|
|
1190
|
+
}, -50);
|
|
1191
|
+
return maxSize;
|
|
1192
|
+
};
|
|
1193
|
+
/** UI Slider with minimum and max input fields give the ability to
|
|
1194
|
+
* select a shoe size range */
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
var ShoeSizeRangeSelector = function ShoeSizeRangeSelector(_ref) {
|
|
1198
|
+
var onChange = _ref.onChange,
|
|
1199
|
+
euShoeSizes = _ref.euShoeSizes,
|
|
1200
|
+
ukShoeSizes = _ref.ukShoeSizes,
|
|
1201
|
+
sizeType = _ref.sizeType;
|
|
1202
|
+
var maxShoeSize = getMaxShoeSize(euShoeSizes, ukShoeSizes, sizeType);
|
|
1203
|
+
|
|
1204
|
+
var handleSlideChange = function handleSlideChange(value) {
|
|
1205
|
+
var min_shoe_size = value.min,
|
|
1206
|
+
max_shoe_size = value.max;
|
|
1207
|
+
onChange({
|
|
1208
|
+
min_shoe_size: min_shoe_size,
|
|
1209
|
+
max_shoe_size: max_shoe_size
|
|
1210
|
+
});
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
var handleMinShoeSizeChange = function handleMinShoeSizeChange(targetValue, currMaxVal, manuallyChangeMinValue) {
|
|
1214
|
+
var value = parseInt(targetValue, 10);
|
|
1215
|
+
value = Number.isNaN(value) ? 0 : value;
|
|
1216
|
+
value = value > currMaxVal ? currMaxVal : value;
|
|
1217
|
+
debounceBuilder$1(function () {
|
|
1218
|
+
manuallyChangeMinValue(value);
|
|
1219
|
+
onChange({
|
|
1220
|
+
min_shoe_size: value,
|
|
1221
|
+
max_shoe_size: currMaxVal
|
|
1222
|
+
});
|
|
1223
|
+
});
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1226
|
+
var handleMaxShoeSizeChange = function handleMaxShoeSizeChange(targetValue, currMinVal, manuallyChangeMaxValue) {
|
|
1227
|
+
var value = parseInt(targetValue, 10);
|
|
1228
|
+
value = Number.isNaN(value) ? 0 : value;
|
|
1229
|
+
value = value < currMinVal ? currMinVal : value;
|
|
1230
|
+
debounceBuilder$1(function () {
|
|
1231
|
+
manuallyChangeMaxValue(value);
|
|
1232
|
+
onChange({
|
|
1233
|
+
max_shoe_size: value,
|
|
1234
|
+
min_shoe_size: currMinVal
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
1240
|
+
className: "shoe-size-ranges"
|
|
1241
|
+
}, /*#__PURE__*/React__default.createElement(RangeSlider$1, {
|
|
1242
|
+
identifier: "shoe-size-range-slider",
|
|
1243
|
+
max: maxShoeSize,
|
|
1244
|
+
defaultMinValue: 1,
|
|
1245
|
+
min: 1,
|
|
1246
|
+
onChange: handleSlideChange,
|
|
1247
|
+
defaultMaxValue: maxShoeSize,
|
|
1248
|
+
title: "Shoe Size Ranges"
|
|
1249
|
+
}, function (_ref2) {
|
|
1250
|
+
var manuallyChangeMinValue = _ref2.manuallyChangeMinValue,
|
|
1251
|
+
manuallyChangeMaxValue = _ref2.manuallyChangeMaxValue,
|
|
1252
|
+
currMinVal = _ref2.currMinVal,
|
|
1253
|
+
currMaxVal = _ref2.currMaxVal;
|
|
1254
|
+
return /*#__PURE__*/React__default.createElement(ShoeSizeInputWrapper, null, /*#__PURE__*/React__default.createElement("input", {
|
|
1255
|
+
"data-qe-id": "masked-input-min",
|
|
1256
|
+
value: currMinVal,
|
|
1257
|
+
onChange: function onChange(value) {
|
|
1258
|
+
handleMinShoeSizeChange(value, currMaxVal, manuallyChangeMinValue);
|
|
1259
|
+
}
|
|
1260
|
+
}), /*#__PURE__*/React__default.createElement("input", {
|
|
1261
|
+
"data-qe-id": "masked-input-max",
|
|
1262
|
+
value: currMaxVal,
|
|
1263
|
+
onChange: function onChange(value) {
|
|
1264
|
+
handleMaxShoeSizeChange(value, currMinVal, manuallyChangeMaxValue);
|
|
1265
|
+
}
|
|
1266
|
+
}));
|
|
1267
|
+
}));
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
ShoeSizeRangeSelector.defaultProps = {
|
|
1271
|
+
onChange: function onChange() {
|
|
1272
|
+
return false;
|
|
1273
|
+
},
|
|
1274
|
+
euShoeSizes: [],
|
|
1275
|
+
ukShoeSizes: [],
|
|
1276
|
+
sizeType: 'Uk'
|
|
1277
|
+
};
|
|
1278
|
+
|
|
1279
|
+
return ShoeSizeRangeSelector;
|
|
1280
|
+
|
|
1281
|
+
})));
|