@ksojecki/purpose-ui 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +123 -2
- package/assets/fonts/Karla[wght].ttf +0 -0
- package/assets/fonts/OFL.txt +93 -0
- package/dist/Alert-D-5k0maf.js +23 -0
- package/dist/Button-T8UI5igR.js +112 -0
- package/dist/Dropdown-BZKzAbKB.js +56 -0
- package/dist/Heading-CWDWXU_n.js +27 -0
- package/dist/IconButton-P7nSooA3.js +18 -0
- package/dist/Link-9mNYgEzY.js +36 -0
- package/dist/Paragraph-DFwfb2Yt.js +14 -0
- package/dist/Switch-CI8vMkGz.js +84 -0
- package/dist/actions/Button.d.ts +69 -0
- package/dist/actions/ButtonGroup.d.ts +20 -0
- package/dist/actions/IconActionButtons.d.ts +34 -0
- package/dist/actions/IconButton.d.ts +21 -0
- package/dist/actions/index.d.ts +10 -0
- package/dist/actions/index.js +41 -0
- package/dist/classNames-x6JVYA2t.js +5 -0
- package/dist/data/DataTable.d.ts +47 -0
- package/dist/data/Metric.d.ts +46 -0
- package/dist/data/Table.d.ts +33 -0
- package/dist/data/index.d.ts +8 -0
- package/dist/data/index.js +85 -0
- package/dist/feedback/Alert.d.ts +23 -0
- package/dist/feedback/Badge.d.ts +23 -0
- package/dist/feedback/ConfirmDeletePanel.d.ts +32 -0
- package/dist/feedback/EmptyState.d.ts +22 -0
- package/dist/feedback/Progress.d.ts +24 -0
- package/dist/feedback/Skeleton.d.ts +10 -0
- package/dist/feedback/Spinner.d.ts +16 -0
- package/dist/feedback/Toast.d.ts +48 -0
- package/dist/feedback/Tooltip.d.ts +21 -0
- package/dist/feedback/index.d.ts +15 -0
- package/dist/feedback/index.js +138 -0
- package/dist/forms/Checkbox.d.ts +16 -0
- package/dist/forms/DatePicker.d.ts +51 -0
- package/dist/forms/Field.d.ts +65 -0
- package/dist/forms/FileInput.d.ts +20 -0
- package/dist/forms/FilterBar.d.ts +21 -0
- package/dist/forms/FilterRow.d.ts +20 -0
- package/dist/forms/FormActions.d.ts +28 -0
- package/dist/forms/FormField.d.ts +39 -0
- package/dist/forms/Input.d.ts +20 -0
- package/dist/forms/Radio.d.ts +52 -0
- package/dist/forms/Range.d.ts +24 -0
- package/dist/forms/SegmentedControl.d.ts +33 -0
- package/dist/forms/Select.d.ts +23 -0
- package/dist/forms/Switch.d.ts +15 -0
- package/dist/forms/Textarea.d.ts +20 -0
- package/dist/forms/TimePicker.d.ts +29 -0
- package/dist/forms/index.d.ts +21 -0
- package/dist/forms/index.js +429 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +2 -0
- package/dist/icons-CMOARHwx.js +18 -0
- package/dist/internal/classNames.d.ts +1 -0
- package/dist/internal/purpose.d.ts +7 -0
- package/dist/layout/BottomSheet.d.ts +25 -0
- package/dist/layout/Card.d.ts +22 -0
- package/dist/layout/Disclosure.d.ts +18 -0
- package/dist/layout/Divider.d.ts +16 -0
- package/dist/layout/Page/Content.d.ts +11 -0
- package/dist/layout/Page/Page.d.ts +6 -0
- package/dist/layout/Page/index.d.ts +19 -0
- package/dist/layout/PageContainer.d.ts +18 -0
- package/dist/layout/PageHeader.d.ts +25 -0
- package/dist/layout/Section.d.ts +22 -0
- package/dist/layout/index.d.ts +13 -0
- package/dist/layout/index.js +173 -0
- package/dist/navigation/Dropdown.d.ts +47 -0
- package/dist/navigation/Link.d.ts +32 -0
- package/dist/navigation/Menu.d.ts +89 -0
- package/dist/navigation/NavMenu.d.ts +56 -0
- package/dist/navigation/index.d.ts +9 -0
- package/dist/navigation/index.js +128 -0
- package/dist/navigation/popoverFade.d.ts +5 -0
- package/dist/overlays/ConsentBanner/ConsentBanner.d.ts +35 -0
- package/dist/overlays/ConsentBanner/index.d.ts +1 -0
- package/dist/overlays/ConsentSettings/ConsentSettings.d.ts +48 -0
- package/dist/overlays/ConsentSettings/index.d.ts +1 -0
- package/dist/overlays/ModalWindow/ModalWindow.d.ts +60 -0
- package/dist/overlays/ModalWindow/index.d.ts +3 -0
- package/dist/overlays/index.d.ts +8 -0
- package/dist/overlays/index.js +195 -0
- package/dist/typography/Heading/Heading.d.ts +24 -0
- package/dist/typography/Heading/index.d.ts +1 -0
- package/dist/typography/Paragraph.d.ts +16 -0
- package/dist/typography/Prose.d.ts +17 -0
- package/dist/typography/index.d.ts +8 -0
- package/dist/typography/index.js +12 -0
- package/package.json +121 -4
- package/styles/budget.css +9 -0
- package/styles/generic.css +9 -0
- package/styles/roadsign.css +9 -0
- package/styles/traffic.css +9 -0
- package/theme.css +341 -0
- package/themes/budget.css +103 -0
- package/themes/generic.css +103 -0
- package/themes/roadsign.css +103 -0
- package/themes/traffic.css +103 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type ActionPurpose } from '../internal/purpose';
|
|
3
|
+
export type ButtonTone = 'default' | 'primary' | 'secondary' | 'ghost' | 'neutral' | 'info' | 'success' | 'warning' | 'error';
|
|
4
|
+
export type ButtonVariant = 'solid' | 'soft' | 'outline';
|
|
5
|
+
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
6
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
fullWidth?: boolean;
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
/** Semantic action meaning. Apps should prefer `purpose` over `tone`. */
|
|
11
|
+
purpose?: ActionPurpose;
|
|
12
|
+
size?: ButtonSize;
|
|
13
|
+
/** Square icon-only button. */
|
|
14
|
+
square?: boolean;
|
|
15
|
+
/** Explicit override of the purpose tone. */
|
|
16
|
+
tone?: ButtonTone;
|
|
17
|
+
/** Explicit override of the purpose variant. */
|
|
18
|
+
variant?: ButtonVariant;
|
|
19
|
+
}
|
|
20
|
+
export interface ButtonClassOptions {
|
|
21
|
+
className?: string;
|
|
22
|
+
fullWidth?: boolean;
|
|
23
|
+
purpose?: ActionPurpose;
|
|
24
|
+
size?: ButtonSize;
|
|
25
|
+
square?: boolean;
|
|
26
|
+
tone?: ButtonTone;
|
|
27
|
+
variant?: ButtonVariant;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Default size for the buttons and links rendered inside it. An explicit `size` prop still wins.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <ButtonSizeProvider size="sm">
|
|
35
|
+
* <Button>Small button</Button>
|
|
36
|
+
* <Link asButton to="/new">
|
|
37
|
+
* Small link
|
|
38
|
+
* </Link>
|
|
39
|
+
* </ButtonSizeProvider>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function ButtonSizeProvider({ size, children }: {
|
|
43
|
+
size: ButtonSize;
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
46
|
+
/** Explicit size, else the nearest `ButtonSizeProvider`, else `md`. */
|
|
47
|
+
export declare function useButtonSize(size?: ButtonSize): ButtonSize;
|
|
48
|
+
/** Explicit `tone`/`variant` win, then `purpose`, then primary/solid. */
|
|
49
|
+
export declare function resolveButtonStyle({ purpose, tone, variant, }: Pick<ButtonClassOptions, 'purpose' | 'tone' | 'variant'>): {
|
|
50
|
+
tone: ButtonTone;
|
|
51
|
+
variant: ButtonVariant;
|
|
52
|
+
};
|
|
53
|
+
/** Class string for any button-styled element. Shared by `Button` and `Link` with `asButton`. */
|
|
54
|
+
export declare function buttonClassName({ className, fullWidth, purpose, size, square, tone, variant, }: ButtonClassOptions): string;
|
|
55
|
+
/**
|
|
56
|
+
* Reusable button component for shared UI actions across applications.
|
|
57
|
+
* Resolution: explicit `tone`/`variant` win, then `purpose`, then primary/solid.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* <Button purpose="save" type="submit">
|
|
62
|
+
* Save
|
|
63
|
+
* </Button>
|
|
64
|
+
* <Button isLoading purpose="save">
|
|
65
|
+
* Saving
|
|
66
|
+
* </Button>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const Button: ({ children, className, disabled, fullWidth, isLoading, purpose, size: sizeProp, square, tone, variant, ...props }: ButtonProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface ButtonGroupProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
/** Accessible name of the group; omit for a plain container. */
|
|
6
|
+
label?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Joins its children (buttons, links, icon buttons, badges) into one segmented strip.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <ButtonGroup label="Range">
|
|
14
|
+
* <Button tone="neutral">Day</Button>
|
|
15
|
+
* <Button tone="neutral">Week</Button>
|
|
16
|
+
* <Button tone="neutral">Month</Button>
|
|
17
|
+
* </ButtonGroup>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function ButtonGroup({ children, className, label }: ButtonGroupProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type IconButtonProps } from './IconButton';
|
|
2
|
+
import type { ButtonTone } from './Button';
|
|
3
|
+
type IconActionButtonProps = Omit<IconButtonProps, 'icon' | 'tone' | 'variant'> & {
|
|
4
|
+
tone?: ButtonTone;
|
|
5
|
+
variant?: IconButtonProps['variant'];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Icon button with a pencil, for editing an item. Neutral and soft by default.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <EditButton label="Edit invoice" onClick={() => edit(invoice.id)} />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function EditButton({ tone, variant, ...props }: IconActionButtonProps): import("react").JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* Icon button with a trash can, for deleting an item. Error and soft by default.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <DeleteButton label="Delete invoice" onClick={() => remove(invoice.id)} />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function DeleteButton({ tone, variant, ...props }: IconActionButtonProps): import("react").JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* Icon button with a plus, for creating an item. Primary and soft by default.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <NewButton label="New invoice" onClick={create} />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function NewButton({ tone, variant, ...props }: IconActionButtonProps): import("react").JSX.Element;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { type ButtonSize, type ButtonTone, type ButtonVariant } from './Button';
|
|
3
|
+
import type { ActionPurpose } from '../internal/purpose';
|
|
4
|
+
export type IconButtonSize = Extract<ButtonSize, 'xs' | 'sm' | 'md'>;
|
|
5
|
+
export interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
icon: ReactNode;
|
|
7
|
+
label: string;
|
|
8
|
+
purpose?: ActionPurpose;
|
|
9
|
+
size?: IconButtonSize;
|
|
10
|
+
tone?: ButtonTone;
|
|
11
|
+
variant?: ButtonVariant;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Square icon-only button. `label` is its accessible name and tooltip. Without `purpose` or `tone` it is a ghost button.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <IconButton icon={<TbSearch />} label="Search" onClick={openSearch} />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function IconButton({ icon, label, purpose, size, tone, variant, className, ...props }: IconButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Buttons, icon buttons and button groups.
|
|
3
|
+
*
|
|
4
|
+
* @module @ksojecki/purpose-ui/actions
|
|
5
|
+
*/
|
|
6
|
+
export * from './Button';
|
|
7
|
+
export * from './ButtonGroup';
|
|
8
|
+
export * from './IconButton';
|
|
9
|
+
export * from './IconActionButtons';
|
|
10
|
+
export * from '../internal/purpose';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { a as e, i as t, n, r, s as i, t as a } from "../Button-T8UI5igR.js";
|
|
2
|
+
import { t as o } from "../classNames-x6JVYA2t.js";
|
|
3
|
+
import { t as s } from "../IconButton-P7nSooA3.js";
|
|
4
|
+
import { t as c } from "../icons-CMOARHwx.js";
|
|
5
|
+
import { Children as l, cloneElement as u, isValidElement as d } from "react";
|
|
6
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
7
|
+
// src/actions/ButtonGroup.tsx
|
|
8
|
+
function p({ children: e, className: t, label: n }) {
|
|
9
|
+
return /* @__PURE__ */ f("div", {
|
|
10
|
+
"aria-label": n,
|
|
11
|
+
className: o("join", t),
|
|
12
|
+
role: n ? "group" : void 0,
|
|
13
|
+
children: l.map(e, (e) => d(e) ? u(e, { className: o("join-item", e.props.className) }) : e)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
// src/actions/IconActionButtons.tsx
|
|
17
|
+
function m({ tone: e = "neutral", variant: t = e === "ghost" ? "solid" : "soft", ...n }) {
|
|
18
|
+
return /* @__PURE__ */ f(s, {
|
|
19
|
+
...n,
|
|
20
|
+
icon: /* @__PURE__ */ f(c.TbPencil, {}),
|
|
21
|
+
tone: e,
|
|
22
|
+
variant: t
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function h({ tone: e = "error", variant: t = e === "ghost" ? "solid" : "soft", ...n }) {
|
|
26
|
+
return /* @__PURE__ */ f(s, {
|
|
27
|
+
...n,
|
|
28
|
+
icon: /* @__PURE__ */ f(c.TbTrash, {}),
|
|
29
|
+
tone: e,
|
|
30
|
+
variant: t
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function g({ tone: e = "primary", variant: t = e === "ghost" ? "solid" : "soft", ...n }) {
|
|
34
|
+
return /* @__PURE__ */ f(s, {
|
|
35
|
+
...n,
|
|
36
|
+
icon: /* @__PURE__ */ f(c.TbPlus, {}),
|
|
37
|
+
tone: e,
|
|
38
|
+
variant: t
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export { i as ACTION_PURPOSES, a as Button, p as ButtonGroup, n as ButtonSizeProvider, h as DeleteButton, m as EditButton, s as IconButton, g as NewButton, r as buttonClassName, t as resolveButtonStyle, e as useButtonSize };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Key, ReactNode } from 'react';
|
|
2
|
+
import { type TableProps } from './Table';
|
|
3
|
+
export interface DataTableColumn<T> {
|
|
4
|
+
/** Property read from each row. Omit it for computed columns and give `id` and `render` instead. */
|
|
5
|
+
key?: keyof T & string;
|
|
6
|
+
/** Identifies a column without `key`. */
|
|
7
|
+
id?: string;
|
|
8
|
+
/** Header content. Defaults to the humanised `key`. */
|
|
9
|
+
header?: ReactNode;
|
|
10
|
+
/** `number` right-aligns the column with tabular, non-wrapping figures. */
|
|
11
|
+
kind?: 'text' | 'number';
|
|
12
|
+
/** Formats the raw property value. */
|
|
13
|
+
format?: (value: T[keyof T], row: T) => ReactNode;
|
|
14
|
+
/** Renders the whole cell content from the row; wins over `format`. */
|
|
15
|
+
render?: (row: T) => ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Hides the header visually but keeps it for screen readers, for action columns. */
|
|
18
|
+
srOnlyHeader?: boolean;
|
|
19
|
+
hidden?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface DataTableProps<T extends object> extends Omit<TableProps, 'children'> {
|
|
22
|
+
rows: readonly T[];
|
|
23
|
+
/** One column per property of the first row when omitted. */
|
|
24
|
+
columns?: ReadonlyArray<DataTableColumn<T>>;
|
|
25
|
+
/** Defaults to `row.id`, then the row index. */
|
|
26
|
+
getRowKey?: (row: T, index: number) => Key;
|
|
27
|
+
/** Rendered instead of the table when there are no rows. */
|
|
28
|
+
empty?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Table driven by plain objects: pass `rows` and optional `columns`, not markup.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <DataTable
|
|
36
|
+
* columns={[
|
|
37
|
+
* { key: 'name' },
|
|
38
|
+
* { key: 'quantity', kind: 'number' },
|
|
39
|
+
* { id: 'status', header: 'Status', render: (row) => <Badge purpose="success">{row.status}</Badge> },
|
|
40
|
+
* ]}
|
|
41
|
+
* empty="No items."
|
|
42
|
+
* label="Items"
|
|
43
|
+
* rows={items}
|
|
44
|
+
* />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function DataTable<T extends object>({ rows, columns, getRowKey, empty, ...tableProps }: DataTableProps<T>): import("react").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import type { StatusPurpose } from '../internal/purpose';
|
|
3
|
+
export interface MetricGroupProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
/** Stacks the stats vertically. Default is horizontal, as daisyUI does. */
|
|
7
|
+
vertical?: boolean;
|
|
8
|
+
/** Stacks the stats below the `sm` breakpoint and lays them out in a row from `sm` up. Wins over `vertical`. */
|
|
9
|
+
responsive?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type MetricAppearance = 'default' | 'boxed';
|
|
12
|
+
export interface MetricProps extends ComponentPropsWithoutRef<'div'> {
|
|
13
|
+
label: ReactNode;
|
|
14
|
+
value: ReactNode;
|
|
15
|
+
description?: ReactNode;
|
|
16
|
+
figure?: ReactNode;
|
|
17
|
+
/** `boxed` draws a bordered card around the figure. Default has no frame. */
|
|
18
|
+
appearance?: MetricAppearance;
|
|
19
|
+
/** Colour of the value. Omit for the default text colour. */
|
|
20
|
+
tone?: StatusPurpose;
|
|
21
|
+
/** Extra classes for the stat container, such as padding. */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** Extra classes for the value, such as a font size. */
|
|
24
|
+
valueClassName?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Container for `Metric` items. Lay out with Tailwind classes passed in `className`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <MetricGroup responsive>
|
|
32
|
+
* <Metric label="Items" value="128" />
|
|
33
|
+
* <Metric label="Out of stock" tone="error" value="5" />
|
|
34
|
+
* </MetricGroup>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const MetricGroup: ({ children, className, responsive, vertical, }: MetricGroupProps) => import("react").JSX.Element;
|
|
38
|
+
/**
|
|
39
|
+
* One figure: a label, a value, and optional description and figure. `appearance="boxed"` frames it as a card.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <Metric appearance="boxed" description="vs. last month" label="Stock growth" tone="success" value="+12%" />
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const Metric: ({ appearance, className, description, figure, label, tone, value, valueClassName, ...rest }: MetricProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from 'react';
|
|
2
|
+
export type TableSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
|
+
export interface TableProps extends ComponentPropsWithRef<'table'> {
|
|
4
|
+
/** Density of rows and cells. Defaults to `sm`. */
|
|
5
|
+
tableSize?: TableSize;
|
|
6
|
+
zebra?: boolean;
|
|
7
|
+
/** Classes for the scrolling wrapper `div`. */
|
|
8
|
+
wrapperClassName?: string;
|
|
9
|
+
/** Accessible name for the scrolling wrapper. Without it the wrapper is not a focusable region. */
|
|
10
|
+
label?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Shared data table. The wrapper scrolls horizontally on narrow screens.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <Table label="Invoices" zebra>
|
|
18
|
+
* <thead>
|
|
19
|
+
* <tr>
|
|
20
|
+
* <th>Number</th>
|
|
21
|
+
* <th>Total</th>
|
|
22
|
+
* </tr>
|
|
23
|
+
* </thead>
|
|
24
|
+
* <tbody>
|
|
25
|
+
* <tr>
|
|
26
|
+
* <td>FV/1/2026</td>
|
|
27
|
+
* <td>120.00</td>
|
|
28
|
+
* </tr>
|
|
29
|
+
* </tbody>
|
|
30
|
+
* </Table>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function Table({ tableSize, zebra, wrapperClassName, className, children, label, ...props }: TableProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { t as e } from "../classNames-x6JVYA2t.js";
|
|
2
|
+
import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
|
+
// src/data/Table.tsx
|
|
4
|
+
var i = {
|
|
5
|
+
xs: "table-xs",
|
|
6
|
+
sm: "table-sm",
|
|
7
|
+
md: "",
|
|
8
|
+
lg: "table-lg"
|
|
9
|
+
};
|
|
10
|
+
function a({ tableSize: t = "sm", zebra: r = !1, wrapperClassName: a, className: o, children: s, label: c, ...l }) {
|
|
11
|
+
return /* @__PURE__ */ n("div", {
|
|
12
|
+
"aria-label": c,
|
|
13
|
+
className: e("overflow-x-auto", a),
|
|
14
|
+
role: c ? "region" : void 0,
|
|
15
|
+
tabIndex: c ? 0 : void 0,
|
|
16
|
+
children: /* @__PURE__ */ n("table", {
|
|
17
|
+
...l,
|
|
18
|
+
className: e("table", i[t], r ? "table-zebra" : void 0, "w-full", o),
|
|
19
|
+
children: s
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// src/data/DataTable.tsx
|
|
24
|
+
var o = "whitespace-nowrap text-right tabular-nums", s = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase().replace(/^./, (e) => e.toUpperCase()), c = (e, t) => e.id ?? e.key ?? String(t);
|
|
25
|
+
function l(e) {
|
|
26
|
+
return e[0] ? Object.keys(e[0]).map((e) => ({ key: e })) : [];
|
|
27
|
+
}
|
|
28
|
+
function u(e, t) {
|
|
29
|
+
if (e.render) return e.render(t);
|
|
30
|
+
if (!e.key) return null;
|
|
31
|
+
let n = t[e.key];
|
|
32
|
+
return e.format ? e.format(n, t) : n == null ? "" : String(n);
|
|
33
|
+
}
|
|
34
|
+
function d({ rows: i, columns: d, getRowKey: f = (e, t) => e.id ?? t, empty: p, ...m }) {
|
|
35
|
+
if (i.length === 0 && p !== void 0) return /* @__PURE__ */ n(t, { children: p });
|
|
36
|
+
let h = (d ?? l(i)).filter((e) => !e.hidden);
|
|
37
|
+
return /* @__PURE__ */ r(a, {
|
|
38
|
+
...m,
|
|
39
|
+
children: [/* @__PURE__ */ n("thead", { children: /* @__PURE__ */ n("tr", { children: h.map((t, r) => /* @__PURE__ */ n("th", {
|
|
40
|
+
className: e(t.kind === "number" ? "text-right" : void 0, t.className),
|
|
41
|
+
children: t.srOnlyHeader ? /* @__PURE__ */ n("span", {
|
|
42
|
+
className: "sr-only",
|
|
43
|
+
children: t.header
|
|
44
|
+
}) : t.header ?? (t.key ? s(t.key) : null)
|
|
45
|
+
}, c(t, r))) }) }), /* @__PURE__ */ n("tbody", { children: i.map((t, r) => /* @__PURE__ */ n("tr", { children: h.map((r, i) => /* @__PURE__ */ n("td", {
|
|
46
|
+
className: e(r.kind === "number" ? o : void 0, r.className),
|
|
47
|
+
children: u(r, t)
|
|
48
|
+
}, c(r, i))) }, f(t, r))) })]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// src/data/Metric.tsx
|
|
52
|
+
var f = {
|
|
53
|
+
default: void 0,
|
|
54
|
+
boxed: "rounded-box border border-base-300 bg-base-100"
|
|
55
|
+
}, p = {
|
|
56
|
+
info: "text-info",
|
|
57
|
+
success: "text-success",
|
|
58
|
+
warning: "text-warning",
|
|
59
|
+
error: "text-error"
|
|
60
|
+
}, m = ({ children: t, className: r, responsive: i = !1, vertical: a = !1 }) => /* @__PURE__ */ n("div", {
|
|
61
|
+
className: e("stats", i ? "stats-vertical sm:stats-horizontal" : a ? "stats-vertical" : void 0, r),
|
|
62
|
+
children: t
|
|
63
|
+
}), h = ({ appearance: t = "default", className: i, description: a, figure: o, label: s, tone: c, value: l, valueClassName: u, ...d }) => /* @__PURE__ */ r("div", {
|
|
64
|
+
...d,
|
|
65
|
+
className: e("stat", f[t], i),
|
|
66
|
+
children: [
|
|
67
|
+
o ? /* @__PURE__ */ n("div", {
|
|
68
|
+
className: "stat-figure",
|
|
69
|
+
children: o
|
|
70
|
+
}) : null,
|
|
71
|
+
/* @__PURE__ */ n("div", {
|
|
72
|
+
className: "stat-title",
|
|
73
|
+
children: s
|
|
74
|
+
}),
|
|
75
|
+
/* @__PURE__ */ n("div", {
|
|
76
|
+
className: e("stat-value", c ? p[c] : void 0, u),
|
|
77
|
+
children: l
|
|
78
|
+
}),
|
|
79
|
+
a ? /* @__PURE__ */ n("div", {
|
|
80
|
+
className: "stat-desc",
|
|
81
|
+
children: a
|
|
82
|
+
}) : null
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
export { d as DataTable, h as Metric, m as MetricGroup, a as Table };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { StatusPurpose } from '../internal/purpose';
|
|
3
|
+
export type AlertVariant = 'solid' | 'soft';
|
|
4
|
+
export interface AlertProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/** Set to false for static notices: no live region is rendered and no role is set. */
|
|
6
|
+
announce?: boolean;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Semantic meaning of the alert. Colour and default live region role are derived from it. */
|
|
9
|
+
purpose?: StatusPurpose;
|
|
10
|
+
variant?: AlertVariant;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Shared inline message. Pass `role` to override the purpose default.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <Alert purpose="success">Saved.</Alert>
|
|
18
|
+
* <Alert announce={false} purpose="info" variant="soft">
|
|
19
|
+
* Prices include VAT.
|
|
20
|
+
* </Alert>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const Alert: ({ announce, children, className, purpose, role, variant, ...props }: AlertProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { StatusPurpose } from '../internal/purpose';
|
|
3
|
+
export type BadgePurpose = StatusPurpose | 'neutral';
|
|
4
|
+
export type BadgeSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
5
|
+
export type BadgeVariant = 'solid' | 'soft' | 'outline';
|
|
6
|
+
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Semantic meaning of the badge. Colour is derived from it. */
|
|
9
|
+
purpose?: BadgePurpose;
|
|
10
|
+
size?: BadgeSize;
|
|
11
|
+
variant?: BadgeVariant;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Shared status label. Use `purpose` for meaning, never a colour class.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <Badge purpose="success" size="sm">
|
|
19
|
+
* Paid
|
|
20
|
+
* </Badge>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const Badge: ({ children, className, purpose, size, variant, ...props }: BadgeProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface ConfirmDeletePanelProps {
|
|
3
|
+
/** Content shown before the warning, such as a reassignment choice. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
/** Non-announced warning about what the delete does. */
|
|
7
|
+
warning?: ReactNode;
|
|
8
|
+
/** Error from the last attempt, announced as an alert. */
|
|
9
|
+
error?: ReactNode;
|
|
10
|
+
/** Disables both buttons while the delete request runs. */
|
|
11
|
+
saving?: boolean;
|
|
12
|
+
cancelLabel: string;
|
|
13
|
+
confirmLabel: string;
|
|
14
|
+
onCancel: () => void;
|
|
15
|
+
onConfirm: () => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Inline confirmation for a destructive action: optional content, warning, error, then cancel and delete.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <ConfirmDeletePanel
|
|
23
|
+
* cancelLabel="Keep"
|
|
24
|
+
* confirmLabel="Delete"
|
|
25
|
+
* onCancel={close}
|
|
26
|
+
* onConfirm={remove}
|
|
27
|
+
* saving={isDeleting}
|
|
28
|
+
* warning="The invoice and its payments are removed."
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const ConfirmDeletePanel: ({ cancelLabel, children, className, confirmLabel, error, onCancel, onConfirm, saving, warning, }: ConfirmDeletePanelProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface EmptyStateProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
/** Short heading above the message. */
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
/** Optional call to action rendered below the message. */
|
|
7
|
+
action?: ReactNode;
|
|
8
|
+
/** `sm` for small inline lists and charts. */
|
|
9
|
+
size?: 'sm' | 'md';
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Placeholder for a list or panel with nothing to show.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <EmptyState action={<NewButton label="New invoice" />} title="No invoices yet">
|
|
18
|
+
* Create the first one to get started.
|
|
19
|
+
* </EmptyState>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const EmptyState: ({ action, children, className, size, title, }: EmptyStateProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import type { StatusPurpose } from '../internal/purpose';
|
|
3
|
+
export type ProgressPurpose = StatusPurpose | 'neutral';
|
|
4
|
+
export interface ProgressProps extends Omit<ComponentPropsWithoutRef<'progress'>, 'value' | 'max'> {
|
|
5
|
+
/** Accessible name announced with the value. Required. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Upper bound of the meter. Defaults to 100. */
|
|
8
|
+
max?: number;
|
|
9
|
+
/** Position of a thin tick over the bar, in the same unit as `max`. Clamped into [0, max]. */
|
|
10
|
+
marker?: number;
|
|
11
|
+
/** Semantic meaning of the meter. Colour is derived from it. */
|
|
12
|
+
purpose?: ProgressPurpose;
|
|
13
|
+
/** Current amount. Clamped into [0, max]. */
|
|
14
|
+
value: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Determinate meter. Pass `label` so assistive tech can name it.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <Progress label="Budget used" marker={80} purpose="warning" value={64} />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const Progress: ({ className, label, marker, max, purpose, value, ...rest }: ProgressProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Placeholder block for loading content. Size it with Tailwind classes.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <Skeleton className="h-4 w-48" />
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare const Skeleton: ({ className, ...rest }: ComponentPropsWithoutRef<'div'>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export type SpinnerSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
|
+
export interface SpinnerProps extends ComponentPropsWithoutRef<'span'> {
|
|
4
|
+
/** Announced text. Without it the spinner is decorative and hidden from assistive tech. */
|
|
5
|
+
label?: string;
|
|
6
|
+
size?: SpinnerSize;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Loading indicator. Pass `label` when it stands for a state the user waits on.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <Spinner label="Loading invoices" size="sm" />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const Spinner: ({ className, label, size, ...rest }: SpinnerProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { StatusPurpose } from '../internal/purpose';
|
|
3
|
+
export type ToastPosition = 'top-end' | 'bottom-end' | 'bottom-center';
|
|
4
|
+
export interface ToastRegionProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Corner or edge the toasts stack in. Defaults to bottom-end. */
|
|
8
|
+
position?: ToastPosition;
|
|
9
|
+
}
|
|
10
|
+
interface ToastBaseProps {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
purpose?: StatusPurpose;
|
|
13
|
+
}
|
|
14
|
+
/** A dismissable toast needs both the handler and the accessible name of its button. */
|
|
15
|
+
export type ToastProps = ToastBaseProps & ({
|
|
16
|
+
dismissLabel?: undefined;
|
|
17
|
+
onDismiss?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
dismissLabel: string;
|
|
20
|
+
onDismiss: () => void;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Live region for toasts. Toasts inside it are announced politely.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <ToastRegion position="top-end">
|
|
28
|
+
* {toasts.map((toast) => (
|
|
29
|
+
* <Toast key={toast.id} purpose={toast.purpose}>
|
|
30
|
+
* {toast.text}
|
|
31
|
+
* </Toast>
|
|
32
|
+
* ))}
|
|
33
|
+
* </ToastRegion>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const ToastRegion: ({ children, className, position }: ToastRegionProps) => import("react").JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* One toast message. The region announces routine status; warnings and errors keep their assertive alert role.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <Toast dismissLabel="Dismiss" onDismiss={dismiss} purpose="success">
|
|
43
|
+
* Invoice sent.
|
|
44
|
+
* </Toast>
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare const Toast: ({ children, dismissLabel, onDismiss, purpose }: ToastProps) => import("react").JSX.Element;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactElement } from 'react';
|
|
2
|
+
export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
export interface TooltipProps extends ComponentPropsWithoutRef<'span'> {
|
|
4
|
+
/** A single focusable element. The tip shows on hover and, in daisyUI, on focus. */
|
|
5
|
+
children: ReactElement<{
|
|
6
|
+
'aria-describedby'?: string;
|
|
7
|
+
}>;
|
|
8
|
+
position?: TooltipPosition;
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Shows `text` on the child. The text is also linked to the child via `aria-describedby`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <Tooltip text="Includes VAT">
|
|
17
|
+
* <Button tone="ghost">Total</Button>
|
|
18
|
+
* </Tooltip>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const Tooltip: ({ children, className, position, text, ...rest }: TooltipProps) => import("react").JSX.Element;
|