@ratio-ui/core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalogue.json +2690 -749
- package/dist/components/accordion/Accordion.d.ts +19 -0
- package/dist/components/accordion/Accordion.js +52 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/alert/Alert.d.ts +18 -0
- package/dist/components/alert/Alert.js +67 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/alert-dialog/AlertDialog.d.ts +48 -0
- package/dist/components/alert-dialog/AlertDialog.js +76 -0
- package/dist/components/alert-dialog/index.d.ts +2 -0
- package/dist/components/alert-dialog/index.js +1 -0
- package/dist/components/app-shell/AppShell.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.d.ts +19 -0
- package/dist/components/breadcrumb/Breadcrumb.js +50 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/calendar/Calendar.d.ts +20 -0
- package/dist/components/calendar/Calendar.js +119 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/chart/Chart.d.ts +137 -0
- package/dist/components/chart/Chart.js +238 -0
- package/dist/components/chart/index.d.ts +2 -0
- package/dist/components/chart/index.js +1 -0
- package/dist/components/checkbox-list/CheckboxList.d.ts +36 -0
- package/dist/components/checkbox-list/CheckboxList.js +93 -0
- package/dist/components/checkbox-list/index.d.ts +2 -0
- package/dist/components/checkbox-list/index.js +1 -0
- package/dist/components/collapsible/Collapsible.d.ts +24 -0
- package/dist/components/collapsible/Collapsible.js +58 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/combobox/Combobox.d.ts +52 -0
- package/dist/components/combobox/Combobox.js +92 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/data-table/DataTable.js +2 -2
- package/dist/components/date-picker/DatePicker.d.ts +34 -0
- package/dist/components/date-picker/DatePicker.js +108 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-range-picker/DateRangePicker.d.ts +40 -0
- package/dist/components/date-range-picker/DateRangePicker.js +146 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/date-range-picker/index.js +1 -0
- package/dist/components/drawer/Drawer.d.ts +52 -0
- package/dist/components/drawer/Drawer.js +120 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/field/Field.d.ts +38 -0
- package/dist/components/field/Field.js +73 -0
- package/dist/components/field/Label.d.ts +8 -0
- package/dist/components/field/Label.js +13 -0
- package/dist/components/field/index.d.ts +3 -0
- package/dist/components/field/index.js +3 -0
- package/dist/components/filter-tabs/FilterTabs.js +1 -1
- package/dist/components/global-search/GlobalSearch.js +1 -1
- package/dist/components/icon/registry.d.ts +2 -2
- package/dist/components/icon/registry.js +5 -1
- package/dist/components/input-group/InputGroup.js +1 -1
- package/dist/components/input-otp/InputOtp.d.ts +43 -0
- package/dist/components/input-otp/InputOtp.js +45 -0
- package/dist/components/input-otp/index.d.ts +2 -0
- package/dist/components/input-otp/index.js +1 -0
- package/dist/components/key-value-list/KeyValueList.d.ts +25 -0
- package/dist/components/key-value-list/KeyValueList.js +40 -0
- package/dist/components/key-value-list/index.d.ts +2 -0
- package/dist/components/key-value-list/index.js +1 -0
- package/dist/components/link/Link.d.ts +22 -0
- package/dist/components/link/Link.js +31 -0
- package/dist/components/link/index.d.ts +2 -0
- package/dist/components/link/index.js +1 -0
- package/dist/components/media-grid/MediaGrid.d.ts +49 -0
- package/dist/components/media-grid/MediaGrid.js +303 -0
- package/dist/components/media-grid/index.d.ts +2 -0
- package/dist/components/media-grid/index.js +1 -0
- package/dist/components/money-input/MoneyInput.d.ts +30 -0
- package/dist/components/money-input/MoneyInput.js +72 -0
- package/dist/components/money-input/index.d.ts +2 -0
- package/dist/components/money-input/index.js +1 -0
- package/dist/components/page-header/PageHeader.js +9 -9
- package/dist/components/progress/Progress.d.ts +25 -0
- package/dist/components/progress/Progress.js +38 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +1 -0
- package/dist/components/radio-group/RadioGroup.d.ts +18 -0
- package/dist/components/radio-group/RadioGroup.js +32 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/save-bar/SaveBar.d.ts +27 -0
- package/dist/components/save-bar/SaveBar.js +37 -0
- package/dist/components/save-bar/index.d.ts +2 -0
- package/dist/components/save-bar/index.js +1 -0
- package/dist/components/scroll-area/ScrollArea.d.ts +12 -0
- package/dist/components/scroll-area/ScrollArea.js +34 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.js +1 -0
- package/dist/components/search-field/SearchField.js +1 -1
- package/dist/components/select/Select.d.ts +40 -0
- package/dist/components/select/Select.js +84 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/separator/Separator.d.ts +15 -0
- package/dist/components/separator/Separator.js +25 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/index.js +1 -0
- package/dist/components/sheet/Sheet.d.ts +52 -0
- package/dist/components/sheet/Sheet.js +89 -0
- package/dist/components/sheet/index.d.ts +2 -0
- package/dist/components/sheet/index.js +1 -0
- package/dist/components/side-nav/SideNav.js +3 -3
- package/dist/components/summary-chips/SummaryChips.d.ts +17 -0
- package/dist/components/summary-chips/SummaryChips.js +19 -0
- package/dist/components/summary-chips/index.d.ts +2 -0
- package/dist/components/summary-chips/index.js +1 -0
- package/dist/components/switch/Switch.d.ts +10 -0
- package/dist/components/switch/Switch.js +20 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/table/Table.js +1 -1
- package/dist/components/tag-input/TagInput.d.ts +44 -0
- package/dist/components/tag-input/TagInput.js +102 -0
- package/dist/components/tag-input/index.d.ts +2 -0
- package/dist/components/tag-input/index.js +1 -0
- package/dist/components/textarea/Textarea.d.ts +15 -0
- package/dist/components/textarea/Textarea.js +21 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/top-bar/StoreSwitcher.js +1 -1
- package/dist/components/top-bar/TopBar.js +2 -2
- package/dist/components/unit-input/UnitInput.d.ts +33 -0
- package/dist/components/unit-input/UnitInput.js +47 -0
- package/dist/components/unit-input/index.d.ts +2 -0
- package/dist/components/unit-input/index.js +1 -0
- package/dist/index.d.ts +70 -9
- package/dist/index.js +38 -7
- package/dist/lib/cn.js +9 -2
- package/dist/lib/format.d.ts +65 -4
- package/dist/lib/format.js +163 -6
- package/dist/styles.css +1 -1
- package/package.json +129 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
/** The props of Accordion: Base UI's accordion props, except className, style and render. */
|
|
4
|
+
export type AccordionProps = Omit<Accordion.Root.Props, 'className' | 'style' | 'render'>;
|
|
5
|
+
/** The props of AccordionItem: Base UI's item props, except className, style and render. Give each a value. */
|
|
6
|
+
export type AccordionItemProps = Omit<Accordion.Item.Props, 'className' | 'style' | 'render'>;
|
|
7
|
+
/** The props of AccordionTrigger: Base UI's trigger props, except className, style and render. */
|
|
8
|
+
export type AccordionTriggerProps = Omit<Accordion.Trigger.Props, 'className' | 'style' | 'render'>;
|
|
9
|
+
/** The props of AccordionContent: Base UI's panel props, except className, style and render. */
|
|
10
|
+
export type AccordionContentProps = Omit<Accordion.Panel.Props, 'className' | 'style' | 'render'>;
|
|
11
|
+
/** A stack of sections that open and close. One section is open at a time unless multiple is set. */
|
|
12
|
+
declare function Accordion$1({ ...props }: AccordionProps): JSX.Element;
|
|
13
|
+
/** One section: a trigger and its content, separated from the next by a hairline. */
|
|
14
|
+
export declare function AccordionItem({ ...props }: AccordionItemProps): JSX.Element;
|
|
15
|
+
/** The heading row of a section, with a chevron that turns when it is open. */
|
|
16
|
+
export declare function AccordionTrigger({ children, ...props }: AccordionTriggerProps): JSX.Element;
|
|
17
|
+
/** The body of a section. It appears and disappears at once, with no height animation. */
|
|
18
|
+
export declare function AccordionContent({ children, ...props }: AccordionContentProps): JSX.Element;
|
|
19
|
+
export { Accordion$1 as Accordion };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/accordion/Accordion.tsx
|
|
6
|
+
/** A stack of sections that open and close. One section is open at a time unless multiple is set. */
|
|
7
|
+
function Accordion$1({ ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(Accordion.Root, {
|
|
9
|
+
"data-slot": "accordion",
|
|
10
|
+
className: "rt:flex rt:w-full rt:flex-col",
|
|
11
|
+
...props
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/** One section: a trigger and its content, separated from the next by a hairline. */
|
|
15
|
+
function AccordionItem({ ...props }) {
|
|
16
|
+
return /* @__PURE__ */ jsx(Accordion.Item, {
|
|
17
|
+
"data-slot": "accordion-item",
|
|
18
|
+
className: "rt:not-last:border-b rt:not-last:border-divider",
|
|
19
|
+
...props
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** The heading row of a section, with a chevron that turns when it is open. */
|
|
23
|
+
function AccordionTrigger({ children, ...props }) {
|
|
24
|
+
return /* @__PURE__ */ jsx(Accordion.Header, {
|
|
25
|
+
className: "rt:flex",
|
|
26
|
+
children: /* @__PURE__ */ jsxs(Accordion.Trigger, {
|
|
27
|
+
"data-slot": "accordion-trigger",
|
|
28
|
+
className: cn("rt:group/accordion-trigger rt:flex rt:flex-1 rt:cursor-pointer rt:items-center rt:justify-between rt:gap-2 rt:rounded-lg rt:bg-transparent rt:py-2.75 rt:text-left rt:text-b4 rt:text-foreground rt:outline-none", "rt:focus-visible:focus-ring rt:forced-outline", "rt:disabled:cursor-not-allowed rt:disabled:opacity-50 rt:data-disabled:cursor-not-allowed rt:data-disabled:opacity-50"),
|
|
29
|
+
...props,
|
|
30
|
+
children: [children, /* @__PURE__ */ jsx("span", {
|
|
31
|
+
className: "rt:flex rt:shrink-0 rt:rotate-0 rt:text-muted-foreground rt:group-aria-expanded/accordion-trigger:rotate-180",
|
|
32
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
33
|
+
name: "nav-chevron",
|
|
34
|
+
size: 12
|
|
35
|
+
})
|
|
36
|
+
})]
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** The body of a section. It appears and disappears at once, with no height animation. */
|
|
41
|
+
function AccordionContent({ children, ...props }) {
|
|
42
|
+
return /* @__PURE__ */ jsx(Accordion.Panel, {
|
|
43
|
+
"data-slot": "accordion-content",
|
|
44
|
+
className: "rt:overflow-hidden rt:text-b3 rt:text-foreground",
|
|
45
|
+
...props,
|
|
46
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: "rt:pb-2.75",
|
|
48
|
+
children
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export { Accordion$1 as Accordion, AccordionContent, AccordionItem, AccordionTrigger };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Accordion, AccordionContent, AccordionContentProps, AccordionItem, AccordionItemProps, AccordionProps, AccordionTrigger, AccordionTriggerProps } from "./Accordion.js";
|
|
2
|
+
export { Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "./Accordion.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HTMLAttributes, JSX, ReactNode, Ref } from "react";
|
|
2
|
+
/** The tone of an alert. Critical uses the question 1 tokens. */
|
|
3
|
+
export type AlertTone = 'info' | 'success' | 'warning' | 'critical';
|
|
4
|
+
/** The props of Alert: the HTML attributes of its div, except className, style, children and title. */
|
|
5
|
+
export type AlertProps = Omit<HTMLAttributes<HTMLDivElement>, 'className' | 'style' | 'children' | 'title'> & {
|
|
6
|
+
/** The tone. Defaults to info. */
|
|
7
|
+
tone?: AlertTone;
|
|
8
|
+
/** An optional bold first line. */
|
|
9
|
+
title?: ReactNode;
|
|
10
|
+
/** An optional second line. */
|
|
11
|
+
description?: ReactNode;
|
|
12
|
+
/** An optional action on the right, usually one Button. */
|
|
13
|
+
action?: ReactNode;
|
|
14
|
+
/** Receives the rendered div. */
|
|
15
|
+
ref?: Ref<HTMLDivElement>;
|
|
16
|
+
};
|
|
17
|
+
/** A message that stays in the page: a tone glyph, an optional title and description, and an optional action. */
|
|
18
|
+
export declare function Alert({ tone, title, description, action, ref, ...rest }: AlertProps): JSX.Element;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import { Text } from "../text/Text.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/alert/Alert.tsx
|
|
6
|
+
const TONES = {
|
|
7
|
+
info: {
|
|
8
|
+
box: "rt:bg-primary-tint rt:border-primary-tint",
|
|
9
|
+
glyph: "rt:text-primary",
|
|
10
|
+
icon: "info-circle"
|
|
11
|
+
},
|
|
12
|
+
success: {
|
|
13
|
+
box: "rt:bg-success-tint rt:border-success-border",
|
|
14
|
+
glyph: "rt:text-success",
|
|
15
|
+
icon: "check"
|
|
16
|
+
},
|
|
17
|
+
warning: {
|
|
18
|
+
box: "rt:bg-warning-tint rt:border-warning-border",
|
|
19
|
+
glyph: "rt:text-warning",
|
|
20
|
+
icon: "alert-triangle"
|
|
21
|
+
},
|
|
22
|
+
critical: {
|
|
23
|
+
box: "rt:bg-alert-critical-background rt:border-alert-critical-border rt:text-alert-critical-foreground",
|
|
24
|
+
glyph: "rt:text-error-icon",
|
|
25
|
+
icon: "alert-triangle"
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/** A message that stays in the page: a tone glyph, an optional title and description, and an optional action. */
|
|
29
|
+
function Alert({ tone = "info", title, description, action, ref, ...rest }) {
|
|
30
|
+
const t = TONES[tone];
|
|
31
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
32
|
+
role: tone === "warning" || tone === "critical" ? "alert" : "status",
|
|
33
|
+
"data-slot": "alert",
|
|
34
|
+
...rest,
|
|
35
|
+
ref,
|
|
36
|
+
"data-tone": tone,
|
|
37
|
+
className: cn("rt:flex rt:w-full rt:min-w-0 rt:items-start rt:gap-2 rt:rounded-lg rt:border rt:px-3 rt:py-2 rt:text-left rt:text-foreground", t.box),
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx("span", {
|
|
40
|
+
className: cn("rt:mt-0.5 rt:shrink-0", t.glyph),
|
|
41
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
42
|
+
name: t.icon,
|
|
43
|
+
size: 16
|
|
44
|
+
})
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ jsxs("div", {
|
|
47
|
+
className: "rt:flex rt:min-w-0 rt:flex-1 rt:flex-col rt:gap-0.5",
|
|
48
|
+
children: [title ? /* @__PURE__ */ jsx(Text, {
|
|
49
|
+
as: "p",
|
|
50
|
+
variant: "b4",
|
|
51
|
+
tone: tone === "critical" ? "inherit" : "default",
|
|
52
|
+
children: title
|
|
53
|
+
}) : null, description ? /* @__PURE__ */ jsx(Text, {
|
|
54
|
+
as: "p",
|
|
55
|
+
tone: tone === "critical" ? "inherit" : "subdued",
|
|
56
|
+
children: description
|
|
57
|
+
}) : null]
|
|
58
|
+
}),
|
|
59
|
+
action ? /* @__PURE__ */ jsx("div", {
|
|
60
|
+
"data-slot": "alert-action",
|
|
61
|
+
className: "rt:shrink-0",
|
|
62
|
+
children: action
|
|
63
|
+
}) : null
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export { Alert };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Alert } from "./Alert.js";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ButtonVariant } from "../button/Button.js";
|
|
2
|
+
import "../button/index.js";
|
|
3
|
+
import { ComponentProps, JSX } from "react";
|
|
4
|
+
import { AlertDialog } from "@base-ui/react/alert-dialog";
|
|
5
|
+
/**
|
|
6
|
+
* The root of a confirmation. It holds the open state and renders nothing itself. Pass `open` and `onOpenChange` to
|
|
7
|
+
* control it, or `defaultOpen` to leave it uncontrolled. Escape closes it; a click outside does not.
|
|
8
|
+
*/
|
|
9
|
+
declare function AlertDialog$1(props: AlertDialog.Root.Props): JSX.Element;
|
|
10
|
+
/** Props of AlertDialogTrigger. */
|
|
11
|
+
export type AlertDialogTriggerProps = Omit<AlertDialog.Trigger.Props, 'className' | 'style'>;
|
|
12
|
+
/** The button that opens the confirmation. */
|
|
13
|
+
export declare function AlertDialogTrigger(props: AlertDialogTriggerProps): JSX.Element;
|
|
14
|
+
/** Props of AlertDialogContent. */
|
|
15
|
+
export type AlertDialogContentProps = Omit<AlertDialog.Popup.Props, 'className' | 'style'>;
|
|
16
|
+
/**
|
|
17
|
+
* The panel: 480px wide, white, drawn with the ring outline and no shadow, with no scrim behind it. Put
|
|
18
|
+
* AlertDialogHeader and AlertDialogFooter inside.
|
|
19
|
+
*/
|
|
20
|
+
export declare function AlertDialogContent(props: AlertDialogContentProps): JSX.Element;
|
|
21
|
+
/** Props of AlertDialogHeader. */
|
|
22
|
+
export type AlertDialogHeaderProps = Omit<ComponentProps<'div'>, 'className' | 'style'>;
|
|
23
|
+
/** The title and description, stacked. */
|
|
24
|
+
export declare function AlertDialogHeader(props: AlertDialogHeaderProps): JSX.Element;
|
|
25
|
+
/** Props of AlertDialogFooter. */
|
|
26
|
+
export type AlertDialogFooterProps = Omit<ComponentProps<'div'>, 'className' | 'style'>;
|
|
27
|
+
/** The row of actions at the bottom, aligned to the end. */
|
|
28
|
+
export declare function AlertDialogFooter(props: AlertDialogFooterProps): JSX.Element;
|
|
29
|
+
/** Props of AlertDialogTitle. */
|
|
30
|
+
export type AlertDialogTitleProps = Omit<AlertDialog.Title.Props, 'className' | 'style'>;
|
|
31
|
+
/** The question, in the b4 style. It names the dialog for assistive technology. */
|
|
32
|
+
export declare function AlertDialogTitle(props: AlertDialogTitleProps): JSX.Element;
|
|
33
|
+
/** Props of AlertDialogDescription. */
|
|
34
|
+
export type AlertDialogDescriptionProps = Omit<AlertDialog.Description.Props, 'className' | 'style'>;
|
|
35
|
+
/** What will happen, in subdued body text. */
|
|
36
|
+
export declare function AlertDialogDescription(props: AlertDialogDescriptionProps): JSX.Element;
|
|
37
|
+
/** Props of AlertDialogAction. */
|
|
38
|
+
export interface AlertDialogActionProps extends Omit<AlertDialog.Close.Props, 'className' | 'style' | 'render'> {
|
|
39
|
+
/** The Button look. Defaults to destructive; use main for a confirmation that deletes nothing. */
|
|
40
|
+
variant?: Extract<ButtonVariant, 'destructive' | 'main'>;
|
|
41
|
+
}
|
|
42
|
+
/** The confirming button. It is the Button's destructive variant and closes the dialog after its onClick runs. */
|
|
43
|
+
export declare function AlertDialogAction({ variant, ...props }: AlertDialogActionProps): JSX.Element;
|
|
44
|
+
/** Props of AlertDialogCancel. */
|
|
45
|
+
export type AlertDialogCancelProps = Omit<AlertDialog.Close.Props, 'className' | 'style' | 'render'>;
|
|
46
|
+
/** The secondary button that closes the dialog without doing anything. */
|
|
47
|
+
export declare function AlertDialogCancel(props: AlertDialogCancelProps): JSX.Element;
|
|
48
|
+
export { AlertDialog$1 as AlertDialog };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Button } from "../button/Button.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { AlertDialog } from "@base-ui/react/alert-dialog";
|
|
4
|
+
// src/components/alert-dialog/AlertDialog.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The root of a confirmation. It holds the open state and renders nothing itself. Pass `open` and `onOpenChange` to
|
|
7
|
+
* control it, or `defaultOpen` to leave it uncontrolled. Escape closes it; a click outside does not.
|
|
8
|
+
*/
|
|
9
|
+
function AlertDialog$1(props) {
|
|
10
|
+
return /* @__PURE__ */ jsx(AlertDialog.Root, { ...props });
|
|
11
|
+
}
|
|
12
|
+
/** The button that opens the confirmation. */
|
|
13
|
+
function AlertDialogTrigger(props) {
|
|
14
|
+
return /* @__PURE__ */ jsx(AlertDialog.Trigger, {
|
|
15
|
+
"data-slot": "alert-dialog-trigger",
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The panel: 480px wide, white, drawn with the ring outline and no shadow, with no scrim behind it. Put
|
|
21
|
+
* AlertDialogHeader and AlertDialogFooter inside.
|
|
22
|
+
*/
|
|
23
|
+
function AlertDialogContent(props) {
|
|
24
|
+
return /* @__PURE__ */ jsx(AlertDialog.Portal, { children: /* @__PURE__ */ jsx(AlertDialog.Popup, {
|
|
25
|
+
"data-slot": "alert-dialog-content",
|
|
26
|
+
className: "rt:fixed rt:inset-0 rt:z-50 rt:m-auto rt:flex rt:h-fit rt:max-h-full rt:w-120 rt:max-w-full rt:overflow-y-auto rt:flex-col rt:gap-6 rt:rounded-lg rt:bg-popover rt:p-6 rt:text-b3 rt:text-popover-foreground rt:shadow-ring-strong rt:forced-outline rt:focus-visible:focus-ring",
|
|
27
|
+
...props
|
|
28
|
+
}) });
|
|
29
|
+
}
|
|
30
|
+
/** The title and description, stacked. */
|
|
31
|
+
function AlertDialogHeader(props) {
|
|
32
|
+
return /* @__PURE__ */ jsx("div", {
|
|
33
|
+
"data-slot": "alert-dialog-header",
|
|
34
|
+
className: "rt:flex rt:flex-col rt:gap-1",
|
|
35
|
+
...props
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/** The row of actions at the bottom, aligned to the end. */
|
|
39
|
+
function AlertDialogFooter(props) {
|
|
40
|
+
return /* @__PURE__ */ jsx("div", {
|
|
41
|
+
"data-slot": "alert-dialog-footer",
|
|
42
|
+
className: "rt:flex rt:items-center rt:justify-end rt:gap-2",
|
|
43
|
+
...props
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** The question, in the b4 style. It names the dialog for assistive technology. */
|
|
47
|
+
function AlertDialogTitle(props) {
|
|
48
|
+
return /* @__PURE__ */ jsx(AlertDialog.Title, {
|
|
49
|
+
"data-slot": "alert-dialog-title",
|
|
50
|
+
className: "rt:text-b4 rt:text-foreground-strong",
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** What will happen, in subdued body text. */
|
|
55
|
+
function AlertDialogDescription(props) {
|
|
56
|
+
return /* @__PURE__ */ jsx(AlertDialog.Description, {
|
|
57
|
+
"data-slot": "alert-dialog-description",
|
|
58
|
+
className: "rt:text-b3 rt:text-foreground-subdued",
|
|
59
|
+
...props
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** The confirming button. It is the Button's destructive variant and closes the dialog after its onClick runs. */
|
|
63
|
+
function AlertDialogAction({ variant = "destructive", ...props }) {
|
|
64
|
+
return /* @__PURE__ */ jsx(AlertDialog.Close, {
|
|
65
|
+
render: /* @__PURE__ */ jsx(Button, { variant }),
|
|
66
|
+
...props
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** The secondary button that closes the dialog without doing anything. */
|
|
70
|
+
function AlertDialogCancel(props) {
|
|
71
|
+
return /* @__PURE__ */ jsx(AlertDialog.Close, {
|
|
72
|
+
render: /* @__PURE__ */ jsx(Button, { variant: "secondary" }),
|
|
73
|
+
...props
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
export { AlertDialog$1 as AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AlertDialog, AlertDialogAction, AlertDialogActionProps, AlertDialogCancel, AlertDialogCancelProps, AlertDialogContent, AlertDialogContentProps, AlertDialogDescription, AlertDialogDescriptionProps, AlertDialogFooter, AlertDialogFooterProps, AlertDialogHeader, AlertDialogHeaderProps, AlertDialogTitle, AlertDialogTitleProps, AlertDialogTrigger, AlertDialogTriggerProps } from "./AlertDialog.js";
|
|
2
|
+
export { AlertDialog, AlertDialogAction, type AlertDialogActionProps, AlertDialogCancel, type AlertDialogCancelProps, AlertDialogContent, type AlertDialogContentProps, AlertDialogDescription, type AlertDialogDescriptionProps, AlertDialogFooter, type AlertDialogFooterProps, AlertDialogHeader, type AlertDialogHeaderProps, AlertDialogTitle, type AlertDialogTitleProps, AlertDialogTrigger, type AlertDialogTriggerProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "./AlertDialog.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ShellNavContext } from "./context.js";
|
|
2
|
-
import { useId, useState } from "react";
|
|
3
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
4
|
// src/components/app-shell/AppShell.tsx
|
|
5
5
|
/**
|
|
6
6
|
* The frame of every page: the side nav at the left, the top bar above and the content below it. It fills the height of its
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { JSX, Ref } from "react";
|
|
2
|
+
/** One step of the trail. The last item, or any item without an href, is shown as plain text; the last is the current page. */
|
|
3
|
+
export type BreadcrumbItem = {
|
|
4
|
+
/** The text of the step. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Where the step goes. Leave out for the current page. */
|
|
7
|
+
href?: string;
|
|
8
|
+
};
|
|
9
|
+
/** The props of Breadcrumb. */
|
|
10
|
+
export type BreadcrumbProps = {
|
|
11
|
+
/** The trail, from the root to the current page. */
|
|
12
|
+
items: BreadcrumbItem[];
|
|
13
|
+
/** Past this many items the middle ones collapse behind an ellipsis, keeping the first and the last two. */
|
|
14
|
+
maxItems?: number;
|
|
15
|
+
/** Receives the rendered nav. */
|
|
16
|
+
ref?: Ref<HTMLElement>;
|
|
17
|
+
};
|
|
18
|
+
/** The trail to the current page: links, chevron separators, the current page as text and an overflow ellipsis. */
|
|
19
|
+
export declare function Breadcrumb({ items, maxItems, ref }: BreadcrumbProps): JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import { RatioLink } from "../link-provider/RatioLink.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
// src/components/breadcrumb/Breadcrumb.tsx
|
|
7
|
+
const STEP = "rt:text-b3 rt:rounded-sm rt:focus-visible:focus-ring";
|
|
8
|
+
/** The trail to the current page: links, chevron separators, the current page as text and an overflow ellipsis. */
|
|
9
|
+
function Breadcrumb({ items, maxItems, ref }) {
|
|
10
|
+
const [expanded, setExpanded] = useState(false);
|
|
11
|
+
const shown = !expanded && maxItems !== void 0 && items.length > maxItems && items.length > 3 ? [
|
|
12
|
+
items[0],
|
|
13
|
+
"ellipsis",
|
|
14
|
+
...items.slice(items.length - 2)
|
|
15
|
+
] : items;
|
|
16
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
17
|
+
ref,
|
|
18
|
+
"aria-label": "Breadcrumb",
|
|
19
|
+
"data-slot": "breadcrumb",
|
|
20
|
+
children: /* @__PURE__ */ jsx("ol", {
|
|
21
|
+
className: "rt:flex rt:flex-wrap rt:items-center rt:gap-2 rt:text-foreground-subdued",
|
|
22
|
+
children: shown.map((item, i) => {
|
|
23
|
+
const isLast = i === shown.length - 1;
|
|
24
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
25
|
+
className: "rt:inline-flex rt:items-center rt:gap-2",
|
|
26
|
+
children: [item === "ellipsis" ? /* @__PURE__ */ jsx("button", {
|
|
27
|
+
type: "button",
|
|
28
|
+
"aria-label": "Show hidden pages",
|
|
29
|
+
onClick: () => setExpanded(true),
|
|
30
|
+
className: cn(STEP, "rt:px-1 rt:transition-colors rt:hover:text-foreground"),
|
|
31
|
+
children: "…"
|
|
32
|
+
}) : isLast || !item.href ? /* @__PURE__ */ jsx("span", {
|
|
33
|
+
...isLast ? { "aria-current": "page" } : {},
|
|
34
|
+
className: cn(STEP, isLast ? "rt:text-foreground" : ""),
|
|
35
|
+
children: item.label
|
|
36
|
+
}) : /* @__PURE__ */ jsx(RatioLink, {
|
|
37
|
+
href: item.href,
|
|
38
|
+
className: cn(STEP, "rt:transition-colors rt:hover:text-foreground"),
|
|
39
|
+
children: item.label
|
|
40
|
+
}), !isLast && /* @__PURE__ */ jsx(Icon, {
|
|
41
|
+
name: "chevron-right",
|
|
42
|
+
size: 8,
|
|
43
|
+
tone: "icon"
|
|
44
|
+
})]
|
|
45
|
+
}, item === "ellipsis" ? "ellipsis" : `${item.label}|${item.href ?? ""}`);
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export { Breadcrumb };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Breadcrumb } from "./Breadcrumb.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JSX } from "react";
|
|
2
|
+
import { DayPickerProps } from "react-day-picker";
|
|
3
|
+
/** Omit for each member of a union, so the selection modes of DayPicker stay a discriminated union. */
|
|
4
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
5
|
+
/**
|
|
6
|
+
* Props of Calendar: DayPicker's props (mode, selected, onSelect, defaultMonth, month, today, disabled, startMonth,
|
|
7
|
+
* endMonth, numberOfMonths, showOutsideDays, locale, labels and the rest), without the ones that restyle it, replace its
|
|
8
|
+
* parts, change how a date is written or animate it: the calendar is drawn by the design system, dates are written by
|
|
9
|
+
* the format module and motion is a colour fade only.
|
|
10
|
+
*/
|
|
11
|
+
export type CalendarProps = DistributiveOmit<DayPickerProps, 'className' | 'style' | 'classNames' | 'styles' | 'modifiersClassNames' | 'modifiersStyles' | 'components' | 'formatters' | 'captionLayout' | 'animate' | 'showWeekNumber'>;
|
|
12
|
+
/**
|
|
13
|
+
* A month grid to pick a day or a range of days, drawn by the design system: 28px days with a 6px radius, today in the
|
|
14
|
+
* accent ink, the selected day filled with the accent, a range as accent ends on a tinted band, disabled days at 50% and
|
|
15
|
+
* the days of the months around it in the muted ink. Every day is named in the format module's date order (28/10/2026).
|
|
16
|
+
* Arrow keys move between days and the previous and next buttons between months. It has no fill of its own, so it sits
|
|
17
|
+
* in a popover or a container as drawn.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Calendar({ showOutsideDays, labels, ...props }: CalendarProps): JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Icon } from "../icon/Icon.js";
|
|
2
|
+
import { Button } from "../button/Button.js";
|
|
3
|
+
import { FORMAT, formatDate } from "../../lib/format.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect, useRef } from "react";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { DayPicker } from "react-day-picker";
|
|
8
|
+
// src/components/calendar/Calendar.tsx
|
|
9
|
+
const dayButtonVariants = cva("rt:flex rt:size-7 rt:items-center rt:justify-center rt:border-0 rt:p-0 rt:select-none rt:cursor-pointer rt:transition-colors rt:focus-visible:focus-ring rt:disabled:pointer-events-none rt:disabled:cursor-not-allowed rt:disabled:opacity-50", {
|
|
10
|
+
variants: { look: {
|
|
11
|
+
plain: "rt:rounded-md rt:bg-transparent rt:text-btn rt:text-foreground rt:hover:bg-muted rt:active:bg-muted",
|
|
12
|
+
today: "rt:rounded-md rt:bg-transparent rt:text-c3 rt:text-primary rt:hover:bg-muted rt:active:bg-muted",
|
|
13
|
+
outside: "rt:rounded-md rt:bg-transparent rt:text-btn rt:text-muted-foreground rt:hover:bg-muted rt:active:bg-muted",
|
|
14
|
+
selected: "rt:rounded-md rt:bg-primary rt:text-btn rt:text-primary-foreground rt:hover:bg-primary-hover rt:active:bg-primary-hover",
|
|
15
|
+
"range-middle": "rt:rounded-none rt:group-first:rounded-l-md rt:group-last:rounded-r-md rt:bg-primary-tint rt:text-btn rt:text-foreground"
|
|
16
|
+
} },
|
|
17
|
+
defaultVariants: { look: "plain" }
|
|
18
|
+
});
|
|
19
|
+
/** The look of a day from DayPicker's modifiers: a selection wins over outside, and outside over today. */
|
|
20
|
+
function dayLook(modifiers) {
|
|
21
|
+
if (modifiers.range_middle) return "range-middle";
|
|
22
|
+
if (modifiers.selected) return "selected";
|
|
23
|
+
if (modifiers.outside) return "outside";
|
|
24
|
+
if (modifiers.today) return "today";
|
|
25
|
+
return "plain";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The number in a day's button, written as the date pattern writes the day (two digits for DD), so the visible text is a
|
|
29
|
+
* word of the button's name (WCAG 2.5.3): 03 in 03/10/2026.
|
|
30
|
+
*/
|
|
31
|
+
function formatDay(date) {
|
|
32
|
+
const day = String(date.getDate());
|
|
33
|
+
return FORMAT.datePattern.includes("DD") ? day.padStart(2, "0") : day;
|
|
34
|
+
}
|
|
35
|
+
/** A day as an accessible name, in the format module's date order: "Today, 28/10/2026, selected". */
|
|
36
|
+
function labelDay(date, modifiers) {
|
|
37
|
+
return `${modifiers?.today ? "Today, " : ""}${formatDate(date)}${modifiers?.selected ? ", selected" : ""}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The button of one day. DayPicker moves focus between days, so the button takes focus when its day is focused. Its look
|
|
41
|
+
* comes after DayPicker's props, so it replaces DayPicker's class name.
|
|
42
|
+
*/
|
|
43
|
+
function CalendarDayButton({ day, modifiers, ...props }) {
|
|
44
|
+
const ref = useRef(null);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (modifiers.focused) ref.current?.focus();
|
|
47
|
+
}, [modifiers.focused]);
|
|
48
|
+
return /* @__PURE__ */ jsx("button", {
|
|
49
|
+
ref,
|
|
50
|
+
...props,
|
|
51
|
+
"data-day": formatDate(day.date),
|
|
52
|
+
className: dayButtonVariants({ look: dayLook(modifiers) })
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** A month navigation button: the ghost Button with a chevron, disabled at the first or last allowed month. */
|
|
56
|
+
function navButton(icon) {
|
|
57
|
+
return function CalendarNavButton({ onClick, tabIndex, "aria-label": label, "aria-disabled": ariaDisabled }) {
|
|
58
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
59
|
+
variant: "ghost",
|
|
60
|
+
iconOnly: true,
|
|
61
|
+
"aria-label": label ?? "",
|
|
62
|
+
disabled: ariaDisabled === true || ariaDisabled === "true",
|
|
63
|
+
tabIndex,
|
|
64
|
+
onClick,
|
|
65
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
66
|
+
name: icon,
|
|
67
|
+
size: 12
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const PreviousMonthButton = navButton("chevron-left");
|
|
73
|
+
const NextMonthButton = navButton("chevron-right");
|
|
74
|
+
const CLASS_NAMES = {
|
|
75
|
+
root: "rt:relative rt:w-fit rt:p-2 rt:text-foreground",
|
|
76
|
+
months: "rt:relative rt:flex rt:flex-col rt:gap-4 rt:md:flex-row",
|
|
77
|
+
month: "rt:flex rt:w-full rt:flex-col rt:gap-2",
|
|
78
|
+
nav: "rt:absolute rt:inset-x-0 rt:top-0 rt:z-10 rt:flex rt:w-full rt:items-center rt:justify-between rt:gap-1",
|
|
79
|
+
month_caption: "rt:flex rt:h-7 rt:w-full rt:items-center rt:justify-center rt:px-7",
|
|
80
|
+
caption_label: "rt:text-c3 rt:text-foreground rt:select-none",
|
|
81
|
+
month_grid: "rt:w-full rt:border-collapse",
|
|
82
|
+
weekdays: "rt:flex",
|
|
83
|
+
weekday: "rt:flex rt:w-7 rt:items-center rt:justify-center rt:text-c1 rt:text-muted-foreground rt:select-none",
|
|
84
|
+
week: "rt:mt-1 rt:flex rt:w-full",
|
|
85
|
+
day: "rt:relative rt:size-7 rt:p-0 rt:text-center rt:select-none rt:first:rounded-l-md rt:last:rounded-r-md rt:group",
|
|
86
|
+
range_start: "rt:rounded-l-md rt:bg-primary-tint",
|
|
87
|
+
range_end: "rt:rounded-r-md rt:bg-primary-tint",
|
|
88
|
+
hidden: "rt:invisible",
|
|
89
|
+
footer: "rt:pt-2 rt:text-c1 rt:text-muted-foreground"
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* A month grid to pick a day or a range of days, drawn by the design system: 28px days with a 6px radius, today in the
|
|
93
|
+
* accent ink, the selected day filled with the accent, a range as accent ends on a tinted band, disabled days at 50% and
|
|
94
|
+
* the days of the months around it in the muted ink. Every day is named in the format module's date order (28/10/2026).
|
|
95
|
+
* Arrow keys move between days and the previous and next buttons between months. It has no fill of its own, so it sits
|
|
96
|
+
* in a popover or a container as drawn.
|
|
97
|
+
*/
|
|
98
|
+
function Calendar({ showOutsideDays = true, labels, ...props }) {
|
|
99
|
+
return /* @__PURE__ */ jsx(DayPicker, {
|
|
100
|
+
"data-slot": "calendar",
|
|
101
|
+
showOutsideDays,
|
|
102
|
+
classNames: CLASS_NAMES,
|
|
103
|
+
components: {
|
|
104
|
+
DayButton: CalendarDayButton,
|
|
105
|
+
PreviousMonthButton,
|
|
106
|
+
NextMonthButton
|
|
107
|
+
},
|
|
108
|
+
formatters: { formatDay },
|
|
109
|
+
labels: {
|
|
110
|
+
labelDayButton: labelDay,
|
|
111
|
+
labelGridcell: labelDay,
|
|
112
|
+
labelPrevious: () => "Previous month",
|
|
113
|
+
labelNext: () => "Next month",
|
|
114
|
+
...labels
|
|
115
|
+
},
|
|
116
|
+
...props
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export { Calendar };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Calendar } from "./Calendar.js";
|