@surflane/ui 0.4.0 → 0.6.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 +2 -2
- package/dist/{disclosure.d.ts → accordion.d.ts} +1 -17
- package/dist/{disclosure.js → accordion.js} +3 -17
- package/dist/alert-dialog.d.ts +31 -0
- package/dist/alert-dialog.js +22 -0
- package/dist/app-shell.d.ts +44 -3
- package/dist/app-shell.js +86 -13
- package/dist/{input-extensions.d.ts → autocomplete.d.ts} +4 -42
- package/dist/{input-extensions.js → autocomplete.js} +7 -26
- package/dist/avatar.js +3 -5
- package/dist/badge.d.ts +20 -0
- package/dist/badge.js +16 -0
- package/dist/bottom-navigation.d.ts +66 -0
- package/dist/bottom-navigation.js +36 -0
- package/dist/{navigation.d.ts → breadcrumbs.d.ts} +2 -6
- package/dist/breadcrumbs.js +31 -0
- package/dist/button.d.ts +11 -0
- package/dist/button.js +27 -4
- package/dist/{content.d.ts → card.d.ts} +6 -24
- package/dist/card.js +26 -0
- package/dist/chart.d.ts +35 -0
- package/dist/chart.js +123 -50
- 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} +5 -30
- 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/{advanced-forms.js → combobox.js} +13 -49
- package/dist/{context-overlays.d.ts → context-menu.d.ts} +6 -28
- package/dist/{context-overlays.js → context-menu.js} +5 -25
- package/dist/css/accordion.css +11 -0
- package/dist/css/alert-dialog.css +11 -0
- package/{src → dist/css}/all.css +1 -1
- package/dist/css/app-shell.css +12 -0
- package/dist/css/autocomplete.css +15 -0
- package/dist/css/avatar.css +10 -0
- package/dist/css/badge.css +10 -0
- package/dist/css/bottom-navigation.css +8 -0
- package/dist/css/breadcrumbs.css +12 -0
- package/dist/css/button.css +8 -0
- package/dist/css/card.css +11 -0
- package/dist/css/chart.css +13 -0
- package/dist/css/checkbox-group.css +9 -0
- package/dist/css/checkbox.css +9 -0
- package/dist/css/choice-label.css +9 -0
- package/dist/css/code.css +13 -0
- package/dist/css/collapsible.css +11 -0
- package/dist/css/combobox.css +14 -0
- package/dist/css/context-menu.css +15 -0
- package/dist/css/date-picker.css +12 -0
- package/dist/css/dialog.css +10 -0
- package/dist/css/drawer.css +11 -0
- package/dist/css/empty-state.css +9 -0
- package/dist/css/field.css +10 -0
- package/dist/css/fieldset.css +8 -0
- package/dist/css/file-upload.css +17 -0
- package/dist/css/filter-bar.css +8 -0
- package/dist/css/form.css +8 -0
- package/dist/css/icon.css +8 -0
- package/dist/css/inline-message.css +10 -0
- package/dist/css/input.css +9 -0
- package/dist/css/layout.css +9 -0
- package/dist/css/link.css +9 -0
- package/dist/css/list.css +9 -0
- package/dist/css/markdown.css +18 -0
- package/dist/css/menu.css +14 -0
- package/dist/css/menubar.css +9 -0
- package/dist/css/meter.css +9 -0
- package/dist/css/native-select.css +13 -0
- package/dist/css/navigation-menu.css +11 -0
- package/dist/css/number-field.css +11 -0
- package/dist/css/otp-field.css +10 -0
- package/dist/css/page-header.css +11 -0
- package/dist/css/pagination.css +11 -0
- package/dist/css/popover.css +9 -0
- package/dist/css/preview-card.css +11 -0
- package/dist/css/progress.css +9 -0
- package/dist/css/radio-group.css +9 -0
- package/dist/css/rules/accordion.css +21 -0
- package/dist/css/rules/alert-dialog.css +23 -0
- package/dist/css/rules/app-shell.css +220 -0
- package/dist/css/rules/autocomplete.css +3 -0
- package/dist/css/rules/avatar.css +17 -0
- package/dist/css/rules/badge.css +17 -0
- package/dist/css/rules/bar.css +38 -0
- package/dist/css/rules/base.css +46 -0
- package/dist/css/rules/bottom-navigation.css +142 -0
- package/dist/css/rules/breadcrumbs.css +9 -0
- package/dist/css/rules/button.css +131 -0
- package/dist/css/rules/card.css +10 -0
- package/dist/css/rules/chart.css +256 -0
- package/dist/css/rules/checkbox-group.css +3 -0
- package/dist/css/rules/checkbox.css +25 -0
- package/dist/css/rules/choice-label.css +52 -0
- package/dist/css/rules/choice.css +104 -0
- package/dist/css/rules/code.css +9 -0
- package/dist/css/rules/collapsible.css +12 -0
- package/dist/css/rules/combobox.css +177 -0
- package/dist/css/rules/context-menu.css +9 -0
- package/dist/css/rules/date-picker.css +301 -0
- package/dist/css/rules/dialog.css +160 -0
- package/dist/css/rules/disclosure.css +107 -0
- package/dist/css/rules/drawer.css +18 -0
- package/dist/css/rules/empty-state.css +9 -0
- package/dist/css/rules/field-control.css +70 -0
- package/dist/css/rules/field.css +56 -0
- package/dist/css/rules/fieldset.css +23 -0
- package/dist/css/rules/file-upload.css +156 -0
- package/dist/css/rules/filter-bar.css +56 -0
- package/dist/css/rules/form.css +15 -0
- package/dist/css/rules/gauge.css +61 -0
- package/dist/css/rules/icon.css +27 -0
- package/dist/css/rules/inline-message.css +10 -0
- package/dist/css/rules/input-group.css +69 -0
- package/dist/css/rules/input.css +33 -0
- package/dist/css/rules/item.css +14 -0
- package/dist/css/rules/layout.css +3 -0
- package/dist/css/rules/link.css +9 -0
- package/dist/css/rules/list.css +10 -0
- package/dist/css/rules/markdown.css +63 -0
- package/dist/css/rules/menu.css +97 -0
- package/dist/css/rules/menubar.css +18 -0
- package/dist/css/rules/meter.css +3 -0
- package/dist/css/rules/native-select.css +3 -0
- package/dist/css/rules/navigation-menu.css +159 -0
- package/dist/css/rules/number-field.css +55 -0
- package/dist/css/rules/otp-field.css +68 -0
- package/dist/css/rules/page-header.css +3 -0
- package/dist/css/rules/pagination.css +3 -0
- package/dist/css/rules/panel.css +221 -0
- package/dist/css/rules/popover.css +41 -0
- package/dist/css/rules/popup.css +27 -0
- package/dist/css/rules/preview-card.css +60 -0
- package/dist/css/rules/progress.css +14 -0
- package/dist/css/rules/radio-group.css +26 -0
- package/dist/css/rules/scroll-area.css +101 -0
- package/dist/css/rules/select.css +88 -0
- package/dist/css/rules/separator.css +3 -0
- package/dist/css/rules/sheet.css +3 -0
- package/dist/css/rules/sizing.css +140 -0
- package/dist/css/rules/skeleton.css +41 -0
- package/dist/css/rules/slider.css +123 -0
- package/dist/css/rules/sparkline.css +52 -0
- package/dist/css/rules/spinner.css +38 -0
- package/dist/css/rules/stat.css +59 -0
- package/dist/css/rules/switch.css +50 -0
- package/dist/css/rules/syntax-highlighter.css +82 -0
- package/dist/css/rules/table.css +28 -0
- package/dist/css/rules/tabs.css +126 -0
- package/dist/css/rules/textarea.css +21 -0
- package/dist/css/rules/toast.css +247 -0
- package/dist/css/rules/toggle-group.css +3 -0
- package/dist/css/rules/toggle.css +27 -0
- package/dist/css/rules/toolbar.css +62 -0
- package/dist/css/rules/tooltip.css +38 -0
- package/dist/css/rules/tree.css +98 -0
- package/dist/css/rules/typography.css +3 -0
- package/dist/css/scroll-area.css +8 -0
- package/dist/css/select.css +12 -0
- package/dist/css/separator.css +9 -0
- package/dist/css/sheet.css +11 -0
- package/dist/css/sizing.css +7 -0
- package/dist/css/skeleton.css +8 -0
- package/dist/css/slider.css +8 -0
- package/dist/css/sparkline.css +8 -0
- package/dist/css/spinner.css +8 -0
- package/dist/css/stat.css +9 -0
- package/dist/css/styles.css +100 -0
- package/dist/css/switch.css +9 -0
- package/dist/css/syntax-highlighter.css +9 -0
- package/dist/css/table.css +12 -0
- package/dist/css/tabs.css +8 -0
- package/dist/css/textarea.css +10 -0
- package/dist/css/toast.css +11 -0
- package/dist/css/toggle-group.css +9 -0
- package/dist/css/toggle.css +10 -0
- package/dist/css/toolbar.css +12 -0
- package/dist/css/tooltip.css +9 -0
- package/dist/css/tree.css +10 -0
- package/dist/css/typography.css +9 -0
- package/dist/date-picker.js +3 -2
- package/dist/dialog.d.ts +6 -24
- package/dist/dialog.js +7 -20
- 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 +7 -5
- package/dist/filter-bar.js +1 -1
- package/dist/form.d.ts +2 -0
- package/dist/form.js +7 -0
- package/dist/format.d.ts +25 -0
- package/dist/format.js +42 -0
- package/dist/icon.d.ts +11 -0
- package/dist/icon.js +19 -3
- package/dist/index.d.ts +61 -30
- package/dist/index.js +75 -33
- package/dist/{messages.d.ts → inline-message.d.ts} +0 -28
- package/dist/{messages.js → inline-message.js} +3 -18
- package/dist/input.js +2 -2
- package/dist/{foundations.d.ts → layout.d.ts} +5 -23
- package/dist/{foundations.js → layout.js} +4 -19
- 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 +4 -5
- package/dist/menu.d.ts +7 -5
- package/dist/menu.js +12 -8
- 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 +8 -5
- package/dist/number-field.d.ts +23 -0
- package/dist/number-field.js +33 -0
- package/dist/page-header.d.ts +12 -0
- package/dist/page-header.js +9 -0
- package/dist/pagination.js +3 -4
- package/dist/panel.d.ts +13 -0
- package/dist/panel.js +13 -0
- package/dist/parts.d.ts +19 -1
- package/dist/parts.js +32 -6
- 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 +3 -4
- package/dist/select.d.ts +8 -8
- package/dist/select.js +19 -54
- 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/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/sparkline.d.ts +41 -0
- package/dist/sparkline.js +50 -0
- package/dist/spinner.d.ts +13 -0
- package/dist/spinner.js +10 -0
- package/dist/stat.d.ts +59 -0
- package/dist/stat.js +26 -0
- package/dist/status.d.ts +2 -20
- package/dist/status.js +11 -14
- package/dist/switch.d.ts +13 -0
- package/dist/switch.js +25 -0
- package/dist/syntax-highlighter.js +2 -1
- package/dist/{data.d.ts → table.d.ts} +8 -32
- package/dist/{data.js → table.js} +15 -30
- package/dist/textarea.d.ts +7 -0
- package/dist/textarea.js +12 -0
- package/dist/toast.d.ts +57 -1
- package/dist/toast.js +80 -8
- 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 +10 -3
- package/dist/tooltip.js +4 -4
- package/dist/tree.js +4 -2
- package/dist/typography.d.ts +12 -0
- package/dist/typography.js +14 -0
- package/package.json +324 -25
- package/dist/chevron.d.ts +0 -3
- package/dist/chevron.js +0 -6
- package/dist/commands.js +0 -27
- 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/navigation.js +0 -41
- package/dist/panels.js +0 -100
- package/src/styles.css +0 -3780
package/dist/stat.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type StatDirection = 'up' | 'down' | 'flat';
|
|
3
|
+
export type StatChangeProps = Omit<React.ComponentPropsWithoutRef<'dd'>, 'children'> & {
|
|
4
|
+
/** The change, such as 0.023 for 2.3%. Its sign sets the direction. */
|
|
5
|
+
value: number;
|
|
6
|
+
/** Text for the change. Defaults to a signed percentage of `value`. */
|
|
7
|
+
format?: (value: number) => React.ReactNode;
|
|
8
|
+
/** Overrides the direction the sign gives. */
|
|
9
|
+
direction?: StatDirection;
|
|
10
|
+
/** For measures where a fall is good, such as latency: the colors swap, the arrow
|
|
11
|
+
* still points the way the value moved. */
|
|
12
|
+
lowerIsBetter?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** A key figure: what it measures, its value, how it moved and what it covers. Renders
|
|
15
|
+
* a description list, so the label names the value for assistive technology. */
|
|
16
|
+
export declare const Stat: {
|
|
17
|
+
Root: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDListElement>, HTMLDListElement>, "ref">, "size"> & {
|
|
18
|
+
size?: import("./sizing.js").ComponentSize;
|
|
19
|
+
} & React.RefAttributes<HTMLDListElement>>;
|
|
20
|
+
Label: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "size"> & {
|
|
21
|
+
size?: import("./sizing.js").ComponentSize;
|
|
22
|
+
} & React.RefAttributes<HTMLElement>>;
|
|
23
|
+
Value: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "size"> & {
|
|
24
|
+
size?: import("./sizing.js").ComponentSize;
|
|
25
|
+
} & React.RefAttributes<HTMLElement>>;
|
|
26
|
+
Change: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "children"> & {
|
|
27
|
+
/** The change, such as 0.023 for 2.3%. Its sign sets the direction. */
|
|
28
|
+
value: number;
|
|
29
|
+
/** Text for the change. Defaults to a signed percentage of `value`. */
|
|
30
|
+
format?: (value: number) => React.ReactNode;
|
|
31
|
+
/** Overrides the direction the sign gives. */
|
|
32
|
+
direction?: StatDirection;
|
|
33
|
+
/** For measures where a fall is good, such as latency: the colors swap, the arrow
|
|
34
|
+
* still points the way the value moved. */
|
|
35
|
+
lowerIsBetter?: boolean;
|
|
36
|
+
} & React.RefAttributes<HTMLElement>>;
|
|
37
|
+
Caption: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "size"> & {
|
|
38
|
+
size?: import("./sizing.js").ComponentSize;
|
|
39
|
+
} & React.RefAttributes<HTMLElement>>;
|
|
40
|
+
};
|
|
41
|
+
export declare const StatRoot: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDListElement>, HTMLDListElement>, "ref">, "size"> & {
|
|
42
|
+
size?: import("./sizing.js").ComponentSize;
|
|
43
|
+
} & React.RefAttributes<HTMLDListElement>>, StatLabel: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "size"> & {
|
|
44
|
+
size?: import("./sizing.js").ComponentSize;
|
|
45
|
+
} & React.RefAttributes<HTMLElement>>, StatValue: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "size"> & {
|
|
46
|
+
size?: import("./sizing.js").ComponentSize;
|
|
47
|
+
} & React.RefAttributes<HTMLElement>>, StatChange: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "children"> & {
|
|
48
|
+
/** The change, such as 0.023 for 2.3%. Its sign sets the direction. */
|
|
49
|
+
value: number;
|
|
50
|
+
/** Text for the change. Defaults to a signed percentage of `value`. */
|
|
51
|
+
format?: (value: number) => React.ReactNode;
|
|
52
|
+
/** Overrides the direction the sign gives. */
|
|
53
|
+
direction?: StatDirection;
|
|
54
|
+
/** For measures where a fall is good, such as latency: the colors swap, the arrow
|
|
55
|
+
* still points the way the value moved. */
|
|
56
|
+
lowerIsBetter?: boolean;
|
|
57
|
+
} & React.RefAttributes<HTMLElement>>, StatCaption: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "size"> & {
|
|
58
|
+
size?: import("./sizing.js").ComponentSize;
|
|
59
|
+
} & React.RefAttributes<HTMLElement>>;
|
package/dist/stat.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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 { part, cx } from './parts.js';
|
|
6
|
+
import { formatPercent } from './format.js';
|
|
7
|
+
const signed = (value) => formatPercent(value, { signed: true });
|
|
8
|
+
const arrows = { up: 'arrow-up', down: 'arrow-down', flat: 'minus' };
|
|
9
|
+
/** A change against an earlier value: an arrow, a signed figure and its direction's
|
|
10
|
+
* color. The sign and the arrow carry the direction, so color is never alone. */
|
|
11
|
+
const ChangePart = /* @__PURE__ */ React.forwardRef(function StatChange({ value, format = signed, direction, lowerIsBetter, className, ...props }, ref) {
|
|
12
|
+
const way = direction ?? (value > 0 ? 'up' : value < 0 ? 'down' : 'flat');
|
|
13
|
+
const tone = way === 'flat' || !lowerIsBetter ? way : way === 'up' ? 'down' : 'up';
|
|
14
|
+
return (_jsxs("dd", { ...props, ref: ref, "data-direction": way, "data-tone": tone, className: cx('pui-stat-change', className), children: [_jsx(Icon, { name: arrows[way] }), format(value)] }));
|
|
15
|
+
});
|
|
16
|
+
/** A key figure: what it measures, its value, how it moved and what it covers. Renders
|
|
17
|
+
* a description list, so the label names the value for assistive technology. */
|
|
18
|
+
export const Stat = {
|
|
19
|
+
Root: /* @__PURE__ */ part('dl', 'pui-stat'),
|
|
20
|
+
Label: /* @__PURE__ */ part('dt', 'pui-stat-label'),
|
|
21
|
+
Value: /* @__PURE__ */ part('dd', 'pui-stat-value'),
|
|
22
|
+
Change: ChangePart,
|
|
23
|
+
Caption: /* @__PURE__ */ part('dd', 'pui-stat-caption'),
|
|
24
|
+
};
|
|
25
|
+
// Flat names for React Server Components, which cannot dot into client exports.
|
|
26
|
+
export const { Root: StatRoot, Label: StatLabel, Value: StatValue, Change: StatChange, Caption: StatCaption, } = Stat;
|
package/dist/status.d.ts
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { type ComponentSize } from './sizing.js';
|
|
3
|
-
export type StatusTone = 'neutral' | 'success' | 'danger' | 'caution' | 'progress';
|
|
4
|
-
export type BadgeProps = React.ComponentPropsWithoutRef<'span'> & {
|
|
5
|
-
size?: ComponentSize;
|
|
6
|
-
tone?: StatusTone;
|
|
7
|
-
icon?: React.ReactNode;
|
|
8
|
-
};
|
|
9
|
-
export declare const Badge: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
10
|
-
size?: ComponentSize;
|
|
11
|
-
tone?: StatusTone;
|
|
12
|
-
icon?: React.ReactNode;
|
|
13
|
-
} & React.RefAttributes<HTMLSpanElement>>;
|
|
1
|
+
export type StatusTone = 'neutral' | 'info' | 'success' | 'danger' | 'caution' | 'progress';
|
|
14
2
|
export declare function StatusIcon({ tone }: {
|
|
15
3
|
tone: StatusTone;
|
|
16
|
-
}):
|
|
17
|
-
/** Domain status labels and live announcements remain the caller's responsibility. */
|
|
18
|
-
export declare const StatusBadge: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
19
|
-
size?: ComponentSize;
|
|
20
|
-
tone?: StatusTone;
|
|
21
|
-
icon?: React.ReactNode;
|
|
22
|
-
} & React.RefAttributes<HTMLSpanElement>>;
|
|
4
|
+
}): import("react").JSX.Element;
|
package/dist/status.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Icon } from './icon.js';
|
|
4
|
+
const statusIcons = {
|
|
5
|
+
neutral: 'minus-circle',
|
|
6
|
+
info: 'info',
|
|
7
|
+
success: 'check',
|
|
8
|
+
danger: 'alert',
|
|
9
|
+
caution: 'warning',
|
|
10
|
+
progress: 'clock',
|
|
11
|
+
};
|
|
11
12
|
export function StatusIcon({ tone }) {
|
|
12
|
-
return
|
|
13
|
+
return _jsx(Icon, { name: statusIcons[tone] });
|
|
13
14
|
}
|
|
14
|
-
/** Domain status labels and live announcements remain the caller's responsibility. */
|
|
15
|
-
export const StatusBadge = /* @__PURE__ */ React.forwardRef(function StatusBadge({ tone = 'neutral', icon, ...props }, ref) {
|
|
16
|
-
return (_jsx(Badge, { ...props, ref: ref, tone: tone, icon: icon === undefined ? _jsx(StatusIcon, { tone: tone }) : icon }));
|
|
17
|
-
});
|
package/dist/switch.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ChoiceSize } from './choice.js';
|
|
3
|
+
declare const SwitchRoot: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/switch").SwitchRootProps, "ref"> & React.RefAttributes<HTMLElement>, "ref"> & ChoiceSize & React.RefAttributes<HTMLElement>>;
|
|
4
|
+
export declare const Switch: {
|
|
5
|
+
Root: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/switch").SwitchRootProps, "ref"> & React.RefAttributes<HTMLElement>, "ref"> & ChoiceSize & React.RefAttributes<HTMLElement>>;
|
|
6
|
+
Thumb: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/switch").SwitchThumbProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
|
|
7
|
+
size?: import("./sizing.js").ComponentSize;
|
|
8
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
|
9
|
+
};
|
|
10
|
+
export { SwitchRoot };
|
|
11
|
+
export declare const SwitchThumb: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/switch").SwitchThumbProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
|
|
12
|
+
size?: import("./sizing.js").ComponentSize;
|
|
13
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
package/dist/switch.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useComponentSize } from './sizing.js';
|
|
5
|
+
import { Switch as BaseSwitch } from '@base-ui/react/switch';
|
|
6
|
+
import { skin, part } from './parts.js';
|
|
7
|
+
import { useRootRef, useResetValue } from './form-state.js';
|
|
8
|
+
const SwitchRoot = /* @__PURE__ */ React.forwardRef(function SwitchRoot({ size, checked, defaultChecked = false, onCheckedChange, className, form, ...props }, ref) {
|
|
9
|
+
const scheme = useComponentSize(size);
|
|
10
|
+
const [element, attach] = useRootRef(ref);
|
|
11
|
+
const [selected, setSelected] = useResetValue(checked, defaultChecked, element, form);
|
|
12
|
+
return (_jsx(BaseSwitch.Root, { ...props, "data-ui-size": size ? scheme : undefined, form: form, ref: attach, checked: selected, className: skin('pui-switch', className), onCheckedChange: (next, event) => {
|
|
13
|
+
onCheckedChange?.(next, event);
|
|
14
|
+
if (checked === undefined && !event.isCanceled)
|
|
15
|
+
setSelected(next);
|
|
16
|
+
} }));
|
|
17
|
+
});
|
|
18
|
+
export const Switch = {
|
|
19
|
+
...BaseSwitch,
|
|
20
|
+
Root: SwitchRoot,
|
|
21
|
+
Thumb: /* @__PURE__ */ part(BaseSwitch.Thumb, 'pui-switch-thumb'),
|
|
22
|
+
};
|
|
23
|
+
// Flat names for React Server Components, which cannot dot into client exports.
|
|
24
|
+
export { SwitchRoot };
|
|
25
|
+
export const { Thumb: SwitchThumb } = Switch;
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ScrollArea } from './scroll-area.js';
|
|
5
5
|
import { SyntaxEngineContext } from './syntax-context.js';
|
|
6
|
+
import { cx } from './parts.js';
|
|
6
7
|
export const syntaxLanguages = [
|
|
7
8
|
'tsx',
|
|
8
9
|
'jsx',
|
|
@@ -63,7 +64,7 @@ export const SyntaxHighlighter = /* @__PURE__ */ React.forwardRef(function Synta
|
|
|
63
64
|
const tokens = result?.code === code && result.language === lang ? result.tokens : null;
|
|
64
65
|
const eols = code.match(/\r\n|\n|\r/g) ?? [];
|
|
65
66
|
const valid = tokens && tokens.length === eols.length + 1;
|
|
66
|
-
const element = (_jsx("code", { ...props, ref: ref, className:
|
|
67
|
+
const element = (_jsx("code", { ...props, ref: ref, className: cx('pui-syntax', className), "data-language": lang, "data-highlighted": valid ? 'true' : 'false', children: valid
|
|
67
68
|
? tokens.map((line, i) => (_jsxs(React.Fragment, { children: [line.map((token, j) => (_jsx("span", { "data-syntax": token.role, children: token.content }, j))), eols[i] ?? ''] }, i)))
|
|
68
69
|
: code }));
|
|
69
70
|
return inline ? (element) : (_jsx(ScrollArea, { label: label, orientation: 'horizontal', rootClassName: 'pui-syntax-scroll', children: _jsx("pre", { className: 'pui-syntax-pre', "data-wrap": wrap || undefined, children: element }) }));
|
|
@@ -7,6 +7,9 @@ declare const TableContainer: React.ForwardRefExoticComponent<Omit<Omit<React.De
|
|
|
7
7
|
scrollChain?: "auto" | "contain";
|
|
8
8
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
9
9
|
label: string;
|
|
10
|
+
/** Hangs the table into the gutter by its cell inset, so cell text lines up with
|
|
11
|
+
* the text around it and a row's hover reaches past it evenly on both sides. */
|
|
12
|
+
bleed?: boolean;
|
|
10
13
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
11
14
|
export type TableDensity = 'default' | 'compact';
|
|
12
15
|
declare const TableRoot: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref">, "size"> & {
|
|
@@ -55,6 +58,9 @@ export declare const Table: {
|
|
|
55
58
|
scrollChain?: "auto" | "contain";
|
|
56
59
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
57
60
|
label: string;
|
|
61
|
+
/** Hangs the table into the gutter by its cell inset, so cell text lines up with
|
|
62
|
+
* the text around it and a row's hover reaches past it evenly on both sides. */
|
|
63
|
+
bleed?: boolean;
|
|
58
64
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
59
65
|
Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref">, "size"> & {
|
|
60
66
|
size?: import("./sizing.js").ComponentSize;
|
|
@@ -97,38 +103,7 @@ export declare const Table: {
|
|
|
97
103
|
colSpan: number;
|
|
98
104
|
} & React.RefAttributes<HTMLTableCellElement>>;
|
|
99
105
|
};
|
|
100
|
-
|
|
101
|
-
declare const ListItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
|
|
102
|
-
selected?: boolean;
|
|
103
|
-
} & React.RefAttributes<HTMLLIElement>>;
|
|
104
|
-
export declare const List: {
|
|
105
|
-
Root: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
|
|
106
|
-
Item: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
|
|
107
|
-
selected?: boolean;
|
|
108
|
-
} & React.RefAttributes<HTMLLIElement>>;
|
|
109
|
-
Content: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
|
|
110
|
-
size?: import("./sizing.js").ComponentSize;
|
|
111
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
112
|
-
Title: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
|
|
113
|
-
size?: import("./sizing.js").ComponentSize;
|
|
114
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
115
|
-
Description: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref">, "size"> & {
|
|
116
|
-
size?: import("./sizing.js").ComponentSize;
|
|
117
|
-
} & React.RefAttributes<HTMLParagraphElement>>;
|
|
118
|
-
Actions: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
|
|
119
|
-
size?: import("./sizing.js").ComponentSize;
|
|
120
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
121
|
-
};
|
|
122
|
-
export { ListRoot, ListItem, TableContainer, TableRoot, TableRow, TableHeaderCell, TableSortHeader, TableCell, TableTruncate, TableMessage, };
|
|
123
|
-
export declare const ListContent: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
|
|
124
|
-
size?: import("./sizing.js").ComponentSize;
|
|
125
|
-
} & React.RefAttributes<HTMLDivElement>>, ListTitle: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
|
|
126
|
-
size?: import("./sizing.js").ComponentSize;
|
|
127
|
-
} & React.RefAttributes<HTMLDivElement>>, ListDescription: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref">, "size"> & {
|
|
128
|
-
size?: import("./sizing.js").ComponentSize;
|
|
129
|
-
} & React.RefAttributes<HTMLParagraphElement>>, ListActions: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
|
|
130
|
-
size?: import("./sizing.js").ComponentSize;
|
|
131
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
106
|
+
export { TableContainer, TableRoot, TableRow, TableHeaderCell, TableSortHeader, TableCell, TableTruncate, TableMessage, };
|
|
132
107
|
export declare const TableCaption: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "size"> & {
|
|
133
108
|
size?: import("./sizing.js").ComponentSize;
|
|
134
109
|
} & React.RefAttributes<HTMLTableCaptionElement>>, TableHead: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref">, "size"> & {
|
|
@@ -138,3 +113,4 @@ export declare const TableCaption: React.ForwardRefExoticComponent<Omit<Omit<Rea
|
|
|
138
113
|
} & React.RefAttributes<HTMLTableSectionElement>>, TableFoot: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref">, "size"> & {
|
|
139
114
|
size?: import("./sizing.js").ComponentSize;
|
|
140
115
|
} & React.RefAttributes<HTMLTableSectionElement>>;
|
|
116
|
+
export { useTableSelection, type TableSelectionOptions, type TableSelectionCheckbox, } from './table-selection.js';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { Icon } from './icon.js';
|
|
4
5
|
import { Button } from './button.js';
|
|
5
|
-
import { part } from './parts.js';
|
|
6
|
+
import { part, cx } from './parts.js';
|
|
6
7
|
import { ScrollArea } from './scroll-area.js';
|
|
7
|
-
const TableContainer = /* @__PURE__ */ React.forwardRef(function TableContainer(props, ref) {
|
|
8
|
-
return _jsx(ScrollArea, { ...props, ref: ref });
|
|
8
|
+
const TableContainer = /* @__PURE__ */ React.forwardRef(function TableContainer({ bleed, rootClassName, ...props }, ref) {
|
|
9
|
+
return (_jsx(ScrollArea, { ...props, ref: ref, rootClassName: cx(bleed && 'pui-table-bleed', rootClassName) }));
|
|
9
10
|
});
|
|
10
11
|
const RootPart = /* @__PURE__ */ part('table', 'pui-table');
|
|
11
12
|
const TableRoot = /* @__PURE__ */ React.forwardRef(function TableRoot({ density, stickyHeader, ...props }, ref) {
|
|
@@ -25,28 +26,26 @@ const TableCell = /* @__PURE__ */ React.forwardRef(function TableCell({ align, n
|
|
|
25
26
|
return _jsx(CellPart, { ...props, ...layout({ align, numeric }), ref: ref });
|
|
26
27
|
});
|
|
27
28
|
function SortIcon({ sort }) {
|
|
28
|
-
return (_jsx(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
return (_jsx(Icon, { name: sort === 'ascending'
|
|
30
|
+
? 'arrow-up'
|
|
31
|
+
: sort === 'descending'
|
|
32
|
+
? 'arrow-down'
|
|
33
|
+
: 'sort', className: 'pui-table-sort-icon' }));
|
|
33
34
|
}
|
|
34
35
|
/** A column header whose button sorts the column. aria-sort names the order on the sorted column only. */
|
|
35
36
|
const TableSortHeader = /* @__PURE__ */ React.forwardRef(function TableSortHeader({ sort, onSort, disabled, children, className, ...props }, ref) {
|
|
36
|
-
return (_jsx(TableHeaderCell, { ...props, ref: ref, scope: 'col', "aria-sort": sort, className:
|
|
37
|
+
return (_jsx(TableHeaderCell, { ...props, ref: ref, scope: 'col', "aria-sort": sort, className: cx('pui-table-sort-header', className), children: _jsxs(Button, { variant: 'ghost', className: 'pui-table-sort', "data-sort": sort, disabled: disabled, onClick: onSort, children: [_jsx("span", { children: children }), _jsx(SortIcon, { sort: sort })] }) }));
|
|
37
38
|
});
|
|
38
39
|
/** One-line text that ends in an ellipsis. String content also becomes the title. */
|
|
39
40
|
const TableTruncate = /* @__PURE__ */ React.forwardRef(function TableTruncate({ className, title, children, ...props }, ref) {
|
|
40
|
-
return (_jsx("span", { ...props, ref: ref, title: title ?? (typeof children === 'string' ? children : undefined), className:
|
|
41
|
+
return (_jsx("span", { ...props, ref: ref, title: title ?? (typeof children === 'string' ? children : undefined), className: cx('pui-table-truncate', className), children: children }));
|
|
41
42
|
});
|
|
42
43
|
/** A full-width body row for loading, empty, error and permission messages. It has no hover. */
|
|
43
44
|
const TableMessage = /* @__PURE__ */ React.forwardRef(function TableMessage({ className, ...props }, ref) {
|
|
44
|
-
return (_jsx("tr", { className: 'pui-table-row pui-table-message-row', children: _jsx("td", { ...props, ref: ref, className:
|
|
45
|
-
.filter(Boolean)
|
|
46
|
-
.join(' ') }) }));
|
|
45
|
+
return (_jsx("tr", { className: 'pui-table-row pui-table-message-row', children: _jsx("td", { ...props, ref: ref, className: cx('pui-table-cell pui-table-message', className) }) }));
|
|
47
46
|
});
|
|
48
47
|
const TableRow = /* @__PURE__ */ React.forwardRef(function TableRow({ selected, className, ...props }, ref) {
|
|
49
|
-
return (_jsx("tr", { ...props, ref: ref, "data-selected": selected || undefined, className:
|
|
48
|
+
return (_jsx("tr", { ...props, ref: ref, "data-selected": selected || undefined, className: cx('pui-table-row', className) }));
|
|
50
49
|
});
|
|
51
50
|
export const Table = {
|
|
52
51
|
Container: TableContainer,
|
|
@@ -62,21 +61,7 @@ export const Table = {
|
|
|
62
61
|
Truncate: TableTruncate,
|
|
63
62
|
Message: TableMessage,
|
|
64
63
|
};
|
|
65
|
-
const ListRoot = /* @__PURE__ */ React.forwardRef(function ListRoot({ className, ...props }, ref) {
|
|
66
|
-
return (_jsx("ul", { role: 'list', ...props, ref: ref, className: ['pui-list', className].filter(Boolean).join(' ') }));
|
|
67
|
-
});
|
|
68
|
-
const ListItem = /* @__PURE__ */ React.forwardRef(function ListItem({ selected, className, ...props }, ref) {
|
|
69
|
-
return (_jsx("li", { ...props, ref: ref, "data-selected": selected || undefined, className: ['pui-list-item', className].filter(Boolean).join(' ') }));
|
|
70
|
-
});
|
|
71
|
-
export const List = {
|
|
72
|
-
Root: ListRoot,
|
|
73
|
-
Item: ListItem,
|
|
74
|
-
Content: /* @__PURE__ */ part('div', 'pui-list-content'),
|
|
75
|
-
Title: /* @__PURE__ */ part('div', 'pui-list-title'),
|
|
76
|
-
Description: /* @__PURE__ */ part('p', 'pui-list-description'),
|
|
77
|
-
Actions: /* @__PURE__ */ part('div', 'pui-list-actions'),
|
|
78
|
-
};
|
|
79
64
|
// Flat names for React Server Components, which cannot dot into client exports.
|
|
80
|
-
export {
|
|
81
|
-
export const { Content: ListContent, Title: ListTitle, Description: ListDescription, Actions: ListActions, } = List;
|
|
65
|
+
export { TableContainer, TableRoot, TableRow, TableHeaderCell, TableSortHeader, TableCell, TableTruncate, TableMessage, };
|
|
82
66
|
export const { Caption: TableCaption, Head: TableHead, Body: TableBody, Foot: TableFoot, } = Table;
|
|
67
|
+
export { useTableSelection, } from './table-selection.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ComponentSizeAlias } from './sizing.js';
|
|
3
|
+
/** A multi-line text field. Inside Field.Root it takes the label, description and
|
|
4
|
+
* error from the field, as Input does. */
|
|
5
|
+
export declare const Textarea: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & {
|
|
6
|
+
size?: ComponentSizeAlias;
|
|
7
|
+
} & React.RefAttributes<HTMLTextAreaElement>>;
|
package/dist/textarea.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useComponentSize } from './sizing.js';
|
|
5
|
+
import { Field as BaseField } from '@base-ui/react/field';
|
|
6
|
+
import { cx } from './parts.js';
|
|
7
|
+
/** A multi-line text field. Inside Field.Root it takes the label, description and
|
|
8
|
+
* error from the field, as Input does. */
|
|
9
|
+
export const Textarea = /* @__PURE__ */ React.forwardRef(function Textarea({ className, size, rows, cols, wrap, ...props }, ref) {
|
|
10
|
+
const scheme = useComponentSize(size);
|
|
11
|
+
return (_jsx(BaseField.Control, { ...props, ref: ref, "data-ui-size": scheme, render: _jsx("textarea", { rows: rows, cols: cols, wrap: wrap }), className: cx('pui-input pui-textarea', className) }));
|
|
12
|
+
});
|
package/dist/toast.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Toast as BaseToast } from '@base-ui/react/toast';
|
|
2
|
+
import { Toast as BaseToast, type ToastManager, type ToastManagerAddOptions } from '@base-ui/react/toast';
|
|
3
3
|
import { type StatusTone } from './status.js';
|
|
4
4
|
export type ToastRootProps = React.ComponentPropsWithoutRef<typeof BaseToast.Root> & {
|
|
5
5
|
tone?: StatusTone;
|
|
@@ -57,3 +57,59 @@ export declare const ToastAction: React.ForwardRefExoticComponent<Omit<Omit<impo
|
|
|
57
57
|
} & React.RefAttributes<HTMLSpanElement>>, ToastText: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
|
|
58
58
|
size?: import("./sizing.js").ComponentSize;
|
|
59
59
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
60
|
+
/** What a toast() call takes besides its title. */
|
|
61
|
+
export type ToastOptions = Omit<ToastManagerAddOptions<object>, 'title' | 'type'> & {
|
|
62
|
+
/** A button in the toast, such as Undo. Shorthand for actionProps. */
|
|
63
|
+
action?: {
|
|
64
|
+
label: React.ReactNode;
|
|
65
|
+
onClick: () => void;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/** A promise step or an update: the options, with the title among them. */
|
|
69
|
+
export type ToastStep = ToastOptions & {
|
|
70
|
+
title?: React.ReactNode;
|
|
71
|
+
};
|
|
72
|
+
type PromiseStep<Value> = React.ReactNode | ToastStep | ((value: Value) => React.ReactNode | ToastStep);
|
|
73
|
+
export type ToastHelper = {
|
|
74
|
+
/** A neutral toast. Returns its ID, which update and dismiss take. */
|
|
75
|
+
(title: React.ReactNode, options?: ToastOptions): string;
|
|
76
|
+
info: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
77
|
+
success: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
78
|
+
warning: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
79
|
+
error: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
80
|
+
/** Stays until updated or dismissed. */
|
|
81
|
+
loading: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
82
|
+
/** A loading toast that turns into success or error when the promise settles. */
|
|
83
|
+
promise: <Value>(promise: Promise<Value>, steps: {
|
|
84
|
+
loading: React.ReactNode | ToastStep;
|
|
85
|
+
success: PromiseStep<Value>;
|
|
86
|
+
error: PromiseStep<unknown>;
|
|
87
|
+
}) => Promise<Value>;
|
|
88
|
+
update: (id: string, options: ToastStep) => void;
|
|
89
|
+
/** Closes one toast, or every toast without an ID. */
|
|
90
|
+
dismiss: (id?: string) => void;
|
|
91
|
+
/** The Base UI manager the Toaster reads. */
|
|
92
|
+
manager: ToastManager;
|
|
93
|
+
};
|
|
94
|
+
/** A toast helper with a manager of its own. Use the shared `toast` unless a region
|
|
95
|
+
* needs separate notifications. */
|
|
96
|
+
export declare function createToaster(): ToastHelper;
|
|
97
|
+
/** The shared toast helper: call toast.success('Saved') anywhere, with one Toaster
|
|
98
|
+
* in the app. */
|
|
99
|
+
export declare const toast: ToastHelper;
|
|
100
|
+
export type ToasterProps = Omit<ToastViewportProps, 'children'> & {
|
|
101
|
+
/** The helper whose toasts this renders. */
|
|
102
|
+
toast?: ToastHelper;
|
|
103
|
+
/** How many toasts stay visible; older ones wait. */
|
|
104
|
+
limit?: number;
|
|
105
|
+
/** Milliseconds before a toast closes, unless it sets its own. */
|
|
106
|
+
timeout?: number;
|
|
107
|
+
/** The notifications region's name. */
|
|
108
|
+
label?: string;
|
|
109
|
+
/** Directions a toast can be swiped away in. */
|
|
110
|
+
swipeDirection?: React.ComponentPropsWithoutRef<typeof BaseToast.Root>['swipeDirection'];
|
|
111
|
+
};
|
|
112
|
+
/** Renders a helper's toasts: the provider, the region and each toast. Put one in the
|
|
113
|
+
* app, then call toast() from anywhere. */
|
|
114
|
+
export declare function Toaster({ toast: helper, limit, timeout, label, swipeDirection, ...props }: ToasterProps): React.JSX.Element;
|
|
115
|
+
export {};
|
package/dist/toast.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { Icon } from './icon.js';
|
|
4
5
|
import { useComponentSize } from './sizing.js';
|
|
5
|
-
import { Toast as BaseToast } from '@base-ui/react/toast';
|
|
6
|
-
import { part, skin } from './parts.js';
|
|
6
|
+
import { Toast as BaseToast, } from '@base-ui/react/toast';
|
|
7
|
+
import { part, skin, cx } from './parts.js';
|
|
7
8
|
import { StatusIcon } from './status.js';
|
|
8
9
|
const ToneContext = /* @__PURE__ */ React.createContext('neutral');
|
|
9
10
|
const Root = /* @__PURE__ */ React.forwardRef(function Root({ tone = 'neutral', className, ...props }, ref) {
|
|
10
11
|
return (_jsx(ToneContext.Provider, { value: tone, children: _jsx(BaseToast.Root, { ...props, ref: ref, "data-tone": tone, className: skin('pui-toast', className) }) }));
|
|
11
12
|
});
|
|
12
|
-
const
|
|
13
|
+
const ToneIcon = /* @__PURE__ */ React.forwardRef(function ToastIcon({ tone, children, className, ...props }, ref) {
|
|
13
14
|
const inherited = React.useContext(ToneContext);
|
|
14
|
-
return (_jsx("span", { ...props, ref: ref, "aria-hidden": 'true', className:
|
|
15
|
+
return (_jsx("span", { ...props, ref: ref, "aria-hidden": 'true', className: cx('pui-toast-icon', className), children: children ?? _jsx(StatusIcon, { tone: tone ?? inherited }) }));
|
|
15
16
|
});
|
|
16
17
|
const Close = /* @__PURE__ */ React.forwardRef(function Close({ className, children, ...props }, ref) {
|
|
17
|
-
return (_jsx(BaseToast.Close, { "aria-label": 'Dismiss notification', "aria-hidden": false, "data-variant": 'ghost', "data-size": 'icon-sm', "data-ui-size": 'small', ...props, ref: ref, className: skin('pui-button pui-toast-close', className), children: children ??
|
|
18
|
+
return (_jsx(BaseToast.Close, { "aria-label": 'Dismiss notification', "aria-hidden": false, "data-variant": 'ghost', "data-size": 'icon-sm', "data-ui-size": 'small', ...props, ref: ref, className: skin('pui-button pui-toast-close', className), children: children ?? _jsx(Icon, { name: 'close' }) }));
|
|
18
19
|
});
|
|
19
20
|
const Action = /* @__PURE__ */ React.forwardRef(function Action({ className, ...props }, ref) {
|
|
20
21
|
return (_jsx(BaseToast.Action, { "data-variant": 'outline', "data-size": 'small', "data-ui-size": 'small', ...props, ref: ref, className: skin('pui-button pui-toast-action', className) }));
|
|
@@ -85,7 +86,7 @@ const Viewport = /* @__PURE__ */ React.forwardRef(function Viewport({ layout = '
|
|
|
85
86
|
export const Toast = {
|
|
86
87
|
...BaseToast,
|
|
87
88
|
Root,
|
|
88
|
-
Icon,
|
|
89
|
+
Icon: ToneIcon,
|
|
89
90
|
Close,
|
|
90
91
|
Action,
|
|
91
92
|
Viewport,
|
|
@@ -93,7 +94,78 @@ export const Toast = {
|
|
|
93
94
|
Title: /* @__PURE__ */ part(BaseToast.Title, 'pui-toast-title'),
|
|
94
95
|
Description: /* @__PURE__ */ part(BaseToast.Description, 'pui-toast-description'),
|
|
95
96
|
Text: /* @__PURE__ */ part('div', 'pui-toast-text'),
|
|
96
|
-
Positioner: /* @__PURE__ */ part(BaseToast.Positioner, 'pui-positioner'),
|
|
97
|
+
Positioner: /* @__PURE__ */ part(BaseToast.Positioner, 'pui-positioner', { portal: true }),
|
|
97
98
|
};
|
|
98
99
|
// Flat names for React Server Components, which cannot dot into client exports.
|
|
99
100
|
export const { Action: ToastAction, Arrow: ToastArrow, Close: ToastClose, Content: ToastContent, Description: ToastDescription, Portal: ToastPortal, Positioner: ToastPositioner, Provider: ToastProvider, Root: ToastRoot, Title: ToastTitle, Viewport: ToastViewport, Icon: ToastIcon, Text: ToastText, } = Toast;
|
|
101
|
+
// Event names, as other toast libraries call them, and the tones they show.
|
|
102
|
+
const tones = {
|
|
103
|
+
info: 'info',
|
|
104
|
+
success: 'success',
|
|
105
|
+
warning: 'caution',
|
|
106
|
+
caution: 'caution',
|
|
107
|
+
error: 'danger',
|
|
108
|
+
danger: 'danger',
|
|
109
|
+
loading: 'progress',
|
|
110
|
+
progress: 'progress',
|
|
111
|
+
};
|
|
112
|
+
const isOptions = (value) => typeof value === 'object' &&
|
|
113
|
+
value !== null &&
|
|
114
|
+
!React.isValidElement(value) &&
|
|
115
|
+
!Array.isArray(value);
|
|
116
|
+
function settle({ action, actionProps, ...rest }, type) {
|
|
117
|
+
return {
|
|
118
|
+
...rest,
|
|
119
|
+
...(type ? { type } : {}),
|
|
120
|
+
actionProps: action
|
|
121
|
+
? { ...actionProps, children: action.label, onClick: action.onClick }
|
|
122
|
+
: actionProps,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const step = (value, type, timeout) => settle(isOptions(value)
|
|
126
|
+
? { ...(timeout === undefined ? {} : { timeout }), ...value }
|
|
127
|
+
: {
|
|
128
|
+
title: value,
|
|
129
|
+
...(timeout === undefined ? {} : { timeout }),
|
|
130
|
+
}, type);
|
|
131
|
+
/** A toast helper with a manager of its own. Use the shared `toast` unless a region
|
|
132
|
+
* needs separate notifications. */
|
|
133
|
+
export function createToaster() {
|
|
134
|
+
const manager = BaseToast.createToastManager();
|
|
135
|
+
const add = (type, timeout) => (title, options = {}) => manager.add({
|
|
136
|
+
...(timeout === undefined ? {} : { timeout }),
|
|
137
|
+
...settle(options, type),
|
|
138
|
+
title,
|
|
139
|
+
});
|
|
140
|
+
return Object.assign(add(), {
|
|
141
|
+
info: add('info'),
|
|
142
|
+
success: add('success'),
|
|
143
|
+
warning: add('warning'),
|
|
144
|
+
error: add('error'),
|
|
145
|
+
loading: add('loading', 0),
|
|
146
|
+
promise: (promise, steps) => manager.promise(promise, {
|
|
147
|
+
loading: step(steps.loading, 'loading', 0),
|
|
148
|
+
success: (value) => step(typeof steps.success === 'function'
|
|
149
|
+
? steps.success(value)
|
|
150
|
+
: steps.success, 'success'),
|
|
151
|
+
error: (error) => step(typeof steps.error === 'function'
|
|
152
|
+
? steps.error(error)
|
|
153
|
+
: steps.error, 'error', 0),
|
|
154
|
+
}),
|
|
155
|
+
update: (id, options) => manager.update(id, settle(options)),
|
|
156
|
+
dismiss: (id) => manager.close(id),
|
|
157
|
+
manager,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/** The shared toast helper: call toast.success('Saved') anywhere, with one Toaster
|
|
161
|
+
* in the app. */
|
|
162
|
+
export const toast = /* @__PURE__ */ createToaster();
|
|
163
|
+
function ToastList({ swipeDirection }) {
|
|
164
|
+
const { toasts } = BaseToast.useToastManager();
|
|
165
|
+
return toasts.map((item) => (_jsx(Root, { toast: item, tone: tones[item.type ?? ''] ?? 'neutral', swipeDirection: swipeDirection, children: _jsxs(Toast.Content, { children: [_jsx(ToneIcon, {}), _jsxs(Toast.Text, { children: [_jsx(Toast.Title, {}), _jsx(Toast.Description, {}), _jsx(Action, {})] }), _jsx(Close, {})] }) }, item.id)));
|
|
166
|
+
}
|
|
167
|
+
/** Renders a helper's toasts: the provider, the region and each toast. Put one in the
|
|
168
|
+
* app, then call toast() from anywhere. */
|
|
169
|
+
export function Toaster({ toast: helper = toast, limit = 3, timeout = 5000, label = 'Notifications', swipeDirection, ...props }) {
|
|
170
|
+
return (_jsx(BaseToast.Provider, { toastManager: helper.manager, limit: limit, timeout: timeout, children: _jsx(BaseToast.Portal, { children: _jsx(Viewport, { "aria-label": label, ...props, children: _jsx(ToastList, { swipeDirection: swipeDirection }) }) }) }));
|
|
171
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ToggleGroup as BaseToggleGroup } from '@base-ui/react/toggle-group';
|
|
3
|
+
export declare function ToggleGroup<Value extends string>({ className, ref, ...props }: BaseToggleGroup.Props<Value> & {
|
|
4
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
5
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ToggleGroup as BaseToggleGroup } from '@base-ui/react/toggle-group';
|
|
4
|
+
import { skin } from './parts.js';
|
|
5
|
+
export function ToggleGroup({ className, ref, ...props }) {
|
|
6
|
+
return (_jsx(BaseToggleGroup, { ...props, ref: ref, className: skin('pui-toggle-group', className) }));
|
|
7
|
+
}
|
package/dist/toggle.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ComponentSizeAlias } from './sizing.js';
|
|
3
|
+
import { Toggle as BaseToggle } from '@base-ui/react/toggle';
|
|
4
|
+
export declare function Toggle<Value extends string>({ className, size, ref, ...props }: BaseToggle.Props<Value> & {
|
|
5
|
+
size?: ComponentSizeAlias | 'icon';
|
|
6
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
7
|
+
}): React.JSX.Element;
|
package/dist/toggle.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useComponentSize } from './sizing.js';
|
|
4
|
+
import { Toggle as BaseToggle } from '@base-ui/react/toggle';
|
|
5
|
+
import { sizeName, skin } from './parts.js';
|
|
6
|
+
export function Toggle({ className, size, ref, ...props }) {
|
|
7
|
+
const scheme = useComponentSize(size === 'icon' ? undefined : size);
|
|
8
|
+
return (_jsx(BaseToggle, { ...props, ref: ref, className: skin('pui-button pui-toggle', className), "data-size": sizeName(size), "data-ui-size": scheme }));
|
|
9
|
+
}
|