@ultralabs/glass 0.0.0-stage → 0.1.1
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/CHANGELOG.md +326 -0
- package/DESIGN.md +682 -0
- package/LICENSE +21 -0
- package/README.md +690 -2
- package/dist/esm/index.js +20991 -0
- package/dist/types/src/charts/ULCartesianChart.d.ts +177 -0
- package/dist/types/src/charts/ULDonutChart.d.ts +65 -0
- package/dist/types/src/charts/ULFunnelChart.d.ts +64 -0
- package/dist/types/src/charts/ULHeatmapChart.d.ts +40 -0
- package/dist/types/src/charts/ULRadarChart.d.ts +19 -0
- package/dist/types/src/charts/ULRadialChart.d.ts +48 -0
- package/dist/types/src/charts/ULScatterChart.d.ts +49 -0
- package/dist/types/src/charts/core.d.ts +287 -0
- package/dist/types/src/charts/decimate.d.ts +8 -0
- package/dist/types/src/charts/nav.d.ts +368 -0
- package/dist/types/src/charts/quadtree.d.ts +9 -0
- package/dist/types/src/charts/scales.d.ts +59 -0
- package/dist/types/src/charts/timeseries.d.ts +56 -0
- package/dist/types/src/components/ULAnchoredSurface/ULAnchoredSurface.d.ts +72 -0
- package/dist/types/src/components/ULBatch2/carousel.d.ts +31 -0
- package/dist/types/src/components/ULBatch2/hovercard.d.ts +40 -0
- package/dist/types/src/components/ULBatch2/layout.d.ts +16 -0
- package/dist/types/src/components/ULBatch2/menubar.d.ts +29 -0
- package/dist/types/src/components/ULBatch2/navmenu.d.ts +51 -0
- package/dist/types/src/components/ULBatch2/resizable.d.ts +48 -0
- package/dist/types/src/components/ULBatch2/typography.d.ts +55 -0
- package/dist/types/src/components/ULButton/ULButton.d.ts +87 -0
- package/dist/types/src/components/ULContainers/ULCard.d.ts +54 -0
- package/dist/types/src/components/ULContainers/ULDialog.d.ts +57 -0
- package/dist/types/src/components/ULContainers/ULLayout.d.ts +81 -0
- package/dist/types/src/components/ULContainers/ULMenu.d.ts +99 -0
- package/dist/types/src/components/ULContainers/ULOverlays.d.ts +113 -0
- package/dist/types/src/components/ULContainers/contextTarget.d.ts +91 -0
- package/dist/types/src/components/ULData/ULData.d.ts +225 -0
- package/dist/types/src/components/ULData/ULKpi.d.ts +159 -0
- package/dist/types/src/components/ULField/ULField.d.ts +93 -0
- package/dist/types/src/components/ULForms/fieldContext.d.ts +39 -0
- package/dist/types/src/components/ULForms/forms.d.ts +143 -0
- package/dist/types/src/components/ULIsland/ULIsland.d.ts +39 -0
- package/dist/types/src/components/ULIsland/headerConfig.d.ts +43 -0
- package/dist/types/src/components/ULIsland/navIndicator.d.ts +26 -0
- package/dist/types/src/components/ULListbox/ULListbox.d.ts +75 -0
- package/dist/types/src/components/ULPickers/ULPickers.d.ts +141 -0
- package/dist/types/src/components/ULSegmented/ULSegmented.d.ts +50 -0
- package/dist/types/src/components/ULSelection/ULSelection.d.ts +71 -0
- package/dist/types/src/components/ULSlider/ULSlider.d.ts +43 -0
- package/dist/types/src/components/ULSpinner/ULSpinner.d.ts +8 -0
- package/dist/types/src/components/ULStructure/kbd.d.ts +22 -0
- package/dist/types/src/components/ULStructure/structure.d.ts +154 -0
- package/dist/types/src/components/ULTabs/ULTabs.d.ts +28 -0
- package/dist/types/src/components/ULTooltip/anchoredTooltip.d.ts +22 -0
- package/dist/types/src/components/actions/actions.d.ts +175 -0
- package/dist/types/src/components/actions/core.d.ts +346 -0
- package/dist/types/src/components/dashboard/blocks.d.ts +583 -0
- package/dist/types/src/components/dashboard/blocks2.d.ts +297 -0
- package/dist/types/src/components/dashboard/columnsDrag.d.ts +27 -0
- package/dist/types/src/components/shared/ULCheckMark.d.ts +9 -0
- package/dist/types/src/components/shared/dev.d.ts +13 -0
- package/dist/types/src/components/shared/icons.d.ts +23 -0
- package/dist/types/src/glass/ULGlass.d.ts +78 -0
- package/dist/types/src/glass/ULGlassGroup.d.ts +16 -0
- package/dist/types/src/glass/accent.d.ts +31 -0
- package/dist/types/src/glass/contrast.d.ts +78 -0
- package/dist/types/src/glass/engine.d.ts +177 -0
- package/dist/types/src/glass/glassDebug.d.ts +27 -0
- package/dist/types/src/glass/material.d.ts +49 -0
- package/dist/types/src/glass/radius.d.ts +2 -0
- package/dist/types/src/hooks/useAnchoredMorph.d.ts +20 -0
- package/dist/types/src/hooks/usePointerLight.d.ts +6 -0
- package/dist/types/src/hooks/useReducedMotion.d.ts +3 -0
- package/dist/types/src/index.d.ts +150 -0
- package/dist/types/src/island/sectionAccent.d.ts +18 -0
- package/dist/types/src/live/ULLiveStatus.d.ts +18 -0
- package/dist/types/src/live/liveQueue.d.ts +13 -0
- package/dist/types/src/live/liveSource.d.ts +149 -0
- package/dist/types/src/live/liveStore.d.ts +72 -0
- package/dist/types/src/motion/anchoredMorph.d.ts +175 -0
- package/dist/types/src/motion/goo.d.ts +3 -0
- package/dist/types/src/motion/lensBubble.d.ts +143 -0
- package/dist/types/src/motion/lensSelect.d.ts +31 -0
- package/dist/types/src/motion/overlayStack.d.ts +13 -0
- package/dist/types/src/motion/placement.d.ts +18 -0
- package/dist/types/src/motion/spring.d.ts +20 -0
- package/dist/types/src/motion/topLayer.d.ts +13 -0
- package/dist/types/src/motion/viewSwap.d.ts +33 -0
- package/dist/types/src/motion/virtualAnchor.d.ts +28 -0
- package/dist/ul-glass.css +10519 -0
- package/dist/ul-glass.js +21034 -0
- package/dist/ul-glass.min.js +14 -0
- package/dist/ul-glass.min.js.map +7 -0
- package/icons/arrow-up-down.svg +5 -0
- package/icons/bell.svg +3 -0
- package/icons/bold.svg +2 -0
- package/icons/calendar.svg +5 -0
- package/icons/check.svg +2 -0
- package/icons/chevron-down.svg +2 -0
- package/icons/chevron-left.svg +2 -0
- package/icons/chevron-right.svg +2 -0
- package/icons/chevrons-right.svg +3 -0
- package/icons/circle-check.svg +3 -0
- package/icons/circle-x.svg +4 -0
- package/icons/circle.svg +2 -0
- package/icons/copy.svg +3 -0
- package/icons/ellipsis.svg +4 -0
- package/icons/eye.svg +3 -0
- package/icons/filter.svg +2 -0
- package/icons/flags/LICENSE.md +2 -0
- package/icons/flags/cs.svg +1 -0
- package/icons/flags/de.svg +1 -0
- package/icons/flags/en.svg +1 -0
- package/icons/flags/sk.svg +1 -0
- package/icons/folder-kanban.svg +5 -0
- package/icons/icons.json +1 -0
- package/icons/inbox.svg +3 -0
- package/icons/info.svg +4 -0
- package/icons/layout-dashboard.svg +5 -0
- package/icons/layout-grid.svg +5 -0
- package/icons/loader-circle.svg +2 -0
- package/icons/lock.svg +3 -0
- package/icons/mail.svg +3 -0
- package/icons/menu.svg +4 -0
- package/icons/minus.svg +2 -0
- package/icons/panel-left-close.svg +4 -0
- package/icons/plus.svg +3 -0
- package/icons/refresh-cw.svg +5 -0
- package/icons/search.svg +3 -0
- package/icons/shield-check.svg +3 -0
- package/icons/shopping-bag.svg +4 -0
- package/icons/sparkles.svg +6 -0
- package/icons/trash-2.svg +6 -0
- package/icons/triangle-alert.svg +4 -0
- package/icons/upload.svg +4 -0
- package/icons/users.svg +5 -0
- package/icons/x.svg +3 -0
- package/package.json +65 -4
- package/tokens/tokens.css +799 -0
- package/tokens/tokens.json +1017 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Accent, AccentStrength, Backdrop } from '../../glass/accent.js';
|
|
3
|
+
import './ULContainers.css';
|
|
4
|
+
export interface DialogView {
|
|
5
|
+
key: string;
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
description?: React.ReactNode;
|
|
8
|
+
/** sm 400 · md 520 · lg 680 · auto (intrinsic, max lg). */
|
|
9
|
+
size?: 'sm' | 'md' | 'lg' | 'auto';
|
|
10
|
+
content?: React.ReactNode;
|
|
11
|
+
footer?: React.ReactNode;
|
|
12
|
+
/** Dirty guard: return false (or a promise of false) to keep the view when back / close / replace is requested. */
|
|
13
|
+
canLeave?: () => boolean | Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
export interface DialogApi {
|
|
16
|
+
push(v: DialogView): void;
|
|
17
|
+
replace(v: DialogView): void;
|
|
18
|
+
pop(): void;
|
|
19
|
+
close(): void;
|
|
20
|
+
depth: number;
|
|
21
|
+
/** Outside a dialog (ULDialogProvider): open a root dialog from a trigger. */
|
|
22
|
+
open?(v: DialogView, o?: {
|
|
23
|
+
triggerRef?: React.RefObject<HTMLElement | null>;
|
|
24
|
+
sheet?: 'auto' | 'always' | 'never';
|
|
25
|
+
}): void;
|
|
26
|
+
}
|
|
27
|
+
/** Inside a dialog: push / replace / pop / close. Outside (under ULDialogProvider): open(). */
|
|
28
|
+
export declare const useDialog: () => DialogApi;
|
|
29
|
+
export interface DialogSurfaceProps {
|
|
30
|
+
/** Controlled open state. */ open: boolean;
|
|
31
|
+
/** Called with the next open state (trigger, Esc, outside click, close button). */ onOpenChange?: (o: boolean) => void;
|
|
32
|
+
/** Trigger element: the surface morphs from it and focus returns to it on close. */ triggerRef?: React.RefObject<HTMLElement | null>;
|
|
33
|
+
/** First view of the dialog stack; push / replace views with useDialog() (same surface morphs). */ root: DialogView;
|
|
34
|
+
/** auto: bottom sheet ≤ 640px · always · never. */
|
|
35
|
+
sheet?: 'auto' | 'always' | 'never';
|
|
36
|
+
/** Drawer: pinned to an edge, grows in from it. */
|
|
37
|
+
edge?: 'left' | 'right';
|
|
38
|
+
/** "dialog" (default) | "alertdialog". */ role?: 'dialog' | 'alertdialog';
|
|
39
|
+
/** Close when the scrim is clicked. Default true (false for role="alertdialog"). */ closeOnScrim?: boolean;
|
|
40
|
+
/** Accessible label of the close button. Default localised "Close". */ closeLabel?: string;
|
|
41
|
+
/** Accessible label of the back button on pushed views. Default localised "Back". */ backLabel?: string;
|
|
42
|
+
/** Element (or selector) focused on open; null = the surface itself. Default: first focusable. */ initialFocus?: HTMLElement | string | null;
|
|
43
|
+
/** Accent colour: accent name ("violet", "ice", "emerald", "amber", "rose") or a CSS colour (checked by guardAccent). */ accent?: Accent;
|
|
44
|
+
/** "subtle" | "tinted" | "vivid" accent intensity of the glass. */ accentStrength?: AccentStrength;
|
|
45
|
+
/** Backdrop hint for the glass: "dark" | "mid" | "light". */ backdrop?: Backdrop;
|
|
46
|
+
/** Extra class on the root element. */ className?: string;
|
|
47
|
+
/** @internal tests */
|
|
48
|
+
surfaceRef?: React.MutableRefObject<HTMLElement | null>;
|
|
49
|
+
/** @internal tests: the live api */
|
|
50
|
+
apiRef?: React.MutableRefObject<DialogApi | null>;
|
|
51
|
+
}
|
|
52
|
+
/** The one dialog surface: modal, sheet and drawer all render through this. */
|
|
53
|
+
export declare function ULDialogSurface({ open, onOpenChange, triggerRef, root, sheet, edge, role, closeOnScrim, closeLabel, backLabel, initialFocus, accent, accentStrength, backdrop, className, surfaceRef, apiRef }: DialogSurfaceProps): React.JSX.Element;
|
|
54
|
+
/** App-level provider: useDialog().open(view, { triggerRef }) from anywhere; push / pop inside. */
|
|
55
|
+
export declare function ULDialogProvider({ children }: {
|
|
56
|
+
children?: React.ReactNode;
|
|
57
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Accent, Backdrop } from '../../glass/accent.js';
|
|
3
|
+
import './ULContainers.css';
|
|
4
|
+
import { type ContextMenuProps } from './contextTarget.js';
|
|
5
|
+
export interface AccordionItem {
|
|
6
|
+
value: string;
|
|
7
|
+
title: React.ReactNode;
|
|
8
|
+
content: React.ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ULAccordionProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {
|
|
12
|
+
items: AccordionItem[];
|
|
13
|
+
type?: 'single' | 'multiple';
|
|
14
|
+
value?: string[];
|
|
15
|
+
defaultValue?: string[];
|
|
16
|
+
onValueChange?: (v: string[]) => void;
|
|
17
|
+
/** single: allow closing the open item. Default true. */
|
|
18
|
+
collapsible?: boolean;
|
|
19
|
+
level?: 2 | 3 | 4;
|
|
20
|
+
}
|
|
21
|
+
/** Accordion. contextMenu target: { component: 'accordion', kind: 'header', id: value, data: item } (headers only). */
|
|
22
|
+
export declare function ULAccordion(props: ULAccordionProps & ContextMenuProps<AccordionItem>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
23
|
+
export interface SidebarItem {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
icon?: React.ReactNode;
|
|
27
|
+
href?: string;
|
|
28
|
+
badge?: React.ReactNode;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface SidebarSection {
|
|
32
|
+
label?: string;
|
|
33
|
+
items: SidebarItem[];
|
|
34
|
+
}
|
|
35
|
+
export interface ULSidebarProps {
|
|
36
|
+
sections: SidebarSection[];
|
|
37
|
+
value?: string;
|
|
38
|
+
onValueChange?: (id: string) => void;
|
|
39
|
+
collapsed?: boolean;
|
|
40
|
+
defaultCollapsed?: boolean;
|
|
41
|
+
onCollapsedChange?: (c: boolean) => void;
|
|
42
|
+
header?: React.ReactNode;
|
|
43
|
+
footer?: React.ReactNode;
|
|
44
|
+
label?: string;
|
|
45
|
+
/** auto: drawer ≤ 900px; always: always a drawer (open with mobileOpen); never. */
|
|
46
|
+
drawer?: 'auto' | 'always' | 'never';
|
|
47
|
+
mobileOpen?: boolean;
|
|
48
|
+
onMobileOpenChange?: (o: boolean) => void;
|
|
49
|
+
mobileTriggerRef?: React.RefObject<HTMLElement | null>;
|
|
50
|
+
collapseLabel?: string;
|
|
51
|
+
expandLabel?: string;
|
|
52
|
+
accent?: Accent;
|
|
53
|
+
backdrop?: Backdrop;
|
|
54
|
+
className?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Sidebar. contextMenu target: { component: 'sidebar', kind: 'item', id, data: SidebarItem }. */
|
|
57
|
+
export declare function ULSidebar(props: ULSidebarProps & ContextMenuProps<SidebarItem>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
58
|
+
export interface ToolbarItem {
|
|
59
|
+
id: string;
|
|
60
|
+
label: string;
|
|
61
|
+
icon?: React.ReactNode;
|
|
62
|
+
onSelect?: () => void;
|
|
63
|
+
toggle?: boolean;
|
|
64
|
+
pressed?: boolean;
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface ToolbarGroup {
|
|
68
|
+
label: string;
|
|
69
|
+
items: ToolbarItem[];
|
|
70
|
+
}
|
|
71
|
+
export interface ULToolbarProps {
|
|
72
|
+
groups: ToolbarGroup[];
|
|
73
|
+
label: string;
|
|
74
|
+
moreLabel?: string; /** Show labels next to icons. Default false (icon + tooltip). */
|
|
75
|
+
labels?: boolean;
|
|
76
|
+
accent?: Accent;
|
|
77
|
+
backdrop?: Backdrop;
|
|
78
|
+
className?: string;
|
|
79
|
+
end?: React.ReactNode;
|
|
80
|
+
}
|
|
81
|
+
export declare function ULToolbar({ groups, label, moreLabel, labels, accent, backdrop, className, end }: ULToolbarProps): React.JSX.Element;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Align, Side } from '../../motion/placement.js';
|
|
3
|
+
import type { Accent, Backdrop } from '../../glass/accent.js';
|
|
4
|
+
import './ULContainers.css';
|
|
5
|
+
export interface MenuItem {
|
|
6
|
+
id?: string;
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
/** Text for typeahead / aria when label is not a string. */
|
|
9
|
+
textValue?: string;
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
shortcut?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
destructive?: boolean;
|
|
14
|
+
type?: 'item' | 'checkbox' | 'radio' | 'separator' | 'label';
|
|
15
|
+
checked?: boolean;
|
|
16
|
+
onSelect?: () => void;
|
|
17
|
+
/** Nested submenu. */
|
|
18
|
+
items?: MenuItem[];
|
|
19
|
+
/** Not rendered (context menus filter these out). */
|
|
20
|
+
hidden?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface ULMenuProps {
|
|
23
|
+
/** Controlled open state. */ open: boolean;
|
|
24
|
+
/** Called with the next open state (trigger, Esc, outside click, close button). */ onOpenChange?: (open: boolean) => void;
|
|
25
|
+
/** Element the surface is anchored to (and morphs from). */ anchorRef: React.RefObject<HTMLElement | null>;
|
|
26
|
+
/** Menu items (action, checkbox, radio, label, separator, submenu). */ items: MenuItem[];
|
|
27
|
+
/** Accessible name of the menu. */ label?: string;
|
|
28
|
+
/** Preferred side: "top" | "bottom" | "left" | "right" (flips when there is no room). */ side?: Side;
|
|
29
|
+
/** Alignment on the side: "start" | "center" | "end". */ align?: Align;
|
|
30
|
+
/** Gap between anchor and surface in px. Default --ul-popover-offset. */ offset?: number;
|
|
31
|
+
/** Called with the item id when an action item is chosen. */ onAction?: (id: string, item: MenuItem) => void;
|
|
32
|
+
/** Close after an action item is chosen. Default true (checkbox items keep it open). */ closeOnSelect?: boolean;
|
|
33
|
+
/** Focus the first (or last) item on open. Default first; null keeps focus on the trigger. */
|
|
34
|
+
initialFocus?: 'first' | 'last' | null;
|
|
35
|
+
/** Accent colour: accent name ("violet", "ice", "emerald", "amber", "rose") or a CSS colour (checked by guardAccent). */ accent?: Accent;
|
|
36
|
+
/** Backdrop hint for the glass: "dark" | "mid" | "light". */ backdrop?: Backdrop;
|
|
37
|
+
/** Extra class on the root element. */ className?: string;
|
|
38
|
+
/** Label of the back row when a submenu drills in (phones: no room beside the parent). Default "Back". */
|
|
39
|
+
backLabel?: string;
|
|
40
|
+
/** @internal tests */
|
|
41
|
+
surfaceRef?: React.MutableRefObject<HTMLElement | null>;
|
|
42
|
+
}
|
|
43
|
+
/** Dropdown menu. Wire the trigger with aria-haspopup="menu" + aria-expanded (ULMenuButton does it). */
|
|
44
|
+
export declare function ULMenu({ open, onOpenChange, anchorRef, items, label, side, align, offset, onAction, closeOnSelect, initialFocus, accent, backdrop, className, surfaceRef, backLabel }: ULMenuProps): React.JSX.Element;
|
|
45
|
+
/** Trigger + menu in one: a button with aria-haspopup / aria-expanded; ↓ / Enter / Space open on the first item, ↑ on the last. */
|
|
46
|
+
export declare function ULMenuButton({ children, items, label, onAction, side, align, buttonProps, className, closeOnSelect }: {
|
|
47
|
+
children: React.ReactNode;
|
|
48
|
+
items: MenuItem[];
|
|
49
|
+
label?: string;
|
|
50
|
+
onAction?: ULMenuProps['onAction'];
|
|
51
|
+
side?: Side;
|
|
52
|
+
align?: Align;
|
|
53
|
+
buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
54
|
+
className?: string; /** Forwarded to ULMenu (false keeps the menu open after an action, e.g. the columns menu). */
|
|
55
|
+
closeOnSelect?: boolean;
|
|
56
|
+
}): React.JSX.Element;
|
|
57
|
+
export interface ULContextMenuProps extends Omit<ULMenuProps, 'open' | 'onOpenChange' | 'anchorRef' | 'side' | 'align'> {
|
|
58
|
+
/** Target element; right-click, long-press, ContextMenu key and Shift+F10 open the menu at the pointer / element. */ children: React.ReactElement;
|
|
59
|
+
/** Ignore context-menu gestures (the browser menu shows). Default false. */ disabled?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Right-click (or long-press, Menu key, Shift+F10 on the focused target): the menu pours out of the POINTER point
|
|
63
|
+
* (0 × 0 virtual anchor) with the same morph. Keyboard: from the focused element's bottom-left corner.
|
|
64
|
+
*/
|
|
65
|
+
export declare function ULContextMenu({ children, items, label, onAction, disabled, closeOnSelect, accent, backdrop, className, surfaceRef }: ULContextMenuProps): React.JSX.Element;
|
|
66
|
+
export interface CommandItem {
|
|
67
|
+
id: string;
|
|
68
|
+
label: string;
|
|
69
|
+
group?: string;
|
|
70
|
+
keywords?: string[];
|
|
71
|
+
icon?: React.ReactNode;
|
|
72
|
+
shortcut?: string;
|
|
73
|
+
disabled?: boolean;
|
|
74
|
+
onRun?: () => void;
|
|
75
|
+
}
|
|
76
|
+
export interface ULCommandPaletteProps {
|
|
77
|
+
/** Controlled open state. */ open: boolean;
|
|
78
|
+
/** Called with the next open state (trigger, Esc, outside click, close button). */ onOpenChange: (open: boolean) => void;
|
|
79
|
+
/** Commands ({ id, label, group?, keywords?, shortcut?, onSelect? }). */ items: CommandItem[];
|
|
80
|
+
/** Search trigger it morphs from; otherwise it grows from the viewport centre. */
|
|
81
|
+
triggerRef?: React.RefObject<HTMLElement | null>;
|
|
82
|
+
/** Register Cmd / Ctrl + K. Default true. */
|
|
83
|
+
hotkey?: boolean;
|
|
84
|
+
/** Placeholder of the search input. */ placeholder?: string;
|
|
85
|
+
/** Accessible name of the palette dialog. */ label?: string;
|
|
86
|
+
/** Text when nothing matches. Default "No matching commands" (English; pass a translated string). */ emptyText?: string;
|
|
87
|
+
/** Heading of the recent group. Default "Recent" (English; pass a translated string). */ recentLabel?: string;
|
|
88
|
+
/** Recent command ids (controlled). Default: kept in memory for the session (never persisted). */
|
|
89
|
+
recent?: string[];
|
|
90
|
+
/** Called with the recent command ids after a run (persist them yourself). */ onRecentChange?: (ids: string[]) => void;
|
|
91
|
+
/** Wide reading layout (--ul-modal-w-reading). Default false. */ reading?: boolean;
|
|
92
|
+
/** Accent colour: accent name ("violet", "ice", "emerald", "amber", "rose") or a CSS colour (checked by guardAccent). */ accent?: Accent;
|
|
93
|
+
/** Extra class on the root element. */ className?: string;
|
|
94
|
+
/** @internal tests */
|
|
95
|
+
surfaceRef?: React.MutableRefObject<HTMLElement | null>;
|
|
96
|
+
}
|
|
97
|
+
/** Subsequence fuzzy score: consecutive and word-start matches score higher; -1 = no match. */
|
|
98
|
+
export declare function fuzzyScore(q: string, s: string): number;
|
|
99
|
+
export declare function ULCommandPalette({ open, onOpenChange, items, triggerRef, hotkey, placeholder, label, emptyText, recentLabel, recent, onRecentChange, reading, accent, className, surfaceRef }: ULCommandPaletteProps): React.JSX.Element;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Accent, AccentStrength, Backdrop } from '../../glass/accent.js';
|
|
3
|
+
import type { Align, Side } from '../../motion/placement.js';
|
|
4
|
+
import './ULContainers.css';
|
|
5
|
+
import { type ContextMenuProps } from './contextTarget.js';
|
|
6
|
+
export interface ULModalProps {
|
|
7
|
+
/** Controlled open state. */ open: boolean;
|
|
8
|
+
/** Called with the next open state (trigger, Esc, outside click, close button). */ onOpenChange?: (open: boolean) => void;
|
|
9
|
+
/** The trigger: the modal morphs out of it and focus returns to it. Without one it grows from the viewport centre. */
|
|
10
|
+
triggerRef?: React.RefObject<HTMLElement | null>;
|
|
11
|
+
/** Heading (labels the dialog / popover via aria-labelledby). */ title: React.ReactNode;
|
|
12
|
+
/** Text under the title (aria-describedby). */ description?: React.ReactNode;
|
|
13
|
+
/** Footer actions (right-aligned row). */ footer?: React.ReactNode;
|
|
14
|
+
/** sm 400 · md 520 · reading 680 (light reading backdrop, larger line length). */
|
|
15
|
+
size?: 'sm' | 'md' | 'reading';
|
|
16
|
+
/** alertdialog: no scrim close, Esc still closes (cancel). */
|
|
17
|
+
role?: 'dialog' | 'alertdialog';
|
|
18
|
+
/** Close when the scrim is clicked. Default true. */ closeOnScrim?: boolean;
|
|
19
|
+
/** Hide the close button (keep another way to close). Default false. */ hideClose?: boolean;
|
|
20
|
+
/** Accessible label of the close button. Default "Close" (English; pass a translated string). */ closeLabel?: string;
|
|
21
|
+
/** auto (default): bottom sheet ≤ 640px; always: always a sheet; never. */
|
|
22
|
+
sheet?: 'auto' | 'always' | 'never';
|
|
23
|
+
/** Element (or selector) focused on open; null = the surface itself. Default: first focusable. */ initialFocus?: HTMLElement | string | null;
|
|
24
|
+
/** Accent colour: accent name ("violet", "ice", "emerald", "amber", "rose") or a CSS colour (checked by guardAccent). */ accent?: Accent;
|
|
25
|
+
/** "subtle" | "tinted" | "vivid" accent intensity of the glass. */ accentStrength?: AccentStrength;
|
|
26
|
+
/** Backdrop hint for the glass: "dark" | "mid" | "light". */ backdrop?: Backdrop;
|
|
27
|
+
/** Extra class on the root element. */ className?: string;
|
|
28
|
+
/** Dialog body. */ children?: React.ReactNode;
|
|
29
|
+
/** @internal tests */
|
|
30
|
+
surfaceRef?: React.MutableRefObject<HTMLElement | null>;
|
|
31
|
+
}
|
|
32
|
+
export declare function ULModal({ open, onOpenChange, triggerRef, title, description, footer, size, role, closeOnScrim, closeLabel, sheet, initialFocus, accent, accentStrength, backdrop, className, children, surfaceRef }: ULModalProps): React.JSX.Element;
|
|
33
|
+
/** Bottom sheet on every viewport (same component, sheet="always"). */
|
|
34
|
+
export declare function ULSheet(props: Omit<ULModalProps, 'sheet'>): React.JSX.Element;
|
|
35
|
+
export interface ULDrawerProps extends Omit<ULModalProps, 'size' | 'sheet' | 'role' | 'triggerRef'> {
|
|
36
|
+
/** right (default; future user drawer) | left (navigation). */
|
|
37
|
+
side?: 'left' | 'right';
|
|
38
|
+
/** The trigger: focus returns to it. The drawer itself grows in from the edge. */
|
|
39
|
+
triggerRef?: React.RefObject<HTMLElement | null>;
|
|
40
|
+
/** auto (default): bottom sheet ≤ 640px. */
|
|
41
|
+
sheet?: 'auto' | 'never';
|
|
42
|
+
}
|
|
43
|
+
export declare function ULDrawer({ open, onOpenChange, side, triggerRef, title, description, footer, closeOnScrim, closeLabel, sheet, initialFocus, accent, accentStrength, backdrop, className, children, surfaceRef }: ULDrawerProps): React.JSX.Element;
|
|
44
|
+
export interface ULPopoverProps {
|
|
45
|
+
/** Controlled open state. */ open: boolean;
|
|
46
|
+
/** Called with the next open state (trigger, Esc, outside click, close button). */ onOpenChange?: (open: boolean) => void;
|
|
47
|
+
/** Trigger element: the surface morphs from it and focus returns to it on close. */ triggerRef: React.RefObject<HTMLElement | null>;
|
|
48
|
+
/** Preferred side: "top" | "bottom" | "left" | "right" (flips when there is no room). */ side?: Side;
|
|
49
|
+
/** Alignment on the side: "start" | "center" | "end". */ align?: Align;
|
|
50
|
+
/** Show the glass arrow toward the trigger. Default false. */ arrow?: boolean;
|
|
51
|
+
/** Reading variant: light backdrop class (dark text scrim stays), wider. */
|
|
52
|
+
reading?: boolean;
|
|
53
|
+
/** Accessible name when there is no visible title. */
|
|
54
|
+
label?: string;
|
|
55
|
+
/** Heading (labels the dialog / popover via aria-labelledby). */ title?: React.ReactNode;
|
|
56
|
+
/** Move focus into the popover on open (default true when it has focusable content). */
|
|
57
|
+
autoFocus?: boolean;
|
|
58
|
+
/** Accent colour: accent name ("violet", "ice", "emerald", "amber", "rose") or a CSS colour (checked by guardAccent). */ accent?: Accent;
|
|
59
|
+
/** Backdrop hint for the glass: "dark" | "mid" | "light". */ backdrop?: Backdrop;
|
|
60
|
+
/** Extra class on the root element. */ className?: string;
|
|
61
|
+
/** Popover body. */ children?: React.ReactNode;
|
|
62
|
+
/** 'covered': the surface starts at the trigger rect in the top layer and covers it from frame 0 (non-modal, no scrim). Default 'above'. */
|
|
63
|
+
anchorVisibility?: 'above' | 'covered';
|
|
64
|
+
/** Close button in the header. Default: on when covered (the trigger is hidden under the surface). */
|
|
65
|
+
closeButton?: boolean;
|
|
66
|
+
/** Accessible label of the close button. Default "Close" (English; pass a translated string). */ closeLabel?: string;
|
|
67
|
+
/** @internal tests */
|
|
68
|
+
surfaceRef?: React.MutableRefObject<HTMLElement | null>;
|
|
69
|
+
}
|
|
70
|
+
export declare function ULPopover({ open, onOpenChange, triggerRef, side, align, arrow, reading, label, title, autoFocus, accent, backdrop, className, children, surfaceRef, anchorVisibility, closeButton, closeLabel }: ULPopoverProps): React.JSX.Element;
|
|
71
|
+
export interface ULTooltipProps {
|
|
72
|
+
content: string; /** Preferred side. Default "top". */
|
|
73
|
+
side?: 'top' | 'bottom' | 'left' | 'right'; /** Open delay in ms. Default the shared tooltip delay. */
|
|
74
|
+
delay?: number; /** Trigger element (must be focusable). */
|
|
75
|
+
children: React.ReactElement;
|
|
76
|
+
}
|
|
77
|
+
export declare function ULTooltip({ content, side, delay, children }: ULTooltipProps): React.JSX.Element;
|
|
78
|
+
export type ToastTone = 'neutral' | 'success' | 'warning' | 'danger';
|
|
79
|
+
export interface ToastOptions {
|
|
80
|
+
title: React.ReactNode;
|
|
81
|
+
description?: React.ReactNode;
|
|
82
|
+
tone?: ToastTone;
|
|
83
|
+
action?: {
|
|
84
|
+
label: string;
|
|
85
|
+
onAction: () => void;
|
|
86
|
+
};
|
|
87
|
+
duration?: number;
|
|
88
|
+
id?: string;
|
|
89
|
+
}
|
|
90
|
+
/** One toast anchored to its trigger (e.g. "Copied" from a copy button). Fixed while open; Esc (focus inside) / swipe / timer dismiss. */
|
|
91
|
+
export interface ULToastProps extends ToastOptions, ContextMenuProps<ToastOptions> {
|
|
92
|
+
open: boolean; /** Called with the next open state (trigger, Esc, outside click, close button). */
|
|
93
|
+
onOpenChange?: (open: boolean) => void; /** Trigger the toast morphs from (optional; without it the toast enters from its stack). */
|
|
94
|
+
anchorRef: React.RefObject<HTMLElement | null>; /** Preferred side: "top" | "bottom" | "left" | "right" (flips when there is no room). */
|
|
95
|
+
side?: Side; /** Accessible label of the dismiss button. Default "Dismiss" (English; pass a translated string). */
|
|
96
|
+
dismissLabel?: string;
|
|
97
|
+
}
|
|
98
|
+
/** contextMenu target: { component: 'toast', kind: 'self', data: the toast options }. */
|
|
99
|
+
export declare function ULToast({ open, onOpenChange, anchorRef, side, dismissLabel, duration, ...t0 }: ULToastProps): React.JSX.Element;
|
|
100
|
+
interface ToastApi {
|
|
101
|
+
toast(o: ToastOptions): string;
|
|
102
|
+
dismiss(id?: string): void;
|
|
103
|
+
}
|
|
104
|
+
export declare const useToast: () => ToastApi;
|
|
105
|
+
export interface ULToastProviderProps {
|
|
106
|
+
position?: 'bottom-right' | 'bottom-center' | 'top-right' | 'top-center'; /** Visible at once; the rest wait in a queue. Default --ul-toast-max (3). */
|
|
107
|
+
max?: number; /** Accessible label of the dismiss button. Default "Dismiss" (English; pass a translated string). */
|
|
108
|
+
dismissLabel?: string; /** Accessible name of the toast region. Default "Notifications" (English; pass a translated string). */
|
|
109
|
+
label?: string; /** App content. */
|
|
110
|
+
children?: React.ReactNode;
|
|
111
|
+
}
|
|
112
|
+
export declare function ULToastProvider({ position, max, dismissLabel, label, children }: ULToastProviderProps): React.JSX.Element;
|
|
113
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One shared context-menu mechanism (B). Every component that takes `contextMenu` routes through useContextMenuTarget:
|
|
3
|
+
* one handler set on the component ROOT (event delegation, never per row), the menu is the existing ULMenu on a 0 × 0
|
|
4
|
+
* virtual anchor at the pointer (same anchored morph as ULContextMenu), so there is no new overlay or animation code.
|
|
5
|
+
* Right-click, long-press (touch, ~500ms, cancelled by movement; scroll wins), ContextMenu key and Shift+F10.
|
|
6
|
+
* Returning null / [] from the callback keeps the native browser menu.
|
|
7
|
+
*/
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { type MenuItem } from './ULMenu.js';
|
|
10
|
+
export interface ContextTarget<D = unknown> {
|
|
11
|
+
/** 'table' | 'kpi' | 'chart' | 'card' | … */
|
|
12
|
+
component: string;
|
|
13
|
+
/** what was hit: 'row' | 'cell' | 'header' | 'point' | 'series' | 'plot' | 'tab' | 'item' | 'self' … */
|
|
14
|
+
kind: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
data?: D;
|
|
17
|
+
/** Table: the column key (cell / header). */
|
|
18
|
+
column?: string;
|
|
19
|
+
/** Table: keys the menu acts on (the selection when the row is selected, else just the row). */
|
|
20
|
+
selection?: string[];
|
|
21
|
+
/** The element the menu returns focus to. */
|
|
22
|
+
el: HTMLElement;
|
|
23
|
+
}
|
|
24
|
+
export type ContextMenuSpec<D = unknown> = MenuItem[] | ((target: ContextTarget<D>) => MenuItem[] | null | undefined);
|
|
25
|
+
export interface ContextMenuProps<D = unknown> {
|
|
26
|
+
contextMenu?: ContextMenuSpec<D>;
|
|
27
|
+
onContextMenuOpen?: (t: ContextTarget<D>) => void;
|
|
28
|
+
onContextMenuClose?: (t: ContextTarget<D>) => void;
|
|
29
|
+
/** Called with the chosen item id (items may also carry their own onSelect). */
|
|
30
|
+
onContextMenuAction?: (id: string, t: ContextTarget<D>) => void;
|
|
31
|
+
/** Where the native menu stays: never | on-text-selection | on-editable (default: on-editable + on-text-selection). */
|
|
32
|
+
contextMenuNative?: 'never' | 'on-text-selection' | 'on-editable';
|
|
33
|
+
contextMenuLabel?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function resolveMenu<D>(spec: ContextMenuSpec<D> | undefined, t: ContextTarget<D>): MenuItem[] | null;
|
|
36
|
+
export interface UseContextMenuOptions<D> extends ContextMenuProps<D> {
|
|
37
|
+
component: string;
|
|
38
|
+
/** Map the hit element to a target (null = not a target → native menu). Default: the root itself, kind 'self'. */
|
|
39
|
+
resolve?: (hit: Element, root: HTMLElement) => Omit<ContextTarget<D>, 'component'> | null;
|
|
40
|
+
/** Keyboard (ContextMenu / Shift+F10): the point to open at for a target. Default: the focused element's bottom-left. */
|
|
41
|
+
keyPoint?: (t: ContextTarget<D>) => {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
} | null;
|
|
45
|
+
}
|
|
46
|
+
export interface ContextMenuApi<D> {
|
|
47
|
+
/** Spread onto the component root. Empty object when no contextMenu is given (zero cost). */
|
|
48
|
+
bind: {
|
|
49
|
+
onContextMenu?: React.MouseEventHandler;
|
|
50
|
+
onKeyDown?: React.KeyboardEventHandler;
|
|
51
|
+
onPointerDown?: React.PointerEventHandler;
|
|
52
|
+
'aria-haspopup'?: 'menu';
|
|
53
|
+
};
|
|
54
|
+
menu: React.ReactNode;
|
|
55
|
+
/** Target of the open menu (tables pin that row and show it as active). */
|
|
56
|
+
active: ContextTarget<D> | null;
|
|
57
|
+
/** Programmatic open (tests, a visible "more" button). */
|
|
58
|
+
openFor: (t: ContextTarget<D>, x?: number, y?: number) => boolean;
|
|
59
|
+
close: () => void;
|
|
60
|
+
}
|
|
61
|
+
export declare function useContextMenuTarget<D = unknown>(o: UseContextMenuOptions<D>): ContextMenuApi<D>;
|
|
62
|
+
/** Merge the context-menu handlers into existing element props (keeps the element's own handlers). */
|
|
63
|
+
export declare function mergeCtx<P extends Record<string, unknown>>(props: P, bind: ContextMenuApi<unknown>['bind']): P;
|
|
64
|
+
/** Generic wrapper for anything without its own prop: <ULContextTarget contextMenu={…} target={{ kind, id, data }}>{child}</ULContextTarget>. */
|
|
65
|
+
export interface ULContextTargetProps<D = unknown> extends ContextMenuProps<D> {
|
|
66
|
+
children: React.ReactElement;
|
|
67
|
+
component?: string;
|
|
68
|
+
target?: {
|
|
69
|
+
kind?: string;
|
|
70
|
+
id?: string;
|
|
71
|
+
data?: D;
|
|
72
|
+
};
|
|
73
|
+
disabled?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export declare function ULContextTarget<D = unknown>({ children, component, target, disabled, ...p }: ULContextTargetProps<D>): React.JSX.Element;
|
|
76
|
+
declare const CTX_KEYS: readonly ["contextMenu", "onContextMenuOpen", "onContextMenuClose", "onContextMenuAction", "contextMenuNative", "contextMenuLabel"];
|
|
77
|
+
/** Split the context-menu props off a props object (so they never reach the DOM). */
|
|
78
|
+
export declare function splitCtx<T extends object>(props: T): [ContextMenuProps<any>, Omit<T, (typeof CTX_KEYS)[number]>];
|
|
79
|
+
/** List-like components: the target is the item under the pointer (selector), its id from data-value / data-ctx-id / text. */
|
|
80
|
+
export interface CtxItems<D> {
|
|
81
|
+
selector: string;
|
|
82
|
+
kind: string;
|
|
83
|
+
data?: (id: string, el: HTMLElement) => D | undefined;
|
|
84
|
+
}
|
|
85
|
+
/** Wrap a component's root element when (and only when) it has a contextMenu prop. */
|
|
86
|
+
export declare function withContextMenu<D>(el: React.ReactElement, p: ContextMenuProps<D>, component: string, target?: {
|
|
87
|
+
kind?: string;
|
|
88
|
+
id?: string;
|
|
89
|
+
data?: D;
|
|
90
|
+
}, items?: CtxItems<D>, contents?: boolean): React.ReactElement;
|
|
91
|
+
export {};
|