@bonlineza/luxity-lib 2.39.6 → 2.39.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.
- package/Accordion.js +352 -342
- package/AddInterest.js +3141 -3135
- package/AddProductInterest.js +7584 -1011
- package/BrandSelector.js +861 -854
- package/Checkbox.js +250 -240
- package/CheckboxButton.js +236 -229
- package/CommunicationPreferenceOptionsRenderer.js +568 -560
- package/CommunicationPreferenceSection.js +659 -651
- package/CommunicationPreferences.js +2402 -2394
- package/ConditionSelector.js +859 -852
- package/CountryCodeSelect.js +6650 -79
- package/CurrencyInputFormatter.js +96 -86
- package/CurrencySelect.js +227 -219
- package/DropdownSelector.js +6820 -211
- package/GALink.js +51 -43
- package/GenderSelector.js +362 -355
- package/GraphQLDropdownSelector.js +11878 -5308
- package/GraphQLMultiSelector.js +601 -593
- package/IconHeader.js +126 -118
- package/IconWrapper.js +25 -17
- package/InterestCatSelector.js +432 -424
- package/InterestItem.js +470 -462
- package/Interests.js +11286 -4716
- package/InterestsSubheading.js +41 -33
- package/InvertedTextButton.js +175 -167
- package/LuxityAppSideNav.js +189 -181
- package/LuxityDesktopHeader.js +1363 -1355
- package/LuxityFooter.js +2236 -2228
- package/LuxityGraphQLDropdownSelector.js +11963 -5393
- package/LuxityGraphQLMultiselector.js +785 -778
- package/LuxityMobileHeader.js +1794 -1786
- package/LuxityPageReady.js +209 -199
- package/LuxityProductInterestItem.js +367 -359
- package/LuxitySideNav.js +673 -665
- package/MaterialSelector.js +11993 -5423
- package/ModelSelector.js +11993 -5423
- package/NotificationDropDown.js +7029 -459
- package/Notify.js +32 -20
- package/OutlinePrimaryButton.js +142 -134
- package/PriceRangeSelector.js +1270 -1264
- package/PrimaryButton.js +137 -129
- package/RadioButtons.js +318 -308
- package/RangeSlider.js +1039 -1033
- package/RareStepFooter.js +264 -257
- package/RareStepHeader.js +808 -801
- package/ReactSelectWrapper.js +6604 -33
- package/SecondaryButton.js +152 -144
- package/ShoeSizeRangeSelector.js +1153 -1147
- package/ShoeSizeSelector.js +1154 -1146
- package/SimpleErrorBoundary.js +138 -130
- package/StyleSelector.js +861 -854
- package/TextButton.js +143 -135
- package/Tooltip.js +184 -176
- package/Tracking.js +25 -15
- package/WrapperButton.js +58 -50
- package/build/bundle.css +1 -1
- package/build/bundle.js +17236 -10632
- package/build/constants.js +45 -32
- package/package.json +2 -2
- package/svg/Accessories.js +42 -34
- package/svg/Account.js +38 -30
- package/svg/Add.js +39 -31
- package/svg/ArrowRight.js +36 -28
- package/svg/Bags.js +48 -40
- package/svg/BurgerMenu.js +32 -24
- package/svg/Calendar.js +106 -98
- package/svg/CalendarCircled.js +108 -100
- package/svg/CheckCircled.js +40 -32
- package/svg/Close.js +37 -29
- package/svg/Clothing.js +44 -36
- package/svg/Dot.js +40 -32
- package/svg/Edit.js +35 -27
- package/svg/Eye.js +36 -28
- package/svg/FileAttach.js +36 -28
- package/svg/FileAttachCircled.js +38 -30
- package/svg/Jewellery.js +57 -49
- package/svg/LightBulb.js +66 -58
- package/svg/Logo.js +140 -132
- package/svg/LuxityMenu.js +36 -28
- package/svg/Minus.js +37 -29
- package/svg/MobileAvatar.js +36 -28
- package/svg/MyOrder.js +44 -36
- package/svg/MyPayment.js +44 -36
- package/svg/MyProfile.js +52 -44
- package/svg/MySale.js +39 -31
- package/svg/Notification.js +38 -30
- package/svg/PointerDown.js +36 -28
- package/svg/Search.js +35 -27
- package/svg/Shoes.js +45 -37
- package/svg/SvgWrapper.js +21 -13
- package/svg/Trash.js +40 -32
- package/svg/Watches.js +55 -47
package/RangeSlider.js
CHANGED
|
@@ -1,1152 +1,1158 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('rc-slider'), require('styled-components'), require('@bonlineza/b-lib/functions')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['react', 'rc-slider', 'styled-components', '@bonlineza/b-lib/functions'], factory) :
|
|
4
|
+
(global = global || self, global.RangeSlider = factory(global.React, global.rcSlider, global.styled, global.function));
|
|
5
|
+
}(this, (function (React, rcSlider, styled, functions) { '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
|
+
}
|
|
14
19
|
}
|
|
15
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];
|
|
16
37
|
}
|
|
17
38
|
|
|
18
39
|
return target;
|
|
19
|
-
};
|
|
20
|
-
return _extends.apply(this, arguments);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
24
|
-
if (source == null) return {};
|
|
25
|
-
var target = {};
|
|
26
|
-
var sourceKeys = Object.keys(source);
|
|
27
|
-
var key, i;
|
|
28
|
-
|
|
29
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
30
|
-
key = sourceKeys[i];
|
|
31
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
32
|
-
target[key] = source[key];
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function _objectWithoutProperties(source, excluded) {
|
|
39
|
-
if (source == null) return {};
|
|
42
|
+
function _objectWithoutProperties(source, excluded) {
|
|
43
|
+
if (source == null) return {};
|
|
40
44
|
|
|
41
|
-
|
|
45
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
var key, i;
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
if (Object.getOwnPropertySymbols) {
|
|
50
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
}
|
|
53
58
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return target;
|
|
57
|
-
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
if (!raw) {
|
|
61
|
-
raw = strings.slice(0);
|
|
60
|
+
return target;
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
raw
|
|
66
|
-
|
|
63
|
+
function _taggedTemplateLiteral(strings, raw) {
|
|
64
|
+
if (!raw) {
|
|
65
|
+
raw = strings.slice(0);
|
|
67
66
|
}
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
return Object.freeze(Object.defineProperties(strings, {
|
|
69
|
+
raw: {
|
|
70
|
+
value: Object.freeze(raw)
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
74
|
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
}
|
|
75
|
+
function _slicedToArray(arr, i) {
|
|
76
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
77
|
+
}
|
|
78
78
|
|
|
79
|
-
function
|
|
80
|
-
|
|
79
|
+
function _arrayWithHoles(arr) {
|
|
80
|
+
if (Array.isArray(arr)) return arr;
|
|
81
|
+
}
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var _n = true;
|
|
85
|
-
var _d = false;
|
|
83
|
+
function _iterableToArrayLimit(arr, i) {
|
|
84
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
if (_i == null) return;
|
|
87
|
+
var _arr = [];
|
|
88
|
+
var _n = true;
|
|
89
|
+
var _d = false;
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
91
|
-
_arr.push(_s.value);
|
|
91
|
+
var _s, _e;
|
|
92
92
|
|
|
93
|
-
if (i && _arr.length === i) break;
|
|
94
|
-
}
|
|
95
|
-
} catch (err) {
|
|
96
|
-
_d = true;
|
|
97
|
-
_e = err;
|
|
98
|
-
} finally {
|
|
99
93
|
try {
|
|
100
|
-
|
|
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;
|
|
101
102
|
} finally {
|
|
102
|
-
|
|
103
|
+
try {
|
|
104
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
105
|
+
} finally {
|
|
106
|
+
if (_d) throw _e;
|
|
107
|
+
}
|
|
103
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);
|
|
104
120
|
}
|
|
105
121
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
113
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
114
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
115
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function _arrayLikeToArray(arr, len) {
|
|
119
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
120
|
-
|
|
121
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
122
|
-
|
|
123
|
-
return arr2;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function _nonIterableRest() {
|
|
127
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
var theme = {
|
|
131
|
-
breakpoints: ['40em', '52em', '64em'],
|
|
132
|
-
space: ['0px', '4px', '8px', '16px', '32px', '64px', '128px', '256px', '512px'],
|
|
133
|
-
fontSizes: ['12px', '14px', '16px', '20px', '24px', '32px', '48px', '64px', '72px'],
|
|
134
|
-
marginPaddings: ['0.5rem', '1rem', '1.5rem', '2rem', '2.5rem', '3rem', '3.5rem', '4rem', '4.5rem', '5rem', '5.5rem', '6rem'],
|
|
135
|
-
letterSpacings: ['-0.5px', '0px', '+0.5px'],
|
|
136
|
-
radii: ['0px', '2px', '4px', '8px'],
|
|
137
|
-
borderRadius: '6px',
|
|
138
|
-
colors: {
|
|
139
|
-
primary: '#000',
|
|
140
|
-
base: '#4e4949',
|
|
141
|
-
baseLt: '#817c7c',
|
|
142
|
-
borderColor: '#d8d8d8',
|
|
143
|
-
ntrlMin: '#fff',
|
|
144
|
-
ntrlMinTen: '#e6e6e6',
|
|
145
|
-
gray: '#efefef',
|
|
146
|
-
darkerGray: '#454141'
|
|
147
|
-
},
|
|
148
|
-
rareStepColors: {
|
|
149
|
-
primary: '#202b58',
|
|
150
|
-
secondary: '#ef5c2d',
|
|
151
|
-
ntrlMin: '#ffffff',
|
|
152
|
-
ntrl40: '#f4f4f4',
|
|
153
|
-
ntrl50: '#808080',
|
|
154
|
-
ntrl60: '#e8e8e8',
|
|
155
|
-
ntrl70: '#252525',
|
|
156
|
-
ntrlMax: '#000000'
|
|
157
|
-
},
|
|
158
|
-
rareStepFontWeights: {
|
|
159
|
-
normal: 400,
|
|
160
|
-
medium: 500,
|
|
161
|
-
semiBold: 600,
|
|
162
|
-
bold: 700
|
|
163
|
-
},
|
|
164
|
-
rareStepFontSize: {
|
|
165
|
-
h1: '36px',
|
|
166
|
-
h2: '30px',
|
|
167
|
-
h3: '24px',
|
|
168
|
-
h4: '20px',
|
|
169
|
-
h5: '16px',
|
|
170
|
-
h6: '14px',
|
|
171
|
-
footerTitle: '16px'
|
|
172
|
-
},
|
|
173
|
-
rareStepPageSizes: {
|
|
174
|
-
mobile: '500px',
|
|
175
|
-
tablet: '768px',
|
|
176
|
-
desktop: '992px',
|
|
177
|
-
screenl: '1280px',
|
|
178
|
-
screenxl: '1680px',
|
|
179
|
-
screenxxl: '1920px',
|
|
180
|
-
container: '1600px'
|
|
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;
|
|
181
128
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
+
});
|
|
191
196
|
});
|
|
192
|
-
});
|
|
193
197
|
|
|
194
|
-
function _extends$1() {
|
|
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];
|
|
198
202
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
203
|
+
for (var key in source) {
|
|
204
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
205
|
+
target[key] = source[key];
|
|
206
|
+
}
|
|
202
207
|
}
|
|
203
208
|
}
|
|
204
|
-
}
|
|
205
209
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
+
return target;
|
|
211
|
+
};
|
|
212
|
+
return _extends$1.apply(this, arguments);
|
|
213
|
+
}
|
|
210
214
|
|
|
211
|
-
function _assertThisInitialized(self) {
|
|
212
|
-
|
|
213
|
-
|
|
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;
|
|
214
221
|
}
|
|
215
222
|
|
|
216
|
-
|
|
217
|
-
|
|
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
|
+
}
|
|
218
230
|
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
};
|
|
224
|
-
return _setPrototypeOf(o, p);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function _inheritsLoose(subClass, superClass) {
|
|
228
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
229
|
-
subClass.prototype.constructor = subClass;
|
|
230
|
-
_setPrototypeOf(subClass, superClass);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function _getPrototypeOf(o) {
|
|
234
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
235
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
236
|
-
};
|
|
237
|
-
return _getPrototypeOf(o);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function _isNativeFunction(fn) {
|
|
241
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function _isNativeReflectConstruct() {
|
|
245
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
246
|
-
if (Reflect.construct.sham) return false;
|
|
247
|
-
if (typeof Proxy === "function") return true;
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
251
|
-
return true;
|
|
252
|
-
} catch (e) {
|
|
253
|
-
return false;
|
|
231
|
+
function _inheritsLoose(subClass, superClass) {
|
|
232
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
233
|
+
subClass.prototype.constructor = subClass;
|
|
234
|
+
_setPrototypeOf(subClass, superClass);
|
|
254
235
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
_construct = Reflect.construct.bind();
|
|
260
|
-
} else {
|
|
261
|
-
_construct = function _construct(Parent, args, Class) {
|
|
262
|
-
var a = [null];
|
|
263
|
-
a.push.apply(a, args);
|
|
264
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
265
|
-
var instance = new Constructor();
|
|
266
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
267
|
-
return instance;
|
|
236
|
+
|
|
237
|
+
function _getPrototypeOf(o) {
|
|
238
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
239
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
268
240
|
};
|
|
241
|
+
return _getPrototypeOf(o);
|
|
269
242
|
}
|
|
270
243
|
|
|
271
|
-
|
|
272
|
-
|
|
244
|
+
function _isNativeFunction(fn) {
|
|
245
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
246
|
+
}
|
|
273
247
|
|
|
274
|
-
function
|
|
275
|
-
|
|
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;
|
|
276
252
|
|
|
277
|
-
|
|
278
|
-
|
|
253
|
+
try {
|
|
254
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
255
|
+
return true;
|
|
256
|
+
} catch (e) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
279
260
|
|
|
280
|
-
|
|
281
|
-
|
|
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
|
+
};
|
|
282
273
|
}
|
|
283
274
|
|
|
284
|
-
|
|
285
|
-
|
|
275
|
+
return _construct.apply(null, arguments);
|
|
276
|
+
}
|
|
286
277
|
|
|
287
|
-
|
|
288
|
-
|
|
278
|
+
function _wrapNativeSuper(Class) {
|
|
279
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
289
280
|
|
|
290
|
-
function
|
|
291
|
-
|
|
292
|
-
}
|
|
281
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
282
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
293
283
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
value: Wrapper,
|
|
297
|
-
enumerable: false,
|
|
298
|
-
writable: true,
|
|
299
|
-
configurable: true
|
|
284
|
+
if (typeof Class !== "function") {
|
|
285
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
300
286
|
}
|
|
301
|
-
});
|
|
302
|
-
return _setPrototypeOf(Wrapper, Class);
|
|
303
|
-
};
|
|
304
287
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
"13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
|
|
328
|
-
"14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
329
|
-
"15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
330
|
-
"16": "You must provide a template to this method.\n\n",
|
|
331
|
-
"17": "You passed an unsupported selector state to this method.\n\n",
|
|
332
|
-
"18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
|
333
|
-
"19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
|
334
|
-
"20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
|
335
|
-
"21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
336
|
-
"22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
337
|
-
"23": "fontFace expects a name of a font-family.\n\n",
|
|
338
|
-
"24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
|
339
|
-
"25": "fontFace expects localFonts to be an array.\n\n",
|
|
340
|
-
"26": "fontFace expects fileFormats to be an array.\n\n",
|
|
341
|
-
"27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
|
342
|
-
"28": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
|
343
|
-
"29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
|
344
|
-
"30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
345
|
-
"31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
|
|
346
|
-
"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",
|
|
347
|
-
"33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
|
|
348
|
-
"34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
|
349
|
-
"35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
|
350
|
-
"36": "Property must be a string value.\n\n",
|
|
351
|
-
"37": "Syntax Error at %s.\n\n",
|
|
352
|
-
"38": "Formula contains a function that needs parentheses at %s.\n\n",
|
|
353
|
-
"39": "Formula is missing closing parenthesis at %s.\n\n",
|
|
354
|
-
"40": "Formula has too many closing parentheses at %s.\n\n",
|
|
355
|
-
"41": "All values in a formula must have the same unit or be unitless.\n\n",
|
|
356
|
-
"42": "Please provide a number of steps to the modularScale helper.\n\n",
|
|
357
|
-
"43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
|
358
|
-
"44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
|
|
359
|
-
"45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
|
|
360
|
-
"46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
|
|
361
|
-
"47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
|
362
|
-
"48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
|
363
|
-
"49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
|
364
|
-
"50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
|
|
365
|
-
"51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
|
|
366
|
-
"52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
|
367
|
-
"53": "fontFace expects localFonts to be an array.\n\n",
|
|
368
|
-
"54": "fontFace expects fileFormats to be an array.\n\n",
|
|
369
|
-
"55": "fontFace expects a name of a font-family.\n\n",
|
|
370
|
-
"56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
|
|
371
|
-
"57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
|
372
|
-
"58": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
|
373
|
-
"59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
|
374
|
-
"60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
375
|
-
"61": "Property must be a string value.\n\n",
|
|
376
|
-
"62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
|
377
|
-
"63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
|
378
|
-
"64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
|
|
379
|
-
"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",
|
|
380
|
-
"66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
|
|
381
|
-
"67": "You must provide a template to this method.\n\n",
|
|
382
|
-
"68": "You passed an unsupported selector state to this method.\n\n",
|
|
383
|
-
"69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
|
|
384
|
-
"70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
|
|
385
|
-
"71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
386
|
-
"72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
387
|
-
"73": "Please provide a valid CSS variable.\n\n",
|
|
388
|
-
"74": "CSS variable not found.\n\n",
|
|
389
|
-
"75": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n"
|
|
390
|
-
};
|
|
391
|
-
/**
|
|
392
|
-
* super basic version of sprintf
|
|
393
|
-
* @private
|
|
394
|
-
*/
|
|
395
|
-
|
|
396
|
-
function format() {
|
|
397
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
398
|
-
args[_key] = arguments[_key];
|
|
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);
|
|
399
310
|
}
|
|
400
311
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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;
|
|
404
408
|
|
|
405
|
-
|
|
406
|
-
|
|
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;
|
|
407
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
|
+
*/
|
|
408
423
|
|
|
409
|
-
b.forEach(function (d) {
|
|
410
|
-
a = a.replace(/%[a-z]/, d);
|
|
411
|
-
});
|
|
412
|
-
return a;
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* Create an error file out of errors.md for development and a simple web link to the full errors
|
|
416
|
-
* in production mode.
|
|
417
|
-
* @private
|
|
418
|
-
*/
|
|
419
424
|
|
|
425
|
+
var PolishedError = /*#__PURE__*/function (_Error) {
|
|
426
|
+
_inheritsLoose(PolishedError, _Error);
|
|
420
427
|
|
|
421
|
-
|
|
422
|
-
|
|
428
|
+
function PolishedError(code) {
|
|
429
|
+
var _this;
|
|
423
430
|
|
|
424
|
-
|
|
425
|
-
|
|
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
|
+
}
|
|
426
437
|
|
|
427
|
-
|
|
428
|
-
_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;
|
|
429
|
-
} else {
|
|
430
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
431
|
-
args[_key2 - 1] = arguments[_key2];
|
|
438
|
+
_this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
|
432
439
|
}
|
|
433
440
|
|
|
434
|
-
|
|
441
|
+
return _assertThisInitialized(_this);
|
|
435
442
|
}
|
|
436
443
|
|
|
437
|
-
return
|
|
444
|
+
return PolishedError;
|
|
445
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
446
|
+
|
|
447
|
+
function colorToInt(color) {
|
|
448
|
+
return Math.round(color * 255);
|
|
438
449
|
}
|
|
439
450
|
|
|
440
|
-
|
|
441
|
-
|
|
451
|
+
function convertToInt(red, green, blue) {
|
|
452
|
+
return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
|
453
|
+
}
|
|
442
454
|
|
|
443
|
-
function
|
|
444
|
-
|
|
445
|
-
|
|
455
|
+
function hslToRgb(hue, saturation, lightness, convert) {
|
|
456
|
+
if (convert === void 0) {
|
|
457
|
+
convert = convertToInt;
|
|
458
|
+
}
|
|
446
459
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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
|
+
}
|
|
450
492
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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);
|
|
454
498
|
}
|
|
455
499
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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;
|
|
487
659
|
}
|
|
488
660
|
|
|
489
|
-
var
|
|
490
|
-
var
|
|
491
|
-
var
|
|
492
|
-
var
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
var
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
coral: 'ff7f50',
|
|
514
|
-
cornflowerblue: '6495ed',
|
|
515
|
-
cornsilk: 'fff8dc',
|
|
516
|
-
crimson: 'dc143c',
|
|
517
|
-
cyan: '00ffff',
|
|
518
|
-
darkblue: '00008b',
|
|
519
|
-
darkcyan: '008b8b',
|
|
520
|
-
darkgoldenrod: 'b8860b',
|
|
521
|
-
darkgray: 'a9a9a9',
|
|
522
|
-
darkgreen: '006400',
|
|
523
|
-
darkgrey: 'a9a9a9',
|
|
524
|
-
darkkhaki: 'bdb76b',
|
|
525
|
-
darkmagenta: '8b008b',
|
|
526
|
-
darkolivegreen: '556b2f',
|
|
527
|
-
darkorange: 'ff8c00',
|
|
528
|
-
darkorchid: '9932cc',
|
|
529
|
-
darkred: '8b0000',
|
|
530
|
-
darksalmon: 'e9967a',
|
|
531
|
-
darkseagreen: '8fbc8f',
|
|
532
|
-
darkslateblue: '483d8b',
|
|
533
|
-
darkslategray: '2f4f4f',
|
|
534
|
-
darkslategrey: '2f4f4f',
|
|
535
|
-
darkturquoise: '00ced1',
|
|
536
|
-
darkviolet: '9400d3',
|
|
537
|
-
deeppink: 'ff1493',
|
|
538
|
-
deepskyblue: '00bfff',
|
|
539
|
-
dimgray: '696969',
|
|
540
|
-
dimgrey: '696969',
|
|
541
|
-
dodgerblue: '1e90ff',
|
|
542
|
-
firebrick: 'b22222',
|
|
543
|
-
floralwhite: 'fffaf0',
|
|
544
|
-
forestgreen: '228b22',
|
|
545
|
-
fuchsia: 'ff00ff',
|
|
546
|
-
gainsboro: 'dcdcdc',
|
|
547
|
-
ghostwhite: 'f8f8ff',
|
|
548
|
-
gold: 'ffd700',
|
|
549
|
-
goldenrod: 'daa520',
|
|
550
|
-
gray: '808080',
|
|
551
|
-
green: '008000',
|
|
552
|
-
greenyellow: 'adff2f',
|
|
553
|
-
grey: '808080',
|
|
554
|
-
honeydew: 'f0fff0',
|
|
555
|
-
hotpink: 'ff69b4',
|
|
556
|
-
indianred: 'cd5c5c',
|
|
557
|
-
indigo: '4b0082',
|
|
558
|
-
ivory: 'fffff0',
|
|
559
|
-
khaki: 'f0e68c',
|
|
560
|
-
lavender: 'e6e6fa',
|
|
561
|
-
lavenderblush: 'fff0f5',
|
|
562
|
-
lawngreen: '7cfc00',
|
|
563
|
-
lemonchiffon: 'fffacd',
|
|
564
|
-
lightblue: 'add8e6',
|
|
565
|
-
lightcoral: 'f08080',
|
|
566
|
-
lightcyan: 'e0ffff',
|
|
567
|
-
lightgoldenrodyellow: 'fafad2',
|
|
568
|
-
lightgray: 'd3d3d3',
|
|
569
|
-
lightgreen: '90ee90',
|
|
570
|
-
lightgrey: 'd3d3d3',
|
|
571
|
-
lightpink: 'ffb6c1',
|
|
572
|
-
lightsalmon: 'ffa07a',
|
|
573
|
-
lightseagreen: '20b2aa',
|
|
574
|
-
lightskyblue: '87cefa',
|
|
575
|
-
lightslategray: '789',
|
|
576
|
-
lightslategrey: '789',
|
|
577
|
-
lightsteelblue: 'b0c4de',
|
|
578
|
-
lightyellow: 'ffffe0',
|
|
579
|
-
lime: '0f0',
|
|
580
|
-
limegreen: '32cd32',
|
|
581
|
-
linen: 'faf0e6',
|
|
582
|
-
magenta: 'f0f',
|
|
583
|
-
maroon: '800000',
|
|
584
|
-
mediumaquamarine: '66cdaa',
|
|
585
|
-
mediumblue: '0000cd',
|
|
586
|
-
mediumorchid: 'ba55d3',
|
|
587
|
-
mediumpurple: '9370db',
|
|
588
|
-
mediumseagreen: '3cb371',
|
|
589
|
-
mediumslateblue: '7b68ee',
|
|
590
|
-
mediumspringgreen: '00fa9a',
|
|
591
|
-
mediumturquoise: '48d1cc',
|
|
592
|
-
mediumvioletred: 'c71585',
|
|
593
|
-
midnightblue: '191970',
|
|
594
|
-
mintcream: 'f5fffa',
|
|
595
|
-
mistyrose: 'ffe4e1',
|
|
596
|
-
moccasin: 'ffe4b5',
|
|
597
|
-
navajowhite: 'ffdead',
|
|
598
|
-
navy: '000080',
|
|
599
|
-
oldlace: 'fdf5e6',
|
|
600
|
-
olive: '808000',
|
|
601
|
-
olivedrab: '6b8e23',
|
|
602
|
-
orange: 'ffa500',
|
|
603
|
-
orangered: 'ff4500',
|
|
604
|
-
orchid: 'da70d6',
|
|
605
|
-
palegoldenrod: 'eee8aa',
|
|
606
|
-
palegreen: '98fb98',
|
|
607
|
-
paleturquoise: 'afeeee',
|
|
608
|
-
palevioletred: 'db7093',
|
|
609
|
-
papayawhip: 'ffefd5',
|
|
610
|
-
peachpuff: 'ffdab9',
|
|
611
|
-
peru: 'cd853f',
|
|
612
|
-
pink: 'ffc0cb',
|
|
613
|
-
plum: 'dda0dd',
|
|
614
|
-
powderblue: 'b0e0e6',
|
|
615
|
-
purple: '800080',
|
|
616
|
-
rebeccapurple: '639',
|
|
617
|
-
red: 'f00',
|
|
618
|
-
rosybrown: 'bc8f8f',
|
|
619
|
-
royalblue: '4169e1',
|
|
620
|
-
saddlebrown: '8b4513',
|
|
621
|
-
salmon: 'fa8072',
|
|
622
|
-
sandybrown: 'f4a460',
|
|
623
|
-
seagreen: '2e8b57',
|
|
624
|
-
seashell: 'fff5ee',
|
|
625
|
-
sienna: 'a0522d',
|
|
626
|
-
silver: 'c0c0c0',
|
|
627
|
-
skyblue: '87ceeb',
|
|
628
|
-
slateblue: '6a5acd',
|
|
629
|
-
slategray: '708090',
|
|
630
|
-
slategrey: '708090',
|
|
631
|
-
snow: 'fffafa',
|
|
632
|
-
springgreen: '00ff7f',
|
|
633
|
-
steelblue: '4682b4',
|
|
634
|
-
tan: 'd2b48c',
|
|
635
|
-
teal: '008080',
|
|
636
|
-
thistle: 'd8bfd8',
|
|
637
|
-
tomato: 'ff6347',
|
|
638
|
-
turquoise: '40e0d0',
|
|
639
|
-
violet: 'ee82ee',
|
|
640
|
-
wheat: 'f5deb3',
|
|
641
|
-
white: 'fff',
|
|
642
|
-
whitesmoke: 'f5f5f5',
|
|
643
|
-
yellow: 'ff0',
|
|
644
|
-
yellowgreen: '9acd32'
|
|
645
|
-
};
|
|
646
|
-
/**
|
|
647
|
-
* Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
|
|
648
|
-
* @private
|
|
649
|
-
*/
|
|
650
|
-
|
|
651
|
-
function nameToHex(color) {
|
|
652
|
-
if (typeof color !== 'string') return color;
|
|
653
|
-
var normalizedColorName = color.toLowerCase();
|
|
654
|
-
return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
var hexRegex = /^#[a-fA-F0-9]{6}$/;
|
|
658
|
-
var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
|
|
659
|
-
var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
|
|
660
|
-
var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
|
|
661
|
-
var rgbRegex = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
|
|
662
|
-
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;
|
|
663
|
-
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;
|
|
664
|
-
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;
|
|
665
|
-
/**
|
|
666
|
-
* Returns an RgbColor or RgbaColor object. This utility function is only useful
|
|
667
|
-
* if want to extract a color component. With the color util `toColorString` you
|
|
668
|
-
* can convert a RgbColor or RgbaColor object back to a string.
|
|
669
|
-
*
|
|
670
|
-
* @example
|
|
671
|
-
* // Assigns `{ red: 255, green: 0, blue: 0 }` to color1
|
|
672
|
-
* const color1 = parseToRgb('rgb(255, 0, 0)');
|
|
673
|
-
* // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
|
|
674
|
-
* const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
|
|
675
|
-
*/
|
|
676
|
-
|
|
677
|
-
function parseToRgb(color) {
|
|
678
|
-
if (typeof color !== 'string') {
|
|
679
|
-
throw new PolishedError(3);
|
|
680
|
-
}
|
|
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
|
+
}
|
|
681
685
|
|
|
682
|
-
|
|
686
|
+
var normalizedColor = nameToHex(color);
|
|
683
687
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
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
|
+
}
|
|
691
695
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
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
|
+
}
|
|
701
705
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
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
|
+
}
|
|
709
713
|
|
|
710
|
-
|
|
711
|
-
|
|
714
|
+
if (normalizedColor.match(reducedRgbaHexRegex)) {
|
|
715
|
+
var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
|
712
716
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
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
|
+
}
|
|
720
724
|
|
|
721
|
-
|
|
725
|
+
var rgbMatched = rgbRegex.exec(normalizedColor);
|
|
722
726
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
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
|
+
}
|
|
730
734
|
|
|
731
|
-
|
|
735
|
+
var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
|
|
732
736
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
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
|
+
}
|
|
741
745
|
|
|
742
|
-
|
|
746
|
+
var hslMatched = hslRegex.exec(normalizedColor);
|
|
743
747
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
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
|
+
}
|
|
750
758
|
|
|
751
|
-
|
|
752
|
-
|
|
759
|
+
return {
|
|
760
|
+
red: parseInt("" + hslRgbMatched[1], 10),
|
|
761
|
+
green: parseInt("" + hslRgbMatched[2], 10),
|
|
762
|
+
blue: parseInt("" + hslRgbMatched[3], 10)
|
|
763
|
+
};
|
|
753
764
|
}
|
|
754
765
|
|
|
755
|
-
|
|
756
|
-
red: parseInt("" + hslRgbMatched[1], 10),
|
|
757
|
-
green: parseInt("" + hslRgbMatched[2], 10),
|
|
758
|
-
blue: parseInt("" + hslRgbMatched[3], 10)
|
|
759
|
-
};
|
|
760
|
-
}
|
|
766
|
+
var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
|
|
761
767
|
|
|
762
|
-
|
|
768
|
+
if (hslaMatched) {
|
|
769
|
+
var _hue = parseInt("" + hslaMatched[1], 10);
|
|
763
770
|
|
|
764
|
-
|
|
765
|
-
var _hue = parseInt("" + hslaMatched[1], 10);
|
|
771
|
+
var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
|
|
766
772
|
|
|
767
|
-
|
|
773
|
+
var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
|
|
768
774
|
|
|
769
|
-
|
|
775
|
+
var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
|
|
770
776
|
|
|
771
|
-
|
|
777
|
+
var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
|
772
778
|
|
|
773
|
-
|
|
779
|
+
if (!_hslRgbMatched) {
|
|
780
|
+
throw new PolishedError(4, normalizedColor, _rgbColorString);
|
|
781
|
+
}
|
|
774
782
|
|
|
775
|
-
|
|
776
|
-
|
|
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
|
+
};
|
|
777
789
|
}
|
|
778
790
|
|
|
779
|
-
|
|
780
|
-
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
781
|
-
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
782
|
-
blue: parseInt("" + _hslRgbMatched[3], 10),
|
|
783
|
-
alpha: parseFloat("" + hslaMatched[4])
|
|
784
|
-
};
|
|
791
|
+
throw new PolishedError(5);
|
|
785
792
|
}
|
|
786
793
|
|
|
787
|
-
|
|
788
|
-
|
|
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
|
+
}
|
|
789
802
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
var
|
|
795
|
-
|
|
796
|
-
return "#" + value[1] + value[3] + value[5];
|
|
803
|
+
return value;
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
function numberToHex(value) {
|
|
807
|
+
var hex = value.toString(16);
|
|
808
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
797
809
|
}
|
|
798
810
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
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, []);
|
|
835
907
|
}
|
|
836
908
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
/**
|
|
841
|
-
* Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
|
|
842
|
-
*
|
|
843
|
-
* Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
|
|
844
|
-
*
|
|
845
|
-
* @example
|
|
846
|
-
* // Styles as object usage
|
|
847
|
-
* const styles = {
|
|
848
|
-
* background: rgba(255, 205, 100, 0.7),
|
|
849
|
-
* background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
|
|
850
|
-
* background: rgba(255, 205, 100, 1),
|
|
851
|
-
* background: rgba('#ffffff', 0.4),
|
|
852
|
-
* background: rgba('black', 0.7),
|
|
853
|
-
* }
|
|
854
|
-
*
|
|
855
|
-
* // styled-components usage
|
|
856
|
-
* const div = styled.div`
|
|
857
|
-
* background: ${rgba(255, 205, 100, 0.7)};
|
|
858
|
-
* background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
|
|
859
|
-
* background: ${rgba(255, 205, 100, 1)};
|
|
860
|
-
* background: ${rgba('#ffffff', 0.4)};
|
|
861
|
-
* background: ${rgba('black', 0.7)};
|
|
862
|
-
* `
|
|
863
|
-
*
|
|
864
|
-
* // CSS in JS Output
|
|
865
|
-
*
|
|
866
|
-
* element {
|
|
867
|
-
* background: "rgba(255,205,100,0.7)";
|
|
868
|
-
* background: "rgba(255,205,100,0.7)";
|
|
869
|
-
* background: "#ffcd64";
|
|
870
|
-
* background: "rgba(255,255,255,0.4)";
|
|
871
|
-
* background: "rgba(0,0,0,0.7)";
|
|
872
|
-
* }
|
|
873
|
-
*/
|
|
874
|
-
function rgba(firstValue, secondValue, thirdValue, fourthValue) {
|
|
875
|
-
if (typeof firstValue === 'string' && typeof secondValue === 'number') {
|
|
876
|
-
var rgbValue = parseToRgb(firstValue);
|
|
877
|
-
return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
|
|
878
|
-
} else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
|
|
879
|
-
return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
|
|
880
|
-
} else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
|
881
|
-
return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
909
|
+
function guard(lowerBoundary, upperBoundary, value) {
|
|
910
|
+
return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
|
882
911
|
}
|
|
883
912
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
//
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
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);
|
|
896
984
|
};
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
* @example
|
|
914
|
-
* // Styles as object usage
|
|
915
|
-
* const styles = {
|
|
916
|
-
* background: transparentize(0.1, '#fff');
|
|
917
|
-
* background: transparentize(0.2, 'hsl(0, 0%, 100%)'),
|
|
918
|
-
* background: transparentize('0.5', 'rgba(255, 0, 0, 0.8)'),
|
|
919
|
-
* }
|
|
920
|
-
*
|
|
921
|
-
* // styled-components usage
|
|
922
|
-
* const div = styled.div`
|
|
923
|
-
* background: ${transparentize(0.1, '#fff')};
|
|
924
|
-
* background: ${transparentize(0.2, 'hsl(0, 0%, 100%)')},
|
|
925
|
-
* background: ${transparentize('0.5', 'rgba(255, 0, 0, 0.8)')},
|
|
926
|
-
* `
|
|
927
|
-
*
|
|
928
|
-
* // CSS in JS Output
|
|
929
|
-
*
|
|
930
|
-
* element {
|
|
931
|
-
* background: "rgba(255,255,255,0.9)";
|
|
932
|
-
* background: "rgba(255,255,255,0.8)";
|
|
933
|
-
* background: "rgba(255,0,0,0.3)";
|
|
934
|
-
* }
|
|
935
|
-
*/
|
|
936
|
-
|
|
937
|
-
function transparentize(amount, color) {
|
|
938
|
-
if (color === 'transparent') return color;
|
|
939
|
-
var parsedColor = parseToRgb(color);
|
|
940
|
-
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
941
|
-
|
|
942
|
-
var colorWithAlpha = _extends$1({}, parsedColor, {
|
|
943
|
-
alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
|
|
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];
|
|
944
999
|
});
|
|
945
1000
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
var
|
|
958
|
-
var
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
},
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
return 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);
|
|
980
|
-
};
|
|
981
|
-
|
|
982
|
-
var _templateObject$2;
|
|
983
|
-
var ToolTipWrapper = styled.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"])));
|
|
984
|
-
|
|
985
|
-
var _templateObject$3;
|
|
986
|
-
var Footer = styled.div(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n display: flex;\n flex-flow: row nowrap;\n justify-content: flex-end;\n"])));
|
|
987
|
-
|
|
988
|
-
var _excluded = ["dragging", "value", "offset", "index"],
|
|
989
|
-
_excluded2 = ["renderTitleSection", "marks", "defaultMinValue", "defaultMaxValue", "min", "max", "toolTipComponent", "renderFooterSection", "onChange", "children", "identifier", "showMarks"];
|
|
990
|
-
|
|
991
|
-
var _templateObject$4;
|
|
992
|
-
var debounceBuilder = debounced(100);
|
|
993
|
-
var ChildrenWrapper = styled.div(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n margin-bottom: ", ";\n"])), function (props) {
|
|
994
|
-
return props.theme.marginPaddings[3];
|
|
995
|
-
});
|
|
996
|
-
|
|
997
|
-
var renderCustomHandle = function renderCustomHandle() {
|
|
998
|
-
var marks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
999
|
-
var toolTipComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1000
|
-
var handleProps = arguments.length > 2 ? arguments[2] : undefined;
|
|
1001
|
-
|
|
1002
|
-
var dragging = handleProps.dragging,
|
|
1003
|
-
value = handleProps.value,
|
|
1004
|
-
offset = handleProps.offset,
|
|
1005
|
-
index = handleProps.index,
|
|
1006
|
-
restHandleProps = _objectWithoutProperties(handleProps, _excluded);
|
|
1007
|
-
|
|
1008
|
-
var getToolTipProps = function getToolTipProps() {
|
|
1009
|
-
var newProps = {}; // Ensures that Tooltip component does not get ref prop
|
|
1010
|
-
|
|
1011
|
-
Object.keys(handleProps).forEach(function (propName) {
|
|
1012
|
-
if (propName !== 'ref') {
|
|
1013
|
-
newProps[propName] = handleProps[propName];
|
|
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, "%")
|
|
1014
1034
|
}
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1035
|
+
}, /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
1036
|
+
marks: marks
|
|
1037
|
+
}, getToolTipProps()))));
|
|
1017
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
|
+
};
|
|
1018
1082
|
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
offset: offset,
|
|
1024
|
-
value: value
|
|
1025
|
-
}, restHandleProps, {
|
|
1026
|
-
dragging: dragging.toString()
|
|
1027
|
-
})), toolTipComponent && /*#__PURE__*/React.createElement(ToolTipWrapper, {
|
|
1028
|
-
style: {
|
|
1029
|
-
left: "".concat(offset, "%")
|
|
1030
|
-
}
|
|
1031
|
-
}, /*#__PURE__*/React.createElement(Tooltip, _extends({
|
|
1032
|
-
marks: marks
|
|
1033
|
-
}, getToolTipProps()))));
|
|
1034
|
-
};
|
|
1035
|
-
/** slider ui component for react */
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
var RangeSlider = function RangeSlider(_ref) {
|
|
1039
|
-
var renderTitleSection = _ref.renderTitleSection,
|
|
1040
|
-
marks = _ref.marks,
|
|
1041
|
-
defaultMinValue = _ref.defaultMinValue,
|
|
1042
|
-
defaultMaxValue = _ref.defaultMaxValue,
|
|
1043
|
-
min = _ref.min,
|
|
1044
|
-
max = _ref.max,
|
|
1045
|
-
toolTipComponent = _ref.toolTipComponent,
|
|
1046
|
-
renderFooterSection = _ref.renderFooterSection,
|
|
1047
|
-
onChange = _ref.onChange,
|
|
1048
|
-
childRenderer = _ref.children,
|
|
1049
|
-
identifier = _ref.identifier,
|
|
1050
|
-
showMarks = _ref.showMarks,
|
|
1051
|
-
restProps = _objectWithoutProperties(_ref, _excluded2);
|
|
1052
|
-
|
|
1053
|
-
var _useState = useState(defaultMinValue),
|
|
1054
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1055
|
-
currMinVal = _useState2[0],
|
|
1056
|
-
setMinVal = _useState2[1];
|
|
1057
|
-
|
|
1058
|
-
var _useState3 = useState(defaultMaxValue),
|
|
1059
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
1060
|
-
currMaxVal = _useState4[0],
|
|
1061
|
-
setMaxVal = _useState4[1];
|
|
1062
|
-
/*
|
|
1063
|
-
*Description variable stores the time that the component renders
|
|
1064
|
-
* the state is used to enforce reenders for the component since the date now
|
|
1065
|
-
* is always changing
|
|
1066
|
-
* */
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
var _useState5 = useState(0),
|
|
1070
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
1071
|
-
seed = _useState6[0],
|
|
1072
|
-
setSeed = _useState6[1];
|
|
1073
|
-
|
|
1074
|
-
var manuallyChangeMinValue = function manuallyChangeMinValue(val) {
|
|
1075
|
-
setMinVal(val);
|
|
1076
|
-
setSeed(Date.now());
|
|
1077
|
-
};
|
|
1083
|
+
var manuallyChangeMaxValue = function manuallyChangeMaxValue(val) {
|
|
1084
|
+
setMaxVal(val);
|
|
1085
|
+
setSeed(Date.now());
|
|
1086
|
+
};
|
|
1078
1087
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
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)));
|
|
1082
1137
|
};
|
|
1083
1138
|
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
var value = {
|
|
1093
|
-
min: currMinVal,
|
|
1094
|
-
max: currMaxVal
|
|
1095
|
-
};
|
|
1096
|
-
debounceBuilder(function () {
|
|
1097
|
-
return onChange(value);
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
}, [currMaxVal, currMinVal, onChange, prevMaxVal, prevMinVal]);
|
|
1101
|
-
var actionsObj = {
|
|
1102
|
-
manuallyChangeMinValue: manuallyChangeMinValue,
|
|
1103
|
-
manuallyChangeMaxValue: manuallyChangeMaxValue,
|
|
1104
|
-
currMinVal: currMinVal,
|
|
1105
|
-
currMaxVal: currMaxVal,
|
|
1106
|
-
defaultMinValue: defaultMinValue,
|
|
1107
|
-
defaultMaxValue: defaultMaxValue
|
|
1108
|
-
};
|
|
1109
|
-
return /*#__PURE__*/React.createElement(SliderContainer, {
|
|
1110
|
-
"data-qe-id": identifier,
|
|
1111
|
-
showMarks: showMarks
|
|
1112
|
-
}, renderTitleSection(actionsObj), childRenderer && /*#__PURE__*/React.createElement(ChildrenWrapper, null, typeof childRenderer === 'function' ? childRenderer(actionsObj) : childRenderer), /*#__PURE__*/React.createElement(Range, _extends({
|
|
1113
|
-
seed: seed,
|
|
1114
|
-
min: min,
|
|
1115
|
-
max: max,
|
|
1116
|
-
defaultValue: [defaultMinValue, defaultMaxValue],
|
|
1117
|
-
onChange: function onChange(_ref2) {
|
|
1118
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
1119
|
-
nextMin = _ref3[0],
|
|
1120
|
-
nextMax = _ref3[1];
|
|
1121
|
-
|
|
1122
|
-
setMinVal(nextMin);
|
|
1123
|
-
setMaxVal(nextMax);
|
|
1139
|
+
RangeSlider.defaultProps = {
|
|
1140
|
+
renderTitleSection: function renderTitleSection() {
|
|
1141
|
+
return false;
|
|
1142
|
+
},
|
|
1143
|
+
marks: {},
|
|
1144
|
+
toolTipComponent: null,
|
|
1145
|
+
renderFooterSection: function renderFooterSection() {
|
|
1146
|
+
return false;
|
|
1124
1147
|
},
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
step: isObjectEmpty(marks) ? 1 : null,
|
|
1128
|
-
handle: function handle(props) {
|
|
1129
|
-
return renderCustomHandle(marks, toolTipComponent, props);
|
|
1148
|
+
onChange: function onChange() {
|
|
1149
|
+
return false;
|
|
1130
1150
|
},
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
};
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
marks: {},
|
|
1140
|
-
toolTipComponent: null,
|
|
1141
|
-
renderFooterSection: function renderFooterSection() {
|
|
1142
|
-
return false;
|
|
1143
|
-
},
|
|
1144
|
-
onChange: function onChange() {
|
|
1145
|
-
return false;
|
|
1146
|
-
},
|
|
1147
|
-
children: null,
|
|
1148
|
-
showMarks: false
|
|
1149
|
-
};
|
|
1150
|
-
var index = themed(RangeSlider);
|
|
1151
|
-
|
|
1152
|
-
export default index;
|
|
1151
|
+
children: null,
|
|
1152
|
+
showMarks: false
|
|
1153
|
+
};
|
|
1154
|
+
var index = themed(RangeSlider);
|
|
1155
|
+
|
|
1156
|
+
return index;
|
|
1157
|
+
|
|
1158
|
+
})));
|