@itcase/ui 1.0.43 → 1.0.44
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/dist/components/Accordion.js +56 -58
- package/dist/components/Avatar.js +31 -29
- package/dist/components/Background.js +15 -12
- package/dist/components/Badge.js +13 -11
- package/dist/components/Breadcrumbs.js +72 -71
- package/dist/components/Button.js +56 -53
- package/dist/components/Caption.js +11 -8
- package/dist/components/Card.js +22 -20
- package/dist/components/Cell.js +52 -50
- package/dist/components/Checkbox.js +31 -29
- package/dist/components/Chips.js +21 -18
- package/dist/components/Choice.js +43 -49
- package/dist/components/Code.js +260 -105
- package/dist/components/ContextMenu.js +38 -34
- package/dist/components/CookiesWarning.js +26 -27
- package/dist/components/DatePicker.js +64 -67
- package/dist/components/Divider.js +15 -12
- package/dist/components/Dot.js +8 -6
- package/dist/components/Dropdown.js +88 -88
- package/dist/components/Empty.js +21 -19
- package/dist/components/Fader.js +13 -10
- package/dist/components/Flex.js +43 -37
- package/dist/components/FormField.js +77 -66
- package/dist/components/Grid.js +66 -57
- package/dist/components/Group.js +33 -30
- package/dist/components/Icon.js +41 -38
- package/dist/components/Image.js +34 -28
- package/dist/components/Input.js +29 -28
- package/dist/components/InputPassword.js +45 -48
- package/dist/components/Label.js +29 -26
- package/dist/components/LanguageSelector.js +29 -30
- package/dist/components/Link.js +43 -39
- package/dist/components/List.js +35 -29
- package/dist/components/Loader.js +22 -19
- package/dist/components/Logo.js +17 -14
- package/dist/components/Menu.js +20 -19
- package/dist/components/MenuItem.js +55 -52
- package/dist/components/Modal.js +51 -63
- package/dist/components/Notification.js +41 -38
- package/dist/components/Pagination.js +17 -15
- package/dist/components/RadioButton.js +31 -29
- package/dist/components/RangeSlider.js +29 -26
- package/dist/components/Scrollbar.js +6 -4
- package/dist/components/Search.js +66 -61
- package/dist/components/Segmented.js +52 -58
- package/dist/components/Select.js +181 -168
- package/dist/components/SiteMenu.js +34 -28
- package/dist/components/Swiper.js +104 -92
- package/dist/components/Switch.js +11 -9
- package/dist/components/Tab.js +95 -80
- package/dist/components/Text.js +27 -24
- package/dist/components/Textarea.js +23 -21
- package/dist/components/Tile.js +37 -34
- package/dist/components/Title.js +38 -30
- package/dist/components/Tooltip.js +24 -21
- package/dist/components/Video.js +16 -13
- package/dist/components/Wrapper.js +23 -20
- package/dist/constants/componentProps/align.js +1 -1
- package/dist/constants/componentProps/alignDirection.js +1 -1
- package/dist/constants/componentProps/borderColor.js +1 -1
- package/dist/constants/componentProps/borderType.js +1 -1
- package/dist/constants/componentProps/captionPosition.js +1 -1
- package/dist/constants/componentProps/direction.js +1 -1
- package/dist/constants/componentProps/emojiSize.js +1 -1
- package/dist/constants/componentProps/fill.js +1 -1
- package/dist/constants/componentProps/fillGradient.js +1 -1
- package/dist/constants/componentProps/fillType.js +1 -1
- package/dist/constants/componentProps/flexAlign.js +1 -1
- package/dist/constants/componentProps/flexJustifyContent.js +1 -1
- package/dist/constants/componentProps/flexWrap.js +1 -1
- package/dist/constants/componentProps/gridAlign.js +1 -1
- package/dist/constants/componentProps/gridAlignSelf.js +1 -1
- package/dist/constants/componentProps/gridJustifyItems.js +1 -1
- package/dist/constants/componentProps/gridJustifySelf.js +1 -1
- package/dist/constants/componentProps/horizontalContentAlign.js +1 -1
- package/dist/constants/componentProps/horizontalResizeMode.js +1 -1
- package/dist/constants/componentProps/iconSize.js +1 -1
- package/dist/constants/componentProps/position.js +1 -1
- package/dist/constants/componentProps/resizeMode.js +1 -1
- package/dist/constants/componentProps/shape.js +1 -1
- package/dist/constants/componentProps/size.js +1 -1
- package/dist/constants/componentProps/stacking.js +1 -1
- package/dist/constants/componentProps/strokeColor.js +1 -1
- package/dist/constants/componentProps/textAlign.js +1 -1
- package/dist/constants/componentProps/textColor.js +1 -1
- package/dist/constants/componentProps/textColorActive.js +1 -1
- package/dist/constants/componentProps/textColorHover.js +1 -1
- package/dist/constants/componentProps/textGradient.js +1 -1
- package/dist/constants/componentProps/textStyle.js +1 -1
- package/dist/constants/componentProps/textTag.js +1 -1
- package/dist/constants/componentProps/textWeight.js +1 -1
- package/dist/constants/componentProps/titleSize.js +1 -1
- package/dist/constants/componentProps/type.js +1 -1
- package/dist/constants/componentProps/underline.js +1 -1
- package/dist/constants/componentProps/verticalContentAlign.js +1 -1
- package/dist/constants/componentProps/verticalResizeMode.js +1 -1
- package/dist/constants/componentProps/width.js +1 -1
- package/dist/constants/componentProps/wrap.js +1 -1
- package/dist/context/Notifications.js +38 -53
- package/dist/context/UIContext.js +14 -17
- package/dist/css/components/Choice/Choice.css +8 -0
- package/dist/css/components/Code/Code.css +35 -34
- package/dist/css/components/DatePicker/DatePicker.css +39 -0
- package/dist/css/components/Swiper/Swiper.css +6 -3
- package/dist/css/components/Tab/Tab.css +10 -1
- package/dist/css/styles/align/align.css +0 -1
- package/dist/css/styles/align/align_horizontal-reverse.css +6 -6
- package/dist/css/styles/align/align_horizontal.css +9 -9
- package/dist/css/styles/border-color/border-color.css +15 -1
- package/dist/css/styles/column-gap/column-gap.css +3 -1
- package/dist/css/styles/gap/gap.css +3 -1
- package/dist/css/styles/row-gap/row-gap.css +3 -1
- package/dist/hooks/useDeviceTargetClass.js +19 -18
- package/dist/hooks/useMediaQueries.js +7 -10
- package/dist/hooks/useStyles.js +127 -8
- package/package.json +30 -29
- package/dist/useStyles-e4accb53.js +0 -153
|
@@ -11,7 +11,7 @@ require('../constants/componentProps/textColorHover.js');
|
|
|
11
11
|
require('../constants/componentProps/size.js');
|
|
12
12
|
require('../constants/componentProps/textStyle.js');
|
|
13
13
|
require('../constants/componentProps/textWeight.js');
|
|
14
|
-
require('../useStyles
|
|
14
|
+
require('../hooks/useStyles.js');
|
|
15
15
|
require('lodash/camelCase');
|
|
16
16
|
require('lodash/maxBy');
|
|
17
17
|
require('lodash/upperFirst');
|
|
@@ -27,79 +27,73 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
27
27
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
28
28
|
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, [options]);
|
|
47
|
-
var borderColorClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
30
|
+
const Choice = /*#__PURE__*/React__default.default.forwardRef((props, ref) => {
|
|
31
|
+
const {
|
|
32
|
+
name,
|
|
33
|
+
className,
|
|
34
|
+
type,
|
|
35
|
+
options,
|
|
36
|
+
active,
|
|
37
|
+
setActiveSegment,
|
|
38
|
+
size,
|
|
39
|
+
labelTextColor,
|
|
40
|
+
labelTextActiveColor,
|
|
41
|
+
labelTextSize
|
|
42
|
+
} = props;
|
|
43
|
+
const controlRef = React.useRef(null);
|
|
44
|
+
const optionsRefs = React.useMemo(() => new Map(options.map(item => [item.value, /*#__PURE__*/React.createRef()])), [options]);
|
|
45
|
+
const borderColorClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
48
46
|
prefix: 'border-color_',
|
|
49
47
|
propsKey: 'borderColor'
|
|
50
48
|
});
|
|
51
|
-
|
|
49
|
+
const borderWidthClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
52
50
|
prefix: 'border-width_',
|
|
53
51
|
propsKey: 'borderWidth'
|
|
54
52
|
});
|
|
55
|
-
|
|
53
|
+
const borderTypeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
56
54
|
prefix: 'border-type_',
|
|
57
55
|
propsKey: 'borderType'
|
|
58
56
|
});
|
|
59
|
-
|
|
57
|
+
const shapeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
60
58
|
prefix: 'choice_shape_',
|
|
61
59
|
propsKey: 'shape'
|
|
62
60
|
});
|
|
63
|
-
|
|
61
|
+
const fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
64
62
|
prefix: 'fill_',
|
|
65
63
|
propsKey: 'fill'
|
|
66
64
|
});
|
|
67
|
-
|
|
65
|
+
const fillHoverClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
68
66
|
prefix: 'fill_hover_',
|
|
69
67
|
propsKey: 'fillHover'
|
|
70
68
|
});
|
|
71
|
-
|
|
69
|
+
const fillActiveClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
72
70
|
prefix: 'fill_active_',
|
|
73
71
|
propsKey: 'fillActive'
|
|
74
72
|
});
|
|
75
73
|
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
76
|
-
className: clsx__default.default(className, 'choice', shapeClass, fillClass, borderColorClass, borderWidthClass, borderTypeClass, size &&
|
|
74
|
+
className: clsx__default.default(className, 'choice', shapeClass, fillClass, borderColorClass, borderWidthClass, borderTypeClass, size && `choice_size_${size}`, type && `choice_type_${type}`),
|
|
77
75
|
ref: controlRef
|
|
78
76
|
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
79
77
|
className: "choice__wrapper"
|
|
80
|
-
}, options
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
textColor: item.value === active.value ? labelTextActiveColor : labelTextColor,
|
|
100
|
-
size: labelTextSize
|
|
101
|
-
}, item.label)));
|
|
102
|
-
})));
|
|
78
|
+
}, options?.map((item, i) => /*#__PURE__*/React__default.default.createElement("div", {
|
|
79
|
+
className: clsx__default.default('choice__item', borderColorClass, borderWidthClass, borderTypeClass, fillHoverClass, item.value === active.value && fillActiveClass, item.value === active.value && 'choice__item_active'),
|
|
80
|
+
key: item.value,
|
|
81
|
+
ref: optionsRefs.get(item.value)
|
|
82
|
+
}, /*#__PURE__*/React__default.default.createElement("input", {
|
|
83
|
+
checked: item.value === active.value,
|
|
84
|
+
className: "choice__item-radio",
|
|
85
|
+
id: item.label,
|
|
86
|
+
name: name,
|
|
87
|
+
type: "radio",
|
|
88
|
+
value: item.value,
|
|
89
|
+
onChange: () => setActiveSegment(item)
|
|
90
|
+
}), /*#__PURE__*/React__default.default.createElement("label", {
|
|
91
|
+
className: clsx__default.default('choice__item-label'),
|
|
92
|
+
htmlFor: item.label
|
|
93
|
+
}, /*#__PURE__*/React__default.default.createElement(index.Text, {
|
|
94
|
+
textColor: item.value === active.value ? labelTextActiveColor : labelTextColor,
|
|
95
|
+
size: labelTextSize
|
|
96
|
+
}, item.label))))));
|
|
103
97
|
});
|
|
104
98
|
Choice.displayName = 'Choice';
|
|
105
99
|
Choice.propTypes = {
|
package/dist/components/Code.js
CHANGED
|
@@ -4,8 +4,7 @@ var React = require('react');
|
|
|
4
4
|
var PropTypes = require('prop-types');
|
|
5
5
|
var clsx = require('clsx');
|
|
6
6
|
var useDeviceTargetClass = require('../hooks/useDeviceTargetClass.js');
|
|
7
|
-
|
|
8
|
-
var index$1 = require('./Input.js');
|
|
7
|
+
require('./Text.js');
|
|
9
8
|
require('lodash/castArray');
|
|
10
9
|
require('lodash/camelCase');
|
|
11
10
|
require('../context/UIContext.js');
|
|
@@ -17,7 +16,7 @@ require('../constants/componentProps/textColorHover.js');
|
|
|
17
16
|
require('../constants/componentProps/size.js');
|
|
18
17
|
require('../constants/componentProps/textStyle.js');
|
|
19
18
|
require('../constants/componentProps/textWeight.js');
|
|
20
|
-
require('../useStyles
|
|
19
|
+
require('../hooks/useStyles.js');
|
|
21
20
|
require('lodash/maxBy');
|
|
22
21
|
require('lodash/upperFirst');
|
|
23
22
|
require('../hooks/styleAttributes.js');
|
|
@@ -28,123 +27,279 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
28
27
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
29
28
|
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
30
29
|
|
|
31
|
-
var
|
|
30
|
+
var isStyleObject = function (obj) { return typeof obj === 'object' && obj !== null; };
|
|
31
|
+
var OTPInput = function (_a) {
|
|
32
|
+
var _b = _a.value, value = _b === void 0 ? '' : _b, _c = _a.numInputs, numInputs = _c === void 0 ? 4 : _c, onChange = _a.onChange, renderInput = _a.renderInput, _d = _a.shouldAutoFocus, shouldAutoFocus = _d === void 0 ? false : _d, _e = _a.inputType, inputType = _e === void 0 ? 'text' : _e, renderSeparator = _a.renderSeparator, placeholder = _a.placeholder, containerStyle = _a.containerStyle, inputStyle = _a.inputStyle;
|
|
33
|
+
var _f = React__default.default.useState(0), activeInput = _f[0], setActiveInput = _f[1];
|
|
34
|
+
var inputRefs = React__default.default.useRef([]);
|
|
35
|
+
var getOTPValue = function () { return (value ? value.toString().split('') : []); };
|
|
36
|
+
var isInputNum = inputType === 'number' || inputType === 'tel';
|
|
37
|
+
React__default.default.useEffect(function () {
|
|
38
|
+
inputRefs.current = inputRefs.current.slice(0, numInputs);
|
|
39
|
+
}, [numInputs]);
|
|
40
|
+
React__default.default.useEffect(function () {
|
|
41
|
+
var _a;
|
|
42
|
+
if (shouldAutoFocus) {
|
|
43
|
+
(_a = inputRefs.current[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
44
|
+
}
|
|
45
|
+
}, [shouldAutoFocus]);
|
|
46
|
+
var getPlaceholderValue = function () {
|
|
47
|
+
if (typeof placeholder === 'string') {
|
|
48
|
+
if (placeholder.length === numInputs) {
|
|
49
|
+
return placeholder;
|
|
50
|
+
}
|
|
51
|
+
if (placeholder.length > 0) {
|
|
52
|
+
console.error('Length of the placeholder should be equal to the number of inputs.');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
};
|
|
57
|
+
var isInputValueValid = function (value) {
|
|
58
|
+
var isTypeValid = isInputNum ? !isNaN(Number(value)) : typeof value === 'string';
|
|
59
|
+
return isTypeValid && value.trim().length === 1;
|
|
60
|
+
};
|
|
61
|
+
var handleChange = function (event) {
|
|
62
|
+
var value = event.target.value;
|
|
63
|
+
if (isInputValueValid(value)) {
|
|
64
|
+
changeCodeAtFocus(value);
|
|
65
|
+
focusInput(activeInput + 1);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var handleInputChange = function (event) {
|
|
69
|
+
var nativeEvent = event.nativeEvent;
|
|
70
|
+
if (!isInputValueValid(event.target.value)) {
|
|
71
|
+
// @ts-expect-error - This was added previosly to handle and edge case
|
|
72
|
+
// for dealing with keyCode "229 Unidentified" on Android. Check if this is
|
|
73
|
+
// still needed.
|
|
74
|
+
if (nativeEvent.data === null && nativeEvent.inputType === 'deleteContentBackward') {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
changeCodeAtFocus('');
|
|
77
|
+
focusInput(activeInput - 1);
|
|
78
|
+
}
|
|
79
|
+
// Clear the input if it's not valid value because firefox allows
|
|
80
|
+
// pasting non-numeric characters in a number type input
|
|
81
|
+
event.target.value = '';
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var handleFocus = function (event) { return function (index) {
|
|
85
|
+
setActiveInput(index);
|
|
86
|
+
event.target.select();
|
|
87
|
+
}; };
|
|
88
|
+
var handleBlur = function () {
|
|
89
|
+
setActiveInput(activeInput - 1);
|
|
90
|
+
};
|
|
91
|
+
var handleKeyDown = function (event) {
|
|
92
|
+
var otp = getOTPValue();
|
|
93
|
+
if ([event.code, event.key].includes('Backspace')) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
changeCodeAtFocus('');
|
|
96
|
+
focusInput(activeInput - 1);
|
|
97
|
+
}
|
|
98
|
+
else if (event.code === 'Delete') {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
changeCodeAtFocus('');
|
|
101
|
+
}
|
|
102
|
+
else if (event.code === 'ArrowLeft') {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
focusInput(activeInput - 1);
|
|
105
|
+
}
|
|
106
|
+
else if (event.code === 'ArrowRight') {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
focusInput(activeInput + 1);
|
|
109
|
+
}
|
|
110
|
+
// React does not trigger onChange when the same value is entered
|
|
111
|
+
// again. So we need to focus the next input manually in this case.
|
|
112
|
+
else if (event.key === otp[activeInput]) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
focusInput(activeInput + 1);
|
|
115
|
+
}
|
|
116
|
+
else if (event.code === 'Spacebar' ||
|
|
117
|
+
event.code === 'Space' ||
|
|
118
|
+
event.code === 'ArrowUp' ||
|
|
119
|
+
event.code === 'ArrowDown') {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var focusInput = function (index) {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
var activeInput = Math.max(Math.min(numInputs - 1, index), 0);
|
|
126
|
+
if (inputRefs.current[activeInput]) {
|
|
127
|
+
(_a = inputRefs.current[activeInput]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
128
|
+
(_b = inputRefs.current[activeInput]) === null || _b === void 0 ? void 0 : _b.select();
|
|
129
|
+
setActiveInput(activeInput);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var changeCodeAtFocus = function (value) {
|
|
133
|
+
var otp = getOTPValue();
|
|
134
|
+
otp[activeInput] = value[0];
|
|
135
|
+
handleOTPChange(otp);
|
|
136
|
+
};
|
|
137
|
+
var handleOTPChange = function (otp) {
|
|
138
|
+
var otpValue = otp.join('');
|
|
139
|
+
onChange(otpValue);
|
|
140
|
+
};
|
|
141
|
+
var handlePaste = function (event) {
|
|
142
|
+
var _a;
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
var otp = getOTPValue();
|
|
145
|
+
var nextActiveInput = activeInput;
|
|
146
|
+
// Get pastedData in an array of max size (num of inputs - current position)
|
|
147
|
+
var pastedData = event.clipboardData
|
|
148
|
+
.getData('text/plain')
|
|
149
|
+
.slice(0, numInputs - activeInput)
|
|
150
|
+
.split('');
|
|
151
|
+
// Prevent pasting if the clipboard data contains non-numeric values for number inputs
|
|
152
|
+
if (isInputNum && pastedData.some(function (value) { return isNaN(Number(value)); })) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// Paste data from focused input onwards
|
|
156
|
+
for (var pos = 0; pos < numInputs; ++pos) {
|
|
157
|
+
if (pos >= activeInput && pastedData.length > 0) {
|
|
158
|
+
otp[pos] = (_a = pastedData.shift()) !== null && _a !== void 0 ? _a : '';
|
|
159
|
+
nextActiveInput++;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
focusInput(nextActiveInput);
|
|
163
|
+
handleOTPChange(otp);
|
|
164
|
+
};
|
|
165
|
+
return (React__default.default.createElement("div", { style: Object.assign({ display: 'flex', alignItems: 'center' }, isStyleObject(containerStyle) && containerStyle), className: typeof containerStyle === 'string' ? containerStyle : undefined }, Array.from({ length: numInputs }, function (_, index) { return index; }).map(function (index) {
|
|
166
|
+
var _a, _b, _c;
|
|
167
|
+
return (React__default.default.createElement(React__default.default.Fragment, { key: index },
|
|
168
|
+
renderInput({
|
|
169
|
+
value: (_a = getOTPValue()[index]) !== null && _a !== void 0 ? _a : '',
|
|
170
|
+
placeholder: (_c = (_b = getPlaceholderValue()) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : undefined,
|
|
171
|
+
ref: function (element) { return (inputRefs.current[index] = element); },
|
|
172
|
+
onChange: handleChange,
|
|
173
|
+
onFocus: function (event) { return handleFocus(event)(index); },
|
|
174
|
+
onBlur: handleBlur,
|
|
175
|
+
onKeyDown: handleKeyDown,
|
|
176
|
+
onPaste: handlePaste,
|
|
177
|
+
autoComplete: 'off',
|
|
178
|
+
maxLength: 1,
|
|
179
|
+
'aria-label': "Please enter OTP character ".concat(index + 1),
|
|
180
|
+
style: Object.assign({ width: '1em', textAlign: 'center' }, isStyleObject(inputStyle) && inputStyle),
|
|
181
|
+
className: typeof inputStyle === 'string' ? inputStyle : undefined,
|
|
182
|
+
type: inputType,
|
|
183
|
+
inputMode: isInputNum ? 'numeric' : 'text',
|
|
184
|
+
onInput: handleInputChange,
|
|
185
|
+
}, index),
|
|
186
|
+
index < numInputs - 1 && (typeof renderSeparator === 'function' ? renderSeparator(index) : renderSeparator)));
|
|
187
|
+
})));
|
|
188
|
+
};
|
|
189
|
+
|
|
32
190
|
function Code(props) {
|
|
33
|
-
|
|
191
|
+
const {
|
|
192
|
+
className,
|
|
193
|
+
inputPlaceholder,
|
|
194
|
+
inputAutoFocus,
|
|
195
|
+
inputCount,
|
|
196
|
+
inputType,
|
|
197
|
+
before,
|
|
198
|
+
after,
|
|
199
|
+
separatorComponent
|
|
200
|
+
} = props;
|
|
201
|
+
const [otp, setOtp] = React.useState('');
|
|
202
|
+
|
|
203
|
+
// const formattedHelpText = useMemo(() => {
|
|
204
|
+
// return helpText.replace('{fields}', inputCount)
|
|
205
|
+
// }, [])
|
|
206
|
+
|
|
207
|
+
const fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
208
|
+
prefix: 'fill_',
|
|
209
|
+
propsKey: 'inputFill'
|
|
210
|
+
});
|
|
211
|
+
const fillHoverClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
212
|
+
prefix: 'fill_hover_',
|
|
213
|
+
propsKey: 'inputFillHover'
|
|
214
|
+
});
|
|
215
|
+
const sizeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
216
|
+
prefix: 'code__input_size_',
|
|
217
|
+
propsKey: 'inputSize'
|
|
218
|
+
});
|
|
219
|
+
const shapeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
220
|
+
prefix: 'code__input_shape_',
|
|
221
|
+
propsKey: 'inputShape'
|
|
222
|
+
});
|
|
223
|
+
const textSizeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
224
|
+
prefix: 'text_size_',
|
|
225
|
+
propsKey: 'inputTextSize'
|
|
226
|
+
});
|
|
227
|
+
const textColorClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
228
|
+
prefix: 'text-color_',
|
|
229
|
+
propsKey: 'inputTextColor'
|
|
230
|
+
});
|
|
231
|
+
const caretClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
232
|
+
prefix: 'caret-color_',
|
|
233
|
+
propsKey: 'inputCaretColor'
|
|
234
|
+
});
|
|
235
|
+
const placeholderClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
236
|
+
prefix: 'placeholder-text-color_',
|
|
237
|
+
propsKey: 'inputPlaceholderTextColor'
|
|
238
|
+
});
|
|
239
|
+
const weightClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
240
|
+
prefix: 'text-weight_',
|
|
241
|
+
propsKey: 'inputTextWeight'
|
|
242
|
+
});
|
|
243
|
+
const borderWidthClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
244
|
+
prefix: 'border-width_',
|
|
245
|
+
propsKey: 'inputBorderWidth'
|
|
246
|
+
});
|
|
247
|
+
const borderColorClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
248
|
+
prefix: 'border-color_',
|
|
249
|
+
propsKey: 'inputBorderColor'
|
|
250
|
+
});
|
|
251
|
+
const borderColorHoverClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
252
|
+
prefix: 'border-color_hover_',
|
|
253
|
+
propsKey: 'inputBorderColorHover'
|
|
254
|
+
});
|
|
255
|
+
const borderColorFocusClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
256
|
+
prefix: 'border-color_focus_',
|
|
257
|
+
propsKey: 'inputBorderFocusColor'
|
|
258
|
+
});
|
|
259
|
+
const gapClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
260
|
+
prefix: 'gap_',
|
|
261
|
+
propsKey: 'gap'
|
|
262
|
+
});
|
|
263
|
+
const widthClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
34
264
|
prefix: 'width_',
|
|
35
265
|
propsKey: 'width'
|
|
36
266
|
});
|
|
37
|
-
var className = props.className,
|
|
38
|
-
fields = props.fields,
|
|
39
|
-
before = props.before,
|
|
40
|
-
errorText = props.errorText,
|
|
41
|
-
errorTextSize = props.errorTextSize,
|
|
42
|
-
errorTextColor = props.errorTextColor,
|
|
43
|
-
errorTextWeight = props.errorTextWeight,
|
|
44
|
-
inputSize = props.inputSize,
|
|
45
|
-
inputFill = props.inputFill,
|
|
46
|
-
inputPlaceholder = props.inputPlaceholder,
|
|
47
|
-
inputPlaceholderColor = props.inputPlaceholderColor,
|
|
48
|
-
inputTextSize = props.inputTextSize,
|
|
49
|
-
inputTextColor = props.inputTextColor,
|
|
50
|
-
inputTextWeight = props.inputTextWeight,
|
|
51
|
-
inputBorderColor = props.inputBorderColor,
|
|
52
|
-
inputBorderWidth = props.inputBorderWidth,
|
|
53
|
-
inputShape = props.inputShape,
|
|
54
|
-
onBlur = props.onBlur,
|
|
55
|
-
onChange = props.onChange,
|
|
56
|
-
helpText = props.helpText,
|
|
57
|
-
helpTextSize = props.helpTextSize,
|
|
58
|
-
helpTextColor = props.helpTextColor,
|
|
59
|
-
helpTextWeight = props.helpTextWeight,
|
|
60
|
-
after = props.after;
|
|
61
|
-
var _useState = React.useState(new Array(fields).fill('')),
|
|
62
|
-
otp = _useState[0],
|
|
63
|
-
setOtp = _useState[1];
|
|
64
|
-
var _useState2 = React.useState(0),
|
|
65
|
-
activeOtpIndex = _useState2[0],
|
|
66
|
-
setActiveOtpIndex = _useState2[1];
|
|
67
|
-
var inputRef = React.useRef(null);
|
|
68
|
-
var formattedHelpText = React.useMemo(function () {
|
|
69
|
-
return helpText.replace('{fields}', fields);
|
|
70
|
-
}, []);
|
|
71
|
-
var handleChange = function handleChange(e) {
|
|
72
|
-
var value = e.target.value;
|
|
73
|
-
var newOtp = [].concat(otp);
|
|
74
|
-
newOtp[currentOtpIndex] = value.substring(value.length - 1);
|
|
75
|
-
if (!value) {
|
|
76
|
-
setActiveOtpIndex(currentOtpIndex - 1);
|
|
77
|
-
} else {
|
|
78
|
-
setActiveOtpIndex(currentOtpIndex + 1);
|
|
79
|
-
}
|
|
80
|
-
setOtp(newOtp);
|
|
81
|
-
onChange && onChange(newOtp);
|
|
82
|
-
};
|
|
83
|
-
var handleOnKeyDown = function handleOnKeyDown(e) {
|
|
84
|
-
var index = +e.target.getAttribute('index');
|
|
85
|
-
currentOtpIndex = index;
|
|
86
|
-
if (e.key === 'Backspace') {
|
|
87
|
-
setActiveOtpIndex(currentOtpIndex - 1);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
React.useEffect(function () {
|
|
91
|
-
var _inputRef$current;
|
|
92
|
-
(_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
93
|
-
}, [activeOtpIndex]);
|
|
94
267
|
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
95
268
|
className: clsx__default.default(className, 'code', widthClass)
|
|
96
|
-
}, before,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
placeholder: inputPlaceholder,
|
|
111
|
-
placeholderTextColor: inputPlaceholderColor,
|
|
112
|
-
textSize: inputTextSize,
|
|
113
|
-
textColor: inputTextColor,
|
|
114
|
-
textWeight: inputTextWeight,
|
|
115
|
-
value: value,
|
|
116
|
-
borderColor: inputBorderColor,
|
|
117
|
-
borderWidth: inputBorderWidth,
|
|
118
|
-
shape: inputShape,
|
|
119
|
-
onBlur: onBlur,
|
|
120
|
-
onChange: handleChange,
|
|
121
|
-
onKeyDown: function onKeyDown(e) {
|
|
122
|
-
return handleOnKeyDown(e);
|
|
123
|
-
},
|
|
124
|
-
inputRef: index === activeOtpIndex ? inputRef : null
|
|
125
|
-
});
|
|
126
|
-
})), helpText && /*#__PURE__*/React__default.default.createElement(index.Text, {
|
|
127
|
-
className: "code__help",
|
|
128
|
-
size: helpTextSize,
|
|
129
|
-
textColor: helpTextColor,
|
|
130
|
-
textWeight: helpTextWeight
|
|
131
|
-
}, formattedHelpText), after);
|
|
269
|
+
}, before, /*#__PURE__*/React__default.default.createElement(OTPInput, {
|
|
270
|
+
containerStyle: clsx__default.default(className, 'code__wrapper', gapClass),
|
|
271
|
+
numInputs: inputCount,
|
|
272
|
+
inputType: inputType,
|
|
273
|
+
placeholder: inputPlaceholder,
|
|
274
|
+
renderInput: props => /*#__PURE__*/React__default.default.createElement("input", Object.assign({}, props, {
|
|
275
|
+
autocomplete: "one-time-code",
|
|
276
|
+
className: clsx__default.default('code__input', caretClass, fillClass, fillHoverClass, placeholderClass, shapeClass, textSizeClass, textColorClass, weightClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderColorFocusClass, sizeClass, fillClass)
|
|
277
|
+
})),
|
|
278
|
+
renderSeparator: separatorComponent || null,
|
|
279
|
+
shouldAutoFocus: inputAutoFocus,
|
|
280
|
+
value: otp,
|
|
281
|
+
onChange: setOtp
|
|
282
|
+
}), after);
|
|
132
283
|
}
|
|
133
284
|
Code.propTypes = {
|
|
134
285
|
value: PropTypes__default.default.number
|
|
135
286
|
};
|
|
136
287
|
Code.defaultProps = {
|
|
137
|
-
|
|
288
|
+
inputCount: 6,
|
|
289
|
+
gap: 12,
|
|
290
|
+
inputType: 'number',
|
|
291
|
+
inputSize: 'normal',
|
|
292
|
+
inputBorderWidth: 1,
|
|
293
|
+
inputPlaceholder: 0,
|
|
294
|
+
inputBorderColor: 'surfaceBorderTertiary',
|
|
295
|
+
inputBorderColorHover: 'surfaceBorderQuaternary',
|
|
296
|
+
inputBorderFocusColor: 'surfaceBorderAccent',
|
|
138
297
|
inputFill: 'surfacePrimary',
|
|
139
|
-
|
|
140
|
-
inputPlaceholderTextColor: 'surfaceTextQuaternary',
|
|
298
|
+
inputFillHover: 'surfaceSecondary',
|
|
141
299
|
inputShape: 'rounded',
|
|
142
300
|
inputTextColor: 'surfaceTextPrimary',
|
|
143
301
|
inputTextSize: 'xxl',
|
|
144
|
-
|
|
145
|
-
helpTextSize: 's',
|
|
146
|
-
helpTextColor: 'surfaceTextTertiary',
|
|
147
|
-
helpTextWeight: 400
|
|
302
|
+
inputCaretColor: 'surfaceItemAccent'
|
|
148
303
|
};
|
|
149
304
|
|
|
150
305
|
exports.Code = Code;
|
|
@@ -19,7 +19,7 @@ require('../constants/componentProps/textColorHover.js');
|
|
|
19
19
|
require('../constants/componentProps/size.js');
|
|
20
20
|
require('../constants/componentProps/textStyle.js');
|
|
21
21
|
require('../constants/componentProps/textWeight.js');
|
|
22
|
-
require('../useStyles
|
|
22
|
+
require('../hooks/useStyles.js');
|
|
23
23
|
require('lodash/maxBy');
|
|
24
24
|
require('lodash/upperFirst');
|
|
25
25
|
require('../hooks/styleAttributes.js');
|
|
@@ -41,21 +41,23 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
|
41
41
|
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
42
42
|
|
|
43
43
|
function ContextMenu(props) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const {
|
|
45
|
+
id,
|
|
46
|
+
children,
|
|
47
|
+
className,
|
|
48
|
+
set,
|
|
49
|
+
onClick
|
|
50
|
+
} = props;
|
|
51
|
+
const fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
50
52
|
prefix: 'fill_',
|
|
51
53
|
propsKey: 'fill'
|
|
52
54
|
});
|
|
53
|
-
|
|
55
|
+
const shapeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
54
56
|
prefix: 'context-menu_shape_',
|
|
55
57
|
propsKey: 'shape'
|
|
56
58
|
});
|
|
57
59
|
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
58
|
-
className: clsx__default.default(className, 'context-menu', set &&
|
|
60
|
+
className: clsx__default.default(className, 'context-menu', set && `context-menu_set_${set}`, shapeClass, fillClass),
|
|
59
61
|
id: id,
|
|
60
62
|
onClick: onClick
|
|
61
63
|
}, children);
|
|
@@ -75,40 +77,42 @@ ContextMenu.defaultProps = {
|
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
function ContextMenuItem(props) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
80
|
+
const {
|
|
81
|
+
id,
|
|
82
|
+
children,
|
|
83
|
+
className,
|
|
84
|
+
label,
|
|
85
|
+
dividerWidth,
|
|
86
|
+
dividerDirection,
|
|
87
|
+
dividerSize,
|
|
88
|
+
dividerFill,
|
|
89
|
+
iconBefore,
|
|
90
|
+
iconBeforeSize,
|
|
91
|
+
iconBeforeBgFill,
|
|
92
|
+
iconBeforeFill,
|
|
93
|
+
iconBeforeStroke,
|
|
94
|
+
iconAfter,
|
|
95
|
+
iconAfterSize,
|
|
96
|
+
iconAfterBgFill,
|
|
97
|
+
iconAfterFill,
|
|
98
|
+
iconAfterStroke,
|
|
99
|
+
isActive,
|
|
100
|
+
onClick
|
|
101
|
+
} = props;
|
|
102
|
+
const labelTextSizeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
99
103
|
propsKey: 'labelTextSize'
|
|
100
104
|
});
|
|
101
|
-
|
|
105
|
+
const labelTextColorClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
102
106
|
propsKey: 'labelTextColor'
|
|
103
107
|
});
|
|
104
|
-
|
|
108
|
+
const labelTextWeightClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
105
109
|
propsKey: 'labelTextWeight'
|
|
106
110
|
});
|
|
107
|
-
|
|
111
|
+
const fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
108
112
|
prefix: 'fill_',
|
|
109
113
|
propsKey: 'fill'
|
|
110
114
|
});
|
|
111
|
-
|
|
115
|
+
const fillHoverClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
112
116
|
prefix: 'fill_hover_',
|
|
113
117
|
propsKey: 'fillHover'
|
|
114
118
|
});
|