@arun-dev/headless 4.13.0 → 4.15.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/dist/avatar/index.cjs +218 -0
- package/dist/avatar/index.d.cts +52 -0
- package/dist/avatar/index.d.ts +52 -0
- package/dist/avatar/index.js +105 -0
- package/dist/chunk-36N5DD5K.js +78 -0
- package/dist/chunk-E4JBFRMM.js +11 -0
- package/dist/chunk-ETNICT5M.js +8 -0
- package/dist/combobox/index.cjs +3 -1
- package/dist/combobox/index.js +6 -6
- package/dist/menu/index.cjs +311 -19
- package/dist/menu/index.d.cts +144 -10
- package/dist/menu/index.d.ts +144 -10
- package/dist/menu/index.js +310 -22
- package/dist/rovingFocus-BZB3yicE.d.cts +11 -0
- package/dist/rovingFocus-BZB3yicE.d.ts +11 -0
- package/dist/tabs/index.d.cts +1 -10
- package/dist/tabs/index.d.ts +1 -10
- package/dist/toggle/index.cjs +232 -0
- package/dist/toggle/index.d.cts +26 -0
- package/dist/toggle/index.d.ts +26 -0
- package/dist/toggle/index.js +68 -0
- package/dist/toggle-group/index.cjs +292 -0
- package/dist/toggle-group/index.d.cts +31 -0
- package/dist/toggle-group/index.d.ts +31 -0
- package/dist/toggle-group/index.js +68 -0
- package/dist/toolbar/index.cjs +357 -0
- package/dist/toolbar/index.d.cts +89 -0
- package/dist/toolbar/index.d.ts +89 -0
- package/dist/toolbar/index.js +152 -0
- package/package.json +41 -1
|
@@ -0,0 +1,31 @@
|
|
|
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 ToggleGroupOwnProps = {
|
|
6
|
+
/** Controlled: the pressed Toggles' values. Provide `onValueChange` alongside it. */
|
|
7
|
+
value?: readonly string[];
|
|
8
|
+
/** Initial value when uncontrolled. Read once, at mount. */
|
|
9
|
+
defaultValue?: readonly string[];
|
|
10
|
+
onValueChange?: (value: string[]) => void;
|
|
11
|
+
/** Lets more than one Toggle be pressed. Without it, pressing one releases the others. */
|
|
12
|
+
multiple?: boolean;
|
|
13
|
+
/** Disables every Toggle in it. */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Which arrow keys move between the Toggles. */
|
|
16
|
+
orientation?: Orientation;
|
|
17
|
+
/** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
|
|
18
|
+
render?: ReactElement;
|
|
19
|
+
/** Ref to the rendered element. Merged with any ref on the `render` element. */
|
|
20
|
+
ref?: Ref<HTMLElement>;
|
|
21
|
+
};
|
|
22
|
+
type ToggleGroupProps = ToggleGroupOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ToggleGroupOwnProps>;
|
|
23
|
+
/**
|
|
24
|
+
* Toggles that share one value (decision 17): `role="group"`, one Tab stop — the pressed Toggle,
|
|
25
|
+
* or the first — and the arrow keys between them. Pressing the pressed Toggle releases it, so the
|
|
26
|
+
* value may be empty. Inside a Toolbar its Toggles join the Toolbar's arrow keys instead. Name it
|
|
27
|
+
* with `aria-label`.
|
|
28
|
+
*/
|
|
29
|
+
declare function ToggleGroup({ value: valueProp, defaultValue, onValueChange, multiple, disabled, orientation, className, children, render, ...rest }: ToggleGroupProps): react.JSX.Element;
|
|
30
|
+
|
|
31
|
+
export { ToggleGroup, type ToggleGroupProps };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ToggleGroupContext
|
|
3
|
+
} from "../chunk-E4JBFRMM.js";
|
|
4
|
+
import {
|
|
5
|
+
RovingGroupContext,
|
|
6
|
+
useRovingGroup,
|
|
7
|
+
useRovingGroupContext
|
|
8
|
+
} from "../chunk-36N5DD5K.js";
|
|
9
|
+
import "../chunk-2S4XG4VD.js";
|
|
10
|
+
import {
|
|
11
|
+
useControlled
|
|
12
|
+
} from "../chunk-UEIB3I3T.js";
|
|
13
|
+
import {
|
|
14
|
+
useRender
|
|
15
|
+
} from "../chunk-OQTWWZ4B.js";
|
|
16
|
+
|
|
17
|
+
// src/toggle-group/ToggleGroup.tsx
|
|
18
|
+
import { useCallback, useMemo } from "react";
|
|
19
|
+
import { jsx } from "react/jsx-runtime";
|
|
20
|
+
function ToggleGroup({
|
|
21
|
+
value: valueProp,
|
|
22
|
+
defaultValue,
|
|
23
|
+
onValueChange,
|
|
24
|
+
multiple = false,
|
|
25
|
+
disabled = false,
|
|
26
|
+
orientation = "horizontal",
|
|
27
|
+
className,
|
|
28
|
+
children,
|
|
29
|
+
render,
|
|
30
|
+
...rest
|
|
31
|
+
}) {
|
|
32
|
+
const [value, setValueState] = useControlled({
|
|
33
|
+
controlled: valueProp,
|
|
34
|
+
default: defaultValue ?? [],
|
|
35
|
+
name: "ToggleGroup",
|
|
36
|
+
state: "value"
|
|
37
|
+
});
|
|
38
|
+
const toggle = useCallback(
|
|
39
|
+
(item) => {
|
|
40
|
+
const pressed = value.includes(item);
|
|
41
|
+
const next = multiple ? pressed ? value.filter((v) => v !== item) : [...value, item] : pressed ? [] : [item];
|
|
42
|
+
setValueState(next);
|
|
43
|
+
onValueChange?.(next);
|
|
44
|
+
},
|
|
45
|
+
[value, multiple, setValueState, onValueChange]
|
|
46
|
+
);
|
|
47
|
+
const outer = useRovingGroupContext();
|
|
48
|
+
const roving = useRovingGroup({ orientation });
|
|
49
|
+
const context = useMemo(() => ({ value, disabled, toggle }), [value, disabled, toggle]);
|
|
50
|
+
const element = useRender({
|
|
51
|
+
render,
|
|
52
|
+
defaultTagName: "div",
|
|
53
|
+
props: {
|
|
54
|
+
role: "group",
|
|
55
|
+
"data-orientation": orientation,
|
|
56
|
+
"data-disabled": disabled ? "" : void 0,
|
|
57
|
+
className,
|
|
58
|
+
children,
|
|
59
|
+
// In a Toolbar, the Toolbar moves focus.
|
|
60
|
+
onKeyDown: outer ? void 0 : roving.onKeyDown
|
|
61
|
+
},
|
|
62
|
+
consumerProps: rest
|
|
63
|
+
});
|
|
64
|
+
return /* @__PURE__ */ jsx(ToggleGroupContext.Provider, { value: context, children: outer ? element : /* @__PURE__ */ jsx(RovingGroupContext.Provider, { value: roving.context, children: element }) });
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
ToggleGroup
|
|
68
|
+
};
|
|
@@ -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 };
|