@q9labsai/chalk-react 5.4.0 → 5.5.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/README.md +7 -30
- package/dist/Board-PPO62QTR.js +80 -0
- package/dist/CallCharts-7ZQLN47C.js +114 -0
- package/dist/CallDetails-IG57GXT2.js +200 -0
- package/dist/CallDialogContent-GST2I23W.js +177 -0
- package/dist/CameraBackgroundPicker-AZXKBGRF.js +72 -0
- package/dist/ConnectionNotice-NQUBBT46.js +55 -0
- package/dist/DeviceAccessCard-MLRBTPRP.js +238 -0
- package/dist/DeviceAccessWaiting-MQXXW45M.js +25 -0
- package/dist/DeviceSheet-GZTV44UW.js +118 -0
- package/dist/InviteQrCode-TNTZA3GS.js +54 -0
- package/dist/KnockNotice-CAW4CJ4S.js +181 -0
- package/dist/ReactionSheet-ZU6RWC66.js +132 -0
- package/dist/chunk-26PBFST5.js +25 -0
- package/dist/{chunk-K5DV2OTY.js → chunk-4RSCAIFK.js} +340 -165
- package/dist/chunk-ADIDI7AJ.js +10 -0
- package/dist/chunk-ALGD3RBI.js +10 -0
- package/dist/chunk-CQBYFA2W.js +73 -0
- package/dist/chunk-E6HPIMFO.js +44 -0
- package/dist/{chunk-LYZ7EBFF.js → chunk-F6QZY5SM.js} +4116 -4605
- package/dist/chunk-I6FSUWKG.js +51 -0
- package/dist/chunk-JDCFKSGV.js +95 -0
- package/dist/chunk-PH3RC6T6.js +476 -0
- package/dist/chunk-PMGIER77.js +92 -0
- package/dist/chunk-Q36UO2T2.js +363 -0
- package/dist/chunk-SBGC5DKV.js +114 -0
- package/dist/chunk-SZNV3J4B.js +9 -0
- package/dist/{chunk-4U7QZC72.js → chunk-TSBY6C5U.js} +1 -102
- package/dist/chunk-XY7WXXME.js +85 -0
- package/dist/chunk-YOWY22N7.js +148 -0
- package/dist/chunk-Z5AASN4L.js +34 -0
- package/dist/components/admission-panel/KnockNotice.d.ts +31 -0
- package/dist/components/admission-panel/answer-all.d.ts +2 -0
- package/dist/components/call-limbo/CallLimbo.d.ts +5 -1
- package/dist/components/chalk/Chalk.d.ts +2 -5
- package/dist/components/chalk/StatusSurface.d.ts +3 -3
- package/dist/components/chalk-ui/ChalkSheet.d.ts +6 -2
- package/dist/components/chalk-ui/InviteLinkButton.d.ts +5 -0
- package/dist/components/chalk-ui/InviteQR.d.ts +4 -0
- package/dist/components/chalk-ui/InviteQrCode.d.ts +3 -0
- package/dist/components/chalk-ui/MenuIcon.d.ts +17 -0
- package/dist/components/chalk-ui/invite-qr-path.d.ts +10 -0
- package/dist/components/chalk-ui/sheet-drag.d.ts +17 -0
- package/dist/components/chalk-ui/useCopyText.d.ts +6 -0
- package/dist/components/chalk-ui/useSheetDrag.d.ts +11 -0
- package/dist/components/composite/ReactionSheet.d.ts +5 -0
- package/dist/components/connection-notice/ConnectionBars.d.ts +4 -0
- package/dist/components/connection-notice/ConnectionNotice.d.ts +12 -0
- package/dist/components/connection-notice/shown-notice.d.ts +12 -0
- package/dist/components/connection-status/ConnectionRing.d.ts +2 -0
- package/dist/components/connection-status/ConnectionStatus.d.ts +24 -0
- package/dist/components/connection-status/LiveConnectionStatus.d.ts +9 -0
- package/dist/components/connection-status/use-connection-phase.d.ts +23 -0
- package/dist/components/control-bar/DockLayout.d.ts +2 -1
- package/dist/components/control-bar/ShareControl.d.ts +3 -1
- package/dist/components/control-bar/ShellIcon.d.ts +18 -6
- package/dist/components/control-bar/control-bar-behavior.d.ts +19 -8
- package/dist/components/control-bar/control-bar-devices.d.ts +8 -0
- package/dist/components/control-bar/useDeviceSheets.d.ts +7 -0
- package/dist/components/device-access/DeviceAccessCard.d.ts +17 -0
- package/dist/components/device-access/DeviceAccessStyles.d.ts +1 -0
- package/dist/components/device-access/DeviceAccessWaiting.d.ts +4 -0
- package/dist/components/device-access/LazyDeviceAccessCard.d.ts +7 -0
- package/dist/components/device-access/browser-marks.d.ts +5 -0
- package/dist/components/device-access/card-copy.d.ts +17 -0
- package/dist/components/device-access/load-card.d.ts +2 -0
- package/dist/components/device-access/model.d.ts +29 -0
- package/dist/components/device-access/ports.d.ts +21 -0
- package/dist/components/device-access/resolve.d.ts +31 -0
- package/dist/components/device-access/store.d.ts +32 -0
- package/dist/components/device-access/useDeviceAccess.d.ts +7 -0
- package/dist/components/device-popover/CameraBackgroundPicker.d.ts +23 -0
- package/dist/components/device-popover/DevicePopover.d.ts +7 -1
- package/dist/components/device-popover/DevicePreview.d.ts +12 -0
- package/dist/components/device-popover/DeviceSheet.d.ts +26 -0
- package/dist/components/index.js +30 -15
- package/dist/components/participant-grid/ParticipantGrid.d.ts +9 -0
- package/dist/components/participant-tile/ParticipantTile.d.ts +12 -1
- package/dist/components/participant-tile/TileConnection.d.ts +9 -0
- package/dist/components/participant-tile/TileShell.d.ts +2 -1
- package/dist/components/participant-tile/useFrozenFrame.d.ts +12 -0
- package/dist/components/participant-tile/useVideoTileVisibility.d.ts +6 -0
- package/dist/components/participants-panel/ParticipantsPanel.d.ts +5 -0
- package/dist/components/participants-panel/participant-options-menu.d.ts +4 -1
- package/dist/components/participants-panel/participant-order.d.ts +13 -0
- package/dist/components/participants-panel/participant-row.d.ts +5 -1
- package/dist/components/participants-panel/participant-search.d.ts +4 -0
- package/dist/components/space-header/CallCharts.d.ts +22 -0
- package/dist/components/space-header/CallDetails.d.ts +5 -13
- package/dist/components/space-header/CallDialog.d.ts +5 -0
- package/dist/components/space-header/CallDialogContent.d.ts +13 -0
- package/dist/components/space-header/CallMenuStyles.d.ts +2 -0
- package/dist/components/space-header/RowIcon.d.ts +12 -0
- package/dist/components/space-header/call-diagnostics.d.ts +2 -1
- package/dist/components/space-header/call-network.d.ts +18 -0
- package/dist/components/space-header/space-header-contract.d.ts +8 -1
- package/dist/components/space-view/SpacePresentation.d.ts +3 -1
- package/dist/components/space-view/SpaceView.d.ts +3 -5
- package/dist/components/space-view/useBoardNotices.d.ts +7 -0
- package/dist/components/space-view/useMicrophoneNotice.d.ts +11 -0
- package/dist/components/toast-stack/ToastStack.d.ts +3 -1
- package/dist/components/toast-stack/call-events.d.ts +4 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +298 -28
- package/dist/internal/call-width.d.ts +9 -0
- package/dist/internal/media-devices.d.ts +11 -0
- package/dist/internal/speaker-test.d.ts +2 -0
- package/dist/internal/useHandOrder.d.ts +2 -0
- package/dist/internal/useHeldWhile.d.ts +2 -0
- package/dist/internal/useInputLevel.d.ts +4 -0
- package/dist/internal/useLongPress.d.ts +15 -0
- package/dist/internal/useSeenConnected.d.ts +9 -0
- package/dist/internal/useSilentMicrophone.d.ts +4 -0
- package/dist/internal/useTrueFor.d.ts +4 -0
- package/dist/participant-options-menu-S3EL6K3M.js +330 -0
- package/dist/pre-join/remembered-devices.d.ts +12 -0
- package/dist/pre-join/usePreJoinDevices.d.ts +47 -0
- package/dist/public-surface.contract.d.ts +1 -1
- package/dist/test-support/index.d.ts +1 -1
- package/dist/test-support/index.js +41 -10
- package/dist/theme.d.ts +32 -32
- package/dist/toast.d.ts +1 -0
- package/dist/toast.js +7 -0
- package/dist/utils/formatClockTime.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +20 -12
- package/package.json +24 -11
- package/dist/components/call-limbo/qr-code.d.ts +0 -4
- package/dist/components/offline-actions/OfflineActions.d.ts +0 -9
- package/dist/components/participants-panel/index.d.ts +0 -2
- package/dist/components/reconnecting-overlay/ReconnectingOverlay.d.ts +0 -12
- package/dist/components/space-header/share-qr.d.ts +0 -2
- package/dist/components/space-view/countdown.d.ts +0 -5
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/components/chalk-ui/ChalkToast.tsx
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
// src/components/toast-stack/notice-announcement.ts
|
|
5
|
+
import { Children, Fragment, isValidElement } from "react";
|
|
6
|
+
function literalText(node) {
|
|
7
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "bigint") return String(node);
|
|
8
|
+
if (node == null || typeof node === "boolean") return "";
|
|
9
|
+
if (isValidElement(node)) return typeof node.type === "string" || node.type === Fragment ? literalText(node.props.children) : "";
|
|
10
|
+
if (typeof node === "object" && "then" in node) return "";
|
|
11
|
+
return typeof node === "object" && Symbol.iterator in node ? Children.toArray(node).map(literalText).join("") : "";
|
|
12
|
+
}
|
|
13
|
+
function noticeAnnouncement(toast) {
|
|
14
|
+
return toast.announcementText ?? literalText(toast.message);
|
|
15
|
+
}
|
|
16
|
+
function noticeIdentity(toast) {
|
|
17
|
+
return JSON.stringify([noticeAnnouncement(toast), toast.announcementKey, toast.type ?? "info"]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/components/chalk-ui/ChalkToast.tsx
|
|
21
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
function ChalkToast({ message, announcementKey, announcementText, type = "info", duration = type === "info" || type === "success" ? 5e3 : Infinity, action, icon, announce = true, onDismiss }) {
|
|
23
|
+
const dismissRef = useRef(onDismiss);
|
|
24
|
+
dismissRef.current = onDismiss;
|
|
25
|
+
const identity = noticeIdentity({ message, announcementText, announcementKey, type });
|
|
26
|
+
const [lifetime, setLifetime] = useState({ identity, exiting: false });
|
|
27
|
+
if (lifetime.identity !== identity) setLifetime({ identity, exiting: false });
|
|
28
|
+
const exiting = lifetime.identity === identity && lifetime.exiting;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (duration === Infinity) return;
|
|
31
|
+
const timer = setTimeout(() => setLifetime({ identity, exiting: true }), duration);
|
|
32
|
+
return () => clearTimeout(timer);
|
|
33
|
+
}, [duration, identity]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!exiting) return;
|
|
36
|
+
const timer = setTimeout(() => dismissRef.current(), 160);
|
|
37
|
+
return () => clearTimeout(timer);
|
|
38
|
+
}, [exiting, identity]);
|
|
39
|
+
return /* @__PURE__ */ jsxs("div", { "data-part": "toast", "data-type": type, "data-exiting": exiting || void 0, className: "chalk-toast", role: announce ? type === "error" ? "alert" : "status" : void 0, "aria-live": announce ? type === "error" ? "assertive" : "polite" : void 0, "aria-atomic": announce || void 0, children: [
|
|
40
|
+
/* @__PURE__ */ jsx("span", { "data-part": "toast-icon", "aria-hidden": "true", children: icon }),
|
|
41
|
+
/* @__PURE__ */ jsx("span", { "data-part": "toast-message", children: message }),
|
|
42
|
+
action ? /* @__PURE__ */ jsx("button", { type: "button", "data-part": "pill-button", className: "chalk-pill-button", onClick: action.onClick, children: action.label }) : null,
|
|
43
|
+
duration === Infinity ? /* @__PURE__ */ jsx("button", { type: "button", "data-part": "toast-dismiss", className: "chalk-dismiss", "aria-label": "Dismiss", onClick: () => setLifetime({ identity, exiting: true }), children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m6 6 12 12M6 18 18 6" }) }) }) : null
|
|
44
|
+
] });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
noticeAnnouncement,
|
|
49
|
+
noticeIdentity,
|
|
50
|
+
ChalkToast
|
|
51
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// src/utils/colorGenerator.ts
|
|
2
|
+
var PARTICIPANT_GRADIENT_PRESETS = [
|
|
3
|
+
{ id: "aurora", label: "Aurora", from: "#0ea5e9", to: "#22c55e" },
|
|
4
|
+
{ id: "ember", label: "Ember", from: "#f97316", to: "#ef4444" },
|
|
5
|
+
{ id: "orchid", label: "Orchid", from: "#a855f7", to: "#ec4899" },
|
|
6
|
+
{ id: "cobalt", label: "Cobalt", from: "#2563eb", to: "#14b8a6" },
|
|
7
|
+
{ id: "gold", label: "Gold", from: "#eab308", to: "#f97316" },
|
|
8
|
+
{ id: "slate", label: "Slate", from: "#64748b", to: "#94a3b8" }
|
|
9
|
+
];
|
|
10
|
+
var AUTO_PALETTE = [
|
|
11
|
+
["#315f72", "#dcebef"],
|
|
12
|
+
["#5c6650", "#e3eadf"],
|
|
13
|
+
["#6b5b4f", "#ece3dc"],
|
|
14
|
+
["#64576b", "#e8e0ea"],
|
|
15
|
+
["#49645d", "#dfeae6"],
|
|
16
|
+
["#665d42", "#ebe6d6"],
|
|
17
|
+
["#4d5d73", "#e1e6ec"],
|
|
18
|
+
["#6d5158", "#eee0e3"]
|
|
19
|
+
];
|
|
20
|
+
function hashIdentity(identity) {
|
|
21
|
+
let hash = 2166136261;
|
|
22
|
+
for (const char of identity.trim().toLowerCase() || "chalk") {
|
|
23
|
+
hash ^= char.charCodeAt(0);
|
|
24
|
+
hash = Math.imul(hash, 16777619);
|
|
25
|
+
}
|
|
26
|
+
return hash >>> 0;
|
|
27
|
+
}
|
|
28
|
+
function resolveGradient(identity = "chalk", preference) {
|
|
29
|
+
if (preference?.mode === "custom" && preference.from && preference.to) {
|
|
30
|
+
return [preference.from, preference.to];
|
|
31
|
+
}
|
|
32
|
+
return AUTO_PALETTE[hashIdentity(identity) % AUTO_PALETTE.length] ?? ["#64748b", "#94a3b8"];
|
|
33
|
+
}
|
|
34
|
+
function getParticipantInitial(name) {
|
|
35
|
+
return (name?.trim()?.[0] ?? "?").toUpperCase();
|
|
36
|
+
}
|
|
37
|
+
function getParticipantInitials(name) {
|
|
38
|
+
const parts = (name ?? "").trim().split(/\s+/).filter(Boolean);
|
|
39
|
+
const first = parts[0]?.[0] ?? getParticipantInitial(name);
|
|
40
|
+
const second = parts[1]?.[0] ?? "";
|
|
41
|
+
return (parts.length > 1 ? first + second : first).toUpperCase();
|
|
42
|
+
}
|
|
43
|
+
function getParticipantColor(identity = "chalk", preference) {
|
|
44
|
+
const [primary, secondary] = resolveGradient(identity, preference);
|
|
45
|
+
return {
|
|
46
|
+
primary,
|
|
47
|
+
secondary,
|
|
48
|
+
text: "#ffffff",
|
|
49
|
+
gradientEnd: secondary
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function getParticipantGradient(identity = "chalk", preference) {
|
|
53
|
+
const [primary, secondary] = resolveGradient(identity, preference);
|
|
54
|
+
return `linear-gradient(135deg, ${primary}, ${secondary})`;
|
|
55
|
+
}
|
|
56
|
+
function getParticipantAvatarGradient(identity = "chalk", preference) {
|
|
57
|
+
return getParticipantGradient(identity, preference);
|
|
58
|
+
}
|
|
59
|
+
function getParticipantBorder(identity = "chalk", preference) {
|
|
60
|
+
return getParticipantColor(identity, preference).primary;
|
|
61
|
+
}
|
|
62
|
+
function getParticipantThemeVariables(identity = "chalk", preference) {
|
|
63
|
+
const colors = getParticipantColor(identity, preference);
|
|
64
|
+
return {
|
|
65
|
+
"--primary": colors.primary,
|
|
66
|
+
"--ring": colors.primary,
|
|
67
|
+
"--chalk-accent": colors.primary,
|
|
68
|
+
"--chalk-accent-2": colors.secondary
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function getParticipantAvatarRecipe(identity = "chalk", preference) {
|
|
72
|
+
const colors = getParticipantColor(identity, preference);
|
|
73
|
+
const avatarGradient = getParticipantGradient(identity, preference);
|
|
74
|
+
return {
|
|
75
|
+
initials: getParticipantInitials(identity),
|
|
76
|
+
gradient: avatarGradient,
|
|
77
|
+
avatarGradient,
|
|
78
|
+
darkerAvatarGradient: `linear-gradient(135deg, ${colors.primary}, #111827)`,
|
|
79
|
+
color: colors.primary,
|
|
80
|
+
border: colors.primary,
|
|
81
|
+
facehashColors: [colors.primary]
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
PARTICIPANT_GRADIENT_PRESETS,
|
|
87
|
+
getParticipantInitial,
|
|
88
|
+
getParticipantInitials,
|
|
89
|
+
getParticipantColor,
|
|
90
|
+
getParticipantGradient,
|
|
91
|
+
getParticipantAvatarGradient,
|
|
92
|
+
getParticipantBorder,
|
|
93
|
+
getParticipantThemeVariables,
|
|
94
|
+
getParticipantAvatarRecipe
|
|
95
|
+
};
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-ADIDI7AJ.js";
|
|
4
|
+
|
|
5
|
+
// src/internal/useMediaQuery.ts
|
|
6
|
+
import { useCallback, useMemo, useSyncExternalStore } from "react";
|
|
7
|
+
var serverSnapshot = () => false;
|
|
8
|
+
function useMediaQuery(query) {
|
|
9
|
+
const mediaQuery = useMemo(() => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query) : void 0, [query]);
|
|
10
|
+
const subscribe = useCallback(
|
|
11
|
+
(notify) => {
|
|
12
|
+
mediaQuery?.addEventListener("change", notify);
|
|
13
|
+
return () => mediaQuery?.removeEventListener("change", notify);
|
|
14
|
+
},
|
|
15
|
+
[mediaQuery]
|
|
16
|
+
);
|
|
17
|
+
return useSyncExternalStore(subscribe, () => mediaQuery?.matches ?? false, serverSnapshot);
|
|
18
|
+
}
|
|
19
|
+
function useIsMobile() {
|
|
20
|
+
return useMediaQuery("(max-width: 767px)");
|
|
21
|
+
}
|
|
22
|
+
function usePrefersReducedMotion() {
|
|
23
|
+
return useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/components/chalk-ui/ChalkButton.tsx
|
|
27
|
+
import { forwardRef } from "react";
|
|
28
|
+
import { jsx } from "react/jsx-runtime";
|
|
29
|
+
var ChalkButton = forwardRef(function ChalkButton2({ className, children, disabled, loading = false, variant = "outline", tone = "neutral", type = "button", ...props }, ref) {
|
|
30
|
+
return /* @__PURE__ */ jsx("button", { ref, type, disabled: disabled || loading, "aria-busy": loading || void 0, "data-part": "pill-button", "data-chalk-variant": variant, "data-chalk-tone": tone, className: cn("chalk-pill-button", className), ...props, children });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// src/components/chalk-ui/ChalkIconButton.tsx
|
|
34
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
35
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
36
|
+
var ChalkIconButton = forwardRef2(function ChalkIconButton2({ className, children, tone = "neutral", size = "md", type = "button", ...props }, ref) {
|
|
37
|
+
return /* @__PURE__ */ jsx2("button", { ref, type, "data-part": "icon-button", "data-chalk-tone": tone, "data-chalk-size": size, className: cn("chalk-icon-button", className), ...props, children });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// src/components/chalk-ui/ChalkPanel.tsx
|
|
41
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
42
|
+
|
|
43
|
+
// src/components/chalk-ui/common.ts
|
|
44
|
+
var CLASSIC_SURFACE_CLASSES = "border border-[var(--chalk-app-line,var(--chalk-line))] bg-[var(--chalk-app-control,var(--chalk-surface))]";
|
|
45
|
+
var CLASSIC_PANEL_CLASSES = "border border-[var(--chalk-app-line,var(--chalk-line))] bg-[var(--chalk-app-panel,var(--chalk-surface))]";
|
|
46
|
+
var CLASSIC_FOCUS_CLASSES = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--chalk-app-control-active-line,var(--chalk-focus))] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--chalk-app-canvas,var(--chalk-canvas))]";
|
|
47
|
+
var CLASSIC_FOCUS_WITHIN_CLASSES = "focus-within:border-[var(--chalk-app-control-active-line,var(--chalk-focus))] focus-within:ring-2 focus-within:ring-[var(--chalk-app-control-active-line,var(--chalk-focus))] focus-within:ring-offset-1 focus-within:ring-offset-[var(--chalk-app-canvas,var(--chalk-canvas))]";
|
|
48
|
+
var CLASSIC_TONE_CLASSES = {
|
|
49
|
+
neutral: {
|
|
50
|
+
border: "border-[var(--chalk-app-line-strong,var(--chalk-line))]",
|
|
51
|
+
text: "text-[var(--chalk-app-text,var(--chalk-text))]",
|
|
52
|
+
background: "bg-[var(--chalk-app-control,var(--chalk-surface))]"
|
|
53
|
+
},
|
|
54
|
+
accent: {
|
|
55
|
+
border: "border-[var(--chalk-app-control-active-line,var(--chalk-focus))]",
|
|
56
|
+
text: "text-[var(--chalk-app-control-active-line,var(--chalk-focus))]",
|
|
57
|
+
background: "bg-[var(--chalk-app-control-active,var(--chalk-surface))]"
|
|
58
|
+
},
|
|
59
|
+
danger: {
|
|
60
|
+
border: "border-[var(--chalk-app-danger,var(--chalk-danger))]",
|
|
61
|
+
text: "text-[var(--chalk-app-danger,var(--chalk-danger))]",
|
|
62
|
+
background: "bg-[var(--chalk-app-control,var(--chalk-surface))]"
|
|
63
|
+
},
|
|
64
|
+
success: {
|
|
65
|
+
border: "border-[var(--chalk-app-success,var(--chalk-positive))]",
|
|
66
|
+
text: "text-[var(--chalk-app-success,var(--chalk-positive))]",
|
|
67
|
+
background: "bg-[var(--chalk-app-control,var(--chalk-surface))]"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function classicToneSurfaceClasses(tone) {
|
|
71
|
+
const toneClasses = CLASSIC_TONE_CLASSES[tone];
|
|
72
|
+
return `${toneClasses.border} ${toneClasses.background} ${toneClasses.text}`;
|
|
73
|
+
}
|
|
74
|
+
function classicTonePanelClasses(tone) {
|
|
75
|
+
const toneClasses = CLASSIC_TONE_CLASSES[tone];
|
|
76
|
+
return `${toneClasses.border} ${toneClasses.text}`;
|
|
77
|
+
}
|
|
78
|
+
function mergeStyle(style, position = "relative") {
|
|
79
|
+
return { position, ...style };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/components/chalk-ui/ChalkPanel.tsx
|
|
83
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
84
|
+
var ChalkPanel = forwardRef3(function ChalkPanel2({ children, className, contentClassName, tone = "neutral", style, ...props }, ref) {
|
|
85
|
+
return /* @__PURE__ */ jsx3("div", { ref, className: cn(cn(CLASSIC_PANEL_CLASSES, CLASSIC_FOCUS_CLASSES, "relative rounded-xl p-4 text-[var(--chalk-app-text,var(--chalk-text))] shadow-[var(--chalk-app-shadow-sm,var(--chalk-shadow))]"), className), style: mergeStyle(style), ...props, children: /* @__PURE__ */ jsx3("div", { className: cn("relative z-[1]", contentClassName), children }) });
|
|
86
|
+
});
|
|
87
|
+
ChalkPanel.displayName = "ChalkPanel";
|
|
88
|
+
|
|
89
|
+
// src/components/chalk-ui/ChalkInput.tsx
|
|
90
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
91
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
92
|
+
var ChalkInput = forwardRef4(function ChalkInput2({ className, wrapperClassName, tone = "neutral", style, type = "text", ...props }, ref) {
|
|
93
|
+
return /* @__PURE__ */ jsx4("span", { className: cn(cn(CLASSIC_SURFACE_CLASSES, CLASSIC_FOCUS_WITHIN_CLASSES, "relative block min-h-10 rounded-md"), wrapperClassName), children: /* @__PURE__ */ jsx4(
|
|
94
|
+
"input",
|
|
95
|
+
{
|
|
96
|
+
ref,
|
|
97
|
+
type,
|
|
98
|
+
className: cn(
|
|
99
|
+
"relative block h-full min-h-10 w-full rounded-md border-0 bg-transparent px-3 py-2 text-sm text-[var(--chalk-app-text,var(--chalk-text))] outline-none placeholder:text-[var(--chalk-app-text-muted,var(--chalk-muted-text))] disabled:cursor-not-allowed disabled:opacity-60",
|
|
100
|
+
className
|
|
101
|
+
),
|
|
102
|
+
style,
|
|
103
|
+
...props
|
|
104
|
+
}
|
|
105
|
+
) });
|
|
106
|
+
});
|
|
107
|
+
ChalkInput.displayName = "ChalkInput";
|
|
108
|
+
|
|
109
|
+
// src/components/chalk-ui/ChalkTextarea.tsx
|
|
110
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
111
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
112
|
+
var ChalkTextarea = forwardRef5(function ChalkTextarea2({ className, wrapperClassName, tone = "neutral", style, ...props }, ref) {
|
|
113
|
+
return /* @__PURE__ */ jsx5("span", { className: cn(cn(CLASSIC_SURFACE_CLASSES, CLASSIC_FOCUS_WITHIN_CLASSES, "relative block min-h-24 rounded-md"), wrapperClassName), children: /* @__PURE__ */ jsx5(
|
|
114
|
+
"textarea",
|
|
115
|
+
{
|
|
116
|
+
ref,
|
|
117
|
+
className: cn(
|
|
118
|
+
"relative block min-h-24 w-full resize-y rounded-md border-0 bg-transparent px-3 py-2 text-sm leading-6 text-[var(--chalk-app-text,var(--chalk-text))] outline-none placeholder:text-[var(--chalk-app-text-muted,var(--chalk-muted-text))] disabled:cursor-not-allowed disabled:opacity-60",
|
|
119
|
+
className
|
|
120
|
+
),
|
|
121
|
+
style,
|
|
122
|
+
...props
|
|
123
|
+
}
|
|
124
|
+
) });
|
|
125
|
+
});
|
|
126
|
+
ChalkTextarea.displayName = "ChalkTextarea";
|
|
127
|
+
|
|
128
|
+
// src/components/chalk-ui/ChalkToggle.tsx
|
|
129
|
+
import { forwardRef as forwardRef6, useState } from "react";
|
|
130
|
+
import { jsx as jsx6, jsxs } from "react/jsx-runtime";
|
|
131
|
+
var ChalkToggle = forwardRef6(function ChalkToggle2({ className, children, pressed, defaultPressed = false, onPressedChange, onClick, tone = "success", type = "button", ...props }, ref) {
|
|
132
|
+
const [local, setLocal] = useState(defaultPressed);
|
|
133
|
+
const value = pressed ?? local;
|
|
134
|
+
return /* @__PURE__ */ jsxs(
|
|
135
|
+
"button",
|
|
136
|
+
{
|
|
137
|
+
ref,
|
|
138
|
+
type,
|
|
139
|
+
role: "switch",
|
|
140
|
+
"aria-checked": value,
|
|
141
|
+
"data-part": "switch",
|
|
142
|
+
"data-chalk-tone": tone,
|
|
143
|
+
className: cn("chalk-switch", className),
|
|
144
|
+
onClick: (event) => {
|
|
145
|
+
if (pressed === void 0) setLocal(!value);
|
|
146
|
+
onPressedChange?.(!value);
|
|
147
|
+
onClick?.(event);
|
|
148
|
+
},
|
|
149
|
+
...props,
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ jsx6("span", { "aria-hidden": "true" }),
|
|
152
|
+
children ? /* @__PURE__ */ jsx6("span", { className: "sr-only", children }) : null
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// src/components/chalk-ui/ChalkBadge.tsx
|
|
159
|
+
import { forwardRef as forwardRef7 } from "react";
|
|
160
|
+
import { Fragment, jsx as jsx7 } from "react/jsx-runtime";
|
|
161
|
+
var ChalkBadge = forwardRef7(function ChalkBadge2({ children, className, tone = "neutral", dot = false, count, max = 99, showZero = false, ...props }, ref) {
|
|
162
|
+
if (!showZero && count === 0 && !dot) return children ? /* @__PURE__ */ jsx7(Fragment, { children }) : null;
|
|
163
|
+
const content = dot ? null : count !== void 0 && count > max ? `${max}+` : count ?? children;
|
|
164
|
+
return /* @__PURE__ */ jsx7("span", { ref, className: cn(cn(classicToneSurfaceClasses(tone), "inline-flex min-h-6 min-w-6 items-center justify-center rounded-full px-2 text-xs font-semibold"), dot && "size-3 min-h-0 min-w-0 p-0", className), "data-chalk-tone": tone, ...props, children: content === null ? null : /* @__PURE__ */ jsx7("span", { className: "relative z-[1]", children: content }) });
|
|
165
|
+
});
|
|
166
|
+
ChalkBadge.displayName = "ChalkBadge";
|
|
167
|
+
|
|
168
|
+
// src/components/chalk-ui/ChalkDivider.tsx
|
|
169
|
+
import { forwardRef as forwardRef8 } from "react";
|
|
170
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
171
|
+
var ChalkDivider = forwardRef8(function ChalkDivider2({ className, tone = "neutral", ...props }, ref) {
|
|
172
|
+
return /* @__PURE__ */ jsx8("div", { className: cn("relative my-3 h-3 w-full", className), "data-chalk-tone": tone, children: /* @__PURE__ */ jsx8("hr", { ref, className: cn("absolute inset-x-0 top-1/2 w-full -translate-y-1/2 border-0 border-t border-[var(--chalk-app-line,var(--chalk-line))]", className), ...props }) });
|
|
173
|
+
});
|
|
174
|
+
ChalkDivider.displayName = "ChalkDivider";
|
|
175
|
+
|
|
176
|
+
// src/components/chalk-ui/ChalkDialogPanel.tsx
|
|
177
|
+
import { forwardRef as forwardRef9 } from "react";
|
|
178
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
179
|
+
var ChalkDialogPanel = forwardRef9(function ChalkDialogPanel2({ children, className, role = "dialog", style, tone = "neutral", ...props }, ref) {
|
|
180
|
+
return /* @__PURE__ */ jsx9("div", { ref, className: cn(cn(CLASSIC_PANEL_CLASSES, "rounded-xl p-5 text-[var(--chalk-app-text,var(--chalk-text))] shadow-[var(--chalk-app-shadow-sm,var(--chalk-shadow))]"), className), role, style: { position: "relative", ...style }, ...props, children: /* @__PURE__ */ jsx9("div", { className: "relative z-[1]", children }) });
|
|
181
|
+
});
|
|
182
|
+
ChalkDialogPanel.displayName = "ChalkDialogPanel";
|
|
183
|
+
|
|
184
|
+
// src/components/chalk-ui/ChalkBackdrop.tsx
|
|
185
|
+
import { forwardRef as forwardRef10 } from "react";
|
|
186
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
187
|
+
var ChalkBackdrop = forwardRef10(function ChalkBackdrop2({ className, style, tone = "neutral", ...props }, ref) {
|
|
188
|
+
return /* @__PURE__ */ jsx10("div", { ref, "aria-hidden": "true", className: cn("pointer-events-auto fixed inset-0 bg-[var(--chalk-app-canvas,var(--chalk-canvas))]/75", className), style: { position: "fixed", ...style }, ...props });
|
|
189
|
+
});
|
|
190
|
+
ChalkBackdrop.displayName = "ChalkBackdrop";
|
|
191
|
+
|
|
192
|
+
// src/components/chalk-ui/ChalkAlert.tsx
|
|
193
|
+
import { forwardRef as forwardRef11 } from "react";
|
|
194
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
195
|
+
var ChalkAlert = forwardRef11(function ChalkAlert2({ children, className, style, tone = "danger", role = "alert", ...props }, ref) {
|
|
196
|
+
return /* @__PURE__ */ jsx11("div", { ref, className: cn(cn(CLASSIC_PANEL_CLASSES, classicTonePanelClasses(tone), "rounded-lg px-4 py-3 text-sm shadow-[var(--chalk-app-shadow-sm,var(--chalk-shadow))]"), className), role, style: { position: "relative", ...style }, ...props, children: /* @__PURE__ */ jsx11("div", { className: "relative z-[1]", children }) });
|
|
197
|
+
});
|
|
198
|
+
ChalkAlert.displayName = "ChalkAlert";
|
|
199
|
+
|
|
200
|
+
// src/components/chalk-ui/ChalkEmptyState.tsx
|
|
201
|
+
import { forwardRef as forwardRef12 } from "react";
|
|
202
|
+
import { jsx as jsx12, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
203
|
+
var ChalkEmptyState = forwardRef12(function ChalkEmptyState2({ children, className, description, style, title, tone = "neutral", role = "status", ...props }, ref) {
|
|
204
|
+
return /* @__PURE__ */ jsx12("div", { ref, className: cn(cn(CLASSIC_PANEL_CLASSES, "rounded-xl px-6 py-10 text-center text-[var(--chalk-app-text,var(--chalk-text))]"), className), role, style: { position: "relative", ...style }, ...props, children: /* @__PURE__ */ jsxs2("div", { className: "relative z-[1]", children: [
|
|
205
|
+
title ? /* @__PURE__ */ jsx12("h2", { className: "text-base font-semibold", children: title }) : null,
|
|
206
|
+
description ? /* @__PURE__ */ jsx12("p", { className: cn("mt-2 text-sm", "text-[var(--chalk-app-text-muted,var(--chalk-muted-text))]"), children: description }) : null,
|
|
207
|
+
children
|
|
208
|
+
] }) });
|
|
209
|
+
});
|
|
210
|
+
ChalkEmptyState.displayName = "ChalkEmptyState";
|
|
211
|
+
|
|
212
|
+
// src/components/chalk-ui/ChalkSpinner.tsx
|
|
213
|
+
import { forwardRef as forwardRef13 } from "react";
|
|
214
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
215
|
+
var ChalkSpinner = forwardRef13(function ChalkSpinner2({ className, label = "Loading", style, tone = "accent", ...props }, ref) {
|
|
216
|
+
return /* @__PURE__ */ jsx13("span", { ref, "aria-label": label, className: cn("motion-safe:animate-spin inline-block size-6 rounded-full border-2 border-[var(--chalk-app-line,var(--chalk-line))] border-t-[var(--chalk-app-control-active-line,var(--chalk-accent))]", className), role: "status", style, ...props });
|
|
217
|
+
});
|
|
218
|
+
ChalkSpinner.displayName = "ChalkSpinner";
|
|
219
|
+
|
|
220
|
+
// src/components/chalk-ui/ChalkSegmentedControl.tsx
|
|
221
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
222
|
+
function ChalkSegmentedControl({
|
|
223
|
+
label,
|
|
224
|
+
value,
|
|
225
|
+
options,
|
|
226
|
+
onValueChange,
|
|
227
|
+
size = "default"
|
|
228
|
+
}) {
|
|
229
|
+
const move = (event) => {
|
|
230
|
+
const delta = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
|
|
231
|
+
if (!delta && event.key !== "Home" && event.key !== "End") return;
|
|
232
|
+
event.preventDefault();
|
|
233
|
+
const index = event.key === "Home" ? 0 : event.key === "End" ? options.length - 1 : (options.findIndex((option) => option.value === value) + delta + options.length) % options.length;
|
|
234
|
+
const next = options[index];
|
|
235
|
+
if (next) {
|
|
236
|
+
onValueChange(next.value);
|
|
237
|
+
event.currentTarget.querySelectorAll("button")[index]?.focus();
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
return /* @__PURE__ */ jsx14("div", { "data-part": "segmented-control", "data-size": size, role: "group", "aria-label": label, className: "chalk-segmented", onKeyDown: move, children: options.map((option) => /* @__PURE__ */ jsx14("button", { "data-part": "segment", type: "button", "aria-pressed": value === option.value, tabIndex: value === option.value ? 0 : -1, onClick: () => onValueChange(option.value), children: option.label }, option.value)) });
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// src/components/chalk-ui/useCopyText.ts
|
|
244
|
+
import { useEffect, useRef, useState as useState2 } from "react";
|
|
245
|
+
var COPIED_MS = 2e3;
|
|
246
|
+
function useCopyText(text) {
|
|
247
|
+
const [copied, setCopied] = useState2(false);
|
|
248
|
+
const [error, setError] = useState2(false);
|
|
249
|
+
const timer = useRef(void 0);
|
|
250
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
251
|
+
const copy = async () => {
|
|
252
|
+
try {
|
|
253
|
+
await navigator.clipboard.writeText(text);
|
|
254
|
+
setCopied(true);
|
|
255
|
+
setError(false);
|
|
256
|
+
clearTimeout(timer.current);
|
|
257
|
+
timer.current = setTimeout(() => setCopied(false), COPIED_MS);
|
|
258
|
+
} catch {
|
|
259
|
+
setError(true);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
return { copied, error, copy };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/components/chalk-ui/ChalkCopyButton.tsx
|
|
266
|
+
import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
267
|
+
function ChalkCopyButton({ text, label = "Copy link", announcement = "Link copied", showLabel = false }) {
|
|
268
|
+
const { copied, error, copy } = useCopyText(text);
|
|
269
|
+
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
270
|
+
/* @__PURE__ */ jsxs3("button", { type: "button", "aria-label": label, "data-part": "copy-button", "data-copied": copied, className: "chalk-copy", onClick: () => void copy(), children: [
|
|
271
|
+
/* @__PURE__ */ jsxs3("span", { "data-part": "copy-icon", className: cn("chalk-copy-icon", copied && "chalk-copied"), "aria-hidden": "true", children: [
|
|
272
|
+
/* @__PURE__ */ jsxs3("svg", { className: "chalk-copy-source", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
273
|
+
/* @__PURE__ */ jsx15("rect", { x: "9", y: "9", width: "12", height: "12", rx: "2" }),
|
|
274
|
+
/* @__PURE__ */ jsx15("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
275
|
+
] }),
|
|
276
|
+
/* @__PURE__ */ jsx15("svg", { className: "chalk-copy-check", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx15("path", { d: "M20 6L9 17l-5-5" }) })
|
|
277
|
+
] }),
|
|
278
|
+
showLabel ? /* @__PURE__ */ jsx15("span", { className: "chalk-copy-label", children: label }) : null
|
|
279
|
+
] }),
|
|
280
|
+
/* @__PURE__ */ jsx15("span", { role: "status", "aria-live": "polite", className: "sr-only", children: error ? "Could not copy. Try again." : copied ? announcement : "" })
|
|
281
|
+
] });
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// src/internal/useHaptics.ts
|
|
285
|
+
var vibrationPattern = {
|
|
286
|
+
light: 8,
|
|
287
|
+
medium: 16,
|
|
288
|
+
heavy: 28,
|
|
289
|
+
soft: 6,
|
|
290
|
+
selection: 10,
|
|
291
|
+
success: [8, 24, 8],
|
|
292
|
+
warning: [16, 32, 16],
|
|
293
|
+
error: [30, 24, 30]
|
|
294
|
+
};
|
|
295
|
+
function useHaptics({ enabled = true } = {}) {
|
|
296
|
+
const isSupported = typeof navigator !== "undefined" && typeof navigator.vibrate === "function";
|
|
297
|
+
return {
|
|
298
|
+
isSupported,
|
|
299
|
+
trigger: async (pattern = "selection") => {
|
|
300
|
+
if (!enabled || !isSupported) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
navigator.vibrate(vibrationPattern[pattern]);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// src/components/chalk-ui/ChalkSheet.tsx
|
|
309
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
310
|
+
import { useCallback as useCallback2, useLayoutEffect, useRef as useRef3, useState as useState3 } from "react";
|
|
311
|
+
|
|
312
|
+
// src/components/chalk-ui/useSheetDrag.ts
|
|
313
|
+
import { useRef as useRef2 } from "react";
|
|
314
|
+
|
|
315
|
+
// src/components/chalk-ui/sheet-drag.ts
|
|
316
|
+
var SHEET_CLOSE_FRACTION = 0.3;
|
|
317
|
+
var SHEET_FLICK_SPEED = 0.5;
|
|
318
|
+
var SHEET_RUBBER_BAND = 0.3;
|
|
319
|
+
var SHEET_SETTLE_MS = 240;
|
|
320
|
+
var SPEED_WINDOW_MS = 100;
|
|
321
|
+
function sheetOffset(travel) {
|
|
322
|
+
return travel < 0 ? travel * SHEET_RUBBER_BAND : travel;
|
|
323
|
+
}
|
|
324
|
+
function releaseSpeed(samples) {
|
|
325
|
+
const last = samples.at(-1);
|
|
326
|
+
const first = samples.find((sample) => last !== void 0 && last.time - sample.time <= SPEED_WINDOW_MS);
|
|
327
|
+
if (!last || !first || last.time === first.time) return 0;
|
|
328
|
+
return (last.y - first.y) / (last.time - first.time);
|
|
329
|
+
}
|
|
330
|
+
function shouldDismiss(offset, sheetHeight, speed) {
|
|
331
|
+
return offset > sheetHeight * SHEET_CLOSE_FRACTION || speed > SHEET_FLICK_SPEED;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/components/chalk-ui/useSheetDrag.ts
|
|
335
|
+
function useSheetDrag(sheet, scrim, dismiss) {
|
|
336
|
+
const drag = useRef2(null);
|
|
337
|
+
const reducedMotion = usePrefersReducedMotion();
|
|
338
|
+
const { trigger } = useHaptics();
|
|
339
|
+
const settle = (closing) => {
|
|
340
|
+
const element = sheet.current;
|
|
341
|
+
if (!element) return;
|
|
342
|
+
element.style.transition = reducedMotion ? "none" : `transform ${SHEET_SETTLE_MS}ms var(--chalk-ease-out-expo)`;
|
|
343
|
+
element.style.transform = closing ? "translateY(100%)" : "";
|
|
344
|
+
if (scrim.current) scrim.current.style.opacity = closing ? "0" : "";
|
|
345
|
+
if (closing) {
|
|
346
|
+
void trigger("success");
|
|
347
|
+
dismiss();
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
window.setTimeout(
|
|
351
|
+
() => {
|
|
352
|
+
element.style.transition = "";
|
|
353
|
+
},
|
|
354
|
+
reducedMotion ? 0 : SHEET_SETTLE_MS
|
|
355
|
+
);
|
|
356
|
+
};
|
|
357
|
+
const start = (event) => {
|
|
358
|
+
const element = sheet.current;
|
|
359
|
+
if (!element || event.button !== 0 || event.target instanceof Element && event.target.closest("button, a, input")) return;
|
|
360
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
361
|
+
drag.current = { pointerId: event.pointerId, startY: event.clientY, height: element.getBoundingClientRect().height, samples: [{ time: event.timeStamp, y: event.clientY }], offset: 0 };
|
|
362
|
+
};
|
|
363
|
+
const move = (event) => {
|
|
364
|
+
const current = drag.current;
|
|
365
|
+
const element = sheet.current;
|
|
366
|
+
if (!current || !element || event.pointerId !== current.pointerId) return;
|
|
367
|
+
current.offset = sheetOffset(event.clientY - current.startY);
|
|
368
|
+
current.samples.push({ time: event.timeStamp, y: event.clientY });
|
|
369
|
+
element.style.transition = "none";
|
|
370
|
+
element.style.transform = `translateY(${current.offset}px)`;
|
|
371
|
+
if (scrim.current) scrim.current.style.opacity = String(Math.max(0, 1 - Math.max(0, current.offset) / current.height));
|
|
372
|
+
};
|
|
373
|
+
const end = (event) => {
|
|
374
|
+
const current = drag.current;
|
|
375
|
+
if (!current || event.pointerId !== current.pointerId) return;
|
|
376
|
+
drag.current = null;
|
|
377
|
+
current.samples.push({ time: event.timeStamp, y: event.clientY });
|
|
378
|
+
settle(event.type === "pointerup" && shouldDismiss(current.offset, current.height, releaseSpeed(current.samples)));
|
|
379
|
+
};
|
|
380
|
+
return { onPointerDown: start, onPointerMove: move, onPointerUp: end, onPointerCancel: end };
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// src/components/chalk-ui/ChalkSheet.tsx
|
|
384
|
+
import { jsx as jsx16, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
385
|
+
function ChalkSheet({ open, onOpenChange, title, accessibleLabel, children, variant = "default" }) {
|
|
386
|
+
const [container, setContainer] = useState3(null);
|
|
387
|
+
const popup = useRef3(null);
|
|
388
|
+
const scrim = useRef3(null);
|
|
389
|
+
const drag = useSheetDrag(popup, scrim, () => onOpenChange(false));
|
|
390
|
+
useLayoutEffect(() => {
|
|
391
|
+
if (!open) return;
|
|
392
|
+
if (popup.current) {
|
|
393
|
+
popup.current.style.transform = "";
|
|
394
|
+
popup.current.style.transition = "";
|
|
395
|
+
}
|
|
396
|
+
if (scrim.current) scrim.current.style.opacity = "";
|
|
397
|
+
}, [open]);
|
|
398
|
+
const attach = useCallback2((element) => setContainer(element?.closest("[data-chalk]") ?? element), []);
|
|
399
|
+
return /* @__PURE__ */ jsx16("span", { ref: attach, style: { display: "contents" }, children: /* @__PURE__ */ jsx16(
|
|
400
|
+
Dialog.Root,
|
|
401
|
+
{
|
|
402
|
+
open,
|
|
403
|
+
onOpenChange: (next, details) => {
|
|
404
|
+
const reached = details.event instanceof FocusEvent ? details.event.relatedTarget : details.event.target;
|
|
405
|
+
if (variant === "reactions" && (details.reason === "outside-press" || details.reason === "focus-out") && reached instanceof Element && reached.closest(".chalk-toasts")) {
|
|
406
|
+
details.cancel();
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
onOpenChange(next);
|
|
410
|
+
},
|
|
411
|
+
modal: variant !== "reactions",
|
|
412
|
+
children: container ? /* @__PURE__ */ jsxs4(Dialog.Portal, { container, children: [
|
|
413
|
+
variant === "reactions" ? null : /* @__PURE__ */ jsx16(Dialog.Backdrop, { ref: scrim, "data-part": "sheet-scrim", className: "chalk-sheet-scrim" }),
|
|
414
|
+
/* @__PURE__ */ jsxs4(
|
|
415
|
+
Dialog.Popup,
|
|
416
|
+
{
|
|
417
|
+
ref: popup,
|
|
418
|
+
...accessibleLabel ? { "aria-label": accessibleLabel, "aria-labelledby": void 0 } : {},
|
|
419
|
+
initialFocus: variant === "ready" ? () => container.querySelector("[data-part=ready-title]") : void 0,
|
|
420
|
+
finalFocus: variant === "ready" ? () => container.querySelector("[data-call-link-trigger]") : void 0,
|
|
421
|
+
"data-part": variant === "ready" ? "call-ready" : variant === "panel" ? "panel-card" : "sheet",
|
|
422
|
+
"data-variant": variant,
|
|
423
|
+
className: variant === "ready" ? "chalk-sheet data-[starting-style]:!translate-y-8 data-[ending-style]:!translate-y-8" : "chalk-sheet",
|
|
424
|
+
style: variant === "ready" ? { padding: "0 var(--space-5) var(--space-12)", borderTop: "1px solid var(--chalk-line)", transitionDuration: "200ms" } : void 0,
|
|
425
|
+
children: [
|
|
426
|
+
/* @__PURE__ */ jsx16("div", { "data-part": "sheet-handle", "data-sheet-drag": true, className: "chalk-sheet-handle", ...drag }),
|
|
427
|
+
variant !== "details" ? /* @__PURE__ */ jsx16(Dialog.Title, { className: "sr-only", children: title }) : /* @__PURE__ */ jsxs4("div", { "data-sheet-drag": true, className: "chalk-sheet-heading", ...drag, children: [
|
|
428
|
+
/* @__PURE__ */ jsx16(Dialog.Title, { children: title }),
|
|
429
|
+
/* @__PURE__ */ jsx16(Dialog.Close, { "data-part": "sheet-dismiss", className: "chalk-dismiss", "aria-label": "Close", children: /* @__PURE__ */ jsx16("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx16("path", { d: "m6 6 12 12M6 18 18 6" }) }) })
|
|
430
|
+
] }),
|
|
431
|
+
variant === "default" || variant === "details" || variant === "reactions" ? /* @__PURE__ */ jsx16("div", { className: "chalk-sheet-body", children }) : children
|
|
432
|
+
]
|
|
433
|
+
}
|
|
434
|
+
)
|
|
435
|
+
] }) : null
|
|
436
|
+
}
|
|
437
|
+
) });
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// src/components/chalk-ui/index.ts
|
|
441
|
+
import { ChalkMenu, ChalkMenuItem } from "@q9labsai/chalk-whiteboard/react";
|
|
442
|
+
import { ChalkMenuLabel } from "@q9labsai/chalk-whiteboard/react";
|
|
443
|
+
import { ChalkPopover } from "@q9labsai/chalk-whiteboard/react";
|
|
444
|
+
import { ChalkTooltip } from "@q9labsai/chalk-whiteboard/react";
|
|
445
|
+
import { ChalkMenuPrimitive, ChalkPopoverPrimitive } from "@q9labsai/chalk-whiteboard/react";
|
|
446
|
+
|
|
447
|
+
export {
|
|
448
|
+
useMediaQuery,
|
|
449
|
+
useIsMobile,
|
|
450
|
+
usePrefersReducedMotion,
|
|
451
|
+
ChalkButton,
|
|
452
|
+
ChalkIconButton,
|
|
453
|
+
ChalkPanel,
|
|
454
|
+
ChalkInput,
|
|
455
|
+
ChalkTextarea,
|
|
456
|
+
ChalkToggle,
|
|
457
|
+
ChalkBadge,
|
|
458
|
+
ChalkDivider,
|
|
459
|
+
ChalkDialogPanel,
|
|
460
|
+
ChalkBackdrop,
|
|
461
|
+
ChalkAlert,
|
|
462
|
+
ChalkEmptyState,
|
|
463
|
+
ChalkSpinner,
|
|
464
|
+
ChalkSegmentedControl,
|
|
465
|
+
useCopyText,
|
|
466
|
+
ChalkCopyButton,
|
|
467
|
+
useHaptics,
|
|
468
|
+
ChalkSheet,
|
|
469
|
+
ChalkMenu,
|
|
470
|
+
ChalkMenuItem,
|
|
471
|
+
ChalkMenuLabel,
|
|
472
|
+
ChalkPopover,
|
|
473
|
+
ChalkTooltip,
|
|
474
|
+
ChalkMenuPrimitive,
|
|
475
|
+
ChalkPopoverPrimitive
|
|
476
|
+
};
|