@arun-dev/headless 4.12.0 → 4.14.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.
@@ -0,0 +1,357 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/toolbar/index.ts
21
+ var toolbar_exports = {};
22
+ __export(toolbar_exports, {
23
+ Toolbar: () => index_parts_exports
24
+ });
25
+ module.exports = __toCommonJS(toolbar_exports);
26
+
27
+ // src/toolbar/index.parts.ts
28
+ var index_parts_exports = {};
29
+ __export(index_parts_exports, {
30
+ Button: () => ToolbarButton,
31
+ Group: () => ToolbarGroup,
32
+ Input: () => ToolbarInput,
33
+ Link: () => ToolbarLink,
34
+ Root: () => ToolbarRoot,
35
+ Separator: () => ToolbarSeparator
36
+ });
37
+
38
+ // src/toolbar/ToolbarRoot.tsx
39
+ var import_react3 = require("react");
40
+
41
+ // src/core/useRender.ts
42
+ var import_react = require("react");
43
+
44
+ // src/core/mergeProps.ts
45
+ function isEventHandler(key) {
46
+ return key.length > 2 && key.startsWith("on") && key[2] === key[2]?.toUpperCase();
47
+ }
48
+ function mergeRefs(...refs) {
49
+ return (node) => {
50
+ const cleanups = refs.map((ref) => {
51
+ if (typeof ref === "function") {
52
+ const result = ref(node);
53
+ return typeof result === "function" ? result : () => ref(null);
54
+ }
55
+ if (ref && typeof ref === "object") {
56
+ ref.current = node;
57
+ return () => {
58
+ ref.current = null;
59
+ };
60
+ }
61
+ return void 0;
62
+ });
63
+ return () => {
64
+ cleanups.forEach((cleanup) => {
65
+ if (typeof cleanup === "function") cleanup();
66
+ });
67
+ };
68
+ };
69
+ }
70
+ function isSyntheticEvent(event) {
71
+ return typeof event === "object" && event !== null && "nativeEvent" in event;
72
+ }
73
+ function makeEventPreventable(event) {
74
+ if (Object.prototype.hasOwnProperty.call(event, "preventComponentHandler")) return;
75
+ const target = event;
76
+ target.preventComponentHandler = () => {
77
+ target.componentHandlerPrevented = true;
78
+ };
79
+ }
80
+ function isComponentHandlerPrevented(event) {
81
+ return typeof event === "object" && event !== null && event.componentHandlerPrevented === true;
82
+ }
83
+ function chainHandlers(earlier, value) {
84
+ return (...args) => {
85
+ const event = args[0];
86
+ if (isSyntheticEvent(event)) makeEventPreventable(event);
87
+ value(...args);
88
+ if (isComponentHandlerPrevented(event)) return;
89
+ earlier(...args);
90
+ };
91
+ }
92
+ function mergeProps(...objects) {
93
+ const merged = {};
94
+ for (const props of objects) {
95
+ if (!props) continue;
96
+ for (const key of Object.keys(props)) {
97
+ const value = props[key];
98
+ if (value === void 0) continue;
99
+ if (isEventHandler(key) && typeof value === "function") {
100
+ const earlier = merged[key];
101
+ merged[key] = typeof earlier === "function" ? chainHandlers(earlier, value) : value;
102
+ } else if (key === "className") {
103
+ merged.className = merged.className ? `${String(merged.className)} ${String(value)}` : value;
104
+ } else if (key === "style") {
105
+ merged.style = { ...merged.style, ...value };
106
+ } else if (key === "ref") {
107
+ merged.ref = merged.ref ? mergeRefs(merged.ref, value) : value;
108
+ } else {
109
+ merged[key] = value;
110
+ }
111
+ }
112
+ }
113
+ return merged;
114
+ }
115
+
116
+ // src/core/useRender.ts
117
+ function useRender({
118
+ render,
119
+ defaultTagName,
120
+ props,
121
+ consumerProps
122
+ }) {
123
+ const merged = mergeProps(props, consumerProps);
124
+ if ((0, import_react.isValidElement)(render)) {
125
+ return (0, import_react.cloneElement)(render, mergeProps(merged, render.props));
126
+ }
127
+ return (0, import_react.createElement)(defaultTagName, merged);
128
+ }
129
+
130
+ // src/core/rovingGroup.ts
131
+ var import_react2 = require("react");
132
+
133
+ // src/core/rovingFocus.ts
134
+ function byDocumentOrder(a, b) {
135
+ const x = a.ref.current;
136
+ const y = b.ref.current;
137
+ if (!x || !y) return 0;
138
+ return x.compareDocumentPosition(y) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
139
+ }
140
+ function rovingIndex(key, {
141
+ count,
142
+ current,
143
+ orientation,
144
+ rtl
145
+ }) {
146
+ if (count === 0) return null;
147
+ const [prevKey, nextKey] = orientation === "vertical" ? ["ArrowUp", "ArrowDown"] : rtl ? ["ArrowRight", "ArrowLeft"] : ["ArrowLeft", "ArrowRight"];
148
+ switch (key) {
149
+ case nextKey:
150
+ return current < 0 ? 0 : (current + 1) % count;
151
+ case prevKey:
152
+ return current < 0 ? count - 1 : (current - 1 + count) % count;
153
+ case "Home":
154
+ return 0;
155
+ case "End":
156
+ return count - 1;
157
+ default:
158
+ return null;
159
+ }
160
+ }
161
+
162
+ // src/core/rovingGroup.ts
163
+ var RovingGroupContext = (0, import_react2.createContext)(null);
164
+ function useRovingGroupContext() {
165
+ return (0, import_react2.useContext)(RovingGroupContext);
166
+ }
167
+ function keyBelongsToField(event, orientation) {
168
+ const target = event.target;
169
+ if (!(target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)) return false;
170
+ if (target instanceof HTMLInputElement && !/^(text|search|url|tel|email|password|number)$/.test(target.type)) {
171
+ return false;
172
+ }
173
+ const { key } = event;
174
+ const along = orientation === "horizontal" ? ["ArrowLeft", "ArrowRight", "Home", "End"] : [];
175
+ if (!along.includes(key)) return false;
176
+ const start = target.selectionStart ?? 0;
177
+ const end = target.selectionEnd ?? 0;
178
+ const atStart = start === 0 && end === 0;
179
+ const atEnd = start === target.value.length && end === target.value.length;
180
+ const rtl = getComputedStyle(target).direction === "rtl";
181
+ const towardStart = key === (rtl ? "ArrowRight" : "ArrowLeft") || key === "Home";
182
+ return towardStart ? !atStart : !atEnd;
183
+ }
184
+ function useRovingGroup({ orientation }) {
185
+ const [items, setItems] = (0, import_react2.useState)([]);
186
+ const register = (0, import_react2.useCallback)((item) => {
187
+ setItems((current) => [...current, item].sort(byDocumentOrder));
188
+ return () => setItems((current) => current.filter((i) => i !== item));
189
+ }, []);
190
+ const [chosen, setTabStop] = (0, import_react2.useState)(null);
191
+ const enabled = items.filter((item) => !item.disabled);
192
+ const tabStop = (
193
+ // Matched by element: an item re-registers when its props change.
194
+ chosen && enabled.find((item) => item.ref === chosen.ref) || enabled.find((item) => item.selected) || enabled[0] || null
195
+ );
196
+ const onKeyDown = (0, import_react2.useCallback)(
197
+ (event) => {
198
+ if (event.defaultPrevented || keyBelongsToField(event, orientation)) return;
199
+ const current = enabled.findIndex((item2) => item2.ref.current?.contains(event.target));
200
+ const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
201
+ const next = rovingIndex(event.key, { count: enabled.length, current, orientation, rtl });
202
+ if (next === null) return;
203
+ const item = enabled[next];
204
+ if (!item) return;
205
+ event.preventDefault();
206
+ item.ref.current?.focus();
207
+ setTabStop(item);
208
+ },
209
+ [enabled, orientation]
210
+ );
211
+ const context = (0, import_react2.useMemo)(() => ({ tabStop, register, setTabStop }), [tabStop, register]);
212
+ return { context, onKeyDown };
213
+ }
214
+ function useRovingItem(ref, disabled, selected = false) {
215
+ const group = useRovingGroupContext();
216
+ const item = (0, import_react2.useMemo)(() => ({ ref, disabled, selected }), [ref, disabled, selected]);
217
+ const register = group?.register;
218
+ (0, import_react2.useLayoutEffect)(() => register?.(item), [register, item]);
219
+ if (!group) return { tabIndex: void 0, onFocus: void 0 };
220
+ return {
221
+ tabIndex: group.tabStop?.ref === ref ? 0 : -1,
222
+ onFocus() {
223
+ group.setTabStop(item);
224
+ }
225
+ };
226
+ }
227
+
228
+ // src/toolbar/ToolbarRoot.tsx
229
+ var import_jsx_runtime = require("react/jsx-runtime");
230
+ var ToolbarContext = (0, import_react3.createContext)(null);
231
+ function useToolbarContext(part) {
232
+ const context = (0, import_react3.useContext)(ToolbarContext);
233
+ if (!context) throw new Error(`<Toolbar.${part}> must be rendered inside <Toolbar.Root>.`);
234
+ return context;
235
+ }
236
+ function ToolbarRoot({
237
+ orientation = "horizontal",
238
+ className,
239
+ children,
240
+ render,
241
+ ...rest
242
+ }) {
243
+ const roving = useRovingGroup({ orientation });
244
+ const element = useRender({
245
+ render,
246
+ defaultTagName: "div",
247
+ props: {
248
+ role: "toolbar",
249
+ "aria-orientation": orientation,
250
+ "data-orientation": orientation,
251
+ className,
252
+ children,
253
+ onKeyDown: roving.onKeyDown
254
+ },
255
+ consumerProps: rest
256
+ });
257
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolbarContext.Provider, { value: { orientation }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RovingGroupContext.Provider, { value: roving.context, children: element }) });
258
+ }
259
+
260
+ // src/toolbar/ToolbarButton.tsx
261
+ var import_react4 = require("react");
262
+ function ToolbarButton({
263
+ disabled = false,
264
+ className,
265
+ render,
266
+ ...rest
267
+ }) {
268
+ useToolbarContext("Button");
269
+ const elementRef = (0, import_react4.useRef)(null);
270
+ const roving = useRovingItem(elementRef, disabled);
271
+ return useRender({
272
+ render,
273
+ defaultTagName: "button",
274
+ props: {
275
+ type: "button",
276
+ disabled: disabled || void 0,
277
+ "data-disabled": disabled ? "" : void 0,
278
+ tabIndex: roving.tabIndex,
279
+ className,
280
+ ref: elementRef,
281
+ onFocus: roving.onFocus
282
+ },
283
+ consumerProps: rest
284
+ });
285
+ }
286
+
287
+ // src/toolbar/ToolbarLink.tsx
288
+ var import_react5 = require("react");
289
+ function ToolbarLink({ className, render, ...rest }) {
290
+ useToolbarContext("Link");
291
+ const elementRef = (0, import_react5.useRef)(null);
292
+ const roving = useRovingItem(elementRef, false);
293
+ return useRender({
294
+ render,
295
+ defaultTagName: "a",
296
+ props: {
297
+ tabIndex: roving.tabIndex,
298
+ className,
299
+ ref: elementRef,
300
+ onFocus: roving.onFocus
301
+ },
302
+ consumerProps: rest
303
+ });
304
+ }
305
+
306
+ // src/toolbar/ToolbarInput.tsx
307
+ var import_react6 = require("react");
308
+ function ToolbarInput({ disabled = false, className, render, ...rest }) {
309
+ useToolbarContext("Input");
310
+ const elementRef = (0, import_react6.useRef)(null);
311
+ const roving = useRovingItem(elementRef, disabled);
312
+ return useRender({
313
+ render,
314
+ defaultTagName: "input",
315
+ props: {
316
+ disabled: disabled || void 0,
317
+ "data-disabled": disabled ? "" : void 0,
318
+ tabIndex: roving.tabIndex,
319
+ className,
320
+ ref: elementRef,
321
+ onFocus: roving.onFocus
322
+ },
323
+ consumerProps: rest
324
+ });
325
+ }
326
+
327
+ // src/toolbar/ToolbarGroup.tsx
328
+ function ToolbarGroup({ className, render, ...rest }) {
329
+ useToolbarContext("Group");
330
+ return useRender({
331
+ render,
332
+ defaultTagName: "div",
333
+ props: { role: "group", className },
334
+ consumerProps: rest
335
+ });
336
+ }
337
+
338
+ // src/toolbar/ToolbarSeparator.tsx
339
+ function ToolbarSeparator({ className, render, ...rest }) {
340
+ const { orientation } = useToolbarContext("Separator");
341
+ const own = orientation === "horizontal" ? "vertical" : "horizontal";
342
+ return useRender({
343
+ render,
344
+ defaultTagName: "div",
345
+ props: {
346
+ role: "separator",
347
+ "aria-orientation": own,
348
+ "data-orientation": own,
349
+ className
350
+ },
351
+ consumerProps: rest
352
+ });
353
+ }
354
+ // Annotate the CommonJS export names for ESM import in node:
355
+ 0 && (module.exports = {
356
+ Toolbar
357
+ });
@@ -0,0 +1,89 @@
1
+ import * as react from 'react';
2
+ import { ReactElement, Ref, ComponentPropsWithRef } from 'react';
3
+ import { O as Orientation } from '../rovingFocus-BZB3yicE.cjs';
4
+
5
+ type ToolbarRootOwnProps = {
6
+ /** Which arrow keys move between items. */
7
+ orientation?: Orientation;
8
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
9
+ render?: ReactElement;
10
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
11
+ ref?: Ref<HTMLElement>;
12
+ };
13
+ type ToolbarRootProps = ToolbarRootOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ToolbarRootOwnProps>;
14
+ /**
15
+ * A row of controls (decision 17): `role="toolbar"`, one Tab stop, and the arrow keys across its
16
+ * Buttons, Links, Inputs and Toggles — a ToggleGroup inside joins in. A text Input keeps the arrow
17
+ * keys for its caret until the caret reaches an end. Name it with `aria-label`.
18
+ */
19
+ declare function ToolbarRoot({ orientation, className, children, render, ...rest }: ToolbarRootProps): react.JSX.Element;
20
+
21
+ type ToolbarButtonOwnProps = {
22
+ /** Out of the arrow keys, and not usable. */
23
+ disabled?: boolean;
24
+ /** Element to render instead of the default `<button>`. Props and ref are merged onto it. */
25
+ render?: ReactElement;
26
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
27
+ ref?: Ref<HTMLElement>;
28
+ };
29
+ type ToolbarButtonProps = ToolbarButtonOwnProps & Omit<ComponentPropsWithRef<'button'>, keyof ToolbarButtonOwnProps>;
30
+ /**
31
+ * A button in the Toolbar, one of its arrow-key items.
32
+ */
33
+ declare function ToolbarButton({ disabled, className, render, ...rest }: ToolbarButtonProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
34
+
35
+ type ToolbarLinkOwnProps = {
36
+ /** Element to render instead of the default `<a>`. Props and ref are merged onto it. */
37
+ render?: ReactElement;
38
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
39
+ ref?: Ref<HTMLElement>;
40
+ };
41
+ type ToolbarLinkProps = ToolbarLinkOwnProps & Omit<ComponentPropsWithRef<'a'>, keyof ToolbarLinkOwnProps>;
42
+ /**
43
+ * A link in the Toolbar, one of its arrow-key items. A link cannot be disabled.
44
+ */
45
+ declare function ToolbarLink({ className, render, ...rest }: ToolbarLinkProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
46
+
47
+ type ToolbarInputOwnProps = {
48
+ /** Out of the arrow keys, and not usable. */
49
+ disabled?: boolean;
50
+ /** Element to render instead of the default `<input>`. Props and ref are merged onto it. */
51
+ render?: ReactElement;
52
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
53
+ ref?: Ref<HTMLElement>;
54
+ };
55
+ type ToolbarInputProps = ToolbarInputOwnProps & Omit<ComponentPropsWithRef<'input'>, keyof ToolbarInputOwnProps>;
56
+ /**
57
+ * A field in the Toolbar, one of its arrow-key items. It keeps Left, Right, Home and End
58
+ * for its caret until the caret is at an end.
59
+ */
60
+ declare function ToolbarInput({ disabled, className, render, ...rest }: ToolbarInputProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
61
+
62
+ type ToolbarGroupOwnProps = {
63
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
64
+ render?: ReactElement;
65
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
66
+ ref?: Ref<HTMLElement>;
67
+ };
68
+ type ToolbarGroupProps = ToolbarGroupOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ToolbarGroupOwnProps>;
69
+ /** Related items, side by side: `role="group"`. Its items stay in the Toolbar's arrow keys. */
70
+ declare function ToolbarGroup({ className, render, ...rest }: ToolbarGroupProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
71
+
72
+ type ToolbarSeparatorOwnProps = {
73
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
74
+ render?: ReactElement;
75
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
76
+ ref?: Ref<HTMLElement>;
77
+ };
78
+ type ToolbarSeparatorProps = ToolbarSeparatorOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ToolbarSeparatorOwnProps | 'children'>;
79
+ /**
80
+ * A line between groups of items: `role="separator"`, upright in a horizontal Toolbar. A toolbar
81
+ * may hold separators; the arrow keys pass it.
82
+ */
83
+ declare function ToolbarSeparator({ className, render, ...rest }: ToolbarSeparatorProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
84
+
85
+ declare namespace index_parts {
86
+ export { ToolbarButton as Button, ToolbarGroup as Group, ToolbarInput as Input, ToolbarLink as Link, ToolbarRoot as Root, ToolbarSeparator as Separator };
87
+ }
88
+
89
+ export { index_parts as Toolbar, type ToolbarButtonProps, type ToolbarGroupProps, type ToolbarInputProps, type ToolbarLinkProps, type ToolbarRootProps, type ToolbarSeparatorProps };
@@ -0,0 +1,89 @@
1
+ import * as react from 'react';
2
+ import { ReactElement, Ref, ComponentPropsWithRef } from 'react';
3
+ import { O as Orientation } from '../rovingFocus-BZB3yicE.js';
4
+
5
+ type ToolbarRootOwnProps = {
6
+ /** Which arrow keys move between items. */
7
+ orientation?: Orientation;
8
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
9
+ render?: ReactElement;
10
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
11
+ ref?: Ref<HTMLElement>;
12
+ };
13
+ type ToolbarRootProps = ToolbarRootOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ToolbarRootOwnProps>;
14
+ /**
15
+ * A row of controls (decision 17): `role="toolbar"`, one Tab stop, and the arrow keys across its
16
+ * Buttons, Links, Inputs and Toggles — a ToggleGroup inside joins in. A text Input keeps the arrow
17
+ * keys for its caret until the caret reaches an end. Name it with `aria-label`.
18
+ */
19
+ declare function ToolbarRoot({ orientation, className, children, render, ...rest }: ToolbarRootProps): react.JSX.Element;
20
+
21
+ type ToolbarButtonOwnProps = {
22
+ /** Out of the arrow keys, and not usable. */
23
+ disabled?: boolean;
24
+ /** Element to render instead of the default `<button>`. Props and ref are merged onto it. */
25
+ render?: ReactElement;
26
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
27
+ ref?: Ref<HTMLElement>;
28
+ };
29
+ type ToolbarButtonProps = ToolbarButtonOwnProps & Omit<ComponentPropsWithRef<'button'>, keyof ToolbarButtonOwnProps>;
30
+ /**
31
+ * A button in the Toolbar, one of its arrow-key items.
32
+ */
33
+ declare function ToolbarButton({ disabled, className, render, ...rest }: ToolbarButtonProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
34
+
35
+ type ToolbarLinkOwnProps = {
36
+ /** Element to render instead of the default `<a>`. Props and ref are merged onto it. */
37
+ render?: ReactElement;
38
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
39
+ ref?: Ref<HTMLElement>;
40
+ };
41
+ type ToolbarLinkProps = ToolbarLinkOwnProps & Omit<ComponentPropsWithRef<'a'>, keyof ToolbarLinkOwnProps>;
42
+ /**
43
+ * A link in the Toolbar, one of its arrow-key items. A link cannot be disabled.
44
+ */
45
+ declare function ToolbarLink({ className, render, ...rest }: ToolbarLinkProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
46
+
47
+ type ToolbarInputOwnProps = {
48
+ /** Out of the arrow keys, and not usable. */
49
+ disabled?: boolean;
50
+ /** Element to render instead of the default `<input>`. Props and ref are merged onto it. */
51
+ render?: ReactElement;
52
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
53
+ ref?: Ref<HTMLElement>;
54
+ };
55
+ type ToolbarInputProps = ToolbarInputOwnProps & Omit<ComponentPropsWithRef<'input'>, keyof ToolbarInputOwnProps>;
56
+ /**
57
+ * A field in the Toolbar, one of its arrow-key items. It keeps Left, Right, Home and End
58
+ * for its caret until the caret is at an end.
59
+ */
60
+ declare function ToolbarInput({ disabled, className, render, ...rest }: ToolbarInputProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
61
+
62
+ type ToolbarGroupOwnProps = {
63
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
64
+ render?: ReactElement;
65
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
66
+ ref?: Ref<HTMLElement>;
67
+ };
68
+ type ToolbarGroupProps = ToolbarGroupOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ToolbarGroupOwnProps>;
69
+ /** Related items, side by side: `role="group"`. Its items stay in the Toolbar's arrow keys. */
70
+ declare function ToolbarGroup({ className, render, ...rest }: ToolbarGroupProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
71
+
72
+ type ToolbarSeparatorOwnProps = {
73
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
74
+ render?: ReactElement;
75
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
76
+ ref?: Ref<HTMLElement>;
77
+ };
78
+ type ToolbarSeparatorProps = ToolbarSeparatorOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ToolbarSeparatorOwnProps | 'children'>;
79
+ /**
80
+ * A line between groups of items: `role="separator"`, upright in a horizontal Toolbar. A toolbar
81
+ * may hold separators; the arrow keys pass it.
82
+ */
83
+ declare function ToolbarSeparator({ className, render, ...rest }: ToolbarSeparatorProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
84
+
85
+ declare namespace index_parts {
86
+ export { ToolbarButton as Button, ToolbarGroup as Group, ToolbarInput as Input, ToolbarLink as Link, ToolbarRoot as Root, ToolbarSeparator as Separator };
87
+ }
88
+
89
+ export { index_parts as Toolbar, type ToolbarButtonProps, type ToolbarGroupProps, type ToolbarInputProps, type ToolbarLinkProps, type ToolbarRootProps, type ToolbarSeparatorProps };
@@ -0,0 +1,152 @@
1
+ import {
2
+ RovingGroupContext,
3
+ useRovingGroup,
4
+ useRovingItem
5
+ } from "../chunk-36N5DD5K.js";
6
+ import "../chunk-2S4XG4VD.js";
7
+ import {
8
+ __export,
9
+ useRender
10
+ } from "../chunk-OQTWWZ4B.js";
11
+
12
+ // src/toolbar/index.parts.ts
13
+ var index_parts_exports = {};
14
+ __export(index_parts_exports, {
15
+ Button: () => ToolbarButton,
16
+ Group: () => ToolbarGroup,
17
+ Input: () => ToolbarInput,
18
+ Link: () => ToolbarLink,
19
+ Root: () => ToolbarRoot,
20
+ Separator: () => ToolbarSeparator
21
+ });
22
+
23
+ // src/toolbar/ToolbarRoot.tsx
24
+ import { createContext, useContext } from "react";
25
+ import { jsx } from "react/jsx-runtime";
26
+ var ToolbarContext = createContext(null);
27
+ function useToolbarContext(part) {
28
+ const context = useContext(ToolbarContext);
29
+ if (!context) throw new Error(`<Toolbar.${part}> must be rendered inside <Toolbar.Root>.`);
30
+ return context;
31
+ }
32
+ function ToolbarRoot({
33
+ orientation = "horizontal",
34
+ className,
35
+ children,
36
+ render,
37
+ ...rest
38
+ }) {
39
+ const roving = useRovingGroup({ orientation });
40
+ const element = useRender({
41
+ render,
42
+ defaultTagName: "div",
43
+ props: {
44
+ role: "toolbar",
45
+ "aria-orientation": orientation,
46
+ "data-orientation": orientation,
47
+ className,
48
+ children,
49
+ onKeyDown: roving.onKeyDown
50
+ },
51
+ consumerProps: rest
52
+ });
53
+ return /* @__PURE__ */ jsx(ToolbarContext.Provider, { value: { orientation }, children: /* @__PURE__ */ jsx(RovingGroupContext.Provider, { value: roving.context, children: element }) });
54
+ }
55
+
56
+ // src/toolbar/ToolbarButton.tsx
57
+ import { useRef } from "react";
58
+ function ToolbarButton({
59
+ disabled = false,
60
+ className,
61
+ render,
62
+ ...rest
63
+ }) {
64
+ useToolbarContext("Button");
65
+ const elementRef = useRef(null);
66
+ const roving = useRovingItem(elementRef, disabled);
67
+ return useRender({
68
+ render,
69
+ defaultTagName: "button",
70
+ props: {
71
+ type: "button",
72
+ disabled: disabled || void 0,
73
+ "data-disabled": disabled ? "" : void 0,
74
+ tabIndex: roving.tabIndex,
75
+ className,
76
+ ref: elementRef,
77
+ onFocus: roving.onFocus
78
+ },
79
+ consumerProps: rest
80
+ });
81
+ }
82
+
83
+ // src/toolbar/ToolbarLink.tsx
84
+ import { useRef as useRef2 } from "react";
85
+ function ToolbarLink({ className, render, ...rest }) {
86
+ useToolbarContext("Link");
87
+ const elementRef = useRef2(null);
88
+ const roving = useRovingItem(elementRef, false);
89
+ return useRender({
90
+ render,
91
+ defaultTagName: "a",
92
+ props: {
93
+ tabIndex: roving.tabIndex,
94
+ className,
95
+ ref: elementRef,
96
+ onFocus: roving.onFocus
97
+ },
98
+ consumerProps: rest
99
+ });
100
+ }
101
+
102
+ // src/toolbar/ToolbarInput.tsx
103
+ import { useRef as useRef3 } from "react";
104
+ function ToolbarInput({ disabled = false, className, render, ...rest }) {
105
+ useToolbarContext("Input");
106
+ const elementRef = useRef3(null);
107
+ const roving = useRovingItem(elementRef, disabled);
108
+ return useRender({
109
+ render,
110
+ defaultTagName: "input",
111
+ props: {
112
+ disabled: disabled || void 0,
113
+ "data-disabled": disabled ? "" : void 0,
114
+ tabIndex: roving.tabIndex,
115
+ className,
116
+ ref: elementRef,
117
+ onFocus: roving.onFocus
118
+ },
119
+ consumerProps: rest
120
+ });
121
+ }
122
+
123
+ // src/toolbar/ToolbarGroup.tsx
124
+ function ToolbarGroup({ className, render, ...rest }) {
125
+ useToolbarContext("Group");
126
+ return useRender({
127
+ render,
128
+ defaultTagName: "div",
129
+ props: { role: "group", className },
130
+ consumerProps: rest
131
+ });
132
+ }
133
+
134
+ // src/toolbar/ToolbarSeparator.tsx
135
+ function ToolbarSeparator({ className, render, ...rest }) {
136
+ const { orientation } = useToolbarContext("Separator");
137
+ const own = orientation === "horizontal" ? "vertical" : "horizontal";
138
+ return useRender({
139
+ render,
140
+ defaultTagName: "div",
141
+ props: {
142
+ role: "separator",
143
+ "aria-orientation": own,
144
+ "data-orientation": own,
145
+ className
146
+ },
147
+ consumerProps: rest
148
+ });
149
+ }
150
+ export {
151
+ index_parts_exports as Toolbar
152
+ };