@ostack.tech/ui 0.13.2 → 0.14.1
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/chunks/{en-DtnihkTA.js → en-BiTLo8i1.js} +30 -1
- package/dist/chunks/en-BiTLo8i1.js.map +1 -0
- package/dist/locales/en-GB.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/fr-FR.js +29 -0
- package/dist/locales/fr-FR.js.map +1 -1
- package/dist/locales/pt-PT.js +29 -0
- package/dist/locales/pt-PT.js.map +1 -1
- package/dist/ostack-ui.css +5 -0
- package/dist/ostack-ui.js +1924 -656
- package/dist/ostack-ui.js.map +1 -1
- package/dist/types/components/Calendar/Calendar.d.ts +3 -3
- package/dist/types/components/Calendar/calendarUtils.d.ts +4 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +13 -1
- package/dist/types/components/CheckboxGroup/CheckboxGroup.d.ts +13 -1
- package/dist/types/components/CheckboxGroup/CheckboxGroupContext.d.ts +2 -1
- package/dist/types/components/CommandMenu/CommandMenu.d.ts +5 -3
- package/dist/types/components/Control/Control.d.ts +162 -0
- package/dist/types/components/Control/ControlContext.d.ts +13 -0
- package/dist/types/components/Control/ControlWithContainerRef.d.ts +14 -0
- package/dist/types/components/Control/controlUtils.d.ts +4 -0
- package/dist/types/components/Control/index.d.ts +4 -0
- package/dist/types/components/ControlAddon/ControlAddon.d.ts +1 -1
- package/dist/types/components/ControlCode/ControlCode.d.ts +1 -1
- package/dist/types/components/DataTable/DataTableFilter.d.ts +2 -3
- package/dist/types/components/DateInput/DateInput.d.ts +37 -7
- package/dist/types/components/DateRangeInput/DateRangeInput.d.ts +35 -9
- package/dist/types/components/Field/Field.d.ts +3 -13
- package/dist/types/components/Field/FieldContext.d.ts +7 -2
- package/dist/types/components/Field/index.d.ts +1 -1
- package/dist/types/components/Form/Form.d.ts +155 -0
- package/dist/types/components/Form/FormContext.d.ts +85 -0
- package/dist/types/components/Form/FormError.d.ts +28 -0
- package/dist/types/components/Form/FormReset.d.ts +7 -0
- package/dist/types/components/Form/FormState.d.ts +30 -0
- package/dist/types/components/Form/FormSubmit.d.ts +7 -0
- package/dist/types/components/Form/HiddenFormControl.d.ts +8 -0
- package/dist/types/components/Form/formUtils.d.ts +10 -0
- package/dist/types/components/Form/index.d.ts +6 -0
- package/dist/types/components/Form/useRegisterFormControl.d.ts +15 -0
- package/dist/types/components/Form/useResetControlOnFormReset.d.ts +2 -0
- package/dist/types/components/Input/Input.d.ts +22 -106
- package/dist/types/components/Input/index.d.ts +0 -1
- package/dist/types/components/NumericInput/NumericInput.d.ts +16 -15
- package/dist/types/components/NumericInput/numericInputUtils.d.ts +24 -0
- package/dist/types/components/Output/Output.d.ts +3 -3
- package/dist/types/components/RadioGroup/Radio.d.ts +1 -1
- package/dist/types/components/RadioGroup/RadioGroup.d.ts +17 -4
- package/dist/types/components/Select/Select.d.ts +17 -27
- package/dist/types/components/Select/SelectContext.d.ts +1 -1
- package/dist/types/components/Select/SelectNative.d.ts +2 -1
- package/dist/types/components/Stepper/Step.d.ts +1 -1
- package/dist/types/components/Table/Table.d.ts +1 -1
- package/dist/types/components/Table/TableCell.d.ts +1 -1
- package/dist/types/components/Table/TableContext.d.ts +1 -1
- package/dist/types/components/Tabs/Tab.d.ts +1 -1
- package/dist/types/components/Tabs/TabsContext.d.ts +1 -1
- package/dist/types/components/TextArea/TextArea.d.ts +14 -3
- package/dist/types/index.d.ts +2 -1
- package/dist/types/providers/LocalizationProvider/LocalizationObject.d.ts +2 -0
- package/dist/types/utils/setNativeProperty.d.ts +1 -1
- package/dist/types/utils/useConstant.d.ts +1 -1
- package/dist/types/utils/validationUtils.d.ts +4 -0
- package/package.json +5 -5
- package/scss/components/Form/_Form.scss +6 -0
- package/scss/index.scss +1 -0
- package/dist/chunks/en-DtnihkTA.js.map +0 -1
- package/dist/types/components/Input/InputWithContainerRef.d.ts +0 -14
- package/dist/types/utils/control.d.ts +0 -23
package/dist/ostack-ui.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { forwardRef, createContext, useContext, useCallback, useRef, useEffect, useId, useMemo, Children, isValidElement,
|
|
2
|
+
import { forwardRef, createContext, useContext, useCallback, useState, useRef, useEffect, useId, useMemo, useLayoutEffect as useLayoutEffect$2, Children, isValidElement, memo, Fragment as Fragment$1, cloneElement, useImperativeHandle, startTransition, useSyncExternalStore, useDeferredValue, useEffectEvent } from "react";
|
|
3
3
|
import { parseKeybinding, tinykeys } from "tinykeys";
|
|
4
4
|
import fromExponential from "from-exponential";
|
|
5
|
-
import { isValid, isDate, addMonths, isBefore, startOfMonth, isAfter, setMonth, setYear, startOfYear, format,
|
|
5
|
+
import { isValid, isDate, addMonths, isBefore, startOfMonth, isAfter, setMonth, setYear, startOfYear, format, parseISO, max, endOfMonth, min, isWithinInterval, lastDayOfMonth, isSameDay, isEqual, parse, formatISO } from "date-fns";
|
|
6
6
|
import { createStore, useStore as useStore$1, create } from "zustand";
|
|
7
7
|
import { shallow } from "zustand/shallow";
|
|
8
8
|
import { numericFormatter, removeNumericFormat, NumericFormat } from "react-number-format";
|
|
@@ -195,9 +195,7 @@ function isPromiseLike(value) {
|
|
|
195
195
|
return typeof value?.then === "function";
|
|
196
196
|
}
|
|
197
197
|
function useConstant(fn) {
|
|
198
|
-
|
|
199
|
-
ref.current ??= { value: fn() };
|
|
200
|
-
return ref.current.value;
|
|
198
|
+
return useState(fn)[0];
|
|
201
199
|
}
|
|
202
200
|
function useLatestValues(values) {
|
|
203
201
|
const valuesRef = useRef({});
|
|
@@ -848,11 +846,14 @@ function useDataTableColumnLabel() {
|
|
|
848
846
|
function useDataTableColumnLabelId() {
|
|
849
847
|
return useContext(DataTableCellContext)?.columnLabelId ?? null;
|
|
850
848
|
}
|
|
849
|
+
const useLayoutEffect$1 = typeof document !== "undefined" ? useLayoutEffect$2 : () => {
|
|
850
|
+
};
|
|
851
851
|
const FieldContext = createContext(null);
|
|
852
852
|
function useCreateFieldContext() {
|
|
853
853
|
return useConstant(
|
|
854
854
|
() => createStore()(
|
|
855
855
|
subscribeWithSelector((set) => ({
|
|
856
|
+
controlName: void 0,
|
|
856
857
|
controlId: void 0,
|
|
857
858
|
controlTagName: void 0,
|
|
858
859
|
controlFocused: false,
|
|
@@ -891,6 +892,9 @@ function useFieldContext() {
|
|
|
891
892
|
function useFieldStore(selector) {
|
|
892
893
|
return useStore$1(useFieldContext() ?? EMPTY_STORE, selector);
|
|
893
894
|
}
|
|
895
|
+
function useFieldControlName() {
|
|
896
|
+
return useFieldStore((state) => state.controlName);
|
|
897
|
+
}
|
|
894
898
|
function useFieldControlId() {
|
|
895
899
|
return useFieldStore((state) => state.controlId);
|
|
896
900
|
}
|
|
@@ -918,13 +922,13 @@ function useFieldDescriptionIds() {
|
|
|
918
922
|
function useFieldErrorMessageIds() {
|
|
919
923
|
return useFieldStore((state) => state.errorMessageIds);
|
|
920
924
|
}
|
|
921
|
-
function
|
|
925
|
+
function useRegisterFieldControl(controlId, controlTagName, controlCodeId, controlHasCode = false, controlRequired = false, controlStatus = void 0) {
|
|
922
926
|
const prefix = usePrefix();
|
|
923
927
|
const store = useFieldContext();
|
|
924
928
|
const generatedId = useId();
|
|
925
929
|
const actualControlId = controlId ?? prefix(`control-${generatedId}`);
|
|
926
930
|
const actualCodeId = controlHasCode ? controlCodeId ?? prefix(`control-code-${generatedId}`) : void 0;
|
|
927
|
-
|
|
931
|
+
useLayoutEffect$1(() => {
|
|
928
932
|
store?.setState({
|
|
929
933
|
controlId: actualControlId,
|
|
930
934
|
controlTagName,
|
|
@@ -953,6 +957,15 @@ function useSetFieldControl(controlId, controlTagName, controlCodeId, controlHas
|
|
|
953
957
|
codeId: actualCodeId
|
|
954
958
|
};
|
|
955
959
|
}
|
|
960
|
+
function useRegisterFieldName(name) {
|
|
961
|
+
const store = useFieldContext();
|
|
962
|
+
useLayoutEffect$1(() => {
|
|
963
|
+
if (name !== void 0) {
|
|
964
|
+
store?.setState({ controlName: name });
|
|
965
|
+
return () => store?.setState?.({ controlName: void 0 });
|
|
966
|
+
}
|
|
967
|
+
}, [name, store]);
|
|
968
|
+
}
|
|
956
969
|
function useSetFieldControlFocused() {
|
|
957
970
|
const store = useFieldContext();
|
|
958
971
|
return useCallback(
|
|
@@ -986,10 +999,8 @@ function useOnFieldLabelChange(cb, { fireImmediately = true } = {}) {
|
|
|
986
999
|
{ fireImmediately }
|
|
987
1000
|
);
|
|
988
1001
|
return () => {
|
|
989
|
-
if (typeof prevCleanup === "function") {
|
|
990
|
-
prevCleanup();
|
|
991
|
-
}
|
|
992
1002
|
unsubscribe();
|
|
1003
|
+
prevCleanup?.();
|
|
993
1004
|
};
|
|
994
1005
|
}, [cb, fireImmediately, store]);
|
|
995
1006
|
}
|
|
@@ -3525,51 +3536,6 @@ const CalendarDay = memo(function CalendarDay2({
|
|
|
3525
3536
|
children: dayContent
|
|
3526
3537
|
}) : /* @__PURE__ */ jsx("span", { className: classNames.day_button, children: dayContent })) });
|
|
3527
3538
|
});
|
|
3528
|
-
const ControlContext = createContext(null);
|
|
3529
|
-
function useControlContext() {
|
|
3530
|
-
return useContext(ControlContext);
|
|
3531
|
-
}
|
|
3532
|
-
function controlStatusToAccent(status, defaultAccent) {
|
|
3533
|
-
switch (status) {
|
|
3534
|
-
case "valid":
|
|
3535
|
-
return "success";
|
|
3536
|
-
case "invalid":
|
|
3537
|
-
return "danger";
|
|
3538
|
-
case "warned":
|
|
3539
|
-
return "warning";
|
|
3540
|
-
default:
|
|
3541
|
-
return defaultAccent;
|
|
3542
|
-
}
|
|
3543
|
-
}
|
|
3544
|
-
const ControlAddon = forwardRef(
|
|
3545
|
-
function ControlAddon2({
|
|
3546
|
-
asChild,
|
|
3547
|
-
variant = "default",
|
|
3548
|
-
status,
|
|
3549
|
-
muted,
|
|
3550
|
-
readOnly,
|
|
3551
|
-
className,
|
|
3552
|
-
...otherProps
|
|
3553
|
-
}, forwardedRef) {
|
|
3554
|
-
const prefix = usePrefix();
|
|
3555
|
-
const controlContext = useControlContext();
|
|
3556
|
-
const As = asChild ? Slot : "div";
|
|
3557
|
-
return /* @__PURE__ */ jsx(ControlContext.Provider, { value: null, children: /* @__PURE__ */ jsx(
|
|
3558
|
-
As,
|
|
3559
|
-
{
|
|
3560
|
-
className: cx(prefix("control-addon"), className),
|
|
3561
|
-
"data-variant": controlContext?.variant ?? variant,
|
|
3562
|
-
"data-status": controlContext?.status ?? status,
|
|
3563
|
-
"data-muted": boolDataAttr(
|
|
3564
|
-
controlContext?.disabled || controlContext?.softDisabled || muted
|
|
3565
|
-
),
|
|
3566
|
-
"data-readonly": boolDataAttr(controlContext?.readOnly || readOnly),
|
|
3567
|
-
ref: forwardedRef,
|
|
3568
|
-
...otherProps
|
|
3569
|
-
}
|
|
3570
|
-
) });
|
|
3571
|
-
}
|
|
3572
|
-
);
|
|
3573
3539
|
function combineAriaIds(...args) {
|
|
3574
3540
|
const ids = [];
|
|
3575
3541
|
for (const arg of args) {
|
|
@@ -4013,7 +3979,7 @@ const Table = forwardRef(
|
|
|
4013
3979
|
visuallyHiddenCaption ??= label;
|
|
4014
3980
|
const descriptionIds = useFieldDescriptionIds();
|
|
4015
3981
|
const errorMessageIds = useFieldErrorMessageIds();
|
|
4016
|
-
const { generatedId, controlId, codeId } =
|
|
3982
|
+
const { generatedId, controlId, codeId } = useRegisterFieldControl(
|
|
4017
3983
|
containerProps?.id,
|
|
4018
3984
|
"DIV",
|
|
4019
3985
|
void 0,
|
|
@@ -4961,6 +4927,7 @@ function useCreateCheckboxGroupContext({
|
|
|
4961
4927
|
defaultValue,
|
|
4962
4928
|
value,
|
|
4963
4929
|
onValueChange,
|
|
4930
|
+
formOnChange,
|
|
4964
4931
|
name,
|
|
4965
4932
|
required,
|
|
4966
4933
|
loadingDescriptionId,
|
|
@@ -4969,7 +4936,7 @@ function useCreateCheckboxGroupContext({
|
|
|
4969
4936
|
checkboxGroupRef
|
|
4970
4937
|
}) {
|
|
4971
4938
|
const prefix = usePrefix();
|
|
4972
|
-
const latest = useLatestValues({ onValueChange });
|
|
4939
|
+
const latest = useLatestValues({ onValueChange, formOnChange });
|
|
4973
4940
|
const store = useConstant(
|
|
4974
4941
|
() => createStore()(
|
|
4975
4942
|
subscribeWithSelector((set, get) => ({
|
|
@@ -4980,12 +4947,13 @@ function useCreateCheckboxGroupContext({
|
|
|
4980
4947
|
const newValue = checked ? [...get().value, checkboxValue] : get().value.filter((v) => v !== checkboxValue);
|
|
4981
4948
|
set({ value: newValue });
|
|
4982
4949
|
latest.onValueChange?.(newValue);
|
|
4950
|
+
latest.formOnChange(newValue);
|
|
4983
4951
|
}
|
|
4984
4952
|
}
|
|
4985
4953
|
}))
|
|
4986
4954
|
)
|
|
4987
4955
|
);
|
|
4988
|
-
|
|
4956
|
+
useLayoutEffect$1(() => {
|
|
4989
4957
|
if (value !== void 0) {
|
|
4990
4958
|
store.setState({ value });
|
|
4991
4959
|
}
|
|
@@ -5055,6 +5023,429 @@ function useCheckboxGroupDescriptionIds(checkboxId) {
|
|
|
5055
5023
|
);
|
|
5056
5024
|
return isFirstCheckbox ? descriptionIds : void 0;
|
|
5057
5025
|
}
|
|
5026
|
+
const NATIVE_VALIDITY_STATE_KEYS = [
|
|
5027
|
+
"valueMissing",
|
|
5028
|
+
"badInput",
|
|
5029
|
+
"typeMismatch",
|
|
5030
|
+
"patternMismatch",
|
|
5031
|
+
"tooShort",
|
|
5032
|
+
"tooLong",
|
|
5033
|
+
"rangeUnderflow",
|
|
5034
|
+
"rangeOverflow",
|
|
5035
|
+
"stepMismatch"
|
|
5036
|
+
];
|
|
5037
|
+
function isFormValidationErrors(value) {
|
|
5038
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && !isValidElement(value) && value.constructor === Object;
|
|
5039
|
+
}
|
|
5040
|
+
function normalizeFormValidationErrors(errors) {
|
|
5041
|
+
return errors ? Object.keys(errors).reduce((obj, name) => {
|
|
5042
|
+
const nameErrors = arrayifyErrors(errors[name]);
|
|
5043
|
+
if (nameErrors.length > 0) {
|
|
5044
|
+
obj[name] = nameErrors;
|
|
5045
|
+
}
|
|
5046
|
+
return obj;
|
|
5047
|
+
}, {}) : {};
|
|
5048
|
+
}
|
|
5049
|
+
function arrayifyErrors(errors) {
|
|
5050
|
+
return Array.isArray(errors) ? errors.filter(
|
|
5051
|
+
(err) => err != null && err !== "" && typeof err !== "boolean"
|
|
5052
|
+
) : errors == null || errors === "" || typeof errors === "boolean" ? [] : [errors];
|
|
5053
|
+
}
|
|
5054
|
+
const FormContext = createContext(null);
|
|
5055
|
+
function useCreateFormContext({
|
|
5056
|
+
validationMode = "onSubmitThenChange",
|
|
5057
|
+
errorDisplayMode = "first",
|
|
5058
|
+
validate,
|
|
5059
|
+
externalErrors,
|
|
5060
|
+
nativeErrorMessages,
|
|
5061
|
+
disableNativeValidations,
|
|
5062
|
+
onValueChange,
|
|
5063
|
+
formRef,
|
|
5064
|
+
apiRef
|
|
5065
|
+
}) {
|
|
5066
|
+
const latest = useLatestValues({ onValueChange, validate });
|
|
5067
|
+
const store = useConstant(
|
|
5068
|
+
() => createStore()(
|
|
5069
|
+
subscribeWithSelector((set, get) => ({
|
|
5070
|
+
submitting: false,
|
|
5071
|
+
submitCount: 0,
|
|
5072
|
+
queuedValidate: false,
|
|
5073
|
+
elements: {},
|
|
5074
|
+
values: {},
|
|
5075
|
+
validateFns: {},
|
|
5076
|
+
touched: {},
|
|
5077
|
+
dirty: {},
|
|
5078
|
+
nativeErrors: {},
|
|
5079
|
+
formValidateErrors: {},
|
|
5080
|
+
validateErrors: {},
|
|
5081
|
+
submitErrors: {},
|
|
5082
|
+
externalErrors: {},
|
|
5083
|
+
actions: {
|
|
5084
|
+
registerControl: (name, initialValue, validateFn) => {
|
|
5085
|
+
set(({ values, validateFns }) => ({
|
|
5086
|
+
values: { ...values, [name]: initialValue },
|
|
5087
|
+
validateFns: { ...validateFns, [name]: validateFn }
|
|
5088
|
+
}));
|
|
5089
|
+
return () => set(
|
|
5090
|
+
({
|
|
5091
|
+
values: { [name]: _values, ...values },
|
|
5092
|
+
validateFns: { [name]: _validateFns, ...validateFns },
|
|
5093
|
+
touched: { [name]: _touched, ...touched },
|
|
5094
|
+
dirty: { [name]: _dirty, ...dirty },
|
|
5095
|
+
nativeErrors: { [name]: _nativeErrors, ...nativeErrors },
|
|
5096
|
+
formValidateErrors: {
|
|
5097
|
+
[name]: _formValidateErrors,
|
|
5098
|
+
...formValidateErrors
|
|
5099
|
+
},
|
|
5100
|
+
validateErrors: {
|
|
5101
|
+
[name]: _validateErrors,
|
|
5102
|
+
...validateErrors
|
|
5103
|
+
},
|
|
5104
|
+
submitErrors: { [name]: _submitErrors, ...submitErrors },
|
|
5105
|
+
externalErrors: {
|
|
5106
|
+
[name]: _externalErrors,
|
|
5107
|
+
...externalErrors2
|
|
5108
|
+
}
|
|
5109
|
+
}) => ({
|
|
5110
|
+
values,
|
|
5111
|
+
validateFns,
|
|
5112
|
+
touched,
|
|
5113
|
+
dirty,
|
|
5114
|
+
formValidateErrors,
|
|
5115
|
+
nativeErrors,
|
|
5116
|
+
validateErrors,
|
|
5117
|
+
submitErrors,
|
|
5118
|
+
externalErrors: externalErrors2
|
|
5119
|
+
})
|
|
5120
|
+
);
|
|
5121
|
+
},
|
|
5122
|
+
onValueChange: () => {
|
|
5123
|
+
latest.onValueChange?.(get().actions.getValue());
|
|
5124
|
+
},
|
|
5125
|
+
getElement: (name) => (name ? formRef.current?.elements[name] : formRef.current) ?? null,
|
|
5126
|
+
getValue: (name) => name ? get().values[name] : get().values,
|
|
5127
|
+
setValue: (name, value) => set(({ values }) => ({ values: { ...values, [name]: value } })),
|
|
5128
|
+
isTouched: (name = "") => {
|
|
5129
|
+
const names = name === "" ? Object.keys(get().values) : [name];
|
|
5130
|
+
return names.some((name2) => get().touched[name2]);
|
|
5131
|
+
},
|
|
5132
|
+
setTouched: (name = "") => {
|
|
5133
|
+
const names = name === "" ? Object.keys(get().values) : [name];
|
|
5134
|
+
for (const name2 of names) {
|
|
5135
|
+
set(({ touched }) => ({ touched: { ...touched, [name2]: true } }));
|
|
5136
|
+
}
|
|
5137
|
+
},
|
|
5138
|
+
setUntouched: (name = "") => {
|
|
5139
|
+
if (name === "") {
|
|
5140
|
+
set({ touched: {} });
|
|
5141
|
+
} else {
|
|
5142
|
+
set(
|
|
5143
|
+
({ touched: { [name]: _touched, ...touched } }) => ({ touched })
|
|
5144
|
+
);
|
|
5145
|
+
}
|
|
5146
|
+
},
|
|
5147
|
+
isDirty: (name = "") => {
|
|
5148
|
+
const names = name === "" ? Object.keys(get().values) : [name];
|
|
5149
|
+
return names.some((name2) => get().dirty[name2]);
|
|
5150
|
+
},
|
|
5151
|
+
setDirty: (name = "") => {
|
|
5152
|
+
const names = name === "" ? Object.keys(get().values) : [name];
|
|
5153
|
+
for (const name2 of names) {
|
|
5154
|
+
set(({ dirty }) => ({ dirty: { ...dirty, [name2]: true } }));
|
|
5155
|
+
}
|
|
5156
|
+
},
|
|
5157
|
+
setPristine: (name = "") => {
|
|
5158
|
+
if (name === "") {
|
|
5159
|
+
set({ dirty: {} });
|
|
5160
|
+
} else {
|
|
5161
|
+
set(
|
|
5162
|
+
({ dirty: { [name]: _dirty, ...dirty } }) => ({ dirty })
|
|
5163
|
+
);
|
|
5164
|
+
}
|
|
5165
|
+
},
|
|
5166
|
+
isValid: (name) => {
|
|
5167
|
+
const names = name === void 0 ? ["", ...Object.keys(get().values)] : [name];
|
|
5168
|
+
for (const name2 of names) {
|
|
5169
|
+
if (get().nativeErrors[name2]?.length || get().validateErrors[name2]?.length || get().formValidateErrors[name2]?.length || get().submitErrors[name2]?.length || get().externalErrors[name2]?.length) {
|
|
5170
|
+
return false;
|
|
5171
|
+
}
|
|
5172
|
+
}
|
|
5173
|
+
return true;
|
|
5174
|
+
},
|
|
5175
|
+
firstInvalid: () => {
|
|
5176
|
+
for (const name of ["", ...Object.keys(get().values)]) {
|
|
5177
|
+
if (!get().actions.isValid(name)) {
|
|
5178
|
+
return name;
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
return null;
|
|
5182
|
+
},
|
|
5183
|
+
runFormValidate: (formValues) => {
|
|
5184
|
+
const { validate: validate2 } = latest;
|
|
5185
|
+
if (!validate2) return;
|
|
5186
|
+
function setResult(result) {
|
|
5187
|
+
set({
|
|
5188
|
+
formValidateErrors: normalizeFormValidationErrors(
|
|
5189
|
+
isFormValidationErrors(result) ? result : { "": result }
|
|
5190
|
+
)
|
|
5191
|
+
});
|
|
5192
|
+
}
|
|
5193
|
+
const resultOrPromise = validate2(formValues);
|
|
5194
|
+
return isPromiseLike(resultOrPromise) ? resultOrPromise.then(setResult) : setResult(resultOrPromise);
|
|
5195
|
+
},
|
|
5196
|
+
validate: (name) => {
|
|
5197
|
+
const names = name === void 0 ? ["", ...Object.keys(get().values)] : [name];
|
|
5198
|
+
const validateResults = names.map(
|
|
5199
|
+
(name2) => name2 === "" ? get().actions.runFormValidate(get().actions.getValue()) : get().validateFns[name2]?.(get().actions.getValue(name2))
|
|
5200
|
+
);
|
|
5201
|
+
return validateResults.some((res) => isPromiseLike(res)) ? Promise.all(validateResults).then(
|
|
5202
|
+
() => get().actions.isValid(name)
|
|
5203
|
+
) : get().actions.isValid(name);
|
|
5204
|
+
},
|
|
5205
|
+
queueValidate: () => {
|
|
5206
|
+
if (get().queuedValidate) return;
|
|
5207
|
+
set({ queuedValidate: true });
|
|
5208
|
+
void Promise.resolve().then(() => {
|
|
5209
|
+
set({ queuedValidate: false });
|
|
5210
|
+
void get().actions.validate();
|
|
5211
|
+
});
|
|
5212
|
+
},
|
|
5213
|
+
setNativeErrors: (name, errors) => set(({ nativeErrors }) => ({
|
|
5214
|
+
nativeErrors: { ...nativeErrors, [name]: errors }
|
|
5215
|
+
})),
|
|
5216
|
+
setValidateErrors: (name, errors) => set(({ validateErrors }) => ({
|
|
5217
|
+
validateErrors: {
|
|
5218
|
+
...validateErrors,
|
|
5219
|
+
[name]: arrayifyErrors(errors)
|
|
5220
|
+
}
|
|
5221
|
+
})),
|
|
5222
|
+
clearSubmitErrors: (name) => {
|
|
5223
|
+
if (name === void 0) {
|
|
5224
|
+
set({ submitErrors: {} });
|
|
5225
|
+
} else {
|
|
5226
|
+
set(
|
|
5227
|
+
({
|
|
5228
|
+
submitErrors: { [name]: _submitErrors, ...submitErrors }
|
|
5229
|
+
}) => ({ submitErrors })
|
|
5230
|
+
);
|
|
5231
|
+
}
|
|
5232
|
+
},
|
|
5233
|
+
clearExternalErrors: (name) => {
|
|
5234
|
+
if (name === void 0) {
|
|
5235
|
+
set({ externalErrors: {} });
|
|
5236
|
+
} else {
|
|
5237
|
+
set(
|
|
5238
|
+
({
|
|
5239
|
+
externalErrors: {
|
|
5240
|
+
[name]: _externalErrors,
|
|
5241
|
+
...externalErrors2
|
|
5242
|
+
}
|
|
5243
|
+
}) => ({ externalErrors: externalErrors2 })
|
|
5244
|
+
);
|
|
5245
|
+
}
|
|
5246
|
+
},
|
|
5247
|
+
focus: (name) => {
|
|
5248
|
+
if (name) {
|
|
5249
|
+
let el = get().actions.getElement(name);
|
|
5250
|
+
if (el instanceof RadioNodeList) {
|
|
5251
|
+
el = el[0];
|
|
5252
|
+
}
|
|
5253
|
+
if (el instanceof HTMLElement) {
|
|
5254
|
+
el.focus();
|
|
5255
|
+
}
|
|
5256
|
+
} else {
|
|
5257
|
+
formRef.current?.scrollIntoView();
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5261
|
+
}))
|
|
5262
|
+
)
|
|
5263
|
+
);
|
|
5264
|
+
const actions = useStore$1(store, ({ actions: actions2 }) => actions2);
|
|
5265
|
+
useImperativeHandle(apiRef, () => buildFormApi(actions));
|
|
5266
|
+
useLayoutEffect$1(() => {
|
|
5267
|
+
store.setState({
|
|
5268
|
+
externalErrors: normalizeFormValidationErrors(externalErrors)
|
|
5269
|
+
});
|
|
5270
|
+
return () => store.setState({ externalErrors: {} });
|
|
5271
|
+
}, [externalErrors, store]);
|
|
5272
|
+
return useMemo(
|
|
5273
|
+
() => ({
|
|
5274
|
+
validationMode,
|
|
5275
|
+
errorDisplayMode,
|
|
5276
|
+
nativeErrorMessages,
|
|
5277
|
+
disableNativeValidations,
|
|
5278
|
+
store
|
|
5279
|
+
}),
|
|
5280
|
+
[
|
|
5281
|
+
disableNativeValidations,
|
|
5282
|
+
errorDisplayMode,
|
|
5283
|
+
nativeErrorMessages,
|
|
5284
|
+
store,
|
|
5285
|
+
validationMode
|
|
5286
|
+
]
|
|
5287
|
+
);
|
|
5288
|
+
}
|
|
5289
|
+
function useFormContext() {
|
|
5290
|
+
const formContext = useContext(FormContext);
|
|
5291
|
+
if (!formContext) {
|
|
5292
|
+
throw new Error("Form context not in scope.");
|
|
5293
|
+
}
|
|
5294
|
+
return formContext;
|
|
5295
|
+
}
|
|
5296
|
+
function buildFormApi(actions) {
|
|
5297
|
+
return {
|
|
5298
|
+
getElement: actions.getElement,
|
|
5299
|
+
getValue: actions.getValue,
|
|
5300
|
+
isTouched: actions.isTouched,
|
|
5301
|
+
setTouched: actions.setTouched,
|
|
5302
|
+
setUntouched: actions.setUntouched,
|
|
5303
|
+
isDirty: actions.isDirty,
|
|
5304
|
+
setDirty: actions.setDirty,
|
|
5305
|
+
setPristine: actions.setPristine,
|
|
5306
|
+
isValid: actions.isValid,
|
|
5307
|
+
validate: actions.validate,
|
|
5308
|
+
clearSubmitErrors: actions.clearSubmitErrors,
|
|
5309
|
+
clearExternalErrors: actions.clearExternalErrors,
|
|
5310
|
+
focus: actions.focus
|
|
5311
|
+
};
|
|
5312
|
+
}
|
|
5313
|
+
function useFormApi() {
|
|
5314
|
+
const { store } = useFormContext();
|
|
5315
|
+
return useStore$1(
|
|
5316
|
+
store,
|
|
5317
|
+
useShallow(({ actions }) => buildFormApi(actions))
|
|
5318
|
+
);
|
|
5319
|
+
}
|
|
5320
|
+
function useFormValue(name) {
|
|
5321
|
+
const { store } = useFormContext();
|
|
5322
|
+
return useStore$1(
|
|
5323
|
+
store,
|
|
5324
|
+
useShallow(({ actions }) => actions.getValue(name))
|
|
5325
|
+
);
|
|
5326
|
+
}
|
|
5327
|
+
function useFormSubmitting() {
|
|
5328
|
+
const { store } = useFormContext();
|
|
5329
|
+
return useStore$1(store, ({ submitting }) => submitting);
|
|
5330
|
+
}
|
|
5331
|
+
function useFormState(name) {
|
|
5332
|
+
const { store } = useFormContext();
|
|
5333
|
+
return useStore$1(
|
|
5334
|
+
store,
|
|
5335
|
+
useShallow(({ submitting, submitCount, actions }) => ({
|
|
5336
|
+
submitting,
|
|
5337
|
+
submitCount,
|
|
5338
|
+
element: actions.getElement(name),
|
|
5339
|
+
value: actions.getValue(name),
|
|
5340
|
+
touched: actions.isTouched(name),
|
|
5341
|
+
dirty: actions.isDirty(name),
|
|
5342
|
+
valid: actions.isValid(name)
|
|
5343
|
+
}))
|
|
5344
|
+
);
|
|
5345
|
+
}
|
|
5346
|
+
function useRegisterFormControl(name, initialValue, validate, validationMode) {
|
|
5347
|
+
const formContext = useContext(FormContext);
|
|
5348
|
+
const store = formContext?.store ?? EMPTY_STORE;
|
|
5349
|
+
validationMode ??= formContext?.validationMode ?? "onSubmitThenChange";
|
|
5350
|
+
const disableNativeValidations = formContext?.disableNativeValidations;
|
|
5351
|
+
useRegisterFieldName(name);
|
|
5352
|
+
const latest = useLatestValues({ disableNativeValidations, validate });
|
|
5353
|
+
const validateControl = useCallback(
|
|
5354
|
+
(value) => {
|
|
5355
|
+
const { actions } = store.getState();
|
|
5356
|
+
if (!name || !actions) return;
|
|
5357
|
+
const el = actions.getElement(name);
|
|
5358
|
+
const els = (el instanceof RadioNodeList ? Array.from(el) : [el]).filter(
|
|
5359
|
+
(el2) => el2?.willValidate === true
|
|
5360
|
+
);
|
|
5361
|
+
if (els.length > 0) {
|
|
5362
|
+
if (!latest.disableNativeValidations) {
|
|
5363
|
+
const seenNativeErrors = /* @__PURE__ */ new Set();
|
|
5364
|
+
const nativeErrors = [];
|
|
5365
|
+
for (const el2 of els) {
|
|
5366
|
+
for (const key of NATIVE_VALIDITY_STATE_KEYS) {
|
|
5367
|
+
if (el2.validity[key] && !seenNativeErrors.has(key)) {
|
|
5368
|
+
nativeErrors.push({ key, element: el2 });
|
|
5369
|
+
}
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
actions.setNativeErrors(name, nativeErrors);
|
|
5373
|
+
}
|
|
5374
|
+
const validate2 = latest.validate;
|
|
5375
|
+
if (validate2) {
|
|
5376
|
+
let setResult = function(result) {
|
|
5377
|
+
actions.setValidateErrors(name, result);
|
|
5378
|
+
};
|
|
5379
|
+
const resultOrPromise = validate2(value, actions.getValue());
|
|
5380
|
+
return isPromiseLike(resultOrPromise) ? resultOrPromise.then(setResult) : setResult(resultOrPromise);
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
},
|
|
5384
|
+
[latest, name, store]
|
|
5385
|
+
);
|
|
5386
|
+
const initialValueRef = useRef(initialValue);
|
|
5387
|
+
useEffect(() => {
|
|
5388
|
+
const { actions } = store.getState();
|
|
5389
|
+
if (!name || !actions) return;
|
|
5390
|
+
const unregisterControl = actions.registerControl(
|
|
5391
|
+
name,
|
|
5392
|
+
initialValueRef.current,
|
|
5393
|
+
validateControl
|
|
5394
|
+
);
|
|
5395
|
+
if (validationMode === "onChange") {
|
|
5396
|
+
actions.queueValidate();
|
|
5397
|
+
}
|
|
5398
|
+
return unregisterControl;
|
|
5399
|
+
}, [name, store, validateControl, validationMode]);
|
|
5400
|
+
const setValue = useCallback(
|
|
5401
|
+
(value) => {
|
|
5402
|
+
const { actions } = store.getState();
|
|
5403
|
+
if (!name || !actions) return;
|
|
5404
|
+
actions.setValue(name, value);
|
|
5405
|
+
},
|
|
5406
|
+
[name, store]
|
|
5407
|
+
);
|
|
5408
|
+
const handleChange = useCallback(
|
|
5409
|
+
(value) => {
|
|
5410
|
+
const { submitCount, actions } = store.getState();
|
|
5411
|
+
if (!name || !actions) return;
|
|
5412
|
+
actions.setValue(name, value);
|
|
5413
|
+
actions.setDirty(name);
|
|
5414
|
+
actions.clearSubmitErrors(name);
|
|
5415
|
+
if (validationMode === "onChange" || validationMode === "onSubmitThenChange" && submitCount !== 0) {
|
|
5416
|
+
actions.queueValidate();
|
|
5417
|
+
}
|
|
5418
|
+
actions.onValueChange();
|
|
5419
|
+
},
|
|
5420
|
+
[name, store, validationMode]
|
|
5421
|
+
);
|
|
5422
|
+
const handleBlur = useCallback(() => {
|
|
5423
|
+
const { submitCount, actions } = store.getState();
|
|
5424
|
+
if (!name || !actions) return;
|
|
5425
|
+
actions.setTouched(name);
|
|
5426
|
+
if (validationMode === "onBlur" || validationMode === "onSubmitThenBlur" && submitCount !== 0) {
|
|
5427
|
+
actions.validate();
|
|
5428
|
+
}
|
|
5429
|
+
}, [name, store, validationMode]);
|
|
5430
|
+
const showInvalid = useStore$1(
|
|
5431
|
+
store,
|
|
5432
|
+
({ actions }) => Boolean(name && actions?.isTouched(name) && !actions.isValid(name))
|
|
5433
|
+
);
|
|
5434
|
+
const submitting = useStore$1(
|
|
5435
|
+
store,
|
|
5436
|
+
({ submitting: submitting2 }) => name && submitting2 || false
|
|
5437
|
+
);
|
|
5438
|
+
return useMemo(
|
|
5439
|
+
() => ({
|
|
5440
|
+
status: showInvalid ? "invalid" : void 0,
|
|
5441
|
+
disabled: submitting,
|
|
5442
|
+
setValue,
|
|
5443
|
+
onChange: handleChange,
|
|
5444
|
+
onBlur: handleBlur
|
|
5445
|
+
}),
|
|
5446
|
+
[handleBlur, handleChange, setValue, showInvalid, submitting]
|
|
5447
|
+
);
|
|
5448
|
+
}
|
|
5058
5449
|
const NATIVE_CONTROLS = /* @__PURE__ */ new Set([
|
|
5059
5450
|
"BUTTON",
|
|
5060
5451
|
"INPUT",
|
|
@@ -5192,6 +5583,8 @@ const Checkbox = forwardRef(function Checkbox2({
|
|
|
5192
5583
|
loadingDescription,
|
|
5193
5584
|
showSpinner = loading,
|
|
5194
5585
|
onBlurToOutside,
|
|
5586
|
+
validate,
|
|
5587
|
+
validationMode,
|
|
5195
5588
|
children,
|
|
5196
5589
|
rootProps,
|
|
5197
5590
|
containerProps,
|
|
@@ -5226,7 +5619,27 @@ const Checkbox = forwardRef(function Checkbox2({
|
|
|
5226
5619
|
const dataTableColumnLabelId = useDataTableColumnLabelId();
|
|
5227
5620
|
const descriptionIds = useFieldDescriptionIds();
|
|
5228
5621
|
const errorMessageIds = useFieldErrorMessageIds();
|
|
5229
|
-
const
|
|
5622
|
+
const containerRef = useRef(null);
|
|
5623
|
+
const labelRef = useRef(null);
|
|
5624
|
+
const isInTableCell = useIsInTableCell();
|
|
5625
|
+
const [checkedInGroup, setCheckedInGroup] = useIsCheckedInGroup(
|
|
5626
|
+
String(value ?? "")
|
|
5627
|
+
);
|
|
5628
|
+
const [checked, setChecked] = useControllableState(
|
|
5629
|
+
defaultChecked ?? false,
|
|
5630
|
+
checkedInGroup ?? controlledChecked
|
|
5631
|
+
);
|
|
5632
|
+
const {
|
|
5633
|
+
status: formStatus,
|
|
5634
|
+
disabled: formDisabled,
|
|
5635
|
+
onChange: formOnChange,
|
|
5636
|
+
onBlur: formOnBlur
|
|
5637
|
+
} = useRegisterFormControl(name, checked, validate, validationMode);
|
|
5638
|
+
const checkboxVariant = variant ?? (isInTableCell ? "cell" : "default");
|
|
5639
|
+
status = controlContext?.status ?? status ?? formStatus;
|
|
5640
|
+
disabled = controlContext?.disabled || disabled || formDisabled;
|
|
5641
|
+
readOnly = controlContext?.readOnly || readOnly;
|
|
5642
|
+
const { generatedId, controlId, codeId } = useRegisterFieldControl(
|
|
5230
5643
|
id,
|
|
5231
5644
|
"BUTTON",
|
|
5232
5645
|
codeProps?.id,
|
|
@@ -5237,22 +5650,8 @@ const Checkbox = forwardRef(function Checkbox2({
|
|
|
5237
5650
|
const labelId = children && (labelProps?.id ?? prefix(`checkbox-label-${generatedId}`));
|
|
5238
5651
|
const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
|
|
5239
5652
|
const checkboxRef = useRef(null);
|
|
5240
|
-
const containerRef = useRef(null);
|
|
5241
|
-
const labelRef = useRef(null);
|
|
5242
|
-
const isInTableCell = useIsInTableCell();
|
|
5243
|
-
const checkboxVariant = variant ?? (isInTableCell ? "cell" : "default");
|
|
5244
|
-
status = controlContext?.status ?? status;
|
|
5245
|
-
disabled = controlContext?.disabled || disabled;
|
|
5246
|
-
readOnly = controlContext?.readOnly || readOnly;
|
|
5247
5653
|
const requiredInGroup = useIsRequiredInGroup();
|
|
5248
5654
|
const groupDescriptionIds = useCheckboxGroupDescriptionIds(controlId);
|
|
5249
|
-
const [checkedInGroup, setCheckedInGroup] = useIsCheckedInGroup(
|
|
5250
|
-
String(value ?? "")
|
|
5251
|
-
);
|
|
5252
|
-
const [checked, setChecked] = useControllableState(
|
|
5253
|
-
defaultChecked ?? false,
|
|
5254
|
-
checkedInGroup ?? controlledChecked
|
|
5255
|
-
);
|
|
5256
5655
|
const softDisabled = controlContext?.softDisabled || loading || ariaDisabled === "true" || ariaDisabled === true;
|
|
5257
5656
|
const handleCheckedChange = useCallback(
|
|
5258
5657
|
(state) => {
|
|
@@ -5260,9 +5659,17 @@ const Checkbox = forwardRef(function Checkbox2({
|
|
|
5260
5659
|
onCheckedChange?.(state);
|
|
5261
5660
|
setChecked(state);
|
|
5262
5661
|
setCheckedInGroup?.(state === true);
|
|
5662
|
+
formOnChange(state);
|
|
5263
5663
|
}
|
|
5264
5664
|
},
|
|
5265
|
-
[
|
|
5665
|
+
[
|
|
5666
|
+
softDisabled,
|
|
5667
|
+
readOnly,
|
|
5668
|
+
onCheckedChange,
|
|
5669
|
+
setChecked,
|
|
5670
|
+
setCheckedInGroup,
|
|
5671
|
+
formOnChange
|
|
5672
|
+
]
|
|
5266
5673
|
);
|
|
5267
5674
|
const setFieldControlFocused = useSetFieldControlFocused();
|
|
5268
5675
|
const handleFocus = useCallback(() => {
|
|
@@ -5271,13 +5678,19 @@ const Checkbox = forwardRef(function Checkbox2({
|
|
|
5271
5678
|
const handleBlur = useCallback(() => {
|
|
5272
5679
|
setFieldControlFocused(false);
|
|
5273
5680
|
}, [setFieldControlFocused]);
|
|
5681
|
+
const handleContainerFocus = (evt) => {
|
|
5682
|
+
if (evt.target.tagName === "INPUT" && evt.target.type === "checkbox" && containerRef.current?.contains(evt.target)) {
|
|
5683
|
+
checkboxRef.current?.focus();
|
|
5684
|
+
}
|
|
5685
|
+
};
|
|
5274
5686
|
const handleContainerBlur = useCallback(
|
|
5275
5687
|
(evt) => {
|
|
5276
|
-
if (
|
|
5277
|
-
onBlurToOutside(evt);
|
|
5688
|
+
if (!evt.relatedTarget || !containerRef.current?.contains(evt.relatedTarget)) {
|
|
5689
|
+
onBlurToOutside?.(evt);
|
|
5690
|
+
formOnBlur();
|
|
5278
5691
|
}
|
|
5279
5692
|
},
|
|
5280
|
-
[onBlurToOutside]
|
|
5693
|
+
[formOnBlur, onBlurToOutside]
|
|
5281
5694
|
);
|
|
5282
5695
|
const handleLabelMouseDown = useCallback(() => {
|
|
5283
5696
|
const labelEl = labelRef.current;
|
|
@@ -5345,6 +5758,10 @@ const Checkbox = forwardRef(function Checkbox2({
|
|
|
5345
5758
|
containerProps?.onBlur,
|
|
5346
5759
|
handleContainerBlur
|
|
5347
5760
|
),
|
|
5761
|
+
onFocus: combineEventHandlers(
|
|
5762
|
+
handleContainerFocus,
|
|
5763
|
+
containerProps?.onFocus
|
|
5764
|
+
),
|
|
5348
5765
|
ref: combinedContainerRef,
|
|
5349
5766
|
children: [
|
|
5350
5767
|
/* @__PURE__ */ jsx(
|
|
@@ -5948,8 +6365,6 @@ const DataTableBody = forwardRef(function DataTableBody2({ emptyMessage, emptyMe
|
|
|
5948
6365
|
!isEmptyOrLoading && (displayMode === "paged" ? /* @__PURE__ */ jsx(PagedDataTableRows, {}) : /* @__PURE__ */ jsx(ScrolledDataTableRows, { scrollableRef }))
|
|
5949
6366
|
] });
|
|
5950
6367
|
});
|
|
5951
|
-
const useLayoutEffect$1 = typeof document !== "undefined" ? useLayoutEffect$2 : () => {
|
|
5952
|
-
};
|
|
5953
6368
|
function useMeasure(element, setMeasurement) {
|
|
5954
6369
|
useLayoutEffect$1(() => {
|
|
5955
6370
|
if (!element) {
|
|
@@ -6206,6 +6621,49 @@ const DataTableContent = forwardRef(function DataTable2({
|
|
|
6206
6621
|
}
|
|
6207
6622
|
);
|
|
6208
6623
|
});
|
|
6624
|
+
const Input$1 = forwardRef(
|
|
6625
|
+
function Input2({
|
|
6626
|
+
type,
|
|
6627
|
+
multiple,
|
|
6628
|
+
name,
|
|
6629
|
+
defaultValue,
|
|
6630
|
+
value,
|
|
6631
|
+
status,
|
|
6632
|
+
disabled,
|
|
6633
|
+
validate,
|
|
6634
|
+
validationMode,
|
|
6635
|
+
onValueChange,
|
|
6636
|
+
onBlurToOutside,
|
|
6637
|
+
...otherProps
|
|
6638
|
+
}, forwardedRef) {
|
|
6639
|
+
const initialValue = type === "file" ? multiple ? [] : null : (value ?? defaultValue)?.toString() ?? "";
|
|
6640
|
+
const formControl = useRegisterFormControl(
|
|
6641
|
+
name,
|
|
6642
|
+
initialValue,
|
|
6643
|
+
validate,
|
|
6644
|
+
validationMode
|
|
6645
|
+
);
|
|
6646
|
+
return /* @__PURE__ */ jsx(
|
|
6647
|
+
Control,
|
|
6648
|
+
{
|
|
6649
|
+
...otherProps,
|
|
6650
|
+
type,
|
|
6651
|
+
multiple,
|
|
6652
|
+
name,
|
|
6653
|
+
defaultValue,
|
|
6654
|
+
value,
|
|
6655
|
+
status: status ?? formControl.status,
|
|
6656
|
+
disabled: disabled || formControl.disabled,
|
|
6657
|
+
onValueChange: combineEventHandlers(formControl.onChange, onValueChange),
|
|
6658
|
+
onBlurToOutside: combineEventHandlers(
|
|
6659
|
+
formControl.onBlur,
|
|
6660
|
+
onBlurToOutside
|
|
6661
|
+
),
|
|
6662
|
+
ref: forwardedRef
|
|
6663
|
+
}
|
|
6664
|
+
);
|
|
6665
|
+
}
|
|
6666
|
+
);
|
|
6209
6667
|
const DataTableFilter = forwardRef(function DataTableFilter2({
|
|
6210
6668
|
preferRightAlignment = true,
|
|
6211
6669
|
endAdornment = /* @__PURE__ */ jsx(ControlAddon, { children: /* @__PURE__ */ jsx(Icon, { icon: faSearch }) }),
|
|
@@ -6493,334 +6951,393 @@ const DataTableSelectionTrigger = forwardRef(function DataTableSelectionTrigger2
|
|
|
6493
6951
|
}
|
|
6494
6952
|
);
|
|
6495
6953
|
});
|
|
6496
|
-
const
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6954
|
+
const ControlContext = createContext(null);
|
|
6955
|
+
function useControlContext() {
|
|
6956
|
+
return useContext(ControlContext);
|
|
6957
|
+
}
|
|
6958
|
+
function controlStatusToAccent(status, defaultAccent) {
|
|
6959
|
+
switch (status) {
|
|
6960
|
+
case "valid":
|
|
6961
|
+
return "success";
|
|
6962
|
+
case "invalid":
|
|
6963
|
+
return "danger";
|
|
6964
|
+
case "warned":
|
|
6965
|
+
return "warning";
|
|
6966
|
+
default:
|
|
6967
|
+
return defaultAccent;
|
|
6968
|
+
}
|
|
6969
|
+
}
|
|
6970
|
+
const REQUIRED_TAGS = ["INPUT", "SELECT", "TEXTAREA"];
|
|
6971
|
+
const READ_ONLY_TAGS = ["INPUT", "TEXTAREA"];
|
|
6972
|
+
const NON_READONLY_INPUT_TYPES = ["file", "color"];
|
|
6973
|
+
const Control = forwardRef(function Control2({
|
|
6974
|
+
asChild,
|
|
6975
|
+
type,
|
|
6976
|
+
defaultValue,
|
|
6977
|
+
value,
|
|
6978
|
+
variant,
|
|
6979
|
+
status,
|
|
6980
|
+
code,
|
|
6981
|
+
loading,
|
|
6982
|
+
loadingDescription,
|
|
6983
|
+
showSpinner = loading,
|
|
6984
|
+
align,
|
|
6985
|
+
startAdornment,
|
|
6986
|
+
endAdornment,
|
|
6987
|
+
showClearButton = type === "file" || type === "search" ? "auto" : void 0,
|
|
6988
|
+
clearDescription,
|
|
6989
|
+
clearButtonLabel,
|
|
6990
|
+
onValueChange,
|
|
6991
|
+
onBlurToOutside,
|
|
6992
|
+
rootProps,
|
|
6993
|
+
codeProps,
|
|
6994
|
+
containerProps,
|
|
6995
|
+
clearButtonProps,
|
|
6996
|
+
spinnerProps,
|
|
6997
|
+
name,
|
|
6998
|
+
id,
|
|
6999
|
+
className,
|
|
7000
|
+
required,
|
|
7001
|
+
disabled,
|
|
7002
|
+
readOnly,
|
|
7003
|
+
style,
|
|
7004
|
+
onChange,
|
|
7005
|
+
onFocus,
|
|
7006
|
+
onBlur,
|
|
7007
|
+
onClick,
|
|
7008
|
+
"aria-disabled": ariaDisabled,
|
|
7009
|
+
"aria-label": ariaLabel,
|
|
7010
|
+
"aria-labelledby": ariaLabelledBy,
|
|
7011
|
+
"aria-describedby": ariaDescribedBy,
|
|
7012
|
+
...otherProps
|
|
7013
|
+
}, forwardedRef) {
|
|
7014
|
+
const prefix = usePrefix();
|
|
7015
|
+
const [locale7] = useLocale();
|
|
7016
|
+
loadingDescription ??= locale7.Input.loadingDescription;
|
|
7017
|
+
clearButtonLabel ??= locale7.Input.clearButtonLabel;
|
|
7018
|
+
const { responsiveValuesToCssVarsAndDataAttrs } = useResponsiveValues();
|
|
7019
|
+
const labelId = useFieldLabelId();
|
|
7020
|
+
const dataTableColumnLabelId = useDataTableColumnLabelId();
|
|
7021
|
+
const descriptionIds = useFieldDescriptionIds();
|
|
7022
|
+
const errorMessageIds = useFieldErrorMessageIds();
|
|
7023
|
+
const { printHidden } = usePrintClassNames();
|
|
7024
|
+
const [controlEl, setControlEl] = useState(null);
|
|
7025
|
+
const tagName = controlEl?.tagName;
|
|
7026
|
+
const { generatedId, controlId, codeId } = useRegisterFieldControl(
|
|
6524
7027
|
id,
|
|
6525
|
-
|
|
7028
|
+
tagName,
|
|
7029
|
+
codeProps?.id,
|
|
7030
|
+
Boolean(code),
|
|
6526
7031
|
required,
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
const [inputEl, setInputEl] = useState(null);
|
|
6551
|
-
const tagName = inputEl?.tagName;
|
|
6552
|
-
const { generatedId, controlId, codeId } = useSetFieldControl(
|
|
6553
|
-
id,
|
|
6554
|
-
tagName,
|
|
6555
|
-
codeProps?.id,
|
|
6556
|
-
Boolean(code),
|
|
6557
|
-
required,
|
|
6558
|
-
status
|
|
6559
|
-
);
|
|
6560
|
-
const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
|
|
6561
|
-
const containerRef = useRef(null);
|
|
6562
|
-
const clearButtonRef = useRef(null);
|
|
6563
|
-
const isInTableCell = useIsInTableCell();
|
|
6564
|
-
variant ??= isInTableCell ? "cell" : "default";
|
|
6565
|
-
const isControlled = value !== void 0;
|
|
6566
|
-
const softDisabled = loading || ariaDisabled === "true" || ariaDisabled === true;
|
|
6567
|
-
const [shouldShowClearButton, setShouldShowClearButton] = useState(
|
|
6568
|
-
((value ?? defaultValue)?.toString() ?? "").length > 0
|
|
6569
|
-
);
|
|
6570
|
-
useEffect(() => {
|
|
6571
|
-
if (inputEl && showClearButton === "auto" && !isControlled) {
|
|
6572
|
-
setShouldShowClearButton(inputEl.value.length > 0);
|
|
7032
|
+
status
|
|
7033
|
+
);
|
|
7034
|
+
const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
|
|
7035
|
+
const containerRef = useRef(null);
|
|
7036
|
+
const clearButtonRef = useRef(null);
|
|
7037
|
+
const isInTableCell = useIsInTableCell();
|
|
7038
|
+
variant ??= isInTableCell ? "cell" : "default";
|
|
7039
|
+
const isControlled = value !== void 0;
|
|
7040
|
+
const softDisabled = loading || ariaDisabled === "true" || ariaDisabled === true;
|
|
7041
|
+
const initialValue = value ?? defaultValue;
|
|
7042
|
+
const [shouldShowClearButton, setShouldShowClearButton] = useState(
|
|
7043
|
+
initialValue != null && (typeof initialValue === "number" || initialValue.length > 0)
|
|
7044
|
+
);
|
|
7045
|
+
useEffect(() => {
|
|
7046
|
+
if (controlEl && showClearButton === "auto" && !isControlled) {
|
|
7047
|
+
setShouldShowClearButton(!valueIsEmpty(getControlValue(controlEl)));
|
|
7048
|
+
}
|
|
7049
|
+
}, [controlEl, isControlled, showClearButton]);
|
|
7050
|
+
const handleChange = useCallback(
|
|
7051
|
+
(evt) => {
|
|
7052
|
+
if (softDisabled) {
|
|
7053
|
+
evt.preventDefault();
|
|
7054
|
+
return;
|
|
6573
7055
|
}
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
(
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
}
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
const handleContainerPointerDown = useCallback(
|
|
6618
|
-
(evt) => {
|
|
6619
|
-
const target = evt.target;
|
|
6620
|
-
if (inputEl && !disabled && !target.closest("input, select, textarea, button, a")) {
|
|
6621
|
-
const cursorIdx = target.closest(`.${prefix("input")} ~ *`) ? inputEl.value.length : 0;
|
|
7056
|
+
const value2 = getControlValue(evt.target);
|
|
7057
|
+
onValueChange?.(value2);
|
|
7058
|
+
if (showClearButton === "auto" && !isControlled) {
|
|
7059
|
+
setShouldShowClearButton(!valueIsEmpty(value2));
|
|
7060
|
+
}
|
|
7061
|
+
},
|
|
7062
|
+
[softDisabled, onValueChange, showClearButton, isControlled]
|
|
7063
|
+
);
|
|
7064
|
+
const setFieldControlFocused = useSetFieldControlFocused();
|
|
7065
|
+
const handleControlFocus = useCallback(
|
|
7066
|
+
(evt) => {
|
|
7067
|
+
if (!disabled && evt.target === controlEl) {
|
|
7068
|
+
setBoolDataAttr(containerRef.current, "focused", true);
|
|
7069
|
+
setFieldControlFocused(true);
|
|
7070
|
+
}
|
|
7071
|
+
},
|
|
7072
|
+
[disabled, controlEl, setFieldControlFocused]
|
|
7073
|
+
);
|
|
7074
|
+
const handleControlBlur = useCallback(
|
|
7075
|
+
(evt) => {
|
|
7076
|
+
if (!evt.relatedTarget || controlEl !== evt.relatedTarget && !clearButtonRef.current?.contains(evt.relatedTarget)) {
|
|
7077
|
+
setBoolDataAttr(containerRef.current, "focused", false);
|
|
7078
|
+
setFieldControlFocused(false);
|
|
7079
|
+
onBlurToOutside?.(evt);
|
|
7080
|
+
}
|
|
7081
|
+
},
|
|
7082
|
+
[controlEl, onBlurToOutside, setFieldControlFocused]
|
|
7083
|
+
);
|
|
7084
|
+
const handleClick = useCallback(
|
|
7085
|
+
(evt) => {
|
|
7086
|
+
if (readOnly && type && NON_READONLY_INPUT_TYPES.includes(type)) {
|
|
7087
|
+
evt.preventDefault();
|
|
7088
|
+
}
|
|
7089
|
+
},
|
|
7090
|
+
[readOnly, type]
|
|
7091
|
+
);
|
|
7092
|
+
const handleContainerPointerDown = useCallback(
|
|
7093
|
+
(evt) => {
|
|
7094
|
+
const target = evt.target;
|
|
7095
|
+
if (controlEl && !disabled && !target.closest("input, select, textarea, button, a")) {
|
|
7096
|
+
const value2 = getControlValue(controlEl);
|
|
7097
|
+
const cursorIdx = typeof value2 === "string" && target.closest(`.${prefix("input")} ~ *`) ? value2.length : 0;
|
|
7098
|
+
if ("setSelectionRange" in controlEl) {
|
|
6622
7099
|
requestAnimationFrame(() => {
|
|
6623
7100
|
try {
|
|
6624
|
-
|
|
7101
|
+
controlEl.setSelectionRange(cursorIdx, cursorIdx);
|
|
6625
7102
|
} catch {
|
|
6626
7103
|
}
|
|
6627
|
-
|
|
7104
|
+
controlEl.focus();
|
|
6628
7105
|
});
|
|
6629
7106
|
}
|
|
6630
|
-
},
|
|
6631
|
-
[disabled, inputEl, prefix]
|
|
6632
|
-
);
|
|
6633
|
-
const handleClearButtonClick = useCallback(() => {
|
|
6634
|
-
if (inputEl && inputEl.value !== "") {
|
|
6635
|
-
setNativeProperty(inputEl, "value", "");
|
|
6636
|
-
const event = new Event(inputEl.type === "file" ? "change" : "input", {
|
|
6637
|
-
bubbles: true,
|
|
6638
|
-
cancelable: true
|
|
6639
|
-
});
|
|
6640
|
-
inputEl.dispatchEvent(event);
|
|
6641
|
-
if (!event.defaultPrevented) {
|
|
6642
|
-
inputEl.focus();
|
|
6643
|
-
}
|
|
6644
7107
|
}
|
|
6645
|
-
},
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
7108
|
+
},
|
|
7109
|
+
[disabled, controlEl, prefix]
|
|
7110
|
+
);
|
|
7111
|
+
const handleClearButtonClick = useCallback(() => {
|
|
7112
|
+
if (controlEl && "value" in controlEl && controlEl.value !== "") {
|
|
7113
|
+
setNativeProperty(controlEl, "value", "");
|
|
7114
|
+
const event = new Event(
|
|
7115
|
+
controlEl instanceof HTMLInputElement && controlEl.type === "file" ? "change" : "input",
|
|
7116
|
+
{ bubbles: true, cancelable: true }
|
|
7117
|
+
);
|
|
7118
|
+
controlEl.dispatchEvent(event);
|
|
7119
|
+
if (!event.defaultPrevented) {
|
|
7120
|
+
controlEl.focus();
|
|
7121
|
+
}
|
|
7122
|
+
}
|
|
7123
|
+
}, [controlEl]);
|
|
7124
|
+
const hasClearButton = !disabled && !softDisabled && !readOnly && (showClearButton === true || showClearButton === "auto" && (isControlled ? (value?.toString() ?? "")?.length > 0 : shouldShowClearButton));
|
|
7125
|
+
const clearDescriptionId = hasClearButton && clearDescription && prefix(`control-clear-${generatedId}`);
|
|
7126
|
+
const { cssVars, dataAttrs } = responsiveValuesToCssVarsAndDataAttrs(
|
|
7127
|
+
"control",
|
|
7128
|
+
{ align }
|
|
7129
|
+
);
|
|
7130
|
+
const supportsRequired = Boolean(tagName && REQUIRED_TAGS.includes(tagName));
|
|
7131
|
+
const supportsReadOnly = Boolean(
|
|
7132
|
+
tagName && READ_ONLY_TAGS.includes(tagName) && (!type || !NON_READONLY_INPUT_TYPES.includes(type))
|
|
7133
|
+
);
|
|
7134
|
+
const combinedLabelIds = combineAriaIds(
|
|
7135
|
+
codeId,
|
|
7136
|
+
labelId ?? dataTableColumnLabelId
|
|
7137
|
+
);
|
|
7138
|
+
const combinedContainerRef = useCombinedRef(
|
|
7139
|
+
containerRef,
|
|
7140
|
+
containerProps?.ref
|
|
7141
|
+
);
|
|
7142
|
+
const combinedControlRef = useCombinedRef(
|
|
7143
|
+
setControlEl,
|
|
7144
|
+
forwardedRef
|
|
7145
|
+
);
|
|
7146
|
+
const combinedClearButtonRef = useCombinedRef(
|
|
7147
|
+
clearButtonRef,
|
|
7148
|
+
clearButtonProps?.ref
|
|
7149
|
+
);
|
|
7150
|
+
const As = asChild ? Slot : "input";
|
|
7151
|
+
return /* @__PURE__ */ jsx(ClearContexts, { field: false, children: /* @__PURE__ */ jsxs(
|
|
7152
|
+
ControlContext.Provider,
|
|
7153
|
+
{
|
|
7154
|
+
value: { variant, status, disabled, softDisabled, readOnly },
|
|
7155
|
+
children: [
|
|
7156
|
+
/* @__PURE__ */ jsxs(
|
|
7157
|
+
"div",
|
|
7158
|
+
{
|
|
7159
|
+
"data-status": status,
|
|
7160
|
+
"data-accent": controlStatusToAccent(status),
|
|
7161
|
+
"data-variant": variant,
|
|
7162
|
+
"data-disabled": boolDataAttr(disabled || softDisabled),
|
|
7163
|
+
"data-readonly": boolDataAttr(readOnly),
|
|
7164
|
+
...rootProps,
|
|
7165
|
+
className: cx(prefix("input__root"), rootProps?.className),
|
|
7166
|
+
children: [
|
|
7167
|
+
codeId && /* @__PURE__ */ jsx(
|
|
7168
|
+
ControlCode,
|
|
7169
|
+
{
|
|
7170
|
+
...codeProps,
|
|
7171
|
+
id: codeId,
|
|
7172
|
+
className: cx(prefix("input__code"), codeProps?.className),
|
|
7173
|
+
children: code
|
|
7174
|
+
}
|
|
7175
|
+
),
|
|
7176
|
+
/* @__PURE__ */ jsxs(
|
|
7177
|
+
"div",
|
|
7178
|
+
{
|
|
7179
|
+
"data-status": status,
|
|
7180
|
+
"data-accent": controlStatusToAccent(status),
|
|
7181
|
+
"data-variant": variant,
|
|
7182
|
+
"data-disabled": boolDataAttr(disabled || softDisabled),
|
|
7183
|
+
"data-readonly": boolDataAttr(readOnly),
|
|
7184
|
+
...containerProps,
|
|
7185
|
+
className: cx(
|
|
7186
|
+
prefix("input__container"),
|
|
7187
|
+
containerProps?.className
|
|
7188
|
+
),
|
|
7189
|
+
onPointerDown: combineEventHandlers(
|
|
7190
|
+
containerProps?.onPointerDown,
|
|
7191
|
+
handleContainerPointerDown,
|
|
7192
|
+
{ checkDefaultPrevented: true }
|
|
7193
|
+
),
|
|
7194
|
+
ref: combinedContainerRef,
|
|
7195
|
+
children: [
|
|
7196
|
+
startAdornment,
|
|
7197
|
+
/* @__PURE__ */ jsx(
|
|
7198
|
+
As,
|
|
7199
|
+
{
|
|
7200
|
+
type,
|
|
7201
|
+
name,
|
|
7202
|
+
defaultValue,
|
|
7203
|
+
value,
|
|
7204
|
+
id: controlId,
|
|
7205
|
+
className: cx(prefix("input"), className),
|
|
7206
|
+
required: required && supportsRequired,
|
|
7207
|
+
disabled,
|
|
7208
|
+
readOnly: (softDisabled || readOnly) && supportsReadOnly,
|
|
7209
|
+
onChange: combineEventHandlers(handleChange, onChange, {
|
|
7210
|
+
checkDefaultPrevented: true
|
|
7211
|
+
}),
|
|
7212
|
+
onFocus: combineEventHandlers(
|
|
7213
|
+
onFocus,
|
|
7214
|
+
handleControlFocus
|
|
7215
|
+
),
|
|
7216
|
+
onBlur: combineEventHandlers(onBlur, handleControlBlur),
|
|
7217
|
+
onClick: combineEventHandlers(onClick, handleClick),
|
|
7218
|
+
style: { ...cssVars, ...style },
|
|
7219
|
+
...dataAttrs,
|
|
7220
|
+
"data-disabled": boolDataAttr(softDisabled),
|
|
7221
|
+
"data-status": status,
|
|
7222
|
+
"data-accent": controlStatusToAccent(status),
|
|
7223
|
+
"data-variant": variant,
|
|
7224
|
+
"aria-disabled": (softDisabled || readOnly) && !supportsReadOnly || void 0,
|
|
7225
|
+
"aria-required": required && !supportsRequired || void 0,
|
|
7226
|
+
"aria-invalid": status === "invalid" || void 0,
|
|
7227
|
+
"aria-label": ariaLabel,
|
|
7228
|
+
"aria-labelledby": ariaLabelledBy ?? (ariaLabel === void 0 && combinedLabelIds !== labelId ? combinedLabelIds : void 0),
|
|
7229
|
+
"aria-describedby": combineAriaIds(
|
|
7230
|
+
loadingDescriptionId,
|
|
7231
|
+
errorMessageIds,
|
|
7232
|
+
ariaDescribedBy,
|
|
7233
|
+
descriptionIds,
|
|
7234
|
+
clearDescriptionId
|
|
7235
|
+
),
|
|
7236
|
+
...otherProps,
|
|
7237
|
+
ref: combinedControlRef
|
|
7238
|
+
}
|
|
6709
7239
|
),
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
7240
|
+
hasClearButton && /* @__PURE__ */ jsx(
|
|
7241
|
+
CloseButton,
|
|
7242
|
+
{
|
|
7243
|
+
size: "sm",
|
|
7244
|
+
label: clearButtonLabel,
|
|
7245
|
+
tabIndex: -1,
|
|
7246
|
+
...clearButtonProps,
|
|
7247
|
+
className: cx(
|
|
7248
|
+
prefix("input__clear-button"),
|
|
7249
|
+
printHidden,
|
|
7250
|
+
clearButtonProps?.className
|
|
7251
|
+
),
|
|
7252
|
+
onClick: combineEventHandlers(
|
|
7253
|
+
clearButtonProps?.onClick,
|
|
7254
|
+
handleClearButtonClick,
|
|
7255
|
+
{ checkDefaultPrevented: true }
|
|
7256
|
+
),
|
|
7257
|
+
onFocus: combineEventHandlers(
|
|
7258
|
+
clearButtonProps?.onFocus,
|
|
7259
|
+
handleControlFocus
|
|
7260
|
+
),
|
|
7261
|
+
onBlur: combineEventHandlers(
|
|
7262
|
+
clearButtonProps?.onBlur,
|
|
7263
|
+
handleControlBlur
|
|
7264
|
+
),
|
|
7265
|
+
ref: combinedClearButtonRef
|
|
7266
|
+
}
|
|
6714
7267
|
),
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
loadingDescriptionId,
|
|
6748
|
-
errorMessageIds,
|
|
6749
|
-
ariaDescribedBy,
|
|
6750
|
-
descriptionIds,
|
|
6751
|
-
clearDescriptionId
|
|
6752
|
-
),
|
|
6753
|
-
...otherProps,
|
|
6754
|
-
ref: combinedInputRef
|
|
6755
|
-
}
|
|
6756
|
-
),
|
|
6757
|
-
hasClearButton && /* @__PURE__ */ jsx(
|
|
6758
|
-
CloseButton,
|
|
6759
|
-
{
|
|
6760
|
-
size: "sm",
|
|
6761
|
-
label: clearButtonLabel,
|
|
6762
|
-
tabIndex: -1,
|
|
6763
|
-
...clearButtonProps,
|
|
6764
|
-
className: cx(
|
|
6765
|
-
prefix("input__clear-button"),
|
|
6766
|
-
printHidden,
|
|
6767
|
-
clearButtonProps?.className
|
|
6768
|
-
),
|
|
6769
|
-
onClick: combineEventHandlers(
|
|
6770
|
-
clearButtonProps?.onClick,
|
|
6771
|
-
handleClearButtonClick,
|
|
6772
|
-
{ checkDefaultPrevented: true }
|
|
6773
|
-
),
|
|
6774
|
-
onFocus: combineEventHandlers(
|
|
6775
|
-
clearButtonProps?.onFocus,
|
|
6776
|
-
handleControlFocus
|
|
6777
|
-
),
|
|
6778
|
-
onBlur: combineEventHandlers(
|
|
6779
|
-
clearButtonProps?.onBlur,
|
|
6780
|
-
handleControlBlur
|
|
6781
|
-
),
|
|
6782
|
-
ref: combinedClearButtonRef
|
|
6783
|
-
}
|
|
6784
|
-
),
|
|
6785
|
-
showSpinner && /* @__PURE__ */ jsx(
|
|
6786
|
-
Spinner,
|
|
6787
|
-
{
|
|
6788
|
-
color: controlStatusToAccent(status, "neutral"),
|
|
6789
|
-
"data-disabled": boolDataAttr(disabled || softDisabled),
|
|
6790
|
-
...spinnerProps,
|
|
6791
|
-
className: cx(
|
|
6792
|
-
prefix("input__spinner"),
|
|
6793
|
-
spinnerProps?.className
|
|
6794
|
-
)
|
|
6795
|
-
}
|
|
6796
|
-
),
|
|
6797
|
-
endAdornment
|
|
6798
|
-
]
|
|
6799
|
-
}
|
|
6800
|
-
)
|
|
6801
|
-
]
|
|
6802
|
-
}
|
|
6803
|
-
),
|
|
6804
|
-
loadingDescriptionId && /* @__PURE__ */ jsx("span", { hidden: true, id: loadingDescriptionId, children: loadingDescription }),
|
|
6805
|
-
clearDescriptionId && /* @__PURE__ */ jsx("span", { hidden: true, id: clearDescriptionId, children: clearDescription })
|
|
6806
|
-
]
|
|
6807
|
-
}
|
|
6808
|
-
) });
|
|
6809
|
-
}
|
|
6810
|
-
);
|
|
6811
|
-
const InputWithContainerRef = forwardRef(function InputWithContainerRef2({ inputRef, containerProps, ...otherProps }, forwardedRef) {
|
|
7268
|
+
showSpinner && /* @__PURE__ */ jsx(
|
|
7269
|
+
Spinner,
|
|
7270
|
+
{
|
|
7271
|
+
color: controlStatusToAccent(status, "neutral"),
|
|
7272
|
+
"data-disabled": boolDataAttr(disabled || softDisabled),
|
|
7273
|
+
...spinnerProps,
|
|
7274
|
+
className: cx(
|
|
7275
|
+
prefix("input__spinner"),
|
|
7276
|
+
spinnerProps?.className
|
|
7277
|
+
)
|
|
7278
|
+
}
|
|
7279
|
+
),
|
|
7280
|
+
endAdornment
|
|
7281
|
+
]
|
|
7282
|
+
}
|
|
7283
|
+
)
|
|
7284
|
+
]
|
|
7285
|
+
}
|
|
7286
|
+
),
|
|
7287
|
+
loadingDescriptionId && /* @__PURE__ */ jsx("span", { hidden: true, id: loadingDescriptionId, children: loadingDescription }),
|
|
7288
|
+
clearDescriptionId && /* @__PURE__ */ jsx("span", { hidden: true, id: clearDescriptionId, children: clearDescription })
|
|
7289
|
+
]
|
|
7290
|
+
}
|
|
7291
|
+
) });
|
|
7292
|
+
});
|
|
7293
|
+
function getControlValue(controlEl) {
|
|
7294
|
+
return controlEl instanceof HTMLInputElement && controlEl.type === "file" ? controlEl.multiple ? Array.from(controlEl.files ?? []) : controlEl.files?.[0] ?? null : controlEl && "value" in controlEl ? controlEl.value : null;
|
|
7295
|
+
}
|
|
7296
|
+
function valueIsEmpty(value) {
|
|
7297
|
+
return typeof value === "string" || Array.isArray(value) ? value.length === 0 : value == null;
|
|
7298
|
+
}
|
|
7299
|
+
const ControlWithContainerRef = forwardRef(function InputWithContainerRef({ controlRef, containerProps, ...otherProps }, forwardedRef) {
|
|
6812
7300
|
return /* @__PURE__ */ jsx(
|
|
6813
|
-
|
|
7301
|
+
Control,
|
|
6814
7302
|
{
|
|
6815
7303
|
containerProps: {
|
|
6816
7304
|
...containerProps,
|
|
6817
7305
|
ref: useCombinedRef(forwardedRef, containerProps?.ref)
|
|
6818
7306
|
},
|
|
6819
|
-
ref:
|
|
7307
|
+
ref: controlRef,
|
|
6820
7308
|
...otherProps
|
|
6821
7309
|
}
|
|
6822
7310
|
);
|
|
6823
7311
|
});
|
|
7312
|
+
const ControlAddon = forwardRef(
|
|
7313
|
+
function ControlAddon2({
|
|
7314
|
+
asChild,
|
|
7315
|
+
variant = "default",
|
|
7316
|
+
status,
|
|
7317
|
+
muted,
|
|
7318
|
+
readOnly,
|
|
7319
|
+
className,
|
|
7320
|
+
...otherProps
|
|
7321
|
+
}, forwardedRef) {
|
|
7322
|
+
const prefix = usePrefix();
|
|
7323
|
+
const controlContext = useControlContext();
|
|
7324
|
+
const As = asChild ? Slot : "div";
|
|
7325
|
+
return /* @__PURE__ */ jsx(ControlContext.Provider, { value: null, children: /* @__PURE__ */ jsx(
|
|
7326
|
+
As,
|
|
7327
|
+
{
|
|
7328
|
+
className: cx(prefix("control-addon"), className),
|
|
7329
|
+
"data-variant": controlContext?.variant ?? variant,
|
|
7330
|
+
"data-status": controlContext?.status ?? status,
|
|
7331
|
+
"data-muted": boolDataAttr(
|
|
7332
|
+
controlContext?.disabled || controlContext?.softDisabled || muted
|
|
7333
|
+
),
|
|
7334
|
+
"data-readonly": boolDataAttr(controlContext?.readOnly || readOnly),
|
|
7335
|
+
ref: forwardedRef,
|
|
7336
|
+
...otherProps
|
|
7337
|
+
}
|
|
7338
|
+
) });
|
|
7339
|
+
}
|
|
7340
|
+
);
|
|
6824
7341
|
const MenuListContext = createContext({
|
|
6825
7342
|
iconPlacement: "start",
|
|
6826
7343
|
variant: "subtle"
|
|
@@ -8337,6 +8854,18 @@ const OptionsGroup = forwardRef(function OptionsGroup2({ children, ...otherProps
|
|
|
8337
8854
|
const { registering } = useSelectContext();
|
|
8338
8855
|
return registering ? children : /* @__PURE__ */ jsx(CommandMenuGroup, { ...otherProps, ref: forwardedRef, children });
|
|
8339
8856
|
});
|
|
8857
|
+
function useResetControlOnFormReset(el, initialValue, setValue) {
|
|
8858
|
+
const initialValueRef = useRef(initialValue);
|
|
8859
|
+
const latest = useLatestValues({ setValue });
|
|
8860
|
+
useEffect(() => {
|
|
8861
|
+
const form = el?.form ?? el?.closest("form");
|
|
8862
|
+
if (form) {
|
|
8863
|
+
const reset = () => latest.setValue(initialValueRef.current);
|
|
8864
|
+
form.addEventListener("reset", reset);
|
|
8865
|
+
return () => form.removeEventListener("reset", reset);
|
|
8866
|
+
}
|
|
8867
|
+
}, [el, latest]);
|
|
8868
|
+
}
|
|
8340
8869
|
const Tag = forwardRef(function Tag2({
|
|
8341
8870
|
asChild,
|
|
8342
8871
|
variant = "solid",
|
|
@@ -8540,11 +9069,28 @@ function SelectMultipleValue() {
|
|
|
8540
9069
|
valuesToRender.length > 0 && !readOnly && valuesTags
|
|
8541
9070
|
] });
|
|
8542
9071
|
}
|
|
8543
|
-
function
|
|
8544
|
-
|
|
8545
|
-
|
|
9072
|
+
function HiddenFormControl({
|
|
9073
|
+
actualElement,
|
|
9074
|
+
form,
|
|
9075
|
+
onFocus,
|
|
8546
9076
|
...otherProps
|
|
8547
9077
|
}) {
|
|
9078
|
+
const isFormControl = actualElement ? !!form || !!actualElement?.closest("form") : true;
|
|
9079
|
+
const handleFocus = () => {
|
|
9080
|
+
actualElement?.focus();
|
|
9081
|
+
};
|
|
9082
|
+
return isFormControl && /* @__PURE__ */ jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
9083
|
+
Slot,
|
|
9084
|
+
{
|
|
9085
|
+
form,
|
|
9086
|
+
onFocus: combineEventHandlers(handleFocus, onFocus),
|
|
9087
|
+
...otherProps,
|
|
9088
|
+
tabIndex: -1,
|
|
9089
|
+
"aria-hidden": true
|
|
9090
|
+
}
|
|
9091
|
+
) });
|
|
9092
|
+
}
|
|
9093
|
+
const SelectNative = forwardRef(function SelectNative2({ actualElement, multiple, onValueChange, value, ...otherProps }, forwardedRef) {
|
|
8548
9094
|
const { store } = useSelectContext();
|
|
8549
9095
|
const hasEmptyOption = useStore$1(
|
|
8550
9096
|
store,
|
|
@@ -8554,36 +9100,33 @@ function SelectNative({
|
|
|
8554
9100
|
store,
|
|
8555
9101
|
useShallow((state) => Array.from(state.options[0].values()))
|
|
8556
9102
|
);
|
|
8557
|
-
const handleChange =
|
|
8558
|
-
(evt) =>
|
|
8559
|
-
multiple ? Array.from(evt.target.options).filter((option) => option.selected).map((option) => option.value) : evt.target.value
|
|
8560
|
-
),
|
|
8561
|
-
[multiple, onValueChange]
|
|
9103
|
+
const handleChange = (evt) => onValueChange(
|
|
9104
|
+
multiple ? Array.from(evt.target.options).filter((option) => option.selected).map((option) => option.value) : evt.target.value
|
|
8562
9105
|
);
|
|
8563
9106
|
const selectKey = useMemo(
|
|
8564
9107
|
() => (hasEmptyOption ? "" : ";") + optionStates.map((opt) => opt.value).join(";"),
|
|
8565
9108
|
[hasEmptyOption, optionStates]
|
|
8566
9109
|
);
|
|
8567
9110
|
const options = useMemo(
|
|
8568
|
-
() => optionStates.map(({ value, disabled }) => /* @__PURE__ */ jsx("option", { value, disabled },
|
|
9111
|
+
() => optionStates.map(({ value: value2, disabled }) => /* @__PURE__ */ jsx("option", { value: value2, disabled }, value2)),
|
|
8569
9112
|
[optionStates]
|
|
8570
9113
|
);
|
|
8571
|
-
return /* @__PURE__ */
|
|
8572
|
-
|
|
9114
|
+
return /* @__PURE__ */ jsx(
|
|
9115
|
+
HiddenFormControl,
|
|
8573
9116
|
{
|
|
9117
|
+
actualElement,
|
|
9118
|
+
onChange: handleChange,
|
|
8574
9119
|
multiple,
|
|
9120
|
+
value,
|
|
8575
9121
|
...otherProps,
|
|
8576
|
-
|
|
8577
|
-
tabIndex: -1,
|
|
8578
|
-
"aria-hidden": true,
|
|
8579
|
-
children: [
|
|
9122
|
+
children: /* @__PURE__ */ jsxs("select", { ref: forwardedRef, children: [
|
|
8580
9123
|
!hasEmptyOption && /* @__PURE__ */ jsx("option", { value: "" }),
|
|
8581
9124
|
options
|
|
8582
|
-
]
|
|
9125
|
+
] })
|
|
8583
9126
|
},
|
|
8584
9127
|
selectKey
|
|
8585
9128
|
);
|
|
8586
|
-
}
|
|
9129
|
+
});
|
|
8587
9130
|
function SelectSingleValue() {
|
|
8588
9131
|
const { value, store } = useSelectContext();
|
|
8589
9132
|
return useStore$1(
|
|
@@ -8627,6 +9170,8 @@ const Select = forwardRef(function Select2({
|
|
|
8627
9170
|
valueTagMaxWidth,
|
|
8628
9171
|
onKeyDown,
|
|
8629
9172
|
onBlurToOutside,
|
|
9173
|
+
validate,
|
|
9174
|
+
validationMode,
|
|
8630
9175
|
className,
|
|
8631
9176
|
rootProps,
|
|
8632
9177
|
codeProps,
|
|
@@ -8686,7 +9231,20 @@ const Select = forwardRef(function Select2({
|
|
|
8686
9231
|
const [buttonEl, setButtonEl] = useState(null);
|
|
8687
9232
|
const popoverRef = useRef(null);
|
|
8688
9233
|
const searchRef = useRef(null);
|
|
8689
|
-
const
|
|
9234
|
+
const {
|
|
9235
|
+
status: formStatus,
|
|
9236
|
+
disabled: formDisabled,
|
|
9237
|
+
setValue: formSetValue,
|
|
9238
|
+
onChange: formOnChange,
|
|
9239
|
+
onBlur: formOnBlur
|
|
9240
|
+
} = useRegisterFormControl(
|
|
9241
|
+
name,
|
|
9242
|
+
actualValue,
|
|
9243
|
+
validate,
|
|
9244
|
+
validationMode
|
|
9245
|
+
);
|
|
9246
|
+
status ??= formStatus;
|
|
9247
|
+
disabled ||= formDisabled;
|
|
8690
9248
|
const handleContainerPointerDown = useCallback(
|
|
8691
9249
|
(evt) => {
|
|
8692
9250
|
evt.preventDefault();
|
|
@@ -8697,12 +9255,19 @@ const Select = forwardRef(function Select2({
|
|
|
8697
9255
|
},
|
|
8698
9256
|
[buttonEl, disabled, setOpen, softDisabled]
|
|
8699
9257
|
);
|
|
9258
|
+
const handleValueChange = useCallback(
|
|
9259
|
+
(value2) => {
|
|
9260
|
+
setValue(value2);
|
|
9261
|
+
onValueChange?.(value2);
|
|
9262
|
+
formOnChange(value2);
|
|
9263
|
+
},
|
|
9264
|
+
[formOnChange, onValueChange, setValue]
|
|
9265
|
+
);
|
|
8700
9266
|
const handleOptionSelect = useCallback(
|
|
8701
9267
|
(optionValue) => {
|
|
8702
9268
|
if (multiple) {
|
|
8703
9269
|
const newValue = actualValue.includes(optionValue) ? actualValue.filter((v) => v !== optionValue) : [...actualValue, optionValue];
|
|
8704
|
-
|
|
8705
|
-
onValueChange?.(newValue);
|
|
9270
|
+
handleValueChange(newValue);
|
|
8706
9271
|
if (open) {
|
|
8707
9272
|
searchRef.current?.focus();
|
|
8708
9273
|
} else {
|
|
@@ -8710,8 +9275,7 @@ const Select = forwardRef(function Select2({
|
|
|
8710
9275
|
}
|
|
8711
9276
|
} else {
|
|
8712
9277
|
if (optionValue !== actualValue) {
|
|
8713
|
-
|
|
8714
|
-
onValueChange?.(optionValue);
|
|
9278
|
+
handleValueChange(optionValue);
|
|
8715
9279
|
}
|
|
8716
9280
|
setOpen(false);
|
|
8717
9281
|
}
|
|
@@ -8721,22 +9285,20 @@ const Select = forwardRef(function Select2({
|
|
|
8721
9285
|
[
|
|
8722
9286
|
actualValue,
|
|
8723
9287
|
buttonEl,
|
|
9288
|
+
handleValueChange,
|
|
8724
9289
|
multiple,
|
|
8725
9290
|
onSearchValueChange,
|
|
8726
|
-
onValueChange,
|
|
8727
9291
|
open,
|
|
8728
9292
|
setOpen,
|
|
8729
|
-
setSearchValue
|
|
8730
|
-
setValue
|
|
9293
|
+
setSearchValue
|
|
8731
9294
|
]
|
|
8732
9295
|
);
|
|
8733
9296
|
const handleClearButtonClick = useCallback(() => {
|
|
8734
9297
|
if (!isEmpty) {
|
|
8735
9298
|
const newValue = multiple ? [] : "";
|
|
8736
|
-
|
|
8737
|
-
onValueChange?.(newValue);
|
|
9299
|
+
handleValueChange(newValue);
|
|
8738
9300
|
}
|
|
8739
|
-
}, [isEmpty, multiple
|
|
9301
|
+
}, [handleValueChange, isEmpty, multiple]);
|
|
8740
9302
|
const handleCloseAutoFocus = useCallback(
|
|
8741
9303
|
(evt) => {
|
|
8742
9304
|
if (document.activeElement === document.body || document.activeElement === document.documentElement) {
|
|
@@ -8759,21 +9321,31 @@ const Select = forwardRef(function Select2({
|
|
|
8759
9321
|
);
|
|
8760
9322
|
const handleControlBlur = useCallback(
|
|
8761
9323
|
(evt) => {
|
|
8762
|
-
if (
|
|
8763
|
-
onBlurToOutside(evt);
|
|
9324
|
+
if (!evt.relatedTarget || !buttonEl?.contains(evt.relatedTarget) && !popoverRef.current?.contains(evt.relatedTarget)) {
|
|
9325
|
+
onBlurToOutside?.(evt);
|
|
9326
|
+
formOnBlur();
|
|
8764
9327
|
}
|
|
8765
9328
|
},
|
|
8766
|
-
[buttonEl, onBlurToOutside]
|
|
9329
|
+
[buttonEl, formOnBlur, onBlurToOutside]
|
|
8767
9330
|
);
|
|
8768
|
-
const
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
9331
|
+
const handleHiddenSelectValueChange = (value2) => {
|
|
9332
|
+
if (!softDisabled && !readOnly) {
|
|
9333
|
+
setValue(value2);
|
|
9334
|
+
formSetValue(value2);
|
|
9335
|
+
}
|
|
9336
|
+
};
|
|
9337
|
+
const selectNativeRef = useRef(null);
|
|
9338
|
+
useResetControlOnFormReset(buttonEl, actualValue, (value2) => {
|
|
9339
|
+
handleHiddenSelectValueChange(value2);
|
|
9340
|
+
const selectNative = selectNativeRef.current;
|
|
9341
|
+
if (selectNative) {
|
|
9342
|
+
setTimeout(
|
|
9343
|
+
() => multiple ? Array.from(selectNative.options).forEach(
|
|
9344
|
+
(opt) => opt.selected = value2.includes(opt.value)
|
|
9345
|
+
) : selectNative.value = value2
|
|
9346
|
+
);
|
|
8775
9347
|
}
|
|
8776
|
-
}
|
|
9348
|
+
});
|
|
8777
9349
|
const selectContext = useCreateSelectContext({
|
|
8778
9350
|
multiple,
|
|
8779
9351
|
value: actualValue,
|
|
@@ -8823,7 +9395,7 @@ const Select = forwardRef(function Select2({
|
|
|
8823
9395
|
...style
|
|
8824
9396
|
},
|
|
8825
9397
|
children: /* @__PURE__ */ jsx(
|
|
8826
|
-
|
|
9398
|
+
ControlWithContainerRef,
|
|
8827
9399
|
{
|
|
8828
9400
|
asChild: true,
|
|
8829
9401
|
variant,
|
|
@@ -8962,19 +9534,21 @@ const Select = forwardRef(function Select2({
|
|
|
8962
9534
|
}
|
|
8963
9535
|
),
|
|
8964
9536
|
ariaLabelId && /* @__PURE__ */ jsx("span", { hidden: true, id: ariaLabelId, children: ariaLabel }),
|
|
8965
|
-
|
|
9537
|
+
/* @__PURE__ */ jsx(
|
|
8966
9538
|
SelectNative,
|
|
8967
9539
|
{
|
|
9540
|
+
actualElement: buttonEl,
|
|
9541
|
+
onValueChange: handleHiddenSelectValueChange,
|
|
8968
9542
|
name,
|
|
8969
9543
|
value: actualValue,
|
|
8970
|
-
onValueChange: setValue,
|
|
8971
9544
|
multiple,
|
|
8972
9545
|
required,
|
|
8973
9546
|
disabled,
|
|
8974
9547
|
autoComplete,
|
|
8975
|
-
form
|
|
9548
|
+
form,
|
|
9549
|
+
ref: selectNativeRef
|
|
8976
9550
|
}
|
|
8977
|
-
)
|
|
9551
|
+
)
|
|
8978
9552
|
] });
|
|
8979
9553
|
});
|
|
8980
9554
|
const CAPTION_FORMAT = "LLLL y";
|
|
@@ -9230,6 +9804,28 @@ const CalendarMonthGrid = memo(function CalendarMonthGrid2({
|
|
|
9230
9804
|
children
|
|
9231
9805
|
] });
|
|
9232
9806
|
});
|
|
9807
|
+
function toValidDate(value) {
|
|
9808
|
+
const date = typeof value === "string" ? parseISO(value) : value ?? null;
|
|
9809
|
+
return date === null || !isValid(date) ? null : date;
|
|
9810
|
+
}
|
|
9811
|
+
function calcMinAllowedDate(minDate, minMonth, minYear) {
|
|
9812
|
+
minMonth = toValidDate(minMonth);
|
|
9813
|
+
const minDates = [
|
|
9814
|
+
toValidDate(minDate),
|
|
9815
|
+
minMonth && startOfMonth(minMonth),
|
|
9816
|
+
minYear != null && new Date(minYear, 0, 1)
|
|
9817
|
+
].filter((d) => d);
|
|
9818
|
+
return minDates.length > 0 ? max(minDates) : void 0;
|
|
9819
|
+
}
|
|
9820
|
+
function calcMaxAllowedDate(maxDate, maxMonth, maxYear) {
|
|
9821
|
+
maxMonth = toValidDate(maxMonth);
|
|
9822
|
+
const maxDates = [
|
|
9823
|
+
toValidDate(maxDate),
|
|
9824
|
+
maxMonth && endOfMonth(maxMonth),
|
|
9825
|
+
maxYear != null && new Date(maxYear, 11, 31)
|
|
9826
|
+
].filter((d) => d);
|
|
9827
|
+
return maxDates.length > 0 ? min(maxDates) : void 0;
|
|
9828
|
+
}
|
|
9233
9829
|
function Calendar({
|
|
9234
9830
|
selectionMode = "none",
|
|
9235
9831
|
defaultValue,
|
|
@@ -9321,24 +9917,14 @@ function Calendar({
|
|
|
9321
9917
|
start: null,
|
|
9322
9918
|
end: null
|
|
9323
9919
|
});
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
return minDates.length > 0 ? max(minDates) : void 0;
|
|
9333
|
-
}, [minDate, minMonth, minYear]);
|
|
9334
|
-
const maxAllowedDate = useMemo(() => {
|
|
9335
|
-
const maxDates = [
|
|
9336
|
-
toValidDate(maxDate),
|
|
9337
|
-
maxMonth && endOfMonth(maxMonth),
|
|
9338
|
-
maxYear != null && new Date(maxYear, 11, 31)
|
|
9339
|
-
].filter((d) => d);
|
|
9340
|
-
return maxDates.length > 0 ? min(maxDates) : void 0;
|
|
9341
|
-
}, [maxDate, maxMonth, maxYear]);
|
|
9920
|
+
const minAllowedDate = useMemo(
|
|
9921
|
+
() => calcMinAllowedDate(minDate, minMonth, minYear),
|
|
9922
|
+
[minDate, minMonth, minYear]
|
|
9923
|
+
);
|
|
9924
|
+
const maxAllowedDate = useMemo(
|
|
9925
|
+
() => calcMaxAllowedDate(maxDate, maxMonth, maxYear),
|
|
9926
|
+
[maxDate, maxMonth, maxYear]
|
|
9927
|
+
);
|
|
9342
9928
|
const curDateStr = (/* @__PURE__ */ new Date()).toISOString();
|
|
9343
9929
|
const curMonth = useMemo(
|
|
9344
9930
|
() => startOfMonth(new Date(curDateStr)),
|
|
@@ -9625,10 +10211,6 @@ function Calendar({
|
|
|
9625
10211
|
}
|
|
9626
10212
|
);
|
|
9627
10213
|
}
|
|
9628
|
-
function toValidDate(value) {
|
|
9629
|
-
const date = typeof value === "string" ? parseISO(value) : value ?? null;
|
|
9630
|
-
return date === null || !isValid(date) ? null : date;
|
|
9631
|
-
}
|
|
9632
10214
|
const CheckboxGroup = forwardRef(function CheckboxGroup2({
|
|
9633
10215
|
inline,
|
|
9634
10216
|
variant,
|
|
@@ -9645,6 +10227,8 @@ const CheckboxGroup = forwardRef(function CheckboxGroup2({
|
|
|
9645
10227
|
value,
|
|
9646
10228
|
onValueChange,
|
|
9647
10229
|
onBlurToOutside,
|
|
10230
|
+
validate,
|
|
10231
|
+
validationMode,
|
|
9648
10232
|
codeProps,
|
|
9649
10233
|
containerProps,
|
|
9650
10234
|
endContainerProps,
|
|
@@ -9664,11 +10248,20 @@ const CheckboxGroup = forwardRef(function CheckboxGroup2({
|
|
|
9664
10248
|
const prefix = usePrefix();
|
|
9665
10249
|
const [locale7] = useLocale();
|
|
9666
10250
|
loadingDescription ??= locale7.Input.loadingDescription;
|
|
10251
|
+
const initialValue = value ?? defaultValue ?? [];
|
|
10252
|
+
const {
|
|
10253
|
+
status: formStatus,
|
|
10254
|
+
disabled: formDisabled,
|
|
10255
|
+
onChange: formOnChange,
|
|
10256
|
+
onBlur: formOnBlur
|
|
10257
|
+
} = useRegisterFormControl(name, initialValue, validate, validationMode);
|
|
10258
|
+
status ??= formStatus;
|
|
10259
|
+
disabled ||= formDisabled;
|
|
9667
10260
|
const labelId = useFieldLabelId();
|
|
9668
10261
|
const dataTableColumnLabelId = useDataTableColumnLabelId();
|
|
9669
10262
|
const descriptionIds = useFieldDescriptionIds();
|
|
9670
10263
|
const errorMessageIds = useFieldErrorMessageIds();
|
|
9671
|
-
const { generatedId, controlId, codeId } =
|
|
10264
|
+
const { generatedId, controlId, codeId } = useRegisterFieldControl(
|
|
9672
10265
|
id,
|
|
9673
10266
|
"DIV",
|
|
9674
10267
|
codeProps?.id,
|
|
@@ -9714,16 +10307,18 @@ const CheckboxGroup = forwardRef(function CheckboxGroup2({
|
|
|
9714
10307
|
const handleBlur = useCallback(
|
|
9715
10308
|
(evt) => {
|
|
9716
10309
|
setFieldControlFocused(false);
|
|
9717
|
-
if (
|
|
9718
|
-
onBlurToOutside(evt);
|
|
10310
|
+
if (!evt.relatedTarget || !checkboxGroupRef.current?.contains(evt.relatedTarget)) {
|
|
10311
|
+
onBlurToOutside?.(evt);
|
|
10312
|
+
formOnBlur();
|
|
9719
10313
|
}
|
|
9720
10314
|
},
|
|
9721
|
-
[onBlurToOutside, setFieldControlFocused]
|
|
10315
|
+
[formOnBlur, onBlurToOutside, setFieldControlFocused]
|
|
9722
10316
|
);
|
|
9723
10317
|
const checkboxGroupContextValue = useCreateCheckboxGroupContext({
|
|
9724
10318
|
defaultValue,
|
|
9725
10319
|
value,
|
|
9726
10320
|
onValueChange,
|
|
10321
|
+
formOnChange,
|
|
9727
10322
|
name,
|
|
9728
10323
|
required,
|
|
9729
10324
|
loadingDescriptionId,
|
|
@@ -9964,6 +10559,7 @@ function useDateTransformer({
|
|
|
9964
10559
|
}
|
|
9965
10560
|
const DateInput = forwardRef(
|
|
9966
10561
|
function DateInput2({
|
|
10562
|
+
name,
|
|
9967
10563
|
value: controlledValue,
|
|
9968
10564
|
defaultValue,
|
|
9969
10565
|
onValueChange,
|
|
@@ -9972,6 +10568,7 @@ const DateInput = forwardRef(
|
|
|
9972
10568
|
disabled,
|
|
9973
10569
|
loading,
|
|
9974
10570
|
readOnly,
|
|
10571
|
+
status,
|
|
9975
10572
|
showClearButton = "auto",
|
|
9976
10573
|
endAdornment,
|
|
9977
10574
|
minDate,
|
|
@@ -9981,10 +10578,14 @@ const DateInput = forwardRef(
|
|
|
9981
10578
|
minYear,
|
|
9982
10579
|
maxYear,
|
|
9983
10580
|
required,
|
|
10581
|
+
autoComplete,
|
|
9984
10582
|
format: format2,
|
|
9985
10583
|
announcedFormat,
|
|
9986
10584
|
formatDescription,
|
|
9987
10585
|
selectedDateDescription,
|
|
10586
|
+
form,
|
|
10587
|
+
validate,
|
|
10588
|
+
validationMode,
|
|
9988
10589
|
calendarButtonLabel,
|
|
9989
10590
|
onPopoverOpenChange,
|
|
9990
10591
|
onBlurToOutside,
|
|
@@ -10022,6 +10623,10 @@ const DateInput = forwardRef(
|
|
|
10022
10623
|
() => parseDate(formattedValue),
|
|
10023
10624
|
[parseDate, formattedValue]
|
|
10024
10625
|
);
|
|
10626
|
+
const stringValue = useMemo(
|
|
10627
|
+
() => dateValue && formatISO(dateValue, { representation: "date" }),
|
|
10628
|
+
[dateValue]
|
|
10629
|
+
);
|
|
10025
10630
|
const deferredFormattedValue = useDeferredValue(formattedValue);
|
|
10026
10631
|
const deferredDateValue = useMemo(
|
|
10027
10632
|
() => parseDate(deferredFormattedValue),
|
|
@@ -10032,12 +10637,26 @@ const DateInput = forwardRef(
|
|
|
10032
10637
|
modal: false
|
|
10033
10638
|
});
|
|
10034
10639
|
const calendarApiRef = useRef(null);
|
|
10035
|
-
const
|
|
10640
|
+
const [inputEl, setInputEl] = useState(null);
|
|
10036
10641
|
const clearButtonRef = useRef(null);
|
|
10037
10642
|
const addonButtonRef = useRef(null);
|
|
10038
10643
|
const popoverRef = useRef(null);
|
|
10039
10644
|
const monthSelectMenuRef = useRef(null);
|
|
10040
10645
|
const yearSelectMenuRef = useRef(null);
|
|
10646
|
+
const {
|
|
10647
|
+
status: formStatus,
|
|
10648
|
+
disabled: formDisabled,
|
|
10649
|
+
setValue: formSetValue,
|
|
10650
|
+
onChange: formOnChange,
|
|
10651
|
+
onBlur: formOnBlur
|
|
10652
|
+
} = useRegisterFormControl(
|
|
10653
|
+
name,
|
|
10654
|
+
stringValue,
|
|
10655
|
+
validate,
|
|
10656
|
+
validationMode
|
|
10657
|
+
);
|
|
10658
|
+
status ??= formStatus;
|
|
10659
|
+
disabled ||= formDisabled;
|
|
10041
10660
|
const changePopoverState = useCallback(
|
|
10042
10661
|
(state) => {
|
|
10043
10662
|
setPopoverState(state);
|
|
@@ -10051,8 +10670,10 @@ const DateInput = forwardRef(
|
|
|
10051
10670
|
(evt) => {
|
|
10052
10671
|
const formattedValue2 = evt.currentTarget.value;
|
|
10053
10672
|
const dateValue2 = parseDate(formattedValue2);
|
|
10054
|
-
|
|
10673
|
+
const stringValue2 = dateValue2 && formatISO(dateValue2, { representation: "date" });
|
|
10674
|
+
onValueChange?.({ formattedValue: formattedValue2, stringValue: stringValue2, dateValue: dateValue2 });
|
|
10055
10675
|
setFormattedValue(formattedValue2);
|
|
10676
|
+
formOnChange(stringValue2);
|
|
10056
10677
|
const calendarApi = calendarApiRef.current;
|
|
10057
10678
|
if (!evt.defaultPrevented && dateValue2 && calendarApi && !calendarApi?.isVisible(dateValue2)) {
|
|
10058
10679
|
const month = startOfMonth(dateValue2);
|
|
@@ -10060,7 +10681,13 @@ const DateInput = forwardRef(
|
|
|
10060
10681
|
calendarApi.setMonth(month);
|
|
10061
10682
|
}
|
|
10062
10683
|
},
|
|
10063
|
-
[
|
|
10684
|
+
[
|
|
10685
|
+
calendarProps,
|
|
10686
|
+
formOnChange,
|
|
10687
|
+
onValueChange,
|
|
10688
|
+
parseDate,
|
|
10689
|
+
setFormattedValue
|
|
10690
|
+
]
|
|
10064
10691
|
);
|
|
10065
10692
|
const handleInputFocus = useCallback(() => {
|
|
10066
10693
|
changePopoverState({ open: true, modal: false });
|
|
@@ -10071,12 +10698,20 @@ const DateInput = forwardRef(
|
|
|
10071
10698
|
const handleCalendarValueChange = useCallback(
|
|
10072
10699
|
(date) => {
|
|
10073
10700
|
const formattedValue2 = formatDate(date);
|
|
10074
|
-
|
|
10701
|
+
const stringValue2 = date && formatISO(date, { representation: "date" });
|
|
10702
|
+
onValueChange?.({ formattedValue: formattedValue2, stringValue: stringValue2, dateValue: date });
|
|
10075
10703
|
setFormattedValue(formattedValue2);
|
|
10704
|
+
formOnChange(stringValue2);
|
|
10076
10705
|
changePopoverState({ open: false, modal: false });
|
|
10077
10706
|
addonButtonRef.current?.focus();
|
|
10078
10707
|
},
|
|
10079
|
-
[
|
|
10708
|
+
[
|
|
10709
|
+
changePopoverState,
|
|
10710
|
+
formOnChange,
|
|
10711
|
+
formatDate,
|
|
10712
|
+
onValueChange,
|
|
10713
|
+
setFormattedValue
|
|
10714
|
+
]
|
|
10080
10715
|
);
|
|
10081
10716
|
const handlePopoverOpenAutoFocus = useCallback(
|
|
10082
10717
|
(evt) => {
|
|
@@ -10088,11 +10723,11 @@ const DateInput = forwardRef(
|
|
|
10088
10723
|
);
|
|
10089
10724
|
const handlePopoverInteractOutside = useCallback(
|
|
10090
10725
|
(evt) => {
|
|
10091
|
-
if (!popoverState.modal &&
|
|
10726
|
+
if (!popoverState.modal && inputEl !== evt.target) {
|
|
10092
10727
|
changePopoverState({ open: false, modal: false });
|
|
10093
10728
|
}
|
|
10094
10729
|
},
|
|
10095
|
-
[changePopoverState, popoverState.modal]
|
|
10730
|
+
[changePopoverState, inputEl, popoverState.modal]
|
|
10096
10731
|
);
|
|
10097
10732
|
const handlePopoverEscapeKeyDown = useCallback(() => {
|
|
10098
10733
|
if (popoverState.modal) {
|
|
@@ -10106,24 +10741,51 @@ const DateInput = forwardRef(
|
|
|
10106
10741
|
}, [changePopoverState, popoverState.modal]);
|
|
10107
10742
|
const handleControlBlur = useCallback(
|
|
10108
10743
|
(evt) => {
|
|
10109
|
-
if (!evt.relatedTarget || !
|
|
10744
|
+
if (!evt.relatedTarget || !inputEl?.contains(evt.relatedTarget) && !clearButtonRef.current?.contains(evt.relatedTarget) && !addonButtonRef.current?.contains(evt.relatedTarget) && !popoverRef.current?.contains(evt.relatedTarget) && !monthSelectMenuRef.current?.contains(evt.relatedTarget) && !yearSelectMenuRef.current?.contains(evt.relatedTarget)) {
|
|
10110
10745
|
const formattedDateValue = formatDate(dateValue);
|
|
10111
10746
|
if (formattedDateValue !== formattedValue) {
|
|
10112
|
-
onValueChange?.({
|
|
10747
|
+
onValueChange?.({
|
|
10748
|
+
formattedValue: formattedDateValue,
|
|
10749
|
+
stringValue,
|
|
10750
|
+
dateValue
|
|
10751
|
+
});
|
|
10113
10752
|
setFormattedValue(formattedDateValue);
|
|
10753
|
+
formOnChange(stringValue);
|
|
10114
10754
|
}
|
|
10115
10755
|
onBlurToOutside?.(evt);
|
|
10756
|
+
formOnBlur();
|
|
10116
10757
|
}
|
|
10117
10758
|
},
|
|
10118
10759
|
[
|
|
10119
|
-
|
|
10760
|
+
inputEl,
|
|
10120
10761
|
formatDate,
|
|
10762
|
+
dateValue,
|
|
10121
10763
|
formattedValue,
|
|
10122
10764
|
onBlurToOutside,
|
|
10765
|
+
formOnBlur,
|
|
10123
10766
|
onValueChange,
|
|
10124
|
-
|
|
10767
|
+
stringValue,
|
|
10768
|
+
setFormattedValue,
|
|
10769
|
+
formOnChange
|
|
10125
10770
|
]
|
|
10126
10771
|
);
|
|
10772
|
+
const hiddenInputMin = useMemo(() => {
|
|
10773
|
+
const minAllowedDate = calcMinAllowedDate(minDate, minMonth, minYear);
|
|
10774
|
+
return minAllowedDate && formatISO(minAllowedDate, { representation: "date" });
|
|
10775
|
+
}, [minDate, minMonth, minYear]);
|
|
10776
|
+
const hiddenInputMax = useMemo(() => {
|
|
10777
|
+
const maxAllowedDate = calcMaxAllowedDate(maxDate, maxMonth, maxYear);
|
|
10778
|
+
return maxAllowedDate && formatISO(maxAllowedDate, { representation: "date" });
|
|
10779
|
+
}, [maxDate, maxMonth, maxYear]);
|
|
10780
|
+
const handleHiddenInputValueChange = (value) => {
|
|
10781
|
+
setFormattedValue(formatDate(value && parseISO(value)));
|
|
10782
|
+
formSetValue(value);
|
|
10783
|
+
};
|
|
10784
|
+
useResetControlOnFormReset(
|
|
10785
|
+
inputEl,
|
|
10786
|
+
stringValue,
|
|
10787
|
+
handleHiddenInputValueChange
|
|
10788
|
+
);
|
|
10127
10789
|
const descriptionFormattedValue = useMemo(
|
|
10128
10790
|
() => formatDate(dateValue, { format: announcedFormat }),
|
|
10129
10791
|
[dateValue, announcedFormat, formatDate]
|
|
@@ -10133,7 +10795,7 @@ const DateInput = forwardRef(
|
|
|
10133
10795
|
clearButtonProps?.ref,
|
|
10134
10796
|
clearButtonRef
|
|
10135
10797
|
);
|
|
10136
|
-
const
|
|
10798
|
+
const combinedControlRef = useCombinedRef(setInputEl, forwardedRef);
|
|
10137
10799
|
const combinedPopoverRef = useCombinedRef(
|
|
10138
10800
|
popoverContentProps?.ref,
|
|
10139
10801
|
popoverRef
|
|
@@ -10141,7 +10803,7 @@ const DateInput = forwardRef(
|
|
|
10141
10803
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10142
10804
|
/* @__PURE__ */ jsxs(Popover, { open: popoverState.open, modal: popoverState.modal, children: [
|
|
10143
10805
|
/* @__PURE__ */ jsx(PopoverAnchor, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
10144
|
-
|
|
10806
|
+
ControlWithContainerRef,
|
|
10145
10807
|
{
|
|
10146
10808
|
className: cx(prefix("date-input"), className),
|
|
10147
10809
|
value: formattedValue,
|
|
@@ -10150,6 +10812,7 @@ const DateInput = forwardRef(
|
|
|
10150
10812
|
disabled,
|
|
10151
10813
|
loading,
|
|
10152
10814
|
readOnly,
|
|
10815
|
+
status,
|
|
10153
10816
|
onChange: combineEventHandlers(onChange, handleInputChange),
|
|
10154
10817
|
onFocus: combineEventHandlers(onFocus, handleInputFocus),
|
|
10155
10818
|
onBlurToOutside: handleControlBlur,
|
|
@@ -10169,6 +10832,7 @@ const DateInput = forwardRef(
|
|
|
10169
10832
|
}
|
|
10170
10833
|
) }) }) })
|
|
10171
10834
|
] }),
|
|
10835
|
+
autoComplete: "off",
|
|
10172
10836
|
"aria-disabled": ariaDisabled,
|
|
10173
10837
|
"aria-describedby": combineAriaIds(
|
|
10174
10838
|
ariaDescribedBy,
|
|
@@ -10184,7 +10848,7 @@ const DateInput = forwardRef(
|
|
|
10184
10848
|
...clearButtonProps,
|
|
10185
10849
|
ref: combinedClearButtonRef
|
|
10186
10850
|
},
|
|
10187
|
-
|
|
10851
|
+
controlRef: combinedControlRef,
|
|
10188
10852
|
...otherProps
|
|
10189
10853
|
}
|
|
10190
10854
|
) }),
|
|
@@ -10264,11 +10928,30 @@ const DateInput = forwardRef(
|
|
|
10264
10928
|
)
|
|
10265
10929
|
] }),
|
|
10266
10930
|
formatDescriptionId && /* @__PURE__ */ jsx("span", { hidden: true, id: formatDescriptionId, children: formatDescription }),
|
|
10267
|
-
selectedDateDescriptionId && /* @__PURE__ */ jsx("span", { hidden: true, id: selectedDateDescriptionId, children: selectedDateDescription(descriptionFormattedValue) })
|
|
10931
|
+
selectedDateDescriptionId && /* @__PURE__ */ jsx("span", { hidden: true, id: selectedDateDescriptionId, children: selectedDateDescription(descriptionFormattedValue) }),
|
|
10932
|
+
/* @__PURE__ */ jsx(
|
|
10933
|
+
HiddenFormControl,
|
|
10934
|
+
{
|
|
10935
|
+
actualElement: inputEl,
|
|
10936
|
+
onChange: (evt) => handleHiddenInputValueChange(evt.target.value),
|
|
10937
|
+
name,
|
|
10938
|
+
type: "date",
|
|
10939
|
+
value: stringValue ?? "",
|
|
10940
|
+
required,
|
|
10941
|
+
disabled,
|
|
10942
|
+
readOnly,
|
|
10943
|
+
autoComplete,
|
|
10944
|
+
min: hiddenInputMin,
|
|
10945
|
+
max: hiddenInputMax,
|
|
10946
|
+
form,
|
|
10947
|
+
children: /* @__PURE__ */ jsx("input", {})
|
|
10948
|
+
}
|
|
10949
|
+
)
|
|
10268
10950
|
] });
|
|
10269
10951
|
}
|
|
10270
10952
|
);
|
|
10271
10953
|
const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
10954
|
+
name,
|
|
10272
10955
|
variant,
|
|
10273
10956
|
status,
|
|
10274
10957
|
code,
|
|
@@ -10308,6 +10991,9 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10308
10991
|
className,
|
|
10309
10992
|
onPopoverOpenChange,
|
|
10310
10993
|
onBlurToOutside,
|
|
10994
|
+
form,
|
|
10995
|
+
validate,
|
|
10996
|
+
validationMode,
|
|
10311
10997
|
codeProps,
|
|
10312
10998
|
popoverAnchorProps,
|
|
10313
10999
|
startContainerProps,
|
|
@@ -10339,36 +11025,8 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10339
11025
|
const { format: formatDate, parse: parseDate } = useDateTransformer({
|
|
10340
11026
|
format: format2
|
|
10341
11027
|
});
|
|
10342
|
-
const dataTableColumnLabelId = useDataTableColumnLabelId();
|
|
10343
|
-
const labelId = useFieldLabelId();
|
|
10344
|
-
const descriptionIds = useFieldDescriptionIds();
|
|
10345
|
-
const errorMessageIds = useFieldErrorMessageIds();
|
|
10346
|
-
const { printHidden } = usePrintClassNames();
|
|
10347
|
-
const { generatedId, controlId, codeId } = useSetFieldControl(
|
|
10348
|
-
startInputProps?.id,
|
|
10349
|
-
"INPUT",
|
|
10350
|
-
codeProps?.id,
|
|
10351
|
-
Boolean(code),
|
|
10352
|
-
required,
|
|
10353
|
-
status
|
|
10354
|
-
);
|
|
10355
|
-
const setFieldControlFocused = useSetFieldControlFocused();
|
|
10356
|
-
const startInputLabelId = startInputLabel && prefix(`control-start-label-${generatedId}`);
|
|
10357
|
-
const endInputLabelId = endInputLabel && prefix(`control-end-label-${generatedId}`);
|
|
10358
|
-
const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
|
|
10359
|
-
const formatDescriptionId = formatDescription && typeof formatDescription !== "boolean" ? prefix(`control-format-${generatedId}`) : void 0;
|
|
10360
11028
|
const isInTableCell = useIsInTableCell();
|
|
10361
11029
|
variant ??= isInTableCell ? "cell" : "default";
|
|
10362
|
-
const startDisabled = disabled || startInputProps?.disabled;
|
|
10363
|
-
const endDisabled = disabled || endInputProps?.disabled;
|
|
10364
|
-
const bothDisabled = startDisabled && endDisabled;
|
|
10365
|
-
const isAriaDisabled = ariaDisabled === "true" || ariaDisabled === true;
|
|
10366
|
-
const startSoftDisabled = loading || isAriaDisabled || startInputProps?.["aria-disabled"] === "true" || startInputProps?.["aria-disabled"] === true;
|
|
10367
|
-
const endSoftDisabled = loading || isAriaDisabled || endInputProps?.["aria-disabled"] === "true" || endInputProps?.["aria-disabled"] === true;
|
|
10368
|
-
const bothSoftDisabled = startSoftDisabled && endSoftDisabled;
|
|
10369
|
-
const startReadOnly = readOnly || startInputProps?.readOnly;
|
|
10370
|
-
const endReadOnly = readOnly || endInputProps?.readOnly;
|
|
10371
|
-
const bothReadOnly = startReadOnly && endReadOnly;
|
|
10372
11030
|
const [formattedValue, setFormattedValue] = useControllableState(
|
|
10373
11031
|
defaultValue && (defaultValue.start === null || isDate(defaultValue.start)) ? {
|
|
10374
11032
|
start: formatDate(defaultValue.start),
|
|
@@ -10389,6 +11047,13 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10389
11047
|
}),
|
|
10390
11048
|
[parseDate, formattedValue]
|
|
10391
11049
|
);
|
|
11050
|
+
const stringValue = useMemo(
|
|
11051
|
+
() => ({
|
|
11052
|
+
start: dateValue.start && formatISO(dateValue.start, { representation: "date" }),
|
|
11053
|
+
end: dateValue.end && formatISO(dateValue.end, { representation: "date" })
|
|
11054
|
+
}),
|
|
11055
|
+
[dateValue.end, dateValue.start]
|
|
11056
|
+
);
|
|
10392
11057
|
const deferredFormattedValue = useDeferredValue(formattedValue);
|
|
10393
11058
|
const deferredDateValue = useMemo(
|
|
10394
11059
|
() => ({
|
|
@@ -10405,14 +11070,58 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10405
11070
|
const calendarApiRef = useRef(null);
|
|
10406
11071
|
const startContainerRef = useRef(null);
|
|
10407
11072
|
const endContainerRef = useRef(null);
|
|
10408
|
-
const
|
|
10409
|
-
|
|
11073
|
+
const [startInputEl, setStartInputEl] = useState(
|
|
11074
|
+
null
|
|
11075
|
+
);
|
|
11076
|
+
const [endInputEl, setEndInputEl] = useState(null);
|
|
10410
11077
|
const startClearButtonRef = useRef(null);
|
|
10411
11078
|
const endClearButtonRef = useRef(null);
|
|
10412
11079
|
const addonButtonRef = useRef(null);
|
|
10413
11080
|
const popoverRef = useRef(null);
|
|
10414
11081
|
const monthSelectMenuRef = useRef(null);
|
|
10415
11082
|
const yearSelectMenuRef = useRef(null);
|
|
11083
|
+
const {
|
|
11084
|
+
status: formStatus,
|
|
11085
|
+
disabled: formDisabled,
|
|
11086
|
+
setValue: formSetValue,
|
|
11087
|
+
onChange: formOnChange,
|
|
11088
|
+
onBlur: formOnBlur
|
|
11089
|
+
} = useRegisterFormControl(
|
|
11090
|
+
name,
|
|
11091
|
+
stringValue,
|
|
11092
|
+
validate,
|
|
11093
|
+
validationMode
|
|
11094
|
+
);
|
|
11095
|
+
status ??= formStatus;
|
|
11096
|
+
disabled ||= formDisabled;
|
|
11097
|
+
const dataTableColumnLabelId = useDataTableColumnLabelId();
|
|
11098
|
+
const labelId = useFieldLabelId();
|
|
11099
|
+
const descriptionIds = useFieldDescriptionIds();
|
|
11100
|
+
const errorMessageIds = useFieldErrorMessageIds();
|
|
11101
|
+
const { printHidden } = usePrintClassNames();
|
|
11102
|
+
const { generatedId, controlId, codeId } = useRegisterFieldControl(
|
|
11103
|
+
startInputProps?.id,
|
|
11104
|
+
"INPUT",
|
|
11105
|
+
codeProps?.id,
|
|
11106
|
+
Boolean(code),
|
|
11107
|
+
required,
|
|
11108
|
+
status
|
|
11109
|
+
);
|
|
11110
|
+
const setFieldControlFocused = useSetFieldControlFocused();
|
|
11111
|
+
const startInputLabelId = startInputLabel && prefix(`control-start-label-${generatedId}`);
|
|
11112
|
+
const endInputLabelId = endInputLabel && prefix(`control-end-label-${generatedId}`);
|
|
11113
|
+
const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
|
|
11114
|
+
const formatDescriptionId = formatDescription && typeof formatDescription !== "boolean" ? prefix(`control-format-${generatedId}`) : void 0;
|
|
11115
|
+
const startDisabled = disabled || startInputProps?.disabled;
|
|
11116
|
+
const endDisabled = disabled || endInputProps?.disabled;
|
|
11117
|
+
const bothDisabled = startDisabled && endDisabled;
|
|
11118
|
+
const isAriaDisabled = ariaDisabled === "true" || ariaDisabled === true;
|
|
11119
|
+
const startSoftDisabled = loading || isAriaDisabled || startInputProps?.["aria-disabled"] === "true" || startInputProps?.["aria-disabled"] === true;
|
|
11120
|
+
const endSoftDisabled = loading || isAriaDisabled || endInputProps?.["aria-disabled"] === "true" || endInputProps?.["aria-disabled"] === true;
|
|
11121
|
+
const bothSoftDisabled = startSoftDisabled && endSoftDisabled;
|
|
11122
|
+
const startReadOnly = readOnly || startInputProps?.readOnly;
|
|
11123
|
+
const endReadOnly = readOnly || endInputProps?.readOnly;
|
|
11124
|
+
const bothReadOnly = startReadOnly && endReadOnly;
|
|
10416
11125
|
const changePopoverState = useCallback(
|
|
10417
11126
|
(state) => {
|
|
10418
11127
|
setPopoverState(state);
|
|
@@ -10431,11 +11140,17 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10431
11140
|
end: formattedValue.end
|
|
10432
11141
|
};
|
|
10433
11142
|
const newDateValue = { start: dateStart, end: dateValue.end };
|
|
11143
|
+
const newStringValue = {
|
|
11144
|
+
start: newDateValue.start && formatISO(newDateValue.start, { representation: "date" }),
|
|
11145
|
+
end: newDateValue.end && formatISO(newDateValue.end, { representation: "date" })
|
|
11146
|
+
};
|
|
10434
11147
|
onValueChange?.({
|
|
10435
11148
|
formattedValue: newFormattedValue,
|
|
11149
|
+
stringValue: newStringValue,
|
|
10436
11150
|
dateValue: newDateValue
|
|
10437
11151
|
});
|
|
10438
11152
|
setFormattedValue(newFormattedValue);
|
|
11153
|
+
formOnChange(newStringValue);
|
|
10439
11154
|
const calendarApi = calendarApiRef.current;
|
|
10440
11155
|
if (!evt.defaultPrevented && dateStart && calendarApi && !calendarApi.isVisible(dateStart)) {
|
|
10441
11156
|
const month = startOfMonth(dateStart);
|
|
@@ -10444,12 +11159,13 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10444
11159
|
}
|
|
10445
11160
|
},
|
|
10446
11161
|
[
|
|
10447
|
-
|
|
10448
|
-
formattedValue.end,
|
|
11162
|
+
calendarProps,
|
|
10449
11163
|
dateValue.end,
|
|
11164
|
+
formattedValue.end,
|
|
11165
|
+
formOnChange,
|
|
10450
11166
|
onValueChange,
|
|
10451
|
-
|
|
10452
|
-
|
|
11167
|
+
parseDate,
|
|
11168
|
+
setFormattedValue
|
|
10453
11169
|
]
|
|
10454
11170
|
);
|
|
10455
11171
|
const handleEndInputChange = useCallback(
|
|
@@ -10461,11 +11177,17 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10461
11177
|
end: formattedEnd
|
|
10462
11178
|
};
|
|
10463
11179
|
const newDateValue = { start: dateValue.start, end: dateEnd };
|
|
11180
|
+
const newStringValue = {
|
|
11181
|
+
start: newDateValue.start && formatISO(newDateValue.start, { representation: "date" }),
|
|
11182
|
+
end: newDateValue.end && formatISO(newDateValue.end, { representation: "date" })
|
|
11183
|
+
};
|
|
10464
11184
|
onValueChange?.({
|
|
10465
11185
|
formattedValue: newFormattedValue,
|
|
11186
|
+
stringValue: newStringValue,
|
|
10466
11187
|
dateValue: newDateValue
|
|
10467
11188
|
});
|
|
10468
11189
|
setFormattedValue(newFormattedValue);
|
|
11190
|
+
formOnChange(newStringValue);
|
|
10469
11191
|
const calendarApi = calendarApiRef.current;
|
|
10470
11192
|
if (!evt.defaultPrevented && dateEnd && calendarApi && !calendarApi.isVisible(dateEnd)) {
|
|
10471
11193
|
const month = addMonths(
|
|
@@ -10477,12 +11199,13 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10477
11199
|
}
|
|
10478
11200
|
},
|
|
10479
11201
|
[
|
|
10480
|
-
|
|
10481
|
-
formattedValue.start,
|
|
11202
|
+
calendarProps,
|
|
10482
11203
|
dateValue.start,
|
|
11204
|
+
formattedValue.start,
|
|
11205
|
+
formOnChange,
|
|
10483
11206
|
onValueChange,
|
|
10484
|
-
|
|
10485
|
-
|
|
11207
|
+
parseDate,
|
|
11208
|
+
setFormattedValue
|
|
10486
11209
|
]
|
|
10487
11210
|
);
|
|
10488
11211
|
const handleInputFocus = useCallback(
|
|
@@ -10496,11 +11219,13 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10496
11219
|
[setFieldControlFocused, changePopoverState]
|
|
10497
11220
|
);
|
|
10498
11221
|
const handleClearButtonClick = useCallback(
|
|
10499
|
-
(
|
|
10500
|
-
const inputEl = ref.current;
|
|
11222
|
+
(inputEl) => () => {
|
|
10501
11223
|
if (inputEl && inputEl.value !== "") {
|
|
10502
11224
|
setNativeProperty(inputEl, "value", "");
|
|
10503
|
-
const event = new Event("change", {
|
|
11225
|
+
const event = new Event("change", {
|
|
11226
|
+
bubbles: true,
|
|
11227
|
+
cancelable: true
|
|
11228
|
+
});
|
|
10504
11229
|
inputEl.dispatchEvent(event);
|
|
10505
11230
|
if (!event.defaultPrevented) {
|
|
10506
11231
|
inputEl.focus();
|
|
@@ -10512,7 +11237,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10512
11237
|
const handleContainerPointerDown = useCallback(
|
|
10513
11238
|
(input) => (evt) => {
|
|
10514
11239
|
const target = evt.target;
|
|
10515
|
-
const inputEl = input === "start" ?
|
|
11240
|
+
const inputEl = input === "start" ? startInputEl : endInputEl;
|
|
10516
11241
|
if (inputEl && !inputEl.disabled && !target.closest("input, select, textarea, button, a")) {
|
|
10517
11242
|
const cursorIdx = target.closest(`.${prefix("date-range-input")} ~ *`) ? inputEl.value.length : 0;
|
|
10518
11243
|
requestAnimationFrame(() => {
|
|
@@ -10524,7 +11249,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10524
11249
|
});
|
|
10525
11250
|
}
|
|
10526
11251
|
},
|
|
10527
|
-
[prefix]
|
|
11252
|
+
[endInputEl, prefix, startInputEl]
|
|
10528
11253
|
);
|
|
10529
11254
|
const handleAddonButtonClick = useCallback(() => {
|
|
10530
11255
|
setSelectionMode("start");
|
|
@@ -10536,18 +11261,27 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10536
11261
|
start: formatDate(range.start),
|
|
10537
11262
|
end: formatDate(range.end)
|
|
10538
11263
|
};
|
|
10539
|
-
|
|
11264
|
+
const newStringValue = {
|
|
11265
|
+
start: range.start && formatISO(range.start, { representation: "date" }),
|
|
11266
|
+
end: range.end && formatISO(range.end, { representation: "date" })
|
|
11267
|
+
};
|
|
11268
|
+
onValueChange?.({
|
|
11269
|
+
formattedValue: newFormattedValue,
|
|
11270
|
+
stringValue: newStringValue,
|
|
11271
|
+
dateValue: range
|
|
11272
|
+
});
|
|
10540
11273
|
setFormattedValue(newFormattedValue);
|
|
11274
|
+
formOnChange(newStringValue);
|
|
10541
11275
|
if (selectionMode === "start") {
|
|
10542
11276
|
setSelectionMode("end");
|
|
10543
11277
|
if (!popoverState.modal) {
|
|
10544
|
-
|
|
11278
|
+
endInputEl?.focus();
|
|
10545
11279
|
}
|
|
10546
11280
|
} else {
|
|
10547
11281
|
if (!range.start) {
|
|
10548
11282
|
setSelectionMode("start");
|
|
10549
11283
|
if (!popoverState.modal) {
|
|
10550
|
-
|
|
11284
|
+
startInputEl?.focus();
|
|
10551
11285
|
}
|
|
10552
11286
|
} else if (range.end) {
|
|
10553
11287
|
changePopoverState({ open: false, modal: false });
|
|
@@ -10556,12 +11290,15 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10556
11290
|
}
|
|
10557
11291
|
},
|
|
10558
11292
|
[
|
|
10559
|
-
changePopoverState,
|
|
10560
11293
|
formatDate,
|
|
10561
11294
|
onValueChange,
|
|
10562
|
-
|
|
11295
|
+
setFormattedValue,
|
|
11296
|
+
formOnChange,
|
|
10563
11297
|
selectionMode,
|
|
10564
|
-
|
|
11298
|
+
popoverState.modal,
|
|
11299
|
+
endInputEl,
|
|
11300
|
+
startInputEl,
|
|
11301
|
+
changePopoverState
|
|
10565
11302
|
]
|
|
10566
11303
|
);
|
|
10567
11304
|
const handlePopoverOpenAutoFocus = useCallback(
|
|
@@ -10574,11 +11311,11 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10574
11311
|
);
|
|
10575
11312
|
const handlePopoverInteractOutside = useCallback(
|
|
10576
11313
|
(evt) => {
|
|
10577
|
-
if (!popoverState.modal &&
|
|
11314
|
+
if (!popoverState.modal && startInputEl !== evt.target && endInputEl !== evt.target) {
|
|
10578
11315
|
changePopoverState({ open: false, modal: false });
|
|
10579
11316
|
}
|
|
10580
11317
|
},
|
|
10581
|
-
[popoverState.modal, changePopoverState]
|
|
11318
|
+
[popoverState.modal, startInputEl, endInputEl, changePopoverState]
|
|
10582
11319
|
);
|
|
10583
11320
|
const handlePopoverEscapeKeyDown = useCallback(() => {
|
|
10584
11321
|
if (popoverState.modal) {
|
|
@@ -10593,7 +11330,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10593
11330
|
const handleControlBlur = useCallback(
|
|
10594
11331
|
(evt) => {
|
|
10595
11332
|
setFieldControlFocused(false);
|
|
10596
|
-
if (!evt.relatedTarget || !
|
|
11333
|
+
if (!evt.relatedTarget || !startInputEl?.contains(evt.relatedTarget) && !endInputEl?.contains(evt.relatedTarget) && !startClearButtonRef.current?.contains(evt.relatedTarget) && !endClearButtonRef.current?.contains(evt.relatedTarget) && !addonButtonRef.current?.contains(evt.relatedTarget) && !popoverRef.current?.contains(evt.relatedTarget) && !monthSelectMenuRef.current?.contains(evt.relatedTarget) && !yearSelectMenuRef.current?.contains(evt.relatedTarget)) {
|
|
10597
11334
|
const formattedStartDateValue = formatDate(dateValue.start);
|
|
10598
11335
|
const formattedEndDateValue = formatDate(dateValue.end);
|
|
10599
11336
|
if (formattedStartDateValue !== formattedValue.start || formattedEndDateValue !== formattedValue.end) {
|
|
@@ -10601,20 +11338,29 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10601
11338
|
start: formattedStartDateValue,
|
|
10602
11339
|
end: formattedEndDateValue
|
|
10603
11340
|
};
|
|
10604
|
-
onValueChange?.({
|
|
11341
|
+
onValueChange?.({
|
|
11342
|
+
formattedValue: newFormattedValue,
|
|
11343
|
+
stringValue,
|
|
11344
|
+
dateValue
|
|
11345
|
+
});
|
|
10605
11346
|
setFormattedValue(newFormattedValue);
|
|
10606
11347
|
}
|
|
10607
11348
|
onBlurToOutside?.(evt);
|
|
11349
|
+
formOnBlur();
|
|
10608
11350
|
}
|
|
10609
11351
|
},
|
|
10610
11352
|
[
|
|
10611
|
-
|
|
11353
|
+
setFieldControlFocused,
|
|
11354
|
+
startInputEl,
|
|
11355
|
+
endInputEl,
|
|
10612
11356
|
formatDate,
|
|
10613
|
-
|
|
11357
|
+
dateValue,
|
|
10614
11358
|
formattedValue.start,
|
|
11359
|
+
formattedValue.end,
|
|
10615
11360
|
onBlurToOutside,
|
|
11361
|
+
formOnBlur,
|
|
10616
11362
|
onValueChange,
|
|
10617
|
-
|
|
11363
|
+
stringValue,
|
|
10618
11364
|
setFormattedValue
|
|
10619
11365
|
]
|
|
10620
11366
|
);
|
|
@@ -10636,12 +11382,54 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10636
11382
|
const selectedStartDateDescriptionId = selectedDateDescription && descriptionFormattedStart && prefix(`date-range-input-start-selected-${generatedId}`);
|
|
10637
11383
|
const selectedEndDateDescriptionId = selectedDateDescription && descriptionFormattedEnd && prefix(`date-range-input-end-selected-${generatedId}`);
|
|
10638
11384
|
const selectedDateRangeDescriptionId = selectedDateRangeDescription && (descriptionFormattedStart || descriptionFormattedEnd) && prefix(`date-range-input-selected-${generatedId}`);
|
|
11385
|
+
const hiddenInputMin = useMemo(() => {
|
|
11386
|
+
const minAllowedDate = calcMinAllowedDate(minDate, minMonth, minYear);
|
|
11387
|
+
return minAllowedDate && formatISO(minAllowedDate, { representation: "date" });
|
|
11388
|
+
}, [minDate, minMonth, minYear]);
|
|
11389
|
+
const hiddenEndInputMin = useMemo(() => {
|
|
11390
|
+
if (!hiddenInputMin) {
|
|
11391
|
+
return stringValue.start ?? void 0;
|
|
11392
|
+
}
|
|
11393
|
+
if (!dateValue.start) {
|
|
11394
|
+
return hiddenInputMin;
|
|
11395
|
+
}
|
|
11396
|
+
const minEndAllowedDate = max([dateValue.start, parseISO(hiddenInputMin)]);
|
|
11397
|
+
return formatISO(minEndAllowedDate, { representation: "date" });
|
|
11398
|
+
}, [dateValue.start, hiddenInputMin, stringValue.start]);
|
|
11399
|
+
const hiddenInputMax = useMemo(() => {
|
|
11400
|
+
const maxAllowedDate = calcMaxAllowedDate(maxDate, maxMonth, maxYear);
|
|
11401
|
+
return maxAllowedDate && formatISO(maxAllowedDate, { representation: "date" });
|
|
11402
|
+
}, [maxDate, maxMonth, maxYear]);
|
|
11403
|
+
const handleHiddenStartInputValueChange = (value) => {
|
|
11404
|
+
setFormattedValue({
|
|
11405
|
+
start: formatDate(value && parseISO(value)),
|
|
11406
|
+
end: formattedValue.end
|
|
11407
|
+
});
|
|
11408
|
+
formSetValue({ start: value, end: stringValue.end });
|
|
11409
|
+
};
|
|
11410
|
+
const handleHiddenEndInputValueChange = (value) => {
|
|
11411
|
+
setFormattedValue({
|
|
11412
|
+
start: formattedValue.start,
|
|
11413
|
+
end: formatDate(value && parseISO(value))
|
|
11414
|
+
});
|
|
11415
|
+
formSetValue({ start: stringValue.start, end: value });
|
|
11416
|
+
};
|
|
11417
|
+
useResetControlOnFormReset(
|
|
11418
|
+
startInputEl,
|
|
11419
|
+
stringValue.start,
|
|
11420
|
+
handleHiddenStartInputValueChange
|
|
11421
|
+
);
|
|
11422
|
+
useResetControlOnFormReset(
|
|
11423
|
+
endInputEl,
|
|
11424
|
+
stringValue.end,
|
|
11425
|
+
handleHiddenEndInputValueChange
|
|
11426
|
+
);
|
|
10639
11427
|
const combinedStartContainerRef = useCombinedRef(
|
|
10640
11428
|
startContainerRef,
|
|
10641
11429
|
startContainerProps?.ref
|
|
10642
11430
|
);
|
|
10643
11431
|
const combinedStartInputRef = useCombinedRef(
|
|
10644
|
-
|
|
11432
|
+
setStartInputEl,
|
|
10645
11433
|
startInputProps?.ref
|
|
10646
11434
|
);
|
|
10647
11435
|
const combinedStartClearButtonRef = useCombinedRef(
|
|
@@ -10652,7 +11440,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10652
11440
|
endContainerRef,
|
|
10653
11441
|
endContainerProps?.ref
|
|
10654
11442
|
);
|
|
10655
|
-
const combinedEndInputRef = useCombinedRef(
|
|
11443
|
+
const combinedEndInputRef = useCombinedRef(setEndInputEl, endInputProps?.ref);
|
|
10656
11444
|
const combinedEndClearButtonRef = useCombinedRef(
|
|
10657
11445
|
endClearButtonRef,
|
|
10658
11446
|
endClearButtonProps?.ref
|
|
@@ -10771,6 +11559,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10771
11559
|
handleControlBlur
|
|
10772
11560
|
),
|
|
10773
11561
|
style: { ...cssVars, ...startInputProps?.style },
|
|
11562
|
+
autoComplete: "off",
|
|
10774
11563
|
...dataAttrs,
|
|
10775
11564
|
"aria-invalid": status === "invalid" || void 0,
|
|
10776
11565
|
"aria-labelledby": startInputProps?.["aria-labelledby"] ?? (startInputProps?.["aria-label"] === void 0 ? combineAriaIds(
|
|
@@ -10804,7 +11593,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10804
11593
|
),
|
|
10805
11594
|
onClick: combineEventHandlers(
|
|
10806
11595
|
startClearButtonProps?.onClick,
|
|
10807
|
-
handleClearButtonClick(
|
|
11596
|
+
handleClearButtonClick(startInputEl),
|
|
10808
11597
|
{ checkDefaultPrevented: true }
|
|
10809
11598
|
),
|
|
10810
11599
|
ref: combinedStartClearButtonRef
|
|
@@ -10882,6 +11671,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10882
11671
|
handleControlBlur
|
|
10883
11672
|
),
|
|
10884
11673
|
style: { ...cssVars, ...endInputProps?.style },
|
|
11674
|
+
autoComplete: "off",
|
|
10885
11675
|
...dataAttrs,
|
|
10886
11676
|
"aria-invalid": status === "invalid" || void 0,
|
|
10887
11677
|
"aria-labelledby": endInputProps?.["aria-labelledby"] ?? (endInputProps?.["aria-label"] === void 0 ? combineAriaIds(
|
|
@@ -10915,7 +11705,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10915
11705
|
),
|
|
10916
11706
|
onClick: combineEventHandlers(
|
|
10917
11707
|
endClearButtonProps?.onClick,
|
|
10918
|
-
handleClearButtonClick(
|
|
11708
|
+
handleClearButtonClick(endInputEl),
|
|
10919
11709
|
{ checkDefaultPrevented: true }
|
|
10920
11710
|
),
|
|
10921
11711
|
ref: combinedEndClearButtonRef
|
|
@@ -11043,7 +11833,43 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
11043
11833
|
selectedDateRangeDescriptionId && /* @__PURE__ */ jsx("span", { hidden: true, id: selectedDateRangeDescriptionId, children: selectedDateRangeDescription({
|
|
11044
11834
|
start: descriptionFormattedStart,
|
|
11045
11835
|
end: descriptionFormattedEnd
|
|
11046
|
-
}) })
|
|
11836
|
+
}) }),
|
|
11837
|
+
/* @__PURE__ */ jsx(
|
|
11838
|
+
HiddenFormControl,
|
|
11839
|
+
{
|
|
11840
|
+
actualElement: startInputEl,
|
|
11841
|
+
onChange: (evt) => handleHiddenStartInputValueChange(evt.target.value),
|
|
11842
|
+
name,
|
|
11843
|
+
type: "date",
|
|
11844
|
+
value: stringValue.start ?? "",
|
|
11845
|
+
required: required || startInputProps?.required,
|
|
11846
|
+
disabled: startDisabled,
|
|
11847
|
+
readOnly: startSoftDisabled || startReadOnly,
|
|
11848
|
+
autoComplete: startInputProps?.autoComplete,
|
|
11849
|
+
min: hiddenInputMin,
|
|
11850
|
+
max: hiddenInputMax,
|
|
11851
|
+
form,
|
|
11852
|
+
children: /* @__PURE__ */ jsx("input", {})
|
|
11853
|
+
}
|
|
11854
|
+
),
|
|
11855
|
+
/* @__PURE__ */ jsx(
|
|
11856
|
+
HiddenFormControl,
|
|
11857
|
+
{
|
|
11858
|
+
actualElement: endInputEl,
|
|
11859
|
+
onChange: (evt) => handleHiddenEndInputValueChange(evt.target.value),
|
|
11860
|
+
name,
|
|
11861
|
+
type: "date",
|
|
11862
|
+
value: stringValue.end ?? "",
|
|
11863
|
+
required: required || endInputProps?.required,
|
|
11864
|
+
disabled: endDisabled,
|
|
11865
|
+
readOnly: endSoftDisabled || endReadOnly,
|
|
11866
|
+
autoComplete: endInputProps?.autoComplete,
|
|
11867
|
+
min: hiddenEndInputMin,
|
|
11868
|
+
max: hiddenInputMax,
|
|
11869
|
+
form,
|
|
11870
|
+
children: /* @__PURE__ */ jsx("input", {})
|
|
11871
|
+
}
|
|
11872
|
+
)
|
|
11047
11873
|
]
|
|
11048
11874
|
}
|
|
11049
11875
|
) });
|
|
@@ -11938,7 +12764,219 @@ const FieldGroupTitle = forwardRef(function FieldGroupTitle2({
|
|
|
11938
12764
|
ref: forwardedRef
|
|
11939
12765
|
}
|
|
11940
12766
|
);
|
|
11941
|
-
});
|
|
12767
|
+
});
|
|
12768
|
+
const Form = forwardRef(function Form2({
|
|
12769
|
+
asChild,
|
|
12770
|
+
validationMode,
|
|
12771
|
+
errorDisplayMode,
|
|
12772
|
+
validate,
|
|
12773
|
+
externalErrors,
|
|
12774
|
+
nativeErrorMessages,
|
|
12775
|
+
className,
|
|
12776
|
+
confirmUnloadWhenDirty,
|
|
12777
|
+
disableNativeValidations,
|
|
12778
|
+
onSubmit,
|
|
12779
|
+
onReset,
|
|
12780
|
+
onValueChange,
|
|
12781
|
+
submitErrorMessage,
|
|
12782
|
+
apiRef,
|
|
12783
|
+
...otherProps
|
|
12784
|
+
}, forwardedRef) {
|
|
12785
|
+
const [locale7] = useLocale();
|
|
12786
|
+
submitErrorMessage ??= locale7.Form.submitErrorMessage;
|
|
12787
|
+
const prefix = usePrefix();
|
|
12788
|
+
const formRef = useRef(null);
|
|
12789
|
+
const { addToast, removeToast } = useToastManager();
|
|
12790
|
+
const formContext = useCreateFormContext({
|
|
12791
|
+
validationMode,
|
|
12792
|
+
errorDisplayMode,
|
|
12793
|
+
validate,
|
|
12794
|
+
externalErrors,
|
|
12795
|
+
nativeErrorMessages,
|
|
12796
|
+
disableNativeValidations,
|
|
12797
|
+
onValueChange,
|
|
12798
|
+
formRef,
|
|
12799
|
+
apiRef
|
|
12800
|
+
});
|
|
12801
|
+
const store = formContext.store;
|
|
12802
|
+
const errorToastIdRef = useRef(null);
|
|
12803
|
+
const handleSubmit = async (evt) => {
|
|
12804
|
+
evt.preventDefault();
|
|
12805
|
+
const { submitting, actions } = store.getState();
|
|
12806
|
+
if (submitting) return;
|
|
12807
|
+
removeToast(errorToastIdRef.current);
|
|
12808
|
+
store.setState(({ submitCount }) => ({
|
|
12809
|
+
submitting: true,
|
|
12810
|
+
submitCount: submitCount + 1
|
|
12811
|
+
}));
|
|
12812
|
+
actions.clearSubmitErrors();
|
|
12813
|
+
const formValues = actions.getValue();
|
|
12814
|
+
const formData = new FormData(evt.currentTarget);
|
|
12815
|
+
actions.setTouched();
|
|
12816
|
+
try {
|
|
12817
|
+
if (await actions.validate()) {
|
|
12818
|
+
const result = await onSubmit?.(formValues, formData, evt);
|
|
12819
|
+
let submitErrors;
|
|
12820
|
+
if (isFormValidationErrors(result)) {
|
|
12821
|
+
submitErrors = normalizeFormValidationErrors(result);
|
|
12822
|
+
}
|
|
12823
|
+
if (submitErrors && Object.keys(submitErrors).length > 0) {
|
|
12824
|
+
store.setState({ submitErrors });
|
|
12825
|
+
} else {
|
|
12826
|
+
actions.setPristine();
|
|
12827
|
+
return;
|
|
12828
|
+
}
|
|
12829
|
+
}
|
|
12830
|
+
const toFocus = actions.firstInvalid();
|
|
12831
|
+
if (toFocus) {
|
|
12832
|
+
void Promise.resolve().then(() => actions.focus(toFocus));
|
|
12833
|
+
}
|
|
12834
|
+
} catch (error) {
|
|
12835
|
+
if (process.env.NODE_ENV !== "production") {
|
|
12836
|
+
console.error(error);
|
|
12837
|
+
}
|
|
12838
|
+
const message = typeof submitErrorMessage === "function" ? submitErrorMessage(error) : submitErrorMessage;
|
|
12839
|
+
if (message && typeof message !== "boolean") {
|
|
12840
|
+
errorToastIdRef.current = addToast(message, { severity: "danger" });
|
|
12841
|
+
}
|
|
12842
|
+
} finally {
|
|
12843
|
+
store.setState({ submitting: false });
|
|
12844
|
+
}
|
|
12845
|
+
};
|
|
12846
|
+
const handleReset = () => {
|
|
12847
|
+
const { submitting } = store.getState();
|
|
12848
|
+
if (submitting) return;
|
|
12849
|
+
store.setState({
|
|
12850
|
+
submitCount: 0,
|
|
12851
|
+
touched: {},
|
|
12852
|
+
dirty: {},
|
|
12853
|
+
nativeErrors: {},
|
|
12854
|
+
formValidateErrors: {},
|
|
12855
|
+
validateErrors: {},
|
|
12856
|
+
submitErrors: {},
|
|
12857
|
+
externalErrors: {}
|
|
12858
|
+
});
|
|
12859
|
+
};
|
|
12860
|
+
const handleBeforeUnload = useEffectEvent((event) => {
|
|
12861
|
+
event.preventDefault();
|
|
12862
|
+
event.returnValue = "";
|
|
12863
|
+
});
|
|
12864
|
+
useEffect(() => {
|
|
12865
|
+
if (confirmUnloadWhenDirty) {
|
|
12866
|
+
let prevCleanup;
|
|
12867
|
+
const unsubscribe = store.subscribe(
|
|
12868
|
+
({ submitting, actions }) => !submitting && actions.isDirty(),
|
|
12869
|
+
(dirty) => {
|
|
12870
|
+
prevCleanup?.();
|
|
12871
|
+
if (dirty) {
|
|
12872
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
12873
|
+
prevCleanup = () => window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
12874
|
+
} else {
|
|
12875
|
+
prevCleanup = void 0;
|
|
12876
|
+
}
|
|
12877
|
+
},
|
|
12878
|
+
{ fireImmediately: true }
|
|
12879
|
+
);
|
|
12880
|
+
return () => {
|
|
12881
|
+
unsubscribe();
|
|
12882
|
+
prevCleanup?.();
|
|
12883
|
+
};
|
|
12884
|
+
}
|
|
12885
|
+
}, [confirmUnloadWhenDirty, store]);
|
|
12886
|
+
const combinedRef = useCombinedRef(formRef, forwardedRef);
|
|
12887
|
+
const As = asChild ? Slot : "form";
|
|
12888
|
+
return /* @__PURE__ */ jsx(FormContext.Provider, { value: formContext, children: /* @__PURE__ */ jsx(
|
|
12889
|
+
As,
|
|
12890
|
+
{
|
|
12891
|
+
noValidate: true,
|
|
12892
|
+
className: cx(prefix("form"), className),
|
|
12893
|
+
onSubmit: handleSubmit,
|
|
12894
|
+
onReset: combineEventHandlers(onReset, handleReset, {
|
|
12895
|
+
checkDefaultPrevented: true
|
|
12896
|
+
}),
|
|
12897
|
+
...otherProps,
|
|
12898
|
+
ref: combinedRef
|
|
12899
|
+
}
|
|
12900
|
+
) });
|
|
12901
|
+
});
|
|
12902
|
+
function FormError({
|
|
12903
|
+
name,
|
|
12904
|
+
errorDisplayMode,
|
|
12905
|
+
nativeErrorMessages,
|
|
12906
|
+
children
|
|
12907
|
+
}) {
|
|
12908
|
+
const [locale7] = useLocale();
|
|
12909
|
+
const {
|
|
12910
|
+
errorDisplayMode: formErrorDisplayMode,
|
|
12911
|
+
nativeErrorMessages: formNativeErrorMessages,
|
|
12912
|
+
store
|
|
12913
|
+
} = useFormContext();
|
|
12914
|
+
const fieldControlName = useFieldControlName();
|
|
12915
|
+
errorDisplayMode ??= formErrorDisplayMode;
|
|
12916
|
+
name ??= fieldControlName ?? "";
|
|
12917
|
+
const touched = useStore$1(store, ({ actions }) => actions.isTouched(name));
|
|
12918
|
+
const nativeErrors = useStore$1(
|
|
12919
|
+
store,
|
|
12920
|
+
({ nativeErrors: nativeErrors2 }) => nativeErrors2[name]
|
|
12921
|
+
);
|
|
12922
|
+
const validateErrors = useStore$1(
|
|
12923
|
+
store,
|
|
12924
|
+
({ validateErrors: validateErrors2 }) => validateErrors2[name]
|
|
12925
|
+
);
|
|
12926
|
+
const formValidateErrors = useStore$1(
|
|
12927
|
+
store,
|
|
12928
|
+
({ formValidateErrors: formValidateErrors2 }) => formValidateErrors2[name]
|
|
12929
|
+
);
|
|
12930
|
+
const submitErrors = useStore$1(
|
|
12931
|
+
store,
|
|
12932
|
+
({ submitErrors: submitErrors2 }) => submitErrors2[name]
|
|
12933
|
+
);
|
|
12934
|
+
const externalErrors = useStore$1(
|
|
12935
|
+
store,
|
|
12936
|
+
({ externalErrors: externalErrors2 }) => externalErrors2[name]
|
|
12937
|
+
);
|
|
12938
|
+
let messages = touched ? [
|
|
12939
|
+
...(nativeErrors ?? []).map(
|
|
12940
|
+
(err) => nativeErrorMessage(nativeErrorMessages, err) ?? nativeErrorMessage(formNativeErrorMessages, err) ?? nativeErrorMessage(locale7.Form.nativeErrorMessages, err)
|
|
12941
|
+
),
|
|
12942
|
+
...validateErrors ?? [],
|
|
12943
|
+
...formValidateErrors ?? [],
|
|
12944
|
+
...submitErrors ?? [],
|
|
12945
|
+
...externalErrors ?? []
|
|
12946
|
+
] : [];
|
|
12947
|
+
if (errorDisplayMode === "first") {
|
|
12948
|
+
messages = messages.slice(0, 1);
|
|
12949
|
+
}
|
|
12950
|
+
children ??= (messages2) => name === "" ? /* @__PURE__ */ jsx(Alert, { severity: "danger", children: messages2.length > 1 ? /* @__PURE__ */ jsx("ul", { children: messages2.map((message, i) => /* @__PURE__ */ jsx("li", { children: message }, i)) }) : messages2[0] }) : /* @__PURE__ */ jsx(FeedbackList, { children: messages2.map((message, i) => /* @__PURE__ */ jsx(Feedback, { type: "error", children: message }, i)) });
|
|
12951
|
+
return messages.length > 0 && children(messages);
|
|
12952
|
+
}
|
|
12953
|
+
function nativeErrorMessage(nativeErrorMessages, nativeError) {
|
|
12954
|
+
const message = nativeErrorMessages?.[nativeError.key];
|
|
12955
|
+
return typeof message === "function" ? message(nativeError.element) : message;
|
|
12956
|
+
}
|
|
12957
|
+
function FormReset({ children, ...otherProps }) {
|
|
12958
|
+
const submitting = useFormSubmitting();
|
|
12959
|
+
const submittingProps = submitting ? { disabled: true } : {};
|
|
12960
|
+
return cloneElement(children, {
|
|
12961
|
+
type: "reset",
|
|
12962
|
+
...otherProps,
|
|
12963
|
+
...submittingProps
|
|
12964
|
+
});
|
|
12965
|
+
}
|
|
12966
|
+
function FormState({ name, children }) {
|
|
12967
|
+
const state = useFormState(name);
|
|
12968
|
+
return children(state);
|
|
12969
|
+
}
|
|
12970
|
+
function FormSubmit({ children, ...otherProps }) {
|
|
12971
|
+
const submitting = useFormSubmitting();
|
|
12972
|
+
const supportsLoading = children.type === Button || children.type === IconButton;
|
|
12973
|
+
const submittingProps = submitting ? supportsLoading ? { loading: true } : { disabled: true } : {};
|
|
12974
|
+
return cloneElement(children, {
|
|
12975
|
+
type: "submit",
|
|
12976
|
+
...otherProps,
|
|
12977
|
+
...submittingProps
|
|
12978
|
+
});
|
|
12979
|
+
}
|
|
11942
12980
|
const Heading = forwardRef(function Heading2({ as, asChild, level = 2, className, ...otherProps }, forwardedRef) {
|
|
11943
12981
|
const prefix = usePrefix();
|
|
11944
12982
|
const As = asChild ? Slot : as ?? `h${level}`;
|
|
@@ -12161,7 +13199,7 @@ function validateNumericTransformerOptions({
|
|
|
12161
13199
|
throw new Error("Decimal and group separators must be different.");
|
|
12162
13200
|
}
|
|
12163
13201
|
}
|
|
12164
|
-
const MOCK_CHANGE_META = {
|
|
13202
|
+
const MOCK_CHANGE_META$1 = {
|
|
12165
13203
|
from: { start: 0, end: 0 },
|
|
12166
13204
|
to: { start: 0, end: 0 },
|
|
12167
13205
|
lastValue: ""
|
|
@@ -12172,7 +13210,7 @@ function parseNumericValue(formattedValue, options = {}) {
|
|
|
12172
13210
|
const isNegative = isNumericStringNegative(formattedValue);
|
|
12173
13211
|
const stringValue = `${isNegative ? "-" : ""}${removeNumericFormat(
|
|
12174
13212
|
formattedValue,
|
|
12175
|
-
MOCK_CHANGE_META,
|
|
13213
|
+
MOCK_CHANGE_META$1,
|
|
12176
13214
|
transformOptions(options)
|
|
12177
13215
|
)}`;
|
|
12178
13216
|
return normalizeNumericString(
|
|
@@ -12206,12 +13244,103 @@ function transformOptions({
|
|
|
12206
13244
|
...otherOptions
|
|
12207
13245
|
};
|
|
12208
13246
|
}
|
|
13247
|
+
const MOCK_CHANGE_META = {
|
|
13248
|
+
from: { start: 0, end: 0 },
|
|
13249
|
+
to: { start: 0, end: 0 },
|
|
13250
|
+
lastValue: ""
|
|
13251
|
+
};
|
|
13252
|
+
function validateNumericProps({
|
|
13253
|
+
valueIsInteger,
|
|
13254
|
+
precision,
|
|
13255
|
+
scale,
|
|
13256
|
+
decimalSeparator,
|
|
13257
|
+
groupSeparator,
|
|
13258
|
+
minString,
|
|
13259
|
+
maxString,
|
|
13260
|
+
exclusiveMinString,
|
|
13261
|
+
exclusiveMaxString
|
|
13262
|
+
}) {
|
|
13263
|
+
validateNumericTransformerOptions({
|
|
13264
|
+
valueIsInteger,
|
|
13265
|
+
scale,
|
|
13266
|
+
decimalSeparator,
|
|
13267
|
+
groupSeparator
|
|
13268
|
+
});
|
|
13269
|
+
if (precision != null && scale == null) {
|
|
13270
|
+
throw new Error(
|
|
13271
|
+
"The scale cannot be set to `null` when a precision is provided."
|
|
13272
|
+
);
|
|
13273
|
+
}
|
|
13274
|
+
if (precision != null && (precision <= 0 || Math.floor(precision) !== precision)) {
|
|
13275
|
+
throw new RangeError("The precision must be a positive integer.");
|
|
13276
|
+
}
|
|
13277
|
+
if (precision != null && scale >= precision) {
|
|
13278
|
+
throw new RangeError("The scale must be less than the precision.");
|
|
13279
|
+
}
|
|
13280
|
+
const lowerLimit = minString && exclusiveMinString ? compareNumericStrings(minString, exclusiveMinString) <= 0 ? exclusiveMinString : minString : minString || exclusiveMinString;
|
|
13281
|
+
const upperLimit = maxString && exclusiveMaxString ? compareNumericStrings(maxString, exclusiveMaxString) >= 0 ? exclusiveMaxString : maxString : maxString || exclusiveMaxString;
|
|
13282
|
+
if (lowerLimit && upperLimit && compareNumericStrings(lowerLimit, upperLimit) > 0) {
|
|
13283
|
+
throw new RangeError(
|
|
13284
|
+
"`min`/`exclusiveMin` should not be greater than `max`/`exclusiveMax`."
|
|
13285
|
+
);
|
|
13286
|
+
}
|
|
13287
|
+
}
|
|
13288
|
+
function valueToRNFString(value, valueIsInteger, formatProps) {
|
|
13289
|
+
if (typeof value === "string" && !formatProps.valueIsNumericString) {
|
|
13290
|
+
return value;
|
|
13291
|
+
}
|
|
13292
|
+
let stringValue = numericToString(value);
|
|
13293
|
+
if (valueIsInteger && formatProps.decimalScale) {
|
|
13294
|
+
stringValue = numericStringIntToFloat(
|
|
13295
|
+
stringValue,
|
|
13296
|
+
formatProps.decimalScale
|
|
13297
|
+
);
|
|
13298
|
+
}
|
|
13299
|
+
return formatProps.valueIsNumericString ? stringValue : numericFormatter(stringValue, formatProps);
|
|
13300
|
+
}
|
|
13301
|
+
function valueToStringValue(value, valueIsInteger, formatProps) {
|
|
13302
|
+
if (typeof value !== "string" || formatProps.valueIsNumericString) {
|
|
13303
|
+
return normalizeNumericString(numericToString(value));
|
|
13304
|
+
}
|
|
13305
|
+
let stringValue = removeNumericFormat(value, MOCK_CHANGE_META, formatProps);
|
|
13306
|
+
if (valueIsInteger && formatProps.decimalScale) {
|
|
13307
|
+
stringValue = numericStringFloatToInt(
|
|
13308
|
+
stringValue,
|
|
13309
|
+
formatProps.decimalScale
|
|
13310
|
+
);
|
|
13311
|
+
}
|
|
13312
|
+
return normalizeNumericString(stringValue);
|
|
13313
|
+
}
|
|
13314
|
+
function transformNumberFormatValues({ formattedValue, value, floatValue }, valueIsInteger, scale) {
|
|
13315
|
+
if (!valueIsInteger || !scale || Number.isNaN(floatValue) || floatValue == null) {
|
|
13316
|
+
return {
|
|
13317
|
+
formattedValue,
|
|
13318
|
+
stringValue: normalizeNumericString(value),
|
|
13319
|
+
numberValue: Number.isNaN(floatValue) || floatValue == null ? null : floatValue
|
|
13320
|
+
};
|
|
13321
|
+
}
|
|
13322
|
+
const stringValue = normalizeNumericString(
|
|
13323
|
+
numericStringFloatToInt(value, scale)
|
|
13324
|
+
);
|
|
13325
|
+
return { formattedValue, stringValue, numberValue: +stringValue };
|
|
13326
|
+
}
|
|
13327
|
+
function scaleToStep(valueIsInteger, scale) {
|
|
13328
|
+
if (valueIsInteger || scale === 0) {
|
|
13329
|
+
return void 0;
|
|
13330
|
+
}
|
|
13331
|
+
if (scale === void 0) {
|
|
13332
|
+
return "any";
|
|
13333
|
+
}
|
|
13334
|
+
return `0.${"0".repeat(scale - 1)}1`;
|
|
13335
|
+
}
|
|
12209
13336
|
const NumericInput = forwardRef(function NumericInput2({
|
|
13337
|
+
name,
|
|
12210
13338
|
defaultValue,
|
|
12211
|
-
value,
|
|
13339
|
+
value: controlledValue,
|
|
12212
13340
|
valueIsUnformattedString = false,
|
|
12213
13341
|
valueIsInteger = false,
|
|
12214
13342
|
onValueChange,
|
|
13343
|
+
onBlurToOutside,
|
|
12215
13344
|
precision,
|
|
12216
13345
|
scale,
|
|
12217
13346
|
fixedScale = scale != null,
|
|
@@ -12219,11 +13348,20 @@ const NumericInput = forwardRef(function NumericInput2({
|
|
|
12219
13348
|
groupDigits = false,
|
|
12220
13349
|
groupingStyle,
|
|
12221
13350
|
groupSeparator,
|
|
13351
|
+
prefix,
|
|
13352
|
+
suffix,
|
|
12222
13353
|
min: min2,
|
|
12223
13354
|
max: max2,
|
|
12224
13355
|
exclusiveMin,
|
|
12225
13356
|
exclusiveMax,
|
|
12226
|
-
|
|
13357
|
+
validate,
|
|
13358
|
+
validationMode,
|
|
13359
|
+
required,
|
|
13360
|
+
disabled,
|
|
13361
|
+
readOnly,
|
|
13362
|
+
status,
|
|
13363
|
+
autoComplete,
|
|
13364
|
+
form,
|
|
12227
13365
|
...otherProps
|
|
12228
13366
|
}, forwardedRef) {
|
|
12229
13367
|
const minString = numericToString(min2);
|
|
@@ -12247,14 +13385,43 @@ const NumericInput = forwardRef(function NumericInput2({
|
|
|
12247
13385
|
exclusiveMaxString
|
|
12248
13386
|
});
|
|
12249
13387
|
}
|
|
12250
|
-
const
|
|
12251
|
-
|
|
12252
|
-
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
|
|
12256
|
-
|
|
13388
|
+
const allowNegative = (!minString || compareNumericStrings(minString, "0") < 0) && (!exclusiveMinString || compareNumericStrings(exclusiveMinString, "0") < 0);
|
|
13389
|
+
const formatProps = useMemo(
|
|
13390
|
+
() => ({
|
|
13391
|
+
valueIsNumericString: valueIsUnformattedString,
|
|
13392
|
+
decimalScale: scale ?? void 0,
|
|
13393
|
+
fixedDecimalScale: fixedScale,
|
|
13394
|
+
decimalSeparator,
|
|
13395
|
+
thousandSeparator: groupDigits ? groupSeparator : "",
|
|
13396
|
+
thousandsGroupStyle: groupDigits ? groupingStyle : "none",
|
|
13397
|
+
prefix,
|
|
13398
|
+
suffix,
|
|
13399
|
+
allowNegative
|
|
13400
|
+
}),
|
|
13401
|
+
[
|
|
13402
|
+
allowNegative,
|
|
13403
|
+
decimalSeparator,
|
|
13404
|
+
fixedScale,
|
|
13405
|
+
groupDigits,
|
|
13406
|
+
groupSeparator,
|
|
13407
|
+
groupingStyle,
|
|
13408
|
+
prefix,
|
|
13409
|
+
scale,
|
|
13410
|
+
suffix,
|
|
13411
|
+
valueIsUnformattedString
|
|
13412
|
+
]
|
|
12257
13413
|
);
|
|
13414
|
+
const [inputEl, setInputEl] = useState(null);
|
|
13415
|
+
const [value, setValue] = useControllableState(defaultValue, controlledValue);
|
|
13416
|
+
const stringValue = useMemo(
|
|
13417
|
+
() => valueToStringValue(value, valueIsInteger, formatProps),
|
|
13418
|
+
[formatProps, value, valueIsInteger]
|
|
13419
|
+
);
|
|
13420
|
+
const rnfString = useMemo(
|
|
13421
|
+
() => valueToRNFString(value, valueIsInteger, formatProps),
|
|
13422
|
+
[formatProps, value, valueIsInteger]
|
|
13423
|
+
);
|
|
13424
|
+
const prevStringValueRef = useRef(stringValue);
|
|
12258
13425
|
const isAllowed = useCallback(
|
|
12259
13426
|
(values) => {
|
|
12260
13427
|
const valueRepresentations = transformNumberFormatValues(
|
|
@@ -12262,41 +13429,53 @@ const NumericInput = forwardRef(function NumericInput2({
|
|
|
12262
13429
|
valueIsInteger,
|
|
12263
13430
|
scale
|
|
12264
13431
|
);
|
|
12265
|
-
const { stringValue } = valueRepresentations;
|
|
12266
|
-
|
|
13432
|
+
const { stringValue: stringValue2 } = valueRepresentations;
|
|
13433
|
+
const prevStringValue = prevStringValueRef.current;
|
|
13434
|
+
if (stringValue2) {
|
|
12267
13435
|
if (precision != null) {
|
|
12268
|
-
const isNegative = isNumericStringNegative(
|
|
13436
|
+
const isNegative = isNumericStringNegative(stringValue2);
|
|
13437
|
+
const prevIsNegative = isNumericStringNegative(prevStringValue);
|
|
12269
13438
|
if (valueIsInteger) {
|
|
12270
|
-
|
|
12271
|
-
|
|
13439
|
+
const curPrecision = stringValue2.length - (isNegative ? 1 : 0);
|
|
13440
|
+
if (curPrecision > precision) {
|
|
13441
|
+
const prevPrecision = prevStringValue.length - (prevIsNegative ? 1 : 0);
|
|
13442
|
+
if (curPrecision > prevPrecision) {
|
|
13443
|
+
return false;
|
|
13444
|
+
}
|
|
12272
13445
|
}
|
|
12273
13446
|
} else {
|
|
12274
|
-
const decimalSeparatorIndex =
|
|
12275
|
-
const decimal = decimalSeparatorIndex === -1 ?
|
|
12276
|
-
|
|
12277
|
-
|
|
13447
|
+
const decimalSeparatorIndex = stringValue2.indexOf(".");
|
|
13448
|
+
const decimal = decimalSeparatorIndex === -1 ? stringValue2 : stringValue2.slice(0, decimalSeparatorIndex);
|
|
13449
|
+
const curDecimalPrecision = decimal.length - (isNegative ? 1 : 0);
|
|
13450
|
+
if (curDecimalPrecision > precision - scale) {
|
|
13451
|
+
const prevDecimalSeparatorIndex = prevStringValue.indexOf(".");
|
|
13452
|
+
const prevDecimal = prevDecimalSeparatorIndex === -1 ? prevStringValue : prevStringValue.slice(0, prevDecimalSeparatorIndex);
|
|
13453
|
+
const prevDecimalPrecision = prevDecimal.length - (prevIsNegative ? 1 : 0);
|
|
13454
|
+
if (curDecimalPrecision > prevDecimalPrecision) {
|
|
13455
|
+
return false;
|
|
13456
|
+
}
|
|
12278
13457
|
}
|
|
12279
13458
|
}
|
|
12280
13459
|
}
|
|
12281
|
-
if (minString && (compareNumericStrings(minString, "0") < 0 && compareNumericStrings(
|
|
13460
|
+
if (minString && (compareNumericStrings(minString, "0") < 0 && compareNumericStrings(stringValue2, minString) < 0 || compareNumericStrings(minString, "0") >= 0 && compareNumericStrings(stringValue2, "0") < 0) && compareNumericStrings(stringValue2, prevStringValue) < 0) {
|
|
12282
13461
|
return false;
|
|
12283
13462
|
}
|
|
12284
|
-
if (maxString && (compareNumericStrings(maxString, "0") > 0 && compareNumericStrings(
|
|
13463
|
+
if (maxString && (compareNumericStrings(maxString, "0") > 0 && compareNumericStrings(stringValue2, maxString) > 0 || compareNumericStrings(maxString, "0") <= 0 && compareNumericStrings(stringValue2, "0") > 0) && compareNumericStrings(stringValue2, prevStringValue) > 0) {
|
|
12285
13464
|
return false;
|
|
12286
13465
|
}
|
|
12287
|
-
if (exclusiveMinString && (compareNumericStrings(exclusiveMinString, "0") < 0 && compareNumericStrings(
|
|
13466
|
+
if (exclusiveMinString && (compareNumericStrings(exclusiveMinString, "0") < 0 && compareNumericStrings(stringValue2, exclusiveMinString) <= 0 || compareNumericStrings(exclusiveMinString, "0") >= 0 && compareNumericStrings(stringValue2, "0") < 0) && compareNumericStrings(stringValue2, prevStringValue) < 0) {
|
|
12288
13467
|
return false;
|
|
12289
13468
|
}
|
|
12290
|
-
if (exclusiveMaxString && (compareNumericStrings(exclusiveMaxString, "0") > 0 && compareNumericStrings(
|
|
13469
|
+
if (exclusiveMaxString && (compareNumericStrings(exclusiveMaxString, "0") > 0 && compareNumericStrings(stringValue2, exclusiveMaxString) >= 0 || compareNumericStrings(exclusiveMaxString, "0") <= 0 && compareNumericStrings(stringValue2, "0") > 0) && compareNumericStrings(stringValue2, prevStringValue) > 0) {
|
|
12291
13470
|
return false;
|
|
12292
13471
|
}
|
|
12293
13472
|
}
|
|
12294
|
-
|
|
13473
|
+
prevStringValueRef.current = stringValue2;
|
|
13474
|
+
return true;
|
|
12295
13475
|
},
|
|
12296
13476
|
[
|
|
12297
13477
|
valueIsInteger,
|
|
12298
13478
|
scale,
|
|
12299
|
-
allowValue,
|
|
12300
13479
|
precision,
|
|
12301
13480
|
minString,
|
|
12302
13481
|
maxString,
|
|
@@ -12304,93 +13483,101 @@ const NumericInput = forwardRef(function NumericInput2({
|
|
|
12304
13483
|
exclusiveMaxString
|
|
12305
13484
|
]
|
|
12306
13485
|
);
|
|
12307
|
-
const
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
13486
|
+
const {
|
|
13487
|
+
status: formStatus,
|
|
13488
|
+
disabled: formDisabled,
|
|
13489
|
+
setValue: formSetValue,
|
|
13490
|
+
onChange: formOnChange,
|
|
13491
|
+
onBlur: formOnBlur
|
|
13492
|
+
} = useRegisterFormControl(
|
|
13493
|
+
name,
|
|
13494
|
+
stringValue,
|
|
13495
|
+
validate,
|
|
13496
|
+
validationMode
|
|
12315
13497
|
);
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
13498
|
+
status ??= formStatus;
|
|
13499
|
+
disabled ||= formDisabled;
|
|
13500
|
+
const handleValueChange = useCallback(
|
|
13501
|
+
(values) => {
|
|
13502
|
+
const representations = transformNumberFormatValues(
|
|
13503
|
+
values,
|
|
13504
|
+
valueIsInteger,
|
|
13505
|
+
scale
|
|
13506
|
+
);
|
|
13507
|
+
onValueChange?.(representations);
|
|
13508
|
+
setValue(
|
|
13509
|
+
valueIsUnformattedString ? representations.stringValue : representations.formattedValue
|
|
13510
|
+
);
|
|
13511
|
+
formOnChange(representations.stringValue);
|
|
13512
|
+
},
|
|
13513
|
+
[
|
|
13514
|
+
formOnChange,
|
|
13515
|
+
onValueChange,
|
|
13516
|
+
scale,
|
|
13517
|
+
setValue,
|
|
13518
|
+
valueIsInteger,
|
|
13519
|
+
valueIsUnformattedString
|
|
13520
|
+
]
|
|
13521
|
+
);
|
|
13522
|
+
const handleHiddenInputValueChange = (value2) => {
|
|
13523
|
+
if (!valueIsUnformattedString) {
|
|
13524
|
+
if (valueIsInteger && scale) {
|
|
13525
|
+
value2 = numericStringIntToFloat(value2, scale);
|
|
13526
|
+
}
|
|
13527
|
+
value2 = numericFormatter(value2, formatProps);
|
|
12335
13528
|
}
|
|
13529
|
+
setValue(value2);
|
|
13530
|
+
formSetValue(value2);
|
|
13531
|
+
};
|
|
13532
|
+
useResetControlOnFormReset(
|
|
13533
|
+
inputEl,
|
|
13534
|
+
stringValue,
|
|
13535
|
+
handleHiddenInputValueChange
|
|
12336
13536
|
);
|
|
13537
|
+
const combinedRef = useCombinedRef(setInputEl, forwardedRef);
|
|
13538
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13539
|
+
/* @__PURE__ */ jsx(
|
|
13540
|
+
NumericFormat,
|
|
13541
|
+
{
|
|
13542
|
+
value: rnfString,
|
|
13543
|
+
...formatProps,
|
|
13544
|
+
required,
|
|
13545
|
+
disabled,
|
|
13546
|
+
readOnly,
|
|
13547
|
+
status,
|
|
13548
|
+
onValueChange: handleValueChange,
|
|
13549
|
+
onBlurToOutside: combineEventHandlers(
|
|
13550
|
+
formOnBlur,
|
|
13551
|
+
onBlurToOutside
|
|
13552
|
+
),
|
|
13553
|
+
isAllowed,
|
|
13554
|
+
customInput: Control,
|
|
13555
|
+
getInputRef: combinedRef,
|
|
13556
|
+
autoComplete: "off",
|
|
13557
|
+
...otherProps
|
|
13558
|
+
}
|
|
13559
|
+
),
|
|
13560
|
+
/* @__PURE__ */ jsx(
|
|
13561
|
+
HiddenFormControl,
|
|
13562
|
+
{
|
|
13563
|
+
actualElement: inputEl,
|
|
13564
|
+
onChange: (evt) => handleHiddenInputValueChange(evt.target.value),
|
|
13565
|
+
name,
|
|
13566
|
+
type: "number",
|
|
13567
|
+
value: stringValue,
|
|
13568
|
+
required,
|
|
13569
|
+
disabled,
|
|
13570
|
+
readOnly,
|
|
13571
|
+
autoComplete,
|
|
13572
|
+
min: minString || void 0,
|
|
13573
|
+
max: maxString || void 0,
|
|
13574
|
+
step: scaleToStep(valueIsInteger, scale),
|
|
13575
|
+
form,
|
|
13576
|
+
children: /* @__PURE__ */ jsx("input", {})
|
|
13577
|
+
}
|
|
13578
|
+
)
|
|
13579
|
+
] });
|
|
12337
13580
|
});
|
|
12338
|
-
function validateNumericProps({
|
|
12339
|
-
valueIsInteger,
|
|
12340
|
-
precision,
|
|
12341
|
-
scale,
|
|
12342
|
-
decimalSeparator,
|
|
12343
|
-
groupSeparator,
|
|
12344
|
-
minString,
|
|
12345
|
-
maxString,
|
|
12346
|
-
exclusiveMinString,
|
|
12347
|
-
exclusiveMaxString
|
|
12348
|
-
}) {
|
|
12349
|
-
validateNumericTransformerOptions({
|
|
12350
|
-
valueIsInteger,
|
|
12351
|
-
scale,
|
|
12352
|
-
decimalSeparator,
|
|
12353
|
-
groupSeparator
|
|
12354
|
-
});
|
|
12355
|
-
if (precision != null && scale == null) {
|
|
12356
|
-
throw new Error(
|
|
12357
|
-
"The scale cannot be set to `null` when a precision is provided."
|
|
12358
|
-
);
|
|
12359
|
-
}
|
|
12360
|
-
if (precision != null && (precision <= 0 || Math.floor(precision) !== precision)) {
|
|
12361
|
-
throw new RangeError("The precision must be a positive integer.");
|
|
12362
|
-
}
|
|
12363
|
-
if (precision != null && scale >= precision) {
|
|
12364
|
-
throw new RangeError("The scale must be less than the precision.");
|
|
12365
|
-
}
|
|
12366
|
-
const lowerLimit = minString && exclusiveMinString ? compareNumericStrings(minString, exclusiveMinString) <= 0 ? exclusiveMinString : minString : minString || exclusiveMinString;
|
|
12367
|
-
const upperLimit = maxString && exclusiveMaxString ? compareNumericStrings(maxString, exclusiveMaxString) >= 0 ? exclusiveMaxString : maxString : maxString || exclusiveMaxString;
|
|
12368
|
-
if (lowerLimit && upperLimit && compareNumericStrings(lowerLimit, upperLimit) > 0) {
|
|
12369
|
-
throw new RangeError(
|
|
12370
|
-
"`min`/`exclusiveMin` should not be greater than `max`/`exclusiveMax`."
|
|
12371
|
-
);
|
|
12372
|
-
}
|
|
12373
|
-
}
|
|
12374
|
-
function valueNeedsTransformation(value, valueIsUnformattedString, valueIsInteger, scale) {
|
|
12375
|
-
return value != null && valueIsInteger && Boolean(scale) && (typeof value !== "string" || valueIsUnformattedString);
|
|
12376
|
-
}
|
|
12377
|
-
function transformIntegerValueWithScale(value, scale) {
|
|
12378
|
-
const stringValue = numericToString(value);
|
|
12379
|
-
return numericStringIntToFloat(stringValue, scale);
|
|
12380
|
-
}
|
|
12381
|
-
function transformNumberFormatValues({ formattedValue, value, floatValue }, valueIsInteger, scale) {
|
|
12382
|
-
if (!valueIsInteger || !scale || Number.isNaN(floatValue) || floatValue == null) {
|
|
12383
|
-
return {
|
|
12384
|
-
formattedValue,
|
|
12385
|
-
stringValue: normalizeNumericString(value),
|
|
12386
|
-
numberValue: Number.isNaN(floatValue) || floatValue == null ? null : floatValue
|
|
12387
|
-
};
|
|
12388
|
-
}
|
|
12389
|
-
const stringValue = normalizeNumericString(
|
|
12390
|
-
numericStringFloatToInt(value, scale)
|
|
12391
|
-
);
|
|
12392
|
-
return { formattedValue, stringValue, numberValue: +stringValue };
|
|
12393
|
-
}
|
|
12394
13581
|
const Output = forwardRef(
|
|
12395
13582
|
function Output2({
|
|
12396
13583
|
pending,
|
|
@@ -12402,7 +13589,7 @@ const Output = forwardRef(
|
|
|
12402
13589
|
}, forwardedRef) {
|
|
12403
13590
|
const prefix = usePrefix();
|
|
12404
13591
|
return /* @__PURE__ */ jsx(
|
|
12405
|
-
|
|
13592
|
+
Control,
|
|
12406
13593
|
{
|
|
12407
13594
|
showSpinner,
|
|
12408
13595
|
"aria-busy": pending || void 0,
|
|
@@ -12461,14 +13648,26 @@ const Radio = forwardRef(function Radio2({
|
|
|
12461
13648
|
},
|
|
12462
13649
|
[softDisabled, readOnly]
|
|
12463
13650
|
);
|
|
13651
|
+
const rootRef = useRef(null);
|
|
13652
|
+
const radioRef = useRef(null);
|
|
13653
|
+
const handleRootFocus = (evt) => {
|
|
13654
|
+
if (evt.target.tagName === "INPUT" && evt.target.type === "radio" && rootRef.current?.contains(evt.target)) {
|
|
13655
|
+
radioRef.current?.focus();
|
|
13656
|
+
}
|
|
13657
|
+
};
|
|
12464
13658
|
const combinedLabelIds = combineAriaIds(codeId, labelId);
|
|
13659
|
+
const combinedRootRef = useCombinedRef(rootRef, rootProps?.ref);
|
|
13660
|
+
const combinedRadioRef = useCombinedRef(radioRef, forwardedRef);
|
|
12465
13661
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12466
13662
|
/* @__PURE__ */ jsxs(
|
|
12467
13663
|
"div",
|
|
12468
13664
|
{
|
|
12469
13665
|
"data-status": status,
|
|
13666
|
+
"data-accent": controlStatusToAccent(status),
|
|
12470
13667
|
...rootProps,
|
|
13668
|
+
onFocus: combineEventHandlers(rootProps?.onFocus, handleRootFocus),
|
|
12471
13669
|
className: cx(prefix("radio__root"), rootProps?.className),
|
|
13670
|
+
ref: combinedRootRef,
|
|
12472
13671
|
children: [
|
|
12473
13672
|
codeId && /* @__PURE__ */ jsx(
|
|
12474
13673
|
ControlCode,
|
|
@@ -12495,7 +13694,7 @@ const Radio = forwardRef(function Radio2({
|
|
|
12495
13694
|
"aria-labelledby": ariaLabelledBy ?? (ariaLabel === void 0 && combinedLabelIds !== labelId ? combinedLabelIds : void 0),
|
|
12496
13695
|
...otherProps,
|
|
12497
13696
|
onClick: combineEventHandlers(onClick, handleClick),
|
|
12498
|
-
ref:
|
|
13697
|
+
ref: combinedRadioRef,
|
|
12499
13698
|
children: /* @__PURE__ */ jsx(
|
|
12500
13699
|
RadioGroup$1.Indicator,
|
|
12501
13700
|
{
|
|
@@ -12556,12 +13755,15 @@ const RadioGroup = forwardRef(function RadioGroup2({
|
|
|
12556
13755
|
clearDescription,
|
|
12557
13756
|
clearButtonLabel,
|
|
12558
13757
|
onBlurToOutside,
|
|
13758
|
+
validate,
|
|
13759
|
+
validationMode,
|
|
12559
13760
|
codeProps,
|
|
12560
13761
|
containerProps,
|
|
12561
13762
|
endContainerProps,
|
|
12562
13763
|
clearButtonProps,
|
|
12563
13764
|
spinnerProps,
|
|
12564
13765
|
id,
|
|
13766
|
+
name,
|
|
12565
13767
|
required,
|
|
12566
13768
|
disabled,
|
|
12567
13769
|
readOnly,
|
|
@@ -12589,7 +13791,16 @@ const RadioGroup = forwardRef(function RadioGroup2({
|
|
|
12589
13791
|
defaultValue ?? "",
|
|
12590
13792
|
controlledValue
|
|
12591
13793
|
);
|
|
12592
|
-
const {
|
|
13794
|
+
const {
|
|
13795
|
+
status: formStatus,
|
|
13796
|
+
disabled: formDisabled,
|
|
13797
|
+
setValue: formSetValue,
|
|
13798
|
+
onChange: formOnChange,
|
|
13799
|
+
onBlur: formOnBlur
|
|
13800
|
+
} = useRegisterFormControl(name, value, validate, validationMode);
|
|
13801
|
+
status ??= formStatus;
|
|
13802
|
+
disabled ||= formDisabled;
|
|
13803
|
+
const { generatedId, controlId, codeId } = useRegisterFieldControl(
|
|
12593
13804
|
id,
|
|
12594
13805
|
"DIV",
|
|
12595
13806
|
codeProps?.id,
|
|
@@ -12598,7 +13809,7 @@ const RadioGroup = forwardRef(function RadioGroup2({
|
|
|
12598
13809
|
status
|
|
12599
13810
|
);
|
|
12600
13811
|
const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
|
|
12601
|
-
const
|
|
13812
|
+
const [radioGroupEl, setRadioGroupEl] = useState(null);
|
|
12602
13813
|
const isInTableCell = useIsInTableCell();
|
|
12603
13814
|
inline ??= isInTableCell;
|
|
12604
13815
|
variant ??= isInTableCell ? "cell" : "default";
|
|
@@ -12608,9 +13819,10 @@ const RadioGroup = forwardRef(function RadioGroup2({
|
|
|
12608
13819
|
if (!softDisabled && !readOnly) {
|
|
12609
13820
|
setValue(value2);
|
|
12610
13821
|
onValueChange?.(value2);
|
|
13822
|
+
formOnChange(value2);
|
|
12611
13823
|
}
|
|
12612
13824
|
},
|
|
12613
|
-
[softDisabled,
|
|
13825
|
+
[softDisabled, readOnly, setValue, onValueChange, formOnChange]
|
|
12614
13826
|
);
|
|
12615
13827
|
const setFieldControlFocused = useSetFieldControlFocused();
|
|
12616
13828
|
const handleControlFocus = useCallback(() => {
|
|
@@ -12619,16 +13831,17 @@ const RadioGroup = forwardRef(function RadioGroup2({
|
|
|
12619
13831
|
const handleControlBlur = useCallback(
|
|
12620
13832
|
(evt) => {
|
|
12621
13833
|
setFieldControlFocused(false);
|
|
12622
|
-
if (!evt.relatedTarget || !
|
|
13834
|
+
if (!evt.relatedTarget || !radioGroupEl?.contains(evt.relatedTarget)) {
|
|
12623
13835
|
onBlurToOutside?.(evt);
|
|
13836
|
+
formOnBlur();
|
|
12624
13837
|
}
|
|
12625
13838
|
},
|
|
12626
|
-
[onBlurToOutside, setFieldControlFocused]
|
|
13839
|
+
[formOnBlur, onBlurToOutside, radioGroupEl, setFieldControlFocused]
|
|
12627
13840
|
);
|
|
12628
13841
|
const handleClearButtonClick = useCallback(() => {
|
|
12629
|
-
handleValueChange(
|
|
12630
|
-
|
|
12631
|
-
}, [handleValueChange]);
|
|
13842
|
+
handleValueChange(null);
|
|
13843
|
+
radioGroupEl?.focus();
|
|
13844
|
+
}, [handleValueChange, radioGroupEl]);
|
|
12632
13845
|
const hasClearButton = !disabled && !softDisabled && !readOnly && (showClearButton === true || showClearButton === "auto" && (value?.length ?? 0) > 0);
|
|
12633
13846
|
const clearDescriptionId = hasClearButton && clearDescription && prefix(`control-clear-${generatedId}`);
|
|
12634
13847
|
const handleKeyDown = useCallback(
|
|
@@ -12639,7 +13852,13 @@ const RadioGroup = forwardRef(function RadioGroup2({
|
|
|
12639
13852
|
},
|
|
12640
13853
|
[handleClearButtonClick, hasClearButton]
|
|
12641
13854
|
);
|
|
12642
|
-
|
|
13855
|
+
useResetControlOnFormReset(radioGroupEl, value, (value2) => {
|
|
13856
|
+
if (!softDisabled && !readOnly) {
|
|
13857
|
+
setValue(value2);
|
|
13858
|
+
formSetValue(value2);
|
|
13859
|
+
}
|
|
13860
|
+
});
|
|
13861
|
+
const combinedRadioGroupRef = useCombinedRef(setRadioGroupEl, forwardedRef);
|
|
12643
13862
|
return /* @__PURE__ */ jsx(ClearContexts, { children: /* @__PURE__ */ jsx(
|
|
12644
13863
|
ControlContext.Provider,
|
|
12645
13864
|
{
|
|
@@ -12650,6 +13869,7 @@ const RadioGroup = forwardRef(function RadioGroup2({
|
|
|
12650
13869
|
value,
|
|
12651
13870
|
onValueChange: handleValueChange,
|
|
12652
13871
|
id: controlId,
|
|
13872
|
+
name,
|
|
12653
13873
|
"data-status": status,
|
|
12654
13874
|
"data-accent": controlStatusToAccent(status),
|
|
12655
13875
|
"data-variant": variant,
|
|
@@ -13759,10 +14979,49 @@ const Tabs = forwardRef(function Tabs2({
|
|
|
13759
14979
|
});
|
|
13760
14980
|
const DEFAULT_ROWS = 3;
|
|
13761
14981
|
const TextArea = forwardRef(
|
|
13762
|
-
function TextArea2({
|
|
14982
|
+
function TextArea2({
|
|
14983
|
+
name,
|
|
14984
|
+
defaultValue,
|
|
14985
|
+
value,
|
|
14986
|
+
status,
|
|
14987
|
+
disabled,
|
|
14988
|
+
validate,
|
|
14989
|
+
validationMode,
|
|
14990
|
+
rows,
|
|
14991
|
+
onValueChange,
|
|
14992
|
+
onBlurToOutside,
|
|
14993
|
+
...otherProps
|
|
14994
|
+
}, forwardedRef) {
|
|
13763
14995
|
const isInTableCell = useIsInTableCell();
|
|
13764
14996
|
rows ??= isInTableCell ? 1 : DEFAULT_ROWS;
|
|
13765
|
-
|
|
14997
|
+
const initialValue = (value ?? defaultValue)?.toString() ?? "";
|
|
14998
|
+
const formControl = useRegisterFormControl(
|
|
14999
|
+
name,
|
|
15000
|
+
initialValue,
|
|
15001
|
+
validate,
|
|
15002
|
+
validationMode
|
|
15003
|
+
);
|
|
15004
|
+
return /* @__PURE__ */ jsx(
|
|
15005
|
+
Control,
|
|
15006
|
+
{
|
|
15007
|
+
...otherProps,
|
|
15008
|
+
asChild: true,
|
|
15009
|
+
name,
|
|
15010
|
+
defaultValue,
|
|
15011
|
+
value,
|
|
15012
|
+
status: status ?? formControl.status,
|
|
15013
|
+
disabled: disabled || formControl.disabled,
|
|
15014
|
+
onValueChange: combineEventHandlers(
|
|
15015
|
+
formControl.onChange,
|
|
15016
|
+
onValueChange
|
|
15017
|
+
),
|
|
15018
|
+
onBlurToOutside: combineEventHandlers(
|
|
15019
|
+
formControl.onBlur,
|
|
15020
|
+
onBlurToOutside
|
|
15021
|
+
),
|
|
15022
|
+
children: /* @__PURE__ */ jsx("textarea", { rows, ref: forwardedRef })
|
|
15023
|
+
}
|
|
15024
|
+
);
|
|
13766
15025
|
}
|
|
13767
15026
|
);
|
|
13768
15027
|
function navigate(url, options) {
|
|
@@ -13945,9 +15204,11 @@ export {
|
|
|
13945
15204
|
CommandMenuGroup,
|
|
13946
15205
|
CommandMenuItem,
|
|
13947
15206
|
Container,
|
|
15207
|
+
Control,
|
|
13948
15208
|
ControlAddon,
|
|
13949
15209
|
ControlCode,
|
|
13950
15210
|
ControlContext,
|
|
15211
|
+
ControlWithContainerRef,
|
|
13951
15212
|
DATA_TABLE_SELECTION_COLUMN_WIDTH,
|
|
13952
15213
|
DEFAULT_DATE_FORMAT,
|
|
13953
15214
|
DEFAULT_DOCUMENT_TITLE_BASE_SEPARATOR,
|
|
@@ -14003,13 +15264,17 @@ export {
|
|
|
14003
15264
|
FieldGroupHeader,
|
|
14004
15265
|
FieldGroupTitle,
|
|
14005
15266
|
FieldProvider,
|
|
15267
|
+
Form,
|
|
15268
|
+
FormError,
|
|
15269
|
+
FormReset,
|
|
15270
|
+
FormState,
|
|
15271
|
+
FormSubmit,
|
|
14006
15272
|
Grid,
|
|
14007
15273
|
Heading,
|
|
14008
15274
|
HelperText,
|
|
14009
15275
|
Icon,
|
|
14010
15276
|
IconButton,
|
|
14011
15277
|
Input$1 as Input,
|
|
14012
|
-
InputWithContainerRef,
|
|
14013
15278
|
Keybinds,
|
|
14014
15279
|
Keyboard,
|
|
14015
15280
|
Label,
|
|
@@ -14134,6 +15399,9 @@ export {
|
|
|
14134
15399
|
useFieldErrorMessageIds,
|
|
14135
15400
|
useFieldLabel,
|
|
14136
15401
|
useFieldLabelId,
|
|
15402
|
+
useFormApi,
|
|
15403
|
+
useFormState,
|
|
15404
|
+
useFormValue,
|
|
14137
15405
|
useIntersectionObserver,
|
|
14138
15406
|
useIsInFeedbackList,
|
|
14139
15407
|
useIsInRoot,
|
|
@@ -14157,12 +15425,12 @@ export {
|
|
|
14157
15425
|
usePrintInProgress,
|
|
14158
15426
|
usePrinterDocumentTitle,
|
|
14159
15427
|
usePrinting,
|
|
15428
|
+
useRegisterFieldControl,
|
|
14160
15429
|
useResponsiveValues,
|
|
14161
15430
|
useScrollPosition,
|
|
14162
15431
|
useScrollbarSize,
|
|
14163
15432
|
useSearchParam,
|
|
14164
15433
|
useSearchParams,
|
|
14165
|
-
useSetFieldControl,
|
|
14166
15434
|
useSetFieldControlFocused,
|
|
14167
15435
|
useSetFieldFeedback,
|
|
14168
15436
|
useSetFieldHelperText,
|