@povio/ui 2.2.9-rc.15 → 2.2.9-rc.17
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.d.ts +3 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +66 -4
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +95 -4
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +66 -4
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +57 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +6 -5
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +3 -2
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +20 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +80 -8
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +83 -8
- package/dist/components/inputs/Inputs/InputItem.d.ts +6 -6
- package/dist/components/inputs/RadioGroup/RadioGroup.js +15 -12
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +3 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +69 -3
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +1 -10
- package/dist/components/inputs/Selection/Select/Select.d.ts +3 -1
- package/dist/components/inputs/Selection/Select/Select.js +69 -3
- package/dist/components/inputs/Selection/shared/SelectInput.js +3 -1
- package/dist/components/inputs/shared/StaticInput.d.ts +21 -0
- package/dist/components/inputs/shared/StaticInput.js +79 -0
- package/dist/components/inputs/shared/input.cva.d.ts +5 -0
- package/dist/components/inputs/shared/input.cva.js +10 -1
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +1 -1
- package/dist/config/uiConfig.context.d.ts +5 -1
- package/dist/config/uiConfig.context.js +7 -0
- package/dist/config/uiStyle.context.d.ts +2 -1
- package/dist/utils/date-time.utils.d.ts +10 -0
- package/dist/utils/date-time.utils.js +82 -1
- package/package.json +1 -1
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { UIStyle } from "../../../../config/uiStyle.context.js";
|
|
2
|
+
import { Loader } from "../../../status/Loader/Loader.js";
|
|
2
3
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
4
|
import { inputBase } from "../../shared/input.cva.js";
|
|
4
5
|
import { FormField } from "../../FormField/FormField.js";
|
|
6
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
5
7
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
6
8
|
import { InputContent } from "../shared/InputContent.js";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
import { clsx } from "clsx";
|
|
9
|
-
import { useCallback, useRef } from "react";
|
|
11
|
+
import { isValidElement, useCallback, useEffect, useRef, useState } from "react";
|
|
10
12
|
import { Input, useLocale } from "react-aria-components";
|
|
11
13
|
import { useFocusVisible, useNumberField } from "react-aria";
|
|
12
14
|
import { mergeRefs } from "@react-aria/utils";
|
|
13
|
-
import { Controller } from "react-hook-form";
|
|
15
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
14
16
|
import { useNumberFieldState } from "react-stately";
|
|
15
17
|
//#region src/components/inputs/Input/NumberInput/NumberInput.tsx
|
|
16
18
|
var NumberInputBase = (props) => {
|
|
17
19
|
const ui = UIConfig.useConfig();
|
|
18
20
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
19
21
|
const inputRef = useRef(null);
|
|
20
|
-
const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, formatOptions = ui.numberInput.formatOptions, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, ...rest } = props;
|
|
22
|
+
const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, formatOptions = ui.numberInput.formatOptions, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, autoFocusOnMount, ...rest } = props;
|
|
21
23
|
const numberFieldRef = useRef(null);
|
|
22
24
|
const { isFocusVisible } = useFocusVisible();
|
|
23
25
|
const { locale } = useLocale();
|
|
@@ -34,6 +36,10 @@ var NumberInputBase = (props) => {
|
|
|
34
36
|
formatOptions
|
|
35
37
|
};
|
|
36
38
|
const { labelProps, inputProps } = useNumberField(numberProps, useNumberFieldState(numberProps), numberFieldRef);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!autoFocusOnMount || isDisabled) return;
|
|
41
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
42
|
+
}, [autoFocusOnMount, isDisabled]);
|
|
37
43
|
const formFieldProps = {
|
|
38
44
|
error,
|
|
39
45
|
label,
|
|
@@ -114,7 +120,68 @@ var NumberInputBase = (props) => {
|
|
|
114
120
|
})
|
|
115
121
|
});
|
|
116
122
|
};
|
|
117
|
-
var
|
|
123
|
+
var renderIconVisual = (icon) => {
|
|
124
|
+
if (!icon) return null;
|
|
125
|
+
if (isValidElement(icon)) return icon;
|
|
126
|
+
return /* @__PURE__ */ jsx(icon, { className: "size-6 text-interactive-text-secondary-idle" });
|
|
127
|
+
};
|
|
128
|
+
var NumberInput = ({ renderStaticInput, ...props }) => {
|
|
129
|
+
const ui = UIConfig.useConfig();
|
|
130
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
131
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
132
|
+
const inputRef = useRef(null);
|
|
133
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
134
|
+
control: props.formControl.control,
|
|
135
|
+
name: props.formControl.name
|
|
136
|
+
}) : props.value;
|
|
137
|
+
let isFormControlDisabled = false;
|
|
138
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (!renderInput || !shouldFocus) return;
|
|
141
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
142
|
+
setShouldFocus(false);
|
|
143
|
+
}, [renderInput, shouldFocus]);
|
|
144
|
+
if (!renderInput) {
|
|
145
|
+
const staticValue = watchedValue ?? props.value ?? props.defaultValue;
|
|
146
|
+
const displayValue = staticValue == null ? "" : `${staticValue}`;
|
|
147
|
+
const hasValue = displayValue !== "";
|
|
148
|
+
const as = props.as ?? ui.input.as;
|
|
149
|
+
const size = props.size ?? ui.input.size;
|
|
150
|
+
const variant = props.variant ?? ui.input.variant;
|
|
151
|
+
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
152
|
+
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
153
|
+
let isDisabled = !!props.isDisabled;
|
|
154
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
155
|
+
const trailingContent = !!props.unit || !!props.isLoading || !!props.action && !props.isLoading || !!props.trailingIcon && !props.isLoading && !props.action ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
156
|
+
props.unit && /* @__PURE__ */ jsx("span", {
|
|
157
|
+
className: "text-label-2 text-text-default-3",
|
|
158
|
+
children: props.unit
|
|
159
|
+
}),
|
|
160
|
+
props.isLoading && /* @__PURE__ */ jsx(Loader, {}),
|
|
161
|
+
!props.isLoading && props.action && renderIconVisual(props.action.icon),
|
|
162
|
+
!props.isLoading && !props.action && props.trailingIcon && renderIconVisual(props.trailingIcon)
|
|
163
|
+
] }) : void 0;
|
|
164
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
165
|
+
...props,
|
|
166
|
+
onInteract: (focus) => {
|
|
167
|
+
setShouldFocus(focus);
|
|
168
|
+
setRenderInput(true);
|
|
169
|
+
},
|
|
170
|
+
as,
|
|
171
|
+
size,
|
|
172
|
+
variant,
|
|
173
|
+
hideLabel,
|
|
174
|
+
isHeaderHidden,
|
|
175
|
+
isDisabled,
|
|
176
|
+
className: clsx("group w-full", as === "inline" && "h-full", props.className),
|
|
177
|
+
inputClassName: props.inputClassName,
|
|
178
|
+
placeholder: as === "floating" ? "" : props.placeholder,
|
|
179
|
+
displayValue,
|
|
180
|
+
isEmpty: !hasValue,
|
|
181
|
+
leadingVisual: renderIconVisual(props.leadingIcon),
|
|
182
|
+
trailingContent
|
|
183
|
+
});
|
|
184
|
+
}
|
|
118
185
|
if ("formControl" in props && props.formControl) {
|
|
119
186
|
const { formControl, ref, ...innerProps } = props;
|
|
120
187
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -122,17 +189,22 @@ var NumberInput = (props) => {
|
|
|
122
189
|
name: formControl.name,
|
|
123
190
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(NumberInputBase, {
|
|
124
191
|
...innerProps,
|
|
125
|
-
ref: mergeRefs(ref, field.ref),
|
|
192
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
126
193
|
value: field.value,
|
|
127
194
|
onChange: field.onChange,
|
|
128
195
|
onBlur: field.onBlur,
|
|
129
196
|
isDirty,
|
|
130
197
|
isDisabled: field.disabled || props.isDisabled,
|
|
131
|
-
error: props.error ?? error?.message
|
|
198
|
+
error: props.error ?? error?.message,
|
|
199
|
+
autoFocusOnMount: shouldFocus
|
|
132
200
|
}, field.value === null || field.value === void 0 ? "empty" : "filled")
|
|
133
201
|
});
|
|
134
202
|
}
|
|
135
|
-
return /* @__PURE__ */ jsx(NumberInputBase, {
|
|
203
|
+
return /* @__PURE__ */ jsx(NumberInputBase, {
|
|
204
|
+
...props,
|
|
205
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
206
|
+
autoFocusOnMount: shouldFocus
|
|
207
|
+
}, props.value === null || props.value === void 0 ? "empty" : "filled");
|
|
136
208
|
};
|
|
137
209
|
//#endregion
|
|
138
210
|
export { NumberInput };
|
|
@@ -13,9 +13,11 @@ interface TextInputBaseProps extends FormFieldProps, InputVariantProps, Omit<Inp
|
|
|
13
13
|
type?: AllowedHTMLInputTypeAttribute;
|
|
14
14
|
todayIcon?: boolean;
|
|
15
15
|
isDirty?: boolean;
|
|
16
|
+
autoFocusOnMount?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export interface TextInputProps extends TextInputBaseProps {
|
|
19
|
+
renderStaticInput?: boolean;
|
|
18
20
|
}
|
|
19
21
|
export type ControlledTextInputProps<TFieldValues extends FieldValues> = ControlProps<TextInputProps, TFieldValues>;
|
|
20
|
-
export declare const TextInput: <TFieldValues extends FieldValues>(props: ControlledTextInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const TextInput: <TFieldValues extends FieldValues>({ renderStaticInput, ...props }: ControlledTextInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
21
23
|
export {};
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { UIStyle } from "../../../../config/uiStyle.context.js";
|
|
2
|
+
import { Loader } from "../../../status/Loader/Loader.js";
|
|
2
3
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
4
|
import { inputBase } from "../../shared/input.cva.js";
|
|
4
5
|
import { FormField } from "../../FormField/FormField.js";
|
|
6
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
5
7
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
6
8
|
import { InputContent } from "../shared/InputContent.js";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
import { clsx } from "clsx";
|
|
9
|
-
import { useRef } from "react";
|
|
11
|
+
import { isValidElement, useEffect, useRef, useState } from "react";
|
|
10
12
|
import { Input } from "react-aria-components";
|
|
11
13
|
import { useFocusVisible, useTextField } from "react-aria";
|
|
12
14
|
import { mergeRefs } from "@react-aria/utils";
|
|
13
|
-
import { Controller } from "react-hook-form";
|
|
15
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
14
16
|
//#region src/components/inputs/Input/TextInput/TextInput.tsx
|
|
15
17
|
var TextInputBase = (props) => {
|
|
16
18
|
const ui = UIConfig.useConfig();
|
|
17
19
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
18
20
|
const inputRef = useRef(null);
|
|
19
|
-
const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, ...rest } = props;
|
|
21
|
+
const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, autoFocusOnMount, ...rest } = props;
|
|
20
22
|
const textFieldRef = useRef(null);
|
|
21
23
|
const { isFocusVisible } = useFocusVisible();
|
|
22
24
|
const { labelProps, inputProps } = useTextField({
|
|
@@ -29,6 +31,10 @@ var TextInputBase = (props) => {
|
|
|
29
31
|
onChange,
|
|
30
32
|
onBlur
|
|
31
33
|
}, textFieldRef);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!autoFocusOnMount || isDisabled) return;
|
|
36
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
37
|
+
}, [autoFocusOnMount, isDisabled]);
|
|
32
38
|
const formFieldProps = {
|
|
33
39
|
error,
|
|
34
40
|
label,
|
|
@@ -111,7 +117,71 @@ var TextInputBase = (props) => {
|
|
|
111
117
|
})
|
|
112
118
|
});
|
|
113
119
|
};
|
|
114
|
-
var
|
|
120
|
+
var renderIconVisual = (icon) => {
|
|
121
|
+
if (!icon) return null;
|
|
122
|
+
if (isValidElement(icon)) return icon;
|
|
123
|
+
return /* @__PURE__ */ jsx(icon, { className: "size-6 text-interactive-text-secondary-idle" });
|
|
124
|
+
};
|
|
125
|
+
var TextInput = ({ renderStaticInput, ...props }) => {
|
|
126
|
+
const ui = UIConfig.useConfig();
|
|
127
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
128
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
129
|
+
const inputRef = useRef(null);
|
|
130
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
131
|
+
control: props.formControl.control,
|
|
132
|
+
name: props.formControl.name
|
|
133
|
+
}) : props.value;
|
|
134
|
+
let isFormControlDisabled = false;
|
|
135
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
136
|
+
const staticValue = watchedValue ?? props.value ?? props.defaultValue ?? "";
|
|
137
|
+
const inputType = props.type;
|
|
138
|
+
if (!renderInput && inputType === "password" && `${staticValue}`.length > 0) setRenderInput(true);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (!renderInput || !shouldFocus) return;
|
|
141
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
142
|
+
setShouldFocus(false);
|
|
143
|
+
}, [renderInput, shouldFocus]);
|
|
144
|
+
if (!renderInput) {
|
|
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
|
+
let isDisabled = !!props.isDisabled;
|
|
151
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
152
|
+
const maskedPasswordValue = inputType === "password" && `${staticValue}`.length > 0 ? "•".repeat(`${staticValue}`.length) : staticValue;
|
|
153
|
+
const displayValue = maskedPasswordValue == null ? "" : `${maskedPasswordValue}`;
|
|
154
|
+
const hasValue = displayValue !== "";
|
|
155
|
+
const trailingContent = !!props.unit || !!props.isLoading || !!props.action && !props.isLoading || !!props.trailingIcon && !props.isLoading && !props.action ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
156
|
+
props.unit && /* @__PURE__ */ jsx("span", {
|
|
157
|
+
className: "text-label-2 text-text-default-3",
|
|
158
|
+
children: props.unit
|
|
159
|
+
}),
|
|
160
|
+
props.isLoading && /* @__PURE__ */ jsx(Loader, {}),
|
|
161
|
+
!props.isLoading && props.action && renderIconVisual(props.action.icon),
|
|
162
|
+
!props.isLoading && !props.action && props.trailingIcon && renderIconVisual(props.trailingIcon)
|
|
163
|
+
] }) : void 0;
|
|
164
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
165
|
+
...props,
|
|
166
|
+
onInteract: (focus) => {
|
|
167
|
+
setShouldFocus(focus);
|
|
168
|
+
setRenderInput(true);
|
|
169
|
+
},
|
|
170
|
+
as,
|
|
171
|
+
size,
|
|
172
|
+
variant,
|
|
173
|
+
hideLabel,
|
|
174
|
+
isHeaderHidden,
|
|
175
|
+
isDisabled,
|
|
176
|
+
className: clsx("group w-full", as === "inline" && "h-full", props.className),
|
|
177
|
+
inputClassName: props.inputClassName,
|
|
178
|
+
placeholder: as === "floating" ? "" : props.placeholder,
|
|
179
|
+
displayValue,
|
|
180
|
+
isEmpty: !hasValue,
|
|
181
|
+
leadingVisual: renderIconVisual(props.leadingIcon),
|
|
182
|
+
trailingContent
|
|
183
|
+
});
|
|
184
|
+
}
|
|
115
185
|
if ("formControl" in props && props.formControl) {
|
|
116
186
|
const { formControl, ref, ...innerProps } = props;
|
|
117
187
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -119,17 +189,22 @@ var TextInput = (props) => {
|
|
|
119
189
|
name: formControl.name,
|
|
120
190
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(TextInputBase, {
|
|
121
191
|
...innerProps,
|
|
122
|
-
ref: mergeRefs(ref, field.ref),
|
|
192
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
123
193
|
value: field.value,
|
|
124
194
|
onChange: field.onChange,
|
|
125
195
|
onBlur: field.onBlur,
|
|
126
196
|
isDirty,
|
|
127
197
|
isDisabled: field.disabled || props.isDisabled,
|
|
128
|
-
error: props.error ?? error?.message
|
|
198
|
+
error: props.error ?? error?.message,
|
|
199
|
+
autoFocusOnMount: shouldFocus
|
|
129
200
|
})
|
|
130
201
|
});
|
|
131
202
|
}
|
|
132
|
-
return /* @__PURE__ */ jsx(TextInputBase, {
|
|
203
|
+
return /* @__PURE__ */ jsx(TextInputBase, {
|
|
204
|
+
...props,
|
|
205
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
206
|
+
autoFocusOnMount: shouldFocus
|
|
207
|
+
});
|
|
133
208
|
};
|
|
134
209
|
//#endregion
|
|
135
210
|
export { TextInput };
|
|
@@ -7,9 +7,9 @@ import { HasRequiredProperty } from '../../../types/common';
|
|
|
7
7
|
declare const componentRegistry: {
|
|
8
8
|
readonly toggle: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Toggle/Toggle').ControlledToggleProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
readonly checkbox: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Checkbox/Checkbox').ControlledCheckboxProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
readonly numberInput: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/NumberInput/NumberInput').ControlledNumberInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
readonly numberInput: <TFieldValues extends import('react-hook-form').FieldValues>({ renderStaticInput, ...props }: import('../Input/NumberInput/NumberInput').ControlledNumberInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
readonly slider: <TFieldValues extends import('react-hook-form').FieldValues, IsRange extends boolean = false>(props: import('../Slider/Slider').ControlledSliderProps<TFieldValues, IsRange>) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
readonly textInput: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/TextInput/TextInput').ControlledTextInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
readonly textInput: <TFieldValues extends import('react-hook-form').FieldValues>({ renderStaticInput, ...props }: import('../Input/TextInput/TextInput').ControlledTextInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
readonly passwordInput: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/PasswordInput/PasswordInput').ControlledPasswordInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
readonly textArea: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/TextArea/TextArea').ControlledTextAreaProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
readonly select: typeof Select;
|
|
@@ -17,10 +17,10 @@ declare const componentRegistry: {
|
|
|
17
17
|
readonly autocomplete: typeof Autocomplete;
|
|
18
18
|
readonly queryAutocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TSelectItem extends import('../../..').SelectItem<any>, TQueryFn extends import('../Selection/Autocomplete/queryAutocomplete.types').QueryFn>({ query, queryParams, queryOptions, queryMap, leadingContent, ...props }: import('../Selection/Autocomplete/queryAutocomplete.types').QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
readonly segment: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key>(props: import('../../..').ControlledSegmentProps<TFieldValues, TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
readonly datePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, ...props }: import('../DateTime/DatePicker/DatePicker').ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
readonly dateTimePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, ...props }: import('../DateTime/DateTimePicker/DateTimePicker').ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
readonly timePicker: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../DateTime/TimePicker/TimePicker').ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
readonly dateRangePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, ...props }: import('../DateTime/DateRangePicker/DateRangePicker').ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
readonly datePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, renderStaticInput, ...props }: import('../DateTime/DatePicker/DatePicker').ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
readonly dateTimePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, renderStaticInput, ...props }: import('../DateTime/DateTimePicker/DateTimePicker').ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
readonly timePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ renderStaticInput, ...props }: import('../DateTime/TimePicker/TimePicker').ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
readonly dateRangePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, renderStaticInput, ...props }: import('../DateTime/DateRangePicker/DateRangePicker').ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
24
24
|
readonly textEditor: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../../../text-editor.js').ControlledTextEditorProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
25
25
|
readonly unknown: null;
|
|
26
26
|
};
|
|
@@ -15,6 +15,18 @@ var RadioGroupBase = (props) => {
|
|
|
15
15
|
const radioTypographyMap = UIStyle.useMapper("radio.typography", radioTypography);
|
|
16
16
|
const radioContentClassNameMap = UIStyle.useMapper("radio.contentClassName", radioContentClassName);
|
|
17
17
|
const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isDisabled, headerClassName, errorClassName, labelClassName, inputClassName, isHeaderHidden, error, className, options, variant = ui.radioGroup.variant, hideLabel = ui.radioGroup.hideLabel, ...rest } = props;
|
|
18
|
+
const radioClassName = radioCva({
|
|
19
|
+
variant,
|
|
20
|
+
...rest
|
|
21
|
+
});
|
|
22
|
+
const radioTypographyProps = radioTypographyMap({
|
|
23
|
+
variant,
|
|
24
|
+
...rest
|
|
25
|
+
});
|
|
26
|
+
const radioContentClassNameValue = radioContentClassNameMap({
|
|
27
|
+
variant,
|
|
28
|
+
...rest
|
|
29
|
+
});
|
|
18
30
|
const formFieldProps = {
|
|
19
31
|
className,
|
|
20
32
|
error,
|
|
@@ -42,18 +54,9 @@ var RadioGroupBase = (props) => {
|
|
|
42
54
|
children: options.map((option) => /* @__PURE__ */ jsxs(Radio, {
|
|
43
55
|
value: option.value,
|
|
44
56
|
className: clsx("relative", radioIndicatorClass),
|
|
45
|
-
children: [/* @__PURE__ */ jsx("div", { className:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}) }), /* @__PURE__ */ jsx(CheckContent, {
|
|
49
|
-
typography: radioTypographyMap({
|
|
50
|
-
variant,
|
|
51
|
-
...rest
|
|
52
|
-
}),
|
|
53
|
-
contentClassName: radioContentClassNameMap({
|
|
54
|
-
variant,
|
|
55
|
-
...rest
|
|
56
|
-
}),
|
|
57
|
+
children: [/* @__PURE__ */ jsx("div", { className: radioClassName }), /* @__PURE__ */ jsx(CheckContent, {
|
|
58
|
+
typography: radioTypographyProps,
|
|
59
|
+
contentClassName: radioContentClassNameValue,
|
|
57
60
|
className: labelClassName,
|
|
58
61
|
children: option.label
|
|
59
62
|
})]
|
|
@@ -4,7 +4,9 @@ import { FieldValues } from 'react-hook-form';
|
|
|
4
4
|
import { SelectBaseProps } from '../shared/SelectBase';
|
|
5
5
|
import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps } from '../shared/select.types';
|
|
6
6
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
7
|
-
export type AutocompleteProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>, "isSearchable"
|
|
7
|
+
export type AutocompleteProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>, "isSearchable"> & {
|
|
8
|
+
renderStaticInput?: boolean;
|
|
9
|
+
};
|
|
8
10
|
export type ControlledAutocompleteProps<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = Omit<AutocompleteProps<TKey, TInitialSelectItem>, keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey, TInitialSelectItem>;
|
|
9
11
|
export declare function Autocomplete<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: AutocompleteProps<TKey, TInitialSelectItem>): ReactElement;
|
|
10
12
|
export declare function Autocomplete<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: ControlledAutocompleteProps<TFieldValues, TKey, TInitialSelectItem>): ReactElement;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
|
|
2
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
1
4
|
import { SelectBase } from "../shared/SelectBase.js";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
import { isValidElement, useEffect, useRef, useState } from "react";
|
|
3
8
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
|
-
import { Controller } from "react-hook-form";
|
|
9
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
5
10
|
//#region src/components/inputs/Selection/Autocomplete/Autocomplete.tsx
|
|
6
|
-
function
|
|
11
|
+
function _Autocomplete(props) {
|
|
7
12
|
if ("formControl" in props && props.formControl) {
|
|
8
13
|
const { ignoreInputValueFiltering = true, formControl, ref, ...innerProps } = props;
|
|
9
14
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -28,5 +33,66 @@ function Autocomplete(props) {
|
|
|
28
33
|
isSearchable: true
|
|
29
34
|
});
|
|
30
35
|
}
|
|
36
|
+
function Autocomplete({ renderStaticInput, ...props }) {
|
|
37
|
+
const ui = UIConfig.useConfig();
|
|
38
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
39
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
40
|
+
const rootRef = useRef(null);
|
|
41
|
+
const currentValue = ("formControl" in props && props.formControl ? useWatch({
|
|
42
|
+
control: props.formControl.control,
|
|
43
|
+
name: props.formControl.name
|
|
44
|
+
}) : props.value) ?? props.value;
|
|
45
|
+
let isFormControlDisabled = false;
|
|
46
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
47
|
+
if (!renderInput && !!props.customTrigger) setRenderInput(true);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!renderInput || !shouldFocus) return;
|
|
50
|
+
requestAnimationFrame(() => {
|
|
51
|
+
(rootRef.current?.querySelector("input, [data-type='select-trigger'], button, [tabindex]"))?.focus();
|
|
52
|
+
});
|
|
53
|
+
setShouldFocus(false);
|
|
54
|
+
}, [renderInput, shouldFocus]);
|
|
55
|
+
if (!renderInput) {
|
|
56
|
+
const getItemLabel = (id) => {
|
|
57
|
+
const item = props.items.find((innerItem) => innerItem.id === id);
|
|
58
|
+
if (!item) return "";
|
|
59
|
+
if (props.showSelectionContent && item.content) return isValidElement(item.content) ? item.label : item.content;
|
|
60
|
+
return item.label;
|
|
61
|
+
};
|
|
62
|
+
const mode = props.selectionMode ?? ui.select.selectionMode;
|
|
63
|
+
let displayValue = "";
|
|
64
|
+
if (mode === "multiple") {
|
|
65
|
+
if (Array.isArray(currentValue) && currentValue.length > 0) displayValue = /* @__PURE__ */ jsx(Fragment, { children: currentValue.map((id) => getItemLabel(id)).filter(Boolean).map((item, index) => /* @__PURE__ */ jsxs("span", { children: [item, index < currentValue.length - 1 && ","] }, `${index}`)) });
|
|
66
|
+
} else if (currentValue != null) displayValue = getItemLabel(currentValue);
|
|
67
|
+
const as = props.as ?? ui.input.as;
|
|
68
|
+
let isDisabled = !!props.isDisabled;
|
|
69
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
70
|
+
const trailingContent = props.trailingContent || !props.hideDropdownIcon ? /* @__PURE__ */ jsxs(Fragment, { children: [props.trailingContent, !props.hideDropdownIcon ? /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: "size-6 shrink-0 text-interactive-text-secondary-idle" }) : void 0] }) : void 0;
|
|
71
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
72
|
+
...props,
|
|
73
|
+
onInteract: (focus) => {
|
|
74
|
+
setShouldFocus(focus);
|
|
75
|
+
setRenderInput(true);
|
|
76
|
+
},
|
|
77
|
+
as,
|
|
78
|
+
size: props.size ?? ui.input.size,
|
|
79
|
+
variant: props.variant ?? ui.input.variant,
|
|
80
|
+
isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
|
|
81
|
+
hideLabel: props.hideLabel ?? ui.input.hideLabel,
|
|
82
|
+
isDisabled,
|
|
83
|
+
className: clsx("w-full", props.containerClassName),
|
|
84
|
+
inputClassName: clsx(props.className, props.inputClassName),
|
|
85
|
+
placeholder: as === "floating" ? "" : props.placeholder,
|
|
86
|
+
displayValue,
|
|
87
|
+
isEmpty: !displayValue,
|
|
88
|
+
leadingContent: props.leadingContent,
|
|
89
|
+
trailingContent
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return /* @__PURE__ */ jsx(_Autocomplete, {
|
|
93
|
+
...props,
|
|
94
|
+
ref: mergeRefs(props.ref, rootRef)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
31
97
|
//#endregion
|
|
32
98
|
export { Autocomplete };
|
|
@@ -15,16 +15,8 @@ export type ExtractQueryOptions<TQueryFn> = TQueryFn extends (params: any, optio
|
|
|
15
15
|
export type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
|
|
16
16
|
export type ExtractPageType<T> = T extends InfiniteData<infer TPage> ? TPage : T;
|
|
17
17
|
export type ExtractedDataType<TQueryFn extends QueryFn> = ExtractPageType<QueryDataType<TQueryFn>> | ExtractPageType<QueryDataType<TQueryFn>>[];
|
|
18
|
-
type QueryAutocompleteFilter = {
|
|
19
|
-
search?: string;
|
|
20
|
-
};
|
|
21
|
-
type QueryAutocompleteSearchParams = {
|
|
22
|
-
search?: string;
|
|
23
|
-
} | {
|
|
24
|
-
filter?: QueryAutocompleteFilter;
|
|
25
|
-
};
|
|
26
18
|
export type QueryAutocompleteProps<TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn> = OmitDiscriminatedUnion<AutocompleteProps<TSelectItem["id"]>, "items" | "onSearchChange" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TSelectItem["id"]> & {
|
|
27
|
-
query:
|
|
19
|
+
query: TQueryFn;
|
|
28
20
|
queryParams?: Omit<ExtractQueryParams<TQueryFn>, "search" | "limit"> & {
|
|
29
21
|
limit?: number;
|
|
30
22
|
};
|
|
@@ -42,4 +34,3 @@ export interface UseQueryAutocompleteOptions<TQueryFn extends QueryFn, TKey exte
|
|
|
42
34
|
initialQueryState?: boolean;
|
|
43
35
|
search?: string;
|
|
44
36
|
}
|
|
45
|
-
export {};
|
|
@@ -4,7 +4,9 @@ import { FieldValues } from 'react-hook-form';
|
|
|
4
4
|
import { SelectBaseProps } from '../shared/SelectBase';
|
|
5
5
|
import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps, SelectAsyncProps } from '../shared/select.types';
|
|
6
6
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
7
|
-
export type SelectProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>, "initialSelection" | "mapInitialToSelectItem" | keyof SelectAsyncProps
|
|
7
|
+
export type SelectProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectBaseProps<TKey, TInitialSelectItem>, "initialSelection" | "mapInitialToSelectItem" | keyof SelectAsyncProps> & {
|
|
8
|
+
renderStaticInput?: boolean;
|
|
9
|
+
};
|
|
8
10
|
export type ControlledSelectProps<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = Omit<SelectProps<TKey, TInitialSelectItem>, keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey, TInitialSelectItem>;
|
|
9
11
|
export declare function Select<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: SelectProps<TKey, TInitialSelectItem>): ReactElement;
|
|
10
12
|
export declare function Select<TFieldValues extends FieldValues, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(props: ControlledSelectProps<TFieldValues, TKey, TInitialSelectItem>): ReactElement;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
|
|
2
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
1
4
|
import { SelectBase } from "../shared/SelectBase.js";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
import { isValidElement, useEffect, useRef, useState } from "react";
|
|
3
8
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
|
-
import { Controller } from "react-hook-form";
|
|
9
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
5
10
|
//#region src/components/inputs/Selection/Select/Select.tsx
|
|
6
|
-
function
|
|
11
|
+
function _Select(props) {
|
|
7
12
|
if ("formControl" in props && props.formControl) {
|
|
8
13
|
const { formControl, ref, ...innerProps } = props;
|
|
9
14
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -23,5 +28,66 @@ function Select(props) {
|
|
|
23
28
|
}
|
|
24
29
|
return /* @__PURE__ */ jsx(SelectBase, { ...props });
|
|
25
30
|
}
|
|
31
|
+
function Select({ renderStaticInput, ...props }) {
|
|
32
|
+
const ui = UIConfig.useConfig();
|
|
33
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
34
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
35
|
+
const rootRef = useRef(null);
|
|
36
|
+
const currentValue = ("formControl" in props && props.formControl ? useWatch({
|
|
37
|
+
control: props.formControl.control,
|
|
38
|
+
name: props.formControl.name
|
|
39
|
+
}) : props.value) ?? props.value;
|
|
40
|
+
let isFormControlDisabled = false;
|
|
41
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
42
|
+
if (!renderInput && props.selectionMode !== "multiple" && !!props.showSelectionContent && currentValue != null) setRenderInput(true);
|
|
43
|
+
if (!renderInput && !!props.customTrigger) setRenderInput(true);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!renderInput || !shouldFocus) return;
|
|
46
|
+
requestAnimationFrame(() => {
|
|
47
|
+
(rootRef.current?.querySelector("[data-type='select-trigger'], input, button, [tabindex]"))?.focus();
|
|
48
|
+
});
|
|
49
|
+
setShouldFocus(false);
|
|
50
|
+
}, [renderInput, shouldFocus]);
|
|
51
|
+
if (!renderInput) {
|
|
52
|
+
const getItemLabel = (id) => {
|
|
53
|
+
const item = props.items.find((innerItem) => innerItem.id === id);
|
|
54
|
+
if (!item) return "";
|
|
55
|
+
if (props.showSelectionContent && item.content) return isValidElement(item.content) ? item.label : item.content;
|
|
56
|
+
return item.label;
|
|
57
|
+
};
|
|
58
|
+
const mode = props.selectionMode ?? ui.select.selectionMode;
|
|
59
|
+
let displayValue = "";
|
|
60
|
+
if (mode === "multiple") {
|
|
61
|
+
if (Array.isArray(currentValue) && currentValue.length > 0) displayValue = /* @__PURE__ */ jsx(Fragment, { children: currentValue.map((id) => getItemLabel(id)).filter(Boolean).map((item, index) => /* @__PURE__ */ jsxs("span", { children: [item, index < currentValue.length - 1 && ","] }, `${index}`)) });
|
|
62
|
+
} else if (currentValue != null) displayValue = getItemLabel(currentValue);
|
|
63
|
+
const as = props.as ?? ui.input.as;
|
|
64
|
+
let isDisabled = !!props.isDisabled;
|
|
65
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
66
|
+
const trailingContent = props.trailingContent || !props.hideDropdownIcon ? /* @__PURE__ */ jsxs(Fragment, { children: [props.trailingContent, !props.hideDropdownIcon ? /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: `size-6 shrink-0 ${isDisabled ? "text-interactive-text-secondary-disabled" : "text-interactive-text-secondary-idle"}` }) : void 0] }) : void 0;
|
|
67
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
68
|
+
...props,
|
|
69
|
+
onInteract: (focus) => {
|
|
70
|
+
setShouldFocus(focus);
|
|
71
|
+
setRenderInput(true);
|
|
72
|
+
},
|
|
73
|
+
as,
|
|
74
|
+
size: props.size ?? ui.input.size,
|
|
75
|
+
variant: props.variant ?? ui.input.variant,
|
|
76
|
+
hideLabel: props.hideLabel ?? ui.input.hideLabel,
|
|
77
|
+
isDisabled,
|
|
78
|
+
className: clsx("w-full", props.containerClassName),
|
|
79
|
+
inputClassName: clsx(props.className, props.inputClassName),
|
|
80
|
+
placeholder: as === "floating" ? "" : props.placeholder,
|
|
81
|
+
displayValue,
|
|
82
|
+
isEmpty: !displayValue,
|
|
83
|
+
leadingContent: props.leadingContent,
|
|
84
|
+
trailingContent
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return /* @__PURE__ */ jsx(_Select, {
|
|
88
|
+
...props,
|
|
89
|
+
ref: mergeRefs(props.ref, rootRef)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
26
92
|
//#endregion
|
|
27
93
|
export { Select };
|
|
@@ -4,7 +4,7 @@ import { Typography } from "../../../text/Typography/Typography.js";
|
|
|
4
4
|
import "../../../../config/i18n.js";
|
|
5
5
|
import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
|
|
6
6
|
import { InputClear } from "../../shared/InputClear.js";
|
|
7
|
-
import { inputBase, inputSize } from "../../shared/input.cva.js";
|
|
7
|
+
import { inputBase, inputClearClass, inputSize } from "../../shared/input.cva.js";
|
|
8
8
|
import { SelectInputTags } from "./SelectInputTags.js";
|
|
9
9
|
import { SelectContext } from "./select.context.js";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -17,6 +17,7 @@ import { useTranslation } from "react-i18next";
|
|
|
17
17
|
var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, leadingContent, trailingContent, onMouseEnter, onFocusCapture, ...props }) => {
|
|
18
18
|
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
19
19
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
20
|
+
const inputClearClassCva = UIStyle.useCva("input.clearClassCva", inputClearClass);
|
|
20
21
|
const { t } = useTranslation("ui");
|
|
21
22
|
const state = use(ComboBoxStateContext);
|
|
22
23
|
const { hoverProps, isHovered } = useHover({ isDisabled });
|
|
@@ -142,6 +143,7 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
142
143
|
onClear();
|
|
143
144
|
if (fireBlurOnChange) onBlur?.({});
|
|
144
145
|
},
|
|
146
|
+
className: inputClearClassCva({ as }),
|
|
145
147
|
show: showClearButton
|
|
146
148
|
}),
|
|
147
149
|
trailingContent && /* @__PURE__ */ jsx("div", {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { FormFieldProps } from '../FormField/FormField';
|
|
3
|
+
import { TextInputProps } from '../Input/TextInput/TextInput';
|
|
4
|
+
import { InputSizeProps, InputVariantProps } from './input.cva';
|
|
5
|
+
interface StaticInputProps extends FormFieldProps {
|
|
6
|
+
onInteract: (shouldFocus: boolean) => void;
|
|
7
|
+
as?: TextInputProps["as"];
|
|
8
|
+
size?: InputSizeProps["size"];
|
|
9
|
+
variant?: InputVariantProps["variant"];
|
|
10
|
+
applyMinInputWidth?: boolean;
|
|
11
|
+
placeholder?: ReactNode;
|
|
12
|
+
displayValue?: ReactNode;
|
|
13
|
+
isEmpty?: boolean;
|
|
14
|
+
leadingVisual?: ReactNode;
|
|
15
|
+
leadingContent?: ReactNode;
|
|
16
|
+
trailingContent?: ReactNode;
|
|
17
|
+
contentRowClassName?: string;
|
|
18
|
+
inputClassName?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const StaticInput: ({ onInteract, as, size, variant, applyMinInputWidth, placeholder, displayValue, isEmpty, leadingVisual, leadingContent, trailingContent, contentRowClassName, inputClassName, className, ...formFieldProps }: StaticInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|