@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,98 @@
|
|
|
1
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
|
|
4
|
+
/* The one cell inset for the real <table> element family (TableHead/TableCell).
|
|
5
|
+
* data-table.tsx's flex-row family pads its own row, so its head labels take
|
|
6
|
+
* TABLE_HEAD_LABEL_CLASS, the typography the head cell adds the inset to. */
|
|
7
|
+
export const TABLE_CELL_INSET = "px-3 py-2";
|
|
8
|
+
export const TABLE_HEAD_LABEL_CLASS = "font-medium text-muted-foreground text-xs";
|
|
9
|
+
export const TABLE_HEAD_CELL_CLASS = `${TABLE_CELL_INSET} text-left ${TABLE_HEAD_LABEL_CLASS}`;
|
|
10
|
+
|
|
11
|
+
const Table: Component<ComponentProps<"table">> = (props) => {
|
|
12
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
13
|
+
return (
|
|
14
|
+
<div data-slot="table-container" class="relative w-full overflow-x-auto">
|
|
15
|
+
<table data-slot="table" class={cn("w-full caption-bottom text-sm", local.class)} {...rest} />
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const TableHeader: Component<ComponentProps<"thead">> = (props) => {
|
|
21
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
22
|
+
return <thead data-slot="table-header" class={cn("[&_tr]:border-b", local.class)} {...rest} />;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const TableBody: Component<ComponentProps<"tbody">> = (props) => {
|
|
26
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
27
|
+
return (
|
|
28
|
+
<tbody data-slot="table-body" class={cn("[&_tr:last-child]:border-0", local.class)} {...rest} />
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const TableFooter: Component<ComponentProps<"tfoot">> = (props) => {
|
|
33
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
34
|
+
return (
|
|
35
|
+
<tfoot
|
|
36
|
+
data-slot="table-footer"
|
|
37
|
+
class={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", local.class)}
|
|
38
|
+
{...rest}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const TableRow: Component<ComponentProps<"tr">> = (props) => {
|
|
44
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
45
|
+
return (
|
|
46
|
+
<tr
|
|
47
|
+
data-slot="table-row"
|
|
48
|
+
class={cn(
|
|
49
|
+
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
50
|
+
local.class,
|
|
51
|
+
)}
|
|
52
|
+
{...rest}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const TableHead: Component<ComponentProps<"th">> = (props) => {
|
|
58
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
59
|
+
return (
|
|
60
|
+
<th
|
|
61
|
+
data-slot="table-head"
|
|
62
|
+
class={cn(
|
|
63
|
+
TABLE_HEAD_CELL_CLASS,
|
|
64
|
+
"h-10 whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
65
|
+
local.class,
|
|
66
|
+
)}
|
|
67
|
+
{...rest}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const TableCell: Component<ComponentProps<"td">> = (props) => {
|
|
73
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
74
|
+
return (
|
|
75
|
+
<td
|
|
76
|
+
data-slot="table-cell"
|
|
77
|
+
class={cn(
|
|
78
|
+
TABLE_CELL_INSET,
|
|
79
|
+
"whitespace-nowrap align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
80
|
+
local.class,
|
|
81
|
+
)}
|
|
82
|
+
{...rest}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const TableCaption: Component<ComponentProps<"caption">> = (props) => {
|
|
88
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
89
|
+
return (
|
|
90
|
+
<caption
|
|
91
|
+
data-slot="table-caption"
|
|
92
|
+
class={cn("mt-4 text-muted-foreground text-sm", local.class)}
|
|
93
|
+
{...rest}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Tabs as TabsPrimitive } from "@kobalte/core/tabs";
|
|
2
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
3
|
+
import { TRACK_SURFACE } from "../lib/card-classes.js";
|
|
4
|
+
import { PRESS_DIP, SETTLE_MOTION } from "../lib/motion-classes.js";
|
|
5
|
+
import { SEGMENT_ITEM } from "../lib/segment-classes.js";
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
import { SlidingIndicator } from "./sliding-indicator.js";
|
|
8
|
+
|
|
9
|
+
/** `split`: the root is `display: contents`, so a host (a modal panel) lays the
|
|
10
|
+
* list and the content out in its own regions while the tab state still spans
|
|
11
|
+
* them. */
|
|
12
|
+
type TabsLayout = "stack" | "split";
|
|
13
|
+
|
|
14
|
+
const TABS_LAYOUT: Record<TabsLayout, string> = {
|
|
15
|
+
stack: "flex flex-col gap-2",
|
|
16
|
+
split: "contents",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type TabsProps = ComponentProps<typeof TabsPrimitive> & { layout?: TabsLayout };
|
|
20
|
+
|
|
21
|
+
const Tabs: Component<TabsProps> = (props) => {
|
|
22
|
+
const [local, others] = splitProps(props, ["class", "layout"]);
|
|
23
|
+
return (
|
|
24
|
+
<TabsPrimitive
|
|
25
|
+
data-slot="tabs"
|
|
26
|
+
data-layout={local.layout ?? "stack"}
|
|
27
|
+
class={cn(TABS_LAYOUT[local.layout ?? "stack"], local.class)}
|
|
28
|
+
{...others}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const TabsList: Component<ComponentProps<typeof TabsPrimitive.List>> = (props) => {
|
|
34
|
+
const [local, others] = splitProps(props, ["class", "children"]);
|
|
35
|
+
return (
|
|
36
|
+
<TabsPrimitive.List
|
|
37
|
+
data-slot="tabs-list"
|
|
38
|
+
class={cn(
|
|
39
|
+
`inline-flex h-9 w-full items-center rounded-lg ${TRACK_SURFACE} p-1 text-muted-foreground`,
|
|
40
|
+
local.class,
|
|
41
|
+
)}
|
|
42
|
+
{...others}
|
|
43
|
+
>
|
|
44
|
+
<SlidingIndicator
|
|
45
|
+
activeSelector="[data-selected]"
|
|
46
|
+
indicatorClass="rounded-md"
|
|
47
|
+
class="flex h-full w-full items-center gap-1"
|
|
48
|
+
>
|
|
49
|
+
{local.children}
|
|
50
|
+
</SlidingIndicator>
|
|
51
|
+
</TabsPrimitive.List>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const TabsTrigger: Component<ComponentProps<typeof TabsPrimitive.Trigger>> = (props) => {
|
|
56
|
+
const [local, others] = splitProps(props, ["class"]);
|
|
57
|
+
return (
|
|
58
|
+
<TabsPrimitive.Trigger
|
|
59
|
+
data-slot="tabs-trigger"
|
|
60
|
+
class={cn(
|
|
61
|
+
SEGMENT_ITEM,
|
|
62
|
+
PRESS_DIP,
|
|
63
|
+
"hover:text-primary/80 data-[selected]:text-primary",
|
|
64
|
+
local.class,
|
|
65
|
+
)}
|
|
66
|
+
{...others}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const TabsContent: Component<ComponentProps<typeof TabsPrimitive.Content>> = (props) => {
|
|
72
|
+
const [local, others] = splitProps(props, ["class"]);
|
|
73
|
+
return (
|
|
74
|
+
<TabsPrimitive.Content
|
|
75
|
+
data-slot="tabs-content"
|
|
76
|
+
class={cn(
|
|
77
|
+
SETTLE_MOTION,
|
|
78
|
+
"outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
79
|
+
local.class,
|
|
80
|
+
)}
|
|
81
|
+
{...others}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
2
|
+
import { FIELD_CONTROL } from "../lib/input-classes.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
|
|
5
|
+
const Textarea: Component<ComponentProps<"textarea">> = (props) => {
|
|
6
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
7
|
+
return (
|
|
8
|
+
<textarea
|
|
9
|
+
data-slot="textarea"
|
|
10
|
+
class={cn(FIELD_CONTROL, "field-sizing-content min-h-16 py-2", local.class)}
|
|
11
|
+
{...rest}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { Textarea };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "@kobalte/core/toggle-group";
|
|
2
|
+
import type { VariantProps } from "cva";
|
|
3
|
+
import {
|
|
4
|
+
type Component,
|
|
5
|
+
type ComponentProps,
|
|
6
|
+
createContext,
|
|
7
|
+
type ParentComponent,
|
|
8
|
+
Show,
|
|
9
|
+
splitProps,
|
|
10
|
+
useContext,
|
|
11
|
+
} from "solid-js";
|
|
12
|
+
import { TRACK_SURFACE } from "../lib/card-classes.js";
|
|
13
|
+
import { cn } from "../lib/utils.js";
|
|
14
|
+
import { SlidingIndicator } from "./sliding-indicator.js";
|
|
15
|
+
import { toggleVariants } from "./toggle.js";
|
|
16
|
+
|
|
17
|
+
// The group also tells its items whether a single sliding indicator is in play: in
|
|
18
|
+
// single-select mode the indicator paints the selected segment, so items go
|
|
19
|
+
// transparent when pressed (else they double-paint). Multi-select has no single
|
|
20
|
+
// active item, so items keep their own pressed background and no indicator renders.
|
|
21
|
+
type ToggleGroupContextValue = VariantProps<typeof toggleVariants> & { sliding: boolean };
|
|
22
|
+
|
|
23
|
+
const ToggleGroupContext = createContext<ToggleGroupContextValue>({
|
|
24
|
+
size: "default",
|
|
25
|
+
variant: "default",
|
|
26
|
+
sliding: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const ToggleGroup: ParentComponent<
|
|
30
|
+
ComponentProps<typeof ToggleGroupPrimitive> & VariantProps<typeof toggleVariants>
|
|
31
|
+
> = (props) => {
|
|
32
|
+
const [local, rest] = splitProps(props, ["class", "variant", "size", "children"] as const);
|
|
33
|
+
// Read `multiple` without splitting it out: Kobalte's root is a single/multiple
|
|
34
|
+
// discriminated union, so pulling `multiple` into a separate prop collapses the
|
|
35
|
+
// union and mistypes `value`. Leave it in `rest` and just peek at it here.
|
|
36
|
+
const sliding = () => !(props as { multiple?: boolean }).multiple;
|
|
37
|
+
return (
|
|
38
|
+
<ToggleGroupPrimitive
|
|
39
|
+
data-slot="toggle-group"
|
|
40
|
+
data-variant={local.variant}
|
|
41
|
+
data-size={local.size}
|
|
42
|
+
class={cn(
|
|
43
|
+
`group/toggle-group flex w-fit items-center rounded-lg ${TRACK_SURFACE} p-1 data-[variant=outline]:shadow-xs`,
|
|
44
|
+
local.class,
|
|
45
|
+
)}
|
|
46
|
+
{...rest}
|
|
47
|
+
>
|
|
48
|
+
<ToggleGroupContext.Provider
|
|
49
|
+
value={{ variant: local.variant, size: local.size, sliding: sliding() }}
|
|
50
|
+
>
|
|
51
|
+
<Show when={sliding()} fallback={local.children}>
|
|
52
|
+
{/* w-full, not w-fit: a shrink-to-fit root still sizes to content, and a
|
|
53
|
+
`class="w-full"` root can finally let its flex-1 items share the width. */}
|
|
54
|
+
<SlidingIndicator
|
|
55
|
+
activeSelector="[data-pressed]"
|
|
56
|
+
indicatorClass="rounded-md"
|
|
57
|
+
class="flex w-full items-center"
|
|
58
|
+
>
|
|
59
|
+
{local.children}
|
|
60
|
+
</SlidingIndicator>
|
|
61
|
+
</Show>
|
|
62
|
+
</ToggleGroupContext.Provider>
|
|
63
|
+
</ToggleGroupPrimitive>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const ToggleGroupItem: Component<
|
|
68
|
+
ComponentProps<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>
|
|
69
|
+
> = (props) => {
|
|
70
|
+
const [local, rest] = splitProps(props, ["class", "variant", "size"] as const);
|
|
71
|
+
const context = useContext(ToggleGroupContext);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<ToggleGroupPrimitive.Item
|
|
75
|
+
data-slot="toggle-group-item"
|
|
76
|
+
data-variant={context.variant || local.variant}
|
|
77
|
+
data-size={context.size || local.size}
|
|
78
|
+
class={cn(
|
|
79
|
+
toggleVariants({
|
|
80
|
+
variant: context.variant || local.variant,
|
|
81
|
+
size: context.size || local.size,
|
|
82
|
+
}),
|
|
83
|
+
// `*-of-type` (not `first:`/`last:`): the sliding indicator is a <div> sibling,
|
|
84
|
+
// so `:first-child`/`:last-child` would land on the indicator and drop the end
|
|
85
|
+
// segments' rounded corners. Items are <button>, so `-of-type` skips the indicator.
|
|
86
|
+
"min-w-0 flex-1 shrink-0 rounded-none px-4 shadow-none first-of-type:rounded-l-md last-of-type:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first-of-type:border-l",
|
|
87
|
+
// Single-select: the sliding indicator paints the active segment, so the
|
|
88
|
+
// item needs no pressed fill of its own and hover only tints the text.
|
|
89
|
+
// Multi-select has no single indicator, so each pressed segment carries
|
|
90
|
+
// its own neutral fill; hover still tints text only, since a fill there
|
|
91
|
+
// would read as a second, squarer selection.
|
|
92
|
+
context.sliding
|
|
93
|
+
? "hover:text-primary"
|
|
94
|
+
: "not-data-[pressed]:hover:text-primary data-[pressed]:bg-muted data-[pressed]:text-foreground",
|
|
95
|
+
local.class,
|
|
96
|
+
)}
|
|
97
|
+
{...rest}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ToggleButton as ToggleButtonPrimitive } from "@kobalte/core/toggle-button";
|
|
2
|
+
import { cva, type VariantProps } from "cva";
|
|
3
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
4
|
+
import { OUTLINE_SURFACE } from "../lib/button-variants.js";
|
|
5
|
+
import { CONTROL_H } from "../lib/input-classes.js";
|
|
6
|
+
import { SEGMENT_ITEM } from "../lib/segment-classes.js";
|
|
7
|
+
import { cn } from "../lib/utils.js";
|
|
8
|
+
|
|
9
|
+
const toggleVariants = cva({
|
|
10
|
+
base: `${SEGMENT_ITEM} border border-transparent aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "bg-transparent",
|
|
14
|
+
outline: OUTLINE_SURFACE,
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
default: `${CONTROL_H.default} min-w-9 px-2`,
|
|
18
|
+
sm: `${CONTROL_H.sm} min-w-8 px-1.5`,
|
|
19
|
+
lg: `${CONTROL_H.lg} min-w-10 px-2.5`,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
size: "default",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/* The hover fill lives here, not in the shared variants: a ToggleGroupItem
|
|
29
|
+
* takes its pressed paint from the group's sliding indicator, and
|
|
30
|
+
* `:not([data-pressed]):hover` (0,3,0) outranks any plain `:hover` the group
|
|
31
|
+
* adds to cancel it. Unpressed only, because a background utility is a no-op
|
|
32
|
+
* once `data-[pressed]:glass` engages, so the pressed hover bumps a knob. */
|
|
33
|
+
const TOGGLE_HOVER: Record<"default" | "outline", string> = {
|
|
34
|
+
default:
|
|
35
|
+
"not-data-[pressed]:hover:bg-muted not-data-[pressed]:hover:text-muted-foreground data-[pressed]:hover:[--glass-wash:40%]",
|
|
36
|
+
outline: "",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const Toggle: Component<
|
|
40
|
+
ComponentProps<typeof ToggleButtonPrimitive> & VariantProps<typeof toggleVariants>
|
|
41
|
+
> = (props) => {
|
|
42
|
+
const [local, rest] = splitProps(props, ["class", "variant", "size"] as const);
|
|
43
|
+
return (
|
|
44
|
+
<ToggleButtonPrimitive
|
|
45
|
+
data-slot="toggle"
|
|
46
|
+
class={cn(
|
|
47
|
+
toggleVariants({ variant: local.variant, size: local.size }),
|
|
48
|
+
TOGGLE_HOVER[local.variant ?? "default"],
|
|
49
|
+
"data-[pressed]:glass data-[pressed]:[--glass-tone:var(--primary)]",
|
|
50
|
+
local.class,
|
|
51
|
+
)}
|
|
52
|
+
{...rest}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Tooltip as TooltipPrimitive } from "@kobalte/core/tooltip";
|
|
2
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
3
|
+
import { OVERLAY_MOTION } from "../lib/motion-classes.js";
|
|
4
|
+
import { FLOATING_PANEL } from "../lib/overlay-classes.js";
|
|
5
|
+
import { cn } from "../lib/utils.js";
|
|
6
|
+
|
|
7
|
+
/* Kobalte takes the popper options on the root, not on the content, so the
|
|
8
|
+
* gutter that keeps the panel off its trigger has to default here. */
|
|
9
|
+
const TooltipRoot: Component<ComponentProps<typeof TooltipPrimitive>> = (props) => (
|
|
10
|
+
<TooltipPrimitive gutter={6} {...props} />
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
/* Object.assign, not a bare wrapper: Kobalte ships Tooltip as a callable
|
|
14
|
+
* namespace and Tooltip.Trigger/.Content/.Portal/.Arrow are part of the
|
|
15
|
+
* published surface. */
|
|
16
|
+
const Tooltip = Object.assign(TooltipRoot, TooltipPrimitive);
|
|
17
|
+
|
|
18
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
19
|
+
|
|
20
|
+
const TooltipContent: Component<ComponentProps<typeof TooltipPrimitive.Content>> = (props) => {
|
|
21
|
+
const [local, others] = splitProps(props, ["class"]);
|
|
22
|
+
return (
|
|
23
|
+
<TooltipPrimitive.Portal>
|
|
24
|
+
<TooltipPrimitive.Content
|
|
25
|
+
data-slot="tooltip-content"
|
|
26
|
+
class={cn(
|
|
27
|
+
FLOATING_PANEL,
|
|
28
|
+
OVERLAY_MOTION,
|
|
29
|
+
"overflow-hidden px-3 py-1.5 text-xs",
|
|
30
|
+
local.class,
|
|
31
|
+
)}
|
|
32
|
+
{...others}
|
|
33
|
+
/>
|
|
34
|
+
</TooltipPrimitive.Portal>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { Tooltip, TooltipContent, TooltipTrigger };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type JSX, mergeProps, Show } from "solid-js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { Card } from "./card.js";
|
|
4
|
+
import { Icon } from "./icon.js";
|
|
5
|
+
import { WidgetIdentity, WidgetMeta, type WidgetSummary, widgetHref } from "./widget-identity.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The registry widget card: `row` for dense lists, `tile` for grids/galleries.
|
|
9
|
+
* Both are a <Card> + the WidgetIdentity/WidgetMeta nucleus. Shared by every
|
|
10
|
+
* widget surface (registry gallery, dashboard browse, admin tables) across
|
|
11
|
+
* apps; the data model is `WidgetSummary`.
|
|
12
|
+
*/
|
|
13
|
+
type WidgetCardProps = {
|
|
14
|
+
widget: WidgetSummary;
|
|
15
|
+
/** `row` for dense lists, `tile` for grids/galleries. Default `row`. */
|
|
16
|
+
layout?: "row" | "tile";
|
|
17
|
+
/** When set, the whole card becomes a link. */
|
|
18
|
+
href?: string;
|
|
19
|
+
/** Click handler (used when no href). */
|
|
20
|
+
onClick?: (e: MouseEvent) => void;
|
|
21
|
+
/** Show the (personal/org) scope pill. Default false. */
|
|
22
|
+
showScopeIndicator?: boolean;
|
|
23
|
+
/** Show the version-count meta. Default false. */
|
|
24
|
+
showVersions?: boolean;
|
|
25
|
+
/** Show the description (tile only). Default true for tiles. */
|
|
26
|
+
showDescription?: boolean;
|
|
27
|
+
/** Custom trailing element for the row layout. Defaults to a chevron when
|
|
28
|
+
* the card is interactive (href/onClick), otherwise nothing. */
|
|
29
|
+
trailing?: JSX.Element;
|
|
30
|
+
class?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function WidgetCard(_props: WidgetCardProps) {
|
|
34
|
+
const props = mergeProps({ layout: "row" as const }, _props);
|
|
35
|
+
// Default: link to the widget's public page. A call-site that wants different
|
|
36
|
+
// behavior (e.g. open a dialog) passes `onClick` and opts out of the link.
|
|
37
|
+
const href = () => props.href ?? (props.onClick ? undefined : widgetHref(props.widget));
|
|
38
|
+
const interactive = () => href() != null || props.onClick != null;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Show
|
|
42
|
+
when={props.layout === "tile"}
|
|
43
|
+
fallback={<WidgetCardRow {...props} href={href()} interactive={interactive()} />}
|
|
44
|
+
>
|
|
45
|
+
<WidgetCardTile {...props} href={href()} interactive={interactive()} />
|
|
46
|
+
</Show>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
type InternalProps = WidgetCardProps & { interactive: boolean };
|
|
51
|
+
|
|
52
|
+
function WidgetCardRow(props: InternalProps) {
|
|
53
|
+
const hasMeta = () =>
|
|
54
|
+
props.widget.downloadCount != null || (props.showVersions && props.widget.versionCount != null);
|
|
55
|
+
const showTrailing = () => props.trailing !== undefined || props.interactive;
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Card
|
|
59
|
+
as={props.href ? "a" : "div"}
|
|
60
|
+
href={props.href}
|
|
61
|
+
onClick={props.onClick}
|
|
62
|
+
interactive={props.interactive}
|
|
63
|
+
padding="sm"
|
|
64
|
+
class={cn("group flex-row items-center gap-3", props.class)}
|
|
65
|
+
>
|
|
66
|
+
<WidgetIdentity
|
|
67
|
+
widget={props.widget}
|
|
68
|
+
iconSize="sm"
|
|
69
|
+
showScopeIndicator={props.showScopeIndicator}
|
|
70
|
+
class="flex-1"
|
|
71
|
+
/>
|
|
72
|
+
<Show when={hasMeta()}>
|
|
73
|
+
<WidgetMeta widget={props.widget} showVersions={props.showVersions} class="shrink-0" />
|
|
74
|
+
</Show>
|
|
75
|
+
<Show when={showTrailing()} fallback={null}>
|
|
76
|
+
<Show
|
|
77
|
+
when={props.trailing !== undefined}
|
|
78
|
+
fallback={
|
|
79
|
+
<Icon
|
|
80
|
+
icon="lucide:chevron-right"
|
|
81
|
+
width={16}
|
|
82
|
+
height={16}
|
|
83
|
+
class="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 group-hover:translate-x-0.5 group-hover:text-foreground"
|
|
84
|
+
/>
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
{props.trailing}
|
|
88
|
+
</Show>
|
|
89
|
+
</Show>
|
|
90
|
+
</Card>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function WidgetCardTile(props: InternalProps) {
|
|
95
|
+
const showDescription = () => props.showDescription !== false;
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Card
|
|
99
|
+
as={props.href ? "a" : "div"}
|
|
100
|
+
href={props.href}
|
|
101
|
+
onClick={props.onClick}
|
|
102
|
+
interactive={props.interactive}
|
|
103
|
+
padding="md"
|
|
104
|
+
class={cn("group h-full", props.class)}
|
|
105
|
+
>
|
|
106
|
+
<div data-slot="widget-card-body" class="flex flex-1 flex-col gap-3">
|
|
107
|
+
<WidgetIdentity widget={props.widget} iconSize="md" showVersionInline={false} />
|
|
108
|
+
<Show when={showDescription() && props.widget.description}>
|
|
109
|
+
<p class="line-clamp-2 text-muted-foreground text-xs leading-relaxed">
|
|
110
|
+
{props.widget.description}
|
|
111
|
+
</p>
|
|
112
|
+
</Show>
|
|
113
|
+
</div>
|
|
114
|
+
<WidgetMeta widget={props.widget} showLatestVersion />
|
|
115
|
+
</Card>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { type JSX, mergeProps, Show } from "solid-js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { Badge } from "./badge.js";
|
|
4
|
+
import { Icon } from "./icon.js";
|
|
5
|
+
import { ScopeIndicator } from "./scope-indicator.js";
|
|
6
|
+
import { SectionIcon, SectionSubtitle } from "./section-card.js";
|
|
7
|
+
import { WidgetTrustBadge } from "./widget-trust-badge.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The reusable nucleus for rendering one widget/package: icon pill + name (with
|
|
11
|
+
* official/unlisted markers + inline version) + the @scope/name line, plus the
|
|
12
|
+
* download/version meta cluster. Shared by every widget surface (registry
|
|
13
|
+
* gallery, dashboard browse, admin tables). App-specific cards (hub's row/tile
|
|
14
|
+
* registry card, dash's interactive picker) compose this; the data model is
|
|
15
|
+
* `WidgetSummary`.
|
|
16
|
+
*/
|
|
17
|
+
export interface WidgetSummary {
|
|
18
|
+
scope: string;
|
|
19
|
+
name: string;
|
|
20
|
+
displayName?: string | null;
|
|
21
|
+
icon?: string | null;
|
|
22
|
+
description?: string | null;
|
|
23
|
+
isOfficial?: boolean;
|
|
24
|
+
isUnlisted?: boolean;
|
|
25
|
+
/** Newest version never finished publishing (bundle upload never confirmed,
|
|
26
|
+
* or no version row at all), so nothing is installable. Distinct from
|
|
27
|
+
* `isUnlisted`, which is a published widget hidden from search.
|
|
28
|
+
* Owner-facing surfaces set it; public ones leave it off. */
|
|
29
|
+
isUnpublished?: boolean;
|
|
30
|
+
downloadCount?: number;
|
|
31
|
+
latestVersion?: string | null;
|
|
32
|
+
versionCount?: number;
|
|
33
|
+
ownerType?: "personal" | "organization";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Canonical public detail URL for a widget (`/widgets/@scope/name`). */
|
|
37
|
+
export function widgetHref(w: { scope: string; name: string }): string {
|
|
38
|
+
return `/widgets/@${w.scope}/${w.name}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Compact download/count formatting, shared by every surface. */
|
|
42
|
+
export function formatWidgetCount(n: number | null | undefined): string {
|
|
43
|
+
const v = n ?? 0;
|
|
44
|
+
if (v >= 1_000_000) return `${(v / 1_000_000).toFixed(1)}M`;
|
|
45
|
+
if (v >= 1000) return `${(v / 1000).toFixed(1)}k`;
|
|
46
|
+
return v.toString();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type WidgetIdentityProps = {
|
|
50
|
+
widget: WidgetSummary;
|
|
51
|
+
/** Icon pill size. Rows use sm, tiles use md. */
|
|
52
|
+
iconSize?: "sm" | "md";
|
|
53
|
+
/** Append `v{latestVersion}` next to the name. Default true. */
|
|
54
|
+
showVersionInline?: boolean;
|
|
55
|
+
/** Show the (personal/org) scope pill after the @scope/name line. */
|
|
56
|
+
showScopeIndicator?: boolean;
|
|
57
|
+
class?: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function WidgetIdentity(_props: WidgetIdentityProps) {
|
|
61
|
+
const props = mergeProps({ iconSize: "sm" as const, showVersionInline: true }, _props);
|
|
62
|
+
return (
|
|
63
|
+
<div data-slot="widget-identity" class={cn("flex min-w-0 items-center gap-3", props.class)}>
|
|
64
|
+
<SectionIcon size={props.iconSize}>
|
|
65
|
+
<Show when={props.widget.icon} fallback={<Icon icon="lucide:package" />}>
|
|
66
|
+
{(icon) => <Icon icon={icon()} />}
|
|
67
|
+
</Show>
|
|
68
|
+
</SectionIcon>
|
|
69
|
+
<div data-slot="widget-identity-headings" class="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
70
|
+
<div data-slot="widget-identity-headline" class="flex items-center gap-2">
|
|
71
|
+
<SectionSubtitle class="truncate">
|
|
72
|
+
{props.widget.displayName || props.widget.name}
|
|
73
|
+
</SectionSubtitle>
|
|
74
|
+
<Show when={props.showVersionInline && props.widget.latestVersion}>
|
|
75
|
+
<span class="shrink-0 font-mono text-muted-foreground text-xs tabular-nums">
|
|
76
|
+
v{props.widget.latestVersion}
|
|
77
|
+
</span>
|
|
78
|
+
</Show>
|
|
79
|
+
<WidgetTrustBadge isOfficial={!!props.widget.isOfficial} />
|
|
80
|
+
|
|
81
|
+
<Show when={props.widget.isUnlisted}>
|
|
82
|
+
<Badge tone="var(--warning)">Unlisted</Badge>
|
|
83
|
+
</Show>
|
|
84
|
+
<Show when={props.widget.isUnpublished}>
|
|
85
|
+
<Badge tone="var(--destructive)">Not published</Badge>
|
|
86
|
+
</Show>
|
|
87
|
+
</div>
|
|
88
|
+
<div data-slot="widget-identity-scope" class="flex min-w-0 flex-wrap items-center gap-1.5">
|
|
89
|
+
<span class="truncate font-mono text-muted-foreground text-xs">
|
|
90
|
+
@{props.widget.scope}/{props.widget.name}
|
|
91
|
+
</span>
|
|
92
|
+
<Show when={props.showScopeIndicator}>
|
|
93
|
+
<ScopeIndicator
|
|
94
|
+
scope={props.widget.scope}
|
|
95
|
+
type={props.widget.ownerType ?? "personal"}
|
|
96
|
+
/>
|
|
97
|
+
</Show>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Downloads (+ optional version counts) meta cluster. */
|
|
105
|
+
export function WidgetMeta(props: {
|
|
106
|
+
widget: WidgetSummary;
|
|
107
|
+
/** Append `N versions`. */
|
|
108
|
+
showVersions?: boolean;
|
|
109
|
+
/** Append `v{latestVersion}` (the tile footer's shape). */
|
|
110
|
+
showLatestVersion?: boolean;
|
|
111
|
+
class?: string;
|
|
112
|
+
}): JSX.Element {
|
|
113
|
+
return (
|
|
114
|
+
<div
|
|
115
|
+
data-slot="widget-meta"
|
|
116
|
+
class={cn("flex items-center gap-4 text-muted-foreground text-xs", props.class)}
|
|
117
|
+
>
|
|
118
|
+
<Show when={props.widget.downloadCount != null}>
|
|
119
|
+
<span class="flex items-center gap-1 tabular-nums">
|
|
120
|
+
<Icon icon="lucide:arrow-down-to-line" width={12} height={12} class="size-3" />
|
|
121
|
+
{formatWidgetCount(props.widget.downloadCount)}
|
|
122
|
+
</span>
|
|
123
|
+
</Show>
|
|
124
|
+
<Show when={props.showVersions && props.widget.versionCount != null}>
|
|
125
|
+
<span class="flex items-center gap-1 tabular-nums">
|
|
126
|
+
<Icon icon="lucide:layers" width={12} height={12} class="size-3" />
|
|
127
|
+
{props.widget.versionCount} versions
|
|
128
|
+
</span>
|
|
129
|
+
</Show>
|
|
130
|
+
<Show when={props.showLatestVersion && props.widget.latestVersion}>
|
|
131
|
+
<span class="tabular-nums">v{props.widget.latestVersion}</span>
|
|
132
|
+
</Show>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|