@povio/ui 2.2.9-rc.2 → 2.2.9-rc.21

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 (95) hide show
  1. package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -1
  2. package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
  3. package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
  4. package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
  5. package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
  6. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +9 -4
  7. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +97 -9
  8. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +9 -4
  9. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +116 -7
  10. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +10 -4
  11. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +92 -7
  12. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +5 -3
  13. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +80 -6
  14. package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
  15. package/dist/components/inputs/DateTime/shared/Calendar.js +23 -6
  16. package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
  17. package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
  18. package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
  19. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +5 -2
  20. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +21 -12
  21. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +7 -3
  22. package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +3 -0
  23. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
  24. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
  25. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
  26. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +20 -0
  27. package/dist/components/inputs/FormField/FormField.d.ts +3 -3
  28. package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
  29. package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
  30. package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
  31. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
  32. package/dist/components/inputs/Input/NumberInput/NumberInput.js +92 -8
  33. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +38 -0
  34. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +318 -0
  35. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
  36. package/dist/components/inputs/Input/TextInput/TextInput.js +95 -8
  37. package/dist/components/inputs/Inputs/InputItem.d.ts +15 -18
  38. package/dist/components/inputs/Inputs/InputItem.js +2 -0
  39. package/dist/components/inputs/RadioGroup/RadioGroup.js +17 -9
  40. package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
  41. package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
  42. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
  43. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +87 -6
  44. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  45. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +15 -10
  46. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
  47. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -2
  48. package/dist/components/inputs/Selection/Select/QuerySelect.js +5 -3
  49. package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
  50. package/dist/components/inputs/Selection/Select/Select.js +86 -4
  51. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
  52. package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
  53. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  54. package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
  55. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  56. package/dist/components/inputs/Selection/shared/SelectInput.js +12 -2
  57. package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
  58. package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
  59. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  60. package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
  61. package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
  62. package/dist/components/inputs/Selection/shared/select.context.js +22 -4
  63. package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
  64. package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
  65. package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
  66. package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
  67. package/dist/components/inputs/Selection/shared/staticSelect.utils.js +35 -0
  68. package/dist/components/inputs/Toggle/Toggle.js +6 -1
  69. package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
  70. package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
  71. package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
  72. package/dist/components/inputs/shared/CheckContent.js +3 -4
  73. package/dist/components/inputs/shared/StaticInput.d.ts +37 -0
  74. package/dist/components/inputs/shared/StaticInput.js +91 -0
  75. package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
  76. package/dist/components/inputs/shared/input.cva.d.ts +5 -0
  77. package/dist/components/inputs/shared/input.cva.js +10 -1
  78. package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
  79. package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
  80. package/dist/config/uiConfig.context.d.ts +8 -2
  81. package/dist/config/uiConfig.context.js +11 -1
  82. package/dist/config/uiStyle.context.d.ts +19 -3
  83. package/dist/helpers/dynamicInputs.d.ts +5 -5
  84. package/dist/helpers/dynamicInputs.js +3 -0
  85. package/dist/hooks/useIntersectionObserver.d.ts +1 -1
  86. package/dist/hooks/useIntersectionObserver.js +29 -10
  87. package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
  88. package/dist/hooks/useQueryAutocomplete.js +13 -3
  89. package/dist/index.d.ts +7 -0
  90. package/dist/index.js +4 -2
  91. package/dist/utils/date-time.utils.d.ts +23 -9
  92. package/dist/utils/date-time.utils.js +97 -1
  93. package/dist/utils/query.utils.d.ts +4 -0
  94. package/dist/utils/query.utils.js +8 -0
  95. package/package.json +1 -1
@@ -1,9 +1,15 @@
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 { getStaticSelectValue } from "../shared/staticSelect.utils.js";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { clsx } from "clsx";
8
+ import { useEffect, useRef, useState } from "react";
3
9
  import { mergeRefs } from "@react-aria/utils";
4
- import { Controller } from "react-hook-form";
10
+ import { Controller, useWatch } from "react-hook-form";
5
11
  //#region src/components/inputs/Selection/Select/Select.tsx
