@arun-dev/headless 4.10.0 → 4.11.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.
@@ -40,6 +40,7 @@ __export(index_parts_exports, {
40
40
  List: () => ComboboxList,
41
41
  Popup: () => ComboboxPopup,
42
42
  Root: () => ComboboxRoot,
43
+ Separator: () => ComboboxSeparator,
43
44
  Status: () => ComboboxStatus,
44
45
  Trigger: () => ComboboxTrigger,
45
46
  Value: () => ComboboxValue
@@ -341,7 +342,7 @@ function ComboboxRoot({
341
342
  (0, import_react3.useEffect)(() => {
342
343
  if (lastSelectedKeyRef.current === selectedKey) return;
343
344
  lastSelectedKeyRef.current = selectedKey;
344
- setInputValueState(selectedLabel);
345
+ setInputValue(selectedLabel, "value-change");
345
346
  }, [selectedKey]);
346
347
  const [chips, setChips] = (0, import_react3.useState)([]);
347
348
  const registerChip = (0, import_react3.useCallback)((entry) => {
@@ -831,7 +832,8 @@ function ComboboxClear({ className, children, render, ...rest }) {
831
832
  type: "button",
832
833
  tabIndex: -1,
833
834
  disabled: disabled || void 0,
834
- ...comboboxClearDataAttributes(selectedItems.length > 0),
835
+ // Nothing to clear while disabled: a disabled field hides it, as it has no effect.
836
+ ...comboboxClearDataAttributes(!disabled && selectedItems.length > 0),
835
837
  className,
836
838
  children,
837
839
  ref: elementRef,
@@ -1085,6 +1087,17 @@ function ComboboxGroupLabel({
1085
1087
  });
1086
1088
  }
1087
1089
 
1090
+ // src/combobox/ComboboxSeparator.tsx
1091
+ function ComboboxSeparator({ className, render, ...rest }) {
1092
+ useComboboxRootContext("Separator");
1093
+ return useRender({
1094
+ render,
1095
+ defaultTagName: "div",
1096
+ props: { "aria-hidden": true, className },
1097
+ consumerProps: rest
1098
+ });
1099
+ }
1100
+
1088
1101
  // src/combobox/ComboboxEmpty.tsx
1089
1102
  function ComboboxEmpty({ className, children, render, ...rest }) {
1090
1103
  const { filteredItems, loading } = useComboboxRootContext("Empty");
@@ -3,7 +3,9 @@ import { ReactNode, ReactElement, Ref, ComponentPropsWithRef } from 'react';
3
3
  import { A as AnchorSide, a as AnchorAlign } from '../anchoring-Btxi0QwC.cjs';
4
4
 
5
5
  /** Why a value, the input's text or the open state changed — the second callback argument. */
6
- type ComboboxChangeReason = 'input' | 'input-press' | 'trigger-press' | 'item-press' | 'keyboard' | 'clear' | 'chip-remove' | 'escape' | 'outside-press' | 'blur' | 'form-reset';
6
+ type ComboboxChangeReason = 'input' | 'input-press' | 'trigger-press' | 'item-press' | 'keyboard' | 'clear' | 'chip-remove' | 'escape' | 'outside-press' | 'blur' | 'form-reset'
7
+ /** The input's text followed a change of `value` — the parent's, not the user's. */
8
+ | 'value-change';
7
9
  type ComboboxChangeDetails = {
8
10
  reason: ComboboxChangeReason;
9
11
  };
@@ -182,7 +184,8 @@ type ComboboxClearProps = ComboboxClearOwnProps & Omit<ComponentPropsWithRef<'bu
182
184
  * Empties the input and the selection — every selected item, with `multiple`. Give it an
183
185
  * `aria-label`.
184
186
  *
185
- * `data-visible` is present while there is a selection to clear; style it hidden otherwise.
187
+ * `data-visible` is present while there is a selection to clear and the Root is not disabled;
188
+ * style it hidden otherwise.
186
189
  * Out of the tab order, and a press keeps focus in the input.
187
190
  */
188
191
  declare function ComboboxClear({ className, children, render, ...rest }: ComboboxClearProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
@@ -285,6 +288,23 @@ type ComboboxGroupLabelProps = ComboboxGroupLabelOwnProps & Omit<ComponentPropsW
285
288
  */
286
289
  declare function ComboboxGroupLabel({ className, children, render, ...rest }: ComboboxGroupLabelProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
287
290
 
291
+ type ComboboxSeparatorOwnProps = {
292
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
293
+ render?: ReactElement;
294
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
295
+ ref?: Ref<HTMLElement>;
296
+ };
297
+ type ComboboxSeparatorProps = ComboboxSeparatorOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxSeparatorOwnProps>;
298
+ /**
299
+ * A line between items or groups in the List, as an `<hr>` in a `<select>`. The arrow keys pass
300
+ * it.
301
+ *
302
+ * Visual only: `aria-hidden`, with no `role="separator"`. A listbox may own only options and
303
+ * groups, so a separator role inside one fails `aria-required-children`; a Group, named by its
304
+ * label, is what tells a screen reader where one set ends.
305
+ */
306
+ declare function ComboboxSeparator({ className, render, ...rest }: ComboboxSeparatorProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
307
+
288
308
  type ComboboxEmptyOwnProps = {
289
309
  /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
290
310
  render?: ReactElement;
@@ -362,7 +382,7 @@ type ComboboxValueProps<T = unknown> = {
362
382
  declare function ComboboxValue<T = unknown>({ children }: ComboboxValueProps<T>): react.JSX.Element;
363
383
 
364
384
  declare namespace index_parts {
365
- export { ComboboxChip as Chip, ComboboxChipRemove as ChipRemove, ComboboxClear as Clear, ComboboxEmpty as Empty, ComboboxGroup as Group, ComboboxGroupLabel as GroupLabel, ComboboxInput as Input, ComboboxInputGroup as InputGroup, ComboboxItem as Item, ComboboxList as List, ComboboxPopup as Popup, ComboboxRoot as Root, ComboboxStatus as Status, ComboboxTrigger as Trigger, ComboboxValue as Value };
385
+ export { ComboboxChip as Chip, ComboboxChipRemove as ChipRemove, ComboboxClear as Clear, ComboboxEmpty as Empty, ComboboxGroup as Group, ComboboxGroupLabel as GroupLabel, ComboboxInput as Input, ComboboxInputGroup as InputGroup, ComboboxItem as Item, ComboboxList as List, ComboboxPopup as Popup, ComboboxRoot as Root, ComboboxSeparator as Separator, ComboboxStatus as Status, ComboboxTrigger as Trigger, ComboboxValue as Value };
366
386
  }
367
387
 
368
388
  /**
@@ -373,4 +393,4 @@ declare namespace index_parts {
373
393
  */
374
394
  declare function defaultFilter<T>(items: readonly T[], query: string, itemToString: (item: T) => string): T[];
375
395
 
376
- export { index_parts as Combobox, type ComboboxAlign, type ComboboxChangeDetails, type ComboboxChangeReason, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxClearProps, type ComboboxEmptyProps, type ComboboxFilter, type ComboboxGroup$1 as ComboboxGroup, type ComboboxGroupLabelProps, type ComboboxGroupProps, type ComboboxHighlightDetails, type ComboboxHighlightReason, type ComboboxInputGroupProps, type ComboboxInputProps, type ComboboxItemProps, type ComboboxListProps, type ComboboxPopupProps, type ComboboxRootProps, type ComboboxSide, type ComboboxState, type ComboboxStatusProps, type ComboboxTriggerProps, type ComboboxValue$1 as ComboboxValue, type ComboboxValueProps, defaultFilter };
396
+ export { index_parts as Combobox, type ComboboxAlign, type ComboboxChangeDetails, type ComboboxChangeReason, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxClearProps, type ComboboxEmptyProps, type ComboboxFilter, type ComboboxGroup$1 as ComboboxGroup, type ComboboxGroupLabelProps, type ComboboxGroupProps, type ComboboxHighlightDetails, type ComboboxHighlightReason, type ComboboxInputGroupProps, type ComboboxInputProps, type ComboboxItemProps, type ComboboxListProps, type ComboboxPopupProps, type ComboboxRootProps, type ComboboxSeparatorProps, type ComboboxSide, type ComboboxState, type ComboboxStatusProps, type ComboboxTriggerProps, type ComboboxValue$1 as ComboboxValue, type ComboboxValueProps, defaultFilter };
@@ -3,7 +3,9 @@ import { ReactNode, ReactElement, Ref, ComponentPropsWithRef } from 'react';
3
3
  import { A as AnchorSide, a as AnchorAlign } from '../anchoring-Btxi0QwC.js';
4
4
 
5
5
  /** Why a value, the input's text or the open state changed — the second callback argument. */
6
- type ComboboxChangeReason = 'input' | 'input-press' | 'trigger-press' | 'item-press' | 'keyboard' | 'clear' | 'chip-remove' | 'escape' | 'outside-press' | 'blur' | 'form-reset';
6
+ type ComboboxChangeReason = 'input' | 'input-press' | 'trigger-press' | 'item-press' | 'keyboard' | 'clear' | 'chip-remove' | 'escape' | 'outside-press' | 'blur' | 'form-reset'
7
+ /** The input's text followed a change of `value` — the parent's, not the user's. */
8
+ | 'value-change';
7
9
  type ComboboxChangeDetails = {
8
10
  reason: ComboboxChangeReason;
9
11
  };
@@ -182,7 +184,8 @@ type ComboboxClearProps = ComboboxClearOwnProps & Omit<ComponentPropsWithRef<'bu
182
184
  * Empties the input and the selection — every selected item, with `multiple`. Give it an
183
185
  * `aria-label`.
184
186
  *
185
- * `data-visible` is present while there is a selection to clear; style it hidden otherwise.
187
+ * `data-visible` is present while there is a selection to clear and the Root is not disabled;
188
+ * style it hidden otherwise.
186
189
  * Out of the tab order, and a press keeps focus in the input.
187
190
  */
188
191
  declare function ComboboxClear({ className, children, render, ...rest }: ComboboxClearProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
@@ -285,6 +288,23 @@ type ComboboxGroupLabelProps = ComboboxGroupLabelOwnProps & Omit<ComponentPropsW
285
288
  */
286
289
  declare function ComboboxGroupLabel({ className, children, render, ...rest }: ComboboxGroupLabelProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
287
290
 
291
+ type ComboboxSeparatorOwnProps = {
292
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
293
+ render?: ReactElement;
294
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
295
+ ref?: Ref<HTMLElement>;
296
+ };
297
+ type ComboboxSeparatorProps = ComboboxSeparatorOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxSeparatorOwnProps>;
298
+ /**
299
+ * A line between items or groups in the List, as an `<hr>` in a `<select>`. The arrow keys pass
300
+ * it.
301
+ *
302
+ * Visual only: `aria-hidden`, with no `role="separator"`. A listbox may own only options and
303
+ * groups, so a separator role inside one fails `aria-required-children`; a Group, named by its
304
+ * label, is what tells a screen reader where one set ends.
305
+ */
306
+ declare function ComboboxSeparator({ className, render, ...rest }: ComboboxSeparatorProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
307
+
288
308
  type ComboboxEmptyOwnProps = {
289
309
  /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
290
310
  render?: ReactElement;
@@ -362,7 +382,7 @@ type ComboboxValueProps<T = unknown> = {
362
382
  declare function ComboboxValue<T = unknown>({ children }: ComboboxValueProps<T>): react.JSX.Element;
363
383
 
364
384
  declare namespace index_parts {
365
- export { ComboboxChip as Chip, ComboboxChipRemove as ChipRemove, ComboboxClear as Clear, ComboboxEmpty as Empty, ComboboxGroup as Group, ComboboxGroupLabel as GroupLabel, ComboboxInput as Input, ComboboxInputGroup as InputGroup, ComboboxItem as Item, ComboboxList as List, ComboboxPopup as Popup, ComboboxRoot as Root, ComboboxStatus as Status, ComboboxTrigger as Trigger, ComboboxValue as Value };
385
+ export { ComboboxChip as Chip, ComboboxChipRemove as ChipRemove, ComboboxClear as Clear, ComboboxEmpty as Empty, ComboboxGroup as Group, ComboboxGroupLabel as GroupLabel, ComboboxInput as Input, ComboboxInputGroup as InputGroup, ComboboxItem as Item, ComboboxList as List, ComboboxPopup as Popup, ComboboxRoot as Root, ComboboxSeparator as Separator, ComboboxStatus as Status, ComboboxTrigger as Trigger, ComboboxValue as Value };
366
386
  }
367
387
 
368
388
  /**
@@ -373,4 +393,4 @@ declare namespace index_parts {
373
393
  */
374
394
  declare function defaultFilter<T>(items: readonly T[], query: string, itemToString: (item: T) => string): T[];
375
395
 
376
- export { index_parts as Combobox, type ComboboxAlign, type ComboboxChangeDetails, type ComboboxChangeReason, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxClearProps, type ComboboxEmptyProps, type ComboboxFilter, type ComboboxGroup$1 as ComboboxGroup, type ComboboxGroupLabelProps, type ComboboxGroupProps, type ComboboxHighlightDetails, type ComboboxHighlightReason, type ComboboxInputGroupProps, type ComboboxInputProps, type ComboboxItemProps, type ComboboxListProps, type ComboboxPopupProps, type ComboboxRootProps, type ComboboxSide, type ComboboxState, type ComboboxStatusProps, type ComboboxTriggerProps, type ComboboxValue$1 as ComboboxValue, type ComboboxValueProps, defaultFilter };
396
+ export { index_parts as Combobox, type ComboboxAlign, type ComboboxChangeDetails, type ComboboxChangeReason, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxClearProps, type ComboboxEmptyProps, type ComboboxFilter, type ComboboxGroup$1 as ComboboxGroup, type ComboboxGroupLabelProps, type ComboboxGroupProps, type ComboboxHighlightDetails, type ComboboxHighlightReason, type ComboboxInputGroupProps, type ComboboxInputProps, type ComboboxItemProps, type ComboboxListProps, type ComboboxPopupProps, type ComboboxRootProps, type ComboboxSeparatorProps, type ComboboxSide, type ComboboxState, type ComboboxStatusProps, type ComboboxTriggerProps, type ComboboxValue$1 as ComboboxValue, type ComboboxValueProps, defaultFilter };
@@ -30,6 +30,7 @@ __export(index_parts_exports, {
30
30
  List: () => ComboboxList,
31
31
  Popup: () => ComboboxPopup,
32
32
  Root: () => ComboboxRoot,
33
+ Separator: () => ComboboxSeparator,
33
34
  Status: () => ComboboxStatus,
34
35
  Trigger: () => ComboboxTrigger,
35
36
  Value: () => ComboboxValue
@@ -247,7 +248,7 @@ function ComboboxRoot({
247
248
  useEffect(() => {
248
249
  if (lastSelectedKeyRef.current === selectedKey) return;
249
250
  lastSelectedKeyRef.current = selectedKey;
250
- setInputValueState(selectedLabel);
251
+ setInputValue(selectedLabel, "value-change");
251
252
  }, [selectedKey]);
252
253
  const [chips, setChips] = useState([]);
253
254
  const registerChip = useCallback((entry) => {
@@ -648,7 +649,8 @@ function ComboboxClear({ className, children, render, ...rest }) {
648
649
  type: "button",
649
650
  tabIndex: -1,
650
651
  disabled: disabled || void 0,
651
- ...comboboxClearDataAttributes(selectedItems.length > 0),
652
+ // Nothing to clear while disabled: a disabled field hides it, as it has no effect.
653
+ ...comboboxClearDataAttributes(!disabled && selectedItems.length > 0),
652
654
  className,
653
655
  children,
654
656
  ref: elementRef,
@@ -902,6 +904,17 @@ function ComboboxGroupLabel({
902
904
  });
903
905
  }
904
906
 
907
+ // src/combobox/ComboboxSeparator.tsx
908
+ function ComboboxSeparator({ className, render, ...rest }) {
909
+ useComboboxRootContext("Separator");
910
+ return useRender({
911
+ render,
912
+ defaultTagName: "div",
913
+ props: { "aria-hidden": true, className },
914
+ consumerProps: rest
915
+ });
916
+ }
917
+
905
918
  // src/combobox/ComboboxEmpty.tsx
906
919
  function ComboboxEmpty({ className, children, render, ...rest }) {
907
920
  const { filteredItems, loading } = useComboboxRootContext("Empty");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arun-dev/headless",
3
- "version": "4.10.0",
3
+ "version": "4.11.0",
4
4
  "description": "Unstyled React behaviour primitives — render engine, controlled/uncontrolled state, and data-* state projection. Ships no CSS and no class names.",
5
5
  "license": "MIT",
6
6
  "type": "module",