@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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.57.2 (2026-07-03)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/calendar@0.14.2]($PUBLIC_PROJECT_URL/blob/master/packages/calendar/CHANGELOG.md)
|
|
10
|
+
* [@snack-uikit/color-picker@0.3.58]($PUBLIC_PROJECT_URL/blob/master/packages/color-picker/CHANGELOG.md)
|
|
11
|
+
* [@snack-uikit/dropdown@0.5.8]($PUBLIC_PROJECT_URL/blob/master/packages/dropdown/CHANGELOG.md)
|
|
12
|
+
* [@snack-uikit/list@0.33.3]($PUBLIC_PROJECT_URL/blob/master/packages/list/CHANGELOG.md)
|
|
13
|
+
* [@snack-uikit/slider@0.3.39]($PUBLIC_PROJECT_URL/blob/master/packages/slider/CHANGELOG.md)
|
|
14
|
+
* [@snack-uikit/tag@0.15.22]($PUBLIC_PROJECT_URL/blob/master/packages/tag/CHANGELOG.md)
|
|
15
|
+
* [@snack-uikit/tooltip@0.18.15]($PUBLIC_PROJECT_URL/blob/master/packages/tooltip/CHANGELOG.md)
|
|
16
|
+
* [@snack-uikit/truncate-string@0.7.14]($PUBLIC_PROJECT_URL/blob/master/packages/truncate-string/CHANGELOG.md)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## 0.57.1 (2026-06-24)
|
|
7
23
|
|
|
8
24
|
|
|
@@ -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];
|
|
@@ -32,48 +34,60 @@ const getValidationState_1 = require("../../utils/getValidationState");
|
|
|
32
34
|
const FieldDecorator_1 = require("../FieldDecorator");
|
|
33
35
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
34
36
|
exports.FieldColor = (0, react_1.forwardRef)((_a, ref) => {
|
|
35
|
-
var
|
|
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
|
-
|
|
37
|
+
var id = _a.id,
|
|
38
|
+
name = _a.name,
|
|
39
|
+
valueProp = _a.value,
|
|
40
|
+
_a$disabled = _a.disabled,
|
|
41
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
42
|
+
_a$readonly = _a.readonly,
|
|
43
|
+
readonly = _a$readonly === void 0 ? false : _a$readonly,
|
|
44
|
+
_a$showCopyButton = _a.showCopyButton,
|
|
45
|
+
showCopyButtonProp = _a$showCopyButton === void 0 ? true : _a$showCopyButton,
|
|
46
|
+
_a$showClearButton = _a.showClearButton,
|
|
47
|
+
showClearButtonProp = _a$showClearButton === void 0 ? true : _a$showClearButton,
|
|
48
|
+
open = _a.open,
|
|
49
|
+
onChange = _a.onChange,
|
|
50
|
+
onOpenChange = _a.onOpenChange,
|
|
51
|
+
className = _a.className,
|
|
52
|
+
label = _a.label,
|
|
53
|
+
labelTooltip = _a.labelTooltip,
|
|
54
|
+
labelTooltipPlacement = _a.labelTooltipPlacement,
|
|
55
|
+
_a$required = _a.required,
|
|
56
|
+
required = _a$required === void 0 ? false : _a$required,
|
|
57
|
+
caption = _a.caption,
|
|
58
|
+
hint = _a.hint,
|
|
59
|
+
showHintIcon = _a.showHintIcon,
|
|
60
|
+
_a$size = _a.size,
|
|
61
|
+
size = _a$size === void 0 ? input_private_1.SIZE.S : _a$size,
|
|
62
|
+
_a$validationState = _a.validationState,
|
|
63
|
+
validationState = _a$validationState === void 0 ? constants_1.VALIDATION_STATE.Default : _a$validationState,
|
|
64
|
+
error = _a.error,
|
|
65
|
+
withAlpha = _a.withAlpha,
|
|
66
|
+
autoApply = _a.autoApply,
|
|
67
|
+
placeholder = _a.placeholder,
|
|
68
|
+
onFocus = _a.onFocus,
|
|
69
|
+
onBlur = _a.onBlur,
|
|
70
|
+
onCopyButtonClick = _a.onCopyButtonClick,
|
|
71
|
+
autoFocus = _a.autoFocus,
|
|
65
72
|
rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "showClearButton", "open", "onChange", "onOpenChange", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "withAlpha", "autoApply", "placeholder", "onFocus", "onBlur", "onCopyButtonClick", "autoFocus"]);
|
|
66
|
-
const
|
|
73
|
+
const _ref = (0, uncontrollable_1.useUncontrolledProp)(open, false, onOpenChange),
|
|
74
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
75
|
+
isOpen = _ref2[0],
|
|
76
|
+
setIsOpen = _ref2[1];
|
|
67
77
|
const localRef = (0, react_1.useRef)(null);
|
|
68
78
|
const showDropList = isOpen && !readonly && !disabled;
|
|
69
79
|
const fieldValidationState = (0, getValidationState_1.getValidationState)({
|
|
70
80
|
validationState,
|
|
71
81
|
error
|
|
72
82
|
});
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
const _ref3 = (0, utils_1.useValueControl)({
|
|
84
|
+
value: valueProp || '',
|
|
85
|
+
onChange: onChange
|
|
86
|
+
}),
|
|
87
|
+
_ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
88
|
+
_ref4$ = _ref4[0],
|
|
89
|
+
value = _ref4$ === void 0 ? '' : _ref4$,
|
|
90
|
+
setValue = _ref4[1];
|
|
77
91
|
const clearButtonRef = (0, react_1.useRef)(null);
|
|
78
92
|
const copyButtonRef = (0, react_1.useRef)(null);
|
|
79
93
|
const showAdditionalButton = Boolean(value && !disabled);
|
|
@@ -99,16 +113,15 @@ exports.FieldColor = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
99
113
|
valueToCopy: value,
|
|
100
114
|
onCopyButtonClick
|
|
101
115
|
});
|
|
102
|
-
const {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
postfixButtons
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
116
|
+
const _ref5 = (0, input_private_1.useButtonNavigation)({
|
|
117
|
+
inputRef: localRef,
|
|
118
|
+
postfixButtons: (0, react_1.useMemo)(() => [clearButtonSettings, copyButtonSettings], [clearButtonSettings, copyButtonSettings]),
|
|
119
|
+
readonly,
|
|
120
|
+
submitKeys: ['Enter', 'Space', 'Tab']
|
|
121
|
+
}),
|
|
122
|
+
postfixButtons = _ref5.postfixButtons,
|
|
123
|
+
inputTabIndex = _ref5.inputTabIndex,
|
|
124
|
+
onInputKeyDown = _ref5.onInputKeyDown;
|
|
112
125
|
(0, react_1.useEffect)(() => {
|
|
113
126
|
var _a;
|
|
114
127
|
if (open) {
|
|
@@ -145,10 +158,8 @@ exports.FieldColor = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
145
158
|
withAlpha: withAlpha,
|
|
146
159
|
autoApply: autoApply,
|
|
147
160
|
value: value,
|
|
148
|
-
onChange:
|
|
149
|
-
let
|
|
150
|
-
hex
|
|
151
|
-
} = _ref;
|
|
161
|
+
onChange: _ref6 => {
|
|
162
|
+
let hex = _ref6.hex;
|
|
152
163
|
setValue === null || setValue === void 0 ? void 0 : setValue(hex || '');
|
|
153
164
|
},
|
|
154
165
|
colorMode: {
|
|
@@ -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];
|
|
@@ -34,37 +36,45 @@ const FieldDecorator_1 = require("../FieldDecorator");
|
|
|
34
36
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
35
37
|
exports.FieldDate = (0, react_1.forwardRef)((_a, ref) => {
|
|
36
38
|
var _b;
|
|
37
|
-
var
|
|
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
|
-
|
|
39
|
+
var id = _a.id,
|
|
40
|
+
name = _a.name,
|
|
41
|
+
valueProp = _a.value,
|
|
42
|
+
_a$disabled = _a.disabled,
|
|
43
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
44
|
+
_a$readonly = _a.readonly,
|
|
45
|
+
readonly = _a$readonly === void 0 ? false : _a$readonly,
|
|
46
|
+
_a$showCopyButton = _a.showCopyButton,
|
|
47
|
+
showCopyButtonProp = _a$showCopyButton === void 0 ? true : _a$showCopyButton,
|
|
48
|
+
_a$showClearButton = _a.showClearButton,
|
|
49
|
+
showClearButtonProp = _a$showClearButton === void 0 ? true : _a$showClearButton,
|
|
50
|
+
open = _a.open,
|
|
51
|
+
onOpenChange = _a.onOpenChange,
|
|
52
|
+
onChange = _a.onChange,
|
|
53
|
+
onFocus = _a.onFocus,
|
|
54
|
+
onBlurProp = _a.onBlur,
|
|
55
|
+
className = _a.className,
|
|
56
|
+
label = _a.label,
|
|
57
|
+
labelTooltip = _a.labelTooltip,
|
|
58
|
+
labelTooltipPlacement = _a.labelTooltipPlacement,
|
|
59
|
+
_a$required = _a.required,
|
|
60
|
+
required = _a$required === void 0 ? false : _a$required,
|
|
61
|
+
caption = _a.caption,
|
|
62
|
+
hint = _a.hint,
|
|
63
|
+
showHintIcon = _a.showHintIcon,
|
|
64
|
+
_a$size = _a.size,
|
|
65
|
+
size = _a$size === void 0 ? input_private_1.SIZE.S : _a$size,
|
|
66
|
+
_a$validationState = _a.validationState,
|
|
67
|
+
validationState = _a$validationState === void 0 ? constants_1.VALIDATION_STATE.Default : _a$validationState,
|
|
68
|
+
buildCellProps = _a.buildCellProps,
|
|
69
|
+
error = _a.error,
|
|
70
|
+
mode = _a.mode,
|
|
71
|
+
onCopyButtonClick = _a.onCopyButtonClick,
|
|
72
|
+
autoFocus = _a.autoFocus,
|
|
66
73
|
rest = __rest(_a, ["id", "name", "value", "disabled", "readonly", "showCopyButton", "showClearButton", "open", "onOpenChange", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "buildCellProps", "error", "mode", "onCopyButtonClick", "autoFocus"]);
|
|
67
|
-
const
|
|
74
|
+
const _ref = (0, uncontrollable_1.useUncontrolledProp)(open, false, onOpenChange),
|
|
75
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
76
|
+
isOpen = _ref2[0],
|
|
77
|
+
setIsOpen = _ref2[1];
|
|
68
78
|
const localRef = (0, react_1.useRef)(null);
|
|
69
79
|
const clearButtonRef = (0, react_1.useRef)(null);
|
|
70
80
|
const copyButtonRef = (0, react_1.useRef)(null);
|
|
@@ -141,37 +151,35 @@ exports.FieldDate = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
141
151
|
}))
|
|
142
152
|
}), [calendarIconSize, size]);
|
|
143
153
|
const memorizedButtons = (0, react_1.useMemo)(() => [clearButtonSettings, copyButtonSettings, calendarIcon], [clearButtonSettings, copyButtonSettings, calendarIcon]);
|
|
144
|
-
const {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
154
|
+
const _ref3 = (0, hooks_1.useDateField)({
|
|
155
|
+
inputRef: localRef,
|
|
156
|
+
onChange,
|
|
157
|
+
readonly,
|
|
158
|
+
locale: constants_1.DEFAULT_LOCALE,
|
|
159
|
+
setIsOpen,
|
|
160
|
+
mode,
|
|
161
|
+
showSeconds
|
|
162
|
+
}),
|
|
163
|
+
value = _ref3.value,
|
|
164
|
+
handleChange = _ref3.handleChange,
|
|
165
|
+
dateInputClickHandler = _ref3.handleClick,
|
|
166
|
+
dateInputKeyDownHandler = _ref3.handleKeyDown,
|
|
167
|
+
dateInputBlurHandler = _ref3.handleBlur,
|
|
168
|
+
mask = _ref3.mask,
|
|
169
|
+
setInputFocus = _ref3.setInputFocus;
|
|
161
170
|
const setInputFocusFromButtons = (0, react_1.useCallback)(() => setInputFocus(mode === 'date' ? constants_1.SlotKey.Year : constants_1.SlotKey.Seconds), [mode, setInputFocus]);
|
|
162
|
-
const {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
postfixButtons
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
});
|
|
171
|
+
const _ref4 = (0, input_private_1.useButtonNavigation)({
|
|
172
|
+
setInputFocus: setInputFocusFromButtons,
|
|
173
|
+
inputRef: localRef,
|
|
174
|
+
postfixButtons: memorizedButtons,
|
|
175
|
+
onButtonKeyDown: checkForLeavingFocus,
|
|
176
|
+
readonly,
|
|
177
|
+
submitKeys: ['Enter', 'Space', 'Tab']
|
|
178
|
+
}),
|
|
179
|
+
postfixButtons = _ref4.postfixButtons,
|
|
180
|
+
inputTabIndex = _ref4.inputTabIndex,
|
|
181
|
+
navigationInputKeyDownHandler = _ref4.onInputKeyDown,
|
|
182
|
+
setInitialTabIndices = _ref4.setInitialTabIndices;
|
|
175
183
|
const handleSelectDate = date => {
|
|
176
184
|
var _a;
|
|
177
185
|
onChange && onChange(date);
|
|
@@ -28,24 +28,24 @@ const Footer_1 = require("./Footer");
|
|
|
28
28
|
const Header_1 = require("./Header");
|
|
29
29
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
30
30
|
exports.FieldDecorator = (0, react_1.forwardRef)((_a, ref) => {
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
var children = _a.children,
|
|
32
|
+
className = _a.className,
|
|
33
|
+
label = _a.label,
|
|
34
|
+
labelTooltip = _a.labelTooltip,
|
|
35
|
+
required = _a.required,
|
|
36
|
+
labelFor = _a.labelFor,
|
|
37
|
+
caption = _a.caption,
|
|
38
|
+
length = _a.length,
|
|
39
|
+
hint = _a.hint,
|
|
40
|
+
disabled = _a.disabled,
|
|
41
|
+
readonly = _a.readonly,
|
|
42
|
+
showHintIcon = _a.showHintIcon,
|
|
43
|
+
labelTooltipPlacement = _a.labelTooltipPlacement,
|
|
44
|
+
_a$size = _a.size,
|
|
45
|
+
size = _a$size === void 0 ? input_private_1.SIZE.S : _a$size,
|
|
46
|
+
error = _a.error,
|
|
47
|
+
_a$validationState = _a.validationState,
|
|
48
|
+
validationState = _a$validationState === void 0 ? constants_1.VALIDATION_STATE.Default : _a$validationState,
|
|
49
49
|
rest = __rest(_a, ["children", "className", "label", "labelTooltip", "required", "labelFor", "caption", "length", "hint", "disabled", "readonly", "showHintIcon", "labelTooltipPlacement", "size", "error", "validationState"]);
|
|
50
50
|
const isFieldActive = !disabled && !readonly;
|
|
51
51
|
const fieldValidationState = (0, getValidationState_1.getValidationState)({
|
|
@@ -44,13 +44,12 @@ function getValidationIcon(props) {
|
|
|
44
44
|
}) : null;
|
|
45
45
|
}
|
|
46
46
|
function Footer(_ref) {
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
validationState = constants_1.VALIDATION_STATE.Default,
|
|
52
|
-
showHintIcon
|
|
53
|
-
} = _ref;
|
|
47
|
+
let length = _ref.length,
|
|
48
|
+
hint = _ref.hint,
|
|
49
|
+
size = _ref.size,
|
|
50
|
+
_ref$validationState = _ref.validationState,
|
|
51
|
+
validationState = _ref$validationState === void 0 ? constants_1.VALIDATION_STATE.Default : _ref$validationState,
|
|
52
|
+
showHintIcon = _ref.showHintIcon;
|
|
54
53
|
const isReverseContainer = !hint && length;
|
|
55
54
|
const limitExceeded = length && length.max && length.current > length.max;
|
|
56
55
|
const icon = (0, react_1.useMemo)(() => getValidationIcon({
|
|
@@ -15,15 +15,16 @@ const tooltip_1 = require("@snack-uikit/tooltip");
|
|
|
15
15
|
const truncate_string_1 = require("@snack-uikit/truncate-string");
|
|
16
16
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
17
17
|
function Header(_ref) {
|
|
18
|
-
let
|
|
19
|
-
label = '',
|
|
20
|
-
labelTooltip,
|
|
21
|
-
caption,
|
|
22
|
-
labelFor,
|
|
23
|
-
size,
|
|
24
|
-
required =
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
let _ref$label = _ref.label,
|
|
19
|
+
label = _ref$label === void 0 ? '' : _ref$label,
|
|
20
|
+
labelTooltip = _ref.labelTooltip,
|
|
21
|
+
caption = _ref.caption,
|
|
22
|
+
labelFor = _ref.labelFor,
|
|
23
|
+
size = _ref.size,
|
|
24
|
+
_ref$required = _ref.required,
|
|
25
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
26
|
+
_ref$labelTooltipPlac = _ref.labelTooltipPlacement,
|
|
27
|
+
labelTooltipPlacement = _ref$labelTooltipPlac === void 0 ? 'top' : _ref$labelTooltipPlac;
|
|
27
28
|
return (0, jsx_runtime_1.jsxs)("span", {
|
|
28
29
|
className: styles_module_scss_1.default.header,
|
|
29
30
|
"data-size": size,
|
|
@@ -5,22 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.extractFieldDecoratorProps = extractFieldDecoratorProps;
|
|
7
7
|
function extractFieldDecoratorProps(_ref) {
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
className
|
|
23
|
-
} = _ref;
|
|
8
|
+
let error = _ref.error,
|
|
9
|
+
required = _ref.required,
|
|
10
|
+
readonly = _ref.readonly,
|
|
11
|
+
label = _ref.label,
|
|
12
|
+
labelTooltip = _ref.labelTooltip,
|
|
13
|
+
labelTooltipPlacement = _ref.labelTooltipPlacement,
|
|
14
|
+
labelFor = _ref.labelFor,
|
|
15
|
+
caption = _ref.caption,
|
|
16
|
+
hint = _ref.hint,
|
|
17
|
+
disabled = _ref.disabled,
|
|
18
|
+
showHintIcon = _ref.showHintIcon,
|
|
19
|
+
size = _ref.size,
|
|
20
|
+
validationState = _ref.validationState,
|
|
21
|
+
className = _ref.className;
|
|
24
22
|
return {
|
|
25
23
|
error,
|
|
26
24
|
required,
|
|
@@ -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 __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
6
|
function adopt(value) {
|
|
5
7
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -56,54 +58,73 @@ const hooks_1 = require("../../hooks");
|
|
|
56
58
|
const getValidationState_1 = require("../../utils/getValidationState");
|
|
57
59
|
const FieldDecorator_1 = require("../FieldDecorator");
|
|
58
60
|
exports.FieldSecure = (0, react_1.forwardRef)((_a, ref) => {
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
61
|
+
var id = _a.id,
|
|
62
|
+
name = _a.name,
|
|
63
|
+
valueProp = _a.value,
|
|
64
|
+
placeholder = _a.placeholder,
|
|
65
|
+
maxLength = _a.maxLength,
|
|
66
|
+
_a$disabled = _a.disabled,
|
|
67
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
68
|
+
_a$readonly = _a.readonly,
|
|
69
|
+
readonly = _a$readonly === void 0 ? false : _a$readonly,
|
|
70
|
+
_a$showCopyButton = _a.showCopyButton,
|
|
71
|
+
showCopyButtonProp = _a$showCopyButton === void 0 ? true : _a$showCopyButton,
|
|
72
|
+
_a$allowMoreThanMaxLe = _a.allowMoreThanMaxLength,
|
|
73
|
+
allowMoreThanMaxLength = _a$allowMoreThanMaxLe === void 0 ? false : _a$allowMoreThanMaxLe,
|
|
74
|
+
hiddenProp = _a.hidden,
|
|
75
|
+
onHiddenChange = _a.onHiddenChange,
|
|
76
|
+
showHintIcon = _a.showHintIcon,
|
|
77
|
+
onChangeProp = _a.onChange,
|
|
78
|
+
onFocus = _a.onFocus,
|
|
79
|
+
onBlur = _a.onBlur,
|
|
80
|
+
className = _a.className,
|
|
81
|
+
label = _a.label,
|
|
82
|
+
labelTooltip = _a.labelTooltip,
|
|
83
|
+
labelTooltipPlacement = _a.labelTooltipPlacement,
|
|
84
|
+
_a$required = _a.required,
|
|
85
|
+
required = _a$required === void 0 ? false : _a$required,
|
|
86
|
+
caption = _a.caption,
|
|
87
|
+
hint = _a.hint,
|
|
88
|
+
_a$size = _a.size,
|
|
89
|
+
size = _a$size === void 0 ? input_private_1.SIZE.S : _a$size,
|
|
90
|
+
_a$validationState = _a.validationState,
|
|
91
|
+
validationState = _a$validationState === void 0 ? constants_1.VALIDATION_STATE.Default : _a$validationState,
|
|
92
|
+
prefixIcon = _a.prefixIcon,
|
|
93
|
+
error = _a.error,
|
|
94
|
+
asyncValueGetter = _a.asyncValueGetter,
|
|
95
|
+
autoComplete = _a.autoComplete,
|
|
96
|
+
autoFocus = _a.autoFocus,
|
|
97
|
+
onCopyButtonClick = _a.onCopyButtonClick,
|
|
91
98
|
rest = __rest(_a, ["id", "name", "value", "placeholder", "maxLength", "disabled", "readonly", "showCopyButton", "allowMoreThanMaxLength", "hidden", "onHiddenChange", "showHintIcon", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "size", "validationState", "prefixIcon", "error", "asyncValueGetter", "autoComplete", "autoFocus", "onCopyButtonClick"]);
|
|
92
99
|
const localRef = (0, react_1.useRef)(null);
|
|
93
100
|
const copyButtonRef = (0, react_1.useRef)(null);
|
|
94
101
|
const hideButtonRef = (0, react_1.useRef)(null);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
const _ref = (0, react_1.useState)(false),
|
|
103
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
104
|
+
isDataRequested = _ref2[0],
|
|
105
|
+
setIsDataRequested = _ref2[1];
|
|
106
|
+
const _ref3 = (0, react_1.useState)(false),
|
|
107
|
+
_ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
108
|
+
isLoading = _ref4[0],
|
|
109
|
+
setIsLoading = _ref4[1];
|
|
110
|
+
const _ref5 = (0, hooks_1.useValueControl)({
|
|
111
|
+
value: valueProp,
|
|
112
|
+
defaultValue: '',
|
|
113
|
+
onChange: onChangeProp
|
|
114
|
+
}),
|
|
115
|
+
_ref6 = (0, _slicedToArray2.default)(_ref5, 2),
|
|
116
|
+
_ref6$ = _ref6[0],
|
|
117
|
+
value = _ref6$ === void 0 ? '' : _ref6$,
|
|
118
|
+
onChange = _ref6[1];
|
|
119
|
+
const _ref7 = (0, hooks_1.useValueControl)({
|
|
120
|
+
value: hiddenProp,
|
|
121
|
+
defaultValue: true,
|
|
122
|
+
onChange: onHiddenChange
|
|
123
|
+
}),
|
|
124
|
+
_ref8 = (0, _slicedToArray2.default)(_ref7, 2),
|
|
125
|
+
_ref8$ = _ref8[0],
|
|
126
|
+
hidden = _ref8$ === void 0 ? true : _ref8$,
|
|
127
|
+
setHidden = _ref8[1];
|
|
107
128
|
const showCopyButton = showCopyButtonProp && Boolean(value) && readonly && !disabled;
|
|
108
129
|
const showHideButton = !(readonly && !value);
|
|
109
130
|
const fieldValidationState = (0, getValidationState_1.getValidationState)({
|
|
@@ -134,10 +155,8 @@ exports.FieldSecure = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
134
155
|
};
|
|
135
156
|
});
|
|
136
157
|
const toggleHidden = () => {
|
|
137
|
-
getAsyncValue().then(
|
|
138
|
-
let
|
|
139
|
-
success
|
|
140
|
-
} = _ref;
|
|
158
|
+
getAsyncValue().then(_ref9 => {
|
|
159
|
+
let success = _ref9.success;
|
|
141
160
|
if (success) {
|
|
142
161
|
setHidden(!hidden);
|
|
143
162
|
if (!readonly) {
|
|
@@ -167,16 +186,15 @@ exports.FieldSecure = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
167
186
|
hidden,
|
|
168
187
|
disabled: disabled || isLoading
|
|
169
188
|
});
|
|
170
|
-
const {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
postfixButtons
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
189
|
+
const _ref0 = (0, input_private_1.useButtonNavigation)({
|
|
190
|
+
inputRef: localRef,
|
|
191
|
+
postfixButtons: (0, react_1.useMemo)(() => [copyButtonSettings, hideButtonSettings], [copyButtonSettings, hideButtonSettings]),
|
|
192
|
+
readonly,
|
|
193
|
+
submitKeys: ['Enter', 'Space', 'Tab']
|
|
194
|
+
}),
|
|
195
|
+
postfixButtons = _ref0.postfixButtons,
|
|
196
|
+
inputTabIndex = _ref0.inputTabIndex,
|
|
197
|
+
onInputKeyDown = _ref0.onInputKeyDown;
|
|
180
198
|
return (0, jsx_runtime_1.jsx)(FieldDecorator_1.FieldDecorator, Object.assign({
|
|
181
199
|
className: className,
|
|
182
200
|
label: label,
|