@povio/ui 2.2.8-rc → 2.2.8

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.
Files changed (35) hide show
  1. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +2 -1
  2. package/dist/components/Breadcrumbs/Breadcrumbs.js +2 -2
  3. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +3 -60
  4. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +3 -89
  5. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +3 -60
  6. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +2 -56
  7. package/dist/components/inputs/File/InputUpload.js +5 -3
  8. package/dist/components/inputs/File/inputUpload.types.d.ts +4 -1
  9. package/dist/components/inputs/File/inputUpload.types.js +9 -0
  10. package/dist/components/inputs/File/shared/FileUploadContentFilled.js +3 -1
  11. package/dist/components/inputs/File/shared/InputUploadContent.d.ts +2 -1
  12. package/dist/components/inputs/File/shared/InputUploadContent.js +4 -3
  13. package/dist/components/inputs/File/shared/InputUploadFilled.d.ts +3 -2
  14. package/dist/components/inputs/File/shared/InputUploadFilled.js +2 -2
  15. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +0 -1
  16. package/dist/components/inputs/Input/NumberInput/NumberInput.js +8 -80
  17. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +0 -1
  18. package/dist/components/inputs/Input/TextInput/TextInput.js +8 -83
  19. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +2 -62
  20. package/dist/components/inputs/Selection/Select/Select.js +2 -63
  21. package/dist/components/inputs/Selection/shared/SelectListBoxItem.d.ts +0 -1
  22. package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +8 -4
  23. package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +5 -3
  24. package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +4 -2
  25. package/dist/components/inputs/Selection/shared/SelectMobile.js +2 -1
  26. package/dist/components/inputs/Selection/shared/selectItem.cva.d.ts +6 -0
  27. package/dist/components/inputs/Selection/shared/selectItem.cva.js +21 -0
  28. package/dist/config/uiConfig.context.d.ts +0 -1
  29. package/dist/config/uiConfig.context.js +0 -1
  30. package/dist/config/uiStyle.context.d.ts +4 -0
  31. package/dist/utils/date-time.utils.d.ts +0 -10
  32. package/dist/utils/date-time.utils.js +1 -82
  33. package/package.json +1 -1
  34. package/dist/components/inputs/shared/StaticInput.d.ts +0 -18
  35. package/dist/components/inputs/shared/StaticInput.js +0 -69
@@ -1,25 +1,23 @@
1
1
  import { UIStyle } from "../../../../config/uiStyle.context.js";
2
- import { Loader } from "../../../status/Loader/Loader.js";
3
2
  import { UIConfig } from "../../../../config/uiConfig.context.js";
4
3
  import { inputBase } from "../../shared/input.cva.js";
5
4
  import { FormField } from "../../FormField/FormField.js";
6
- import { StaticInput } from "../../shared/StaticInput.js";
7
5
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
8
6
  import { InputContent } from "../shared/InputContent.js";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { jsx } from "react/jsx-runtime";
10
8
  import { clsx } from "clsx";
11
- import { isValidElement, useCallback, useEffect, useRef, useState } from "react";
9
+ import { useCallback, useRef } from "react";
12
10
  import { Input, useLocale } from "react-aria-components";
13
11
  import { useFocusVisible, useNumberField } from "react-aria";
14
12
  import { mergeRefs } from "@react-aria/utils";
15
- import { Controller, useWatch } from "react-hook-form";
13
+ import { Controller } from "react-hook-form";
16
14
  import { useNumberFieldState } from "react-stately";
17
15
  //#region src/components/inputs/Input/NumberInput/NumberInput.tsx
18
16
  var NumberInputBase = (props) => {
19
17
  const ui = UIConfig.useConfig();
20
18
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
21
19
  const inputRef = useRef(null);
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;
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;
23
21
  const numberFieldRef = useRef(null);
24
22
  const { isFocusVisible } = useFocusVisible();
25
23
  const { locale } = useLocale();
@@ -36,10 +34,6 @@ var NumberInputBase = (props) => {
36
34
  formatOptions
37
35
  };
38
36
  const { labelProps, inputProps } = useNumberField(numberProps, useNumberFieldState(numberProps), numberFieldRef);
39
- useEffect(() => {
40
- if (!autoFocusOnMount || isDisabled) return;
41
- requestAnimationFrame(() => inputRef.current?.focus());
42
- }, [autoFocusOnMount, isDisabled]);
43
37
  const formFieldProps = {
44
38
  error,
45
39
  label,
@@ -107,7 +101,7 @@ var NumberInputBase = (props) => {
107
101
  "data-is-dirty": isDirty || void 0,
108
102
  "data-is-required": isRequired || void 0,
109
103
  "data-is-empty": value === null || value === void 0 || void 0,
110
- placeholder: as === "floating" ? "" : inputProps.placeholder,
104
+ placeholder: as === "floating" ? "\xA0" : inputProps.placeholder,
111
105
  className: "w-full outline-none",
112
106
  onFocus: (e) => {
113
107
  inputProps.onFocus?.(e);
@@ -119,68 +113,7 @@ var NumberInputBase = (props) => {
119
113
  })
120
114
  });
121
115
  };
