@bazza-ui/react 0.0.0 → 0.1.0-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/ListboxStore-BtcTXpzi.d.cts +351 -0
  2. package/dist/ListboxStore-DPqpLlAL.d.ts +351 -0
  3. package/dist/adapters/index.cjs +2 -0
  4. package/dist/adapters/index.cjs.map +1 -0
  5. package/dist/adapters/index.d.cts +363 -0
  6. package/dist/adapters/index.d.ts +363 -0
  7. package/dist/adapters/index.js +2 -0
  8. package/dist/adapters/index.js.map +1 -0
  9. package/dist/chunk-4C666HHU.js +2 -0
  10. package/dist/chunk-4C666HHU.js.map +1 -0
  11. package/dist/chunk-AVZ64JQ3.js +2 -0
  12. package/dist/chunk-AVZ64JQ3.js.map +1 -0
  13. package/dist/chunk-BGJJC6GX.cjs +2 -0
  14. package/dist/chunk-BGJJC6GX.cjs.map +1 -0
  15. package/dist/chunk-FWWOE2SW.cjs +2 -0
  16. package/dist/chunk-FWWOE2SW.cjs.map +1 -0
  17. package/dist/chunk-JSPKF52O.cjs +2 -0
  18. package/dist/chunk-JSPKF52O.cjs.map +1 -0
  19. package/dist/chunk-KWGD24VS.js +2 -0
  20. package/dist/chunk-KWGD24VS.js.map +1 -0
  21. package/dist/chunk-M4G6J7DP.cjs +2 -0
  22. package/dist/chunk-M4G6J7DP.cjs.map +1 -0
  23. package/dist/chunk-WKAPAKUL.js +2 -0
  24. package/dist/chunk-WKAPAKUL.js.map +1 -0
  25. package/dist/combobox/index.cjs +2 -0
  26. package/dist/combobox/index.cjs.map +1 -0
  27. package/dist/combobox/index.d.cts +1039 -0
  28. package/dist/combobox/index.d.ts +1039 -0
  29. package/dist/combobox/index.js +2 -0
  30. package/dist/combobox/index.js.map +1 -0
  31. package/dist/command-score-Dgo3ZS3Z.d.ts +36 -0
  32. package/dist/command-score-YjNr3ZWi.d.cts +36 -0
  33. package/dist/context-menu/index.cjs +2 -0
  34. package/dist/context-menu/index.cjs.map +1 -0
  35. package/dist/context-menu/index.d.cts +658 -0
  36. package/dist/context-menu/index.d.ts +658 -0
  37. package/dist/context-menu/index.js +2 -0
  38. package/dist/context-menu/index.js.map +1 -0
  39. package/dist/data-surface-B-eIGTBi.d.cts +678 -0
  40. package/dist/data-surface-D1OilMDu.d.ts +678 -0
  41. package/dist/dropdown-menu/index.cjs +2 -0
  42. package/dist/dropdown-menu/index.cjs.map +1 -0
  43. package/dist/dropdown-menu/index.d.cts +700 -0
  44. package/dist/dropdown-menu/index.d.ts +700 -0
  45. package/dist/dropdown-menu/index.js +2 -0
  46. package/dist/dropdown-menu/index.js.map +1 -0
  47. package/dist/events-BPr8sRGH.d.cts +166 -0
  48. package/dist/events-BPr8sRGH.d.ts +166 -0
  49. package/dist/input-BoIK003I.d.cts +41 -0
  50. package/dist/input-DF7D8YzW.d.ts +41 -0
  51. package/dist/internal/listbox/index.cjs +2 -0
  52. package/dist/internal/listbox/index.cjs.map +1 -0
  53. package/dist/internal/listbox/index.d.cts +269 -0
  54. package/dist/internal/listbox/index.d.ts +269 -0
  55. package/dist/internal/listbox/index.js +2 -0
  56. package/dist/internal/listbox/index.js.map +1 -0
  57. package/dist/internal/popup-menu/index.cjs +2 -0
  58. package/dist/internal/popup-menu/index.cjs.map +1 -0
  59. package/dist/internal/popup-menu/index.d.cts +846 -0
  60. package/dist/internal/popup-menu/index.d.ts +846 -0
  61. package/dist/internal/popup-menu/index.js +2 -0
  62. package/dist/internal/popup-menu/index.js.map +1 -0
  63. package/dist/item-equality-B6TbXlBT.d.cts +7 -0
  64. package/dist/item-equality-B6TbXlBT.d.ts +7 -0
  65. package/dist/loading-DphSt8MY.d.cts +27 -0
  66. package/dist/loading-TsgH6v92.d.ts +27 -0
  67. package/dist/select/index.cjs +2 -0
  68. package/dist/select/index.cjs.map +1 -0
  69. package/dist/select/index.d.cts +927 -0
  70. package/dist/select/index.d.ts +927 -0
  71. package/dist/select/index.js +2 -0
  72. package/dist/select/index.js.map +1 -0
  73. package/dist/separator-B4Ot84B0.d.ts +748 -0
  74. package/dist/separator-BmbUeeaT.d.cts +748 -0
  75. package/dist/types-9vS1uLIK.d.cts +1557 -0
  76. package/dist/types-lQCIvWW8.d.ts +1557 -0
  77. package/dist/use-listbox-item-BIi4eRPI.d.cts +182 -0
  78. package/dist/use-listbox-item-BIi4eRPI.d.ts +182 -0
  79. package/package.json +50 -12
  80. package/dist/index.d.ts +0 -2
  81. package/dist/index.js +0 -2
