@redsift/design-system 11.6.0 → 11.7.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/_internal/NumberField.js +37 -21
- package/_internal/NumberField.js.map +1 -1
- package/_internal/SideNavigationMenu.js +15 -1
- package/_internal/SideNavigationMenu.js.map +1 -1
- package/_internal/SideNavigationMenuItem.js.map +1 -1
- package/_internal/Spinner2.js +4 -215
- package/_internal/Spinner2.js.map +1 -1
- package/_internal/useAppSidePanel.js +4 -2
- package/_internal/useAppSidePanel.js.map +1 -1
- package/_internal/useLocalizedStringFormatter.js +217 -0
- package/_internal/useLocalizedStringFormatter.js.map +1 -0
- package/_internal/useSideNavigationMenuBar.js +5 -2
- package/_internal/useSideNavigationMenuBar.js.map +1 -1
- package/index.d.ts +5 -2
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/package.json +3 -3
package/_internal/NumberField.js
CHANGED
|
@@ -9,8 +9,9 @@ import { mdiMenuUp, mdiMenuDown } from '@redsift/icons';
|
|
|
9
9
|
import { S as StyledIconButton } from './styles2.js';
|
|
10
10
|
import { a as useSSRSafeId, u as useLocale } from './context2.js';
|
|
11
11
|
import { N as NumberFormatter, u as useNumberFormatter } from './useNumberFormatter.js';
|
|
12
|
-
import { u as
|
|
12
|
+
import { u as useLocalizedStringFormatter } from './useLocalizedStringFormatter.js';
|
|
13
13
|
import { b as useLayoutEffect, i as isFirefox, c as isMac, d as isWebKit, e as isIPad, f as useEffectEvent, g as isIOS, h as getOwnerDocument, j as isVirtualPointerEvent, k as isVirtualClick, l as getOwnerWindow, m as getInteractionModality, n as useFocus, s as setInteractionModality, a as useFocusWithin, o as isIPhone, p as isAndroid, u as useFocusRing } from './useFocusRing.js';
|
|
14
|
+
import { u as useMessageFormatter } from './useMessageFormatter.js';
|
|
14
15
|
import c from 'clsx';
|
|
15
16
|
import { u as useTheme } from './useTheme.js';
|
|
16
17
|
import { a as Icon } from './Icon2.js';
|
|
@@ -2260,6 +2261,7 @@ function useNumberFieldState(props) {
|
|
|
2260
2261
|
}
|
|
2261
2262
|
}
|
|
2262
2263
|
let [numberValue, setNumberValue] = useControlledState(value, isNaN(defaultValue) ? NaN : defaultValue, onChange);
|
|
2264
|
+
let [initialValue] = useState(numberValue);
|
|
2263
2265
|
let [inputValue, setInputValue] = useState(() => isNaN(numberValue) ? '' : new NumberFormatter(locale, formatOptions).format(numberValue));
|
|
2264
2266
|
let numberParser = useMemo(() => new NumberParser(locale, formatOptions), [locale, formatOptions]);
|
|
2265
2267
|
let numberingSystem = useMemo(() => numberParser.getNumberingSystem(inputValue), [numberParser, inputValue]);
|
|
@@ -2315,6 +2317,7 @@ function useNumberFieldState(props) {
|
|
|
2315
2317
|
|
|
2316
2318
|
// in a controlled state, the numberValue won't change, so we won't go back to our old input without help
|
|
2317
2319
|
setInputValue(format(value === undefined ? clampedValue : numberValue));
|
|
2320
|
+
validation.commitValidation();
|
|
2318
2321
|
};
|
|
2319
2322
|
let safeNextStep = function (operation) {
|
|
2320
2323
|
let minMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -2381,6 +2384,7 @@ function useNumberFieldState(props) {
|
|
|
2381
2384
|
minValue,
|
|
2382
2385
|
maxValue,
|
|
2383
2386
|
numberValue: parsedValue,
|
|
2387
|
+
defaultNumberValue: isNaN(defaultValue) ? initialValue : defaultValue,
|
|
2384
2388
|
setNumberValue,
|
|
2385
2389
|
setInputValue,
|
|
2386
2390
|
inputValue,
|
|
@@ -3185,6 +3189,7 @@ const _excluded$1 = ["id", "decrementAriaLabel", "incrementAriaLabel", "isDisabl
|
|
|
3185
3189
|
* Number fields allow users to enter a number, and increment or decrement the value using stepper buttons.
|
|
3186
3190
|
*/
|
|
3187
3191
|
function useNumberField(props, state, inputRef) {
|
|
3192
|
+
var _intlOptions$maximumF;
|
|
3188
3193
|
let {
|
|
3189
3194
|
id,
|
|
3190
3195
|
decrementAriaLabel,
|
|
@@ -3217,7 +3222,7 @@ function useNumberField(props, state, inputRef) {
|
|
|
3217
3222
|
commit,
|
|
3218
3223
|
commitValidation
|
|
3219
3224
|
} = state;
|
|
3220
|
-
const
|
|
3225
|
+
const stringFormatter = useLocalizedStringFormatter(intlMessages$1, '@react-aria/numberfield');
|
|
3221
3226
|
let inputId = useId(id);
|
|
3222
3227
|
let {
|
|
3223
3228
|
focusProps
|
|
@@ -3285,7 +3290,7 @@ function useNumberField(props, state, inputRef) {
|
|
|
3285
3290
|
// Browsers and operating systems are quite inconsistent about what keys are available, however.
|
|
3286
3291
|
// We choose between numeric and decimal based on whether we allow negative and fractional numbers,
|
|
3287
3292
|
// and based on testing on various devices to determine what keys are available in each inputMode.
|
|
3288
|
-
let hasDecimals = intlOptions.maximumFractionDigits > 0;
|
|
3293
|
+
let hasDecimals = ((_intlOptions$maximumF = intlOptions.maximumFractionDigits) !== null && _intlOptions$maximumF !== void 0 ? _intlOptions$maximumF : 0) > 0;
|
|
3289
3294
|
let hasNegative = state.minValue === undefined || isNaN(state.minValue) || state.minValue < 0;
|
|
3290
3295
|
let inputMode = 'numeric';
|
|
3291
3296
|
if (isIPhone()) {
|
|
@@ -3313,6 +3318,9 @@ function useNumberField(props, state, inputRef) {
|
|
|
3313
3318
|
};
|
|
3314
3319
|
let domProps = filterDOMProps(props);
|
|
3315
3320
|
let onKeyDownEnter = useCallback(e => {
|
|
3321
|
+
if (e.nativeEvent.isComposing) {
|
|
3322
|
+
return;
|
|
3323
|
+
}
|
|
3316
3324
|
if (e.key === 'Enter') {
|
|
3317
3325
|
commit();
|
|
3318
3326
|
commitValidation();
|
|
@@ -3331,7 +3339,9 @@ function useNumberField(props, state, inputRef) {
|
|
|
3331
3339
|
descriptionProps,
|
|
3332
3340
|
errorMessageProps
|
|
3333
3341
|
} = useFormattedTextField(_objectSpread2(_objectSpread2(_objectSpread2({}, otherProps), domProps), {}, {
|
|
3342
|
+
// These props are added to a hidden input rather than the formatted textfield.
|
|
3334
3343
|
name: undefined,
|
|
3344
|
+
form: undefined,
|
|
3335
3345
|
label,
|
|
3336
3346
|
autoFocus,
|
|
3337
3347
|
isDisabled,
|
|
@@ -3340,8 +3350,8 @@ function useNumberField(props, state, inputRef) {
|
|
|
3340
3350
|
validate: undefined,
|
|
3341
3351
|
[privateValidationStateProp]: state,
|
|
3342
3352
|
value: inputValue,
|
|
3343
|
-
defaultValue:
|
|
3344
|
-
//
|
|
3353
|
+
defaultValue: '!',
|
|
3354
|
+
// an invalid value so that form reset is ignored in onChange above
|
|
3345
3355
|
autoComplete: 'off',
|
|
3346
3356
|
'aria-label': props['aria-label'] || undefined,
|
|
3347
3357
|
'aria-labelledby': props['aria-labelledby'] || undefined,
|
|
@@ -3358,12 +3368,12 @@ function useNumberField(props, state, inputRef) {
|
|
|
3358
3368
|
description,
|
|
3359
3369
|
errorMessage
|
|
3360
3370
|
}), state, inputRef);
|
|
3361
|
-
useFormReset(inputRef, state.
|
|
3371
|
+
useFormReset(inputRef, state.defaultNumberValue, state.setNumberValue);
|
|
3362
3372
|
let inputProps = mergeProps(spinButtonProps, focusProps, textFieldProps, {
|
|
3363
3373
|
// override the spinbutton role, we can't focus a spin button with VO
|
|
3364
3374
|
role: null,
|
|
3365
3375
|
// ignore aria-roledescription on iOS so that required state will announce when it is present
|
|
3366
|
-
'aria-roledescription': !isIOS() ? format('numberField') : null,
|
|
3376
|
+
'aria-roledescription': !isIOS() ? stringFormatter.format('numberField') : null,
|
|
3367
3377
|
'aria-valuemax': null,
|
|
3368
3378
|
'aria-valuemin': null,
|
|
3369
3379
|
'aria-valuenow': null,
|
|
@@ -3410,7 +3420,7 @@ function useNumberField(props, state, inputRef) {
|
|
|
3410
3420
|
let incrementId = useId();
|
|
3411
3421
|
let decrementId = useId();
|
|
3412
3422
|
let incrementButtonProps = mergeProps(incButtonProps, {
|
|
3413
|
-
'aria-label': incrementAriaLabel || format('increase', {
|
|
3423
|
+
'aria-label': incrementAriaLabel || stringFormatter.format('increase', {
|
|
3414
3424
|
fieldLabel
|
|
3415
3425
|
}).trim(),
|
|
3416
3426
|
id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,
|
|
@@ -3423,7 +3433,7 @@ function useNumberField(props, state, inputRef) {
|
|
|
3423
3433
|
onPressStart: onButtonPressStart
|
|
3424
3434
|
});
|
|
3425
3435
|
let decrementButtonProps = mergeProps(decButtonProps, {
|
|
3426
|
-
'aria-label': decrementAriaLabel || format('decrease', {
|
|
3436
|
+
'aria-label': decrementAriaLabel || stringFormatter.format('decrease', {
|
|
3427
3437
|
fieldLabel
|
|
3428
3438
|
}).trim(),
|
|
3429
3439
|
id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,
|
|
@@ -3755,6 +3765,16 @@ const StyledNumberField = styled.div`
|
|
|
3755
3765
|
border-bottom-right-radius: 4px;
|
|
3756
3766
|
border-bottom-left-radius: 0;
|
|
3757
3767
|
}
|
|
3768
|
+
|
|
3769
|
+
.redsift-number-field-input-wrapper-toolbar__increment-button--disabled,
|
|
3770
|
+
.redsift-number-field-input-wrapper-toolbar__decrement-button--disabled {
|
|
3771
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3774
|
+
.redsift-number-field-input-wrapper-toolbar__increment-button--disabled > .colored,
|
|
3775
|
+
.redsift-number-field-input-wrapper-toolbar__decrement-button--disabled > .colored {
|
|
3776
|
+
color: rgba(0, 0, 0, 0.5);
|
|
3777
|
+
}
|
|
3758
3778
|
}
|
|
3759
3779
|
|
|
3760
3780
|
${$variant !== NumberFieldVariant.underline ? css`
|
|
@@ -3908,21 +3928,17 @@ const NumberField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3908
3928
|
gap: "0",
|
|
3909
3929
|
width: "100%"
|
|
3910
3930
|
}), /*#__PURE__*/React__default.createElement("input", _extends({}, propsInputProps, inputProps, {
|
|
3911
|
-
onChange: event => {
|
|
3912
|
-
if (propsOnChange) {
|
|
3913
|
-
propsOnChange(Number(event.target.value));
|
|
3914
|
-
} else {
|
|
3915
|
-
var _inputProps$onChange;
|
|
3916
|
-
(_inputProps$onChange = inputProps.onChange) === null || _inputProps$onChange === void 0 ? void 0 : _inputProps$onChange.call(inputProps, event);
|
|
3917
|
-
}
|
|
3918
|
-
},
|
|
3919
3931
|
onBlur: event => {
|
|
3932
|
+
var _inputProps$onBlur;
|
|
3920
3933
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
3921
3934
|
onBlurProps === null || onBlurProps === void 0 ? void 0 : onBlurProps(event);
|
|
3935
|
+
(_inputProps$onBlur = inputProps.onBlur) === null || _inputProps$onBlur === void 0 ? void 0 : _inputProps$onBlur.call(inputProps, event);
|
|
3922
3936
|
},
|
|
3923
3937
|
onFocus: event => {
|
|
3938
|
+
var _inputProps$onFocus;
|
|
3924
3939
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
3925
3940
|
onFocusProps === null || onFocusProps === void 0 ? void 0 : onFocusProps(event);
|
|
3941
|
+
(_inputProps$onFocus = inputProps.onFocus) === null || _inputProps$onFocus === void 0 ? void 0 : _inputProps$onFocus.call(inputProps, event);
|
|
3926
3942
|
},
|
|
3927
3943
|
placeholder: placeholder ? `${placeholder}` : undefined,
|
|
3928
3944
|
className: `${NumberField.className}-input-wrapper__input`,
|
|
@@ -3935,28 +3951,28 @@ const NumberField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3935
3951
|
}, /*#__PURE__*/React__default.createElement(StyledIconButton, _extends({
|
|
3936
3952
|
$color: "grey",
|
|
3937
3953
|
$isActive: false,
|
|
3938
|
-
$isDisabled: isDisabled,
|
|
3939
3954
|
$isGradient: false,
|
|
3940
3955
|
$isHovered: false,
|
|
3941
3956
|
$isLoading: false,
|
|
3942
3957
|
$variant: variant === NumberFieldVariant.underline ? 'unstyled' : 'secondary',
|
|
3943
3958
|
$theme: theme
|
|
3944
3959
|
}, incrementButtonForwardedProps, {
|
|
3945
|
-
|
|
3960
|
+
$isDisabled: isDisabled || incrementButtonForwardedProps.disabled,
|
|
3961
|
+
className: `${NumberField.className}-input-wrapper-toolbar__increment-button ${isDisabled || incrementButtonForwardedProps.disabled ? `${NumberField.className}-input-wrapper-toolbar__increment-button--disabled` : ''}`
|
|
3946
3962
|
}), /*#__PURE__*/React__default.createElement(Icon, {
|
|
3947
3963
|
icon: mdiMenuUp,
|
|
3948
3964
|
color: isDisabled ? undefined : 'grey'
|
|
3949
3965
|
})), /*#__PURE__*/React__default.createElement(StyledIconButton, _extends({
|
|
3950
3966
|
$color: "grey",
|
|
3951
3967
|
$isActive: false,
|
|
3952
|
-
$isDisabled: isDisabled,
|
|
3953
3968
|
$isGradient: false,
|
|
3954
3969
|
$isHovered: false,
|
|
3955
3970
|
$isLoading: false,
|
|
3956
3971
|
$variant: variant === NumberFieldVariant.underline ? 'unstyled' : 'secondary',
|
|
3957
3972
|
$theme: theme
|
|
3958
3973
|
}, decrementButtonForwardedProps, {
|
|
3959
|
-
|
|
3974
|
+
$isDisabled: isDisabled || decrementButtonForwardedProps.disabled,
|
|
3975
|
+
className: `${NumberField.className}-input-wrapper-toolbar__decrement-button ${isDisabled || decrementButtonForwardedProps.disabled ? `${NumberField.className}-input-wrapper-toolbar__decrement-button--disabled` : ''}`
|
|
3960
3976
|
}), /*#__PURE__*/React__default.createElement(Icon, {
|
|
3961
3977
|
icon: mdiMenuDown,
|
|
3962
3978
|
color: isDisabled ? undefined : 'grey'
|