@via-profit/ui-kit 0.2.1-alpha.1 → 0.2.1-alpha.3
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/Autocomplete/AutocompleteContainer.d.ts +33 -6
- package/Autocomplete/AutocompleteContainer.js +28 -24
- package/Autocomplete/AutocompleteItem.d.ts +1 -1
- package/Autocomplete/AutocompleteTextField.d.ts +3 -0
- package/Autocomplete/AutocompleteTextField.js +63 -1
- package/Autocomplete/OverrideMenuList.d.ts +4 -0
- package/Autocomplete/OverrideMenuList.js +39 -0
- package/Autocomplete/context.d.ts +9 -1
- package/Autocomplete/context.js +15 -1
- package/Autocomplete/index.js +9 -10
- package/Autocomplete2/Autocomplete2.d.ts +12 -0
- package/Autocomplete2/Autocomplete2.js +83 -0
- package/Autocomplete2/Autocomplete2TextField.d.ts +7 -0
- package/Autocomplete2/Autocomplete2TextField.js +39 -0
- package/Autocomplete2/index.d.ts +2 -0
- package/Autocomplete2/index.js +7 -0
- package/Avatar/index.js +1 -1
- package/Badge/BadgeDeleteButton.js +6 -6
- package/Badge/BadgeOutlined.js +2 -2
- package/Badge/BadgeStandard.js +1 -1
- package/Button/ButtonOutlined.js +1 -1
- package/Button/ButtonPlain.js +1 -1
- package/Button/ButtonStandard.js +4 -11
- package/Calendar/CalendarCell.js +6 -2
- package/Calendar/CalendarComponent.d.ts +226 -0
- package/Calendar/CalendarComponent.js +572 -0
- package/Calendar/CalendarControlButton.js +16 -9
- package/Calendar/CalendarDayBadge.js +1 -1
- package/Calendar/CalendarEmptyCell.d.ts +2 -2
- package/Calendar/CalendarEmptyCell.js +8 -3
- package/Calendar/CalendarHeading.js +2 -1
- package/Calendar/CalendarSubheading.js +3 -2
- package/Calendar/CalendarWeekDayCell.d.ts +10 -0
- package/Calendar/CalendarWeekDayCell.js +32 -0
- package/Calendar/CalendarWeekDayWeekNumber.d.ts +7 -0
- package/Calendar/CalendarWeekDayWeekNumber.js +38 -0
- package/Calendar/CalendarWeekRow.d.ts +2 -2
- package/Calendar/CalendarWeekRow.js +2 -1
- package/Calendar/CalendarWeekRowButton.d.ts +13 -0
- package/Calendar/CalendarWeekRowButton.js +31 -0
- package/Calendar/CalendarYearsSelector.d.ts +39 -1
- package/Calendar/CalendarYearsSelector.js +52 -16
- package/Calendar/IconChevronDown.d.ts +3 -0
- package/Calendar/IconChevronDown.js +31 -0
- package/Calendar/index.d.ts +7 -224
- package/Calendar/index.js +19 -281
- package/Calendar/use-calendar.d.ts +1 -1
- package/Color/Color.d.ts +138 -0
- package/Color/Color.js +324 -0
- package/Color/ColorGenerator.d.ts +29 -0
- package/Color/ColorGenerator.js +141 -0
- package/Color/ColorParser.d.ts +20 -0
- package/Color/ColorParser.js +284 -0
- package/Color/index.d.ts +4 -122
- package/Color/index.js +18 -473
- package/DatePicker/index.d.ts +2 -17
- package/DatePicker/index.js +47 -61
- package/DatePicker/useDatePickerFormat.js +5 -5
- package/ErrorBoundary/Fallback.d.ts +3 -0
- package/ErrorBoundary/Fallback.js +51 -0
- package/ErrorBoundary/RenderError.d.ts +6 -0
- package/ErrorBoundary/RenderError.js +80 -0
- package/ErrorBoundary/index.d.ts +7 -11
- package/ErrorBoundary/index.js +4 -51
- package/LoadingIndicator/Spinner.d.ts +5 -3
- package/LoadingIndicator/Spinner.js +61 -32
- package/LoadingIndicator/index.d.ts +3 -3
- package/LoadingIndicator/index.js +15 -2
- package/MaskedField/index.d.ts +1 -1
- package/MaskedField/index.js +11 -10
- package/Menu/AutoHeightWrapper.d.ts +6 -0
- package/Menu/AutoHeightWrapper.js +43 -0
- package/Menu/MeasuredItem.d.ts +10 -0
- package/Menu/MeasuredItem.js +51 -0
- package/Menu/MenuContainer.d.ts +51 -18
- package/Menu/MenuContainer.js +18 -11
- package/Menu/MenuItem.d.ts +24 -7
- package/Menu/MenuItem.js +13 -6
- package/Menu/MenuList.d.ts +4 -2
- package/Menu/MenuList.js +26 -6
- package/Menu/VirtualizedItem.d.ts +22 -0
- package/Menu/VirtualizedItem.js +69 -0
- package/Menu/VirtualizedList.d.ts +18 -0
- package/Menu/VirtualizedList.js +28 -0
- package/Menu/VirtualizedListComponent.d.ts +20 -0
- package/Menu/VirtualizedListComponent.js +305 -0
- package/Menu/index.d.ts +3 -1
- package/Menu/index.js +2 -0
- package/Popper/Popper.d.ts +7 -80
- package/Popper/Popper.js +26 -12
- package/Popper/PopperContainer.js +1 -1
- package/Popper/usePopprer.d.ts +88 -3
- package/Popper/usePopprer.js +240 -65
- package/Selectbox/SelectboxButton.d.ts +5 -0
- package/Selectbox/SelectboxButton.js +48 -8
- package/Selectbox/SelectboxButtonWrapper.d.ts +2 -0
- package/Selectbox/SelectboxButtonWrapper.js +1 -17
- package/Selectbox/SelectboxMenu.d.ts +12 -0
- package/Selectbox/SelectboxMenu.js +50 -0
- package/Selectbox/index.d.ts +5 -5
- package/Selectbox/index.js +115 -97
- package/Surface/index.js +1 -1
- package/Swiper/Swiper.d.ts +44 -0
- package/Swiper/Swiper.js +139 -0
- package/Swiper/SwiperContainer.d.ts +7 -0
- package/Swiper/SwiperContainer.js +14 -0
- package/Swiper/SwiperSlide.d.ts +7 -0
- package/Swiper/SwiperSlide.js +55 -0
- package/Swiper/SwiperTrack.d.ts +14 -0
- package/Swiper/SwiperTrack.js +58 -0
- package/Swiper/SwiperWrapper.d.ts +14 -0
- package/Swiper/SwiperWrapper.js +60 -0
- package/Swiper/index.d.ts +7 -0
- package/Swiper/index.js +26 -0
- package/Switch/SwitchDot.js +1 -1
- package/Switch/SwitchTrack.js +1 -1
- package/TextField/TextFieldContainer.d.ts +2 -2
- package/TextField/TextFieldContainer.js +5 -3
- package/TextField/TextFieldErrorText.d.ts +2 -2
- package/TextField/TextFieldErrorText.js +5 -4
- package/TextField/TextFieldIconWrapper.d.ts +3 -3
- package/TextField/TextFieldIconWrapper.js +5 -3
- package/TextField/TextFieldInput.d.ts +2 -2
- package/TextField/TextFieldInput.js +6 -4
- package/TextField/TextFieldInputWrapper.d.ts +2 -2
- package/TextField/TextFieldInputWrapper.js +5 -3
- package/TextField/TextFieldLabel.d.ts +2 -2
- package/TextField/TextFieldLabel.js +5 -3
- package/TextField/TextFieldLabelAsterisk.d.ts +2 -2
- package/TextField/TextFieldLabelAsterisk.js +5 -3
- package/TextField/index.d.ts +8 -1
- package/TextField/index.js +49 -22
- package/ThemeProvider/createTheme.js +2 -2
- package/package.json +1 -1
- package/Calendar/reducer.d.ts +0 -17
- package/Calendar/reducer.js +0 -50
- /package/Calendar/{IconChevronRight.d.ts → CalendarIconNext.d.ts} +0 -0
- /package/Calendar/{IconChevronRight.js → CalendarIconNext.js} +0 -0
package/Color/index.js
CHANGED
|
@@ -1,476 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
7
15
|
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _Color_color, _Color_cache;
|
|
14
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
__classPrivateFieldSet(this, _Color_color, Object.assign({}, value.rgb()), "f");
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
__classPrivateFieldSet(this, _Color_color, Color.parseColor(value), "f");
|
|
24
|
-
}
|
|
25
|
-
__classPrivateFieldSet(this, _Color_cache, Object.assign({}, __classPrivateFieldGet(this, _Color_color, "f")), "f");
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Lightens the current color by the \
|
|
30
|
-
* transmitted number of conventional units.\
|
|
31
|
-
* \
|
|
32
|
-
* Example:
|
|
33
|
-
* ```tsx
|
|
34
|
-
* const color = theme.colors
|
|
35
|
-
* .accentPrimary
|
|
36
|
-
* .lighten(60)
|
|
37
|
-
* .toString();
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
lighten(decimal) {
|
|
42
|
-
return this.shade(decimal);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Darkens the current color by\
|
|
46
|
-
* the transmitted number of conventional units.
|
|
47
|
-
* \
|
|
48
|
-
* Example:
|
|
49
|
-
* ```tsx
|
|
50
|
-
* const color = theme.colors
|
|
51
|
-
* .accentPrimary
|
|
52
|
-
* .darken(60)
|
|
53
|
-
* .toString();
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
darken(decimal) {
|
|
57
|
-
return this.shade(-decimal);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Applies transparency (alpha channel) to the current color\
|
|
61
|
-
* Takes as an argument a number from 0 to 1
|
|
62
|
-
* \
|
|
63
|
-
* Example:
|
|
64
|
-
* ```tsx
|
|
65
|
-
* const color = theme.colors
|
|
66
|
-
* .accentPrimary
|
|
67
|
-
* .alpha(0.5)
|
|
68
|
-
* .toString();
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
alpha(decimal) {
|
|
72
|
-
__classPrivateFieldGet(this, _Color_color, "f").a = decimal;
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Returns color luminance value
|
|
77
|
-
*/
|
|
78
|
-
getLuminance() {
|
|
79
|
-
const RED = 0.2126;
|
|
80
|
-
const GREEN = 0.7152;
|
|
81
|
-
const BLUE = 0.0722;
|
|
82
|
-
const GAMMA = 2.4;
|
|
83
|
-
const a = [__classPrivateFieldGet(this, _Color_color, "f").r, __classPrivateFieldGet(this, _Color_color, "f").g, __classPrivateFieldGet(this, _Color_color, "f").b].map(v => {
|
|
84
|
-
v /= 255;
|
|
85
|
-
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, GAMMA);
|
|
86
|
-
});
|
|
87
|
-
return a[0] * RED + a[1] * GREEN + a[2] * BLUE;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Returns the contrast level between the\
|
|
91
|
-
* current and transmitted colors
|
|
92
|
-
* \
|
|
93
|
-
* Example:
|
|
94
|
-
* ```tsx
|
|
95
|
-
* const { colors } = themes;
|
|
96
|
-
* const contrast = colors
|
|
97
|
-
* .accentPrimary
|
|
98
|
-
* .getContrast(color.textPrimary.rgbString());
|
|
99
|
-
*
|
|
100
|
-
* if (contrast > 5) {
|
|
101
|
-
* return color.textPrimary.toString();
|
|
102
|
-
* } else {
|
|
103
|
-
* return color.textSecondary.toString()
|
|
104
|
-
* }
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
getContrast(rgb2) {
|
|
108
|
-
const color2 = rgb2 instanceof Color ? rgb2 : new Color(rgb2);
|
|
109
|
-
const lum1 = this.getLuminance();
|
|
110
|
-
const lum2 = color2.getLuminance();
|
|
111
|
-
const brightest = Math.max(lum1, lum2);
|
|
112
|
-
const darkest = Math.min(lum1, lum2);
|
|
113
|
-
return (brightest + 0.05) / (darkest + 0.05);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Lighten or darknest color to lum steps
|
|
117
|
-
* lum - 0-25
|
|
118
|
-
*/
|
|
119
|
-
shade(lum) {
|
|
120
|
-
__classPrivateFieldGet(this, _Color_color, "f").r = parseInt('0' + Math.min(255, Math.max(0, __classPrivateFieldGet(this, _Color_color, "f").r + lum)), 10);
|
|
121
|
-
__classPrivateFieldGet(this, _Color_color, "f").g = parseInt('0' + Math.min(255, Math.max(0, __classPrivateFieldGet(this, _Color_color, "f").g + lum)), 10);
|
|
122
|
-
__classPrivateFieldGet(this, _Color_color, "f").b = parseInt('0' + Math.min(255, Math.max(0, __classPrivateFieldGet(this, _Color_color, "f").b + lum)), 10);
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
luminance(lum) {
|
|
126
|
-
const { r, g, b } = __classPrivateFieldGet(this, _Color_color, "f");
|
|
127
|
-
__classPrivateFieldGet(this, _Color_color, "f").r = Math.round(Math.min(Math.max(0, r + r * lum), 255));
|
|
128
|
-
__classPrivateFieldGet(this, _Color_color, "f").g = Math.round(Math.min(Math.max(0, g + g * lum), 255));
|
|
129
|
-
__classPrivateFieldGet(this, _Color_color, "f").b = Math.round(Math.min(Math.max(0, b + b * lum), 255));
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
static stringToHashCode(str) {
|
|
133
|
-
let hash = 0;
|
|
134
|
-
for (let i = 0; i < str.length; i++) {
|
|
135
|
-
const char = str.charCodeAt(i);
|
|
136
|
-
hash = (hash << 5) - hash + char;
|
|
137
|
-
hash |= 0; // Convert to a 32-bit integer
|
|
138
|
-
}
|
|
139
|
-
return hash;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Convert the integer value to a string color value
|
|
143
|
-
*/
|
|
144
|
-
static intToRGB(i) {
|
|
145
|
-
const red = (i >> 16) & 0xff;
|
|
146
|
-
const green = (i >> 8) & 0xff;
|
|
147
|
-
const blue = i & 0xff;
|
|
148
|
-
return `rgb(${red},${green},${blue})`;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Convert GUID string value to a color string
|
|
152
|
-
*/
|
|
153
|
-
static uuidToColor(uuid) {
|
|
154
|
-
const hash = Color.stringToHashCode(uuid);
|
|
155
|
-
return Color.intToRGB(hash);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Returns the current color as separate rgb channels
|
|
159
|
-
*/
|
|
160
|
-
rgb() {
|
|
161
|
-
const result = Object.assign({}, __classPrivateFieldGet(this, _Color_color, "f"));
|
|
162
|
-
__classPrivateFieldSet(this, _Color_color, Object.assign({}, __classPrivateFieldGet(this, _Color_cache, "f")), "f");
|
|
163
|
-
return result;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Returns the current color as an rgba string
|
|
167
|
-
*/
|
|
168
|
-
toString() {
|
|
169
|
-
const result = this.rgbString();
|
|
170
|
-
__classPrivateFieldSet(this, _Color_color, Object.assign({}, __classPrivateFieldGet(this, _Color_cache, "f")), "f");
|
|
171
|
-
return result;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Returns the current color as an rgba string
|
|
175
|
-
*/
|
|
176
|
-
rgbString() {
|
|
177
|
-
const result = `rgba(${__classPrivateFieldGet(this, _Color_color, "f").r}, ${__classPrivateFieldGet(this, _Color_color, "f").g}, ${__classPrivateFieldGet(this, _Color_color, "f").b}, ${__classPrivateFieldGet(this, _Color_color, "f").a})`;
|
|
178
|
-
__classPrivateFieldSet(this, _Color_color, Object.assign({}, __classPrivateFieldGet(this, _Color_cache, "f")), "f");
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Returns the current color as a hex string
|
|
183
|
-
*/
|
|
184
|
-
hexString() {
|
|
185
|
-
const colorToHex = (color) => {
|
|
186
|
-
const hexadecimal = color.toString(16);
|
|
187
|
-
return hexadecimal.length === 1 ? `0${hexadecimal}` : hexadecimal;
|
|
188
|
-
};
|
|
189
|
-
const result = '#' + colorToHex(__classPrivateFieldGet(this, _Color_color, "f").r) + colorToHex(__classPrivateFieldGet(this, _Color_color, "f").g) + colorToHex(__classPrivateFieldGet(this, _Color_color, "f").b);
|
|
190
|
-
__classPrivateFieldSet(this, _Color_color, Object.assign({}, __classPrivateFieldGet(this, _Color_cache, "f")), "f");
|
|
191
|
-
return result;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Parse the transmitted color and returns its\
|
|
195
|
-
* representation as separate rgba channels
|
|
196
|
-
*/
|
|
197
|
-
static parseColor(value) {
|
|
198
|
-
const inputColor = value.trim().toLowerCase();
|
|
199
|
-
const hsl = inputColor.indexOf('hsl') === 0;
|
|
200
|
-
const hex3 = inputColor.replace(/[^#0-9a-f]/g, '').match(/^#([0-9a-f]{3})$/i);
|
|
201
|
-
const hex6 = inputColor.replace(/[^#0-9a-f]/g, '').match(/^#([0-9a-f]{6})$/i);
|
|
202
|
-
const rgb = inputColor
|
|
203
|
-
.replace(/[^rgb(),.0-9]/g, '')
|
|
204
|
-
.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);
|
|
205
|
-
const rgba = inputColor
|
|
206
|
-
.replace(/[^rgba(),.0-9]/g, '')
|
|
207
|
-
.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+.*\d*)\s*\)$/i) ||
|
|
208
|
-
inputColor
|
|
209
|
-
.replace(/[^rgba(),.0-9]/g, '')
|
|
210
|
-
.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);
|
|
211
|
-
if (hex3 && hex3.length > 1) {
|
|
212
|
-
// in three-character format, each value is multiplied by 0x11 to give an
|
|
213
|
-
// even scale from 0x00 to 0xff
|
|
214
|
-
return {
|
|
215
|
-
r: parseInt(hex3[1].charAt(0), 16) * 0x11,
|
|
216
|
-
g: parseInt(hex3[1].charAt(1), 16) * 0x11,
|
|
217
|
-
b: parseInt(hex3[1].charAt(2), 16) * 0x11,
|
|
218
|
-
a: 1,
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
if (hex6 && hex6.length >= 1) {
|
|
222
|
-
return {
|
|
223
|
-
r: parseInt(hex6[1].substring(0, 2), 16),
|
|
224
|
-
g: parseInt(hex6[1].substring(2, 4), 16),
|
|
225
|
-
b: parseInt(hex6[1].substring(4, 6), 16),
|
|
226
|
-
a: 1,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
if (rgb && rgb.length >= 3) {
|
|
230
|
-
return {
|
|
231
|
-
r: parseInt(rgb[1], 10),
|
|
232
|
-
g: parseInt(rgb[2], 10),
|
|
233
|
-
b: parseInt(rgb[3], 10),
|
|
234
|
-
a: 1,
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
if (rgba && rgba.length >= 3) {
|
|
238
|
-
return {
|
|
239
|
-
r: parseInt(rgba[1], 10),
|
|
240
|
-
g: parseInt(rgba[2], 10),
|
|
241
|
-
b: parseInt(rgba[3], 10),
|
|
242
|
-
a: rgba[4] === undefined ? 1 : Number(rgba[4]),
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
if (hsl) {
|
|
246
|
-
return Color.hslToRgb(inputColor);
|
|
247
|
-
}
|
|
248
|
-
const webHex = Color.getHextByWebColor(inputColor);
|
|
249
|
-
if (webHex) {
|
|
250
|
-
return Color.parseColor(webHex);
|
|
251
|
-
}
|
|
252
|
-
console.error(`Failed to parse color value «${value}»`);
|
|
253
|
-
return {
|
|
254
|
-
r: 0,
|
|
255
|
-
g: 0,
|
|
256
|
-
b: 0,
|
|
257
|
-
a: 1,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Decodes the transmitted color value in hsl format to rgba
|
|
262
|
-
*/
|
|
263
|
-
static hslToRgb(value) {
|
|
264
|
-
const hsl = value.match(/(\d+(\.\d+)?)/g);
|
|
265
|
-
if (!hsl || hsl.length < 3) {
|
|
266
|
-
throw new Error(`[@via-profit/ui-kit] «${hsl}» Is not a valid hsl color`);
|
|
267
|
-
}
|
|
268
|
-
const h = Number(hsl[0]) / 360;
|
|
269
|
-
const s = Number(hsl[1]) / 100;
|
|
270
|
-
const l = Number(hsl[2]) / 100;
|
|
271
|
-
const a = hsl[3] === undefined ? 1 : Number(hsl[3]);
|
|
272
|
-
let t1;
|
|
273
|
-
let t2;
|
|
274
|
-
let t3;
|
|
275
|
-
let rgb;
|
|
276
|
-
let val;
|
|
277
|
-
if (s === 0) {
|
|
278
|
-
val = Math.round(l * 255);
|
|
279
|
-
rgb = [val, val, val, a];
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
if (l < 0.5) {
|
|
283
|
-
t2 = l * (1 + s);
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
t2 = l + s - l * s;
|
|
287
|
-
}
|
|
288
|
-
t1 = 2 * l - t2;
|
|
289
|
-
rgb = [0, 0, 0];
|
|
290
|
-
for (let i = 0; i < 3; i++) {
|
|
291
|
-
t3 = h + (1 / 3) * -(i - 1);
|
|
292
|
-
t3 < 0 && t3++;
|
|
293
|
-
t3 > 1 && t3--;
|
|
294
|
-
if (6 * t3 < 1) {
|
|
295
|
-
val = t1 + (t2 - t1) * 6 * t3;
|
|
296
|
-
}
|
|
297
|
-
else if (2 * t3 < 1) {
|
|
298
|
-
val = t2;
|
|
299
|
-
}
|
|
300
|
-
else if (3 * t3 < 2) {
|
|
301
|
-
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
val = t1;
|
|
305
|
-
}
|
|
306
|
-
rgb[i] = Math.round(val * 255);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
rgb.push(a);
|
|
310
|
-
return {
|
|
311
|
-
r: Number(rgb[0]),
|
|
312
|
-
g: Number(rgb[1]),
|
|
313
|
-
b: Number(rgb[2]),
|
|
314
|
-
a: typeof rgb[3] === 'undefined' ? 1 : Number(rgb[3]),
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Returns color code by web color name
|
|
319
|
-
*/
|
|
320
|
-
static getHextByWebColor(value) {
|
|
321
|
-
const webColors = {
|
|
322
|
-
aliceblue: '#F0F8FF',
|
|
323
|
-
antiquewhite: '#FAEBD7',
|
|
324
|
-
aqua: '#00FFFF',
|
|
325
|
-
aquamarine: '#7FFFD4',
|
|
326
|
-
azure: '#F0FFFF',
|
|
327
|
-
beige: '#F5F5DC',
|
|
328
|
-
bisque: '#FFE4C4',
|
|
329
|
-
black: '#000000',
|
|
330
|
-
blanchedalmond: '#FFEBCD',
|
|
331
|
-
blue: '#0000FF',
|
|
332
|
-
blueviolet: '#8A2BE2',
|
|
333
|
-
brown: '#A52A2A',
|
|
334
|
-
burlywood: '#DEB887',
|
|
335
|
-
cadetblue: '#5F9EA0',
|
|
336
|
-
chartreuse: '#7FFF00',
|
|
337
|
-
chocolate: '#D2691E',
|
|
338
|
-
coral: '#FF7F50',
|
|
339
|
-
cornflowerblue: '#6495ED',
|
|
340
|
-
cornsilk: '#FFF8DC',
|
|
341
|
-
crimson: '#DC143C',
|
|
342
|
-
cyan: '#00FFFF',
|
|
343
|
-
darkblue: '#00008B',
|
|
344
|
-
darkcyan: '#008B8B',
|
|
345
|
-
darkgoldenrod: '#B8860B',
|
|
346
|
-
darkgray: '#A9A9A9',
|
|
347
|
-
darkgrey: '#A9A9A9',
|
|
348
|
-
darkgreen: '#006400',
|
|
349
|
-
darkkhaki: '#BDB76B',
|
|
350
|
-
darkmagenta: '#8B008B',
|
|
351
|
-
darkolivegreen: '#556B2F',
|
|
352
|
-
darkorange: '#FF8C00',
|
|
353
|
-
darkorchid: '#9932CC',
|
|
354
|
-
darkred: '#8B0000',
|
|
355
|
-
darksalmon: '#E9967A',
|
|
356
|
-
darkseagreen: '#8FBC8F',
|
|
357
|
-
darkslateblue: '#483D8B',
|
|
358
|
-
darkslategray: '#2F4F4F',
|
|
359
|
-
darkslategrey: '#2F4F4F',
|
|
360
|
-
darkturquoise: '#00CED1',
|
|
361
|
-
darkviolet: '#9400D3',
|
|
362
|
-
deeppink: '#FF1493',
|
|
363
|
-
deepskyblue: '#00BFFF',
|
|
364
|
-
dimgray: '#696969',
|
|
365
|
-
dimgrey: '#696969',
|
|
366
|
-
dodgerblue: '#1E90FF',
|
|
367
|
-
firebrick: '#B22222',
|
|
368
|
-
floralwhite: '#FFFAF0',
|
|
369
|
-
forestgreen: '#228B22',
|
|
370
|
-
fuchsia: '#FF00FF',
|
|
371
|
-
gainsboro: '#DCDCDC',
|
|
372
|
-
ghostwhite: '#F8F8FF',
|
|
373
|
-
gold: '#FFD700',
|
|
374
|
-
goldenrod: '#DAA520',
|
|
375
|
-
gray: '#808080',
|
|
376
|
-
grey: '#808080',
|
|
377
|
-
green: '#008000',
|
|
378
|
-
greenyellow: '#ADFF2F',
|
|
379
|
-
honeydew: '#F0FFF0',
|
|
380
|
-
hotpink: '#FF69B4',
|
|
381
|
-
'indianred ': '#CD5C5C',
|
|
382
|
-
'indigo ': '#4B0082',
|
|
383
|
-
ivory: '#FFFFF0',
|
|
384
|
-
khaki: '#F0E68C',
|
|
385
|
-
lavender: '#E6E6FA',
|
|
386
|
-
lavenderblush: '#FFF0F5',
|
|
387
|
-
lawngreen: '#7CFC00',
|
|
388
|
-
lemonchiffon: '#FFFACD',
|
|
389
|
-
lightblue: '#ADD8E6',
|
|
390
|
-
lightcoral: '#F08080',
|
|
391
|
-
lightcyan: '#E0FFFF',
|
|
392
|
-
lightgoldenrodyellow: '#FAFAD2',
|
|
393
|
-
lightgray: '#D3D3D3',
|
|
394
|
-
lightgrey: '#D3D3D3',
|
|
395
|
-
lightgreen: '#90EE90',
|
|
396
|
-
lightpink: '#FFB6C1',
|
|
397
|
-
lightsalmon: '#FFA07A',
|
|
398
|
-
lightseagreen: '#20B2AA',
|
|
399
|
-
lightskyblue: '#87CEFA',
|
|
400
|
-
lightslategray: '#778899',
|
|
401
|
-
lightslategrey: '#778899',
|
|
402
|
-
lightsteelblue: '#B0C4DE',
|
|
403
|
-
lightyellow: '#FFFFE0',
|
|
404
|
-
lime: '#00FF00',
|
|
405
|
-
limegreen: '#32CD32',
|
|
406
|
-
linen: '#FAF0E6',
|
|
407
|
-
magenta: '#FF00FF',
|
|
408
|
-
maroon: '#800000',
|
|
409
|
-
mediumaquamarine: '#66CDAA',
|
|
410
|
-
mediumblue: '#0000CD',
|
|
411
|
-
mediumorchid: '#BA55D3',
|
|
412
|
-
mediumpurple: '#9370DB',
|
|
413
|
-
mediumseagreen: '#3CB371',
|
|
414
|
-
mediumslateblue: '#7B68EE',
|
|
415
|
-
mediumspringgreen: '#00FA9A',
|
|
416
|
-
mediumturquoise: '#48D1CC',
|
|
417
|
-
mediumvioletred: '#C71585',
|
|
418
|
-
midnightblue: '#191970',
|
|
419
|
-
mintcream: '#F5FFFA',
|
|
420
|
-
mistyrose: '#FFE4E1',
|
|
421
|
-
moccasin: '#FFE4B5',
|
|
422
|
-
navajowhite: '#FFDEAD',
|
|
423
|
-
navy: '#000080',
|
|
424
|
-
oldlace: '#FDF5E6',
|
|
425
|
-
olive: '#808000',
|
|
426
|
-
olivedrab: '#6B8E23',
|
|
427
|
-
orange: '#FFA500',
|
|
428
|
-
orangered: '#FF4500',
|
|
429
|
-
orchid: '#DA70D6',
|
|
430
|
-
palegoldenrod: '#EEE8AA',
|
|
431
|
-
palegreen: '#98FB98',
|
|
432
|
-
paleturquoise: '#AFEEEE',
|
|
433
|
-
palevioletred: '#DB7093',
|
|
434
|
-
papayawhip: '#FFEFD5',
|
|
435
|
-
peachpuff: '#FFDAB9',
|
|
436
|
-
peru: '#CD853F',
|
|
437
|
-
pink: '#FFC0CB',
|
|
438
|
-
plum: '#DDA0DD',
|
|
439
|
-
powderblue: '#B0E0E6',
|
|
440
|
-
purple: '#800080',
|
|
441
|
-
rebeccapurple: '#663399',
|
|
442
|
-
red: '#FF0000',
|
|
443
|
-
rosybrown: '#BC8F8F',
|
|
444
|
-
royalblue: '#4169E1',
|
|
445
|
-
saddlebrown: '#8B4513',
|
|
446
|
-
salmon: '#FA8072',
|
|
447
|
-
sandybrown: '#F4A460',
|
|
448
|
-
seagreen: '#2E8B57',
|
|
449
|
-
seashell: '#FFF5EE',
|
|
450
|
-
sienna: '#A0522D',
|
|
451
|
-
silver: '#C0C0C0',
|
|
452
|
-
skyblue: '#87CEEB',
|
|
453
|
-
slateblue: '#6A5ACD',
|
|
454
|
-
slategray: '#708090',
|
|
455
|
-
slategrey: '#708090',
|
|
456
|
-
snow: '#FFFAFA',
|
|
457
|
-
springgreen: '#00FF7F',
|
|
458
|
-
steelblue: '#4682B4',
|
|
459
|
-
tan: '#D2B48C',
|
|
460
|
-
teal: '#008080',
|
|
461
|
-
thistle: '#D8BFD8',
|
|
462
|
-
tomato: '#FF6347',
|
|
463
|
-
turquoise: '#40E0D0',
|
|
464
|
-
violet: '#EE82EE',
|
|
465
|
-
wheat: '#F5DEB3',
|
|
466
|
-
white: '#FFFFFF',
|
|
467
|
-
whitesmoke: '#F5F5F5',
|
|
468
|
-
yellow: '#FFFF00',
|
|
469
|
-
yellowgreen: '#9ACD32',
|
|
470
|
-
};
|
|
471
|
-
const v = value.trim().toLowerCase();
|
|
472
|
-
return webColors[v];
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
_Color_color = new WeakMap(), _Color_cache = new WeakMap();
|
|
476
|
-
exports.default = Color;
|
|
17
|
+
const Color_1 = require("./Color");
|
|
18
|
+
__exportStar(require("./Color"), exports);
|
|
19
|
+
__exportStar(require("./ColorParser"), exports);
|
|
20
|
+
__exportStar(require("./ColorGenerator"), exports);
|
|
21
|
+
exports.default = Color_1.Color;
|
package/DatePicker/index.d.ts
CHANGED
|
@@ -56,22 +56,6 @@ export type DatePickerProps = Omit<TextFieldProps, 'value' | 'onChange' | 'overr
|
|
|
56
56
|
* array of badges
|
|
57
57
|
*/
|
|
58
58
|
readonly badges?: readonly CalendarBadge[];
|
|
59
|
-
/**
|
|
60
|
-
* Tooltip for the Prev month button
|
|
61
|
-
*/
|
|
62
|
-
readonly prevMonthButtonTooltip?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Tooltip for the Next month button
|
|
65
|
-
*/
|
|
66
|
-
readonly nextMonthButtonTooltip?: string;
|
|
67
|
-
/**
|
|
68
|
-
* Tooltip for tne month selector button
|
|
69
|
-
*/
|
|
70
|
-
readonly changeMonthButtonTooltip?: string;
|
|
71
|
-
/**
|
|
72
|
-
* Tooltip for the year selector button
|
|
73
|
-
*/
|
|
74
|
-
readonly changeYearButtonTooltip?: string;
|
|
75
59
|
/**
|
|
76
60
|
* Label for the Reset button. If label passed, then button will be rendered
|
|
77
61
|
*/
|
|
@@ -91,7 +75,8 @@ export type DatePickerProps = Omit<TextFieldProps, 'value' | 'onChange' | 'overr
|
|
|
91
75
|
/**
|
|
92
76
|
* Initial name of the view
|
|
93
77
|
*/
|
|
94
|
-
readonly
|
|
78
|
+
readonly view?: CalendarView;
|
|
79
|
+
readonly views?: readonly CalendarView[];
|
|
95
80
|
/**
|
|
96
81
|
* Custom footer elements
|
|
97
82
|
*/
|
package/DatePicker/index.js
CHANGED
|
@@ -49,10 +49,10 @@ const StyledMaskedField = (0, styled_1.default)(MaskedField_1.default) `
|
|
|
49
49
|
`}
|
|
50
50
|
`;
|
|
51
51
|
const DatePicker = props => {
|
|
52
|
-
const { value, template, onChange, calendarButtonTooltip, readOnly, disabled, minDate = new Date(new Date().getFullYear() - 100, 0, 1, 0, 0, 0), maxDate = new Date(new Date().getFullYear() + 100, 0, 1, 0, 0, 0), weekStartDay = 'monday', locale = 'ru-RU', badges = [], displayLeadingZero = false,
|
|
52
|
+
const { value, template, onChange, calendarButtonTooltip, readOnly, disabled, minDate = new Date(new Date().getFullYear() - 100, 0, 1, 0, 0, 0), maxDate = new Date(new Date().getFullYear() + 100, 0, 1, 0, 0, 0), weekStartDay = 'monday', locale = 'ru-RU', badges = [], displayLeadingZero = false, resetButtonLabel, toodayButtonLabel, heading, subheading, view, views, footer, overrides } = props, restInputProps = __rest(props, ["value", "template", "onChange", "calendarButtonTooltip", "readOnly", "disabled", "minDate", "maxDate", "weekStartDay", "locale", "badges", "displayLeadingZero", "resetButtonLabel", "toodayButtonLabel", "heading", "subheading", "view", "views", "footer", "overrides"]);
|
|
53
53
|
const {
|
|
54
54
|
// Calendar overrides
|
|
55
|
-
Body, Cell, EmptyCell, Paper, Header, WeekRow, DateContainer, Toolbar, YearsSelector, MonthsSelector, MonthCell,
|
|
55
|
+
Body, Cell, EmptyCell, Paper, Header, WeekRow, DateContainer, Toolbar, YearsSelector, MonthsSelector, MonthCell, DayBadge, Footer, ControlButton, Heading, Subheading, IconPrev, IconNext, WeekDaysBar,
|
|
56
56
|
// Textfield overrides
|
|
57
57
|
Input, ErrorText, IconWrapper, InputWrapper, Label, Asterisk, Container, } = overrides || {};
|
|
58
58
|
const [currentValue, setCurrentValue] = react_1.default.useState(value);
|
|
@@ -80,69 +80,55 @@ const DatePicker = props => {
|
|
|
80
80
|
const b = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
|
|
81
81
|
return b.getTime() <= a.getTime();
|
|
82
82
|
}, [maxDate]);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
const handleClick = react_1.default.useCallback(() => {
|
|
84
|
+
if (readOnly) {
|
|
85
|
+
setOpenSate(!isOpen);
|
|
86
|
+
}
|
|
87
|
+
}, [isOpen, readOnly]);
|
|
88
|
+
const endIcon = react_1.default.useMemo(() => (react_1.default.createElement(Button_1.default, { disabled: disabled, iconOnly: true, variant: "plain", type: "button", onClick: () => setOpenSate(true), title: calendarButtonTooltip },
|
|
89
|
+
react_1.default.createElement(DatePickerIcon_1.default, null))), [calendarButtonTooltip, disabled]);
|
|
90
|
+
const handleChange = react_1.default.useCallback(({ isValid, text }) => {
|
|
91
|
+
if (isValid) {
|
|
92
|
+
const parsedDate = parseInputByTemplate(text, template);
|
|
93
|
+
// Trying to parse the input date value
|
|
94
|
+
if (parsedDate instanceof Date && !isNaN(parsedDate.getTime())) {
|
|
95
|
+
// if the date satisfies the restrictions
|
|
96
|
+
if (isGreatherThenMinDate(parsedDate) && isLessThenMaxDate(parsedDate)) {
|
|
97
|
+
onChange(parsedDate);
|
|
98
|
+
// if the date violates the restrictions
|
|
87
99
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
onChange(parsedDate);
|
|
97
|
-
// if the date violates the restrictions
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// set as minDate if parsed date less then minDate value constraint
|
|
101
|
-
if (!isGreatherThenMinDate(parsedDate)) {
|
|
102
|
-
onChange(minDate);
|
|
103
|
-
}
|
|
104
|
-
// set as maxDate if parsed date greather then maxDate value constraint
|
|
105
|
-
if (!isLessThenMaxDate(parsedDate)) {
|
|
106
|
-
onChange(maxDate);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
100
|
+
else {
|
|
101
|
+
// set as minDate if parsed date less then minDate value constraint
|
|
102
|
+
if (!isGreatherThenMinDate(parsedDate)) {
|
|
103
|
+
onChange(minDate);
|
|
104
|
+
}
|
|
105
|
+
// set as maxDate if parsed date greather then maxDate value constraint
|
|
106
|
+
if (!isLessThenMaxDate(parsedDate)) {
|
|
107
|
+
onChange(maxDate);
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, [
|
|
113
|
+
isGreatherThenMinDate,
|
|
114
|
+
isLessThenMaxDate,
|
|
115
|
+
maxDate,
|
|
116
|
+
minDate,
|
|
117
|
+
onChange,
|
|
118
|
+
parseInputByTemplate,
|
|
119
|
+
template,
|
|
120
|
+
]);
|
|
121
|
+
const calendarValue = react_1.default.useMemo(() => currentValue || new Date(), [currentValue]);
|
|
122
|
+
const calendarChange = react_1.default.useCallback(date => {
|
|
123
|
+
if (date) {
|
|
124
|
+
onChange(date);
|
|
125
|
+
}
|
|
126
|
+
setOpenSate(false);
|
|
127
|
+
}, [onChange]);
|
|
128
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
129
|
+
react_1.default.createElement(StyledMaskedField, Object.assign({ onClick: handleClick, disabled: disabled, mask: getMaskByTemplate(template), ref: setTextFieldRef, readOnly: readOnly, endIcon: endIcon }, restInputProps, { value: currentValue ? formatInputByTemplate(currentValue, template) : '', onChange: handleChange })),
|
|
120
130
|
react_1.default.createElement(ClickOutside_1.default, { onOutsideClick: () => setOpenSate(false), mouseEvent: "onMouseDown" },
|
|
121
131
|
react_1.default.createElement(Popper_1.default, { isOpen: isOpen, anchorElement: textFieldRef },
|
|
122
|
-
react_1.default.createElement(Calendar_1.default, { minDate: minDate, maxDate: maxDate, weekStartDay: weekStartDay, locale: locale, badges: badges, displayLeadingZero: displayLeadingZero,
|
|
123
|
-
onChange(date);
|
|
124
|
-
setOpenSate(false);
|
|
125
|
-
}, overrides: {
|
|
126
|
-
Body,
|
|
127
|
-
Cell,
|
|
128
|
-
EmptyCell,
|
|
129
|
-
Paper,
|
|
130
|
-
Header,
|
|
131
|
-
WeekRow,
|
|
132
|
-
DateContainer,
|
|
133
|
-
Toolbar,
|
|
134
|
-
YearsSelector,
|
|
135
|
-
MonthsSelector,
|
|
136
|
-
MonthCell,
|
|
137
|
-
YearCell,
|
|
138
|
-
DayBadge,
|
|
139
|
-
Footer,
|
|
140
|
-
ControlButton,
|
|
141
|
-
Heading,
|
|
142
|
-
Subheading,
|
|
143
|
-
IconPrev,
|
|
144
|
-
IconNext,
|
|
145
|
-
WeekDaysBar,
|
|
146
|
-
} })))));
|
|
132
|
+
react_1.default.createElement(Calendar_1.default, { minDate: minDate, maxDate: maxDate, weekStartDay: weekStartDay, locale: locale, badges: badges, displayLeadingZero: displayLeadingZero, resetButtonLabel: resetButtonLabel, todayButtonLabel: toodayButtonLabel, heading: heading, subheading: subheading, view: view, views: views, footer: footer, value: calendarValue, onChange: calendarChange })))));
|
|
147
133
|
};
|
|
148
134
|
exports.default = DatePicker;
|