@krizaka/ui 2.0.0-beta.1 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/dist/button-G5qY4qSY.d.ts +68 -0
- package/dist/card.js +1 -1
- package/dist/checkbox.d.ts +52 -0
- package/dist/checkbox.js +42 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/chip.d.ts +97 -0
- package/dist/chip.js +93 -0
- package/dist/chip.js.map +1 -0
- package/dist/{chunk-RLOXWF2G.js → chunk-5AXLA4LK.js} +1 -1
- package/dist/chunk-5AXLA4LK.js.map +1 -0
- package/dist/chunk-5FRYKFTO.js +121 -0
- package/dist/chunk-5FRYKFTO.js.map +1 -0
- package/dist/{chunk-CPMZS4XA.js → chunk-FJDSLNXK.js} +1 -1
- package/dist/chunk-FJDSLNXK.js.map +1 -0
- package/dist/cn.d.ts +3 -0
- package/dist/cn.js +1 -1
- package/dist/command.d.ts +156 -0
- package/dist/command.js +111 -0
- package/dist/command.js.map +1 -0
- package/dist/confirm-button.d.ts +23 -0
- package/dist/confirm-button.js +85 -0
- package/dist/confirm-button.js.map +1 -0
- package/dist/dialog-DGBY2grk.d.ts +147 -0
- package/dist/dialog.d.ts +4 -131
- package/dist/dialog.js +26 -90
- package/dist/dialog.js.map +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/field.js +1 -1
- package/dist/motion.css +7 -1
- package/dist/popover.js +1 -1
- package/dist/progress.d.ts +87 -0
- package/dist/progress.js +85 -0
- package/dist/progress.js.map +1 -0
- package/dist/radio-group.d.ts +77 -0
- package/dist/radio-group.js +48 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/slider.d.ts +88 -0
- package/dist/slider.js +82 -0
- package/dist/slider.js.map +1 -0
- package/dist/switch.d.ts +72 -0
- package/dist/switch.js +38 -0
- package/dist/switch.js.map +1 -0
- package/dist/tabs.d.ts +83 -0
- package/dist/tabs.js +60 -0
- package/dist/tabs.js.map +1 -0
- package/dist/theme.d.ts +2 -59
- package/dist/toast.js +1 -1
- package/dist/tooltip.js +1 -1
- package/package.json +134 -5
- package/dist/chunk-CPMZS4XA.js.map +0 -1
- package/dist/chunk-RLOXWF2G.js.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/radio-group/radio-group.tsx
|
|
4
|
+
import { RadioGroup as RadioGroupPrimitive } from "radix-ui";
|
|
5
|
+
import { tv } from "tailwind-variants";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
var radioGroup = tv({
|
|
8
|
+
slots: {
|
|
9
|
+
root: "grid gap-2 data-[orientation=horizontal]:flex data-[orientation=horizontal]:flex-wrap",
|
|
10
|
+
item: "peer inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-border-strong bg-surface-1 transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 hover:border-accent disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:border-accent aria-invalid:border-danger",
|
|
11
|
+
dot: "h-2.5 w-2.5 rounded-full bg-accent",
|
|
12
|
+
label: "flex cursor-pointer items-start gap-3 text-sm text-fg has-disabled:cursor-not-allowed has-disabled:opacity-60",
|
|
13
|
+
card: "relative flex min-w-0 flex-col items-start gap-1 rounded-xl border border-border-default bg-surface-1 p-3 text-left text-sm text-fg transition-colors hover:border-border-strong focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:border-accent data-[state=checked]:bg-accent-soft data-[state=checked]:shadow-sm"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
var s = radioGroup();
|
|
17
|
+
function RadioGroupRoot({ label, invalid, className, ...props }) {
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
RadioGroupPrimitive.Root,
|
|
20
|
+
{
|
|
21
|
+
"aria-label": label,
|
|
22
|
+
"aria-invalid": invalid || void 0,
|
|
23
|
+
"data-invalid": invalid ? "" : void 0,
|
|
24
|
+
className: s.root({ className }),
|
|
25
|
+
...props
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function RadioGroupItem({ className, children, ...props }) {
|
|
30
|
+
const item = /* @__PURE__ */ jsx(RadioGroupPrimitive.Item, { className: s.item({ className: children ? "mt-0.5" : className }), ...props, children: /* @__PURE__ */ jsx(RadioGroupPrimitive.Indicator, { className: s.dot() }) });
|
|
31
|
+
if (!children) return item;
|
|
32
|
+
return /* @__PURE__ */ jsxs("label", { className: s.label({ className }), children: [
|
|
33
|
+
item,
|
|
34
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0", children })
|
|
35
|
+
] });
|
|
36
|
+
}
|
|
37
|
+
function RadioGroupCard({ className, ...props }) {
|
|
38
|
+
return /* @__PURE__ */ jsx(RadioGroupPrimitive.Item, { className: s.card({ className }), ...props });
|
|
39
|
+
}
|
|
40
|
+
var RadioGroup = { Root: RadioGroupRoot, Item: RadioGroupItem, Card: RadioGroupCard };
|
|
41
|
+
export {
|
|
42
|
+
RadioGroup,
|
|
43
|
+
RadioGroupCard,
|
|
44
|
+
RadioGroupItem,
|
|
45
|
+
RadioGroupRoot,
|
|
46
|
+
radioGroup
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=radio-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/radio-group/radio-group.tsx"],"sourcesContent":["// Client (a context). Radix RadioGroup: role=\"radiogroup\" / \"radio\", one tab stop, the arrows move and select, a\n// hidden input inside a form. Two looks: `RadioGroup.Item` (a dot and its words) and `RadioGroup.Card` (a whole card\n// is the radio: an amount, a pack, a payment method, a plan).\nimport { RadioGroup as RadioGroupPrimitive } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nexport const radioGroup = tv({\n slots: {\n root: \"grid gap-2 data-[orientation=horizontal]:flex data-[orientation=horizontal]:flex-wrap\",\n item:\n \"peer inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-border-strong bg-surface-1 transition-colors \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 \" +\n \"hover:border-accent disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:border-accent aria-invalid:border-danger\",\n dot: \"h-2.5 w-2.5 rounded-full bg-accent\",\n label: \"flex cursor-pointer items-start gap-3 text-sm text-fg has-disabled:cursor-not-allowed has-disabled:opacity-60\",\n card:\n \"relative flex min-w-0 flex-col items-start gap-1 rounded-xl border border-border-default bg-surface-1 p-3 text-left text-sm text-fg transition-colors \" +\n \"hover:border-border-strong focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring \" +\n \"disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:border-accent data-[state=checked]:bg-accent-soft \" +\n \"data-[state=checked]:shadow-sm\",\n },\n});\nconst s = radioGroup();\n\nexport type RadioGroupRootProps = React.ComponentProps<typeof RadioGroupPrimitive.Root> & {\n /** The group's accessible name — passed translated (or `aria-labelledby` a visible heading). */\n label?: string;\n /** Marks every radio invalid: aria-invalid (pair it with a `Field.Error`). */\n invalid?: boolean;\n};\n\n/** `value`/`defaultValue` + `onValueChange`, `orientation`, `required`, `name` for a form. */\nexport function RadioGroupRoot({ label, invalid, className, ...props }: RadioGroupRootProps) {\n return (\n <RadioGroupPrimitive.Root\n aria-label={label}\n aria-invalid={invalid || undefined}\n data-invalid={invalid ? \"\" : undefined}\n className={s.root({ className })}\n {...props}\n />\n );\n}\n\nexport type RadioGroupItemProps = Omit<React.ComponentProps<typeof RadioGroupPrimitive.Item>, \"children\"> & {\n /** The words next to the dot, clickable. Otherwise name it with `Field.Label htmlFor` or `aria-label`. */\n children?: React.ReactNode;\n};\n\n/** A radio: a dot, and its words when given. */\nexport function RadioGroupItem({ className, children, ...props }: RadioGroupItemProps) {\n const item = (\n <RadioGroupPrimitive.Item className={s.item({ className: children ? \"mt-0.5\" : className })} {...props}>\n <RadioGroupPrimitive.Indicator className={s.dot()} />\n </RadioGroupPrimitive.Item>\n );\n if (!children) return item;\n return (\n <label className={s.label({ className })}>\n {item}\n <span className=\"min-w-0\">{children}</span>\n </label>\n );\n}\n\n/** A whole card as the radio: its content is the radio's name. `data-state=\"checked\"` styles the chosen one. */\nexport function RadioGroupCard({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {\n return <RadioGroupPrimitive.Item className={s.card({ className })} {...props} />;\n}\n\n/** `RadioGroup.Root/Item/Card`. */\nexport const RadioGroup = { Root: RadioGroupRoot, Item: RadioGroupItem, Card: RadioGroupCard };\n"],"mappings":";;;AAGA,SAAS,cAAc,2BAA2B;AAElD,SAAS,UAAU;AA8Bf,cAwBA,YAxBA;AA5BG,IAAM,aAAa,GAAG;AAAA,EAC3B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,MACE;AAAA,IAGF,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MACE;AAAA,EAIJ;AACF,CAAC;AACD,IAAM,IAAI,WAAW;AAUd,SAAS,eAAe,EAAE,OAAO,SAAS,WAAW,GAAG,MAAM,GAAwB;AAC3F,SACE;AAAA,IAAC,oBAAoB;AAAA,IAApB;AAAA,MACC,cAAY;AAAA,MACZ,gBAAc,WAAW;AAAA,MACzB,gBAAc,UAAU,KAAK;AAAA,MAC7B,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC;AAAA,MAC9B,GAAG;AAAA;AAAA,EACN;AAEJ;AAQO,SAAS,eAAe,EAAE,WAAW,UAAU,GAAG,MAAM,GAAwB;AACrF,QAAM,OACJ,oBAAC,oBAAoB,MAApB,EAAyB,WAAW,EAAE,KAAK,EAAE,WAAW,WAAW,WAAW,UAAU,CAAC,GAAI,GAAG,OAC/F,8BAAC,oBAAoB,WAApB,EAA8B,WAAW,EAAE,IAAI,GAAG,GACrD;AAEF,MAAI,CAAC,SAAU,QAAO;AACtB,SACE,qBAAC,WAAM,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,GACpC;AAAA;AAAA,IACD,oBAAC,UAAK,WAAU,WAAW,UAAS;AAAA,KACtC;AAEJ;AAGO,SAAS,eAAe,EAAE,WAAW,GAAG,MAAM,GAA0D;AAC7G,SAAO,oBAAC,oBAAoB,MAApB,EAAyB,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,GAAI,GAAG,OAAO;AAChF;AAGO,IAAM,aAAa,EAAE,MAAM,gBAAgB,MAAM,gBAAgB,MAAM,eAAe;","names":[]}
|
package/dist/slider.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import { Slider as Slider$1 } from 'radix-ui';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
declare const slider: tailwind_variants.TVReturnType<{
|
|
6
|
+
[key: string]: {
|
|
7
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
8
|
+
root?: tailwind_variants.ClassValue;
|
|
9
|
+
header?: tailwind_variants.ClassValue;
|
|
10
|
+
value?: tailwind_variants.ClassValue;
|
|
11
|
+
control?: tailwind_variants.ClassValue;
|
|
12
|
+
track?: tailwind_variants.ClassValue;
|
|
13
|
+
range?: tailwind_variants.ClassValue;
|
|
14
|
+
thumb?: tailwind_variants.ClassValue;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
[x: string]: {
|
|
19
|
+
[x: string]: tailwind_variants.ClassValue | {
|
|
20
|
+
root?: tailwind_variants.ClassValue;
|
|
21
|
+
header?: tailwind_variants.ClassValue;
|
|
22
|
+
value?: tailwind_variants.ClassValue;
|
|
23
|
+
control?: tailwind_variants.ClassValue;
|
|
24
|
+
track?: tailwind_variants.ClassValue;
|
|
25
|
+
range?: tailwind_variants.ClassValue;
|
|
26
|
+
thumb?: tailwind_variants.ClassValue;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
} | {}, {
|
|
30
|
+
root: string;
|
|
31
|
+
header: string;
|
|
32
|
+
value: string;
|
|
33
|
+
control: string;
|
|
34
|
+
track: string;
|
|
35
|
+
range: string;
|
|
36
|
+
thumb: string;
|
|
37
|
+
}, undefined, {
|
|
38
|
+
[key: string]: {
|
|
39
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
40
|
+
root?: tailwind_variants.ClassValue;
|
|
41
|
+
header?: tailwind_variants.ClassValue;
|
|
42
|
+
value?: tailwind_variants.ClassValue;
|
|
43
|
+
control?: tailwind_variants.ClassValue;
|
|
44
|
+
track?: tailwind_variants.ClassValue;
|
|
45
|
+
range?: tailwind_variants.ClassValue;
|
|
46
|
+
thumb?: tailwind_variants.ClassValue;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
} | {}, {
|
|
50
|
+
root: string;
|
|
51
|
+
header: string;
|
|
52
|
+
value: string;
|
|
53
|
+
control: string;
|
|
54
|
+
track: string;
|
|
55
|
+
range: string;
|
|
56
|
+
thumb: string;
|
|
57
|
+
}, tailwind_variants.TVReturnTypeLike<unknown, {
|
|
58
|
+
root: string;
|
|
59
|
+
header: string;
|
|
60
|
+
value: string;
|
|
61
|
+
control: string;
|
|
62
|
+
track: string;
|
|
63
|
+
range: string;
|
|
64
|
+
thumb: string;
|
|
65
|
+
}>>;
|
|
66
|
+
type SliderValue = number | [number, number];
|
|
67
|
+
type SliderProps<V extends SliderValue = number> = Omit<React.ComponentProps<typeof Slider$1.Root>, "value" | "defaultValue" | "onValueChange" | "onValueCommit" | "children"> & {
|
|
68
|
+
/** One number (a thumb) or two (a range). Controlled with `onValueChange`. */
|
|
69
|
+
value?: V;
|
|
70
|
+
defaultValue?: V;
|
|
71
|
+
onValueChange?: (value: V) => void;
|
|
72
|
+
/** Called once the drag or the key press ends. */
|
|
73
|
+
onValueCommit?: (value: V) => void;
|
|
74
|
+
/** The accessible name — of the thumb, or of both thumbs of a range — passed translated. */
|
|
75
|
+
label: string;
|
|
76
|
+
/** For a range: each thumb's own name (["Minimum", "Maximum"]), passed translated. */
|
|
77
|
+
thumbLabels?: [string, string];
|
|
78
|
+
/** The value as words (aria-valuetext) and as shown: "1.5×", "−12 %", "3 min". */
|
|
79
|
+
formatValue?: (value: number) => string;
|
|
80
|
+
/** Shows the label and the value above the track. Without it, `label` only names the thumb. */
|
|
81
|
+
showLabel?: boolean;
|
|
82
|
+
/** Fills from this value instead of the minimum (a ±range from 0: brightness, balance). One thumb only. */
|
|
83
|
+
origin?: number;
|
|
84
|
+
};
|
|
85
|
+
/** A slider on one value or a range: `value`/`defaultValue` + `onValueChange`, `min`, `max`, `step`. */
|
|
86
|
+
declare function Slider<V extends SliderValue = number>({ value, defaultValue, onValueChange, onValueCommit, label, thumbLabels, formatValue, showLabel, origin, min, max, className, ...props }: SliderProps<V>): React.JSX.Element;
|
|
87
|
+
|
|
88
|
+
export { Slider, type SliderProps, type SliderValue, slider };
|
package/dist/slider.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/slider/slider.tsx
|
|
4
|
+
import { Slider as SliderPrimitive } from "radix-ui";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { tv } from "tailwind-variants";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var slider = tv({
|
|
9
|
+
slots: {
|
|
10
|
+
root: "flex flex-col gap-2",
|
|
11
|
+
header: "flex items-baseline justify-between gap-3 text-xs font-semibold text-fg-secondary",
|
|
12
|
+
value: "font-mono text-[11px] tabular-nums text-fg-secondary",
|
|
13
|
+
control: "relative flex h-6 w-full touch-none select-none items-center data-disabled:cursor-not-allowed data-disabled:opacity-40",
|
|
14
|
+
track: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-surface-3",
|
|
15
|
+
range: "absolute h-full rounded-full bg-linear-to-r from-accent to-accent-2",
|
|
16
|
+
thumb: "block h-5 w-5 cursor-grab rounded-full border border-border-strong bg-fg-on-media shadow-md transition-[box-shadow] focus-visible:outline-hidden focus-visible:ring-4 focus-visible:ring-ring/50 active:cursor-grabbing"
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var toArray = (v) => v === void 0 ? void 0 : typeof v === "number" ? [v] : v;
|
|
20
|
+
function Slider({
|
|
21
|
+
value,
|
|
22
|
+
defaultValue,
|
|
23
|
+
onValueChange,
|
|
24
|
+
onValueCommit,
|
|
25
|
+
label,
|
|
26
|
+
thumbLabels,
|
|
27
|
+
formatValue = String,
|
|
28
|
+
showLabel,
|
|
29
|
+
origin,
|
|
30
|
+
min = 0,
|
|
31
|
+
max = 100,
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}) {
|
|
35
|
+
const s = slider();
|
|
36
|
+
const range = Array.isArray(value ?? defaultValue);
|
|
37
|
+
const [inner, setInner] = React.useState(() => toArray(defaultValue) ?? [min]);
|
|
38
|
+
const current = toArray(value) ?? inner;
|
|
39
|
+
const out = (next) => range ? next : next[0];
|
|
40
|
+
const pct = (v) => (v - min) / (max - min || 1) * 100;
|
|
41
|
+
const fill = origin !== void 0 && !range ? { left: `${Math.min(pct(origin), pct(current[0]))}%`, right: `${100 - Math.max(pct(origin), pct(current[0]))}%` } : void 0;
|
|
42
|
+
const id = React.useId();
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", { className: s.root({ className }), "data-range": range ? "" : void 0, children: [
|
|
44
|
+
showLabel && /* @__PURE__ */ jsxs("div", { className: s.header(), children: [
|
|
45
|
+
/* @__PURE__ */ jsx("span", { id: `${id}-label`, children: label }),
|
|
46
|
+
/* @__PURE__ */ jsx("span", { className: s.value(), "aria-hidden": true, children: current.map(formatValue).join(" \u2013 ") })
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ jsxs(
|
|
49
|
+
SliderPrimitive.Root,
|
|
50
|
+
{
|
|
51
|
+
min,
|
|
52
|
+
max,
|
|
53
|
+
value: current,
|
|
54
|
+
onValueChange: (next) => {
|
|
55
|
+
if (value === void 0) setInner(next);
|
|
56
|
+
onValueChange?.(out(next));
|
|
57
|
+
},
|
|
58
|
+
onValueCommit: onValueCommit && ((next) => onValueCommit(out(next))),
|
|
59
|
+
className: s.control(),
|
|
60
|
+
...props,
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsx(SliderPrimitive.Track, { className: s.track(), children: fill ? /* @__PURE__ */ jsx("span", { "data-origin": "", className: s.range(), style: fill }) : /* @__PURE__ */ jsx(SliderPrimitive.Range, { className: s.range() }) }),
|
|
63
|
+
current.map((v, i) => /* @__PURE__ */ jsx(
|
|
64
|
+
SliderPrimitive.Thumb,
|
|
65
|
+
{
|
|
66
|
+
"aria-label": range ? thumbLabels?.[i] ?? label : showLabel ? void 0 : label,
|
|
67
|
+
"aria-labelledby": !range && showLabel ? `${id}-label` : void 0,
|
|
68
|
+
"aria-valuetext": formatValue(v),
|
|
69
|
+
className: s.thumb()
|
|
70
|
+
},
|
|
71
|
+
i
|
|
72
|
+
))
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] });
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
Slider,
|
|
80
|
+
slider
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/slider/slider.tsx"],"sourcesContent":["// Client. Radix Slider: role=\"slider\" on each thumb, arrows / Page Up / Page Down / Home / End, a range with two\n// thumbs. The words arrive as props: `label` names the thumb(s), `formatValue` gives the aria-valuetext and the value\n// shown next to a visible label.\nimport { Slider as SliderPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nexport const slider = tv({\n slots: {\n root: \"flex flex-col gap-2\",\n header: \"flex items-baseline justify-between gap-3 text-xs font-semibold text-fg-secondary\",\n value: \"font-mono text-[11px] tabular-nums text-fg-secondary\",\n control:\n \"relative flex h-6 w-full touch-none select-none items-center data-disabled:cursor-not-allowed data-disabled:opacity-40\",\n track: \"relative h-1.5 w-full grow overflow-hidden rounded-full bg-surface-3\",\n range: \"absolute h-full rounded-full bg-linear-to-r from-accent to-accent-2\",\n thumb:\n \"block h-5 w-5 cursor-grab rounded-full border border-border-strong bg-fg-on-media shadow-md transition-[box-shadow] \" +\n \"focus-visible:outline-hidden focus-visible:ring-4 focus-visible:ring-ring/50 active:cursor-grabbing\",\n },\n});\n\nexport type SliderValue = number | [number, number];\n\nexport type SliderProps<V extends SliderValue = number> = Omit<\n React.ComponentProps<typeof SliderPrimitive.Root>,\n \"value\" | \"defaultValue\" | \"onValueChange\" | \"onValueCommit\" | \"children\"\n> & {\n /** One number (a thumb) or two (a range). Controlled with `onValueChange`. */\n value?: V;\n defaultValue?: V;\n onValueChange?: (value: V) => void;\n /** Called once the drag or the key press ends. */\n onValueCommit?: (value: V) => void;\n /** The accessible name — of the thumb, or of both thumbs of a range — passed translated. */\n label: string;\n /** For a range: each thumb's own name ([\"Minimum\", \"Maximum\"]), passed translated. */\n thumbLabels?: [string, string];\n /** The value as words (aria-valuetext) and as shown: \"1.5×\", \"−12 %\", \"3 min\". */\n formatValue?: (value: number) => string;\n /** Shows the label and the value above the track. Without it, `label` only names the thumb. */\n showLabel?: boolean;\n /** Fills from this value instead of the minimum (a ±range from 0: brightness, balance). One thumb only. */\n origin?: number;\n};\n\nconst toArray = (v: SliderValue | undefined) => (v === undefined ? undefined : typeof v === \"number\" ? [v] : v);\n\n/** A slider on one value or a range: `value`/`defaultValue` + `onValueChange`, `min`, `max`, `step`. */\nexport function Slider<V extends SliderValue = number>({\n value,\n defaultValue,\n onValueChange,\n onValueCommit,\n label,\n thumbLabels,\n formatValue = String,\n showLabel,\n origin,\n min = 0,\n max = 100,\n className,\n ...props\n}: SliderProps<V>) {\n const s = slider();\n const range = Array.isArray(value ?? defaultValue);\n const [inner, setInner] = React.useState(() => toArray(defaultValue) ?? [min]);\n const current = toArray(value) ?? inner;\n const out = (next: number[]) => (range ? next : next[0]) as V;\n const pct = (v: number) => ((v - min) / (max - min || 1)) * 100;\n const fill =\n origin !== undefined && !range\n ? { left: `${Math.min(pct(origin), pct(current[0]))}%`, right: `${100 - Math.max(pct(origin), pct(current[0]))}%` }\n : undefined;\n const id = React.useId();\n return (\n <div className={s.root({ className })} data-range={range ? \"\" : undefined}>\n {showLabel && (\n <div className={s.header()}>\n <span id={`${id}-label`}>{label}</span>\n <span className={s.value()} aria-hidden>\n {current.map(formatValue).join(\" – \")}\n </span>\n </div>\n )}\n <SliderPrimitive.Root\n min={min}\n max={max}\n value={current}\n onValueChange={(next) => {\n if (value === undefined) setInner(next);\n onValueChange?.(out(next));\n }}\n onValueCommit={onValueCommit && ((next) => onValueCommit(out(next)))}\n className={s.control()}\n {...props}\n >\n <SliderPrimitive.Track className={s.track()}>\n {fill ? <span data-origin=\"\" className={s.range()} style={fill} /> : <SliderPrimitive.Range className={s.range()} />}\n </SliderPrimitive.Track>\n {current.map((v, i) => (\n <SliderPrimitive.Thumb\n key={i}\n aria-label={range ? (thumbLabels?.[i] ?? label) : showLabel ? undefined : label}\n aria-labelledby={!range && showLabel ? `${id}-label` : undefined}\n aria-valuetext={formatValue(v)}\n className={s.thumb()}\n />\n ))}\n </SliderPrimitive.Root>\n </div>\n );\n}\n"],"mappings":";;;AAGA,SAAS,UAAU,uBAAuB;AAC1C,YAAY,WAAW;AACvB,SAAS,UAAU;AAyEX,SACE,KADF;AAvED,IAAM,SAAS,GAAG;AAAA,EACvB,OAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,SACE;AAAA,IACF,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OACE;AAAA,EAEJ;AACF,CAAC;AA0BD,IAAM,UAAU,CAAC,MAAgC,MAAM,SAAY,SAAY,OAAO,MAAM,WAAW,CAAC,CAAC,IAAI;AAGtG,SAAS,OAAuC;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,MAAM;AAAA,EACN;AAAA,EACA,GAAG;AACL,GAAmB;AACjB,QAAM,IAAI,OAAO;AACjB,QAAM,QAAQ,MAAM,QAAQ,SAAS,YAAY;AACjD,QAAM,CAAC,OAAO,QAAQ,IAAU,eAAS,MAAM,QAAQ,YAAY,KAAK,CAAC,GAAG,CAAC;AAC7E,QAAM,UAAU,QAAQ,KAAK,KAAK;AAClC,QAAM,MAAM,CAAC,SAAoB,QAAQ,OAAO,KAAK,CAAC;AACtD,QAAM,MAAM,CAAC,OAAgB,IAAI,QAAQ,MAAM,OAAO,KAAM;AAC5D,QAAM,OACJ,WAAW,UAAa,CAAC,QACrB,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI,MAAM,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,MAAM,KAAK,IAAI,IAAI,MAAM,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,IAChH;AACN,QAAM,KAAW,YAAM;AACvB,SACE,qBAAC,SAAI,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,cAAY,QAAQ,KAAK,QAC7D;AAAA,iBACC,qBAAC,SAAI,WAAW,EAAE,OAAO,GACvB;AAAA,0BAAC,UAAK,IAAI,GAAG,EAAE,UAAW,iBAAM;AAAA,MAChC,oBAAC,UAAK,WAAW,EAAE,MAAM,GAAG,eAAW,MACpC,kBAAQ,IAAI,WAAW,EAAE,KAAK,UAAK,GACtC;AAAA,OACF;AAAA,IAEF;AAAA,MAAC,gBAAgB;AAAA,MAAhB;AAAA,QACC;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP,eAAe,CAAC,SAAS;AACvB,cAAI,UAAU,OAAW,UAAS,IAAI;AACtC,0BAAgB,IAAI,IAAI,CAAC;AAAA,QAC3B;AAAA,QACA,eAAe,kBAAkB,CAAC,SAAS,cAAc,IAAI,IAAI,CAAC;AAAA,QAClE,WAAW,EAAE,QAAQ;AAAA,QACpB,GAAG;AAAA,QAEJ;AAAA,8BAAC,gBAAgB,OAAhB,EAAsB,WAAW,EAAE,MAAM,GACvC,iBAAO,oBAAC,UAAK,eAAY,IAAG,WAAW,EAAE,MAAM,GAAG,OAAO,MAAM,IAAK,oBAAC,gBAAgB,OAAhB,EAAsB,WAAW,EAAE,MAAM,GAAG,GACpH;AAAA,UACC,QAAQ,IAAI,CAAC,GAAG,MACf;AAAA,YAAC,gBAAgB;AAAA,YAAhB;AAAA,cAEC,cAAY,QAAS,cAAc,CAAC,KAAK,QAAS,YAAY,SAAY;AAAA,cAC1E,mBAAiB,CAAC,SAAS,YAAY,GAAG,EAAE,WAAW;AAAA,cACvD,kBAAgB,YAAY,CAAC;AAAA,cAC7B,WAAW,EAAE,MAAM;AAAA;AAAA,YAJd;AAAA,UAKP,CACD;AAAA;AAAA;AAAA,IACH;AAAA,KACF;AAEJ;","names":[]}
|
package/dist/switch.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import { VariantProps } from 'tailwind-variants';
|
|
3
|
+
import { Switch as Switch$1 } from 'radix-ui';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
declare const switchVariants: tailwind_variants.TVReturnType<{
|
|
7
|
+
size: {
|
|
8
|
+
sm: {
|
|
9
|
+
root: string;
|
|
10
|
+
thumb: string;
|
|
11
|
+
};
|
|
12
|
+
md: {
|
|
13
|
+
root: string;
|
|
14
|
+
thumb: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}, {
|
|
18
|
+
root: string;
|
|
19
|
+
thumb: string;
|
|
20
|
+
}, undefined, {
|
|
21
|
+
size: {
|
|
22
|
+
sm: {
|
|
23
|
+
root: string;
|
|
24
|
+
thumb: string;
|
|
25
|
+
};
|
|
26
|
+
md: {
|
|
27
|
+
root: string;
|
|
28
|
+
thumb: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}, {
|
|
32
|
+
root: string;
|
|
33
|
+
thumb: string;
|
|
34
|
+
}, tailwind_variants.TVReturnTypeLike<{
|
|
35
|
+
size: {
|
|
36
|
+
sm: {
|
|
37
|
+
root: string;
|
|
38
|
+
thumb: string;
|
|
39
|
+
};
|
|
40
|
+
md: {
|
|
41
|
+
root: string;
|
|
42
|
+
thumb: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}, {
|
|
46
|
+
root: string;
|
|
47
|
+
thumb: string;
|
|
48
|
+
}>>;
|
|
49
|
+
type SwitchVariants = VariantProps<typeof switchVariants>;
|
|
50
|
+
type Named =
|
|
51
|
+
/** The accessible name — required when no visible label names it, passed translated. */
|
|
52
|
+
{
|
|
53
|
+
label: string;
|
|
54
|
+
}
|
|
55
|
+
/** Named by a visible `<label htmlFor={id}>` (e.g. `Field.Label`). */
|
|
56
|
+
| {
|
|
57
|
+
label?: undefined;
|
|
58
|
+
id: string;
|
|
59
|
+
}
|
|
60
|
+
/** Named by another element. */
|
|
61
|
+
| {
|
|
62
|
+
label?: undefined;
|
|
63
|
+
"aria-labelledby": string;
|
|
64
|
+
};
|
|
65
|
+
type SwitchProps = Omit<React.ComponentProps<typeof Switch$1.Root>, "children"> & SwitchVariants & Named & {
|
|
66
|
+
/** Marks it invalid: aria-invalid and data-invalid. */
|
|
67
|
+
invalid?: boolean;
|
|
68
|
+
};
|
|
69
|
+
/** An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`. */
|
|
70
|
+
declare function Switch({ label, size, invalid, className, ...props }: SwitchProps): React.JSX.Element;
|
|
71
|
+
|
|
72
|
+
export { Switch, type SwitchProps, type SwitchVariants, switchVariants };
|
package/dist/switch.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/switch/switch.tsx
|
|
4
|
+
import { Switch as SwitchPrimitive } from "radix-ui";
|
|
5
|
+
import { tv } from "tailwind-variants";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var switchVariants = tv({
|
|
8
|
+
slots: {
|
|
9
|
+
root: "peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-fg-muted transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:bg-accent aria-invalid:border-danger",
|
|
10
|
+
thumb: "pointer-events-none block rounded-full bg-fg-on-media shadow-sm transition-transform data-[state=unchecked]:translate-x-0.5 motion-reduce:transition-none"
|
|
11
|
+
},
|
|
12
|
+
variants: {
|
|
13
|
+
size: {
|
|
14
|
+
sm: { root: "h-5 w-9", thumb: "h-4 w-4 data-[state=checked]:translate-x-[1.125rem]" },
|
|
15
|
+
md: { root: "h-6 w-11", thumb: "h-5 w-5 data-[state=checked]:translate-x-[1.375rem]" }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: { size: "md" }
|
|
19
|
+
});
|
|
20
|
+
function Switch({ label, size, invalid, className, ...props }) {
|
|
21
|
+
const s = switchVariants({ size });
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
SwitchPrimitive.Root,
|
|
24
|
+
{
|
|
25
|
+
"aria-label": label,
|
|
26
|
+
"aria-invalid": invalid || void 0,
|
|
27
|
+
"data-invalid": invalid ? "" : void 0,
|
|
28
|
+
className: s.root({ className }),
|
|
29
|
+
...props,
|
|
30
|
+
children: /* @__PURE__ */ jsx(SwitchPrimitive.Thumb, { className: s.thumb() })
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
Switch,
|
|
36
|
+
switchVariants
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/switch/switch.tsx"],"sourcesContent":["// Client. Radix Switch: role=\"switch\", aria-checked, Space and Enter toggle, a hidden input inside a form.\nimport { Switch as SwitchPrimitive } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const switchVariants = tv({\n slots: {\n root:\n \"peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-fg-muted transition-colors \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 \" +\n \"disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:bg-accent aria-invalid:border-danger\",\n thumb:\n \"pointer-events-none block rounded-full bg-fg-on-media shadow-sm transition-transform data-[state=unchecked]:translate-x-0.5 motion-reduce:transition-none\",\n },\n variants: {\n size: {\n sm: { root: \"h-5 w-9\", thumb: \"h-4 w-4 data-[state=checked]:translate-x-[1.125rem]\" },\n md: { root: \"h-6 w-11\", thumb: \"h-5 w-5 data-[state=checked]:translate-x-[1.375rem]\" },\n },\n },\n defaultVariants: { size: \"md\" },\n});\n\nexport type SwitchVariants = VariantProps<typeof switchVariants>;\n\ntype Named =\n /** The accessible name — required when no visible label names it, passed translated. */\n | { label: string }\n /** Named by a visible `<label htmlFor={id}>` (e.g. `Field.Label`). */\n | { label?: undefined; id: string }\n /** Named by another element. */\n | { label?: undefined; \"aria-labelledby\": string };\n\nexport type SwitchProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, \"children\"> &\n SwitchVariants &\n Named & {\n /** Marks it invalid: aria-invalid and data-invalid. */\n invalid?: boolean;\n };\n\n/** An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`. */\nexport function Switch({ label, size, invalid, className, ...props }: SwitchProps) {\n const s = switchVariants({ size });\n return (\n <SwitchPrimitive.Root\n aria-label={label}\n aria-invalid={invalid || undefined}\n data-invalid={invalid ? \"\" : undefined}\n className={s.root({ className })}\n {...props}\n >\n <SwitchPrimitive.Thumb className={s.thumb()} />\n </SwitchPrimitive.Root>\n );\n}\n"],"mappings":";;;AACA,SAAS,UAAU,uBAAuB;AAE1C,SAAS,UAA6B;AAgDhC;AA9CC,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MACE;AAAA,IAGF,OACE;AAAA,EACJ;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI,EAAE,MAAM,WAAW,OAAO,sDAAsD;AAAA,MACpF,IAAI,EAAE,MAAM,YAAY,OAAO,sDAAsD;AAAA,IACvF;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,MAAM,KAAK;AAChC,CAAC;AAoBM,SAAS,OAAO,EAAE,OAAO,MAAM,SAAS,WAAW,GAAG,MAAM,GAAgB;AACjF,QAAM,IAAI,eAAe,EAAE,KAAK,CAAC;AACjC,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,cAAY;AAAA,MACZ,gBAAc,WAAW;AAAA,MACzB,gBAAc,UAAU,KAAK;AAAA,MAC7B,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC;AAAA,MAC9B,GAAG;AAAA,MAEJ,8BAAC,gBAAgB,OAAhB,EAAsB,WAAW,EAAE,MAAM,GAAG;AAAA;AAAA,EAC/C;AAEJ;","names":[]}
|
package/dist/tabs.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import { VariantProps } from 'tailwind-variants';
|
|
3
|
+
import { Tabs as Tabs$1 } from 'radix-ui';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
declare const tabs: tailwind_variants.TVReturnType<{
|
|
7
|
+
variant: {
|
|
8
|
+
underline: {
|
|
9
|
+
list: string;
|
|
10
|
+
trigger: string;
|
|
11
|
+
};
|
|
12
|
+
segmented: {
|
|
13
|
+
list: string;
|
|
14
|
+
trigger: string;
|
|
15
|
+
};
|
|
16
|
+
pills: {
|
|
17
|
+
list: string;
|
|
18
|
+
trigger: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}, {
|
|
22
|
+
root: string;
|
|
23
|
+
list: string;
|
|
24
|
+
trigger: string;
|
|
25
|
+
content: string;
|
|
26
|
+
}, undefined, {
|
|
27
|
+
variant: {
|
|
28
|
+
underline: {
|
|
29
|
+
list: string;
|
|
30
|
+
trigger: string;
|
|
31
|
+
};
|
|
32
|
+
segmented: {
|
|
33
|
+
list: string;
|
|
34
|
+
trigger: string;
|
|
35
|
+
};
|
|
36
|
+
pills: {
|
|
37
|
+
list: string;
|
|
38
|
+
trigger: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}, {
|
|
42
|
+
root: string;
|
|
43
|
+
list: string;
|
|
44
|
+
trigger: string;
|
|
45
|
+
content: string;
|
|
46
|
+
}, tailwind_variants.TVReturnTypeLike<{
|
|
47
|
+
variant: {
|
|
48
|
+
underline: {
|
|
49
|
+
list: string;
|
|
50
|
+
trigger: string;
|
|
51
|
+
};
|
|
52
|
+
segmented: {
|
|
53
|
+
list: string;
|
|
54
|
+
trigger: string;
|
|
55
|
+
};
|
|
56
|
+
pills: {
|
|
57
|
+
list: string;
|
|
58
|
+
trigger: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}, {
|
|
62
|
+
root: string;
|
|
63
|
+
list: string;
|
|
64
|
+
trigger: string;
|
|
65
|
+
content: string;
|
|
66
|
+
}>>;
|
|
67
|
+
type TabsVariants = VariantProps<typeof tabs>;
|
|
68
|
+
type TabsRootProps = React.ComponentProps<typeof Tabs$1.Root> & TabsVariants;
|
|
69
|
+
/** `value`/`defaultValue` + `onValueChange`, `orientation` (horizontal by default), `variant` for the list. */
|
|
70
|
+
declare function TabsRoot({ variant, className, ...props }: TabsRootProps): React.JSX.Element;
|
|
71
|
+
/** The tabs. Name it (`aria-label`) when no heading says what it switches. */
|
|
72
|
+
declare function TabsList({ className, ...props }: React.ComponentProps<typeof Tabs$1.List>): React.JSX.Element;
|
|
73
|
+
declare function TabsTrigger({ className, ...props }: React.ComponentProps<typeof Tabs$1.Trigger>): React.JSX.Element;
|
|
74
|
+
declare function TabsContent({ className, ...props }: React.ComponentProps<typeof Tabs$1.Content>): React.JSX.Element;
|
|
75
|
+
/** `Tabs.Root/List/Trigger/Content` — `variant` underline · segmented · pills on the root. */
|
|
76
|
+
declare const Tabs: {
|
|
77
|
+
Root: typeof TabsRoot;
|
|
78
|
+
List: typeof TabsList;
|
|
79
|
+
Trigger: typeof TabsTrigger;
|
|
80
|
+
Content: typeof TabsContent;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export { Tabs, TabsContent, TabsList, TabsRoot, type TabsRootProps, TabsTrigger, type TabsVariants, tabs };
|
package/dist/tabs.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/tabs/tabs.tsx
|
|
4
|
+
import { Tabs as TabsPrimitive } from "radix-ui";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { tv } from "tailwind-variants";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var tabs = tv({
|
|
9
|
+
slots: {
|
|
10
|
+
root: "flex gap-4 data-[orientation=horizontal]:flex-col data-[orientation=vertical]:flex-row",
|
|
11
|
+
list: "flex shrink-0 data-[orientation=vertical]:flex-col",
|
|
12
|
+
trigger: "inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap font-semibold transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40",
|
|
13
|
+
content: "kz-fade min-w-0 flex-1 rounded-lg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
|
|
14
|
+
},
|
|
15
|
+
variants: {
|
|
16
|
+
variant: {
|
|
17
|
+
/* The section of a page: a line under the list, the active tab underlined in the accent. */
|
|
18
|
+
underline: {
|
|
19
|
+
list: "gap-1 border-border-default data-[orientation=horizontal]:border-b data-[orientation=vertical]:border-r",
|
|
20
|
+
trigger: "relative rounded-md px-3 py-2.5 text-sm text-fg-secondary hover:text-fg data-[state=active]:text-fg after:absolute after:rounded-full after:bg-transparent data-[state=active]:after:bg-accent data-[orientation=horizontal]:after:inset-x-2 data-[orientation=horizontal]:after:-bottom-px data-[orientation=horizontal]:after:h-0.5 data-[orientation=vertical]:justify-start data-[orientation=vertical]:after:inset-y-1.5 data-[orientation=vertical]:after:-right-px data-[orientation=vertical]:after:w-0.5"
|
|
21
|
+
},
|
|
22
|
+
/* A view switch: equal segments in a track, the active one filled. */
|
|
23
|
+
segmented: {
|
|
24
|
+
list: "inline-grid auto-cols-fr grid-flow-col gap-1 self-start rounded-xl border border-border-default bg-surface-1 p-1 data-[orientation=vertical]:grid-flow-row",
|
|
25
|
+
trigger: "min-h-8 rounded-lg px-3 py-1.5 text-xs text-fg-secondary hover:bg-surface-2 hover:text-fg data-[state=active]:bg-accent data-[state=active]:text-on-accent data-[state=active]:shadow-sm data-[state=active]:hover:bg-accent"
|
|
26
|
+
},
|
|
27
|
+
/* Pills that scroll sideways on a phone: a feed's sections. */
|
|
28
|
+
pills: {
|
|
29
|
+
list: "gap-1.5 overflow-x-auto overscroll-x-contain [scrollbar-width:none] data-[orientation=horizontal]:pb-1",
|
|
30
|
+
trigger: "h-9 rounded-full border border-border-default bg-surface-1 px-4 text-xs text-fg-secondary hover:border-border-strong hover:text-fg data-[state=active]:border-accent data-[state=active]:bg-accent-soft data-[state=active]:text-fg"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: { variant: "underline" }
|
|
35
|
+
});
|
|
36
|
+
var VariantContext = React.createContext("underline");
|
|
37
|
+
function TabsRoot({ variant = "underline", className, ...props }) {
|
|
38
|
+
return /* @__PURE__ */ jsx(VariantContext.Provider, { value: variant, children: /* @__PURE__ */ jsx(TabsPrimitive.Root, { "data-variant": variant, className: tabs({ variant }).root({ className }), ...props }) });
|
|
39
|
+
}
|
|
40
|
+
function TabsList({ className, ...props }) {
|
|
41
|
+
const variant = React.useContext(VariantContext);
|
|
42
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.List, { "data-variant": variant, className: tabs({ variant }).list({ className }), ...props });
|
|
43
|
+
}
|
|
44
|
+
function TabsTrigger({ className, ...props }) {
|
|
45
|
+
const variant = React.useContext(VariantContext);
|
|
46
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.Trigger, { className: tabs({ variant }).trigger({ className }), ...props });
|
|
47
|
+
}
|
|
48
|
+
function TabsContent({ className, ...props }) {
|
|
49
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.Content, { className: tabs().content({ className }), ...props });
|
|
50
|
+
}
|
|
51
|
+
var Tabs = { Root: TabsRoot, List: TabsList, Trigger: TabsTrigger, Content: TabsContent };
|
|
52
|
+
export {
|
|
53
|
+
Tabs,
|
|
54
|
+
TabsContent,
|
|
55
|
+
TabsList,
|
|
56
|
+
TabsRoot,
|
|
57
|
+
TabsTrigger,
|
|
58
|
+
tabs
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=tabs.js.map
|
package/dist/tabs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tabs/tabs.tsx"],"sourcesContent":["// Client (a context). Radix Tabs does the roles (tablist, tab, tabpanel), the aria-selected / aria-controls wiring,\n// the roving focus (arrows, Home, End) and automatic activation: this file only holds the three looks.\nimport { Tabs as TabsPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const tabs = tv({\n slots: {\n root: \"flex gap-4 data-[orientation=horizontal]:flex-col data-[orientation=vertical]:flex-row\",\n list: \"flex shrink-0 data-[orientation=vertical]:flex-col\",\n trigger:\n \"inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap font-semibold transition-colors \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40\",\n content: \"kz-fade min-w-0 flex-1 rounded-lg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\",\n },\n variants: {\n variant: {\n /* The section of a page: a line under the list, the active tab underlined in the accent. */\n underline: {\n list: \"gap-1 border-border-default data-[orientation=horizontal]:border-b data-[orientation=vertical]:border-r\",\n trigger:\n \"relative rounded-md px-3 py-2.5 text-sm text-fg-secondary hover:text-fg data-[state=active]:text-fg \" +\n \"after:absolute after:rounded-full after:bg-transparent data-[state=active]:after:bg-accent \" +\n \"data-[orientation=horizontal]:after:inset-x-2 data-[orientation=horizontal]:after:-bottom-px data-[orientation=horizontal]:after:h-0.5 \" +\n \"data-[orientation=vertical]:justify-start data-[orientation=vertical]:after:inset-y-1.5 data-[orientation=vertical]:after:-right-px data-[orientation=vertical]:after:w-0.5\",\n },\n /* A view switch: equal segments in a track, the active one filled. */\n segmented: {\n list: \"inline-grid auto-cols-fr grid-flow-col gap-1 self-start rounded-xl border border-border-default bg-surface-1 p-1 data-[orientation=vertical]:grid-flow-row\",\n trigger:\n \"min-h-8 rounded-lg px-3 py-1.5 text-xs text-fg-secondary hover:bg-surface-2 hover:text-fg \" +\n \"data-[state=active]:bg-accent data-[state=active]:text-on-accent data-[state=active]:shadow-sm data-[state=active]:hover:bg-accent\",\n },\n /* Pills that scroll sideways on a phone: a feed's sections. */\n pills: {\n list: \"gap-1.5 overflow-x-auto overscroll-x-contain [scrollbar-width:none] data-[orientation=horizontal]:pb-1\",\n trigger:\n \"h-9 rounded-full border border-border-default bg-surface-1 px-4 text-xs text-fg-secondary hover:border-border-strong hover:text-fg \" +\n \"data-[state=active]:border-accent data-[state=active]:bg-accent-soft data-[state=active]:text-fg\",\n },\n },\n },\n defaultVariants: { variant: \"underline\" },\n});\n\nexport type TabsVariants = VariantProps<typeof tabs>;\ntype Variant = NonNullable<TabsVariants[\"variant\"]>;\n\nconst VariantContext = React.createContext<Variant>(\"underline\");\n\nexport type TabsRootProps = React.ComponentProps<typeof TabsPrimitive.Root> & TabsVariants;\n\n/** `value`/`defaultValue` + `onValueChange`, `orientation` (horizontal by default), `variant` for the list. */\nexport function TabsRoot({ variant = \"underline\", className, ...props }: TabsRootProps) {\n return (\n <VariantContext.Provider value={variant}>\n <TabsPrimitive.Root data-variant={variant} className={tabs({ variant }).root({ className })} {...props} />\n </VariantContext.Provider>\n );\n}\n\n/** The tabs. Name it (`aria-label`) when no heading says what it switches. */\nexport function TabsList({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.List>) {\n const variant = React.useContext(VariantContext);\n return <TabsPrimitive.List data-variant={variant} className={tabs({ variant }).list({ className })} {...props} />;\n}\n\nexport function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>) {\n const variant = React.useContext(VariantContext);\n return <TabsPrimitive.Trigger className={tabs({ variant }).trigger({ className })} {...props} />;\n}\n\nexport function TabsContent({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Content>) {\n return <TabsPrimitive.Content className={tabs().content({ className })} {...props} />;\n}\n\n/** `Tabs.Root/List/Trigger/Content` — `variant` underline · segmented · pills on the root. */\nexport const Tabs = { Root: TabsRoot, List: TabsList, Trigger: TabsTrigger, Content: TabsContent };\n"],"mappings":";;;AAEA,SAAS,QAAQ,qBAAqB;AACtC,YAAY,WAAW;AACvB,SAAS,UAA6B;AAoDhC;AAlDC,IAAM,OAAO,GAAG;AAAA,EACrB,OAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,IAEF,SAAS;AAAA,EACX;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA;AAAA,MAEP,WAAW;AAAA,QACT,MAAM;AAAA,QACN,SACE;AAAA,MAIJ;AAAA;AAAA,MAEA,WAAW;AAAA,QACT,MAAM;AAAA,QACN,SACE;AAAA,MAEJ;AAAA;AAAA,MAEA,OAAO;AAAA,QACL,MAAM;AAAA,QACN,SACE;AAAA,MAEJ;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,SAAS,YAAY;AAC1C,CAAC;AAKD,IAAM,iBAAuB,oBAAuB,WAAW;AAKxD,SAAS,SAAS,EAAE,UAAU,aAAa,WAAW,GAAG,MAAM,GAAkB;AACtF,SACE,oBAAC,eAAe,UAAf,EAAwB,OAAO,SAC9B,8BAAC,cAAc,MAAd,EAAmB,gBAAc,SAAS,WAAW,KAAK,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,GAAI,GAAG,OAAO,GAC1G;AAEJ;AAGO,SAAS,SAAS,EAAE,WAAW,GAAG,MAAM,GAAoD;AACjG,QAAM,UAAgB,iBAAW,cAAc;AAC/C,SAAO,oBAAC,cAAc,MAAd,EAAmB,gBAAc,SAAS,WAAW,KAAK,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,GAAI,GAAG,OAAO;AACjH;AAEO,SAAS,YAAY,EAAE,WAAW,GAAG,MAAM,GAAuD;AACvG,QAAM,UAAgB,iBAAW,cAAc;AAC/C,SAAO,oBAAC,cAAc,SAAd,EAAsB,WAAW,KAAK,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,GAAI,GAAG,OAAO;AAChG;AAEO,SAAS,YAAY,EAAE,WAAW,GAAG,MAAM,GAAuD;AACvG,SAAO,oBAAC,cAAc,SAAd,EAAsB,WAAW,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,GAAI,GAAG,OAAO;AACrF;AAGO,IAAM,OAAO,EAAE,MAAM,UAAU,MAAM,UAAU,SAAS,aAAa,SAAS,YAAY;","names":[]}
|
package/dist/theme.d.ts
CHANGED
|
@@ -1,63 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
declare const buttonVariants: tailwind_variants.TVReturnType<{
|
|
6
|
-
variant: {
|
|
7
|
-
primary: "bg-accent text-on-accent shadow-sm hover:bg-accent-hover";
|
|
8
|
-
secondary: "border border-border-default bg-surface-2 text-fg hover:border-border-strong hover:bg-surface-3";
|
|
9
|
-
outline: "border border-border-default bg-transparent text-fg hover:border-accent hover:text-accent";
|
|
10
|
-
ghost: "text-fg-secondary hover:bg-surface-2 hover:text-fg";
|
|
11
|
-
danger: "border border-danger/50 bg-danger/10 text-fg hover:border-danger hover:bg-danger/20";
|
|
12
|
-
};
|
|
13
|
-
size: {
|
|
14
|
-
sm: "h-8 px-3 text-xs";
|
|
15
|
-
md: "h-10 px-4 text-sm";
|
|
16
|
-
lg: "h-12 px-6 text-sm";
|
|
17
|
-
icon: "h-10 w-10";
|
|
18
|
-
};
|
|
19
|
-
shape: {
|
|
20
|
-
rounded: "rounded-lg";
|
|
21
|
-
pill: "rounded-full";
|
|
22
|
-
};
|
|
23
|
-
}, undefined, string, {
|
|
24
|
-
variant: {
|
|
25
|
-
primary: "bg-accent text-on-accent shadow-sm hover:bg-accent-hover";
|
|
26
|
-
secondary: "border border-border-default bg-surface-2 text-fg hover:border-border-strong hover:bg-surface-3";
|
|
27
|
-
outline: "border border-border-default bg-transparent text-fg hover:border-accent hover:text-accent";
|
|
28
|
-
ghost: "text-fg-secondary hover:bg-surface-2 hover:text-fg";
|
|
29
|
-
danger: "border border-danger/50 bg-danger/10 text-fg hover:border-danger hover:bg-danger/20";
|
|
30
|
-
};
|
|
31
|
-
size: {
|
|
32
|
-
sm: "h-8 px-3 text-xs";
|
|
33
|
-
md: "h-10 px-4 text-sm";
|
|
34
|
-
lg: "h-12 px-6 text-sm";
|
|
35
|
-
icon: "h-10 w-10";
|
|
36
|
-
};
|
|
37
|
-
shape: {
|
|
38
|
-
rounded: "rounded-lg";
|
|
39
|
-
pill: "rounded-full";
|
|
40
|
-
};
|
|
41
|
-
}, undefined, tailwind_variants.TVReturnTypeLike<{
|
|
42
|
-
variant: {
|
|
43
|
-
primary: "bg-accent text-on-accent shadow-sm hover:bg-accent-hover";
|
|
44
|
-
secondary: "border border-border-default bg-surface-2 text-fg hover:border-border-strong hover:bg-surface-3";
|
|
45
|
-
outline: "border border-border-default bg-transparent text-fg hover:border-accent hover:text-accent";
|
|
46
|
-
ghost: "text-fg-secondary hover:bg-surface-2 hover:text-fg";
|
|
47
|
-
danger: "border border-danger/50 bg-danger/10 text-fg hover:border-danger hover:bg-danger/20";
|
|
48
|
-
};
|
|
49
|
-
size: {
|
|
50
|
-
sm: "h-8 px-3 text-xs";
|
|
51
|
-
md: "h-10 px-4 text-sm";
|
|
52
|
-
lg: "h-12 px-6 text-sm";
|
|
53
|
-
icon: "h-10 w-10";
|
|
54
|
-
};
|
|
55
|
-
shape: {
|
|
56
|
-
rounded: "rounded-lg";
|
|
57
|
-
pill: "rounded-full";
|
|
58
|
-
};
|
|
59
|
-
}, undefined>>;
|
|
60
|
-
type ButtonVariants = VariantProps<typeof buttonVariants>;
|
|
2
|
+
import { a as ButtonVariants } from './button-G5qY4qSY.js';
|
|
3
|
+
import 'tailwind-variants';
|
|
61
4
|
|
|
62
5
|
type Mode = "dark" | "light" | "system";
|
|
63
6
|
/**
|
package/dist/toast.js
CHANGED