@glasshome/ui 1.9.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -13
- package/SPEC.md +4 -4
- package/dist/lib/badge-tone.d.ts +0 -2
- package/dist/solid/badge.d.ts +1 -1
- package/dist/solid/card.d.ts +4 -2
- package/dist/solid/icon.d.ts +14 -0
- package/dist/solid/index.js +1645 -1632
- package/dist/solid/spinner.d.ts +1 -1
- package/package.json +9 -12
- package/scripts/check-pack.ts +32 -0
- package/src/index.ts +111 -0
- package/src/lib/badge-tone.ts +0 -4
- package/src/lib/carousel-classes.ts +2 -3
- package/src/solid/accordion.tsx +60 -0
- package/src/solid/alert-dialog.tsx +148 -0
- package/src/solid/alert.tsx +118 -0
- package/src/solid/area-picker.tsx +225 -0
- package/src/solid/aspect-ratio.tsx +21 -0
- package/src/solid/avatar.tsx +41 -0
- package/src/solid/badge.tsx +74 -0
- package/src/solid/bottom-sheet/arbitration.ts +40 -0
- package/src/solid/bottom-sheet/bottom-sheet.tsx +457 -0
- package/src/solid/bottom-sheet/constants.ts +8 -0
- package/src/solid/bottom-sheet/drag-controller.ts +221 -0
- package/src/solid/bottom-sheet/focus-trap.ts +56 -0
- package/src/solid/bottom-sheet/index.ts +14 -0
- package/src/solid/bottom-sheet/keyboard.ts +35 -0
- package/src/solid/bottom-sheet/scroll-lock.ts +64 -0
- package/src/solid/bottom-sheet/state-machine.ts +40 -0
- package/src/solid/bottom-sheet/velocity.ts +42 -0
- package/src/solid/breadcrumb.tsx +105 -0
- package/src/solid/button-group.tsx +66 -0
- package/src/solid/button.tsx +20 -0
- package/src/solid/card.tsx +101 -0
- package/src/solid/carousel.tsx +302 -0
- package/src/solid/charts.tsx +338 -0
- package/src/solid/checkbox.tsx +70 -0
- package/src/solid/collapsible.tsx +38 -0
- package/src/solid/color-slider.tsx +98 -0
- package/src/solid/color-wheel.tsx +77 -0
- package/src/solid/context-menu.tsx +109 -0
- package/src/solid/copy-button.tsx +46 -0
- package/src/solid/count-pill.tsx +24 -0
- package/src/solid/data-table.tsx +248 -0
- package/src/solid/dialog-parts.tsx +242 -0
- package/src/solid/dialog.tsx +121 -0
- package/src/solid/dock.tsx +186 -0
- package/src/solid/dropdown-menu.tsx +130 -0
- package/src/solid/empty.tsx +99 -0
- package/src/solid/entity-data.ts +78 -0
- package/src/solid/entity-selector.tsx +697 -0
- package/src/solid/field.tsx +253 -0
- package/src/solid/form.tsx +231 -0
- package/src/solid/hero-action.tsx +117 -0
- package/src/solid/hover-card.tsx +26 -0
- package/src/solid/icon-picker.tsx +432 -0
- package/src/solid/icon.tsx +20 -0
- package/src/solid/image-picker.tsx +380 -0
- package/src/solid/index.ts +417 -0
- package/src/solid/input-group.tsx +170 -0
- package/src/solid/input-otp.tsx +175 -0
- package/src/solid/input.tsx +12 -0
- package/src/solid/item.tsx +179 -0
- package/src/solid/kbd.tsx +30 -0
- package/src/solid/label.tsx +19 -0
- package/src/solid/list-reorder.ts +148 -0
- package/src/solid/logo.tsx +79 -0
- package/src/solid/media-copy.ts +37 -0
- package/src/solid/media-store.ts +110 -0
- package/src/solid/media-tile.tsx +100 -0
- package/src/solid/menu-parts.tsx +248 -0
- package/src/solid/number-field.tsx +72 -0
- package/src/solid/option-card.tsx +218 -0
- package/src/solid/ornament.tsx +53 -0
- package/src/solid/overlay.tsx +16 -0
- package/src/solid/page-header.tsx +102 -0
- package/src/solid/pagination.tsx +111 -0
- package/src/solid/password-input.tsx +69 -0
- package/src/solid/picker-row.tsx +102 -0
- package/src/solid/picker-search.tsx +78 -0
- package/src/solid/popover.tsx +103 -0
- package/src/solid/progress.tsx +31 -0
- package/src/solid/radio-group.tsx +60 -0
- package/src/solid/resizable.tsx +149 -0
- package/src/solid/responsive-dialog.tsx +180 -0
- package/src/solid/schema-form.tsx +830 -0
- package/src/solid/scope-indicator.tsx +13 -0
- package/src/solid/scroll-area.tsx +27 -0
- package/src/solid/section-card.tsx +358 -0
- package/src/solid/select.tsx +139 -0
- package/src/solid/separator.tsx +35 -0
- package/src/solid/settings-row.tsx +159 -0
- package/src/solid/sheet.tsx +157 -0
- package/src/solid/skeleton.tsx +15 -0
- package/src/solid/slider.tsx +148 -0
- package/src/solid/sliding-indicator.tsx +294 -0
- package/src/solid/sonner.tsx +219 -0
- package/src/solid/spinner.tsx +20 -0
- package/src/solid/step-indicator.tsx +30 -0
- package/src/solid/switch.tsx +62 -0
- package/src/solid/table.tsx +98 -0
- package/src/solid/tabs.tsx +86 -0
- package/src/solid/textarea.tsx +16 -0
- package/src/solid/toggle-group.tsx +102 -0
- package/src/solid/toggle.tsx +57 -0
- package/src/solid/tooltip.tsx +38 -0
- package/src/solid/widget-card.tsx +117 -0
- package/src/solid/widget-identity.tsx +135 -0
- package/src/solid/widget-trust-badge.tsx +37 -0
- package/src/tokens/hex.ts +50 -0
- package/src/tokens/index.ts +8 -0
- package/src/tokens/presets.ts +192 -0
- package/src/tokens/theme-colors.ts +147 -0
- package/dist/lib/carousel-init.d.ts +0 -9
- package/src/astro/Alert.astro +0 -63
- package/src/astro/Badge.astro +0 -18
- package/src/astro/Button.astro +0 -47
- package/src/astro/Card.astro +0 -48
- package/src/astro/Carousel.astro +0 -82
- package/src/astro/Logo.astro +0 -73
- package/src/astro/TierBadge.astro +0 -33
- package/src/lib/carousel-init.ts +0 -87
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Collapsible as CollapsiblePrimitive } from "@kobalte/core/collapsible";
|
|
2
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
|
|
5
|
+
const Collapsible: Component<ComponentProps<typeof CollapsiblePrimitive>> = (props) => {
|
|
6
|
+
return <CollapsiblePrimitive data-slot="collapsible" {...props} />;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const CollapsibleTrigger: Component<ComponentProps<typeof CollapsiblePrimitive.Trigger>> = (
|
|
10
|
+
props,
|
|
11
|
+
) => {
|
|
12
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
13
|
+
return (
|
|
14
|
+
<CollapsiblePrimitive.Trigger
|
|
15
|
+
data-slot="collapsible-trigger"
|
|
16
|
+
class={cn("cursor-pointer py-3", local.class)}
|
|
17
|
+
{...rest}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const CollapsibleContent: Component<ComponentProps<typeof CollapsiblePrimitive.Content>> = (
|
|
23
|
+
props,
|
|
24
|
+
) => {
|
|
25
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
26
|
+
return (
|
|
27
|
+
<CollapsiblePrimitive.Content
|
|
28
|
+
data-slot="collapsible-content"
|
|
29
|
+
class={cn(
|
|
30
|
+
"overflow-hidden data-closed:animate-collapsible-up data-expanded:animate-collapsible-down",
|
|
31
|
+
local.class,
|
|
32
|
+
)}
|
|
33
|
+
{...rest}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { Collapsible, CollapsibleContent, CollapsibleTrigger };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ColorSlider as KColorSlider } from "@kobalte/core/color-slider";
|
|
2
|
+
import type { Color, ColorChannel } from "@kobalte/core/colors";
|
|
3
|
+
import type { Component } from "solid-js";
|
|
4
|
+
import { splitProps } from "solid-js";
|
|
5
|
+
import { FOCUS_RING } from "../lib/input-classes.js";
|
|
6
|
+
import { THUMB_CLASS, THUMB_COLOR_RING, THUMB_RAIL_PAD } from "../lib/thumb-classes.js";
|
|
7
|
+
import { cn } from "../lib/utils.js";
|
|
8
|
+
|
|
9
|
+
interface ColorSliderProps {
|
|
10
|
+
value?: Color;
|
|
11
|
+
defaultValue?: Color;
|
|
12
|
+
channel: ColorChannel;
|
|
13
|
+
onChange?: (value: Color) => void;
|
|
14
|
+
onChangeEnd?: (value: Color) => void;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
class?: string;
|
|
17
|
+
"aria-label"?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ColorSlider: Component<ColorSliderProps> = (props) => {
|
|
21
|
+
const [local] = splitProps(props, [
|
|
22
|
+
"value",
|
|
23
|
+
"defaultValue",
|
|
24
|
+
"channel",
|
|
25
|
+
"onChange",
|
|
26
|
+
"onChangeEnd",
|
|
27
|
+
"disabled",
|
|
28
|
+
"class",
|
|
29
|
+
"aria-label",
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
// Kobalte paints the channel gradient on the (half-thumb padded) track, which
|
|
33
|
+
// leaves naked strips at the ends, so we rebuild it on the full-width root.
|
|
34
|
+
const gradient = () => {
|
|
35
|
+
const color = local.value ?? local.defaultValue;
|
|
36
|
+
if (!color) return undefined;
|
|
37
|
+
const channel = local.channel;
|
|
38
|
+
if (channel === "hue") {
|
|
39
|
+
const stops = [0, 60, 120, 180, 240, 300, 360]
|
|
40
|
+
.map((h) => color.withChannelValue("hue", h).toString("css"))
|
|
41
|
+
.join(", ");
|
|
42
|
+
return `linear-gradient(to right, ${stops})`;
|
|
43
|
+
}
|
|
44
|
+
const { minValue, maxValue } = color.getChannelRange(channel);
|
|
45
|
+
const start = color.withChannelValue(channel, minValue).toString("css");
|
|
46
|
+
const end = color.withChannelValue(channel, maxValue).toString("css");
|
|
47
|
+
if (channel === "lightness") {
|
|
48
|
+
const middle = color.withChannelValue(channel, (maxValue - minValue) / 2).toString("css");
|
|
49
|
+
return `linear-gradient(to right, ${start}, ${middle}, ${end})`;
|
|
50
|
+
}
|
|
51
|
+
return `linear-gradient(to right, ${start}, ${end})`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<KColorSlider
|
|
56
|
+
value={local.value}
|
|
57
|
+
defaultValue={local.defaultValue}
|
|
58
|
+
channel={local.channel}
|
|
59
|
+
onChange={local.onChange}
|
|
60
|
+
onChangeEnd={local.onChangeEnd}
|
|
61
|
+
disabled={local.disabled}
|
|
62
|
+
data-slot="color-slider"
|
|
63
|
+
class={cn(
|
|
64
|
+
"relative flex w-full touch-none select-none items-center rounded-xl",
|
|
65
|
+
THUMB_RAIL_PAD,
|
|
66
|
+
local.disabled && "cursor-not-allowed opacity-50",
|
|
67
|
+
local.class,
|
|
68
|
+
)}
|
|
69
|
+
style={{ background: gradient() }}
|
|
70
|
+
>
|
|
71
|
+
<KColorSlider.Track
|
|
72
|
+
data-slot="color-slider-track"
|
|
73
|
+
class={cn("relative h-7 w-full", local.disabled ? "cursor-not-allowed" : "cursor-pointer")}
|
|
74
|
+
// Kobalte paints the channel gradient as an inline background here, which
|
|
75
|
+
// no class can beat; clearing it inline is what keeps the root's
|
|
76
|
+
// full-width gradient the only one.
|
|
77
|
+
style={{ background: "none" }}
|
|
78
|
+
>
|
|
79
|
+
<KColorSlider.Thumb
|
|
80
|
+
data-slot="color-slider-thumb"
|
|
81
|
+
class={cn(
|
|
82
|
+
THUMB_CLASS,
|
|
83
|
+
FOCUS_RING,
|
|
84
|
+
THUMB_COLOR_RING,
|
|
85
|
+
"absolute top-0",
|
|
86
|
+
local.disabled && "cursor-not-allowed",
|
|
87
|
+
)}
|
|
88
|
+
aria-label={local["aria-label"] ?? local.channel}
|
|
89
|
+
style={{ background: "var(--kb-color-current)" }}
|
|
90
|
+
>
|
|
91
|
+
<KColorSlider.Input />
|
|
92
|
+
</KColorSlider.Thumb>
|
|
93
|
+
</KColorSlider.Track>
|
|
94
|
+
</KColorSlider>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { ColorSlider };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ColorWheel as KColorWheel } from "@kobalte/core/color-wheel";
|
|
2
|
+
import type { Color } from "@kobalte/core/colors";
|
|
3
|
+
import type { Component } from "solid-js";
|
|
4
|
+
import { splitProps } from "solid-js";
|
|
5
|
+
import { FOCUS_RING } from "../lib/input-classes.js";
|
|
6
|
+
import { THUMB_CLASS, THUMB_COLOR_RING, THUMB_SIZE } from "../lib/thumb-classes.js";
|
|
7
|
+
import { cn } from "../lib/utils.js";
|
|
8
|
+
|
|
9
|
+
interface ColorWheelProps {
|
|
10
|
+
value?: Color;
|
|
11
|
+
defaultValue?: Color;
|
|
12
|
+
onChange?: (value: Color) => void;
|
|
13
|
+
onChangeEnd?: (value: Color) => void;
|
|
14
|
+
/** Wheel diameter in px */
|
|
15
|
+
size?: number;
|
|
16
|
+
/** Ring thickness, 0-100 relative to the radius */
|
|
17
|
+
thickness?: number;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
class?: string;
|
|
20
|
+
"aria-label"?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ColorWheel: Component<ColorWheelProps> = (props) => {
|
|
24
|
+
const [local] = splitProps(props, [
|
|
25
|
+
"value",
|
|
26
|
+
"defaultValue",
|
|
27
|
+
"onChange",
|
|
28
|
+
"onChangeEnd",
|
|
29
|
+
"size",
|
|
30
|
+
"thickness",
|
|
31
|
+
"disabled",
|
|
32
|
+
"class",
|
|
33
|
+
"aria-label",
|
|
34
|
+
]);
|
|
35
|
+
const size = () => local.size ?? 200;
|
|
36
|
+
// Kobalte reads `thickness` as a percentage of the radius, so a px thumb
|
|
37
|
+
// only fits if the ring is sized from the same number the class resolves to.
|
|
38
|
+
// Clamped at the top of that range: past it Kobalte's mask radius goes
|
|
39
|
+
// negative and the ring renders as a filled disc.
|
|
40
|
+
const thickness = () =>
|
|
41
|
+
local.thickness ?? Math.min(100, Math.ceil((THUMB_SIZE / (size() / 2)) * 100));
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<KColorWheel
|
|
45
|
+
value={local.value}
|
|
46
|
+
defaultValue={local.defaultValue}
|
|
47
|
+
onChange={local.onChange}
|
|
48
|
+
onChangeEnd={local.onChangeEnd}
|
|
49
|
+
thickness={thickness()}
|
|
50
|
+
disabled={local.disabled}
|
|
51
|
+
data-slot="color-wheel"
|
|
52
|
+
class={cn(
|
|
53
|
+
"relative touch-none select-none",
|
|
54
|
+
local.disabled && "cursor-not-allowed opacity-50",
|
|
55
|
+
local.class,
|
|
56
|
+
)}
|
|
57
|
+
style={{ width: `${size()}px`, height: `${size()}px` }}
|
|
58
|
+
>
|
|
59
|
+
<KColorWheel.Track
|
|
60
|
+
data-slot="color-wheel-track"
|
|
61
|
+
class={cn("h-full w-full", local.disabled ? "cursor-not-allowed" : "cursor-pointer")}
|
|
62
|
+
>
|
|
63
|
+
{/* Always a circle: the thumb rides a circular track, theme corner radius looks broken there. */}
|
|
64
|
+
<KColorWheel.Thumb
|
|
65
|
+
data-slot="color-wheel-thumb"
|
|
66
|
+
class={cn(THUMB_CLASS, FOCUS_RING, THUMB_COLOR_RING, "rounded-full")}
|
|
67
|
+
aria-label={local["aria-label"] ?? "Hue"}
|
|
68
|
+
style={{ background: "var(--kb-color-current)" }}
|
|
69
|
+
>
|
|
70
|
+
<KColorWheel.Input />
|
|
71
|
+
</KColorWheel.Thumb>
|
|
72
|
+
</KColorWheel.Track>
|
|
73
|
+
</KColorWheel>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { ColorWheel };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ContextMenu as ContextMenuPrimitive } from "@kobalte/core/context-menu";
|
|
2
|
+
import { type Component, type ComponentProps, type ParentComponent, splitProps } from "solid-js";
|
|
3
|
+
import { OVERLAY_MOTION } from "../lib/motion-classes.js";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
import {
|
|
6
|
+
MENU_CONTENT_CLASS,
|
|
7
|
+
MenuCheckboxItemPart,
|
|
8
|
+
MenuContentIndicator,
|
|
9
|
+
MenuItemPart,
|
|
10
|
+
MenuLabelPart,
|
|
11
|
+
MenuRadioItemPart,
|
|
12
|
+
MenuSeparatorPart,
|
|
13
|
+
MenuSubContentPart,
|
|
14
|
+
MenuSubTriggerPart,
|
|
15
|
+
} from "./menu-parts.js";
|
|
16
|
+
|
|
17
|
+
const ContextMenu = ContextMenuPrimitive;
|
|
18
|
+
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
|
19
|
+
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
|
20
|
+
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
21
|
+
|
|
22
|
+
const ContextMenuTrigger: Component<ComponentProps<typeof ContextMenuPrimitive.Trigger>> = (
|
|
23
|
+
props,
|
|
24
|
+
) => {
|
|
25
|
+
return <ContextMenuPrimitive.Trigger data-slot="context-menu-trigger" {...props} />;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const ContextMenuSubTrigger: ParentComponent<
|
|
29
|
+
ComponentProps<typeof ContextMenuPrimitive.SubTrigger> & { inset?: boolean }
|
|
30
|
+
> = (props) => <MenuSubTriggerPart slotName="context-menu-sub-trigger" {...props} />;
|
|
31
|
+
|
|
32
|
+
const ContextMenuSubContent: Component<ComponentProps<typeof ContextMenuPrimitive.SubContent>> = (
|
|
33
|
+
props,
|
|
34
|
+
) => <MenuSubContentPart slotName="context-menu-sub-content" {...props} />;
|
|
35
|
+
|
|
36
|
+
const ContextMenuContent: Component<ComponentProps<typeof ContextMenuPrimitive.Content>> = (
|
|
37
|
+
props,
|
|
38
|
+
) => {
|
|
39
|
+
const [local, rest] = splitProps(props, ["class", "children"]);
|
|
40
|
+
return (
|
|
41
|
+
<ContextMenuPrimitive.Portal>
|
|
42
|
+
<ContextMenuPrimitive.Content
|
|
43
|
+
data-slot="context-menu-content"
|
|
44
|
+
class={cn(
|
|
45
|
+
MENU_CONTENT_CLASS,
|
|
46
|
+
OVERLAY_MOTION,
|
|
47
|
+
"overflow-y-auto overflow-x-hidden",
|
|
48
|
+
local.class,
|
|
49
|
+
)}
|
|
50
|
+
{...rest}
|
|
51
|
+
>
|
|
52
|
+
<MenuContentIndicator>{local.children}</MenuContentIndicator>
|
|
53
|
+
</ContextMenuPrimitive.Content>
|
|
54
|
+
</ContextMenuPrimitive.Portal>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const ContextMenuItem: Component<
|
|
59
|
+
ComponentProps<typeof ContextMenuPrimitive.Item> & {
|
|
60
|
+
inset?: boolean;
|
|
61
|
+
tone?: string;
|
|
62
|
+
/** @deprecated pass `tone="var(--destructive)"` instead */
|
|
63
|
+
variant?: "default" | "destructive";
|
|
64
|
+
}
|
|
65
|
+
> = (props) => <MenuItemPart slotName="context-menu-item" {...props} />;
|
|
66
|
+
|
|
67
|
+
const ContextMenuCheckboxItem: ParentComponent<
|
|
68
|
+
ComponentProps<typeof ContextMenuPrimitive.CheckboxItem>
|
|
69
|
+
> = (props) => <MenuCheckboxItemPart slotName="context-menu-checkbox-item" {...props} />;
|
|
70
|
+
|
|
71
|
+
const ContextMenuRadioItem: ParentComponent<
|
|
72
|
+
ComponentProps<typeof ContextMenuPrimitive.RadioItem>
|
|
73
|
+
> = (props) => <MenuRadioItemPart slotName="context-menu-radio-item" {...props} />;
|
|
74
|
+
|
|
75
|
+
const ContextMenuLabel: Component<
|
|
76
|
+
ComponentProps<typeof ContextMenuPrimitive.GroupLabel> & { inset?: boolean }
|
|
77
|
+
> = (props) => <MenuLabelPart slotName="context-menu-label" {...props} />;
|
|
78
|
+
|
|
79
|
+
const ContextMenuSeparator: Component<ComponentProps<typeof ContextMenuPrimitive.Separator>> = (
|
|
80
|
+
props,
|
|
81
|
+
) => <MenuSeparatorPart slotName="context-menu-separator" {...props} />;
|
|
82
|
+
|
|
83
|
+
const ContextMenuShortcut: Component<ComponentProps<"span">> = (props) => {
|
|
84
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
85
|
+
return (
|
|
86
|
+
<span
|
|
87
|
+
data-slot="context-menu-shortcut"
|
|
88
|
+
class={cn("ml-auto text-muted-foreground text-xs tracking-widest", local.class)}
|
|
89
|
+
{...rest}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
ContextMenu,
|
|
96
|
+
ContextMenuCheckboxItem,
|
|
97
|
+
ContextMenuContent,
|
|
98
|
+
ContextMenuGroup,
|
|
99
|
+
ContextMenuItem,
|
|
100
|
+
ContextMenuLabel,
|
|
101
|
+
ContextMenuRadioGroup,
|
|
102
|
+
ContextMenuRadioItem,
|
|
103
|
+
ContextMenuSeparator,
|
|
104
|
+
ContextMenuShortcut,
|
|
105
|
+
ContextMenuSub,
|
|
106
|
+
ContextMenuSubContent,
|
|
107
|
+
ContextMenuSubTrigger,
|
|
108
|
+
ContextMenuTrigger,
|
|
109
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Component, createSignal, Show } from "solid-js";
|
|
2
|
+
import { ICON_BUTTON_CLASS } from "../lib/button-variants.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { Icon } from "./icon.js";
|
|
5
|
+
import { toast } from "./sonner.js";
|
|
6
|
+
|
|
7
|
+
interface CopyButtonProps {
|
|
8
|
+
text: string;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const CopyButton: Component<CopyButtonProps> = (props) => {
|
|
13
|
+
const [copied, setCopied] = createSignal(false);
|
|
14
|
+
|
|
15
|
+
const handleCopy = async () => {
|
|
16
|
+
try {
|
|
17
|
+
await navigator.clipboard.writeText(props.text);
|
|
18
|
+
setCopied(true);
|
|
19
|
+
toast.success("Copied to clipboard");
|
|
20
|
+
setTimeout(() => setCopied(false), 2000);
|
|
21
|
+
} catch {
|
|
22
|
+
toast.error("Failed to copy");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
data-slot="copy-button"
|
|
30
|
+
onClick={handleCopy}
|
|
31
|
+
class={cn(ICON_BUTTON_CLASS, "size-8", props.class)}
|
|
32
|
+
aria-label={copied() ? "Copied!" : "Copy to clipboard"}
|
|
33
|
+
>
|
|
34
|
+
<Show
|
|
35
|
+
when={copied()}
|
|
36
|
+
fallback={
|
|
37
|
+
<Icon icon="lucide:copy" width={16} height={16} class="h-4 w-4 text-muted-foreground" />
|
|
38
|
+
}
|
|
39
|
+
>
|
|
40
|
+
<Icon icon="lucide:check" width={16} height={16} class="h-4 w-4 text-success" />
|
|
41
|
+
</Show>
|
|
42
|
+
</button>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { CopyButton };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { Badge } from "./badge.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Small neutral count chip (list size, item count) sitting next to a title:
|
|
7
|
+
* the Badge material with the muted tone, mono figures that do not jitter.
|
|
8
|
+
* Whole-pixel box, line-height equal to it and a 2px top pad: Geist Mono
|
|
9
|
+
* digits sit above the line centre, and fractional boxes drift a further
|
|
10
|
+
* pixel per DPR (measured 1/1.5/2/4).
|
|
11
|
+
*/
|
|
12
|
+
export function CountPill(props: { children: JSX.Element; class?: string }) {
|
|
13
|
+
return (
|
|
14
|
+
<Badge
|
|
15
|
+
tone="var(--muted-foreground)"
|
|
16
|
+
class={cn(
|
|
17
|
+
"h-[20px] min-w-[20px] justify-center pt-[2px] pr-[6px] pb-0 pl-[7px] font-mono text-[11px] tabular-nums leading-[20px]",
|
|
18
|
+
props.class,
|
|
19
|
+
)}
|
|
20
|
+
>
|
|
21
|
+
{props.children}
|
|
22
|
+
</Badge>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { For, type JSX, Show, splitProps } from "solid-js";
|
|
2
|
+
import { SECTION_PADDING } from "../lib/section-tokens.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { Button } from "./button.js";
|
|
5
|
+
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia } from "./empty.js";
|
|
6
|
+
import { Icon } from "./icon.js";
|
|
7
|
+
import { Input } from "./input.js";
|
|
8
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
|
|
9
|
+
import { Skeleton } from "./skeleton.js";
|
|
10
|
+
import { TABLE_HEAD_CELL_CLASS, TABLE_HEAD_LABEL_CLASS } from "./table.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generic data-table vocabulary: sticky-less header, row height/padding, border
|
|
14
|
+
* treatment, hover, numeric alignment, toolbar (search/filter/sort), bulk bar,
|
|
15
|
+
* and empty/loading/error states. Each list renders its own row markup but
|
|
16
|
+
* shares these primitives + class tokens. Presentational only — no app data.
|
|
17
|
+
*
|
|
18
|
+
* Tables live inside a card; go edge-to-edge with `TABLE_BLEED` (cancels the
|
|
19
|
+
* card's p-3) and re-add the inset via the cell padding tokens.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export { TABLE_HEAD_CELL_CLASS, TABLE_HEAD_LABEL_CLASS };
|
|
23
|
+
|
|
24
|
+
// Literal counterpart of SECTION_PADDING's spacing number, kept for
|
|
25
|
+
// Tailwind's static scanner (same split as lib/layers.ts's Z/Z_CLASS). Keying
|
|
26
|
+
// on the literal type of SECTION_PADDING makes a drift a compile error here
|
|
27
|
+
// instead of a runtime throw.
|
|
28
|
+
const BLEED_BY_SECTION_PADDING: Record<typeof SECTION_PADDING, string> = { "p-3": "-mx-3" };
|
|
29
|
+
export const TABLE_BLEED = `${BLEED_BY_SECTION_PADDING[SECTION_PADDING]} border-border/50 border-t`;
|
|
30
|
+
|
|
31
|
+
export const TABLE_CELL_X = "px-4";
|
|
32
|
+
export const TABLE_ROW_CLASS =
|
|
33
|
+
"flex items-center gap-4 border-border/50 border-b px-4 py-2.5 transition-colors last:border-b-0 hover:bg-foreground/[0.03]";
|
|
34
|
+
export const TABLE_HEAD_CLASS = "flex items-center gap-4 border-border/50 border-b px-4 py-2";
|
|
35
|
+
export const TABLE_SCROLL_CLASS = "max-h-[600px] overflow-auto gh-scroll";
|
|
36
|
+
export const TABLE_NUM_CELL_CLASS = "text-right text-muted-foreground text-xs tabular-nums";
|
|
37
|
+
|
|
38
|
+
export type SortDirection = "asc" | "desc";
|
|
39
|
+
|
|
40
|
+
/** Toolbar filter dropdown, built on the Select. Leading filter icon, h-9. Pass
|
|
41
|
+
* `label` to render an option key as display text (include counts there). */
|
|
42
|
+
export function TableFilterSelect(props: {
|
|
43
|
+
options: readonly string[];
|
|
44
|
+
value: string;
|
|
45
|
+
onChange: (value: string) => void;
|
|
46
|
+
label: (value: string) => string;
|
|
47
|
+
ariaLabel: string;
|
|
48
|
+
class?: string;
|
|
49
|
+
}) {
|
|
50
|
+
return (
|
|
51
|
+
<Select<string>
|
|
52
|
+
options={[...props.options]}
|
|
53
|
+
value={props.value}
|
|
54
|
+
onChange={(next) => {
|
|
55
|
+
if (next != null) props.onChange(next);
|
|
56
|
+
}}
|
|
57
|
+
itemComponent={(itemProps) => (
|
|
58
|
+
<SelectItem item={itemProps.item}>{props.label(itemProps.item.rawValue)}</SelectItem>
|
|
59
|
+
)}
|
|
60
|
+
>
|
|
61
|
+
<SelectTrigger
|
|
62
|
+
data-slot="table-filter-select"
|
|
63
|
+
class={cn("h-9 w-auto gap-1.5 text-xs", props.class)}
|
|
64
|
+
aria-label={props.ariaLabel}
|
|
65
|
+
>
|
|
66
|
+
<Icon
|
|
67
|
+
icon="lucide:funnel"
|
|
68
|
+
width={14}
|
|
69
|
+
height={14}
|
|
70
|
+
class="size-3.5 shrink-0 text-muted-foreground"
|
|
71
|
+
/>
|
|
72
|
+
<SelectValue<string>>{(state) => props.label(state.selectedOption())}</SelectValue>
|
|
73
|
+
</SelectTrigger>
|
|
74
|
+
<SelectContent />
|
|
75
|
+
</Select>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Toolbar search box: leading icon, h-9, trailing clear. Debounce in caller. */
|
|
80
|
+
export function TableSearchInput(props: {
|
|
81
|
+
value: string;
|
|
82
|
+
onInput: (value: string) => void;
|
|
83
|
+
placeholder: string;
|
|
84
|
+
label: string;
|
|
85
|
+
class?: string;
|
|
86
|
+
}) {
|
|
87
|
+
return (
|
|
88
|
+
<div data-slot="table-search-input" class={cn("relative w-full sm:w-64", props.class)}>
|
|
89
|
+
<Icon
|
|
90
|
+
icon="lucide:search"
|
|
91
|
+
width={14}
|
|
92
|
+
height={14}
|
|
93
|
+
class="pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground"
|
|
94
|
+
/>
|
|
95
|
+
<Input
|
|
96
|
+
placeholder={props.placeholder}
|
|
97
|
+
value={props.value}
|
|
98
|
+
onInput={(e) => props.onInput((e.currentTarget as HTMLInputElement).value)}
|
|
99
|
+
class="h-9 w-full pr-7 pl-7 text-xs"
|
|
100
|
+
aria-label={props.label}
|
|
101
|
+
/>
|
|
102
|
+
<Show when={props.value}>
|
|
103
|
+
<Button
|
|
104
|
+
type="button"
|
|
105
|
+
variant="ghost"
|
|
106
|
+
size="icon"
|
|
107
|
+
onClick={() => props.onInput("")}
|
|
108
|
+
class="absolute top-1/2 right-1 size-6 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground"
|
|
109
|
+
aria-label="Clear search"
|
|
110
|
+
>
|
|
111
|
+
<Icon icon="lucide:x" width={14} height={14} class="size-3.5" />
|
|
112
|
+
</Button>
|
|
113
|
+
</Show>
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Sortable column header button. `align="end"` for numeric columns. */
|
|
119
|
+
export function TableSortHeader(props: {
|
|
120
|
+
label: string;
|
|
121
|
+
active: boolean;
|
|
122
|
+
dir: SortDirection;
|
|
123
|
+
onClick: () => void;
|
|
124
|
+
align?: "start" | "end";
|
|
125
|
+
class?: string;
|
|
126
|
+
}) {
|
|
127
|
+
return (
|
|
128
|
+
<Button
|
|
129
|
+
type="button"
|
|
130
|
+
variant="ghost"
|
|
131
|
+
size="sm"
|
|
132
|
+
onClick={props.onClick}
|
|
133
|
+
data-slot="table-sort-header"
|
|
134
|
+
class={cn(
|
|
135
|
+
"h-auto gap-1 px-1.5 py-0.5 font-medium text-muted-foreground text-xs hover:text-foreground",
|
|
136
|
+
props.align === "end" && "justify-end",
|
|
137
|
+
props.class,
|
|
138
|
+
)}
|
|
139
|
+
aria-label={`Sort by ${props.label}`}
|
|
140
|
+
>
|
|
141
|
+
{props.label}
|
|
142
|
+
<Show
|
|
143
|
+
when={props.active}
|
|
144
|
+
fallback={
|
|
145
|
+
<Icon icon="lucide:chevrons-up-down" width={12} height={12} class="size-3 opacity-30" />
|
|
146
|
+
}
|
|
147
|
+
>
|
|
148
|
+
<Show
|
|
149
|
+
when={props.dir === "asc"}
|
|
150
|
+
fallback={<Icon icon="lucide:arrow-down" width={12} height={12} class="size-3" />}
|
|
151
|
+
>
|
|
152
|
+
<Icon icon="lucide:arrow-up" width={12} height={12} class="size-3" />
|
|
153
|
+
</Show>
|
|
154
|
+
</Show>
|
|
155
|
+
</Button>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Centered empty state inside the table body. `icon` takes JSX or an iconify name. */
|
|
160
|
+
export function TableEmpty(props: {
|
|
161
|
+
icon?: JSX.Element | string;
|
|
162
|
+
message: JSX.Element;
|
|
163
|
+
action?: JSX.Element;
|
|
164
|
+
}) {
|
|
165
|
+
return (
|
|
166
|
+
<Empty class="gap-3 rounded-none border-none py-12">
|
|
167
|
+
<EmptyHeader>
|
|
168
|
+
<Show when={props.icon}>
|
|
169
|
+
<EmptyMedia media="icon">
|
|
170
|
+
{typeof props.icon === "string" ? (
|
|
171
|
+
<Icon icon={props.icon} width={24} height={24} />
|
|
172
|
+
) : (
|
|
173
|
+
props.icon
|
|
174
|
+
)}
|
|
175
|
+
</EmptyMedia>
|
|
176
|
+
</Show>
|
|
177
|
+
<EmptyDescription>{props.message}</EmptyDescription>
|
|
178
|
+
</EmptyHeader>
|
|
179
|
+
<Show when={props.action}>
|
|
180
|
+
<EmptyContent>{props.action}</EmptyContent>
|
|
181
|
+
</Show>
|
|
182
|
+
</Empty>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Inline error state with a Retry button. */
|
|
187
|
+
export function TableError(props: { message: JSX.Element; onRetry: () => void }) {
|
|
188
|
+
return (
|
|
189
|
+
<div data-slot="table-error" class="px-4 py-10 text-center">
|
|
190
|
+
<p class="text-destructive text-sm">{props.message}</p>
|
|
191
|
+
<Button variant="outline" size="sm" class="mt-3" onClick={props.onRetry}>
|
|
192
|
+
Retry
|
|
193
|
+
</Button>
|
|
194
|
+
</div>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const SKELETON_TITLE_WIDTHS = ["w-2/5", "w-1/3", "w-1/2", "w-2/5", "w-5/12"] as const;
|
|
199
|
+
const SKELETON_META_WIDTHS = ["w-1/2", "w-2/5", "w-3/5", "w-1/2", "w-3/5"] as const;
|
|
200
|
+
|
|
201
|
+
/** Table-shaped loading skeleton: N rows at the shared row height. */
|
|
202
|
+
export function TableSkeleton(props: { count?: number; class?: string }) {
|
|
203
|
+
const n = props.count ?? 5;
|
|
204
|
+
return (
|
|
205
|
+
<div data-slot="table-skeleton" aria-busy="true">
|
|
206
|
+
<For each={Array.from({ length: n })}>
|
|
207
|
+
{(_, i) => (
|
|
208
|
+
<div data-slot="table-skeleton-row" class={cn(TABLE_ROW_CLASS, props.class)}>
|
|
209
|
+
<Skeleton class="h-4 w-4 shrink-0" />
|
|
210
|
+
<div class="flex min-w-0 flex-1 items-start gap-3 sm:items-center">
|
|
211
|
+
<Skeleton class="size-9 shrink-0 rounded-full sm:size-7" />
|
|
212
|
+
<div class="flex min-w-0 flex-1 flex-col gap-1.5">
|
|
213
|
+
<Skeleton
|
|
214
|
+
class={cn("h-3", SKELETON_TITLE_WIDTHS[i() % SKELETON_TITLE_WIDTHS.length])}
|
|
215
|
+
/>
|
|
216
|
+
<Skeleton
|
|
217
|
+
class={cn("h-2.5", SKELETON_META_WIDTHS[i() % SKELETON_META_WIDTHS.length])}
|
|
218
|
+
/>
|
|
219
|
+
<div class="flex gap-1 pt-0.5 sm:hidden">
|
|
220
|
+
<Skeleton class="h-4 w-12 rounded-full" />
|
|
221
|
+
<Skeleton class="h-4 w-16 rounded-full" />
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
<Skeleton class="h-3 w-12 shrink-0" />
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
)}
|
|
228
|
+
</For>
|
|
229
|
+
</div>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Bulk-action bar above the rows when a selection is active. */
|
|
234
|
+
export function TableBulkBar(props: { class?: string; children: JSX.Element }) {
|
|
235
|
+
const [local, rest] = splitProps(props, ["class", "children"]);
|
|
236
|
+
return (
|
|
237
|
+
<div
|
|
238
|
+
data-slot="table-bulk-bar"
|
|
239
|
+
class={cn(
|
|
240
|
+
"flex flex-wrap items-center gap-2 border-border/50 border-b bg-foreground/[0.03] px-4 py-2",
|
|
241
|
+
local.class,
|
|
242
|
+
)}
|
|
243
|
+
{...rest}
|
|
244
|
+
>
|
|
245
|
+
{local.children}
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
}
|