@povio/ui 2.2.11 → 2.3.0-rc.1
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/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
- package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +10 -5
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +89 -9
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +10 -5
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +95 -7
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +11 -5
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +95 -9
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +5 -3
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +77 -7
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/Calendar.js +49 -8
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +78 -61
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +11 -4
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +4 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +21 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -0
- package/dist/components/inputs/File/FileUpload.js +1 -0
- package/dist/components/inputs/File/shared/InputUploadContent.js +1 -0
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +81 -7
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +146 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +235 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +4 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +5 -0
- package/dist/components/inputs/Input/TextArea/TextArea.js +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +82 -7
- package/dist/components/inputs/Input/shared/InputContent.js +7 -6
- package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
- package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
- package/dist/components/inputs/Inputs/InputItem.d.ts +16 -21
- package/dist/components/inputs/Inputs/InputItem.js +6 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +2 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +106 -25
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +17 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +42 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +102 -7
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -18
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +33 -8
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +36 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +14 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.js +42 -0
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +115 -5
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +8 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +11 -3
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +27 -4
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +9 -3
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +6 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +13 -0
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +27 -4
- package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +77 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +200 -0
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +8 -3
- package/dist/components/inputs/Toggle/Toggle.js +6 -1
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
- package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
- package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
- package/dist/components/inputs/shared/CheckContent.js +3 -4
- package/dist/components/inputs/shared/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +13 -1
- package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
- package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
- package/dist/components/inputs/shared/input.cva.d.ts +10 -0
- package/dist/components/inputs/shared/input.cva.js +19 -1
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +13 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.js +47 -0
- package/dist/components/overlays/BottomSheet/BottomSheet.js +1 -1
- package/dist/components/segment/Segment.js +2 -1
- package/dist/components/segment/SegmentItem.d.ts +1 -1
- package/dist/components/segment/SegmentItem.js +5 -2
- package/dist/components/segment/segment.types.d.ts +1 -0
- package/dist/config/router.context.d.ts +3 -4
- package/dist/config/router.context.js +1 -3
- package/dist/config/uiConfig.context.d.ts +15 -3
- package/dist/config/uiConfig.context.js +16 -3
- package/dist/config/uiStyle.context.d.ts +27 -4
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +3 -0
- package/dist/hooks/useFilters.js +27 -23
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +29 -10
- package/dist/hooks/usePagination.js +8 -4
- package/dist/hooks/useQueryAutocomplete.d.ts +14 -0
- package/dist/hooks/useQueryAutocomplete.js +56 -0
- package/dist/hooks/useSorting.js +7 -4
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -3
- package/dist/tw-ui-plugin.js +2 -0
- package/dist/utils/date-time.utils.d.ts +31 -10
- package/dist/utils/date-time.utils.js +123 -22
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/dist/utils/routing.utils.d.ts +1 -0
- package/dist/utils/routing.utils.js +14 -0
- package/package.json +4 -4
|
@@ -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, onCloseComboBox, onBlur, ...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 });
|
|
@@ -44,9 +45,13 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
44
45
|
if (e.key === "Enter" && !isMultiple && !isLoading && listItems.length === 1 && !listItems[0].isDisabled) {
|
|
45
46
|
e.preventDefault();
|
|
46
47
|
onChange(listItems[0].id);
|
|
48
|
+
if (fireBlurOnChange) onBlur?.({});
|
|
47
49
|
onCloseComboBox?.(state);
|
|
48
50
|
}
|
|
49
|
-
if (e.key === "Backspace" && isMultiple && fieldState.inputValue === "" && Array.isArray(fieldState.value) && fieldState.value.length > 0)
|
|
51
|
+
if (e.key === "Backspace" && isMultiple && fieldState.inputValue === "" && Array.isArray(fieldState.value) && fieldState.value.length > 0) {
|
|
52
|
+
onChange(fieldState.value.slice(0, -1));
|
|
53
|
+
if (fireBlurOnChange) onBlur?.({});
|
|
54
|
+
}
|
|
50
55
|
};
|
|
51
56
|
const onClick = () => {
|
|
52
57
|
if (isDisabled) return;
|
|
@@ -66,6 +71,7 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
66
71
|
}),
|
|
67
72
|
"data-rac": "",
|
|
68
73
|
"data-disabled": isDisabled || void 0,
|
|
74
|
+
"data-is-disabled": isDisabled || void 0,
|
|
69
75
|
"data-hovered": isHovered || void 0,
|
|
70
76
|
"data-focused": isOpen || isFocused || void 0,
|
|
71
77
|
"data-focus-within": isFocused || void 0,
|
|
@@ -75,7 +81,12 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
75
81
|
"data-has-search": fieldState.searchValue !== "" || void 0,
|
|
76
82
|
"data-invalid": isInvalid || void 0,
|
|
77
83
|
"data-is-empty": isEmpty || void 0,
|
|
84
|
+
"data-is-filled": !isEmpty || void 0,
|
|
85
|
+
"data-is-required": isRequired || void 0,
|
|
86
|
+
"data-is-dirty": isDirty || void 0,
|
|
78
87
|
"data-select-input": "",
|
|
88
|
+
onMouseEnter,
|
|
89
|
+
onFocusCapture,
|
|
79
90
|
...hoverProps,
|
|
80
91
|
...focusWithinProps,
|
|
81
92
|
children: [
|
|
@@ -92,6 +103,10 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
92
103
|
...headerProps,
|
|
93
104
|
labelProps
|
|
94
105
|
}),
|
|
106
|
+
leadingContent && /* @__PURE__ */ jsx("div", {
|
|
107
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
108
|
+
children: leadingContent
|
|
109
|
+
}),
|
|
95
110
|
(showTags || isSearchable) && /* @__PURE__ */ jsxs("div", {
|
|
96
111
|
className: clsx("flex flex-1 flex-wrap gap-input-gap-input-text-to-elements truncate", !isSearchable && "pointer-events-none z-1"),
|
|
97
112
|
children: [showTags && /* @__PURE__ */ jsx(SelectInputTags, {
|
|
@@ -125,9 +140,17 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
|
|
|
125
140
|
]
|
|
126
141
|
}),
|
|
127
142
|
isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
128
|
-
onClear
|
|
143
|
+
onClear: () => {
|
|
144
|
+
onClear();
|
|
145
|
+
if (fireBlurOnChange) onBlur?.({});
|
|
146
|
+
},
|
|
147
|
+
className: inputClearClassCva({ as }),
|
|
129
148
|
show: showClearButton
|
|
130
149
|
}),
|
|
150
|
+
trailingContent && /* @__PURE__ */ jsx("div", {
|
|
151
|
+
className: "flex shrink-0 items-center",
|
|
152
|
+
children: trailingContent
|
|
153
|
+
}),
|
|
131
154
|
!hideDropdownIcon && /* @__PURE__ */ jsx(Button, {
|
|
132
155
|
excludeFromTabOrder: true,
|
|
133
156
|
"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, ...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,8 +13,8 @@ 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, ...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;
|
|
16
|
+
var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
|
|
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,
|
|
20
20
|
label,
|
|
@@ -57,6 +57,8 @@ 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", {
|
|
@@ -79,8 +81,12 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
|
|
|
79
81
|
onBlur: void 0,
|
|
80
82
|
fieldProps,
|
|
81
83
|
headerProps,
|
|
84
|
+
leadingContent,
|
|
85
|
+
trailingContent,
|
|
82
86
|
collapseAfter,
|
|
83
|
-
selectedTagsType
|
|
87
|
+
selectedTagsType,
|
|
88
|
+
isRequired,
|
|
89
|
+
isDirty
|
|
84
90
|
}), /* @__PURE__ */ jsx(BottomSheet, {
|
|
85
91
|
isOpen,
|
|
86
92
|
onOpenChange: handleOpenChange,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { Key } from 'react-aria-components';
|
|
3
|
+
import { SelectItem } from './select.types';
|
|
4
|
+
export type QueryFn<TData = any> = (...args: any[]) => UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
|
|
5
|
+
export type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
|
|
6
|
+
export declare const getQueryItems: <TQueryFn extends QueryFn, TKey extends Key = Key>(data: QueryDataType<TQueryFn> | undefined, queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[]) => SelectItem<TKey>[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/components/inputs/Selection/shared/querySelect.utils.ts
|
|
2
|
+
var getQueryItems = (data, queryMap) => {
|
|
3
|
+
if (!data) return [];
|
|
4
|
+
if (queryMap) return queryMap(data);
|
|
5
|
+
if (Array.isArray(data)) return data;
|
|
6
|
+
if (typeof data === "object" && data !== null) {
|
|
7
|
+
if ("items" in data && Array.isArray(data.items)) return data.items;
|
|
8
|
+
if ("pages" in data && Array.isArray(data.pages)) return data.pages.flatMap((page) => page && typeof page === "object" && "items" in page && Array.isArray(page.items) ? page.items : []);
|
|
9
|
+
}
|
|
10
|
+
return [];
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getQueryItems };
|
|
@@ -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
|
}
|
|
@@ -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,9 +42,14 @@ var SelectContext;
|
|
|
42
42
|
newItemMinLength,
|
|
43
43
|
isLoading,
|
|
44
44
|
hasLoadMore,
|
|
45
|
-
isClientSearchDisabled
|
|
45
|
+
isClientSearchDisabled: ignoreInputValueFiltering ?? isClientSearchDisabled
|
|
46
46
|
});
|
|
47
|
-
const selectedItems = useMemo(() =>
|
|
47
|
+
const selectedItems = useMemo(() => {
|
|
48
|
+
const getItem = (id) => allItems.find((item) => item.id === id) ?? null;
|
|
49
|
+
if (Array.isArray(fieldState.value)) return fieldState.value.map((id) => getItem(id)).filter((item) => item !== null);
|
|
50
|
+
const selectedItem = fieldState.value != null ? getItem(fieldState.value) : null;
|
|
51
|
+
return selectedItem ? [selectedItem] : [];
|
|
52
|
+
}, [allItems, fieldState.value]);
|
|
48
53
|
const selectedIds = useMemo(() => selectedItems.map(({ id }) => id), [selectedItems]);
|
|
49
54
|
const getItem = useCallback((value) => allItems.find((item) => item && item.id === value) ?? null, [allItems]);
|
|
50
55
|
const updateValue = useCallback((value) => {
|
|
@@ -84,7 +89,7 @@ var SelectContext;
|
|
|
84
89
|
else updateValue(value);
|
|
85
90
|
}, [props.value]);
|
|
86
91
|
useEffect(() => {
|
|
87
|
-
if (!isMultiple && fieldState.value && fieldState.inputValue === "" && getItem(fieldState.value)?.label) syncFieldState(fieldState.value);
|
|
92
|
+
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
93
|
}, [allListItems]);
|
|
89
94
|
const handleInputChange = useCallback((inputValue) => {
|
|
90
95
|
const newFieldState = {
|
|
@@ -144,6 +149,22 @@ var SelectContext;
|
|
|
144
149
|
fieldState.value,
|
|
145
150
|
onChange
|
|
146
151
|
]);
|
|
152
|
+
const onBlur = useCallback(() => {
|
|
153
|
+
if (props.isSearchable && isMultiple && fieldState.searchValue !== "") {
|
|
154
|
+
const newFieldState = {
|
|
155
|
+
...fieldState,
|
|
156
|
+
inputValue: "",
|
|
157
|
+
searchValue: ""
|
|
158
|
+
};
|
|
159
|
+
setFieldState(newFieldState);
|
|
160
|
+
emitStateChanges(newFieldState);
|
|
161
|
+
setShowAll(true);
|
|
162
|
+
}
|
|
163
|
+
}, [
|
|
164
|
+
props.isSearchable,
|
|
165
|
+
isMultiple,
|
|
166
|
+
fieldState
|
|
167
|
+
]);
|
|
147
168
|
const value = useMemo(() => ({
|
|
148
169
|
fieldState,
|
|
149
170
|
isOpen,
|
|
@@ -154,6 +175,7 @@ var SelectContext;
|
|
|
154
175
|
onClear,
|
|
155
176
|
onSelectAll,
|
|
156
177
|
onRemove,
|
|
178
|
+
onBlur,
|
|
157
179
|
listItems,
|
|
158
180
|
selectableListItems,
|
|
159
181
|
selectedItems,
|
|
@@ -171,6 +193,7 @@ var SelectContext;
|
|
|
171
193
|
onClear,
|
|
172
194
|
onSelectAll,
|
|
173
195
|
onRemove,
|
|
196
|
+
onBlur,
|
|
174
197
|
listItems,
|
|
175
198
|
selectableListItems,
|
|
176
199
|
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 |
|
|
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,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,37 @@
|
|
|
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 getItem = (id) => allItemsMap.get(id) ?? null;
|
|
12
|
+
const selectedItems = Array.isArray(value) ? value.map((id) => getItem(id)).filter((item) => item != null) : [];
|
|
13
|
+
const selectedItem = !Array.isArray(value) && value != null ? getItem(value) : null;
|
|
14
|
+
if (selectionMode === "multiple") return {
|
|
15
|
+
selectedItem,
|
|
16
|
+
selectedItems,
|
|
17
|
+
displayValue: selectedItems.length > 0 ? /* @__PURE__ */ jsx(SelectInputTags, {
|
|
18
|
+
selectedItems,
|
|
19
|
+
isDisabled,
|
|
20
|
+
collapseAfter,
|
|
21
|
+
selectedTagsType,
|
|
22
|
+
onRemove: () => void 0
|
|
23
|
+
}) : "",
|
|
24
|
+
isEmpty: selectedItems.length === 0
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
selectedItem,
|
|
28
|
+
selectedItems,
|
|
29
|
+
displayValue: selectedItem != null ? showSelectionContent && selectedItem.content ? selectedItem.content : /* @__PURE__ */ jsx("div", {
|
|
30
|
+
className: "min-w-0 flex-1 truncate",
|
|
31
|
+
children: selectedItem.label
|
|
32
|
+
}) : "",
|
|
33
|
+
isEmpty: selectedItem == null
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { getStaticSelectValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { FC, FocusEventHandler, MouseEventHandler, ReactElement, ReactNode, Ref, SVGProps } from 'react';
|
|
2
|
+
import { InlineIconButtonProps } from '../../buttons/InlineIconButton/InlineIconButton';
|
|
3
|
+
import { FormFieldProps } from '../FormField/FormField';
|
|
4
|
+
import { FormFieldHeaderProps } from '../FormField/FormFieldHeader';
|
|
5
|
+
import { InputVariantProps } from '../shared/input.cva';
|
|
6
|
+
import { TypographyVariantProps } from '../../text/Typography/typography.cva';
|
|
7
|
+
type InputFrameIcon = FC<SVGProps<SVGSVGElement>> | ReactElement;
|
|
8
|
+
interface InputFrameAction {
|
|
9
|
+
icon: InlineIconButtonProps["icon"];
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
altText: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
interface InputFrameDataAttributes {
|
|
15
|
+
dataDisabled?: boolean;
|
|
16
|
+
dataHasSearch?: boolean;
|
|
17
|
+
dataHasSelection?: boolean;
|
|
18
|
+
dataInvalid?: boolean;
|
|
19
|
+
dataIsDirty?: boolean;
|
|
20
|
+
dataIsDisabled?: boolean;
|
|
21
|
+
dataIsEmpty?: boolean;
|
|
22
|
+
dataIsFilled?: boolean;
|
|
23
|
+
dataIsRequired?: boolean;
|
|
24
|
+
}
|
|
25
|
+
type InputFrameDataAttributeProps = {
|
|
26
|
+
"data-disabled"?: boolean;
|
|
27
|
+
"data-has-search"?: boolean;
|
|
28
|
+
"data-has-selection"?: boolean;
|
|
29
|
+
"data-invalid"?: boolean;
|
|
30
|
+
"data-is-dirty"?: boolean;
|
|
31
|
+
"data-is-disabled"?: boolean;
|
|
32
|
+
"data-is-empty"?: boolean;
|
|
33
|
+
"data-is-filled"?: boolean;
|
|
34
|
+
"data-is-required"?: boolean;
|
|
35
|
+
};
|
|
36
|
+
type InputFrameChildProps = InputFrameDataAttributeProps & {
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
type InputFrameChildren = ReactNode | ((childProps: InputFrameChildProps) => ReactNode);
|
|
40
|
+
type InputFrameLabelPlacement = "content-wrapper" | "content-row";
|
|
41
|
+
type InputFrameActionContentPlacement = "content-wrapper" | "content-row";
|
|
42
|
+
export interface InputFrameProps extends InputVariantProps, Partial<FormFieldProps> {
|
|
43
|
+
ref?: Ref<HTMLDivElement>;
|
|
44
|
+
children: InputFrameChildren;
|
|
45
|
+
formFieldRef?: Ref<HTMLDivElement>;
|
|
46
|
+
onMouseEnter?: MouseEventHandler<HTMLDivElement>;
|
|
47
|
+
onFocusCapture?: FocusEventHandler<HTMLDivElement>;
|
|
48
|
+
labelProps?: FormFieldHeaderProps["labelProps"];
|
|
49
|
+
headerProps?: FormFieldHeaderProps;
|
|
50
|
+
leadingContent?: ReactNode;
|
|
51
|
+
leadingIcon?: InputFrameIcon;
|
|
52
|
+
actionContent?: ReactNode;
|
|
53
|
+
actionContentPlacement?: InputFrameActionContentPlacement;
|
|
54
|
+
trailingContent?: ReactNode;
|
|
55
|
+
trailingIcon?: InputFrameIcon;
|
|
56
|
+
trailingAction?: ReactNode;
|
|
57
|
+
unit?: string;
|
|
58
|
+
isLoading?: boolean;
|
|
59
|
+
action?: InputFrameAction;
|
|
60
|
+
isClearable?: boolean;
|
|
61
|
+
showClear?: boolean;
|
|
62
|
+
renderStatic?: boolean;
|
|
63
|
+
onStaticInteract?: (shouldFocus: boolean) => void;
|
|
64
|
+
clearClassName?: string;
|
|
65
|
+
onClear?: () => void;
|
|
66
|
+
dataAttributes?: InputFrameDataAttributes;
|
|
67
|
+
typographySize?: TypographyVariantProps["size"];
|
|
68
|
+
id?: string;
|
|
69
|
+
inputClassName?: string;
|
|
70
|
+
contentClassName?: string;
|
|
71
|
+
contentWrapperClassName?: string;
|
|
72
|
+
wrapContentAndTrailing?: boolean;
|
|
73
|
+
labelPlacement?: InputFrameLabelPlacement;
|
|
74
|
+
trailingClassName?: string;
|
|
75
|
+
}
|
|
76
|
+
export declare const InputFrame: (props: InputFrameProps) => import("react/jsx-runtime").JSX.Element;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { UIStyle } from "../../../config/uiStyle.context.js";
|
|
2
|
+
import { typography } from "../../text/Typography/typography.cva.js";
|
|
3
|
+
import { Loader } from "../../status/Loader/Loader.js";
|
|
4
|
+
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
5
|
+
import { InlineIconButton } from "../../buttons/InlineIconButton/InlineIconButton.js";
|
|
6
|
+
import { FormFieldLabel } from "../FormField/FormFieldLabel.js";
|
|
7
|
+
import { InputClear } from "../shared/InputClear.js";
|
|
8
|
+
import { inputBase, inputContentWrapper, inputSize } from "../shared/input.cva.js";
|
|
9
|
+
import { FormField } from "../FormField/FormField.js";
|
|
10
|
+
import { TooltipWrapper } from "../shared/TooltipWrapper.js";
|
|
11
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { clsx } from "clsx";
|
|
13
|
+
import { isValidElement, useId } from "react";
|
|
14
|
+
//#region src/components/inputs/Skeleton/InputFrame.tsx
|
|
15
|
+
var InputFrame = (props) => {
|
|
16
|
+
const ui = UIConfig.useConfig();
|
|
17
|
+
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
18
|
+
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
19
|
+
const inputContentWrapperCva = UIStyle.useCva("input.contentWrapperCva", inputContentWrapper);
|
|
20
|
+
const typographyCva = UIStyle.useCva("typography.cva", typography);
|
|
21
|
+
const generatedInputId = useId();
|
|
22
|
+
const { ref, children, formFieldRef, labelProps: labelPropsProp, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel: hideLabelProp, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, actionContentPlacement = "content-wrapper", trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable: isClearableProp, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, id: idProp, inputClassName, contentClassName, contentWrapperClassName, wrapContentAndTrailing, labelPlacement = "content-wrapper", trailingClassName, onMouseEnter, onFocusCapture, variant: variantProp, as: asProp, size: sizeProp } = props;
|
|
23
|
+
const as = asProp ?? ui.input.as;
|
|
24
|
+
const size = sizeProp ?? ui.input.size;
|
|
25
|
+
const variant = variantProp ?? ui.input.variant;
|
|
26
|
+
const hideLabel = hideLabelProp ?? ui.input.hideLabel;
|
|
27
|
+
const hasClear = !!(isClearableProp ?? ui.input.isClearable);
|
|
28
|
+
const isLeadingIconElement = leadingIcon && isValidElement(leadingIcon);
|
|
29
|
+
const isTrailingIconElement = trailingIcon && isValidElement(trailingIcon);
|
|
30
|
+
const hasTrailingContent = hasClear || !!trailingContent || !!unit || !!isLoading || !!action || !!trailingIcon || !!trailingAction;
|
|
31
|
+
const isTrailingInteractive = !!action || !!trailingAction || !!isTrailingIconElement || hasClear && !!showClear || !!trailingContent;
|
|
32
|
+
const dataAttributeProps = getInputFrameDataAttributeProps(dataAttributes);
|
|
33
|
+
const baseLabelProps = headerProps?.labelProps ?? labelPropsProp;
|
|
34
|
+
const inputId = idProp ?? baseLabelProps?.htmlFor ?? `input-frame_${generatedInputId}`;
|
|
35
|
+
const labelProps = {
|
|
36
|
+
...baseLabelProps,
|
|
37
|
+
htmlFor: inputId
|
|
38
|
+
};
|
|
39
|
+
const formFieldProps = {
|
|
40
|
+
error,
|
|
41
|
+
label: label ?? "",
|
|
42
|
+
tooltipText,
|
|
43
|
+
helperText,
|
|
44
|
+
isRequired,
|
|
45
|
+
rightContent,
|
|
46
|
+
isHeaderHidden: isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
|
|
47
|
+
hideLabel,
|
|
48
|
+
isDisabled,
|
|
49
|
+
headerClassName,
|
|
50
|
+
errorClassName,
|
|
51
|
+
className
|
|
52
|
+
};
|
|
53
|
+
const resolvedHeaderProps = headerProps ? {
|
|
54
|
+
...headerProps,
|
|
55
|
+
labelProps
|
|
56
|
+
} : {
|
|
57
|
+
label: label ?? "",
|
|
58
|
+
tooltipText,
|
|
59
|
+
helperText,
|
|
60
|
+
isRequired,
|
|
61
|
+
rightContent,
|
|
62
|
+
isHeaderHidden: hideLabel || isHeaderHidden,
|
|
63
|
+
isDisabled,
|
|
64
|
+
className: headerClassName,
|
|
65
|
+
labelProps
|
|
66
|
+
};
|
|
67
|
+
const labelContent = as && ["filter", "floating"].includes(as) ? /* @__PURE__ */ jsx(FormFieldLabel, {
|
|
68
|
+
as,
|
|
69
|
+
size,
|
|
70
|
+
...resolvedHeaderProps
|
|
71
|
+
}) : null;
|
|
72
|
+
const resolvedContentWrapperClassName = contentWrapperClassName ?? inputContentWrapperCva({ as });
|
|
73
|
+
const contentRow = /* @__PURE__ */ jsxs("div", {
|
|
74
|
+
className: clsx("group/input-frame flex min-w-0 w-full items-center gap-input-gap-input-text-to-elements", as === "inline" && "h-full", inputSizeCva({
|
|
75
|
+
size,
|
|
76
|
+
as
|
|
77
|
+
}), typographySize && typographyCva({ size: typographySize }), contentClassName),
|
|
78
|
+
children: [
|
|
79
|
+
leadingContent,
|
|
80
|
+
leadingIcon && /* @__PURE__ */ jsx("div", {
|
|
81
|
+
className: clsx(!isLeadingIconElement && "pointer-events-none"),
|
|
82
|
+
children: renderIconVisual(leadingIcon)
|
|
83
|
+
}),
|
|
84
|
+
labelPlacement === "content-row" && labelContent,
|
|
85
|
+
actionContentPlacement === "content-row" && actionContent,
|
|
86
|
+
/* @__PURE__ */ jsxs("div", {
|
|
87
|
+
className: resolvedContentWrapperClassName,
|
|
88
|
+
children: [
|
|
89
|
+
labelPlacement === "content-wrapper" && labelContent,
|
|
90
|
+
actionContentPlacement === "content-wrapper" && actionContent,
|
|
91
|
+
typeof children === "function" ? children({
|
|
92
|
+
...dataAttributeProps,
|
|
93
|
+
id: inputId
|
|
94
|
+
}) : children
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
const trailingRow = hasTrailingContent ? /* @__PURE__ */ jsxs("div", {
|
|
100
|
+
className: clsx("flex items-center gap-input-gap-trailing-elements", inputSizeCva({
|
|
101
|
+
size,
|
|
102
|
+
as
|
|
103
|
+
}), !isTrailingInteractive && "pointer-events-none", trailingClassName),
|
|
104
|
+
children: [
|
|
105
|
+
hasClear && /* @__PURE__ */ jsx(InputClear, {
|
|
106
|
+
onClear: () => onClear?.(),
|
|
107
|
+
className: clearClassName,
|
|
108
|
+
show: !!showClear,
|
|
109
|
+
renderStatic
|
|
110
|
+
}),
|
|
111
|
+
trailingContent,
|
|
112
|
+
unit && /* @__PURE__ */ jsx("span", {
|
|
113
|
+
className: typographyCva({
|
|
114
|
+
size: "label-2",
|
|
115
|
+
sizeMobile: "label-2",
|
|
116
|
+
variant: "prominent-1",
|
|
117
|
+
className: "text-text-default-3"
|
|
118
|
+
}),
|
|
119
|
+
children: unit
|
|
120
|
+
}),
|
|
121
|
+
isLoading && /* @__PURE__ */ jsx("div", {
|
|
122
|
+
className: "inline-flex",
|
|
123
|
+
children: /* @__PURE__ */ jsx(Loader, {})
|
|
124
|
+
}),
|
|
125
|
+
!isLoading && action && /* @__PURE__ */ jsx(InlineIconButton, {
|
|
126
|
+
color: "secondary",
|
|
127
|
+
icon: action.icon,
|
|
128
|
+
isDisabled,
|
|
129
|
+
onPress: action.onClick,
|
|
130
|
+
excludeFromTabOrder: true,
|
|
131
|
+
label: action.altText,
|
|
132
|
+
className: clsx("border-0!", action.className)
|
|
133
|
+
}),
|
|
134
|
+
!isLoading && !action && trailingIcon && renderIconVisual(trailingIcon),
|
|
135
|
+
trailingAction
|
|
136
|
+
]
|
|
137
|
+
}) : null;
|
|
138
|
+
const inputFrameContent = wrapContentAndTrailing ? /* @__PURE__ */ jsxs("div", {
|
|
139
|
+
className: "flex w-full items-center gap-input-gap-input-text-to-elements",
|
|
140
|
+
children: [contentRow, trailingRow]
|
|
141
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [contentRow, trailingRow] });
|
|
142
|
+
return /* @__PURE__ */ jsx(TooltipWrapper, {
|
|
143
|
+
as,
|
|
144
|
+
error,
|
|
145
|
+
triggerTabIndex: as === "inline" ? -1 : void 0,
|
|
146
|
+
children: /* @__PURE__ */ jsx(FormField, {
|
|
147
|
+
...formFieldProps,
|
|
148
|
+
...dataAttributeProps,
|
|
149
|
+
ref: formFieldRef,
|
|
150
|
+
as,
|
|
151
|
+
labelProps,
|
|
152
|
+
tabIndex: as === "inline" ? -1 : void 0,
|
|
153
|
+
onMouseEnter: (event) => {
|
|
154
|
+
onMouseEnter?.(event);
|
|
155
|
+
if (renderStatic) onStaticInteract?.(false);
|
|
156
|
+
},
|
|
157
|
+
onFocusCapture: (event) => {
|
|
158
|
+
onFocusCapture?.(event);
|
|
159
|
+
if (renderStatic) onStaticInteract?.(true);
|
|
160
|
+
},
|
|
161
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
162
|
+
ref,
|
|
163
|
+
...dataAttributeProps,
|
|
164
|
+
className: clsx("relative flex cursor-text has-disabled:cursor-default", inputBaseCva({
|
|
165
|
+
variant,
|
|
166
|
+
as
|
|
167
|
+
}), inputClassName),
|
|
168
|
+
tabIndex: renderStatic ? isDisabled ? -1 : 0 : void 0,
|
|
169
|
+
onFocus: () => {
|
|
170
|
+
if (renderStatic) onStaticInteract?.(true);
|
|
171
|
+
},
|
|
172
|
+
onClick: () => {
|
|
173
|
+
if (renderStatic) onStaticInteract?.(true);
|
|
174
|
+
},
|
|
175
|
+
onPointerDown: () => {
|
|
176
|
+
if (renderStatic) onStaticInteract?.(true);
|
|
177
|
+
},
|
|
178
|
+
"data-rac": "",
|
|
179
|
+
children: inputFrameContent
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
var renderIconVisual = (icon) => {
|
|
185
|
+
if (isValidElement(icon)) return icon;
|
|
186
|
+
return /* @__PURE__ */ jsx(icon, { className: "size-6 text-interactive-text-secondary-idle" });
|
|
187
|
+
};
|
|
188
|
+
var getInputFrameDataAttributeProps = (dataAttributes) => ({
|
|
189
|
+
"data-is-empty": dataAttributes?.dataIsEmpty || void 0,
|
|
190
|
+
"data-is-filled": dataAttributes?.dataIsFilled || void 0,
|
|
191
|
+
"data-is-dirty": dataAttributes?.dataIsDirty || void 0,
|
|
192
|
+
"data-is-required": dataAttributes?.dataIsRequired || void 0,
|
|
193
|
+
"data-is-disabled": dataAttributes?.dataIsDisabled || void 0,
|
|
194
|
+
"data-disabled": dataAttributes?.dataDisabled || void 0,
|
|
195
|
+
"data-has-search": dataAttributes?.dataHasSearch || void 0,
|
|
196
|
+
"data-invalid": dataAttributes?.dataInvalid || void 0,
|
|
197
|
+
"data-has-selection": dataAttributes?.dataHasSelection || void 0
|
|
198
|
+
});
|
|
199
|
+
//#endregion
|
|
200
|
+
export { InputFrame };
|