panelui-web 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert/index.d.ts +15 -8
- package/dist/components/alert/index.js +65 -18
- package/dist/components/alert-dialog/index.d.ts +9 -3
- package/dist/components/alert-dialog/index.js +23 -7
- package/dist/components/avatar/index.d.ts +9 -3
- package/dist/components/avatar/index.js +34 -10
- package/dist/components/badge/index.d.ts +57 -0
- package/dist/components/badge/index.js +61 -0
- package/dist/components/bar-picker/index.d.ts +8 -1
- package/dist/components/bar-picker/index.js +35 -26
- package/dist/components/button/index.d.ts +68 -46
- package/dist/components/button/index.js +38 -2
- package/dist/components/button-group/index.d.ts +11 -5
- package/dist/components/button-group/index.js +31 -7
- package/dist/components/canvas/index.d.ts +9 -3
- package/dist/components/canvas/index.js +53 -25
- package/dist/components/card/index.d.ts +13 -7
- package/dist/components/card/index.js +45 -17
- package/dist/components/checkbox/index.d.ts +73 -0
- package/dist/components/checkbox/index.js +100 -0
- package/dist/components/chip/index.d.ts +79 -0
- package/dist/components/chip/index.js +112 -0
- package/dist/components/choice-cards/index.d.ts +11 -5
- package/dist/components/choice-cards/index.js +25 -6
- package/dist/components/command-dock/index.d.ts +16 -9
- package/dist/components/command-dock/index.js +76 -19
- package/dist/components/day-grid/index.d.ts +12 -6
- package/dist/components/day-grid/index.js +71 -27
- package/dist/components/dialog/index.d.ts +19 -12
- package/dist/components/dialog/index.js +84 -25
- package/dist/components/feedback/index.d.ts +20 -13
- package/dist/components/feedback/index.js +83 -27
- package/dist/components/field/index.d.ts +85 -0
- package/dist/components/field/index.js +90 -0
- package/dist/components/flow/index.d.ts +21 -14
- package/dist/components/flow/index.js +56 -20
- package/dist/components/frame/index.d.ts +17 -11
- package/dist/components/frame/index.js +73 -22
- package/dist/components/input/index.d.ts +9 -24
- package/dist/components/input/index.js +53 -6
- package/dist/components/inspector/index.d.ts +69 -63
- package/dist/components/inspector/index.js +31 -9
- package/dist/components/kpi/index.d.ts +20 -14
- package/dist/components/kpi/index.js +111 -36
- package/dist/components/label/index.d.ts +10 -4
- package/dist/components/label/index.js +39 -9
- package/dist/components/lane-board/index.d.ts +15 -9
- package/dist/components/lane-board/index.js +97 -57
- package/dist/components/menu/index.d.ts +10 -4
- package/dist/components/menu/index.js +28 -10
- package/dist/components/message/index.d.ts +15 -9
- package/dist/components/message/index.js +71 -19
- package/dist/components/not-found/index.d.ts +10 -4
- package/dist/components/not-found/index.js +48 -12
- package/dist/components/planet/index.d.ts +11 -5
- package/dist/components/planet/index.js +73 -20
- package/dist/components/prompt/index.d.ts +30 -23
- package/dist/components/prompt/index.js +148 -52
- package/dist/components/radio-group/index.d.ts +124 -0
- package/dist/components/radio-group/index.js +216 -0
- package/dist/components/range-meter/index.d.ts +9 -3
- package/dist/components/range-meter/index.js +61 -27
- package/dist/components/rolling-number/index.d.ts +8 -1
- package/dist/components/rolling-number/index.js +15 -6
- package/dist/components/select/index.d.ts +7 -1
- package/dist/components/select/index.js +13 -4
- package/dist/components/sheet/index.d.ts +8 -2
- package/dist/components/sheet/index.js +27 -15
- package/dist/components/slider/index.d.ts +11 -4
- package/dist/components/slider/index.js +30 -10
- package/dist/components/soundwave/index.d.ts +8 -2
- package/dist/components/soundwave/index.js +26 -6
- package/dist/components/stat/index.d.ts +13 -7
- package/dist/components/stat/index.js +45 -15
- package/dist/components/table/index.d.ts +128 -0
- package/dist/components/table/index.js +145 -0
- package/dist/components/tabs/index.d.ts +7 -1
- package/dist/components/tabs/index.js +8 -2
- package/dist/components/textarea/index.d.ts +0 -23
- package/dist/components/textarea/index.js +22 -5
- package/dist/components/tilt-card/index.d.ts +9 -3
- package/dist/components/tilt-card/index.js +28 -8
- package/dist/components/timeline/index.d.ts +20 -13
- package/dist/components/timeline/index.js +166 -59
- package/dist/components/toast/dither-text.d.ts +13 -0
- package/dist/components/toast/dither-text.js +143 -0
- package/dist/components/toast/dither.d.ts +29 -0
- package/dist/components/toast/dither.js +153 -0
- package/dist/components/toast/index.d.ts +108 -0
- package/dist/components/toast/index.js +225 -0
- package/dist/components/toolbar/index.d.ts +9 -3
- package/dist/components/toolbar/index.js +23 -6
- package/dist/components/workbench/index.d.ts +50 -43
- package/dist/components/workbench/index.js +77 -20
- package/dist/components/xy-pad/index.d.ts +9 -3
- package/dist/components/xy-pad/index.js +13 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/package.json +1 -1
|
@@ -41,6 +41,13 @@
|
|
|
41
41
|
* anywhere outside it.
|
|
42
42
|
*/
|
|
43
43
|
import { type ComponentProps, type ReactNode } from 'react';
|
|
44
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
45
|
+
import type * as ReactTypes from 'react';
|
|
46
|
+
import type { ElementType as RenderElementType } from 'react';
|
|
47
|
+
/** Draws a part as another element, or composes it with a component: `render={<a href="/" />}`. */
|
|
48
|
+
type RenderProp<Tag extends RenderElementType> = {
|
|
49
|
+
render?: useRender.ComponentProps<Tag>['render'];
|
|
50
|
+
};
|
|
44
51
|
export interface CommandDockProps extends Omit<ComponentProps<'div'>, 'onSubmit' | 'defaultValue'> {
|
|
45
52
|
/** Whether it is open, when the caller holds that. */
|
|
46
53
|
open?: boolean;
|
|
@@ -59,21 +66,21 @@ export interface CommandDockProps extends Omit<ComponentProps<'div'>, 'onSubmit'
|
|
|
59
66
|
/** How wide it is while closed, as a CSS length. */
|
|
60
67
|
closedWidth?: string;
|
|
61
68
|
}
|
|
62
|
-
declare function CommandDockRoot({ open: controlledOpen, defaultOpen, onOpenChange, value: controlledValue, onValueChange, onSubmit, busy, closedWidth, className, style, children, ...props }: CommandDockProps):
|
|
69
|
+
declare function CommandDockRoot({ open: controlledOpen, defaultOpen, onOpenChange, value: controlledValue, onValueChange, onSubmit, busy, closedWidth, className, style, children, ...props }: CommandDockProps): ReactTypes.JSX.Element;
|
|
63
70
|
declare namespace CommandDockRoot {
|
|
64
71
|
var displayName: string;
|
|
65
72
|
}
|
|
66
73
|
export interface CommandDockTriggerProps extends ComponentProps<'button'> {
|
|
67
74
|
}
|
|
68
75
|
/** The closed form: a button that opens the dock. */
|
|
69
|
-
declare function CommandDockTrigger({ className, onClick, ...props }: CommandDockTriggerProps):
|
|
76
|
+
declare function CommandDockTrigger({ className, onClick, render, ...props }: CommandDockTriggerProps & RenderProp<'button'>): ReactTypes.ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
70
77
|
declare namespace CommandDockTrigger {
|
|
71
78
|
var displayName: string;
|
|
72
79
|
}
|
|
73
80
|
export interface CommandDockPanelProps extends ComponentProps<'div'> {
|
|
74
81
|
}
|
|
75
82
|
/** The open form: the field, and the rows under it. */
|
|
76
|
-
declare function CommandDockPanel({ className, ...props }: CommandDockPanelProps):
|
|
83
|
+
declare function CommandDockPanel({ className, render, ...props }: CommandDockPanelProps & RenderProp<'div'>): ReactTypes.ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
77
84
|
declare namespace CommandDockPanel {
|
|
78
85
|
var displayName: string;
|
|
79
86
|
}
|
|
@@ -82,7 +89,7 @@ export interface CommandDockInputProps extends Omit<ComponentProps<'input'>, 'va
|
|
|
82
89
|
submitLabel?: string;
|
|
83
90
|
}
|
|
84
91
|
/** The field, with a button to send what is in it. Enter sends too. */
|
|
85
|
-
declare function CommandDockInput({ className, submitLabel, 'aria-label': ariaLabel, ...props }: CommandDockInputProps):
|
|
92
|
+
declare function CommandDockInput({ className, submitLabel, 'aria-label': ariaLabel, ...props }: CommandDockInputProps): ReactTypes.JSX.Element;
|
|
86
93
|
declare namespace CommandDockInput {
|
|
87
94
|
var displayName: string;
|
|
88
95
|
}
|
|
@@ -91,7 +98,7 @@ export interface CommandDockResultsProps extends ComponentProps<'div'> {
|
|
|
91
98
|
label?: string;
|
|
92
99
|
}
|
|
93
100
|
/** Where the rows go. It takes no room until there is something in it. */
|
|
94
|
-
declare function CommandDockResults({ className, label, children, ...props }: CommandDockResultsProps):
|
|
101
|
+
declare function CommandDockResults({ className, label, children, render, ...props }: CommandDockResultsProps & RenderProp<'div'>): ReactTypes.JSX.Element;
|
|
95
102
|
declare namespace CommandDockResults {
|
|
96
103
|
var displayName: string;
|
|
97
104
|
}
|
|
@@ -100,21 +107,21 @@ export interface CommandDockRowProps extends ComponentProps<'div'> {
|
|
|
100
107
|
onSelect?: () => void;
|
|
101
108
|
}
|
|
102
109
|
/** One row of the answer. It slides in when it is added. */
|
|
103
|
-
declare function CommandDockRow({ className, onSelect, children, ...props }: CommandDockRowProps):
|
|
110
|
+
declare function CommandDockRow({ className, onSelect, children, render, ...props }: CommandDockRowProps & RenderProp<'div'>): ReactTypes.ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
104
111
|
declare namespace CommandDockRow {
|
|
105
112
|
var displayName: string;
|
|
106
113
|
}
|
|
107
114
|
export interface CommandDockRowTitleProps extends ComponentProps<'span'> {
|
|
108
115
|
}
|
|
109
116
|
/** What a row is, in a line that takes the row's spare width and truncates. */
|
|
110
|
-
declare function CommandDockRowTitle({ className, ...props }: CommandDockRowTitleProps):
|
|
117
|
+
declare function CommandDockRowTitle({ className, render, ...props }: CommandDockRowTitleProps & RenderProp<'span'>): ReactTypes.ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
111
118
|
declare namespace CommandDockRowTitle {
|
|
112
119
|
var displayName: string;
|
|
113
120
|
}
|
|
114
121
|
export interface CommandDockRowMetaProps extends ComponentProps<'span'> {
|
|
115
122
|
}
|
|
116
123
|
/** Something short at the end of a row, quieter than its title: a date, a place. */
|
|
117
|
-
declare function CommandDockRowMeta({ className, ...props }: CommandDockRowMetaProps):
|
|
124
|
+
declare function CommandDockRowMeta({ className, render, ...props }: CommandDockRowMetaProps & RenderProp<'span'>): ReactTypes.ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
118
125
|
declare namespace CommandDockRowMeta {
|
|
119
126
|
var displayName: string;
|
|
120
127
|
}
|
|
@@ -122,7 +129,7 @@ export interface CommandDockStatusProps extends ComponentProps<'div'> {
|
|
|
122
129
|
children?: ReactNode;
|
|
123
130
|
}
|
|
124
131
|
/** Shown under the rows while `busy`: three dots, and words if you give it some. */
|
|
125
|
-
declare function CommandDockStatus({ className, children, ...props }: CommandDockStatusProps):
|
|
132
|
+
declare function CommandDockStatus({ className, children, render, ...props }: CommandDockStatusProps & RenderProp<'div'>): ReactTypes.ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
126
133
|
declare namespace CommandDockStatus {
|
|
127
134
|
var displayName: string;
|
|
128
135
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
4
|
* CommandDock — a small button that opens into a place to ask for something,
|
|
5
5
|
* with the answer arriving under it a row at a time.
|
|
@@ -44,6 +44,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
44
44
|
*/
|
|
45
45
|
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
46
46
|
import { tv } from 'tailwind-variants';
|
|
47
|
+
import { mergeProps } from '@base-ui/react/merge-props';
|
|
48
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
47
49
|
const commandDockVariants = tv({
|
|
48
50
|
slots: {
|
|
49
51
|
root: 'relative flex w-full justify-center',
|
|
@@ -175,23 +177,44 @@ function useInert(inert) {
|
|
|
175
177
|
return ref;
|
|
176
178
|
}
|
|
177
179
|
/** The closed form: a button that opens the dock. */
|
|
178
|
-
function CommandDockTrigger({ className, onClick, ...props }) {
|
|
180
|
+
function CommandDockTrigger({ className, onClick, render, ...props }) {
|
|
179
181
|
const dock = useDock('CommandDock.Trigger');
|
|
180
182
|
const ref = useInert(dock.open);
|
|
181
|
-
return (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
return useRender({
|
|
184
|
+
defaultTagName: 'button',
|
|
185
|
+
render,
|
|
186
|
+
props: mergeProps({
|
|
187
|
+
ref: ref,
|
|
188
|
+
type: 'button',
|
|
189
|
+
'data-dock-trigger': '',
|
|
190
|
+
'aria-expanded': dock.open,
|
|
191
|
+
'aria-controls': dock.panelId,
|
|
192
|
+
className: commandDockVariants({ open: dock.open }).trigger({ className }),
|
|
193
|
+
onClick: (event) => {
|
|
194
|
+
onClick?.(event);
|
|
195
|
+
if (!event.defaultPrevented)
|
|
196
|
+
dock.setOpen(true);
|
|
197
|
+
},
|
|
198
|
+
}, props),
|
|
199
|
+
});
|
|
186
200
|
}
|
|
187
201
|
CommandDockTrigger.displayName = 'CommandDock.Trigger';
|
|
188
202
|
/** The open form: the field, and the rows under it. */
|
|
189
|
-
function CommandDockPanel({ className, ...props }) {
|
|
203
|
+
function CommandDockPanel({ className, render, ...props }) {
|
|
190
204
|
const dock = useDock('CommandDock.Panel');
|
|
191
205
|
// Kept in the page while closed, so it can be seen folding away. Inert, so
|
|
192
206
|
// nothing in it can be reached while it cannot be seen.
|
|
193
207
|
const ref = useInert(!dock.open);
|
|
194
|
-
return (
|
|
208
|
+
return useRender({
|
|
209
|
+
defaultTagName: 'div',
|
|
210
|
+
render,
|
|
211
|
+
props: mergeProps({
|
|
212
|
+
ref: ref,
|
|
213
|
+
id: dock.panelId,
|
|
214
|
+
'data-open': dock.open ? '' : undefined,
|
|
215
|
+
className: commandDockVariants().panel({ className }),
|
|
216
|
+
}, props),
|
|
217
|
+
});
|
|
195
218
|
}
|
|
196
219
|
CommandDockPanel.displayName = 'CommandDock.Panel';
|
|
197
220
|
/** The field, with a button to send what is in it. Enter sends too. */
|
|
@@ -213,35 +236,69 @@ function CommandDockInput({ className, submitLabel = 'Send', 'aria-label': ariaL
|
|
|
213
236
|
}
|
|
214
237
|
CommandDockInput.displayName = 'CommandDock.Input';
|
|
215
238
|
/** Where the rows go. It takes no room until there is something in it. */
|
|
216
|
-
function CommandDockResults({ className, label = 'Results', children, ...props }) {
|
|
239
|
+
function CommandDockResults({ className, label = 'Results', children, render, ...props }) {
|
|
217
240
|
const dock = useDock('CommandDock.Results');
|
|
218
241
|
const rows = Array.isArray(children) ? children.flat().filter(Boolean).length : children ? 1 : 0;
|
|
219
242
|
// Closed, it folds away whatever it holds.
|
|
220
243
|
const filled = dock.open && (rows > 0 || dock.busy);
|
|
221
244
|
const slots = commandDockVariants({ filled });
|
|
222
|
-
|
|
245
|
+
const element = useRender({
|
|
246
|
+
defaultTagName: 'div',
|
|
247
|
+
render,
|
|
248
|
+
props: mergeProps({
|
|
249
|
+
role: 'list',
|
|
250
|
+
'aria-label': label,
|
|
251
|
+
'aria-live': 'polite',
|
|
252
|
+
className: slots.resultsInner({ className }),
|
|
253
|
+
children: _jsx(_Fragment, { children: children }),
|
|
254
|
+
}, props),
|
|
255
|
+
});
|
|
256
|
+
return (_jsx("div", { className: slots.results(), children: _jsx("div", { className: slots.resultsClip(), children: element }) }));
|
|
223
257
|
}
|
|
224
258
|
CommandDockResults.displayName = 'CommandDock.Results';
|
|
225
259
|
/** One row of the answer. It slides in when it is added. */
|
|
226
|
-
function CommandDockRow({ className, onSelect, children, ...props }) {
|
|
260
|
+
function CommandDockRow({ className, onSelect, children, render, ...props }) {
|
|
227
261
|
const slots = commandDockVariants({ interactive: onSelect !== undefined });
|
|
228
|
-
return (
|
|
262
|
+
return useRender({
|
|
263
|
+
defaultTagName: 'div',
|
|
264
|
+
render,
|
|
265
|
+
props: mergeProps({
|
|
266
|
+
role: 'listitem',
|
|
267
|
+
children: (_jsx(_Fragment, { children: onSelect ? (_jsx("button", { type: "button", onClick: onSelect, className: slots.row({ className: ['w-full text-start', className] }), children: children })) : (_jsx("div", { className: slots.row({ className }), children: children })) })),
|
|
268
|
+
}, props),
|
|
269
|
+
});
|
|
229
270
|
}
|
|
230
271
|
CommandDockRow.displayName = 'CommandDock.Row';
|
|
231
272
|
/** What a row is, in a line that takes the row's spare width and truncates. */
|
|
232
|
-
function CommandDockRowTitle({ className, ...props }) {
|
|
233
|
-
return (
|
|
273
|
+
function CommandDockRowTitle({ className, render, ...props }) {
|
|
274
|
+
return useRender({
|
|
275
|
+
defaultTagName: 'span',
|
|
276
|
+
render,
|
|
277
|
+
props: mergeProps({ 'data-slot': 'command-dock-row-title', className: commandDockVariants().rowTitle({ className }) }, props),
|
|
278
|
+
});
|
|
234
279
|
}
|
|
235
280
|
CommandDockRowTitle.displayName = 'CommandDock.RowTitle';
|
|
236
281
|
/** Something short at the end of a row, quieter than its title: a date, a place. */
|
|
237
|
-
function CommandDockRowMeta({ className, ...props }) {
|
|
238
|
-
return (
|
|
282
|
+
function CommandDockRowMeta({ className, render, ...props }) {
|
|
283
|
+
return useRender({
|
|
284
|
+
defaultTagName: 'span',
|
|
285
|
+
render,
|
|
286
|
+
props: mergeProps({ 'data-slot': 'command-dock-row-meta', className: commandDockVariants().rowMeta({ className }) }, props),
|
|
287
|
+
});
|
|
239
288
|
}
|
|
240
289
|
CommandDockRowMeta.displayName = 'CommandDock.RowMeta';
|
|
241
290
|
/** Shown under the rows while `busy`: three dots, and words if you give it some. */
|
|
242
|
-
function CommandDockStatus({ className, children = 'Working', ...props }) {
|
|
291
|
+
function CommandDockStatus({ className, children = 'Working', render, ...props }) {
|
|
243
292
|
const slots = commandDockVariants();
|
|
244
|
-
return (
|
|
293
|
+
return useRender({
|
|
294
|
+
defaultTagName: 'div',
|
|
295
|
+
render,
|
|
296
|
+
props: mergeProps({
|
|
297
|
+
role: 'status',
|
|
298
|
+
className: slots.status({ className }),
|
|
299
|
+
children: (_jsxs(_Fragment, { children: [_jsxs("span", { "aria-hidden": "true", className: slots.dots(), children: [_jsx("span", { className: slots.dot() }), _jsx("span", { className: slots.dot({ className: '[animation-delay:150ms]' }) }), _jsx("span", { className: slots.dot({ className: '[animation-delay:300ms]' }) })] }), children] })),
|
|
300
|
+
}, props),
|
|
301
|
+
});
|
|
245
302
|
}
|
|
246
303
|
CommandDockStatus.displayName = 'CommandDock.Status';
|
|
247
304
|
export const CommandDock = Object.assign(CommandDockRoot, {
|
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
* between days, so forty days are not forty presses of Tab.
|
|
31
31
|
*/
|
|
32
32
|
import { type ComponentProps, type ReactNode } from 'react';
|
|
33
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
34
|
+
import type { ElementType as RenderElementType } from 'react';
|
|
35
|
+
/** Draws a part as another element, or composes it with a component: `render={<a href="/" />}`. */
|
|
36
|
+
type RenderProp<Tag extends RenderElementType> = {
|
|
37
|
+
render?: useRender.ComponentProps<Tag>['render'];
|
|
38
|
+
};
|
|
33
39
|
/** How much happened on a day: 0 is nothing, 4 is the most. */
|
|
34
40
|
export type DayLevel = 0 | 1 | 2 | 3 | 4;
|
|
35
41
|
/** Which of the theme's roles the dots are drawn in. */
|
|
@@ -64,7 +70,7 @@ export interface DayGridProps extends Omit<ComponentProps<'div'>, 'children' | '
|
|
|
64
70
|
/** What a screen reader calls the grid. */
|
|
65
71
|
label?: string;
|
|
66
72
|
}
|
|
67
|
-
declare function DayGridRoot({ cells, columns, rows: perColumn, color, value, onValueChange, lens, label, className, style, onPointerMove, onPointerLeave, ...props }: DayGridProps): import("react").JSX.Element;
|
|
73
|
+
declare function DayGridRoot({ cells, columns, rows: perColumn, color, value, onValueChange, lens, label, className, style, onPointerMove, onPointerLeave, render, ...props }: DayGridProps & RenderProp<'div'>): import("react").JSX.Element;
|
|
68
74
|
declare namespace DayGridRoot {
|
|
69
75
|
var displayName: string;
|
|
70
76
|
}
|
|
@@ -77,7 +83,7 @@ export interface DayGridLegendProps extends Omit<ComponentProps<'div'>, 'childre
|
|
|
77
83
|
more?: ReactNode;
|
|
78
84
|
}
|
|
79
85
|
/** The five sizes, quietest to busiest, with a word at each end. */
|
|
80
|
-
declare function DayGridLegend({ color, less, more, className, ...props }: DayGridLegendProps): import("react").
|
|
86
|
+
declare function DayGridLegend({ color, less, more, className, render, ...props }: DayGridLegendProps & RenderProp<'div'>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
81
87
|
declare namespace DayGridLegend {
|
|
82
88
|
var displayName: string;
|
|
83
89
|
}
|
|
@@ -93,7 +99,7 @@ export interface DayGridWeekdaysProps extends Omit<ComponentProps<'div'>, 'child
|
|
|
93
99
|
* Put it beside the grid, in a row with it. Hidden from screen readers, which
|
|
94
100
|
* are given each day's own label.
|
|
95
101
|
*/
|
|
96
|
-
declare function DayGridWeekdays({ labels, className, style, ...props }: DayGridWeekdaysProps): import("react").
|
|
102
|
+
declare function DayGridWeekdays({ labels, className, style, render, ...props }: DayGridWeekdaysProps & RenderProp<'div'>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
97
103
|
declare namespace DayGridWeekdays {
|
|
98
104
|
var displayName: string;
|
|
99
105
|
}
|
|
@@ -103,21 +109,21 @@ export interface DayGridCaptionProps extends ComponentProps<'div'> {
|
|
|
103
109
|
* What the picked day holds, written out beside the grid: a `DayGrid.Title`
|
|
104
110
|
* over a `DayGrid.Description`. Read out politely each time the pick changes.
|
|
105
111
|
*/
|
|
106
|
-
declare function DayGridCaption({ className, ...props }: DayGridCaptionProps): import("react").
|
|
112
|
+
declare function DayGridCaption({ className, render, ...props }: DayGridCaptionProps & RenderProp<'div'>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
107
113
|
declare namespace DayGridCaption {
|
|
108
114
|
var displayName: string;
|
|
109
115
|
}
|
|
110
116
|
export interface DayGridTitleProps extends ComponentProps<'p'> {
|
|
111
117
|
}
|
|
112
118
|
/** The picked day's figure: "17 merged". */
|
|
113
|
-
declare function DayGridTitle({ className, ...props }: DayGridTitleProps): import("react").
|
|
119
|
+
declare function DayGridTitle({ className, render, ...props }: DayGridTitleProps & RenderProp<'p'>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
114
120
|
declare namespace DayGridTitle {
|
|
115
121
|
var displayName: string;
|
|
116
122
|
}
|
|
117
123
|
export interface DayGridDescriptionProps extends ComponentProps<'p'> {
|
|
118
124
|
}
|
|
119
125
|
/** The picked day's date, quieter, under its figure. */
|
|
120
|
-
declare function DayGridDescription({ className, ...props }: DayGridDescriptionProps): import("react").
|
|
126
|
+
declare function DayGridDescription({ className, render, ...props }: DayGridDescriptionProps & RenderProp<'p'>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
121
127
|
declare namespace DayGridDescription {
|
|
122
128
|
var displayName: string;
|
|
123
129
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
4
|
* DayGrid — a run of days as a field of dots, each sized by how much happened
|
|
5
5
|
* on it.
|
|
@@ -33,6 +33,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
33
33
|
*/
|
|
34
34
|
import { useEffect, useMemo, useRef, useState, } from 'react';
|
|
35
35
|
import { tv } from 'tailwind-variants';
|
|
36
|
+
import { mergeProps } from '@base-ui/react/merge-props';
|
|
37
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
36
38
|
const dayGridVariants = tv({
|
|
37
39
|
slots: {
|
|
38
40
|
root: 'relative grid w-full gap-1',
|
|
@@ -95,7 +97,7 @@ const LEVELS = [0, 1, 2, 3, 4];
|
|
|
95
97
|
const LENS_REACH = 2.4;
|
|
96
98
|
/** Milliseconds between one diagonal of dots arriving and the next. */
|
|
97
99
|
const STAGGER = 22;
|
|
98
|
-
function DayGridRoot({ cells, columns = 7, rows: perColumn, color = 'primary', value = null, onValueChange, lens = true, label = 'Activity', className, style, onPointerMove, onPointerLeave, ...props }) {
|
|
100
|
+
function DayGridRoot({ cells, columns = 7, rows: perColumn, color = 'primary', value = null, onValueChange, lens = true, label = 'Activity', className, style, onPointerMove, onPointerLeave, render, ...props }) {
|
|
99
101
|
const slots = dayGridVariants({ color });
|
|
100
102
|
const root = useRef(null);
|
|
101
103
|
const nodes = useRef([]);
|
|
@@ -227,27 +229,47 @@ function DayGridRoot({ cells, columns = 7, rows: perColumn, color = 'primary', v
|
|
|
227
229
|
nodes.current[next]?.focus();
|
|
228
230
|
onValueChange(next);
|
|
229
231
|
};
|
|
230
|
-
return (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
232
|
+
return useRender({
|
|
233
|
+
defaultTagName: 'div',
|
|
234
|
+
render,
|
|
235
|
+
props: mergeProps({
|
|
236
|
+
ref: root,
|
|
237
|
+
role: 'group',
|
|
238
|
+
'aria-label': summary,
|
|
239
|
+
className: slots.root({ className }),
|
|
240
|
+
style: layout,
|
|
241
|
+
onPointerMove: moveLens,
|
|
242
|
+
onPointerLeave: leave,
|
|
243
|
+
children: (_jsxs(_Fragment, { children: [cells.map((cell, index) => {
|
|
244
|
+
const part = dayGridVariants({
|
|
245
|
+
level: cell.level,
|
|
246
|
+
interactive: true,
|
|
247
|
+
selected: value === index,
|
|
248
|
+
});
|
|
249
|
+
return (_jsx("button", { ref: (node) => {
|
|
250
|
+
nodes.current[index] = node;
|
|
251
|
+
}, type: "button", "aria-label": cell.label ?? `Day ${index + 1}, level ${cell.level} of 4`, "aria-pressed": value === index, tabIndex: index === focusable ? 0 : -1, onClick: () => onValueChange(index), onKeyDown: (event) => onKeyDown(event, index), onFocus: (event) => {
|
|
252
|
+
// Only for focus that came from the keyboard: a click focuses
|
|
253
|
+
// too, and the pointer is already showing that day's tag.
|
|
254
|
+
if (event.currentTarget.matches(':focus-visible'))
|
|
255
|
+
setPointed(index);
|
|
256
|
+
}, onBlur: () => setPointed((current) => (current === index ? null : current)), className: part.cell(), children: _jsx("span", { className: part.dot(), style: dotStyle(index) }) }, index));
|
|
257
|
+
}), tag] })),
|
|
258
|
+
}, props),
|
|
259
|
+
});
|
|
245
260
|
}
|
|
246
261
|
DayGridRoot.displayName = 'DayGrid';
|
|
247
262
|
/** The five sizes, quietest to busiest, with a word at each end. */
|
|
248
|
-
function DayGridLegend({ color = 'primary', less = 'Less', more = 'More', className, ...props }) {
|
|
263
|
+
function DayGridLegend({ color = 'primary', less = 'Less', more = 'More', className, render, ...props }) {
|
|
249
264
|
const slots = dayGridVariants({ color });
|
|
250
|
-
return (
|
|
265
|
+
return useRender({
|
|
266
|
+
defaultTagName: 'div',
|
|
267
|
+
render,
|
|
268
|
+
props: mergeProps({
|
|
269
|
+
className: slots.legend({ className }),
|
|
270
|
+
children: (_jsxs(_Fragment, { children: [_jsx("span", { children: less }), LEVELS.map((level) => (_jsx("span", { "aria-hidden": "true", className: slots.swatch(), children: _jsx("span", { className: dayGridVariants({ level }).dot({ className: 'shadow-none' }) }) }, level))), _jsx("span", { children: more })] })),
|
|
271
|
+
}, props),
|
|
272
|
+
});
|
|
251
273
|
}
|
|
252
274
|
DayGridLegend.displayName = 'DayGrid.Legend';
|
|
253
275
|
/**
|
|
@@ -255,27 +277,49 @@ DayGridLegend.displayName = 'DayGrid.Legend';
|
|
|
255
277
|
* Put it beside the grid, in a row with it. Hidden from screen readers, which
|
|
256
278
|
* are given each day's own label.
|
|
257
279
|
*/
|
|
258
|
-
function DayGridWeekdays({ labels = ['Mon', '', 'Wed', '', 'Fri', '', 'Sun'], className, style, ...props }) {
|
|
280
|
+
function DayGridWeekdays({ labels = ['Mon', '', 'Wed', '', 'Fri', '', 'Sun'], className, style, render, ...props }) {
|
|
259
281
|
const slots = dayGridVariants();
|
|
260
|
-
return (
|
|
282
|
+
return useRender({
|
|
283
|
+
defaultTagName: 'div',
|
|
284
|
+
render,
|
|
285
|
+
props: mergeProps({
|
|
286
|
+
'aria-hidden': 'true',
|
|
287
|
+
'data-slot': 'day-grid-weekdays',
|
|
288
|
+
className: slots.weekdays({ className }),
|
|
289
|
+
style: { gridTemplateRows: `repeat(${labels.length}, minmax(0, 1fr))`, ...style },
|
|
290
|
+
children: (_jsx(_Fragment, { children: labels.map((day, index) => (_jsx("span", { className: slots.weekday(), children: day }, index))) })),
|
|
291
|
+
}, props),
|
|
292
|
+
});
|
|
261
293
|
}
|
|
262
294
|
DayGridWeekdays.displayName = 'DayGrid.Weekdays';
|
|
263
295
|
/**
|
|
264
296
|
* What the picked day holds, written out beside the grid: a `DayGrid.Title`
|
|
265
297
|
* over a `DayGrid.Description`. Read out politely each time the pick changes.
|
|
266
298
|
*/
|
|
267
|
-
function DayGridCaption({ className, ...props }) {
|
|
268
|
-
return (
|
|
299
|
+
function DayGridCaption({ className, render, ...props }) {
|
|
300
|
+
return useRender({
|
|
301
|
+
defaultTagName: 'div',
|
|
302
|
+
render,
|
|
303
|
+
props: mergeProps({ 'aria-live': 'polite', 'data-slot': 'day-grid-caption', className: dayGridVariants().caption({ className }) }, props),
|
|
304
|
+
});
|
|
269
305
|
}
|
|
270
306
|
DayGridCaption.displayName = 'DayGrid.Caption';
|
|
271
307
|
/** The picked day's figure: "17 merged". */
|
|
272
|
-
function DayGridTitle({ className, ...props }) {
|
|
273
|
-
return
|
|
308
|
+
function DayGridTitle({ className, render, ...props }) {
|
|
309
|
+
return useRender({
|
|
310
|
+
defaultTagName: 'p',
|
|
311
|
+
render,
|
|
312
|
+
props: mergeProps({ 'data-slot': 'day-grid-title', className: dayGridVariants().title({ className }) }, props),
|
|
313
|
+
});
|
|
274
314
|
}
|
|
275
315
|
DayGridTitle.displayName = 'DayGrid.Title';
|
|
276
316
|
/** The picked day's date, quieter, under its figure. */
|
|
277
|
-
function DayGridDescription({ className, ...props }) {
|
|
278
|
-
return (
|
|
317
|
+
function DayGridDescription({ className, render, ...props }) {
|
|
318
|
+
return useRender({
|
|
319
|
+
defaultTagName: 'p',
|
|
320
|
+
render,
|
|
321
|
+
props: mergeProps({ 'data-slot': 'day-grid-description', className: dayGridVariants().description({ className }) }, props),
|
|
322
|
+
});
|
|
279
323
|
}
|
|
280
324
|
DayGridDescription.displayName = 'DayGrid.Description';
|
|
281
325
|
export const DayGrid = Object.assign(DayGridRoot, {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { type ComponentProps, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type * as ReactTypes from 'react';
|
|
4
|
+
import type { ElementType as RenderElementType } from 'react';
|
|
5
|
+
/** Draws a part as another element, or composes it with a component: `render={<a href="/" />}`. */
|
|
6
|
+
type RenderProp<Tag extends RenderElementType> = {
|
|
7
|
+
render?: useRender.ComponentProps<Tag>['render'];
|
|
8
|
+
};
|
|
2
9
|
export interface DialogProps {
|
|
3
10
|
children?: ReactNode;
|
|
4
11
|
/** Whether it is open, when the caller holds that. */
|
|
@@ -14,7 +21,7 @@ export interface DialogProps {
|
|
|
14
21
|
*/
|
|
15
22
|
dismissible?: boolean;
|
|
16
23
|
}
|
|
17
|
-
declare function DialogRoot({ children, open, defaultOpen, onOpenChange, dismissible
|
|
24
|
+
declare function DialogRoot({ children, open, defaultOpen, onOpenChange, dismissible }: DialogProps): ReactTypes.JSX.Element;
|
|
18
25
|
declare namespace DialogRoot {
|
|
19
26
|
var displayName: string;
|
|
20
27
|
}
|
|
@@ -27,7 +34,7 @@ export interface DialogTriggerProps extends Omit<ComponentProps<'button'>, 'chil
|
|
|
27
34
|
render?: ReactElement;
|
|
28
35
|
}
|
|
29
36
|
/** What opens the dialog. A plain button unless `render` supplies one. */
|
|
30
|
-
declare function DialogTrigger({ render, children, ...props }: DialogTriggerProps):
|
|
37
|
+
declare function DialogTrigger({ render, children, ...props }: DialogTriggerProps): ReactTypes.JSX.Element;
|
|
31
38
|
declare namespace DialogTrigger {
|
|
32
39
|
var displayName: string;
|
|
33
40
|
}
|
|
@@ -51,7 +58,7 @@ export interface DialogContentProps extends Omit<ComponentProps<'div'>, 'childre
|
|
|
51
58
|
inline?: boolean;
|
|
52
59
|
}
|
|
53
60
|
/** The dialog itself, with the dimmed page behind it. */
|
|
54
|
-
declare function DialogContent({ variant, size, showClose, blur, inline, className, children, ...props }: DialogContentProps):
|
|
61
|
+
declare function DialogContent({ variant, size, showClose, blur, inline, className, children, ...props }: DialogContentProps): ReactTypes.JSX.Element;
|
|
55
62
|
declare namespace DialogContent {
|
|
56
63
|
var displayName: string;
|
|
57
64
|
}
|
|
@@ -62,21 +69,21 @@ export interface DialogHeaderProps extends Omit<ComponentProps<'div'>, 'title'>
|
|
|
62
69
|
description?: ReactNode;
|
|
63
70
|
}
|
|
64
71
|
/** The heading block. It leaves room for the close button beside the title. */
|
|
65
|
-
declare function DialogHeader({ title, description, className, children, ...props }: DialogHeaderProps):
|
|
72
|
+
declare function DialogHeader({ title, description, className, children, render, ...props }: DialogHeaderProps & RenderProp<'div'>): ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
66
73
|
declare namespace DialogHeader {
|
|
67
74
|
var displayName: string;
|
|
68
75
|
}
|
|
69
76
|
export interface DialogTitleProps extends ComponentProps<'h2'> {
|
|
70
77
|
}
|
|
71
78
|
/** The dialog's name, announced when it opens. */
|
|
72
|
-
declare function DialogTitle({ className, ...props }: DialogTitleProps):
|
|
79
|
+
declare function DialogTitle({ className, ...props }: DialogTitleProps): ReactTypes.JSX.Element;
|
|
73
80
|
declare namespace DialogTitle {
|
|
74
81
|
var displayName: string;
|
|
75
82
|
}
|
|
76
83
|
export interface DialogDescriptionProps extends ComponentProps<'p'> {
|
|
77
84
|
}
|
|
78
85
|
/** A sentence under the title, read out after it. */
|
|
79
|
-
declare function DialogDescription({ className, ...props }: DialogDescriptionProps):
|
|
86
|
+
declare function DialogDescription({ className, ...props }: DialogDescriptionProps): ReactTypes.JSX.Element;
|
|
80
87
|
declare namespace DialogDescription {
|
|
81
88
|
var displayName: string;
|
|
82
89
|
}
|
|
@@ -86,7 +93,7 @@ export interface DialogBodyProps extends ComponentProps<'div'> {
|
|
|
86
93
|
* The part that scrolls, between the header and the footer. Its children are
|
|
87
94
|
* laid out in a column with a gap, so a form's fields need no wrapper.
|
|
88
95
|
*/
|
|
89
|
-
declare function DialogBody({ className, children, ...props }: DialogBodyProps):
|
|
96
|
+
declare function DialogBody({ className, children, ...props }: DialogBodyProps): ReactTypes.JSX.Element;
|
|
90
97
|
declare namespace DialogBody {
|
|
91
98
|
var displayName: string;
|
|
92
99
|
}
|
|
@@ -97,7 +104,7 @@ export interface DialogFooterProps extends ComponentProps<'div'> {
|
|
|
97
104
|
* equal pills; in `plain` they sit at the end of a ruled strip. Keep it a
|
|
98
105
|
* direct child of `Dialog.Content`, so the band can find it.
|
|
99
106
|
*/
|
|
100
|
-
declare function DialogFooter({ className, ...props }: DialogFooterProps):
|
|
107
|
+
declare function DialogFooter({ className, render, ...props }: DialogFooterProps & RenderProp<'div'>): ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
101
108
|
declare namespace DialogFooter {
|
|
102
109
|
var displayName: string;
|
|
103
110
|
}
|
|
@@ -108,7 +115,7 @@ export interface DialogCloseProps extends ComponentProps<'button'> {
|
|
|
108
115
|
icon?: boolean;
|
|
109
116
|
}
|
|
110
117
|
/** Closes the dialog. */
|
|
111
|
-
declare function DialogClose({ render, icon, children, ...props }: DialogCloseProps):
|
|
118
|
+
declare function DialogClose({ render, icon, children, ...props }: DialogCloseProps): ReactTypes.JSX.Element;
|
|
112
119
|
declare namespace DialogClose {
|
|
113
120
|
var displayName: string;
|
|
114
121
|
}
|
|
@@ -118,7 +125,7 @@ export interface DialogListProps extends ComponentProps<'div'> {
|
|
|
118
125
|
* A list of one-line choices in the body. The arrow keys, Home and End move
|
|
119
126
|
* between its items, and it opens scrolled to the selected one.
|
|
120
127
|
*/
|
|
121
|
-
declare function DialogList({ className, onKeyDown, children, ...props }: DialogListProps):
|
|
128
|
+
declare function DialogList({ className, onKeyDown, children, render, ...props }: DialogListProps & RenderProp<'div'>): ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
122
129
|
declare namespace DialogList {
|
|
123
130
|
var displayName: string;
|
|
124
131
|
}
|
|
@@ -127,7 +134,7 @@ export interface DialogListGroupProps extends Omit<ComponentProps<'div'>, 'title
|
|
|
127
134
|
label: ReactNode;
|
|
128
135
|
}
|
|
129
136
|
/** A run of items in `Dialog.List` under a heading of their own. */
|
|
130
|
-
declare function DialogListGroup({ label, className, children, ...props }: DialogListGroupProps):
|
|
137
|
+
declare function DialogListGroup({ label, className, children, render, ...props }: DialogListGroupProps & RenderProp<'div'>): ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
131
138
|
declare namespace DialogListGroup {
|
|
132
139
|
var displayName: string;
|
|
133
140
|
}
|
|
@@ -142,7 +149,7 @@ export interface DialogListItemProps extends Omit<ComponentProps<'div'>, 'onSele
|
|
|
142
149
|
disabled?: boolean;
|
|
143
150
|
}
|
|
144
151
|
/** One choice in `Dialog.List`, on one line. */
|
|
145
|
-
declare function DialogListItem({ selected, onSelect, meta, disabled, className, onClick, onKeyDown, children, ...props }: DialogListItemProps):
|
|
152
|
+
declare function DialogListItem({ selected, onSelect, meta, disabled, className, onClick, onKeyDown, children, render, ...props }: DialogListItemProps & RenderProp<'div'>): ReactElement<unknown, string | ReactTypes.JSXElementConstructor<any>>;
|
|
146
153
|
declare namespace DialogListItem {
|
|
147
154
|
var displayName: string;
|
|
148
155
|
}
|