@povio/ui 2.2.9-rc.30 → 2.2.9-rc.31
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 +0 -8
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +0 -8
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +0 -8
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +0 -9
- 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 +97 -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 +1 -1
- package/dist/components/inputs/Skeleton/InputFrame.js +9 -2
- package/dist/components/inputs/shared/InputClear.js +2 -2
- package/package.json +1 -1
- package/dist/components/inputs/shared/StaticInput.js +0 -104
|
@@ -212,9 +212,6 @@ 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;
|
|
@@ -230,8 +227,6 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...pr
|
|
|
230
227
|
});
|
|
231
228
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
232
229
|
...props,
|
|
233
|
-
isHeaderHidden,
|
|
234
|
-
hideLabel,
|
|
235
230
|
isDisabled,
|
|
236
231
|
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
237
232
|
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
@@ -252,9 +247,6 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...pr
|
|
|
252
247
|
setShouldFocus(focus);
|
|
253
248
|
setRenderInput(true);
|
|
254
249
|
},
|
|
255
|
-
as,
|
|
256
|
-
size,
|
|
257
|
-
variant,
|
|
258
250
|
actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
259
251
|
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
260
252
|
children: staticSegments
|
|
@@ -612,9 +612,6 @@ 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;
|
|
@@ -631,8 +628,6 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
631
628
|
});
|
|
632
629
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
633
630
|
...props,
|
|
634
|
-
isHeaderHidden,
|
|
635
|
-
hideLabel,
|
|
636
631
|
isDisabled,
|
|
637
632
|
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
638
633
|
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
@@ -653,9 +648,6 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
653
648
|
setShouldFocus(focus);
|
|
654
649
|
setRenderInput(true);
|
|
655
650
|
},
|
|
656
|
-
as,
|
|
657
|
-
size,
|
|
658
|
-
variant,
|
|
659
651
|
actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
660
652
|
trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
|
|
661
653
|
children: staticSegments
|
|
@@ -226,9 +226,6 @@ 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;
|
|
@@ -244,8 +241,6 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
|
|
|
244
241
|
});
|
|
245
242
|
return /* @__PURE__ */ jsx(InputFrame, {
|
|
246
243
|
...props,
|
|
247
|
-
isHeaderHidden,
|
|
248
|
-
hideLabel,
|
|
249
244
|
isDisabled,
|
|
250
245
|
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
251
246
|
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
@@ -266,9 +261,6 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
|
|
|
266
261
|
setShouldFocus(focus);
|
|
267
262
|
setRenderInput(true);
|
|
268
263
|
},
|
|
269
|
-
as,
|
|
270
|
-
size,
|
|
271
|
-
variant,
|
|
272
264
|
actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
|
|
273
265
|
trailingContent: showDropdown ? ui.dateInput.dateTimeIcon : void 0,
|
|
274
266
|
children: staticSegments
|
|
@@ -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
|
});
|
|
@@ -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,70 @@ 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
|
+
children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
174
|
+
/* @__PURE__ */ jsx("input", {
|
|
175
|
+
readOnly: true,
|
|
176
|
+
disabled: isDisabled,
|
|
177
|
+
tabIndex: -1,
|
|
178
|
+
value: minDisplay ?? "",
|
|
179
|
+
placeholder: props.minPlaceholder ?? "Min",
|
|
180
|
+
className: clsx("w-full bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.minInputClassName),
|
|
181
|
+
...dataAttributeProps,
|
|
182
|
+
"data-rac": true
|
|
183
|
+
}),
|
|
184
|
+
isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
185
|
+
onClear: () => {},
|
|
186
|
+
renderStatic: true
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ jsx("span", {
|
|
189
|
+
className: "pointer-events-none shrink-0 select-none text-label-2 text-text-default-3",
|
|
190
|
+
children: "-"
|
|
191
|
+
}),
|
|
192
|
+
/* @__PURE__ */ jsx("input", {
|
|
193
|
+
readOnly: true,
|
|
194
|
+
disabled: isDisabled,
|
|
195
|
+
tabIndex: -1,
|
|
196
|
+
value: maxDisplay ?? "",
|
|
197
|
+
placeholder: props.maxPlaceholder ?? "Max",
|
|
198
|
+
className: clsx("w-full bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.maxInputClassName),
|
|
199
|
+
...dataAttributeProps,
|
|
200
|
+
"data-rac": true
|
|
201
|
+
}),
|
|
202
|
+
isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
203
|
+
onClear: () => {},
|
|
204
|
+
renderStatic: true
|
|
205
|
+
})
|
|
206
|
+
] })
|
|
293
207
|
});
|
|
294
208
|
}
|
|
295
209
|
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", {
|
|
@@ -64,5 +64,5 @@ export interface InputFrameProps extends InputVariantProps, Partial<FormFieldPro
|
|
|
64
64
|
labelPlacement?: InputFrameLabelPlacement;
|
|
65
65
|
trailingClassName?: string;
|
|
66
66
|
}
|
|
67
|
-
export declare const InputFrame: (
|
|
67
|
+
export declare const InputFrame: (props: InputFrameProps) => import("react/jsx-runtime").JSX.Element;
|
|
68
68
|
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";
|
|
@@ -11,12 +12,18 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
11
12
|
import { clsx } from "clsx";
|
|
12
13
|
import { isValidElement } 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 { ref, children, formFieldRef, labelProps, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel: hideLabelProp, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable: isClearableProp, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, inputClassName, contentClassName, contentWrapperClassName, labelPlacement = "content-wrapper", trailingClassName, variant: variantProp, as: asProp, size: sizeProp } = props;
|
|
22
|
+
const as = asProp ?? ui.input.as;
|
|
23
|
+
const size = sizeProp ?? ui.input.size;
|
|
24
|
+
const variant = variantProp ?? ui.input.variant;
|
|
25
|
+
const hideLabel = hideLabelProp ?? ui.input.hideLabel;
|
|
26
|
+
const hasClear = !!(isClearableProp ?? ui.input.isClearable);
|
|
20
27
|
const isLeadingIconElement = leadingIcon && isValidElement(leadingIcon);
|
|
21
28
|
const isTrailingIconElement = trailingIcon && isValidElement(trailingIcon);
|
|
22
29
|
const hasTrailingContent = hasClear || !!trailingContent || !!unit || !!isLoading || !!action || !!trailingIcon || !!trailingAction;
|
|
@@ -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 };
|