122
- var renderIconVisual = (icon) => {
123
- if (!icon) return null;
124
- if (isValidElement(icon)) return icon;
125
- return /* @__PURE__ */ jsx(icon, { className: "size-6 text-interactive-text-secondary-idle" });
126
- };
127
116
  var NumberInput = (props) => {
128
- const ui = UIConfig.useConfig();
129
- const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
130
- const [shouldFocus, setShouldFocus] = useState(false);
131
- const inputRef = useRef(null);
132
- const watchedValue = "formControl" in props && props.formControl ? useWatch({
133
- control: props.formControl.control,
134
- name: props.formControl.name
135
- }) : props.value;
136
- let isFormControlDisabled = false;
137
- if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
138
- useEffect(() => {
139
- if (!renderInput || !shouldFocus) return;
140
- requestAnimationFrame(() => inputRef.current?.focus());
141
- setShouldFocus(false);
142
- }, [renderInput, shouldFocus]);
143
- if (!renderInput) {
144
- const staticValue = watchedValue ?? props.value ?? props.defaultValue;
145
- const displayValue = staticValue == null ? "" : `${staticValue}`;
146
- const hasValue = displayValue !== "";
147
- const as = props.as ?? ui.input.as;
148
- const size = props.size ?? ui.input.size;
149
- const variant = props.variant ?? ui.input.variant;
150
- const hideLabel = props.hideLabel ?? ui.input.hideLabel;
151
- const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
152
- let isDisabled = !!props.isDisabled;
153
- if (isFormControlDisabled) isDisabled = true;
154
- const trailingVisual = !!props.unit || !!props.isLoading || !!props.action && !props.isLoading || !!props.trailingIcon && !props.isLoading && !props.action ? /* @__PURE__ */ jsxs(Fragment, { children: [
155
- props.unit && /* @__PURE__ */ jsx("span", {
156
- className: "text-label-2 text-text-default-3",
157
- children: props.unit
158
- }),
159
- props.isLoading && /* @__PURE__ */ jsx(Loader, {}),
160
- !props.isLoading && props.action && renderIconVisual(props.action.icon),
161
- !props.isLoading && !props.action && props.trailingIcon && renderIconVisual(props.trailingIcon)
162
- ] }) : void 0;
163
- return /* @__PURE__ */ jsx(StaticInput, {
164
- ...props,
165
- onInteract: (focus) => {
166
- setShouldFocus(focus);
167
- setRenderInput(true);
168
- },
169
- as,
170
- size,
171
- variant,
172
- hideLabel,
173
- isHeaderHidden,
174
- isDisabled,
175
- className: clsx("group w-full", as === "inline" && "h-full", props.className),
176
- inputClassName: props.inputClassName,
177
- placeholder: as === "floating" ? "" : props.placeholder,
178
- displayValue,
179
- isEmpty: !hasValue,
180
- leadingVisual: renderIconVisual(props.leadingIcon),
181
- trailingVisual
182
- });
183
- }
184
117
  if ("formControl" in props && props.formControl) {
185
118
  const { formControl, ref, ...innerProps } = props;
186
119
  return /* @__PURE__ */ jsx(Controller, {
@@ -188,22 +121,17 @@ var NumberInput = (props) => {
188
121
  name: formControl.name,
189
122
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(NumberInputBase, {
190
123
  ...innerProps,
191
- ref: mergeRefs(ref, field.ref, inputRef),
124
+ ref: mergeRefs(ref, field.ref),
192
125
  value: field.value,
193
126
  onChange: field.onChange,
194
127
  onBlur: field.onBlur,
195
128
  isDirty,
196
129
  isDisabled: field.disabled || props.isDisabled,
197
- error: props.error ?? error?.message,
198
- autoFocusOnMount: shouldFocus
130
+ error: props.error ?? error?.message
199
131
  }, field.value === null || field.value === void 0 ? "empty" : "filled")
200
132
  });
201
133
  }
202
- return /* @__PURE__ */ jsx(NumberInputBase, {
203
- ...props,
204
- ref: mergeRefs(props.ref, inputRef),
205
- autoFocusOnMount: shouldFocus
206
- }, props.value === null || props.value === void 0 ? "empty" : "filled");
134
+ return /* @__PURE__ */ jsx(NumberInputBase, { ...props }, props.value === null || props.value === void 0 ? "empty" : "filled");
207
135
  };
208
136
  //#endregion
209
137
  export { NumberInput };
@@ -13,7 +13,6 @@ interface TextInputBaseProps extends FormFieldProps, InputVariantProps, Omit<Inp
13
13
  type?: AllowedHTMLInputTypeAttribute;
14
14
  todayIcon?: boolean;
15
15
  isDirty?: boolean;
16
- autoFocusOnMount?: boolean;
17
16
  }
