@povio/ui 0.0.9 → 0.1.0

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 (49) hide show
  1. package/dist/components/buttons/Button/Button.d.ts +3 -2
  2. package/dist/components/buttons/Button/Button.js +6 -1
  3. package/dist/components/buttons/IconButton/IconButton.d.ts +3 -2
  4. package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +3 -2
  5. package/dist/components/buttons/SplitButton/SplitButton.d.ts +3 -2
  6. package/dist/components/buttons/TextButton/TextButton.d.ts +3 -2
  7. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +53 -45
  8. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +86 -77
  9. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +63 -55
  10. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +46 -38
  11. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +1 -0
  12. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +1 -0
  13. package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +1 -1
  14. package/dist/components/inputs/Input/NumberInput/NumberInput.js +30 -21
  15. package/dist/components/inputs/Input/TextArea/TextArea.js +41 -32
  16. package/dist/components/inputs/Input/TextInput/TextInput.js +32 -40
  17. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +1 -0
  18. package/dist/components/inputs/Selection/shared/SelectBase.js +3 -1
  19. package/dist/components/inputs/Selection/shared/SelectDesktop.js +72 -60
  20. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  21. package/dist/components/inputs/Selection/shared/SelectInput.js +3 -0
  22. package/dist/components/inputs/Selection/shared/SelectInputTags.d.ts +2 -1
  23. package/dist/components/inputs/Selection/shared/SelectInputTags.js +43 -16
  24. package/dist/components/inputs/Selection/shared/SelectListBox.js +74 -55
  25. package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +1 -1
  26. package/dist/components/inputs/Selection/shared/SelectMobile.js +6 -2
  27. package/dist/components/inputs/shared/TooltipWrapper.d.ts +8 -0
  28. package/dist/components/inputs/shared/TooltipWrapper.js +21 -0
  29. package/dist/components/inputs/shared/label.cva.js +1 -1
  30. package/dist/components/overlays/Tooltip/Tooltip.d.ts +2 -1
  31. package/dist/components/overlays/Tooltip/Tooltip.js +12 -2
  32. package/dist/components/table/HeaderText.js +1 -1
  33. package/dist/components/table/table.cva.js +6 -6
  34. package/dist/components/text/Link/Link.d.ts +3 -1
  35. package/dist/components/text/Link/Link.js +7 -1
  36. package/dist/config/link.context.d.ts +10 -0
  37. package/dist/config/link.context.js +19 -0
  38. package/dist/config/uiConfig.context.d.ts +1 -1
  39. package/dist/config/uiConfig.context.js +2 -1
  40. package/dist/hooks/useTableNav.js +0 -15
  41. package/dist/index.d.ts +2 -4
  42. package/dist/index.js +3 -3
  43. package/dist/utils/vendor/acl/AclGuard.d.ts +5 -5
  44. package/dist/utils/vendor/acl/AclGuard.js +2 -3
  45. package/dist/utils/vendor/auth/auth.context.d.ts +2 -1
  46. package/dist/utils/vendor/auth/auth.context.js +2 -0
  47. package/package.json +1 -1
  48. package/dist/utils/vendor/auth/withPrivateAuthGuard.d.ts +0 -6
  49. package/dist/utils/vendor/auth/withPrivateAuthGuard.js +0 -17
