@cloud-ru/ds-fields 3.0.8-preview-029c7dbb.0 → 3.0.8-preview-e3402248.0
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/cjs/components/FieldSecure/FieldSecure.js +8 -8
- package/dist/cjs/components/FieldStepper/FieldStepper.js +2 -6
- package/dist/esm/components/FieldSecure/FieldSecure.js +8 -8
- package/dist/esm/components/FieldStepper/FieldStepper.js +2 -6
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/components/FieldSecure/FieldSecure.tsx +9 -9
- package/src/components/FieldStepper/FieldStepper.tsx +2 -10
|
@@ -40,24 +40,24 @@ exports.FieldSecure = (0, react_1.forwardRef)(function FieldSecure({ label = '',
|
|
|
40
40
|
}, [onChange, setValue]);
|
|
41
41
|
const ensureAsyncValue = (0, react_1.useCallback)(async () => {
|
|
42
42
|
if (!asyncValueGetter || isAsyncLoaded) {
|
|
43
|
-
return true;
|
|
43
|
+
return { success: true, value };
|
|
44
44
|
}
|
|
45
45
|
setIsLoading(true);
|
|
46
46
|
try {
|
|
47
47
|
const next = await asyncValueGetter();
|
|
48
48
|
setIsAsyncLoaded(true);
|
|
49
49
|
emitChange(next);
|
|
50
|
-
return true;
|
|
50
|
+
return { success: true, value: next };
|
|
51
51
|
}
|
|
52
52
|
catch {
|
|
53
|
-
return false;
|
|
53
|
+
return { success: false };
|
|
54
54
|
}
|
|
55
55
|
finally {
|
|
56
56
|
setIsLoading(false);
|
|
57
57
|
}
|
|
58
|
-
}, [asyncValueGetter, emitChange, isAsyncLoaded]);
|
|
58
|
+
}, [asyncValueGetter, emitChange, isAsyncLoaded, value]);
|
|
59
59
|
const toggleHidden = (0, react_1.useCallback)(() => {
|
|
60
|
-
ensureAsyncValue().then(success => {
|
|
60
|
+
ensureAsyncValue().then(({ success }) => {
|
|
61
61
|
if (!success) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
@@ -83,13 +83,13 @@ exports.FieldSecure = (0, react_1.forwardRef)(function FieldSecure({ label = '',
|
|
|
83
83
|
const stringValue = String(value ?? '');
|
|
84
84
|
const showCopyUi = Boolean(showCopyButtonProp && stringValue && !disabled && readOnly);
|
|
85
85
|
const showHideUi = Boolean(showHideButtonProp && !(readOnly && !stringValue));
|
|
86
|
-
const onCopy = (0, react_1.useCallback)(() => ensureAsyncValue().then(async (
|
|
87
|
-
const copied = success && (await (0, shared_1.copyTextToClipboard)(
|
|
86
|
+
const onCopy = (0, react_1.useCallback)(() => ensureAsyncValue().then(async (result) => {
|
|
87
|
+
const copied = result.success && (await (0, shared_1.copyTextToClipboard)(result.value));
|
|
88
88
|
if (copied) {
|
|
89
89
|
onCopyButtonClick?.();
|
|
90
90
|
}
|
|
91
91
|
return copied;
|
|
92
|
-
}), [ensureAsyncValue, onCopyButtonClick
|
|
92
|
+
}), [ensureAsyncValue, onCopyButtonClick]);
|
|
93
93
|
const copyButtonSettings = (0, shared_1.useCopyButton)({
|
|
94
94
|
copyButtonRef,
|
|
95
95
|
showCopyButton: showCopyUi,
|
|
@@ -59,7 +59,7 @@ exports.FieldStepper = (0, react_1.forwardRef)(function FieldStepper({ label = '
|
|
|
59
59
|
emitValue((0, utils_2.applyStep)(value, step));
|
|
60
60
|
}, [emitValue, step, value]);
|
|
61
61
|
const handleInputChange = (0, react_1.useCallback)((raw, event) => {
|
|
62
|
-
if (raw === '-') {
|
|
62
|
+
if (raw === '' || raw === '-') {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
const parsed = Number(raw);
|
|
@@ -155,10 +155,6 @@ exports.FieldStepper = (0, react_1.forwardRef)(function FieldStepper({ label = '
|
|
|
155
155
|
readonly: readOnly,
|
|
156
156
|
hover,
|
|
157
157
|
focusVisible,
|
|
158
|
-
}), children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.acrylicBg, "aria-hidden": true }) }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.borderStateLayer, "data-state": 'borderOnBackground' }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.focusLayer })] }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.elementWrapperBefore, children: [renderStepButton('minus'), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.lineWrapper, "data-outline": background || undefined, children: (0, jsx_runtime_1.jsx)(divider_1.Divider, { orientation: 'vertical', variant: 'regular' }) })] }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.fieldContainer, onClick: ()
|
|
159
|
-
if (!disabled && !readOnly && localRef.current) {
|
|
160
|
-
localRef.current.focus();
|
|
161
|
-
}
|
|
162
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.contentWrapper, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.inputLine, styles_module_scss_2.default.inputLine), children: [prefix && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.prefix, children: prefix }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.inputArea, styles_module_scss_2.default.inputArea), children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_2.default.inputWrapper, style: { '--field-stepper-input-ch': inputWidthCh }, children: (0, jsx_runtime_1.jsx)(input_private_1.InputPrivate, { ref: (0, merge_refs_1.default)(ref, localRef), className: (0, classnames_1.default)(styles_module_scss_1.default.fieldInput, styles_module_scss_2.default.input), value: String(value), type: input_private_1.TYPE.Number, disabled: disabled, readonly: readOnly, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleInputKeyDown, id: id, name: name, min: min, max: max, step: step, autoFocus: resolvedAutoFocus, "data-test-id": constants_1.TEST_IDS.fieldStepperInput, ...(0, utils_1.extractSupportProps)(rest) }) }) }), postfix && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.postfix, children: postfix }), showCopyUi && ((0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.postfixButtonsSlot, children: (0, jsx_runtime_1.jsx)(button_1.Button, { innerRef: copyButtonRef, type: 'button', view: 'function', appearance: 'neutral', size: input_private_1.BUTTON_SIZE_MAP[size], icon: copied ? (0, jsx_runtime_1.jsx)(system_1.CheckSVG, {}) : (0, jsx_runtime_1.jsx)(system_1.CopySVG, {}), onClick: handleCopy, onKeyDown: handleCopyButtonKeyDown, tabIndex: -1, "data-test-id": constants_1.TEST_IDS.fieldStepperCopyButton }) }))] }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.elementWrapperAfter, children: [(0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.lineWrapper, "data-outline": background || undefined, children: (0, jsx_runtime_1.jsx)(divider_1.Divider, { orientation: 'vertical', variant: 'regular' }) }), renderStepButton('plus')] })] }));
|
|
158
|
+
}), children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.acrylicBg, "aria-hidden": true }) }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.borderStateLayer, "data-state": 'borderOnBackground' }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.focusLayer })] }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.elementWrapperBefore, children: [renderStepButton('minus'), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.lineWrapper, "data-outline": background || undefined, children: (0, jsx_runtime_1.jsx)(divider_1.Divider, { orientation: 'vertical', variant: 'regular' }) })] }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.fieldContainer, children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.contentWrapper, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.inputLine, styles_module_scss_2.default.inputLine), children: [prefix && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.prefix, children: prefix }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.inputArea, styles_module_scss_2.default.inputArea), children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_2.default.inputWrapper, style: { '--field-stepper-input-ch': inputWidthCh }, children: (0, jsx_runtime_1.jsx)(input_private_1.InputPrivate, { ref: (0, merge_refs_1.default)(ref, localRef), className: (0, classnames_1.default)(styles_module_scss_1.default.fieldInput, styles_module_scss_2.default.input), value: String(value), type: input_private_1.TYPE.Number, disabled: disabled, readonly: readOnly, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleInputKeyDown, id: id, name: name, min: min, max: max, step: step, autoFocus: resolvedAutoFocus, "data-test-id": constants_1.TEST_IDS.fieldStepperInput, ...(0, utils_1.extractSupportProps)(rest) }) }) }), postfix && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.postfix, children: postfix }), showCopyUi && ((0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.postfixButtonsSlot, children: (0, jsx_runtime_1.jsx)(button_1.Button, { innerRef: copyButtonRef, type: 'button', view: 'function', appearance: 'neutral', size: input_private_1.BUTTON_SIZE_MAP[size], icon: copied ? (0, jsx_runtime_1.jsx)(system_1.CheckSVG, {}) : (0, jsx_runtime_1.jsx)(system_1.CopySVG, {}), onClick: handleCopy, onKeyDown: handleCopyButtonKeyDown, tabIndex: -1, "data-test-id": constants_1.TEST_IDS.fieldStepperCopyButton }) }))] }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.elementWrapperAfter, children: [(0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.lineWrapper, "data-outline": background || undefined, children: (0, jsx_runtime_1.jsx)(divider_1.Divider, { orientation: 'vertical', variant: 'regular' }) }), renderStepButton('plus')] })] }));
|
|
163
159
|
return ((0, jsx_runtime_1.jsx)(field_decorator_1.FieldDecorator, { className: className, label: label, labelTooltip: labelTooltip, caption: caption, hint: hint, error: error, validationState: effectiveValidationState, showHintIcon: showHintIcon, length: length, required: required, labelFor: id, disabled: disabled, readonly: readOnly, size: size, "data-test-id": dataTestId, children: clampTooltip ? ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { tip: clampTooltip, open: true, "data-test-id": constants_1.TEST_IDS.fieldStepperLimitTooltip, children: shell })) : (shell) }));
|
|
164
160
|
});
|
|
@@ -34,24 +34,24 @@ export const FieldSecure = forwardRef(function FieldSecure({ label = '', labelTo
|
|
|
34
34
|
}, [onChange, setValue]);
|
|
35
35
|
const ensureAsyncValue = useCallback(async () => {
|
|
36
36
|
if (!asyncValueGetter || isAsyncLoaded) {
|
|
37
|
-
return true;
|
|
37
|
+
return { success: true, value };
|
|
38
38
|
}
|
|
39
39
|
setIsLoading(true);
|
|
40
40
|
try {
|
|
41
41
|
const next = await asyncValueGetter();
|
|
42
42
|
setIsAsyncLoaded(true);
|
|
43
43
|
emitChange(next);
|
|
44
|
-
return true;
|
|
44
|
+
return { success: true, value: next };
|
|
45
45
|
}
|
|
46
46
|
catch {
|
|
47
|
-
return false;
|
|
47
|
+
return { success: false };
|
|
48
48
|
}
|
|
49
49
|
finally {
|
|
50
50
|
setIsLoading(false);
|
|
51
51
|
}
|
|
52
|
-
}, [asyncValueGetter, emitChange, isAsyncLoaded]);
|
|
52
|
+
}, [asyncValueGetter, emitChange, isAsyncLoaded, value]);
|
|
53
53
|
const toggleHidden = useCallback(() => {
|
|
54
|
-
ensureAsyncValue().then(success => {
|
|
54
|
+
ensureAsyncValue().then(({ success }) => {
|
|
55
55
|
if (!success) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
@@ -77,13 +77,13 @@ export const FieldSecure = forwardRef(function FieldSecure({ label = '', labelTo
|
|
|
77
77
|
const stringValue = String(value ?? '');
|
|
78
78
|
const showCopyUi = Boolean(showCopyButtonProp && stringValue && !disabled && readOnly);
|
|
79
79
|
const showHideUi = Boolean(showHideButtonProp && !(readOnly && !stringValue));
|
|
80
|
-
const onCopy = useCallback(() => ensureAsyncValue().then(async (
|
|
81
|
-
const copied = success && (await copyTextToClipboard(
|
|
80
|
+
const onCopy = useCallback(() => ensureAsyncValue().then(async (result) => {
|
|
81
|
+
const copied = result.success && (await copyTextToClipboard(result.value));
|
|
82
82
|
if (copied) {
|
|
83
83
|
onCopyButtonClick?.();
|
|
84
84
|
}
|
|
85
85
|
return copied;
|
|
86
|
-
}), [ensureAsyncValue, onCopyButtonClick
|
|
86
|
+
}), [ensureAsyncValue, onCopyButtonClick]);
|
|
87
87
|
const copyButtonSettings = useCopyButton({
|
|
88
88
|
copyButtonRef,
|
|
89
89
|
showCopyButton: showCopyUi,
|
|
@@ -53,7 +53,7 @@ export const FieldStepper = forwardRef(function FieldStepper({ label = '', label
|
|
|
53
53
|
emitValue(applyStep(value, step));
|
|
54
54
|
}, [emitValue, step, value]);
|
|
55
55
|
const handleInputChange = useCallback((raw, event) => {
|
|
56
|
-
if (raw === '-') {
|
|
56
|
+
if (raw === '' || raw === '-') {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
const parsed = Number(raw);
|
|
@@ -149,10 +149,6 @@ export const FieldStepper = forwardRef(function FieldStepper({ label = '', label
|
|
|
149
149
|
readonly: readOnly,
|
|
150
150
|
hover,
|
|
151
151
|
focusVisible,
|
|
152
|
-
}), children: _jsx("div", { className: fieldStyles.acrylicBg, "aria-hidden": true }) }), _jsx("div", { className: fieldStyles.borderStateLayer, "data-state": 'borderOnBackground' }), _jsx("div", { className: fieldStyles.focusLayer })] }), _jsxs("div", { className: fieldStyles.elementWrapperBefore, children: [renderStepButton('minus'), _jsx("div", { className: fieldStyles.lineWrapper, "data-outline": background || undefined, children: _jsx(Divider, { orientation: 'vertical', variant: 'regular' }) })] }), _jsx("div", { className: fieldStyles.fieldContainer, onClick: ()
|
|
153
|
-
if (!disabled && !readOnly && localRef.current) {
|
|
154
|
-
localRef.current.focus();
|
|
155
|
-
}
|
|
156
|
-
}, children: _jsx("div", { className: fieldStyles.contentWrapper, children: _jsxs("div", { className: cn(fieldStyles.inputLine, styles.inputLine), children: [prefix && _jsx("span", { className: fieldStyles.prefix, children: prefix }), _jsx("div", { className: cn(fieldStyles.inputArea, styles.inputArea), children: _jsx("div", { className: styles.inputWrapper, style: { '--field-stepper-input-ch': inputWidthCh }, children: _jsx(InputPrivate, { ref: mergeRefs(ref, localRef), className: cn(fieldStyles.fieldInput, styles.input), value: String(value), type: TYPE.Number, disabled: disabled, readonly: readOnly, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleInputKeyDown, id: id, name: name, min: min, max: max, step: step, autoFocus: resolvedAutoFocus, "data-test-id": TEST_IDS.fieldStepperInput, ...extractSupportProps(rest) }) }) }), postfix && _jsx("span", { className: fieldStyles.postfix, children: postfix }), showCopyUi && (_jsx("span", { className: fieldStyles.postfixButtonsSlot, children: _jsx(Button, { innerRef: copyButtonRef, type: 'button', view: 'function', appearance: 'neutral', size: BUTTON_SIZE_MAP[size], icon: copied ? _jsx(CheckSVG, {}) : _jsx(CopySVG, {}), onClick: handleCopy, onKeyDown: handleCopyButtonKeyDown, tabIndex: -1, "data-test-id": TEST_IDS.fieldStepperCopyButton }) }))] }) }) }), _jsxs("div", { className: fieldStyles.elementWrapperAfter, children: [_jsx("div", { className: fieldStyles.lineWrapper, "data-outline": background || undefined, children: _jsx(Divider, { orientation: 'vertical', variant: 'regular' }) }), renderStepButton('plus')] })] }));
|
|
152
|
+
}), children: _jsx("div", { className: fieldStyles.acrylicBg, "aria-hidden": true }) }), _jsx("div", { className: fieldStyles.borderStateLayer, "data-state": 'borderOnBackground' }), _jsx("div", { className: fieldStyles.focusLayer })] }), _jsxs("div", { className: fieldStyles.elementWrapperBefore, children: [renderStepButton('minus'), _jsx("div", { className: fieldStyles.lineWrapper, "data-outline": background || undefined, children: _jsx(Divider, { orientation: 'vertical', variant: 'regular' }) })] }), _jsx("div", { className: fieldStyles.fieldContainer, children: _jsx("div", { className: fieldStyles.contentWrapper, children: _jsxs("div", { className: cn(fieldStyles.inputLine, styles.inputLine), children: [prefix && _jsx("span", { className: fieldStyles.prefix, children: prefix }), _jsx("div", { className: cn(fieldStyles.inputArea, styles.inputArea), children: _jsx("div", { className: styles.inputWrapper, style: { '--field-stepper-input-ch': inputWidthCh }, children: _jsx(InputPrivate, { ref: mergeRefs(ref, localRef), className: cn(fieldStyles.fieldInput, styles.input), value: String(value), type: TYPE.Number, disabled: disabled, readonly: readOnly, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleInputKeyDown, id: id, name: name, min: min, max: max, step: step, autoFocus: resolvedAutoFocus, "data-test-id": TEST_IDS.fieldStepperInput, ...extractSupportProps(rest) }) }) }), postfix && _jsx("span", { className: fieldStyles.postfix, children: postfix }), showCopyUi && (_jsx("span", { className: fieldStyles.postfixButtonsSlot, children: _jsx(Button, { innerRef: copyButtonRef, type: 'button', view: 'function', appearance: 'neutral', size: BUTTON_SIZE_MAP[size], icon: copied ? _jsx(CheckSVG, {}) : _jsx(CopySVG, {}), onClick: handleCopy, onKeyDown: handleCopyButtonKeyDown, tabIndex: -1, "data-test-id": TEST_IDS.fieldStepperCopyButton }) }))] }) }) }), _jsxs("div", { className: fieldStyles.elementWrapperAfter, children: [_jsx("div", { className: fieldStyles.lineWrapper, "data-outline": background || undefined, children: _jsx(Divider, { orientation: 'vertical', variant: 'regular' }) }), renderStepButton('plus')] })] }));
|
|
157
153
|
return (_jsx(FieldDecorator, { className: className, label: label, labelTooltip: labelTooltip, caption: caption, hint: hint, error: error, validationState: effectiveValidationState, showHintIcon: showHintIcon, length: length, required: required, labelFor: id, disabled: disabled, readonly: readOnly, size: size, "data-test-id": dataTestId, children: clampTooltip ? (_jsx(Tooltip, { tip: clampTooltip, open: true, "data-test-id": TEST_IDS.fieldStepperLimitTooltip, children: shell })) : (shell) }));
|
|
158
154
|
});
|