6
- var Select = (props) => {
12
+ function _Select(props) {
7
13
  if ("formControl" in props && props.formControl) {
8
14
  const { formControl, ref, ...innerProps } = props;
9
15
  return /* @__PURE__ */ jsx(Controller, {
@@ -22,6 +28,82 @@ var Select = (props) => {
22
28
  });
23
29
  }
24
30
  return /* @__PURE__ */ jsx(SelectBase, { ...props });
25
- };
31
+ }
32
+ function Select({ renderStaticInput, ...props }) {
33
+ const ui = UIConfig.useConfig();
34
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
35
+ const [shouldFocus, setShouldFocus] = useState(false);
36
+ const rootRef = useRef(null);
37
+ const currentValue = ("formControl" in props && props.formControl ? useWatch({
38
+ control: props.formControl.control,
39
+ name: props.formControl.name
40
+ }) : props.value) ?? props.value;
41
+ let isFormControlDisabled = false;
42
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
43
+ if (!renderInput && props.selectionMode !== "multiple" && !!props.showSelectionContent && currentValue != null) setRenderInput(true);
44
+ if (!renderInput && !!props.customTrigger) setRenderInput(true);
45
+ useEffect(() => {
46
+ if (!renderInput || !shouldFocus) return;
47
+ requestAnimationFrame(() => {
48
+ (rootRef.current?.querySelector("[data-type='select-trigger'], input, button, [tabindex]"))?.focus();
49
+ });
50
+ setShouldFocus(false);
51
+ }, [renderInput, shouldFocus]);
52
+ if (!renderInput) {
53
+ const as = props.as ?? ui.input.as;
54
+ let isDisabled = !!props.isDisabled;
55
+ if (isFormControlDisabled) isDisabled = true;
56
+ const mode = props.selectionMode ?? ui.select.selectionMode;
57
+ const { displayValue, isEmpty } = getStaticSelectValue({
58
+ items: props.items,
59
+ value: currentValue,
60
+ selectionMode: mode,
61
+ initialSelection: props.initialSelection,
62
+ mapInitialToSelectItem: props.mapInitialToSelectItem,
63
+ showSelectionContent: props.showSelectionContent,
64
+ isDisabled,
65
+ collapseAfter: props.collapseAfter ?? ui.select.collapseAfter,
66
+ selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
67
+ });
68
+ 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;
69
+ return /* @__PURE__ */ jsx(StaticInput, {
70
+ ...props,
71
+ onInteract: (focus) => {
72
+ setShouldFocus(focus);
73
+ setRenderInput(true);
74
+ },
75
+ as,
76
+ typographySize: "label-1",
77
+ size: props.size ?? ui.input.size,
78
+ variant: props.variant ?? ui.input.variant,
79
+ isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
80
+ hideLabel: props.hideLabel ?? ui.input.hideLabel,
81
+ isDisabled,
82
+ className: clsx("w-full", props.containerClassName),
83
+ inputClassName: clsx(props.className, props.inputClassName),
84
+ placeholder: props.placeholder,
85
+ showPlacholderIfFilled: mode !== "single",
86
+ displayValue,
87
+ isEmpty,
88
+ dataAttributes: {
89
+ dataIsEmpty: isEmpty,
90
+ dataIsFilled: !isEmpty,
91
+ dataIsDirty: props.isDirty,
92
+ dataIsRequired: props.isRequired,
93
+ dataIsDisabled: isDisabled,
94
+ dataDisabled: isDisabled,
95
+ dataInvalid: !!props.error,
96
+ dataHasSelection: !isEmpty,
97
+ dataHasSearch: false
98
+ },
99
+ leadingContent: props.leadingContent,
100
+ trailingContent
101
+ });
102
+ }
103
+ return /* @__PURE__ */ jsx(_Select, {
104
+ ...props,
105
+ ref: mergeRefs(props.ref, rootRef)
106
+ });
107
+ }
26
108
  //#endregion
27
109
  export { Select };
@@ -1,4 +1,4 @@
1
- import { FocusEventHandler, MouseEventHandler, ReactElement, Ref } from 'react';
1
+ import { FocusEventHandler, MouseEventHandler, ReactElement, ReactNode, Ref } from 'react';
2
2
  import { AriaButtonProps } from 'react-aria';
3
3
  import { Key } from 'react-aria-components';
4
4
  import { FormFieldProps } from '../../FormField/FormField';
@@ -14,10 +14,13 @@ export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = Default
14
14
  isSearchable?: boolean;
15
15
  isClearable?: boolean;
16
16
  isClientSearchDisabled?: boolean;
17
+ ignoreInputValueFiltering?: boolean;
17
18
  ignoreTriggerWidth?: boolean;
18
19
  items: SelectItem<TKey>[];
19
20
  inputClassName?: string;
20
21
  containerClassName?: string;
22
+ leadingContent?: ReactNode;
23
+ trailingContent?: ReactNode;
21
24
  customTrigger?: ReactElement;
22
25
  selectedTagsType?: "tags" | "list";
23
26
  collapseAfter?: number;
@@ -17,10 +17,11 @@ var SelectBase = (dProps) => {
17
17
  isClearable: dProps.isClearable ?? ui.input.isClearable,
18
18
  isSearchable: dProps.isSearchable ?? ui.select.isSearchable,
19
19
  selectedTagsType: dProps.selectedTagsType ?? ui.select.selectedTagsType,
20
- ignoreTriggerWidth: dProps.virtualizerOptions || dProps.items.length > 100 ? false : dProps.ignoreTriggerWidth ?? false,
20
+ ignoreTriggerWidth: dProps.virtualizerOptions || (dProps.totalItems ?? 0) > 100 || dProps.hasLoadMore ? false : dProps.ignoreTriggerWidth ?? false,
21
21
  collapseAfter: dProps.collapseAfter ?? ui.select.collapseAfter,
22
22
  hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon,
23
- fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange
23
+ fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange,
24
+ isClientSearchDisabled: dProps.ignoreInputValueFiltering ?? dProps.isClientSearchDisabled
24
25
  };
25
26
  const isDesktop = useBreakpoint("md");
26
27
  return /* @__PURE__ */ jsx(SelectContext.Provider, {
@@ -1,5 +1,5 @@
1
1
  import { Key } from 'react-aria-components';
2
2
  import { SelectBaseProps } from './SelectBase';
3
3
  type SelectDesktopProps<TKey extends Key = Key> = SelectBaseProps<TKey>;
4
- export declare const SelectDesktop: <TKey extends Key = Key>({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectDesktopProps<TKey>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const SelectDesktop: <TKey extends Key = Key>({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectDesktopProps<TKey>) => import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -6,6 +6,7 @@ import "./useSelectItems.js";
6
6
  import { SelectContext } from "./select.context.js";
7
7
  import { SelectInput } from "./SelectInput.js";
8
8
  import { SelectListBox } from "./SelectListBox.js";
9
+ import { selectPopoverCva } from "./selectDesktop.cva.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
11
  import { clsx } from "clsx";
11
12
  import { Fragment as Fragment$1, useLayoutEffect, useMemo, useRef, useState } from "react";
@@ -13,9 +14,10 @@ import { ComboBox, DialogTrigger, Popover } from "react-aria-components";
13
14
  import { useLabel, usePreventScroll } from "react-aria";
14
15
  import { mergeRefs } from "@react-aria/utils";
15
16
  //#region src/components/inputs/Selection/shared/SelectDesktop.tsx
16
- var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
17
+ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
17
18
  const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, isSearchable, isClearable, isLoading, as, size, collapseAfter, selectedTagsType } = props;
18
19
  const popoverCva = UIStyle.useCva("popover.cva", popover);
20
+ const selectPopoverCva$1 = UIStyle.useCva("select.popoverCva", selectPopoverCva);
19
21
  const formFieldProps = {
20
22
  error,
21
23
  label,
@@ -113,14 +115,14 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
113
115
  className: clsx("w-full", containerClassName)
114
116
  },
115
117
  as,
118
+ onMouseEnter,
119
+ onFocusCapture,
116
120
  ref: wrapperRef,
117
121
  children: [customTrigger ? /* @__PURE__ */ jsx(DialogTrigger, {
118
122
  ...dialogTriggerProps,
119
123
  children: /* @__PURE__ */ jsx("div", {
120
124
  ...fieldProps,
121
125
  ref: mergeRefs(ref, triggerRef),
122
- onMouseEnter,
123
- onFocusCapture,
124
126
  children: customTrigger
125
127
  })
126
128
  }) : /* @__PURE__ */ jsx(SelectInput, {
@@ -137,6 +139,8 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
137
139
  isClearable,
138
140
  showSelectionContent,
139
141
  inputClassName,
142
+ leadingContent,
143
+ trailingContent,
140
144
  collapseAfter,
141
145
  selectedTagsType,
142
146
  isRequired,
@@ -151,7 +155,7 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
151
155
  triggerRef,
152
156
  isOpen,
153
157
  onOpenChange: setIsOpen,
154
- className: "my-4 outline-none",
158
+ className: selectPopoverCva$1({}),
155
159
  style: { width: !ignoreTriggerWidth ? popoverWidth : void 0 },
156
160
  offset: 0,
157
161
  children: /* @__PURE__ */ jsx(SelectListBox, {
@@ -4,12 +4,12 @@ import { FormFieldHeaderProps } from '../../FormField/FormFieldHeader';
4
4
  import { SelectBaseProps } from './SelectBase';
5
5
  import { SelectItem } from './select.types';
6
6
  import { InputVariantProps } from '../../shared/input.cva';
7
- interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter" | "isRequired" | "isDirty" | "fireBlurOnChange" | "onMouseEnter" | "onFocusCapture"> {
7
+ interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter" | "isRequired" | "isDirty" | "fireBlurOnChange" | "leadingContent" | "trailingContent" | "onMouseEnter" | "onFocusCapture"> {
8
8
  isInvalid?: boolean;
9
9
  className?: string;
10
10
  fieldProps?: AriaFieldProps;
11
11
  headerProps?: FormFieldHeaderProps;
12
12
  onCloseComboBox?: (state: ComboBoxState<SelectItem> | null) => void;
13
13
  }
14
- export declare const SelectInput: ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, onMouseEnter, onFocusCapture, ...props }: SelectInputProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const 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 }: SelectInputProps) => import("react/jsx-runtime").JSX.Element;
15
15
  export {};
@@ -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";
@@ -14,9 +14,10 @@ import { Button, ComboBoxStateContext, Input } from "react-aria-components";
14
14
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
15
15
  import { useTranslation } from "react-i18next";
16
16
  //#region src/components/inputs/Selection/shared/SelectInput.tsx
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, onMouseEnter, onFocusCapture, ...props }) => {
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 });
@@ -101,6 +102,10 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
101
102
  ...headerProps,
102
103
  labelProps
103
104
  }),
105
+ leadingContent && /* @__PURE__ */ jsx("div", {
106
+ className: "ml-input-side-default flex shrink-0 items-center",
107
+ children: leadingContent
108
+ }),
104
109
  (showTags || isSearchable) && /* @__PURE__ */ jsxs("div", {
105
110
  className: clsx("flex flex-1 flex-wrap gap-input-gap-input-text-to-elements truncate", !isSearchable && "pointer-events-none z-1"),
106
111
  children: [showTags && /* @__PURE__ */ jsx(SelectInputTags, {
@@ -138,8 +143,13 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
138
143
  onClear();
139
144
  if (fireBlurOnChange) onBlur?.({});
140
145
  },
146
+ className: inputClearClassCva({ as }),
141
147
  show: showClearButton
142
148
  }),
149
+ trailingContent && /* @__PURE__ */ jsx("div", {
150
+ className: "flex shrink-0 items-center",
151
+ children: trailingContent
152
+ }),
143
153
  !hideDropdownIcon && /* @__PURE__ */ jsx(Button, {
144
154
  excludeFromTabOrder: true,
145
155
  "aria-label": t(($) => isOpen ? $.ui.closeAlt : $.ui.openAlt),
@@ -1,9 +1,9 @@
1
1
  import { AriaListBoxProps } from 'react-aria';
2
2
  import { SelectBaseProps } from './SelectBase';
3
3
  import { SelectItem } from './select.types';
4
- export interface SelectListBoxProps extends Pick<SelectBaseProps, "label" | "newItemRender" | "onLoadMore" | "selectionMode" | "isSearchable" | "virtualizerOptions">, Omit<AriaListBoxProps<SelectItem>, "children" | "aria-label" | "selectionMode" | "items" | "selectedKeys" | "onSelectionChange" | "escapeKeyBehavior" | "shouldSelectOnPressUp" | "label"> {
4
+ export interface SelectListBoxProps extends Pick<SelectBaseProps, "label" | "newItemRender" | "onLoadMore" | "selectionMode" | "isSearchable" | "virtualizerOptions" | "totalItems" | "hasLoadMore">, Omit<AriaListBoxProps<SelectItem>, "children" | "aria-label" | "selectionMode" | "items" | "selectedKeys" | "onSelectionChange" | "escapeKeyBehavior" | "shouldSelectOnPressUp" | "label"> {
5
5
  className?: string;
6
6
  isScrollable?: boolean;
7
7
  onClose?: () => void;
8
8
  }
9
- export declare const SelectListBox: ({ label, selectionMode, isSearchable, isScrollable, virtualizerOptions, newItemRender, onLoadMore, className, onClose, ...props }: SelectListBoxProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const SelectListBox: ({ label, selectionMode, isSearchable, isScrollable, virtualizerOptions, totalItems, newItemRender, onLoadMore, className, onClose, ...props }: SelectListBoxProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,8 +7,8 @@ import { jsx } from "react/jsx-runtime";
7
7
  import { clsx } from "clsx";
8
8
  import { ListBox, ListLayout, Virtualizer } from "react-aria-components";
9
9
  //#region src/components/inputs/Selection/shared/SelectListBox.tsx
10
- var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true, virtualizerOptions, newItemRender, onLoadMore, className, onClose, ...props }) => {
11
- const { fieldState, onChange, listItems, selectableListItems, selectedIds, isMultiple, onClear, onSelectAll } = SelectContext.useSelect();
10
+ var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true, virtualizerOptions, totalItems, newItemRender, onLoadMore, className, onClose, ...props }) => {
11
+ const { fieldState, onChange, listItems, selectableListItems, selectedIds, isMultiple, onClear, onSelectAll, hasLoadMore } = SelectContext.useSelect();
12
12
  const onSelectionChange = (value) => {
13
13
  const ids = Array.from(value);
14
14
  if (!isMultiple && ids.length === 0) {
@@ -42,7 +42,7 @@ var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true,
42
42
  newItemRender
43
43
  }, item.id);
44
44
  };
45
- if (virtualizerOptions || listItems.length > 100) return /* @__PURE__ */ jsx(Virtualizer, {
45
+ if (virtualizerOptions || (totalItems ?? listItems.length) > 100 || hasLoadMore) return /* @__PURE__ */ jsx(Virtualizer, {
46
46
  layout: ListLayout,
47
47
  layoutOptions: virtualizerOptions,
48
48
  children: /* @__PURE__ */ jsx(ListBox, {
@@ -1,5 +1,5 @@
1
1
  import { Key } from 'react-aria-components';
2
2
  import { SelectBaseProps } from './SelectBase';
3
3
  type SelectMobileProps<TKey extends Key = Key> = SelectBaseProps<TKey>;
4
- export declare const SelectMobile: <TKey extends Key = Key>({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectMobileProps<TKey>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const SelectMobile: <TKey extends Key = Key>({ ref, error, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectMobileProps<TKey>) => import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -13,7 +13,7 @@ import { useRef } from "react";
13
13
  import { DialogTrigger } from "react-aria-components";
14
14
  import { useLabel } from "react-aria";
15
15
  //#region src/components/inputs/Selection/shared/SelectMobile.tsx
16
- var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
16
+ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
17
17
  const { label, tooltipText, helperText, isDirty, 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,
@@ -57,13 +57,13 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
57
57
  as,
58
58
  labelProps,
59
59
  className: clsx("w-full", containerClassName),
60
+ onMouseEnter,
61
+ onFocusCapture,
60
62
  children: /* @__PURE__ */ jsxs(DialogTrigger, {
61
63
  ...dialogTriggerProps,
62
64
  children: [customTrigger ? /* @__PURE__ */ jsx("div", {
63
65
  ...fieldProps,
64
66
  ref,
65
- onMouseEnter,
66
- onFocusCapture,
67
67
  children: customTrigger
68
68
  }) : /* @__PURE__ */ jsx(SelectInput, {
69
69
  ref,
@@ -81,6 +81,8 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
81
81
  onBlur: void 0,
82
82
  fieldProps,
83
83
  headerProps,
84
+ leadingContent,
85
+ trailingContent,
84
86
  collapseAfter,
85
87
  selectedTagsType,
86
88
  isRequired,
@@ -17,14 +17,15 @@ export declare namespace SelectContext {
17
17
  onClear: () => void;
18
18
  onSelectAll: () => void;
19
19
  onRemove: (val: Key) => void;
20
+ onBlur: () => void;
20
21
  listItems: ExtendedSelectItem[];
21
22
  selectableListItems: SelectItem[];
22
23
  selectedItems: SelectItem[];
23
24
  selectedIds: Key[];
24
25
  isMultiple: boolean;
25
26
  } & Pick<SelectBaseProps, "onInputChange" | "isLoading" | "hasLoadMore">;
26
- export type ProviderProps = GroupedSelectProps & Pick<SelectBaseProps, "items" | "onInputChange" | "onSearchChange" | "showSelectAllOption" | "showNewItemOption" | "newItemMinLength" | "onNewItemOption" | "isLoading" | "hasLoadMore" | "mapInitialToSelectItem" | "isSearchable" | "isClientSearchDisabled">;
27
- export const Provider: ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, children, mapInitialToSelectItem, ...props }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
27
+ export type ProviderProps = GroupedSelectProps & Pick<SelectBaseProps, "items" | "onInputChange" | "onSearchChange" | "showSelectAllOption" | "showNewItemOption" | "newItemMinLength" | "onNewItemOption" | "isLoading" | "hasLoadMore" | "mapInitialToSelectItem" | "isSearchable" | "isClientSearchDisabled" | "ignoreInputValueFiltering">;
28
+ export const Provider: ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, ignoreInputValueFiltering, children, mapInitialToSelectItem, ...props }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
28
29
  export const useSelect: () => Type;
29
30
  export {};
30
31
  }
@@ -1,5 +1,5 @@
1
- import { useSelectItems } from "./useSelectItems.js";
2
1
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
2
+ import { useSelectItems } from "./useSelectItems.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
5
5
  //#region src/components/inputs/Selection/shared/select.context.tsx
@@ -10,7 +10,7 @@ var SelectContext;
10
10
  id: item.id,
11
11
  label: item.label ?? item.name ?? ""
12
12
  });
13
- _SelectContext.Provider = ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, children, mapInitialToSelectItem = defaultMapInitialToSelectItem, ...props }) => {
13
+ _SelectContext.Provider = ({ items, onInputChange, onSearchChange, showSelectAllOption, showNewItemOption, newItemMinLength, onNewItemOption, isLoading, hasLoadMore, isClientSearchDisabled, ignoreInputValueFiltering, children, mapInitialToSelectItem = defaultMapInitialToSelectItem, ...props }) => {
14
14
  const isMultiple = props.selectionMode === "multiple";
15
15
  const initialSelectedItems = useMemo(() => {
16
16
  if (!props.initialSelection) return null;
@@ -42,7 +42,7 @@ var SelectContext;
42
42
  newItemMinLength,
43
43
  isLoading,
44
44
  hasLoadMore,
45
- isClientSearchDisabled
45
+ isClientSearchDisabled: ignoreInputValueFiltering ?? isClientSearchDisabled
46
46
  });
47
47
  const selectedItems = useMemo(() => allItems.filter(({ id }) => Array.isArray(fieldState.value) ? fieldState.value.includes(id) : id === fieldState.value), [allItems, fieldState.value]);
48
48
  const selectedIds = useMemo(() => selectedItems.map(({ id }) => id), [selectedItems]);
@@ -84,7 +84,7 @@ var SelectContext;
84
84
  else updateValue(value);
85
85
  }, [props.value]);
86
86
  useEffect(() => {
87
- if (!isMultiple && fieldState.value && fieldState.inputValue === "" && getItem(fieldState.value)?.label) syncFieldState(fieldState.value);
87
+ if (!isMultiple && props.value !== null && props.value !== void 0 && fieldState.value !== null && fieldState.value !== void 0 && fieldState.inputValue === "" && getItem(fieldState.value)?.label) syncFieldState(fieldState.value);
88
88
  }, [allListItems]);
89
89
  const handleInputChange = useCallback((inputValue) => {
90
90
  const newFieldState = {
@@ -144,6 +144,22 @@ var SelectContext;
144
144
  fieldState.value,
145
145
  onChange
146
146
  ]);
147
+ const onBlur = useCallback(() => {
148
+ if (props.isSearchable && isMultiple && fieldState.searchValue !== "") {
149
+ const newFieldState = {
150
+ ...fieldState,
151
+ inputValue: "",
152
+ searchValue: ""
153
+ };
154
+ setFieldState(newFieldState);
155
+ emitStateChanges(newFieldState);
156
+ setShowAll(true);
157
+ }
158
+ }, [
159
+ props.isSearchable,
160
+ isMultiple,
161
+ fieldState
162
+ ]);
147
163
  const value = useMemo(() => ({
148
164
  fieldState,
149
165
  isOpen,
@@ -154,6 +170,7 @@ var SelectContext;
154
170
  onClear,
155
171
  onSelectAll,
156
172
  onRemove,
173
+ onBlur,
157
174
  listItems,
158
175
  selectableListItems,
159
176
  selectedItems,
@@ -171,6 +188,7 @@ var SelectContext;
171
188
  onClear,
172
189
  onSelectAll,
173
190
  onRemove,
191
+ onBlur,
174
192
  listItems,
175
193
  selectableListItems,
176
194
  selectedIds,
@@ -1,11 +1,11 @@
1
- import { ReactElement } from 'react';
1
+ import { ReactElement, ReactNode } from 'react';
2
2
  import { Key } from 'react-aria-components';
3
3
  import { FieldValues } from 'react-hook-form';
4
4
  import { ControlProps } from '../../shared/form.types';
5
5
  export interface SelectItem<TKey extends Key = Key> {
6
6
  id: TKey;
7
7
  label: string;
8
- content?: string | ReactElement;
8
+ content?: string | ReactNode;
9
9
  isDisabled?: boolean;
10
10
  }
11
11
  export interface ExtendedSelectItem<TKey extends Key = Key> extends SelectItem<TKey> {
@@ -54,6 +54,7 @@ export interface SelectAsyncProps {
54
54
  onLoadMore?: () => void;
55
55
  }
56
56
  export interface SelectVirtualizationProps {
57
+ totalItems?: number;
57
58
  virtualizerOptions?: {
58
59
  rowHeight?: number;
59
60
  estimatedRowHeight?: number;
@@ -0,0 +1,3 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ export declare const selectPopoverCva: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
3
+ export type SelectPopoverCva = VariantProps<typeof selectPopoverCva>;
@@ -0,0 +1,5 @@
1
+ import { cva } from "class-variance-authority";
2
+ //#region src/components/inputs/Selection/shared/selectDesktop.cva.ts
3
+ var selectPopoverCva = cva("my-4 outline-none");
4
+ //#endregion
5
+ export { selectPopoverCva };
@@ -0,0 +1,23 @@
1
+ import { ReactNode } from 'react';
2
+ import { Key } from 'react-aria-components';
3
+ import { SelectBaseProps } from './SelectBase';
4
+ import { DefaultInitialSelectItem, SelectItem } from './select.types';
5
+ interface GetStaticSelectValueOptions<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> {
6
+ items: SelectItem<TKey>[];
7
+ value: TKey | TKey[] | null | undefined;
8
+ selectionMode: SelectBaseProps<TKey>["selectionMode"];
9
+ initialSelection?: TInitialSelectItem | TInitialSelectItem[] | null;
10
+ mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
11
+ showSelectionContent?: boolean;
12
+ isDisabled?: boolean;
13
+ collapseAfter?: SelectBaseProps<TKey>["collapseAfter"];
14
+ selectedTagsType?: SelectBaseProps<TKey>["selectedTagsType"];
15
+ }
16
+ interface StaticSelectValueResult<TKey extends Key = Key> {
17
+ selectedItem: SelectItem<TKey> | null;
18
+ selectedItems: SelectItem<TKey>[];
19
+ displayValue: ReactNode;
20
+ isEmpty: boolean;
21
+ }
22
+ export declare const getStaticSelectValue: <TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>({ items, value, selectionMode, initialSelection, mapInitialToSelectItem, showSelectionContent, isDisabled, collapseAfter, selectedTagsType, }: GetStaticSelectValueOptions<TKey, TInitialSelectItem>) => StaticSelectValueResult<TKey>;
23
+ export {};
@@ -0,0 +1,35 @@
1
+ import { SelectInputTags } from "./SelectInputTags.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/components/inputs/Selection/shared/staticSelect.utils.tsx
4
+ var getStaticSelectValue = ({ items, value, selectionMode, initialSelection, mapInitialToSelectItem = ((item) => ({
5
+ id: item.id,
6
+ label: item.label ?? item.name ?? ""
7
+ })), showSelectionContent, isDisabled, collapseAfter, selectedTagsType }) => {
8
+ const initialSelectedItems = initialSelection ? (Array.isArray(initialSelection) ? initialSelection : [initialSelection]).map((item) => mapInitialToSelectItem(item)) : [];
9
+ const allItemsMap = /* @__PURE__ */ new Map();
10
+ [...initialSelectedItems, ...items].forEach((item) => allItemsMap.set(item.id, item));
11
+ const allItems = Array.from(allItemsMap.values());
12
+ const getItem = (id) => allItems.find((item) => item.id === id) ?? null;
13
+ const selectedItems = Array.isArray(value) ? value.map((id) => getItem(id)).filter((item) => item != null) : [];
14
+ const selectedItem = !Array.isArray(value) && value != null ? getItem(value) : null;
15
+ if (selectionMode === "multiple") return {
16
+ selectedItem,
17
+ selectedItems,
18
+ displayValue: selectedItems.length > 0 ? /* @__PURE__ */ jsx(SelectInputTags, {
19
+ selectedItems,
20
+ isDisabled,
21
+ collapseAfter,
22
+ selectedTagsType,
23
+ onRemove: () => void 0
24
+ }) : "",
25
+ isEmpty: selectedItems.length === 0
26
+ };
27
+ return {
28
+ selectedItem,
29
+ selectedItems,
30
+ displayValue: selectedItem != null ? showSelectionContent && selectedItem.content ? selectedItem.content : selectedItem.label : "",
31
+ isEmpty: selectedItem == null
32
+ };
33
+ };
34
+ //#endregion
35
+ export { getStaticSelectValue };
@@ -2,7 +2,7 @@ import { UIStyle } from "../../../config/uiStyle.context.js";
2
2
  import { UIConfig } from "../../../config/uiConfig.context.js";
3
3
  import { FormFieldError } from "../FormField/FormFieldError.js";
4
4
  import { CheckContent } from "../shared/CheckContent.js";
5
- import { toggle, toggleTypography } from "./toggle.cva.js";
5
+ import { toggle, toggleContentClassName, toggleTypography } from "./toggle.cva.js";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { clsx } from "clsx";
8
8
  import { Switch } from "react-aria-components";
@@ -13,6 +13,7 @@ var ToggleBase = (props) => {
13
13
  const ui = UIConfig.useConfig();
14
14
  const toggleCva = UIStyle.useCva("toggle.cva", toggle);
15
15
  const toggleTypographyMap = UIStyle.useMapper("toggle.typography", toggleTypography);
16
+ const toggleContentClassNameMap = UIStyle.useMapper("toggle.contentClassName", toggleContentClassName);
16
17
  const { className, children, isDisabled, error, variant = ui.toggle.variant, ...rest } = props;
17
18
  const formFieldErrorProps = {
18
19
  error,
@@ -32,6 +33,10 @@ var ToggleBase = (props) => {
32
33
  variant,
33
34
  ...rest
34
35
  }),
36
+ contentClassName: toggleContentClassNameMap({
37
+ variant,
38
+ ...rest
39
+ }),
35
40
  children
36
41
  })]
37
42
  }), /* @__PURE__ */ jsx(FormFieldError, { ...formFieldErrorProps })] });
@@ -8,3 +8,6 @@ export interface ToggleVariantProps extends VariantProps<typeof toggle> {
8
8
  export declare const toggleTypography: (props: {
9
9
  variant?: "default" | null | undefined;
10
10
  }) => TypographyVariantProps | undefined;
11
+ export declare const toggleContentClassName: (props: {
12
+ variant?: "default" | null | undefined;
13
+ }) => string | undefined;
@@ -26,5 +26,6 @@ var toggleTypography = compoundMapper({ default: {
26
26
  sizeMobile: "label-1",
27
27
  variant: "default"
28
28
  } });
29
+ var toggleContentClassName = compoundMapper({ default: "text-text-default-2" });
29
30
  //#endregion
30
- export { toggle, toggleTypography };
31
+ export { toggle, toggleContentClassName, toggleTypography };
@@ -3,6 +3,7 @@ import { TypographyVariantProps } from '../../text/Typography/typography.cva';
3
3
  interface CheckContentProps {
4
4
  typography?: TypographyVariantProps;
5
5
  className?: string;
6
+ contentClassName?: string;
6
7
  }
7
- export declare const CheckContent: ({ children, className, ...props }: PropsWithChildren<CheckContentProps>) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const CheckContent: ({ children, className, contentClassName, ...props }: PropsWithChildren<CheckContentProps>) => import("react/jsx-runtime").JSX.Element;
8
9
  export {};
@@ -3,15 +3,14 @@ import { typography } from "../../text/Typography/typography.cva.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import clsx$1 from "clsx";
5
5
  //#region src/components/inputs/shared/CheckContent.tsx
6
- var CheckContent = ({ children, className, ...props }) => {
6
+ var CheckContent = ({ children, className, contentClassName, ...props }) => {
7
7
  return /* @__PURE__ */ jsx("div", {
8
8
  className: clsx$1(UIStyle.useCva("typography.cva", typography)({
9
9
  size: "label-1",
10
10
  sizeMobile: "label-1",
11
11
  variant: "default",
12
- ...props.typography,
13
- className: "text-text-default-2"
14
- }), className),
12
+ ...props.typography
13
+ }), contentClassName, className),
15
14
  children
16
15
  });
17
16
  };