@lab206/ui 0.1.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 +114 -0
- package/README.md +6 -0
- package/dist/components/Accordion.d.ts +25 -0
- package/dist/components/Accordion.d.ts.map +1 -0
- package/dist/components/Accordion.js +123 -0
- package/dist/components/Accordion.js.map +1 -0
- package/dist/components/Alert.d.ts +17 -0
- package/dist/components/Alert.d.ts.map +1 -0
- package/dist/components/Alert.js +59 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/AspectRatio.d.ts +13 -0
- package/dist/components/AspectRatio.d.ts.map +1 -0
- package/dist/components/AspectRatio.js +38 -0
- package/dist/components/AspectRatio.js.map +1 -0
- package/dist/components/Avatar.d.ts +17 -0
- package/dist/components/Avatar.d.ts.map +1 -0
- package/dist/components/Avatar.js +57 -0
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/Badge.d.ts +12 -0
- package/dist/components/Badge.d.ts.map +1 -0
- package/dist/components/Badge.js +62 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Breadcrumb.d.ts +16 -0
- package/dist/components/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Breadcrumb.js +76 -0
- package/dist/components/Breadcrumb.js.map +1 -0
- package/dist/components/Button.d.ts +28 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Button.js +110 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/Card.d.ts +18 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Card.js +57 -0
- package/dist/components/Card.js.map +1 -0
- package/dist/components/Checkbox.d.ts +23 -0
- package/dist/components/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox.js +107 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/Chip.d.ts +18 -0
- package/dist/components/Chip.d.ts.map +1 -0
- package/dist/components/Chip.js +103 -0
- package/dist/components/Chip.js.map +1 -0
- package/dist/components/Code.d.ts +12 -0
- package/dist/components/Code.d.ts.map +1 -0
- package/dist/components/Code.js +57 -0
- package/dist/components/Code.js.map +1 -0
- package/dist/components/Collapse.d.ts +15 -0
- package/dist/components/Collapse.d.ts.map +1 -0
- package/dist/components/Collapse.js +49 -0
- package/dist/components/Collapse.js.map +1 -0
- package/dist/components/Combobox.d.ts +47 -0
- package/dist/components/Combobox.d.ts.map +1 -0
- package/dist/components/Combobox.js +325 -0
- package/dist/components/Combobox.js.map +1 -0
- package/dist/components/Command.d.ts +42 -0
- package/dist/components/Command.d.ts.map +1 -0
- package/dist/components/Command.js +263 -0
- package/dist/components/Command.js.map +1 -0
- package/dist/components/Container.d.ts +11 -0
- package/dist/components/Container.d.ts.map +1 -0
- package/dist/components/Container.js +38 -0
- package/dist/components/Container.js.map +1 -0
- package/dist/components/Dialog.d.ts +26 -0
- package/dist/components/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog.js +159 -0
- package/dist/components/Dialog.js.map +1 -0
- package/dist/components/Divider.d.ts +10 -0
- package/dist/components/Divider.d.ts.map +1 -0
- package/dist/components/Divider.js +52 -0
- package/dist/components/Divider.js.map +1 -0
- package/dist/components/Drawer.d.ts +19 -0
- package/dist/components/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer.js +131 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/Empty.d.ts +17 -0
- package/dist/components/Empty.d.ts.map +1 -0
- package/dist/components/Empty.js +51 -0
- package/dist/components/Empty.js.map +1 -0
- package/dist/components/Field.d.ts +27 -0
- package/dist/components/Field.d.ts.map +1 -0
- package/dist/components/Field.js +153 -0
- package/dist/components/Field.js.map +1 -0
- package/dist/components/Grid.d.ts +13 -0
- package/dist/components/Grid.d.ts.map +1 -0
- package/dist/components/Grid.js +44 -0
- package/dist/components/Grid.js.map +1 -0
- package/dist/components/Input.d.ts +55 -0
- package/dist/components/Input.d.ts.map +1 -0
- package/dist/components/Input.js +113 -0
- package/dist/components/Input.js.map +1 -0
- package/dist/components/Kbd.d.ts +10 -0
- package/dist/components/Kbd.d.ts.map +1 -0
- package/dist/components/Kbd.js +41 -0
- package/dist/components/Kbd.js.map +1 -0
- package/dist/components/Label.d.ts +13 -0
- package/dist/components/Label.d.ts.map +1 -0
- package/dist/components/Label.js +34 -0
- package/dist/components/Label.js.map +1 -0
- package/dist/components/Link.d.ts +18 -0
- package/dist/components/Link.d.ts.map +1 -0
- package/dist/components/Link.js +41 -0
- package/dist/components/Link.js.map +1 -0
- package/dist/components/List.d.ts +22 -0
- package/dist/components/List.d.ts.map +1 -0
- package/dist/components/List.js +157 -0
- package/dist/components/List.js.map +1 -0
- package/dist/components/Menu.d.ts +28 -0
- package/dist/components/Menu.d.ts.map +1 -0
- package/dist/components/Menu.js +126 -0
- package/dist/components/Menu.js.map +1 -0
- package/dist/components/NumberInput.d.ts +27 -0
- package/dist/components/NumberInput.d.ts.map +1 -0
- package/dist/components/NumberInput.js +92 -0
- package/dist/components/NumberInput.js.map +1 -0
- package/dist/components/Pagination.d.ts +13 -0
- package/dist/components/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination.js +104 -0
- package/dist/components/Pagination.js.map +1 -0
- package/dist/components/Popover.d.ts +26 -0
- package/dist/components/Popover.d.ts.map +1 -0
- package/dist/components/Popover.js +165 -0
- package/dist/components/Popover.js.map +1 -0
- package/dist/components/Progress.d.ts +15 -0
- package/dist/components/Progress.d.ts.map +1 -0
- package/dist/components/Progress.js +63 -0
- package/dist/components/Progress.js.map +1 -0
- package/dist/components/Radio.d.ts +25 -0
- package/dist/components/Radio.d.ts.map +1 -0
- package/dist/components/Radio.js +95 -0
- package/dist/components/Radio.js.map +1 -0
- package/dist/components/ScrollArea.d.ts +13 -0
- package/dist/components/ScrollArea.d.ts.map +1 -0
- package/dist/components/ScrollArea.js +33 -0
- package/dist/components/ScrollArea.js.map +1 -0
- package/dist/components/Select.d.ts +34 -0
- package/dist/components/Select.d.ts.map +1 -0
- package/dist/components/Select.js +108 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Skeleton.d.ts +18 -0
- package/dist/components/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton.js +86 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/Slider.d.ts +26 -0
- package/dist/components/Slider.d.ts.map +1 -0
- package/dist/components/Slider.js +113 -0
- package/dist/components/Slider.js.map +1 -0
- package/dist/components/Spinner.d.ts +12 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +44 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Stack.d.ts +21 -0
- package/dist/components/Stack.d.ts.map +1 -0
- package/dist/components/Stack.js +48 -0
- package/dist/components/Stack.js.map +1 -0
- package/dist/components/Stat.d.ts +23 -0
- package/dist/components/Stat.d.ts.map +1 -0
- package/dist/components/Stat.js +115 -0
- package/dist/components/Stat.js.map +1 -0
- package/dist/components/Steps.d.ts +20 -0
- package/dist/components/Steps.d.ts.map +1 -0
- package/dist/components/Steps.js +126 -0
- package/dist/components/Steps.js.map +1 -0
- package/dist/components/Switch.d.ts +23 -0
- package/dist/components/Switch.d.ts.map +1 -0
- package/dist/components/Switch.js +108 -0
- package/dist/components/Switch.js.map +1 -0
- package/dist/components/Table.d.ts +27 -0
- package/dist/components/Table.d.ts.map +1 -0
- package/dist/components/Table.js +112 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/Tabs.d.ts +27 -0
- package/dist/components/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs.js +171 -0
- package/dist/components/Tabs.js.map +1 -0
- package/dist/components/Text.d.ts +17 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/Text.js +48 -0
- package/dist/components/Text.js.map +1 -0
- package/dist/components/Textarea.d.ts +32 -0
- package/dist/components/Textarea.d.ts.map +1 -0
- package/dist/components/Textarea.js +91 -0
- package/dist/components/Textarea.js.map +1 -0
- package/dist/components/Timeline.d.ts +17 -0
- package/dist/components/Timeline.d.ts.map +1 -0
- package/dist/components/Timeline.js +95 -0
- package/dist/components/Timeline.js.map +1 -0
- package/dist/components/Toast.d.ts +36 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/Toast.js +143 -0
- package/dist/components/Toast.js.map +1 -0
- package/dist/components/ToggleGroup.d.ts +25 -0
- package/dist/components/ToggleGroup.d.ts.map +1 -0
- package/dist/components/ToggleGroup.js +103 -0
- package/dist/components/ToggleGroup.js.map +1 -0
- package/dist/components/Tooltip.d.ts +19 -0
- package/dist/components/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip.js +141 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/Transition.d.ts +22 -0
- package/dist/components/Transition.d.ts.map +1 -0
- package/dist/components/Transition.js +139 -0
- package/dist/components/Transition.js.map +1 -0
- package/dist/density.d.ts +21 -0
- package/dist/density.d.ts.map +1 -0
- package/dist/density.js +31 -0
- package/dist/density.js.map +1 -0
- package/dist/dev.d.ts +27 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/dev.js +77 -0
- package/dist/dev.js.map +1 -0
- package/dist/focusTrap.d.ts +6 -0
- package/dist/focusTrap.d.ts.map +1 -0
- package/dist/focusTrap.js +55 -0
- package/dist/focusTrap.js.map +1 -0
- package/dist/form.d.ts +125 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +192 -0
- package/dist/form.js.map +1 -0
- package/dist/index.d.ts +134 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/motion.d.ts +29 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +43 -0
- package/dist/motion.js.map +1 -0
- package/dist/overlay.d.ts +63 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +172 -0
- package/dist/overlay.js.map +1 -0
- package/dist/palette.d.ts +20 -0
- package/dist/palette.d.ts.map +1 -0
- package/dist/palette.js +52 -0
- package/dist/palette.js.map +1 -0
- package/dist/reactive.d.ts +25 -0
- package/dist/reactive.d.ts.map +1 -0
- package/dist/reactive.js +43 -0
- package/dist/reactive.js.map +1 -0
- package/dist/rovingFocus.d.ts +36 -0
- package/dist/rovingFocus.d.ts.map +1 -0
- package/dist/rovingFocus.js +127 -0
- package/dist/rovingFocus.js.map +1 -0
- package/dist/size-entries/form-kit.d.ts +12 -0
- package/dist/size-entries/form-kit.d.ts.map +1 -0
- package/dist/size-entries/form-kit.js +12 -0
- package/dist/size-entries/form-kit.js.map +1 -0
- package/dist/styles.d.ts +29 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +53 -0
- package/dist/styles.js.map +1 -0
- package/dist/theme.d.ts +22 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +32 -0
- package/dist/theme.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +24 -0
- package/dist/utils.js.map +1 -0
- package/package.json +71 -0
- package/src/components/Accordion.tsx +194 -0
- package/src/components/Alert.tsx +88 -0
- package/src/components/AspectRatio.tsx +64 -0
- package/src/components/Avatar.tsx +89 -0
- package/src/components/Badge.tsx +84 -0
- package/src/components/Breadcrumb.tsx +116 -0
- package/src/components/Button.tsx +148 -0
- package/src/components/Card.tsx +92 -0
- package/src/components/Checkbox.tsx +143 -0
- package/src/components/Chip.tsx +153 -0
- package/src/components/Code.tsx +71 -0
- package/src/components/Collapse.tsx +76 -0
- package/src/components/Combobox.tsx +438 -0
- package/src/components/Command.tsx +380 -0
- package/src/components/Container.tsx +58 -0
- package/src/components/Dialog.tsx +226 -0
- package/src/components/Divider.tsx +72 -0
- package/src/components/Drawer.tsx +191 -0
- package/src/components/Empty.tsx +86 -0
- package/src/components/Field.tsx +184 -0
- package/src/components/Grid.tsx +67 -0
- package/src/components/Input.tsx +169 -0
- package/src/components/Kbd.tsx +57 -0
- package/src/components/Label.tsx +54 -0
- package/src/components/Link.tsx +87 -0
- package/src/components/List.tsx +236 -0
- package/src/components/Menu.tsx +195 -0
- package/src/components/NumberInput.tsx +158 -0
- package/src/components/Pagination.tsx +153 -0
- package/src/components/Popover.tsx +219 -0
- package/src/components/Progress.tsx +108 -0
- package/src/components/Radio.tsx +161 -0
- package/src/components/ScrollArea.tsx +58 -0
- package/src/components/Select.tsx +128 -0
- package/src/components/Skeleton.tsx +117 -0
- package/src/components/Slider.tsx +175 -0
- package/src/components/Spinner.tsx +70 -0
- package/src/components/Stack.tsx +79 -0
- package/src/components/Stat.tsx +169 -0
- package/src/components/Steps.tsx +191 -0
- package/src/components/Switch.tsx +146 -0
- package/src/components/Table.tsx +168 -0
- package/src/components/Tabs.tsx +246 -0
- package/src/components/Text.tsx +69 -0
- package/src/components/Textarea.tsx +128 -0
- package/src/components/Timeline.tsx +150 -0
- package/src/components/Toast.tsx +221 -0
- package/src/components/ToggleGroup.tsx +161 -0
- package/src/components/Tooltip.tsx +187 -0
- package/src/components/Transition.tsx +155 -0
- package/src/density.ts +46 -0
- package/src/dev.ts +87 -0
- package/src/focusTrap.ts +61 -0
- package/src/form.ts +269 -0
- package/src/index.ts +243 -0
- package/src/motion.ts +62 -0
- package/src/overlay.ts +232 -0
- package/src/palette.ts +70 -0
- package/src/reactive.ts +54 -0
- package/src/rovingFocus.ts +171 -0
- package/src/size-entries/form-kit.ts +11 -0
- package/src/styles/base.css +70 -0
- package/src/styles/theme.css +14 -0
- package/src/styles/tokens.css +377 -0
- package/src/styles/utilities.css +216 -0
- package/src/styles.ts +52 -0
- package/src/theme.ts +48 -0
- package/src/utils.ts +25 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { component, mergeProps, type ComponentProps } from "@lab206/dom";
|
|
2
|
+
import { cx } from "../utils.js";
|
|
3
|
+
|
|
4
|
+
export type DividerProps = {
|
|
5
|
+
/** Visual label centered on the line */
|
|
6
|
+
label?: string;
|
|
7
|
+
class?: string | (() => string);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const styles = `
|
|
11
|
+
.pu-divider {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: var(--pu-space-3);
|
|
15
|
+
width: 100%;
|
|
16
|
+
border: 0;
|
|
17
|
+
margin: var(--pu-space-4) 0;
|
|
18
|
+
color: var(--pu-color-text-muted);
|
|
19
|
+
font-size: var(--pu-text-xs);
|
|
20
|
+
font-weight: var(--pu-font-semibold);
|
|
21
|
+
letter-spacing: 0.04em;
|
|
22
|
+
text-transform: uppercase;
|
|
23
|
+
}
|
|
24
|
+
.pu-divider::before,
|
|
25
|
+
.pu-divider::after {
|
|
26
|
+
content: "";
|
|
27
|
+
flex: 1;
|
|
28
|
+
height: 1px;
|
|
29
|
+
background: var(--pu-color-border);
|
|
30
|
+
}
|
|
31
|
+
.pu-divider--plain {
|
|
32
|
+
height: 1px;
|
|
33
|
+
margin: var(--pu-space-4) 0;
|
|
34
|
+
background: var(--pu-color-border);
|
|
35
|
+
gap: 0;
|
|
36
|
+
text-indent: -9999px;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
}
|
|
39
|
+
.pu-divider--plain::before,
|
|
40
|
+
.pu-divider--plain::after { display: none; }
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
let injected = false;
|
|
44
|
+
function ensureStyles() {
|
|
45
|
+
if (injected || typeof document === "undefined") return;
|
|
46
|
+
injected = true;
|
|
47
|
+
const el = document.createElement("style");
|
|
48
|
+
el.setAttribute("data-pu-ui", "divider");
|
|
49
|
+
el.textContent = styles;
|
|
50
|
+
document.head.appendChild(el);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const Divider = component((raw: DividerProps) => {
|
|
54
|
+
ensureStyles();
|
|
55
|
+
const props = mergeProps({}, raw) as ComponentProps<DividerProps>;
|
|
56
|
+
const hasLabel = !!props.label;
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div
|
|
60
|
+
role="separator"
|
|
61
|
+
class={() =>
|
|
62
|
+
cx(
|
|
63
|
+
"pu-divider",
|
|
64
|
+
!hasLabel && "pu-divider--plain",
|
|
65
|
+
typeof props.class === "function" ? props.class() : props.class,
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
>
|
|
69
|
+
{hasLabel ? props.label : "\u00a0"}
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
});
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { effect } from "@lab206/core";
|
|
2
|
+
import { component, mergeProps, type ComponentProps } from "@lab206/dom";
|
|
3
|
+
import { cx } from "../utils.js";
|
|
4
|
+
import { createStyleSheet } from "../styles.js";
|
|
5
|
+
import { attachOverlay } from "../overlay.js";
|
|
6
|
+
import { readBool, type MaybeReactive } from "../reactive.js";
|
|
7
|
+
|
|
8
|
+
export type DrawerProps = {
|
|
9
|
+
open: MaybeReactive<boolean>;
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
title?: string;
|
|
12
|
+
side?: "left" | "right";
|
|
13
|
+
class?: MaybeReactive<string>;
|
|
14
|
+
children?: unknown;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const ensure = createStyleSheet(
|
|
18
|
+
"drawer",
|
|
19
|
+
`
|
|
20
|
+
.pu-drawer-root {
|
|
21
|
+
position: fixed;
|
|
22
|
+
inset: 0;
|
|
23
|
+
z-index: var(--pu-z-overlay);
|
|
24
|
+
pointer-events: none;
|
|
25
|
+
opacity: 0;
|
|
26
|
+
visibility: hidden;
|
|
27
|
+
transition: opacity var(--pu-duration) var(--pu-ease-out),
|
|
28
|
+
visibility var(--pu-duration) var(--pu-ease-out);
|
|
29
|
+
}
|
|
30
|
+
.pu-drawer-root--open {
|
|
31
|
+
pointer-events: auto;
|
|
32
|
+
opacity: 1;
|
|
33
|
+
visibility: visible;
|
|
34
|
+
}
|
|
35
|
+
.pu-drawer-backdrop {
|
|
36
|
+
position: absolute;
|
|
37
|
+
inset: 0;
|
|
38
|
+
background: var(--pu-overlay-scrim);
|
|
39
|
+
backdrop-filter: blur(4px);
|
|
40
|
+
}
|
|
41
|
+
.pu-drawer-panel {
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 0;
|
|
44
|
+
bottom: 0;
|
|
45
|
+
width: min(22rem, 92vw);
|
|
46
|
+
background: var(--pu-color-surface-elevated);
|
|
47
|
+
color: var(--pu-color-text);
|
|
48
|
+
border: 0 solid var(--pu-color-border);
|
|
49
|
+
box-shadow: var(--pu-shadow-float);
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
transition: transform var(--pu-duration-slow) var(--pu-ease-out);
|
|
53
|
+
}
|
|
54
|
+
.pu-drawer-panel--right {
|
|
55
|
+
right: 0;
|
|
56
|
+
border-left-width: 1px;
|
|
57
|
+
transform: translateX(100%);
|
|
58
|
+
}
|
|
59
|
+
.pu-drawer-panel--left {
|
|
60
|
+
left: 0;
|
|
61
|
+
border-right-width: 1px;
|
|
62
|
+
transform: translateX(-100%);
|
|
63
|
+
}
|
|
64
|
+
.pu-drawer-root--open .pu-drawer-panel { transform: translateX(0); }
|
|
65
|
+
.pu-drawer__head {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: space-between;
|
|
69
|
+
gap: 0.5rem;
|
|
70
|
+
padding: var(--pu-space-4);
|
|
71
|
+
border-bottom: 1px solid var(--pu-color-border);
|
|
72
|
+
}
|
|
73
|
+
.pu-drawer__title {
|
|
74
|
+
margin: 0;
|
|
75
|
+
font-size: var(--pu-text-lg);
|
|
76
|
+
font-weight: var(--pu-font-bold);
|
|
77
|
+
letter-spacing: var(--pu-tracking-tight);
|
|
78
|
+
}
|
|
79
|
+
.pu-drawer__close {
|
|
80
|
+
appearance: none;
|
|
81
|
+
border: 0;
|
|
82
|
+
background: transparent;
|
|
83
|
+
color: var(--pu-color-text-muted);
|
|
84
|
+
font-size: 1.2rem;
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
width: 2rem;
|
|
87
|
+
height: 2rem;
|
|
88
|
+
border-radius: var(--pu-radius-md);
|
|
89
|
+
}
|
|
90
|
+
.pu-drawer__close:hover {
|
|
91
|
+
background: var(--pu-color-surface-2);
|
|
92
|
+
color: var(--pu-color-text);
|
|
93
|
+
}
|
|
94
|
+
.pu-drawer__close:focus-visible {
|
|
95
|
+
outline: none;
|
|
96
|
+
color: var(--pu-color-text);
|
|
97
|
+
box-shadow:
|
|
98
|
+
0 0 0 2px var(--pu-color-surface-elevated),
|
|
99
|
+
0 0 0 4px color-mix(in srgb, var(--pu-color-focus) 55%, transparent);
|
|
100
|
+
}
|
|
101
|
+
.pu-drawer__body {
|
|
102
|
+
padding: var(--pu-space-4);
|
|
103
|
+
overflow: auto;
|
|
104
|
+
flex: 1;
|
|
105
|
+
font-size: var(--pu-text-sm);
|
|
106
|
+
line-height: 1.55;
|
|
107
|
+
}
|
|
108
|
+
@media (prefers-reduced-motion: reduce) {
|
|
109
|
+
.pu-drawer-root, .pu-drawer-panel { transition: none; }
|
|
110
|
+
}
|
|
111
|
+
`,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
/** Slide-over panel. Esc + backdrop + focus trap via shared `attachOverlay`. */
|
|
115
|
+
export const Drawer = component((raw: DrawerProps) => {
|
|
116
|
+
ensure();
|
|
117
|
+
const props = mergeProps({ side: "right" as const }, raw) as ComponentProps<
|
|
118
|
+
DrawerProps & { side: "left" | "right" }
|
|
119
|
+
>;
|
|
120
|
+
const isOpen = () => readBool(props.open as MaybeReactive<boolean>);
|
|
121
|
+
let rootEl: HTMLElement | null = null;
|
|
122
|
+
let panelEl: HTMLElement | null = null;
|
|
123
|
+
|
|
124
|
+
effect(() => {
|
|
125
|
+
if (!isOpen()) return;
|
|
126
|
+
return attachOverlay({
|
|
127
|
+
getRoot: () => rootEl,
|
|
128
|
+
getFocusRoot: () => panelEl,
|
|
129
|
+
onClose: () => props.onClose?.(),
|
|
130
|
+
scrollLock: true,
|
|
131
|
+
escape: true,
|
|
132
|
+
onAttach: ({ doc }) => {
|
|
133
|
+
ensure(doc);
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<div
|
|
140
|
+
class={() =>
|
|
141
|
+
cx(
|
|
142
|
+
"pu-drawer-root",
|
|
143
|
+
isOpen() && "pu-drawer-root--open",
|
|
144
|
+
typeof props.class === "function"
|
|
145
|
+
? (props.class as () => string)()
|
|
146
|
+
: props.class,
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
aria-hidden={() => (!isOpen() ? "true" : "false")}
|
|
150
|
+
ref={(el) => {
|
|
151
|
+
rootEl = el;
|
|
152
|
+
ensure(el.ownerDocument);
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<div
|
|
156
|
+
class="pu-drawer-backdrop"
|
|
157
|
+
onClick={() => props.onClose?.()}
|
|
158
|
+
aria-hidden="true"
|
|
159
|
+
/>
|
|
160
|
+
<div
|
|
161
|
+
class={() => cx("pu-drawer-panel", `pu-drawer-panel--${props.side}`)}
|
|
162
|
+
role="dialog"
|
|
163
|
+
aria-modal="true"
|
|
164
|
+
ref={(el) => {
|
|
165
|
+
panelEl = el;
|
|
166
|
+
}}
|
|
167
|
+
>
|
|
168
|
+
{(props.title || props.onClose) && (
|
|
169
|
+
<div class="pu-drawer__head">
|
|
170
|
+
{props.title ? (
|
|
171
|
+
<h2 class="pu-drawer__title">{props.title}</h2>
|
|
172
|
+
) : (
|
|
173
|
+
<span />
|
|
174
|
+
)}
|
|
175
|
+
{props.onClose ? (
|
|
176
|
+
<button
|
|
177
|
+
type="button"
|
|
178
|
+
class="pu-drawer__close"
|
|
179
|
+
aria-label="Close"
|
|
180
|
+
onClick={() => props.onClose?.()}
|
|
181
|
+
>
|
|
182
|
+
×
|
|
183
|
+
</button>
|
|
184
|
+
) : null}
|
|
185
|
+
</div>
|
|
186
|
+
)}
|
|
187
|
+
<div class="pu-drawer__body">{props.children as never}</div>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { component, type ComponentProps } from "@lab206/dom";
|
|
2
|
+
import { cx } from "../utils.js";
|
|
3
|
+
import { createStyleSheet } from "../styles.js";
|
|
4
|
+
|
|
5
|
+
export type EmptyProps = {
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
/** Optional emoji / icon glyph */
|
|
9
|
+
icon?: string;
|
|
10
|
+
class?: string | (() => string);
|
|
11
|
+
children?: unknown;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const ensure = createStyleSheet(
|
|
15
|
+
"empty",
|
|
16
|
+
`
|
|
17
|
+
.pu-empty {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
text-align: center;
|
|
23
|
+
gap: 0.5rem;
|
|
24
|
+
padding: 2.5rem 1.5rem;
|
|
25
|
+
border: 1px dashed var(--pu-color-border);
|
|
26
|
+
border-radius: var(--pu-radius-lg);
|
|
27
|
+
background: color-mix(in srgb, var(--pu-color-surface-2) 50%, transparent);
|
|
28
|
+
}
|
|
29
|
+
.pu-empty__icon {
|
|
30
|
+
font-size: 1.75rem;
|
|
31
|
+
line-height: 1;
|
|
32
|
+
opacity: 0.85;
|
|
33
|
+
margin-bottom: 0.25rem;
|
|
34
|
+
}
|
|
35
|
+
.pu-empty__title {
|
|
36
|
+
margin: 0;
|
|
37
|
+
font-size: var(--pu-text-md);
|
|
38
|
+
font-weight: var(--pu-font-semibold);
|
|
39
|
+
color: var(--pu-color-text);
|
|
40
|
+
}
|
|
41
|
+
.pu-empty__desc {
|
|
42
|
+
margin: 0;
|
|
43
|
+
font-size: var(--pu-text-sm);
|
|
44
|
+
color: var(--pu-color-text-muted);
|
|
45
|
+
max-width: 22rem;
|
|
46
|
+
line-height: 1.5;
|
|
47
|
+
}
|
|
48
|
+
.pu-empty__actions {
|
|
49
|
+
margin-top: 0.75rem;
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-wrap: wrap;
|
|
52
|
+
gap: 0.5rem;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
}
|
|
55
|
+
`,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
/** Empty state for lists, tables, and panels. */
|
|
59
|
+
export const Empty = component((raw: EmptyProps) => {
|
|
60
|
+
ensure();
|
|
61
|
+
const props = raw as ComponentProps<EmptyProps>;
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
class={() =>
|
|
65
|
+
cx(
|
|
66
|
+
"pu-empty",
|
|
67
|
+
typeof props.class === "function" ? props.class() : props.class,
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
ref={(el) => ensure(el.ownerDocument)}
|
|
71
|
+
>
|
|
72
|
+
{props.icon ? (
|
|
73
|
+
<div class="pu-empty__icon" aria-hidden="true">
|
|
74
|
+
{props.icon}
|
|
75
|
+
</div>
|
|
76
|
+
) : null}
|
|
77
|
+
{props.title ? <h3 class="pu-empty__title">{props.title}</h3> : null}
|
|
78
|
+
{props.description ? (
|
|
79
|
+
<p class="pu-empty__desc">{props.description}</p>
|
|
80
|
+
) : null}
|
|
81
|
+
{props.children ? (
|
|
82
|
+
<div class="pu-empty__actions">{props.children as never}</div>
|
|
83
|
+
) : null}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { effect } from "@lab206/core";
|
|
2
|
+
import { component, mergeProps, type ComponentProps } from "@lab206/dom";
|
|
3
|
+
import { cx, puId } from "../utils.js";
|
|
4
|
+
import { Label } from "./Label.js";
|
|
5
|
+
|
|
6
|
+
export type FieldProps = {
|
|
7
|
+
label?: string;
|
|
8
|
+
/** Explicit control id. When omitted, Field generates one and wires the first control. */
|
|
9
|
+
htmlFor?: string;
|
|
10
|
+
hint?: string | (() => string);
|
|
11
|
+
error?: string | (() => string | undefined | null | false);
|
|
12
|
+
required?: boolean;
|
|
13
|
+
class?: string | (() => string);
|
|
14
|
+
children?: unknown;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const styles = `
|
|
18
|
+
.pu-field {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: var(--pu-field-gap);
|
|
22
|
+
min-width: 0;
|
|
23
|
+
}
|
|
24
|
+
/* Stable footer slot — prevents layout shift (and scroll jumps) when errors appear */
|
|
25
|
+
.pu-field__footer {
|
|
26
|
+
min-height: 1.25em;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
justify-content: flex-start;
|
|
30
|
+
}
|
|
31
|
+
.pu-field__hint,
|
|
32
|
+
.pu-field__error {
|
|
33
|
+
margin: 0;
|
|
34
|
+
font-size: var(--pu-text-xs);
|
|
35
|
+
line-height: 1.35;
|
|
36
|
+
min-height: 1.25em;
|
|
37
|
+
}
|
|
38
|
+
.pu-field__hint {
|
|
39
|
+
color: var(--pu-color-text-muted);
|
|
40
|
+
}
|
|
41
|
+
.pu-field__error {
|
|
42
|
+
color: var(--pu-color-danger);
|
|
43
|
+
font-weight: var(--pu-font-medium);
|
|
44
|
+
}
|
|
45
|
+
.pu-field__error:empty,
|
|
46
|
+
.pu-field__hint:empty {
|
|
47
|
+
/* keep box for layout; empty text has zero width but min-height holds space when one is shown */
|
|
48
|
+
}
|
|
49
|
+
.pu-field--invalid :is(.pu-input, .pu-textarea, .pu-select) {
|
|
50
|
+
border-color: var(--pu-color-danger);
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
let injected = false;
|
|
55
|
+
function ensureStyles() {
|
|
56
|
+
if (injected || typeof document === "undefined") return;
|
|
57
|
+
injected = true;
|
|
58
|
+
const el = document.createElement("style");
|
|
59
|
+
el.setAttribute("data-pu-ui", "field");
|
|
60
|
+
el.textContent = styles;
|
|
61
|
+
document.head.appendChild(el);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const CONTROL_SEL =
|
|
65
|
+
"input:not([type='hidden']):not([type='checkbox']):not([type='radio']), textarea, select, [role='combobox'], .pu-select";
|
|
66
|
+
|
|
67
|
+
function findControl(root: HTMLElement): HTMLElement | null {
|
|
68
|
+
return root.querySelector(CONTROL_SEL) as HTMLElement | null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Form field layout: label + control + hint/error.
|
|
73
|
+
*
|
|
74
|
+
* - Auto-wires `htmlFor` / control `id` when you pass a `label` (unless `htmlFor` set)
|
|
75
|
+
* - Mirrors error/hint onto `aria-invalid` / `aria-describedby` on the control
|
|
76
|
+
* - Error region never uses role="alert" (avoids scroll/steal focus while typing)
|
|
77
|
+
*/
|
|
78
|
+
export const Field = component((raw: FieldProps) => {
|
|
79
|
+
ensureStyles();
|
|
80
|
+
const props = mergeProps({}, raw) as ComponentProps<FieldProps>;
|
|
81
|
+
|
|
82
|
+
const controlId = props.htmlFor ?? puId("pu-field");
|
|
83
|
+
const msgId = puId("pu-field-msg");
|
|
84
|
+
let rootEl: HTMLElement | null = null;
|
|
85
|
+
|
|
86
|
+
const errorText = () => {
|
|
87
|
+
const e = props.error as string | undefined | null | false;
|
|
88
|
+
return e ? String(e) : "";
|
|
89
|
+
};
|
|
90
|
+
const hintText = () => {
|
|
91
|
+
const h = props.hint as string | undefined | null | false;
|
|
92
|
+
return h ? String(h) : "";
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
effect(() => {
|
|
96
|
+
const err = errorText();
|
|
97
|
+
const hint = hintText();
|
|
98
|
+
// Re-run when messages change; also after microtask so children exist
|
|
99
|
+
const apply = () => {
|
|
100
|
+
const root = rootEl;
|
|
101
|
+
if (!root) return;
|
|
102
|
+
const control = findControl(root);
|
|
103
|
+
if (!control) return;
|
|
104
|
+
// Prefer explicit control id; else apply field id for label association
|
|
105
|
+
if (!control.id) control.id = controlId;
|
|
106
|
+
|
|
107
|
+
if (err) {
|
|
108
|
+
control.setAttribute("aria-invalid", "true");
|
|
109
|
+
control.setAttribute("aria-describedby", msgId);
|
|
110
|
+
} else if (hint) {
|
|
111
|
+
control.removeAttribute("aria-invalid");
|
|
112
|
+
control.setAttribute("aria-describedby", msgId);
|
|
113
|
+
} else {
|
|
114
|
+
control.removeAttribute("aria-invalid");
|
|
115
|
+
// Only clear if we own the describedby
|
|
116
|
+
if (control.getAttribute("aria-describedby") === msgId) {
|
|
117
|
+
control.removeAttribute("aria-describedby");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
queueMicrotask(apply);
|
|
122
|
+
// Children may mount after first microtask (effects order)
|
|
123
|
+
const t =
|
|
124
|
+
typeof window !== "undefined"
|
|
125
|
+
? window.setTimeout(apply, 0)
|
|
126
|
+
: (null as unknown as number);
|
|
127
|
+
return () => {
|
|
128
|
+
if (t != null && typeof window !== "undefined") window.clearTimeout(t);
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<div
|
|
134
|
+
class={() =>
|
|
135
|
+
cx(
|
|
136
|
+
"pu-field",
|
|
137
|
+
errorText() && "pu-field--invalid",
|
|
138
|
+
typeof props.class === "function" ? props.class() : props.class,
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
ref={(el) => {
|
|
142
|
+
rootEl = el;
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
{props.label
|
|
146
|
+
? Label({
|
|
147
|
+
htmlFor: controlId,
|
|
148
|
+
...(props.required !== undefined
|
|
149
|
+
? { required: props.required }
|
|
150
|
+
: {}),
|
|
151
|
+
children: props.label,
|
|
152
|
+
})
|
|
153
|
+
: null}
|
|
154
|
+
{props.children as never}
|
|
155
|
+
<div class="pu-field__footer">
|
|
156
|
+
{() => {
|
|
157
|
+
const err = errorText();
|
|
158
|
+
const hint = hintText();
|
|
159
|
+
if (err) {
|
|
160
|
+
const p = document.createElement("p");
|
|
161
|
+
p.className = "pu-field__error";
|
|
162
|
+
p.id = msgId;
|
|
163
|
+
p.setAttribute("role", "status");
|
|
164
|
+
p.setAttribute("aria-live", "polite");
|
|
165
|
+
p.textContent = err;
|
|
166
|
+
return p;
|
|
167
|
+
}
|
|
168
|
+
if (hint) {
|
|
169
|
+
const p = document.createElement("p");
|
|
170
|
+
p.className = "pu-field__hint";
|
|
171
|
+
p.id = msgId;
|
|
172
|
+
p.textContent = hint;
|
|
173
|
+
return p;
|
|
174
|
+
}
|
|
175
|
+
const spacer = document.createElement("p");
|
|
176
|
+
spacer.className = "pu-field__hint";
|
|
177
|
+
spacer.setAttribute("aria-hidden", "true");
|
|
178
|
+
spacer.innerHTML = " ";
|
|
179
|
+
return spacer;
|
|
180
|
+
}}
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
);
|
|
184
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { component, mergeProps, type ComponentProps } from "@lab206/dom";
|
|
2
|
+
import { cx } from "../utils.js";
|
|
3
|
+
|
|
4
|
+
export type GridProps = {
|
|
5
|
+
cols?: 1 | 2 | 3 | 4;
|
|
6
|
+
gap?: 2 | 3 | 4 | 5 | 6 | 8;
|
|
7
|
+
class?: string | (() => string);
|
|
8
|
+
children?: unknown;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const styles = `
|
|
12
|
+
.pu-grid {
|
|
13
|
+
display: grid;
|
|
14
|
+
width: 100%;
|
|
15
|
+
}
|
|
16
|
+
.pu-grid--gap-2 { gap: var(--pu-space-2); }
|
|
17
|
+
.pu-grid--gap-3 { gap: var(--pu-space-3); }
|
|
18
|
+
.pu-grid--gap-4 { gap: var(--pu-space-4); }
|
|
19
|
+
.pu-grid--gap-5 { gap: var(--pu-space-5); }
|
|
20
|
+
.pu-grid--gap-6 { gap: var(--pu-space-6); }
|
|
21
|
+
.pu-grid--gap-8 { gap: var(--pu-space-8); }
|
|
22
|
+
.pu-grid--cols-1 { grid-template-columns: 1fr; }
|
|
23
|
+
.pu-grid--cols-2 { grid-template-columns: 1fr; }
|
|
24
|
+
.pu-grid--cols-3 { grid-template-columns: 1fr; }
|
|
25
|
+
.pu-grid--cols-4 { grid-template-columns: 1fr; }
|
|
26
|
+
@media (min-width: 640px) {
|
|
27
|
+
.pu-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
|
|
28
|
+
.pu-grid--cols-3 { grid-template-columns: repeat(2, 1fr); }
|
|
29
|
+
.pu-grid--cols-4 { grid-template-columns: repeat(2, 1fr); }
|
|
30
|
+
}
|
|
31
|
+
@media (min-width: 900px) {
|
|
32
|
+
.pu-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
|
|
33
|
+
.pu-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
let injected = false;
|
|
38
|
+
function ensureStyles() {
|
|
39
|
+
if (injected || typeof document === "undefined") return;
|
|
40
|
+
injected = true;
|
|
41
|
+
const el = document.createElement("style");
|
|
42
|
+
el.setAttribute("data-pu-ui", "grid");
|
|
43
|
+
el.textContent = styles;
|
|
44
|
+
document.head.appendChild(el);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const Grid = component((raw: GridProps) => {
|
|
48
|
+
ensureStyles();
|
|
49
|
+
const props = mergeProps(
|
|
50
|
+
{ cols: 3 as const, gap: 4 as const },
|
|
51
|
+
raw,
|
|
52
|
+
) as ComponentProps<Required<Pick<GridProps, "cols" | "gap">> & GridProps>;
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
class={() =>
|
|
56
|
+
cx(
|
|
57
|
+
"pu-grid",
|
|
58
|
+
`pu-grid--cols-${props.cols}`,
|
|
59
|
+
`pu-grid--gap-${props.gap}`,
|
|
60
|
+
typeof props.class === "function" ? props.class() : props.class,
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
{props.children as never}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
});
|