@asanchez-sa/abby 0.2.0 → 0.4.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/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +2 -1
- package/dist/components/alert-dialog/alert-dialog.d.ts +10 -1
- package/dist/components/alert-dialog/alert-dialog.js +80 -3
- package/dist/components/badge/badge.d.ts +3 -2
- package/dist/components/badge/badge.js +27 -11
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +3 -2
- package/dist/components/calendar/calendar.d.ts +26 -5
- package/dist/components/calendar/calendar.js +387 -72
- package/dist/components/chart/chart.d.ts +76 -0
- package/dist/components/chart/chart.js +565 -0
- package/dist/components/chart/parts/axes.js +126 -0
- package/dist/components/chart/parts/frame.d.ts +31 -0
- package/dist/components/chart/parts/frame.js +278 -0
- package/dist/components/chart/parts/legend.d.ts +16 -0
- package/dist/components/chart/parts/legend.js +82 -0
- package/dist/components/chart/parts/points.d.ts +1 -0
- package/dist/components/chart/parts/points.js +139 -0
- package/dist/components/chart/parts/scale.js +139 -0
- package/dist/components/chart/parts/table.js +105 -0
- package/dist/components/chart/parts/types.d.ts +44 -0
- package/dist/components/chart/parts/types.js +8 -0
- package/dist/components/dialog/dialog.d.ts +9 -1
- package/dist/components/dialog/dialog.js +82 -3
- package/dist/components/field/field.d.ts +5 -1
- package/dist/components/field/field.js +25 -21
- package/dist/components/filter-chip/filter-chip.d.ts +36 -0
- package/dist/components/filter-chip/filter-chip.js +97 -0
- package/dist/components/graph/graph.d.ts +151 -0
- package/dist/components/graph/graph.js +959 -0
- package/dist/components/input/input.d.ts +8 -1
- package/dist/components/input/input.js +2 -2
- package/dist/components/meter/meter.d.ts +52 -3
- package/dist/components/meter/meter.js +535 -33
- package/dist/components/model-selector/model-selector.d.ts +38 -3
- package/dist/components/model-selector/model-selector.js +331 -73
- package/dist/components/note-editor/parts/suggestions.js +2 -2
- package/dist/components/number-input/number-input.d.ts +14 -3
- package/dist/components/number-input/number-input.js +193 -34
- package/dist/components/otp-input/otp-input.d.ts +6 -2
- package/dist/components/otp-input/otp-input.js +40 -20
- package/dist/components/sheet/sheet.js +1 -1
- package/dist/components/spinner/spinner.d.ts +7 -1
- package/dist/components/spinner/spinner.js +86 -26
- package/dist/components/switch/switch.d.ts +9 -2
- package/dist/components/switch/switch.js +23 -17
- package/dist/components/toast/toast.d.ts +19 -2
- package/dist/components/toast/toast.js +211 -49
- package/dist/components/toggle/toggle.d.ts +18 -4
- package/dist/components/toggle/toggle.js +167 -32
- package/dist/components/week-strip/week-strip.d.ts +27 -5
- package/dist/components/week-strip/week-strip.js +288 -134
- package/package.json +4 -1
- package/skills/agent-ready-ui/SKILL.md +1 -1
- package/skills/blocks/SKILL.md +1 -1
- package/skills/compose-screens/SKILL.md +97 -10
- package/skills/compose-screens/references/calendar-week.md +77 -0
- package/skills/compose-screens/references/charts-and-maps.md +183 -0
- package/skills/compose-screens/references/filter-chips.md +61 -0
- package/skills/compose-screens/references/number-units.md +52 -0
- package/skills/note-editor/SKILL.md +1 -1
- package/skills/note-status/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ButtonLook } from "../button/button.js";
|
|
2
2
|
import { ComponentProps } from "react";
|
|
3
3
|
import { Toast as Toast$1, ToastAction as ToastAction$1, ToastActionData, ToastActionDetails, ToastButtonState, ToastCancel, ToastClose as ToastClose$1, ToastData, ToastDescription as ToastDescription$1, ToastDismissDetails, ToastDismissReason, ToastItem, ToastOptions, ToastPauseReason, ToastRegionOptions, ToastRegionProps, ToastRegionState, ToastState, ToastTitle as ToastTitle$1, ToastType, Toaster, createToaster, toast } from "@ui-sdk/react/toast";
|
|
4
|
-
declare function ToastRegion({ className, children, render, ...props }: ToastRegionProps): import("react").JSX.Element;
|
|
4
|
+
declare function ToastRegion({ className, children, render, toaster, ref, ...props }: ToastRegionProps): import("react").JSX.Element;
|
|
5
5
|
declare function Toast({ className, ...props }: ComponentProps<typeof Toast$1>): import("react").JSX.Element;
|
|
6
6
|
declare function ToastTitle({ className, ...props }: ComponentProps<typeof ToastTitle$1>): import("react").JSX.Element;
|
|
7
7
|
declare function ToastDescription({ className, ...props }: ComponentProps<typeof ToastDescription$1>): import("react").JSX.Element;
|
|
@@ -9,4 +9,21 @@ type ToastActionProps = ComponentProps<typeof ToastAction$1> & ButtonLook;
|
|
|
9
9
|
declare function ToastAction({ variant, size, className, ...props }: ToastActionProps): import("react").JSX.Element;
|
|
10
10
|
type ToastCloseProps = ComponentProps<typeof ToastClose$1> & ButtonLook;
|
|
11
11
|
declare function ToastClose({ variant, size, className, children, ...props }: ToastCloseProps): import("react").JSX.Element;
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A thin bar on the toast's bottom edge that empties over the toast's
|
|
14
|
+
* `duration`, so a person sees how long an Undo is left. Compose it inside
|
|
15
|
+
* `Toast`, in the children of `ToastRegion`. It draws nothing for a toast that
|
|
16
|
+
* never closes (`duration: Infinity`) or is `loading`, and it stays full under
|
|
17
|
+
* reduced motion.
|
|
18
|
+
*
|
|
19
|
+
* It follows ui-sdk's timer: it pauses while the pointer (not a touch) or
|
|
20
|
+
* focus is in the region, a toast is swiped, the page is hidden, the window
|
|
21
|
+
* is inactive or the toast's action is pending; an update starts it over, and
|
|
22
|
+
* a toast hidden past `maxVisible` goes on where it stopped. Two pauses leave
|
|
23
|
+
* no trace a part can read, so the bar doesn't follow them: an `onDismiss`
|
|
24
|
+
* that cancels the timeout keeps the toast and starts ui-sdk's timer over
|
|
25
|
+
* while the bar stays empty, and a `pause()` an agent calls on the region
|
|
26
|
+
* holds the toast while the bar runs on.
|
|
27
|
+
*/
|
|
28
|
+
declare function ToastProgress({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element | null;
|
|
29
|
+
export { Toast, ToastAction, type ToastActionData, type ToastActionDetails, type ToastActionProps, type ToastButtonState, type ToastCancel, ToastClose, type ToastCloseProps, type ToastData, ToastDescription, type ToastDismissDetails, type ToastDismissReason, type ToastItem, type ToastOptions, type ToastPauseReason, ToastProgress, ToastRegion, type ToastRegionOptions, type ToastRegionProps, type ToastRegionState, type ToastState, ToastTitle, type ToastType, type Toaster, createToaster, toast };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { mergeProps } from "../../core/ui-sdk.js";
|
|
3
|
+
import "../../core/index.js";
|
|
2
4
|
import { cn, cnState } from "../../utilities/cn/index.js";
|
|
3
5
|
import { buttonLook } from "../button/button.js";
|
|
4
6
|
import { Icon } from "../icon/icon.js";
|
|
5
7
|
import { c } from "react/compiler-runtime";
|
|
8
|
+
import { createContext, use, useState } from "react";
|
|
6
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
10
|
import { Alert02Icon, Cancel01Icon, CheckmarkCircle02Icon, InformationCircleIcon, Loading03Icon, MultiplicationSignCircleIcon } from "@hugeicons/core-free-icons";
|
|
8
11
|
import { Toast as Toast$1, ToastAction as ToastAction$1, ToastClose as ToastClose$1, ToastDescription as ToastDescription$1, ToastRegion as ToastRegion$1, ToastTitle as ToastTitle$1, createToaster, toast } from "@ui-sdk/react/toast";
|
|
@@ -33,58 +36,104 @@ function defaultToast(item) {
|
|
|
33
36
|
/* @__PURE__ */ jsx(ToastAction, {})
|
|
34
37
|
] });
|
|
35
38
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
39
|
+
const ToastScope = createContext(null);
|
|
40
|
+
function watchRegion() {
|
|
41
|
+
const reasons = /* @__PURE__ */ new Set();
|
|
42
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
43
|
+
const stopped = /* @__PURE__ */ new Map();
|
|
44
|
+
const hold = (reason, on) => {
|
|
45
|
+
if (on === reasons.has(reason)) return;
|
|
46
|
+
if (on) reasons.add(reason);
|
|
47
|
+
else reasons.delete(reason);
|
|
48
|
+
listeners.forEach((listener) => listener());
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
paused: () => reasons.size > 0,
|
|
52
|
+
subscribe(listener) {
|
|
53
|
+
listeners.add(listener);
|
|
54
|
+
return () => void listeners.delete(listener);
|
|
55
|
+
},
|
|
56
|
+
/** Keeps where a bar stopped while its toast is still in the queue. */
|
|
57
|
+
stop(key, time, toaster) {
|
|
58
|
+
const queued = new Set(toaster.toasts().map((toast) => `${toast.id}:${toast.version}`));
|
|
59
|
+
for (const old of stopped.keys()) if (!queued.has(old)) stopped.delete(old);
|
|
60
|
+
if (queued.has(key)) stopped.set(key, time);
|
|
61
|
+
},
|
|
62
|
+
/** Where the bar of a toast that shows again goes on from. */
|
|
63
|
+
resume(key) {
|
|
64
|
+
const time = stopped.get(key);
|
|
65
|
+
stopped.delete(key);
|
|
66
|
+
return time;
|
|
67
|
+
},
|
|
68
|
+
/** The region element's ref: listens while it's on the page. */
|
|
69
|
+
attach: (region) => {
|
|
70
|
+
const doc = region.ownerDocument;
|
|
71
|
+
const view = doc.defaultView ?? window;
|
|
72
|
+
const offs = [];
|
|
73
|
+
const listen = (target, type, handler) => {
|
|
74
|
+
target.addEventListener(type, handler);
|
|
75
|
+
offs.push(() => target.removeEventListener(type, handler));
|
|
76
|
+
};
|
|
77
|
+
listen(region, "pointerenter", (e) => {
|
|
78
|
+
if (e.pointerType !== "touch") hold("item-hover", true);
|
|
79
|
+
});
|
|
80
|
+
listen(region, "pointerleave", (e) => {
|
|
81
|
+
if (e.pointerType !== "touch") hold("item-hover", false);
|
|
82
|
+
});
|
|
83
|
+
listen(region, "focusin", () => hold("focus-in", true));
|
|
84
|
+
listen(region, "focusout", (e) => {
|
|
85
|
+
const to = e.relatedTarget;
|
|
86
|
+
if (to) {
|
|
87
|
+
if (!region.contains(to)) hold("focus-in", false);
|
|
88
|
+
} else queueMicrotask(() => {
|
|
89
|
+
if (!doc.hasFocus() || !region.contains(doc.activeElement)) hold("focus-in", false);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
listen(view, "blur", () => setTimeout(() => doc.activeElement?.tagName !== "IFRAME" && hold("window-blur", true)));
|
|
93
|
+
listen(view, "focus", () => hold("window-blur", false));
|
|
94
|
+
listen(doc, "visibilitychange", () => hold("page-hide", doc.visibilityState === "hidden"));
|
|
95
|
+
hold("page-hide", doc.visibilityState === "hidden");
|
|
96
|
+
const swiping = () => hold("swipe", !!region.querySelector("[data-swiping]"));
|
|
97
|
+
const swipes = new MutationObserver(swiping);
|
|
98
|
+
swipes.observe(region, {
|
|
99
|
+
subtree: true,
|
|
100
|
+
attributeFilter: ["data-swiping"]
|
|
101
|
+
});
|
|
102
|
+
offs.push(() => swipes.disconnect());
|
|
103
|
+
swiping();
|
|
104
|
+
return () => {
|
|
105
|
+
offs.forEach((off) => off());
|
|
106
|
+
for (const reason of reasons) hold(reason, false);
|
|
107
|
+
stopped.clear();
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function ToastRegion({ className, children = defaultToast, render, toaster = toast, ref, ...props }) {
|
|
113
|
+
const [pauses] = useState(watchRegion);
|
|
114
|
+
return /* @__PURE__ */ jsx(ToastRegion$1, {
|
|
115
|
+
ref: mergeProps({ ref: pauses.attach }, { ref }).ref,
|
|
116
|
+
toaster,
|
|
117
|
+
render: render ?? ((regionProps, state) => /* @__PURE__ */ jsx("section", {
|
|
118
|
+
...regionProps,
|
|
119
|
+
"data-agent-hidden": state.toasts.length === 0 ? "" : void 0
|
|
120
|
+
})),
|
|
121
|
+
className: cnState([
|
|
60
122
|
"fixed inset-auto m-4 h-(--toast-front-height) w-89 max-w-[calc(100vw-2rem)] overflow-visible border-0 bg-transparent p-0",
|
|
61
123
|
"data-expanded:h-[calc(var(--toast-stack-height)+(var(--toast-count)-1)*0.75rem)]",
|
|
62
124
|
"data-[side=bottom]:bottom-0 data-[side=top]:top-0",
|
|
63
125
|
"data-[align=start]:start-0 data-[align=end]:end-0 data-[align=center]:left-1/2 data-[align=center]:mx-0 data-[align=center]:-translate-x-1/2"
|
|
64
|
-
], className)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
$[7] = children;
|
|
77
|
-
$[8] = props;
|
|
78
|
-
$[9] = t2;
|
|
79
|
-
$[10] = t3;
|
|
80
|
-
$[11] = t4;
|
|
81
|
-
} else t4 = $[11];
|
|
82
|
-
return t4;
|
|
83
|
-
}
|
|
84
|
-
function _temp(regionProps, state) {
|
|
85
|
-
return /* @__PURE__ */ jsx("section", {
|
|
86
|
-
...regionProps,
|
|
87
|
-
"data-agent-hidden": state.toasts.length === 0 ? "" : void 0
|
|
126
|
+
], className),
|
|
127
|
+
...props,
|
|
128
|
+
children: (item, entry) => /* @__PURE__ */ jsx(ToastScope, {
|
|
129
|
+
value: {
|
|
130
|
+
item,
|
|
131
|
+
entry,
|
|
132
|
+
pauses,
|
|
133
|
+
toaster
|
|
134
|
+
},
|
|
135
|
+
children: children(item, entry)
|
|
136
|
+
})
|
|
88
137
|
});
|
|
89
138
|
}
|
|
90
139
|
function Toast(t0) {
|
|
@@ -282,4 +331,117 @@ function ToastClose(t0) {
|
|
|
282
331
|
} else t3 = $[17];
|
|
283
332
|
return t3;
|
|
284
333
|
}
|
|
285
|
-
|
|
334
|
+
/**
|
|
335
|
+
* A thin bar on the toast's bottom edge that empties over the toast's
|
|
336
|
+
* `duration`, so a person sees how long an Undo is left. Compose it inside
|
|
337
|
+
* `Toast`, in the children of `ToastRegion`. It draws nothing for a toast that
|
|
338
|
+
* never closes (`duration: Infinity`) or is `loading`, and it stays full under
|
|
339
|
+
* reduced motion.
|
|
340
|
+
*
|
|
341
|
+
* It follows ui-sdk's timer: it pauses while the pointer (not a touch) or
|
|
342
|
+
* focus is in the region, a toast is swiped, the page is hidden, the window
|
|
343
|
+
* is inactive or the toast's action is pending; an update starts it over, and
|
|
344
|
+
* a toast hidden past `maxVisible` goes on where it stopped. Two pauses leave
|
|
345
|
+
* no trace a part can read, so the bar doesn't follow them: an `onDismiss`
|
|
346
|
+
* that cancels the timeout keeps the toast and starts ui-sdk's timer over
|
|
347
|
+
* while the bar stays empty, and a `pause()` an agent calls on the region
|
|
348
|
+
* holds the toast while the bar runs on.
|
|
349
|
+
*/
|
|
350
|
+
function ToastProgress(t0) {
|
|
351
|
+
const $ = c(19);
|
|
352
|
+
let className;
|
|
353
|
+
let props;
|
|
354
|
+
if ($[0] !== t0) {
|
|
355
|
+
({className, ...props} = t0);
|
|
356
|
+
$[0] = t0;
|
|
357
|
+
$[1] = className;
|
|
358
|
+
$[2] = props;
|
|
359
|
+
} else {
|
|
360
|
+
className = $[1];
|
|
361
|
+
props = $[2];
|
|
362
|
+
}
|
|
363
|
+
const scope = use(ToastScope);
|
|
364
|
+
if (!scope) return null;
|
|
365
|
+
const { item, entry, pauses, toaster } = scope;
|
|
366
|
+
if (!Number.isFinite(item.duration) || item.type === "loading") return null;
|
|
367
|
+
const { duration, id, version } = item;
|
|
368
|
+
const leaving = entry.leaving;
|
|
369
|
+
let t1;
|
|
370
|
+
if ($[3] !== className) {
|
|
371
|
+
t1 = cn("pointer-events-none absolute inset-x-0 bottom-0 h-0.5 bg-secondary", className);
|
|
372
|
+
$[3] = className;
|
|
373
|
+
$[4] = t1;
|
|
374
|
+
} else t1 = $[4];
|
|
375
|
+
const t2 = leaving ? "" : void 0;
|
|
376
|
+
let t3;
|
|
377
|
+
if ($[5] !== duration || $[6] !== id || $[7] !== pauses || $[8] !== toaster || $[9] !== version) {
|
|
378
|
+
t3 = (fill) => fill ? countDown(fill, duration, `${id}:${version}`, pauses, toaster) : void 0;
|
|
379
|
+
$[5] = duration;
|
|
380
|
+
$[6] = id;
|
|
381
|
+
$[7] = pauses;
|
|
382
|
+
$[8] = toaster;
|
|
383
|
+
$[9] = version;
|
|
384
|
+
$[10] = t3;
|
|
385
|
+
} else t3 = $[10];
|
|
386
|
+
let t4;
|
|
387
|
+
if ($[11] !== t2 || $[12] !== t3 || $[13] !== version) {
|
|
388
|
+
t4 = /* @__PURE__ */ jsx("div", {
|
|
389
|
+
"data-slot": "toast-progress-fill",
|
|
390
|
+
"data-leaving": t2,
|
|
391
|
+
className: "h-full origin-left bg-primary rtl:origin-right",
|
|
392
|
+
ref: t3
|
|
393
|
+
}, version);
|
|
394
|
+
$[11] = t2;
|
|
395
|
+
$[12] = t3;
|
|
396
|
+
$[13] = version;
|
|
397
|
+
$[14] = t4;
|
|
398
|
+
} else t4 = $[14];
|
|
399
|
+
let t5;
|
|
400
|
+
if ($[15] !== props || $[16] !== t1 || $[17] !== t4) {
|
|
401
|
+
t5 = /* @__PURE__ */ jsx("div", {
|
|
402
|
+
"aria-hidden": "true",
|
|
403
|
+
"data-slot": "toast-progress",
|
|
404
|
+
className: t1,
|
|
405
|
+
...props,
|
|
406
|
+
children: t4
|
|
407
|
+
});
|
|
408
|
+
$[15] = props;
|
|
409
|
+
$[16] = t1;
|
|
410
|
+
$[17] = t4;
|
|
411
|
+
$[18] = t5;
|
|
412
|
+
} else t5 = $[18];
|
|
413
|
+
return t5;
|
|
414
|
+
}
|
|
415
|
+
function countDown(fill, duration, key, pauses, toaster) {
|
|
416
|
+
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
|
417
|
+
const animation = fill.animate([{ scale: "1 1" }, { scale: "0 1" }], {
|
|
418
|
+
duration,
|
|
419
|
+
easing: "linear",
|
|
420
|
+
fill: "forwards"
|
|
421
|
+
});
|
|
422
|
+
const resumed = pauses.resume(key);
|
|
423
|
+
if (resumed !== void 0) animation.currentTime = resumed;
|
|
424
|
+
const root = fill.closest("[data-slot=\"toast\"]");
|
|
425
|
+
const held = () => !!root?.querySelector("[data-slot=\"toast-action\"][data-pending], [data-slot=\"toast-close\"][data-pending]");
|
|
426
|
+
const hidden = () => fill.hasAttribute("data-leaving") && toaster.toasts().some((toast) => `${toast.id}:${toast.version}` === key);
|
|
427
|
+
const sync = () => {
|
|
428
|
+
if (animation.playState === "finished") return;
|
|
429
|
+
if (pauses.paused() || held() || hidden()) animation.pause();
|
|
430
|
+
else if (animation.playState === "paused") animation.play();
|
|
431
|
+
};
|
|
432
|
+
const watcher = new MutationObserver(sync);
|
|
433
|
+
if (root) watcher.observe(root, {
|
|
434
|
+
subtree: true,
|
|
435
|
+
attributeFilter: ["data-pending"]
|
|
436
|
+
});
|
|
437
|
+
watcher.observe(fill, { attributeFilter: ["data-leaving"] });
|
|
438
|
+
const unsubscribe = pauses.subscribe(sync);
|
|
439
|
+
sync();
|
|
440
|
+
return () => {
|
|
441
|
+
unsubscribe();
|
|
442
|
+
watcher.disconnect();
|
|
443
|
+
if (hidden() && animation.playState === "paused") pauses.stop(key, Number(animation.currentTime ?? 0), toaster);
|
|
444
|
+
animation.cancel();
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
export { Toast, ToastAction, ToastClose, ToastDescription, ToastProgress, ToastRegion, ToastTitle, createToaster, toast };
|
|
@@ -2,14 +2,28 @@ import { VariantProps } from "../../utilities/cn/index.js";
|
|
|
2
2
|
import { ComponentProps } from "react";
|
|
3
3
|
import { Toggle as Toggle$1, ToggleGroup as ToggleGroup$1, ToggleIcon as ToggleIcon$1, createToggleController, createToggleGroupController } from "@ui-sdk/react/toggle";
|
|
4
4
|
declare const toggleVariants: (props?: ({
|
|
5
|
-
variant?: "default" | "outline" | null | undefined;
|
|
5
|
+
variant?: "chip" | "default" | "outline" | null | undefined;
|
|
6
6
|
size?: "default" | "lg" | "sm" | "xs" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
type ToggleProps = ComponentProps<typeof Toggle$1> & VariantProps<typeof toggleVariants>;
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* A toggle with only an icon needs an `aria-label`. `variant="chip"` is one
|
|
11
|
+
* choice in a row of filters: use `size="sm"` (28px) and a `ToggleGroup` with
|
|
12
|
+
* `deselectable={false}` so one always stays chosen.
|
|
13
|
+
*/
|
|
14
|
+
declare function Toggle({ variant, size, className, "aria-describedby": describedBy, ...props }: ToggleProps): import("react").JSX.Element;
|
|
15
|
+
type ToggleCountProps = Omit<ComponentProps<"span">, "children"> & {
|
|
16
|
+
/** The number, or text, shown after the name. */
|
|
17
|
+
children: string | number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* What a chip holds, after its name ("Payments 142"): small, in `subtle` and
|
|
21
|
+
* with tabular figures. It is `aria-hidden` and its text is the chip's
|
|
22
|
+
* description, so the chip's name stays its own.
|
|
23
|
+
*/
|
|
24
|
+
declare function ToggleCount({ className, children, ...props }: ToggleCountProps): import("react").JSX.Element;
|
|
11
25
|
declare function ToggleIcon({ className, ...props }: ComponentProps<typeof ToggleIcon$1>): import("react").JSX.Element;
|
|
12
26
|
type ToggleGroupProps<T extends string = string> = Parameters<typeof ToggleGroup$1<T>>[0];
|
|
13
27
|
/** Name it with `aria-label`, and give each toggle a `value`. */
|
|
14
28
|
declare function ToggleGroup<T extends string = string>({ className, ...props }: ToggleGroupProps<T>): import("react").JSX.Element;
|
|
15
|
-
export { Toggle, ToggleGroup, type ToggleGroupProps, ToggleIcon, type ToggleProps, createToggleController, createToggleGroupController, toggleVariants };
|
|
29
|
+
export { Toggle, ToggleCount, type ToggleCountProps, ToggleGroup, type ToggleGroupProps, ToggleIcon, type ToggleProps, createToggleController, createToggleGroupController, toggleVariants };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cnState, cva } from "../../utilities/cn/index.js";
|
|
2
|
+
import { cn, cnState, cva } from "../../utilities/cn/index.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
|
-
import {
|
|
4
|
+
import { createContext, useContext, useEffect, useId, useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { Toggle as Toggle$1, ToggleGroup as ToggleGroup$1, ToggleIcon as ToggleIcon$1, createToggleController, createToggleGroupController } from "@ui-sdk/react/toggle";
|
|
6
7
|
// src/components/toggle/toggle.tsx
|
|
7
8
|
const toggleVariants = cva("inline-flex items-center justify-center gap-1.5 rounded-full text-sm font-medium whitespace-nowrap text-foreground select-none press hover:bg-accent focus-ring data-disabled:pointer-events-none data-disabled:opacity-50 data-[orientation=vertical]:justify-start data-pressed:bg-primary data-pressed:text-primary-foreground data-pressed:hover:bg-primary/85 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
8
9
|
variants: {
|
|
9
10
|
variant: {
|
|
10
11
|
default: "bg-transparent",
|
|
11
|
-
outline: "border border-input bg-background data-pressed:border-primary"
|
|
12
|
+
outline: "border border-input bg-background data-pressed:border-primary",
|
|
13
|
+
chip: "group/toggle border border-transparent bg-transparent font-normal text-muted-foreground data-pressed:border-input data-pressed:bg-background data-pressed:font-semibold data-pressed:text-foreground data-pressed:hover:bg-background"
|
|
12
14
|
},
|
|
13
15
|
size: {
|
|
14
16
|
xs: "h-6 min-w-6 gap-1 px-1 text-xs",
|
|
@@ -17,59 +19,192 @@ const toggleVariants = cva("inline-flex items-center justify-center gap-1.5 roun
|
|
|
17
19
|
lg: "h-11 min-w-11 px-3.5 text-base"
|
|
18
20
|
}
|
|
19
21
|
},
|
|
22
|
+
compoundVariants: [{
|
|
23
|
+
variant: "chip",
|
|
24
|
+
size: "sm",
|
|
25
|
+
className: "gap-1.5 px-3"
|
|
26
|
+
}],
|
|
20
27
|
defaultVariants: {
|
|
21
28
|
variant: "default",
|
|
22
29
|
size: "default"
|
|
23
30
|
}
|
|
24
31
|
});
|
|
25
|
-
|
|
32
|
+
const CountContext = createContext(null);
|
|
33
|
+
/**
|
|
34
|
+
* A toggle with only an icon needs an `aria-label`. `variant="chip"` is one
|
|
35
|
+
* choice in a row of filters: use `size="sm"` (28px) and a `ToggleGroup` with
|
|
36
|
+
* `deselectable={false}` so one always stays chosen.
|
|
37
|
+
*/
|
|
26
38
|
function Toggle(t0) {
|
|
27
|
-
const $ = c(
|
|
39
|
+
const $ = c(26);
|
|
28
40
|
let className;
|
|
41
|
+
let describedBy;
|
|
29
42
|
let props;
|
|
30
43
|
let size;
|
|
31
44
|
let variant;
|
|
32
45
|
if ($[0] !== t0) {
|
|
33
|
-
({variant, size, className, ...props} = t0);
|
|
46
|
+
({variant, size, className, "aria-describedby": describedBy, ...props} = t0);
|
|
34
47
|
$[0] = t0;
|
|
35
48
|
$[1] = className;
|
|
36
|
-
$[2] =
|
|
37
|
-
$[3] =
|
|
38
|
-
$[4] =
|
|
49
|
+
$[2] = describedBy;
|
|
50
|
+
$[3] = props;
|
|
51
|
+
$[4] = size;
|
|
52
|
+
$[5] = variant;
|
|
39
53
|
} else {
|
|
40
54
|
className = $[1];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
describedBy = $[2];
|
|
56
|
+
props = $[3];
|
|
57
|
+
size = $[4];
|
|
58
|
+
variant = $[5];
|
|
44
59
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
60
|
+
const id = useId();
|
|
61
|
+
const [counted, setCounted] = useState(false);
|
|
62
|
+
let t1;
|
|
63
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
64
|
+
t1 = () => (on) => setCounted(on);
|
|
65
|
+
$[6] = t1;
|
|
66
|
+
} else t1 = $[6];
|
|
67
|
+
const [describe] = useState(t1);
|
|
68
|
+
const t2 = counted ? `${id}-count` : void 0;
|
|
47
69
|
let t3;
|
|
48
|
-
if ($[
|
|
49
|
-
t3 =
|
|
70
|
+
if ($[7] !== describedBy || $[8] !== t2) {
|
|
71
|
+
t3 = [describedBy, t2].filter(Boolean);
|
|
72
|
+
$[7] = describedBy;
|
|
73
|
+
$[8] = t2;
|
|
74
|
+
$[9] = t3;
|
|
75
|
+
} else t3 = $[9];
|
|
76
|
+
const description = t3.join(" ");
|
|
77
|
+
let t4;
|
|
78
|
+
if ($[10] !== describe || $[11] !== id) {
|
|
79
|
+
t4 = {
|
|
80
|
+
id,
|
|
81
|
+
describe
|
|
82
|
+
};
|
|
83
|
+
$[10] = describe;
|
|
84
|
+
$[11] = id;
|
|
85
|
+
$[12] = t4;
|
|
86
|
+
} else t4 = $[12];
|
|
87
|
+
const t5 = variant ?? "default";
|
|
88
|
+
const t6 = size ?? "default";
|
|
89
|
+
const t7 = description || void 0;
|
|
90
|
+
let t8;
|
|
91
|
+
if ($[13] !== className || $[14] !== size || $[15] !== variant) {
|
|
92
|
+
t8 = cnState(toggleVariants({
|
|
50
93
|
variant,
|
|
51
94
|
size
|
|
52
95
|
}), className);
|
|
53
|
-
$[
|
|
54
|
-
$[
|
|
55
|
-
$[
|
|
96
|
+
$[13] = className;
|
|
97
|
+
$[14] = size;
|
|
98
|
+
$[15] = variant;
|
|
99
|
+
$[16] = t8;
|
|
100
|
+
} else t8 = $[16];
|
|
101
|
+
let t9;
|
|
102
|
+
if ($[17] !== props || $[18] !== t5 || $[19] !== t6 || $[20] !== t7 || $[21] !== t8) {
|
|
103
|
+
t9 = /* @__PURE__ */ jsx(Toggle$1, {
|
|
104
|
+
"data-variant": t5,
|
|
105
|
+
"data-size": t6,
|
|
106
|
+
"aria-describedby": t7,
|
|
107
|
+
className: t8,
|
|
108
|
+
...props
|
|
109
|
+
});
|
|
110
|
+
$[17] = props;
|
|
111
|
+
$[18] = t5;
|
|
112
|
+
$[19] = t6;
|
|
113
|
+
$[20] = t7;
|
|
114
|
+
$[21] = t8;
|
|
115
|
+
$[22] = t9;
|
|
116
|
+
} else t9 = $[22];
|
|
117
|
+
let t10;
|
|
118
|
+
if ($[23] !== t4 || $[24] !== t9) {
|
|
119
|
+
t10 = /* @__PURE__ */ jsx(CountContext.Provider, {
|
|
120
|
+
value: t4,
|
|
121
|
+
children: t9
|
|
122
|
+
});
|
|
123
|
+
$[23] = t4;
|
|
124
|
+
$[24] = t9;
|
|
125
|
+
$[25] = t10;
|
|
126
|
+
} else t10 = $[25];
|
|
127
|
+
return t10;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* What a chip holds, after its name ("Payments 142"): small, in `subtle` and
|
|
131
|
+
* with tabular figures. It is `aria-hidden` and its text is the chip's
|
|
132
|
+
* description, so the chip's name stays its own.
|
|
133
|
+
*/
|
|
134
|
+
function ToggleCount(t0) {
|
|
135
|
+
const $ = c(19);
|
|
136
|
+
let children;
|
|
137
|
+
let className;
|
|
138
|
+
let props;
|
|
139
|
+
if ($[0] !== t0) {
|
|
140
|
+
({className, children, ...props} = t0);
|
|
141
|
+
$[0] = t0;
|
|
142
|
+
$[1] = children;
|
|
143
|
+
$[2] = className;
|
|
144
|
+
$[3] = props;
|
|
145
|
+
} else {
|
|
146
|
+
children = $[1];
|
|
147
|
+
className = $[2];
|
|
148
|
+
props = $[3];
|
|
149
|
+
}
|
|
150
|
+
const scope = useContext(CountContext);
|
|
151
|
+
const describe = scope?.describe;
|
|
152
|
+
let t1;
|
|
153
|
+
let t2;
|
|
154
|
+
if ($[4] !== describe) {
|
|
155
|
+
t1 = () => {
|
|
156
|
+
describe?.(true);
|
|
157
|
+
return () => describe?.(false);
|
|
158
|
+
};
|
|
159
|
+
t2 = [describe];
|
|
160
|
+
$[4] = describe;
|
|
161
|
+
$[5] = t1;
|
|
162
|
+
$[6] = t2;
|
|
163
|
+
} else {
|
|
164
|
+
t1 = $[5];
|
|
165
|
+
t2 = $[6];
|
|
166
|
+
}
|
|
167
|
+
useEffect(t1, t2);
|
|
168
|
+
let t3;
|
|
169
|
+
if ($[7] !== className) {
|
|
170
|
+
t3 = cn("text-supporting text-subtle tabular-nums group-data-pressed/toggle:text-muted-foreground", className);
|
|
171
|
+
$[7] = className;
|
|
56
172
|
$[8] = t3;
|
|
57
173
|
} else t3 = $[8];
|
|
58
174
|
let t4;
|
|
59
|
-
if ($[9] !==
|
|
60
|
-
t4 = /* @__PURE__ */ jsx(
|
|
61
|
-
"data-
|
|
62
|
-
"
|
|
175
|
+
if ($[9] !== children || $[10] !== props || $[11] !== t3) {
|
|
176
|
+
t4 = /* @__PURE__ */ jsx("span", {
|
|
177
|
+
"data-slot": "toggle-count",
|
|
178
|
+
"aria-hidden": "true",
|
|
63
179
|
className: t3,
|
|
64
|
-
...props
|
|
180
|
+
...props,
|
|
181
|
+
children
|
|
65
182
|
});
|
|
66
|
-
$[9] =
|
|
67
|
-
$[10] =
|
|
68
|
-
$[11] =
|
|
69
|
-
$[12] =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
183
|
+
$[9] = children;
|
|
184
|
+
$[10] = props;
|
|
185
|
+
$[11] = t3;
|
|
186
|
+
$[12] = t4;
|
|
187
|
+
} else t4 = $[12];
|
|
188
|
+
let t5;
|
|
189
|
+
if ($[13] !== children || $[14] !== scope) {
|
|
190
|
+
t5 = scope ? /* @__PURE__ */ jsx("span", {
|
|
191
|
+
id: `${scope.id}-count`,
|
|
192
|
+
hidden: true,
|
|
193
|
+
"aria-hidden": "true",
|
|
194
|
+
children
|
|
195
|
+
}) : null;
|
|
196
|
+
$[13] = children;
|
|
197
|
+
$[14] = scope;
|
|
198
|
+
$[15] = t5;
|
|
199
|
+
} else t5 = $[15];
|
|
200
|
+
let t6;
|
|
201
|
+
if ($[16] !== t4 || $[17] !== t5) {
|
|
202
|
+
t6 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t4, t5] });
|
|
203
|
+
$[16] = t4;
|
|
204
|
+
$[17] = t5;
|
|
205
|
+
$[18] = t6;
|
|
206
|
+
} else t6 = $[18];
|
|
207
|
+
return t6;
|
|
73
208
|
}
|
|
74
209
|
function ToggleIcon(t0) {
|
|
75
210
|
const $ = c(8);
|
|
@@ -134,4 +269,4 @@ function ToggleGroup(t0) {
|
|
|
134
269
|
} else t2 = $[7];
|
|
135
270
|
return t2;
|
|
136
271
|
}
|
|
137
|
-
export { Toggle, ToggleGroup, ToggleIcon, createToggleController, createToggleGroupController, toggleVariants };
|
|
272
|
+
export { Toggle, ToggleCount, ToggleGroup, ToggleIcon, createToggleController, createToggleGroupController, toggleVariants };
|