@glasshome/ui 1.21.1 → 1.22.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/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/index.d.ts +9 -9
- package/dist/solid/index.js +5431 -5424
- package/dist/solid/sonner.d.ts +1 -0
- 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 +127 -127
- package/src/solid/dialog.tsx +113 -113
- package/src/solid/dock-paging.ts +9 -9
- package/src/solid/dock.tsx +339 -339
- 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 +56 -56
- 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 +164 -164
- 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 +743 -743
- 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 +165 -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/resizable.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
type Component,
|
|
3
|
+
type ComponentProps,
|
|
4
|
+
createContext,
|
|
5
|
+
type ParentComponent,
|
|
6
|
+
Show,
|
|
7
|
+
splitProps,
|
|
8
|
+
useContext,
|
|
9
9
|
} from "solid-js";
|
|
10
10
|
import { cn } from "../lib/utils.js";
|
|
11
11
|
import { Icon } from "./icon.js";
|
|
@@ -15,135 +15,135 @@ type Direction = "horizontal" | "vertical";
|
|
|
15
15
|
const ResizableContext = createContext<{ direction: () => Direction }>();
|
|
16
16
|
|
|
17
17
|
const ResizablePanelGroup: ParentComponent<ComponentProps<"div"> & { direction?: Direction }> = (
|
|
18
|
-
|
|
18
|
+
props,
|
|
19
19
|
) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
const [local, rest] = splitProps(props, ["class", "children", "direction"]);
|
|
21
|
+
const direction = () => local.direction ?? "horizontal";
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ResizableContext.Provider value={{ direction }}>
|
|
25
|
+
<div
|
|
26
|
+
data-slot="resizable-panel-group"
|
|
27
|
+
data-panel-group-direction={direction()}
|
|
28
|
+
class={cn("flex h-full w-full data-[panel-group-direction=vertical]:flex-col", local.class)}
|
|
29
|
+
{...rest}
|
|
30
|
+
>
|
|
31
|
+
{local.children}
|
|
32
|
+
</div>
|
|
33
|
+
</ResizableContext.Provider>
|
|
34
|
+
);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const ResizablePanel: ParentComponent<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
ComponentProps<"div"> & {
|
|
39
|
+
defaultSize?: number;
|
|
40
|
+
minSize?: number;
|
|
41
|
+
maxSize?: number;
|
|
42
|
+
}
|
|
43
43
|
> = (props) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
44
|
+
const [local, rest] = splitProps(props, [
|
|
45
|
+
"class",
|
|
46
|
+
"children",
|
|
47
|
+
"defaultSize",
|
|
48
|
+
"minSize",
|
|
49
|
+
"maxSize",
|
|
50
|
+
"style",
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
data-slot="resizable-panel"
|
|
56
|
+
class={cn("flex-1 overflow-auto", local.class)}
|
|
57
|
+
style={{
|
|
58
|
+
...(typeof local.style === "object" ? local.style : {}),
|
|
59
|
+
"flex-grow": local.defaultSize ? String(local.defaultSize) : undefined,
|
|
60
|
+
"min-width": local.minSize ? `${local.minSize}%` : undefined,
|
|
61
|
+
"max-width": local.maxSize ? `${local.maxSize}%` : undefined,
|
|
62
|
+
}}
|
|
63
|
+
{...rest}
|
|
64
|
+
>
|
|
65
|
+
{local.children}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
const ResizableHandle: Component<ComponentProps<"div"> & { withHandle?: boolean }> = (props) => {
|
|
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
|
-
|
|
146
|
-
|
|
71
|
+
const [local, rest] = splitProps(props, ["class", "withHandle"]);
|
|
72
|
+
const ctx = useContext(ResizableContext);
|
|
73
|
+
|
|
74
|
+
const handlePointerDown = (e: PointerEvent) => {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
const target = e.currentTarget as HTMLElement;
|
|
77
|
+
target.setPointerCapture(e.pointerId);
|
|
78
|
+
|
|
79
|
+
const group = target.parentElement;
|
|
80
|
+
if (!group) return;
|
|
81
|
+
|
|
82
|
+
const dir = ctx?.direction() ?? "horizontal";
|
|
83
|
+
const panels = Array.from(group.querySelectorAll<HTMLElement>("[data-slot='resizable-panel']"));
|
|
84
|
+
const children = Array.from(group.children);
|
|
85
|
+
const handleIndex = children.indexOf(target);
|
|
86
|
+
|
|
87
|
+
// Find panels adjacent to this handle
|
|
88
|
+
let leftPanelIdx = -1;
|
|
89
|
+
let rightPanelIdx = -1;
|
|
90
|
+
let panelCount = 0;
|
|
91
|
+
for (let i = 0; i < children.length; i++) {
|
|
92
|
+
if ((children[i] as HTMLElement).dataset.slot === "resizable-panel") {
|
|
93
|
+
if (i < handleIndex) leftPanelIdx = panelCount;
|
|
94
|
+
if (i > handleIndex && rightPanelIdx === -1) rightPanelIdx = panelCount;
|
|
95
|
+
panelCount++;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const leftPanel = panels[leftPanelIdx];
|
|
100
|
+
const rightPanel = panels[rightPanelIdx];
|
|
101
|
+
if (!leftPanel || !rightPanel) return;
|
|
102
|
+
|
|
103
|
+
const startPos = dir === "horizontal" ? e.clientX : e.clientY;
|
|
104
|
+
const totalSize =
|
|
105
|
+
dir === "horizontal"
|
|
106
|
+
? group.getBoundingClientRect().width
|
|
107
|
+
: group.getBoundingClientRect().height;
|
|
108
|
+
const leftStart = dir === "horizontal" ? leftPanel.offsetWidth : leftPanel.offsetHeight;
|
|
109
|
+
const rightStart = dir === "horizontal" ? rightPanel.offsetWidth : rightPanel.offsetHeight;
|
|
110
|
+
|
|
111
|
+
const handleMove = (ev: PointerEvent) => {
|
|
112
|
+
const currentPos = dir === "horizontal" ? ev.clientX : ev.clientY;
|
|
113
|
+
const delta = currentPos - startPos;
|
|
114
|
+
const newLeft = Math.max(0, leftStart + delta);
|
|
115
|
+
const newRight = Math.max(0, rightStart - delta);
|
|
116
|
+
leftPanel.style.flexGrow = String((newLeft / totalSize) * 100);
|
|
117
|
+
rightPanel.style.flexGrow = String((newRight / totalSize) * 100);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const handleUp = () => {
|
|
121
|
+
target.removeEventListener("pointermove", handleMove);
|
|
122
|
+
target.removeEventListener("pointerup", handleUp);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
target.addEventListener("pointermove", handleMove);
|
|
126
|
+
target.addEventListener("pointerup", handleUp);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div
|
|
131
|
+
data-slot="resizable-handle"
|
|
132
|
+
data-panel-group-direction={ctx?.direction()}
|
|
133
|
+
class={cn(
|
|
134
|
+
"bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",
|
|
135
|
+
local.class,
|
|
136
|
+
)}
|
|
137
|
+
onPointerDown={handlePointerDown}
|
|
138
|
+
{...rest}
|
|
139
|
+
>
|
|
140
|
+
<Show when={local.withHandle}>
|
|
141
|
+
<div class="bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border">
|
|
142
|
+
<Icon icon="lucide:grip-vertical" width={10} height={10} class="size-2.5" />
|
|
143
|
+
</div>
|
|
144
|
+
</Show>
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
export { ResizableHandle, ResizablePanel, ResizablePanelGroup };
|
|
@@ -1,188 +1,188 @@
|
|
|
1
1
|
import type { VariantProps } from "cva";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
type Component,
|
|
4
|
+
type ComponentProps,
|
|
5
|
+
createContext,
|
|
6
|
+
createSignal,
|
|
7
|
+
type JSX,
|
|
8
|
+
type ParentComponent,
|
|
9
|
+
Show,
|
|
10
|
+
splitProps,
|
|
11
|
+
useContext,
|
|
12
|
+
type ValidComponent,
|
|
13
13
|
} from "solid-js";
|
|
14
14
|
import type { buttonVariants } from "../lib/button-variants.js";
|
|
15
15
|
import { createIsMobile } from "../lib/use-is-mobile.js";
|
|
16
16
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
BottomSheet,
|
|
18
|
+
BottomSheetContent,
|
|
19
|
+
BottomSheetDescription,
|
|
20
|
+
BottomSheetHandle,
|
|
21
|
+
BottomSheetOverlay,
|
|
22
|
+
BottomSheetPortal,
|
|
23
|
+
BottomSheetTitle,
|
|
24
|
+
BottomSheetTrigger,
|
|
25
25
|
} from "./bottom-sheet/index.js";
|
|
26
26
|
import { Button } from "./button.js";
|
|
27
27
|
import { Dialog, DialogContent, DialogDescription, DialogTitle, DialogTrigger } from "./dialog.js";
|
|
28
28
|
import { createModalParts, type ModalSize } from "./dialog-parts.js";
|
|
29
29
|
|
|
30
30
|
interface ResponsiveDialogContextValue {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
open: () => boolean;
|
|
32
|
+
setOpen: (open: boolean) => void;
|
|
33
|
+
isMobile: () => boolean;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const ResponsiveDialogContext = createContext<ResponsiveDialogContextValue>();
|
|
37
37
|
|
|
38
38
|
function useResponsiveDialogContext(): ResponsiveDialogContextValue {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const ctx = useContext(ResponsiveDialogContext);
|
|
40
|
+
if (!ctx) throw new Error("ResponsiveDialog parts must be used within <ResponsiveDialog>");
|
|
41
|
+
return ctx;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
interface ResponsiveDialogProps {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
children: JSX.Element;
|
|
46
|
+
open?: boolean;
|
|
47
|
+
onOpenChange?: (open: boolean) => void;
|
|
48
|
+
defaultOpen?: boolean;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/** Centred kobalte dialog from `sm` up, drag-to-dismiss bottom sheet below it.
|
|
52
52
|
* Both branches render the same parts, so a call site never branches. */
|
|
53
53
|
const ResponsiveDialog: ParentComponent<ResponsiveDialogProps> = (props) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
54
|
+
const [uncontrolledOpen, setUncontrolledOpen] = createSignal(props.defaultOpen ?? false);
|
|
55
|
+
const mobile = createIsMobile();
|
|
56
|
+
const isMobile = () => mobile() === true;
|
|
57
|
+
|
|
58
|
+
const open = () => (props.open !== undefined ? props.open === true : uncontrolledOpen());
|
|
59
|
+
const setOpen = (next: boolean) => {
|
|
60
|
+
if (props.open === undefined) setUncontrolledOpen(next);
|
|
61
|
+
props.onOpenChange?.(next);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<ResponsiveDialogContext.Provider value={{ open, setOpen, isMobile }}>
|
|
66
|
+
<Show
|
|
67
|
+
when={isMobile()}
|
|
68
|
+
fallback={
|
|
69
|
+
<Dialog open={open()} onOpenChange={setOpen}>
|
|
70
|
+
{props.children}
|
|
71
|
+
</Dialog>
|
|
72
|
+
}
|
|
73
|
+
>
|
|
74
|
+
<BottomSheet open={open()} onOpenChange={setOpen}>
|
|
75
|
+
{props.children}
|
|
76
|
+
</BottomSheet>
|
|
77
|
+
</Show>
|
|
78
|
+
</ResponsiveDialogContext.Provider>
|
|
79
|
+
);
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
const ResponsiveDialogTrigger: ParentComponent<
|
|
83
|
-
|
|
83
|
+
ComponentProps<"button"> & { as?: ValidComponent }
|
|
84
84
|
> = (props) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
const ctx = useResponsiveDialogContext();
|
|
86
|
+
return (
|
|
87
|
+
<Show when={ctx.isMobile()} fallback={<DialogTrigger {...props} />}>
|
|
88
|
+
<BottomSheetTrigger {...props} />
|
|
89
|
+
</Show>
|
|
90
|
+
);
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
type ResponsiveDialogContentProps = ComponentProps<"div"> & {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
/** Desktop panel width. The mobile sheet is always full width. */
|
|
95
|
+
size?: ModalSize;
|
|
96
|
+
/** Names a panel that has no `ResponsiveDialogTitle`. */
|
|
97
|
+
ariaLabel?: string;
|
|
98
|
+
/** Desktop only: opens the panel beside this element instead of centred. The mobile sheet ignores it. */
|
|
99
|
+
anchor?: HTMLElement;
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
const ResponsiveDialogContent: ParentComponent<ResponsiveDialogContentProps> = (props) => {
|
|
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
|
-
|
|
103
|
+
const ctx = useResponsiveDialogContext();
|
|
104
|
+
const [local, rest] = splitProps(props, ["class", "children", "size", "ariaLabel", "anchor"]);
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<Show
|
|
108
|
+
when={ctx.isMobile()}
|
|
109
|
+
fallback={
|
|
110
|
+
<DialogContent
|
|
111
|
+
class={local.class}
|
|
112
|
+
size={local.size}
|
|
113
|
+
ariaLabel={local.ariaLabel}
|
|
114
|
+
anchor={local.anchor}
|
|
115
|
+
{...rest}
|
|
116
|
+
>
|
|
117
|
+
{local.children}
|
|
118
|
+
</DialogContent>
|
|
119
|
+
}
|
|
120
|
+
>
|
|
121
|
+
<BottomSheetPortal>
|
|
122
|
+
<BottomSheetOverlay />
|
|
123
|
+
<BottomSheetContent class={local.class} ariaLabel={local.ariaLabel} {...rest}>
|
|
124
|
+
<BottomSheetHandle />
|
|
125
|
+
{local.children}
|
|
126
|
+
</BottomSheetContent>
|
|
127
|
+
</BottomSheetPortal>
|
|
128
|
+
</Show>
|
|
129
|
+
);
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
const {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
Header: ResponsiveDialogHeader,
|
|
134
|
+
Body: ResponsiveDialogBody,
|
|
135
|
+
Footer: ResponsiveDialogFooter,
|
|
136
136
|
} = createModalParts("responsive-dialog");
|
|
137
137
|
|
|
138
138
|
const ResponsiveDialogTitle: Component<ComponentProps<"h2">> = (props) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
const ctx = useResponsiveDialogContext();
|
|
140
|
+
return (
|
|
141
|
+
<Show when={ctx.isMobile()} fallback={<DialogTitle {...props} />}>
|
|
142
|
+
<BottomSheetTitle {...props} />
|
|
143
|
+
</Show>
|
|
144
|
+
);
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
const ResponsiveDialogDescription: Component<ComponentProps<"p">> = (props) => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
const ctx = useResponsiveDialogContext();
|
|
149
|
+
return (
|
|
150
|
+
<Show when={ctx.isMobile()} fallback={<DialogDescription {...props} />}>
|
|
151
|
+
<BottomSheetDescription {...props} />
|
|
152
|
+
</Show>
|
|
153
|
+
);
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
/** Defaults to the footer's outline button; an icon-only close passes `ghost`
|
|
157
157
|
* so the glyph is not boxed. */
|
|
158
158
|
const ResponsiveDialogClose: ParentComponent<
|
|
159
|
-
|
|
159
|
+
ComponentProps<"button"> & VariantProps<typeof buttonVariants>
|
|
160
160
|
> = (props) => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
161
|
+
const [local, rest] = splitProps(props, ["children", "class", "variant", "size"]);
|
|
162
|
+
const ctx = useResponsiveDialogContext();
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<Button
|
|
166
|
+
data-slot="responsive-dialog-close"
|
|
167
|
+
variant={local.variant ?? "outline"}
|
|
168
|
+
size={local.size}
|
|
169
|
+
onClick={() => ctx.setOpen(false)}
|
|
170
|
+
class={local.class}
|
|
171
|
+
{...rest}
|
|
172
|
+
>
|
|
173
|
+
{local.children ?? "Close"}
|
|
174
|
+
</Button>
|
|
175
|
+
);
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
export {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
179
|
+
ResponsiveDialog,
|
|
180
|
+
ResponsiveDialogBody,
|
|
181
|
+
ResponsiveDialogClose,
|
|
182
|
+
ResponsiveDialogContent,
|
|
183
|
+
ResponsiveDialogDescription,
|
|
184
|
+
ResponsiveDialogFooter,
|
|
185
|
+
ResponsiveDialogHeader,
|
|
186
|
+
ResponsiveDialogTitle,
|
|
187
|
+
ResponsiveDialogTrigger,
|
|
188
188
|
};
|