@povio/ui 2.2.9-rc.30 → 2.2.9-rc.32
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/components/inputs/DateTime/DatePicker/DatePicker.js +4 -9
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +4 -9
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +4 -9
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +0 -9
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +0 -9
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +146 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +2 -5
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +100 -183
- package/dist/components/inputs/Input/TextInput/TextInput.js +0 -9
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +0 -5
- package/dist/components/inputs/Selection/Select/Select.js +0 -7
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +8 -2
- package/dist/components/inputs/Skeleton/InputFrame.js +27 -6
- package/dist/components/inputs/shared/InputClear.js +2 -2
- package/package.json +1 -1
- package/dist/components/inputs/shared/StaticInput.js +0 -104
|
@@ -212,12 +212,11 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...pr
|
|
|
212
212
|
const dateValue = rawValue ? parseCalendarDate(rawValue) : null;
|
|
213
213
|
const as = props.as ?? ui.input.as;
|
|
214
214
|
const size = props.size ?? ui.input.size;
|
|
215
|
-
const variant = props.variant ?? ui.input.variant;
|
|
216
|
-
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
217
|
-
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
218
215
|
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
219
216
|
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
220
217
|
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
218
|
+
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
219
|
+
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
|
|
221
220
|
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
222
221
|
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
223
222
|
const staticSegments = getStaticCalendarDateSegments({
|
|
@@ -230,8 +229,6 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...pr
|
|
|
230
229
|
});
|
|
231
230
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
232
231
|
...props,
|
|
233
|
-
isHeaderHidden,
|
|
234
|
-
hideLabel,
|
|
235
232
|
isDisabled,
|
|
236
233
|
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
237
234
|
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
@@ -252,10 +249,8 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...pr
|
|
|
252
249
|
setShouldFocus(focus);
|
|
253
250
|
setRenderInput(true);
|
|
254
251
|
},
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
variant,
|
|
258
|
-
actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
252
|
+
actionContent: staticTodayIcon,
|
|
253
|
+
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
259
254
|
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
260
255
|
children: staticSegments
|
|
261
256
|
});
|
|
@@ -612,12 +612,11 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
612
612
|
const hasProvidedRangeValue = !!(rawValue?.start || rawValue?.end);
|
|
613
613
|
const as = props.as ?? ui.input.as;
|
|
614
614
|
const size = props.size ?? ui.input.size;
|
|
615
|
-
const variant = props.variant ?? ui.input.variant;
|
|
616
|
-
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
617
|
-
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
618
615
|
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
619
616
|
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
620
617
|
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
618
|
+
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
619
|
+
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
|
|
621
620
|
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
622
621
|
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
623
622
|
const staticSegments = getStaticDateRangeSegments({
|
|
@@ -631,8 +630,6 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
631
630
|
});
|
|
632
631
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
633
632
|
...props,
|
|
634
|
-
isHeaderHidden,
|
|
635
|
-
hideLabel,
|
|
636
633
|
isDisabled,
|
|
637
634
|
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
638
635
|
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
@@ -653,10 +650,8 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
653
650
|
setShouldFocus(focus);
|
|
654
651
|
setRenderInput(true);
|
|
655
652
|
},
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
variant,
|
|
659
|
-
actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
653
|
+
actionContent: staticTodayIcon,
|
|
654
|
+
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
660
655
|
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
661
656
|
children: staticSegments
|
|
662
657
|
});
|
|
@@ -226,12 +226,11 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
|
|
|
226
226
|
const dateTimeValue = rawValue ? parseDateValue(rawValue) : null;
|
|
227
227
|
const as = props.as ?? ui.input.as;
|
|
228
228
|
const size = props.size ?? ui.input.size;
|
|
229
|
-
const variant = props.variant ?? ui.input.variant;
|
|
230
|
-
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
231
|
-
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
232
229
|
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
233
230
|
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
234
231
|
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
232
|
+
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
233
|
+
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
|
|
235
234
|
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
236
235
|
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
237
236
|
const staticSegments = getStaticCalendarDateTimeSegments({
|
|
@@ -244,8 +243,6 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
|
|
|
244
243
|
});
|
|
245
244
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
246
245
|
...props,
|
|
247
|
-
isHeaderHidden,
|
|
248
|
-
hideLabel,
|
|
249
246
|
isDisabled,
|
|
250
247
|
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
251
248
|
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
@@ -266,10 +263,8 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
|
|
|
266
263
|
setShouldFocus(focus);
|
|
267
264
|
setRenderInput(true);
|
|
268
265
|
},
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
variant,
|
|
272
|
-
actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
266
|
+
actionContent: staticTodayIcon,
|
|
267
|
+
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
273
268
|
trailingContent: showDropdown ? ui.dateInput.dateTimeIcon : void 0,
|
|
274
269
|
children: staticSegments
|
|
275
270
|
});
|
|
@@ -171,10 +171,6 @@ var TimePicker = ({ renderStaticInput, ...props }) => {
|
|
|
171
171
|
if (!renderInput) {
|
|
172
172
|
const timeValue = rawValue ? parseTimeValue(rawValue) : null;
|
|
173
173
|
const as = props.as ?? ui.input.as;
|
|
174
|
-
const size = props.size ?? ui.input.size;
|
|
175
|
-
const variant = props.variant ?? ui.input.variant;
|
|
176
|
-
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
177
|
-
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
178
174
|
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
179
175
|
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
180
176
|
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
@@ -187,8 +183,6 @@ var TimePicker = ({ renderStaticInput, ...props }) => {
|
|
|
187
183
|
});
|
|
188
184
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
189
185
|
...props,
|
|
190
|
-
isHeaderHidden,
|
|
191
|
-
hideLabel,
|
|
192
186
|
isDisabled,
|
|
193
187
|
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
194
188
|
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
@@ -208,9 +202,6 @@ var TimePicker = ({ renderStaticInput, ...props }) => {
|
|
|
208
202
|
setShouldFocus(focus);
|
|
209
203
|
setRenderInput(true);
|
|
210
204
|
},
|
|
211
|
-
as,
|
|
212
|
-
size,
|
|
213
|
-
variant,
|
|
214
205
|
trailingContent: showDropdown ? ui.dateInput.timeIcon : void 0,
|
|
215
206
|
children: staticSegments
|
|
216
207
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DOMAttributes } from '@react-types/shared';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { LabelHTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
export interface FormFieldHeaderProps {
|
|
4
4
|
label: string;
|
|
5
5
|
tooltipText?: string;
|
|
@@ -9,6 +9,6 @@ export interface FormFieldHeaderProps {
|
|
|
9
9
|
isHeaderHidden?: boolean;
|
|
10
10
|
isDisabled?: boolean;
|
|
11
11
|
className?: string;
|
|
12
|
-
labelProps?: DOMAttributes<HTMLLabelElement>;
|
|
12
|
+
labelProps?: DOMAttributes<HTMLLabelElement> & LabelHTMLAttributes<HTMLLabelElement>;
|
|
13
13
|
}
|
|
14
14
|
export declare const FormFieldHeader: ({ label, tooltipText, helperText, isRequired, rightContent, isHeaderHidden, isDisabled, className, labelProps, }: FormFieldHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DOMAttributes } from '@react-types/shared';
|
|
2
|
-
import { RefCallback } from 'react';
|
|
2
|
+
import { LabelHTMLAttributes, RefCallback } from 'react';
|
|
3
3
|
import { InputSizeProps } from '../shared/input.cva';
|
|
4
4
|
import { LabelBaseProps } from '../shared/label.cva';
|
|
5
5
|
export interface FormFieldLabelProps extends LabelBaseProps, InputSizeProps {
|
|
@@ -7,7 +7,7 @@ export interface FormFieldLabelProps extends LabelBaseProps, InputSizeProps {
|
|
|
7
7
|
isRequired?: boolean;
|
|
8
8
|
isDisabled?: boolean;
|
|
9
9
|
ref?: RefCallback<HTMLOrSVGElement>;
|
|
10
|
-
labelProps?: DOMAttributes<HTMLLabelElement>;
|
|
10
|
+
labelProps?: DOMAttributes<HTMLLabelElement> & LabelHTMLAttributes<HTMLLabelElement>;
|
|
11
11
|
className?: string;
|
|
12
12
|
}
|
|
13
13
|
export declare const FormFieldLabel: ({ ref, as, label, isRequired, isDisabled, labelProps, className, }: FormFieldLabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -143,10 +143,6 @@ var NumberInput = ({ renderStaticInput, ...props }) => {
|
|
|
143
143
|
const displayValue = getStaticNumberDisplayValue(staticValue, new Intl.NumberFormat(locale, formatOptions)) ?? "";
|
|
144
144
|
const hasValue = displayValue !== "";
|
|
145
145
|
const as = props.as ?? ui.input.as;
|
|
146
|
-
const size = props.size ?? ui.input.size;
|
|
147
|
-
const variant = props.variant ?? ui.input.variant;
|
|
148
|
-
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
149
|
-
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
150
146
|
let isDisabled = !!props.isDisabled;
|
|
151
147
|
if (isFormControlDisabled) isDisabled = true;
|
|
152
148
|
const dataAttributes = {
|
|
@@ -161,8 +157,6 @@ var NumberInput = ({ renderStaticInput, ...props }) => {
|
|
|
161
157
|
};
|
|
162
158
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
163
159
|
...props,
|
|
164
|
-
isHeaderHidden,
|
|
165
|
-
hideLabel,
|
|
166
160
|
isDisabled,
|
|
167
161
|
className: clsx("group w-full", as === "inline" && "h-full", props.className),
|
|
168
162
|
dataAttributes,
|
|
@@ -172,9 +166,6 @@ var NumberInput = ({ renderStaticInput, ...props }) => {
|
|
|
172
166
|
setRenderInput(true);
|
|
173
167
|
},
|
|
174
168
|
inputClassName: props.inputClassName,
|
|
175
|
-
as,
|
|
176
|
-
size,
|
|
177
|
-
variant,
|
|
178
169
|
children: (dataAttributeProps) => /* @__PURE__ */ jsx("input", {
|
|
179
170
|
ref: inputRef,
|
|
180
171
|
readOnly: true,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FocusEvent, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { NumberFieldProps as AriaNumberFieldProps } from 'react-aria-components';
|
|
3
|
+
import { FormFieldProps } from '../../FormField/FormField';
|
|
4
|
+
import { FormFieldHeaderProps } from '../../FormField/FormFieldHeader';
|
|
5
|
+
import { InputVariantProps } from '../../shared/input.cva';
|
|
6
|
+
export interface NumberRangeValue {
|
|
7
|
+
min: number | null;
|
|
8
|
+
max: number | null;
|
|
9
|
+
}
|
|
10
|
+
type NumberRangeFieldInputProps = Omit<AriaNumberFieldProps, "className" | "defaultValue" | "label" | "maxValue" | "minValue" | "onBlur" | "onChange" | "value">;
|
|
11
|
+
export interface NumberRangeFieldProps extends NumberRangeFieldInputProps {
|
|
12
|
+
ref?: Ref<HTMLDivElement>;
|
|
13
|
+
as: InputVariantProps["as"];
|
|
14
|
+
className?: string;
|
|
15
|
+
inputClassName?: string;
|
|
16
|
+
minInputClassName?: string;
|
|
17
|
+
maxInputClassName?: string;
|
|
18
|
+
inputBaseClassName: string;
|
|
19
|
+
inputSizeClassName: string;
|
|
20
|
+
formFieldProps: FormFieldProps;
|
|
21
|
+
headerProps: FormFieldHeaderProps;
|
|
22
|
+
rangeValue: NumberRangeValue;
|
|
23
|
+
effectiveError?: string;
|
|
24
|
+
minPlaceholder: string;
|
|
25
|
+
maxPlaceholder: string;
|
|
26
|
+
minLabel: string;
|
|
27
|
+
maxLabel: string;
|
|
28
|
+
hideInnerLabels?: boolean;
|
|
29
|
+
isDirty?: boolean;
|
|
30
|
+
isClearable?: boolean;
|
|
31
|
+
autoFocusOnMount?: boolean;
|
|
32
|
+
isDisabled?: boolean;
|
|
33
|
+
isRequired?: boolean;
|
|
34
|
+
isEmpty: boolean;
|
|
35
|
+
isHovered: boolean;
|
|
36
|
+
isFocused: boolean;
|
|
37
|
+
isFocusVisible: boolean;
|
|
38
|
+
focusWithinProps: HTMLAttributes<HTMLElement>;
|
|
39
|
+
hoverProps: HTMLAttributes<HTMLElement>;
|
|
40
|
+
onRangeSideChange: (side: keyof NumberRangeValue, nextValue: number | null) => void;
|
|
41
|
+
onRangeSideClear: (side: keyof NumberRangeValue) => void;
|
|
42
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
43
|
+
}
|
|
44
|
+
export declare const NumberRangeField: ({ ref, as, className, inputClassName, minInputClassName, maxInputClassName, inputBaseClassName, inputSizeClassName, formFieldProps, headerProps, rangeValue, effectiveError, minPlaceholder, maxPlaceholder, minLabel, maxLabel, hideInnerLabels, isDirty, isClearable, autoFocusOnMount, isDisabled, isRequired, isEmpty, isHovered, isFocused, isFocusVisible, focusWithinProps, hoverProps, onRangeSideChange, onRangeSideClear, onBlur, ...numberFieldProps }: NumberRangeFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
|
+
import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
|
|
3
|
+
import { InputClear } from "../../shared/InputClear.js";
|
|
4
|
+
import { FormField } from "../../FormField/FormField.js";
|
|
5
|
+
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { clsx } from "clsx";
|
|
8
|
+
import { useEffect, useRef } from "react";
|
|
9
|
+
import { Input, useLocale } from "react-aria-components";
|
|
10
|
+
import { useFocusVisible, useNumberField } from "react-aria";
|
|
11
|
+
import { mergeRefs } from "@react-aria/utils";
|
|
12
|
+
import { useNumberFieldState } from "react-stately";
|
|
13
|
+
//#region src/components/inputs/Input/NumberRangeInput/NumberRangeField.tsx
|
|
14
|
+
var NumberRangeValueField = ({ label, value, placeholder, isDisabled, isInvalid, isRequired, formatOptions, hideInnerLabels, autoFocusOnMount, isClearable, className, onChange, onClear, onBlur, ...rest }) => {
|
|
15
|
+
const ui = UIConfig.useConfig();
|
|
16
|
+
const { locale } = useLocale();
|
|
17
|
+
const { isFocusVisible } = useFocusVisible();
|
|
18
|
+
const inputRef = useRef(null);
|
|
19
|
+
const numberFieldRef = useRef(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!autoFocusOnMount || isDisabled) return;
|
|
22
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
23
|
+
}, [autoFocusOnMount, isDisabled]);
|
|
24
|
+
const numberProps = {
|
|
25
|
+
...rest,
|
|
26
|
+
label,
|
|
27
|
+
value: value ?? NaN,
|
|
28
|
+
placeholder,
|
|
29
|
+
isDisabled,
|
|
30
|
+
isInvalid,
|
|
31
|
+
isRequired,
|
|
32
|
+
onChange,
|
|
33
|
+
onBlur: (e) => onBlur?.({ target: e.target }),
|
|
34
|
+
locale,
|
|
35
|
+
formatOptions: formatOptions ?? ui.numberInput.formatOptions
|
|
36
|
+
};
|
|
37
|
+
const { labelProps, inputProps } = useNumberField(numberProps, useNumberFieldState(numberProps), numberFieldRef);
|
|
38
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
39
|
+
className: "min-w-0 flex-1",
|
|
40
|
+
children: [/* @__PURE__ */ jsx(FormFieldLabel, {
|
|
41
|
+
label,
|
|
42
|
+
labelProps,
|
|
43
|
+
isRequired,
|
|
44
|
+
isDisabled,
|
|
45
|
+
className: clsx(hideInnerLabels && "sr-only")
|
|
46
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
47
|
+
className: "flex items-center gap-input-gap-trailing-elements",
|
|
48
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
49
|
+
...inputProps,
|
|
50
|
+
ref: mergeRefs(inputRef, numberFieldRef),
|
|
51
|
+
placeholder: inputProps.placeholder,
|
|
52
|
+
className: clsx("w-full min-w-0 bg-transparent outline-none", className),
|
|
53
|
+
onFocus: (e) => {
|
|
54
|
+
inputProps.onFocus?.(e);
|
|
55
|
+
if (isFocusVisible) e.target.select();
|
|
56
|
+
}
|
|
57
|
+
}), isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
58
|
+
onClear,
|
|
59
|
+
show: value !== null && !isDisabled
|
|
60
|
+
})]
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
var NumberRangeField = ({ ref, as, className, inputClassName, minInputClassName, maxInputClassName, inputBaseClassName, inputSizeClassName, formFieldProps, headerProps, rangeValue, effectiveError, minPlaceholder, maxPlaceholder, minLabel, maxLabel, hideInnerLabels, isDirty, isClearable, autoFocusOnMount, isDisabled, isRequired, isEmpty, isHovered, isFocused, isFocusVisible, focusWithinProps, hoverProps, onRangeSideChange, onRangeSideClear, onBlur, ...numberFieldProps }) => /* @__PURE__ */ jsx(TooltipWrapper, {
|
|
65
|
+
as,
|
|
66
|
+
error: effectiveError,
|
|
67
|
+
triggerTabIndex: as === "inline" ? -1 : void 0,
|
|
68
|
+
children: /* @__PURE__ */ jsx(FormField, {
|
|
69
|
+
...formFieldProps,
|
|
70
|
+
ref,
|
|
71
|
+
as,
|
|
72
|
+
className: clsx("group w-full", className),
|
|
73
|
+
tabIndex: as === "inline" ? -1 : void 0,
|
|
74
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
75
|
+
className: clsx(inputBaseClassName, "group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2", inputClassName),
|
|
76
|
+
"data-rac": "",
|
|
77
|
+
"data-hovered": isHovered || void 0,
|
|
78
|
+
"data-disabled": isDisabled || void 0,
|
|
79
|
+
"data-is-disabled": isDisabled || void 0,
|
|
80
|
+
"data-invalid": !!effectiveError || void 0,
|
|
81
|
+
"data-is-empty": isEmpty || void 0,
|
|
82
|
+
"data-focus-within": isFocused || void 0,
|
|
83
|
+
"data-focus-visible": isFocused && isFocusVisible || void 0,
|
|
84
|
+
"data-has-selection": !isEmpty || void 0,
|
|
85
|
+
"data-is-dirty": isDirty || void 0,
|
|
86
|
+
"data-is-required": isRequired || void 0,
|
|
87
|
+
"data-is-filled": !isEmpty || void 0,
|
|
88
|
+
...focusWithinProps,
|
|
89
|
+
...hoverProps,
|
|
90
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
91
|
+
className: clsx("flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeClassName),
|
|
92
|
+
children: [
|
|
93
|
+
as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
|
|
94
|
+
as,
|
|
95
|
+
...headerProps
|
|
96
|
+
}),
|
|
97
|
+
/* @__PURE__ */ jsx(NumberRangeValueField, {
|
|
98
|
+
...numberFieldProps,
|
|
99
|
+
label: minLabel,
|
|
100
|
+
placeholder: minPlaceholder,
|
|
101
|
+
value: rangeValue.min,
|
|
102
|
+
onChange: (nextValue) => {
|
|
103
|
+
onRangeSideChange("min", nextValue);
|
|
104
|
+
},
|
|
105
|
+
onBlur,
|
|
106
|
+
isDisabled,
|
|
107
|
+
isInvalid: !!effectiveError,
|
|
108
|
+
isRequired,
|
|
109
|
+
hideInnerLabels,
|
|
110
|
+
autoFocusOnMount,
|
|
111
|
+
isClearable,
|
|
112
|
+
onClear: () => {
|
|
113
|
+
onRangeSideClear("min");
|
|
114
|
+
},
|
|
115
|
+
className: minInputClassName
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ jsx("span", {
|
|
118
|
+
className: clsx("pointer-events-none shrink-0 select-none text-label-2 text-text-default-3", isDisabled && "text-interactive-text-secondary-disabled"),
|
|
119
|
+
children: "-"
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx(NumberRangeValueField, {
|
|
122
|
+
...numberFieldProps,
|
|
123
|
+
label: maxLabel,
|
|
124
|
+
placeholder: maxPlaceholder,
|
|
125
|
+
value: rangeValue.max,
|
|
126
|
+
onChange: (nextValue) => {
|
|
127
|
+
onRangeSideChange("max", nextValue);
|
|
128
|
+
},
|
|
129
|
+
onBlur,
|
|
130
|
+
isDisabled,
|
|
131
|
+
isInvalid: !!effectiveError,
|
|
132
|
+
isRequired,
|
|
133
|
+
hideInnerLabels,
|
|
134
|
+
isClearable,
|
|
135
|
+
onClear: () => {
|
|
136
|
+
onRangeSideClear("max");
|
|
137
|
+
},
|
|
138
|
+
className: maxInputClassName
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
//#endregion
|
|
146
|
+
export { NumberRangeField };
|
|
@@ -2,12 +2,10 @@ import { FocusEvent, Ref } from 'react';
|
|
|
2
2
|
import { NumberFieldProps as AriaNumberFieldProps } from 'react-aria-components';
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
5
|
+
import { NumberRangeValue } from './NumberRangeField';
|
|
5
6
|
import { ControlProps } from '../../shared/form.types';
|
|
6
7
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
7
|
-
export
|
|
8
|
-
min: number | null;
|
|
9
|
-
max: number | null;
|
|
10
|
-
}
|
|
8
|
+
export type { NumberRangeValue } from './NumberRangeField';
|
|
11
9
|
interface NumberRangeInputBaseProps extends FormFieldProps, InputVariantProps, Omit<AriaNumberFieldProps, "className" | "defaultValue" | "label" | "maxValue" | "minValue" | "onBlur" | "onChange" | "value"> {
|
|
12
10
|
ref?: Ref<HTMLDivElement>;
|
|
13
11
|
value?: NumberRangeValue | null;
|
|
@@ -35,4 +33,3 @@ export type NumberRangeInputProps = NumberRangeInputBaseProps & {
|
|
|
35
33
|
};
|
|
36
34
|
export type ControlledNumberRangeInputProps<TFieldValues extends FieldValues> = ControlProps<NumberRangeInputProps, TFieldValues>;
|
|
37
35
|
export declare const NumberRangeInput: <TFieldValues extends FieldValues>({ renderStaticInput, ...props }: ControlledNumberRangeInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
export {};
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { UIStyle } from "../../../../config/uiStyle.context.js";
|
|
2
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
-
import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
|
|
4
3
|
import { InputClear } from "../../shared/InputClear.js";
|
|
5
4
|
import { inputBase, inputSize } from "../../shared/input.cva.js";
|
|
6
|
-
import {
|
|
7
|
-
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
5
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
8
6
|
import { getStaticNumberDisplayValue } from "../shared/numberStatic.utils.js";
|
|
9
|
-
import {
|
|
7
|
+
import { NumberRangeField } from "./NumberRangeField.js";
|
|
10
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
9
|
import { clsx } from "clsx";
|
|
12
|
-
import { useEffect,
|
|
13
|
-
import {
|
|
14
|
-
import { useFocusVisible, useFocusWithin, useHover
|
|
15
|
-
import { mergeRefs } from "@react-aria/utils";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
import { useLocale } from "react-aria-components";
|
|
12
|
+
import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
|
|
16
13
|
import { Controller, useWatch } from "react-hook-form";
|
|
17
|
-
import { useNumberFieldState } from "react-stately";
|
|
18
14
|
//#region src/components/inputs/Input/NumberRangeInput/NumberRangeInput.tsx
|
|
19
15
|
var EMPTY_RANGE = {
|
|
20
16
|
min: null,
|
|
@@ -27,56 +23,6 @@ var normalizeRangeValue = (value, minValue, maxValue) => {
|
|
|
27
23
|
max: maxValue ?? null
|
|
28
24
|
};
|
|
29
25
|
};
|
|
30
|
-
var NumberRangeField = ({ label, value, placeholder, isDisabled, isInvalid, isRequired, formatOptions, hideInnerLabels, autoFocusOnMount, isClearable, className, onChange, onClear, onBlur, ...rest }) => {
|
|
31
|
-
const ui = UIConfig.useConfig();
|
|
32
|
-
const { locale } = useLocale();
|
|
33
|
-
const { isFocusVisible } = useFocusVisible();
|
|
34
|
-
const inputRef = useRef(null);
|
|
35
|
-
const numberFieldRef = useRef(null);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (!autoFocusOnMount || isDisabled) return;
|
|
38
|
-
requestAnimationFrame(() => inputRef.current?.focus());
|
|
39
|
-
}, [autoFocusOnMount, isDisabled]);
|
|
40
|
-
const numberProps = {
|
|
41
|
-
...rest,
|
|
42
|
-
label,
|
|
43
|
-
value: value ?? NaN,
|
|
44
|
-
placeholder,
|
|
45
|
-
isDisabled,
|
|
46
|
-
isInvalid,
|
|
47
|
-
isRequired,
|
|
48
|
-
onChange,
|
|
49
|
-
onBlur: (e) => onBlur?.({ target: e.target }),
|
|
50
|
-
locale,
|
|
51
|
-
formatOptions: formatOptions ?? ui.numberInput.formatOptions
|
|
52
|
-
};
|
|
53
|
-
const { labelProps, inputProps } = useNumberField(numberProps, useNumberFieldState(numberProps), numberFieldRef);
|
|
54
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
55
|
-
className: "min-w-0 flex-1",
|
|
56
|
-
children: [/* @__PURE__ */ jsx(FormFieldLabel, {
|
|
57
|
-
label,
|
|
58
|
-
labelProps,
|
|
59
|
-
isRequired,
|
|
60
|
-
isDisabled,
|
|
61
|
-
className: clsx(hideInnerLabels && "sr-only")
|
|
62
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
63
|
-
className: "flex items-center gap-input-gap-trailing-elements",
|
|
64
|
-
children: [/* @__PURE__ */ jsx(Input, {
|
|
65
|
-
...inputProps,
|
|
66
|
-
ref: mergeRefs(inputRef, numberFieldRef),
|
|
67
|
-
placeholder: inputProps.placeholder,
|
|
68
|
-
className: clsx("w-full min-w-0 bg-transparent outline-none", className),
|
|
69
|
-
onFocus: (e) => {
|
|
70
|
-
inputProps.onFocus?.(e);
|
|
71
|
-
if (isFocusVisible) e.target.select();
|
|
72
|
-
}
|
|
73
|
-
}), isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
74
|
-
onClear,
|
|
75
|
-
show: value !== null && !isDisabled
|
|
76
|
-
})]
|
|
77
|
-
})]
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
26
|
var NumberRangeInputBase = (props) => {
|
|
81
27
|
const ui = UIConfig.useConfig();
|
|
82
28
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
@@ -131,92 +77,45 @@ var NumberRangeInputBase = (props) => {
|
|
|
131
77
|
updateRange(side, null);
|
|
132
78
|
onBlur?.({ target: { value: "" } });
|
|
133
79
|
};
|
|
134
|
-
return /* @__PURE__ */ jsx(
|
|
80
|
+
return /* @__PURE__ */ jsx(NumberRangeField, {
|
|
81
|
+
...rest,
|
|
82
|
+
ref,
|
|
135
83
|
as,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
...headerProps
|
|
172
|
-
}),
|
|
173
|
-
/* @__PURE__ */ jsx(NumberRangeField, {
|
|
174
|
-
...rest,
|
|
175
|
-
label: minLabel,
|
|
176
|
-
placeholder: minPlaceholder,
|
|
177
|
-
value: rangeValue.min,
|
|
178
|
-
onChange: (nextValue) => {
|
|
179
|
-
updateRange("min", nextValue);
|
|
180
|
-
},
|
|
181
|
-
onBlur,
|
|
182
|
-
isDisabled,
|
|
183
|
-
isInvalid: !!effectiveError,
|
|
184
|
-
isRequired,
|
|
185
|
-
hideInnerLabels,
|
|
186
|
-
autoFocusOnMount,
|
|
187
|
-
isClearable,
|
|
188
|
-
onClear: () => {
|
|
189
|
-
clearRangeSide("min");
|
|
190
|
-
},
|
|
191
|
-
className: minInputClassName
|
|
192
|
-
}),
|
|
193
|
-
/* @__PURE__ */ jsx("span", {
|
|
194
|
-
className: clsx("pointer-events-none shrink-0 select-none text-label-2 text-text-default-3", isDisabled && "text-interactive-text-secondary-disabled"),
|
|
195
|
-
children: "-"
|
|
196
|
-
}),
|
|
197
|
-
/* @__PURE__ */ jsx(NumberRangeField, {
|
|
198
|
-
...rest,
|
|
199
|
-
label: maxLabel,
|
|
200
|
-
placeholder: maxPlaceholder,
|
|
201
|
-
value: rangeValue.max,
|
|
202
|
-
onChange: (nextValue) => {
|
|
203
|
-
updateRange("max", nextValue);
|
|
204
|
-
},
|
|
205
|
-
onBlur,
|
|
206
|
-
isDisabled,
|
|
207
|
-
isInvalid: !!effectiveError,
|
|
208
|
-
isRequired,
|
|
209
|
-
hideInnerLabels,
|
|
210
|
-
isClearable,
|
|
211
|
-
onClear: () => {
|
|
212
|
-
clearRangeSide("max");
|
|
213
|
-
},
|
|
214
|
-
className: maxInputClassName
|
|
215
|
-
})
|
|
216
|
-
]
|
|
217
|
-
})
|
|
218
|
-
})
|
|
219
|
-
})
|
|
84
|
+
className,
|
|
85
|
+
inputClassName,
|
|
86
|
+
minInputClassName,
|
|
87
|
+
maxInputClassName,
|
|
88
|
+
inputBaseClassName: inputBaseCva({
|
|
89
|
+
variant,
|
|
90
|
+
as
|
|
91
|
+
}),
|
|
92
|
+
inputSizeClassName: inputSizeCva({
|
|
93
|
+
size,
|
|
94
|
+
as
|
|
95
|
+
}),
|
|
96
|
+
formFieldProps,
|
|
97
|
+
headerProps,
|
|
98
|
+
rangeValue,
|
|
99
|
+
effectiveError,
|
|
100
|
+
minPlaceholder,
|
|
101
|
+
maxPlaceholder,
|
|
102
|
+
minLabel,
|
|
103
|
+
maxLabel,
|
|
104
|
+
hideInnerLabels,
|
|
105
|
+
isDirty,
|
|
106
|
+
isClearable,
|
|
107
|
+
autoFocusOnMount,
|
|
108
|
+
isDisabled,
|
|
109
|
+
isRequired,
|
|
110
|
+
isEmpty,
|
|
111
|
+
isHovered,
|
|
112
|
+
isFocused,
|
|
113
|
+
isFocusVisible,
|
|
114
|
+
focusWithinProps,
|
|
115
|
+
hoverProps,
|
|
116
|
+
onRangeSideChange: updateRange,
|
|
117
|
+
onRangeSideClear: clearRangeSide,
|
|
118
|
+
onBlur
|
|
220
119
|
});
|
|
221
120
|
};
|
|
222
121
|
var NumberRangeInput = ({ renderStaticInput, ...props }) => {
|
|
@@ -241,55 +140,73 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
|
|
|
241
140
|
const minDisplay = getStaticNumberDisplayValue(staticValue.min, formatter);
|
|
242
141
|
const maxDisplay = getStaticNumberDisplayValue(staticValue.max, formatter);
|
|
243
142
|
const hasValue = minDisplay !== null || maxDisplay !== null;
|
|
244
|
-
const displayValue = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
245
|
-
/* @__PURE__ */ jsx("span", {
|
|
246
|
-
className: clsx("w-full bg-transparent outline-none", minDisplay ? props.minInputClassName : "text-text-default-3"),
|
|
247
|
-
children: minDisplay ?? props.minPlaceholder ?? "Min"
|
|
248
|
-
}),
|
|
249
|
-
/* @__PURE__ */ jsx("span", {
|
|
250
|
-
className: "pointer-events-none shrink-0 select-none text-label-2 text-text-default-3",
|
|
251
|
-
children: "-"
|
|
252
|
-
}),
|
|
253
|
-
/* @__PURE__ */ jsx("span", {
|
|
254
|
-
className: clsx("w-full bg-transparent outline-none", maxDisplay ? props.maxInputClassName : "text-text-default-3"),
|
|
255
|
-
children: maxDisplay ?? props.maxPlaceholder ?? "Max"
|
|
256
|
-
})
|
|
257
|
-
] });
|
|
258
143
|
const rangeError = staticValue.min !== null && staticValue.max !== null && staticValue.min > staticValue.max ? props.invalidRangeError ?? "Minimum cannot be greater than maximum" : void 0;
|
|
259
144
|
const effectiveError = props.error || rangeError;
|
|
260
145
|
const as = props.as ?? ui.input.as;
|
|
261
|
-
const size = props.size ?? ui.input.size;
|
|
262
|
-
const variant = props.variant ?? ui.input.variant;
|
|
263
|
-
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
264
|
-
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
265
146
|
let isDisabled = !!props.isDisabled;
|
|
266
147
|
if (isFormControlDisabled) isDisabled = true;
|
|
267
|
-
|
|
148
|
+
const isClearable = props.isClearable ?? ui.input.isClearable;
|
|
149
|
+
const dataAttributes = {
|
|
150
|
+
dataIsEmpty: !hasValue,
|
|
151
|
+
dataIsFilled: hasValue,
|
|
152
|
+
dataIsDirty: props.isDirty,
|
|
153
|
+
dataIsRequired: props.isRequired,
|
|
154
|
+
dataIsDisabled: isDisabled,
|
|
155
|
+
dataDisabled: isDisabled,
|
|
156
|
+
dataInvalid: !!effectiveError,
|
|
157
|
+
dataHasSelection: hasValue
|
|
158
|
+
};
|
|
159
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
268
160
|
...props,
|
|
269
161
|
error: effectiveError,
|
|
270
|
-
onInteract: (focus) => {
|
|
271
|
-
setShouldFocus(focus);
|
|
272
|
-
setRenderInput(true);
|
|
273
|
-
},
|
|
274
|
-
as,
|
|
275
|
-
size,
|
|
276
|
-
variant,
|
|
277
|
-
hideLabel,
|
|
278
|
-
isHeaderHidden,
|
|
279
162
|
isDisabled,
|
|
280
163
|
className: clsx("group w-full", as === "inline" && "h-full", props.className),
|
|
281
164
|
inputClassName: props.inputClassName,
|
|
282
|
-
|
|
283
|
-
dataAttributes
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
165
|
+
contentWrapperClassName: "flex w-full items-center gap-input-gap-input-text-to-elements",
|
|
166
|
+
dataAttributes,
|
|
167
|
+
renderStatic: true,
|
|
168
|
+
onStaticInteract: (focus) => {
|
|
169
|
+
setShouldFocus(focus);
|
|
170
|
+
setRenderInput(true);
|
|
171
|
+
},
|
|
172
|
+
isClearable: false,
|
|
173
|
+
labelPlacement: "content-row",
|
|
174
|
+
children: ({ id, ...dataAttributeProps }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
175
|
+
/* @__PURE__ */ jsx("input", {
|
|
176
|
+
id,
|
|
177
|
+
readOnly: true,
|
|
178
|
+
disabled: isDisabled,
|
|
179
|
+
tabIndex: -1,
|
|
180
|
+
value: minDisplay ?? "",
|
|
181
|
+
placeholder: props.minPlaceholder ?? "Min",
|
|
182
|
+
className: clsx("w-full bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.minInputClassName),
|
|
183
|
+
...dataAttributeProps,
|
|
184
|
+
"data-rac": true
|
|
185
|
+
}),
|
|
186
|
+
isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
187
|
+
onClear: () => {},
|
|
188
|
+
renderStatic: true
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ jsx("span", {
|
|
191
|
+
className: "pointer-events-none shrink-0 select-none text-label-2 text-text-default-3",
|
|
192
|
+
children: "-"
|
|
193
|
+
}),
|
|
194
|
+
/* @__PURE__ */ jsx("input", {
|
|
195
|
+
id: `${id}-max`,
|
|
196
|
+
readOnly: true,
|
|
197
|
+
disabled: isDisabled,
|
|
198
|
+
tabIndex: -1,
|
|
199
|
+
value: maxDisplay ?? "",
|
|
200
|
+
placeholder: props.maxPlaceholder ?? "Max",
|
|
201
|
+
className: clsx("w-full bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.maxInputClassName),
|
|
202
|
+
...dataAttributeProps,
|
|
203
|
+
"data-rac": true
|
|
204
|
+
}),
|
|
205
|
+
isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
206
|
+
onClear: () => {},
|
|
207
|
+
renderStatic: true
|
|
208
|
+
})
|
|
209
|
+
] })
|
|
293
210
|
});
|
|
294
211
|
}
|
|
295
212
|
if ("formControl" in props && props.formControl) {
|
|
@@ -137,10 +137,6 @@ var TextInput = ({ renderStaticInput, ...props }) => {
|
|
|
137
137
|
}, [renderInput, shouldFocus]);
|
|
138
138
|
if (!renderInput) {
|
|
139
139
|
const as = props.as ?? ui.input.as;
|
|
140
|
-
const size = props.size ?? ui.input.size;
|
|
141
|
-
const variant = props.variant ?? ui.input.variant;
|
|
142
|
-
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
143
|
-
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
144
140
|
let isDisabled = !!props.isDisabled;
|
|
145
141
|
if (isFormControlDisabled) isDisabled = true;
|
|
146
142
|
const maskedPasswordValue = inputType === "password" && `${staticValue}`.length > 0 ? "•".repeat(`${staticValue}`.length) : staticValue;
|
|
@@ -158,8 +154,6 @@ var TextInput = ({ renderStaticInput, ...props }) => {
|
|
|
158
154
|
};
|
|
159
155
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
160
156
|
...props,
|
|
161
|
-
isHeaderHidden,
|
|
162
|
-
hideLabel,
|
|
163
157
|
isDisabled,
|
|
164
158
|
className: clsx("group w-full", as === "inline" && "h-full", props.className),
|
|
165
159
|
dataAttributes,
|
|
@@ -169,9 +163,6 @@ var TextInput = ({ renderStaticInput, ...props }) => {
|
|
|
169
163
|
setRenderInput(true);
|
|
170
164
|
},
|
|
171
165
|
inputClassName: props.inputClassName,
|
|
172
|
-
as,
|
|
173
|
-
size,
|
|
174
|
-
variant,
|
|
175
166
|
children: (dataAttributeProps) => /* @__PURE__ */ jsx("input", {
|
|
176
167
|
ref: inputRef,
|
|
177
168
|
type: inputType === "hidden" ? "password" : inputType,
|
|
@@ -87,8 +87,6 @@ function Autocomplete({ renderStaticInput, ...props }) {
|
|
|
87
87
|
};
|
|
88
88
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
89
89
|
...props,
|
|
90
|
-
isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
|
|
91
|
-
hideLabel: props.hideLabel ?? ui.input.hideLabel,
|
|
92
90
|
isDisabled,
|
|
93
91
|
className: clsx("w-full", props.containerClassName),
|
|
94
92
|
inputClassName: clsx(props.className, props.inputClassName),
|
|
@@ -100,9 +98,6 @@ function Autocomplete({ renderStaticInput, ...props }) {
|
|
|
100
98
|
setShouldFocus(focus);
|
|
101
99
|
setRenderInput(true);
|
|
102
100
|
},
|
|
103
|
-
as,
|
|
104
|
-
size: props.size ?? ui.input.size,
|
|
105
|
-
variant: props.variant ?? ui.input.variant,
|
|
106
101
|
leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
|
|
107
102
|
className: "ml-input-side-default flex shrink-0 items-center",
|
|
108
103
|
children: props.leadingContent
|
|
@@ -53,7 +53,6 @@ function Select({ renderStaticInput, ...props }) {
|
|
|
53
53
|
const as = props.as ?? ui.input.as;
|
|
54
54
|
let isDisabled = !!props.isDisabled;
|
|
55
55
|
if (isFormControlDisabled) isDisabled = true;
|
|
56
|
-
const isClearable = props.isClearable ?? ui.input.isClearable;
|
|
57
56
|
const mode = props.selectionMode ?? ui.select.selectionMode;
|
|
58
57
|
const isMultiple = mode === "multiple";
|
|
59
58
|
const { selectedItem, displayValue, isEmpty } = getStaticSelectValue({
|
|
@@ -89,8 +88,6 @@ function Select({ renderStaticInput, ...props }) {
|
|
|
89
88
|
}) : displayValue;
|
|
90
89
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
91
90
|
...props,
|
|
92
|
-
isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
|
|
93
|
-
hideLabel: props.hideLabel ?? ui.input.hideLabel,
|
|
94
91
|
isDisabled,
|
|
95
92
|
className: clsx("w-full", props.containerClassName),
|
|
96
93
|
inputClassName: clsx(props.className, props.inputClassName),
|
|
@@ -102,14 +99,10 @@ function Select({ renderStaticInput, ...props }) {
|
|
|
102
99
|
setShouldFocus(focus);
|
|
103
100
|
setRenderInput(true);
|
|
104
101
|
},
|
|
105
|
-
as,
|
|
106
|
-
size: props.size ?? ui.input.size,
|
|
107
|
-
variant: props.variant ?? ui.input.variant,
|
|
108
102
|
leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
|
|
109
103
|
className: "ml-input-side-default flex shrink-0 items-center",
|
|
110
104
|
children: props.leadingContent
|
|
111
105
|
}),
|
|
112
|
-
isClearable,
|
|
113
106
|
showClear: false,
|
|
114
107
|
trailingContent,
|
|
115
108
|
children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [isMultiple && !isEmpty && displayValue, isSearchable ? /* @__PURE__ */ jsx("input", {
|
|
@@ -33,8 +33,12 @@ type InputFrameDataAttributeProps = {
|
|
|
33
33
|
"data-is-filled"?: boolean;
|
|
34
34
|
"data-is-required"?: boolean;
|
|
35
35
|
};
|
|
36
|
-
type
|
|
36
|
+
type InputFrameChildProps = InputFrameDataAttributeProps & {
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
type InputFrameChildren = ReactNode | ((childProps: InputFrameChildProps) => ReactNode);
|
|
37
40
|
type InputFrameLabelPlacement = "content-wrapper" | "content-row";
|
|
41
|
+
type InputFrameActionContentPlacement = "content-wrapper" | "content-row";
|
|
38
42
|
export interface InputFrameProps extends InputVariantProps, Partial<FormFieldProps> {
|
|
39
43
|
ref?: Ref<HTMLDivElement>;
|
|
40
44
|
children: InputFrameChildren;
|
|
@@ -44,6 +48,7 @@ export interface InputFrameProps extends InputVariantProps, Partial<FormFieldPro
|
|
|
44
48
|
leadingContent?: ReactNode;
|
|
45
49
|
leadingIcon?: InputFrameIcon;
|
|
46
50
|
actionContent?: ReactNode;
|
|
51
|
+
actionContentPlacement?: InputFrameActionContentPlacement;
|
|
47
52
|
trailingContent?: ReactNode;
|
|
48
53
|
trailingIcon?: InputFrameIcon;
|
|
49
54
|
trailingAction?: ReactNode;
|
|
@@ -58,11 +63,12 @@ export interface InputFrameProps extends InputVariantProps, Partial<FormFieldPro
|
|
|
58
63
|
onClear?: () => void;
|
|
59
64
|
dataAttributes?: InputFrameDataAttributes;
|
|
60
65
|
typographySize?: TypographyVariantProps["size"];
|
|
66
|
+
id?: string;
|
|
61
67
|
inputClassName?: string;
|
|
62
68
|
contentClassName?: string;
|
|
63
69
|
contentWrapperClassName?: string;
|
|
64
70
|
labelPlacement?: InputFrameLabelPlacement;
|
|
65
71
|
trailingClassName?: string;
|
|
66
72
|
}
|
|
67
|
-
export declare const InputFrame: (
|
|
73
|
+
export declare const InputFrame: (props: InputFrameProps) => import("react/jsx-runtime").JSX.Element;
|
|
68
74
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UIStyle } from "../../../config/uiStyle.context.js";
|
|
2
2
|
import { typography } from "../../text/Typography/typography.cva.js";
|
|
3
3
|
import { Loader } from "../../status/Loader/Loader.js";
|
|
4
|
+
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
4
5
|
import { InlineIconButton } from "../../buttons/InlineIconButton/InlineIconButton.js";
|
|
5
6
|
import { FormFieldLabel } from "../FormField/FormFieldLabel.js";
|
|
6
7
|
import { InputClear } from "../shared/InputClear.js";
|
|
@@ -9,19 +10,32 @@ import { FormField } from "../FormField/FormField.js";
|
|
|
9
10
|
import { TooltipWrapper } from "../shared/TooltipWrapper.js";
|
|
10
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import { clsx } from "clsx";
|
|
12
|
-
import { isValidElement } from "react";
|
|
13
|
+
import { isValidElement, useId } from "react";
|
|
13
14
|
//#region src/components/inputs/Skeleton/InputFrame.tsx
|
|
14
|
-
var InputFrame = (
|
|
15
|
+
var InputFrame = (props) => {
|
|
16
|
+
const ui = UIConfig.useConfig();
|
|
15
17
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
16
18
|
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
17
19
|
const inputContentWrapperCva = UIStyle.useCva("input.contentWrapperCva", inputContentWrapper);
|
|
18
20
|
const typographyCva = UIStyle.useCva("typography.cva", typography);
|
|
19
|
-
const
|
|
21
|
+
const generatedInputId = useId();
|
|
22
|
+
const { ref, children, formFieldRef, labelProps: labelPropsProp, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel: hideLabelProp, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, actionContentPlacement = "content-wrapper", trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable: isClearableProp, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, id: idProp, inputClassName, contentClassName, contentWrapperClassName, labelPlacement = "content-wrapper", trailingClassName, variant: variantProp, as: asProp, size: sizeProp } = props;
|
|
23
|
+
const as = asProp ?? ui.input.as;
|
|
24
|
+
const size = sizeProp ?? ui.input.size;
|
|
25
|
+
const variant = variantProp ?? ui.input.variant;
|
|
26
|
+
const hideLabel = hideLabelProp ?? ui.input.hideLabel;
|
|
27
|
+
const hasClear = !!(isClearableProp ?? ui.input.isClearable);
|
|
20
28
|
const isLeadingIconElement = leadingIcon && isValidElement(leadingIcon);
|
|
21
29
|
const isTrailingIconElement = trailingIcon && isValidElement(trailingIcon);
|
|
22
30
|
const hasTrailingContent = hasClear || !!trailingContent || !!unit || !!isLoading || !!action || !!trailingIcon || !!trailingAction;
|
|
23
31
|
const isTrailingInteractive = !!action || !!trailingAction || !!isTrailingIconElement || hasClear && !!showClear || !!trailingContent;
|
|
24
32
|
const dataAttributeProps = getInputFrameDataAttributeProps(dataAttributes);
|
|
33
|
+
const baseLabelProps = headerProps?.labelProps ?? labelPropsProp;
|
|
34
|
+
const inputId = idProp ?? baseLabelProps?.htmlFor ?? `input-frame_${generatedInputId}`;
|
|
35
|
+
const labelProps = {
|
|
36
|
+
...baseLabelProps,
|
|
37
|
+
htmlFor: inputId
|
|
38
|
+
};
|
|
25
39
|
const formFieldProps = {
|
|
26
40
|
error,
|
|
27
41
|
label: label ?? "",
|
|
@@ -36,7 +50,10 @@ var InputFrame = ({ ref, children, formFieldRef, labelProps, headerProps, error,
|
|
|
36
50
|
errorClassName,
|
|
37
51
|
className
|
|
38
52
|
};
|
|
39
|
-
const resolvedHeaderProps = headerProps
|
|
53
|
+
const resolvedHeaderProps = headerProps ? {
|
|
54
|
+
...headerProps,
|
|
55
|
+
labelProps
|
|
56
|
+
} : {
|
|
40
57
|
label: label ?? "",
|
|
41
58
|
tooltipText,
|
|
42
59
|
helperText,
|
|
@@ -100,12 +117,16 @@ var InputFrame = ({ ref, children, formFieldRef, labelProps, headerProps, error,
|
|
|
100
117
|
children: renderIconVisual(leadingIcon)
|
|
101
118
|
}),
|
|
102
119
|
labelPlacement === "content-row" && labelContent,
|
|
120
|
+
actionContentPlacement === "content-row" && actionContent,
|
|
103
121
|
/* @__PURE__ */ jsxs("div", {
|
|
104
122
|
className: resolvedContentWrapperClassName,
|
|
105
123
|
children: [
|
|
106
124
|
labelPlacement === "content-wrapper" && labelContent,
|
|
107
|
-
actionContent,
|
|
108
|
-
typeof children === "function" ? children(
|
|
125
|
+
actionContentPlacement === "content-wrapper" && actionContent,
|
|
126
|
+
typeof children === "function" ? children({
|
|
127
|
+
...dataAttributeProps,
|
|
128
|
+
id: inputId
|
|
129
|
+
}) : children
|
|
109
130
|
]
|
|
110
131
|
})
|
|
111
132
|
]
|
|
@@ -6,8 +6,8 @@ import { clsx } from "clsx";
|
|
|
6
6
|
import { useTranslation } from "react-i18next";
|
|
7
7
|
//#region src/components/inputs/shared/InputClear.tsx
|
|
8
8
|
var InputClear = ({ onClear, className, style, show, renderStatic }) => {
|
|
9
|
-
if (renderStatic) return /* @__PURE__ */ jsx("
|
|
10
|
-
className: clsx("size-6 shrink-0", className),
|
|
9
|
+
if (renderStatic) return /* @__PURE__ */ jsx("button", {
|
|
10
|
+
className: clsx("invisible relative z-1 flex items-center size-6 shrink-0", "group-focus-within:visible group-hover/date-picker-content:visible group-hover/select-content:visible group-hover/text-area:visible group-hover:visible", "border-0!", !show && "invisible!", className),
|
|
11
11
|
style
|
|
12
12
|
});
|
|
13
13
|
return /* @__PURE__ */ jsx(InputClearButton, {
|
package/package.json
CHANGED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { UIStyle } from "../../../config/uiStyle.context.js";
|
|
2
|
-
import { typography } from "../../text/Typography/typography.cva.js";
|
|
3
|
-
import { FormFieldLabel } from "../FormField/FormFieldLabel.js";
|
|
4
|
-
import { inputBase, inputSize } from "./input.cva.js";
|
|
5
|
-
import { FormField } from "../FormField/FormField.js";
|
|
6
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { clsx } from "clsx";
|
|
8
|
-
//#region src/components/inputs/shared/StaticInput.tsx
|
|
9
|
-
var StaticInput = ({ onInteract, as, typographySize, size, variant, applyMinInputWidth, placeholder, showPlacholderIfFilled = false, displayValue, isEmpty, leadingVisual, leadingContent, leadingContentClassName, hasClearIcon, trailingContent, contentRowClassName, inputClassName, dataAttributes, className, ...formFieldProps }) => {
|
|
10
|
-
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
11
|
-
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
12
|
-
const typographyCva = UIStyle.useCva("typography.cva", typography);
|
|
13
|
-
let hasValue = !!displayValue;
|
|
14
|
-
if (isEmpty != null) hasValue = !isEmpty;
|
|
15
|
-
let staticDisplayContent = placeholder;
|
|
16
|
-
if (hasValue) staticDisplayContent = displayValue;
|
|
17
|
-
else if (as === "floating") staticDisplayContent = null;
|
|
18
|
-
const shouldRenderPlaceholderAfterValue = showPlacholderIfFilled && placeholder && hasValue;
|
|
19
|
-
const shouldRenderFloatingLineSpacer = as === "floating" && !hasValue;
|
|
20
|
-
const inputDataAttributes = {
|
|
21
|
-
dataIsEmpty: !hasValue,
|
|
22
|
-
dataDisabled: formFieldProps.isDisabled,
|
|
23
|
-
dataIsDisabled: formFieldProps.isDisabled,
|
|
24
|
-
dataHasSelection: hasValue,
|
|
25
|
-
...dataAttributes
|
|
26
|
-
};
|
|
27
|
-
return /* @__PURE__ */ jsx(FormField, {
|
|
28
|
-
...formFieldProps,
|
|
29
|
-
as,
|
|
30
|
-
className,
|
|
31
|
-
onMouseEnter: () => onInteract(false),
|
|
32
|
-
tabIndex: as === "inline" ? -1 : void 0,
|
|
33
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
34
|
-
tabIndex: formFieldProps.isDisabled ? -1 : 0,
|
|
35
|
-
onFocus: () => onInteract(true),
|
|
36
|
-
onClick: () => onInteract(true),
|
|
37
|
-
onPointerDown: () => onInteract(true),
|
|
38
|
-
"data-is-empty": inputDataAttributes.dataIsEmpty || void 0,
|
|
39
|
-
"data-disabled": inputDataAttributes.dataDisabled || void 0,
|
|
40
|
-
"data-is-disabled": inputDataAttributes.dataIsDisabled || void 0,
|
|
41
|
-
"data-has-selection": inputDataAttributes.dataHasSelection || void 0,
|
|
42
|
-
"data-has-search": inputDataAttributes.dataHasSearch || void 0,
|
|
43
|
-
"data-invalid": inputDataAttributes.dataInvalid || void 0,
|
|
44
|
-
"data-is-dirty": inputDataAttributes.dataIsDirty || void 0,
|
|
45
|
-
"data-is-filled": inputDataAttributes.dataIsFilled || void 0,
|
|
46
|
-
"data-is-required": inputDataAttributes.dataIsRequired || void 0,
|
|
47
|
-
"data-rac": "",
|
|
48
|
-
className: clsx("group/static-input group/input-content group/select-content relative flex items-center gap-input-gap-input-text-to-elements", applyMinInputWidth && "min-w-input-width-min-width", inputBaseCva({
|
|
49
|
-
as,
|
|
50
|
-
variant
|
|
51
|
-
}), inputClassName),
|
|
52
|
-
children: [
|
|
53
|
-
/* @__PURE__ */ jsxs("div", {
|
|
54
|
-
className: clsx("group/input-content flex min-w-0 w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeCva({
|
|
55
|
-
size,
|
|
56
|
-
as
|
|
57
|
-
}), typographySize && typographyCva({ size: typographySize }), contentRowClassName),
|
|
58
|
-
children: [
|
|
59
|
-
leadingVisual && /* @__PURE__ */ jsx("div", {
|
|
60
|
-
className: "pointer-events-none shrink-0",
|
|
61
|
-
children: leadingVisual
|
|
62
|
-
}),
|
|
63
|
-
as && ["filter", "floating"].includes(as) && /* @__PURE__ */ jsx(FormFieldLabel, {
|
|
64
|
-
as,
|
|
65
|
-
size,
|
|
66
|
-
label: formFieldProps.label,
|
|
67
|
-
isRequired: formFieldProps.isRequired,
|
|
68
|
-
isDisabled: formFieldProps.isDisabled
|
|
69
|
-
}),
|
|
70
|
-
leadingContent && /* @__PURE__ */ jsx("div", {
|
|
71
|
-
className: clsx("ml-input-side-default flex shrink-0 items-center", leadingContentClassName),
|
|
72
|
-
children: leadingContent
|
|
73
|
-
}),
|
|
74
|
-
!hasValue ? /* @__PURE__ */ jsx("div", {
|
|
75
|
-
className: "text-text-default-3",
|
|
76
|
-
children: staticDisplayContent
|
|
77
|
-
}) : staticDisplayContent,
|
|
78
|
-
shouldRenderFloatingLineSpacer && /* @__PURE__ */ jsx(Fragment, { children: "\xA0" }),
|
|
79
|
-
shouldRenderPlaceholderAfterValue && /* @__PURE__ */ jsx("div", {
|
|
80
|
-
className: "shrink-0 text-text-default-3",
|
|
81
|
-
children: placeholder
|
|
82
|
-
})
|
|
83
|
-
]
|
|
84
|
-
}),
|
|
85
|
-
hasClearIcon && /* @__PURE__ */ jsx("div", {
|
|
86
|
-
className: clsx("flex items-center gap-input-gap-trailing-elements py-0! pl-0!", inputSizeCva({
|
|
87
|
-
size,
|
|
88
|
-
as
|
|
89
|
-
})),
|
|
90
|
-
children: /* @__PURE__ */ jsx("div", { className: "size-6 shrink-0" })
|
|
91
|
-
}),
|
|
92
|
-
trailingContent && /* @__PURE__ */ jsx("div", {
|
|
93
|
-
className: clsx(inputSizeCva({
|
|
94
|
-
size,
|
|
95
|
-
as
|
|
96
|
-
}), "pointer-events-none flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
|
|
97
|
-
children: trailingContent
|
|
98
|
-
})
|
|
99
|
-
]
|
|
100
|
-
})
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
//#endregion
|
|
104
|
-
export { StaticInput };
|