@bento/listbox 0.1.3 → 0.2.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.
- package/README.md +34 -26
- package/README.mdx +34 -26
- package/dist/index.cjs +16 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -20
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/header.tsx +3 -3
- package/src/listbox-item.tsx +3 -3
- package/src/listbox-section.tsx +23 -27
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ export function DynamicCollectionExample({ items, ...args }: any) {
|
|
|
120
120
|
|
|
121
121
|
In this pattern, `children` is called for each item in the `items` array, receiving the individual item data to render `ListBoxItem` components.
|
|
122
122
|
|
|
123
|
-
### When no `items` prop is provided
|
|
123
|
+
### When no `items` prop is provided
|
|
124
124
|
When you don't provide an `items` prop but use `children` as a function, it follows **Bento's render prop pattern** and receives an object with render props:
|
|
125
125
|
|
|
126
126
|
```tsx
|
|
@@ -173,42 +173,50 @@ The ListBox components provide extensive customization options through data attr
|
|
|
173
173
|
|
|
174
174
|
### Styling with Data Attributes
|
|
175
175
|
|
|
176
|
-
All ListBox components expose their internal state through
|
|
176
|
+
All ListBox components expose their internal state through data attributes,
|
|
177
|
+
enabling CSS-based styling without JavaScript. This follows Bento's design
|
|
178
|
+
philosophy of returning styling control to CSS.
|
|
177
179
|
|
|
178
180
|
#### ListBox Container Attributes
|
|
179
181
|
|
|
180
182
|
The main `ListBox` component exposes these data attributes:
|
|
181
183
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
184
|
+
| Attribute | Description | Example Values |
|
|
185
|
+
| ---------------------------- | ------------------------------------------------- | ----------------------------- |
|
|
186
|
+
| `data-empty` | Applied when the listbox contains no items | "true" |
|
|
187
|
+
| `data-focused` | Applied when the listbox is focused | "true" |
|
|
188
|
+
| `data-focus-visible` | Applied when the listbox has keyboard focus | "true" |
|
|
189
|
+
| `data-layout` | The layout type | "stack" |
|
|
190
|
+
| `data-orientation` | The primary orientation | "vertical" / "horizontal" |
|
|
191
|
+
| `data-selection-mode` | The selection mode | "none" / "single" / "multiple"|
|
|
192
|
+
| `data-selection-behavior` | How selection behaves | "toggle" / "replace" |
|
|
193
|
+
| `data-allows-tab-navigation` | Whether tab navigation is enabled | "true" |
|
|
194
|
+
| `data-focus-wrap` | Whether focus wraps around the collection | "true" |
|
|
191
195
|
|
|
192
196
|
#### ListBoxItem Attributes
|
|
193
197
|
|
|
194
198
|
Individual `ListBoxItem` components expose these data attributes:
|
|
195
199
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
| Attribute | Description | Example Values |
|
|
201
|
+
| ------------------------ | ------------------------------------------ | ----------------------------- |
|
|
202
|
+
| `data-selected` | Applied when the item is selected | "true" |
|
|
203
|
+
| `data-disabled` | Applied when the item is disabled | "true" |
|
|
204
|
+
| `data-hovered` | Applied when the item is being hovered | "true" |
|
|
205
|
+
| `data-focused` | Applied when the item is focused | "true" |
|
|
206
|
+
| `data-focus-visible` | Applied when the item has keyboard focus | "true" |
|
|
207
|
+
| `data-pressed` | Applied when the item is being pressed | "true" |
|
|
208
|
+
| `data-level` | The nesting level (useful for indentation) | "0" / "1" / "2" |
|
|
209
|
+
| `data-selection-mode` | Inherited selection mode | "none" / "single" / "multiple"|
|
|
210
|
+
| `data-selection-behavior`| Inherited selection behavior | "toggle" / "replace" |
|
|
211
|
+
| `data-text-value` | The computed text value for the item | "Item text" |
|
|
206
212
|
|
|
207
213
|
#### ListBoxSection Attributes
|
|
208
214
|
|
|
209
215
|
The `ListBoxSection` component exposes:
|
|
210
216
|
|
|
211
|
-
|
|
217
|
+
| Attribute | Description | Example Values |
|
|
218
|
+
| ------------ | -------------------------------- | --------------- |
|
|
219
|
+
| `data-level` | The nesting level of the section | "0" / "1" / "2" |
|
|
212
220
|
|
|
213
221
|
#### CSS Styling Examples
|
|
214
222
|
|
|
@@ -389,12 +397,12 @@ const slots = {
|
|
|
389
397
|
'my-listbox.fruits.header': ({ original, props }) => (
|
|
390
398
|
<Header {...props}>🍎 {original}</Header>
|
|
391
399
|
),
|
|
392
|
-
|
|
400
|
+
|
|
393
401
|
// Override a specific item in a specific section
|
|
394
402
|
'my-listbox.fruits.apple': ({ original }) => (
|
|
395
403
|
<div className="special-item">⭐ {original}</div>
|
|
396
404
|
),
|
|
397
|
-
|
|
405
|
+
|
|
398
406
|
// Override an entire section
|
|
399
407
|
'my-listbox.vegetables': ({ original }) => (
|
|
400
408
|
<div className="veggie-section">{original}</div>
|
|
@@ -473,7 +481,7 @@ Customize the appearance when no items are present:
|
|
|
473
481
|
All components support standard ARIA attributes for enhanced accessibility:
|
|
474
482
|
|
|
475
483
|
```tsx
|
|
476
|
-
<ListBox
|
|
484
|
+
<ListBox
|
|
477
485
|
aria-label="Food menu"
|
|
478
486
|
aria-describedby="menu-description"
|
|
479
487
|
>
|
|
@@ -496,7 +504,7 @@ const StyledListBox = styled.div`
|
|
|
496
504
|
&[data-focused] {
|
|
497
505
|
box-shadow: 0 0 0 2px blue;
|
|
498
506
|
}
|
|
499
|
-
|
|
507
|
+
|
|
500
508
|
[role="option"][data-selected] {
|
|
501
509
|
background: ${props => props.theme.primary};
|
|
502
510
|
}
|
package/README.mdx
CHANGED
|
@@ -57,7 +57,7 @@ When you provide an `items` prop, the `children` function receives **individual
|
|
|
57
57
|
|
|
58
58
|
In this pattern, `children` is called for each item in the `items` array, receiving the individual item data to render `ListBoxItem` components.
|
|
59
59
|
|
|
60
|
-
### When no `items` prop is provided
|
|
60
|
+
### When no `items` prop is provided
|
|
61
61
|
When you don't provide an `items` prop but use `children` as a function, it follows **Bento's render prop pattern** and receives an object with render props:
|
|
62
62
|
|
|
63
63
|
```tsx
|
|
@@ -86,42 +86,50 @@ The ListBox components provide extensive customization options through data attr
|
|
|
86
86
|
|
|
87
87
|
### Styling with Data Attributes
|
|
88
88
|
|
|
89
|
-
All ListBox components expose their internal state through
|
|
89
|
+
All ListBox components expose their internal state through data attributes,
|
|
90
|
+
enabling CSS-based styling without JavaScript. This follows Bento's design
|
|
91
|
+
philosophy of returning styling control to CSS.
|
|
90
92
|
|
|
91
93
|
#### ListBox Container Attributes
|
|
92
94
|
|
|
93
95
|
The main `ListBox` component exposes these data attributes:
|
|
94
96
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
| Attribute | Description | Example Values |
|
|
98
|
+
| ---------------------------- | ------------------------------------------------- | ----------------------------- |
|
|
99
|
+
| `data-empty` | Applied when the listbox contains no items | "true" |
|
|
100
|
+
| `data-focused` | Applied when the listbox is focused | "true" |
|
|
101
|
+
| `data-focus-visible` | Applied when the listbox has keyboard focus | "true" |
|
|
102
|
+
| `data-layout` | The layout type | "stack" |
|
|
103
|
+
| `data-orientation` | The primary orientation | "vertical" / "horizontal" |
|
|
104
|
+
| `data-selection-mode` | The selection mode | "none" / "single" / "multiple"|
|
|
105
|
+
| `data-selection-behavior` | How selection behaves | "toggle" / "replace" |
|
|
106
|
+
| `data-allows-tab-navigation` | Whether tab navigation is enabled | "true" |
|
|
107
|
+
| `data-focus-wrap` | Whether focus wraps around the collection | "true" |
|
|
104
108
|
|
|
105
109
|
#### ListBoxItem Attributes
|
|
106
110
|
|
|
107
111
|
Individual `ListBoxItem` components expose these data attributes:
|
|
108
112
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
| Attribute | Description | Example Values |
|
|
114
|
+
| ------------------------ | ------------------------------------------ | ----------------------------- |
|
|
115
|
+
| `data-selected` | Applied when the item is selected | "true" |
|
|
116
|
+
| `data-disabled` | Applied when the item is disabled | "true" |
|
|
117
|
+
| `data-hovered` | Applied when the item is being hovered | "true" |
|
|
118
|
+
| `data-focused` | Applied when the item is focused | "true" |
|
|
119
|
+
| `data-focus-visible` | Applied when the item has keyboard focus | "true" |
|
|
120
|
+
| `data-pressed` | Applied when the item is being pressed | "true" |
|
|
121
|
+
| `data-level` | The nesting level (useful for indentation) | "0" / "1" / "2" |
|
|
122
|
+
| `data-selection-mode` | Inherited selection mode | "none" / "single" / "multiple"|
|
|
123
|
+
| `data-selection-behavior`| Inherited selection behavior | "toggle" / "replace" |
|
|
124
|
+
| `data-text-value` | The computed text value for the item | "Item text" |
|
|
119
125
|
|
|
120
126
|
#### ListBoxSection Attributes
|
|
121
127
|
|
|
122
128
|
The `ListBoxSection` component exposes:
|
|
123
129
|
|
|
124
|
-
|
|
130
|
+
| Attribute | Description | Example Values |
|
|
131
|
+
| ------------ | -------------------------------- | --------------- |
|
|
132
|
+
| `data-level` | The nesting level of the section | "0" / "1" / "2" |
|
|
125
133
|
|
|
126
134
|
#### CSS Styling Examples
|
|
127
135
|
|
|
@@ -199,12 +207,12 @@ const slots = {
|
|
|
199
207
|
'my-listbox.fruits.header': ({ original, props }) => (
|
|
200
208
|
<Header {...props}>🍎 {original}</Header>
|
|
201
209
|
),
|
|
202
|
-
|
|
210
|
+
|
|
203
211
|
// Override a specific item in a specific section
|
|
204
212
|
'my-listbox.fruits.apple': ({ original }) => (
|
|
205
213
|
<div className="special-item">⭐ {original}</div>
|
|
206
214
|
),
|
|
207
|
-
|
|
215
|
+
|
|
208
216
|
// Override an entire section
|
|
209
217
|
'my-listbox.vegetables': ({ original }) => (
|
|
210
218
|
<div className="veggie-section">{original}</div>
|
|
@@ -283,7 +291,7 @@ Customize the appearance when no items are present:
|
|
|
283
291
|
All components support standard ARIA attributes for enhanced accessibility:
|
|
284
292
|
|
|
285
293
|
```tsx
|
|
286
|
-
<ListBox
|
|
294
|
+
<ListBox
|
|
287
295
|
aria-label="Food menu"
|
|
288
296
|
aria-describedby="menu-description"
|
|
289
297
|
>
|
|
@@ -306,7 +314,7 @@ const StyledListBox = styled.div`
|
|
|
306
314
|
&[data-focused] {
|
|
307
315
|
box-shadow: 0 0 0 2px blue;
|
|
308
316
|
}
|
|
309
|
-
|
|
317
|
+
|
|
310
318
|
[role="option"][data-selected] {
|
|
311
319
|
background: ${props => props.theme.primary};
|
|
312
320
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ var React4__default = /*#__PURE__*/_interopDefault(React4);
|
|
|
17
17
|
var HeaderContext = React4.createContext({});
|
|
18
18
|
var BentoHeaderImpl = slots.withSlots(
|
|
19
19
|
"BentoHeader",
|
|
20
|
-
|
|
20
|
+
function BentoHeader(props, ref) {
|
|
21
21
|
const { props: processedProps, apply } = useProps.useProps(props);
|
|
22
22
|
const contextProps = React4.useContext(HeaderContext);
|
|
23
23
|
const appliedUserProps = apply(processedProps);
|
|
@@ -27,29 +27,26 @@ var BentoHeaderImpl = slots.withSlots(
|
|
|
27
27
|
// User props take precedence over context
|
|
28
28
|
};
|
|
29
29
|
return /* @__PURE__ */ React4__default.default.createElement("header", { ...composed, ref: contextProps.ref || ref }, processedProps.children);
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
31
|
);
|
|
32
32
|
function HeaderWrapper(props, ref) {
|
|
33
33
|
return /* @__PURE__ */ React4__default.default.createElement(BentoHeaderImpl, { ...props, ref });
|
|
34
34
|
}
|
|
35
35
|
var HeaderBase = collections.createLeafComponent("header", HeaderWrapper);
|
|
36
36
|
var Header = HeaderBase;
|
|
37
|
-
var BentoListBoxSectionImpl = slots.withSlots(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return /* @__PURE__ */ React4__default.default.createElement("section", { ...composed, ref }, /* @__PURE__ */ React4__default.default.createElement(HeaderContext.Provider, { value: { ...headingProps, ref: headingRef } }, title && /* @__PURE__ */ React4__default.default.createElement("div", { ...headingProps }, title), sectionContent));
|
|
51
|
-
})
|
|
52
|
-
);
|
|
37
|
+
var BentoListBoxSectionImpl = slots.withSlots("BentoListBoxSection", function BentoListBoxSectionImpl2({ __node, children, title: titleProp, ...rest }, ref) {
|
|
38
|
+
const { props, apply } = useProps.useProps(rest);
|
|
39
|
+
const data = useDataAttributes.useDataAttributes({ level: __node?.level });
|
|
40
|
+
const headingRef = React4.useRef(null);
|
|
41
|
+
const title = titleProp ?? props.title ?? __node?.rendered;
|
|
42
|
+
const { groupProps, headingProps } = reactAria.useListBoxSection({
|
|
43
|
+
heading: title,
|
|
44
|
+
"aria-label": props["aria-label"]
|
|
45
|
+
});
|
|
46
|
+
const composed = reactAria.mergeProps(apply({ ...data, ...props }, ["children", "title", "slot"]), groupProps);
|
|
47
|
+
const sectionContent = children || props.children;
|
|
48
|
+
return /* @__PURE__ */ React4__default.default.createElement("section", { ...composed, ref }, /* @__PURE__ */ React4__default.default.createElement(HeaderContext.Provider, { value: { ...headingProps, ref: headingRef } }, title && /* @__PURE__ */ React4__default.default.createElement("div", { ...headingProps }, title), sectionContent));
|
|
49
|
+
});
|
|
53
50
|
function ListBoxSectionWrapper(props, ref, section) {
|
|
54
51
|
return /* @__PURE__ */ React4__default.default.createElement(BentoListBoxSectionImpl, { ...props, __node: section, ref });
|
|
55
52
|
}
|
|
@@ -363,7 +360,7 @@ var ListBoxItemImplComponent = function ListBoxItemImplComponent2({ __node, ...p
|
|
|
363
360
|
};
|
|
364
361
|
return /* @__PURE__ */ React4__default.default.createElement(TextContext.Provider, { value: textContext }, React4__default.default.createElement(ElementType, finalAttributes, content));
|
|
365
362
|
};
|
|
366
|
-
var ListBoxItemImpl = slots.withSlots("BentoListBoxItem",
|
|
363
|
+
var ListBoxItemImpl = slots.withSlots("BentoListBoxItem", ListBoxItemImplComponent);
|
|
367
364
|
function ListBoxItemComponent(props, forwardedRef, item) {
|
|
368
365
|
return /* @__PURE__ */ React4__default.default.createElement(ListBoxItemImpl, { ...props, ref: forwardedRef, __node: item });
|
|
369
366
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/header.tsx","../src/listbox-section.tsx","../src/utils.ts","../src/listbox.tsx","../src/listbox-item.tsx"],"names":["createContext","withSlots","forwardRef","useProps","useContext","React","createLeafComponent","BentoListBoxSectionImpl","useDataAttributes","useRef","useListBoxSection","mergeProps","createBranchComponent","ListBoxSectionInner","CollectionRendererContext","useEffect","useListState","useMemo","ListKeyboardDelegate","ListBoxInner","useLocale","useCollator","useListBox","useFocusRing","FocusScope","CollectionBuilder","AriaCollection","StandaloneListBox","ListBoxItemImplComponent","useOption","useHover"],"mappings":";;;;;;;;;;;;;;;;AA2CO,IAAM,aAAA,GAAgBA,oBAAA,CAAkC,EAAE;AASjE,IAAM,eAAA,GAAkBC,eAAA;AAAA,EACtB,aAAA;AAAA,EACAC,iBAAA,CAAW,SAAS,WAAA,CAAY,KAAA,EAAyB,GAAA,EAAsC;AAC7F,IAAA,MAAM,EAAE,KAAA,EAAO,cAAA,EAAgB,KAAA,EAAM,GAAIC,kBAAS,KAAK,CAAA;AACvD,IAAA,MAAM,YAAA,GAAeC,kBAAW,aAAa,CAAA;AAG7C,IAAA,MAAM,gBAAA,GAAmB,MAAM,cAAc,CAAA;AAE7C,IAAA,MAAM,QAAA,GAAW;AAAA,MACf,GAAG,YAAA;AAAA,MACH,GAAG;AAAA;AAAA,KACL;AAEA,IAAA,uBACEC,uBAAA,CAAA,aAAA,CAAC,YAAQ,GAAG,QAAA,EAAU,KAAK,YAAA,CAAa,GAAA,IAAO,GAAA,EAAA,EAC5C,cAAA,CAAe,QAClB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OA,IAAM,eAAA,GAAkBC,+BAAAA,CAAoB,MAAA,EAAQ,oBAAoB,CAAA;AAcjE,IAAM,WAAA,GAAc","file":"index.cjs","sourcesContent":["import React, { forwardRef, createContext, useContext } from 'react';\nimport { createLeafComponent } from '@react-aria/collections';\nimport { useProps } from '@bento/use-props';\nimport { withSlots, type Slots } from '@bento/slots';\n\n/**\n * Props for the Header component.\n * @interface HeaderProps\n */\nexport interface HeaderProps extends Slots, React.ComponentProps<'header'> {\n /**\n * The children of the header.\n */\n readonly children?: React.ReactNode;\n}\n\n/**\n * Context value structure for Header components.\n * Extends HTML attributes to support all standard header element properties.\n * @interface HeaderContextValue\n */\ninterface HeaderContextValue extends React.HTMLAttributes<HTMLElement> {\n /**\n * Reference to the header element for forwarding.\n */\n readonly ref?: React.RefObject<HTMLDivElement>;\n}\n\n/**\n * Combined props type for the internal BentoHeader implementation.\n * Merges Header-specific props with standard HTML attributes to provide\n * a comprehensive interface for the internal header component.\n *\n * @type BentoHeaderProps\n * @internal\n */\ntype BentoHeaderProps = HeaderProps & React.HTMLAttributes<HTMLElement>;\n\n/**\n * React context for providing header-related attributes and refs to Header components.\n * Used internally by ListBoxSection to pass heading props to Header elements.\n * @public\n */\nexport const HeaderContext = createContext<HeaderContextValue>({});\n\n/**\n * Internal implementation of the BentoHeader component with slots support.\n * This component handles prop processing and context integration.\n * It merges props from useProps and HeaderContext while preserving styling props.\n *\n * @internal\n */\nconst BentoHeaderImpl = withSlots(\n 'BentoHeader',\n forwardRef(function BentoHeader(props: BentoHeaderProps, ref: React.ForwardedRef<HTMLElement>) {\n const { props: processedProps, apply } = useProps(props);\n const contextProps = useContext(HeaderContext);\n\n // Apply user props directly (preserves className, style, etc.)\n const appliedUserProps = apply(processedProps);\n\n const composed = {\n ...contextProps,\n ...appliedUserProps // User props take precedence over context\n };\n\n return (\n <header {...composed} ref={contextProps.ref || ref}>\n {processedProps.children}\n </header>\n );\n })\n);\n\n/**\n * Wrapper component that connects the BentoHeaderImpl to React Aria's collection system.\n * This function serves as an adapter between the createLeafComponent system and\n * the internal BentoHeaderImpl component, ensuring proper prop forwarding and ref handling.\n *\n * @param {HeaderProps} props - Header component props\n * @param {React.ReactNode} [props.children] - React children to render inside the header\n * @param {React.ForwardedRef<HTMLElement>} ref - Forwarded ref to the header element\n * @returns {React.ReactElement} The BentoHeaderImpl component with forwarded props and ref\n * @internal\n */\nfunction HeaderWrapper(props: HeaderProps, ref: React.ForwardedRef<HTMLElement>) {\n return <BentoHeaderImpl {...props} ref={ref} />;\n}\n\n/**\n * A Header represents a heading for a section within a ListBox.\n * Uses React Aria's createLeafComponent for automatic collection handling.\n *\n * @component\n * @param {HeaderProps} props - The props for the Header component\n * @param {React.ForwardedRef<HTMLElement>} ref - Forwarded ref to the header element\n * @returns {JSX.Element} A header element with proper accessibility attributes\n *\n * @example\n * ```tsx\n * <Header>My Section Title</Header>\n * ```\n * @public\n */\n/**\n * Base Header component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state and\n * integrates with the collection rendering system.\n * @internal\n */\nconst HeaderBase = createLeafComponent('header', HeaderWrapper);\n\n/**\n * A Header component for section headings within a ListBox.\n * Provides semantic header structure with proper accessibility attributes\n * and integrates with React Aria's collection system for automatic handling.\n *\n * This is the main public interface for creating headers in ListBox sections.\n * It automatically receives heading props from the parent ListBoxSection via HeaderContext.\n *\n * @component\n * @example\n * ```tsx\n * <ListBoxSection>\n * <Header>Fruits</Header>\n * <ListBoxItem>Apple</ListBoxItem>\n * <ListBoxItem>Banana</ListBoxItem>\n * </ListBoxSection>\n * ```\n * @public\n */\nexport const Header = HeaderBase as React.ForwardRefExoticComponent<HeaderProps & React.RefAttributes<HTMLElement>>;\n","import React, { forwardRef, useRef, useContext } from 'react';\nimport { useListBoxSection, mergeProps } from 'react-aria';\nimport { createBranchComponent } from '@react-aria/collections';\nimport { CollectionRendererContext } from 'react-aria-components';\nimport type { Node } from '@react-types/shared';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport { HeaderContext } from './header';\nimport { ListStateContext } from './listbox';\n\n/**\n * Props for the ListBoxSection component.\n * @interface ListBoxSectionProps\n */\nexport interface ListBoxSectionProps extends Omit<React.ComponentProps<'section'>, 'title'> {\n /**\n * A slot name for the component. Used by Bento's slot system.\n */\n readonly slot?: string;\n /**\n * The title of the section.\n */\n readonly title?: React.ReactNode;\n /**\n * The children of the section.\n */\n readonly children?: React.ReactNode;\n}\n\n/**\n * Internal props interface for BentoListBoxSectionImpl component.\n * Extends ListBoxSectionProps with internal React Aria node data and allows\n * additional properties for flexibility in prop handling.\n *\n * @interface BentoListBoxSectionImplProps\n * @template T - The type of the section node data\n * @internal\n */\ninterface BentoListBoxSectionImplProps<T = unknown> extends ListBoxSectionProps {\n readonly __node?: Node<T>;\n readonly [key: string]: unknown;\n}\n\n/**\n * Props interface for the ListBoxSectionInner component.\n * Contains the React Aria section node that represents this section\n * in the collection hierarchy for dynamic rendering.\n *\n * @interface ListBoxSectionInnerProps\n * @internal\n */\ninterface ListBoxSectionInnerProps {\n readonly section: Node<unknown>;\n}\n\n/**\n * Internal implementation of the BentoListBoxSection component with slots support.\n * This component handles the core logic for rendering a section within a ListBox,\n * including title rendering, accessibility attributes, and child content management.\n * It integrates with React Aria's useListBoxSection hook for proper ARIA compliance.\n *\n * @internal\n */\nconst BentoListBoxSectionImpl = withSlots(\n 'BentoListBoxSection',\n forwardRef(function BentoListBoxSectionImpl<T>(\n { __node, children, title: titleProp, ...rest }: BentoListBoxSectionImplProps<T>,\n ref: React.ForwardedRef<HTMLElement>\n ) {\n const { props, apply } = useProps(rest);\n const data = useDataAttributes({ level: __node?.level });\n const headingRef = useRef<HTMLDivElement>(null);\n\n const title = titleProp ?? props.title ?? __node?.rendered;\n const { groupProps, headingProps } = useListBoxSection({\n heading: title,\n 'aria-label': props['aria-label']\n });\n\n const composed = mergeProps(apply({ ...data, ...props }, ['children', 'title', 'slot']), groupProps);\n\n const sectionContent = children || props.children;\n\n return (\n <section {...composed} ref={ref}>\n <HeaderContext.Provider value={{ ...headingProps, ref: headingRef }}>\n {title && <div {...headingProps}>{title}</div>}\n {sectionContent}\n </HeaderContext.Provider>\n </section>\n );\n })\n);\n\n/**\n * Wrapper component that connects BentoListBoxSectionImpl to React Aria's collection system.\n * This function serves as an adapter between createBranchComponent and the internal\n * BentoListBoxSectionImpl, ensuring proper prop forwarding and node injection for sections.\n *\n * @template T - The type of the section node data\n * @param {ListBoxSectionProps} props - ListBoxSection component props\n * @param {string} [props.slot] - Slot name for Bento's slot system\n * @param {React.ReactNode} [props.title] - Title for the section\n * @param {React.ReactNode} [props.children] - Children to render in the section\n * @param {string} [props.aria-label] - ARIA label for accessibility\n * @param {React.ForwardedRef<HTMLElement>} ref - Ref forwarded from the collection system\n * @param {Node<T>} section - React Aria node containing section metadata and collection info\n * @returns {React.ReactElement} The BentoListBoxSectionImpl component with proper node and ref wiring\n * @internal\n */\n/* v8 ignore start */\nfunction ListBoxSectionWrapper<T extends object>(\n props: ListBoxSectionProps,\n ref: React.ForwardedRef<HTMLElement>,\n section: Node<T>\n) {\n return <BentoListBoxSectionImpl {...props} __node={section} ref={ref} />;\n}\n/* v8 ignore stop */\n\n/**\n * Base ListBoxSection component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state and\n * manages the branch structure for nested items.\n * @internal\n */\nconst ListBoxSectionBase = createBranchComponent('section', ListBoxSectionWrapper);\n\n/**\n * Internal component for rendering dynamic collection sections.\n * This component is used specifically for sections that are part of a dynamic collection,\n * connecting to the ListStateContext and CollectionRendererContext to properly render\n * nested items through React Aria's collection system.\n *\n * @component\n * @param {object} props - The component props containing the section node\n * @param {Node<unknown>} props.section - The React Aria node representing this section in the collection\n * @throws {BentoError} Throws an error if used outside of a ListBox context\n * @returns {React.ReactElement} JSX element representing a dynamically rendered listbox section\n * @internal\n */\nexport const ListBoxSectionInner: React.FC<ListBoxSectionInnerProps> = function ListBoxSectionInner({ section }) {\n const state = useContext(ListStateContext);\n const { CollectionBranch } = useContext(CollectionRendererContext);\n\n return (\n <BentoListBoxSectionImpl {...section.props} __node={section}>\n {CollectionBranch && state?.collection ? (\n <CollectionBranch collection={state.collection} parent={section} />\n ) : null}\n </BentoListBoxSectionImpl>\n );\n};\n\n/**\n * A section component for organizing related items within a ListBox.\n *\n * @component\n * @example\n * ```tsx\n * <ListBoxSection title=\"Fruits\">\n * <ListBoxItem>Apple</ListBoxItem>\n * <ListBoxItem>Banana</ListBoxItem>\n * </ListBoxSection>\n * ```\n * @public\n */\nexport const ListBoxSection = ListBoxSectionBase as <_T extends object>(\n props: ListBoxSectionProps & { children?: React.ReactNode }\n) => React.ReactElement;\n","/* v8 ignore next */\nimport React, { type ForwardedRef, useEffect, useRef } from 'react';\n\n/**\n * NOTE: This utility will be moved to the new use-collection package.\n * Safe wrapper for React Aria's useObjectRef that handles test environments where refs are not extensible.\n *\n * **Critical for Vitest Browser Mode Testing**: When running tests in Vitest's browser mode with Playwright,\n * the test environment can freeze or make objects non-extensible. React Aria's `useObjectRef` attempts to\n * dynamically add properties to ref objects, which fails with \"Cannot add property current, object is not extensible\"\n * in these constrained test environments.\n *\n * **Technical Details:**\n * - Vitest browser mode uses Playwright's Chrome DevTools Protocol for test execution\n * - The V8 engine's security model can freeze objects during test isolation\n * - React Aria's useObjectRef uses `Object.defineProperty()` to add reactive properties to refs\n * - This conflicts with frozen objects in browser testing scenarios\n *\n * **Why This Solution Works:**\n * - Creates an internal ref that's always mutable (created in our controlled environment)\n * - Safely forwards values to the external ref using try/catch for frozen object scenarios\n * - Maintains the same ref forwarding behavior as React Aria's useObjectRef in normal environments\n * - Gracefully degrades in test environments without breaking functionality\n *\n * **Production Impact**: Zero. Object freezing only occurs in specific test configurations.\n * In production and development, this behaves identically to React Aria's useObjectRef.\n *\n * @template T - The type of the ref element\n * @param {React.ForwardedRef<T>} ref - The forwarded ref to handle safely\n * @returns {React.RefObject<T>} A safe ref object that works in all environments including frozen test contexts\n * @public\n */\nexport function useSafeObjectRef<T>(ref: ForwardedRef<T>): React.RefObject<T> {\n const internalRef = useRef<T>(null);\n\n useEffect(function updateForwardedRef() {\n const current = internalRef.current;\n\n if (typeof ref === 'function') {\n ref(current);\n } else if (ref && 'current' in ref) {\n try {\n (ref as React.MutableRefObject<T | null>).current = current;\n /* v8 ignore start */\n } catch {\n //\n // Silently ignore errors in test environments where objects might be frozen.\n // This specifically handles Vitest browser mode with Playwright where the V8 engine\n // may freeze ref objects during test isolation, preventing dynamic property assignment.\n //\n }\n /* v8 ignore stop */\n }\n });\n\n return internalRef;\n}\n","import React, { createContext, useContext, useMemo, ForwardedRef, RefObject } from 'react';\nimport {\n FocusScope,\n mergeProps,\n useCollator,\n useLocale,\n useListBox,\n useFocusRing,\n ListKeyboardDelegate\n} from 'react-aria';\nimport { ListState, SelectionBehavior, useListState, Orientation, Node } from 'react-stately';\nimport { CollectionBuilder, Collection as AriaCollection } from '@react-aria/collections';\nimport { AriaListBoxProps } from '@react-types/listbox';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots, Slots } from '@bento/slots';\nimport { ListBoxItemImpl } from './listbox-item';\nimport { ListBoxSectionInner } from './listbox-section';\nimport { useSafeObjectRef } from './utils';\n\n/**\n * Render props provided to ListBox render functions and empty state renderers.\n * @interface ListBoxRenderProps\n */\nexport interface ListBoxRenderProps {\n /**\n * Whether the listbox has no items and should display its empty state.\n * @selector [data-empty]\n */\n readonly isEmpty: boolean;\n /**\n * Whether the listbox is currently focused.\n * @selector [data-focused]\n */\n readonly isFocused: boolean;\n /**\n * Whether the listbox is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n readonly isFocusVisible: boolean;\n /**\n * Whether the listbox is currently the active drop target.\n * @selector [data-drop-target]\n */\n readonly isDropTarget: boolean;\n /**\n * Whether the items are arranged in a stack or grid.\n * @selector [data-layout=\"stack | grid\"]\n */\n readonly layout?: 'stack' | 'grid';\n /**\n * State of the listbox.\n */\n readonly state: ListState<unknown>;\n /**\n * The items array when using dynamic collections.\n */\n readonly items?: Iterable<unknown>;\n}\n\n/**\n * Props for the ListBox component.\n * @interface ListBoxProps\n * @template T The type of items in the collection\n */\nexport interface ListBoxProps<T>\n extends Omit<AriaListBoxProps<T>, 'label' | 'children'>,\n Omit<React.ComponentProps<'div'>, keyof AriaListBoxProps<T> | 'children'>,\n Slots {\n /**\n * How multiple selection should behave in the collection.\n */\n readonly selectionBehavior?: SelectionBehavior;\n /**\n * Provides content to display when there are no items in the list.\n */\n readonly renderEmptyState?: (props: ListBoxRenderProps) => React.ReactNode;\n /**\n * Whether the items are arranged in a stack layout.\n * @default 'stack'\n */\n readonly layout?: 'stack';\n /**\n * The primary orientation of the items. Usually this is the direction that the collection scrolls.\n * @default 'vertical'\n */\n readonly orientation?: Orientation;\n /**\n * Static children or render function for the ListBox.\n * When items prop is provided, children receives individual items for React Aria compatibility.\n * When no items prop is provided, children receives Bento render props { isEmpty, isFocused, state, etc. }.\n */\n readonly children?:\n | React.ReactNode\n | ((item: T) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n}\n\n/**\n * React context for sharing ListBox state across components.\n * This context provides the ListBox state to child components like ListBoxItem and ListBoxSection,\n * enabling them to access selection state, collection data, and other shared functionality.\n *\n * @context\n * @internal\n */\nconst ListStateContext = createContext<ListState<unknown> | null>(null);\n\n/**\n * Custom hook to manage ListBox state creation and context handling.\n * This hook either uses an existing state from context or creates a new one.\n * It's designed to work both as a standalone component and within a parent component\n * that provides ListBox state through context.\n *\n * @param {Record<string, unknown>} props - Configuration object for the ListBox state\n * @returns {object} An object containing the state instance and context state flag\n * @returns {ListState<unknown>} returns.state - The ListBox state instance\n * @returns {ListState<unknown> | null} returns.contextState - Existing context state, if any\n * @internal\n */\nfunction useListBoxState(props: Record<string, unknown>) {\n const contextState = useContext(ListStateContext);\n\n const stateProps = {\n ...props,\n children: undefined,\n items: undefined\n };\n\n const state = contextState ?? useListState(stateProps);\n\n return { state, contextState };\n}\n\n/**\n * Renders content with optional context provider wrapper.\n * If no context state exists, wraps the content in a ListStateContext.Provider.\n * This allows the ListBox to work both standalone and as part of a larger component tree.\n *\n * @param {React.ReactNode} content - The React content to render\n * @param {ListState<unknown>} state - The ListBox state to provide via context\n * @param {ListState<unknown> | null} contextState - Existing context state, if any\n * @returns {React.ReactNode} The content, optionally wrapped in a context provider\n * @internal\n */\nfunction renderWithOptionalContext(\n content: React.ReactNode,\n state: ListState<unknown>,\n contextState: ListState<unknown> | null\n): React.ReactNode {\n /* v8 ignore next */\n return contextState ? content : <ListStateContext.Provider value={state}>{content}</ListStateContext.Provider>;\n}\n\n/**\n * Creates and memoizes a keyboard delegate for the ListBox.\n * The keyboard delegate handles keyboard navigation logic, including\n * arrow key navigation, home/end keys, and type-ahead functionality.\n *\n * @param {object} config - Configuration object for the keyboard delegate\n * @param {ListState<unknown>['collection']} config.collection - The collection of items in the ListBox\n * @param {Intl.Collator} config.collator - Intl collator for string comparison in type-ahead\n * @param {React.RefObject<HTMLDivElement>} config.listBoxRef - Reference to the ListBox DOM element\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager from the state\n * @param {'stack' | 'grid'} [config.layout] - Layout mode (stack or grid)\n * @param {Orientation} [config.orientation] - Primary orientation of the items\n * @param {'ltr' | 'rtl'} config.direction - Text direction (ltr or rtl)\n * @param {ListKeyboardDelegate<unknown>} [config.keyboardDelegate] - Custom keyboard delegate to use instead of default\n * @returns {ListKeyboardDelegate<unknown>} A keyboard delegate instance for handling keyboard interactions\n * @internal\n */\nfunction useKeyboardDelegate({\n collection,\n collator,\n listBoxRef,\n selectionManager,\n layout,\n orientation,\n direction,\n keyboardDelegate: providedDelegate\n}: {\n readonly collection: ListState<unknown>['collection'];\n readonly collator: Intl.Collator;\n readonly listBoxRef: React.RefObject<HTMLDivElement>;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly layout?: 'stack' | 'grid';\n readonly orientation?: Orientation;\n readonly direction: 'ltr' | 'rtl';\n readonly keyboardDelegate?: ListKeyboardDelegate<unknown>;\n}): ListKeyboardDelegate<unknown> {\n const { disabledBehavior, disabledKeys } = selectionManager;\n\n return useMemo(\n function createKeyboardDelegate() {\n return (\n providedDelegate ||\n new ListKeyboardDelegate({\n collection,\n collator,\n ref: listBoxRef,\n disabledKeys,\n disabledBehavior,\n layout,\n orientation,\n direction\n })\n );\n },\n [collection, collator, listBoxRef, selectionManager, orientation, direction, layout, providedDelegate]\n );\n}\n\n/**\n * Generates data attributes for the ListBox element based on its current state.\n * These attributes are used for styling selectors and accessibility indicators.\n *\n * @param {object} config - Configuration object containing ListBox state flags\n * @param {boolean} config.isEmpty - Whether the listbox has no items\n * @param {boolean} config.isFocused - Whether the listbox is currently focused\n * @param {boolean} config.isFocusVisible - Whether focus should be visually indicated\n * @param {'stack' | 'grid'} [config.layout] - Layout mode (stack or grid)\n * @param {Orientation} [config.orientation] - Primary orientation of the items\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager containing selection state\n * @param {boolean} [config.allowsTabNavigation] - Whether tab navigation is enabled\n * @param {boolean} [config.shouldFocusWrap] - Whether focus wraps at boundaries\n * @param {SelectionBehavior} [config.originalSelectionBehavior] - Original selection behavior setting\n * @returns {Record<string, unknown>} Object with data attributes for the ListBox element\n * @internal\n */\nfunction useListBoxDataAttributes({\n isEmpty,\n isFocused,\n isFocusVisible,\n layout,\n orientation,\n selectionManager,\n allowsTabNavigation,\n shouldFocusWrap,\n originalSelectionBehavior\n}: {\n readonly isEmpty: boolean;\n readonly isFocused: boolean;\n readonly isFocusVisible: boolean;\n readonly layout?: 'stack' | 'grid';\n readonly orientation?: Orientation;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly allowsTabNavigation?: boolean;\n readonly shouldFocusWrap?: boolean;\n readonly originalSelectionBehavior?: SelectionBehavior;\n}) {\n return useDataAttributes({\n empty: isEmpty,\n focused: isFocused,\n 'focus-visible': isFocusVisible,\n layout,\n orientation,\n 'selection-mode': selectionManager.selectionMode !== 'none' ? selectionManager.selectionMode : undefined,\n 'selection-behavior': originalSelectionBehavior !== undefined ? selectionManager.selectionBehavior : undefined,\n 'allows-tab-navigation': allowsTabNavigation,\n 'focus-wrap': shouldFocusWrap\n });\n}\n\n/**\n * Composes all props for the ListBox element including DOM props, ARIA props,\n * focus props, and data attributes. Handles prop application through useProps\n * and manages ref assignment to avoid proxy extensibility issues.\n *\n * @param {object} config - Configuration object containing all props to compose\n * @param {Record<string, unknown>} config.otherProps - Additional props from the component\n * @param {ListBoxRenderProps} config.renderValues - Values available to render functions\n * @param {Record<string, unknown>} config.listBoxProps - Props from useListBox hook\n * @param {Record<string, unknown>} config.focusProps - Props from useFocusRing hook\n * @param {Record<string, unknown>} config.dataAttributes - Data attributes for styling/selectors\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager for ARIA attributes\n * @param {React.RefObject<HTMLDivElement>} config.listBoxRef - Reference to attach to the final element\n * @returns {Record<string, unknown>} Composed props object ready for the ListBox element\n * @internal\n */\nfunction useComposedProps({\n otherProps,\n renderValues,\n listBoxProps,\n focusProps,\n dataAttributes,\n selectionManager,\n listBoxRef\n}: {\n readonly otherProps: Record<string, unknown>;\n readonly renderValues: ListBoxRenderProps;\n readonly listBoxProps: Record<string, unknown>;\n readonly focusProps: Record<string, unknown>;\n readonly dataAttributes: Record<string, unknown>;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly listBoxRef: React.RefObject<HTMLDivElement>;\n}) {\n const { apply } = useProps(otherProps, renderValues);\n\n const propsToExclude = [\n 'renderEmptyState',\n 'selectionMode',\n 'defaultSelectedKeys',\n 'disabledKeys',\n 'disallowEmptySelection',\n 'shouldFocusWrap',\n 'items',\n 'children',\n 'selectionBehavior',\n 'keyboardDelegate'\n ];\n\n // Apply user props directly (preserves className, style, etc.)\n const appliedUserProps = apply(otherProps, propsToExclude);\n\n // React Aria and Bento props\n const baseProps = {\n ...mergeProps(listBoxProps, focusProps),\n ...dataAttributes,\n ...(selectionManager.selectionMode !== 'none' && {\n 'aria-multiselectable': selectionManager.selectionMode === 'multiple'\n })\n };\n\n //\n // Merge all props together with user props taking precedence\n //\n const finalProps = {\n ...baseProps,\n ...appliedUserProps,\n ref: listBoxRef // Set ref directly to avoid extensibility issues\n };\n\n return finalProps;\n}\n\n/**\n * Renders the empty state content for the ListBox when no items are present.\n * Handles both function-based render props and direct JSX elements.\n * If a function is provided, calls it with render values; otherwise returns as-is.\n *\n * @param {(props: ListBoxRenderProps) => React.ReactNode} renderEmptyStateFn - Function or JSX element to render for empty state\n * @param {ListBoxRenderProps} renderValues - Current render values to pass to render function\n * @returns {React.ReactNode} Rendered empty state content\n * @internal\n */\nfunction renderEmptyState(\n renderEmptyStateFn: (props: ListBoxRenderProps) => React.ReactNode,\n renderValues: ListBoxRenderProps\n): React.ReactNode {\n //\n // Handle cases where renderEmptyState is not a function (e.g., JSX element passed directly)\n //\n if (typeof renderEmptyStateFn === 'function') {\n return renderEmptyStateFn(renderValues);\n }\n //\n // If it's not a function, just return it as-is (likely a JSX element)\n //\n return renderEmptyStateFn as React.ReactNode;\n}\n\n/**\n * Renders all items in the collection as React elements.\n * Handles both regular items and section items, using the appropriate\n * components (ListBoxItemImpl for items, ListBoxSectionInner for sections).\n *\n * @param {ListState<unknown>['collection']} collection - The collection of items to render\n * @returns {React.ReactElement[]} Array of rendered React elements for all collection items\n * @internal\n */\nfunction renderCollectionItems(collection: ListState<unknown>['collection']): React.ReactElement[] {\n return [...collection].map(function renderCollectionItem(item: Node<unknown>) {\n return item.type === 'section' ? (\n <ListBoxSectionInner key={item.key} section={item} />\n ) : (\n <ListBoxItemImpl key={item.key} __node={item as Node<object>}>\n {item.rendered}\n </ListBoxItemImpl>\n );\n });\n}\n\n/**\n * Determines what content to render inside the ListBox based on its configuration.\n * Handles three cases:\n * 1. Function children without items (Bento render prop pattern with full render props)\n * 2. Empty state when no items and renderEmptyState is provided\n * 3. Normal collection rendering (including items with children functions for React Aria compatibility)\n *\n * @param {object} config - Configuration object for rendering\n * @param {React.ReactNode | ((item: unknown) => React.ReactNode) | ((props: ListBoxRenderProps) => React.ReactNode)} [config.children] - Children prop (static, item render function, or ListBox render prop)\n * @param {Iterable<unknown>} [config.items] - Items array for dynamic collections\n * @param {boolean} config.isEmpty - Whether the collection is empty\n * @param {(props: ListBoxRenderProps) => React.ReactNode} [config.renderEmptyStateProp] - Function to render empty state\n * @param {ListBoxRenderProps} config.renderValues - Current render values for render functions\n * @param {ListState<unknown>['collection']} config.collection - The collection state to render\n * @returns {React.ReactNode} The appropriate content to render inside the ListBox\n * @internal\n */\nfunction renderListBoxContent({\n children,\n items,\n isEmpty,\n renderEmptyStateProp,\n renderValues,\n collection\n}: {\n readonly children?:\n | React.ReactNode\n | ((item: unknown) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n readonly items?: Iterable<unknown>;\n readonly isEmpty: boolean;\n readonly renderEmptyStateProp?: (props: ListBoxRenderProps) => React.ReactNode;\n readonly renderValues: ListBoxRenderProps;\n readonly collection: ListState<unknown>['collection'];\n}): React.ReactNode {\n // If children is a function AND no items provided, use Bento render prop pattern\n /* v8 ignore next */\n const hasRenderChildren = typeof children === 'function' && !items;\n\n /* v8 ignore next 3 */\n if (hasRenderChildren) {\n return (children as (props: ListBoxRenderProps) => React.ReactNode)(renderValues);\n }\n\n // Handle empty state\n if (isEmpty && renderEmptyStateProp) {\n return renderEmptyState(renderEmptyStateProp, renderValues);\n }\n\n // Render collection items (React Aria handles items + children function internally)\n return renderCollectionItems(collection);\n}\n\n/**\n * Internal ListBox component that handles the core rendering logic.\n * This component manages all the hooks, state, and prop composition needed\n * for a fully functional ListBox. It's wrapped by the main ListBox component\n * which handles collection building.\n *\n * @param {object} props - Component props\n * @param {ListState<unknown>} props.state - The ListBox state instance\n * @param {(props: ListBoxRenderProps) => React.ReactNode} [props.renderEmptyState] - Function to render when no items are present\n * @param {React.ReactNode | ((item: unknown) => React.ReactNode) | ((props: ListBoxRenderProps) => React.ReactNode)} [props.children] - Static children, item render function, or ListBox render function\n * @param {Iterable<unknown>} [props.items] - Items array for dynamic collections\n * @param {React.RefObject<HTMLDivElement>} props.listBoxRef - Reference to the ListBox DOM element\n * @param {'stack'} [props.layout] - Layout mode (stack or grid)\n * @param {Orientation} [props.orientation] - Primary orientation of the items\n * @param {boolean} [props.shouldSelectOnPressUp] - Whether selection occurs on pointer up\n * @param {ListKeyboardDelegate<unknown>} [props.keyboardDelegate] - Custom keyboard navigation delegate\n * @param {boolean} [props.allowsTabNavigation] - Whether tab key navigates between items\n * @param {boolean} [props.shouldFocusWrap] - Whether focus wraps at boundaries\n * @param {'none' | 'single' | 'multiple'} [props.selectionMode] - Selection mode (none, single, multiple)\n * @param {SelectionBehavior} [props.selectionBehavior] - Selection behavior (toggle, replace)\n * @returns {React.ReactElement} A fully functional ListBox element with focus scope\n * @internal\n */\nconst ListBoxInner: React.FC<{\n readonly state: ListState<unknown>;\n readonly renderEmptyState?: (props: ListBoxRenderProps) => React.ReactNode;\n readonly children?:\n | React.ReactNode\n | ((item: unknown) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n readonly items?: Iterable<unknown>;\n readonly listBoxRef: RefObject<HTMLDivElement>;\n readonly layout?: 'stack';\n readonly orientation?: Orientation;\n readonly shouldSelectOnPressUp?: boolean;\n readonly keyboardDelegate?: ListKeyboardDelegate<unknown>;\n readonly allowsTabNavigation?: boolean;\n readonly shouldFocusWrap?: boolean;\n readonly selectionMode?: 'none' | 'single' | 'multiple';\n readonly selectionBehavior?: SelectionBehavior;\n}> = function ListBoxInner({\n state,\n renderEmptyState: renderEmptyStateProp,\n children,\n items,\n listBoxRef,\n ...otherProps\n}) {\n const { layout = 'stack', orientation = 'vertical', shouldSelectOnPressUp, selectionBehavior } = otherProps;\n\n const { collection, selectionManager } = state;\n const { direction } = useLocale();\n const collator = useCollator({ usage: 'search', sensitivity: 'base' });\n\n const keyboardDelegate = useKeyboardDelegate({\n collection,\n collator,\n listBoxRef,\n selectionManager,\n layout,\n orientation,\n direction,\n keyboardDelegate: otherProps.keyboardDelegate\n });\n\n const { listBoxProps } = useListBox(\n {\n ...otherProps,\n shouldSelectOnPressUp,\n keyboardDelegate\n },\n state,\n listBoxRef\n );\n\n const { focusProps, isFocused, isFocusVisible } = useFocusRing();\n const isEmpty = state.collection.size === 0;\n\n const renderValues: ListBoxRenderProps = {\n isEmpty,\n isFocused,\n isFocusVisible,\n isDropTarget: false,\n layout,\n state,\n items\n };\n\n const dataAttributes = useListBoxDataAttributes({\n isEmpty,\n isFocused,\n isFocusVisible,\n layout,\n orientation,\n selectionManager,\n allowsTabNavigation: otherProps.allowsTabNavigation,\n shouldFocusWrap: otherProps.shouldFocusWrap,\n originalSelectionBehavior: selectionBehavior\n });\n\n const composedProps = useComposedProps({\n otherProps,\n renderValues,\n listBoxProps: listBoxProps as Record<string, unknown>,\n focusProps: focusProps as Record<string, unknown>,\n dataAttributes,\n selectionManager,\n listBoxRef\n });\n\n return (\n <FocusScope>\n <div {...composedProps}>\n {renderListBoxContent({\n children,\n items,\n isEmpty,\n renderEmptyStateProp,\n renderValues,\n collection\n })}\n </div>\n </FocusScope>\n );\n};\n\n/**\n * A complete ListBox component providing accessible selection lists with keyboard navigation.\n * Supports both static children and dynamic collections, with single/multiple selection modes.\n * Built on React Aria with full ARIA compliance and keyboard accessibility.\n *\n * @component\n * @template T The type of items in the collection\n * @param {ListBoxProps<T>} args - The properties passed to the ListBox component\n * @param {React.ForwardedRef<HTMLDivElement>} ref - The ref to the listbox container\n * @returns {React.ReactElement} A ListBox component\n *\n * @example\n * ```tsx\n * <ListBox aria-label=\"Fruits\" selectionMode=\"single\">\n * <ListBoxItem id=\"apple\" textValue=\"Apple\">Apple</ListBoxItem>\n * <ListBoxItem id=\"banana\" textValue=\"Banana\">Banana</ListBoxItem>\n * </ListBox>\n * ```\n * @public\n */\nfunction ListBoxComponent<T>(args: ListBoxProps<T>, ref: React.ForwardedRef<HTMLDivElement>): React.ReactElement {\n return (\n <CollectionBuilder content={<AriaCollection {...(args as unknown as Parameters<typeof AriaCollection>[0])} />}>\n {function buildCollection(collection: unknown) {\n return <StandaloneListBox props={args as ListBoxProps<unknown>} listBoxRef={ref} collection={collection} />;\n }}\n </CollectionBuilder>\n );\n}\n\n/**\n * Standalone ListBox component that manages its own state and collection.\n * This component is used internally by the main ListBox component after\n * collection building is complete. It handles prop processing, state creation,\n * and context management.\n *\n * @param {object} props - Component props\n * @param {ListBoxProps<unknown>} props.props - The original ListBox props\n * @param {React.ForwardedRef<HTMLDivElement>} props.listBoxRef - Reference to forward to the ListBox element\n * @param {unknown} props.collection - Built collection from CollectionBuilder\n * @returns {React.ReactElement} A complete ListBox with state management and optional context wrapping\n * @internal\n */\nconst StandaloneListBox: React.FC<{\n readonly props: ListBoxProps<unknown>;\n readonly listBoxRef: ForwardedRef<HTMLDivElement>;\n readonly collection: unknown;\n}> = function StandaloneListBox({ props, listBoxRef, collection }) {\n //\n // Extract renderEmptyState before useProps processes it to avoid render prop corruption\n //\n const originalRenderEmptyState = props.renderEmptyState;\n\n const { props: processedProps } = useProps(props);\n const processedRef = useSafeObjectRef(listBoxRef);\n const { state, contextState } = useListBoxState({ ...processedProps, collection });\n\n const { renderEmptyState: _, ...cleanProcessedProps } = processedProps as ListBoxProps<unknown> & {\n renderEmptyState?: unknown;\n };\n\n const content = (\n <ListBoxInner\n state={state}\n listBoxRef={processedRef}\n renderEmptyState={originalRenderEmptyState}\n {...cleanProcessedProps}\n />\n );\n\n return renderWithOptionalContext(content, state, contextState);\n};\n\n/**\n * A complete ListBox component providing accessible selection lists with keyboard navigation.\n * Supports both static children and dynamic collections, with single/multiple selection modes.\n * Built on React Aria with full ARIA compliance and keyboard accessibility.\n *\n * @component\n * @example\n * ```tsx\n * <ListBox aria-label=\"Fruits\" selectionMode=\"single\">\n * <ListBoxItem id=\"apple\" textValue=\"Apple\">Apple</ListBoxItem>\n * <ListBoxItem id=\"banana\" textValue=\"Banana\">Banana</ListBoxItem>\n * </ListBox>\n * ```\n * @public\n */\nexport const ListBox = withSlots('BentoListBox', ListBoxComponent);\n\n/**\n * Collection component for building dynamic collections in ListBox.\n * Re-exported from React Aria Collections.\n * @public\n */\nexport { AriaCollection as Collection };\n\n/**\n * Context for sharing ListBox state across components.\n * Used internally by ListBoxItem and ListBoxSection components.\n * @public\n */\nexport { ListStateContext };\n","import React, { ForwardedRef, ReactNode, createContext, useContext, useMemo, forwardRef } from 'react';\nimport { mergeProps, useOption, useHover } from 'react-aria';\nimport { createLeafComponent } from '@react-aria/collections';\nimport { HoverEvents, Key, LinkDOMProps, Node } from '@react-types/shared';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { ListStateContext } from './listbox';\nimport { useSafeObjectRef } from './utils';\nimport { withSlots } from '@bento/slots';\n\n/**\n * Context value structure for text-related slot attributes.\n * Used to provide label and description attributes to child components.\n * @interface TextContextValue\n */\ninterface TextContextValue {\n readonly slots: {\n /** Attributes for label elements */\n readonly label?: React.HTMLAttributes<HTMLElement>;\n /** Attributes for description elements */\n readonly description?: React.HTMLAttributes<HTMLElement>;\n };\n}\n\n/**\n * Internal context for providing text-related slot attributes to child components.\n * This context allows ListBoxItem to pass label and description attributes\n * to nested components that need them for accessibility.\n * @internal\n */\nconst TextContext = createContext<TextContextValue>({ slots: {} });\n\n/**\n * Render props provided to ListBoxItem render functions.\n * @interface ListBoxItemRenderProps\n */\nexport interface ListBoxItemRenderProps {\n /**\n * Whether the item is currently hovered.\n * @selector [data-hovered]\n */\n readonly isHovered: boolean;\n /**\n * Whether the item is currently pressed.\n * @selector [data-pressed]\n */\n readonly isPressed: boolean;\n /**\n * Whether the item is currently selected.\n * @selector [data-selected]\n */\n readonly isSelected: boolean;\n /**\n * Whether the item is currently focused.\n * @selector [data-focused]\n */\n readonly isFocused: boolean;\n /**\n * Whether the item is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n readonly isFocusVisible: boolean;\n /**\n * Whether the item is disabled.\n * @selector [data-disabled]\n */\n readonly isDisabled: boolean;\n /**\n * The type of selection that is allowed in the collection.\n * @selector [data-selection-mode=\"none | single | multiple\"]\n */\n readonly selectionMode: 'none' | 'single' | 'multiple';\n /**\n * The selection behavior for the collection.\n * @selector [data-selection-behavior=\"toggle | replace\"]\n */\n readonly selectionBehavior: 'toggle' | 'replace';\n}\n\n/**\n * Props for the ListBoxItem component.\n * @interface ListBoxItemProps\n * @template T The type of the item value\n */\nexport interface ListBoxItemProps<T = object>\n extends LinkDOMProps,\n HoverEvents,\n Omit<React.HTMLAttributes<HTMLElement>, keyof LinkDOMProps | keyof HoverEvents | 'id' | 'children'> {\n /** The unique id of the item. If not provided, React Aria will auto-generate one. */\n readonly id?: Key;\n /** The object value that this item represents. When using dynamic collections, this is set automatically. */\n readonly value?: T;\n /** A string representation of the item's contents, used for features like typeahead. If not provided, React Aria will derive it from children automatically. */\n readonly textValue?: string;\n /**\n * Handler that is called when a user performs an action on the item. The exact user event depends on the\n * collection's `selectionBehavior` prop and the interaction modality.\n */\n readonly onAction?: () => void;\n /** The contents of the item. Can be a render function that receives render props. */\n readonly children?: ReactNode | ((values: ListBoxItemRenderProps) => ReactNode);\n /**\n * A slot name for the component. Used by Bento's slot system.\n */\n readonly slot?: string;\n /** Whether the item is disabled. */\n readonly isDisabled?: boolean;\n}\n\n/**\n * Internal implementation component for ListBoxItem.\n * Handles the core logic for rendering a single listbox item with proper accessibility.\n * This component manages all the hooks, state, and interactions needed for a functional\n * listbox item including selection, hover, focus, and keyboard interactions.\n *\n * @template T - The type of the item value\n * @param {object} props - Combined ListBoxItem props and internal node data\n * @param {Node<T>} props.__node - Internal React Aria node containing item metadata\n * @param {React.ReactNode | ((values: ListBoxItemRenderProps) => React.ReactNode)} [props.children] - Content to render, can be static or a render function\n * @param {boolean} [props.isDisabled] - Whether the item is disabled\n * @param {string} [props.aria-label] - ARIA label for accessibility\n * @param {(e: HoverEvent) => void} [props.onHoverStart] - Handler for hover start events\n * @param {(isHovering: boolean) => void} [props.onHoverChange] - Handler for hover change events\n * @param {(e: HoverEvent) => void} [props.onHoverEnd] - Handler for hover end events\n * @param {React.ForwardedRef<HTMLDivElement>} ref - Forwarded ref to the item element\n * @returns {React.ReactElement} A fully interactive listbox item with accessibility and state management\n * @internal\n */\nconst ListBoxItemImplComponent = function ListBoxItemImplComponent<T extends object>(\n { __node, ...props }: ListBoxItemProps<T> & { readonly __node: Node<T> },\n ref: ForwardedRef<HTMLDivElement>\n) {\n const state = useContext(ListStateContext)!;\n const safeRef = useSafeObjectRef(ref);\n\n const { optionProps, labelProps, descriptionProps, ...states } = useOption(\n {\n key: __node.key,\n 'aria-label': props['aria-label'],\n isDisabled: props.isDisabled\n },\n state,\n safeRef\n );\n\n const { hoverProps, isHovered } = useHover({\n isDisabled: states.isDisabled,\n onHoverStart: props.onHoverStart,\n onHoverChange: props.onHoverChange,\n onHoverEnd: props.onHoverEnd\n });\n\n const renderValues: ListBoxItemRenderProps = {\n ...states,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior\n };\n\n const content = typeof props.children === 'function' ? props.children(renderValues) : props.children;\n\n const { apply } = useProps(props, renderValues);\n\n const dataAttributes = useDataAttributes({\n selected: states.isSelected,\n disabled: states.isDisabled,\n hovered: isHovered,\n focused: states.isFocused,\n 'focus-visible': states.isFocusVisible,\n pressed: states.isPressed,\n level: __node.level,\n 'selection-mode': state.selectionManager.selectionMode,\n 'selection-behavior': state.selectionManager.selectionBehavior\n });\n\n const textContext = useMemo(\n function createTextContext() {\n return {\n slots: {\n label: labelProps,\n description: descriptionProps\n }\n };\n },\n [labelProps, descriptionProps]\n );\n\n const ElementType = __node.props.href ? 'a' : 'div';\n\n // Use original node props (which contain className) not filtered finalProps\n const appliedUserProps = apply(__node.props, ['ref']);\n\n const finalAttributes = {\n ...mergeProps(optionProps, hoverProps), // React Aria props\n ...dataAttributes, // Bento data attributes\n ...appliedUserProps,\n ref: safeRef,\n 'data-text-value': __node.textValue\n };\n\n return (\n <TextContext.Provider value={textContext}>\n {React.createElement(ElementType, finalAttributes, content)}\n </TextContext.Provider>\n );\n};\n\n/**\n * Enhanced ListBoxItem implementation with slots support.\n * This wraps the core ListBoxItemImplComponent with Bento's slot system\n * for advanced composition and styling capabilities.\n * @internal\n */\nexport const ListBoxItemImpl = withSlots('BentoListBoxItem', forwardRef(ListBoxItemImplComponent));\n\n/**\n * Adapter component that connects ListBoxItemImpl to React Aria's collection system.\n * This function serves as a bridge between React Aria's createLeafComponent and\n * the internal ListBoxItemImpl, ensuring proper prop forwarding and node injection.\n *\n * @template T - The type of the item value\n * @param {ListBoxItemProps<T>} props - ListBoxItem component props\n * @param {React.ForwardedRef<HTMLDivElement>} forwardedRef - Ref forwarded from the collection system\n * @param {Node<T>} item - React Aria node containing item metadata and collection info\n * @returns {React.ReactElement} The ListBoxItemImpl component with proper node and ref wiring\n * @internal\n */\nfunction ListBoxItemComponent<T extends object>(\n props: ListBoxItemProps<T>,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n item: Node<T>\n) {\n return <ListBoxItemImpl {...props} ref={forwardedRef} __node={item} />;\n}\n\n/**\n * Base ListBoxItem component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state.\n * @internal\n */\nconst ListBoxItemBase = createLeafComponent('item', ListBoxItemComponent);\n\n/**\n * A single item within a ListBox component.\n * Handles user interactions, accessibility, and state management for individual options.\n *\n * @component\n * @template T The type of the item value\n * @example\n * ```tsx\n * <ListBoxItem>Simple option</ListBoxItem>\n * ```\n * @public\n */\nexport const ListBoxItem = ListBoxItemBase;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/header.tsx","../src/listbox-section.tsx","../src/utils.ts","../src/listbox.tsx","../src/listbox-item.tsx"],"names":["createContext","withSlots","useProps","useContext","React","createLeafComponent","BentoListBoxSectionImpl","useDataAttributes","useRef","useListBoxSection","mergeProps","createBranchComponent","ListBoxSectionInner","CollectionRendererContext","useEffect","useListState","useMemo","ListKeyboardDelegate","ListBoxInner","useLocale","useCollator","useListBox","useFocusRing","FocusScope","CollectionBuilder","AriaCollection","StandaloneListBox","ListBoxItemImplComponent","useOption","useHover"],"mappings":";;;;;;;;;;;;;;;;AA2CO,IAAM,aAAA,GAAgBA,oBAAA,CAAkC,EAAE;AASjE,IAAM,eAAA,GAAkBC,eAAA;AAAA,EACtB,aAAA;AAAA,EACA,SAAS,WAAA,CAAY,KAAA,EAAyB,GAAA,EAAsC;AAClF,IAAA,MAAM,EAAE,KAAA,EAAO,cAAA,EAAgB,KAAA,EAAM,GAAIC,kBAAS,KAAK,CAAA;AACvD,IAAA,MAAM,YAAA,GAAeC,kBAAW,aAAa,CAAA;AAG7C,IAAA,MAAM,gBAAA,GAAmB,MAAM,cAAc,CAAA;AAE7C,IAAA,MAAM,QAAA,GAAW;AAAA,MACf,GAAG,YAAA;AAAA,MACH,GAAG;AAAA;AAAA,KACL;AAEA,IAAA,uBACEC,uBAAA,CAAA,aAAA,CAAC,YAAQ,GAAG,QAAA,EAAU,KAAK,YAAA,CAAa,GAAA,IAAO,GAAA,EAAA,EAC5C,cAAA,CAAe,QAClB,CAAA;AAAA,EAEJ;AACF,CAAA;AAaA,SAAS,aAAA,CAAc,OAAoB,GAAA,EAAsC;AAC/E,EAAA,uBAAOA,uBAAA,CAAA,aAAA,CAAC,eAAA,EAAA,EAAiB,GAAG,KAAA,EAAO,GAAA,EAAU,CAAA;AAC/C;AAuBA,IAAM,UAAA,GAAaC,+BAAA,CAAoB,QAAA,EAAU,aAAa,CAAA;AAqBvD,IAAM,MAAA,GAAS;ACnEtB,IAAM,uBAAA,GAA0BJ,eAAAA,CAAU,qBAAA,EAAuB,SAASK,wBAAAA,CAExE,EAAE,MAAA,EAAQ,QAAA,EAAU,KAAA,EAAO,SAAA,EAAW,GAAG,IAAA,IAAyC,GAAA,EAAsC;AACxH,EAAA,MAAM,EAAE,KAAA,EAA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;AAEpD,EAAA,MAAM,eAAA,GAAkB;AAAA,IACtB,GAAGN,oBAAAA,CAAW,WAAA,EAAa,UAAU,CAAA;AAAA;AAAA,IACrC,GAAG,cAAA;AAAA;AAAA,IACH,GAAG,gBAAA;AAAA,IACH,GAAA,EAAK,OAAA;AAAA,IACL,mBAAmB,MAAA,CAAO;AAAA,GAC5B;AAEA,EAAA,uBACEN,uBAAAA,CAAA,aAAA,CAAC,WAAA,CAAY,QAAA,EAAZ,EAAqB,KAAA,EAAO,WAAA,EAAA,EAC1BA,uBAAAA,CAAM,aAAA,CAAc,WAAA,EAAa,eAAA,EAAiB,OAAO,CAC5D,CAAA;AAEJ,CAAA;AAQO,IAAM,eAAA,GAAkBH,eAAAA,CAAU,kBAAA,EAAoB,wBAAwB,CAAA;AAcrF,SAAS,oBAAA,CACP,KAAA,EACA,YAAA,EACA,IAAA,EACA;AACA,EAAA,uBAAOG,wBAAA,aAAA,CAAC,eAAA,EAAA,EAAiB,GAAG,KAAA,EAAO,GAAA,EAAK,YAAA,EAAqB,MAAA,EAAQ,IAAA,EAAM,CAAA;AAC7E;AAOA,IAAM,eAAA,GAAkBC,+BAAAA,CAAoB,MAAA,EAAQ,oBAAoB,CAAA;AAcjE,IAAM,WAAA,GAAc","file":"index.cjs","sourcesContent":["import React, { createContext, useContext } from 'react';\nimport { createLeafComponent } from '@react-aria/collections';\nimport { useProps } from '@bento/use-props';\nimport { withSlots, type Slots } from '@bento/slots';\n\n/**\n * Props for the Header component.\n * @interface HeaderProps\n */\nexport interface HeaderProps extends Slots, React.ComponentProps<'header'> {\n /**\n * The children of the header.\n */\n readonly children?: React.ReactNode;\n}\n\n/**\n * Context value structure for Header components.\n * Extends HTML attributes to support all standard header element properties.\n * @interface HeaderContextValue\n */\ninterface HeaderContextValue extends React.HTMLAttributes<HTMLElement> {\n /**\n * Reference to the header element for forwarding.\n */\n readonly ref?: React.RefObject<HTMLDivElement>;\n}\n\n/**\n * Combined props type for the internal BentoHeader implementation.\n * Merges Header-specific props with standard HTML attributes to provide\n * a comprehensive interface for the internal header component.\n *\n * @type BentoHeaderProps\n * @internal\n */\ntype BentoHeaderProps = HeaderProps & React.HTMLAttributes<HTMLElement>;\n\n/**\n * React context for providing header-related attributes and refs to Header components.\n * Used internally by ListBoxSection to pass heading props to Header elements.\n * @public\n */\nexport const HeaderContext = createContext<HeaderContextValue>({});\n\n/**\n * Internal implementation of the BentoHeader component with slots support.\n * This component handles prop processing and context integration.\n * It merges props from useProps and HeaderContext while preserving styling props.\n *\n * @internal\n */\nconst BentoHeaderImpl = withSlots(\n 'BentoHeader',\n function BentoHeader(props: BentoHeaderProps, ref: React.ForwardedRef<HTMLElement>) {\n const { props: processedProps, apply } = useProps(props);\n const contextProps = useContext(HeaderContext);\n\n // Apply user props directly (preserves className, style, etc.)\n const appliedUserProps = apply(processedProps);\n\n const composed = {\n ...contextProps,\n ...appliedUserProps // User props take precedence over context\n };\n\n return (\n <header {...composed} ref={contextProps.ref || ref}>\n {processedProps.children}\n </header>\n );\n }\n);\n\n/**\n * Wrapper component that connects the BentoHeaderImpl to React Aria's collection system.\n * This function serves as an adapter between the createLeafComponent system and\n * the internal BentoHeaderImpl component, ensuring proper prop forwarding and ref handling.\n *\n * @param {HeaderProps} props - Header component props\n * @param {React.ReactNode} [props.children] - React children to render inside the header\n * @param {React.ForwardedRef<HTMLElement>} ref - Forwarded ref to the header element\n * @returns {React.ReactElement} The BentoHeaderImpl component with forwarded props and ref\n * @internal\n */\nfunction HeaderWrapper(props: HeaderProps, ref: React.ForwardedRef<HTMLElement>) {\n return <BentoHeaderImpl {...props} ref={ref} />;\n}\n\n/**\n * A Header represents a heading for a section within a ListBox.\n * Uses React Aria's createLeafComponent for automatic collection handling.\n *\n * @component\n * @param {HeaderProps} props - The props for the Header component\n * @param {React.ForwardedRef<HTMLElement>} ref - Forwarded ref to the header element\n * @returns {JSX.Element} A header element with proper accessibility attributes\n *\n * @example\n * ```tsx\n * <Header>My Section Title</Header>\n * ```\n * @public\n */\n/**\n * Base Header component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state and\n * integrates with the collection rendering system.\n * @internal\n */\nconst HeaderBase = createLeafComponent('header', HeaderWrapper);\n\n/**\n * A Header component for section headings within a ListBox.\n * Provides semantic header structure with proper accessibility attributes\n * and integrates with React Aria's collection system for automatic handling.\n *\n * This is the main public interface for creating headers in ListBox sections.\n * It automatically receives heading props from the parent ListBoxSection via HeaderContext.\n *\n * @component\n * @example\n * ```tsx\n * <ListBoxSection>\n * <Header>Fruits</Header>\n * <ListBoxItem>Apple</ListBoxItem>\n * <ListBoxItem>Banana</ListBoxItem>\n * </ListBoxSection>\n * ```\n * @public\n */\nexport const Header = HeaderBase as React.ForwardRefExoticComponent<HeaderProps & React.RefAttributes<HTMLElement>>;\n","import React, { useRef, useContext } from 'react';\nimport { useListBoxSection, mergeProps } from 'react-aria';\nimport { createBranchComponent } from '@react-aria/collections';\nimport { CollectionRendererContext } from 'react-aria-components';\nimport type { Node } from '@react-types/shared';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport { HeaderContext } from './header';\nimport { ListStateContext } from './listbox';\n\n/**\n * Props for the ListBoxSection component.\n * @interface ListBoxSectionProps\n */\nexport interface ListBoxSectionProps extends Omit<React.ComponentProps<'section'>, 'title'> {\n /**\n * A slot name for the component. Used by Bento's slot system.\n */\n readonly slot?: string;\n /**\n * The title of the section.\n */\n readonly title?: React.ReactNode;\n /**\n * The children of the section.\n */\n readonly children?: React.ReactNode;\n}\n\n/**\n * Internal props interface for BentoListBoxSectionImpl component.\n * Extends ListBoxSectionProps with internal React Aria node data and allows\n * additional properties for flexibility in prop handling.\n *\n * @interface BentoListBoxSectionImplProps\n * @template T - The type of the section node data\n * @internal\n */\ninterface BentoListBoxSectionImplProps<T = unknown> extends ListBoxSectionProps {\n readonly __node?: Node<T>;\n readonly [key: string]: unknown;\n}\n\n/**\n * Props interface for the ListBoxSectionInner component.\n * Contains the React Aria section node that represents this section\n * in the collection hierarchy for dynamic rendering.\n *\n * @interface ListBoxSectionInnerProps\n * @internal\n */\ninterface ListBoxSectionInnerProps {\n readonly section: Node<unknown>;\n}\n\n/**\n * Internal implementation of the BentoListBoxSection component with slots support.\n * This component handles the core logic for rendering a section within a ListBox,\n * including title rendering, accessibility attributes, and child content management.\n * It integrates with React Aria's useListBoxSection hook for proper ARIA compliance.\n *\n * @internal\n */\nconst BentoListBoxSectionImpl = withSlots('BentoListBoxSection', function BentoListBoxSectionImpl<\n T\n>({ __node, children, title: titleProp, ...rest }: BentoListBoxSectionImplProps<T>, ref: React.ForwardedRef<HTMLElement>) {\n const { props, apply } = useProps(rest);\n const data = useDataAttributes({ level: __node?.level });\n const headingRef = useRef<HTMLDivElement>(null);\n\n const title = titleProp ?? props.title ?? __node?.rendered;\n const { groupProps, headingProps } = useListBoxSection({\n heading: title,\n 'aria-label': props['aria-label']\n });\n\n const composed = mergeProps(apply({ ...data, ...props }, ['children', 'title', 'slot']), groupProps);\n\n const sectionContent = children || props.children;\n\n return (\n <section {...composed} ref={ref}>\n <HeaderContext.Provider value={{ ...headingProps, ref: headingRef }}>\n {title && <div {...headingProps}>{title}</div>}\n {sectionContent}\n </HeaderContext.Provider>\n </section>\n );\n});\n\n/**\n * Wrapper component that connects BentoListBoxSectionImpl to React Aria's collection system.\n * This function serves as an adapter between createBranchComponent and the internal\n * BentoListBoxSectionImpl, ensuring proper prop forwarding and node injection for sections.\n *\n * @template T - The type of the section node data\n * @param {ListBoxSectionProps} props - ListBoxSection component props\n * @param {string} [props.slot] - Slot name for Bento's slot system\n * @param {React.ReactNode} [props.title] - Title for the section\n * @param {React.ReactNode} [props.children] - Children to render in the section\n * @param {string} [props.aria-label] - ARIA label for accessibility\n * @param {React.ForwardedRef<HTMLElement>} ref - Ref forwarded from the collection system\n * @param {Node<T>} section - React Aria node containing section metadata and collection info\n * @returns {React.ReactElement} The BentoListBoxSectionImpl component with proper node and ref wiring\n * @internal\n */\n/* v8 ignore start */\nfunction ListBoxSectionWrapper<T extends object>(\n props: ListBoxSectionProps,\n ref: React.ForwardedRef<HTMLElement>,\n section: Node<T>\n) {\n return <BentoListBoxSectionImpl {...props} __node={section} ref={ref} />;\n}\n/* v8 ignore stop */\n\n/**\n * Base ListBoxSection component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state and\n * manages the branch structure for nested items.\n * @internal\n */\nconst ListBoxSectionBase = createBranchComponent('section', ListBoxSectionWrapper);\n\n/**\n * Internal component for rendering dynamic collection sections.\n * This component is used specifically for sections that are part of a dynamic collection,\n * connecting to the ListStateContext and CollectionRendererContext to properly render\n * nested items through React Aria's collection system.\n *\n * @component\n * @param {object} props - The component props containing the section node\n * @param {Node<unknown>} props.section - The React Aria node representing this section in the collection\n * @throws {BentoError} Throws an error if used outside of a ListBox context\n * @returns {React.ReactElement} JSX element representing a dynamically rendered listbox section\n * @internal\n */\nexport const ListBoxSectionInner: React.FC<ListBoxSectionInnerProps> = function ListBoxSectionInner({ section }) {\n const state = useContext(ListStateContext);\n const { CollectionBranch } = useContext(CollectionRendererContext);\n\n return (\n <BentoListBoxSectionImpl {...section.props} __node={section}>\n {CollectionBranch && state?.collection ? (\n <CollectionBranch collection={state.collection} parent={section} />\n ) : null}\n </BentoListBoxSectionImpl>\n );\n};\n\n/**\n * A section component for organizing related items within a ListBox.\n *\n * @component\n * @example\n * ```tsx\n * <ListBoxSection title=\"Fruits\">\n * <ListBoxItem>Apple</ListBoxItem>\n * <ListBoxItem>Banana</ListBoxItem>\n * </ListBoxSection>\n * ```\n * @public\n */\nexport const ListBoxSection = ListBoxSectionBase as <_T extends object>(\n props: ListBoxSectionProps & { children?: React.ReactNode }\n) => React.ReactElement;\n","/* v8 ignore next */\nimport React, { type ForwardedRef, useEffect, useRef } from 'react';\n\n/**\n * NOTE: This utility will be moved to the new use-collection package.\n * Safe wrapper for React Aria's useObjectRef that handles test environments where refs are not extensible.\n *\n * **Critical for Vitest Browser Mode Testing**: When running tests in Vitest's browser mode with Playwright,\n * the test environment can freeze or make objects non-extensible. React Aria's `useObjectRef` attempts to\n * dynamically add properties to ref objects, which fails with \"Cannot add property current, object is not extensible\"\n * in these constrained test environments.\n *\n * **Technical Details:**\n * - Vitest browser mode uses Playwright's Chrome DevTools Protocol for test execution\n * - The V8 engine's security model can freeze objects during test isolation\n * - React Aria's useObjectRef uses `Object.defineProperty()` to add reactive properties to refs\n * - This conflicts with frozen objects in browser testing scenarios\n *\n * **Why This Solution Works:**\n * - Creates an internal ref that's always mutable (created in our controlled environment)\n * - Safely forwards values to the external ref using try/catch for frozen object scenarios\n * - Maintains the same ref forwarding behavior as React Aria's useObjectRef in normal environments\n * - Gracefully degrades in test environments without breaking functionality\n *\n * **Production Impact**: Zero. Object freezing only occurs in specific test configurations.\n * In production and development, this behaves identically to React Aria's useObjectRef.\n *\n * @template T - The type of the ref element\n * @param {React.ForwardedRef<T>} ref - The forwarded ref to handle safely\n * @returns {React.RefObject<T>} A safe ref object that works in all environments including frozen test contexts\n * @public\n */\nexport function useSafeObjectRef<T>(ref: ForwardedRef<T>): React.RefObject<T> {\n const internalRef = useRef<T>(null);\n\n useEffect(function updateForwardedRef() {\n const current = internalRef.current;\n\n if (typeof ref === 'function') {\n ref(current);\n } else if (ref && 'current' in ref) {\n try {\n (ref as React.MutableRefObject<T | null>).current = current;\n /* v8 ignore start */\n } catch {\n //\n // Silently ignore errors in test environments where objects might be frozen.\n // This specifically handles Vitest browser mode with Playwright where the V8 engine\n // may freeze ref objects during test isolation, preventing dynamic property assignment.\n //\n }\n /* v8 ignore stop */\n }\n });\n\n return internalRef;\n}\n","import React, { createContext, useContext, useMemo, ForwardedRef, RefObject } from 'react';\nimport {\n FocusScope,\n mergeProps,\n useCollator,\n useLocale,\n useListBox,\n useFocusRing,\n ListKeyboardDelegate\n} from 'react-aria';\nimport { ListState, SelectionBehavior, useListState, Orientation, Node } from 'react-stately';\nimport { CollectionBuilder, Collection as AriaCollection } from '@react-aria/collections';\nimport { AriaListBoxProps } from '@react-types/listbox';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots, Slots } from '@bento/slots';\nimport { ListBoxItemImpl } from './listbox-item';\nimport { ListBoxSectionInner } from './listbox-section';\nimport { useSafeObjectRef } from './utils';\n\n/**\n * Render props provided to ListBox render functions and empty state renderers.\n * @interface ListBoxRenderProps\n */\nexport interface ListBoxRenderProps {\n /**\n * Whether the listbox has no items and should display its empty state.\n * @selector [data-empty]\n */\n readonly isEmpty: boolean;\n /**\n * Whether the listbox is currently focused.\n * @selector [data-focused]\n */\n readonly isFocused: boolean;\n /**\n * Whether the listbox is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n readonly isFocusVisible: boolean;\n /**\n * Whether the listbox is currently the active drop target.\n * @selector [data-drop-target]\n */\n readonly isDropTarget: boolean;\n /**\n * Whether the items are arranged in a stack or grid.\n * @selector [data-layout=\"stack | grid\"]\n */\n readonly layout?: 'stack' | 'grid';\n /**\n * State of the listbox.\n */\n readonly state: ListState<unknown>;\n /**\n * The items array when using dynamic collections.\n */\n readonly items?: Iterable<unknown>;\n}\n\n/**\n * Props for the ListBox component.\n * @interface ListBoxProps\n * @template T The type of items in the collection\n */\nexport interface ListBoxProps<T>\n extends Omit<AriaListBoxProps<T>, 'label' | 'children'>,\n Omit<React.ComponentProps<'div'>, keyof AriaListBoxProps<T> | 'children'>,\n Slots {\n /**\n * How multiple selection should behave in the collection.\n */\n readonly selectionBehavior?: SelectionBehavior;\n /**\n * Provides content to display when there are no items in the list.\n */\n readonly renderEmptyState?: (props: ListBoxRenderProps) => React.ReactNode;\n /**\n * Whether the items are arranged in a stack layout.\n * @default 'stack'\n */\n readonly layout?: 'stack';\n /**\n * The primary orientation of the items. Usually this is the direction that the collection scrolls.\n * @default 'vertical'\n */\n readonly orientation?: Orientation;\n /**\n * Static children or render function for the ListBox.\n * When items prop is provided, children receives individual items for React Aria compatibility.\n * When no items prop is provided, children receives Bento render props { isEmpty, isFocused, state, etc. }.\n */\n readonly children?:\n | React.ReactNode\n | ((item: T) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n}\n\n/**\n * React context for sharing ListBox state across components.\n * This context provides the ListBox state to child components like ListBoxItem and ListBoxSection,\n * enabling them to access selection state, collection data, and other shared functionality.\n *\n * @context\n * @internal\n */\nconst ListStateContext = createContext<ListState<unknown> | null>(null);\n\n/**\n * Custom hook to manage ListBox state creation and context handling.\n * This hook either uses an existing state from context or creates a new one.\n * It's designed to work both as a standalone component and within a parent component\n * that provides ListBox state through context.\n *\n * @param {Record<string, unknown>} props - Configuration object for the ListBox state\n * @returns {object} An object containing the state instance and context state flag\n * @returns {ListState<unknown>} returns.state - The ListBox state instance\n * @returns {ListState<unknown> | null} returns.contextState - Existing context state, if any\n * @internal\n */\nfunction useListBoxState(props: Record<string, unknown>) {\n const contextState = useContext(ListStateContext);\n\n const stateProps = {\n ...props,\n children: undefined,\n items: undefined\n };\n\n const state = contextState ?? useListState(stateProps);\n\n return { state, contextState };\n}\n\n/**\n * Renders content with optional context provider wrapper.\n * If no context state exists, wraps the content in a ListStateContext.Provider.\n * This allows the ListBox to work both standalone and as part of a larger component tree.\n *\n * @param {React.ReactNode} content - The React content to render\n * @param {ListState<unknown>} state - The ListBox state to provide via context\n * @param {ListState<unknown> | null} contextState - Existing context state, if any\n * @returns {React.ReactNode} The content, optionally wrapped in a context provider\n * @internal\n */\nfunction renderWithOptionalContext(\n content: React.ReactNode,\n state: ListState<unknown>,\n contextState: ListState<unknown> | null\n): React.ReactNode {\n /* v8 ignore next */\n return contextState ? content : <ListStateContext.Provider value={state}>{content}</ListStateContext.Provider>;\n}\n\n/**\n * Creates and memoizes a keyboard delegate for the ListBox.\n * The keyboard delegate handles keyboard navigation logic, including\n * arrow key navigation, home/end keys, and type-ahead functionality.\n *\n * @param {object} config - Configuration object for the keyboard delegate\n * @param {ListState<unknown>['collection']} config.collection - The collection of items in the ListBox\n * @param {Intl.Collator} config.collator - Intl collator for string comparison in type-ahead\n * @param {React.RefObject<HTMLDivElement>} config.listBoxRef - Reference to the ListBox DOM element\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager from the state\n * @param {'stack' | 'grid'} [config.layout] - Layout mode (stack or grid)\n * @param {Orientation} [config.orientation] - Primary orientation of the items\n * @param {'ltr' | 'rtl'} config.direction - Text direction (ltr or rtl)\n * @param {ListKeyboardDelegate<unknown>} [config.keyboardDelegate] - Custom keyboard delegate to use instead of default\n * @returns {ListKeyboardDelegate<unknown>} A keyboard delegate instance for handling keyboard interactions\n * @internal\n */\nfunction useKeyboardDelegate({\n collection,\n collator,\n listBoxRef,\n selectionManager,\n layout,\n orientation,\n direction,\n keyboardDelegate: providedDelegate\n}: {\n readonly collection: ListState<unknown>['collection'];\n readonly collator: Intl.Collator;\n readonly listBoxRef: React.RefObject<HTMLDivElement>;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly layout?: 'stack' | 'grid';\n readonly orientation?: Orientation;\n readonly direction: 'ltr' | 'rtl';\n readonly keyboardDelegate?: ListKeyboardDelegate<unknown>;\n}): ListKeyboardDelegate<unknown> {\n const { disabledBehavior, disabledKeys } = selectionManager;\n\n return useMemo(\n function createKeyboardDelegate() {\n return (\n providedDelegate ||\n new ListKeyboardDelegate({\n collection,\n collator,\n ref: listBoxRef,\n disabledKeys,\n disabledBehavior,\n layout,\n orientation,\n direction\n })\n );\n },\n [collection, collator, listBoxRef, selectionManager, orientation, direction, layout, providedDelegate]\n );\n}\n\n/**\n * Generates data attributes for the ListBox element based on its current state.\n * These attributes are used for styling selectors and accessibility indicators.\n *\n * @param {object} config - Configuration object containing ListBox state flags\n * @param {boolean} config.isEmpty - Whether the listbox has no items\n * @param {boolean} config.isFocused - Whether the listbox is currently focused\n * @param {boolean} config.isFocusVisible - Whether focus should be visually indicated\n * @param {'stack' | 'grid'} [config.layout] - Layout mode (stack or grid)\n * @param {Orientation} [config.orientation] - Primary orientation of the items\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager containing selection state\n * @param {boolean} [config.allowsTabNavigation] - Whether tab navigation is enabled\n * @param {boolean} [config.shouldFocusWrap] - Whether focus wraps at boundaries\n * @param {SelectionBehavior} [config.originalSelectionBehavior] - Original selection behavior setting\n * @returns {Record<string, unknown>} Object with data attributes for the ListBox element\n * @internal\n */\nfunction useListBoxDataAttributes({\n isEmpty,\n isFocused,\n isFocusVisible,\n layout,\n orientation,\n selectionManager,\n allowsTabNavigation,\n shouldFocusWrap,\n originalSelectionBehavior\n}: {\n readonly isEmpty: boolean;\n readonly isFocused: boolean;\n readonly isFocusVisible: boolean;\n readonly layout?: 'stack' | 'grid';\n readonly orientation?: Orientation;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly allowsTabNavigation?: boolean;\n readonly shouldFocusWrap?: boolean;\n readonly originalSelectionBehavior?: SelectionBehavior;\n}) {\n return useDataAttributes({\n empty: isEmpty,\n focused: isFocused,\n 'focus-visible': isFocusVisible,\n layout,\n orientation,\n 'selection-mode': selectionManager.selectionMode !== 'none' ? selectionManager.selectionMode : undefined,\n 'selection-behavior': originalSelectionBehavior !== undefined ? selectionManager.selectionBehavior : undefined,\n 'allows-tab-navigation': allowsTabNavigation,\n 'focus-wrap': shouldFocusWrap\n });\n}\n\n/**\n * Composes all props for the ListBox element including DOM props, ARIA props,\n * focus props, and data attributes. Handles prop application through useProps\n * and manages ref assignment to avoid proxy extensibility issues.\n *\n * @param {object} config - Configuration object containing all props to compose\n * @param {Record<string, unknown>} config.otherProps - Additional props from the component\n * @param {ListBoxRenderProps} config.renderValues - Values available to render functions\n * @param {Record<string, unknown>} config.listBoxProps - Props from useListBox hook\n * @param {Record<string, unknown>} config.focusProps - Props from useFocusRing hook\n * @param {Record<string, unknown>} config.dataAttributes - Data attributes for styling/selectors\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager for ARIA attributes\n * @param {React.RefObject<HTMLDivElement>} config.listBoxRef - Reference to attach to the final element\n * @returns {Record<string, unknown>} Composed props object ready for the ListBox element\n * @internal\n */\nfunction useComposedProps({\n otherProps,\n renderValues,\n listBoxProps,\n focusProps,\n dataAttributes,\n selectionManager,\n listBoxRef\n}: {\n readonly otherProps: Record<string, unknown>;\n readonly renderValues: ListBoxRenderProps;\n readonly listBoxProps: Record<string, unknown>;\n readonly focusProps: Record<string, unknown>;\n readonly dataAttributes: Record<string, unknown>;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly listBoxRef: React.RefObject<HTMLDivElement>;\n}) {\n const { apply } = useProps(otherProps, renderValues);\n\n const propsToExclude = [\n 'renderEmptyState',\n 'selectionMode',\n 'defaultSelectedKeys',\n 'disabledKeys',\n 'disallowEmptySelection',\n 'shouldFocusWrap',\n 'items',\n 'children',\n 'selectionBehavior',\n 'keyboardDelegate'\n ];\n\n // Apply user props directly (preserves className, style, etc.)\n const appliedUserProps = apply(otherProps, propsToExclude);\n\n // React Aria and Bento props\n const baseProps = {\n ...mergeProps(listBoxProps, focusProps),\n ...dataAttributes,\n ...(selectionManager.selectionMode !== 'none' && {\n 'aria-multiselectable': selectionManager.selectionMode === 'multiple'\n })\n };\n\n //\n // Merge all props together with user props taking precedence\n //\n const finalProps = {\n ...baseProps,\n ...appliedUserProps,\n ref: listBoxRef // Set ref directly to avoid extensibility issues\n };\n\n return finalProps;\n}\n\n/**\n * Renders the empty state content for the ListBox when no items are present.\n * Handles both function-based render props and direct JSX elements.\n * If a function is provided, calls it with render values; otherwise returns as-is.\n *\n * @param {(props: ListBoxRenderProps) => React.ReactNode} renderEmptyStateFn - Function or JSX element to render for empty state\n * @param {ListBoxRenderProps} renderValues - Current render values to pass to render function\n * @returns {React.ReactNode} Rendered empty state content\n * @internal\n */\nfunction renderEmptyState(\n renderEmptyStateFn: (props: ListBoxRenderProps) => React.ReactNode,\n renderValues: ListBoxRenderProps\n): React.ReactNode {\n //\n // Handle cases where renderEmptyState is not a function (e.g., JSX element passed directly)\n //\n if (typeof renderEmptyStateFn === 'function') {\n return renderEmptyStateFn(renderValues);\n }\n //\n // If it's not a function, just return it as-is (likely a JSX element)\n //\n return renderEmptyStateFn as React.ReactNode;\n}\n\n/**\n * Renders all items in the collection as React elements.\n * Handles both regular items and section items, using the appropriate\n * components (ListBoxItemImpl for items, ListBoxSectionInner for sections).\n *\n * @param {ListState<unknown>['collection']} collection - The collection of items to render\n * @returns {React.ReactElement[]} Array of rendered React elements for all collection items\n * @internal\n */\nfunction renderCollectionItems(collection: ListState<unknown>['collection']): React.ReactElement[] {\n return [...collection].map(function renderCollectionItem(item: Node<unknown>) {\n return item.type === 'section' ? (\n <ListBoxSectionInner key={item.key} section={item} />\n ) : (\n <ListBoxItemImpl key={item.key} __node={item as Node<object>}>\n {item.rendered}\n </ListBoxItemImpl>\n );\n });\n}\n\n/**\n * Determines what content to render inside the ListBox based on its configuration.\n * Handles three cases:\n * 1. Function children without items (Bento render prop pattern with full render props)\n * 2. Empty state when no items and renderEmptyState is provided\n * 3. Normal collection rendering (including items with children functions for React Aria compatibility)\n *\n * @param {object} config - Configuration object for rendering\n * @param {React.ReactNode | ((item: unknown) => React.ReactNode) | ((props: ListBoxRenderProps) => React.ReactNode)} [config.children] - Children prop (static, item render function, or ListBox render prop)\n * @param {Iterable<unknown>} [config.items] - Items array for dynamic collections\n * @param {boolean} config.isEmpty - Whether the collection is empty\n * @param {(props: ListBoxRenderProps) => React.ReactNode} [config.renderEmptyStateProp] - Function to render empty state\n * @param {ListBoxRenderProps} config.renderValues - Current render values for render functions\n * @param {ListState<unknown>['collection']} config.collection - The collection state to render\n * @returns {React.ReactNode} The appropriate content to render inside the ListBox\n * @internal\n */\nfunction renderListBoxContent({\n children,\n items,\n isEmpty,\n renderEmptyStateProp,\n renderValues,\n collection\n}: {\n readonly children?:\n | React.ReactNode\n | ((item: unknown) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n readonly items?: Iterable<unknown>;\n readonly isEmpty: boolean;\n readonly renderEmptyStateProp?: (props: ListBoxRenderProps) => React.ReactNode;\n readonly renderValues: ListBoxRenderProps;\n readonly collection: ListState<unknown>['collection'];\n}): React.ReactNode {\n // If children is a function AND no items provided, use Bento render prop pattern\n /* v8 ignore next */\n const hasRenderChildren = typeof children === 'function' && !items;\n\n /* v8 ignore next 3 */\n if (hasRenderChildren) {\n return (children as (props: ListBoxRenderProps) => React.ReactNode)(renderValues);\n }\n\n // Handle empty state\n if (isEmpty && renderEmptyStateProp) {\n return renderEmptyState(renderEmptyStateProp, renderValues);\n }\n\n // Render collection items (React Aria handles items + children function internally)\n return renderCollectionItems(collection);\n}\n\n/**\n * Internal ListBox component that handles the core rendering logic.\n * This component manages all the hooks, state, and prop composition needed\n * for a fully functional ListBox. It's wrapped by the main ListBox component\n * which handles collection building.\n *\n * @param {object} props - Component props\n * @param {ListState<unknown>} props.state - The ListBox state instance\n * @param {(props: ListBoxRenderProps) => React.ReactNode} [props.renderEmptyState] - Function to render when no items are present\n * @param {React.ReactNode | ((item: unknown) => React.ReactNode) | ((props: ListBoxRenderProps) => React.ReactNode)} [props.children] - Static children, item render function, or ListBox render function\n * @param {Iterable<unknown>} [props.items] - Items array for dynamic collections\n * @param {React.RefObject<HTMLDivElement>} props.listBoxRef - Reference to the ListBox DOM element\n * @param {'stack'} [props.layout] - Layout mode (stack or grid)\n * @param {Orientation} [props.orientation] - Primary orientation of the items\n * @param {boolean} [props.shouldSelectOnPressUp] - Whether selection occurs on pointer up\n * @param {ListKeyboardDelegate<unknown>} [props.keyboardDelegate] - Custom keyboard navigation delegate\n * @param {boolean} [props.allowsTabNavigation] - Whether tab key navigates between items\n * @param {boolean} [props.shouldFocusWrap] - Whether focus wraps at boundaries\n * @param {'none' | 'single' | 'multiple'} [props.selectionMode] - Selection mode (none, single, multiple)\n * @param {SelectionBehavior} [props.selectionBehavior] - Selection behavior (toggle, replace)\n * @returns {React.ReactElement} A fully functional ListBox element with focus scope\n * @internal\n */\nconst ListBoxInner: React.FC<{\n readonly state: ListState<unknown>;\n readonly renderEmptyState?: (props: ListBoxRenderProps) => React.ReactNode;\n readonly children?:\n | React.ReactNode\n | ((item: unknown) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n readonly items?: Iterable<unknown>;\n readonly listBoxRef: RefObject<HTMLDivElement>;\n readonly layout?: 'stack';\n readonly orientation?: Orientation;\n readonly shouldSelectOnPressUp?: boolean;\n readonly keyboardDelegate?: ListKeyboardDelegate<unknown>;\n readonly allowsTabNavigation?: boolean;\n readonly shouldFocusWrap?: boolean;\n readonly selectionMode?: 'none' | 'single' | 'multiple';\n readonly selectionBehavior?: SelectionBehavior;\n}> = function ListBoxInner({\n state,\n renderEmptyState: renderEmptyStateProp,\n children,\n items,\n listBoxRef,\n ...otherProps\n}) {\n const { layout = 'stack', orientation = 'vertical', shouldSelectOnPressUp, selectionBehavior } = otherProps;\n\n const { collection, selectionManager } = state;\n const { direction } = useLocale();\n const collator = useCollator({ usage: 'search', sensitivity: 'base' });\n\n const keyboardDelegate = useKeyboardDelegate({\n collection,\n collator,\n listBoxRef,\n selectionManager,\n layout,\n orientation,\n direction,\n keyboardDelegate: otherProps.keyboardDelegate\n });\n\n const { listBoxProps } = useListBox(\n {\n ...otherProps,\n shouldSelectOnPressUp,\n keyboardDelegate\n },\n state,\n listBoxRef\n );\n\n const { focusProps, isFocused, isFocusVisible } = useFocusRing();\n const isEmpty = state.collection.size === 0;\n\n const renderValues: ListBoxRenderProps = {\n isEmpty,\n isFocused,\n isFocusVisible,\n isDropTarget: false,\n layout,\n state,\n items\n };\n\n const dataAttributes = useListBoxDataAttributes({\n isEmpty,\n isFocused,\n isFocusVisible,\n layout,\n orientation,\n selectionManager,\n allowsTabNavigation: otherProps.allowsTabNavigation,\n shouldFocusWrap: otherProps.shouldFocusWrap,\n originalSelectionBehavior: selectionBehavior\n });\n\n const composedProps = useComposedProps({\n otherProps,\n renderValues,\n listBoxProps: listBoxProps as Record<string, unknown>,\n focusProps: focusProps as Record<string, unknown>,\n dataAttributes,\n selectionManager,\n listBoxRef\n });\n\n return (\n <FocusScope>\n <div {...composedProps}>\n {renderListBoxContent({\n children,\n items,\n isEmpty,\n renderEmptyStateProp,\n renderValues,\n collection\n })}\n </div>\n </FocusScope>\n );\n};\n\n/**\n * A complete ListBox component providing accessible selection lists with keyboard navigation.\n * Supports both static children and dynamic collections, with single/multiple selection modes.\n * Built on React Aria with full ARIA compliance and keyboard accessibility.\n *\n * @component\n * @template T The type of items in the collection\n * @param {ListBoxProps<T>} args - The properties passed to the ListBox component\n * @param {React.ForwardedRef<HTMLDivElement>} ref - The ref to the listbox container\n * @returns {React.ReactElement} A ListBox component\n *\n * @example\n * ```tsx\n * <ListBox aria-label=\"Fruits\" selectionMode=\"single\">\n * <ListBoxItem id=\"apple\" textValue=\"Apple\">Apple</ListBoxItem>\n * <ListBoxItem id=\"banana\" textValue=\"Banana\">Banana</ListBoxItem>\n * </ListBox>\n * ```\n * @public\n */\nfunction ListBoxComponent<T>(args: ListBoxProps<T>, ref: React.ForwardedRef<HTMLDivElement>): React.ReactElement {\n return (\n <CollectionBuilder content={<AriaCollection {...(args as unknown as Parameters<typeof AriaCollection>[0])} />}>\n {function buildCollection(collection: unknown) {\n return <StandaloneListBox props={args as ListBoxProps<unknown>} listBoxRef={ref} collection={collection} />;\n }}\n </CollectionBuilder>\n );\n}\n\n/**\n * Standalone ListBox component that manages its own state and collection.\n * This component is used internally by the main ListBox component after\n * collection building is complete. It handles prop processing, state creation,\n * and context management.\n *\n * @param {object} props - Component props\n * @param {ListBoxProps<unknown>} props.props - The original ListBox props\n * @param {React.ForwardedRef<HTMLDivElement>} props.listBoxRef - Reference to forward to the ListBox element\n * @param {unknown} props.collection - Built collection from CollectionBuilder\n * @returns {React.ReactElement} A complete ListBox with state management and optional context wrapping\n * @internal\n */\nconst StandaloneListBox: React.FC<{\n readonly props: ListBoxProps<unknown>;\n readonly listBoxRef: ForwardedRef<HTMLDivElement>;\n readonly collection: unknown;\n}> = function StandaloneListBox({ props, listBoxRef, collection }) {\n //\n // Extract renderEmptyState before useProps processes it to avoid render prop corruption\n //\n const originalRenderEmptyState = props.renderEmptyState;\n\n const { props: processedProps } = useProps(props);\n const processedRef = useSafeObjectRef(listBoxRef);\n const { state, contextState } = useListBoxState({ ...processedProps, collection });\n\n const { renderEmptyState: _, ...cleanProcessedProps } = processedProps as ListBoxProps<unknown> & {\n renderEmptyState?: unknown;\n };\n\n const content = (\n <ListBoxInner\n state={state}\n listBoxRef={processedRef}\n renderEmptyState={originalRenderEmptyState}\n {...cleanProcessedProps}\n />\n );\n\n return renderWithOptionalContext(content, state, contextState);\n};\n\n/**\n * A complete ListBox component providing accessible selection lists with keyboard navigation.\n * Supports both static children and dynamic collections, with single/multiple selection modes.\n * Built on React Aria with full ARIA compliance and keyboard accessibility.\n *\n * @component\n * @example\n * ```tsx\n * <ListBox aria-label=\"Fruits\" selectionMode=\"single\">\n * <ListBoxItem id=\"apple\" textValue=\"Apple\">Apple</ListBoxItem>\n * <ListBoxItem id=\"banana\" textValue=\"Banana\">Banana</ListBoxItem>\n * </ListBox>\n * ```\n * @public\n */\nexport const ListBox = withSlots('BentoListBox', ListBoxComponent);\n\n/**\n * Collection component for building dynamic collections in ListBox.\n * Re-exported from React Aria Collections.\n * @public\n */\nexport { AriaCollection as Collection };\n\n/**\n * Context for sharing ListBox state across components.\n * Used internally by ListBoxItem and ListBoxSection components.\n * @public\n */\nexport { ListStateContext };\n","import React, { ForwardedRef, ReactNode, createContext, useContext, useMemo } from 'react';\nimport { mergeProps, useOption, useHover } from 'react-aria';\nimport { createLeafComponent } from '@react-aria/collections';\nimport { HoverEvents, Key, LinkDOMProps, Node } from '@react-types/shared';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { ListStateContext } from './listbox';\nimport { useSafeObjectRef } from './utils';\nimport { withSlots } from '@bento/slots';\n\n/**\n * Context value structure for text-related slot attributes.\n * Used to provide label and description attributes to child components.\n * @interface TextContextValue\n */\ninterface TextContextValue {\n readonly slots: {\n /** Attributes for label elements */\n readonly label?: React.HTMLAttributes<HTMLElement>;\n /** Attributes for description elements */\n readonly description?: React.HTMLAttributes<HTMLElement>;\n };\n}\n\n/**\n * Internal context for providing text-related slot attributes to child components.\n * This context allows ListBoxItem to pass label and description attributes\n * to nested components that need them for accessibility.\n * @internal\n */\nconst TextContext = createContext<TextContextValue>({ slots: {} });\n\n/**\n * Render props provided to ListBoxItem render functions.\n * @interface ListBoxItemRenderProps\n */\nexport interface ListBoxItemRenderProps {\n /**\n * Whether the item is currently hovered.\n * @selector [data-hovered]\n */\n readonly isHovered: boolean;\n /**\n * Whether the item is currently pressed.\n * @selector [data-pressed]\n */\n readonly isPressed: boolean;\n /**\n * Whether the item is currently selected.\n * @selector [data-selected]\n */\n readonly isSelected: boolean;\n /**\n * Whether the item is currently focused.\n * @selector [data-focused]\n */\n readonly isFocused: boolean;\n /**\n * Whether the item is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n readonly isFocusVisible: boolean;\n /**\n * Whether the item is disabled.\n * @selector [data-disabled]\n */\n readonly isDisabled: boolean;\n /**\n * The type of selection that is allowed in the collection.\n * @selector [data-selection-mode=\"none | single | multiple\"]\n */\n readonly selectionMode: 'none' | 'single' | 'multiple';\n /**\n * The selection behavior for the collection.\n * @selector [data-selection-behavior=\"toggle | replace\"]\n */\n readonly selectionBehavior: 'toggle' | 'replace';\n}\n\n/**\n * Props for the ListBoxItem component.\n * @interface ListBoxItemProps\n * @template T The type of the item value\n */\nexport interface ListBoxItemProps<T = object>\n extends LinkDOMProps,\n HoverEvents,\n Omit<React.HTMLAttributes<HTMLElement>, keyof LinkDOMProps | keyof HoverEvents | 'id' | 'children'> {\n /** The unique id of the item. If not provided, React Aria will auto-generate one. */\n readonly id?: Key;\n /** The object value that this item represents. When using dynamic collections, this is set automatically. */\n readonly value?: T;\n /** A string representation of the item's contents, used for features like typeahead. If not provided, React Aria will derive it from children automatically. */\n readonly textValue?: string;\n /**\n * Handler that is called when a user performs an action on the item. The exact user event depends on the\n * collection's `selectionBehavior` prop and the interaction modality.\n */\n readonly onAction?: () => void;\n /** The contents of the item. Can be a render function that receives render props. */\n readonly children?: ReactNode | ((values: ListBoxItemRenderProps) => ReactNode);\n /**\n * A slot name for the component. Used by Bento's slot system.\n */\n readonly slot?: string;\n /** Whether the item is disabled. */\n readonly isDisabled?: boolean;\n}\n\n/**\n * Internal implementation component for ListBoxItem.\n * Handles the core logic for rendering a single listbox item with proper accessibility.\n * This component manages all the hooks, state, and interactions needed for a functional\n * listbox item including selection, hover, focus, and keyboard interactions.\n *\n * @template T - The type of the item value\n * @param {object} props - Combined ListBoxItem props and internal node data\n * @param {Node<T>} props.__node - Internal React Aria node containing item metadata\n * @param {React.ReactNode | ((values: ListBoxItemRenderProps) => React.ReactNode)} [props.children] - Content to render, can be static or a render function\n * @param {boolean} [props.isDisabled] - Whether the item is disabled\n * @param {string} [props.aria-label] - ARIA label for accessibility\n * @param {(e: HoverEvent) => void} [props.onHoverStart] - Handler for hover start events\n * @param {(isHovering: boolean) => void} [props.onHoverChange] - Handler for hover change events\n * @param {(e: HoverEvent) => void} [props.onHoverEnd] - Handler for hover end events\n * @param {React.ForwardedRef<HTMLDivElement>} ref - Forwarded ref to the item element\n * @returns {React.ReactElement} A fully interactive listbox item with accessibility and state management\n * @internal\n */\nconst ListBoxItemImplComponent = function ListBoxItemImplComponent<T extends object>(\n { __node, ...props }: ListBoxItemProps<T> & { readonly __node: Node<T> },\n ref: ForwardedRef<HTMLDivElement>\n) {\n const state = useContext(ListStateContext)!;\n const safeRef = useSafeObjectRef(ref);\n\n const { optionProps, labelProps, descriptionProps, ...states } = useOption(\n {\n key: __node.key,\n 'aria-label': props['aria-label'],\n isDisabled: props.isDisabled\n },\n state,\n safeRef\n );\n\n const { hoverProps, isHovered } = useHover({\n isDisabled: states.isDisabled,\n onHoverStart: props.onHoverStart,\n onHoverChange: props.onHoverChange,\n onHoverEnd: props.onHoverEnd\n });\n\n const renderValues: ListBoxItemRenderProps = {\n ...states,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior\n };\n\n const content = typeof props.children === 'function' ? props.children(renderValues) : props.children;\n\n const { apply } = useProps(props, renderValues);\n\n const dataAttributes = useDataAttributes({\n selected: states.isSelected,\n disabled: states.isDisabled,\n hovered: isHovered,\n focused: states.isFocused,\n 'focus-visible': states.isFocusVisible,\n pressed: states.isPressed,\n level: __node.level,\n 'selection-mode': state.selectionManager.selectionMode,\n 'selection-behavior': state.selectionManager.selectionBehavior\n });\n\n const textContext = useMemo(\n function createTextContext() {\n return {\n slots: {\n label: labelProps,\n description: descriptionProps\n }\n };\n },\n [labelProps, descriptionProps]\n );\n\n const ElementType = __node.props.href ? 'a' : 'div';\n\n // Use original node props (which contain className) not filtered finalProps\n const appliedUserProps = apply(__node.props, ['ref']);\n\n const finalAttributes = {\n ...mergeProps(optionProps, hoverProps), // React Aria props\n ...dataAttributes, // Bento data attributes\n ...appliedUserProps,\n ref: safeRef,\n 'data-text-value': __node.textValue\n };\n\n return (\n <TextContext.Provider value={textContext}>\n {React.createElement(ElementType, finalAttributes, content)}\n </TextContext.Provider>\n );\n};\n\n/**\n * Enhanced ListBoxItem implementation with slots support.\n * This wraps the core ListBoxItemImplComponent with Bento's slot system\n * for advanced composition and styling capabilities.\n * @internal\n */\nexport const ListBoxItemImpl = withSlots('BentoListBoxItem', ListBoxItemImplComponent);\n\n/**\n * Adapter component that connects ListBoxItemImpl to React Aria's collection system.\n * This function serves as a bridge between React Aria's createLeafComponent and\n * the internal ListBoxItemImpl, ensuring proper prop forwarding and node injection.\n *\n * @template T - The type of the item value\n * @param {ListBoxItemProps<T>} props - ListBoxItem component props\n * @param {React.ForwardedRef<HTMLDivElement>} forwardedRef - Ref forwarded from the collection system\n * @param {Node<T>} item - React Aria node containing item metadata and collection info\n * @returns {React.ReactElement} The ListBoxItemImpl component with proper node and ref wiring\n * @internal\n */\nfunction ListBoxItemComponent<T extends object>(\n props: ListBoxItemProps<T>,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n item: Node<T>\n) {\n return <ListBoxItemImpl {...props} ref={forwardedRef as any} __node={item} />;\n}\n\n/**\n * Base ListBoxItem component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state.\n * @internal\n */\nconst ListBoxItemBase = createLeafComponent('item', ListBoxItemComponent);\n\n/**\n * A single item within a ListBox component.\n * Handles user interactions, accessibility, and state management for individual options.\n *\n * @component\n * @template T The type of the item value\n * @example\n * ```tsx\n * <ListBoxItem>Simple option</ListBoxItem>\n * ```\n * @public\n */\nexport const ListBoxItem = ListBoxItemBase;\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -224,7 +224,7 @@ interface ListBoxProps<T> extends Omit<AriaListBoxProps<T>, 'label' | 'children'
|
|
|
224
224
|
* ```
|
|
225
225
|
* @public
|
|
226
226
|
*/
|
|
227
|
-
declare const ListBox: React.
|
|
227
|
+
declare const ListBox: React.MemoExoticComponent<React.ComponentType<ListBoxProps<unknown> & Slots>>;
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
230
|
* Props for the ListBoxSection component.
|
package/dist/index.d.ts
CHANGED
|
@@ -224,7 +224,7 @@ interface ListBoxProps<T> extends Omit<AriaListBoxProps<T>, 'label' | 'children'
|
|
|
224
224
|
* ```
|
|
225
225
|
* @public
|
|
226
226
|
*/
|
|
227
|
-
declare const ListBox: React.
|
|
227
|
+
declare const ListBox: React.MemoExoticComponent<React.ComponentType<ListBoxProps<unknown> & Slots>>;
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
230
|
* Props for the ListBoxSection component.
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React4, { createContext,
|
|
1
|
+
import React4, { createContext, useContext, useRef, useMemo, useEffect } from 'react';
|
|
2
2
|
import { createLeafComponent, createBranchComponent, CollectionBuilder, Collection } from '@react-aria/collections';
|
|
3
3
|
export { Collection } from '@react-aria/collections';
|
|
4
4
|
import { useProps } from '@bento/use-props';
|
|
@@ -12,7 +12,7 @@ import { CollectionRendererContext } from 'react-aria-components';
|
|
|
12
12
|
var HeaderContext = createContext({});
|
|
13
13
|
var BentoHeaderImpl = withSlots(
|
|
14
14
|
"BentoHeader",
|
|
15
|
-
|
|
15
|
+
function BentoHeader(props, ref) {
|
|
16
16
|
const { props: processedProps, apply } = useProps(props);
|
|
17
17
|
const contextProps = useContext(HeaderContext);
|
|
18
18
|
const appliedUserProps = apply(processedProps);
|
|
@@ -22,29 +22,26 @@ var BentoHeaderImpl = withSlots(
|
|
|
22
22
|
// User props take precedence over context
|
|
23
23
|
};
|
|
24
24
|
return /* @__PURE__ */ React4.createElement("header", { ...composed, ref: contextProps.ref || ref }, processedProps.children);
|
|
25
|
-
}
|
|
25
|
+
}
|
|
26
26
|
);
|
|
27
27
|
function HeaderWrapper(props, ref) {
|
|
28
28
|
return /* @__PURE__ */ React4.createElement(BentoHeaderImpl, { ...props, ref });
|
|
29
29
|
}
|
|
30
30
|
var HeaderBase = createLeafComponent("header", HeaderWrapper);
|
|
31
31
|
var Header = HeaderBase;
|
|
32
|
-
var BentoListBoxSectionImpl = withSlots(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return /* @__PURE__ */ React4.createElement("section", { ...composed, ref }, /* @__PURE__ */ React4.createElement(HeaderContext.Provider, { value: { ...headingProps, ref: headingRef } }, title && /* @__PURE__ */ React4.createElement("div", { ...headingProps }, title), sectionContent));
|
|
46
|
-
})
|
|
47
|
-
);
|
|
32
|
+
var BentoListBoxSectionImpl = withSlots("BentoListBoxSection", function BentoListBoxSectionImpl2({ __node, children, title: titleProp, ...rest }, ref) {
|
|
33
|
+
const { props, apply } = useProps(rest);
|
|
34
|
+
const data = useDataAttributes({ level: __node?.level });
|
|
35
|
+
const headingRef = useRef(null);
|
|
36
|
+
const title = titleProp ?? props.title ?? __node?.rendered;
|
|
37
|
+
const { groupProps, headingProps } = useListBoxSection({
|
|
38
|
+
heading: title,
|
|
39
|
+
"aria-label": props["aria-label"]
|
|
40
|
+
});
|
|
41
|
+
const composed = mergeProps(apply({ ...data, ...props }, ["children", "title", "slot"]), groupProps);
|
|
42
|
+
const sectionContent = children || props.children;
|
|
43
|
+
return /* @__PURE__ */ React4.createElement("section", { ...composed, ref }, /* @__PURE__ */ React4.createElement(HeaderContext.Provider, { value: { ...headingProps, ref: headingRef } }, title && /* @__PURE__ */ React4.createElement("div", { ...headingProps }, title), sectionContent));
|
|
44
|
+
});
|
|
48
45
|
function ListBoxSectionWrapper(props, ref, section) {
|
|
49
46
|
return /* @__PURE__ */ React4.createElement(BentoListBoxSectionImpl, { ...props, __node: section, ref });
|
|
50
47
|
}
|
|
@@ -358,7 +355,7 @@ var ListBoxItemImplComponent = function ListBoxItemImplComponent2({ __node, ...p
|
|
|
358
355
|
};
|
|
359
356
|
return /* @__PURE__ */ React4.createElement(TextContext.Provider, { value: textContext }, React4.createElement(ElementType, finalAttributes, content));
|
|
360
357
|
};
|
|
361
|
-
var ListBoxItemImpl = withSlots("BentoListBoxItem",
|
|
358
|
+
var ListBoxItemImpl = withSlots("BentoListBoxItem", ListBoxItemImplComponent);
|
|
362
359
|
function ListBoxItemComponent(props, forwardedRef, item) {
|
|
363
360
|
return /* @__PURE__ */ React4.createElement(ListBoxItemImpl, { ...props, ref: forwardedRef, __node: item });
|
|
364
361
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/header.tsx","../src/listbox-section.tsx","../src/utils.ts","../src/listbox.tsx","../src/listbox-item.tsx"],"names":["React","withSlots","forwardRef","BentoListBoxSectionImpl","useProps","ListBoxSectionInner","useContext","useRef","createContext","useDataAttributes","mergeProps","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AAG,gBAAA;AAAA,IACH,GAAA,EAAK,OAAA;AAAA,IACL,mBAAmB,MAAA,CAAO;AAAA,GAC5B;AAEA,EAAA,uBACEV,MAAAA,CAAA,aAAA,CAAC,WAAA,CAAY,QAAA,EAAZ,EAAqB,KAAA,EAAO,WAAA,EAAA,EAC1BA,MAAAA,CAAM,aAAA,CAAc,WAAA,EAAa,eAAA,EAAiB,OAAO,CAC5D,CAAA;AAEJ,CAAA;AAQO,IAAM,eAAA,GAAkBC,SAAAA,CAAU,kBAAA,EAAoBC,UAAAA,CAAW,wBAAwB,CAAC,CAAA;AAcjG,SAAS,oBAAA,CACP,KAAA,EACA,YAAA,EACA,IAAA,EACA;AACA,EAAA,uBAAOF,OAAA,aAAA,CAAC,eAAA,EAAA,EAAiB,GAAG,KAAA,EAAO,GAAA,EAAK,YAAA,EAAc,MAAA,EAAQ,IAAA,EAAM,CAAA;AACtE;AAOA,IAAM,eAAA,GAAkBgB,mBAAAA,CAAoB,MAAA,EAAQ,oBAAoB,CAAA;AAcjE,IAAM,WAAA,GAAc","file":"index.js","sourcesContent":["import React, { forwardRef, createContext, useContext } from 'react';\nimport { createLeafComponent } from '@react-aria/collections';\nimport { useProps } from '@bento/use-props';\nimport { withSlots, type Slots } from '@bento/slots';\n\n/**\n * Props for the Header component.\n * @interface HeaderProps\n */\nexport interface HeaderProps extends Slots, React.ComponentProps<'header'> {\n /**\n * The children of the header.\n */\n readonly children?: React.ReactNode;\n}\n\n/**\n * Context value structure for Header components.\n * Extends HTML attributes to support all standard header element properties.\n * @interface HeaderContextValue\n */\ninterface HeaderContextValue extends React.HTMLAttributes<HTMLElement> {\n /**\n * Reference to the header element for forwarding.\n */\n readonly ref?: React.RefObject<HTMLDivElement>;\n}\n\n/**\n * Combined props type for the internal BentoHeader implementation.\n * Merges Header-specific props with standard HTML attributes to provide\n * a comprehensive interface for the internal header component.\n *\n * @type BentoHeaderProps\n * @internal\n */\ntype BentoHeaderProps = HeaderProps & React.HTMLAttributes<HTMLElement>;\n\n/**\n * React context for providing header-related attributes and refs to Header components.\n * Used internally by ListBoxSection to pass heading props to Header elements.\n * @public\n */\nexport const HeaderContext = createContext<HeaderContextValue>({});\n\n/**\n * Internal implementation of the BentoHeader component with slots support.\n * This component handles prop processing and context integration.\n * It merges props from useProps and HeaderContext while preserving styling props.\n *\n * @internal\n */\nconst BentoHeaderImpl = withSlots(\n 'BentoHeader',\n forwardRef(function BentoHeader(props: BentoHeaderProps, ref: React.ForwardedRef<HTMLElement>) {\n const { props: processedProps, apply } = useProps(props);\n const contextProps = useContext(HeaderContext);\n\n // Apply user props directly (preserves className, style, etc.)\n const appliedUserProps = apply(processedProps);\n\n const composed = {\n ...contextProps,\n ...appliedUserProps // User props take precedence over context\n };\n\n return (\n <header {...composed} ref={contextProps.ref || ref}>\n {processedProps.children}\n </header>\n );\n })\n);\n\n/**\n * Wrapper component that connects the BentoHeaderImpl to React Aria's collection system.\n * This function serves as an adapter between the createLeafComponent system and\n * the internal BentoHeaderImpl component, ensuring proper prop forwarding and ref handling.\n *\n * @param {HeaderProps} props - Header component props\n * @param {React.ReactNode} [props.children] - React children to render inside the header\n * @param {React.ForwardedRef<HTMLElement>} ref - Forwarded ref to the header element\n * @returns {React.ReactElement} The BentoHeaderImpl component with forwarded props and ref\n * @internal\n */\nfunction HeaderWrapper(props: HeaderProps, ref: React.ForwardedRef<HTMLElement>) {\n return <BentoHeaderImpl {...props} ref={ref} />;\n}\n\n/**\n * A Header represents a heading for a section within a ListBox.\n * Uses React Aria's createLeafComponent for automatic collection handling.\n *\n * @component\n * @param {HeaderProps} props - The props for the Header component\n * @param {React.ForwardedRef<HTMLElement>} ref - Forwarded ref to the header element\n * @returns {JSX.Element} A header element with proper accessibility attributes\n *\n * @example\n * ```tsx\n * <Header>My Section Title</Header>\n * ```\n * @public\n */\n/**\n * Base Header component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state and\n * integrates with the collection rendering system.\n * @internal\n */\nconst HeaderBase = createLeafComponent('header', HeaderWrapper);\n\n/**\n * A Header component for section headings within a ListBox.\n * Provides semantic header structure with proper accessibility attributes\n * and integrates with React Aria's collection system for automatic handling.\n *\n * This is the main public interface for creating headers in ListBox sections.\n * It automatically receives heading props from the parent ListBoxSection via HeaderContext.\n *\n * @component\n * @example\n * ```tsx\n * <ListBoxSection>\n * <Header>Fruits</Header>\n * <ListBoxItem>Apple</ListBoxItem>\n * <ListBoxItem>Banana</ListBoxItem>\n * </ListBoxSection>\n * ```\n * @public\n */\nexport const Header = HeaderBase as React.ForwardRefExoticComponent<HeaderProps & React.RefAttributes<HTMLElement>>;\n","import React, { forwardRef, useRef, useContext } from 'react';\nimport { useListBoxSection, mergeProps } from 'react-aria';\nimport { createBranchComponent } from '@react-aria/collections';\nimport { CollectionRendererContext } from 'react-aria-components';\nimport type { Node } from '@react-types/shared';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport { HeaderContext } from './header';\nimport { ListStateContext } from './listbox';\n\n/**\n * Props for the ListBoxSection component.\n * @interface ListBoxSectionProps\n */\nexport interface ListBoxSectionProps extends Omit<React.ComponentProps<'section'>, 'title'> {\n /**\n * A slot name for the component. Used by Bento's slot system.\n */\n readonly slot?: string;\n /**\n * The title of the section.\n */\n readonly title?: React.ReactNode;\n /**\n * The children of the section.\n */\n readonly children?: React.ReactNode;\n}\n\n/**\n * Internal props interface for BentoListBoxSectionImpl component.\n * Extends ListBoxSectionProps with internal React Aria node data and allows\n * additional properties for flexibility in prop handling.\n *\n * @interface BentoListBoxSectionImplProps\n * @template T - The type of the section node data\n * @internal\n */\ninterface BentoListBoxSectionImplProps<T = unknown> extends ListBoxSectionProps {\n readonly __node?: Node<T>;\n readonly [key: string]: unknown;\n}\n\n/**\n * Props interface for the ListBoxSectionInner component.\n * Contains the React Aria section node that represents this section\n * in the collection hierarchy for dynamic rendering.\n *\n * @interface ListBoxSectionInnerProps\n * @internal\n */\ninterface ListBoxSectionInnerProps {\n readonly section: Node<unknown>;\n}\n\n/**\n * Internal implementation of the BentoListBoxSection component with slots support.\n * This component handles the core logic for rendering a section within a ListBox,\n * including title rendering, accessibility attributes, and child content management.\n * It integrates with React Aria's useListBoxSection hook for proper ARIA compliance.\n *\n * @internal\n */\nconst BentoListBoxSectionImpl = withSlots(\n 'BentoListBoxSection',\n forwardRef(function BentoListBoxSectionImpl<T>(\n { __node, children, title: titleProp, ...rest }: BentoListBoxSectionImplProps<T>,\n ref: React.ForwardedRef<HTMLElement>\n ) {\n const { props, apply } = useProps(rest);\n const data = useDataAttributes({ level: __node?.level });\n const headingRef = useRef<HTMLDivElement>(null);\n\n const title = titleProp ?? props.title ?? __node?.rendered;\n const { groupProps, headingProps } = useListBoxSection({\n heading: title,\n 'aria-label': props['aria-label']\n });\n\n const composed = mergeProps(apply({ ...data, ...props }, ['children', 'title', 'slot']), groupProps);\n\n const sectionContent = children || props.children;\n\n return (\n <section {...composed} ref={ref}>\n <HeaderContext.Provider value={{ ...headingProps, ref: headingRef }}>\n {title && <div {...headingProps}>{title}</div>}\n {sectionContent}\n </HeaderContext.Provider>\n </section>\n );\n })\n);\n\n/**\n * Wrapper component that connects BentoListBoxSectionImpl to React Aria's collection system.\n * This function serves as an adapter between createBranchComponent and the internal\n * BentoListBoxSectionImpl, ensuring proper prop forwarding and node injection for sections.\n *\n * @template T - The type of the section node data\n * @param {ListBoxSectionProps} props - ListBoxSection component props\n * @param {string} [props.slot] - Slot name for Bento's slot system\n * @param {React.ReactNode} [props.title] - Title for the section\n * @param {React.ReactNode} [props.children] - Children to render in the section\n * @param {string} [props.aria-label] - ARIA label for accessibility\n * @param {React.ForwardedRef<HTMLElement>} ref - Ref forwarded from the collection system\n * @param {Node<T>} section - React Aria node containing section metadata and collection info\n * @returns {React.ReactElement} The BentoListBoxSectionImpl component with proper node and ref wiring\n * @internal\n */\n/* v8 ignore start */\nfunction ListBoxSectionWrapper<T extends object>(\n props: ListBoxSectionProps,\n ref: React.ForwardedRef<HTMLElement>,\n section: Node<T>\n) {\n return <BentoListBoxSectionImpl {...props} __node={section} ref={ref} />;\n}\n/* v8 ignore stop */\n\n/**\n * Base ListBoxSection component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state and\n * manages the branch structure for nested items.\n * @internal\n */\nconst ListBoxSectionBase = createBranchComponent('section', ListBoxSectionWrapper);\n\n/**\n * Internal component for rendering dynamic collection sections.\n * This component is used specifically for sections that are part of a dynamic collection,\n * connecting to the ListStateContext and CollectionRendererContext to properly render\n * nested items through React Aria's collection system.\n *\n * @component\n * @param {object} props - The component props containing the section node\n * @param {Node<unknown>} props.section - The React Aria node representing this section in the collection\n * @throws {BentoError} Throws an error if used outside of a ListBox context\n * @returns {React.ReactElement} JSX element representing a dynamically rendered listbox section\n * @internal\n */\nexport const ListBoxSectionInner: React.FC<ListBoxSectionInnerProps> = function ListBoxSectionInner({ section }) {\n const state = useContext(ListStateContext);\n const { CollectionBranch } = useContext(CollectionRendererContext);\n\n return (\n <BentoListBoxSectionImpl {...section.props} __node={section}>\n {CollectionBranch && state?.collection ? (\n <CollectionBranch collection={state.collection} parent={section} />\n ) : null}\n </BentoListBoxSectionImpl>\n );\n};\n\n/**\n * A section component for organizing related items within a ListBox.\n *\n * @component\n * @example\n * ```tsx\n * <ListBoxSection title=\"Fruits\">\n * <ListBoxItem>Apple</ListBoxItem>\n * <ListBoxItem>Banana</ListBoxItem>\n * </ListBoxSection>\n * ```\n * @public\n */\nexport const ListBoxSection = ListBoxSectionBase as <_T extends object>(\n props: ListBoxSectionProps & { children?: React.ReactNode }\n) => React.ReactElement;\n","/* v8 ignore next */\nimport React, { type ForwardedRef, useEffect, useRef } from 'react';\n\n/**\n * NOTE: This utility will be moved to the new use-collection package.\n * Safe wrapper for React Aria's useObjectRef that handles test environments where refs are not extensible.\n *\n * **Critical for Vitest Browser Mode Testing**: When running tests in Vitest's browser mode with Playwright,\n * the test environment can freeze or make objects non-extensible. React Aria's `useObjectRef` attempts to\n * dynamically add properties to ref objects, which fails with \"Cannot add property current, object is not extensible\"\n * in these constrained test environments.\n *\n * **Technical Details:**\n * - Vitest browser mode uses Playwright's Chrome DevTools Protocol for test execution\n * - The V8 engine's security model can freeze objects during test isolation\n * - React Aria's useObjectRef uses `Object.defineProperty()` to add reactive properties to refs\n * - This conflicts with frozen objects in browser testing scenarios\n *\n * **Why This Solution Works:**\n * - Creates an internal ref that's always mutable (created in our controlled environment)\n * - Safely forwards values to the external ref using try/catch for frozen object scenarios\n * - Maintains the same ref forwarding behavior as React Aria's useObjectRef in normal environments\n * - Gracefully degrades in test environments without breaking functionality\n *\n * **Production Impact**: Zero. Object freezing only occurs in specific test configurations.\n * In production and development, this behaves identically to React Aria's useObjectRef.\n *\n * @template T - The type of the ref element\n * @param {React.ForwardedRef<T>} ref - The forwarded ref to handle safely\n * @returns {React.RefObject<T>} A safe ref object that works in all environments including frozen test contexts\n * @public\n */\nexport function useSafeObjectRef<T>(ref: ForwardedRef<T>): React.RefObject<T> {\n const internalRef = useRef<T>(null);\n\n useEffect(function updateForwardedRef() {\n const current = internalRef.current;\n\n if (typeof ref === 'function') {\n ref(current);\n } else if (ref && 'current' in ref) {\n try {\n (ref as React.MutableRefObject<T | null>).current = current;\n /* v8 ignore start */\n } catch {\n //\n // Silently ignore errors in test environments where objects might be frozen.\n // This specifically handles Vitest browser mode with Playwright where the V8 engine\n // may freeze ref objects during test isolation, preventing dynamic property assignment.\n //\n }\n /* v8 ignore stop */\n }\n });\n\n return internalRef;\n}\n","import React, { createContext, useContext, useMemo, ForwardedRef, RefObject } from 'react';\nimport {\n FocusScope,\n mergeProps,\n useCollator,\n useLocale,\n useListBox,\n useFocusRing,\n ListKeyboardDelegate\n} from 'react-aria';\nimport { ListState, SelectionBehavior, useListState, Orientation, Node } from 'react-stately';\nimport { CollectionBuilder, Collection as AriaCollection } from '@react-aria/collections';\nimport { AriaListBoxProps } from '@react-types/listbox';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots, Slots } from '@bento/slots';\nimport { ListBoxItemImpl } from './listbox-item';\nimport { ListBoxSectionInner } from './listbox-section';\nimport { useSafeObjectRef } from './utils';\n\n/**\n * Render props provided to ListBox render functions and empty state renderers.\n * @interface ListBoxRenderProps\n */\nexport interface ListBoxRenderProps {\n /**\n * Whether the listbox has no items and should display its empty state.\n * @selector [data-empty]\n */\n readonly isEmpty: boolean;\n /**\n * Whether the listbox is currently focused.\n * @selector [data-focused]\n */\n readonly isFocused: boolean;\n /**\n * Whether the listbox is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n readonly isFocusVisible: boolean;\n /**\n * Whether the listbox is currently the active drop target.\n * @selector [data-drop-target]\n */\n readonly isDropTarget: boolean;\n /**\n * Whether the items are arranged in a stack or grid.\n * @selector [data-layout=\"stack | grid\"]\n */\n readonly layout?: 'stack' | 'grid';\n /**\n * State of the listbox.\n */\n readonly state: ListState<unknown>;\n /**\n * The items array when using dynamic collections.\n */\n readonly items?: Iterable<unknown>;\n}\n\n/**\n * Props for the ListBox component.\n * @interface ListBoxProps\n * @template T The type of items in the collection\n */\nexport interface ListBoxProps<T>\n extends Omit<AriaListBoxProps<T>, 'label' | 'children'>,\n Omit<React.ComponentProps<'div'>, keyof AriaListBoxProps<T> | 'children'>,\n Slots {\n /**\n * How multiple selection should behave in the collection.\n */\n readonly selectionBehavior?: SelectionBehavior;\n /**\n * Provides content to display when there are no items in the list.\n */\n readonly renderEmptyState?: (props: ListBoxRenderProps) => React.ReactNode;\n /**\n * Whether the items are arranged in a stack layout.\n * @default 'stack'\n */\n readonly layout?: 'stack';\n /**\n * The primary orientation of the items. Usually this is the direction that the collection scrolls.\n * @default 'vertical'\n */\n readonly orientation?: Orientation;\n /**\n * Static children or render function for the ListBox.\n * When items prop is provided, children receives individual items for React Aria compatibility.\n * When no items prop is provided, children receives Bento render props { isEmpty, isFocused, state, etc. }.\n */\n readonly children?:\n | React.ReactNode\n | ((item: T) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n}\n\n/**\n * React context for sharing ListBox state across components.\n * This context provides the ListBox state to child components like ListBoxItem and ListBoxSection,\n * enabling them to access selection state, collection data, and other shared functionality.\n *\n * @context\n * @internal\n */\nconst ListStateContext = createContext<ListState<unknown> | null>(null);\n\n/**\n * Custom hook to manage ListBox state creation and context handling.\n * This hook either uses an existing state from context or creates a new one.\n * It's designed to work both as a standalone component and within a parent component\n * that provides ListBox state through context.\n *\n * @param {Record<string, unknown>} props - Configuration object for the ListBox state\n * @returns {object} An object containing the state instance and context state flag\n * @returns {ListState<unknown>} returns.state - The ListBox state instance\n * @returns {ListState<unknown> | null} returns.contextState - Existing context state, if any\n * @internal\n */\nfunction useListBoxState(props: Record<string, unknown>) {\n const contextState = useContext(ListStateContext);\n\n const stateProps = {\n ...props,\n children: undefined,\n items: undefined\n };\n\n const state = contextState ?? useListState(stateProps);\n\n return { state, contextState };\n}\n\n/**\n * Renders content with optional context provider wrapper.\n * If no context state exists, wraps the content in a ListStateContext.Provider.\n * This allows the ListBox to work both standalone and as part of a larger component tree.\n *\n * @param {React.ReactNode} content - The React content to render\n * @param {ListState<unknown>} state - The ListBox state to provide via context\n * @param {ListState<unknown> | null} contextState - Existing context state, if any\n * @returns {React.ReactNode} The content, optionally wrapped in a context provider\n * @internal\n */\nfunction renderWithOptionalContext(\n content: React.ReactNode,\n state: ListState<unknown>,\n contextState: ListState<unknown> | null\n): React.ReactNode {\n /* v8 ignore next */\n return contextState ? content : <ListStateContext.Provider value={state}>{content}</ListStateContext.Provider>;\n}\n\n/**\n * Creates and memoizes a keyboard delegate for the ListBox.\n * The keyboard delegate handles keyboard navigation logic, including\n * arrow key navigation, home/end keys, and type-ahead functionality.\n *\n * @param {object} config - Configuration object for the keyboard delegate\n * @param {ListState<unknown>['collection']} config.collection - The collection of items in the ListBox\n * @param {Intl.Collator} config.collator - Intl collator for string comparison in type-ahead\n * @param {React.RefObject<HTMLDivElement>} config.listBoxRef - Reference to the ListBox DOM element\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager from the state\n * @param {'stack' | 'grid'} [config.layout] - Layout mode (stack or grid)\n * @param {Orientation} [config.orientation] - Primary orientation of the items\n * @param {'ltr' | 'rtl'} config.direction - Text direction (ltr or rtl)\n * @param {ListKeyboardDelegate<unknown>} [config.keyboardDelegate] - Custom keyboard delegate to use instead of default\n * @returns {ListKeyboardDelegate<unknown>} A keyboard delegate instance for handling keyboard interactions\n * @internal\n */\nfunction useKeyboardDelegate({\n collection,\n collator,\n listBoxRef,\n selectionManager,\n layout,\n orientation,\n direction,\n keyboardDelegate: providedDelegate\n}: {\n readonly collection: ListState<unknown>['collection'];\n readonly collator: Intl.Collator;\n readonly listBoxRef: React.RefObject<HTMLDivElement>;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly layout?: 'stack' | 'grid';\n readonly orientation?: Orientation;\n readonly direction: 'ltr' | 'rtl';\n readonly keyboardDelegate?: ListKeyboardDelegate<unknown>;\n}): ListKeyboardDelegate<unknown> {\n const { disabledBehavior, disabledKeys } = selectionManager;\n\n return useMemo(\n function createKeyboardDelegate() {\n return (\n providedDelegate ||\n new ListKeyboardDelegate({\n collection,\n collator,\n ref: listBoxRef,\n disabledKeys,\n disabledBehavior,\n layout,\n orientation,\n direction\n })\n );\n },\n [collection, collator, listBoxRef, selectionManager, orientation, direction, layout, providedDelegate]\n );\n}\n\n/**\n * Generates data attributes for the ListBox element based on its current state.\n * These attributes are used for styling selectors and accessibility indicators.\n *\n * @param {object} config - Configuration object containing ListBox state flags\n * @param {boolean} config.isEmpty - Whether the listbox has no items\n * @param {boolean} config.isFocused - Whether the listbox is currently focused\n * @param {boolean} config.isFocusVisible - Whether focus should be visually indicated\n * @param {'stack' | 'grid'} [config.layout] - Layout mode (stack or grid)\n * @param {Orientation} [config.orientation] - Primary orientation of the items\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager containing selection state\n * @param {boolean} [config.allowsTabNavigation] - Whether tab navigation is enabled\n * @param {boolean} [config.shouldFocusWrap] - Whether focus wraps at boundaries\n * @param {SelectionBehavior} [config.originalSelectionBehavior] - Original selection behavior setting\n * @returns {Record<string, unknown>} Object with data attributes for the ListBox element\n * @internal\n */\nfunction useListBoxDataAttributes({\n isEmpty,\n isFocused,\n isFocusVisible,\n layout,\n orientation,\n selectionManager,\n allowsTabNavigation,\n shouldFocusWrap,\n originalSelectionBehavior\n}: {\n readonly isEmpty: boolean;\n readonly isFocused: boolean;\n readonly isFocusVisible: boolean;\n readonly layout?: 'stack' | 'grid';\n readonly orientation?: Orientation;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly allowsTabNavigation?: boolean;\n readonly shouldFocusWrap?: boolean;\n readonly originalSelectionBehavior?: SelectionBehavior;\n}) {\n return useDataAttributes({\n empty: isEmpty,\n focused: isFocused,\n 'focus-visible': isFocusVisible,\n layout,\n orientation,\n 'selection-mode': selectionManager.selectionMode !== 'none' ? selectionManager.selectionMode : undefined,\n 'selection-behavior': originalSelectionBehavior !== undefined ? selectionManager.selectionBehavior : undefined,\n 'allows-tab-navigation': allowsTabNavigation,\n 'focus-wrap': shouldFocusWrap\n });\n}\n\n/**\n * Composes all props for the ListBox element including DOM props, ARIA props,\n * focus props, and data attributes. Handles prop application through useProps\n * and manages ref assignment to avoid proxy extensibility issues.\n *\n * @param {object} config - Configuration object containing all props to compose\n * @param {Record<string, unknown>} config.otherProps - Additional props from the component\n * @param {ListBoxRenderProps} config.renderValues - Values available to render functions\n * @param {Record<string, unknown>} config.listBoxProps - Props from useListBox hook\n * @param {Record<string, unknown>} config.focusProps - Props from useFocusRing hook\n * @param {Record<string, unknown>} config.dataAttributes - Data attributes for styling/selectors\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager for ARIA attributes\n * @param {React.RefObject<HTMLDivElement>} config.listBoxRef - Reference to attach to the final element\n * @returns {Record<string, unknown>} Composed props object ready for the ListBox element\n * @internal\n */\nfunction useComposedProps({\n otherProps,\n renderValues,\n listBoxProps,\n focusProps,\n dataAttributes,\n selectionManager,\n listBoxRef\n}: {\n readonly otherProps: Record<string, unknown>;\n readonly renderValues: ListBoxRenderProps;\n readonly listBoxProps: Record<string, unknown>;\n readonly focusProps: Record<string, unknown>;\n readonly dataAttributes: Record<string, unknown>;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly listBoxRef: React.RefObject<HTMLDivElement>;\n}) {\n const { apply } = useProps(otherProps, renderValues);\n\n const propsToExclude = [\n 'renderEmptyState',\n 'selectionMode',\n 'defaultSelectedKeys',\n 'disabledKeys',\n 'disallowEmptySelection',\n 'shouldFocusWrap',\n 'items',\n 'children',\n 'selectionBehavior',\n 'keyboardDelegate'\n ];\n\n // Apply user props directly (preserves className, style, etc.)\n const appliedUserProps = apply(otherProps, propsToExclude);\n\n // React Aria and Bento props\n const baseProps = {\n ...mergeProps(listBoxProps, focusProps),\n ...dataAttributes,\n ...(selectionManager.selectionMode !== 'none' && {\n 'aria-multiselectable': selectionManager.selectionMode === 'multiple'\n })\n };\n\n //\n // Merge all props together with user props taking precedence\n //\n const finalProps = {\n ...baseProps,\n ...appliedUserProps,\n ref: listBoxRef // Set ref directly to avoid extensibility issues\n };\n\n return finalProps;\n}\n\n/**\n * Renders the empty state content for the ListBox when no items are present.\n * Handles both function-based render props and direct JSX elements.\n * If a function is provided, calls it with render values; otherwise returns as-is.\n *\n * @param {(props: ListBoxRenderProps) => React.ReactNode} renderEmptyStateFn - Function or JSX element to render for empty state\n * @param {ListBoxRenderProps} renderValues - Current render values to pass to render function\n * @returns {React.ReactNode} Rendered empty state content\n * @internal\n */\nfunction renderEmptyState(\n renderEmptyStateFn: (props: ListBoxRenderProps) => React.ReactNode,\n renderValues: ListBoxRenderProps\n): React.ReactNode {\n //\n // Handle cases where renderEmptyState is not a function (e.g., JSX element passed directly)\n //\n if (typeof renderEmptyStateFn === 'function') {\n return renderEmptyStateFn(renderValues);\n }\n //\n // If it's not a function, just return it as-is (likely a JSX element)\n //\n return renderEmptyStateFn as React.ReactNode;\n}\n\n/**\n * Renders all items in the collection as React elements.\n * Handles both regular items and section items, using the appropriate\n * components (ListBoxItemImpl for items, ListBoxSectionInner for sections).\n *\n * @param {ListState<unknown>['collection']} collection - The collection of items to render\n * @returns {React.ReactElement[]} Array of rendered React elements for all collection items\n * @internal\n */\nfunction renderCollectionItems(collection: ListState<unknown>['collection']): React.ReactElement[] {\n return [...collection].map(function renderCollectionItem(item: Node<unknown>) {\n return item.type === 'section' ? (\n <ListBoxSectionInner key={item.key} section={item} />\n ) : (\n <ListBoxItemImpl key={item.key} __node={item as Node<object>}>\n {item.rendered}\n </ListBoxItemImpl>\n );\n });\n}\n\n/**\n * Determines what content to render inside the ListBox based on its configuration.\n * Handles three cases:\n * 1. Function children without items (Bento render prop pattern with full render props)\n * 2. Empty state when no items and renderEmptyState is provided\n * 3. Normal collection rendering (including items with children functions for React Aria compatibility)\n *\n * @param {object} config - Configuration object for rendering\n * @param {React.ReactNode | ((item: unknown) => React.ReactNode) | ((props: ListBoxRenderProps) => React.ReactNode)} [config.children] - Children prop (static, item render function, or ListBox render prop)\n * @param {Iterable<unknown>} [config.items] - Items array for dynamic collections\n * @param {boolean} config.isEmpty - Whether the collection is empty\n * @param {(props: ListBoxRenderProps) => React.ReactNode} [config.renderEmptyStateProp] - Function to render empty state\n * @param {ListBoxRenderProps} config.renderValues - Current render values for render functions\n * @param {ListState<unknown>['collection']} config.collection - The collection state to render\n * @returns {React.ReactNode} The appropriate content to render inside the ListBox\n * @internal\n */\nfunction renderListBoxContent({\n children,\n items,\n isEmpty,\n renderEmptyStateProp,\n renderValues,\n collection\n}: {\n readonly children?:\n | React.ReactNode\n | ((item: unknown) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n readonly items?: Iterable<unknown>;\n readonly isEmpty: boolean;\n readonly renderEmptyStateProp?: (props: ListBoxRenderProps) => React.ReactNode;\n readonly renderValues: ListBoxRenderProps;\n readonly collection: ListState<unknown>['collection'];\n}): React.ReactNode {\n // If children is a function AND no items provided, use Bento render prop pattern\n /* v8 ignore next */\n const hasRenderChildren = typeof children === 'function' && !items;\n\n /* v8 ignore next 3 */\n if (hasRenderChildren) {\n return (children as (props: ListBoxRenderProps) => React.ReactNode)(renderValues);\n }\n\n // Handle empty state\n if (isEmpty && renderEmptyStateProp) {\n return renderEmptyState(renderEmptyStateProp, renderValues);\n }\n\n // Render collection items (React Aria handles items + children function internally)\n return renderCollectionItems(collection);\n}\n\n/**\n * Internal ListBox component that handles the core rendering logic.\n * This component manages all the hooks, state, and prop composition needed\n * for a fully functional ListBox. It's wrapped by the main ListBox component\n * which handles collection building.\n *\n * @param {object} props - Component props\n * @param {ListState<unknown>} props.state - The ListBox state instance\n * @param {(props: ListBoxRenderProps) => React.ReactNode} [props.renderEmptyState] - Function to render when no items are present\n * @param {React.ReactNode | ((item: unknown) => React.ReactNode) | ((props: ListBoxRenderProps) => React.ReactNode)} [props.children] - Static children, item render function, or ListBox render function\n * @param {Iterable<unknown>} [props.items] - Items array for dynamic collections\n * @param {React.RefObject<HTMLDivElement>} props.listBoxRef - Reference to the ListBox DOM element\n * @param {'stack'} [props.layout] - Layout mode (stack or grid)\n * @param {Orientation} [props.orientation] - Primary orientation of the items\n * @param {boolean} [props.shouldSelectOnPressUp] - Whether selection occurs on pointer up\n * @param {ListKeyboardDelegate<unknown>} [props.keyboardDelegate] - Custom keyboard navigation delegate\n * @param {boolean} [props.allowsTabNavigation] - Whether tab key navigates between items\n * @param {boolean} [props.shouldFocusWrap] - Whether focus wraps at boundaries\n * @param {'none' | 'single' | 'multiple'} [props.selectionMode] - Selection mode (none, single, multiple)\n * @param {SelectionBehavior} [props.selectionBehavior] - Selection behavior (toggle, replace)\n * @returns {React.ReactElement} A fully functional ListBox element with focus scope\n * @internal\n */\nconst ListBoxInner: React.FC<{\n readonly state: ListState<unknown>;\n readonly renderEmptyState?: (props: ListBoxRenderProps) => React.ReactNode;\n readonly children?:\n | React.ReactNode\n | ((item: unknown) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n readonly items?: Iterable<unknown>;\n readonly listBoxRef: RefObject<HTMLDivElement>;\n readonly layout?: 'stack';\n readonly orientation?: Orientation;\n readonly shouldSelectOnPressUp?: boolean;\n readonly keyboardDelegate?: ListKeyboardDelegate<unknown>;\n readonly allowsTabNavigation?: boolean;\n readonly shouldFocusWrap?: boolean;\n readonly selectionMode?: 'none' | 'single' | 'multiple';\n readonly selectionBehavior?: SelectionBehavior;\n}> = function ListBoxInner({\n state,\n renderEmptyState: renderEmptyStateProp,\n children,\n items,\n listBoxRef,\n ...otherProps\n}) {\n const { layout = 'stack', orientation = 'vertical', shouldSelectOnPressUp, selectionBehavior } = otherProps;\n\n const { collection, selectionManager } = state;\n const { direction } = useLocale();\n const collator = useCollator({ usage: 'search', sensitivity: 'base' });\n\n const keyboardDelegate = useKeyboardDelegate({\n collection,\n collator,\n listBoxRef,\n selectionManager,\n layout,\n orientation,\n direction,\n keyboardDelegate: otherProps.keyboardDelegate\n });\n\n const { listBoxProps } = useListBox(\n {\n ...otherProps,\n shouldSelectOnPressUp,\n keyboardDelegate\n },\n state,\n listBoxRef\n );\n\n const { focusProps, isFocused, isFocusVisible } = useFocusRing();\n const isEmpty = state.collection.size === 0;\n\n const renderValues: ListBoxRenderProps = {\n isEmpty,\n isFocused,\n isFocusVisible,\n isDropTarget: false,\n layout,\n state,\n items\n };\n\n const dataAttributes = useListBoxDataAttributes({\n isEmpty,\n isFocused,\n isFocusVisible,\n layout,\n orientation,\n selectionManager,\n allowsTabNavigation: otherProps.allowsTabNavigation,\n shouldFocusWrap: otherProps.shouldFocusWrap,\n originalSelectionBehavior: selectionBehavior\n });\n\n const composedProps = useComposedProps({\n otherProps,\n renderValues,\n listBoxProps: listBoxProps as Record<string, unknown>,\n focusProps: focusProps as Record<string, unknown>,\n dataAttributes,\n selectionManager,\n listBoxRef\n });\n\n return (\n <FocusScope>\n <div {...composedProps}>\n {renderListBoxContent({\n children,\n items,\n isEmpty,\n renderEmptyStateProp,\n renderValues,\n collection\n })}\n </div>\n </FocusScope>\n );\n};\n\n/**\n * A complete ListBox component providing accessible selection lists with keyboard navigation.\n * Supports both static children and dynamic collections, with single/multiple selection modes.\n * Built on React Aria with full ARIA compliance and keyboard accessibility.\n *\n * @component\n * @template T The type of items in the collection\n * @param {ListBoxProps<T>} args - The properties passed to the ListBox component\n * @param {React.ForwardedRef<HTMLDivElement>} ref - The ref to the listbox container\n * @returns {React.ReactElement} A ListBox component\n *\n * @example\n * ```tsx\n * <ListBox aria-label=\"Fruits\" selectionMode=\"single\">\n * <ListBoxItem id=\"apple\" textValue=\"Apple\">Apple</ListBoxItem>\n * <ListBoxItem id=\"banana\" textValue=\"Banana\">Banana</ListBoxItem>\n * </ListBox>\n * ```\n * @public\n */\nfunction ListBoxComponent<T>(args: ListBoxProps<T>, ref: React.ForwardedRef<HTMLDivElement>): React.ReactElement {\n return (\n <CollectionBuilder content={<AriaCollection {...(args as unknown as Parameters<typeof AriaCollection>[0])} />}>\n {function buildCollection(collection: unknown) {\n return <StandaloneListBox props={args as ListBoxProps<unknown>} listBoxRef={ref} collection={collection} />;\n }}\n </CollectionBuilder>\n );\n}\n\n/**\n * Standalone ListBox component that manages its own state and collection.\n * This component is used internally by the main ListBox component after\n * collection building is complete. It handles prop processing, state creation,\n * and context management.\n *\n * @param {object} props - Component props\n * @param {ListBoxProps<unknown>} props.props - The original ListBox props\n * @param {React.ForwardedRef<HTMLDivElement>} props.listBoxRef - Reference to forward to the ListBox element\n * @param {unknown} props.collection - Built collection from CollectionBuilder\n * @returns {React.ReactElement} A complete ListBox with state management and optional context wrapping\n * @internal\n */\nconst StandaloneListBox: React.FC<{\n readonly props: ListBoxProps<unknown>;\n readonly listBoxRef: ForwardedRef<HTMLDivElement>;\n readonly collection: unknown;\n}> = function StandaloneListBox({ props, listBoxRef, collection }) {\n //\n // Extract renderEmptyState before useProps processes it to avoid render prop corruption\n //\n const originalRenderEmptyState = props.renderEmptyState;\n\n const { props: processedProps } = useProps(props);\n const processedRef = useSafeObjectRef(listBoxRef);\n const { state, contextState } = useListBoxState({ ...processedProps, collection });\n\n const { renderEmptyState: _, ...cleanProcessedProps } = processedProps as ListBoxProps<unknown> & {\n renderEmptyState?: unknown;\n };\n\n const content = (\n <ListBoxInner\n state={state}\n listBoxRef={processedRef}\n renderEmptyState={originalRenderEmptyState}\n {...cleanProcessedProps}\n />\n );\n\n return renderWithOptionalContext(content, state, contextState);\n};\n\n/**\n * A complete ListBox component providing accessible selection lists with keyboard navigation.\n * Supports both static children and dynamic collections, with single/multiple selection modes.\n * Built on React Aria with full ARIA compliance and keyboard accessibility.\n *\n * @component\n * @example\n * ```tsx\n * <ListBox aria-label=\"Fruits\" selectionMode=\"single\">\n * <ListBoxItem id=\"apple\" textValue=\"Apple\">Apple</ListBoxItem>\n * <ListBoxItem id=\"banana\" textValue=\"Banana\">Banana</ListBoxItem>\n * </ListBox>\n * ```\n * @public\n */\nexport const ListBox = withSlots('BentoListBox', ListBoxComponent);\n\n/**\n * Collection component for building dynamic collections in ListBox.\n * Re-exported from React Aria Collections.\n * @public\n */\nexport { AriaCollection as Collection };\n\n/**\n * Context for sharing ListBox state across components.\n * Used internally by ListBoxItem and ListBoxSection components.\n * @public\n */\nexport { ListStateContext };\n","import React, { ForwardedRef, ReactNode, createContext, useContext, useMemo, forwardRef } from 'react';\nimport { mergeProps, useOption, useHover } from 'react-aria';\nimport { createLeafComponent } from '@react-aria/collections';\nimport { HoverEvents, Key, LinkDOMProps, Node } from '@react-types/shared';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { ListStateContext } from './listbox';\nimport { useSafeObjectRef } from './utils';\nimport { withSlots } from '@bento/slots';\n\n/**\n * Context value structure for text-related slot attributes.\n * Used to provide label and description attributes to child components.\n * @interface TextContextValue\n */\ninterface TextContextValue {\n readonly slots: {\n /** Attributes for label elements */\n readonly label?: React.HTMLAttributes<HTMLElement>;\n /** Attributes for description elements */\n readonly description?: React.HTMLAttributes<HTMLElement>;\n };\n}\n\n/**\n * Internal context for providing text-related slot attributes to child components.\n * This context allows ListBoxItem to pass label and description attributes\n * to nested components that need them for accessibility.\n * @internal\n */\nconst TextContext = createContext<TextContextValue>({ slots: {} });\n\n/**\n * Render props provided to ListBoxItem render functions.\n * @interface ListBoxItemRenderProps\n */\nexport interface ListBoxItemRenderProps {\n /**\n * Whether the item is currently hovered.\n * @selector [data-hovered]\n */\n readonly isHovered: boolean;\n /**\n * Whether the item is currently pressed.\n * @selector [data-pressed]\n */\n readonly isPressed: boolean;\n /**\n * Whether the item is currently selected.\n * @selector [data-selected]\n */\n readonly isSelected: boolean;\n /**\n * Whether the item is currently focused.\n * @selector [data-focused]\n */\n readonly isFocused: boolean;\n /**\n * Whether the item is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n readonly isFocusVisible: boolean;\n /**\n * Whether the item is disabled.\n * @selector [data-disabled]\n */\n readonly isDisabled: boolean;\n /**\n * The type of selection that is allowed in the collection.\n * @selector [data-selection-mode=\"none | single | multiple\"]\n */\n readonly selectionMode: 'none' | 'single' | 'multiple';\n /**\n * The selection behavior for the collection.\n * @selector [data-selection-behavior=\"toggle | replace\"]\n */\n readonly selectionBehavior: 'toggle' | 'replace';\n}\n\n/**\n * Props for the ListBoxItem component.\n * @interface ListBoxItemProps\n * @template T The type of the item value\n */\nexport interface ListBoxItemProps<T = object>\n extends LinkDOMProps,\n HoverEvents,\n Omit<React.HTMLAttributes<HTMLElement>, keyof LinkDOMProps | keyof HoverEvents | 'id' | 'children'> {\n /** The unique id of the item. If not provided, React Aria will auto-generate one. */\n readonly id?: Key;\n /** The object value that this item represents. When using dynamic collections, this is set automatically. */\n readonly value?: T;\n /** A string representation of the item's contents, used for features like typeahead. If not provided, React Aria will derive it from children automatically. */\n readonly textValue?: string;\n /**\n * Handler that is called when a user performs an action on the item. The exact user event depends on the\n * collection's `selectionBehavior` prop and the interaction modality.\n */\n readonly onAction?: () => void;\n /** The contents of the item. Can be a render function that receives render props. */\n readonly children?: ReactNode | ((values: ListBoxItemRenderProps) => ReactNode);\n /**\n * A slot name for the component. Used by Bento's slot system.\n */\n readonly slot?: string;\n /** Whether the item is disabled. */\n readonly isDisabled?: boolean;\n}\n\n/**\n * Internal implementation component for ListBoxItem.\n * Handles the core logic for rendering a single listbox item with proper accessibility.\n * This component manages all the hooks, state, and interactions needed for a functional\n * listbox item including selection, hover, focus, and keyboard interactions.\n *\n * @template T - The type of the item value\n * @param {object} props - Combined ListBoxItem props and internal node data\n * @param {Node<T>} props.__node - Internal React Aria node containing item metadata\n * @param {React.ReactNode | ((values: ListBoxItemRenderProps) => React.ReactNode)} [props.children] - Content to render, can be static or a render function\n * @param {boolean} [props.isDisabled] - Whether the item is disabled\n * @param {string} [props.aria-label] - ARIA label for accessibility\n * @param {(e: HoverEvent) => void} [props.onHoverStart] - Handler for hover start events\n * @param {(isHovering: boolean) => void} [props.onHoverChange] - Handler for hover change events\n * @param {(e: HoverEvent) => void} [props.onHoverEnd] - Handler for hover end events\n * @param {React.ForwardedRef<HTMLDivElement>} ref - Forwarded ref to the item element\n * @returns {React.ReactElement} A fully interactive listbox item with accessibility and state management\n * @internal\n */\nconst ListBoxItemImplComponent = function ListBoxItemImplComponent<T extends object>(\n { __node, ...props }: ListBoxItemProps<T> & { readonly __node: Node<T> },\n ref: ForwardedRef<HTMLDivElement>\n) {\n const state = useContext(ListStateContext)!;\n const safeRef = useSafeObjectRef(ref);\n\n const { optionProps, labelProps, descriptionProps, ...states } = useOption(\n {\n key: __node.key,\n 'aria-label': props['aria-label'],\n isDisabled: props.isDisabled\n },\n state,\n safeRef\n );\n\n const { hoverProps, isHovered } = useHover({\n isDisabled: states.isDisabled,\n onHoverStart: props.onHoverStart,\n onHoverChange: props.onHoverChange,\n onHoverEnd: props.onHoverEnd\n });\n\n const renderValues: ListBoxItemRenderProps = {\n ...states,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior\n };\n\n const content = typeof props.children === 'function' ? props.children(renderValues) : props.children;\n\n const { apply } = useProps(props, renderValues);\n\n const dataAttributes = useDataAttributes({\n selected: states.isSelected,\n disabled: states.isDisabled,\n hovered: isHovered,\n focused: states.isFocused,\n 'focus-visible': states.isFocusVisible,\n pressed: states.isPressed,\n level: __node.level,\n 'selection-mode': state.selectionManager.selectionMode,\n 'selection-behavior': state.selectionManager.selectionBehavior\n });\n\n const textContext = useMemo(\n function createTextContext() {\n return {\n slots: {\n label: labelProps,\n description: descriptionProps\n }\n };\n },\n [labelProps, descriptionProps]\n );\n\n const ElementType = __node.props.href ? 'a' : 'div';\n\n // Use original node props (which contain className) not filtered finalProps\n const appliedUserProps = apply(__node.props, ['ref']);\n\n const finalAttributes = {\n ...mergeProps(optionProps, hoverProps), // React Aria props\n ...dataAttributes, // Bento data attributes\n ...appliedUserProps,\n ref: safeRef,\n 'data-text-value': __node.textValue\n };\n\n return (\n <TextContext.Provider value={textContext}>\n {React.createElement(ElementType, finalAttributes, content)}\n </TextContext.Provider>\n );\n};\n\n/**\n * Enhanced ListBoxItem implementation with slots support.\n * This wraps the core ListBoxItemImplComponent with Bento's slot system\n * for advanced composition and styling capabilities.\n * @internal\n */\nexport const ListBoxItemImpl = withSlots('BentoListBoxItem', forwardRef(ListBoxItemImplComponent));\n\n/**\n * Adapter component that connects ListBoxItemImpl to React Aria's collection system.\n * This function serves as a bridge between React Aria's createLeafComponent and\n * the internal ListBoxItemImpl, ensuring proper prop forwarding and node injection.\n *\n * @template T - The type of the item value\n * @param {ListBoxItemProps<T>} props - ListBoxItem component props\n * @param {React.ForwardedRef<HTMLDivElement>} forwardedRef - Ref forwarded from the collection system\n * @param {Node<T>} item - React Aria node containing item metadata and collection info\n * @returns {React.ReactElement} The ListBoxItemImpl component with proper node and ref wiring\n * @internal\n */\nfunction ListBoxItemComponent<T extends object>(\n props: ListBoxItemProps<T>,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n item: Node<T>\n) {\n return <ListBoxItemImpl {...props} ref={forwardedRef} __node={item} />;\n}\n\n/**\n * Base ListBoxItem component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state.\n * @internal\n */\nconst ListBoxItemBase = createLeafComponent('item', ListBoxItemComponent);\n\n/**\n * A single item within a ListBox component.\n * Handles user interactions, accessibility, and state management for individual options.\n *\n * @component\n * @template T The type of the item value\n * @example\n * ```tsx\n * <ListBoxItem>Simple option</ListBoxItem>\n * ```\n * @public\n */\nexport const ListBoxItem = ListBoxItemBase;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/header.tsx","../src/listbox-section.tsx","../src/utils.ts","../src/listbox.tsx","../src/listbox-item.tsx"],"names":["React","withSlots","BentoListBoxSectionImpl","useProps","ListBoxSectionInner","useContext","useRef","createContext","useDataAttributes","mergeProps","ListBoxInner","AriaCollection","StandaloneListBox","ListBoxItemImplComponent","useMemo","createLeafComponent"],"mappings":";;;;;;;;;;;AA2CO,IAAM,aAAA,GAAgB,aAAA,CAAkC,EAAE;AASjE,IAAM,eAAA,GAAkB,SAAA;AAAA,EACtB,aAAA;AAAA,EACA,SAAS,WAAA,CAAY,KAAA,EAAyB,GAAA,EAAsC;AAClF,IAAA,MAAM,EAAE,KAAA,EAAO,cAAA,EAAgB,KAAA,EAAM,GAAI,SAAS,KAAK,CAAA;AACvD,IAAA,MAAM,YAAA,GAAe,WAAW,aAAa,CAAA;AAG7C,IAAA,MAAM,gBAAA,GAAmB,MAAM,cAAc,CAAA;AAE7C,IAAA,MAAM,QAAA,GAAW;AAAA,MACf,GAAG,YAAA;AAAA,MACH,GAAG;AAAA;AAAA,KACL;AAEA,IAAA,uBACEA,MAAA,CAAA,aAAA,CAAC,YAAQ,GAAG,QAAA,EAAU,KAAK,YAAA,CAAa,GAAA,IAAO,GAAA,EAAA,EAC5C,cAAA,CAAe,QAClB,CAAA;AAAA,EAEJ;AACF,CAAA;AAaA,SAAS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AA,GAAoB;AAC3B,MAAA,OAAO;AAAA,QACL,KAAA,EAAO;AAAA,UACL,KAAA,EAAO,UAAA;AAAA,UACP,WAAA,EAAa;AAAA;AACf,OACF;AAAA,IACF,CAAA;AAAA,IACA,CAAC,YAAY,gBAAgB;AAAA,GAC/B;AAEA,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,KAAA,CAAM,IAAA,GAAO,GAAA,GAAM,KAAA;AAG9C,EAAA,MAAM,mBAAmB,KAAA,CAAM,MAAA,CAAO,KAAA,EAAO,CAAC,KAAK,CAAC,CAAA;AAEpD,EAAA,MAAM,eAAA,GAAkB;AAAA,IACtB,GAAGL,UAAAA,CAAW,WAAA,EAAa,UAAU,CAAA;AAAA;AAAA,IACrC,GAAG,cAAA;AAAA;AAAA,IACH,GAAG,gBAAA;AAAA,IACH,GAAA,EAAK,OAAA;AAAA,IACL,mBAAmB,MAAA,CAAO;AAAA,GAC5B;AAEA,EAAA,uBACET,MAAAA,CAAA,aAAA,CAAC,WAAA,CAAY,QAAA,EAAZ,EAAqB,KAAA,EAAO,WAAA,EAAA,EAC1BA,MAAAA,CAAM,aAAA,CAAc,WAAA,EAAa,eAAA,EAAiB,OAAO,CAC5D,CAAA;AAEJ,CAAA;AAQO,IAAM,eAAA,GAAkBC,SAAAA,CAAU,kBAAA,EAAoB,wBAAwB,CAAA;AAcrF,SAAS,oBAAA,CACP,KAAA,EACA,YAAA,EACA,IAAA,EACA;AACA,EAAA,uBAAOD,OAAA,aAAA,CAAC,eAAA,EAAA,EAAiB,GAAG,KAAA,EAAO,GAAA,EAAK,YAAA,EAAqB,MAAA,EAAQ,IAAA,EAAM,CAAA;AAC7E;AAOA,IAAM,eAAA,GAAkBe,mBAAAA,CAAoB,MAAA,EAAQ,oBAAoB,CAAA;AAcjE,IAAM,WAAA,GAAc","file":"index.js","sourcesContent":["import React, { createContext, useContext } from 'react';\nimport { createLeafComponent } from '@react-aria/collections';\nimport { useProps } from '@bento/use-props';\nimport { withSlots, type Slots } from '@bento/slots';\n\n/**\n * Props for the Header component.\n * @interface HeaderProps\n */\nexport interface HeaderProps extends Slots, React.ComponentProps<'header'> {\n /**\n * The children of the header.\n */\n readonly children?: React.ReactNode;\n}\n\n/**\n * Context value structure for Header components.\n * Extends HTML attributes to support all standard header element properties.\n * @interface HeaderContextValue\n */\ninterface HeaderContextValue extends React.HTMLAttributes<HTMLElement> {\n /**\n * Reference to the header element for forwarding.\n */\n readonly ref?: React.RefObject<HTMLDivElement>;\n}\n\n/**\n * Combined props type for the internal BentoHeader implementation.\n * Merges Header-specific props with standard HTML attributes to provide\n * a comprehensive interface for the internal header component.\n *\n * @type BentoHeaderProps\n * @internal\n */\ntype BentoHeaderProps = HeaderProps & React.HTMLAttributes<HTMLElement>;\n\n/**\n * React context for providing header-related attributes and refs to Header components.\n * Used internally by ListBoxSection to pass heading props to Header elements.\n * @public\n */\nexport const HeaderContext = createContext<HeaderContextValue>({});\n\n/**\n * Internal implementation of the BentoHeader component with slots support.\n * This component handles prop processing and context integration.\n * It merges props from useProps and HeaderContext while preserving styling props.\n *\n * @internal\n */\nconst BentoHeaderImpl = withSlots(\n 'BentoHeader',\n function BentoHeader(props: BentoHeaderProps, ref: React.ForwardedRef<HTMLElement>) {\n const { props: processedProps, apply } = useProps(props);\n const contextProps = useContext(HeaderContext);\n\n // Apply user props directly (preserves className, style, etc.)\n const appliedUserProps = apply(processedProps);\n\n const composed = {\n ...contextProps,\n ...appliedUserProps // User props take precedence over context\n };\n\n return (\n <header {...composed} ref={contextProps.ref || ref}>\n {processedProps.children}\n </header>\n );\n }\n);\n\n/**\n * Wrapper component that connects the BentoHeaderImpl to React Aria's collection system.\n * This function serves as an adapter between the createLeafComponent system and\n * the internal BentoHeaderImpl component, ensuring proper prop forwarding and ref handling.\n *\n * @param {HeaderProps} props - Header component props\n * @param {React.ReactNode} [props.children] - React children to render inside the header\n * @param {React.ForwardedRef<HTMLElement>} ref - Forwarded ref to the header element\n * @returns {React.ReactElement} The BentoHeaderImpl component with forwarded props and ref\n * @internal\n */\nfunction HeaderWrapper(props: HeaderProps, ref: React.ForwardedRef<HTMLElement>) {\n return <BentoHeaderImpl {...props} ref={ref} />;\n}\n\n/**\n * A Header represents a heading for a section within a ListBox.\n * Uses React Aria's createLeafComponent for automatic collection handling.\n *\n * @component\n * @param {HeaderProps} props - The props for the Header component\n * @param {React.ForwardedRef<HTMLElement>} ref - Forwarded ref to the header element\n * @returns {JSX.Element} A header element with proper accessibility attributes\n *\n * @example\n * ```tsx\n * <Header>My Section Title</Header>\n * ```\n * @public\n */\n/**\n * Base Header component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state and\n * integrates with the collection rendering system.\n * @internal\n */\nconst HeaderBase = createLeafComponent('header', HeaderWrapper);\n\n/**\n * A Header component for section headings within a ListBox.\n * Provides semantic header structure with proper accessibility attributes\n * and integrates with React Aria's collection system for automatic handling.\n *\n * This is the main public interface for creating headers in ListBox sections.\n * It automatically receives heading props from the parent ListBoxSection via HeaderContext.\n *\n * @component\n * @example\n * ```tsx\n * <ListBoxSection>\n * <Header>Fruits</Header>\n * <ListBoxItem>Apple</ListBoxItem>\n * <ListBoxItem>Banana</ListBoxItem>\n * </ListBoxSection>\n * ```\n * @public\n */\nexport const Header = HeaderBase as React.ForwardRefExoticComponent<HeaderProps & React.RefAttributes<HTMLElement>>;\n","import React, { useRef, useContext } from 'react';\nimport { useListBoxSection, mergeProps } from 'react-aria';\nimport { createBranchComponent } from '@react-aria/collections';\nimport { CollectionRendererContext } from 'react-aria-components';\nimport type { Node } from '@react-types/shared';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport { HeaderContext } from './header';\nimport { ListStateContext } from './listbox';\n\n/**\n * Props for the ListBoxSection component.\n * @interface ListBoxSectionProps\n */\nexport interface ListBoxSectionProps extends Omit<React.ComponentProps<'section'>, 'title'> {\n /**\n * A slot name for the component. Used by Bento's slot system.\n */\n readonly slot?: string;\n /**\n * The title of the section.\n */\n readonly title?: React.ReactNode;\n /**\n * The children of the section.\n */\n readonly children?: React.ReactNode;\n}\n\n/**\n * Internal props interface for BentoListBoxSectionImpl component.\n * Extends ListBoxSectionProps with internal React Aria node data and allows\n * additional properties for flexibility in prop handling.\n *\n * @interface BentoListBoxSectionImplProps\n * @template T - The type of the section node data\n * @internal\n */\ninterface BentoListBoxSectionImplProps<T = unknown> extends ListBoxSectionProps {\n readonly __node?: Node<T>;\n readonly [key: string]: unknown;\n}\n\n/**\n * Props interface for the ListBoxSectionInner component.\n * Contains the React Aria section node that represents this section\n * in the collection hierarchy for dynamic rendering.\n *\n * @interface ListBoxSectionInnerProps\n * @internal\n */\ninterface ListBoxSectionInnerProps {\n readonly section: Node<unknown>;\n}\n\n/**\n * Internal implementation of the BentoListBoxSection component with slots support.\n * This component handles the core logic for rendering a section within a ListBox,\n * including title rendering, accessibility attributes, and child content management.\n * It integrates with React Aria's useListBoxSection hook for proper ARIA compliance.\n *\n * @internal\n */\nconst BentoListBoxSectionImpl = withSlots('BentoListBoxSection', function BentoListBoxSectionImpl<\n T\n>({ __node, children, title: titleProp, ...rest }: BentoListBoxSectionImplProps<T>, ref: React.ForwardedRef<HTMLElement>) {\n const { props, apply } = useProps(rest);\n const data = useDataAttributes({ level: __node?.level });\n const headingRef = useRef<HTMLDivElement>(null);\n\n const title = titleProp ?? props.title ?? __node?.rendered;\n const { groupProps, headingProps } = useListBoxSection({\n heading: title,\n 'aria-label': props['aria-label']\n });\n\n const composed = mergeProps(apply({ ...data, ...props }, ['children', 'title', 'slot']), groupProps);\n\n const sectionContent = children || props.children;\n\n return (\n <section {...composed} ref={ref}>\n <HeaderContext.Provider value={{ ...headingProps, ref: headingRef }}>\n {title && <div {...headingProps}>{title}</div>}\n {sectionContent}\n </HeaderContext.Provider>\n </section>\n );\n});\n\n/**\n * Wrapper component that connects BentoListBoxSectionImpl to React Aria's collection system.\n * This function serves as an adapter between createBranchComponent and the internal\n * BentoListBoxSectionImpl, ensuring proper prop forwarding and node injection for sections.\n *\n * @template T - The type of the section node data\n * @param {ListBoxSectionProps} props - ListBoxSection component props\n * @param {string} [props.slot] - Slot name for Bento's slot system\n * @param {React.ReactNode} [props.title] - Title for the section\n * @param {React.ReactNode} [props.children] - Children to render in the section\n * @param {string} [props.aria-label] - ARIA label for accessibility\n * @param {React.ForwardedRef<HTMLElement>} ref - Ref forwarded from the collection system\n * @param {Node<T>} section - React Aria node containing section metadata and collection info\n * @returns {React.ReactElement} The BentoListBoxSectionImpl component with proper node and ref wiring\n * @internal\n */\n/* v8 ignore start */\nfunction ListBoxSectionWrapper<T extends object>(\n props: ListBoxSectionProps,\n ref: React.ForwardedRef<HTMLElement>,\n section: Node<T>\n) {\n return <BentoListBoxSectionImpl {...props} __node={section} ref={ref} />;\n}\n/* v8 ignore stop */\n\n/**\n * Base ListBoxSection component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state and\n * manages the branch structure for nested items.\n * @internal\n */\nconst ListBoxSectionBase = createBranchComponent('section', ListBoxSectionWrapper);\n\n/**\n * Internal component for rendering dynamic collection sections.\n * This component is used specifically for sections that are part of a dynamic collection,\n * connecting to the ListStateContext and CollectionRendererContext to properly render\n * nested items through React Aria's collection system.\n *\n * @component\n * @param {object} props - The component props containing the section node\n * @param {Node<unknown>} props.section - The React Aria node representing this section in the collection\n * @throws {BentoError} Throws an error if used outside of a ListBox context\n * @returns {React.ReactElement} JSX element representing a dynamically rendered listbox section\n * @internal\n */\nexport const ListBoxSectionInner: React.FC<ListBoxSectionInnerProps> = function ListBoxSectionInner({ section }) {\n const state = useContext(ListStateContext);\n const { CollectionBranch } = useContext(CollectionRendererContext);\n\n return (\n <BentoListBoxSectionImpl {...section.props} __node={section}>\n {CollectionBranch && state?.collection ? (\n <CollectionBranch collection={state.collection} parent={section} />\n ) : null}\n </BentoListBoxSectionImpl>\n );\n};\n\n/**\n * A section component for organizing related items within a ListBox.\n *\n * @component\n * @example\n * ```tsx\n * <ListBoxSection title=\"Fruits\">\n * <ListBoxItem>Apple</ListBoxItem>\n * <ListBoxItem>Banana</ListBoxItem>\n * </ListBoxSection>\n * ```\n * @public\n */\nexport const ListBoxSection = ListBoxSectionBase as <_T extends object>(\n props: ListBoxSectionProps & { children?: React.ReactNode }\n) => React.ReactElement;\n","/* v8 ignore next */\nimport React, { type ForwardedRef, useEffect, useRef } from 'react';\n\n/**\n * NOTE: This utility will be moved to the new use-collection package.\n * Safe wrapper for React Aria's useObjectRef that handles test environments where refs are not extensible.\n *\n * **Critical for Vitest Browser Mode Testing**: When running tests in Vitest's browser mode with Playwright,\n * the test environment can freeze or make objects non-extensible. React Aria's `useObjectRef` attempts to\n * dynamically add properties to ref objects, which fails with \"Cannot add property current, object is not extensible\"\n * in these constrained test environments.\n *\n * **Technical Details:**\n * - Vitest browser mode uses Playwright's Chrome DevTools Protocol for test execution\n * - The V8 engine's security model can freeze objects during test isolation\n * - React Aria's useObjectRef uses `Object.defineProperty()` to add reactive properties to refs\n * - This conflicts with frozen objects in browser testing scenarios\n *\n * **Why This Solution Works:**\n * - Creates an internal ref that's always mutable (created in our controlled environment)\n * - Safely forwards values to the external ref using try/catch for frozen object scenarios\n * - Maintains the same ref forwarding behavior as React Aria's useObjectRef in normal environments\n * - Gracefully degrades in test environments without breaking functionality\n *\n * **Production Impact**: Zero. Object freezing only occurs in specific test configurations.\n * In production and development, this behaves identically to React Aria's useObjectRef.\n *\n * @template T - The type of the ref element\n * @param {React.ForwardedRef<T>} ref - The forwarded ref to handle safely\n * @returns {React.RefObject<T>} A safe ref object that works in all environments including frozen test contexts\n * @public\n */\nexport function useSafeObjectRef<T>(ref: ForwardedRef<T>): React.RefObject<T> {\n const internalRef = useRef<T>(null);\n\n useEffect(function updateForwardedRef() {\n const current = internalRef.current;\n\n if (typeof ref === 'function') {\n ref(current);\n } else if (ref && 'current' in ref) {\n try {\n (ref as React.MutableRefObject<T | null>).current = current;\n /* v8 ignore start */\n } catch {\n //\n // Silently ignore errors in test environments where objects might be frozen.\n // This specifically handles Vitest browser mode with Playwright where the V8 engine\n // may freeze ref objects during test isolation, preventing dynamic property assignment.\n //\n }\n /* v8 ignore stop */\n }\n });\n\n return internalRef;\n}\n","import React, { createContext, useContext, useMemo, ForwardedRef, RefObject } from 'react';\nimport {\n FocusScope,\n mergeProps,\n useCollator,\n useLocale,\n useListBox,\n useFocusRing,\n ListKeyboardDelegate\n} from 'react-aria';\nimport { ListState, SelectionBehavior, useListState, Orientation, Node } from 'react-stately';\nimport { CollectionBuilder, Collection as AriaCollection } from '@react-aria/collections';\nimport { AriaListBoxProps } from '@react-types/listbox';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots, Slots } from '@bento/slots';\nimport { ListBoxItemImpl } from './listbox-item';\nimport { ListBoxSectionInner } from './listbox-section';\nimport { useSafeObjectRef } from './utils';\n\n/**\n * Render props provided to ListBox render functions and empty state renderers.\n * @interface ListBoxRenderProps\n */\nexport interface ListBoxRenderProps {\n /**\n * Whether the listbox has no items and should display its empty state.\n * @selector [data-empty]\n */\n readonly isEmpty: boolean;\n /**\n * Whether the listbox is currently focused.\n * @selector [data-focused]\n */\n readonly isFocused: boolean;\n /**\n * Whether the listbox is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n readonly isFocusVisible: boolean;\n /**\n * Whether the listbox is currently the active drop target.\n * @selector [data-drop-target]\n */\n readonly isDropTarget: boolean;\n /**\n * Whether the items are arranged in a stack or grid.\n * @selector [data-layout=\"stack | grid\"]\n */\n readonly layout?: 'stack' | 'grid';\n /**\n * State of the listbox.\n */\n readonly state: ListState<unknown>;\n /**\n * The items array when using dynamic collections.\n */\n readonly items?: Iterable<unknown>;\n}\n\n/**\n * Props for the ListBox component.\n * @interface ListBoxProps\n * @template T The type of items in the collection\n */\nexport interface ListBoxProps<T>\n extends Omit<AriaListBoxProps<T>, 'label' | 'children'>,\n Omit<React.ComponentProps<'div'>, keyof AriaListBoxProps<T> | 'children'>,\n Slots {\n /**\n * How multiple selection should behave in the collection.\n */\n readonly selectionBehavior?: SelectionBehavior;\n /**\n * Provides content to display when there are no items in the list.\n */\n readonly renderEmptyState?: (props: ListBoxRenderProps) => React.ReactNode;\n /**\n * Whether the items are arranged in a stack layout.\n * @default 'stack'\n */\n readonly layout?: 'stack';\n /**\n * The primary orientation of the items. Usually this is the direction that the collection scrolls.\n * @default 'vertical'\n */\n readonly orientation?: Orientation;\n /**\n * Static children or render function for the ListBox.\n * When items prop is provided, children receives individual items for React Aria compatibility.\n * When no items prop is provided, children receives Bento render props { isEmpty, isFocused, state, etc. }.\n */\n readonly children?:\n | React.ReactNode\n | ((item: T) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n}\n\n/**\n * React context for sharing ListBox state across components.\n * This context provides the ListBox state to child components like ListBoxItem and ListBoxSection,\n * enabling them to access selection state, collection data, and other shared functionality.\n *\n * @context\n * @internal\n */\nconst ListStateContext = createContext<ListState<unknown> | null>(null);\n\n/**\n * Custom hook to manage ListBox state creation and context handling.\n * This hook either uses an existing state from context or creates a new one.\n * It's designed to work both as a standalone component and within a parent component\n * that provides ListBox state through context.\n *\n * @param {Record<string, unknown>} props - Configuration object for the ListBox state\n * @returns {object} An object containing the state instance and context state flag\n * @returns {ListState<unknown>} returns.state - The ListBox state instance\n * @returns {ListState<unknown> | null} returns.contextState - Existing context state, if any\n * @internal\n */\nfunction useListBoxState(props: Record<string, unknown>) {\n const contextState = useContext(ListStateContext);\n\n const stateProps = {\n ...props,\n children: undefined,\n items: undefined\n };\n\n const state = contextState ?? useListState(stateProps);\n\n return { state, contextState };\n}\n\n/**\n * Renders content with optional context provider wrapper.\n * If no context state exists, wraps the content in a ListStateContext.Provider.\n * This allows the ListBox to work both standalone and as part of a larger component tree.\n *\n * @param {React.ReactNode} content - The React content to render\n * @param {ListState<unknown>} state - The ListBox state to provide via context\n * @param {ListState<unknown> | null} contextState - Existing context state, if any\n * @returns {React.ReactNode} The content, optionally wrapped in a context provider\n * @internal\n */\nfunction renderWithOptionalContext(\n content: React.ReactNode,\n state: ListState<unknown>,\n contextState: ListState<unknown> | null\n): React.ReactNode {\n /* v8 ignore next */\n return contextState ? content : <ListStateContext.Provider value={state}>{content}</ListStateContext.Provider>;\n}\n\n/**\n * Creates and memoizes a keyboard delegate for the ListBox.\n * The keyboard delegate handles keyboard navigation logic, including\n * arrow key navigation, home/end keys, and type-ahead functionality.\n *\n * @param {object} config - Configuration object for the keyboard delegate\n * @param {ListState<unknown>['collection']} config.collection - The collection of items in the ListBox\n * @param {Intl.Collator} config.collator - Intl collator for string comparison in type-ahead\n * @param {React.RefObject<HTMLDivElement>} config.listBoxRef - Reference to the ListBox DOM element\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager from the state\n * @param {'stack' | 'grid'} [config.layout] - Layout mode (stack or grid)\n * @param {Orientation} [config.orientation] - Primary orientation of the items\n * @param {'ltr' | 'rtl'} config.direction - Text direction (ltr or rtl)\n * @param {ListKeyboardDelegate<unknown>} [config.keyboardDelegate] - Custom keyboard delegate to use instead of default\n * @returns {ListKeyboardDelegate<unknown>} A keyboard delegate instance for handling keyboard interactions\n * @internal\n */\nfunction useKeyboardDelegate({\n collection,\n collator,\n listBoxRef,\n selectionManager,\n layout,\n orientation,\n direction,\n keyboardDelegate: providedDelegate\n}: {\n readonly collection: ListState<unknown>['collection'];\n readonly collator: Intl.Collator;\n readonly listBoxRef: React.RefObject<HTMLDivElement>;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly layout?: 'stack' | 'grid';\n readonly orientation?: Orientation;\n readonly direction: 'ltr' | 'rtl';\n readonly keyboardDelegate?: ListKeyboardDelegate<unknown>;\n}): ListKeyboardDelegate<unknown> {\n const { disabledBehavior, disabledKeys } = selectionManager;\n\n return useMemo(\n function createKeyboardDelegate() {\n return (\n providedDelegate ||\n new ListKeyboardDelegate({\n collection,\n collator,\n ref: listBoxRef,\n disabledKeys,\n disabledBehavior,\n layout,\n orientation,\n direction\n })\n );\n },\n [collection, collator, listBoxRef, selectionManager, orientation, direction, layout, providedDelegate]\n );\n}\n\n/**\n * Generates data attributes for the ListBox element based on its current state.\n * These attributes are used for styling selectors and accessibility indicators.\n *\n * @param {object} config - Configuration object containing ListBox state flags\n * @param {boolean} config.isEmpty - Whether the listbox has no items\n * @param {boolean} config.isFocused - Whether the listbox is currently focused\n * @param {boolean} config.isFocusVisible - Whether focus should be visually indicated\n * @param {'stack' | 'grid'} [config.layout] - Layout mode (stack or grid)\n * @param {Orientation} [config.orientation] - Primary orientation of the items\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager containing selection state\n * @param {boolean} [config.allowsTabNavigation] - Whether tab navigation is enabled\n * @param {boolean} [config.shouldFocusWrap] - Whether focus wraps at boundaries\n * @param {SelectionBehavior} [config.originalSelectionBehavior] - Original selection behavior setting\n * @returns {Record<string, unknown>} Object with data attributes for the ListBox element\n * @internal\n */\nfunction useListBoxDataAttributes({\n isEmpty,\n isFocused,\n isFocusVisible,\n layout,\n orientation,\n selectionManager,\n allowsTabNavigation,\n shouldFocusWrap,\n originalSelectionBehavior\n}: {\n readonly isEmpty: boolean;\n readonly isFocused: boolean;\n readonly isFocusVisible: boolean;\n readonly layout?: 'stack' | 'grid';\n readonly orientation?: Orientation;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly allowsTabNavigation?: boolean;\n readonly shouldFocusWrap?: boolean;\n readonly originalSelectionBehavior?: SelectionBehavior;\n}) {\n return useDataAttributes({\n empty: isEmpty,\n focused: isFocused,\n 'focus-visible': isFocusVisible,\n layout,\n orientation,\n 'selection-mode': selectionManager.selectionMode !== 'none' ? selectionManager.selectionMode : undefined,\n 'selection-behavior': originalSelectionBehavior !== undefined ? selectionManager.selectionBehavior : undefined,\n 'allows-tab-navigation': allowsTabNavigation,\n 'focus-wrap': shouldFocusWrap\n });\n}\n\n/**\n * Composes all props for the ListBox element including DOM props, ARIA props,\n * focus props, and data attributes. Handles prop application through useProps\n * and manages ref assignment to avoid proxy extensibility issues.\n *\n * @param {object} config - Configuration object containing all props to compose\n * @param {Record<string, unknown>} config.otherProps - Additional props from the component\n * @param {ListBoxRenderProps} config.renderValues - Values available to render functions\n * @param {Record<string, unknown>} config.listBoxProps - Props from useListBox hook\n * @param {Record<string, unknown>} config.focusProps - Props from useFocusRing hook\n * @param {Record<string, unknown>} config.dataAttributes - Data attributes for styling/selectors\n * @param {ListState<unknown>['selectionManager']} config.selectionManager - Selection manager for ARIA attributes\n * @param {React.RefObject<HTMLDivElement>} config.listBoxRef - Reference to attach to the final element\n * @returns {Record<string, unknown>} Composed props object ready for the ListBox element\n * @internal\n */\nfunction useComposedProps({\n otherProps,\n renderValues,\n listBoxProps,\n focusProps,\n dataAttributes,\n selectionManager,\n listBoxRef\n}: {\n readonly otherProps: Record<string, unknown>;\n readonly renderValues: ListBoxRenderProps;\n readonly listBoxProps: Record<string, unknown>;\n readonly focusProps: Record<string, unknown>;\n readonly dataAttributes: Record<string, unknown>;\n readonly selectionManager: ListState<unknown>['selectionManager'];\n readonly listBoxRef: React.RefObject<HTMLDivElement>;\n}) {\n const { apply } = useProps(otherProps, renderValues);\n\n const propsToExclude = [\n 'renderEmptyState',\n 'selectionMode',\n 'defaultSelectedKeys',\n 'disabledKeys',\n 'disallowEmptySelection',\n 'shouldFocusWrap',\n 'items',\n 'children',\n 'selectionBehavior',\n 'keyboardDelegate'\n ];\n\n // Apply user props directly (preserves className, style, etc.)\n const appliedUserProps = apply(otherProps, propsToExclude);\n\n // React Aria and Bento props\n const baseProps = {\n ...mergeProps(listBoxProps, focusProps),\n ...dataAttributes,\n ...(selectionManager.selectionMode !== 'none' && {\n 'aria-multiselectable': selectionManager.selectionMode === 'multiple'\n })\n };\n\n //\n // Merge all props together with user props taking precedence\n //\n const finalProps = {\n ...baseProps,\n ...appliedUserProps,\n ref: listBoxRef // Set ref directly to avoid extensibility issues\n };\n\n return finalProps;\n}\n\n/**\n * Renders the empty state content for the ListBox when no items are present.\n * Handles both function-based render props and direct JSX elements.\n * If a function is provided, calls it with render values; otherwise returns as-is.\n *\n * @param {(props: ListBoxRenderProps) => React.ReactNode} renderEmptyStateFn - Function or JSX element to render for empty state\n * @param {ListBoxRenderProps} renderValues - Current render values to pass to render function\n * @returns {React.ReactNode} Rendered empty state content\n * @internal\n */\nfunction renderEmptyState(\n renderEmptyStateFn: (props: ListBoxRenderProps) => React.ReactNode,\n renderValues: ListBoxRenderProps\n): React.ReactNode {\n //\n // Handle cases where renderEmptyState is not a function (e.g., JSX element passed directly)\n //\n if (typeof renderEmptyStateFn === 'function') {\n return renderEmptyStateFn(renderValues);\n }\n //\n // If it's not a function, just return it as-is (likely a JSX element)\n //\n return renderEmptyStateFn as React.ReactNode;\n}\n\n/**\n * Renders all items in the collection as React elements.\n * Handles both regular items and section items, using the appropriate\n * components (ListBoxItemImpl for items, ListBoxSectionInner for sections).\n *\n * @param {ListState<unknown>['collection']} collection - The collection of items to render\n * @returns {React.ReactElement[]} Array of rendered React elements for all collection items\n * @internal\n */\nfunction renderCollectionItems(collection: ListState<unknown>['collection']): React.ReactElement[] {\n return [...collection].map(function renderCollectionItem(item: Node<unknown>) {\n return item.type === 'section' ? (\n <ListBoxSectionInner key={item.key} section={item} />\n ) : (\n <ListBoxItemImpl key={item.key} __node={item as Node<object>}>\n {item.rendered}\n </ListBoxItemImpl>\n );\n });\n}\n\n/**\n * Determines what content to render inside the ListBox based on its configuration.\n * Handles three cases:\n * 1. Function children without items (Bento render prop pattern with full render props)\n * 2. Empty state when no items and renderEmptyState is provided\n * 3. Normal collection rendering (including items with children functions for React Aria compatibility)\n *\n * @param {object} config - Configuration object for rendering\n * @param {React.ReactNode | ((item: unknown) => React.ReactNode) | ((props: ListBoxRenderProps) => React.ReactNode)} [config.children] - Children prop (static, item render function, or ListBox render prop)\n * @param {Iterable<unknown>} [config.items] - Items array for dynamic collections\n * @param {boolean} config.isEmpty - Whether the collection is empty\n * @param {(props: ListBoxRenderProps) => React.ReactNode} [config.renderEmptyStateProp] - Function to render empty state\n * @param {ListBoxRenderProps} config.renderValues - Current render values for render functions\n * @param {ListState<unknown>['collection']} config.collection - The collection state to render\n * @returns {React.ReactNode} The appropriate content to render inside the ListBox\n * @internal\n */\nfunction renderListBoxContent({\n children,\n items,\n isEmpty,\n renderEmptyStateProp,\n renderValues,\n collection\n}: {\n readonly children?:\n | React.ReactNode\n | ((item: unknown) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n readonly items?: Iterable<unknown>;\n readonly isEmpty: boolean;\n readonly renderEmptyStateProp?: (props: ListBoxRenderProps) => React.ReactNode;\n readonly renderValues: ListBoxRenderProps;\n readonly collection: ListState<unknown>['collection'];\n}): React.ReactNode {\n // If children is a function AND no items provided, use Bento render prop pattern\n /* v8 ignore next */\n const hasRenderChildren = typeof children === 'function' && !items;\n\n /* v8 ignore next 3 */\n if (hasRenderChildren) {\n return (children as (props: ListBoxRenderProps) => React.ReactNode)(renderValues);\n }\n\n // Handle empty state\n if (isEmpty && renderEmptyStateProp) {\n return renderEmptyState(renderEmptyStateProp, renderValues);\n }\n\n // Render collection items (React Aria handles items + children function internally)\n return renderCollectionItems(collection);\n}\n\n/**\n * Internal ListBox component that handles the core rendering logic.\n * This component manages all the hooks, state, and prop composition needed\n * for a fully functional ListBox. It's wrapped by the main ListBox component\n * which handles collection building.\n *\n * @param {object} props - Component props\n * @param {ListState<unknown>} props.state - The ListBox state instance\n * @param {(props: ListBoxRenderProps) => React.ReactNode} [props.renderEmptyState] - Function to render when no items are present\n * @param {React.ReactNode | ((item: unknown) => React.ReactNode) | ((props: ListBoxRenderProps) => React.ReactNode)} [props.children] - Static children, item render function, or ListBox render function\n * @param {Iterable<unknown>} [props.items] - Items array for dynamic collections\n * @param {React.RefObject<HTMLDivElement>} props.listBoxRef - Reference to the ListBox DOM element\n * @param {'stack'} [props.layout] - Layout mode (stack or grid)\n * @param {Orientation} [props.orientation] - Primary orientation of the items\n * @param {boolean} [props.shouldSelectOnPressUp] - Whether selection occurs on pointer up\n * @param {ListKeyboardDelegate<unknown>} [props.keyboardDelegate] - Custom keyboard navigation delegate\n * @param {boolean} [props.allowsTabNavigation] - Whether tab key navigates between items\n * @param {boolean} [props.shouldFocusWrap] - Whether focus wraps at boundaries\n * @param {'none' | 'single' | 'multiple'} [props.selectionMode] - Selection mode (none, single, multiple)\n * @param {SelectionBehavior} [props.selectionBehavior] - Selection behavior (toggle, replace)\n * @returns {React.ReactElement} A fully functional ListBox element with focus scope\n * @internal\n */\nconst ListBoxInner: React.FC<{\n readonly state: ListState<unknown>;\n readonly renderEmptyState?: (props: ListBoxRenderProps) => React.ReactNode;\n readonly children?:\n | React.ReactNode\n | ((item: unknown) => React.ReactNode)\n | ((props: ListBoxRenderProps) => React.ReactNode);\n readonly items?: Iterable<unknown>;\n readonly listBoxRef: RefObject<HTMLDivElement>;\n readonly layout?: 'stack';\n readonly orientation?: Orientation;\n readonly shouldSelectOnPressUp?: boolean;\n readonly keyboardDelegate?: ListKeyboardDelegate<unknown>;\n readonly allowsTabNavigation?: boolean;\n readonly shouldFocusWrap?: boolean;\n readonly selectionMode?: 'none' | 'single' | 'multiple';\n readonly selectionBehavior?: SelectionBehavior;\n}> = function ListBoxInner({\n state,\n renderEmptyState: renderEmptyStateProp,\n children,\n items,\n listBoxRef,\n ...otherProps\n}) {\n const { layout = 'stack', orientation = 'vertical', shouldSelectOnPressUp, selectionBehavior } = otherProps;\n\n const { collection, selectionManager } = state;\n const { direction } = useLocale();\n const collator = useCollator({ usage: 'search', sensitivity: 'base' });\n\n const keyboardDelegate = useKeyboardDelegate({\n collection,\n collator,\n listBoxRef,\n selectionManager,\n layout,\n orientation,\n direction,\n keyboardDelegate: otherProps.keyboardDelegate\n });\n\n const { listBoxProps } = useListBox(\n {\n ...otherProps,\n shouldSelectOnPressUp,\n keyboardDelegate\n },\n state,\n listBoxRef\n );\n\n const { focusProps, isFocused, isFocusVisible } = useFocusRing();\n const isEmpty = state.collection.size === 0;\n\n const renderValues: ListBoxRenderProps = {\n isEmpty,\n isFocused,\n isFocusVisible,\n isDropTarget: false,\n layout,\n state,\n items\n };\n\n const dataAttributes = useListBoxDataAttributes({\n isEmpty,\n isFocused,\n isFocusVisible,\n layout,\n orientation,\n selectionManager,\n allowsTabNavigation: otherProps.allowsTabNavigation,\n shouldFocusWrap: otherProps.shouldFocusWrap,\n originalSelectionBehavior: selectionBehavior\n });\n\n const composedProps = useComposedProps({\n otherProps,\n renderValues,\n listBoxProps: listBoxProps as Record<string, unknown>,\n focusProps: focusProps as Record<string, unknown>,\n dataAttributes,\n selectionManager,\n listBoxRef\n });\n\n return (\n <FocusScope>\n <div {...composedProps}>\n {renderListBoxContent({\n children,\n items,\n isEmpty,\n renderEmptyStateProp,\n renderValues,\n collection\n })}\n </div>\n </FocusScope>\n );\n};\n\n/**\n * A complete ListBox component providing accessible selection lists with keyboard navigation.\n * Supports both static children and dynamic collections, with single/multiple selection modes.\n * Built on React Aria with full ARIA compliance and keyboard accessibility.\n *\n * @component\n * @template T The type of items in the collection\n * @param {ListBoxProps<T>} args - The properties passed to the ListBox component\n * @param {React.ForwardedRef<HTMLDivElement>} ref - The ref to the listbox container\n * @returns {React.ReactElement} A ListBox component\n *\n * @example\n * ```tsx\n * <ListBox aria-label=\"Fruits\" selectionMode=\"single\">\n * <ListBoxItem id=\"apple\" textValue=\"Apple\">Apple</ListBoxItem>\n * <ListBoxItem id=\"banana\" textValue=\"Banana\">Banana</ListBoxItem>\n * </ListBox>\n * ```\n * @public\n */\nfunction ListBoxComponent<T>(args: ListBoxProps<T>, ref: React.ForwardedRef<HTMLDivElement>): React.ReactElement {\n return (\n <CollectionBuilder content={<AriaCollection {...(args as unknown as Parameters<typeof AriaCollection>[0])} />}>\n {function buildCollection(collection: unknown) {\n return <StandaloneListBox props={args as ListBoxProps<unknown>} listBoxRef={ref} collection={collection} />;\n }}\n </CollectionBuilder>\n );\n}\n\n/**\n * Standalone ListBox component that manages its own state and collection.\n * This component is used internally by the main ListBox component after\n * collection building is complete. It handles prop processing, state creation,\n * and context management.\n *\n * @param {object} props - Component props\n * @param {ListBoxProps<unknown>} props.props - The original ListBox props\n * @param {React.ForwardedRef<HTMLDivElement>} props.listBoxRef - Reference to forward to the ListBox element\n * @param {unknown} props.collection - Built collection from CollectionBuilder\n * @returns {React.ReactElement} A complete ListBox with state management and optional context wrapping\n * @internal\n */\nconst StandaloneListBox: React.FC<{\n readonly props: ListBoxProps<unknown>;\n readonly listBoxRef: ForwardedRef<HTMLDivElement>;\n readonly collection: unknown;\n}> = function StandaloneListBox({ props, listBoxRef, collection }) {\n //\n // Extract renderEmptyState before useProps processes it to avoid render prop corruption\n //\n const originalRenderEmptyState = props.renderEmptyState;\n\n const { props: processedProps } = useProps(props);\n const processedRef = useSafeObjectRef(listBoxRef);\n const { state, contextState } = useListBoxState({ ...processedProps, collection });\n\n const { renderEmptyState: _, ...cleanProcessedProps } = processedProps as ListBoxProps<unknown> & {\n renderEmptyState?: unknown;\n };\n\n const content = (\n <ListBoxInner\n state={state}\n listBoxRef={processedRef}\n renderEmptyState={originalRenderEmptyState}\n {...cleanProcessedProps}\n />\n );\n\n return renderWithOptionalContext(content, state, contextState);\n};\n\n/**\n * A complete ListBox component providing accessible selection lists with keyboard navigation.\n * Supports both static children and dynamic collections, with single/multiple selection modes.\n * Built on React Aria with full ARIA compliance and keyboard accessibility.\n *\n * @component\n * @example\n * ```tsx\n * <ListBox aria-label=\"Fruits\" selectionMode=\"single\">\n * <ListBoxItem id=\"apple\" textValue=\"Apple\">Apple</ListBoxItem>\n * <ListBoxItem id=\"banana\" textValue=\"Banana\">Banana</ListBoxItem>\n * </ListBox>\n * ```\n * @public\n */\nexport const ListBox = withSlots('BentoListBox', ListBoxComponent);\n\n/**\n * Collection component for building dynamic collections in ListBox.\n * Re-exported from React Aria Collections.\n * @public\n */\nexport { AriaCollection as Collection };\n\n/**\n * Context for sharing ListBox state across components.\n * Used internally by ListBoxItem and ListBoxSection components.\n * @public\n */\nexport { ListStateContext };\n","import React, { ForwardedRef, ReactNode, createContext, useContext, useMemo } from 'react';\nimport { mergeProps, useOption, useHover } from 'react-aria';\nimport { createLeafComponent } from '@react-aria/collections';\nimport { HoverEvents, Key, LinkDOMProps, Node } from '@react-types/shared';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { ListStateContext } from './listbox';\nimport { useSafeObjectRef } from './utils';\nimport { withSlots } from '@bento/slots';\n\n/**\n * Context value structure for text-related slot attributes.\n * Used to provide label and description attributes to child components.\n * @interface TextContextValue\n */\ninterface TextContextValue {\n readonly slots: {\n /** Attributes for label elements */\n readonly label?: React.HTMLAttributes<HTMLElement>;\n /** Attributes for description elements */\n readonly description?: React.HTMLAttributes<HTMLElement>;\n };\n}\n\n/**\n * Internal context for providing text-related slot attributes to child components.\n * This context allows ListBoxItem to pass label and description attributes\n * to nested components that need them for accessibility.\n * @internal\n */\nconst TextContext = createContext<TextContextValue>({ slots: {} });\n\n/**\n * Render props provided to ListBoxItem render functions.\n * @interface ListBoxItemRenderProps\n */\nexport interface ListBoxItemRenderProps {\n /**\n * Whether the item is currently hovered.\n * @selector [data-hovered]\n */\n readonly isHovered: boolean;\n /**\n * Whether the item is currently pressed.\n * @selector [data-pressed]\n */\n readonly isPressed: boolean;\n /**\n * Whether the item is currently selected.\n * @selector [data-selected]\n */\n readonly isSelected: boolean;\n /**\n * Whether the item is currently focused.\n * @selector [data-focused]\n */\n readonly isFocused: boolean;\n /**\n * Whether the item is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n readonly isFocusVisible: boolean;\n /**\n * Whether the item is disabled.\n * @selector [data-disabled]\n */\n readonly isDisabled: boolean;\n /**\n * The type of selection that is allowed in the collection.\n * @selector [data-selection-mode=\"none | single | multiple\"]\n */\n readonly selectionMode: 'none' | 'single' | 'multiple';\n /**\n * The selection behavior for the collection.\n * @selector [data-selection-behavior=\"toggle | replace\"]\n */\n readonly selectionBehavior: 'toggle' | 'replace';\n}\n\n/**\n * Props for the ListBoxItem component.\n * @interface ListBoxItemProps\n * @template T The type of the item value\n */\nexport interface ListBoxItemProps<T = object>\n extends LinkDOMProps,\n HoverEvents,\n Omit<React.HTMLAttributes<HTMLElement>, keyof LinkDOMProps | keyof HoverEvents | 'id' | 'children'> {\n /** The unique id of the item. If not provided, React Aria will auto-generate one. */\n readonly id?: Key;\n /** The object value that this item represents. When using dynamic collections, this is set automatically. */\n readonly value?: T;\n /** A string representation of the item's contents, used for features like typeahead. If not provided, React Aria will derive it from children automatically. */\n readonly textValue?: string;\n /**\n * Handler that is called when a user performs an action on the item. The exact user event depends on the\n * collection's `selectionBehavior` prop and the interaction modality.\n */\n readonly onAction?: () => void;\n /** The contents of the item. Can be a render function that receives render props. */\n readonly children?: ReactNode | ((values: ListBoxItemRenderProps) => ReactNode);\n /**\n * A slot name for the component. Used by Bento's slot system.\n */\n readonly slot?: string;\n /** Whether the item is disabled. */\n readonly isDisabled?: boolean;\n}\n\n/**\n * Internal implementation component for ListBoxItem.\n * Handles the core logic for rendering a single listbox item with proper accessibility.\n * This component manages all the hooks, state, and interactions needed for a functional\n * listbox item including selection, hover, focus, and keyboard interactions.\n *\n * @template T - The type of the item value\n * @param {object} props - Combined ListBoxItem props and internal node data\n * @param {Node<T>} props.__node - Internal React Aria node containing item metadata\n * @param {React.ReactNode | ((values: ListBoxItemRenderProps) => React.ReactNode)} [props.children] - Content to render, can be static or a render function\n * @param {boolean} [props.isDisabled] - Whether the item is disabled\n * @param {string} [props.aria-label] - ARIA label for accessibility\n * @param {(e: HoverEvent) => void} [props.onHoverStart] - Handler for hover start events\n * @param {(isHovering: boolean) => void} [props.onHoverChange] - Handler for hover change events\n * @param {(e: HoverEvent) => void} [props.onHoverEnd] - Handler for hover end events\n * @param {React.ForwardedRef<HTMLDivElement>} ref - Forwarded ref to the item element\n * @returns {React.ReactElement} A fully interactive listbox item with accessibility and state management\n * @internal\n */\nconst ListBoxItemImplComponent = function ListBoxItemImplComponent<T extends object>(\n { __node, ...props }: ListBoxItemProps<T> & { readonly __node: Node<T> },\n ref: ForwardedRef<HTMLDivElement>\n) {\n const state = useContext(ListStateContext)!;\n const safeRef = useSafeObjectRef(ref);\n\n const { optionProps, labelProps, descriptionProps, ...states } = useOption(\n {\n key: __node.key,\n 'aria-label': props['aria-label'],\n isDisabled: props.isDisabled\n },\n state,\n safeRef\n );\n\n const { hoverProps, isHovered } = useHover({\n isDisabled: states.isDisabled,\n onHoverStart: props.onHoverStart,\n onHoverChange: props.onHoverChange,\n onHoverEnd: props.onHoverEnd\n });\n\n const renderValues: ListBoxItemRenderProps = {\n ...states,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior\n };\n\n const content = typeof props.children === 'function' ? props.children(renderValues) : props.children;\n\n const { apply } = useProps(props, renderValues);\n\n const dataAttributes = useDataAttributes({\n selected: states.isSelected,\n disabled: states.isDisabled,\n hovered: isHovered,\n focused: states.isFocused,\n 'focus-visible': states.isFocusVisible,\n pressed: states.isPressed,\n level: __node.level,\n 'selection-mode': state.selectionManager.selectionMode,\n 'selection-behavior': state.selectionManager.selectionBehavior\n });\n\n const textContext = useMemo(\n function createTextContext() {\n return {\n slots: {\n label: labelProps,\n description: descriptionProps\n }\n };\n },\n [labelProps, descriptionProps]\n );\n\n const ElementType = __node.props.href ? 'a' : 'div';\n\n // Use original node props (which contain className) not filtered finalProps\n const appliedUserProps = apply(__node.props, ['ref']);\n\n const finalAttributes = {\n ...mergeProps(optionProps, hoverProps), // React Aria props\n ...dataAttributes, // Bento data attributes\n ...appliedUserProps,\n ref: safeRef,\n 'data-text-value': __node.textValue\n };\n\n return (\n <TextContext.Provider value={textContext}>\n {React.createElement(ElementType, finalAttributes, content)}\n </TextContext.Provider>\n );\n};\n\n/**\n * Enhanced ListBoxItem implementation with slots support.\n * This wraps the core ListBoxItemImplComponent with Bento's slot system\n * for advanced composition and styling capabilities.\n * @internal\n */\nexport const ListBoxItemImpl = withSlots('BentoListBoxItem', ListBoxItemImplComponent);\n\n/**\n * Adapter component that connects ListBoxItemImpl to React Aria's collection system.\n * This function serves as a bridge between React Aria's createLeafComponent and\n * the internal ListBoxItemImpl, ensuring proper prop forwarding and node injection.\n *\n * @template T - The type of the item value\n * @param {ListBoxItemProps<T>} props - ListBoxItem component props\n * @param {React.ForwardedRef<HTMLDivElement>} forwardedRef - Ref forwarded from the collection system\n * @param {Node<T>} item - React Aria node containing item metadata and collection info\n * @returns {React.ReactElement} The ListBoxItemImpl component with proper node and ref wiring\n * @internal\n */\nfunction ListBoxItemComponent<T extends object>(\n props: ListBoxItemProps<T>,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n item: Node<T>\n) {\n return <ListBoxItemImpl {...props} ref={forwardedRef as any} __node={item} />;\n}\n\n/**\n * Base ListBoxItem component created through React Aria's collection system.\n * This handles the connection to the parent ListBox's collection state.\n * @internal\n */\nconst ListBoxItemBase = createLeafComponent('item', ListBoxItemComponent);\n\n/**\n * A single item within a ListBox component.\n * Handles user interactions, accessibility, and state management for individual options.\n *\n * @component\n * @template T The type of the item value\n * @example\n * ```tsx\n * <ListBoxItem>Simple option</ListBoxItem>\n * ```\n * @public\n */\nexport const ListBoxItem = ListBoxItemBase;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento/listbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Listbox component",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"package.json"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@bento/slots": "^0.
|
|
46
|
+
"@bento/slots": "^0.2.0",
|
|
47
47
|
"@bento/use-data-attributes": "^0.1.1",
|
|
48
|
-
"@bento/use-props": "^0.
|
|
48
|
+
"@bento/use-props": "^0.2.0",
|
|
49
49
|
"@react-aria/collections": "^3.0.0",
|
|
50
50
|
"@react-types/listbox": "^3.7.1",
|
|
51
51
|
"react-aria": "^3.44.0",
|
package/src/header.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
2
|
import { createLeafComponent } from '@react-aria/collections';
|
|
3
3
|
import { useProps } from '@bento/use-props';
|
|
4
4
|
import { withSlots, type Slots } from '@bento/slots';
|
|
@@ -52,7 +52,7 @@ export const HeaderContext = createContext<HeaderContextValue>({});
|
|
|
52
52
|
*/
|
|
53
53
|
const BentoHeaderImpl = withSlots(
|
|
54
54
|
'BentoHeader',
|
|
55
|
-
|
|
55
|
+
function BentoHeader(props: BentoHeaderProps, ref: React.ForwardedRef<HTMLElement>) {
|
|
56
56
|
const { props: processedProps, apply } = useProps(props);
|
|
57
57
|
const contextProps = useContext(HeaderContext);
|
|
58
58
|
|
|
@@ -69,7 +69,7 @@ const BentoHeaderImpl = withSlots(
|
|
|
69
69
|
{processedProps.children}
|
|
70
70
|
</header>
|
|
71
71
|
);
|
|
72
|
-
}
|
|
72
|
+
}
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
/**
|
package/src/listbox-item.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ForwardedRef, ReactNode, createContext, useContext, useMemo
|
|
1
|
+
import React, { ForwardedRef, ReactNode, createContext, useContext, useMemo } from 'react';
|
|
2
2
|
import { mergeProps, useOption, useHover } from 'react-aria';
|
|
3
3
|
import { createLeafComponent } from '@react-aria/collections';
|
|
4
4
|
import { HoverEvents, Key, LinkDOMProps, Node } from '@react-types/shared';
|
|
@@ -211,7 +211,7 @@ const ListBoxItemImplComponent = function ListBoxItemImplComponent<T extends obj
|
|
|
211
211
|
* for advanced composition and styling capabilities.
|
|
212
212
|
* @internal
|
|
213
213
|
*/
|
|
214
|
-
export const ListBoxItemImpl = withSlots('BentoListBoxItem',
|
|
214
|
+
export const ListBoxItemImpl = withSlots('BentoListBoxItem', ListBoxItemImplComponent);
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
217
|
* Adapter component that connects ListBoxItemImpl to React Aria's collection system.
|
|
@@ -230,7 +230,7 @@ function ListBoxItemComponent<T extends object>(
|
|
|
230
230
|
forwardedRef: ForwardedRef<HTMLDivElement>,
|
|
231
231
|
item: Node<T>
|
|
232
232
|
) {
|
|
233
|
-
return <ListBoxItemImpl {...props} ref={forwardedRef} __node={item} />;
|
|
233
|
+
return <ListBoxItemImpl {...props} ref={forwardedRef as any} __node={item} />;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
/**
|
package/src/listbox-section.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useRef, useContext } from 'react';
|
|
2
2
|
import { useListBoxSection, mergeProps } from 'react-aria';
|
|
3
3
|
import { createBranchComponent } from '@react-aria/collections';
|
|
4
4
|
import { CollectionRendererContext } from 'react-aria-components';
|
|
@@ -62,36 +62,32 @@ interface ListBoxSectionInnerProps {
|
|
|
62
62
|
*
|
|
63
63
|
* @internal
|
|
64
64
|
*/
|
|
65
|
-
const BentoListBoxSectionImpl = withSlots(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
const { props, apply } = useProps(rest);
|
|
72
|
-
const data = useDataAttributes({ level: __node?.level });
|
|
73
|
-
const headingRef = useRef<HTMLDivElement>(null);
|
|
65
|
+
const BentoListBoxSectionImpl = withSlots('BentoListBoxSection', function BentoListBoxSectionImpl<
|
|
66
|
+
T
|
|
67
|
+
>({ __node, children, title: titleProp, ...rest }: BentoListBoxSectionImplProps<T>, ref: React.ForwardedRef<HTMLElement>) {
|
|
68
|
+
const { props, apply } = useProps(rest);
|
|
69
|
+
const data = useDataAttributes({ level: __node?.level });
|
|
70
|
+
const headingRef = useRef<HTMLDivElement>(null);
|
|
74
71
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
const title = titleProp ?? props.title ?? __node?.rendered;
|
|
73
|
+
const { groupProps, headingProps } = useListBoxSection({
|
|
74
|
+
heading: title,
|
|
75
|
+
'aria-label': props['aria-label']
|
|
76
|
+
});
|
|
80
77
|
|
|
81
|
-
|
|
78
|
+
const composed = mergeProps(apply({ ...data, ...props }, ['children', 'title', 'slot']), groupProps);
|
|
82
79
|
|
|
83
|
-
|
|
80
|
+
const sectionContent = children || props.children;
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
);
|
|
82
|
+
return (
|
|
83
|
+
<section {...composed} ref={ref}>
|
|
84
|
+
<HeaderContext.Provider value={{ ...headingProps, ref: headingRef }}>
|
|
85
|
+
{title && <div {...headingProps}>{title}</div>}
|
|
86
|
+
{sectionContent}
|
|
87
|
+
</HeaderContext.Provider>
|
|
88
|
+
</section>
|
|
89
|
+
);
|
|
90
|
+
});
|
|
95
91
|
|
|
96
92
|
/**
|
|
97
93
|
* Wrapper component that connects BentoListBoxSectionImpl to React Aria's collection system.
|