canny-ui-react 1.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordion/Accordion.d.ts +32 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/Alert/Alert.types.d.ts +8 -0
- package/dist/components/Autocomplete/Autocomplete.d.ts +19 -0
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +71 -0
- package/dist/components/Autocomplete/index.d.ts +2 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +14 -0
- package/dist/components/Breadcrumb/index.d.ts +2 -0
- package/dist/components/Chip/Chip.d.ts +37 -0
- package/dist/components/Chip/index.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +31 -0
- package/dist/components/CommandPalette/CommandPalette.types.d.ts +71 -0
- package/dist/components/CommandPalette/index.d.ts +2 -0
- package/dist/components/DatePicker/DatePicker.d.ts +2 -0
- package/dist/components/DatePicker/DatePicker.types.d.ts +83 -0
- package/dist/components/DatePicker/dateUtils.d.ts +28 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/Dialog/Dialog.d.ts +34 -0
- package/dist/components/Dialog/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.d.ts +35 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/Layout/AspectRatio.d.ts +11 -0
- package/dist/components/Layout/Center.d.ts +7 -0
- package/dist/components/Layout/Grid.d.ts +7 -1
- package/dist/components/Layout/Group.d.ts +10 -0
- package/dist/components/Layout/index.d.ts +6 -0
- package/dist/components/List/List.d.ts +42 -0
- package/dist/components/List/index.d.ts +2 -0
- package/dist/components/Menu/Menu.d.ts +51 -0
- package/dist/components/Menu/index.d.ts +2 -0
- package/dist/components/Pagination/Pagination.d.ts +22 -0
- package/dist/components/Pagination/index.d.ts +2 -0
- package/dist/components/Popover/Popover.d.ts +24 -0
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Slider/Slider.d.ts +15 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Stepper/Stepper.d.ts +16 -0
- package/dist/components/Stepper/index.d.ts +2 -0
- package/dist/components/Tabs/Tabs.d.ts +34 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Toast/Toast.d.ts +15 -0
- package/dist/components/Toast/Toast.types.d.ts +57 -0
- package/dist/components/Toast/index.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +46 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/index.cjs +98 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.js +8248 -4204
- package/dist/index.js.map +1 -1
- package/package.json +21 -16
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
3
|
+
type RootSingle = ComponentPropsWithoutRef<typeof AccordionPrimitive.Root> & {
|
|
4
|
+
type: 'single';
|
|
5
|
+
};
|
|
6
|
+
type RootMultiple = ComponentPropsWithoutRef<typeof AccordionPrimitive.Root> & {
|
|
7
|
+
type: 'multiple';
|
|
8
|
+
};
|
|
9
|
+
export type AccordionProps = (RootSingle | RootMultiple) & {
|
|
10
|
+
variant?: 'plain' | 'bordered' | 'separated';
|
|
11
|
+
};
|
|
12
|
+
export declare const Accordion: import("react").ForwardRefExoticComponent<((Omit<AccordionPrimitive.AccordionSingleProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
13
|
+
type: "single";
|
|
14
|
+
} & {
|
|
15
|
+
variant?: "plain" | "bordered" | "separated";
|
|
16
|
+
}) | (Omit<AccordionPrimitive.AccordionMultipleProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
17
|
+
type: "multiple";
|
|
18
|
+
} & {
|
|
19
|
+
variant?: "plain" | "bordered" | "separated";
|
|
20
|
+
})) & import("react").RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export type AccordionItemProps = ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>;
|
|
22
|
+
export declare const AccordionItem: import("react").ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
23
|
+
export interface AccordionTriggerProps extends ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> {
|
|
24
|
+
/** Optional leading icon in the trigger row. */
|
|
25
|
+
icon?: ReactNode;
|
|
26
|
+
/** Hide the chevron indicator. */
|
|
27
|
+
hideIndicator?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const AccordionTrigger: import("react").ForwardRefExoticComponent<AccordionTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
30
|
+
export type AccordionContentProps = ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>;
|
|
31
|
+
export declare const AccordionContent: import("react").ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
|
+
export {};
|
|
@@ -5,4 +5,12 @@ export interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'
|
|
|
5
5
|
solid?: boolean;
|
|
6
6
|
title?: ReactNode;
|
|
7
7
|
children?: ReactNode;
|
|
8
|
+
/** Custom icon node. Pass `false` to hide the default icon. */
|
|
9
|
+
icon?: ReactNode | false;
|
|
10
|
+
/** Inline action slot — a button or link rendered on the right. */
|
|
11
|
+
action?: ReactNode;
|
|
12
|
+
/** When provided, renders a close button that invokes this callback. */
|
|
13
|
+
onDismiss?: () => void;
|
|
14
|
+
/** Accessible label for the dismiss button. */
|
|
15
|
+
dismissLabel?: string;
|
|
8
16
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AutocompleteProps } from './Autocomplete.types';
|
|
2
|
+
/**
|
|
3
|
+
* Searchable combobox. Single or multi-select. Built on @radix-ui/react-popover
|
|
4
|
+
* for positioning + cmdk for filter / keyboard nav. Replaces MUI's
|
|
5
|
+
* `Autocomplete` with a more compact API.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <Autocomplete
|
|
9
|
+
* options={[
|
|
10
|
+
* { value: 'eng', label: 'Engineering', group: 'Departments' },
|
|
11
|
+
* { value: 'des', label: 'Design', group: 'Departments' },
|
|
12
|
+
* ]}
|
|
13
|
+
* placeholder="Pick a department"
|
|
14
|
+
* onValueChange={(v) => console.log(v)}
|
|
15
|
+
* />
|
|
16
|
+
*
|
|
17
|
+
* <Autocomplete multiple options={…} placeholder="Pick attendees" />
|
|
18
|
+
*/
|
|
19
|
+
export declare const Autocomplete: import("react").ForwardRefExoticComponent<AutocompleteProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface AutocompleteOption {
|
|
3
|
+
/** Stable identifier — what gets stored in `value`. */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Visible label. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Optional group heading. Options with the same `group` cluster together. */
|
|
8
|
+
group?: string;
|
|
9
|
+
/** Disable selection of this option. */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/** Right-aligned secondary text (e.g. department, hint). */
|
|
12
|
+
hint?: ReactNode;
|
|
13
|
+
/** Leading icon node (overrides the avatar character). */
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export type AutocompleteSize = 'sm' | 'md' | 'lg';
|
|
17
|
+
export type AutocompleteColor = 'primary' | 'danger' | 'warning' | 'success';
|
|
18
|
+
interface AutocompleteBase {
|
|
19
|
+
/** Flat list of options. */
|
|
20
|
+
options: AutocompleteOption[];
|
|
21
|
+
/** Trigger placeholder when nothing is selected. */
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
/** Search input placeholder inside the dropdown. */
|
|
24
|
+
searchPlaceholder?: string;
|
|
25
|
+
/** Empty-state when no options match the search. */
|
|
26
|
+
emptyText?: ReactNode;
|
|
27
|
+
/** Show a loading spinner inside the dropdown. */
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
/** Loading-state text. */
|
|
30
|
+
loadingText?: ReactNode;
|
|
31
|
+
/** Trigger size. */
|
|
32
|
+
size?: AutocompleteSize;
|
|
33
|
+
/** Validation color on the trigger. */
|
|
34
|
+
color?: AutocompleteColor;
|
|
35
|
+
/** Disable the entire control. */
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/** Show a clear button when something is selected. */
|
|
38
|
+
clearable?: boolean;
|
|
39
|
+
/** Field-threading: id forwarded to the trigger. */
|
|
40
|
+
id?: string;
|
|
41
|
+
/** Field-threading: forwarded ARIA. */
|
|
42
|
+
'aria-invalid'?: boolean;
|
|
43
|
+
/** Field-threading: forwarded ARIA. */
|
|
44
|
+
'aria-describedby'?: string;
|
|
45
|
+
/** Accessible label when no `<Field>` wraps the control. */
|
|
46
|
+
'aria-label'?: string;
|
|
47
|
+
/** Custom className on the trigger. */
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface AutocompleteSingleProps extends AutocompleteBase {
|
|
51
|
+
multiple?: false;
|
|
52
|
+
/** Controlled selected value. */
|
|
53
|
+
value?: string | null;
|
|
54
|
+
/** Uncontrolled initial value. */
|
|
55
|
+
defaultValue?: string | null;
|
|
56
|
+
/** Fires on selection change. */
|
|
57
|
+
onValueChange?: (value: string | null) => void;
|
|
58
|
+
}
|
|
59
|
+
export interface AutocompleteMultipleProps extends AutocompleteBase {
|
|
60
|
+
multiple: true;
|
|
61
|
+
/** Controlled selected values. */
|
|
62
|
+
value?: string[];
|
|
63
|
+
/** Uncontrolled initial values. */
|
|
64
|
+
defaultValue?: string[];
|
|
65
|
+
/** Fires on selection change. */
|
|
66
|
+
onValueChange?: (value: string[]) => void;
|
|
67
|
+
/** Cap on how many can be selected. */
|
|
68
|
+
maxItems?: number;
|
|
69
|
+
}
|
|
70
|
+
export type AutocompleteProps = AutocompleteSingleProps | AutocompleteMultipleProps;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface BreadcrumbItem {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
href?: string;
|
|
5
|
+
/** Custom render — e.g. `<Link>`. Receives the rendered label. */
|
|
6
|
+
render?: (label: ReactNode) => ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface BreadcrumbProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
|
9
|
+
items: BreadcrumbItem[];
|
|
10
|
+
/** Separator node between items. Default: chevron. */
|
|
11
|
+
separator?: ReactNode;
|
|
12
|
+
size?: 'sm' | 'md';
|
|
13
|
+
}
|
|
14
|
+
export declare const Breadcrumb: import("react").ForwardRefExoticComponent<BreadcrumbProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { HTMLAttributes, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
export type ChipColor = 'default' | 'primary' | 'success' | 'info' | 'warning' | 'danger';
|
|
3
|
+
export type ChipSize = 'sm' | 'md';
|
|
4
|
+
export type ChipVariant = 'soft' | 'outline' | 'solid';
|
|
5
|
+
export interface ChipProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'onSelect'> {
|
|
6
|
+
/** Color/variant tone. Default: `default`. */
|
|
7
|
+
color?: ChipColor;
|
|
8
|
+
/** Visual style. Default: `soft`. */
|
|
9
|
+
variant?: ChipVariant;
|
|
10
|
+
/** Size preset. Default: `md`. */
|
|
11
|
+
size?: ChipSize;
|
|
12
|
+
/** Leading icon or avatar node. */
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
/** Avatar node (rendered before icon if both supplied). */
|
|
15
|
+
avatar?: ReactNode;
|
|
16
|
+
/** When provided, renders an X button that calls this. */
|
|
17
|
+
onDelete?: MouseEventHandler<HTMLButtonElement>;
|
|
18
|
+
/** Accessible label for the delete button. Default: `Remove`. */
|
|
19
|
+
deleteLabel?: string;
|
|
20
|
+
/** Make the chip itself clickable (becomes role=button). */
|
|
21
|
+
onClick?: MouseEventHandler<HTMLSpanElement>;
|
|
22
|
+
/** Disabled visual + non-interactive. */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** The chip's text/content. */
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Compact label primitive for tags, statuses, filter pills, and selected items.
|
|
29
|
+
* Six color tones × three variants. Optional leading icon/avatar and trailing
|
|
30
|
+
* delete button.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* <Chip color="success">Active</Chip>
|
|
34
|
+
* <Chip color="primary" variant="outline" onDelete={() => …}>Engineering</Chip>
|
|
35
|
+
* <Chip avatar={<Avatar size="xs">PS</Avatar>}>Premkumar S.</Chip>
|
|
36
|
+
*/
|
|
37
|
+
export declare const Chip: import("react").ForwardRefExoticComponent<ChipProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CommandPaletteProps, CommandPaletteTriggerProps, UseCommandPaletteOptions, UseCommandPaletteReturn } from './CommandPalette.types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that manages open state and binds the ⌘K / Ctrl+K hotkey.
|
|
4
|
+
* Pass `{ hotkey: false }` to opt out and wire your own toggle.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useCommandPalette({ hotkey }?: UseCommandPaletteOptions): UseCommandPaletteReturn;
|
|
7
|
+
/**
|
|
8
|
+
* Command palette — keyboard-driven search overlay built on cmdk + Radix Dialog.
|
|
9
|
+
* Render once near the root of your app; use `useCommandPalette()` (or your own
|
|
10
|
+
* state) to control `open`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const { open, setOpen } = useCommandPalette();
|
|
14
|
+
* <CommandPalette
|
|
15
|
+
* open={open}
|
|
16
|
+
* onOpenChange={setOpen}
|
|
17
|
+
* sections={[
|
|
18
|
+
* { title: 'Pages', items: [{ id: '/', label: 'Home', href: '/' }] },
|
|
19
|
+
* ]}
|
|
20
|
+
* onItemSelect={(item) => item.href && router.push(item.href)}
|
|
21
|
+
* />
|
|
22
|
+
*/
|
|
23
|
+
export declare function CommandPalette({ open, onOpenChange, sections, placeholder, title, description, emptyText, footer, onItemSelect, contentClassName, }: CommandPaletteProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* Pill-shaped trigger button for the command palette. Use in a Navbar or
|
|
26
|
+
* anywhere you want a visible search affordance.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <CommandPaletteTrigger onClick={() => setOpen(true)} />
|
|
30
|
+
*/
|
|
31
|
+
export declare function CommandPaletteTrigger({ onClick, label, shortcut, className, }: CommandPaletteTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface CommandPaletteItem {
|
|
3
|
+
/** Stable identifier — used as React key. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Visible label. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** When provided, selecting the item navigates to this href via `onItemSelect` (consumer wires the router). */
|
|
8
|
+
href?: string;
|
|
9
|
+
/** Custom select handler — overrides default href navigation. */
|
|
10
|
+
onSelect?: () => void;
|
|
11
|
+
/** Additional searchable terms beyond the label. */
|
|
12
|
+
keywords?: string[];
|
|
13
|
+
/** Right-aligned badge (e.g. "new"). */
|
|
14
|
+
badge?: ReactNode;
|
|
15
|
+
/** Leading icon. Defaults to a section-derived icon if not provided. */
|
|
16
|
+
icon?: ReactNode;
|
|
17
|
+
/** Right-aligned hint text (e.g. a path). */
|
|
18
|
+
hint?: ReactNode;
|
|
19
|
+
/** Disable selection. */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface CommandPaletteSection {
|
|
23
|
+
/** Group heading rendered above items. */
|
|
24
|
+
title: string;
|
|
25
|
+
/** Items in this group. */
|
|
26
|
+
items: CommandPaletteItem[];
|
|
27
|
+
}
|
|
28
|
+
export interface CommandPaletteProps {
|
|
29
|
+
/** Controlled open state. */
|
|
30
|
+
open: boolean;
|
|
31
|
+
/** Open-state setter. */
|
|
32
|
+
onOpenChange: (open: boolean) => void;
|
|
33
|
+
/** Grouped item sections. */
|
|
34
|
+
sections: CommandPaletteSection[];
|
|
35
|
+
/** Search input placeholder. */
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
/** Title for assistive tech (visually hidden). */
|
|
38
|
+
title?: string;
|
|
39
|
+
/** Description for assistive tech (visually hidden). */
|
|
40
|
+
description?: string;
|
|
41
|
+
/** Empty-state content. */
|
|
42
|
+
emptyText?: ReactNode;
|
|
43
|
+
/** Footer content. Defaults to keyboard hints. Pass `false` to hide. */
|
|
44
|
+
footer?: ReactNode | false;
|
|
45
|
+
/**
|
|
46
|
+
* Fires when the user selects an item. Use this to navigate via your router.
|
|
47
|
+
* If the item has its own `onSelect`, that runs first.
|
|
48
|
+
*/
|
|
49
|
+
onItemSelect?: (item: CommandPaletteItem) => void;
|
|
50
|
+
/** Extra className on the dialog content. */
|
|
51
|
+
contentClassName?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface CommandPaletteTriggerProps {
|
|
54
|
+
/** Click handler — usually `() => setOpen(true)`. */
|
|
55
|
+
onClick: () => void;
|
|
56
|
+
/** Visible label. */
|
|
57
|
+
label?: string;
|
|
58
|
+
/** Keyboard shortcut hint. Defaults to "⌘K". */
|
|
59
|
+
shortcut?: string;
|
|
60
|
+
/** Extra className. */
|
|
61
|
+
className?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface UseCommandPaletteOptions {
|
|
64
|
+
/** Bind the ⌘K / Ctrl+K hotkey. Default: true. */
|
|
65
|
+
hotkey?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface UseCommandPaletteReturn {
|
|
68
|
+
open: boolean;
|
|
69
|
+
setOpen: (open: boolean) => void;
|
|
70
|
+
toggle: () => void;
|
|
71
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { CommandPalette, CommandPaletteTrigger, useCommandPalette } from './CommandPalette';
|
|
2
|
+
export type { CommandPaletteItem, CommandPaletteSection, CommandPaletteProps, CommandPaletteTriggerProps, UseCommandPaletteOptions, UseCommandPaletteReturn, } from './CommandPalette.types';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { WeekDay } from './dateUtils';
|
|
3
|
+
export type DatePickerSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
export type DatePickerColor = 'primary' | 'danger' | 'warning' | 'success';
|
|
5
|
+
export type DatePickerMode = 'date' | 'month' | 'year' | 'time' | 'datetime';
|
|
6
|
+
/**
|
|
7
|
+
* Declarative date-window constraint.
|
|
8
|
+
* - `'any'` (default): no restriction
|
|
9
|
+
* - `'future'`: today and later
|
|
10
|
+
* - `'past'`: today and earlier
|
|
11
|
+
* - `'current'`: today only
|
|
12
|
+
*
|
|
13
|
+
* Combines with explicit `min` / `max` — the stricter of the two always wins.
|
|
14
|
+
*/
|
|
15
|
+
export type DatePickerAllow = 'any' | 'future' | 'past' | 'current';
|
|
16
|
+
export interface DatePickerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'children'> {
|
|
17
|
+
/** Which picker to show. */
|
|
18
|
+
mode?: DatePickerMode;
|
|
19
|
+
/** Controlled value. `null` means cleared. */
|
|
20
|
+
value?: Date | string | null;
|
|
21
|
+
/** Uncontrolled initial value. */
|
|
22
|
+
defaultValue?: Date | string;
|
|
23
|
+
/** Fires on selection and clear. */
|
|
24
|
+
onChange?: (date: Date | null) => void;
|
|
25
|
+
/** Earliest selectable date (inclusive). */
|
|
26
|
+
min?: Date | string;
|
|
27
|
+
/** Latest selectable date (inclusive). */
|
|
28
|
+
max?: Date | string;
|
|
29
|
+
/** Declarative date-window constraint. Combines with `min`/`max` (stricter wins). */
|
|
30
|
+
allow?: DatePickerAllow;
|
|
31
|
+
/** Predicate to disable arbitrary dates (ignored for time-only mode). */
|
|
32
|
+
disabledDate?: (date: Date) => boolean;
|
|
33
|
+
/** Predicate to disable specific times (hour/minute/second combos). */
|
|
34
|
+
disabledTime?: (date: Date) => boolean;
|
|
35
|
+
/** Text shown when empty. */
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
/** Trigger size. */
|
|
38
|
+
size?: DatePickerSize;
|
|
39
|
+
/** Validation color on the trigger. Auto-flips to `'danger'` on validation errors. */
|
|
40
|
+
color?: DatePickerColor;
|
|
41
|
+
/** Disable the trigger. */
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/** Show a clear button when a value is selected. */
|
|
44
|
+
clearable?: boolean;
|
|
45
|
+
/** BCP-47 locale tag. Defaults to the browser's. */
|
|
46
|
+
locale?: string;
|
|
47
|
+
/** 0 = Sunday, 1 = Monday, …, 6 = Saturday. Defaults to 0. */
|
|
48
|
+
weekStartsOn?: WeekDay;
|
|
49
|
+
/** Use 12-hour clock with AM/PM for time / datetime. Default: inferred from locale. */
|
|
50
|
+
hour12?: boolean;
|
|
51
|
+
/** Show a seconds column in time / datetime. */
|
|
52
|
+
showSeconds?: boolean;
|
|
53
|
+
/** Minute granularity (1–30). Default 1. */
|
|
54
|
+
minuteStep?: number;
|
|
55
|
+
/** Second granularity (1–30). Default 1. */
|
|
56
|
+
secondStep?: number;
|
|
57
|
+
/** Custom display formatter for the selected value. */
|
|
58
|
+
format?: (date: Date, mode: DatePickerMode) => string;
|
|
59
|
+
/** Replace the trigger icon. */
|
|
60
|
+
icon?: ReactNode;
|
|
61
|
+
/** Required — empty value is treated as invalid. */
|
|
62
|
+
required?: boolean;
|
|
63
|
+
/** Custom validator. Returns an error message or null/undefined if valid. */
|
|
64
|
+
validate?: (date: Date | null) => string | null | undefined;
|
|
65
|
+
/** Explicit error message. When set, forces danger state and renders below the trigger. */
|
|
66
|
+
error?: ReactNode;
|
|
67
|
+
/** Fires whenever the internal validation state changes. */
|
|
68
|
+
onValidate?: (error: string | null) => void;
|
|
69
|
+
/** id forwarded to the trigger (for Field integration). */
|
|
70
|
+
id?: string;
|
|
71
|
+
/** aria-invalid forwarded to the trigger. */
|
|
72
|
+
'aria-invalid'?: boolean;
|
|
73
|
+
/** aria-describedby forwarded to the trigger. */
|
|
74
|
+
'aria-describedby'?: string;
|
|
75
|
+
/** Accessible label for the dialog. */
|
|
76
|
+
dialogLabel?: string;
|
|
77
|
+
/** Name for form submission. */
|
|
78
|
+
name?: string;
|
|
79
|
+
/** Controlled open state. */
|
|
80
|
+
open?: boolean;
|
|
81
|
+
/** Called when open state changes. */
|
|
82
|
+
onOpenChange?: (open: boolean) => void;
|
|
83
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
2
|
+
export declare function startOfDay(d: Date): Date;
|
|
3
|
+
export declare function endOfDay(d: Date): Date;
|
|
4
|
+
export declare function isSameDay(a: Date | null | undefined, b: Date | null | undefined): boolean;
|
|
5
|
+
export declare function isSameMonth(a: Date, b: Date): boolean;
|
|
6
|
+
export declare function isSameYear(a: Date, b: Date): boolean;
|
|
7
|
+
export declare function startOfMonth(d: Date): Date;
|
|
8
|
+
export declare function startOfYear(d: Date): Date;
|
|
9
|
+
export declare function startOfDecade(d: Date): Date;
|
|
10
|
+
export declare function addMonths(d: Date, n: number): Date;
|
|
11
|
+
export declare function addDays(d: Date, n: number): Date;
|
|
12
|
+
export declare function addYears(d: Date, n: number): Date;
|
|
13
|
+
export declare function withTime(d: Date, h: number, m: number, s?: number): Date;
|
|
14
|
+
export declare function clamp(d: Date, min?: Date | null, max?: Date | null): Date;
|
|
15
|
+
/** 6×7 grid (42 cells) starting on `weekStartsOn`. */
|
|
16
|
+
export declare function buildMonthGrid(viewDate: Date, weekStartsOn: WeekDay): Date[];
|
|
17
|
+
export declare function weekdayLabels(locale: string, weekStartsOn: WeekDay): string[];
|
|
18
|
+
export declare function monthLabels(locale: string, style?: 'short' | 'long'): string[];
|
|
19
|
+
export declare function formatMonthYear(d: Date, locale: string): string;
|
|
20
|
+
export declare function formatYearOnly(d: Date, locale: string): string;
|
|
21
|
+
export declare function formatMonthOnly(d: Date, locale: string): string;
|
|
22
|
+
export declare function formatMedium(d: Date, locale: string): string;
|
|
23
|
+
export declare function formatTime(d: Date, locale: string, hour12: boolean, showSeconds: boolean): string;
|
|
24
|
+
export declare function formatDateTime(d: Date, locale: string, hour12: boolean, showSeconds: boolean): string;
|
|
25
|
+
export declare function parseDate(input: Date | string | null | undefined): Date | null;
|
|
26
|
+
export declare function isBefore(a: Date, b: Date): boolean;
|
|
27
|
+
export declare function isAfter(a: Date, b: Date): boolean;
|
|
28
|
+
export declare function pad2(n: number): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import * as RadixDialog from '@radix-ui/react-dialog';
|
|
3
|
+
export type DialogSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
4
|
+
export interface DialogProps extends ComponentPropsWithoutRef<typeof RadixDialog.Root> {
|
|
5
|
+
/** Title rendered as the visible h2. Required for accessibility. */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
/** Optional descriptive subhead under the title. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
/** Body content (forms, copy, lists). */
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/** Footer node (typically a Button row). */
|
|
12
|
+
footer?: ReactNode;
|
|
13
|
+
/** Width preset. Default: `md`. */
|
|
14
|
+
size?: DialogSize;
|
|
15
|
+
/** Hide the built-in X close button. */
|
|
16
|
+
hideClose?: boolean;
|
|
17
|
+
/** Extra className on the dialog content. */
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Modal dialog built on @radix-ui/react-dialog. Includes a backdrop, focus trap,
|
|
22
|
+
* Esc-to-close, scroll lock, and an accessible title/description out of the box.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const [open, setOpen] = useState(false);
|
|
26
|
+
* <Dialog open={open} onOpenChange={setOpen} title="Confirm delete">
|
|
27
|
+
* This action can't be undone.
|
|
28
|
+
* </Dialog>
|
|
29
|
+
*/
|
|
30
|
+
export declare const Dialog: import("react").ForwardRefExoticComponent<DialogProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
31
|
+
/** Trigger button to open a Dialog when wired with a controlled root. */
|
|
32
|
+
export declare const DialogTrigger: import("react").ForwardRefExoticComponent<RadixDialog.DialogTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
/** Close button — typically used inside the body or footer. */
|
|
34
|
+
export declare const DialogClose: import("react").ForwardRefExoticComponent<RadixDialog.DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import * as RadixDialog from '@radix-ui/react-dialog';
|
|
3
|
+
export type DrawerSide = 'left' | 'right' | 'top' | 'bottom';
|
|
4
|
+
export type DrawerSize = 'sm' | 'md' | 'lg' | 'xl';
|
|
5
|
+
export interface DrawerProps extends ComponentPropsWithoutRef<typeof RadixDialog.Root> {
|
|
6
|
+
/** Visible heading for the drawer. Required for AT. */
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
/** Optional subhead under the title. */
|
|
9
|
+
description?: ReactNode;
|
|
10
|
+
/** Body content. */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/** Footer (typically Buttons). */
|
|
13
|
+
footer?: ReactNode;
|
|
14
|
+
/** Edge the drawer slides in from. Default: `right`. */
|
|
15
|
+
side?: DrawerSide;
|
|
16
|
+
/** Width preset (for left/right) or height preset (for top/bottom). Default: `md`. */
|
|
17
|
+
size?: DrawerSize;
|
|
18
|
+
/** Hide the built-in X close button. */
|
|
19
|
+
hideClose?: boolean;
|
|
20
|
+
/** Extra className on the drawer content. */
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Off-canvas drawer / sheet. Slides in from any edge. Built on
|
|
25
|
+
* @radix-ui/react-dialog so it gets focus trapping, Esc-to-close, scroll
|
|
26
|
+
* lock, and accessibility for free.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <Drawer open={open} onOpenChange={setOpen} side="right" title="Settings">
|
|
30
|
+
* <SettingsForm />
|
|
31
|
+
* </Drawer>
|
|
32
|
+
*/
|
|
33
|
+
export declare const Drawer: import("react").ForwardRefExoticComponent<DrawerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
|
+
export declare const DrawerTrigger: import("react").ForwardRefExoticComponent<RadixDialog.DialogTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
35
|
+
export declare const DrawerClose: import("react").ForwardRefExoticComponent<RadixDialog.DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface AspectRatioProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
3
|
+
/** Ratio = width / height. e.g. 16/9, 4/3, 1, 21/9. Default 16/9. */
|
|
4
|
+
ratio?: number;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Locks a child to a fixed aspect ratio. Useful for video/image tiles,
|
|
9
|
+
* map embeds, and avatar grids. Pure CSS via `aspect-ratio`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AspectRatio: import("react").ForwardRefExoticComponent<AspectRatioProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ElementType, ForwardedRef, ReactElement } from 'react';
|
|
2
|
+
import type { BoxProps } from './Box';
|
|
3
|
+
export type CenterProps<E extends ElementType = 'div'> = Omit<BoxProps<E>, 'display' | 'align' | 'justify'>;
|
|
4
|
+
/** Flex-centers its children (both axes). */
|
|
5
|
+
export declare const Center: <E extends ElementType = "div">(props: CenterProps<E> & {
|
|
6
|
+
ref?: ForwardedRef<Element>;
|
|
7
|
+
}) => ReactElement;
|
|
@@ -2,9 +2,15 @@ import type { ElementType, ForwardedRef, ReactElement } from 'react';
|
|
|
2
2
|
import type { BoxProps } from './Box';
|
|
3
3
|
type GridCols = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
4
4
|
export type GridProps<E extends ElementType = 'div'> = Omit<BoxProps<E>, 'display' | 'direction'> & {
|
|
5
|
+
/** Fixed column count. Maps to `.grid-cols-{n}` utility. Ignored if `minColWidth` is set. */
|
|
5
6
|
cols?: GridCols;
|
|
7
|
+
/**
|
|
8
|
+
* Auto-fit responsive grid: `repeat(auto-fit, minmax(minColWidth, 1fr))`.
|
|
9
|
+
* Pass a CSS length (e.g. `'240px'`, `'18rem'`).
|
|
10
|
+
*/
|
|
11
|
+
minColWidth?: string;
|
|
6
12
|
};
|
|
7
|
-
/** CSS Grid container. `cols`
|
|
13
|
+
/** CSS Grid container. Use `cols` for fixed tracks, or `minColWidth` for responsive auto-fit. */
|
|
8
14
|
export declare const Grid: <E extends ElementType = "div">(props: GridProps<E> & {
|
|
9
15
|
ref?: ForwardedRef<Element>;
|
|
10
16
|
}) => ReactElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ElementType, ForwardedRef, ReactElement } from 'react';
|
|
2
|
+
import type { BoxProps } from './Box';
|
|
3
|
+
export type GroupProps<E extends ElementType = 'div'> = Omit<BoxProps<E>, 'direction' | 'display'>;
|
|
4
|
+
/**
|
|
5
|
+
* Horizontal flex row tuned for toolbars / trigger groups.
|
|
6
|
+
* Defaults: align center, gap 2, wrap on overflow.
|
|
7
|
+
*/
|
|
8
|
+
export declare const Group: <E extends ElementType = "div">(props: GroupProps<E> & {
|
|
9
|
+
ref?: ForwardedRef<Element>;
|
|
10
|
+
}) => ReactElement;
|
|
@@ -4,10 +4,16 @@ export { Grid } from './Grid';
|
|
|
4
4
|
export { Container } from './Container';
|
|
5
5
|
export { Divider } from './Divider';
|
|
6
6
|
export { Spacer } from './Spacer';
|
|
7
|
+
export { AspectRatio } from './AspectRatio';
|
|
8
|
+
export { Center } from './Center';
|
|
9
|
+
export { Group } from './Group';
|
|
7
10
|
export type { BoxProps } from './Box';
|
|
8
11
|
export type { StackProps, RowProps } from './Stack';
|
|
9
12
|
export type { GridProps } from './Grid';
|
|
10
13
|
export type { ContainerProps, ContainerSize } from './Container';
|
|
11
14
|
export type { DividerProps } from './Divider';
|
|
12
15
|
export type { SpacerProps } from './Spacer';
|
|
16
|
+
export type { AspectRatioProps } from './AspectRatio';
|
|
17
|
+
export type { CenterProps } from './Center';
|
|
18
|
+
export type { GroupProps } from './Group';
|
|
13
19
|
export type { Space, Align, Justify, Direction, Display, LayoutProps } from './layout.types';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode, MouseEventHandler } from 'react';
|
|
2
|
+
export type ListVariant = 'plain' | 'bordered' | 'dividers';
|
|
3
|
+
export type ListSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
export interface ListProps extends HTMLAttributes<HTMLUListElement> {
|
|
5
|
+
/** Visual style. Default: `dividers`. */
|
|
6
|
+
variant?: ListVariant;
|
|
7
|
+
/** Row size. Default: `md`. */
|
|
8
|
+
size?: ListSize;
|
|
9
|
+
/** Use this when items have explicit dividers via `<ListSeparator>` to
|
|
10
|
+
* disable automatic divider rendering. */
|
|
11
|
+
dense?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const List: import("react").ForwardRefExoticComponent<ListProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
14
|
+
export interface ListItemProps {
|
|
15
|
+
/** Leading icon or avatar. */
|
|
16
|
+
leading?: ReactNode;
|
|
17
|
+
/** Trailing actions (button, chip, badge). */
|
|
18
|
+
trailing?: ReactNode;
|
|
19
|
+
/** Primary text — bold/regular depending on variant. */
|
|
20
|
+
primary?: ReactNode;
|
|
21
|
+
/** Secondary text — muted, single-line by default. */
|
|
22
|
+
secondary?: ReactNode;
|
|
23
|
+
/** Whole-row click handler. Becomes role=button. */
|
|
24
|
+
onClick?: MouseEventHandler<HTMLLIElement>;
|
|
25
|
+
/** Render the row as a link by passing an `href`. */
|
|
26
|
+
href?: string;
|
|
27
|
+
/** Disable interactivity + visual. */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** Render as currently-active row. */
|
|
30
|
+
active?: boolean;
|
|
31
|
+
/** Override the rendered element (default: `li`, `a` if href, `button` if onClick). */
|
|
32
|
+
as?: ElementType;
|
|
33
|
+
/** Accessible name override (when `primary` isn't a string). */
|
|
34
|
+
'aria-label'?: string;
|
|
35
|
+
/** Free-form children — overrides the leading/primary/secondary/trailing slots. */
|
|
36
|
+
children?: ReactNode;
|
|
37
|
+
/** Extra className. */
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare const ListItem: import("react").ForwardRefExoticComponent<ListItemProps & import("react").RefAttributes<HTMLElement>>;
|
|
41
|
+
export declare const ListSeparator: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLLIElement> & import("react").RefAttributes<HTMLLIElement>>;
|
|
42
|
+
export declare const ListSubheader: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLLIElement> & import("react").RefAttributes<HTMLLIElement>>;
|