@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,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@lab206/dom/jsx-runtime";
|
|
2
|
+
import { component, mergeProps } from "@lab206/dom";
|
|
3
|
+
import { cx } from "../utils.js";
|
|
4
|
+
import { createStyleSheet } from "../styles.js";
|
|
5
|
+
import { readBool, readNum } from "../reactive.js";
|
|
6
|
+
const ensure = createStyleSheet("number-input", `
|
|
7
|
+
.pu-number {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: stretch;
|
|
10
|
+
border: 1px solid var(--pu-color-control-border, var(--pu-color-border));
|
|
11
|
+
border-radius: var(--pu-radius-md);
|
|
12
|
+
background: var(--pu-color-surface);
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
height: var(--pu-control-h-md);
|
|
15
|
+
}
|
|
16
|
+
.pu-number:focus-within {
|
|
17
|
+
border-color: var(--pu-color-accent);
|
|
18
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--pu-color-accent) 18%, transparent);
|
|
19
|
+
}
|
|
20
|
+
.pu-number[data-disabled="true"] {
|
|
21
|
+
opacity: 0.55;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
24
|
+
.pu-number__btn {
|
|
25
|
+
appearance: none;
|
|
26
|
+
border: 0;
|
|
27
|
+
background: var(--pu-color-surface-2);
|
|
28
|
+
color: var(--pu-color-text);
|
|
29
|
+
width: 2rem;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
font-size: 1rem;
|
|
32
|
+
line-height: 1;
|
|
33
|
+
flex-shrink: 0;
|
|
34
|
+
}
|
|
35
|
+
.pu-number__btn:hover:not(:disabled) {
|
|
36
|
+
background: color-mix(in srgb, var(--pu-color-accent) 12%, var(--pu-color-surface-2));
|
|
37
|
+
}
|
|
38
|
+
.pu-number__btn:focus-visible {
|
|
39
|
+
outline: none;
|
|
40
|
+
z-index: 1;
|
|
41
|
+
box-shadow:
|
|
42
|
+
inset 0 0 0 2px color-mix(in srgb, var(--pu-color-focus) 45%, transparent);
|
|
43
|
+
}
|
|
44
|
+
.pu-number__btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
45
|
+
.pu-number__input {
|
|
46
|
+
appearance: textfield;
|
|
47
|
+
-moz-appearance: textfield;
|
|
48
|
+
border: 0;
|
|
49
|
+
background: transparent;
|
|
50
|
+
color: var(--pu-color-text);
|
|
51
|
+
font: inherit;
|
|
52
|
+
font-size: var(--pu-text-sm);
|
|
53
|
+
font-variant-numeric: tabular-nums;
|
|
54
|
+
text-align: center;
|
|
55
|
+
width: 4rem;
|
|
56
|
+
min-width: 0;
|
|
57
|
+
padding: 0 0.25rem;
|
|
58
|
+
outline: none;
|
|
59
|
+
}
|
|
60
|
+
.pu-number__input::-webkit-outer-spin-button,
|
|
61
|
+
.pu-number__input::-webkit-inner-spin-button {
|
|
62
|
+
-webkit-appearance: none;
|
|
63
|
+
margin: 0;
|
|
64
|
+
}
|
|
65
|
+
`);
|
|
66
|
+
function clamp(n, min, max) {
|
|
67
|
+
let v = n;
|
|
68
|
+
if (min != null && !Number.isNaN(min))
|
|
69
|
+
v = Math.max(min, v);
|
|
70
|
+
if (max != null && !Number.isNaN(max))
|
|
71
|
+
v = Math.min(max, v);
|
|
72
|
+
return v;
|
|
73
|
+
}
|
|
74
|
+
/** Numeric stepper with − / + controls. */
|
|
75
|
+
export const NumberInput = component((raw) => {
|
|
76
|
+
ensure();
|
|
77
|
+
const props = mergeProps({ step: 1 }, raw);
|
|
78
|
+
const id = props.id ?? `pu-num-${Math.random().toString(36).slice(2, 9)}`;
|
|
79
|
+
const val = () => readNum(props.value, 0);
|
|
80
|
+
const isDisabled = () => readBool(props.disabled);
|
|
81
|
+
const set = (n) => {
|
|
82
|
+
const next = clamp(n, props.min, props.max);
|
|
83
|
+
if (!Number.isNaN(next))
|
|
84
|
+
props.onChange?.(next);
|
|
85
|
+
};
|
|
86
|
+
return (_jsxs("div", { class: () => cx("pu-number", typeof props.class === "function" ? props.class() : props.class), "data-disabled": () => (isDisabled() ? "true" : "false"), ref: (el) => ensure(el.ownerDocument), children: [_jsx("button", { type: "button", class: "pu-number__btn", "aria-label": "Decrease", disabled: () => isDisabled() || (props.min != null && val() <= props.min), onClick: () => set(val() - props.step), children: "\u2212" }), _jsx("input", { id: id, class: "pu-number__input", type: "number", value: val, min: props.min, max: props.max, step: props.step, disabled: isDisabled, placeholder: props.placeholder, "aria-label": props["aria-label"], onInput: (e) => {
|
|
87
|
+
const n = Number(e.target.value);
|
|
88
|
+
if (!Number.isNaN(n))
|
|
89
|
+
set(n);
|
|
90
|
+
} }), _jsx("button", { type: "button", class: "pu-number__btn", "aria-label": "Increase", disabled: () => isDisabled() || (props.max != null && val() >= props.max), onClick: () => set(val() + props.step), children: "+" })] }));
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=NumberInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberInput.js","sourceRoot":"","sources":["../../src/components/NumberInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAsB,MAAM,gBAAgB,CAAC;AAevE,MAAM,MAAM,GAAG,gBAAgB,CAC7B,cAAc,EACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DD,CACA,CAAC;AAEF,SAAS,KAAK,CAAC,CAAS,EAAE,GAAY,EAAE,GAAY;IAClD,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC5D,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC5D,OAAO,CAAC,CAAC;AACX,CAAC;AAED,2CAA2C;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,GAAqB,EAAE,EAAE;IAC7D,MAAM,EAAE,CAA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,GAAG,IAAI,IAAI,IAAI,GAAG,EAAE,IAAI,KAAK,CAAC,GAAG,CAAC,EAE3D,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,uBAG/B,EACT,gBACE,EAAE,EAAE,EAAE,EACN,KAAK,EAAC,kBAAkB,EACxB,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,GAAG,EACV,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,QAAQ,EAAE,UAAU,EACpB,WAAW,EAAE,KAAK,CAAC,WAAW,gBAClB,KAAK,CAAC,YAAY,CAAC,EAC/B,OAAO,EAAE,CAAC,CAAQ,EAAE,EAAE;oBACpB,MAAM,CAAC,GAAG,MAAM,CAAE,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAC,CAAC;oBACvD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;wBAAE,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC/B,CAAC,GACD,EACF,iBACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,gBAAgB,gBACX,UAAU,EACrB,QAAQ,EAAE,GAAG,EAAE,CACb,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,GAAG,EAAE,IAAI,KAAK,CAAC,GAAG,CAAC,EAE3D,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,kBAG/B,IACL,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PaginationProps = {
|
|
2
|
+
page: number | (() => number);
|
|
3
|
+
pageCount: number | (() => number);
|
|
4
|
+
onChange?: (page: number) => void;
|
|
5
|
+
class?: string | (() => string);
|
|
6
|
+
};
|
|
7
|
+
export declare const Pagination: import("@lab206/dom").Component<{
|
|
8
|
+
page: number | (() => number);
|
|
9
|
+
pageCount: number | (() => number);
|
|
10
|
+
onChange?: (page: number) => void;
|
|
11
|
+
class?: string | (() => string);
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=Pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../../src/components/Pagination.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;CACjC,CAAC;AA0DF,eAAO,MAAM,UAAU;UA9Df,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC;eAClB,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC;eACvB,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI;YACzB,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC;EAgJ/B,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@lab206/dom/jsx-runtime";
|
|
2
|
+
import { component } from "@lab206/dom";
|
|
3
|
+
import { cx } from "../utils.js";
|
|
4
|
+
import { createStyleSheet } from "../styles.js";
|
|
5
|
+
const ensure = createStyleSheet("pagination", `
|
|
6
|
+
.pu-pagination {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: 0.35rem;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
}
|
|
12
|
+
.pu-pagination__btn {
|
|
13
|
+
appearance: none;
|
|
14
|
+
border: 1px solid var(--pu-color-border);
|
|
15
|
+
background: var(--pu-color-surface);
|
|
16
|
+
color: var(--pu-color-text);
|
|
17
|
+
font: inherit;
|
|
18
|
+
font-size: var(--pu-text-sm);
|
|
19
|
+
font-weight: var(--pu-font-medium);
|
|
20
|
+
min-width: 2rem;
|
|
21
|
+
height: 2rem;
|
|
22
|
+
padding: 0 0.5rem;
|
|
23
|
+
border-radius: var(--pu-radius-md);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
}
|
|
26
|
+
.pu-pagination__btn:hover:not(:disabled) {
|
|
27
|
+
background: var(--pu-color-surface-2);
|
|
28
|
+
}
|
|
29
|
+
.pu-pagination__btn:focus-visible {
|
|
30
|
+
outline: none;
|
|
31
|
+
box-shadow:
|
|
32
|
+
0 0 0 2px var(--pu-color-surface),
|
|
33
|
+
0 0 0 4px color-mix(in srgb, var(--pu-color-focus) 55%, transparent);
|
|
34
|
+
}
|
|
35
|
+
.pu-pagination__btn:disabled {
|
|
36
|
+
opacity: 0.45;
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
}
|
|
39
|
+
.pu-pagination__btn.is-active {
|
|
40
|
+
background: var(--pu-color-accent);
|
|
41
|
+
color: var(--pu-color-accent-fg);
|
|
42
|
+
border-color: transparent;
|
|
43
|
+
}
|
|
44
|
+
.pu-pagination__btn {
|
|
45
|
+
transition:
|
|
46
|
+
background var(--pu-duration-fast) var(--pu-ease),
|
|
47
|
+
color var(--pu-duration-fast) var(--pu-ease),
|
|
48
|
+
border-color var(--pu-duration-fast) var(--pu-ease),
|
|
49
|
+
box-shadow var(--pu-duration-fast) var(--pu-ease);
|
|
50
|
+
}
|
|
51
|
+
.pu-pagination__meta {
|
|
52
|
+
font-size: var(--pu-text-xs);
|
|
53
|
+
color: var(--pu-color-text-muted);
|
|
54
|
+
margin-left: 0.35rem;
|
|
55
|
+
}
|
|
56
|
+
`);
|
|
57
|
+
export const Pagination = component((raw) => {
|
|
58
|
+
ensure();
|
|
59
|
+
const props = raw;
|
|
60
|
+
const page = () => typeof props.page === "function"
|
|
61
|
+
? props.page()
|
|
62
|
+
: props.page;
|
|
63
|
+
const count = () => typeof props.pageCount === "function"
|
|
64
|
+
? props.pageCount()
|
|
65
|
+
: props.pageCount;
|
|
66
|
+
const go = (p) => {
|
|
67
|
+
const c = Math.max(1, count());
|
|
68
|
+
const next = Math.min(c, Math.max(1, p));
|
|
69
|
+
props.onChange?.(next);
|
|
70
|
+
};
|
|
71
|
+
// Build a compact page list: 1 … n around current
|
|
72
|
+
const pages = () => {
|
|
73
|
+
const c = Math.max(1, count());
|
|
74
|
+
const p = page();
|
|
75
|
+
const set = new Set([1, c, p - 1, p, p + 1]);
|
|
76
|
+
return [...set].filter((n) => n >= 1 && n <= c).sort((a, b) => a - b);
|
|
77
|
+
};
|
|
78
|
+
return (_jsxs("div", { class: () => cx("pu-pagination", typeof props.class === "function" ? props.class() : props.class), role: "navigation", "aria-label": "Pagination", ref: (el) => ensure(el.ownerDocument), children: [_jsx("button", { type: "button", class: "pu-pagination__btn", disabled: () => page() <= 1, onClick: () => go(page() - 1), "aria-label": "Previous page", children: "\u2039" }), () => {
|
|
79
|
+
const list = pages();
|
|
80
|
+
const frag = document.createDocumentFragment();
|
|
81
|
+
let prev = 0;
|
|
82
|
+
for (const n of list) {
|
|
83
|
+
if (prev && n - prev > 1) {
|
|
84
|
+
const dots = document.createElement("span");
|
|
85
|
+
dots.className = "pu-pagination__meta";
|
|
86
|
+
dots.textContent = "…";
|
|
87
|
+
frag.appendChild(dots);
|
|
88
|
+
}
|
|
89
|
+
const btn = document.createElement("button");
|
|
90
|
+
btn.type = "button";
|
|
91
|
+
btn.className =
|
|
92
|
+
"pu-pagination__btn" + (n === page() ? " is-active" : "");
|
|
93
|
+
btn.textContent = String(n);
|
|
94
|
+
btn.setAttribute("aria-label", `Page ${n}`);
|
|
95
|
+
if (n === page())
|
|
96
|
+
btn.setAttribute("aria-current", "page");
|
|
97
|
+
btn.onclick = () => go(n);
|
|
98
|
+
frag.appendChild(btn);
|
|
99
|
+
prev = n;
|
|
100
|
+
}
|
|
101
|
+
return frag;
|
|
102
|
+
}, _jsx("button", { type: "button", class: "pu-pagination__btn", disabled: () => page() >= count(), onClick: () => go(page() + 1), "aria-label": "Next page", children: "\u203A" }), _jsx("span", { class: "pu-pagination__meta", children: () => `Page ${page()} / ${count()}` })] }));
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=Pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.js","sourceRoot":"","sources":["../../src/components/Pagination.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAShD,MAAM,MAAM,GAAG,gBAAgB,CAC7B,YAAY,EACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDD,CACA,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,GAAoB,EAAE,EAAE;IAC3D,MAAM,EAAE,CAAC;IACT,MAAM,KAAK,GAAG,GAAsC,CAAC;IACrD,MAAM,IAAI,GAAG,GAAG,EAAE,CAChB,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU;QAC9B,CAAC,CAAE,KAAK,CAAC,IAAqB,EAAE;QAChC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IACjB,MAAM,KAAK,GAAG,GAAG,EAAE,CACjB,OAAO,KAAK,CAAC,SAAS,KAAK,UAAU;QACnC,CAAC,CAAE,KAAK,CAAC,SAA0B,EAAE;QACrC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAEtB,MAAM,EAAE,GAAG,CAAC,CAAS,EAAE,EAAE;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK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AC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,EACD,iBACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,oBAAoB,EAC1B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,EAAE,EACjC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,gBAClB,WAAW,uBAGf,EACT,eAAM,KAAK,EAAC,qBAAqB,YAC9B,GAAG,EAAE,CAAC,QAAQ,IAAI,EAAE,MAAM,KAAK,EAAE,EAAE,GAC/B,IACH,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type MaybeReactive } from "../reactive.js";
|
|
2
|
+
export type PopoverProps = {
|
|
3
|
+
/** Controlled open state (boolean, signal, or accessor) */
|
|
4
|
+
open: MaybeReactive<boolean>;
|
|
5
|
+
onOpenChange?: (open: boolean) => void;
|
|
6
|
+
/** Trigger content (usually a Button) */
|
|
7
|
+
trigger: unknown;
|
|
8
|
+
/** Panel body */
|
|
9
|
+
children?: unknown;
|
|
10
|
+
/** Preferred alignment under the trigger */
|
|
11
|
+
align?: "start" | "center" | "end";
|
|
12
|
+
class?: MaybeReactive<string>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Anchored floating panel. Control with `open` + `onOpenChange`.
|
|
16
|
+
* Escape + outside dismiss via shared `attachOverlay` (stacked with modals).
|
|
17
|
+
*/
|
|
18
|
+
export declare const Popover: import("@lab206/dom").Component<{
|
|
19
|
+
open: MaybeReactive<boolean>;
|
|
20
|
+
onOpenChange?: (open: boolean) => void;
|
|
21
|
+
trigger: unknown;
|
|
22
|
+
children?: unknown;
|
|
23
|
+
align?: "start" | "center" | "end";
|
|
24
|
+
class?: MaybeReactive<string>;
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=Popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../src/components/Popover.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,2DAA2D;IAC3D,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AAiEF;;;GAGG;AACH,eAAO,MAAM,OAAO;UA9EZ,aAAa,CAAC,OAAO,CAAC;mBACb,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI;aAE7B,OAAO;eAEL,OAAO;YAEV,OAAO,GAAG,QAAQ,GAAG,KAAK;YAC1B,aAAa,CAAC,MAAM,CAAC;EA0M7B,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@lab206/dom/jsx-runtime";
|
|
2
|
+
import { effect } from "@lab206/core";
|
|
3
|
+
import { component, mergeProps } from "@lab206/dom";
|
|
4
|
+
import { cx } from "../utils.js";
|
|
5
|
+
import { attachOverlay } from "../overlay.js";
|
|
6
|
+
import { readBool } from "../reactive.js";
|
|
7
|
+
const styles = `
|
|
8
|
+
.pu-popover {
|
|
9
|
+
position: relative;
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
vertical-align: middle;
|
|
12
|
+
max-width: 100%;
|
|
13
|
+
}
|
|
14
|
+
.pu-popover--open {
|
|
15
|
+
z-index: var(--pu-z-overlay);
|
|
16
|
+
}
|
|
17
|
+
.pu-popover__trigger {
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
.pu-popover__panel {
|
|
23
|
+
position: fixed;
|
|
24
|
+
z-index: var(--pu-z-overlay);
|
|
25
|
+
min-width: 12rem;
|
|
26
|
+
max-width: min(20rem, calc(100vw - 1.5rem));
|
|
27
|
+
max-height: min(70vh, 24rem);
|
|
28
|
+
overflow: auto;
|
|
29
|
+
padding: var(--pu-space-3);
|
|
30
|
+
border-radius: var(--pu-radius-lg);
|
|
31
|
+
background: var(--pu-color-surface-elevated);
|
|
32
|
+
color: var(--pu-color-text);
|
|
33
|
+
border: 1px solid var(--pu-color-border);
|
|
34
|
+
box-shadow: var(--pu-shadow-float);
|
|
35
|
+
opacity: 0;
|
|
36
|
+
visibility: hidden;
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
transform: translateY(6px) scale(0.98);
|
|
39
|
+
transform-origin: top center;
|
|
40
|
+
transition:
|
|
41
|
+
opacity var(--pu-duration) var(--pu-ease-out),
|
|
42
|
+
transform var(--pu-duration) var(--pu-ease-out),
|
|
43
|
+
visibility var(--pu-duration) var(--pu-ease-out);
|
|
44
|
+
}
|
|
45
|
+
.pu-popover__panel[data-side="top"] {
|
|
46
|
+
transform: translateY(-6px) scale(0.98);
|
|
47
|
+
transform-origin: bottom center;
|
|
48
|
+
}
|
|
49
|
+
.pu-popover--open .pu-popover__panel {
|
|
50
|
+
opacity: 1;
|
|
51
|
+
visibility: visible;
|
|
52
|
+
pointer-events: auto;
|
|
53
|
+
transform: translateY(0) scale(1);
|
|
54
|
+
}
|
|
55
|
+
@media (prefers-reduced-motion: reduce) {
|
|
56
|
+
.pu-popover__panel { transition: none; transform: none; }
|
|
57
|
+
.pu-popover--open .pu-popover__panel { transform: none; }
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
function ensureStyles(doc = document) {
|
|
61
|
+
if (typeof doc === "undefined")
|
|
62
|
+
return;
|
|
63
|
+
if (doc.querySelector('style[data-pu-ui="popover"]'))
|
|
64
|
+
return;
|
|
65
|
+
const el = doc.createElement("style");
|
|
66
|
+
el.setAttribute("data-pu-ui", "popover");
|
|
67
|
+
el.textContent = styles;
|
|
68
|
+
doc.head.appendChild(el);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Anchored floating panel. Control with `open` + `onOpenChange`.
|
|
72
|
+
* Escape + outside dismiss via shared `attachOverlay` (stacked with modals).
|
|
73
|
+
*/
|
|
74
|
+
export const Popover = component((raw) => {
|
|
75
|
+
ensureStyles();
|
|
76
|
+
const props = mergeProps({ align: "start" }, raw);
|
|
77
|
+
const isOpen = () => readBool(props.open);
|
|
78
|
+
let rootEl = null;
|
|
79
|
+
let panelEl = null;
|
|
80
|
+
let triggerEl = null;
|
|
81
|
+
const placePanel = () => {
|
|
82
|
+
if (!rootEl || !panelEl || !triggerEl || !isOpen())
|
|
83
|
+
return;
|
|
84
|
+
const doc = rootEl.ownerDocument;
|
|
85
|
+
const win = doc.defaultView ?? window;
|
|
86
|
+
const gap = 8;
|
|
87
|
+
const pad = 8;
|
|
88
|
+
const rect = triggerEl.getBoundingClientRect();
|
|
89
|
+
const vw = win.innerWidth;
|
|
90
|
+
const vh = win.innerHeight;
|
|
91
|
+
panelEl.style.maxHeight = "";
|
|
92
|
+
const naturalH = panelEl.scrollHeight || panelEl.offsetHeight || 160;
|
|
93
|
+
const pw = Math.min(panelEl.offsetWidth || 192, Math.max(pad * 2, vw - pad * 2));
|
|
94
|
+
const spaceBelow = vh - rect.bottom - gap - pad;
|
|
95
|
+
const spaceAbove = rect.top - gap - pad;
|
|
96
|
+
const placeAbove = spaceBelow < Math.min(naturalH, 120) && spaceAbove > spaceBelow;
|
|
97
|
+
const available = Math.max(96, placeAbove ? spaceAbove : spaceBelow);
|
|
98
|
+
const maxH = Math.min(naturalH, available, vh * 0.7);
|
|
99
|
+
panelEl.style.maxHeight = `${Math.round(maxH)}px`;
|
|
100
|
+
const ph = Math.min(panelEl.offsetHeight || maxH, maxH);
|
|
101
|
+
let top;
|
|
102
|
+
if (placeAbove) {
|
|
103
|
+
top = rect.top - gap - ph;
|
|
104
|
+
panelEl.dataset.side = "top";
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
top = rect.bottom + gap;
|
|
108
|
+
panelEl.dataset.side = "bottom";
|
|
109
|
+
}
|
|
110
|
+
top = Math.min(Math.max(pad, top), Math.max(pad, vh - ph - pad));
|
|
111
|
+
let left = rect.left;
|
|
112
|
+
if (props.align === "center") {
|
|
113
|
+
left = rect.left + rect.width / 2 - pw / 2;
|
|
114
|
+
}
|
|
115
|
+
else if (props.align === "end") {
|
|
116
|
+
left = rect.right - pw;
|
|
117
|
+
}
|
|
118
|
+
left = Math.min(Math.max(pad, left), Math.max(pad, vw - pw - pad));
|
|
119
|
+
panelEl.style.top = `${Math.round(top)}px`;
|
|
120
|
+
panelEl.style.left = `${Math.round(left)}px`;
|
|
121
|
+
panelEl.style.width = "max-content";
|
|
122
|
+
panelEl.style.minWidth = `${Math.min(pw, Math.max(rect.width, 10.5 * 16))}px`;
|
|
123
|
+
};
|
|
124
|
+
effect(() => {
|
|
125
|
+
if (!isOpen())
|
|
126
|
+
return;
|
|
127
|
+
return attachOverlay({
|
|
128
|
+
getRoot: () => rootEl,
|
|
129
|
+
onClose: () => props.onOpenChange?.(false),
|
|
130
|
+
escape: true,
|
|
131
|
+
dismissOutside: true,
|
|
132
|
+
onAttach: ({ doc, win }) => {
|
|
133
|
+
ensureStyles(doc);
|
|
134
|
+
const onReposition = () => placePanel();
|
|
135
|
+
const placeTimer = win.setTimeout(() => {
|
|
136
|
+
placePanel();
|
|
137
|
+
win.setTimeout(placePanel, 16);
|
|
138
|
+
}, 0);
|
|
139
|
+
win.addEventListener("resize", onReposition);
|
|
140
|
+
doc.addEventListener("scroll", onReposition, true);
|
|
141
|
+
win.addEventListener("scroll", onReposition, true);
|
|
142
|
+
return () => {
|
|
143
|
+
win.clearTimeout(placeTimer);
|
|
144
|
+
win.removeEventListener("resize", onReposition);
|
|
145
|
+
doc.removeEventListener("scroll", onReposition, true);
|
|
146
|
+
win.removeEventListener("scroll", onReposition, true);
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
return (_jsxs("div", { class: () => cx("pu-popover", isOpen() && "pu-popover--open", typeof props.class === "function"
|
|
152
|
+
? props.class()
|
|
153
|
+
: props.class), ref: (el) => {
|
|
154
|
+
rootEl = el;
|
|
155
|
+
ensureStyles(el.ownerDocument);
|
|
156
|
+
}, children: [_jsx("div", { class: "pu-popover__trigger", ref: (el) => {
|
|
157
|
+
triggerEl = el;
|
|
158
|
+
}, onClick: (e) => {
|
|
159
|
+
e.stopPropagation();
|
|
160
|
+
props.onOpenChange?.(!isOpen());
|
|
161
|
+
}, children: props.trigger }), _jsx("div", { class: "pu-popover__panel", role: "dialog", "aria-modal": "false", "aria-hidden": () => (!isOpen() ? "true" : "false"), ref: (el) => {
|
|
162
|
+
panelEl = el;
|
|
163
|
+
}, children: props.children })] }));
|
|
164
|
+
});
|
|
165
|
+
//# sourceMappingURL=Popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../src/components/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAsB,MAAM,gBAAgB,CAAC;AAe9D,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDd,CAAC;AAEF,SAAS,YAAY,CAAC,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OAAO,CACL,eACE,KAAK,EAAE,GAAG,EAAE,CACV,EAAE,CACA,YAAY,EACZ,MAAM,EAAE,IAAI,kBAAkB,EAC9B,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU;YAC/B,CAAC,CAAE,KAAK,CAAC,KAAsB,EAAE;YACjC,CAAC,CAAC,KAAK,CAAC,KAAK,CAChB,EAEH,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE;YACV,MAAM,GAAG,EAAE,CAAC;YACZ,YAAY,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC,aAED,cACE,KAAK,EAAC,qBAAqB,EAC3B,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE;oBACV,SAAS,GAAG,EAAE,CAAC;gBACjB,CAAC,EACD,OAAO,EAAE,CAAC,CAAa,EAAE,EAAE;oBACzB,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;gBAClC,CAAC,YAEA,KAAK,CAAC,OAAgB,GACnB,EACN,cACE,KAAK,EAAC,mBAAmB,EACzB,IAAI,EAAC,QAAQ,gBACF,OAAO,iBACL,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EACjD,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE;oBACV,OAAO,GAAG,EAAE,CAAC;gBACf,CAAC,YAEA,KAAK,CAAC,QAAiB,GACpB,IACF,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type ProgressProps = {
|
|
2
|
+
/** 0–100 */
|
|
3
|
+
value?: number | (() => number);
|
|
4
|
+
/** Accessible label */
|
|
5
|
+
label?: string;
|
|
6
|
+
size?: "sm" | "md";
|
|
7
|
+
class?: string | (() => string);
|
|
8
|
+
};
|
|
9
|
+
export declare const Progress: import("@lab206/dom").Component<{
|
|
10
|
+
value?: number | (() => number);
|
|
11
|
+
label?: string;
|
|
12
|
+
size?: "sm" | "md";
|
|
13
|
+
class?: string | (() => string);
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=Progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../../src/components/Progress.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAChC,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;CACjC,CAAC;AAmDF,eAAO,MAAM,QAAQ;YAxDX,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC;YAEvB,MAAM;WACP,IAAI,GAAG,IAAI;YACV,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC;EAkG/B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@lab206/dom/jsx-runtime";
|
|
2
|
+
import { component, mergeProps } from "@lab206/dom";
|
|
3
|
+
import { cx } from "../utils.js";
|
|
4
|
+
const styles = `
|
|
5
|
+
.pu-progress {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: var(--pu-space-2);
|
|
9
|
+
width: 100%;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
}
|
|
12
|
+
.pu-progress__meta {
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
align-items: baseline;
|
|
16
|
+
gap: var(--pu-space-3);
|
|
17
|
+
font-size: var(--pu-text-xs);
|
|
18
|
+
color: var(--pu-color-text-muted);
|
|
19
|
+
font-weight: var(--pu-font-medium);
|
|
20
|
+
}
|
|
21
|
+
.pu-progress__track {
|
|
22
|
+
width: 100%;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
border-radius: var(--pu-radius-full);
|
|
25
|
+
background: var(--pu-color-surface-sunken);
|
|
26
|
+
border: 1px solid var(--pu-color-border);
|
|
27
|
+
}
|
|
28
|
+
.pu-progress--sm .pu-progress__track { height: 0.4rem; }
|
|
29
|
+
.pu-progress--md .pu-progress__track { height: 0.55rem; }
|
|
30
|
+
.pu-progress__bar {
|
|
31
|
+
height: 100%;
|
|
32
|
+
border-radius: inherit;
|
|
33
|
+
background: linear-gradient(
|
|
34
|
+
90deg,
|
|
35
|
+
var(--pu-brand-500),
|
|
36
|
+
var(--pu-sage-400)
|
|
37
|
+
);
|
|
38
|
+
transition: width var(--pu-duration-slow) var(--pu-ease-out);
|
|
39
|
+
box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 10%, transparent);
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
let injected = false;
|
|
43
|
+
function ensureStyles() {
|
|
44
|
+
if (injected || typeof document === "undefined")
|
|
45
|
+
return;
|
|
46
|
+
injected = true;
|
|
47
|
+
const el = document.createElement("style");
|
|
48
|
+
el.setAttribute("data-pu-ui", "progress");
|
|
49
|
+
el.textContent = styles;
|
|
50
|
+
document.head.appendChild(el);
|
|
51
|
+
}
|
|
52
|
+
export const Progress = component((raw) => {
|
|
53
|
+
ensureStyles();
|
|
54
|
+
const props = mergeProps({ value: 0, size: "md" }, raw);
|
|
55
|
+
const pct = () => {
|
|
56
|
+
const v = typeof props.value === "function"
|
|
57
|
+
? props.value()
|
|
58
|
+
: props.value;
|
|
59
|
+
return Math.max(0, Math.min(100, Number.isFinite(v) ? v : 0));
|
|
60
|
+
};
|
|
61
|
+
return (_jsxs("div", { class: () => cx("pu-progress", `pu-progress--${props.size}`, typeof props.class === "function" ? props.class() : props.class), children: [props.label ? (_jsxs("div", { class: "pu-progress__meta", children: [_jsx("span", { children: props.label }), _jsx("span", { children: () => `${Math.round(pct())}%` })] })) : null, _jsx("div", { class: "pu-progress__track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": () => Math.round(pct()), "aria-label": props.label, children: _jsx("div", { class: "pu-progress__bar", style: () => ({ width: `${pct()}%` }) }) })] }));
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=Progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../src/components/Progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAWjC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCd,CAAC;AAEF,IAAI,QAAQ,GAAG,KAAK,CAAC;AACrB,SAAS,YAAY;IACnB,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IACxD,QAAQ,GAAG,IAAI,CAAC;IAChB,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAC1C,EAAE,CAAC,WAAW,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,GAAkB,EAAE,EAAE;IACvD,YAAY,EAAE,CAAC;IACf,MAAM,KAAK,GAAG,UAAU,CACtB,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAa,EAAE,EACjC,GAAG,CACqF,CAAC;IAE3F,MAAM,GAAG,GAAG,GAAG,EAAE;QACf,MAAM,CAAC,GACL,OAAO,KAAK,CAA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|
4
|
+
disabled?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type RadioGroupProps = {
|
|
7
|
+
options: RadioOption[] | (() => RadioOption[]);
|
|
8
|
+
value?: string | (() => string);
|
|
9
|
+
name?: string;
|
|
10
|
+
disabled?: boolean | (() => boolean);
|
|
11
|
+
onChange?: (value: string) => void;
|
|
12
|
+
orientation?: "vertical" | "horizontal";
|
|
13
|
+
class?: string | (() => string);
|
|
14
|
+
};
|
|
15
|
+
/** Radio group — single selection from options. */
|
|
16
|
+
export declare const RadioGroup: import("@lab206/dom").Component<{
|
|
17
|
+
options: RadioOption[] | (() => RadioOption[]);
|
|
18
|
+
value?: string | (() => string);
|
|
19
|
+
name?: string;
|
|
20
|
+
disabled?: boolean | (() => boolean);
|
|
21
|
+
onChange?: (value: string) => void;
|
|
22
|
+
orientation?: "vertical" | "horizontal";
|
|
23
|
+
class?: string | (() => string);
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=Radio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../src/components/Radio.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,WAAW,EAAE,CAAC,CAAC;IAC/C,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;CACjC,CAAC;AAkFF,mDAAmD;AACnD,eAAO,MAAM,UAAU;aA1FZ,WAAW,EAAE,GAAG,CAAC,MAAM,WAAW,EAAE,CAAC;YACtC,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC;WACxB,MAAM;eACF,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC;eACzB,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;kBACpB,UAAU,GAAG,YAAY;YAC/B,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC;EA+I/B,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@lab206/dom/jsx-runtime";
|
|
2
|
+
import { For, component, mergeProps } from "@lab206/dom";
|
|
3
|
+
import { cx } from "../utils.js";
|
|
4
|
+
import { createStyleSheet } from "../styles.js";
|
|
5
|
+
const ensure = createStyleSheet("radio", `
|
|
6
|
+
.pu-radio-group {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: 0.5rem;
|
|
10
|
+
}
|
|
11
|
+
.pu-radio-group--horizontal {
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
gap: 0.75rem 1.25rem;
|
|
15
|
+
}
|
|
16
|
+
.pu-radio {
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: var(--pu-space-2);
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
user-select: none;
|
|
22
|
+
font-size: var(--pu-text-sm);
|
|
23
|
+
color: var(--pu-color-text);
|
|
24
|
+
}
|
|
25
|
+
.pu-radio[data-disabled="true"] {
|
|
26
|
+
opacity: 0.55;
|
|
27
|
+
cursor: not-allowed;
|
|
28
|
+
}
|
|
29
|
+
.pu-radio__dot {
|
|
30
|
+
width: 1.1rem;
|
|
31
|
+
height: 1.1rem;
|
|
32
|
+
border-radius: 50%;
|
|
33
|
+
border: 1.5px solid var(--pu-color-control-border, var(--pu-color-border-strong));
|
|
34
|
+
background: var(--pu-color-surface);
|
|
35
|
+
display: grid;
|
|
36
|
+
place-items: center;
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
transition:
|
|
39
|
+
border-color var(--pu-duration) var(--pu-ease),
|
|
40
|
+
background var(--pu-duration) var(--pu-ease);
|
|
41
|
+
}
|
|
42
|
+
.pu-radio:hover:not([data-disabled="true"]) .pu-radio__dot {
|
|
43
|
+
border-color: var(--pu-color-border-strong);
|
|
44
|
+
}
|
|
45
|
+
.pu-radio[data-checked="true"] .pu-radio__dot {
|
|
46
|
+
border-color: var(--pu-color-accent);
|
|
47
|
+
}
|
|
48
|
+
.pu-radio__dot::after {
|
|
49
|
+
content: "";
|
|
50
|
+
width: 0.45rem;
|
|
51
|
+
height: 0.45rem;
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
background: var(--pu-color-accent);
|
|
54
|
+
opacity: 0;
|
|
55
|
+
transform: scale(0.5);
|
|
56
|
+
transition:
|
|
57
|
+
opacity var(--pu-duration) var(--pu-ease),
|
|
58
|
+
transform var(--pu-duration) var(--pu-ease);
|
|
59
|
+
}
|
|
60
|
+
.pu-radio[data-checked="true"] .pu-radio__dot::after {
|
|
61
|
+
opacity: 1;
|
|
62
|
+
transform: scale(1);
|
|
63
|
+
}
|
|
64
|
+
.pu-radio__input {
|
|
65
|
+
position: absolute;
|
|
66
|
+
opacity: 0;
|
|
67
|
+
width: 0;
|
|
68
|
+
height: 0;
|
|
69
|
+
}
|
|
70
|
+
.pu-radio__input:focus-visible + .pu-radio__dot {
|
|
71
|
+
outline: none;
|
|
72
|
+
box-shadow:
|
|
73
|
+
0 0 0 2px var(--pu-color-surface),
|
|
74
|
+
0 0 0 4px color-mix(in srgb, var(--pu-color-focus) 55%, transparent);
|
|
75
|
+
}
|
|
76
|
+
@media (prefers-reduced-motion: reduce) {
|
|
77
|
+
.pu-radio__dot,
|
|
78
|
+
.pu-radio__dot::after { transition: none; }
|
|
79
|
+
}
|
|
80
|
+
`);
|
|
81
|
+
/** Radio group — single selection from options. */
|
|
82
|
+
export const RadioGroup = component((raw) => {
|
|
83
|
+
ensure();
|
|
84
|
+
const props = mergeProps({ orientation: "vertical" }, raw);
|
|
85
|
+
const name = props.name ?? `pu-radio-${Math.random().toString(36).slice(2, 9)}`;
|
|
86
|
+
const current = () => typeof props.value === "function"
|
|
87
|
+
? props.value()
|
|
88
|
+
: (props.value ?? "");
|
|
89
|
+
const groupDisabled = () => !!(typeof props.disabled === "function" ? props.disabled() : props.disabled);
|
|
90
|
+
const getOptions = () => typeof props.options === "function"
|
|
91
|
+
? props.options()
|
|
92
|
+
: (props.options ?? []);
|
|
93
|
+
return (_jsx("div", { class: () => cx("pu-radio-group", props.orientation === "horizontal" && "pu-radio-group--horizontal", typeof props.class === "function" ? props.class() : props.class), role: "radiogroup", ref: (el) => ensure(el.ownerDocument), children: _jsx(For, { each: getOptions, children: (opt) => (_jsxs("label", { class: "pu-radio", "data-checked": () => (current() === opt().value ? "true" : "false"), "data-disabled": () => groupDisabled() || opt().disabled ? "true" : "false", children: [_jsx("input", { class: "pu-radio__input", type: "radio", name: name, value: () => opt().value, checked: () => current() === opt().value, disabled: () => groupDisabled() || !!opt().disabled, onChange: () => props.onChange?.(opt().value) }), _jsx("span", { class: "pu-radio__dot", "aria-hidden": "true" }), _jsx("span", { children: () => opt().label })] })) }) }));
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=Radio.js.map
|