@glasshome/ui 1.21.0 → 1.21.2
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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/use-is-mobile.d.ts +3 -1
- package/dist/solid/alert-dialog.d.ts +7 -1
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +7 -1
- package/dist/solid/dialog-parts.d.ts +3 -2
- package/dist/solid/dialog.d.ts +7 -1
- package/dist/solid/docked-panel.d.ts +7 -1
- package/dist/solid/index.d.ts +9 -9
- package/dist/solid/index.js +5456 -5447
- package/dist/solid/media-store.d.ts +4 -1
- package/dist/solid/option-card.d.ts +4 -1
- package/dist/solid/responsive-dialog.d.ts +7 -1
- package/dist/solid/sheet.d.ts +7 -1
- package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
- package/package.json +128 -126
- package/scripts/check-gallery.ts +142 -142
- package/scripts/check-pack.ts +13 -13
- package/scripts/check-structural-classes.ts +20 -20
- package/scripts/check-tokens.ts +27 -27
- package/scripts/check-ui-drift.mjs +103 -103
- package/src/index.ts +75 -80
- package/src/lib/alert-tones.ts +41 -41
- package/src/lib/anchor-placement.ts +21 -21
- package/src/lib/button-variants.ts +28 -28
- package/src/lib/card-classes.ts +9 -9
- package/src/lib/carousel-classes.ts +14 -14
- package/src/lib/glass-tone.ts +11 -11
- package/src/lib/input-classes.ts +6 -6
- package/src/lib/layers.ts +4 -4
- package/src/lib/logo-lockup.ts +8 -8
- package/src/lib/menu-classes.ts +2 -2
- package/src/lib/motion-classes.ts +8 -8
- package/src/lib/motion-window.ts +24 -24
- package/src/lib/overlay-classes.ts +6 -6
- package/src/lib/pill-classes.ts +3 -3
- package/src/lib/position-bar-classes.ts +1 -1
- package/src/lib/spotlight-geometry.ts +67 -67
- package/src/lib/thumb-classes.ts +2 -2
- package/src/lib/tier-badge.ts +16 -16
- package/src/lib/use-is-mobile.ts +17 -14
- package/src/lib/utils.ts +1 -1
- package/src/solid/accordion.tsx +41 -41
- package/src/solid/alert-dialog.tsx +95 -95
- package/src/solid/alert.tsx +88 -88
- package/src/solid/area-picker.tsx +204 -204
- package/src/solid/aspect-ratio.tsx +13 -13
- package/src/solid/avatar.tsx +27 -27
- package/src/solid/badge.tsx +49 -49
- package/src/solid/bottom-sheet/arbitration.ts +22 -22
- package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
- package/src/solid/bottom-sheet/drag-controller.ts +201 -201
- package/src/solid/bottom-sheet/focus-trap.ts +51 -47
- package/src/solid/bottom-sheet/index.ts +12 -12
- package/src/solid/bottom-sheet/keyboard.ts +25 -25
- package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
- package/src/solid/bottom-sheet/state-machine.ts +28 -28
- package/src/solid/bottom-sheet/velocity.ts +29 -29
- package/src/solid/breadcrumb.tsx +76 -76
- package/src/solid/button-group.tsx +46 -46
- package/src/solid/button.tsx +19 -19
- package/src/solid/card.tsx +67 -67
- package/src/solid/carousel.tsx +246 -246
- package/src/solid/charts.tsx +253 -253
- package/src/solid/checkbox.tsx +51 -51
- package/src/solid/collapsible.tsx +22 -22
- package/src/solid/color-disc.tsx +213 -213
- package/src/solid/color-slider.tsx +81 -81
- package/src/solid/color-wheel.tsx +61 -61
- package/src/solid/context-menu.tsx +63 -63
- package/src/solid/copy-button.tsx +31 -31
- package/src/solid/count-pill.tsx +11 -11
- package/src/solid/dashboard-preview.tsx +104 -104
- package/src/solid/data-table.tsx +228 -228
- package/src/solid/dialog-parts.tsx +129 -129
- package/src/solid/dialog.tsx +113 -113
- package/src/solid/dock-paging.ts +9 -9
- package/src/solid/dock.tsx +339 -338
- package/src/solid/docked-panel.tsx +35 -35
- package/src/solid/dropdown-menu.tsx +77 -77
- package/src/solid/empty.tsx +70 -70
- package/src/solid/entity-data.ts +38 -38
- package/src/solid/entity-selector.tsx +634 -634
- package/src/solid/field.tsx +205 -205
- package/src/solid/form.tsx +159 -159
- package/src/solid/hero-action.tsx +85 -85
- package/src/solid/hover-card.tsx +11 -11
- package/src/solid/icon-picker.tsx +401 -401
- package/src/solid/icon.tsx +101 -78
- package/src/solid/image-picker.tsx +416 -414
- package/src/solid/index.ts +265 -304
- package/src/solid/input-group.tsx +123 -123
- package/src/solid/input-otp.tsx +143 -143
- package/src/solid/input.tsx +4 -4
- package/src/solid/item.tsx +130 -130
- package/src/solid/kbd.tsx +20 -20
- package/src/solid/label.tsx +12 -12
- package/src/solid/list-reorder.ts +122 -122
- package/src/solid/logo.tsx +60 -60
- package/src/solid/media-copy.ts +21 -21
- package/src/solid/media-store.ts +60 -57
- package/src/solid/media-tile.tsx +85 -85
- package/src/solid/menu-parts.tsx +164 -164
- package/src/solid/number-field.tsx +56 -56
- package/src/solid/option-card.tsx +168 -165
- package/src/solid/ornament.tsx +43 -43
- package/src/solid/overlay.tsx +4 -4
- package/src/solid/page-header.tsx +75 -75
- package/src/solid/pagination.tsx +80 -80
- package/src/solid/password-input.tsx +51 -51
- package/src/solid/picker-row.tsx +83 -83
- package/src/solid/picker-search.tsx +65 -63
- package/src/solid/picker-trigger.tsx +59 -57
- package/src/solid/popover.tsx +54 -54
- package/src/solid/preview-tile.tsx +67 -67
- package/src/solid/progress.tsx +21 -21
- package/src/solid/radio-group.tsx +51 -51
- package/src/solid/resizable.tsx +128 -128
- package/src/solid/responsive-dialog.tsx +134 -134
- package/src/solid/schema-form.tsx +746 -739
- package/src/solid/scope-indicator.tsx +5 -5
- package/src/solid/scroll-area.tsx +16 -16
- package/src/solid/section-card.tsx +281 -281
- package/src/solid/select.tsx +101 -101
- package/src/solid/separator.tsx +25 -25
- package/src/solid/settings-row.tsx +122 -122
- package/src/solid/sheet.tsx +96 -96
- package/src/solid/skeleton.tsx +8 -8
- package/src/solid/slider.tsx +132 -132
- package/src/solid/sliding-indicator.tsx +280 -265
- package/src/solid/sonner.tsx +164 -164
- package/src/solid/spinner.tsx +12 -12
- package/src/solid/spotlight.tsx +140 -140
- package/src/solid/step-indicator.tsx +18 -18
- package/src/solid/swatch-picker.tsx +38 -38
- package/src/solid/switch.tsx +52 -52
- package/src/solid/table.tsx +63 -63
- package/src/solid/tabs.tsx +93 -93
- package/src/solid/textarea.tsx +8 -8
- package/src/solid/toggle-group.tsx +83 -83
- package/src/solid/toggle.tsx +33 -33
- package/src/solid/tooltip.tsx +16 -16
- package/src/solid/widget-card.tsx +90 -90
- package/src/solid/widget-identity.tsx +99 -99
- package/src/solid/widget-trust-badge.tsx +20 -20
- package/src/styles/globals.css +316 -319
- package/src/styles/theme.css +448 -448
- package/src/tokens/hex.ts +29 -29
- package/src/tokens/material.ts +75 -75
- package/src/tokens/presets.ts +303 -303
- package/src/tokens/readability.ts +32 -32
- package/src/tokens/theme-colors.ts +95 -95
- package/src/tokens/theme-css.ts +22 -22
- package/src/tokens/theme-recipe.ts +106 -106
package/src/solid/sheet.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Dialog as DialogPrimitive, useDialogContext } from "@kobalte/core/dialog";
|
|
2
2
|
import type { VariantProps } from "cva";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
type Component,
|
|
5
|
+
type ComponentProps,
|
|
6
|
+
type JSX,
|
|
7
|
+
type ParentComponent,
|
|
8
|
+
Show,
|
|
9
|
+
splitProps,
|
|
10
10
|
} from "solid-js";
|
|
11
11
|
import { buttonVariants } from "../lib/button-variants.js";
|
|
12
12
|
import { Z_CLASS } from "../lib/layers.js";
|
|
@@ -14,58 +14,58 @@ import { SCRIM_MOTION } from "../lib/motion-classes.js";
|
|
|
14
14
|
import { OVERLAY_SURFACE, SCRIM_CLASS } from "../lib/overlay-classes.js";
|
|
15
15
|
import { cn } from "../lib/utils.js";
|
|
16
16
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
createModalDismiss,
|
|
18
|
+
createModalParts,
|
|
19
|
+
MODAL_DESCRIPTION,
|
|
20
|
+
MODAL_MAX_H,
|
|
21
|
+
MODAL_TITLE,
|
|
22
|
+
type ModalDismissProps,
|
|
23
|
+
ModalScrollLock,
|
|
24
24
|
} from "./dialog-parts.js";
|
|
25
25
|
|
|
26
26
|
/* Kobalte's own scroll lock is off here too: ModalScrollLock is the one
|
|
27
27
|
* refcounted page lock every modal family shares. */
|
|
28
28
|
const Sheet: ParentComponent<ComponentProps<typeof DialogPrimitive>> = (props) => (
|
|
29
|
-
|
|
29
|
+
<DialogPrimitive {...props} preventScroll={false} />
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
const SheetTrigger: Component<ComponentProps<typeof DialogPrimitive.Trigger>> = (props) => (
|
|
33
|
-
|
|
33
|
+
<DialogPrimitive.Trigger data-slot="sheet-trigger" {...props} />
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
type SheetCloseProps = ModalDismissProps &
|
|
37
|
-
|
|
37
|
+
Partial<Pick<VariantProps<typeof buttonVariants>, "variant" | "size">>;
|
|
38
38
|
|
|
39
39
|
const SheetDismiss = createModalDismiss("sheet-close");
|
|
40
40
|
|
|
41
41
|
/** Already the outline button; see DialogClose on why `as={Button}` is wrong. */
|
|
42
42
|
const SheetClose: ParentComponent<SheetCloseProps> = (props) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
const [local, rest] = splitProps(props, ["class", "variant", "size", "children"]);
|
|
44
|
+
return (
|
|
45
|
+
<SheetDismiss
|
|
46
|
+
class={cn(
|
|
47
|
+
buttonVariants({ variant: local.variant ?? "outline", size: local.size }),
|
|
48
|
+
local.class,
|
|
49
|
+
)}
|
|
50
|
+
{...rest}
|
|
51
|
+
>
|
|
52
|
+
{local.children ?? "Close"}
|
|
53
|
+
</SheetDismiss>
|
|
54
|
+
);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
const SheetOverlay: Component<ComponentProps<typeof DialogPrimitive.Overlay>> = (props) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
59
|
+
return (
|
|
60
|
+
<DialogPrimitive.Overlay
|
|
61
|
+
data-slot="sheet-overlay"
|
|
62
|
+
class={cn(
|
|
63
|
+
`${SCRIM_MOTION} pointer-events-auto fixed inset-0 select-none ${Z_CLASS.overlay} ${SCRIM_CLASS}`,
|
|
64
|
+
local.class,
|
|
65
|
+
)}
|
|
66
|
+
{...rest}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
/* A viewport-tall panel would stretch the percentage-sized sheen into a small
|
|
@@ -75,83 +75,83 @@ const SHEET_SURFACE = `${OVERLAY_SURFACE} [--glass-sheen:600px_300px]`;
|
|
|
75
75
|
const SHEET_PANEL = `fixed ${Z_CLASS.overlay} flex flex-col overflow-hidden rounded-lg ${SHEET_SURFACE} transition ease-in-out focus:outline-none focus-visible:outline-none data-[closed]:animate-out data-[expanded]:animate-in data-[closed]:duration-300 data-[expanded]:duration-500`;
|
|
76
76
|
|
|
77
77
|
const SHEET_SIDE = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
right:
|
|
79
|
+
"data-[closed]:slide-out-to-right data-[expanded]:slide-in-from-right inset-y-3 right-3 w-3/4 sm:max-w-sm",
|
|
80
|
+
left: "data-[closed]:slide-out-to-left data-[expanded]:slide-in-from-left inset-y-3 left-3 w-3/4 sm:max-w-sm",
|
|
81
|
+
top: `data-[closed]:slide-out-to-top data-[expanded]:slide-in-from-top inset-x-3 top-3 ${MODAL_MAX_H}`,
|
|
82
|
+
/** @deprecated a modal from the bottom is `BottomSheet` / `ResponsiveDialog`. */
|
|
83
|
+
bottom: `data-[closed]:slide-out-to-bottom data-[expanded]:slide-in-from-bottom inset-x-3 bottom-3 ${MODAL_MAX_H}`,
|
|
84
84
|
} as const;
|
|
85
85
|
|
|
86
86
|
type SheetSide = keyof typeof SHEET_SIDE;
|
|
87
87
|
|
|
88
88
|
type SheetContentProps = ComponentProps<typeof DialogPrimitive.Content> & {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
/** A modal belongs in `ResponsiveDialog`; this family slides from an edge. */
|
|
90
|
+
side?: SheetSide;
|
|
91
|
+
above?: JSX.Element;
|
|
92
|
+
/** Names a panel that has no `SheetTitle`. A registered Title wins. */
|
|
93
|
+
ariaLabel?: string;
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
const SheetAbove: Component<{ above?: JSX.Element }> = (props) => (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
<Show when={props.above}>
|
|
98
|
+
<div data-slot="sheet-content-above" class="flex w-full shrink-0 items-end justify-center">
|
|
99
|
+
{props.above}
|
|
100
|
+
</div>
|
|
101
|
+
</Show>
|
|
102
102
|
);
|
|
103
103
|
|
|
104
104
|
const SheetContent: ParentComponent<SheetContentProps> = (props) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
105
|
+
const [local, rest] = splitProps(props, ["class", "children", "side", "above", "ariaLabel"]);
|
|
106
|
+
const context = useDialogContext();
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<DialogPrimitive.Portal>
|
|
110
|
+
<ModalScrollLock />
|
|
111
|
+
<SheetOverlay />
|
|
112
|
+
<DialogPrimitive.Content
|
|
113
|
+
data-slot="sheet-content"
|
|
114
|
+
role="dialog"
|
|
115
|
+
aria-label={context.titleId() ? undefined : local.ariaLabel}
|
|
116
|
+
class={cn(SHEET_PANEL, SHEET_SIDE[local.side ?? "right"], local.class)}
|
|
117
|
+
onOpenAutoFocus={(e: Event) => e.preventDefault()}
|
|
118
|
+
{...rest}
|
|
119
|
+
>
|
|
120
|
+
<SheetAbove above={local.above} />
|
|
121
|
+
{local.children}
|
|
122
|
+
</DialogPrimitive.Content>
|
|
123
|
+
</DialogPrimitive.Portal>
|
|
124
|
+
);
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
const { Header: SheetHeader, Body: SheetBody, Footer: SheetFooter } = createModalParts("sheet");
|
|
128
128
|
|
|
129
129
|
const SheetTitle: Component<ComponentProps<typeof DialogPrimitive.Title>> = (props) => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
131
|
+
return (
|
|
132
|
+
<DialogPrimitive.Title data-slot="sheet-title" class={cn(MODAL_TITLE, local.class)} {...rest} />
|
|
133
|
+
);
|
|
134
134
|
};
|
|
135
135
|
|
|
136
136
|
const SheetDescription: Component<ComponentProps<typeof DialogPrimitive.Description>> = (props) => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
138
|
+
return (
|
|
139
|
+
<DialogPrimitive.Description
|
|
140
|
+
data-slot="sheet-description"
|
|
141
|
+
class={cn(MODAL_DESCRIPTION, local.class)}
|
|
142
|
+
{...rest}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
Sheet,
|
|
149
|
+
SheetBody,
|
|
150
|
+
SheetClose,
|
|
151
|
+
SheetContent,
|
|
152
|
+
SheetDescription,
|
|
153
|
+
SheetFooter,
|
|
154
|
+
SheetHeader,
|
|
155
|
+
SheetTitle,
|
|
156
|
+
SheetTrigger,
|
|
157
157
|
};
|
package/src/solid/skeleton.tsx
CHANGED
|
@@ -2,14 +2,14 @@ import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
|
2
2
|
import { cn } from "../lib/utils.js";
|
|
3
3
|
|
|
4
4
|
const Skeleton: Component<ComponentProps<"div">> = (props) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const [local, others] = splitProps(props, ["class"]);
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="skeleton"
|
|
9
|
+
class={cn("bg-muted animate-pulse rounded-md", local.class)}
|
|
10
|
+
{...others}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export { Skeleton };
|
package/src/solid/slider.tsx
CHANGED
|
@@ -6,143 +6,143 @@ import { THUMB_CLASS, THUMB_RAIL_BLEED, THUMB_RAIL_PAD } from "../lib/thumb-clas
|
|
|
6
6
|
import { cn } from "../lib/utils.js";
|
|
7
7
|
|
|
8
8
|
interface SliderProps {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
value?: number[];
|
|
10
|
+
defaultValue?: number[];
|
|
11
|
+
min?: number;
|
|
12
|
+
max?: number;
|
|
13
|
+
step?: number;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
onChange?: (values: number[]) => void;
|
|
16
|
+
onChangeEnd?: (values: number[]) => void;
|
|
17
|
+
class?: string;
|
|
18
|
+
trackClass?: string;
|
|
19
|
+
thumbClass?: string;
|
|
20
|
+
/** Per-thumb background color, index-matched to value[]. Color only; the thumb keeps its material. */
|
|
21
|
+
thumbColors?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Fill tint. A single color swaps --glass-tone; a pair runs a horizontal
|
|
24
|
+
* two-tone wash via the glass tone-2 knobs. The fill stays the one glass
|
|
25
|
+
* material either way.
|
|
26
|
+
*/
|
|
27
|
+
fillTone?: string | [string, string];
|
|
28
|
+
/** Value-positioned tick annotations on the track (e.g. a current-temperature reading). */
|
|
29
|
+
markers?: number[];
|
|
30
|
+
minStepsBetweenThumbs?: number;
|
|
31
|
+
"aria-label"?: string;
|
|
32
|
+
"aria-labelledby"?: string;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const Slider: Component<SliderProps> = (props) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
const [local] = splitProps(props, [
|
|
37
|
+
"value",
|
|
38
|
+
"defaultValue",
|
|
39
|
+
"min",
|
|
40
|
+
"max",
|
|
41
|
+
"step",
|
|
42
|
+
"disabled",
|
|
43
|
+
"onChange",
|
|
44
|
+
"onChangeEnd",
|
|
45
|
+
"class",
|
|
46
|
+
"trackClass",
|
|
47
|
+
"thumbClass",
|
|
48
|
+
"thumbColors",
|
|
49
|
+
"fillTone",
|
|
50
|
+
"markers",
|
|
51
|
+
"minStepsBetweenThumbs",
|
|
52
|
+
"aria-label",
|
|
53
|
+
"aria-labelledby",
|
|
54
|
+
]);
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
const markerPct = (v: number) => {
|
|
57
|
+
const min = local.min ?? 0;
|
|
58
|
+
const max = local.max ?? 100;
|
|
59
|
+
return max === min ? 0 : ((v - min) / (max - min)) * 100;
|
|
60
|
+
};
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
62
|
+
return (
|
|
63
|
+
<KSlider
|
|
64
|
+
value={local.value}
|
|
65
|
+
defaultValue={local.defaultValue}
|
|
66
|
+
minValue={local.min ?? 0}
|
|
67
|
+
maxValue={local.max ?? 100}
|
|
68
|
+
step={local.step ?? 1}
|
|
69
|
+
minStepsBetweenThumbs={local.minStepsBetweenThumbs}
|
|
70
|
+
disabled={local.disabled}
|
|
71
|
+
onChange={local.onChange}
|
|
72
|
+
onChangeEnd={local.onChangeEnd}
|
|
73
|
+
data-slot="slider"
|
|
74
|
+
class={cn(
|
|
75
|
+
// The rail wears the shared toggle/rail chrome, so it reads as an empty
|
|
76
|
+
// well in both themes (a field's light-theme fill rises to the card).
|
|
77
|
+
"relative flex w-full touch-none items-center rounded-xl select-none",
|
|
78
|
+
THUMB_RAIL_PAD,
|
|
79
|
+
FIELD_CHROME,
|
|
80
|
+
local.disabled && "cursor-not-allowed opacity-50",
|
|
81
|
+
local.class,
|
|
82
|
+
)}
|
|
83
|
+
>
|
|
84
|
+
<KSlider.Track
|
|
85
|
+
data-slot="slider-track"
|
|
86
|
+
class={cn(
|
|
87
|
+
"relative h-7 w-full",
|
|
88
|
+
local.disabled ? "cursor-not-allowed" : "cursor-pointer",
|
|
89
|
+
local.trackClass,
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
92
|
+
<KSlider.Fill
|
|
93
|
+
data-slot="slider-fill"
|
|
94
|
+
class={cn(
|
|
95
|
+
// The fill sits sunk inside the recessed rail: the tinted-surface
|
|
96
|
+
// outer drop shadow would read as a halo leaking out of the groove.
|
|
97
|
+
"glass glass-tint absolute inset-y-0 rounded-xl [--glass-drop:0%]",
|
|
98
|
+
THUMB_RAIL_BLEED,
|
|
99
|
+
Array.isArray(local.fillTone) && "glass-edge-gradient",
|
|
100
|
+
)}
|
|
101
|
+
style={
|
|
102
|
+
Array.isArray(local.fillTone)
|
|
103
|
+
? {
|
|
104
|
+
"--glass-tone": local.fillTone[0],
|
|
105
|
+
"--glass-tone-2": local.fillTone[1],
|
|
106
|
+
"--glass-wash-2": "var(--glass-wash)",
|
|
107
|
+
"--glass-wash-angle": "90deg",
|
|
108
|
+
}
|
|
109
|
+
: { "--glass-tone": local.fillTone ?? "var(--primary)" }
|
|
110
|
+
}
|
|
111
|
+
/>
|
|
112
|
+
<Index each={local.markers ?? []}>
|
|
113
|
+
{(marker) => (
|
|
114
|
+
<span
|
|
115
|
+
data-slot="slider-marker"
|
|
116
|
+
class="pointer-events-none absolute top-1/2 h-3 w-0.5 -translate-x-1/2 -translate-y-1/2 rounded-full"
|
|
117
|
+
style={{
|
|
118
|
+
left: `${markerPct(marker())}%`,
|
|
119
|
+
background: "color-mix(in oklab, var(--foreground) 60%, transparent)",
|
|
120
|
+
}}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
</Index>
|
|
124
|
+
<Index each={local.value ?? local.defaultValue ?? [0]}>
|
|
125
|
+
{(_, thumbIndex) => (
|
|
126
|
+
<KSlider.Thumb
|
|
127
|
+
data-slot="slider-thumb"
|
|
128
|
+
class={cn(
|
|
129
|
+
THUMB_CLASS,
|
|
130
|
+
FOCUS_RING,
|
|
131
|
+
"absolute top-0 transition-transform duration-200 ease-out hover:scale-125 active:scale-110",
|
|
132
|
+
local.disabled && "cursor-not-allowed",
|
|
133
|
+
local.thumbClass,
|
|
134
|
+
)}
|
|
135
|
+
aria-label={local["aria-label"]}
|
|
136
|
+
aria-labelledby={local["aria-labelledby"]}
|
|
137
|
+
style={{ background: local.thumbColors?.[thumbIndex] ?? "var(--primary)" }}
|
|
138
|
+
>
|
|
139
|
+
<KSlider.Input />
|
|
140
|
+
</KSlider.Thumb>
|
|
141
|
+
)}
|
|
142
|
+
</Index>
|
|
143
|
+
</KSlider.Track>
|
|
144
|
+
</KSlider>
|
|
145
|
+
);
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
export { Slider };
|