18
17
  export interface TextInputProps extends TextInputBaseProps {
19
18
  }
@@ -1,24 +1,22 @@
1
1
  import { UIStyle } from "../../../../config/uiStyle.context.js";
2
- import { Loader } from "../../../status/Loader/Loader.js";
3
2
  import { UIConfig } from "../../../../config/uiConfig.context.js";
4
3
  import { inputBase } from "../../shared/input.cva.js";
5
4
  import { FormField } from "../../FormField/FormField.js";
6
- import { StaticInput } from "../../shared/StaticInput.js";
7
5
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
8
6
  import { InputContent } from "../shared/InputContent.js";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { jsx } from "react/jsx-runtime";
10
8
  import { clsx } from "clsx";
11
- import { isValidElement, useEffect, useRef, useState } from "react";
9
+ import { useRef } from "react";
12
10
  import { Input } from "react-aria-components";
13
11
  import { useFocusVisible, useTextField } from "react-aria";
14
12
  import { mergeRefs } from "@react-aria/utils";
15
- import { Controller, useWatch } from "react-hook-form";
13
+ import { Controller } from "react-hook-form";
16
14
  //#region src/components/inputs/Input/TextInput/TextInput.tsx
17
15
  var TextInputBase = (props) => {
18
16
  const ui = UIConfig.useConfig();
19
17
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
20
18
  const inputRef = useRef(null);
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;
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;
22
20
  const textFieldRef = useRef(null);
23
21
  const { isFocusVisible } = useFocusVisible();
24
22
  const { labelProps, inputProps } = useTextField({
@@ -31,10 +29,6 @@ var TextInputBase = (props) => {
31
29
  onChange,
32
30
  onBlur
33
31
  }, textFieldRef);
34
- useEffect(() => {
35
- if (!autoFocusOnMount || isDisabled) return;
36
- requestAnimationFrame(() => inputRef.current?.focus());
37
- }, [autoFocusOnMount, isDisabled]);
38
32
  const formFieldProps = {
39
33
  error,
40
34
  label,
@@ -100,7 +94,7 @@ var TextInputBase = (props) => {
100
94
  "data-is-dirty": isDirty || void 0,
101
95
  "data-is-required": isRequired || void 0,
102
96
  "data-is-disabled": isDisabled || void 0,
103
- placeholder: as === "floating" ? "" : inputProps.placeholder,
97
+ placeholder: as === "floating" ? "\xA0" : inputProps.placeholder,
104
98
  className: "w-full outline-none",
105
99
  onFocus: (e) => {
106
100
  inputProps.onFocus?.(e);
@@ -112,71 +106,7 @@ var TextInputBase = (props) => {
112
106
  })
113
107
  });
114
108
  };
115
- var renderIconVisual = (icon) => {
116
- if (!icon) return null;
117
- if (isValidElement(icon)) return icon;
118
- return /* @__PURE__ */ jsx(icon, { className: "size-6 text-interactive-text-secondary-idle" });
119
- };
120
109
  var TextInput = (props) => {
121
- const ui = UIConfig.useConfig();
122
- const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
123
- const [shouldFocus, setShouldFocus] = useState(false);
124
- const inputRef = useRef(null);
125
- const watchedValue = "formControl" in props && props.formControl ? useWatch({
126
- control: props.formControl.control,
127
- name: props.formControl.name
128
- }) : props.value;
129
- let isFormControlDisabled = false;
130
- if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
131
- const staticValue = watchedValue ?? props.value ?? props.defaultValue ?? "";
132
- const inputType = props.type;
133
- if (!renderInput && inputType === "password" && `${staticValue}`.length > 0) setRenderInput(true);
134
- useEffect(() => {
135
- if (!renderInput || !shouldFocus) return;
136
- requestAnimationFrame(() => inputRef.current?.focus());
137
- setShouldFocus(false);
138
- }, [renderInput, shouldFocus]);
139
- if (!renderInput) {
140
- const as = props.as ?? ui.input.as;
141
- const size = props.size ?? ui.input.size;
142
- const variant = props.variant ?? ui.input.variant;
143
- const hideLabel = props.hideLabel ?? ui.input.hideLabel;
144
- const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
145
- let isDisabled = !!props.isDisabled;
146
- if (isFormControlDisabled) isDisabled = true;
147
- const maskedPasswordValue = inputType === "password" && `${staticValue}`.length > 0 ? "•".repeat(`${staticValue}`.length) : staticValue;
148
- const displayValue = maskedPasswordValue == null ? "" : `${maskedPasswordValue}`;
149
- const hasValue = displayValue !== "";
150
- const trailingVisual = !!props.unit || !!props.isLoading || !!props.action && !props.isLoading || !!props.trailingIcon && !props.isLoading && !props.action ? /* @__PURE__ */ jsxs(Fragment, { children: [
151
- props.unit && /* @__PURE__ */ jsx("span", {
152
- className: "text-label-2 text-text-default-3",
153
- children: props.unit
154
- }),
155
- props.isLoading && /* @__PURE__ */ jsx(Loader, {}),
156
- !props.isLoading && props.action && renderIconVisual(props.action.icon),
157
- !props.isLoading && !props.action && props.trailingIcon && renderIconVisual(props.trailingIcon)
158
- ] }) : void 0;
159
- return /* @__PURE__ */ jsx(StaticInput, {
160
- ...props,
161
- onInteract: (focus) => {
162
- setShouldFocus(focus);
163
- setRenderInput(true);
164
- },
165
- as,
166
- size,
167
- variant,
168
- hideLabel,
169
- isHeaderHidden,
170
- isDisabled,
171
- className: clsx("group w-full", as === "inline" && "h-full", props.className),
172
- inputClassName: props.inputClassName,
173
- placeholder: as === "floating" ? "" : props.placeholder,
174
- displayValue,
175
- isEmpty: !hasValue,
176
- leadingVisual: renderIconVisual(props.leadingIcon),
177
- trailingVisual
178
- });
179
- }
180
110
  if ("formControl" in props && props.formControl) {
181
111
  const { formControl, ref, ...innerProps } = props;
182
112
  return /* @__PURE__ */ jsx(Controller, {
@@ -184,22 +114,17 @@ var TextInput = (props) => {
184
114
  name: formControl.name,
185
115
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(TextInputBase, {
186
116
  ...innerProps,
187
- ref: mergeRefs(ref, field.ref, inputRef),
117
+ ref: mergeRefs(ref, field.ref),
188
118
  value: field.value,
189
119
  onChange: field.onChange,
190
120
  onBlur: field.onBlur,
191
121
  isDirty,
192
122
  isDisabled: field.disabled || props.isDisabled,
193
- error: props.error ?? error?.message,
194
- autoFocusOnMount: shouldFocus
123
+ error: props.error ?? error?.message
195
124
  })
196
125
  });
197
126
  }
198
- return /* @__PURE__ */ jsx(TextInputBase, {
199
- ...props,
200
- ref: mergeRefs(props.ref, inputRef),
201
- autoFocusOnMount: shouldFocus
202
- });
127
+ return /* @__PURE__ */ jsx(TextInputBase, { ...props });
203
128
  };
204
129
  //#endregion
205
130
  export { TextInput };
@@ -1,13 +1,9 @@
1
- import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
2
- import { UIConfig } from "../../../../config/uiConfig.context.js";
3
- import { StaticInput } from "../../shared/StaticInput.js";
4
1
  import { SelectBase } from "../shared/SelectBase.js";
5
2
  import { jsx } from "react/jsx-runtime";
6
- import { isValidElement, useEffect, useRef, useState } from "react";
7
3
  import { mergeRefs } from "@react-aria/utils";
8
- import { Controller, useWatch } from "react-hook-form";
4
+ import { Controller } from "react-hook-form";
9
5
  //#region src/components/inputs/Selection/Autocomplete/Autocomplete.tsx
10
- var _Autocomplete = (props) => {
6
+ var Autocomplete = (props) => {
11
7
  if ("formControl" in props && props.formControl) {
12
8
  const { formControl, ref, ...innerProps } = props;
13
9
  return /* @__PURE__ */ jsx(Controller, {
@@ -30,61 +26,5 @@ var _Autocomplete = (props) => {
30
26
  isSearchable: true
31
27
  });
32
28
  };
33
- var Autocomplete = (props) => {
34
- const ui = UIConfig.useConfig();
35
- const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
36
- const [shouldFocus, setShouldFocus] = useState(false);
37
- const rootRef = useRef(null);
38
- const currentValue = ("formControl" in props && props.formControl ? useWatch({
39
- control: props.formControl.control,
40
- name: props.formControl.name
41
- }) : props.value) ?? props.value;
42
- let isFormControlDisabled = false;
43
- if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
44
- useEffect(() => {
45
- if (!renderInput || !shouldFocus) return;
46
- requestAnimationFrame(() => {
47
- (rootRef.current?.querySelector("input, [data-type='select-trigger'], 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 = currentValue.map((id) => getItemLabel(id)).filter(Boolean).join(", ");
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
- return /* @__PURE__ */ jsx(StaticInput, {
67
- ...props,
68
- onInteract: (focus) => {
69
- setShouldFocus(focus);
70
- setRenderInput(true);
71
- },
72
- as,
73
- size: props.size ?? ui.input.size,
74
- variant: props.variant ?? ui.input.variant,
75
- isHeaderHidden: props.isHeaderHidden || as === "inline",
76
- hideLabel: props.hideLabel ?? ui.input.hideLabel,
77
- isDisabled,
78
- placeholder: as === "floating" ? "" : props.placeholder,
79
- displayValue,
80
- isEmpty: !displayValue,
81
- trailingVisual: /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: "size-6 shrink-0 text-interactive-text-secondary-idle" })
82
- });
83
- }
84
- return /* @__PURE__ */ jsx(_Autocomplete, {
85
- ...props,
86
- ref: mergeRefs(props.ref, rootRef)
87
- });
88
- };
89
29
  //#endregion
90
30
  export { Autocomplete };
@@ -1,13 +1,9 @@
1
- import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
2
- import { UIConfig } from "../../../../config/uiConfig.context.js";
3
- import { StaticInput } from "../../shared/StaticInput.js";
4
1
  import { SelectBase } from "../shared/SelectBase.js";
5
2
  import { jsx } from "react/jsx-runtime";
6
- import { isValidElement, useEffect, useRef, useState } from "react";
7
3
  import { mergeRefs } from "@react-aria/utils";
8
- import { Controller, useWatch } from "react-hook-form";
4
+ import { Controller } from "react-hook-form";
9
5
  //#region src/components/inputs/Selection/Select/Select.tsx
10
- var _Select = (props) => {
6
+ var Select = (props) => {
11
7
  if ("formControl" in props && props.formControl) {
12
8
  const { formControl, ref, ...innerProps } = props;
13
9
  return /* @__PURE__ */ jsx(Controller, {
@@ -26,62 +22,5 @@ var _Select = (props) => {
26
22
  }
27
23
  return /* @__PURE__ */ jsx(SelectBase, { ...props });
28
24
  };
29
- var Select = (props) => {
30
- const ui = UIConfig.useConfig();
31
- const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
32
- const [shouldFocus, setShouldFocus] = useState(false);
33
- const rootRef = useRef(null);
34
- const currentValue = ("formControl" in props && props.formControl ? useWatch({
35
- control: props.formControl.control,
36
- name: props.formControl.name
37
- }) : props.value) ?? props.value;
38
- let isFormControlDisabled = false;
39
- if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
40
- if (!renderInput && props.selectionMode !== "multiple" && !!props.showSelectionContent && currentValue != null) setRenderInput(true);
41
- useEffect(() => {
42
- if (!renderInput || !shouldFocus) return;
43
- requestAnimationFrame(() => {
44
- (rootRef.current?.querySelector("[data-type='select-trigger'], input, button, [tabindex]"))?.focus();
45
- });
46
- setShouldFocus(false);
47
- }, [renderInput, shouldFocus]);
48
- if (!renderInput) {
49
- const getItemLabel = (id) => {
50
- const item = props.items.find((innerItem) => innerItem.id === id);
51
- if (!item) return "";
52
- if (props.showSelectionContent && item.content) return isValidElement(item.content) ? item.label : item.content;
53
- return item.label;
54
- };
55
- const mode = props.selectionMode ?? ui.select.selectionMode;
56
- let displayValue = "";
57
- if (mode === "multiple") {
58
- if (Array.isArray(currentValue) && currentValue.length > 0) displayValue = currentValue.map((id) => getItemLabel(id)).filter(Boolean).join(", ");
59
- } else if (currentValue != null) displayValue = getItemLabel(currentValue);
60
- const as = props.as ?? ui.input.as;
61
- let isDisabled = !!props.isDisabled;
62
- if (isFormControlDisabled) isDisabled = true;
63
- return /* @__PURE__ */ jsx(StaticInput, {
64
- ...props,
65
- onInteract: (focus) => {
66
- setShouldFocus(focus);
67
- setRenderInput(true);
68
- },
69
- as,
70
- size: props.size ?? ui.input.size,
71
- variant: props.variant ?? ui.input.variant,
72
- isHeaderHidden: props.isHeaderHidden || as === "inline",
73
- hideLabel: props.hideLabel ?? ui.input.hideLabel,
74
- isDisabled,
75
- placeholder: as === "floating" ? "" : props.placeholder,
76
- displayValue,
77
- isEmpty: !displayValue,
78
- trailingVisual: /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: "size-6 shrink-0 text-interactive-text-secondary-idle" })
79
- });
80
- }
81
- return /* @__PURE__ */ jsx(_Select, {
82
- ...props,
83
- ref: mergeRefs(props.ref, rootRef)
84
- });
85
- };
86
25
  //#endregion
87
26
  export { Select };
@@ -4,5 +4,4 @@ interface SelectListBoxItemProps extends Pick<SelectBaseProps, "isSearchable" |
4
4
  isNewItem?: boolean;
5
5
  }
6
6
  export declare const SelectListBoxItem: ({ isSearchable, isNewItem, newItemRender, id, label, content, isDisabled, }: SelectListBoxItemProps) => import("react/jsx-runtime").JSX.Element;
7
- export declare const selectListBoxItemClass: string;
8
7
  export {};
@@ -1,13 +1,15 @@
1
+ import { UIStyle } from "../../../../config/uiStyle.context.js";
1
2
  import "../../../../config/i18n.js";
2
3
  import { CheckboxCheckmark } from "../../Checkbox/CheckboxCheckmark.js";
3
4
  import { SelectContext } from "./select.context.js";
5
+ import { selectListBoxItemCva } from "./selectItem.cva.js";
4
6
  import { jsx, jsxs } from "react/jsx-runtime";
5
- import { clsx } from "clsx";
6
7
  import { useMemo, useRef } from "react";
7
8
  import { ListBoxItem } from "react-aria-components";
8
9
  import { useTranslation } from "react-i18next";
9
10
  //#region src/components/inputs/Selection/shared/SelectListBoxItem.tsx
10
11
  var SelectListBoxItem = ({ isSearchable, isNewItem, newItemRender, id, label, content, isDisabled }) => {
12
+ const selectListItemCva = UIStyle.useCva("select.listBoxItemCva", selectListBoxItemCva);
11
13
  const ref = useRef(null);
12
14
  const { t } = useTranslation("ui");
13
15
  const { selectedIds, isMultiple } = SelectContext.useSelect();
@@ -26,7 +28,10 @@ var SelectListBoxItem = ({ isSearchable, isNewItem, newItemRender, id, label, co
26
28
  id,
27
29
  textValue: label,
28
30
  isDisabled,
29
- className: clsx(selectListBoxItemClass, !isMultiple && "selected:bg-interactive-contained-primary-idle selected:text-interactive-contained-primary-on-idle", isNewItem ? "text-interactive-text-primary-idle" : "text-interactive-text-secondary-idle"),
31
+ className: selectListItemCva({
32
+ isSingle: !isMultiple,
33
+ isNewItem
34
+ }),
30
35
  children: [
31
36
  isMultiple && !isSearchable && /* @__PURE__ */ jsx(CheckboxCheckmark, {
32
37
  variant: "default",
@@ -45,6 +50,5 @@ var SelectListBoxItem = ({ isSearchable, isNewItem, newItemRender, id, label, co
45
50
  ]
46
51
  });
47
52
  };
48
- var selectListBoxItemClass = clsx("group flex cursor-pointer items-center gap-2 px-list-side-item-left py-list-height-item", "border-b border-b-elevation-outline-default-1 outline-none", "font-labels-default text-interactive-text-secondary-idle text-label-2", "hover:text-interactive-text-secondary-hover", "focus-visible:bg-interactive-contained-primary-focus focus-visible:text-interactive-text-secondary-idle-inverted", "disabled:cursor-default disabled:text-interactive-text-secondary-disabled");
49
53
  //#endregion
50
- export { SelectListBoxItem, selectListBoxItemClass };
54
+ export { SelectListBoxItem };
@@ -1,13 +1,15 @@
1
+ import { UIStyle } from "../../../../config/uiStyle.context.js";
1
2
  import "../../../../config/i18n.js";
2
3
  import { CheckboxCheckmark } from "../../Checkbox/CheckboxCheckmark.js";
3
4
  import { SelectContext } from "./select.context.js";
4
- import { selectListBoxItemClass } from "./SelectListBoxItem.js";
5
+ import { selectListBoxItemCva } from "./selectItem.cva.js";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
7
  import { useRef } from "react";
7
8
  import { ListBoxItem } from "react-aria-components";
8
9
  import { useTranslation } from "react-i18next";
9
10
  //#region src/components/inputs/Selection/shared/SelectListBoxItemSelectAll.tsx
10
11
  var SelectListBoxItemSelectAll = ({ id, label, isDisabled }) => {
12
+ const selectListItemCva = UIStyle.useCva("select.listBoxItemCva", selectListBoxItemCva);
11
13
  const ref = useRef(null);
12
14
  const { t } = useTranslation("ui");
13
15
  const { selectableListItems, selectedIds } = SelectContext.useSelect();
@@ -16,7 +18,7 @@ var SelectListBoxItemSelectAll = ({ id, label, isDisabled }) => {
16
18
  id,
17
19
  textValue: label || t(($) => $.ui.select.allOption),
18
20
  isDisabled,
19
- className: selectListBoxItemClass,
21
+ className: selectListItemCva({}),
20
22
  children: [/* @__PURE__ */ jsx("div", {
21
23
  className: "group",
22
24
  "data-rac": "",
@@ -24,7 +26,7 @@ var SelectListBoxItemSelectAll = ({ id, label, isDisabled }) => {
24
26
  "data-indeterminate": selectedIds.length > 0 && selectedIds.length < selectableListItems.length || void 0,
25
27
  children: /* @__PURE__ */ jsx(CheckboxCheckmark, {
26
28
  variant: "default",
27
- className: "group-focus-visible:!outline-none"
29
+ className: "group-focus-visible:outline-none!"
28
30
  })
29
31
  }), t(($) => $.ui.select.allOption)]
30
32
  });
@@ -1,7 +1,8 @@
1
+ import { UIStyle } from "../../../../config/uiStyle.context.js";
1
2
  import { Loader } from "../../../status/Loader/Loader.js";
2
3
  import "../../../../config/i18n.js";
3
4
  import { SelectContext } from "./select.context.js";
4
- import { selectListBoxItemClass } from "./SelectListBoxItem.js";
5
+ import { selectListBoxItemCva } from "./selectItem.cva.js";
5
6
  import { useIntersectionObserver } from "../../../../hooks/useIntersectionObserver.js";
6
7
  import { jsx } from "react/jsx-runtime";
7
8
  import { useCallback } from "react";
@@ -9,6 +10,7 @@ import { ListBoxItem } from "react-aria-components";
9
10
  import { useTranslation } from "react-i18next";
10
11
  //#region src/components/inputs/Selection/shared/SelectListBoxLoadingItem.tsx
11
12
  var SelectListBoxLoadingItem = ({ id, label, onLoadMore }) => {
13
+ const selectListItemCva = UIStyle.useCva("select.listBoxItemCva", selectListBoxItemCva);
12
14
  const { t } = useTranslation("ui");
13
15
  const { isDebouncing, isLoading, hasLoadMore } = SelectContext.useSelect();
14
16
  const { ref } = useIntersectionObserver({
@@ -26,7 +28,7 @@ var SelectListBoxLoadingItem = ({ id, label, onLoadMore }) => {
26
28
  id,
27
29
  textValue: label || t(($) => $.ui.loadingState.text),
28
30
  isDisabled: true,
29
- className: selectListBoxItemClass,
31
+ className: selectListItemCva({}),
30
32
  children: /* @__PURE__ */ jsx("div", {
31
33
  ref,
32
34
  className: "flex flex-1 justify-center text-interactive-text-primary-idle",
@@ -14,7 +14,7 @@ import { DialogTrigger } from "react-aria-components";
14
14
  import { useLabel } from "react-aria";
15
15
  //#region src/components/inputs/Selection/shared/SelectMobile.tsx
16
16
  var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }) => {
17
- const { label, tooltipText, helperText, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, hideSearchIcon, isSearchable, isClearable, as, collapseAfter, selectedTagsType } = props;
17
+ const { label, tooltipText, helperText, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, hideSearchIcon, isSearchable, isClearable, as, size, collapseAfter, selectedTagsType } = props;
18
18
  const formFieldProps = {
19
19
  error,
20
20
  label,
@@ -68,6 +68,7 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
68
68
  placeholder,
69
69
  variant,
70
70
  as,
71
+ size,
71
72
  isDisabled,
72
73
  isInvalid: !!error,
73
74
  className,
@@ -0,0 +1,6 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ export declare const selectListBoxItemCva: (props?: ({
3
+ isSingle?: boolean | null | undefined;
4
+ isNewItem?: boolean | null | undefined;
5
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
6
+ export type SelectListBoxItemCva = VariantProps<typeof selectListBoxItemCva>;
@@ -0,0 +1,21 @@
1
+ import { cva } from "class-variance-authority";
2
+ //#region src/components/inputs/Selection/shared/selectItem.cva.ts
3
+ var selectListBoxItemCva = cva([
4
+ "group flex cursor-pointer items-center gap-2 px-list-side-item-left py-list-height-item",
5
+ "border-b border-b-elevation-outline-default-1 outline-none",
6
+ "font-labels-default text-label-2",
7
+ "hover:text-interactive-text-secondary-hover",
8
+ "focus-visible:bg-interactive-contained-primary-focus focus-visible:text-interactive-text-secondary-idle-inverted",
9
+ "disabled:cursor-default disabled:text-interactive-text-secondary-disabled"
10
+ ], {
11
+ variants: {
12
+ isSingle: { true: "selected:bg-interactive-contained-primary-idle selected:text-interactive-contained-primary-on-idle" },
13
+ isNewItem: {
14
+ true: "text-interactive-text-primary-idle",
15
+ false: "text-interactive-text-secondary-idle"
16
+ }
17
+ },
18
+ defaultVariants: { isNewItem: false }
19
+ });
20
+ //#endregion
21
+ export { selectListBoxItemCva };
@@ -19,7 +19,6 @@ export declare namespace UIConfig {
19
19
  [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : Exclude<T[P], null | undefined>;
20
20
  };
21
21
  export interface Options {
22
- renderStaticInput: boolean;
23
22
  input: Pick<TextInputProps, "variant" | "isClearable" | "hideLabel" | "as" | "size">;
24
23
  button: Pick<ButtonProps, "variant" | "size">;
25
24
  numberInput: Pick<NumberInputProps, "formatOptions">;
@@ -6,7 +6,6 @@ import { createContext, use } from "react";
6
6
  var UIConfig;
7
7
  (function(_UIConfig) {
8
8
  const DEFAULT_CONFIG = {
9
- renderStaticInput: true,
10
9
  input: {
11
10
  variant: "outlined",
12
11
  as: "default",
@@ -24,6 +24,7 @@ import { LinkVariantProps } from '../components/text/Link/link.cva';
24
24
  import { TagVariantProps } from '../components/text/Tag/tag.cva';
25
25
  import { TypographyVariantProps } from '../components/text/Typography/typography.cva';
26
26
  import { CompoundMapper, ConfigSchema } from '../utils/compoundMapper';
27
+ import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
27
28
  export declare namespace UIStyle {
28
29
  export type Cva<T> = (props: (T & ClassProp) | ClassProp) => string;
29
30
  type OptionKey = {
@@ -147,6 +148,9 @@ export declare namespace UIStyle {
147
148
  errorLabelCva?: Cva<FormFieldErrorVariantProps>;
148
149
  helperLabelCva?: Cva<FormFieldHelperVariantProps>;
149
150
  };
151
+ select: {
152
+ listBoxItemCva?: Cva<SelectListBoxItemCva>;
153
+ };
150
154
  }
151
155
  interface ProviderProps {
152
156
  config?: Partial<Options>;