@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
|
@@ -15,14 +15,13 @@ const icons_1 = require("@snack-uikit/icons");
|
|
|
15
15
|
const input_private_1 = require("@snack-uikit/input-private");
|
|
16
16
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
17
17
|
exports.ButtonHideValue = (0, react_1.forwardRef)((_ref, ref) => {
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
tabIndex = -1,
|
|
24
|
-
onKeyDown
|
|
25
|
-
} = _ref;
|
|
18
|
+
let size = _ref.size,
|
|
19
|
+
onClick = _ref.onClick,
|
|
20
|
+
hidden = _ref.hidden,
|
|
21
|
+
disabled = _ref.disabled,
|
|
22
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
23
|
+
tabIndex = _ref$tabIndex === void 0 ? -1 : _ref$tabIndex,
|
|
24
|
+
onKeyDown = _ref.onKeyDown;
|
|
26
25
|
const handleClick = event => {
|
|
27
26
|
if (disabled) {
|
|
28
27
|
return;
|
|
@@ -23,22 +23,20 @@ const utils_1 = require("@snack-uikit/utils");
|
|
|
23
23
|
const constants_1 = require("../../constants");
|
|
24
24
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
25
25
|
function FieldContainerPrivate(_a) {
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
inputRef
|
|
41
|
-
} = _a,
|
|
26
|
+
var className = _a.className,
|
|
27
|
+
children = _a.children,
|
|
28
|
+
size = _a.size,
|
|
29
|
+
validationState = _a.validationState,
|
|
30
|
+
variant = _a.variant,
|
|
31
|
+
disabled = _a.disabled,
|
|
32
|
+
readonly = _a.readonly,
|
|
33
|
+
focused = _a.focused,
|
|
34
|
+
disableFocus = _a.disableFocus,
|
|
35
|
+
selectable = _a.selectable,
|
|
36
|
+
style = _a.style,
|
|
37
|
+
prefix = _a.prefix,
|
|
38
|
+
postfix = _a.postfix,
|
|
39
|
+
inputRef = _a.inputRef,
|
|
42
40
|
rest = __rest(_a, ["className", "children", "size", "validationState", "variant", "disabled", "readonly", "focused", "disableFocus", "selectable", "style", "prefix", "postfix", "inputRef"]);
|
|
43
41
|
const handleContainerClick = () => {
|
|
44
42
|
var _a;
|
|
@@ -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];
|
|
@@ -24,30 +26,36 @@ const react_textarea_autosize_1 = __importDefault(require("react-textarea-autosi
|
|
|
24
26
|
const utils_1 = require("@snack-uikit/utils");
|
|
25
27
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
26
28
|
exports.TextArea = (0, react_1.forwardRef)((_a, ref) => {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
var name = _a.name,
|
|
30
|
+
_a$value = _a.value,
|
|
31
|
+
value = _a$value === void 0 ? '' : _a$value,
|
|
32
|
+
onChange = _a.onChange,
|
|
33
|
+
placeholder = _a.placeholder,
|
|
34
|
+
id = _a.id,
|
|
35
|
+
className = _a.className,
|
|
36
|
+
_a$disabled = _a.disabled,
|
|
37
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
38
|
+
_a$readonly = _a.readonly,
|
|
39
|
+
readonly = _a$readonly === void 0 ? false : _a$readonly,
|
|
40
|
+
_a$autoComplete = _a.autoComplete,
|
|
41
|
+
autoComplete = _a$autoComplete === void 0 ? false : _a$autoComplete,
|
|
42
|
+
_a$autoFocus = _a.autoFocus,
|
|
43
|
+
autoFocus = _a$autoFocus === void 0 ? false : _a$autoFocus,
|
|
44
|
+
maxLength = _a.maxLength,
|
|
45
|
+
onFocus = _a.onFocus,
|
|
46
|
+
onBlur = _a.onBlur,
|
|
47
|
+
onKeyDown = _a.onKeyDown,
|
|
48
|
+
tabIndex = _a.tabIndex,
|
|
49
|
+
_a$minRows = _a.minRows,
|
|
50
|
+
minRows = _a$minRows === void 0 ? 3 : _a$minRows,
|
|
51
|
+
spellCheck = _a.spellCheck,
|
|
52
|
+
inputMode = _a.inputMode,
|
|
47
53
|
rest = __rest(_a, ["name", "value", "onChange", "placeholder", "id", "className", "disabled", "readonly", "autoComplete", "autoFocus", "maxLength", "onFocus", "onBlur", "onKeyDown", "tabIndex", "minRows", "spellCheck", "inputMode"]);
|
|
48
54
|
// fix of height on the initial render
|
|
49
55
|
// see https://github.com/Andarist/react-textarea-autosize/issues/337#issuecomment-1024980737
|
|
50
|
-
const
|
|
56
|
+
const _ref = (0, react_1.useState)(false),
|
|
57
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
58
|
+
setIsRerendered = _ref2[1];
|
|
51
59
|
(0, utils_1.useLayoutEffect)(() => setIsRerendered(true), []);
|
|
52
60
|
const onChangeHandler = e => onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value, e);
|
|
53
61
|
const stopPropagation = e => e.stopPropagation();
|
|
@@ -16,11 +16,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
16
16
|
const react_1 = require("react");
|
|
17
17
|
function withCharacterCount(FieldComponent) {
|
|
18
18
|
return (0, react_1.forwardRef)((_a, ref) => {
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
maxLength
|
|
23
|
-
} = _a,
|
|
19
|
+
var handleReachLimit = _a.handleReachLimit,
|
|
20
|
+
onChange = _a.onChange,
|
|
21
|
+
maxLength = _a.maxLength,
|
|
24
22
|
restProps = __rest(_a, ["handleReachLimit", "onChange", "maxLength"]);
|
|
25
23
|
const handleLimitedChange = (0, react_1.useCallback)((value, e) => {
|
|
26
24
|
if (!maxLength || value.length > maxLength) {
|
|
@@ -8,20 +8,18 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const helperComponents_1 = require("../../helperComponents");
|
|
10
10
|
function useAddonButton(_ref) {
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
onBlur
|
|
21
|
-
} = _ref;
|
|
11
|
+
let variant = _ref.variant,
|
|
12
|
+
button = _ref.button,
|
|
13
|
+
icon = _ref.icon,
|
|
14
|
+
size = _ref.size,
|
|
15
|
+
disabled = _ref.disabled,
|
|
16
|
+
readonly = _ref.readonly,
|
|
17
|
+
type = _ref.type,
|
|
18
|
+
onFocus = _ref.onFocus,
|
|
19
|
+
onBlur = _ref.onBlur;
|
|
22
20
|
const buttonListRef = (0, react_1.useRef)(null);
|
|
23
21
|
const addonIconProps = (0, react_1.useMemo)(() => ({
|
|
24
|
-
id:
|
|
22
|
+
id: "".concat(type, "Icon"),
|
|
25
23
|
active: false,
|
|
26
24
|
show: Boolean(icon && !button),
|
|
27
25
|
render: () => (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {
|
|
@@ -29,7 +27,7 @@ function useAddonButton(_ref) {
|
|
|
29
27
|
})
|
|
30
28
|
}), [button, icon, type]);
|
|
31
29
|
const addonButtonProps = (0, react_1.useMemo)(() => ({
|
|
32
|
-
id:
|
|
30
|
+
id: "".concat(type, "Button"),
|
|
33
31
|
active: false,
|
|
34
32
|
show: Boolean(button && button.variant === variant),
|
|
35
33
|
render: renderProps => {
|
|
@@ -14,9 +14,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
14
14
|
exports.usePostfixButton = usePostfixButton;
|
|
15
15
|
const useAddonButton_1 = require("./useAddonButton");
|
|
16
16
|
function usePostfixButton(_a) {
|
|
17
|
-
var
|
|
18
|
-
postfixIcon
|
|
19
|
-
} = _a,
|
|
17
|
+
var postfixIcon = _a.postfixIcon,
|
|
20
18
|
props = __rest(_a, ["postfixIcon"]);
|
|
21
19
|
return (0, useAddonButton_1.useAddonButton)(Object.assign(Object.assign({}, props), {
|
|
22
20
|
icon: postfixIcon,
|
|
@@ -14,9 +14,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
14
14
|
exports.usePrefixButton = usePrefixButton;
|
|
15
15
|
const useAddonButton_1 = require("./useAddonButton");
|
|
16
16
|
function usePrefixButton(_a) {
|
|
17
|
-
var
|
|
18
|
-
prefixIcon
|
|
19
|
-
} = _a,
|
|
17
|
+
var prefixIcon = _a.prefixIcon,
|
|
20
18
|
props = __rest(_a, ["prefixIcon"]);
|
|
21
19
|
return (0, useAddonButton_1.useAddonButton)(Object.assign(Object.assign({}, props), {
|
|
22
20
|
icon: prefixIcon,
|
|
@@ -9,37 +9,35 @@ const utils_1 = require("@snack-uikit/utils");
|
|
|
9
9
|
const constants_1 = require("../../constants");
|
|
10
10
|
const useDateFieldHelpersForMode_1 = require("./useDateFieldHelpersForMode");
|
|
11
11
|
function useDateField(_ref) {
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
locale = constants_1.DEFAULT_LOCALE,
|
|
17
|
-
setIsOpen,
|
|
18
|
-
mode,
|
|
19
|
-
showSeconds
|
|
20
|
-
} = _ref;
|
|
12
|
+
let inputRef = _ref.inputRef,
|
|
13
|
+
onChange = _ref.onChange,
|
|
14
|
+
readonly = _ref.readonly,
|
|
15
|
+
_ref$locale = _ref.locale,
|
|
16
|
+
locale = _ref$locale === void 0 ? constants_1.DEFAULT_LOCALE : _ref$locale,
|
|
17
|
+
setIsOpen = _ref.setIsOpen,
|
|
18
|
+
mode = _ref.mode,
|
|
19
|
+
showSeconds = _ref.showSeconds;
|
|
21
20
|
var _a;
|
|
22
21
|
const dateTimeMode = mode === constants_1.MODES.DateTime && !showSeconds ? constants_1.NO_SECONDS_MODE : mode;
|
|
23
22
|
const slotsInfo = constants_1.SLOTS[dateTimeMode];
|
|
24
23
|
const mask = constants_1.MASK[dateTimeMode][locale.baseName] || constants_1.MASK[dateTimeMode][constants_1.DEFAULT_LOCALE.baseName];
|
|
25
24
|
const slotsPlaceholder = constants_1.SLOTS_PLACEHOLDER[dateTimeMode][locale.baseName] || constants_1.SLOTS_PLACEHOLDER[dateTimeMode][constants_1.DEFAULT_LOCALE.baseName];
|
|
26
25
|
const slotOrder = constants_1.SLOT_ORDER[dateTimeMode];
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
26
|
+
const _ref2 = (0, useDateFieldHelpersForMode_1.useDateFieldHelpersForMode)({
|
|
27
|
+
inputRef,
|
|
28
|
+
mode: dateTimeMode
|
|
29
|
+
}),
|
|
30
|
+
getNextSlotKey = _ref2.getNextSlotKey,
|
|
31
|
+
getPrevSlotKey = _ref2.getPrevSlotKey,
|
|
32
|
+
getSlotKeyFromIndex = _ref2.getSlotKeyFromIndex,
|
|
33
|
+
setFocus = _ref2.setFocus,
|
|
34
|
+
updateSlot = _ref2.updateSlot,
|
|
35
|
+
getSlot = _ref2.getSlot,
|
|
36
|
+
isLikeDate = _ref2.isLikeDate,
|
|
37
|
+
isAllSelected = _ref2.isAllSelected,
|
|
38
|
+
tryToCompleteInput = _ref2.tryToCompleteInput,
|
|
39
|
+
isValidInput = _ref2.isValidInput,
|
|
40
|
+
parseDate = _ref2.parseDate;
|
|
43
41
|
const focusSlotKey = (0, react_1.useMemo)(() => slotOrder[0], [slotOrder]);
|
|
44
42
|
const focusSlotRef = (0, react_1.useRef)(focusSlotKey);
|
|
45
43
|
const setInputFocus = (0, react_1.useCallback)(focusSlot => {
|
|
@@ -66,10 +64,9 @@ function useDateField(_ref) {
|
|
|
66
64
|
}
|
|
67
65
|
const slotKey = getSlotKeyFromIndex(inputRef.current.selectionStart);
|
|
68
66
|
if (slotKey) {
|
|
69
|
-
const
|
|
70
|
-
start,
|
|
71
|
-
end
|
|
72
|
-
} = slotsInfo[slotKey];
|
|
67
|
+
const _slotsInfo$slotKey = slotsInfo[slotKey],
|
|
68
|
+
start = _slotsInfo$slotKey.start,
|
|
69
|
+
end = _slotsInfo$slotKey.end;
|
|
73
70
|
inputRef.current.setSelectionRange(start, end);
|
|
74
71
|
}
|
|
75
72
|
}, [inputRef, readonly, isLikeDate, focusSlotKey, getSlotKeyFromIndex, mask, setFocus, slotsInfo]);
|
|
@@ -126,10 +123,9 @@ function useDateField(_ref) {
|
|
|
126
123
|
const slotKey = getSlotKeyFromIndex(clickIndex);
|
|
127
124
|
if (slotKey) {
|
|
128
125
|
const value = getSlot(slotKey);
|
|
129
|
-
const
|
|
130
|
-
max,
|
|
131
|
-
min
|
|
132
|
-
} = slotsInfo[slotKey];
|
|
126
|
+
const _slotsInfo$slotKey2 = slotsInfo[slotKey],
|
|
127
|
+
max = _slotsInfo$slotKey2.max,
|
|
128
|
+
min = _slotsInfo$slotKey2.min;
|
|
133
129
|
const numberValue = Number(value) || 0;
|
|
134
130
|
if (e.key === 'ArrowRight') {
|
|
135
131
|
if (isAllSelected() || slotKey === slotOrder[slotOrder.length - 1]) {
|
|
@@ -8,16 +8,13 @@ const react_1 = require("react");
|
|
|
8
8
|
const constants_1 = require("../../constants");
|
|
9
9
|
const dateFields_1 = require("../../utils/dateFields");
|
|
10
10
|
function useDateFieldHelpersForMode(_ref) {
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
mode
|
|
14
|
-
} = _ref;
|
|
11
|
+
let inputRef = _ref.inputRef,
|
|
12
|
+
mode = _ref.mode;
|
|
15
13
|
const setFocus = (0, react_1.useCallback)(slotKey => {
|
|
16
14
|
if (inputRef.current) {
|
|
17
|
-
const
|
|
18
|
-
start,
|
|
19
|
-
end
|
|
20
|
-
} = constants_1.SLOTS[mode][slotKey];
|
|
15
|
+
const _constants_1$SLOTS$mo = constants_1.SLOTS[mode][slotKey],
|
|
16
|
+
start = _constants_1$SLOTS$mo.start,
|
|
17
|
+
end = _constants_1$SLOTS$mo.end;
|
|
21
18
|
inputRef.current.setSelectionRange(start, end);
|
|
22
19
|
}
|
|
23
20
|
}, [mode, inputRef]);
|
|
@@ -59,14 +56,12 @@ function useDateFieldHelpersForMode(_ref) {
|
|
|
59
56
|
res[slotKey] = parseInt(getSlot(slotKey), 10);
|
|
60
57
|
return res;
|
|
61
58
|
}, {});
|
|
62
|
-
const
|
|
63
|
-
[constants_1.SlotKey.
|
|
64
|
-
[constants_1.SlotKey.
|
|
65
|
-
[constants_1.SlotKey.
|
|
66
|
-
[constants_1.SlotKey.
|
|
67
|
-
[constants_1.SlotKey.
|
|
68
|
-
[constants_1.SlotKey.Seconds]: seconds
|
|
69
|
-
} = parsedSlotsData;
|
|
59
|
+
const day = parsedSlotsData[constants_1.SlotKey.Day],
|
|
60
|
+
month = parsedSlotsData[constants_1.SlotKey.Month],
|
|
61
|
+
year = parsedSlotsData[constants_1.SlotKey.Year],
|
|
62
|
+
hours = parsedSlotsData[constants_1.SlotKey.Hours],
|
|
63
|
+
minutes = parsedSlotsData[constants_1.SlotKey.Minutes],
|
|
64
|
+
seconds = parsedSlotsData[constants_1.SlotKey.Seconds];
|
|
70
65
|
const yearSlotMeta = constants_1.SLOTS[mode][constants_1.SlotKey.Year];
|
|
71
66
|
const isDateCompleted = Boolean(day && month && year >= (yearSlotMeta === null || yearSlotMeta === void 0 ? void 0 : yearSlotMeta.min) && year <= (yearSlotMeta === null || yearSlotMeta === void 0 ? void 0 : yearSlotMeta.max));
|
|
72
67
|
const isTimeCompleted = [hours, minutes, ...(mode === constants_1.MODES.DateTime || mode === constants_1.TIME_MODES.FullTime ? [seconds] : [])].every(value => value !== undefined);
|
|
@@ -86,11 +81,10 @@ function useDateFieldHelpersForMode(_ref) {
|
|
|
86
81
|
}, [getSlot, inputRef, mode]);
|
|
87
82
|
const updateSlot = (0, react_1.useCallback)((slotKey, slotValue) => {
|
|
88
83
|
if (inputRef.current) {
|
|
89
|
-
const
|
|
90
|
-
start,
|
|
91
|
-
end,
|
|
92
|
-
max
|
|
93
|
-
} = constants_1.SLOTS[mode][slotKey];
|
|
84
|
+
const _constants_1$SLOTS$mo2 = constants_1.SLOTS[mode][slotKey],
|
|
85
|
+
start = _constants_1$SLOTS$mo2.start,
|
|
86
|
+
end = _constants_1$SLOTS$mo2.end,
|
|
87
|
+
max = _constants_1$SLOTS$mo2.max;
|
|
94
88
|
inputRef.current.value = inputRef.current.value.slice(0, start) + slotValue.toString().padStart(max.toString().length, '0') + inputRef.current.value.slice(end);
|
|
95
89
|
setFocus(slotKey);
|
|
96
90
|
}
|
|
@@ -10,10 +10,8 @@ const react_1 = require("react");
|
|
|
10
10
|
* Основано на том факте что событию фокуса в результате клика предшествует событие onMouseDown.
|
|
11
11
|
*/
|
|
12
12
|
function useFocusHandlers(_ref) {
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
onFocusByClick
|
|
16
|
-
} = _ref;
|
|
13
|
+
let onFocusByKeyboard = _ref.onFocusByKeyboard,
|
|
14
|
+
onFocusByClick = _ref.onFocusByClick;
|
|
17
15
|
const isFocused = (0, react_1.useRef)(false);
|
|
18
16
|
const isMouseDown = (0, react_1.useRef)(false);
|
|
19
17
|
const onFocus = (0, react_1.useCallback)(e => {
|
|
@@ -17,26 +17,24 @@ const react_1 = require("react");
|
|
|
17
17
|
const input_private_1 = require("@snack-uikit/input-private");
|
|
18
18
|
const helperComponents_1 = require("../helperComponents");
|
|
19
19
|
function useCopyButton(_ref) {
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
prefix = '',
|
|
29
|
-
postfix =
|
|
30
|
-
|
|
20
|
+
let copyButtonRef = _ref.copyButtonRef,
|
|
21
|
+
showCopyButton = _ref.showCopyButton,
|
|
22
|
+
size = _ref.size,
|
|
23
|
+
valueToCopy = _ref.valueToCopy,
|
|
24
|
+
onValueRequest = _ref.onValueRequest,
|
|
25
|
+
onCopyButtonClick = _ref.onCopyButtonClick,
|
|
26
|
+
disabled = _ref.disabled,
|
|
27
|
+
_ref$prefix = _ref.prefix,
|
|
28
|
+
prefix = _ref$prefix === void 0 ? '' : _ref$prefix,
|
|
29
|
+
_ref$postfix = _ref.postfix,
|
|
30
|
+
postfix = _ref$postfix === void 0 ? '' : _ref$postfix;
|
|
31
31
|
return (0, react_1.useMemo)(() => ({
|
|
32
32
|
id: 'copy',
|
|
33
33
|
active: true,
|
|
34
34
|
ref: copyButtonRef,
|
|
35
35
|
show: showCopyButton,
|
|
36
36
|
render: _a => {
|
|
37
|
-
var
|
|
38
|
-
key
|
|
39
|
-
} = _a,
|
|
37
|
+
var key = _a.key,
|
|
40
38
|
props = __rest(_a, ["key"]);
|
|
41
39
|
return (0, jsx_runtime_1.jsx)(helperComponents_1.ButtonCopyValue, Object.assign({}, props, {
|
|
42
40
|
size: input_private_1.BUTTON_SIZE_MAP[size],
|
|
@@ -18,14 +18,12 @@ const input_private_1 = require("@snack-uikit/input-private");
|
|
|
18
18
|
const utils_1 = require("@snack-uikit/utils");
|
|
19
19
|
const helperComponents_1 = require("../helperComponents");
|
|
20
20
|
function useHideButton(_ref) {
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
disabled
|
|
28
|
-
} = _ref;
|
|
21
|
+
let hideButtonRef = _ref.hideButtonRef,
|
|
22
|
+
showHideButton = _ref.showHideButton,
|
|
23
|
+
size = _ref.size,
|
|
24
|
+
toggleHidden = _ref.toggleHidden,
|
|
25
|
+
hidden = _ref.hidden,
|
|
26
|
+
disabled = _ref.disabled;
|
|
29
27
|
const toggleHiddenEventHandler = (0, utils_1.useEventHandler)(toggleHidden);
|
|
30
28
|
return (0, react_1.useMemo)(() => ({
|
|
31
29
|
id: 'hide',
|
|
@@ -33,9 +31,7 @@ function useHideButton(_ref) {
|
|
|
33
31
|
ref: hideButtonRef,
|
|
34
32
|
show: showHideButton,
|
|
35
33
|
render: _a => {
|
|
36
|
-
var
|
|
37
|
-
key
|
|
38
|
-
} = _a,
|
|
34
|
+
var key = _a.key,
|
|
39
35
|
props = __rest(_a, ["key"]);
|
|
40
36
|
const handleClick = event => {
|
|
41
37
|
props.onClick(event);
|
|
@@ -21,18 +21,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
21
21
|
const react_1 = require("react");
|
|
22
22
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
23
23
|
function usePostfix(_ref) {
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
disabled
|
|
27
|
-
} = _ref;
|
|
24
|
+
let postfix = _ref.postfix,
|
|
25
|
+
disabled = _ref.disabled;
|
|
28
26
|
return (0, react_1.useMemo)(() => ({
|
|
29
27
|
id: 'postfix',
|
|
30
28
|
active: false,
|
|
31
29
|
show: Boolean(postfix),
|
|
32
30
|
render: _a => {
|
|
33
|
-
var
|
|
34
|
-
key
|
|
35
|
-
} = _a,
|
|
31
|
+
var key = _a.key,
|
|
36
32
|
props = __rest(_a, ["key"]);
|
|
37
33
|
return (0, jsx_runtime_1.jsx)("div", Object.assign({}, props, {
|
|
38
34
|
className: styles_module_scss_1.default.postfix,
|
|
@@ -21,18 +21,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
21
21
|
const react_1 = require("react");
|
|
22
22
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
23
23
|
function usePrefix(_ref) {
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
disabled
|
|
27
|
-
} = _ref;
|
|
24
|
+
let prefix = _ref.prefix,
|
|
25
|
+
disabled = _ref.disabled;
|
|
28
26
|
return (0, react_1.useMemo)(() => ({
|
|
29
27
|
id: 'prefix',
|
|
30
28
|
active: false,
|
|
31
29
|
show: Boolean(prefix),
|
|
32
30
|
render: _a => {
|
|
33
|
-
var
|
|
34
|
-
key
|
|
35
|
-
} = _a,
|
|
31
|
+
var key = _a.key,
|
|
36
32
|
props = __rest(_a, ["key"]);
|
|
37
33
|
return (0, jsx_runtime_1.jsx)("div", Object.assign({}, props, {
|
|
38
34
|
"data-test-id": 'field-prefix',
|
|
@@ -6,11 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useValueControl = useValueControl;
|
|
7
7
|
const uncontrollable_1 = require("uncontrollable");
|
|
8
8
|
function useValueControl(_ref) {
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
defaultValue
|
|
13
|
-
} = _ref;
|
|
9
|
+
let value = _ref.value,
|
|
10
|
+
onChange = _ref.onChange,
|
|
11
|
+
defaultValue = _ref.defaultValue;
|
|
14
12
|
return (0, uncontrollable_1.useUncontrolledProp)(value, defaultValue, newValue => {
|
|
15
13
|
const newState = typeof newValue === 'function' ? newValue(value) : newValue;
|
|
16
14
|
onChange === null || onChange === void 0 ? void 0 : onChange(newState);
|
|
@@ -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
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -50,7 +52,11 @@ function parseDate(value) {
|
|
|
50
52
|
const splittedValue = value.split(', ');
|
|
51
53
|
const date = splittedValue[0];
|
|
52
54
|
let time = splittedValue[1];
|
|
53
|
-
let
|
|
55
|
+
let _date$split$map = date.split('.').map(Number),
|
|
56
|
+
_date$split$map2 = (0, _slicedToArray2.default)(_date$split$map, 3),
|
|
57
|
+
day = _date$split$map2[0],
|
|
58
|
+
month = _date$split$map2[1],
|
|
59
|
+
year = _date$split$map2[2];
|
|
54
60
|
month -= 1;
|
|
55
61
|
if (date.includes(':')) {
|
|
56
62
|
time = date;
|
|
@@ -61,7 +67,14 @@ function parseDate(value) {
|
|
|
61
67
|
month = DATE_STUB.getMonth();
|
|
62
68
|
day = DATE_STUB.getDay();
|
|
63
69
|
}
|
|
64
|
-
const
|
|
70
|
+
const _time$split$map = time.split(':').map(str => Number(str !== null && str !== void 0 ? str : 0)),
|
|
71
|
+
_time$split$map2 = (0, _slicedToArray2.default)(_time$split$map, 3),
|
|
72
|
+
_time$split$map2$ = _time$split$map2[0],
|
|
73
|
+
hours = _time$split$map2$ === void 0 ? 0 : _time$split$map2$,
|
|
74
|
+
_time$split$map2$2 = _time$split$map2[1],
|
|
75
|
+
minutes = _time$split$map2$2 === void 0 ? 0 : _time$split$map2$2,
|
|
76
|
+
_time$split$map2$3 = _time$split$map2[2],
|
|
77
|
+
seconds = _time$split$map2$3 === void 0 ? 0 : _time$split$map2$3;
|
|
65
78
|
return new Date(year, month, day, hours, minutes, seconds);
|
|
66
79
|
}
|
|
67
80
|
return new Date(year, month, day);
|
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getValidationState = getValidationState;
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
8
|
function getValidationState(_ref) {
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
error
|
|
12
|
-
} = _ref;
|
|
9
|
+
let validationState = _ref.validationState,
|
|
10
|
+
error = _ref.error;
|
|
13
11
|
return error ? constants_1.VALIDATION_STATE.Error : validationState !== null && validationState !== void 0 ? validationState : constants_1.VALIDATION_STATE.Default;
|
|
14
12
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Fields",
|
|
7
|
-
"version": "0.57.2
|
|
7
|
+
"version": "0.57.2",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@snack-uikit/button": "0.19.19",
|
|
40
|
-
"@snack-uikit/calendar": "0.14.2
|
|
41
|
-
"@snack-uikit/color-picker": "0.3.58
|
|
40
|
+
"@snack-uikit/calendar": "0.14.2",
|
|
41
|
+
"@snack-uikit/color-picker": "0.3.58",
|
|
42
42
|
"@snack-uikit/divider": "3.2.12",
|
|
43
|
-
"@snack-uikit/dropdown": "0.5.8
|
|
43
|
+
"@snack-uikit/dropdown": "0.5.8",
|
|
44
44
|
"@snack-uikit/icons": "0.27.7",
|
|
45
45
|
"@snack-uikit/input-private": "4.8.9",
|
|
46
|
-
"@snack-uikit/list": "0.33.3
|
|
46
|
+
"@snack-uikit/list": "0.33.3",
|
|
47
47
|
"@snack-uikit/scroll": "0.11.0",
|
|
48
48
|
"@snack-uikit/skeleton": "0.6.11",
|
|
49
|
-
"@snack-uikit/slider": "0.3.39
|
|
50
|
-
"@snack-uikit/tag": "0.15.22
|
|
51
|
-
"@snack-uikit/tooltip": "0.18.15
|
|
52
|
-
"@snack-uikit/truncate-string": "0.7.14
|
|
49
|
+
"@snack-uikit/slider": "0.3.39",
|
|
50
|
+
"@snack-uikit/tag": "0.15.22",
|
|
51
|
+
"@snack-uikit/tooltip": "0.18.15",
|
|
52
|
+
"@snack-uikit/truncate-string": "0.7.14",
|
|
53
53
|
"@snack-uikit/utils": "4.0.2",
|
|
54
54
|
"classnames": "2.5.1",
|
|
55
55
|
"copy-to-clipboard": "3.3.3",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@snack-uikit/locale": "*"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "864821fceaa6bbb61080166d14f1682fa16e3f85"
|
|
70
70
|
}
|