@surflane/ui 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -8
- package/dist/accordion.d.ts +26 -0
- package/dist/accordion.js +27 -0
- package/dist/alert-dialog.d.ts +31 -0
- package/dist/alert-dialog.js +22 -0
- package/dist/app-shell.js +17 -17
- package/dist/{input-extensions.d.ts → autocomplete.d.ts} +4 -42
- package/dist/{input-extensions.js → autocomplete.js} +12 -31
- package/dist/avatar.d.ts +24 -0
- package/dist/avatar.js +24 -0
- package/dist/badge.d.ts +20 -0
- package/dist/badge.js +16 -0
- package/dist/breadcrumbs.d.ts +13 -0
- package/dist/breadcrumbs.js +31 -0
- package/dist/button.d.ts +11 -0
- package/dist/button.js +28 -5
- package/dist/{content.d.ts → card.d.ts} +6 -24
- package/dist/card.js +26 -0
- package/dist/chart.d.ts +19 -0
- package/dist/chart.js +29 -8
- package/dist/checkbox-group.d.ts +2 -0
- package/dist/checkbox-group.js +16 -0
- package/dist/checkbox.d.ts +9 -0
- package/dist/checkbox.js +29 -0
- package/dist/choice-label.d.ts +25 -0
- package/dist/choice-label.js +14 -0
- package/dist/choice.d.ts +7 -0
- package/dist/choice.js +3 -0
- package/dist/code.d.ts +21 -0
- package/dist/{content.js → code.js} +10 -32
- package/dist/collapsible.d.ts +18 -0
- package/dist/collapsible.js +21 -0
- package/dist/{advanced-forms.d.ts → combobox.d.ts} +5 -25
- package/dist/combobox.js +57 -0
- package/dist/{context-overlays.d.ts → context-menu.d.ts} +6 -28
- package/dist/context-menu.js +30 -0
- package/dist/date-picker.js +3 -2
- package/dist/dialog.d.ts +6 -24
- package/dist/dialog.js +9 -21
- package/dist/{panels.d.ts → drawer.d.ts} +3 -34
- package/dist/drawer.js +47 -0
- package/dist/empty-state.d.ts +29 -0
- package/dist/empty-state.js +19 -0
- package/dist/field.d.ts +42 -0
- package/dist/field.js +21 -0
- package/dist/fieldset.d.ts +14 -0
- package/dist/fieldset.js +10 -0
- package/dist/file-upload.d.ts +3 -1
- package/dist/file-upload.js +8 -6
- package/dist/filter-bar.js +6 -6
- package/dist/form.d.ts +2 -0
- package/dist/form.js +7 -0
- package/dist/icon.d.ts +10 -0
- package/dist/icon.js +19 -2
- package/dist/index.d.ts +57 -31
- package/dist/index.js +71 -31
- package/dist/{messages.d.ts → inline-message.d.ts} +0 -28
- package/dist/inline-message.js +23 -0
- package/dist/input.js +3 -3
- package/dist/{foundations.d.ts → layout.d.ts} +5 -23
- package/dist/layout.js +40 -0
- package/dist/link.d.ts +6 -0
- package/dist/link.js +17 -0
- package/dist/list.d.ts +33 -0
- package/dist/list.js +21 -0
- package/dist/markdown.js +7 -7
- package/dist/menu.d.ts +7 -5
- package/dist/menu.js +24 -20
- package/dist/menubar.d.ts +4 -0
- package/dist/menubar.js +4 -0
- package/dist/meter.d.ts +29 -0
- package/dist/meter.js +13 -0
- package/dist/native-select.d.ts +8 -0
- package/dist/native-select.js +54 -0
- package/dist/navigation-menu.js +14 -11
- package/dist/number-field.d.ts +23 -0
- package/dist/number-field.js +33 -0
- package/dist/otp-field.js +4 -4
- package/dist/page-header.d.ts +12 -0
- package/dist/page-header.js +9 -0
- package/dist/pagination.js +4 -5
- package/dist/panel.d.ts +13 -0
- package/dist/panel.js +13 -0
- package/dist/parts.d.ts +22 -1
- package/dist/parts.js +40 -7
- package/dist/popover.d.ts +23 -6
- package/dist/popover.js +17 -7
- package/dist/preview-card.d.ts +29 -0
- package/dist/preview-card.js +27 -0
- package/dist/progress.d.ts +29 -0
- package/dist/progress.js +13 -0
- package/dist/radio-group.d.ts +16 -0
- package/dist/radio-group.js +31 -0
- package/dist/scroll-area.js +4 -5
- package/dist/select.d.ts +8 -8
- package/dist/select.js +19 -53
- package/dist/separator.d.ts +4 -0
- package/dist/separator.js +8 -0
- package/dist/sheet.d.ts +29 -0
- package/dist/sheet.js +39 -0
- package/dist/sizing.js +1 -1
- package/dist/skeleton.d.ts +8 -0
- package/dist/skeleton.js +8 -0
- package/dist/slider.d.ts +40 -0
- package/dist/slider.js +27 -0
- package/dist/spinner.d.ts +13 -0
- package/dist/spinner.js +10 -0
- package/dist/status.d.ts +1 -19
- package/dist/status.js +10 -14
- package/dist/switch.d.ts +13 -0
- package/dist/switch.js +25 -0
- package/dist/syntax-context.d.ts +7 -0
- package/dist/syntax-context.js +4 -0
- package/dist/syntax-highlighter.d.ts +4 -1
- package/dist/syntax-highlighter.js +13 -6
- package/dist/syntax-highlighting.d.ts +8 -0
- package/dist/syntax-highlighting.js +12 -0
- package/dist/{data.d.ts → table.d.ts} +8 -32
- package/dist/table.js +67 -0
- package/dist/tabs.d.ts +29 -0
- package/dist/tabs.js +13 -0
- package/dist/textarea.d.ts +7 -0
- package/dist/textarea.js +12 -0
- package/dist/toast.js +18 -17
- package/dist/toggle-group.d.ts +5 -0
- package/dist/toggle-group.js +7 -0
- package/dist/toggle.d.ts +7 -0
- package/dist/toggle.js +9 -0
- package/dist/{commands.d.ts → toolbar.d.ts} +0 -13
- package/dist/toolbar.js +14 -0
- package/dist/tooltip.d.ts +3 -2
- package/dist/tooltip.js +2 -2
- package/dist/tree.js +4 -2
- package/dist/typography.d.ts +12 -0
- package/dist/typography.js +14 -0
- package/package.json +286 -21
- package/src/all.css +8 -0
- package/src/styles.css +3745 -3629
- package/dist/advanced-forms.js +0 -93
- package/dist/commands.js +0 -27
- package/dist/context-overlays.js +0 -50
- package/dist/data.js +0 -82
- package/dist/feedback.d.ts +0 -76
- package/dist/feedback.js +0 -35
- package/dist/forms.d.ts +0 -91
- package/dist/forms.js +0 -109
- package/dist/foundations.js +0 -55
- package/dist/messages.js +0 -38
- package/dist/navigation.d.ts +0 -107
- package/dist/navigation.js +0 -108
- package/dist/panels.js +0 -99
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
declare const CardRoot: React.ForwardRefExoticComponent<Omit<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
surface?: import("./layout.js").SurfaceKind;
|
|
4
|
+
tone?: import("./layout.js").SurfaceKind;
|
|
5
|
+
padding?: import("./layout.js").Space;
|
|
5
6
|
}, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
6
7
|
declare const CardTitle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & {
|
|
7
8
|
level?: 2 | 3 | 4 | 5 | 6;
|
|
8
9
|
} & React.RefAttributes<HTMLHeadingElement>>;
|
|
9
10
|
export declare const Card: {
|
|
10
11
|
Root: React.ForwardRefExoticComponent<Omit<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
surface?: import("./layout.js").SurfaceKind;
|
|
13
|
+
tone?: import("./layout.js").SurfaceKind;
|
|
14
|
+
padding?: import("./layout.js").Space;
|
|
13
15
|
}, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
14
16
|
Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
|
|
15
17
|
size?: import("./sizing.js").ComponentSize;
|
|
@@ -27,26 +29,6 @@ export declare const Card: {
|
|
|
27
29
|
size?: import("./sizing.js").ComponentSize;
|
|
28
30
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
29
31
|
};
|
|
30
|
-
export type CodeBlockProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children' | 'onCopy'> & {
|
|
31
|
-
code: string;
|
|
32
|
-
label?: string;
|
|
33
|
-
language?: string;
|
|
34
|
-
wrap?: boolean;
|
|
35
|
-
copyLabel?: string;
|
|
36
|
-
copiedLabel?: string;
|
|
37
|
-
copyErrorLabel?: string;
|
|
38
|
-
onCopy?: (code: string) => void | Promise<void>;
|
|
39
|
-
};
|
|
40
|
-
export declare const CodeBlock: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children" | "onCopy"> & {
|
|
41
|
-
code: string;
|
|
42
|
-
label?: string;
|
|
43
|
-
language?: string;
|
|
44
|
-
wrap?: boolean;
|
|
45
|
-
copyLabel?: string;
|
|
46
|
-
copiedLabel?: string;
|
|
47
|
-
copyErrorLabel?: string;
|
|
48
|
-
onCopy?: (code: string) => void | Promise<void>;
|
|
49
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
50
32
|
export { CardRoot, CardTitle };
|
|
51
33
|
export declare const CardHeader: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
|
|
52
34
|
size?: import("./sizing.js").ComponentSize;
|
package/dist/card.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Surface } from './layout.js';
|
|
5
|
+
import { part, cx } from './parts.js';
|
|
6
|
+
const CardRoot = /* @__PURE__ */ React.forwardRef(function CardRoot({ className, padding, ...props }, ref) {
|
|
7
|
+
return (_jsx(Surface, { ...props, padding: padding, ref: ref, className: cx('pui-card', className) }));
|
|
8
|
+
});
|
|
9
|
+
const CardTitle = /* @__PURE__ */ React.forwardRef(function CardTitle({ level = 3, className, ...props }, ref) {
|
|
10
|
+
return React.createElement(`h${level}`, {
|
|
11
|
+
...props,
|
|
12
|
+
ref,
|
|
13
|
+
className: cx('pui-card-title', className),
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
export const Card = {
|
|
17
|
+
Root: CardRoot,
|
|
18
|
+
Header: /* @__PURE__ */ part('div', 'pui-card-header'),
|
|
19
|
+
Title: CardTitle,
|
|
20
|
+
Description: /* @__PURE__ */ part('p', 'pui-card-description'),
|
|
21
|
+
Body: /* @__PURE__ */ part('div', 'pui-card-body'),
|
|
22
|
+
Footer: /* @__PURE__ */ part('div', 'pui-card-footer'),
|
|
23
|
+
};
|
|
24
|
+
// Flat names for React Server Components, which cannot dot into client exports.
|
|
25
|
+
export { CardRoot, CardTitle };
|
|
26
|
+
export const { Header: CardHeader, Description: CardDescription, Body: CardBody, Footer: CardFooter, } = Card;
|
package/dist/chart.d.ts
CHANGED
|
@@ -20,12 +20,27 @@ export type ChartProps = Omit<React.ComponentPropsWithoutRef<'figure'>, 'childre
|
|
|
20
20
|
height?: number;
|
|
21
21
|
locale?: string;
|
|
22
22
|
formatValue?: (value: number) => string;
|
|
23
|
+
/** Text the chart shows or announces; pass translations here. */
|
|
24
|
+
labels?: Partial<ChartLabels>;
|
|
25
|
+
/** @deprecated Use labels.missing. */
|
|
23
26
|
missingLabel?: string;
|
|
27
|
+
/** @deprecated Use labels.empty. */
|
|
24
28
|
emptyLabel?: string;
|
|
25
29
|
hiddenSeries?: readonly string[];
|
|
26
30
|
defaultHiddenSeries?: readonly string[];
|
|
27
31
|
onHiddenSeriesChange?: (keys: string[]) => void;
|
|
28
32
|
};
|
|
33
|
+
export type ChartLabels = {
|
|
34
|
+
missing: string;
|
|
35
|
+
empty: string;
|
|
36
|
+
noSeries: string;
|
|
37
|
+
showAll: string;
|
|
38
|
+
keyboardHelp: string;
|
|
39
|
+
values: (title: string) => string;
|
|
40
|
+
viewTable: string;
|
|
41
|
+
table: (title: string) => string;
|
|
42
|
+
tableCaption: (unit: string) => string;
|
|
43
|
+
};
|
|
29
44
|
/** Cartesian trends with a persistent, keyboard-readable tooltip region and a
|
|
30
45
|
* full data-table alternative. Missing values are gaps, never fabricated zeros. */
|
|
31
46
|
export declare const Chart: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "children" | "title"> & {
|
|
@@ -40,7 +55,11 @@ export declare const Chart: React.ForwardRefExoticComponent<Omit<Omit<React.Deta
|
|
|
40
55
|
height?: number;
|
|
41
56
|
locale?: string;
|
|
42
57
|
formatValue?: (value: number) => string;
|
|
58
|
+
/** Text the chart shows or announces; pass translations here. */
|
|
59
|
+
labels?: Partial<ChartLabels>;
|
|
60
|
+
/** @deprecated Use labels.missing. */
|
|
43
61
|
missingLabel?: string;
|
|
62
|
+
/** @deprecated Use labels.empty. */
|
|
44
63
|
emptyLabel?: string;
|
|
45
64
|
hiddenSeries?: readonly string[];
|
|
46
65
|
defaultHiddenSeries?: readonly string[];
|
package/dist/chart.js
CHANGED
|
@@ -2,8 +2,20 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Area, Bar, CartesianGrid, ComposedChart, Line, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts';
|
|
5
|
-
import { Table } from './
|
|
5
|
+
import { Table } from './table.js';
|
|
6
6
|
import { Button } from './button.js';
|
|
7
|
+
import { cx } from './parts.js';
|
|
8
|
+
const chartLabels = {
|
|
9
|
+
missing: 'Not available',
|
|
10
|
+
empty: 'No numeric measurements to display.',
|
|
11
|
+
noSeries: 'No series selected.',
|
|
12
|
+
showAll: 'Show all series',
|
|
13
|
+
keyboardHelp: 'Focus the chart and use Left/Right to inspect points. Escape clears details. The data table includes every series.',
|
|
14
|
+
values: (title) => `${title} values`,
|
|
15
|
+
viewTable: 'View data table',
|
|
16
|
+
table: (title) => `${title} data table`,
|
|
17
|
+
tableCaption: (unit) => `All input measurements, including hidden series. Unit: ${unit}.`,
|
|
18
|
+
};
|
|
7
19
|
const dashes = [undefined, '7 4', '2 4', '10 3 2 3', '12 5', '4 3'];
|
|
8
20
|
const colorFor = (index) => `var(--chart-series-${(index % 3) + 1})`;
|
|
9
21
|
function Marker({ cx, cy, color, index, }) {
|
|
@@ -20,7 +32,13 @@ function Pattern({ id, index, color, }) {
|
|
|
20
32
|
}
|
|
21
33
|
/** Cartesian trends with a persistent, keyboard-readable tooltip region and a
|
|
22
34
|
* full data-table alternative. Missing values are gaps, never fabricated zeros. */
|
|
23
|
-
export const Chart = React.forwardRef(function Chart({ title, description, data, series, unit, xLabel, yLabel, type = 'line', height = 280, locale = 'en-US', formatValue, missingLabel
|
|
35
|
+
export const Chart = /* @__PURE__ */ React.forwardRef(function Chart({ title, description, data, series, unit, xLabel, yLabel, type = 'line', height = 280, locale = 'en-US', formatValue, labels, missingLabel, emptyLabel, hiddenSeries, defaultHiddenSeries = [], onHiddenSeriesChange, className, ...props }, ref) {
|
|
36
|
+
const text = {
|
|
37
|
+
...chartLabels,
|
|
38
|
+
...(missingLabel === undefined ? {} : { missing: missingLabel }),
|
|
39
|
+
...(emptyLabel === undefined ? {} : { empty: emptyLabel }),
|
|
40
|
+
...labels,
|
|
41
|
+
};
|
|
24
42
|
const id = React.useId().replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
25
43
|
const [internalHidden, setInternalHidden] = React.useState(defaultHiddenSeries);
|
|
26
44
|
const hidden = new Set(hiddenSeries ?? internalHidden);
|
|
@@ -43,7 +61,7 @@ export const Chart = React.forwardRef(function Chart({ title, description, data,
|
|
|
43
61
|
}), [locale]);
|
|
44
62
|
const format = (value) => typeof value === 'number' && Number.isFinite(value)
|
|
45
63
|
? `${formatValue ? formatValue(value) : number.format(value)} ${unit}`
|
|
46
|
-
:
|
|
64
|
+
: text.missing;
|
|
47
65
|
const rows = React.useMemo(() => {
|
|
48
66
|
const ids = new Set(), keys = new Set();
|
|
49
67
|
for (const s of series) {
|
|
@@ -82,16 +100,19 @@ export const Chart = React.forwardRef(function Chart({ title, description, data,
|
|
|
82
100
|
.filter((s) => (s.key === key ? !hidden.has(key) : hidden.has(s.key)))
|
|
83
101
|
.map((s) => s.key));
|
|
84
102
|
const chartHeight = Number.isFinite(height) ? Math.max(200, height) : 280;
|
|
85
|
-
return (_jsxs("figure", { ...props, ref: ref, className:
|
|
103
|
+
return (_jsxs("figure", { ...props, ref: ref, className: cx('pui-chart', className), "aria-labelledby": `${id}-title`, children: [_jsxs("figcaption", { className: 'pui-chart-caption', children: [_jsx("strong", { id: `${id}-title`, children: title }), _jsx("p", { id: `${id}-summary`, children: description })] }), _jsx("ul", { className: 'pui-chart-legend', "aria-label": `${title} series`, children: series.map((s, index) => (_jsx("li", { children: _jsxs("button", { ref: index === 0 ? firstLegend : undefined, type: 'button', className: 'pui-chart-legend-button', "aria-label": `${s.label} series`, "aria-pressed": !hidden.has(s.key), onClick: () => toggle(s.key), children: [_jsx("svg", { width: '32', height: '20', viewBox: '0 0 32 20', "aria-hidden": 'true', children: type === 'bar' ? (_jsxs(_Fragment, { children: [_jsx("defs", { children: _jsx(Pattern, { id: `${id}-legend-${index}`, color: colorFor(index), index: index }) }), _jsx("rect", { x: '4', y: '3', width: '24', height: '14', rx: '2', fill: `url(#${id}-legend-${index})` })] })) : (_jsxs(_Fragment, { children: [_jsx("path", { d: 'M1 10h30', stroke: colorFor(index), strokeWidth: '2', strokeDasharray: dashes[index % dashes.length] }), _jsx(Marker, { cx: 16, cy: 10, index: index, color: colorFor(index) })] })) }), _jsx("span", { children: s.label })] }) }, s.key))) }), _jsxs("p", { className: 'pui-chart-axis-label', children: [yLabel, " (", unit, ")"] }), hasValues ? (_jsxs(_Fragment, { children: [_jsx("p", { className: 'pui-chart-help', id: `${id}-keys`, children: text.keyboardHelp }), _jsx("div", { className: 'pui-chart-plot', onKeyDownCapture: (event) => {
|
|
86
104
|
if (event.key === 'Escape')
|
|
87
105
|
setDismissed(true);
|
|
88
|
-
else if (event.key === 'ArrowLeft' ||
|
|
106
|
+
else if (event.key === 'ArrowLeft' ||
|
|
107
|
+
event.key === 'ArrowRight')
|
|
89
108
|
setDismissed(false);
|
|
90
109
|
}, onMouseMoveCapture: () => setDismissed(false), onTouchStartCapture: () => setDismissed(false), onFocusCapture: () => setDismissed(false), children: _jsx(ResponsiveContainer, { width: '100%', height: chartHeight, minWidth: 0, initialDimension: { width: 320, height: chartHeight }, children: _jsxs(ComposedChart, { data: rows, accessibilityLayer: true, role: 'application', "aria-label": title, "aria-describedby": `${id}-summary ${id}-keys`, margin: { top: 16, right: 20, bottom: 8, left: 0 }, children: [_jsx("defs", { children: series.map((s, index) => (_jsx(Pattern, { id: `${id}-pattern-${index}`, index: index, color: colorFor(index) }, s.key))) }), _jsx(CartesianGrid, { vertical: false, stroke: 'var(--line)' }), _jsx(XAxis, { dataKey: 'id', tickFormatter: (value) => {
|
|
91
110
|
const label = byId.get(String(value))?.label ?? String(value);
|
|
92
111
|
// minTickGap already drops ticks that would overlap; the cap
|
|
93
112
|
// only keeps one very long label from crowding the axis.
|
|
94
|
-
return label.length > 24
|
|
113
|
+
return label.length > 24
|
|
114
|
+
? label.slice(0, 23) + '…'
|
|
115
|
+
: label;
|
|
95
116
|
}, tick: { fill: 'var(--ink-muted)', fontSize: 12 }, tickLine: false, axisLine: { stroke: 'var(--line)' }, minTickGap: 24, interval: 'preserveStartEnd' }), _jsx(YAxis, { width: 56, tickFormatter: (value) => compact.format(Number(value)), tick: { fill: 'var(--ink-muted)', fontSize: 12 }, tickLine: false, axisLine: false, domain: [min, max === min ? max + 1 : max] }), _jsx(ReferenceLine, { y: 0, stroke: 'var(--ink-muted)' }), host && (_jsx(Tooltip, { portal: host, isAnimationActive: false, active: dismissed ? false : undefined, filterNull: false, cursor: dismissed
|
|
96
117
|
? false
|
|
97
118
|
: {
|
|
@@ -119,8 +140,8 @@ export const Chart = React.forwardRef(function Chart({ title, description, data,
|
|
|
119
140
|
: (dot) => (_jsx(Marker, { ...dot, color: colorFor(index), index: index })), activeDot: false }, s.key)) : (_jsx(Line, { ...common, type: 'linear', strokeWidth: 2, strokeDasharray: dashes[index % dashes.length], connectNulls: false, dot: rows.length > 40
|
|
120
141
|
? false
|
|
121
142
|
: (dot) => (_jsx(Marker, { ...dot, color: colorFor(index), index: index })), activeDot: false }, s.key));
|
|
122
|
-
})] }) }) }), _jsx("p", { className: 'pui-chart-axis-label pui-chart-x-label', children: xLabel })] })) : (_jsx("div", { className: 'pui-chart-empty', role: 'status', children: visible.length === 0 && series.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("p", { children:
|
|
143
|
+
})] }) }) }), _jsx("p", { className: 'pui-chart-axis-label pui-chart-x-label', children: xLabel })] })) : (_jsx("div", { className: 'pui-chart-empty', role: 'status', children: visible.length === 0 && series.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("p", { children: text.noSeries }), _jsx(Button, { variant: 'outline', onClick: () => {
|
|
123
144
|
setRestoreRequested(true);
|
|
124
145
|
changeHidden([]);
|
|
125
|
-
}, children:
|
|
146
|
+
}, children: text.showAll })] })) : (_jsx("p", { children: text.empty })) })), _jsx("div", { className: 'pui-chart-inspector', ref: setHost, role: 'status', "aria-live": 'polite', "aria-atomic": 'true', "aria-label": text.values(title), hidden: !hasValues }), _jsxs("details", { className: 'pui-chart-table', children: [_jsx("summary", { children: text.viewTable }), _jsx(Table.Container, { label: text.table(title), orientation: 'both', scrollChain: 'contain', children: _jsxs(Table.Root, { children: [_jsx(Table.Caption, { children: text.tableCaption(unit) }), _jsx(Table.Head, { children: _jsxs(Table.Row, { children: [_jsx(Table.HeaderCell, { scope: 'col', children: xLabel }), series.map((s) => (_jsxs(Table.HeaderCell, { scope: 'col', children: [s.label, " (", unit, ")"] }, s.key)))] }) }), _jsx(Table.Body, { children: rows.length ? (rows.map((row) => (_jsxs(Table.Row, { children: [_jsx(Table.HeaderCell, { scope: 'row', children: row.label }), series.map((s) => (_jsx(Table.Cell, { children: format(row.values[s.key]) }, s.key)))] }, row.id)))) : (_jsx(Table.Row, { children: _jsx(Table.Cell, { colSpan: series.length + 1, children: "No rows." }) })) })] }) })] })] }));
|
|
126
147
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { CheckboxGroup as BaseCheckboxGroup } from '@base-ui/react/checkbox-group';
|
|
5
|
+
import { skin } from './parts.js';
|
|
6
|
+
import { useRootRef, useResetValue } from './form-state.js';
|
|
7
|
+
import { ChoiceResetPaint } from './choice.js';
|
|
8
|
+
export const CheckboxGroup = /* @__PURE__ */ React.forwardRef(function CheckboxGroup({ value, defaultValue = [], onValueChange, className, ...props }, ref) {
|
|
9
|
+
const [element, attach] = useRootRef(ref);
|
|
10
|
+
const [selected, setSelected, revision] = useResetValue(value, defaultValue, element);
|
|
11
|
+
return (_jsx(ChoiceResetPaint.Provider, { value: revision, children: _jsx(BaseCheckboxGroup, { ...props, ref: attach, value: selected, className: skin('pui-choice-group', className), onValueChange: (next, event) => {
|
|
12
|
+
onValueChange?.(next, event);
|
|
13
|
+
if (value === undefined && !event.isCanceled)
|
|
14
|
+
setSelected(next);
|
|
15
|
+
} }) }));
|
|
16
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ChoiceSize } from './choice.js';
|
|
3
|
+
declare const CheckboxRoot: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/checkbox").CheckboxRootProps, "ref"> & React.RefAttributes<HTMLElement>, "ref"> & ChoiceSize & React.RefAttributes<HTMLElement>>;
|
|
4
|
+
declare const CheckboxIndicator: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/checkbox").CheckboxIndicatorProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
5
|
+
export declare const Checkbox: {
|
|
6
|
+
Root: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/checkbox").CheckboxRootProps, "ref"> & React.RefAttributes<HTMLElement>, "ref"> & ChoiceSize & React.RefAttributes<HTMLElement>>;
|
|
7
|
+
Indicator: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/checkbox").CheckboxIndicatorProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
8
|
+
};
|
|
9
|
+
export { CheckboxIndicator, CheckboxRoot };
|
package/dist/checkbox.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useComponentSize } from './sizing.js';
|
|
5
|
+
import { Checkbox as BaseCheckbox } from '@base-ui/react/checkbox';
|
|
6
|
+
import { skin } from './parts.js';
|
|
7
|
+
import { useRootRef, useResetValue } from './form-state.js';
|
|
8
|
+
import { ChoiceResetPaint } from './choice.js';
|
|
9
|
+
const CheckboxRoot = /* @__PURE__ */ React.forwardRef(function CheckboxRoot({ size, checked, defaultChecked = false, onCheckedChange, className, form, ...props }, ref) {
|
|
10
|
+
React.useContext(ChoiceResetPaint);
|
|
11
|
+
const scheme = useComponentSize(size);
|
|
12
|
+
const [element, attach] = useRootRef(ref);
|
|
13
|
+
const [selected, setSelected] = useResetValue(checked, defaultChecked, element, form);
|
|
14
|
+
return (_jsx(BaseCheckbox.Root, { ...props, "data-ui-size": size ? scheme : undefined, form: form, ref: attach, checked: selected, className: skin('pui-checkbox', className), onCheckedChange: (next, event) => {
|
|
15
|
+
onCheckedChange?.(next, event);
|
|
16
|
+
if (checked === undefined && !event.isCanceled)
|
|
17
|
+
setSelected(next);
|
|
18
|
+
} }));
|
|
19
|
+
});
|
|
20
|
+
const CheckboxIndicator = /* @__PURE__ */ React.forwardRef(function CheckboxIndicator({ className, children, ...props }, ref) {
|
|
21
|
+
return (_jsx(BaseCheckbox.Indicator, { ...props, ref: ref, className: skin('pui-checkbox-indicator', className), children: children ?? (_jsxs("svg", { width: '14', height: '14', viewBox: '0 0 20 20', fill: 'none', stroke: 'currentColor', strokeWidth: '2', "aria-hidden": 'true', children: [_jsx("path", { className: 'pui-checkbox-check', d: 'm4 10 4 4 8-8' }), _jsx("path", { className: 'pui-checkbox-mixed', d: 'M4 10h12' })] })) }));
|
|
22
|
+
});
|
|
23
|
+
export const Checkbox = {
|
|
24
|
+
...BaseCheckbox,
|
|
25
|
+
Root: CheckboxRoot,
|
|
26
|
+
Indicator: CheckboxIndicator,
|
|
27
|
+
};
|
|
28
|
+
// Flat names for React Server Components, which cannot dot into client exports.
|
|
29
|
+
export { CheckboxIndicator, CheckboxRoot };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type ChoiceLabelProps = Omit<React.ComponentPropsWithoutRef<'label'>, 'children'> & {
|
|
3
|
+
/** The Checkbox, Radio or Switch the label names. */
|
|
4
|
+
control: React.ReactElement<{
|
|
5
|
+
'aria-labelledby'?: string;
|
|
6
|
+
'aria-describedby'?: string;
|
|
7
|
+
}>;
|
|
8
|
+
/** The label text; it alone names the control. */
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
/** A longer explanation, read as the control's description. */
|
|
11
|
+
description?: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/** A checkbox, radio or switch with its label, and an optional description below it.
|
|
14
|
+
* The whole label toggles the control; the control sits on the first line. */
|
|
15
|
+
export declare const ChoiceLabel: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref">, "children"> & {
|
|
16
|
+
/** The Checkbox, Radio or Switch the label names. */
|
|
17
|
+
control: React.ReactElement<{
|
|
18
|
+
"aria-labelledby"?: string;
|
|
19
|
+
"aria-describedby"?: string;
|
|
20
|
+
}>;
|
|
21
|
+
/** The label text; it alone names the control. */
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
/** A longer explanation, read as the control's description. */
|
|
24
|
+
description?: React.ReactNode;
|
|
25
|
+
} & React.RefAttributes<HTMLLabelElement>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cx } from './parts.js';
|
|
5
|
+
/** A checkbox, radio or switch with its label, and an optional description below it.
|
|
6
|
+
* The whole label toggles the control; the control sits on the first line. */
|
|
7
|
+
export const ChoiceLabel = /* @__PURE__ */ React.forwardRef(function ChoiceLabel({ control, children, description, className, ...props }, ref) {
|
|
8
|
+
const id = React.useId();
|
|
9
|
+
return (_jsxs("label", { ...props, ref: ref, className: cx('pui-choice-label', className), children: [_jsx("span", { className: 'pui-choice-control', children: React.cloneElement(control, {
|
|
10
|
+
'aria-labelledby': control.props['aria-labelledby'] ?? `${id}-label`,
|
|
11
|
+
'aria-describedby': control.props['aria-describedby'] ??
|
|
12
|
+
(description ? `${id}-description` : undefined),
|
|
13
|
+
}) }), _jsxs("span", { className: 'pui-choice-text', children: [_jsx("span", { id: `${id}-label`, children: children }), description && (_jsx("span", { className: 'pui-choice-description', id: `${id}-description`, children: description }))] })] }));
|
|
14
|
+
});
|
package/dist/choice.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ComponentSizeAlias } from './sizing.js';
|
|
3
|
+
export declare const ChoiceResetPaint: React.Context<number>;
|
|
4
|
+
/** Choice controls follow the surrounding size; `size` sets one control's scale. */
|
|
5
|
+
export type ChoiceSize = {
|
|
6
|
+
size?: ComponentSizeAlias;
|
|
7
|
+
};
|
package/dist/choice.js
ADDED
package/dist/code.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type CodeBlockProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children' | 'onCopy'> & {
|
|
3
|
+
code: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
language?: string;
|
|
6
|
+
wrap?: boolean;
|
|
7
|
+
copyLabel?: string;
|
|
8
|
+
copiedLabel?: string;
|
|
9
|
+
copyErrorLabel?: string;
|
|
10
|
+
onCopy?: (code: string) => void | Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export declare const CodeBlock: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children" | "onCopy"> & {
|
|
13
|
+
code: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
language?: string;
|
|
16
|
+
wrap?: boolean;
|
|
17
|
+
copyLabel?: string;
|
|
18
|
+
copiedLabel?: string;
|
|
19
|
+
copyErrorLabel?: string;
|
|
20
|
+
onCopy?: (code: string) => void | Promise<void>;
|
|
21
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,37 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Icon } from './icon.js';
|
|
5
|
+
import { cx } from './parts.js';
|
|
6
6
|
import { Button } from './button.js';
|
|
7
7
|
import { SyntaxHighlighter } from './syntax-highlighter.js';
|
|
8
8
|
import { ScrollArea } from './scroll-area.js';
|
|
9
|
-
const
|
|
10
|
-
return (_jsx(Surface, { ...props, padding: padding, ref: ref, className: ['pui-card', className].filter(Boolean).join(' ') }));
|
|
11
|
-
});
|
|
12
|
-
const CardTitle = React.forwardRef(function CardTitle({ level = 3, className, ...props }, ref) {
|
|
13
|
-
return React.createElement(`h${level}`, {
|
|
14
|
-
...props,
|
|
15
|
-
ref,
|
|
16
|
-
className: ['pui-card-title', className].filter(Boolean).join(' '),
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
export const Card = {
|
|
20
|
-
Root: CardRoot,
|
|
21
|
-
Header: part('div', 'pui-card-header'),
|
|
22
|
-
Title: CardTitle,
|
|
23
|
-
Description: part('p', 'pui-card-description'),
|
|
24
|
-
Body: part('div', 'pui-card-body'),
|
|
25
|
-
Footer: part('div', 'pui-card-footer'),
|
|
26
|
-
};
|
|
27
|
-
const copyIcons = {
|
|
28
|
-
idle: (_jsxs(_Fragment, { children: [_jsx("rect", { x: '8', y: '8', width: '12', height: '12', rx: '2' }), _jsx("path", { d: 'M16 8V4H4v12h4' })] })),
|
|
29
|
-
copied: _jsx("path", { d: 'm5 12.5 4.5 4.5L19 7.5' }),
|
|
30
|
-
failed: (_jsx("path", { d: 'M12 7v6m0 4v.01M4.5 12a7.5 7.5 0 1 0 15 0 7.5 7.5 0 0 0-15 0' })),
|
|
31
|
-
};
|
|
9
|
+
const copyIcons = { idle: 'copy', copied: 'check', failed: 'alert' };
|
|
32
10
|
// Feedback stays inside the copy button and returns to the action after this long.
|
|
33
11
|
const copyFeedbackDuration = 2000;
|
|
34
|
-
export const CodeBlock = React.forwardRef(function CodeBlock({ code, label = 'Code', language, wrap = false, copyLabel = 'Copy code', copiedLabel = 'Copied', copyErrorLabel = 'Copy unavailable', onCopy, className, ...props }, ref) {
|
|
12
|
+
export const CodeBlock = /* @__PURE__ */ React.forwardRef(function CodeBlock({ code, label = 'Code', language, wrap = false, copyLabel = 'Copy code', copiedLabel = 'Copied', copyErrorLabel = 'Copy unavailable', onCopy, className, ...props }, ref) {
|
|
35
13
|
const [state, setState] = React.useState('idle');
|
|
36
14
|
// After the first copy, each change of label fades in; the first render does not.
|
|
37
15
|
const [used, setUsed] = React.useState(false);
|
|
@@ -50,6 +28,8 @@ export const CodeBlock = React.forwardRef(function CodeBlock({ code, label = 'Co
|
|
|
50
28
|
clearTimeout(timer.current);
|
|
51
29
|
setState('idle');
|
|
52
30
|
}, [code]);
|
|
31
|
+
const resting = React.useRef(true);
|
|
32
|
+
resting.current = state === 'idle';
|
|
53
33
|
// The button keeps its resting width, so the feedback never moves the toolbar.
|
|
54
34
|
React.useLayoutEffect(() => {
|
|
55
35
|
const element = button.current;
|
|
@@ -60,8 +40,9 @@ export const CodeBlock = React.forwardRef(function CodeBlock({ code, label = 'Co
|
|
|
60
40
|
element.style.minInlineSize = `${element.getBoundingClientRect().width}px`;
|
|
61
41
|
};
|
|
62
42
|
measure();
|
|
43
|
+
// Fonts can finish loading after a copy; the result label must not set the width.
|
|
63
44
|
document.fonts?.ready.then(() => {
|
|
64
|
-
if (mounted.current)
|
|
45
|
+
if (mounted.current && resting.current)
|
|
65
46
|
measure();
|
|
66
47
|
});
|
|
67
48
|
}, [copyLabel, state]);
|
|
@@ -93,12 +74,9 @@ export const CodeBlock = React.forwardRef(function CodeBlock({ code, label = 'Co
|
|
|
93
74
|
}, copyFeedbackDuration);
|
|
94
75
|
}
|
|
95
76
|
const icon = state === 'copied' || state === 'failed' ? state : 'idle';
|
|
96
|
-
return (_jsxs("div", { ...props, ref: ref, "data-wrap": wrap || undefined, className:
|
|
77
|
+
return (_jsxs("div", { ...props, ref: ref, "data-wrap": wrap || undefined, className: cx('pui-code-block', className), children: [_jsxs("div", { className: 'pui-code-toolbar', children: [_jsxs("span", { className: 'pui-code-label', children: [label, language && _jsx("span", { className: 'pui-code-language', children: language })] }), _jsxs(Button, { ref: button, type: 'button', variant: 'outline', size: 'sm', className: 'pui-code-copy', onClick: copy, disabled: state === 'busy', "aria-busy": state === 'busy' || undefined, "data-copy-state": icon === 'idle' ? undefined : icon, "data-copy-used": used || undefined, children: [_jsx(Icon, { name: copyIcons[icon], className: 'pui-code-copy-icon' }, icon), _jsx("span", { "aria-live": 'polite', children: _jsx("span", { className: 'pui-code-copy-label', children: state === 'copied'
|
|
97
78
|
? copiedLabel
|
|
98
79
|
: state === 'failed'
|
|
99
80
|
? copyErrorLabel
|
|
100
81
|
: copyLabel }, icon) })] })] }), _jsx(ScrollArea, { label: label, orientation: 'horizontal', children: _jsx("pre", { ref: source, className: 'pui-code-text', children: _jsx(SyntaxHighlighter, { code: code, language: language, inline: true }) }) })] }));
|
|
101
82
|
});
|
|
102
|
-
// Flat names for React Server Components, which cannot dot into client exports.
|
|
103
|
-
export { CardRoot, CardTitle };
|
|
104
|
-
export const { Header: CardHeader, Description: CardDescription, Body: CardBody, Footer: CardFooter, } = Card;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare const CollapsibleTrigger: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/collapsible").CollapsibleTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref"> & {
|
|
3
|
+
indicator?: React.ReactNode;
|
|
4
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
declare const CollapsiblePanel: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/collapsible").CollapsiblePanelProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export declare const Collapsible: {
|
|
7
|
+
Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/collapsible").CollapsibleRootProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
|
|
8
|
+
size?: import("./sizing.js").ComponentSize;
|
|
9
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
Trigger: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/collapsible").CollapsibleTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref"> & {
|
|
11
|
+
indicator?: React.ReactNode;
|
|
12
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
13
|
+
Panel: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/collapsible").CollapsiblePanelProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
};
|
|
15
|
+
export { CollapsiblePanel, CollapsibleTrigger };
|
|
16
|
+
export declare const CollapsibleRoot: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/collapsible").CollapsibleRootProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
|
|
17
|
+
size?: import("./sizing.js").ComponentSize;
|
|
18
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Collapsible as BaseCollapsible } from '@base-ui/react/collapsible';
|
|
5
|
+
import { Icon } from './icon.js';
|
|
6
|
+
import { skin, part } from './parts.js';
|
|
7
|
+
const CollapsibleTrigger = /* @__PURE__ */ React.forwardRef(function CollapsibleTrigger({ className, children, indicator, ...props }, ref) {
|
|
8
|
+
return (_jsxs(BaseCollapsible.Trigger, { ...props, ref: ref, className: skin('pui-disclosure-trigger', className), children: [_jsx("span", { className: 'pui-disclosure-label', children: children }), indicator === undefined ? (_jsx(Icon, { name: 'chevron-forward', className: 'pui-disclosure-chevron' })) : (indicator)] }));
|
|
9
|
+
});
|
|
10
|
+
const CollapsiblePanel = /* @__PURE__ */ React.forwardRef(function CollapsiblePanel({ className, children, ...props }, ref) {
|
|
11
|
+
return (_jsx(BaseCollapsible.Panel, { ...props, ref: ref, className: skin('pui-collapsible-panel', className), children: _jsx("div", { className: 'pui-disclosure-body', children: children }) }));
|
|
12
|
+
});
|
|
13
|
+
export const Collapsible = {
|
|
14
|
+
...BaseCollapsible,
|
|
15
|
+
Root: /* @__PURE__ */ part(BaseCollapsible.Root, 'pui-collapsible'),
|
|
16
|
+
Trigger: CollapsibleTrigger,
|
|
17
|
+
Panel: CollapsiblePanel,
|
|
18
|
+
};
|
|
19
|
+
// Flat names for React Server Components, which cannot dot into client exports.
|
|
20
|
+
export { CollapsiblePanel, CollapsibleTrigger };
|
|
21
|
+
export const { Root: CollapsibleRoot } = Collapsible;
|
|
@@ -3,7 +3,9 @@ import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
|
|
|
3
3
|
declare function ComboboxRoot<Value, Multiple extends boolean | undefined = false, Item = Value>({ children, form, ...props }: BaseCombobox.Root.Props<Value, Multiple, Item>): React.JSX.Element;
|
|
4
4
|
export declare const Combobox: {
|
|
5
5
|
Root: typeof ComboboxRoot;
|
|
6
|
-
|
|
6
|
+
Portal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/combobox").ComboboxPortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Content: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/combobox").ComboboxPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & Pick<Omit<Omit<import("@base-ui/react/combobox").ComboboxPositionerProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "side" | "align" | "sideOffset" | "collisionPadding"> & {
|
|
8
|
+
/** @deprecated Pass side, align, sideOffset and collisionPadding directly. */
|
|
7
9
|
positionerProps?: React.ComponentPropsWithoutRef<typeof BaseCombobox.Positioner>;
|
|
8
10
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
9
11
|
Popup: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/combobox").ComboboxPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
|
|
@@ -51,7 +53,6 @@ export declare const Combobox: {
|
|
|
51
53
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
52
54
|
Label: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/combobox").ComboboxLabelProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
53
55
|
Value: typeof BaseCombobox.Value;
|
|
54
|
-
Portal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/combobox").ComboboxPortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
55
56
|
Backdrop: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/combobox").ComboboxBackdropProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
56
57
|
Arrow: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/combobox").ComboboxArrowProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
57
58
|
Icon: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/combobox").ComboboxIconProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -61,21 +62,6 @@ export declare const Combobox: {
|
|
|
61
62
|
useFilteredItems: typeof BaseCombobox.useFilteredItems;
|
|
62
63
|
createItems: typeof BaseCombobox.createItems;
|
|
63
64
|
};
|
|
64
|
-
export declare const NumberField: {
|
|
65
|
-
Root: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/number-field").NumberFieldRootProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
66
|
-
Increment: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/number-field").NumberFieldIncrementProps, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
67
|
-
Decrement: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/number-field").NumberFieldDecrementProps, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
68
|
-
Group: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/number-field").NumberFieldGroupProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
|
|
69
|
-
size?: import("./sizing.js").ComponentSize;
|
|
70
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
71
|
-
Input: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/number-field").NumberFieldInputProps, "ref"> & React.RefAttributes<HTMLInputElement>, "ref">, "size"> & {
|
|
72
|
-
size?: import("./sizing.js").ComponentSize;
|
|
73
|
-
} & React.RefAttributes<HTMLInputElement>>;
|
|
74
|
-
ScrubArea: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/number-field").NumberFieldScrubAreaProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
|
|
75
|
-
size?: import("./sizing.js").ComponentSize;
|
|
76
|
-
} & React.RefAttributes<HTMLSpanElement>>;
|
|
77
|
-
ScrubAreaCursor: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/number-field").NumberFieldScrubAreaCursorProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
78
|
-
};
|
|
79
65
|
export { ComboboxRoot };
|
|
80
66
|
export declare const ComboboxArrow: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/combobox").ComboboxArrowProps, "ref"> & React.RefAttributes<HTMLDivElement>>, ComboboxBackdrop: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/combobox").ComboboxBackdropProps, "ref"> & React.RefAttributes<HTMLDivElement>>, ComboboxChip: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/combobox").ComboboxChipProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
|
|
81
67
|
size?: import("./sizing.js").ComponentSize;
|
|
@@ -103,13 +89,7 @@ export declare const ComboboxArrow: React.ForwardRefExoticComponent<Omit<import(
|
|
|
103
89
|
size?: import("./sizing.js").ComponentSize;
|
|
104
90
|
} & React.RefAttributes<HTMLDivElement>>, ComboboxStatus: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/combobox").ComboboxStatusProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
|
|
105
91
|
size?: import("./sizing.js").ComponentSize;
|
|
106
|
-
} & React.RefAttributes<HTMLDivElement>>, ComboboxTrigger: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/combobox").ComboboxTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>, ComboboxValue: typeof BaseCombobox.Value, ComboboxContent: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/combobox").ComboboxPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
92
|
+
} & React.RefAttributes<HTMLDivElement>>, ComboboxTrigger: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/combobox").ComboboxTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>, ComboboxValue: typeof BaseCombobox.Value, ComboboxContent: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/combobox").ComboboxPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & Pick<Omit<Omit<import("@base-ui/react/combobox").ComboboxPositionerProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "side" | "align" | "sideOffset" | "collisionPadding"> & {
|
|
93
|
+
/** @deprecated Pass side, align, sideOffset and collisionPadding directly. */
|
|
107
94
|
positionerProps?: React.ComponentPropsWithoutRef<typeof BaseCombobox.Positioner>;
|
|
108
95
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
109
|
-
export declare const NumberFieldDecrement: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/number-field").NumberFieldDecrementProps, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>, NumberFieldGroup: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/number-field").NumberFieldGroupProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
|
|
110
|
-
size?: import("./sizing.js").ComponentSize;
|
|
111
|
-
} & React.RefAttributes<HTMLDivElement>>, NumberFieldIncrement: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/number-field").NumberFieldIncrementProps, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>, NumberFieldInput: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/number-field").NumberFieldInputProps, "ref"> & React.RefAttributes<HTMLInputElement>, "ref">, "size"> & {
|
|
112
|
-
size?: import("./sizing.js").ComponentSize;
|
|
113
|
-
} & React.RefAttributes<HTMLInputElement>>, NumberFieldRoot: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/number-field").NumberFieldRootProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>, NumberFieldScrubArea: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/number-field").NumberFieldScrubAreaProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
|
|
114
|
-
size?: import("./sizing.js").ComponentSize;
|
|
115
|
-
} & React.RefAttributes<HTMLSpanElement>>, NumberFieldScrubAreaCursor: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/number-field").NumberFieldScrubAreaCursorProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
package/dist/combobox.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Icon } from './icon.js';
|
|
5
|
+
import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
|
|
6
|
+
import { OwnPortal, defined, part, scopedPortal, skin } from './parts.js';
|
|
7
|
+
import { useResetValue } from './form-state.js';
|
|
8
|
+
function ComboboxRoot({ children, form, ...props }) {
|
|
9
|
+
const anchor = React.useRef(null);
|
|
10
|
+
// Base UI does not reset its internal selection/query model on native form reset.
|
|
11
|
+
// Recreate that model together; controlled value/query props remain caller-owned.
|
|
12
|
+
const [, , revision] = useResetValue(true, true, anchor, form);
|
|
13
|
+
return (_jsxs(BaseCombobox.Root, { ...props, form: form, children: [_jsx("span", { hidden: true, ref: anchor }), children] }, revision));
|
|
14
|
+
}
|
|
15
|
+
const ComboPopup = /* @__PURE__ */ part(BaseCombobox.Popup, 'pui-combobox-popup', { portal: true });
|
|
16
|
+
const ComboPositioner = /* @__PURE__ */ part(BaseCombobox.Positioner, 'pui-positioner', { portal: true });
|
|
17
|
+
const ComboContent = /* @__PURE__ */ React.forwardRef(function ComboContent({ side, align, sideOffset, collisionPadding, positionerProps, ...props }, ref) {
|
|
18
|
+
return (_jsx(OwnPortal, { portal: BaseCombobox.Portal, children: _jsx(ComboPositioner, { sideOffset: 6, ...positionerProps, ...defined({ side, align, sideOffset, collisionPadding }), children: _jsx(ComboPopup, { ...props, ref: ref }) }) }));
|
|
19
|
+
});
|
|
20
|
+
const ComboTrigger = /* @__PURE__ */ React.forwardRef(function ComboTrigger({ children, className, ...props }, ref) {
|
|
21
|
+
return (_jsx(BaseCombobox.Trigger, { "aria-label": 'Show options', ...props, ref: ref, className: skin('pui-combobox-action', className), children: children ?? _jsx(Icon, { name: 'chevron-down' }) }));
|
|
22
|
+
});
|
|
23
|
+
const ComboClear = /* @__PURE__ */ React.forwardRef(function ComboClear({ children, className, ...props }, ref) {
|
|
24
|
+
return (_jsx(BaseCombobox.Clear, { "aria-label": 'Clear selection', ...props, ref: ref, className: skin('pui-combobox-action', className), children: children ?? _jsx(Icon, { name: 'close' }) }));
|
|
25
|
+
});
|
|
26
|
+
const ComboIndicator = /* @__PURE__ */ React.forwardRef(function ComboIndicator({ children, className, ...props }, ref) {
|
|
27
|
+
return (_jsx(BaseCombobox.ItemIndicator, { keepMounted: true, ...props, ref: ref, className: skin('pui-combobox-indicator', className), children: children ?? _jsx(Icon, { name: 'check' }) }));
|
|
28
|
+
});
|
|
29
|
+
const ComboRemove = /* @__PURE__ */ React.forwardRef(function ComboRemove({ children, className, ...props }, ref) {
|
|
30
|
+
return (_jsx(BaseCombobox.ChipRemove, { ...props, ref: ref, className: skin('pui-combobox-chip-remove', className), children: children ?? _jsx(Icon, { name: 'close' }) }));
|
|
31
|
+
});
|
|
32
|
+
export const Combobox = {
|
|
33
|
+
...BaseCombobox,
|
|
34
|
+
Root: ComboboxRoot,
|
|
35
|
+
Portal: /* @__PURE__ */ scopedPortal(BaseCombobox.Portal),
|
|
36
|
+
Content: ComboContent,
|
|
37
|
+
Popup: ComboPopup,
|
|
38
|
+
Positioner: ComboPositioner,
|
|
39
|
+
Trigger: ComboTrigger,
|
|
40
|
+
Clear: ComboClear,
|
|
41
|
+
ItemIndicator: ComboIndicator,
|
|
42
|
+
ChipRemove: ComboRemove,
|
|
43
|
+
Input: /* @__PURE__ */ part(BaseCombobox.Input, 'pui-input pui-combobox-input'),
|
|
44
|
+
InputGroup: /* @__PURE__ */ part(BaseCombobox.InputGroup, 'pui-combobox-group'),
|
|
45
|
+
List: /* @__PURE__ */ part(BaseCombobox.List, 'pui-combobox-list'),
|
|
46
|
+
Item: /* @__PURE__ */ part(BaseCombobox.Item, 'pui-combobox-item'),
|
|
47
|
+
Empty: /* @__PURE__ */ part(BaseCombobox.Empty, 'pui-combobox-empty'),
|
|
48
|
+
Status: /* @__PURE__ */ part(BaseCombobox.Status, 'pui-combobox-status'),
|
|
49
|
+
Group: /* @__PURE__ */ part(BaseCombobox.Group, 'pui-combobox-section'),
|
|
50
|
+
GroupLabel: /* @__PURE__ */ part(BaseCombobox.GroupLabel, 'pui-combobox-section-label'),
|
|
51
|
+
Separator: /* @__PURE__ */ part(BaseCombobox.Separator, 'pui-combobox-separator'),
|
|
52
|
+
Chips: /* @__PURE__ */ part(BaseCombobox.Chips, 'pui-combobox-chips'),
|
|
53
|
+
Chip: /* @__PURE__ */ part(BaseCombobox.Chip, 'pui-combobox-chip'),
|
|
54
|
+
};
|
|
55
|
+
// Flat names for React Server Components, which cannot dot into client exports.
|
|
56
|
+
export { ComboboxRoot };
|
|
57
|
+
export const { Arrow: ComboboxArrow, Backdrop: ComboboxBackdrop, Chip: ComboboxChip, ChipRemove: ComboboxChipRemove, Chips: ComboboxChips, Clear: ComboboxClear, Collection: ComboboxCollection, Empty: ComboboxEmpty, Group: ComboboxGroup, GroupLabel: ComboboxGroupLabel, Icon: ComboboxIcon, Input: ComboboxInput, InputGroup: ComboboxInputGroup, Item: ComboboxItem, ItemIndicator: ComboboxItemIndicator, Label: ComboboxLabel, List: ComboboxList, Popup: ComboboxPopup, Portal: ComboboxPortal, Positioner: ComboboxPositioner, Row: ComboboxRow, Separator: ComboboxSeparator, Status: ComboboxStatus, Trigger: ComboboxTrigger, Value: ComboboxValue, Content: ComboboxContent, } = Combobox;
|