@vygruppen/spor-react 12.8.3 → 12.8.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
3
  "type": "module",
4
- "version": "12.8.3",
4
+ "version": "12.8.5",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -24,7 +24,6 @@ export type ComboboxProps<T> = Exclude<
24
24
  leftIcon?: ReactNode;
25
25
  rightIcon?: ReactNode;
26
26
  variant?: "core" | "floating";
27
- children?: React.ReactNode;
28
27
  };
29
28
  /**
30
29
  * A combobox is a combination of an input and a list of suggestions.
@@ -76,6 +75,17 @@ export const Combobox = (props: ComboboxProps<object>) => {
76
75
  inputRef: externalInputRef,
77
76
  children,
78
77
  variant,
78
+ allowsEmptyCollection,
79
+ onSelectionChange,
80
+ inputValue,
81
+ onInputChange,
82
+ menuTrigger,
83
+ allowsCustomValue,
84
+ onFocusChange,
85
+ defaultInputValue,
86
+ defaultItems,
87
+ defaultSelectedKey,
88
+ onOpenChange,
79
89
  ...restProps
80
90
  } = props;
81
91
  const { contains } = useFilter({ sensitivity: "base" });
@@ -85,13 +95,24 @@ export const Combobox = (props: ComboboxProps<object>) => {
85
95
  const listBoxRef = useRef<HTMLUListElement>(null);
86
96
  const popoverRef = useRef(null);
87
97
 
88
- const listboxId = `${useId()}-listbox`;
98
+ const listboxId = useId();
89
99
 
90
100
  const inputWidth = useInputWidth(inputRef);
91
101
 
92
102
  const state = useComboBoxState({
93
103
  defaultFilter: contains,
94
104
  shouldCloseOnBlur: true,
105
+ allowsEmptyCollection,
106
+ onSelectionChange,
107
+ inputValue,
108
+ onInputChange,
109
+ menuTrigger,
110
+ allowsCustomValue,
111
+ onFocusChange,
112
+ defaultInputValue,
113
+ defaultItems,
114
+ defaultSelectedKey,
115
+ onOpenChange,
95
116
  ...props,
96
117
  });
97
118
 
@@ -110,22 +131,34 @@ export const Combobox = (props: ComboboxProps<object>) => {
110
131
  paddingLeft,
111
132
  paddingX,
112
133
  paddingY,
113
- leftIcon,
114
134
  };
115
135
 
116
- const {
117
- inputProps: { ...inputProps },
118
- listBoxProps,
119
- } = useComboBox(
136
+ const { inputProps, listBoxProps } = useComboBox(
120
137
  {
121
138
  ...props,
122
139
  inputRef,
123
140
  listBoxRef,
124
141
  popoverRef,
125
142
  label,
143
+ onSelectionChange,
144
+ inputValue,
145
+ onInputChange,
146
+ menuTrigger,
147
+ allowsCustomValue,
148
+ onFocusChange,
149
+ defaultInputValue,
150
+ defaultItems,
151
+ defaultSelectedKey,
152
+ onOpenChange,
126
153
  },
127
154
  state,
128
155
  );
156
+
157
+ // Remove aria-labelledby and id from inputProps, as these are handled by the Input component
158
+ // This prevents potential conflicts or duplication of accessibility attributes
159
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
160
+ const { "aria-labelledby": _, id: __, ...filteredInputProps } = inputProps;
161
+
129
162
  return (
130
163
  <>
131
164
  <Input
@@ -151,7 +184,7 @@ export const Combobox = (props: ComboboxProps<object>) => {
151
184
  state.isOpen && !loading ? 0 : borderBottomRightRadius
152
185
  }
153
186
  _active={{ backgroundColor: "core.surface.active" }}
154
- {...inputProps}
187
+ {...filteredInputProps}
155
188
  startElement={leftIcon}
156
189
  endElement={
157
190
  loading ? (
@@ -215,6 +248,7 @@ Combobox.displayName = "Combobox";
215
248
 
216
249
  const useInputWidth = (inputRef: React.RefObject<HTMLInputElement>) => {
217
250
  const [inputWidth, setInputWidth] = useState("auto");
251
+
218
252
  useEffect(() => {
219
253
  const onResize = debounce(() => {
220
254
  if (inputRef.current) {