@snack-uikit/fields 0.57.2-preview-02d918ac.0 → 0.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/components/FieldColor/FieldColor.js +60 -49
- package/dist/cjs/components/FieldDate/FieldDate.js +68 -60
- package/dist/cjs/components/FieldDecorator/FieldDecorator.js +18 -18
- package/dist/cjs/components/FieldDecorator/Footer.js +6 -7
- package/dist/cjs/components/FieldDecorator/Header.js +10 -9
- package/dist/cjs/components/FieldDecorator/utils.js +14 -16
- package/dist/cjs/components/FieldSecure/FieldSecure.js +76 -58
- package/dist/cjs/components/FieldSelect/FieldSelectMultiple.js +112 -97
- package/dist/cjs/components/FieldSelect/FieldSelectSingle.js +115 -99
- package/dist/cjs/components/FieldSelect/hooks/common.js +43 -43
- package/dist/cjs/components/FieldSelect/hooks/customOption.js +12 -18
- package/dist/cjs/components/FieldSelect/legacy/components/Items/hooks.js +18 -21
- package/dist/cjs/components/FieldSelect/legacy/utils.js +18 -26
- package/dist/cjs/components/FieldSelect/utils/checkisSearchUnavailable.js +3 -5
- package/dist/cjs/components/FieldSelect/utils/extractListProps.js +13 -15
- package/dist/cjs/components/FieldSelect/utils/getArrowIcon.js +2 -4
- package/dist/cjs/components/FieldSelect/utils/options.js +17 -18
- package/dist/cjs/components/FieldSelect/utils/updateItems.js +6 -10
- package/dist/cjs/components/FieldSlider/FieldSlider.js +55 -46
- package/dist/cjs/components/FieldStepper/FieldStepper.js +60 -42
- package/dist/cjs/components/FieldText/FieldText.js +76 -58
- package/dist/cjs/components/FieldText/helpers.js +1 -3
- package/dist/cjs/components/FieldTextArea/FieldTextArea.js +64 -50
- package/dist/cjs/components/FieldTime/FieldTime.js +71 -64
- package/dist/cjs/helperComponents/ButtonCopyValue/ButtonCopyValue.js +17 -15
- package/dist/cjs/helperComponents/ButtonCopyValue/helpers.js +2 -4
- package/dist/cjs/helperComponents/ButtonField/ButtonField.js +21 -21
- package/dist/cjs/helperComponents/ButtonFieldList/ButtonFieldList.js +12 -9
- package/dist/cjs/helperComponents/ButtonFieldList/helpers.js +1 -3
- package/dist/cjs/helperComponents/ButtonHideValue/ButtonHideValue.js +7 -8
- package/dist/cjs/helperComponents/FieldContainerPrivate/FieldContainerPrivate.js +14 -16
- package/dist/cjs/helperComponents/TextArea/TextArea.js +29 -21
- package/dist/cjs/hocs/withCharacterCount.js +3 -5
- package/dist/cjs/hooks/addonButton/useAddonButton.js +11 -13
- package/dist/cjs/hooks/addonButton/usePostfixButton.js +1 -3
- package/dist/cjs/hooks/addonButton/usePrefixButton.js +1 -3
- package/dist/cjs/hooks/dateHandlers/useDateField.js +29 -33
- package/dist/cjs/hooks/dateHandlers/useDateFieldHelpersForMode.js +15 -21
- package/dist/cjs/hooks/dateHandlers/useFocusHandlers.js +2 -4
- package/dist/cjs/hooks/useCopyButton.js +12 -14
- package/dist/cjs/hooks/useHideButton.js +7 -11
- package/dist/cjs/hooks/usePostfix.js +3 -7
- package/dist/cjs/hooks/usePrefix.js +3 -7
- package/dist/cjs/hooks/useValueControl.js +3 -5
- package/dist/cjs/utils/dateFields.js +15 -2
- package/dist/cjs/utils/getValidationState.js +2 -4
- package/package.json +10 -10
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -29,51 +31,62 @@ const getValidationState_1 = require("../../utils/getValidationState");
|
|
|
29
31
|
const FieldDecorator_1 = require("../FieldDecorator");
|
|
30
32
|
const helpers_1 = require("./helpers");
|
|
31
33
|
exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
34
|
+
var id = _a.id,
|
|
35
|
+
name = _a.name,
|
|
36
|
+
valueProp = _a.value,
|
|
37
|
+
placeholder = _a.placeholder,
|
|
38
|
+
maxLength = _a.maxLength,
|
|
39
|
+
_a$disabled = _a.disabled,
|
|
40
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
41
|
+
_a$readonly = _a.readonly,
|
|
42
|
+
readonly = _a$readonly === void 0 ? false : _a$readonly,
|
|
43
|
+
_a$showCopyButton = _a.showCopyButton,
|
|
44
|
+
showCopyButtonProp = _a$showCopyButton === void 0 ? true : _a$showCopyButton,
|
|
45
|
+
_a$showClearButton = _a.showClearButton,
|
|
46
|
+
showClearButtonProp = _a$showClearButton === void 0 ? true : _a$showClearButton,
|
|
47
|
+
_a$allowMoreThanMaxLe = _a.allowMoreThanMaxLength,
|
|
48
|
+
allowMoreThanMaxLength = _a$allowMoreThanMaxLe === void 0 ? false : _a$allowMoreThanMaxLe,
|
|
49
|
+
onChangeProp = _a.onChange,
|
|
50
|
+
onFocus = _a.onFocus,
|
|
51
|
+
onBlur = _a.onBlur,
|
|
52
|
+
onCopyButtonClick = _a.onCopyButtonClick,
|
|
53
|
+
onClearButtonClick = _a.onClearButtonClick,
|
|
54
|
+
className = _a.className,
|
|
55
|
+
label = _a.label,
|
|
56
|
+
labelTooltip = _a.labelTooltip,
|
|
57
|
+
labelTooltipPlacement = _a.labelTooltipPlacement,
|
|
58
|
+
_a$required = _a.required,
|
|
59
|
+
required = _a$required === void 0 ? false : _a$required,
|
|
60
|
+
caption = _a.caption,
|
|
61
|
+
hint = _a.hint,
|
|
62
|
+
showHintIcon = _a.showHintIcon,
|
|
63
|
+
_a$size = _a.size,
|
|
64
|
+
size = _a$size === void 0 ? input_private_1.SIZE.S : _a$size,
|
|
65
|
+
_a$validationState = _a.validationState,
|
|
66
|
+
validationState = _a$validationState === void 0 ? constants_1.VALIDATION_STATE.Default : _a$validationState,
|
|
67
|
+
error = _a.error,
|
|
68
|
+
autoComplete = _a.autoComplete,
|
|
69
|
+
autoFocus = _a.autoFocus,
|
|
70
|
+
prefixIcon = _a.prefixIcon,
|
|
71
|
+
prefix = _a.prefix,
|
|
72
|
+
postfix = _a.postfix,
|
|
73
|
+
buttonProp = _a.button,
|
|
74
|
+
onPaste = _a.onPaste,
|
|
75
|
+
onKeyDown = _a.onKeyDown,
|
|
76
|
+
_a$type = _a.type,
|
|
77
|
+
type = _a$type === void 0 ? 'text' : _a$type,
|
|
78
|
+
inputMode = _a.inputMode,
|
|
79
|
+
spellCheck = _a.spellCheck,
|
|
71
80
|
rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "onChange", "onFocus", "onBlur", "onCopyButtonClick", "onClearButtonClick", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "autoComplete", "autoFocus", "prefixIcon", "prefix", "postfix", "button", "onPaste", "onKeyDown", "type", "inputMode", "spellCheck"]);
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
const _ref = (0, hooks_1.useValueControl)({
|
|
82
|
+
value: valueProp,
|
|
83
|
+
defaultValue: '',
|
|
84
|
+
onChange: onChangeProp
|
|
85
|
+
}),
|
|
86
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
87
|
+
_ref2$ = _ref2[0],
|
|
88
|
+
value = _ref2$ === void 0 ? '' : _ref2$,
|
|
89
|
+
onChange = _ref2[1];
|
|
77
90
|
const localRef = (0, react_1.useRef)(null);
|
|
78
91
|
const clearButtonRef = (0, react_1.useRef)(null);
|
|
79
92
|
const copyButtonRef = (0, react_1.useRef)(null);
|
|
@@ -99,7 +112,10 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
99
112
|
const containerVariant = (0, helpers_1.getContainerVariant)({
|
|
100
113
|
button
|
|
101
114
|
});
|
|
102
|
-
const
|
|
115
|
+
const _ref3 = (0, react_1.useState)(false),
|
|
116
|
+
_ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
117
|
+
isFieldFocused = _ref4[0],
|
|
118
|
+
setIsFieldFocused = _ref4[1];
|
|
103
119
|
const focusedRef = (0, react_1.useRef)(false);
|
|
104
120
|
const onClear = e => {
|
|
105
121
|
var _a;
|
|
@@ -129,7 +145,10 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
129
145
|
postfix: typeof postfix === 'string' ? postfix : undefined,
|
|
130
146
|
onCopyButtonClick
|
|
131
147
|
});
|
|
132
|
-
const
|
|
148
|
+
const _ref5 = (0, react_1.useState)(false),
|
|
149
|
+
_ref6 = (0, _slicedToArray2.default)(_ref5, 2),
|
|
150
|
+
isButtonFocused = _ref6[0],
|
|
151
|
+
setIsButtonFocused = _ref6[1];
|
|
133
152
|
const onButtonFocus = (0, react_1.useCallback)(() => setIsButtonFocused(true), []);
|
|
134
153
|
const onButtonBlur = (0, react_1.useCallback)(() => setIsButtonFocused(false), []);
|
|
135
154
|
const prefixSettings = (0, hooks_1.usePrefix)({
|
|
@@ -157,18 +176,17 @@ exports.FieldText = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
157
176
|
onFocus: onButtonFocus,
|
|
158
177
|
onBlur: onButtonBlur
|
|
159
178
|
});
|
|
160
|
-
const {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
postfixButtons
|
|
168
|
-
prefixButtons
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
179
|
+
const _ref7 = (0, input_private_1.useButtonNavigation)({
|
|
180
|
+
inputRef: localRef,
|
|
181
|
+
postfixButtons: (0, react_1.useMemo)(() => [clearButtonSettings, copyButtonSettings, postfixSettings, postfixButtonSettings], [clearButtonSettings, copyButtonSettings, postfixSettings, postfixButtonSettings]),
|
|
182
|
+
prefixButtons: (0, react_1.useMemo)(() => [prefixButtonSettings, prefixSettings], [prefixButtonSettings, prefixSettings]),
|
|
183
|
+
readonly,
|
|
184
|
+
submitKeys: ['Enter', 'Space', 'Tab']
|
|
185
|
+
}),
|
|
186
|
+
postfixButtons = _ref7.postfixButtons,
|
|
187
|
+
prefixButtons = _ref7.prefixButtons,
|
|
188
|
+
inputTabIndex = _ref7.inputTabIndex,
|
|
189
|
+
onInputKeyDown = _ref7.onInputKeyDown;
|
|
172
190
|
const handleKeyDown = event => {
|
|
173
191
|
onInputKeyDown(event);
|
|
174
192
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getContainerVariant = getContainerVariant;
|
|
7
7
|
function getContainerVariant(_ref) {
|
|
8
|
-
let
|
|
9
|
-
button
|
|
10
|
-
} = _ref;
|
|
8
|
+
let button = _ref.button;
|
|
11
9
|
if ((button === null || button === void 0 ? void 0 : button.variant) === 'before') {
|
|
12
10
|
return 'single-line-container-button-before';
|
|
13
11
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -30,51 +32,64 @@ const getValidationState_1 = require("../../utils/getValidationState");
|
|
|
30
32
|
const FieldDecorator_1 = require("../FieldDecorator");
|
|
31
33
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
32
34
|
exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
35
|
+
var id = _a.id,
|
|
36
|
+
name = _a.name,
|
|
37
|
+
valueProp = _a.value,
|
|
38
|
+
placeholder = _a.placeholder,
|
|
39
|
+
maxLength = _a.maxLength,
|
|
40
|
+
_a$minRows = _a.minRows,
|
|
41
|
+
minRows = _a$minRows === void 0 ? 3 : _a$minRows,
|
|
42
|
+
_a$maxRows = _a.maxRows,
|
|
43
|
+
maxRows = _a$maxRows === void 0 ? 1000 : _a$maxRows,
|
|
44
|
+
_a$disabled = _a.disabled,
|
|
45
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
46
|
+
_a$resizable = _a.resizable,
|
|
47
|
+
resizable = _a$resizable === void 0 ? false : _a$resizable,
|
|
48
|
+
_a$readonly = _a.readonly,
|
|
49
|
+
readonly = _a$readonly === void 0 ? false : _a$readonly,
|
|
50
|
+
_a$showCopyButton = _a.showCopyButton,
|
|
51
|
+
showCopyButtonProp = _a$showCopyButton === void 0 ? readonly : _a$showCopyButton,
|
|
52
|
+
_a$showClearButton = _a.showClearButton,
|
|
53
|
+
showClearButtonProp = _a$showClearButton === void 0 ? true : _a$showClearButton,
|
|
54
|
+
_a$allowMoreThanMaxLe = _a.allowMoreThanMaxLength,
|
|
55
|
+
allowMoreThanMaxLength = _a$allowMoreThanMaxLe === void 0 ? true : _a$allowMoreThanMaxLe,
|
|
56
|
+
showHintIcon = _a.showHintIcon,
|
|
57
|
+
onChangeProp = _a.onChange,
|
|
58
|
+
onFocus = _a.onFocus,
|
|
59
|
+
onBlur = _a.onBlur,
|
|
60
|
+
onKeyDown = _a.onKeyDown,
|
|
61
|
+
className = _a.className,
|
|
62
|
+
label = _a.label,
|
|
63
|
+
labelTooltip = _a.labelTooltip,
|
|
64
|
+
labelTooltipPlacement = _a.labelTooltipPlacement,
|
|
65
|
+
_a$required = _a.required,
|
|
66
|
+
required = _a$required === void 0 ? false : _a$required,
|
|
67
|
+
caption = _a.caption,
|
|
68
|
+
hint = _a.hint,
|
|
69
|
+
error = _a.error,
|
|
70
|
+
_a$size = _a.size,
|
|
71
|
+
size = _a$size === void 0 ? input_private_1.SIZE.S : _a$size,
|
|
72
|
+
_a$validationState = _a.validationState,
|
|
73
|
+
validationState = _a$validationState === void 0 ? constants_1.VALIDATION_STATE.Default : _a$validationState,
|
|
74
|
+
onCopyButtonClick = _a.onCopyButtonClick,
|
|
75
|
+
footer = _a.footer,
|
|
76
|
+
spellCheck = _a.spellCheck,
|
|
77
|
+
autoFocus = _a.autoFocus,
|
|
78
|
+
inputMode = _a.inputMode,
|
|
68
79
|
rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "minRows", "maxRows", "disabled", "resizable", "readonly", "showCopyButton", "showClearButton", "allowMoreThanMaxLength", "showHintIcon", "onChange", "onFocus", "onBlur", "onKeyDown", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "error", "size", "validationState", "onCopyButtonClick", "footer", "spellCheck", "autoFocus", "inputMode"]);
|
|
69
80
|
const localRef = (0, react_1.useRef)(null);
|
|
70
81
|
const clearButtonRef = (0, react_1.useRef)(null);
|
|
71
82
|
const copyButtonRef = (0, react_1.useRef)(null);
|
|
72
83
|
const isResizable = !readonly && !disabled && resizable;
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
const _ref = (0, hooks_1.useValueControl)({
|
|
85
|
+
value: valueProp,
|
|
86
|
+
defaultValue: '',
|
|
87
|
+
onChange: onChangeProp
|
|
88
|
+
}),
|
|
89
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
90
|
+
_ref2$ = _ref2[0],
|
|
91
|
+
value = _ref2$ === void 0 ? '' : _ref2$,
|
|
92
|
+
onChange = _ref2[1];
|
|
78
93
|
const showCopyButton = showCopyButtonProp && Boolean(value) && !disabled;
|
|
79
94
|
const showClearButton = showClearButtonProp && Boolean(value) && !disabled && !readonly;
|
|
80
95
|
const fieldValidationState = (0, getValidationState_1.getValidationState)({
|
|
@@ -101,16 +116,15 @@ exports.FieldTextArea = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
101
116
|
valueToCopy: value,
|
|
102
117
|
onCopyButtonClick
|
|
103
118
|
});
|
|
104
|
-
const {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
postfixButtons
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
});
|
|
119
|
+
const _ref3 = (0, input_private_1.useButtonNavigation)({
|
|
120
|
+
inputRef: localRef,
|
|
121
|
+
postfixButtons: (0, react_1.useMemo)(() => [clearButtonSettings, copyButtonSettings], [clearButtonSettings, copyButtonSettings]),
|
|
122
|
+
readonly,
|
|
123
|
+
submitKeys: ['Enter', 'Space', 'Tab']
|
|
124
|
+
}),
|
|
125
|
+
postfixButtons = _ref3.postfixButtons,
|
|
126
|
+
inputTabIndex = _ref3.inputTabIndex,
|
|
127
|
+
onInputKeyDown = _ref3.onInputKeyDown;
|
|
114
128
|
const handleKeyDown = event => {
|
|
115
129
|
onInputKeyDown(event);
|
|
116
130
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -33,10 +35,8 @@ const getValidationState_1 = require("../../utils/getValidationState");
|
|
|
33
35
|
const FieldDecorator_1 = require("../FieldDecorator");
|
|
34
36
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
35
37
|
const getStringTimeValue = (time, _ref) => {
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
locale
|
|
39
|
-
} = _ref;
|
|
38
|
+
let showSeconds = _ref.showSeconds,
|
|
39
|
+
locale = _ref.locale;
|
|
40
40
|
var _a, _b, _c;
|
|
41
41
|
if (!time) {
|
|
42
42
|
return '';
|
|
@@ -52,37 +52,46 @@ const getStringTimeValue = (time, _ref) => {
|
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
54
|
exports.FieldTime = (0, react_1.forwardRef)((_a, ref) => {
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
55
|
+
var id = _a.id,
|
|
56
|
+
name = _a.name,
|
|
57
|
+
valueProp = _a.value,
|
|
58
|
+
_a$disabled = _a.disabled,
|
|
59
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
60
|
+
_a$readonly = _a.readonly,
|
|
61
|
+
readonly = _a$readonly === void 0 ? false : _a$readonly,
|
|
62
|
+
_a$showCopyButton = _a.showCopyButton,
|
|
63
|
+
showCopyButtonProp = _a$showCopyButton === void 0 ? true : _a$showCopyButton,
|
|
64
|
+
_a$showClearButton = _a.showClearButton,
|
|
65
|
+
showClearButtonProp = _a$showClearButton === void 0 ? true : _a$showClearButton,
|
|
66
|
+
open = _a.open,
|
|
67
|
+
onOpenChange = _a.onOpenChange,
|
|
68
|
+
onChange = _a.onChange,
|
|
69
|
+
onFocus = _a.onFocus,
|
|
70
|
+
onBlurProp = _a.onBlur,
|
|
71
|
+
className = _a.className,
|
|
72
|
+
label = _a.label,
|
|
73
|
+
labelTooltip = _a.labelTooltip,
|
|
74
|
+
labelTooltipPlacement = _a.labelTooltipPlacement,
|
|
75
|
+
_a$required = _a.required,
|
|
76
|
+
required = _a$required === void 0 ? false : _a$required,
|
|
77
|
+
caption = _a.caption,
|
|
78
|
+
hint = _a.hint,
|
|
79
|
+
showHintIcon = _a.showHintIcon,
|
|
80
|
+
_a$showSeconds = _a.showSeconds,
|
|
81
|
+
showSeconds = _a$showSeconds === void 0 ? true : _a$showSeconds,
|
|
82
|
+
_a$size = _a.size,
|
|
83
|
+
size = _a$size === void 0 ? input_private_1.SIZE.S : _a$size,
|
|
84
|
+
_a$validationState = _a.validationState,
|
|
85
|
+
validationState = _a$validationState === void 0 ? constants_1.VALIDATION_STATE.Default : _a$validationState,
|
|
86
|
+
error = _a.error,
|
|
87
|
+
onCopyButtonClick = _a.onCopyButtonClick,
|
|
88
|
+
autoFocus = _a.autoFocus,
|
|
89
|
+
footerMode = _a.footerMode,
|
|
84
90
|
rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "showClearButton", "open", "onOpenChange", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "showSeconds", "size", "validationState", "error", "onCopyButtonClick", "autoFocus", "footerMode"]);
|
|
85
|
-
const
|
|
91
|
+
const _ref2 = (0, uncontrollable_1.useUncontrolledProp)(open, false, onOpenChange),
|
|
92
|
+
_ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
93
|
+
isOpen = _ref3[0],
|
|
94
|
+
setIsOpen = _ref3[1];
|
|
86
95
|
const localRef = (0, react_1.useRef)(null);
|
|
87
96
|
const clearButtonRef = (0, react_1.useRef)(null);
|
|
88
97
|
const copyButtonRef = (0, react_1.useRef)(null);
|
|
@@ -147,37 +156,35 @@ exports.FieldTime = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
147
156
|
}))
|
|
148
157
|
}), [calendarIconSize, size]);
|
|
149
158
|
const memorizedButtons = (0, react_1.useMemo)(() => [clearButtonSettings, copyButtonSettings, calendarIcon], [clearButtonSettings, copyButtonSettings, calendarIcon]);
|
|
150
|
-
const {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
});
|
|
159
|
+
const _ref4 = (0, hooks_1.useDateField)({
|
|
160
|
+
inputRef: localRef,
|
|
161
|
+
onChange,
|
|
162
|
+
readonly,
|
|
163
|
+
locale: constants_1.DEFAULT_LOCALE,
|
|
164
|
+
setIsOpen,
|
|
165
|
+
mode: showSeconds ? constants_1.TIME_MODES.FullTime : constants_1.TIME_MODES.NoSeconds,
|
|
166
|
+
showSeconds
|
|
167
|
+
}),
|
|
168
|
+
value = _ref4.value,
|
|
169
|
+
handleChange = _ref4.handleChange,
|
|
170
|
+
timeInputClickHandler = _ref4.handleClick,
|
|
171
|
+
timeInputKeyDownHandler = _ref4.handleKeyDown,
|
|
172
|
+
timeInputBlurHandler = _ref4.handleBlur,
|
|
173
|
+
mask = _ref4.mask,
|
|
174
|
+
setInputFocus = _ref4.setInputFocus;
|
|
167
175
|
const setInputFocusFromButtons = (0, react_1.useCallback)(() => setInputFocus(constants_1.SlotKey.Seconds), [setInputFocus]);
|
|
168
|
-
const {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
postfixButtons
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
});
|
|
176
|
+
const _ref5 = (0, input_private_1.useButtonNavigation)({
|
|
177
|
+
setInputFocus: setInputFocusFromButtons,
|
|
178
|
+
inputRef: localRef,
|
|
179
|
+
postfixButtons: memorizedButtons,
|
|
180
|
+
onButtonKeyDown: checkForLeavingFocus,
|
|
181
|
+
readonly,
|
|
182
|
+
submitKeys: ['Enter', 'Space', 'Tab']
|
|
183
|
+
}),
|
|
184
|
+
postfixButtons = _ref5.postfixButtons,
|
|
185
|
+
inputTabIndex = _ref5.inputTabIndex,
|
|
186
|
+
navigationInputKeyDownHandler = _ref5.onInputKeyDown,
|
|
187
|
+
setInitialTabIndices = _ref5.setInitialTabIndices;
|
|
181
188
|
const handleSelectTime = time => {
|
|
182
189
|
var _a;
|
|
183
190
|
onChange && onChange(time);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
4
6
|
return mod && mod.__esModule ? mod : {
|
|
5
7
|
"default": mod
|
|
@@ -15,16 +17,18 @@ const react_1 = require("react");
|
|
|
15
17
|
const helpers_1 = require("./helpers");
|
|
16
18
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
17
19
|
exports.ButtonCopyValue = (0, react_1.forwardRef)((_ref, ref) => {
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
tabIndex = -1,
|
|
22
|
-
onKeyDown,
|
|
23
|
-
onClick,
|
|
24
|
-
onValueRequest,
|
|
25
|
-
disabled
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
let size = _ref.size,
|
|
21
|
+
valueToCopy = _ref.valueToCopy,
|
|
22
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
23
|
+
tabIndex = _ref$tabIndex === void 0 ? -1 : _ref$tabIndex,
|
|
24
|
+
onKeyDown = _ref.onKeyDown,
|
|
25
|
+
onClick = _ref.onClick,
|
|
26
|
+
onValueRequest = _ref.onValueRequest,
|
|
27
|
+
disabled = _ref.disabled;
|
|
28
|
+
const _ref2 = (0, react_1.useState)(false),
|
|
29
|
+
_ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
30
|
+
isChecked = _ref3[0],
|
|
31
|
+
setIsChecked = _ref3[1];
|
|
28
32
|
const timerId = (0, react_1.useRef)();
|
|
29
33
|
const closeTooltip = () => setIsChecked(false);
|
|
30
34
|
const handleCopy = (event, asyncValue) => {
|
|
@@ -40,11 +44,9 @@ exports.ButtonCopyValue = (0, react_1.forwardRef)((_ref, ref) => {
|
|
|
40
44
|
const handleClick = event => {
|
|
41
45
|
event.stopPropagation();
|
|
42
46
|
if (onValueRequest) {
|
|
43
|
-
onValueRequest().then(
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
value
|
|
47
|
-
} = _ref2;
|
|
47
|
+
onValueRequest().then(_ref4 => {
|
|
48
|
+
let success = _ref4.success,
|
|
49
|
+
value = _ref4.value;
|
|
48
50
|
if (success) {
|
|
49
51
|
handleCopy(event, value);
|
|
50
52
|
}
|
|
@@ -8,10 +8,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const icons_1 = require("@snack-uikit/icons");
|
|
9
9
|
const input_private_1 = require("@snack-uikit/input-private");
|
|
10
10
|
function getIcon(_ref) {
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
isChecked
|
|
14
|
-
} = _ref;
|
|
11
|
+
let size = _ref.size,
|
|
12
|
+
isChecked = _ref.isChecked;
|
|
15
13
|
switch (size) {
|
|
16
14
|
case input_private_1.BUTTON_SIZE.S:
|
|
17
15
|
{
|
|
@@ -16,27 +16,27 @@ const divider_1 = require("@snack-uikit/divider");
|
|
|
16
16
|
const utils_1 = require("../../components/FieldSelect/utils");
|
|
17
17
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
18
18
|
exports.ButtonField = (0, react_1.forwardRef)((_ref, ref) => {
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
tabIndex = 0,
|
|
22
|
-
onClick,
|
|
23
|
-
onKeyDown,
|
|
24
|
-
onFocus,
|
|
25
|
-
onBlur,
|
|
26
|
-
disabled,
|
|
27
|
-
content,
|
|
28
|
-
hasArrow =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
let size = _ref.size,
|
|
20
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
21
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
|
|
22
|
+
onClick = _ref.onClick,
|
|
23
|
+
onKeyDown = _ref.onKeyDown,
|
|
24
|
+
onFocus = _ref.onFocus,
|
|
25
|
+
onBlur = _ref.onBlur,
|
|
26
|
+
disabled = _ref.disabled,
|
|
27
|
+
content = _ref.content,
|
|
28
|
+
_ref$hasArrow = _ref.hasArrow,
|
|
29
|
+
hasArrow = _ref$hasArrow === void 0 ? false : _ref$hasArrow,
|
|
30
|
+
_ref$arrowOpen = _ref.arrowOpen,
|
|
31
|
+
arrowOpen = _ref$arrowOpen === void 0 ? false : _ref$arrowOpen,
|
|
32
|
+
variant = _ref.variant,
|
|
33
|
+
className = _ref.className;
|
|
34
|
+
const _ref2 = (0, utils_1.getArrowIcon)({
|
|
35
|
+
open: arrowOpen,
|
|
36
|
+
size: 'm'
|
|
37
|
+
}),
|
|
38
|
+
ArrowIcon = _ref2.ArrowIcon,
|
|
39
|
+
arrowIconSize = _ref2.arrowIconSize;
|
|
40
40
|
return (0, jsx_runtime_1.jsxs)("button", {
|
|
41
41
|
className: (0, classnames_1.default)(className, styles_module_scss_1.default.buttonField),
|
|
42
42
|
"data-size": size,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -25,16 +27,17 @@ const ButtonField_1 = require("../ButtonField");
|
|
|
25
27
|
const helpers_1 = require("./helpers");
|
|
26
28
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
27
29
|
exports.ButtonFieldList = (0, react_1.forwardRef)((_a, ref) => {
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
scroll
|
|
35
|
-
} = _a,
|
|
30
|
+
var items = _a.items,
|
|
31
|
+
selection = _a.selection,
|
|
32
|
+
open = _a.open,
|
|
33
|
+
onOpenChange = _a.onOpenChange,
|
|
34
|
+
search = _a.search,
|
|
35
|
+
scroll = _a.scroll,
|
|
36
36
|
rest = __rest(_a, ["items", "selection", "open", "onOpenChange", "search", "scroll"]);
|
|
37
|
-
const
|
|
37
|
+
const _ref = (0, uncontrollable_1.useUncontrolledProp)(open, false, onOpenChange),
|
|
38
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
39
|
+
isOpen = _ref2[0],
|
|
40
|
+
setIsOpen = _ref2[1];
|
|
38
41
|
const placement = (0, helpers_1.getPlacement)(rest);
|
|
39
42
|
return (0, jsx_runtime_1.jsx)(list_1.Droplist, {
|
|
40
43
|
"data-test-id": 'button-field-list',
|