@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,380 @@
|
|
|
1
|
+
import { signal, effect } from "@lab206/core";
|
|
2
|
+
import { For, Show, component, mergeProps, type ComponentProps } from "@lab206/dom";
|
|
3
|
+
import { cx } from "../utils.js";
|
|
4
|
+
import { attachOverlay } from "../overlay.js";
|
|
5
|
+
import { readBool, readStr, type MaybeReactive } from "../reactive.js";
|
|
6
|
+
|
|
7
|
+
export type CommandItem = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
hint?: string;
|
|
11
|
+
group?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type CommandProps = {
|
|
16
|
+
open: MaybeReactive<boolean>;
|
|
17
|
+
onOpenChange?: (open: boolean) => void;
|
|
18
|
+
items: CommandItem[] | (() => CommandItem[]);
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Async command sources: show a loading row while `items` is still settling.
|
|
22
|
+
* Use a reactive `items` function + toggle `loading` around the fetch.
|
|
23
|
+
*/
|
|
24
|
+
loading?: MaybeReactive<boolean>;
|
|
25
|
+
/** Empty-state copy (default: “No commands match”) */
|
|
26
|
+
emptyText?: MaybeReactive<string>;
|
|
27
|
+
/** Loading-state copy (default: “Loading…”) */
|
|
28
|
+
loadingText?: MaybeReactive<string>;
|
|
29
|
+
onSelect?: (id: string) => void;
|
|
30
|
+
class?: MaybeReactive<string>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const styles = `
|
|
34
|
+
.pu-command-root {
|
|
35
|
+
position: fixed;
|
|
36
|
+
inset: 0;
|
|
37
|
+
z-index: var(--pu-z-overlay);
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: flex-start;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
padding: min(20vh, 6rem) var(--pu-space-4) var(--pu-space-4);
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
opacity: 0;
|
|
44
|
+
visibility: hidden;
|
|
45
|
+
transition: opacity var(--pu-duration) var(--pu-ease-out),
|
|
46
|
+
visibility var(--pu-duration) var(--pu-ease-out);
|
|
47
|
+
}
|
|
48
|
+
.pu-command-root--open {
|
|
49
|
+
pointer-events: auto;
|
|
50
|
+
opacity: 1;
|
|
51
|
+
visibility: visible;
|
|
52
|
+
}
|
|
53
|
+
.pu-command-backdrop {
|
|
54
|
+
position: absolute;
|
|
55
|
+
inset: 0;
|
|
56
|
+
background: var(--pu-overlay-scrim);
|
|
57
|
+
backdrop-filter: blur(6px);
|
|
58
|
+
-webkit-backdrop-filter: blur(6px);
|
|
59
|
+
}
|
|
60
|
+
.pu-command {
|
|
61
|
+
position: relative;
|
|
62
|
+
width: min(32rem, 100%);
|
|
63
|
+
max-height: min(28rem, 70vh);
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
border-radius: var(--pu-radius-xl);
|
|
67
|
+
background: var(--pu-color-surface-elevated);
|
|
68
|
+
border: 1px solid var(--pu-color-border);
|
|
69
|
+
box-shadow: var(--pu-shadow-float);
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
transform: translateY(8px) scale(0.98);
|
|
72
|
+
transition: transform var(--pu-duration-slow) var(--pu-ease-out);
|
|
73
|
+
}
|
|
74
|
+
.pu-command-root--open .pu-command {
|
|
75
|
+
transform: translateY(0) scale(1);
|
|
76
|
+
}
|
|
77
|
+
.pu-command__input {
|
|
78
|
+
width: 100%;
|
|
79
|
+
border: 0;
|
|
80
|
+
border-bottom: 1px solid var(--pu-color-border);
|
|
81
|
+
background: transparent;
|
|
82
|
+
color: var(--pu-color-text);
|
|
83
|
+
font: inherit;
|
|
84
|
+
font-size: var(--pu-text-md);
|
|
85
|
+
padding: 0.9rem 1rem;
|
|
86
|
+
outline: none;
|
|
87
|
+
}
|
|
88
|
+
.pu-command__input::placeholder { color: var(--pu-color-text-muted); }
|
|
89
|
+
.pu-command__input:focus-visible {
|
|
90
|
+
box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--pu-color-focus) 35%, transparent);
|
|
91
|
+
}
|
|
92
|
+
.pu-command__list {
|
|
93
|
+
overflow: auto;
|
|
94
|
+
padding: 0.35rem;
|
|
95
|
+
flex: 1;
|
|
96
|
+
min-height: 0;
|
|
97
|
+
}
|
|
98
|
+
.pu-command__item {
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: space-between;
|
|
102
|
+
gap: 0.75rem;
|
|
103
|
+
width: 100%;
|
|
104
|
+
appearance: none;
|
|
105
|
+
border: 0;
|
|
106
|
+
background: transparent;
|
|
107
|
+
text-align: left;
|
|
108
|
+
font: inherit;
|
|
109
|
+
font-size: var(--pu-text-sm);
|
|
110
|
+
color: var(--pu-color-text);
|
|
111
|
+
padding: 0.55rem 0.7rem;
|
|
112
|
+
border-radius: var(--pu-radius-md);
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
}
|
|
115
|
+
.pu-command__item:hover:not(:disabled),
|
|
116
|
+
.pu-command__item.is-active:not(:disabled) {
|
|
117
|
+
background: color-mix(in srgb, var(--pu-color-accent) 12%, var(--pu-color-surface-2));
|
|
118
|
+
}
|
|
119
|
+
.pu-command__item:focus-visible:not(:disabled) {
|
|
120
|
+
outline: none;
|
|
121
|
+
box-shadow:
|
|
122
|
+
0 0 0 2px var(--pu-color-surface-elevated),
|
|
123
|
+
0 0 0 4px color-mix(in srgb, var(--pu-color-focus) 55%, transparent);
|
|
124
|
+
background: color-mix(in srgb, var(--pu-color-accent) 12%, var(--pu-color-surface-2));
|
|
125
|
+
}
|
|
126
|
+
.pu-command__item:disabled {
|
|
127
|
+
opacity: 0.45;
|
|
128
|
+
cursor: not-allowed;
|
|
129
|
+
}
|
|
130
|
+
.pu-command__hint {
|
|
131
|
+
font-size: var(--pu-text-xs);
|
|
132
|
+
color: var(--pu-color-text-muted);
|
|
133
|
+
font-family: var(--pu-font-mono);
|
|
134
|
+
}
|
|
135
|
+
.pu-command__status {
|
|
136
|
+
padding: 1.25rem;
|
|
137
|
+
text-align: center;
|
|
138
|
+
color: var(--pu-color-text-muted);
|
|
139
|
+
font-size: var(--pu-text-sm);
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
justify-content: center;
|
|
143
|
+
gap: 0.55rem;
|
|
144
|
+
}
|
|
145
|
+
.pu-command__status--loading::before {
|
|
146
|
+
content: "";
|
|
147
|
+
width: 0.75rem;
|
|
148
|
+
height: 0.75rem;
|
|
149
|
+
border-radius: 50%;
|
|
150
|
+
border: 2px solid color-mix(in srgb, var(--pu-color-accent) 30%, transparent);
|
|
151
|
+
border-top-color: var(--pu-color-accent);
|
|
152
|
+
animation: pu-command-spin 0.7s linear infinite;
|
|
153
|
+
flex-shrink: 0;
|
|
154
|
+
}
|
|
155
|
+
@keyframes pu-command-spin {
|
|
156
|
+
to { transform: rotate(360deg); }
|
|
157
|
+
}
|
|
158
|
+
@media (prefers-reduced-motion: reduce) {
|
|
159
|
+
.pu-command__status--loading::before { animation: none; opacity: 0.7; }
|
|
160
|
+
}
|
|
161
|
+
.pu-command__footer {
|
|
162
|
+
border-top: 1px solid var(--pu-color-border);
|
|
163
|
+
padding: 0.45rem 0.75rem;
|
|
164
|
+
font-size: var(--pu-text-xs);
|
|
165
|
+
color: var(--pu-color-text-muted);
|
|
166
|
+
display: flex;
|
|
167
|
+
gap: 0.75rem;
|
|
168
|
+
flex-wrap: wrap;
|
|
169
|
+
}
|
|
170
|
+
@media (prefers-reduced-motion: reduce) {
|
|
171
|
+
.pu-command-root, .pu-command { transition: none; }
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
|
|
175
|
+
function ensureStyles(doc: Document = document) {
|
|
176
|
+
if (typeof doc === "undefined") return;
|
|
177
|
+
if (doc.querySelector('style[data-pu-ui="command"]')) return;
|
|
178
|
+
const el = doc.createElement("style");
|
|
179
|
+
el.setAttribute("data-pu-ui", "command");
|
|
180
|
+
el.textContent = styles;
|
|
181
|
+
doc.head.appendChild(el);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Command palette (⌘K style): search + run an action.
|
|
186
|
+
* Control with `open` + `onOpenChange`. Esc / backdrop close via `attachOverlay`.
|
|
187
|
+
* For async sources: reactive `items` + `loading`.
|
|
188
|
+
*/
|
|
189
|
+
export const Command = component((raw: CommandProps) => {
|
|
190
|
+
ensureStyles();
|
|
191
|
+
const props = mergeProps(
|
|
192
|
+
{
|
|
193
|
+
placeholder: "Type a command…",
|
|
194
|
+
emptyText: "No commands match",
|
|
195
|
+
loadingText: "Loading…",
|
|
196
|
+
},
|
|
197
|
+
raw,
|
|
198
|
+
) as ComponentProps<
|
|
199
|
+
CommandProps & {
|
|
200
|
+
placeholder: string;
|
|
201
|
+
emptyText: string;
|
|
202
|
+
loadingText: string;
|
|
203
|
+
}
|
|
204
|
+
>;
|
|
205
|
+
|
|
206
|
+
const isOpen = () => readBool(props.open as MaybeReactive<boolean>);
|
|
207
|
+
const isLoading = () =>
|
|
208
|
+
readBool(props.loading as MaybeReactive<boolean> | undefined);
|
|
209
|
+
const query = signal("");
|
|
210
|
+
const active = signal(0);
|
|
211
|
+
let rootEl: HTMLElement | null = null;
|
|
212
|
+
let panelEl: HTMLElement | null = null;
|
|
213
|
+
let inputEl: HTMLInputElement | null = null;
|
|
214
|
+
|
|
215
|
+
const getItems = (): CommandItem[] => {
|
|
216
|
+
const i = props.items;
|
|
217
|
+
return typeof i === "function" ? (i as () => CommandItem[])() : (i ?? []);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const filtered = () => {
|
|
221
|
+
if (isLoading()) return [] as CommandItem[];
|
|
222
|
+
const q = query().trim().toLowerCase();
|
|
223
|
+
const list = getItems();
|
|
224
|
+
if (!q) return list;
|
|
225
|
+
return list.filter(
|
|
226
|
+
(it) =>
|
|
227
|
+
it.label.toLowerCase().includes(q) ||
|
|
228
|
+
(it.hint?.toLowerCase().includes(q) ?? false) ||
|
|
229
|
+
(it.group?.toLowerCase().includes(q) ?? false),
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
effect(() => {
|
|
234
|
+
if (!isOpen()) {
|
|
235
|
+
query.set("");
|
|
236
|
+
active.set(0);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
return attachOverlay({
|
|
240
|
+
getRoot: () => rootEl,
|
|
241
|
+
getFocusRoot: () => panelEl,
|
|
242
|
+
onClose: () => props.onOpenChange?.(false),
|
|
243
|
+
scrollLock: true,
|
|
244
|
+
escape: true,
|
|
245
|
+
onAttach: ({ doc, win }) => {
|
|
246
|
+
ensureStyles(doc);
|
|
247
|
+
const t = win.setTimeout(() => inputEl?.focus(), 0);
|
|
248
|
+
return () => win.clearTimeout(t);
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
const run = (item: CommandItem) => {
|
|
254
|
+
if (item.disabled || isLoading()) return;
|
|
255
|
+
props.onSelect?.(item.id);
|
|
256
|
+
props.onOpenChange?.(false);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<div
|
|
261
|
+
class={() =>
|
|
262
|
+
cx(
|
|
263
|
+
"pu-command-root",
|
|
264
|
+
isOpen() && "pu-command-root--open",
|
|
265
|
+
isLoading() && "pu-command-root--loading",
|
|
266
|
+
typeof props.class === "function" ? props.class() : props.class,
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
aria-hidden={() => (!isOpen() ? "true" : "false")}
|
|
270
|
+
ref={(el) => {
|
|
271
|
+
rootEl = el;
|
|
272
|
+
ensureStyles(el.ownerDocument);
|
|
273
|
+
}}
|
|
274
|
+
>
|
|
275
|
+
<div
|
|
276
|
+
class="pu-command-backdrop"
|
|
277
|
+
onClick={() => props.onOpenChange?.(false)}
|
|
278
|
+
aria-hidden="true"
|
|
279
|
+
/>
|
|
280
|
+
<div
|
|
281
|
+
class="pu-command"
|
|
282
|
+
role="dialog"
|
|
283
|
+
aria-modal="true"
|
|
284
|
+
aria-label="Command palette"
|
|
285
|
+
aria-busy={() => (isLoading() ? "true" : "false")}
|
|
286
|
+
onClick={(e: MouseEvent) => e.stopPropagation()}
|
|
287
|
+
ref={(el) => {
|
|
288
|
+
panelEl = el;
|
|
289
|
+
}}
|
|
290
|
+
>
|
|
291
|
+
<input
|
|
292
|
+
class="pu-command__input"
|
|
293
|
+
type="text"
|
|
294
|
+
role="combobox"
|
|
295
|
+
aria-expanded="true"
|
|
296
|
+
aria-busy={() => (isLoading() ? "true" : "false")}
|
|
297
|
+
placeholder={props.placeholder}
|
|
298
|
+
value={query}
|
|
299
|
+
ref={(el) => {
|
|
300
|
+
inputEl = el as HTMLInputElement;
|
|
301
|
+
}}
|
|
302
|
+
onInput={(e: Event) => {
|
|
303
|
+
query.set((e.target as HTMLInputElement).value);
|
|
304
|
+
active.set(0);
|
|
305
|
+
}}
|
|
306
|
+
onKeyDown={(e: KeyboardEvent) => {
|
|
307
|
+
if (isLoading()) return;
|
|
308
|
+
const list = filtered();
|
|
309
|
+
if (e.key === "ArrowDown") {
|
|
310
|
+
e.preventDefault();
|
|
311
|
+
active.set(Math.min(Math.max(list.length - 1, 0), active() + 1));
|
|
312
|
+
} else if (e.key === "ArrowUp") {
|
|
313
|
+
e.preventDefault();
|
|
314
|
+
active.set(Math.max(0, active() - 1));
|
|
315
|
+
} else if (e.key === "Enter") {
|
|
316
|
+
e.preventDefault();
|
|
317
|
+
const item = list[active()];
|
|
318
|
+
if (item) run(item);
|
|
319
|
+
}
|
|
320
|
+
}}
|
|
321
|
+
/>
|
|
322
|
+
<div class="pu-command__list" role="listbox">
|
|
323
|
+
<Show when={() => isLoading()}>
|
|
324
|
+
{() => {
|
|
325
|
+
const d = document.createElement("div");
|
|
326
|
+
d.className = "pu-command__status pu-command__status--loading";
|
|
327
|
+
d.setAttribute("role", "status");
|
|
328
|
+
d.textContent =
|
|
329
|
+
readStr(props.loadingText as MaybeReactive<string>) ||
|
|
330
|
+
"Loading…";
|
|
331
|
+
return d;
|
|
332
|
+
}}
|
|
333
|
+
</Show>
|
|
334
|
+
<Show when={() => !isLoading() && filtered().length === 0}>
|
|
335
|
+
{() => {
|
|
336
|
+
const d = document.createElement("div");
|
|
337
|
+
d.className = "pu-command__status";
|
|
338
|
+
d.setAttribute("role", "status");
|
|
339
|
+
d.textContent =
|
|
340
|
+
readStr(props.emptyText as MaybeReactive<string>) ||
|
|
341
|
+
"No commands match";
|
|
342
|
+
return d;
|
|
343
|
+
}}
|
|
344
|
+
</Show>
|
|
345
|
+
<Show when={() => !isLoading()}>
|
|
346
|
+
{() => (
|
|
347
|
+
<For each={filtered}>
|
|
348
|
+
{(item, index) => (
|
|
349
|
+
<button
|
|
350
|
+
type="button"
|
|
351
|
+
role="option"
|
|
352
|
+
class={() =>
|
|
353
|
+
cx(
|
|
354
|
+
"pu-command__item",
|
|
355
|
+
active() === index() && "is-active",
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
disabled={() => !!item().disabled}
|
|
359
|
+
onClick={() => run(item())}
|
|
360
|
+
onMouseEnter={() => active.set(index())}
|
|
361
|
+
>
|
|
362
|
+
<span>{() => item().label}</span>
|
|
363
|
+
<span class="pu-command__hint">
|
|
364
|
+
{() => item().hint ?? ""}
|
|
365
|
+
</span>
|
|
366
|
+
</button>
|
|
367
|
+
)}
|
|
368
|
+
</For>
|
|
369
|
+
)}
|
|
370
|
+
</Show>
|
|
371
|
+
</div>
|
|
372
|
+
<div class="pu-command__footer">
|
|
373
|
+
<span>↑↓ navigate</span>
|
|
374
|
+
<span>↵ run</span>
|
|
375
|
+
<span>esc close</span>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
</div>
|
|
379
|
+
);
|
|
380
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { component, mergeProps, type ComponentProps } from "@lab206/dom";
|
|
2
|
+
import { cx } from "../utils.js";
|
|
3
|
+
|
|
4
|
+
export type ContainerProps = {
|
|
5
|
+
size?: "sm" | "md" | "lg" | "xl";
|
|
6
|
+
class?: string | (() => string);
|
|
7
|
+
children?: unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const styles = `
|
|
11
|
+
.pu-container {
|
|
12
|
+
width: 100%;
|
|
13
|
+
margin-inline: auto;
|
|
14
|
+
/* Prefer site-level gutters when demos define them (unified chrome) */
|
|
15
|
+
padding-inline: var(--site-gutter, var(--pu-space-4));
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
@media (min-width: 640px) {
|
|
19
|
+
.pu-container {
|
|
20
|
+
padding-inline: var(--site-gutter, var(--pu-space-6));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
.pu-container--sm { max-width: 40rem; }
|
|
24
|
+
.pu-container--md { max-width: 48rem; }
|
|
25
|
+
.pu-container--lg { max-width: 64rem; }
|
|
26
|
+
/* Default “app shell” width — match site nav + main content */
|
|
27
|
+
.pu-container--xl { max-width: var(--site-max, 80rem); }
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
let injected = false;
|
|
31
|
+
function ensureStyles() {
|
|
32
|
+
if (injected || typeof document === "undefined") return;
|
|
33
|
+
injected = true;
|
|
34
|
+
const el = document.createElement("style");
|
|
35
|
+
el.setAttribute("data-pu-ui", "container");
|
|
36
|
+
el.textContent = styles;
|
|
37
|
+
document.head.appendChild(el);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Container = component((raw: ContainerProps) => {
|
|
41
|
+
ensureStyles();
|
|
42
|
+
const props = mergeProps({ size: "lg" as const }, raw) as ComponentProps<
|
|
43
|
+
ContainerProps & { size: NonNullable<ContainerProps["size"]> }
|
|
44
|
+
>;
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
class={() =>
|
|
48
|
+
cx(
|
|
49
|
+
"pu-container",
|
|
50
|
+
`pu-container--${props.size}`,
|
|
51
|
+
typeof props.class === "function" ? props.class() : props.class,
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
>
|
|
55
|
+
{props.children as never}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
});
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { effect } from "@lab206/core";
|
|
2
|
+
import { component, mergeProps, type ComponentProps } from "@lab206/dom";
|
|
3
|
+
import { cx, puId } from "../utils.js";
|
|
4
|
+
import { attachOverlay } from "../overlay.js";
|
|
5
|
+
import { readBool, type MaybeReactive } from "../reactive.js";
|
|
6
|
+
|
|
7
|
+
export type DialogProps = {
|
|
8
|
+
/** Controlled open state (boolean, signal, or accessor) */
|
|
9
|
+
open: MaybeReactive<boolean>;
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Panel size */
|
|
14
|
+
size?: "sm" | "md" | "lg";
|
|
15
|
+
class?: MaybeReactive<string>;
|
|
16
|
+
children?: unknown;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const styles = `
|
|
20
|
+
.pu-dialog-root {
|
|
21
|
+
position: fixed;
|
|
22
|
+
inset: 0;
|
|
23
|
+
z-index: var(--pu-z-overlay);
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
padding: var(--pu-space-4);
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
opacity: 0;
|
|
30
|
+
visibility: hidden;
|
|
31
|
+
transition:
|
|
32
|
+
opacity var(--pu-duration-slow) var(--pu-ease-out),
|
|
33
|
+
visibility var(--pu-duration-slow) var(--pu-ease-out);
|
|
34
|
+
}
|
|
35
|
+
.pu-dialog-root--open {
|
|
36
|
+
pointer-events: auto;
|
|
37
|
+
opacity: 1;
|
|
38
|
+
visibility: visible;
|
|
39
|
+
}
|
|
40
|
+
.pu-dialog-backdrop {
|
|
41
|
+
position: absolute;
|
|
42
|
+
inset: 0;
|
|
43
|
+
background: var(--pu-overlay-scrim);
|
|
44
|
+
backdrop-filter: blur(6px);
|
|
45
|
+
-webkit-backdrop-filter: blur(6px);
|
|
46
|
+
}
|
|
47
|
+
.pu-dialog-panel {
|
|
48
|
+
position: relative;
|
|
49
|
+
width: 100%;
|
|
50
|
+
max-height: min(88vh, 720px);
|
|
51
|
+
overflow: auto;
|
|
52
|
+
background: var(--pu-color-surface-elevated);
|
|
53
|
+
color: var(--pu-color-text);
|
|
54
|
+
border: 1px solid var(--pu-color-border);
|
|
55
|
+
border-radius: var(--pu-radius-xl);
|
|
56
|
+
box-shadow: var(--pu-shadow-float);
|
|
57
|
+
padding: var(--pu-space-6);
|
|
58
|
+
transform: translateY(12px) scale(0.96);
|
|
59
|
+
transition: transform var(--pu-duration-slow) var(--pu-ease-spring);
|
|
60
|
+
}
|
|
61
|
+
.pu-dialog-root--open .pu-dialog-panel {
|
|
62
|
+
transform: translateY(0) scale(1);
|
|
63
|
+
}
|
|
64
|
+
.pu-dialog-panel--sm { max-width: 22rem; }
|
|
65
|
+
.pu-dialog-panel--md { max-width: 28rem; }
|
|
66
|
+
.pu-dialog-panel--lg { max-width: 36rem; }
|
|
67
|
+
.pu-dialog__head {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: flex-start;
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
gap: var(--pu-space-3);
|
|
72
|
+
margin-bottom: var(--pu-space-4);
|
|
73
|
+
}
|
|
74
|
+
.pu-dialog__title {
|
|
75
|
+
margin: 0;
|
|
76
|
+
font-size: var(--pu-text-xl);
|
|
77
|
+
font-weight: var(--pu-font-bold);
|
|
78
|
+
letter-spacing: var(--pu-tracking-tight);
|
|
79
|
+
line-height: var(--pu-leading-tight);
|
|
80
|
+
color: var(--pu-color-text);
|
|
81
|
+
}
|
|
82
|
+
.pu-dialog__desc {
|
|
83
|
+
margin: var(--pu-space-2) 0 0;
|
|
84
|
+
color: var(--pu-color-text-muted);
|
|
85
|
+
font-size: var(--pu-text-sm);
|
|
86
|
+
line-height: 1.5;
|
|
87
|
+
}
|
|
88
|
+
.pu-dialog__close {
|
|
89
|
+
flex-shrink: 0;
|
|
90
|
+
width: 2rem;
|
|
91
|
+
height: 2rem;
|
|
92
|
+
display: inline-flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
border: 1px solid transparent;
|
|
96
|
+
border-radius: var(--pu-radius-md);
|
|
97
|
+
background: transparent;
|
|
98
|
+
color: var(--pu-color-text-muted);
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
font-size: 1.15rem;
|
|
101
|
+
line-height: 1;
|
|
102
|
+
transition:
|
|
103
|
+
background var(--pu-duration) var(--pu-ease),
|
|
104
|
+
color var(--pu-duration) var(--pu-ease);
|
|
105
|
+
}
|
|
106
|
+
.pu-dialog__close:hover {
|
|
107
|
+
background: var(--pu-color-surface-2);
|
|
108
|
+
color: var(--pu-color-text);
|
|
109
|
+
}
|
|
110
|
+
.pu-dialog__close:focus-visible {
|
|
111
|
+
outline: none;
|
|
112
|
+
color: var(--pu-color-text);
|
|
113
|
+
box-shadow:
|
|
114
|
+
0 0 0 2px var(--pu-color-surface-elevated),
|
|
115
|
+
0 0 0 4px color-mix(in srgb, var(--pu-color-focus) 55%, transparent);
|
|
116
|
+
}
|
|
117
|
+
.pu-dialog__body {
|
|
118
|
+
font-size: var(--pu-text-sm);
|
|
119
|
+
line-height: 1.55;
|
|
120
|
+
color: var(--pu-color-text);
|
|
121
|
+
}
|
|
122
|
+
@media (prefers-reduced-motion: reduce) {
|
|
123
|
+
.pu-dialog-root,
|
|
124
|
+
.pu-dialog-panel { transition: none; }
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
|
|
128
|
+
function ensureStyles(doc: Document = document) {
|
|
129
|
+
if (typeof doc === "undefined") return;
|
|
130
|
+
if (doc.querySelector('style[data-pu-ui="dialog"]')) return;
|
|
131
|
+
const el = doc.createElement("style");
|
|
132
|
+
el.setAttribute("data-pu-ui", "dialog");
|
|
133
|
+
el.textContent = styles;
|
|
134
|
+
doc.head.appendChild(el);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Modal dialog with scrim. Control via `open` + `onClose`.
|
|
139
|
+
* Escape, scroll lock, and focus trap via shared `attachOverlay`.
|
|
140
|
+
*/
|
|
141
|
+
export const Dialog = component((raw: DialogProps) => {
|
|
142
|
+
ensureStyles();
|
|
143
|
+
const props = mergeProps({ size: "md" as const }, raw) as ComponentProps<
|
|
144
|
+
DialogProps & { size: "sm" | "md" | "lg" }
|
|
145
|
+
>;
|
|
146
|
+
|
|
147
|
+
const isOpen = () => readBool(props.open as MaybeReactive<boolean>);
|
|
148
|
+
const titleId = puId("pu-dialog-title");
|
|
149
|
+
let rootEl: HTMLElement | null = null;
|
|
150
|
+
let panelEl: HTMLElement | null = null;
|
|
151
|
+
|
|
152
|
+
effect(() => {
|
|
153
|
+
if (!isOpen()) return;
|
|
154
|
+
return attachOverlay({
|
|
155
|
+
getRoot: () => rootEl,
|
|
156
|
+
getFocusRoot: () => panelEl,
|
|
157
|
+
onClose: () => props.onClose?.(),
|
|
158
|
+
scrollLock: true,
|
|
159
|
+
escape: true,
|
|
160
|
+
onAttach: ({ doc }) => {
|
|
161
|
+
ensureStyles(doc);
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div
|
|
168
|
+
class={() =>
|
|
169
|
+
cx(
|
|
170
|
+
"pu-dialog-root",
|
|
171
|
+
isOpen() && "pu-dialog-root--open",
|
|
172
|
+
typeof props.class === "function"
|
|
173
|
+
? (props.class as () => string)()
|
|
174
|
+
: props.class,
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
aria-hidden={() => (!isOpen() ? "true" : "false")}
|
|
178
|
+
ref={(el) => {
|
|
179
|
+
rootEl = el;
|
|
180
|
+
ensureStyles(el.ownerDocument);
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
<div
|
|
184
|
+
class="pu-dialog-backdrop"
|
|
185
|
+
onClick={() => props.onClose?.()}
|
|
186
|
+
aria-hidden="true"
|
|
187
|
+
/>
|
|
188
|
+
<div
|
|
189
|
+
class={() => cx("pu-dialog-panel", `pu-dialog-panel--${props.size}`)}
|
|
190
|
+
role="dialog"
|
|
191
|
+
aria-modal="true"
|
|
192
|
+
aria-labelledby={props.title ? titleId : undefined}
|
|
193
|
+
onClick={(e: MouseEvent) => e.stopPropagation()}
|
|
194
|
+
ref={(el) => {
|
|
195
|
+
panelEl = el;
|
|
196
|
+
}}
|
|
197
|
+
>
|
|
198
|
+
{(props.title || props.onClose) && (
|
|
199
|
+
<div class="pu-dialog__head">
|
|
200
|
+
<div>
|
|
201
|
+
{props.title ? (
|
|
202
|
+
<h2 class="pu-dialog__title" id={titleId}>
|
|
203
|
+
{props.title}
|
|
204
|
+
</h2>
|
|
205
|
+
) : null}
|
|
206
|
+
{props.description ? (
|
|
207
|
+
<p class="pu-dialog__desc">{props.description}</p>
|
|
208
|
+
) : null}
|
|
209
|
+
</div>
|
|
210
|
+
{props.onClose ? (
|
|
211
|
+
<button
|
|
212
|
+
type="button"
|
|
213
|
+
class="pu-dialog__close"
|
|
214
|
+
aria-label="Close"
|
|
215
|
+
onClick={() => props.onClose?.()}
|
|
216
|
+
>
|
|
217
|
+
×
|
|
218
|
+
</button>
|
|
219
|
+
) : null}
|
|
220
|
+
</div>
|
|
221
|
+
)}
|
|
222
|
+
<div class="pu-dialog__body">{props.children as never}</div>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
);
|
|
226
|
+
});
|