@@ -92,6 +92,7 @@ const DatePickerInput = ({
92
92
  "data-hovered": isHovered || void 0,
93
93
  "data-disabled": isDisabled || void 0,
94
94
  "data-invalid": isInvalid || void 0,
95
+ "data-is-empty": fieldProps.value === null || void 0,
95
96
  "data-focus-within": isFocused || void 0,
96
97
  "data-focus-visible": isFocused && isFocusVisible || void 0,
97
98
  "data-has-selection": fieldProps.value !== null || void 0,
@@ -58,6 +58,7 @@ const TimePickerInput = ({
58
58
  "data-hovered": isHovered || void 0,
59
59
  "data-disabled": isDisabled || void 0,
60
60
  "data-invalid": isInvalid || void 0,
61
+ "data-is-empty": state.value === null || void 0,
61
62
  "data-focus-within": isFocused || void 0,
62
63
  "data-focus-visible": isFocused && isFocusVisible || void 0,
63
64
  "data-has-selection": state.value !== null || void 0,
@@ -70,7 +70,7 @@ const FileUploadContentEmpty = ({
70
70
  children: uploadText
71
71
  }
72
72
  ),
73
- !hideButton && browseText && (as === "link" ? /* @__PURE__ */ jsx(TextButton, { className: "[&>span>span]:!font-medium text-interactive-text-primary-idle lowercase", children: browseText }) : /* @__PURE__ */ jsx(
73
+ !hideButton && browseText && (as === "link" ? /* @__PURE__ */ jsx(TextButton, { className: "text-interactive-text-primary-idle lowercase", children: browseText }) : /* @__PURE__ */ jsx(
74
74
  Button,
75
75
  {
76
76
  variant: "outlined",
@@ -9,6 +9,7 @@ import { useNumberFieldState } from "react-stately";
9
9
  import { FormField } from "../../FormField/FormField.js";
10
10
  import { InputContent } from "../shared/InputContent.js";
11
11
  import { useInputCva } from "../../shared/input.cva.js";
12
+ import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
12
13
  import { UIConfig } from "../../../../config/uiConfig.context.js";
13
14
  const NumberInputBase = (props) => {
14
15
  const ui = UIConfig.useConfig();
@@ -93,33 +94,41 @@ const NumberInputBase = (props) => {
93
94
  labelProps
94
95
  };
95
96
  return /* @__PURE__ */ jsx(
96
- FormField,
97
+ TooltipWrapper,
97
98
  {
98
- ...formFieldProps,
99
99
  as,
100
- labelProps,
101
- className: clsx("group w-full", className),
100
+ error,
102
101
  children: /* @__PURE__ */ jsx(
103
- InputContent,
102
+ FormField,
104
103
  {
105
- ...inputContentProps,
106
- headerProps,
104
+ ...formFieldProps,
107
105
  as,
108
- size,
109
- children: (style) => /* @__PURE__ */ jsx(
110
- Input,
106
+ labelProps,
107
+ className: clsx("group w-full", className),
108
+ children: /* @__PURE__ */ jsx(
109
+ InputContent,
111
110
  {
112
- ...inputProps,
113
- ref,
114
- placeholder: as === "floating" ? "" : inputProps.placeholder,
115
- className: inputCva({
116
- variant,
117
- as,
118
- size,
119
- ...rest,
120
- className: inputClassName
121
- }),
122
- style
111
+ ...inputContentProps,
112
+ headerProps,
113
+ as,
114
+ size,
115
+ children: (style) => /* @__PURE__ */ jsx(
116
+ Input,
117
+ {
118
+ ...inputProps,
119
+ ref,
120
+ "data-is-empty": value === null || value === void 0 || void 0,
121
+ placeholder: as === "floating" ? "" : inputProps.placeholder,
122
+ className: inputCva({
123
+ variant,
124
+ as,
125
+ size,
126
+ ...rest,
127
+ className: inputClassName
128
+ }),
129
+ style
130
+ }
131
+ )
123
132
  }
124
133
  )
125
134
  }
@@ -9,6 +9,7 @@ import { FormField } from "../../FormField/FormField.js";
9
9
  import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
10
10
  import { InputClear } from "../../shared/InputClear.js";
11
11
  import { useInputCva, inputSize } from "../../shared/input.cva.js";
12
+ import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
12
13
  import { UIConfig } from "../../../../config/uiConfig.context.js";
13
14
  import { UIStyle } from "../../../../config/uiStyle.context.js";
14
15
  const TextAreaBase = (props) => {
@@ -77,41 +78,49 @@ const TextAreaBase = (props) => {
77
78
  };
78
79
  const showClear = isClearable && !!value;
79
80
  return /* @__PURE__ */ jsx(
80
- FormField,
81
+ TooltipWrapper,
81
82
  {
82
- ...formFieldProps,
83
83
  as,
84
- labelProps,
85
- className: clsx("w-full", className),
86
- children: /* @__PURE__ */ jsxs(
87
- "div",
84
+ error,
85
+ children: /* @__PURE__ */ jsx(
86
+ FormField,
88
87
  {
89
- className: "group/text-area relative h-full",
90
- "data-text-area": true,
91
- children: [
92
- as === "floating" && headerProps && /* @__PURE__ */ jsx(
93
- FormFieldLabel,
94
- {
95
- as,
96
- ...headerProps
97
- }
98
- ),
99
- /* @__PURE__ */ jsx(
100
- TextArea$1,
101
- {
102
- ...inputProps,
103
- placeholder: as === "floating" ? "" : inputProps.placeholder,
104
- className: inputCva({
105
- variant,
106
- as,
107
- ...rest,
108
- className: clsx("block h-full min-h-8", inputClassName)
109
- }),
110
- ref
111
- }
112
- ),
113
- showClear && /* @__PURE__ */ jsx("span", { className: clsx("absolute top-0 right-0", inputSizeCva({ size: "default" })), children: /* @__PURE__ */ jsx(InputClear, { onClear: () => onChange?.("") }) })
114
- ]
88
+ ...formFieldProps,
89
+ as,
90
+ labelProps,
91
+ className: clsx("w-full", className),
92
+ children: /* @__PURE__ */ jsxs(
93
+ "div",
94
+ {
95
+ className: "group/text-area relative h-full",
96
+ "data-text-area": true,
97
+ children: [
98
+ as === "floating" && headerProps && /* @__PURE__ */ jsx(
99
+ FormFieldLabel,
100
+ {
101
+ as,
102
+ ...headerProps
103
+ }
104
+ ),
105
+ /* @__PURE__ */ jsx(
106
+ TextArea$1,
107
+ {
108
+ ...inputProps,
109
+ "data-is-empty": value?.trim() === "" || value === null || value === void 0 || void 0,
110
+ placeholder: as === "floating" ? "" : inputProps.placeholder,
111
+ className: inputCva({
112
+ variant,
113
+ as,
114
+ ...rest,
115
+ className: clsx("block h-full min-h-8", inputClassName)
116
+ }),
117
+ ref
118
+ }
119
+ ),
120
+ showClear && /* @__PURE__ */ jsx("span", { className: clsx("absolute top-0 right-0", inputSizeCva({ size: "default" })), children: /* @__PURE__ */ jsx(InputClear, { onClear: () => onChange?.("") }) })
121
+ ]
122
+ }
123
+ )
115
124
  }
116
125
  )
117
126
  }
@@ -8,24 +8,8 @@ import { Controller } from "react-hook-form";
8
8
  import { FormField } from "../../FormField/FormField.js";
9
9
  import { InputContent } from "../shared/InputContent.js";
10
10
  import { useInputCva } from "../../shared/input.cva.js";
11
- import { Tooltip } from "../../../overlays/Tooltip/Tooltip.js";
11
+ import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
12
12
  import { UIConfig } from "../../../../config/uiConfig.context.js";
13
- const TooltipWrapper = (props) => {
14
- if (props.as !== "inline") {
15
- return props.children;
16
- }
17
- return /* @__PURE__ */ jsx(
18
- Tooltip,
19
- {
20
- text: props.error || void 0,
21
- placement: "bottom",
22
- color: "error",
23
- hidden: !props.error,
24
- isNonInteractiveTrigger: true,
25
- children: /* @__PURE__ */ jsx("div", { children: props.children })
26
- }
27
- );
28
- };
29
13
  const TextInputBase = (props) => {
30
14
  const ui = UIConfig.useConfig();
31
15
  const inputCva = useInputCva();
@@ -105,40 +89,48 @@ const TextInputBase = (props) => {
105
89
  className: headerClassName,
106
90
  labelProps
107
91
  };
108
- return /* @__PURE__ */ jsx(TooltipWrapper, { ...props, children: /* @__PURE__ */ jsx(
109
- FormField,
92
+ return /* @__PURE__ */ jsx(
93
+ TooltipWrapper,
110
94
  {
111
- ...formFieldProps,
112
95
  as,
113
- labelProps,
114
- className: clsx(
115
- "group w-full",
116
- {
117
- "h-full": as === "inline"
118
- },
119
- className
120
- ),
96
+ error,
121
97
  children: /* @__PURE__ */ jsx(
122
- InputContent,
98
+ FormField,
123
99
  {
124
- ...inputContentProps,
125
- headerProps,
100
+ ...formFieldProps,
126
101
  as,
127
- size,
128
- children: (style) => /* @__PURE__ */ jsx(
129
- Input,
102
+ labelProps,
103
+ className: clsx(
104
+ "group w-full",
130
105
  {
131
- ...inputProps,
132
- ref,
133
- placeholder: as === "floating" ? "" : inputProps.placeholder,
134
- className: inputCva({ variant, as, size, ...rest, className: inputClassName }),
135
- style
106
+ "h-full": as === "inline"
107
+ },
108
+ className
109
+ ),
110
+ children: /* @__PURE__ */ jsx(
111
+ InputContent,
112
+ {
113
+ ...inputContentProps,
114
+ headerProps,
115
+ as,
116
+ size,
117
+ children: (style) => /* @__PURE__ */ jsx(
118
+ Input,
119
+ {
120
+ ...inputProps,
121
+ ref,
122
+ "data-is-empty": value === "" || value === null || value === void 0 || void 0,
123
+ placeholder: as === "floating" ? "" : inputProps.placeholder,
124
+ className: inputCva({ variant, as, size, ...rest, className: inputClassName }),
125
+ style
126
+ }
127
+ )
136
128
  }
137
129
  )
138
130
  }
139
131
  )
140
132
  }
141
- ) });
133
+ );
142
134
  };
143
135
  const TextInput = (props) => {
144
136
  if ("formControl" in props && props.formControl) {
@@ -18,6 +18,7 @@ export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = Default
18
18
  containerClassName?: string;
19
19
  customTrigger?: ReactElement;
20
20
  selectedTagsType?: "tags" | "list";
21
+ collapseAfter?: number;
21
22
  onInputChange?: (value: string) => void;
22
23
  onSearchChange?: (value: string) => void;
23
24
  mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
@@ -15,7 +15,9 @@ const SelectBase = (dProps) => {
15
15
  hideLabel: dProps.hideLabel ?? ui.input.hideLabel,
16
16
  isClearable: dProps.isClearable ?? ui.input.isClearable,
17
17
  isSearchable: dProps.isSearchable ?? ui.select.isSearchable,
18
- selectedTagsType: dProps.selectedTagsType ?? ui.select.selectedTagsType
18
+ selectedTagsType: dProps.selectedTagsType ?? ui.select.selectedTagsType,
19
+ ignoreTriggerWidth: dProps.virtualizerOptions || dProps.items.length > 100 ? false : dProps.ignoreTriggerWidth ?? false,
20
+ collapseAfter: dProps.collapseAfter ?? ui.select.collapseAfter
19
21
  };
20
22
  const isDesktop = useBreakpoint("md");
21
23
  return /* @__PURE__ */ jsx(SelectContext.Provider, { ...props, children: isDesktop ? /* @__PURE__ */ jsx(SelectDesktop, { ...props }) : /* @__PURE__ */ jsx(SelectMobile, { ...props }) });
@@ -10,6 +10,7 @@ import { SelectInput } from "./SelectInput.js";
10
10
  import { SelectListBox } from "./SelectListBox.js";
11
11
  import { SelectContext } from "./select.context.js";
12
12
  import { SelectAllItemId } from "./useSelectItems.js";
13
+ import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
13
14
  const SelectDesktop = ({
14
15
  ref,
15
16
  error,
@@ -40,7 +41,9 @@ const SelectDesktop = ({
40
41
  isClearable,
41
42
  isLoading,
42
43
  as,
43
- size
44
+ size,
45
+ collapseAfter,
46
+ selectedTagsType
44
47
  } = props;
45
48
  const formFieldProps = {
46
49
  error,
@@ -139,72 +142,81 @@ const SelectDesktop = ({
139
142
  () => listItems.filter((item) => !item.isSelectAllItem).length > 0 || isLoading,
140
143
  [listItems, isLoading]
141
144
  );
142
- return /* @__PURE__ */ jsx(WrapperComponent, { ...isSearchable ? comboBoxProps : {}, children: /* @__PURE__ */ jsxs(
143
- FormField,
145
+ return /* @__PURE__ */ jsx(
146
+ TooltipWrapper,
144
147
  {
145
- ...formFieldProps,
146
- ...!isSearchable && {
147
- labelProps,
148
- className: clsx("w-full", containerClassName)
149
- },
150
148
  as,
151
- ref: wrapperRef,
152
- children: [
153
- customTrigger ? /* @__PURE__ */ jsx(DialogTrigger, { ...dialogTriggerProps, children: /* @__PURE__ */ jsx(
154
- "div",
155
- {
156
- ...fieldProps,
157
- ref: mergeRefs(ref, triggerRef),
158
- children: customTrigger
159
- }
160
- ) }) : /* @__PURE__ */ jsx(
161
- SelectInput,
162
- {
163
- ref: mergeRefs(ref, triggerRef),
164
- placeholder,
165
- variant,
166
- as,
167
- size,
168
- isDisabled,
169
- isInvalid: !!error,
170
- className,
171
- hideDropdownIcon,
172
- isSearchable,
173
- isClearable,
174
- showSelectionContent,
175
- inputClassName,
176
- onBlur,
177
- onCloseComboBox: (state) => {
178
- if (isSearchable) {
179
- closeComboBoxRef.current = state;
149
+ error,
150
+ children: /* @__PURE__ */ jsx(WrapperComponent, { ...isSearchable ? comboBoxProps : {}, children: /* @__PURE__ */ jsxs(
151
+ FormField,
152
+ {
153
+ ...formFieldProps,
154
+ ...!isSearchable && {
155
+ labelProps,
156
+ className: clsx("w-full", containerClassName)
157
+ },
158
+ as,
159
+ ref: wrapperRef,
160
+ children: [
161
+ customTrigger ? /* @__PURE__ */ jsx(DialogTrigger, { ...dialogTriggerProps, children: /* @__PURE__ */ jsx(
162
+ "div",
163
+ {
164
+ ...fieldProps,
165
+ ref: mergeRefs(ref, triggerRef),
166
+ children: customTrigger
167
+ }
168
+ ) }) : /* @__PURE__ */ jsx(
169
+ SelectInput,
170
+ {
171
+ ref: mergeRefs(ref, triggerRef),
172
+ placeholder,
173
+ variant,
174
+ as,
175
+ size,
176
+ isDisabled,
177
+ isInvalid: !!error,
178
+ className,
179
+ hideDropdownIcon,
180
+ isSearchable,
181
+ isClearable,
182
+ showSelectionContent,
183
+ inputClassName,
184
+ collapseAfter,
185
+ selectedTagsType,
186
+ onBlur,
187
+ onCloseComboBox: (state) => {
188
+ if (isSearchable) {
189
+ closeComboBoxRef.current = state;
190
+ }
191
+ },
192
+ fieldProps,
193
+ headerProps
180
194
  }
181
- },
182
- fieldProps,
183
- headerProps
184
- }
185
- ),
186
- (!isSearchable || showPopover) && /* @__PURE__ */ jsx(
187
- Popover,
188
- {
189
- triggerRef,
190
- isOpen,
191
- onOpenChange: setIsOpen,
192
- className: "my-4 outline-none",
193
- style: { width: !ignoreTriggerWidth ? width : void 0 },
194
- offset: 0,
195
- children: /* @__PURE__ */ jsx(
196
- SelectListBox,
195
+ ),
196
+ (!isSearchable || showPopover) && /* @__PURE__ */ jsx(
197
+ Popover,
197
198
  {
198
- ...props,
199
- className: "max-h-80 rounded-list-rounding-dropdown border border-elevation-outline-default-1 bg-elevation-fill-default-1 shadow-5 [scrollbar-width:thin]",
200
- autoFocus: !isSearchable
199
+ triggerRef,
200
+ isOpen,
201
+ onOpenChange: setIsOpen,
202
+ className: "my-4 outline-none",
203
+ style: { width: !ignoreTriggerWidth ? width : void 0 },
204
+ offset: 0,
205
+ children: /* @__PURE__ */ jsx(
206
+ SelectListBox,
207
+ {
208
+ ...props,
209
+ className: "max-h-80 rounded-list-rounding-dropdown border border-elevation-outline-default-1 bg-elevation-fill-default-1 shadow-5 [scrollbar-width:thin]",
210
+ autoFocus: !isSearchable
211
+ }
212
+ )
201
213
  }
202
214
  )
203
- }
204
- )
205
- ]
215
+ ]
216
+ }
217
+ ) })
206
218
  }
207
- ) });
219
+ );
208
220
  };
209
221
  export {
210
222
  SelectDesktop
@@ -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"> {
7
+ interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter"> {
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, onCloseComboBox, onBlur, ...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, onCloseComboBox, onBlur, ...props }: SelectInputProps) => import("react/jsx-runtime").JSX.Element;
15
15
  export {};
@@ -31,6 +31,7 @@ const SelectInput = ({
31
31
  fieldProps,
32
32
  headerProps,
33
33
  selectedTagsType,
34
+ collapseAfter,
34
35
  onCloseComboBox,
35
36
  onBlur,
36
37
  ...props
@@ -113,6 +114,7 @@ const SelectInput = ({
113
114
  "data-has-selection": !isEmpty || void 0,
114
115
  "data-has-search": fieldState.searchValue !== "" || void 0,
115
116
  "data-invalid": isInvalid || void 0,
117
+ "data-is-empty": isEmpty || void 0,
116
118
  ...hoverProps,
117
119
  ...focusWithinProps,
118
120
  children: [
@@ -137,6 +139,7 @@ const SelectInput = ({
137
139
  {
138
140
  selectedItems,
139
141
  isDisabled,
142
+ collapseAfter,
140
143
  selectedTagsType,
141
144
  onRemove
142
145
  }
@@ -5,7 +5,8 @@ interface SelectInputTagsProps {
5
5
  selectedItems: SelectItem[];
6
6
  isDisabled: SelectBaseProps["isDisabled"];
7
7
  selectedTagsType: SelectBaseProps["selectedTagsType"];
8
+ collapseAfter?: SelectBaseProps["collapseAfter"];
8
9
  onRemove: (id: Key) => void;
9
10
  }
10
- export declare const SelectInputTags: ({ selectedItems, isDisabled, selectedTagsType, onRemove }: SelectInputTagsProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const SelectInputTags: ({ selectedItems, isDisabled, selectedTagsType, collapseAfter, onRemove, }: SelectInputTagsProps) => import("react/jsx-runtime").JSX.Element;
11
12
  export {};
@@ -1,21 +1,48 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
2
3
  import { Tag } from "../../../text/Tag/Tag.js";
3
- const SelectInputTags = ({ selectedItems, isDisabled, selectedTagsType, onRemove }) => {
4
- if (selectedTagsType !== "tags") {
5
- return /* @__PURE__ */ jsx("p", { children: selectedItems.map((item) => item.label).join(", ") });
4
+ const SelectInputTags = ({
5
+ selectedItems,
6
+ isDisabled,
7
+ selectedTagsType,
8
+ collapseAfter,
9
+ onRemove
10
+ }) => {
11
+ const { displayedItems, remainingCount } = useMemo(() => {
12
+ if (!collapseAfter || selectedItems.length <= collapseAfter) {
13
+ return { displayedItems: selectedItems, remainingCount: 0 };
14
+ }
15
+ return {
16
+ displayedItems: selectedItems.slice(0, collapseAfter - 1),
17
+ remainingCount: selectedItems.length - (collapseAfter - 1)
18
+ };
19
+ }, [selectedItems, collapseAfter]);
20
+ if (selectedTagsType === "tags") {
21
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
22
+ displayedItems.map((item) => /* @__PURE__ */ jsx(
23
+ Tag,
24
+ {
25
+ dismissable: true,
26
+ isDisabled,
27
+ onDismiss: () => onRemove(item.id),
28
+ excludeFromTabOrder: true,
29
+ className: "z-1",
30
+ children: item.label
31
+ },
32
+ item.id
33
+ )),
34
+ remainingCount > 0 && /* @__PURE__ */ jsx(
35
+ Tag,
36
+ {
37
+ isDisabled,
38
+ excludeFromTabOrder: true,
39
+ children: `+${remainingCount} more`
40
+ },
41
+ "remaining-count"
42
+ )
43
+ ] });
6
44
  }
7
- return /* @__PURE__ */ jsx(Fragment, { children: selectedItems.map((item) => /* @__PURE__ */ jsx(
8
- Tag,
9
- {
10
- dismissable: true,
11
- isDisabled,
12
- onDismiss: () => onRemove(item.id),
13
- excludeFromTabOrder: true,
14
- className: "z-1",
15
- children: item.label
16
- },
17
- item.id
18
- )) });
45
+ return /* @__PURE__ */ jsx("p", { children: selectedItems.map((item) => item.label).join(", ") });
19
46
  };
20
47
  export {
21
48
  SelectInputTags