@@ -0,0 +1,182 @@
1
+ import * as React from 'react';
2
+
3
+ interface ItemContextValue {
4
+ /** Unique ID for this item (for DOM id attribute) */
5
+ id: string;
6
+ /** Whether the item is highlighted */
7
+ highlighted: boolean;
8
+ /** Whether the item is disabled */
9
+ disabled: boolean;
10
+ /** Keyboard shortcut for this item */
11
+ shortcut?: string;
12
+ }
13
+ declare const ItemContext: React.Context<ItemContextValue | null>;
14
+ declare function useItemContext(): ItemContextValue;
15
+ declare function useMaybeItemContext(): ItemContextValue | null;
16
+
17
+ /**
18
+ * Aim guard refs for submenu navigation.
19
+ * Optional - only needed for popup menus with submenus.
20
+ */
21
+ interface AimGuardRefs {
22
+ /** Whether aim guard is currently active */
23
+ aimGuardActiveRef: React.RefObject<boolean>;
24
+ /** The depth at which aim guard is active (null when not guarding) */
25
+ guardedDepthRef: React.RefObject<number | null>;
26
+ }
27
+ /**
28
+ * Parameters for the useListboxItem hook.
29
+ */
30
+ interface UseListboxItemParams {
31
+ /**
32
+ * Explicit unique identifier for this item in the store.
33
+ * Takes highest priority for item registration.
34
+ * Used by data-first APIs to ensure consistent IDs.
35
+ */
36
+ id?: string;
37
+ /**
38
+ * Unique value for this item used as identifier and for filtering.
39
+ * If not provided, will be inferred from textContent.
40
+ * Used for registration when `id` is not provided.
41
+ */
42
+ value?: string;
43
+ /**
44
+ * Additional keywords to match against when filtering.
45
+ * Useful for aliases or synonyms.
46
+ */
47
+ keywords?: string[];
48
+ /**
49
+ * Whether this item is disabled.
50
+ * Disabled items are not selectable and are skipped during keyboard navigation.
51
+ */
52
+ disabled?: boolean;
53
+ /**
54
+ * Whether to force render this item regardless of filter results.
55
+ * @default false
56
+ */
57
+ forceMount?: boolean;
58
+ /**
59
+ * Keyboard shortcut to trigger this item.
60
+ * When the menu is focused and the user presses this key, the item will be selected.
61
+ * Should be a single character (e.g., "1", "a", etc.).
62
+ */
63
+ shortcut?: string;
64
+ /**
65
+ * Forces this row's relative order during score-based sorting.
66
+ * Lower values appear earlier.
67
+ * @default 0
68
+ */
69
+ forceOrder?: number;
70
+ /**
71
+ * Overrides this row's computed fuzzy-match score.
72
+ * Useful for pinning or manually ranking rows in score-based views.
73
+ */
74
+ forceScore?: number;
75
+ /**
76
+ * Whether this item is a submenu trigger (for store registration).
77
+ * @default false
78
+ */
79
+ isSubmenuTrigger?: boolean;
80
+ /**
81
+ * Callback when this item is selected (via click or Enter key).
82
+ * For simple items, pass this directly. For checkbox/radio items,
83
+ * use registerSelect() to register a dynamic handler.
84
+ */
85
+ onSelect?: () => void;
86
+ /**
87
+ * Whether selecting this item should close the menu.
88
+ * @default true
89
+ */
90
+ closeOnClick?: boolean;
91
+ /**
92
+ * Callback invoked after selection occurs (via click).
93
+ * Called with the item's ID. The consumer handles any
94
+ * post-selection behavior like closing menus.
95
+ */
96
+ onAfterSelect?: (itemId: string) => void;
97
+ /**
98
+ * Children (used for text content inference when value is not provided).
99
+ */
100
+ children?: React.ReactNode;
101
+ /**
102
+ * Optional aim guard refs for popup menu navigation.
103
+ * When provided, pointer move events will respect the aim guard.
104
+ */
105
+ aimGuard?: AimGuardRefs;
106
+ }
107
+ /**
108
+ * Return value from the useListboxItem hook.
109
+ */
110
+ interface UseListboxItemReturn {
111
+ /** Unique ID for this item (DOM ID for aria-activedescendant) */
112
+ id: string;
113
+ /**
114
+ * Store identifier for this item.
115
+ * Use this when calling store methods like setHighlightedId, registerSubmenuOpen, etc.
116
+ * This is the `value` prop (or inferred from textContent).
117
+ */
118
+ storeId: string;
119
+ /** Ref to attach to the item element */
120
+ ref: React.RefObject<HTMLDivElement | null>;
121
+ /** Whether item is currently highlighted */
122
+ isHighlighted: boolean;
123
+ /** Whether item should be rendered (passes filter) */
124
+ isVisible: boolean;
125
+ /** Context value to provide to children via ItemContext.Provider */
126
+ contextValue: ItemContextValue;
127
+ /**
128
+ * Event handlers to spread on the element.
129
+ * These handle click, pointer move, and pointer down events.
130
+ */
131
+ handlers: {
132
+ onClick: React.MouseEventHandler<HTMLDivElement>;
133
+ onPointerMove: React.PointerEventHandler<HTMLDivElement>;
134
+ onPointerDown: React.PointerEventHandler<HTMLDivElement>;
135
+ };
136
+ /**
137
+ * Register a custom onSelect handler.
138
+ * This is useful for checkbox/radio items where the select behavior
139
+ * needs to be customized (e.g., toggle checked state).
140
+ * Returns an unregister function.
141
+ */
142
+ registerSelect: (handler: (() => void) | undefined) => () => void;
143
+ }
144
+ /**
145
+ * Hook that provides all shared logic for navigatable/highlightable listbox items.
146
+ *
147
+ * This hook handles:
148
+ * - Item registration with the listbox store
149
+ * - Highlight state management (keyboard and pointer)
150
+ * - Filter/search visibility
151
+ * - Scroll into view on keyboard navigation
152
+ * - Click, pointer move, and pointer down event handlers
153
+ * - Optional aim guard integration (for submenu navigation)
154
+ *
155
+ * @example
156
+ * ```tsx
157
+ * function CustomItem(props) {
158
+ * const item = useListboxItem({
159
+ * value: props.value,
160
+ * disabled: props.disabled,
161
+ * onSelect: props.onSelect,
162
+ * })
163
+ *
164
+ * if (!item.isVisible) return null
165
+ *
166
+ * return (
167
+ * <ItemContext.Provider value={item.contextValue}>
168
+ * <div
169
+ * ref={item.ref}
170
+ * {...item.handlers}
171
+ * data-highlighted={item.isHighlighted || undefined}
172
+ * >
173
+ * {props.children}
174
+ * </div>
175
+ * </ItemContext.Provider>
176
+ * )
177
+ * }
178
+ * ```
179
+ */
180
+ declare function useListboxItem(params: UseListboxItemParams): UseListboxItemReturn;
181
+
182
+ export { type AimGuardRefs as A, type ItemContextValue as I, type UseListboxItemParams as U, useMaybeItemContext as a, ItemContext as b, type UseListboxItemReturn as c, useListboxItem as d, useItemContext as u };
@@ -0,0 +1,182 @@
1
+ import * as React from 'react';
2
+
3
+ interface ItemContextValue {
4
+ /** Unique ID for this item (for DOM id attribute) */
5
+ id: string;
6
+ /** Whether the item is highlighted */
7
+ highlighted: boolean;
8
+ /** Whether the item is disabled */
9
+ disabled: boolean;
10
+ /** Keyboard shortcut for this item */
11
+ shortcut?: string;
12
+ }
13
+ declare const ItemContext: React.Context<ItemContextValue | null>;
14
+ declare function useItemContext(): ItemContextValue;
15
+ declare function useMaybeItemContext(): ItemContextValue | null;
16
+
17
+ /**
18
+ * Aim guard refs for submenu navigation.
19
+ * Optional - only needed for popup menus with submenus.
20
+ */
21
+ interface AimGuardRefs {
22
+ /** Whether aim guard is currently active */
23
+ aimGuardActiveRef: React.RefObject<boolean>;
24
+ /** The depth at which aim guard is active (null when not guarding) */
25
+ guardedDepthRef: React.RefObject<number | null>;
26
+ }
27
+ /**
28
+ * Parameters for the useListboxItem hook.
29
+ */
30
+ interface UseListboxItemParams {
31
+ /**
32
+ * Explicit unique identifier for this item in the store.
33
+ * Takes highest priority for item registration.
34
+ * Used by data-first APIs to ensure consistent IDs.
35
+ */
36
+ id?: string;
37
+ /**
38
+ * Unique value for this item used as identifier and for filtering.
39
+ * If not provided, will be inferred from textContent.
40
+ * Used for registration when `id` is not provided.
41
+ */
42
+ value?: string;
43
+ /**
44
+ * Additional keywords to match against when filtering.
45
+ * Useful for aliases or synonyms.
46
+ */
47
+ keywords?: string[];
48
+ /**
49
+ * Whether this item is disabled.
50
+ * Disabled items are not selectable and are skipped during keyboard navigation.
51
+ */
52
+ disabled?: boolean;
53
+ /**
54
+ * Whether to force render this item regardless of filter results.
55
+ * @default false
56
+ */
57
+ forceMount?: boolean;
58
+ /**
59
+ * Keyboard shortcut to trigger this item.
60
+ * When the menu is focused and the user presses this key, the item will be selected.
61
+ * Should be a single character (e.g., "1", "a", etc.).
62
+ */
63
+ shortcut?: string;
64
+ /**
65
+ * Forces this row's relative order during score-based sorting.
66
+ * Lower values appear earlier.
67
+ * @default 0
68
+ */
69
+ forceOrder?: number;
70
+ /**
71
+ * Overrides this row's computed fuzzy-match score.
72
+ * Useful for pinning or manually ranking rows in score-based views.
73
+ */
74
+ forceScore?: number;
75
+ /**
76
+ * Whether this item is a submenu trigger (for store registration).
77
+ * @default false
78
+ */
79
+ isSubmenuTrigger?: boolean;
80
+ /**
81
+ * Callback when this item is selected (via click or Enter key).
82
+ * For simple items, pass this directly. For checkbox/radio items,
83
+ * use registerSelect() to register a dynamic handler.
84
+ */
85
+ onSelect?: () => void;
86
+ /**
87
+ * Whether selecting this item should close the menu.
88
+ * @default true
89
+ */
90
+ closeOnClick?: boolean;
91
+ /**
92
+ * Callback invoked after selection occurs (via click).
93
+ * Called with the item's ID. The consumer handles any
94
+ * post-selection behavior like closing menus.
95
+ */
96
+ onAfterSelect?: (itemId: string) => void;
97
+ /**
98
+ * Children (used for text content inference when value is not provided).
99
+ */
100
+ children?: React.ReactNode;
101
+ /**
102
+ * Optional aim guard refs for popup menu navigation.
103
+ * When provided, pointer move events will respect the aim guard.
104
+ */
105
+ aimGuard?: AimGuardRefs;
106
+ }
107
+ /**
108
+ * Return value from the useListboxItem hook.
109
+ */
110
+ interface UseListboxItemReturn {
111
+ /** Unique ID for this item (DOM ID for aria-activedescendant) */
112
+ id: string;
113
+ /**
114
+ * Store identifier for this item.
115
+ * Use this when calling store methods like setHighlightedId, registerSubmenuOpen, etc.
116
+ * This is the `value` prop (or inferred from textContent).
117
+ */
118
+ storeId: string;
119
+ /** Ref to attach to the item element */
120
+ ref: React.RefObject<HTMLDivElement | null>;
121
+ /** Whether item is currently highlighted */
122
+ isHighlighted: boolean;
123
+ /** Whether item should be rendered (passes filter) */
124
+ isVisible: boolean;
125
+ /** Context value to provide to children via ItemContext.Provider */
126
+ contextValue: ItemContextValue;
127
+ /**
128
+ * Event handlers to spread on the element.
129
+ * These handle click, pointer move, and pointer down events.
130
+ */
131
+ handlers: {
132
+ onClick: React.MouseEventHandler<HTMLDivElement>;
133
+ onPointerMove: React.PointerEventHandler<HTMLDivElement>;
134
+ onPointerDown: React.PointerEventHandler<HTMLDivElement>;
135
+ };
136
+ /**
137
+ * Register a custom onSelect handler.
138
+ * This is useful for checkbox/radio items where the select behavior
139
+ * needs to be customized (e.g., toggle checked state).
140
+ * Returns an unregister function.
141
+ */
142
+ registerSelect: (handler: (() => void) | undefined) => () => void;
143
+ }
144
+ /**
145
+ * Hook that provides all shared logic for navigatable/highlightable listbox items.
146
+ *
147
+ * This hook handles:
148
+ * - Item registration with the listbox store
149
+ * - Highlight state management (keyboard and pointer)
150
+ * - Filter/search visibility
151
+ * - Scroll into view on keyboard navigation
152
+ * - Click, pointer move, and pointer down event handlers
153
+ * - Optional aim guard integration (for submenu navigation)
154
+ *
155
+ * @example
156
+ * ```tsx
157
+ * function CustomItem(props) {
158
+ * const item = useListboxItem({
159
+ * value: props.value,
160
+ * disabled: props.disabled,
161
+ * onSelect: props.onSelect,
162
+ * })
163
+ *
164
+ * if (!item.isVisible) return null
165
+ *
166
+ * return (
167
+ * <ItemContext.Provider value={item.contextValue}>
168
+ * <div
169
+ * ref={item.ref}
170
+ * {...item.handlers}
171
+ * data-highlighted={item.isHighlighted || undefined}
172
+ * >
173
+ * {props.children}
174
+ * </div>
175
+ * </ItemContext.Provider>
176
+ * )
177
+ * }
178
+ * ```
179
+ */
180
+ declare function useListboxItem(params: UseListboxItemParams): UseListboxItemReturn;
181
+
182
+ export { type AimGuardRefs as A, type ItemContextValue as I, type UseListboxItemParams as U, useMaybeItemContext as a, ItemContext as b, type UseListboxItemReturn as c, useListboxItem as d, useItemContext as u };
package/package.json CHANGED
@@ -1,18 +1,46 @@
1
1
  {
2
2
  "name": "@bazza-ui/react",
3
- "version": "0.0.0",
3
+ "version": "0.1.0-canary.2",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "type": "module",
9
- "main": "./dist/index.js",
10
- "module": "./dist/index.js",
11
- "types": "./dist/index.d.ts",
12
9
  "exports": {
13
- ".": {
14
- "types": "./dist/index.d.ts",
15
- "import": "./dist/index.js"
10
+ "./dropdown-menu": {
11
+ "types": "./dist/dropdown-menu/index.d.ts",
12
+ "import": "./dist/dropdown-menu/index.js",
13
+ "require": "./dist/dropdown-menu/index.cjs"
14
+ },
15
+ "./select": {
16
+ "types": "./dist/select/index.d.ts",
17
+ "import": "./dist/select/index.js",
18
+ "require": "./dist/select/index.cjs"
19
+ },
20
+ "./combobox": {
21
+ "types": "./dist/combobox/index.d.ts",
22
+ "import": "./dist/combobox/index.js",
23
+ "require": "./dist/combobox/index.cjs"
24
+ },
25
+ "./context-menu": {
26
+ "types": "./dist/context-menu/index.d.ts",
27
+ "import": "./dist/context-menu/index.js",
28
+ "require": "./dist/context-menu/index.cjs"
29
+ },
30
+ "./adapters": {
31
+ "types": "./dist/adapters/index.d.ts",
32
+ "import": "./dist/adapters/index.js",
33
+ "require": "./dist/adapters/index.cjs"
34
+ },
35
+ "./internal/listbox": {
36
+ "types": "./dist/internal/listbox/index.d.ts",
37
+ "import": "./dist/internal/listbox/index.js",
38
+ "require": "./dist/internal/listbox/index.cjs"
39
+ },
40
+ "./internal/popup-menu": {
41
+ "types": "./dist/internal/popup-menu/index.d.ts",
42
+ "import": "./dist/internal/popup-menu/index.js",
43
+ "require": "./dist/internal/popup-menu/index.cjs"
16
44
  }
17
45
  },
18
46
  "files": [
@@ -21,21 +49,31 @@
21
49
  "scripts": {
22
50
  "dev": "tsup --watch",
23
51
  "type-check": "tsc --noEmit",
24
- "build": "tsup"
52
+ "build": "tsup",
53
+ "test": "vitest run",
54
+ "test:watch": "vitest --watch"
25
55
  },
26
56
  "peerDependencies": {
27
57
  "react": ">=18.0.0",
28
58
  "react-dom": ">=18.0.0"
29
59
  },
30
60
  "dependencies": {
31
- "@base-ui/react": "^1.0.0",
32
- "@base-ui/utils": "^0.2.3"
61
+ "@base-ui/react": "1.0.0",
62
+ "@base-ui/utils": "0.2.3"
33
63
  },
34
64
  "devDependencies": {
35
65
  "@bazza-ui/typescript-config": "0.0.0",
66
+ "@tanstack/react-form": "^1.27.7",
67
+ "@testing-library/jest-dom": "^6.9.1",
68
+ "@testing-library/react": "^16.3.1",
69
+ "@testing-library/user-event": "^14.6.1",
36
70
  "@types/react": "^19.1.2",
37
71
  "@types/react-dom": "^19.1.2",
38
- "tsup": "^8.5.0",
39
- "typescript": "^5.9.3"
72
+ "@vitejs/plugin-react": "^5.1.2",
73
+ "jsdom": "^27.4.0",
74
+ "react-hook-form": "^7.71.1",
75
+ "tsup": "^8.5.1",
76
+ "typescript": "^5.9.3",
77
+ "vitest": "^4.0.17"
40
78
  }
41
79
  }
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- // @bazza-ui/react - placeholder release
2
- export {};
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- // @bazza-ui/react - placeholder release
2
- export {};