@rinzai/zen 0.4.2 → 0.6.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 +2 -2
- package/dist/animated-number/index.js +33 -0
- package/dist/avatar/index.js +38 -0
- package/dist/backdrop/index.d.ts +7 -3
- package/dist/backdrop/index.d.ts.map +1 -1
- package/dist/backdrop/index.js +98 -0
- package/dist/badge/index.d.ts +1 -1
- package/dist/badge/index.js +24 -0
- package/dist/button/index.d.ts +10 -3
- package/dist/button/index.d.ts.map +1 -1
- package/dist/button/index.js +54 -0
- package/dist/calendar/index.d.ts +44 -0
- package/dist/calendar/index.d.ts.map +1 -0
- package/dist/calendar/index.js +161 -0
- package/dist/card/index.d.ts +15 -6
- package/dist/card/index.d.ts.map +1 -1
- package/dist/card/index.js +60 -0
- package/dist/chart/donut.d.ts +30 -0
- package/dist/chart/donut.d.ts.map +1 -0
- package/dist/chart/donut.js +96 -0
- package/dist/chart/index.d.ts +81 -0
- package/dist/chart/index.d.ts.map +1 -0
- package/dist/chart/index.js +362 -0
- package/dist/chart/tooltip.d.ts +25 -0
- package/dist/chart/tooltip.d.ts.map +1 -0
- package/dist/chart/tooltip.js +51 -0
- package/dist/checkbox/index.d.ts +20 -0
- package/dist/checkbox/index.d.ts.map +1 -0
- package/dist/checkbox/index.js +61 -0
- package/dist/chip/index.d.ts +12 -0
- package/dist/chip/index.d.ts.map +1 -0
- package/dist/chip/index.js +14 -0
- package/dist/code-block/index.js +36 -0
- package/dist/collapse/index.d.ts +17 -7
- package/dist/collapse/index.d.ts.map +1 -1
- package/dist/collapse/index.js +82 -0
- package/dist/combobox/index.d.ts +89 -0
- package/dist/combobox/index.d.ts.map +1 -0
- package/dist/combobox/index.js +262 -0
- package/dist/confirm-dialog/index.d.ts.map +1 -1
- package/dist/confirm-dialog/index.js +25 -0
- package/dist/date-picker/index.d.ts +48 -0
- package/dist/date-picker/index.d.ts.map +1 -0
- package/dist/date-picker/index.js +112 -0
- package/dist/dialog/index.d.ts +14 -2
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +77 -0
- package/dist/disclosure/index.d.ts +25 -0
- package/dist/disclosure/index.d.ts.map +1 -0
- package/dist/disclosure/index.js +66 -0
- package/dist/editable-cell/index.js +24 -0
- package/dist/field/index.d.ts +42 -3
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +66 -0
- package/dist/header/index.js +17 -0
- package/dist/icons/chevron-down.js +21 -0
- package/dist/icons/chevron-left.js +21 -0
- package/dist/icons/chevron-right.js +21 -0
- package/dist/icons/chevron-up.js +21 -0
- package/dist/icons/ellipsis.d.ts +4 -0
- package/dist/icons/ellipsis.d.ts.map +1 -0
- package/dist/icons/ellipsis.js +31 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/icons/search.js +21 -0
- package/dist/icons/x-mark.js +21 -0
- package/dist/index.d.ts +24 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/input/index.d.ts.map +1 -1
- package/dist/input/index.js +16 -0
- package/dist/input-group/index.d.ts.map +1 -1
- package/dist/input-group/index.js +36 -0
- package/dist/inset/index.d.ts +16 -0
- package/dist/inset/index.d.ts.map +1 -0
- package/dist/inset/index.js +23 -0
- package/dist/lib.js +74 -0
- package/dist/menu/index.d.ts +55 -0
- package/dist/menu/index.d.ts.map +1 -0
- package/dist/menu/index.js +118 -0
- package/dist/meter/index.js +41 -0
- package/dist/money-input/index.d.ts +77 -7
- package/dist/money-input/index.d.ts.map +1 -1
- package/dist/money-input/index.js +304 -0
- package/dist/month-picker/index.d.ts +4 -3
- package/dist/month-picker/index.d.ts.map +1 -1
- package/dist/month-picker/index.js +93 -0
- package/dist/page-header/index.js +26 -0
- package/dist/pills/index.d.ts +35 -0
- package/dist/pills/index.d.ts.map +1 -0
- package/dist/pills/index.js +50 -0
- package/dist/popover/index.d.ts +41 -22
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +75 -0
- package/dist/progress-ring/index.js +49 -0
- package/dist/radio-cards/index.d.ts +34 -0
- package/dist/radio-cards/index.d.ts.map +1 -0
- package/dist/radio-cards/index.js +48 -0
- package/dist/radio-group/index.d.ts +39 -0
- package/dist/radio-group/index.d.ts.map +1 -0
- package/dist/radio-group/index.js +63 -0
- package/dist/segmented/index.d.ts +16 -6
- package/dist/segmented/index.d.ts.map +1 -1
- package/dist/segmented/index.js +58 -0
- package/dist/select/index.d.ts +28 -14
- package/dist/select/index.d.ts.map +1 -1
- package/dist/select/index.js +187 -0
- package/dist/side-nav/index.js +37 -0
- package/dist/skeleton/index.js +12 -0
- package/dist/slider/index.js +34 -0
- package/dist/spinner/index.js +14 -0
- package/dist/tab-bar/index.d.ts +3 -0
- package/dist/tab-bar/index.d.ts.map +1 -1
- package/dist/tab-bar/index.js +34 -0
- package/dist/table/index.js +148 -0
- package/dist/table-of-contents/index.js +37 -0
- package/dist/tabs/index.d.ts +3 -2
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +114 -0
- package/dist/tailwind.css +1 -1
- package/dist/textarea/index.d.ts.map +1 -1
- package/dist/textarea/index.js +16 -0
- package/dist/theme-toggle/index.js +43 -0
- package/dist/theme.css +178 -13
- package/dist/toast/index.d.ts +13 -2
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +248 -0
- package/dist/toggle/index.d.ts +3 -2
- package/dist/toggle/index.d.ts.map +1 -1
- package/dist/toggle/index.js +26 -0
- package/dist/tooltip/index.d.ts +25 -0
- package/dist/tooltip/index.d.ts.map +1 -0
- package/dist/tooltip/index.js +108 -0
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/tree/index.js +135 -0
- package/dist/utils/cva.js +25 -0
- package/dist/utils/cx.js +6 -0
- package/dist/utils/date.d.ts +37 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +68 -0
- package/dist/utils/field-chevron.js +19 -0
- package/dist/utils/fx.d.ts +30 -0
- package/dist/utils/fx.d.ts.map +1 -0
- package/dist/utils/fx.js +21 -0
- package/dist/utils/graphics.js +33 -0
- package/dist/utils/indicator.d.ts +24 -0
- package/dist/utils/indicator.d.ts.map +1 -0
- package/dist/utils/indicator.js +37 -0
- package/dist/utils/merge.js +305 -0
- package/dist/utils/money.js +73 -0
- package/dist/utils/month.js +46 -0
- package/dist/utils/slot.d.ts +9 -5
- package/dist/utils/slot.d.ts.map +1 -1
- package/dist/utils/slot.js +25 -0
- package/dist/utils/status-icons.js +48 -0
- package/dist/utils/styles.d.ts +6 -6
- package/dist/utils/styles.d.ts.map +1 -1
- package/dist/utils/styles.js +6 -0
- package/dist/utils/theme.js +200 -0
- package/dist/utils/useAnchoredPopup.d.ts +8 -2
- package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
- package/dist/utils/useAnchoredPopup.js +63 -0
- package/dist/utils/useHydrated.js +9 -0
- package/dist/utils/useVirtualList.js +45 -0
- package/dist/variables.css +22 -0
- package/dist/zen.css +1 -1
- package/package.json +9 -4
- package/dist/actions-menu/index.d.ts +0 -18
- package/dist/actions-menu/index.d.ts.map +0 -1
- package/dist/dropdown/index.d.ts +0 -28
- package/dist/dropdown/index.d.ts.map +0 -1
- package/dist/nav-pills/index.d.ts +0 -31
- package/dist/nav-pills/index.d.ts.map +0 -1
- package/dist/zen.js +0 -2929
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { useGraphicsMode as t } from "../utils/graphics.js";
|
|
4
|
+
import { Slot as n } from "../utils/slot.js";
|
|
5
|
+
import { anchoredStyle as r, useAnchoredPopup as i } from "../utils/useAnchoredPopup.js";
|
|
6
|
+
import a from "../button/index.js";
|
|
7
|
+
import { POPUP as o } from "../utils/styles.js";
|
|
8
|
+
import { createContext as s, useContext as c, useEffect as l } from "react";
|
|
9
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
10
|
+
//#region packages/popover/index.tsx
|
|
11
|
+
var d = s(null);
|
|
12
|
+
function f(e) {
|
|
13
|
+
let t = c(d);
|
|
14
|
+
if (!t) throw Error(`<${e}> must be inside <Popover>`);
|
|
15
|
+
return t;
|
|
16
|
+
}
|
|
17
|
+
function p({ open: e, defaultOpen: n = !1, onOpenChange: r, children: a }) {
|
|
18
|
+
t();
|
|
19
|
+
let o = i({ onOpenChange: r }), { setOpen: s } = o;
|
|
20
|
+
return l(() => {
|
|
21
|
+
e !== void 0 && s(e);
|
|
22
|
+
}, [e, s]), l(() => {
|
|
23
|
+
n && s(!0);
|
|
24
|
+
}, []), /* @__PURE__ */ u(d.Provider, {
|
|
25
|
+
value: o,
|
|
26
|
+
children: a
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function m({ asChild: e, style: t, children: r, ...i }) {
|
|
30
|
+
let a = f("PopoverTrigger"), o = {
|
|
31
|
+
...a.triggerProps,
|
|
32
|
+
"aria-haspopup": "dialog",
|
|
33
|
+
...i,
|
|
34
|
+
style: {
|
|
35
|
+
...a.triggerProps.style,
|
|
36
|
+
...t
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return e ? /* @__PURE__ */ u(n, {
|
|
40
|
+
...o,
|
|
41
|
+
children: r
|
|
42
|
+
}) : /* @__PURE__ */ u("button", {
|
|
43
|
+
type: "button",
|
|
44
|
+
...o,
|
|
45
|
+
children: r
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function h({ align: t = "center", offset: n = 5, className: i, style: a, children: s, ...c }) {
|
|
49
|
+
let l = f("PopoverContent");
|
|
50
|
+
return /* @__PURE__ */ u("div", {
|
|
51
|
+
role: "dialog",
|
|
52
|
+
...c,
|
|
53
|
+
...l.popupProps,
|
|
54
|
+
style: {
|
|
55
|
+
...r(l.id, {
|
|
56
|
+
align: t,
|
|
57
|
+
offset: n
|
|
58
|
+
}),
|
|
59
|
+
...a
|
|
60
|
+
},
|
|
61
|
+
className: e("zen__popover fixed z-50 w-[anchor-size(width)] min-w-max overflow-visible p-0", o, i),
|
|
62
|
+
children: s
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function g({ onClick: e, ...t }) {
|
|
66
|
+
let n = f("PopoverClose");
|
|
67
|
+
return /* @__PURE__ */ u(a, {
|
|
68
|
+
...t,
|
|
69
|
+
onClick: (t) => {
|
|
70
|
+
e?.(t), t.defaultPrevented || n.setOpen(!1);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { g as PopoverClose, h as PopoverContent, m as PopoverTrigger, p as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
4
|
+
//#region packages/progress-ring/index.tsx
|
|
5
|
+
function r({ value: r, size: i = 84, stroke: a = 7, label: o, children: s, className: c }) {
|
|
6
|
+
let l = (i - a) / 2, u = 2 * Math.PI * l, d = Math.min(Math.max(r, 0), 1);
|
|
7
|
+
return /* @__PURE__ */ n("div", {
|
|
8
|
+
role: "progressbar",
|
|
9
|
+
"aria-label": o,
|
|
10
|
+
"aria-valuemin": 0,
|
|
11
|
+
"aria-valuemax": 100,
|
|
12
|
+
"aria-valuenow": Math.round(d * 100),
|
|
13
|
+
className: e("zen__progress-ring relative grid shrink-0 place-items-center", c),
|
|
14
|
+
style: {
|
|
15
|
+
width: i,
|
|
16
|
+
height: i
|
|
17
|
+
},
|
|
18
|
+
children: [/* @__PURE__ */ n("svg", {
|
|
19
|
+
width: i,
|
|
20
|
+
height: i,
|
|
21
|
+
viewBox: `0 0 ${i} ${i}`,
|
|
22
|
+
className: "-rotate-90",
|
|
23
|
+
"aria-hidden": !0,
|
|
24
|
+
children: [/* @__PURE__ */ t("circle", {
|
|
25
|
+
cx: i / 2,
|
|
26
|
+
cy: i / 2,
|
|
27
|
+
r: l,
|
|
28
|
+
fill: "none",
|
|
29
|
+
strokeWidth: a,
|
|
30
|
+
className: "stroke-tint/[0.07]"
|
|
31
|
+
}), /* @__PURE__ */ t("circle", {
|
|
32
|
+
cx: i / 2,
|
|
33
|
+
cy: i / 2,
|
|
34
|
+
r: l,
|
|
35
|
+
fill: "none",
|
|
36
|
+
strokeWidth: a,
|
|
37
|
+
strokeLinecap: "round",
|
|
38
|
+
strokeDasharray: u,
|
|
39
|
+
strokeDashoffset: u * (1 - d),
|
|
40
|
+
className: "stroke-primary [filter:drop-shadow(0_0_6px_oklch(var(--glow)/0.45))] transition-[stroke-dashoffset] duration-700 ease-out"
|
|
41
|
+
})]
|
|
42
|
+
}), /* @__PURE__ */ t("div", {
|
|
43
|
+
className: "absolute inset-0 grid place-items-center text-center",
|
|
44
|
+
children: s
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { r as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A choice of one among a few cards, each showing what it picks (a palette, a
|
|
4
|
+
* plan). Native radio inputs underneath, so arrow keys and forms work as for any
|
|
5
|
+
* radio group. Lay the cards out with className (e.g. a grid); fill it with
|
|
6
|
+
* RadioCard. For short text options, use Segmented.
|
|
7
|
+
*/
|
|
8
|
+
export default function RadioCards<V extends string>({ label, value, onChange, name, className, children, }: RadioCardsProps<V>): import('react').JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* One card: a native radio covering whatever you put inside, so the whole card
|
|
11
|
+
* is the click target. Outlined, lit when chosen; style it further with
|
|
12
|
+
* className and style (e.g. a background showing the choice).
|
|
13
|
+
*/
|
|
14
|
+
export declare function RadioCard({ value, disabled, className, style, children }: RadioCardProps): import('react').JSX.Element;
|
|
15
|
+
export interface RadioCardsProps<V extends string> {
|
|
16
|
+
label: string;
|
|
17
|
+
value: V;
|
|
18
|
+
onChange: (value: V) => void;
|
|
19
|
+
/** Form field name; defaults to a generated one. */
|
|
20
|
+
name?: string;
|
|
21
|
+
/** Classes for the cards' container: its layout (e.g. a grid). */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** The RadioCards. */
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export interface RadioCardProps {
|
|
27
|
+
value: string;
|
|
28
|
+
/** Can't be chosen (and the arrow keys skip it). */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
className?: string;
|
|
31
|
+
style?: CSSProperties;
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/radio-cards/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,aAAa,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AAUnF;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,EACjD,KAAK,EACL,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,QAAQ,GACX,EAAE,eAAe,CAAC,CAAC,CAAC,+BAgBpB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,+BAyBxF;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACvB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { createContext as t, useContext as n, useId as r } from "react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
//#region packages/radio-cards/index.tsx
|
|
6
|
+
var o = t(null);
|
|
7
|
+
function s({ label: e, value: t, onChange: n, name: s, className: c, children: l }) {
|
|
8
|
+
let u = r();
|
|
9
|
+
return /* @__PURE__ */ a("div", {
|
|
10
|
+
className: "zen__radio-cards flex flex-col gap-2",
|
|
11
|
+
children: [/* @__PURE__ */ i("span", {
|
|
12
|
+
id: u,
|
|
13
|
+
className: "text-sm font-medium",
|
|
14
|
+
children: e
|
|
15
|
+
}), /* @__PURE__ */ i("div", {
|
|
16
|
+
role: "radiogroup",
|
|
17
|
+
"aria-labelledby": u,
|
|
18
|
+
className: c,
|
|
19
|
+
children: /* @__PURE__ */ i(o.Provider, {
|
|
20
|
+
value: {
|
|
21
|
+
name: s ?? u,
|
|
22
|
+
value: t,
|
|
23
|
+
onChange: n
|
|
24
|
+
},
|
|
25
|
+
children: l
|
|
26
|
+
})
|
|
27
|
+
})]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function c({ value: t, disabled: r, className: s, style: c, children: l }) {
|
|
31
|
+
let u = n(o);
|
|
32
|
+
if (!u) throw Error("<RadioCard> must be inside <RadioCards>");
|
|
33
|
+
return /* @__PURE__ */ a("label", {
|
|
34
|
+
style: c,
|
|
35
|
+
className: e("zen__radio-card border-tint/10 relative flex items-center gap-3 rounded-xl border p-2.5 text-left text-sm transition-[border-color,box-shadow] duration-200", "hover:has-enabled:border-tint/20 has-checked:border-primary/60 has-checked:shadow-[0_0_0_3px_oklch(var(--primary)/0.15)]", "has-focus-visible:ring-ring/50 has-focus-visible:ring-2 has-disabled:opacity-60", s),
|
|
36
|
+
children: [/* @__PURE__ */ i("input", {
|
|
37
|
+
type: "radio",
|
|
38
|
+
name: u.name,
|
|
39
|
+
value: t,
|
|
40
|
+
checked: u.value === t,
|
|
41
|
+
disabled: r,
|
|
42
|
+
onChange: () => u.onChange(t),
|
|
43
|
+
className: "absolute inset-0 z-10 m-0 size-full cursor-pointer appearance-none rounded-[inherit] opacity-0 disabled:cursor-not-allowed"
|
|
44
|
+
}), l]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { c as RadioCard, s as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Choose one of a list: native radios underneath, so arrow keys move and pick
|
|
4
|
+
* within the group, and forms work as usual. Fill it with Radio. For a few
|
|
5
|
+
* short options side by side use Segmented; for options that show themselves,
|
|
6
|
+
* RadioCards.
|
|
7
|
+
*/
|
|
8
|
+
export default function RadioGroup<V extends string>({ label, value, onChange, name, disabled, orientation, className, children, ...aria }: RadioGroupProps<V>): import('react').JSX.Element;
|
|
9
|
+
/** One option: a round radio that fills with a glowing dot when chosen, its label, and an optional description. */
|
|
10
|
+
export declare function Radio({ value, disabled, description, className, children }: RadioProps): import('react').JSX.Element;
|
|
11
|
+
export interface RadioGroupProps<V extends string> {
|
|
12
|
+
/** Shown above the options, naming the group. Without it, give the group an aria-label. */
|
|
13
|
+
label?: ReactNode;
|
|
14
|
+
/** The chosen option, or null for none yet. */
|
|
15
|
+
value: V | null;
|
|
16
|
+
onChange: (value: V) => void;
|
|
17
|
+
/** Form field name; defaults to a generated one. */
|
|
18
|
+
name?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Options in a column (default) or wrapping in a row. */
|
|
21
|
+
orientation?: 'vertical' | 'horizontal';
|
|
22
|
+
'aria-label'?: string;
|
|
23
|
+
'aria-describedby'?: string;
|
|
24
|
+
/** Classes for the options' container. */
|
|
25
|
+
className?: string;
|
|
26
|
+
/** The Radios. */
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export interface RadioProps {
|
|
30
|
+
value: string;
|
|
31
|
+
/** Can't be chosen (and the arrow keys skip it). */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/** A muted line under the label. */
|
|
34
|
+
description?: ReactNode;
|
|
35
|
+
className?: string;
|
|
36
|
+
/** The label. */
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/radio-group/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,SAAS,EAAqB,MAAM,OAAO,CAAC;AAWpE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,EACjD,KAAK,EACL,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAgB,EAChB,WAAwB,EACxB,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,eAAe,CAAC,CAAC,CAAC,+BA6BpB;AAED,mHAAmH;AACnH,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,UAAU,+BAoCtF;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM;IAC7C,2FAA2F;IAC3F,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,+CAA+C;IAC/C,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB;IAClB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oCAAoC;IACpC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB;IACjB,QAAQ,EAAE,SAAS,CAAC;CACvB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { createContext as t, useContext as n, useId as r } from "react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
//#region packages/radio-group/index.tsx
|
|
6
|
+
var o = t(null);
|
|
7
|
+
function s({ label: t, value: n, onChange: s, name: c, disabled: l = !1, orientation: u = "vertical", className: d, children: f, ...p }) {
|
|
8
|
+
let m = r();
|
|
9
|
+
return /* @__PURE__ */ a("div", {
|
|
10
|
+
className: "zen__radio-group flex flex-col gap-2",
|
|
11
|
+
children: [t && /* @__PURE__ */ i("span", {
|
|
12
|
+
id: m,
|
|
13
|
+
className: "text-sm font-medium",
|
|
14
|
+
children: t
|
|
15
|
+
}), /* @__PURE__ */ i("div", {
|
|
16
|
+
role: "radiogroup",
|
|
17
|
+
"aria-labelledby": t ? m : void 0,
|
|
18
|
+
"aria-orientation": u,
|
|
19
|
+
"aria-disabled": l || void 0,
|
|
20
|
+
...p,
|
|
21
|
+
className: e("flex", u === "vertical" ? "flex-col gap-2.5" : "flex-wrap gap-x-5 gap-y-2", d),
|
|
22
|
+
children: /* @__PURE__ */ i(o.Provider, {
|
|
23
|
+
value: {
|
|
24
|
+
name: c ?? m,
|
|
25
|
+
value: n,
|
|
26
|
+
onChange: s,
|
|
27
|
+
disabled: l
|
|
28
|
+
},
|
|
29
|
+
children: f
|
|
30
|
+
})
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function c({ value: t, disabled: r, description: s, className: c, children: l }) {
|
|
35
|
+
let u = n(o);
|
|
36
|
+
if (!u) throw Error("<Radio> must be inside <RadioGroup>");
|
|
37
|
+
return /* @__PURE__ */ a("label", {
|
|
38
|
+
className: e("inline-flex cursor-pointer items-start gap-2.5 text-sm has-disabled:cursor-not-allowed has-disabled:opacity-60", c),
|
|
39
|
+
children: [/* @__PURE__ */ a("span", {
|
|
40
|
+
className: "relative mt-px inline-grid size-[1.125rem] shrink-0 place-items-center",
|
|
41
|
+
children: [/* @__PURE__ */ i("input", {
|
|
42
|
+
type: "radio",
|
|
43
|
+
name: u.name,
|
|
44
|
+
value: t,
|
|
45
|
+
checked: u.value === t,
|
|
46
|
+
disabled: r || u.disabled,
|
|
47
|
+
onChange: () => u.onChange(t),
|
|
48
|
+
className: e("peer border-tint/20 bg-tint/[0.04] m-0 size-full cursor-pointer appearance-none rounded-full border outline-hidden", "transition-[border-color,box-shadow] duration-200", "hover:enabled:border-tint/35 focus-visible:ring-ring/50 focus-visible:ring-2", "checked:border-primary checked:shadow-[0_0_14px_-3px_oklch(var(--glow)/0.8)] disabled:cursor-not-allowed")
|
|
49
|
+
}), /* @__PURE__ */ i("span", {
|
|
50
|
+
"aria-hidden": !0,
|
|
51
|
+
className: "bg-primary pointer-events-none absolute size-2 scale-0 rounded-full shadow-[0_0_8px_oklch(var(--glow)/0.9)] transition-transform duration-200 ease-[cubic-bezier(0.3,1.6,0.5,1)] peer-checked:scale-100"
|
|
52
|
+
})]
|
|
53
|
+
}), /* @__PURE__ */ a("span", {
|
|
54
|
+
className: "flex flex-col gap-0.5",
|
|
55
|
+
children: [l, s && /* @__PURE__ */ i("span", {
|
|
56
|
+
className: "text-muted-foreground text-xs",
|
|
57
|
+
children: s
|
|
58
|
+
})]
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { c as Radio, s as default };
|
|
@@ -1,19 +1,29 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* A small set of mutually exclusive options, shown as a pill row. Native radio
|
|
3
4
|
* inputs underneath, so arrow keys and forms work as for any radio group. The
|
|
4
|
-
* selection slides between options, like
|
|
5
|
+
* selection slides between options, like Pills. Fill it with
|
|
6
|
+
* SegmentedItem (any content: text, icons, a disabled option).
|
|
5
7
|
*/
|
|
6
|
-
export default function Segmented<V extends string>({ label, value,
|
|
8
|
+
export default function Segmented<V extends string>({ label, value, onChange, name, className, children, }: SegmentedProps<V>): import('react').JSX.Element;
|
|
9
|
+
/** One option of a Segmented: a native radio covering whatever you put inside. */
|
|
10
|
+
export declare function SegmentedItem({ value, disabled, className, children }: SegmentedItemProps): import('react').JSX.Element;
|
|
7
11
|
export interface SegmentedProps<V extends string> {
|
|
8
12
|
label: string;
|
|
9
13
|
value: V;
|
|
10
|
-
options: readonly {
|
|
11
|
-
value: V;
|
|
12
|
-
label: string;
|
|
13
|
-
}[];
|
|
14
14
|
onChange: (value: V) => void;
|
|
15
15
|
/** Form field name; defaults to a generated one. */
|
|
16
16
|
name?: string;
|
|
17
17
|
className?: string;
|
|
18
|
+
/** The SegmentedItems. */
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export interface SegmentedItemProps {
|
|
22
|
+
value: string;
|
|
23
|
+
/** Skipped by the arrow keys and can't be chosen. */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
className?: string;
|
|
26
|
+
/** What the option shows: text, an icon, both. */
|
|
27
|
+
children: ReactNode;
|
|
18
28
|
}
|
|
19
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/segmented/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/segmented/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,SAAS,EAA6B,MAAM,OAAO,CAAC;AAY5E;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,EAChD,KAAK,EACL,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,QAAQ,GACX,EAAE,cAAc,CAAC,CAAC,CAAC,+BAuCnB;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,kBAAkB,+BA4BzF;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,QAAQ,EAAE,SAAS,CAAC;CACvB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { useIndicator as t } from "../utils/indicator.js";
|
|
4
|
+
import { createContext as n, useContext as r, useId as i, useRef as a } from "react";
|
|
5
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/segmented/index.tsx
|
|
7
|
+
var c = n(null);
|
|
8
|
+
function l({ label: n, value: r, onChange: l, name: u, className: d, children: f }) {
|
|
9
|
+
let p = i(), m = a(null), h = t(m, "label:has(input:checked)", [r, f]);
|
|
10
|
+
return /* @__PURE__ */ s("div", {
|
|
11
|
+
className: e("zen__segmented flex flex-col gap-2", d),
|
|
12
|
+
children: [/* @__PURE__ */ o("span", {
|
|
13
|
+
id: p,
|
|
14
|
+
className: "text-sm font-medium",
|
|
15
|
+
children: n
|
|
16
|
+
}), /* @__PURE__ */ s("div", {
|
|
17
|
+
ref: m,
|
|
18
|
+
role: "radiogroup",
|
|
19
|
+
"aria-labelledby": p,
|
|
20
|
+
className: "glow-edge border-tint/10 bg-tint/[0.03] relative inline-flex w-fit flex-wrap gap-1 rounded-xl border p-1",
|
|
21
|
+
children: [h && /* @__PURE__ */ o("span", {
|
|
22
|
+
"aria-hidden": !0,
|
|
23
|
+
className: "bg-primary/15 absolute top-0 left-0 rounded-lg shadow-[inset_0_0_0_1px_oklch(var(--primary)/0.4)] transition-[translate,width,height] duration-500 ease-[cubic-bezier(0.2,0.8,0.2,1)]",
|
|
24
|
+
style: {
|
|
25
|
+
translate: `${h.x}px ${h.y}px`,
|
|
26
|
+
width: h.w,
|
|
27
|
+
height: h.h
|
|
28
|
+
}
|
|
29
|
+
}), /* @__PURE__ */ o(c.Provider, {
|
|
30
|
+
value: {
|
|
31
|
+
name: u ?? p,
|
|
32
|
+
value: r,
|
|
33
|
+
onChange: l,
|
|
34
|
+
measured: h !== null
|
|
35
|
+
},
|
|
36
|
+
children: f
|
|
37
|
+
})]
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function u({ value: t, disabled: n, className: i, children: a }) {
|
|
42
|
+
let l = r(c);
|
|
43
|
+
if (!l) throw Error("SegmentedItem must be inside a Segmented");
|
|
44
|
+
return /* @__PURE__ */ s("label", {
|
|
45
|
+
className: e("text-muted-foreground relative cursor-pointer rounded-lg px-3 py-1.5 text-sm transition-colors duration-300", "hover:text-foreground has-checked:text-foreground has-focus-visible:ring-ring/50 has-focus-visible:ring-2", "has-disabled:hover:text-muted-foreground has-disabled:cursor-not-allowed has-disabled:opacity-50", !l.measured && "has-checked:bg-primary/15 has-checked:shadow-[inset_0_0_0_1px_oklch(var(--primary)/0.4)]", i),
|
|
46
|
+
children: [/* @__PURE__ */ o("input", {
|
|
47
|
+
type: "radio",
|
|
48
|
+
className: "absolute inset-0 z-10 m-0 size-full cursor-pointer appearance-none rounded-[inherit] opacity-0 disabled:cursor-not-allowed",
|
|
49
|
+
name: l.name,
|
|
50
|
+
value: t,
|
|
51
|
+
checked: l.value === t,
|
|
52
|
+
disabled: n,
|
|
53
|
+
onChange: () => l.onChange(t)
|
|
54
|
+
}), a]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { u as SegmentedItem, l as default };
|
package/dist/select/index.d.ts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export interface SelectOption<V extends string> {
|
|
3
|
-
value: V;
|
|
4
|
-
/** Text shown, and matched when the user types to jump to an option. */
|
|
5
|
-
label: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
}
|
|
1
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
8
2
|
/**
|
|
9
3
|
* Pick one value from a short list: a field-styled button that opens a list
|
|
10
4
|
* below it. Keyboard: arrows, Home/End, type to jump, Enter to choose, Escape
|
|
11
|
-
* to close.
|
|
5
|
+
* to close. Fill it with SelectItem, organised with SelectGroup and
|
|
6
|
+
* SelectSeparator. For long or searchable lists, use Combobox.
|
|
7
|
+
*/
|
|
8
|
+
export default function Select<V extends string>({ value, onChange, placeholder, disabled, name, id, className, listClassName, children, style, onKeyDown, ...rest }: SelectProps<V>): import('react').JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* One choice in a Select. Its `label` (or its text, when that's all it holds)
|
|
11
|
+
* shows in the field once chosen and is matched when typing to jump.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export declare function SelectItem({ value, label, disabled, className, children }: SelectItemProps): import('react').JSX.Element;
|
|
14
|
+
/** A labelled group of SelectItems. */
|
|
15
|
+
export declare function SelectGroup({ label, children }: {
|
|
16
|
+
label: ReactNode;
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}): import('react').JSX.Element;
|
|
19
|
+
/** A hairline between items or groups. */
|
|
20
|
+
export declare function SelectSeparator(): import('react').JSX.Element;
|
|
21
|
+
/** Also takes the trigger button's props (aria-*, data-*, onBlur…), so Field can wire it up. */
|
|
22
|
+
export interface SelectProps<V extends string> extends Omit<ComponentProps<'button'>, 'value' | 'onChange' | 'children' | 'defaultValue' | 'name'> {
|
|
15
23
|
value: V | null;
|
|
16
|
-
options: readonly SelectOption<V>[];
|
|
17
24
|
onChange: (value: V) => void;
|
|
18
25
|
/** Shown while nothing is chosen. */
|
|
19
26
|
placeholder?: string;
|
|
20
27
|
disabled?: boolean;
|
|
21
|
-
/** Custom content for each option (the label is still used for typing to jump). */
|
|
22
|
-
renderOption?: (option: SelectOption<V>) => ReactNode;
|
|
23
28
|
/** Form field name: adds a hidden input with the value. */
|
|
24
29
|
name?: string;
|
|
25
30
|
id?: string;
|
|
@@ -27,6 +32,15 @@ export interface SelectProps<V extends string> {
|
|
|
27
32
|
className?: string;
|
|
28
33
|
/** Classes for the popup list. */
|
|
29
34
|
listClassName?: string;
|
|
30
|
-
|
|
35
|
+
/** SelectItem, SelectGroup and SelectSeparator. */
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
export interface SelectItemProps {
|
|
39
|
+
value: string;
|
|
40
|
+
/** Text for the field and for typing to jump (defaults to the item's text). */
|
|
41
|
+
label?: string;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
className?: string;
|
|
44
|
+
children: ReactNode;
|
|
31
45
|
}
|
|
32
46
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/select/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/select/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAMH,cAAc,EAEd,SAAS,EAQZ,MAAM,OAAO,CAAC;AAaf;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,EAC7C,KAAK,EACL,QAAQ,EACR,WAAuB,EACvB,QAAgB,EAChB,IAAI,EACJ,EAAE,EACF,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,EACL,SAAS,EACT,GAAG,IAAI,EACV,EAAE,WAAW,CAAC,CAAC,CAAC,+BAsIhB;AAuBD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,eAAe,+BAiC1F;AAED,uCAAuC;AACvC,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,+BASzF;AAED,0CAA0C;AAC1C,wBAAgB,eAAe,gCAE9B;AAED,gGAAgG;AAChG,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,IAAI,CACvD,cAAc,CAAC,QAAQ,CAAC,EACxB,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,GAAG,MAAM,CAC9D;IACG,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACvB"}
|