@krizaka/ui 3.2.0 → 3.3.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/{chunk-I5RVM5CW.js → chunk-2FRWNSRO.js} +2 -6
- package/dist/chunk-2FRWNSRO.js.map +1 -0
- package/dist/chunk-BTMFZ66D.js +135 -0
- package/dist/chunk-BTMFZ66D.js.map +1 -0
- package/dist/chunk-C2BRIFJG.js +13 -0
- package/dist/chunk-C2BRIFJG.js.map +1 -0
- package/dist/chunk-KDXRYUD3.js +39 -0
- package/dist/chunk-KDXRYUD3.js.map +1 -0
- package/dist/{chunk-2PUDI7JS.js → chunk-ZKVQGXLD.js} +5 -3
- package/dist/{chunk-2PUDI7JS.js.map → chunk-ZKVQGXLD.js.map} +1 -1
- package/dist/command.js +1 -1
- package/dist/confirm-button.js +1 -1
- package/dist/data-table.js +3 -2
- package/dist/data-table.js.map +1 -1
- package/dist/date-picker.d.ts +3 -1
- package/dist/date-picker.js +13 -13
- package/dist/date-picker.js.map +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/filter-bar.js +3 -2
- package/dist/form.d.ts +23 -12
- package/dist/form.js +11 -47
- package/dist/form.js.map +1 -1
- package/dist/glow-card.js +1 -1
- package/dist/image-cropper.js +3 -1
- package/dist/image-cropper.js.map +1 -1
- package/dist/marquee.js +1 -1
- package/dist/native/form.d.ts +60 -15
- package/dist/native/form.js +103 -42
- package/dist/native/form.js.map +1 -1
- package/dist/native.d.ts +206 -2
- package/dist/native.js +1172 -541
- package/dist/native.js.map +1 -1
- package/dist/nav-bar.js +1 -1
- package/dist/popover.js +1 -1
- package/dist/radio-group.d.ts +66 -32
- package/dist/radio-group.js +54 -10
- package/dist/radio-group.js.map +1 -1
- package/dist/slider.d.ts +96 -35
- package/dist/slider.js +67 -13
- package/dist/slider.js.map +1 -1
- package/dist/terminal-replay.js +34 -60
- package/dist/terminal-replay.js.map +1 -1
- package/dist/toast.js +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/video-player.js +3 -1
- package/dist/video-player.js.map +1 -1
- package/package.json +6 -6
- package/registry/combobox.json +225 -3
- package/registry/date-picker.json +16 -2
- package/registry/dialog.json +74 -3
- package/registry/examples/combobox/native/multiple.d.ts +4 -0
- package/registry/examples/combobox/native/multiple.dark.png +0 -0
- package/registry/examples/combobox/native/multiple.js +15 -0
- package/registry/examples/combobox/native/multiple.light.png +0 -0
- package/registry/examples/combobox/native/multiple.tsx +15 -0
- package/registry/examples/combobox/native/search.d.ts +4 -0
- package/registry/examples/combobox/native/search.dark.png +0 -0
- package/registry/examples/combobox/native/search.js +15 -0
- package/registry/examples/combobox/native/search.light.png +0 -0
- package/registry/examples/combobox/native/search.tsx +15 -0
- package/registry/examples/dialog/native/sheet.d.ts +4 -0
- package/registry/examples/dialog/native/sheet.dark.png +0 -0
- package/registry/examples/dialog/native/sheet.js +21 -0
- package/registry/examples/dialog/native/sheet.light.png +0 -0
- package/registry/examples/dialog/native/sheet.tsx +18 -0
- package/registry/examples/field/native/select.d.ts +4 -0
- package/registry/examples/field/native/select.dark.png +0 -0
- package/registry/examples/field/native/select.js +29 -0
- package/registry/examples/field/native/select.light.png +0 -0
- package/registry/examples/field/native/select.tsx +25 -0
- package/registry/examples/form/native/audience.dark.png +0 -0
- package/registry/examples/form/native/audience.light.png +0 -0
- package/registry/examples/form/native/profile.dark.png +0 -0
- package/registry/examples/form/native/profile.light.png +0 -0
- package/registry/examples/form/native/settings.dark.png +0 -0
- package/registry/examples/form/native/settings.light.png +0 -0
- package/registry/examples/form/native/sign-up.dark.png +0 -0
- package/registry/examples/form/native/sign-up.light.png +0 -0
- package/registry/examples/form/native/upload.dark.png +0 -0
- package/registry/examples/form/native/upload.light.png +0 -0
- package/registry/examples/radio-group/buttons.d.ts +4 -0
- package/registry/examples/radio-group/buttons.js +17 -0
- package/registry/examples/radio-group/buttons.tsx +21 -0
- package/registry/examples/radio-group/cards.js +1 -1
- package/registry/examples/radio-group/cards.tsx +2 -2
- package/registry/examples/radio-group/native/buttons.d.ts +4 -0
- package/registry/examples/radio-group/native/buttons.dark.png +0 -0
- package/registry/examples/radio-group/native/buttons.js +25 -0
- package/registry/examples/radio-group/native/buttons.light.png +0 -0
- package/registry/examples/radio-group/native/buttons.tsx +21 -0
- package/registry/examples/radio-group/native/cards.d.ts +4 -0
- package/registry/examples/radio-group/native/cards.dark.png +0 -0
- package/registry/examples/radio-group/native/cards.js +23 -0
- package/registry/examples/radio-group/native/cards.light.png +0 -0
- package/registry/examples/radio-group/native/cards.tsx +19 -0
- package/registry/examples/radio-group/native/list.d.ts +4 -0
- package/registry/examples/radio-group/native/list.dark.png +0 -0
- package/registry/examples/radio-group/native/list.js +24 -0
- package/registry/examples/radio-group/native/list.light.png +0 -0
- package/registry/examples/radio-group/native/list.tsx +20 -0
- package/registry/examples/radio-group/native/segmented.d.ts +4 -0
- package/registry/examples/radio-group/native/segmented.dark.png +0 -0
- package/registry/examples/radio-group/native/segmented.js +24 -0
- package/registry/examples/radio-group/native/segmented.light.png +0 -0
- package/registry/examples/radio-group/native/segmented.tsx +20 -0
- package/registry/examples/radio-group/segmented.d.ts +4 -0
- package/registry/examples/radio-group/segmented.js +15 -0
- package/registry/examples/radio-group/segmented.tsx +12 -0
- package/registry/examples/slider/floating.d.ts +4 -0
- package/registry/examples/slider/floating.js +11 -0
- package/registry/examples/slider/floating.tsx +12 -0
- package/registry/examples/slider/native/default.d.ts +4 -0
- package/registry/examples/slider/native/default.dark.png +0 -0
- package/registry/examples/slider/native/default.js +14 -0
- package/registry/examples/slider/native/default.light.png +0 -0
- package/registry/examples/slider/native/default.tsx +13 -0
- package/registry/examples/slider/native/range.d.ts +4 -0
- package/registry/examples/slider/native/range.dark.png +0 -0
- package/registry/examples/slider/native/range.js +12 -0
- package/registry/examples/slider/native/range.light.png +0 -0
- package/registry/examples/slider/native/range.tsx +11 -0
- package/registry/examples/slider/native/stepped.d.ts +4 -0
- package/registry/examples/slider/native/stepped.dark.png +0 -0
- package/registry/examples/slider/native/stepped.js +28 -0
- package/registry/examples/slider/native/stepped.light.png +0 -0
- package/registry/examples/slider/native/stepped.tsx +24 -0
- package/registry/examples/slider/native/vertical.d.ts +4 -0
- package/registry/examples/slider/native/vertical.dark.png +0 -0
- package/registry/examples/slider/native/vertical.js +16 -0
- package/registry/examples/slider/native/vertical.light.png +0 -0
- package/registry/examples/slider/native/vertical.tsx +13 -0
- package/registry/examples/slider/price-range.d.ts +4 -0
- package/registry/examples/slider/price-range.js +29 -0
- package/registry/examples/slider/price-range.tsx +27 -0
- package/registry/examples/slider/stepped.d.ts +4 -0
- package/registry/examples/slider/stepped.js +28 -0
- package/registry/examples/slider/stepped.tsx +24 -0
- package/registry/examples/slider/vertical.d.ts +4 -0
- package/registry/examples/slider/vertical.js +15 -0
- package/registry/examples/slider/vertical.tsx +14 -0
- package/registry/examples/switch/native/default.d.ts +4 -0
- package/registry/examples/switch/native/default.dark.png +0 -0
- package/registry/examples/switch/native/default.js +16 -0
- package/registry/examples/switch/native/default.light.png +0 -0
- package/registry/examples/switch/native/default.tsx +13 -0
- package/registry/examples/switch/native/settings.d.ts +4 -0
- package/registry/examples/switch/native/settings.dark.png +0 -0
- package/registry/examples/switch/native/settings.js +20 -0
- package/registry/examples/switch/native/settings.light.png +0 -0
- package/registry/examples/switch/native/settings.tsx +17 -0
- package/registry/field.json +15 -3
- package/registry/form.json +250 -42
- package/registry/index.json +24 -20
- package/registry/radio-group.json +227 -15
- package/registry/slider.json +314 -13
- package/registry/switch.json +115 -3
- package/registry/tabs.json +2 -2
- package/skills/choice-controls/SKILL.md +39 -0
- package/skills/form/SKILL.md +3 -0
- package/dist/chunk-I5RVM5CW.js.map +0 -1
- package/dist/chunk-RUPRYJ45.js +0 -82
- package/dist/chunk-RUPRYJ45.js.map +0 -1
package/dist/nav-bar.js
CHANGED
package/dist/popover.js
CHANGED
package/dist/radio-group.d.ts
CHANGED
|
@@ -3,75 +3,109 @@ import { RadioGroup as RadioGroup$1 } from 'radix-ui';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
5
|
declare const radioGroup: tailwind_variants.TVReturnType<{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
label?: tailwind_variants.ClassValue;
|
|
11
|
-
item?: tailwind_variants.ClassValue;
|
|
12
|
-
card?: tailwind_variants.ClassValue;
|
|
6
|
+
variant: {
|
|
7
|
+
list: {};
|
|
8
|
+
cards: {
|
|
9
|
+
root: string;
|
|
13
10
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[x: string]: {
|
|
17
|
-
[x: string]: tailwind_variants.ClassValue | {
|
|
18
|
-
root?: tailwind_variants.ClassValue;
|
|
19
|
-
dot?: tailwind_variants.ClassValue;
|
|
20
|
-
label?: tailwind_variants.ClassValue;
|
|
21
|
-
item?: tailwind_variants.ClassValue;
|
|
22
|
-
card?: tailwind_variants.ClassValue;
|
|
11
|
+
buttons: {
|
|
12
|
+
root: string;
|
|
23
13
|
};
|
|
14
|
+
segmented: {};
|
|
24
15
|
};
|
|
25
|
-
}
|
|
16
|
+
}, {
|
|
26
17
|
root: string;
|
|
27
18
|
item: string;
|
|
28
19
|
dot: string;
|
|
29
20
|
label: string;
|
|
30
21
|
card: string;
|
|
22
|
+
cardCheck: string;
|
|
23
|
+
button: string;
|
|
24
|
+
buttonHint: string;
|
|
25
|
+
segmented: string;
|
|
26
|
+
segment: string;
|
|
31
27
|
}, undefined, {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
variant: {
|
|
29
|
+
list: {};
|
|
30
|
+
cards: {
|
|
31
|
+
root: string;
|
|
32
|
+
};
|
|
33
|
+
buttons: {
|
|
34
|
+
root: string;
|
|
39
35
|
};
|
|
36
|
+
segmented: {};
|
|
40
37
|
};
|
|
41
|
-
}
|
|
38
|
+
}, {
|
|
42
39
|
root: string;
|
|
43
40
|
item: string;
|
|
44
41
|
dot: string;
|
|
45
42
|
label: string;
|
|
46
43
|
card: string;
|
|
47
|
-
|
|
44
|
+
cardCheck: string;
|
|
45
|
+
button: string;
|
|
46
|
+
buttonHint: string;
|
|
47
|
+
segmented: string;
|
|
48
|
+
segment: string;
|
|
49
|
+
}, tailwind_variants.TVReturnTypeLike<{
|
|
50
|
+
variant: {
|
|
51
|
+
list: {};
|
|
52
|
+
cards: {
|
|
53
|
+
root: string;
|
|
54
|
+
};
|
|
55
|
+
buttons: {
|
|
56
|
+
root: string;
|
|
57
|
+
};
|
|
58
|
+
segmented: {};
|
|
59
|
+
};
|
|
60
|
+
}, {
|
|
48
61
|
root: string;
|
|
49
62
|
item: string;
|
|
50
63
|
dot: string;
|
|
51
64
|
label: string;
|
|
52
65
|
card: string;
|
|
66
|
+
cardCheck: string;
|
|
67
|
+
button: string;
|
|
68
|
+
buttonHint: string;
|
|
69
|
+
segmented: string;
|
|
70
|
+
segment: string;
|
|
53
71
|
}>>;
|
|
54
72
|
type RadioGroupRootProps = React.ComponentProps<typeof RadioGroup$1.Root> & {
|
|
55
73
|
/** The group's accessible name — passed translated (or `aria-labelledby` a visible heading). */
|
|
56
74
|
label?: string;
|
|
57
75
|
/** Marks every radio invalid: aria-invalid (pair it with a `Field.Error`). */
|
|
58
76
|
invalid?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* The layout of the radios: `list` (dots), `cards` (a grid of `Card`s), `buttons` (a row of tactile `Button`s), or
|
|
79
|
+
* `segmented` (a track of `Segment`s, one light gliding to the choice).
|
|
80
|
+
* @default "list"
|
|
81
|
+
*/
|
|
82
|
+
variant?: "list" | "cards" | "buttons" | "segmented";
|
|
59
83
|
};
|
|
60
|
-
/** `value`/`defaultValue` + `onValueChange`, `orientation`, `required`, `name` for a form. */
|
|
61
|
-
declare function RadioGroupRoot({ label, invalid, className, ...props }: RadioGroupRootProps): React.JSX.Element;
|
|
84
|
+
/** `value`/`defaultValue` + `onValueChange`, `orientation`, `required`, `name` for a form, `variant` for the layout. */
|
|
85
|
+
declare function RadioGroupRoot({ label, invalid, variant, className, ...props }: RadioGroupRootProps): React.JSX.Element;
|
|
62
86
|
type RadioGroupItemProps = Omit<React.ComponentProps<typeof RadioGroup$1.Item>, "children"> & {
|
|
63
87
|
/** The words next to the dot, clickable. Otherwise name it with `Field.Label htmlFor` or `aria-label`. */
|
|
64
88
|
children?: React.ReactNode;
|
|
65
89
|
};
|
|
66
90
|
/** A radio: a dot, and its words when given. */
|
|
67
91
|
declare function RadioGroupItem({ className, children, ...props }: RadioGroupItemProps): React.JSX.Element;
|
|
68
|
-
/** A whole card as the radio: its content is the radio's name
|
|
69
|
-
declare function RadioGroupCard({ className, ...props }: React.ComponentProps<typeof RadioGroup$1.Item>): React.JSX.Element;
|
|
70
|
-
|
|
92
|
+
/** A whole card as the radio: its content is the radio's name; its check lights up when chosen. */
|
|
93
|
+
declare function RadioGroupCard({ className, children, ...props }: React.ComponentProps<typeof RadioGroup$1.Item>): React.JSX.Element;
|
|
94
|
+
type RadioGroupButtonProps = React.ComponentProps<typeof RadioGroup$1.Item> & {
|
|
95
|
+
/** A second line under the words ("+15 %"), part of the radio's name. */
|
|
96
|
+
hint?: React.ReactNode;
|
|
97
|
+
};
|
|
98
|
+
/** A tactile key: raised on its ledge, pressed in while held and once chosen — sizes, a tip, a level. */
|
|
99
|
+
declare function RadioGroupButton({ className, children, hint, ...props }: RadioGroupButtonProps): React.JSX.Element;
|
|
100
|
+
/** A segment of a `variant="segmented"` group: equal widths, one light gliding to the choice. */
|
|
101
|
+
declare function RadioGroupSegment({ className, ...props }: React.ComponentProps<typeof RadioGroup$1.Item>): React.JSX.Element;
|
|
102
|
+
/** `RadioGroup.Root/Item/Card/Button/Segment`. */
|
|
71
103
|
declare const RadioGroup: {
|
|
72
104
|
Root: typeof RadioGroupRoot;
|
|
73
105
|
Item: typeof RadioGroupItem;
|
|
74
106
|
Card: typeof RadioGroupCard;
|
|
107
|
+
Button: typeof RadioGroupButton;
|
|
108
|
+
Segment: typeof RadioGroupSegment;
|
|
75
109
|
};
|
|
76
110
|
|
|
77
|
-
export { RadioGroup, RadioGroupCard, RadioGroupItem, type RadioGroupItemProps, RadioGroupRoot, type RadioGroupRootProps, radioGroup };
|
|
111
|
+
export { RadioGroup, RadioGroupButton, type RadioGroupButtonProps, RadioGroupCard, RadioGroupItem, type RadioGroupItemProps, RadioGroupRoot, type RadioGroupRootProps, RadioGroupSegment, radioGroup };
|
package/dist/radio-group.js
CHANGED
|
@@ -1,27 +1,57 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
CheckGlyph
|
|
4
|
+
} from "./chunk-KDXRYUD3.js";
|
|
5
|
+
import {
|
|
6
|
+
useSlidingIndicator
|
|
7
|
+
} from "./chunk-VDR2EP6K.js";
|
|
8
|
+
import {
|
|
9
|
+
tv
|
|
10
|
+
} from "./chunk-C2BRIFJG.js";
|
|
11
|
+
import "./chunk-2FRWNSRO.js";
|
|
2
12
|
|
|
3
13
|
// src/radio-group/radio-group.tsx
|
|
4
14
|
import { RadioGroup as RadioGroupPrimitive } from "radix-ui";
|
|
5
|
-
import { tv } from "tailwind-variants";
|
|
6
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
16
|
var radioGroup = tv({
|
|
8
17
|
slots: {
|
|
9
18
|
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:
|
|
11
|
-
dot: "h-2
|
|
19
|
+
item: "peer inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-border-strong bg-surface-1 inset-shadow-well transition-colors focus-visible:outline-hidden focus-visible:focus-ring hover:border-accent disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:border-accent data-[state=checked]:bg-accent data-[state=checked]:shadow-glow aria-invalid:border-danger",
|
|
20
|
+
dot: "h-2 w-2 rounded-full bg-on-accent",
|
|
12
21
|
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-
|
|
14
|
-
|
|
22
|
+
card: "group relative flex min-w-0 flex-col items-start gap-1 rounded-2xl border border-border-default bg-surface-1 bg-sheen p-4 pr-10 text-left text-sm text-fg inset-shadow-edge transition-[border-color,background-color,box-shadow,transform] duration-200 hover:border-border-strong active:scale-[0.99] motion-reduce:transition-none motion-reduce:active:scale-100 focus-visible:outline-hidden focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-40 aria-invalid:border-danger data-[state=checked]:border-accent data-[state=checked]:bg-accent-soft data-[state=checked]:shadow-glow",
|
|
23
|
+
// The card's check: an empty ring at rest, the accent filled with its check once chosen.
|
|
24
|
+
cardCheck: "absolute right-3.5 top-3.5 inline-flex h-5 w-5 items-center justify-center rounded-full border border-border-strong bg-surface-1 text-on-accent transition-colors group-data-[state=checked]:border-accent group-data-[state=checked]:bg-accent",
|
|
25
|
+
// The tactile key: on a ledge (its lower edge), lifted on hover, pressed in while held and once chosen.
|
|
26
|
+
button: "relative inline-flex min-h-12 min-w-12 select-none flex-col items-center justify-center gap-0.5 rounded-xl border border-border-default bg-surface-2 bg-sheen px-4 py-2 text-sm font-semibold text-fg inset-shadow-edge shadow-[0_4px_0_0_var(--kz-border-strong)] transition-[transform,box-shadow,background-color,border-color,color] duration-100 ease-out motion-reduce:transition-none hover:-translate-y-px hover:shadow-[0_5px_0_0_var(--kz-border-strong)] active:translate-y-[3px] active:shadow-[0_1px_0_0_var(--kz-border-strong)] focus-visible:outline-hidden focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:translate-y-0 aria-invalid:border-danger data-[state=checked]:translate-y-[3px] data-[state=checked]:border-accent data-[state=checked]:bg-accent data-[state=checked]:bg-fill-shade data-[state=checked]:text-on-accent data-[state=checked]:inset-shadow-edge-fill data-[state=checked]:shadow-[0_1px_0_0_var(--kz-accent-hover)] data-[state=checked]:hover:translate-y-[3px]",
|
|
27
|
+
buttonHint: "text-[11px] font-medium text-fg-secondary group-data-[state=checked]:text-on-accent",
|
|
28
|
+
segmented: "relative isolate inline-grid auto-cols-fr grid-flow-col gap-1 rounded-xl border border-border-default bg-surface-2 p-1 inset-shadow-well before:pointer-events-none before:absolute before:left-0 before:top-0 before:-z-10 before:h-(--kz-ind-h) before:w-(--kz-ind-w) before:translate-x-(--kz-ind-x) before:translate-y-(--kz-ind-y) before:rounded-lg before:border before:border-border-default before:bg-surface-0 before:bg-sheen before:opacity-0 before:shadow-raised before:transition-[translate,width,height,opacity] before:duration-300 motion-reduce:before:transition-none data-[indicator=on]:before:opacity-100",
|
|
29
|
+
segment: "inline-flex min-h-9 select-none items-center justify-center gap-1.5 whitespace-nowrap rounded-lg px-3.5 text-sm font-semibold text-fg-secondary transition-colors hover:text-fg focus-visible:outline-hidden focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:border data-[state=checked]:border-border-default data-[state=checked]:bg-surface-0 data-[state=checked]:text-fg data-[state=checked]:shadow-raised group-data-[indicator=on]/seg:data-[state=checked]:border-transparent group-data-[indicator=on]/seg:data-[state=checked]:bg-transparent group-data-[indicator=on]/seg:data-[state=checked]:shadow-none"
|
|
30
|
+
},
|
|
31
|
+
variants: {
|
|
32
|
+
variant: {
|
|
33
|
+
list: {},
|
|
34
|
+
cards: { root: "grid-cols-[repeat(auto-fit,minmax(10rem,1fr))] gap-3" },
|
|
35
|
+
buttons: { root: "flex flex-wrap gap-2.5 pb-1" },
|
|
36
|
+
segmented: {}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: { variant: "list" }
|
|
15
40
|
});
|
|
16
41
|
var s = radioGroup();
|
|
17
|
-
function RadioGroupRoot({ label, invalid, className, ...props }) {
|
|
42
|
+
function RadioGroupRoot({ label, invalid, variant = "list", className, ...props }) {
|
|
43
|
+
const { ref } = useSlidingIndicator({ item: "[role=radio]", active: "[role=radio][data-state=checked]" });
|
|
44
|
+
const segmented = variant === "segmented";
|
|
18
45
|
return /* @__PURE__ */ jsx(
|
|
19
46
|
RadioGroupPrimitive.Root,
|
|
20
47
|
{
|
|
48
|
+
ref: segmented ? ref : void 0,
|
|
21
49
|
"aria-label": label,
|
|
22
50
|
"aria-invalid": invalid || void 0,
|
|
23
51
|
"data-invalid": invalid ? "" : void 0,
|
|
24
|
-
|
|
52
|
+
"data-variant": variant,
|
|
53
|
+
orientation: segmented ? "horizontal" : props.orientation,
|
|
54
|
+
className: segmented ? s.segmented({ className: ["group/seg", className].filter(Boolean).join(" ") }) : radioGroup({ variant }).root({ className }),
|
|
25
55
|
...props
|
|
26
56
|
}
|
|
27
57
|
);
|
|
@@ -34,15 +64,29 @@ function RadioGroupItem({ className, children, ...props }) {
|
|
|
34
64
|
/* @__PURE__ */ jsx("span", { className: "min-w-0", children })
|
|
35
65
|
] });
|
|
36
66
|
}
|
|
37
|
-
function RadioGroupCard({ className, ...props }) {
|
|
38
|
-
return /* @__PURE__ */
|
|
67
|
+
function RadioGroupCard({ className, children, ...props }) {
|
|
68
|
+
return /* @__PURE__ */ jsxs(RadioGroupPrimitive.Item, { className: s.card({ className }), ...props, children: [
|
|
69
|
+
children,
|
|
70
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: s.cardCheck(), children: /* @__PURE__ */ jsx(RadioGroupPrimitive.Indicator, { forceMount: true, className: "inline-flex data-[state=unchecked]:hidden", children: /* @__PURE__ */ jsx(CheckGlyph, { className: "h-3 w-3" }) }) })
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
function RadioGroupButton({ className, children, hint, ...props }) {
|
|
74
|
+
return /* @__PURE__ */ jsxs(RadioGroupPrimitive.Item, { className: s.button({ className: ["group", className].filter(Boolean).join(" ") }), ...props, children: [
|
|
75
|
+
/* @__PURE__ */ jsx("span", { children }),
|
|
76
|
+
hint ? /* @__PURE__ */ jsx("span", { className: s.buttonHint(), children: hint }) : null
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
function RadioGroupSegment({ className, ...props }) {
|
|
80
|
+
return /* @__PURE__ */ jsx(RadioGroupPrimitive.Item, { className: s.segment({ className }), ...props });
|
|
39
81
|
}
|
|
40
|
-
var RadioGroup = { Root: RadioGroupRoot, Item: RadioGroupItem, Card: RadioGroupCard };
|
|
82
|
+
var RadioGroup = { Root: RadioGroupRoot, Item: RadioGroupItem, Card: RadioGroupCard, Button: RadioGroupButton, Segment: RadioGroupSegment };
|
|
41
83
|
export {
|
|
42
84
|
RadioGroup,
|
|
85
|
+
RadioGroupButton,
|
|
43
86
|
RadioGroupCard,
|
|
44
87
|
RadioGroupItem,
|
|
45
88
|
RadioGroupRoot,
|
|
89
|
+
RadioGroupSegment,
|
|
46
90
|
radioGroup
|
|
47
91
|
};
|
|
48
92
|
//# sourceMappingURL=radio-group.js.map
|
package/dist/radio-group.js.map
CHANGED
|
@@ -1 +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":[]}
|
|
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. Four looks, one behaviour:\n// - `RadioGroup.Item`: a dot and its words (a settings list);\n// - `RadioGroup.Card`: a whole card is the radio — an amount, a pack, a plan — its check lit when chosen;\n// - `RadioGroup.Button`: a tactile key that presses in — raised on a ledge, sunk when chosen (a size, a tip, a level);\n// - `RadioGroup.Segment` in `<RadioGroup.Root variant=\"segmented\">`: a segmented control, one light gliding to the choice.\nimport { RadioGroup as RadioGroupPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { CheckGlyph } from \"../glyphs\";\nimport { useSlidingIndicator } from \"../sliding-indicator\";\nimport { tv } from \"../tv\";\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 inset-shadow-well transition-colors \" +\n \"focus-visible:outline-hidden focus-visible:focus-ring hover:border-accent disabled:cursor-not-allowed disabled:opacity-40 \" +\n \"data-[state=checked]:border-accent data-[state=checked]:bg-accent data-[state=checked]:shadow-glow aria-invalid:border-danger\",\n dot: \"h-2 w-2 rounded-full bg-on-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 \"group relative flex min-w-0 flex-col items-start gap-1 rounded-2xl border border-border-default bg-surface-1 bg-sheen p-4 pr-10 text-left text-sm text-fg inset-shadow-edge \" +\n \"transition-[border-color,background-color,box-shadow,transform] duration-200 hover:border-border-strong active:scale-[0.99] motion-reduce:transition-none motion-reduce:active:scale-100 \" +\n \"focus-visible:outline-hidden focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-40 aria-invalid:border-danger \" +\n \"data-[state=checked]:border-accent data-[state=checked]:bg-accent-soft data-[state=checked]:shadow-glow\",\n // The card's check: an empty ring at rest, the accent filled with its check once chosen.\n cardCheck:\n \"absolute right-3.5 top-3.5 inline-flex h-5 w-5 items-center justify-center rounded-full border border-border-strong bg-surface-1 text-on-accent transition-colors \" +\n \"group-data-[state=checked]:border-accent group-data-[state=checked]:bg-accent\",\n // The tactile key: on a ledge (its lower edge), lifted on hover, pressed in while held and once chosen.\n button:\n \"relative inline-flex min-h-12 min-w-12 select-none flex-col items-center justify-center gap-0.5 rounded-xl border border-border-default bg-surface-2 bg-sheen px-4 py-2 \" +\n \"text-sm font-semibold text-fg inset-shadow-edge shadow-[0_4px_0_0_var(--kz-border-strong)] \" +\n \"transition-[transform,box-shadow,background-color,border-color,color] duration-100 ease-out motion-reduce:transition-none \" +\n \"hover:-translate-y-px hover:shadow-[0_5px_0_0_var(--kz-border-strong)] \" +\n \"active:translate-y-[3px] active:shadow-[0_1px_0_0_var(--kz-border-strong)] \" +\n \"focus-visible:outline-hidden focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:translate-y-0 aria-invalid:border-danger \" +\n \"data-[state=checked]:translate-y-[3px] data-[state=checked]:border-accent data-[state=checked]:bg-accent data-[state=checked]:bg-fill-shade \" +\n \"data-[state=checked]:text-on-accent data-[state=checked]:inset-shadow-edge-fill data-[state=checked]:shadow-[0_1px_0_0_var(--kz-accent-hover)] \" +\n \"data-[state=checked]:hover:translate-y-[3px]\",\n buttonHint: \"text-[11px] font-medium text-fg-secondary group-data-[state=checked]:text-on-accent\",\n segmented:\n \"relative isolate inline-grid auto-cols-fr grid-flow-col gap-1 rounded-xl border border-border-default bg-surface-2 p-1 inset-shadow-well \" +\n \"before:pointer-events-none before:absolute before:left-0 before:top-0 before:-z-10 before:h-(--kz-ind-h) before:w-(--kz-ind-w) \" +\n \"before:translate-x-(--kz-ind-x) before:translate-y-(--kz-ind-y) before:rounded-lg before:border before:border-border-default before:bg-surface-0 before:bg-sheen \" +\n \"before:opacity-0 before:shadow-raised before:transition-[translate,width,height,opacity] before:duration-300 motion-reduce:before:transition-none data-[indicator=on]:before:opacity-100\",\n segment:\n \"inline-flex min-h-9 select-none items-center justify-center gap-1.5 whitespace-nowrap rounded-lg px-3.5 text-sm font-semibold text-fg-secondary transition-colors \" +\n \"hover:text-fg focus-visible:outline-hidden focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-40 \" +\n \"data-[state=checked]:border data-[state=checked]:border-border-default data-[state=checked]:bg-surface-0 data-[state=checked]:text-fg data-[state=checked]:shadow-raised \" +\n \"group-data-[indicator=on]/seg:data-[state=checked]:border-transparent group-data-[indicator=on]/seg:data-[state=checked]:bg-transparent group-data-[indicator=on]/seg:data-[state=checked]:shadow-none\",\n },\n variants: {\n variant: {\n list: {},\n cards: { root: \"grid-cols-[repeat(auto-fit,minmax(10rem,1fr))] gap-3\" },\n buttons: { root: \"flex flex-wrap gap-2.5 pb-1\" },\n segmented: {},\n },\n },\n defaultVariants: { variant: \"list\" },\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 * The layout of the radios: `list` (dots), `cards` (a grid of `Card`s), `buttons` (a row of tactile `Button`s), or\n * `segmented` (a track of `Segment`s, one light gliding to the choice).\n * @default \"list\"\n */\n variant?: \"list\" | \"cards\" | \"buttons\" | \"segmented\";\n};\n\n/** `value`/`defaultValue` + `onValueChange`, `orientation`, `required`, `name` for a form, `variant` for the layout. */\nexport function RadioGroupRoot({ label, invalid, variant = \"list\", className, ...props }: RadioGroupRootProps) {\n const { ref } = useSlidingIndicator<HTMLDivElement>({ item: \"[role=radio]\", active: \"[role=radio][data-state=checked]\" });\n const segmented = variant === \"segmented\";\n return (\n <RadioGroupPrimitive.Root\n ref={segmented ? ref : undefined}\n aria-label={label}\n aria-invalid={invalid || undefined}\n data-invalid={invalid ? \"\" : undefined}\n data-variant={variant}\n orientation={segmented ? \"horizontal\" : props.orientation}\n className={segmented ? s.segmented({ className: [\"group/seg\", className].filter(Boolean).join(\" \") }) : radioGroup({ variant }).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; its check lights up when chosen. */\nexport function RadioGroupCard({ className, children, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {\n return (\n <RadioGroupPrimitive.Item className={s.card({ className })} {...props}>\n {children}\n <span aria-hidden className={s.cardCheck()}>\n <RadioGroupPrimitive.Indicator forceMount className=\"inline-flex data-[state=unchecked]:hidden\">\n <CheckGlyph className=\"h-3 w-3\" />\n </RadioGroupPrimitive.Indicator>\n </span>\n </RadioGroupPrimitive.Item>\n );\n}\n\nexport type RadioGroupButtonProps = React.ComponentProps<typeof RadioGroupPrimitive.Item> & {\n /** A second line under the words (\"+15 %\"), part of the radio's name. */\n hint?: React.ReactNode;\n};\n\n/** A tactile key: raised on its ledge, pressed in while held and once chosen — sizes, a tip, a level. */\nexport function RadioGroupButton({ className, children, hint, ...props }: RadioGroupButtonProps) {\n return (\n <RadioGroupPrimitive.Item className={s.button({ className: [\"group\", className].filter(Boolean).join(\" \") })} {...props}>\n <span>{children}</span>\n {hint ? <span className={s.buttonHint()}>{hint}</span> : null}\n </RadioGroupPrimitive.Item>\n );\n}\n\n/** A segment of a `variant=\"segmented\"` group: equal widths, one light gliding to the choice. */\nexport function RadioGroupSegment({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {\n return <RadioGroupPrimitive.Item className={s.segment({ className })} {...props} />;\n}\n\n/** `RadioGroup.Root/Item/Card/Button/Segment`. */\nexport const RadioGroup = { Root: RadioGroupRoot, Item: RadioGroupItem, Card: RadioGroupCard, Button: RadioGroupButton, Segment: RadioGroupSegment };\n"],"mappings":";;;;;;;;;;;;;AAMA,SAAS,cAAc,2BAA2B;AA8E9C,cA2BA,YA3BA;AAvEG,IAAM,aAAa,GAAG;AAAA,EAC3B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,MACE;AAAA,IAGF,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MACE;AAAA;AAAA,IAKF,WACE;AAAA;AAAA,IAGF,QACE;AAAA,IASF,YAAY;AAAA,IACZ,WACE;AAAA,IAIF,SACE;AAAA,EAIJ;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA,MACP,MAAM,CAAC;AAAA,MACP,OAAO,EAAE,MAAM,uDAAuD;AAAA,MACtE,SAAS,EAAE,MAAM,8BAA8B;AAAA,MAC/C,WAAW,CAAC;AAAA,IACd;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,SAAS,OAAO;AACrC,CAAC;AACD,IAAM,IAAI,WAAW;AAgBd,SAAS,eAAe,EAAE,OAAO,SAAS,UAAU,QAAQ,WAAW,GAAG,MAAM,GAAwB;AAC7G,QAAM,EAAE,IAAI,IAAI,oBAAoC,EAAE,MAAM,gBAAgB,QAAQ,mCAAmC,CAAC;AACxH,QAAM,YAAY,YAAY;AAC9B,SACE;AAAA,IAAC,oBAAoB;AAAA,IAApB;AAAA,MACC,KAAK,YAAY,MAAM;AAAA,MACvB,cAAY;AAAA,MACZ,gBAAc,WAAW;AAAA,MACzB,gBAAc,UAAU,KAAK;AAAA,MAC7B,gBAAc;AAAA,MACd,aAAa,YAAY,eAAe,MAAM;AAAA,MAC9C,WAAW,YAAY,EAAE,UAAU,EAAE,WAAW,CAAC,aAAa,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,CAAC,IAAI,WAAW,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC;AAAA,MACjJ,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,UAAU,GAAG,MAAM,GAA0D;AACvH,SACE,qBAAC,oBAAoB,MAApB,EAAyB,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,GAAI,GAAG,OAC7D;AAAA;AAAA,IACD,oBAAC,UAAK,eAAW,MAAC,WAAW,EAAE,UAAU,GACvC,8BAAC,oBAAoB,WAApB,EAA8B,YAAU,MAAC,WAAU,6CAClD,8BAAC,cAAW,WAAU,WAAU,GAClC,GACF;AAAA,KACF;AAEJ;AAQO,SAAS,iBAAiB,EAAE,WAAW,UAAU,MAAM,GAAG,MAAM,GAA0B;AAC/F,SACE,qBAAC,oBAAoB,MAApB,EAAyB,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,SAAS,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,CAAC,GAAI,GAAG,OAChH;AAAA,wBAAC,UAAM,UAAS;AAAA,IACf,OAAO,oBAAC,UAAK,WAAW,EAAE,WAAW,GAAI,gBAAK,IAAU;AAAA,KAC3D;AAEJ;AAGO,SAAS,kBAAkB,EAAE,WAAW,GAAG,MAAM,GAA0D;AAChH,SAAO,oBAAC,oBAAoB,MAApB,EAAyB,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,GAAI,GAAG,OAAO;AACnF;AAGO,IAAM,aAAa,EAAE,MAAM,gBAAgB,MAAM,gBAAgB,MAAM,gBAAgB,QAAQ,kBAAkB,SAAS,kBAAkB;","names":[]}
|
package/dist/slider.d.ts
CHANGED
|
@@ -3,30 +3,25 @@ import { Slider as Slider$1 } from 'radix-ui';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
5
|
declare const slider: tailwind_variants.TVReturnType<{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
range
|
|
14
|
-
thumb?: tailwind_variants.ClassValue;
|
|
6
|
+
tone: {
|
|
7
|
+
/** The brand's signature: accent → accent-2, a glow under it. */
|
|
8
|
+
gradient: {
|
|
9
|
+
range: string;
|
|
10
|
+
};
|
|
11
|
+
/** The accent alone. */
|
|
12
|
+
solid: {
|
|
13
|
+
range: string;
|
|
15
14
|
};
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
control?: tailwind_variants.ClassValue;
|
|
24
|
-
track?: tailwind_variants.ClassValue;
|
|
25
|
-
range?: tailwind_variants.ClassValue;
|
|
26
|
-
thumb?: tailwind_variants.ClassValue;
|
|
16
|
+
size: {
|
|
17
|
+
md: {};
|
|
18
|
+
lg: {
|
|
19
|
+
track: string;
|
|
20
|
+
thumb: string;
|
|
21
|
+
control: string;
|
|
27
22
|
};
|
|
28
23
|
};
|
|
29
|
-
}
|
|
24
|
+
}, {
|
|
30
25
|
root: string;
|
|
31
26
|
header: string;
|
|
32
27
|
value: string;
|
|
@@ -34,19 +29,32 @@ declare const slider: tailwind_variants.TVReturnType<{
|
|
|
34
29
|
track: string;
|
|
35
30
|
range: string;
|
|
36
31
|
thumb: string;
|
|
32
|
+
bubble: string;
|
|
33
|
+
bubbleVertical: string;
|
|
34
|
+
ticks: string;
|
|
35
|
+
tick: string;
|
|
36
|
+
marks: string;
|
|
37
|
+
mark: string;
|
|
37
38
|
}, undefined, {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
range
|
|
46
|
-
|
|
39
|
+
tone: {
|
|
40
|
+
/** The brand's signature: accent → accent-2, a glow under it. */
|
|
41
|
+
gradient: {
|
|
42
|
+
range: string;
|
|
43
|
+
};
|
|
44
|
+
/** The accent alone. */
|
|
45
|
+
solid: {
|
|
46
|
+
range: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
size: {
|
|
50
|
+
md: {};
|
|
51
|
+
lg: {
|
|
52
|
+
track: string;
|
|
53
|
+
thumb: string;
|
|
54
|
+
control: string;
|
|
47
55
|
};
|
|
48
56
|
};
|
|
49
|
-
}
|
|
57
|
+
}, {
|
|
50
58
|
root: string;
|
|
51
59
|
header: string;
|
|
52
60
|
value: string;
|
|
@@ -54,7 +62,32 @@ declare const slider: tailwind_variants.TVReturnType<{
|
|
|
54
62
|
track: string;
|
|
55
63
|
range: string;
|
|
56
64
|
thumb: string;
|
|
57
|
-
|
|
65
|
+
bubble: string;
|
|
66
|
+
bubbleVertical: string;
|
|
67
|
+
ticks: string;
|
|
68
|
+
tick: string;
|
|
69
|
+
marks: string;
|
|
70
|
+
mark: string;
|
|
71
|
+
}, tailwind_variants.TVReturnTypeLike<{
|
|
72
|
+
tone: {
|
|
73
|
+
/** The brand's signature: accent → accent-2, a glow under it. */
|
|
74
|
+
gradient: {
|
|
75
|
+
range: string;
|
|
76
|
+
};
|
|
77
|
+
/** The accent alone. */
|
|
78
|
+
solid: {
|
|
79
|
+
range: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
size: {
|
|
83
|
+
md: {};
|
|
84
|
+
lg: {
|
|
85
|
+
track: string;
|
|
86
|
+
thumb: string;
|
|
87
|
+
control: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
}, {
|
|
58
91
|
root: string;
|
|
59
92
|
header: string;
|
|
60
93
|
value: string;
|
|
@@ -62,8 +95,20 @@ declare const slider: tailwind_variants.TVReturnType<{
|
|
|
62
95
|
track: string;
|
|
63
96
|
range: string;
|
|
64
97
|
thumb: string;
|
|
98
|
+
bubble: string;
|
|
99
|
+
bubbleVertical: string;
|
|
100
|
+
ticks: string;
|
|
101
|
+
tick: string;
|
|
102
|
+
marks: string;
|
|
103
|
+
mark: string;
|
|
65
104
|
}>>;
|
|
66
105
|
type SliderValue = number | [number, number];
|
|
106
|
+
type SliderMark = {
|
|
107
|
+
/** Where the mark stands. */
|
|
108
|
+
value: number;
|
|
109
|
+
/** Its words under the track ("0", "50 %", "Max"), passed translated. */
|
|
110
|
+
label: string;
|
|
111
|
+
};
|
|
67
112
|
type SliderProps<V extends SliderValue = number> = Omit<React.ComponentProps<typeof Slider$1.Root>, "value" | "defaultValue" | "onValueChange" | "onValueCommit" | "children"> & {
|
|
68
113
|
/** One number (a thumb) or two (a range). Controlled with `onValueChange`. */
|
|
69
114
|
value?: V;
|
|
@@ -81,10 +126,26 @@ type SliderProps<V extends SliderValue = number> = Omit<React.ComponentProps<typ
|
|
|
81
126
|
formatValue?: (value: number) => string;
|
|
82
127
|
/** Shows the label and the value above the track. Without it, `label` only names the thumb. */
|
|
83
128
|
showLabel?: boolean;
|
|
84
|
-
/**
|
|
129
|
+
/** Shows the value floating over the thumb while it is hovered, focused or held (`"always"`: at all times). */
|
|
130
|
+
floatingValue?: boolean | "always";
|
|
131
|
+
/** Fills from this value instead of the minimum (a ±range from 0: brightness, balance). One horizontal thumb only. */
|
|
85
132
|
origin?: number;
|
|
133
|
+
/** Draws a graduation at every step (`true`, up to 40 of them) or at the values given. */
|
|
134
|
+
ticks?: boolean | readonly number[];
|
|
135
|
+
/** Words under the track at some values (`[{ value: 0, label: "0" }, { value: 100, label: "100" }]`). Horizontal only. */
|
|
136
|
+
marks?: readonly SliderMark[];
|
|
137
|
+
/**
|
|
138
|
+
* `gradient` (the brand's accent → accent-2, a glow) or `solid` (the accent alone).
|
|
139
|
+
* @default "gradient"
|
|
140
|
+
*/
|
|
141
|
+
tone?: "gradient" | "solid";
|
|
142
|
+
/**
|
|
143
|
+
* md · lg (a thicker track and thumb: a hero control, a touch screen).
|
|
144
|
+
* @default "md"
|
|
145
|
+
*/
|
|
146
|
+
size?: "md" | "lg";
|
|
86
147
|
};
|
|
87
|
-
/** A slider on one value or a range: `value`/`defaultValue` + `onValueChange`, `min`, `max`, `step`. */
|
|
88
|
-
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;
|
|
148
|
+
/** A slider on one value or a range: `value`/`defaultValue` + `onValueChange`, `min`, `max`, `step`, `orientation`. */
|
|
149
|
+
declare function Slider<V extends SliderValue = number>({ value, defaultValue, onValueChange, onValueCommit, label, thumbLabels, formatValue, showLabel, floatingValue, origin, ticks, marks, tone, size, min, max, step, orientation, className, ...props }: SliderProps<V>): React.JSX.Element;
|
|
89
150
|
|
|
90
|
-
export { Slider, type SliderProps, type SliderValue, slider };
|
|
151
|
+
export { Slider, type SliderMark, type SliderProps, type SliderValue, slider };
|
package/dist/slider.js
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
tv
|
|
4
|
+
} from "./chunk-C2BRIFJG.js";
|
|
5
|
+
import "./chunk-2FRWNSRO.js";
|
|
2
6
|
|
|
3
7
|
// src/slider/slider.tsx
|
|
4
8
|
import { Slider as SliderPrimitive } from "radix-ui";
|
|
5
9
|
import * as React from "react";
|
|
6
|
-
import { tv } from "tailwind-variants";
|
|
7
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
11
|
var slider = tv({
|
|
9
12
|
slots: {
|
|
10
|
-
root: "flex flex-col gap-2",
|
|
13
|
+
root: "flex flex-col gap-2 data-[orientation=vertical]:h-full data-[orientation=vertical]:items-center",
|
|
11
14
|
header: "flex items-baseline justify-between gap-3 text-xs font-semibold text-fg-secondary",
|
|
12
15
|
value: "font-mono text-[11px] tabular-nums text-fg-secondary",
|
|
13
|
-
control: "relative flex
|
|
14
|
-
track: "relative h-1.5 w-full
|
|
15
|
-
range: "absolute
|
|
16
|
-
thumb: "block h-5 w-5 cursor-grab rounded-full border border-
|
|
17
|
-
|
|
16
|
+
control: "relative flex touch-none select-none items-center data-disabled:cursor-not-allowed data-disabled:opacity-40 data-[orientation=horizontal]:h-6 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-6 data-[orientation=vertical]:flex-col",
|
|
17
|
+
track: "relative grow overflow-hidden rounded-full bg-surface-3 inset-shadow-well data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",
|
|
18
|
+
range: "absolute rounded-full data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full",
|
|
19
|
+
thumb: "group/thumb relative block h-5 w-5 cursor-grab rounded-full border-2 border-accent bg-fg-on-media shadow-raised transition-[box-shadow,scale] duration-150 hover:scale-110 focus-visible:outline-hidden focus-visible:focus-ring active:scale-110 active:cursor-grabbing motion-reduce:transition-none motion-reduce:hover:scale-100 motion-reduce:active:scale-100",
|
|
20
|
+
// The value over the thumb: shown while the thumb is hovered, focused or held.
|
|
21
|
+
bubble: "pointer-events-none absolute bottom-full left-1/2 mb-2.5 -translate-x-1/2 whitespace-nowrap rounded-lg bg-fg px-2 py-1 font-mono text-[11px] font-semibold tabular-nums text-surface-0 opacity-0 shadow-floating transition-opacity duration-150 after:absolute after:left-1/2 after:top-full after:-translate-x-1/2 after:border-4 after:border-transparent after:border-t-fg group-hover/thumb:opacity-100 group-focus-visible/thumb:opacity-100 group-active/thumb:opacity-100 data-[always]:opacity-100 motion-reduce:transition-none",
|
|
22
|
+
bubbleVertical: "bottom-auto left-full top-1/2 mb-0 ml-3 -translate-x-0 -translate-y-1/2 after:hidden",
|
|
23
|
+
ticks: "pointer-events-none absolute inset-0",
|
|
24
|
+
tick: "absolute rounded-full bg-border-strong data-[on]:bg-on-accent/70 data-[orientation=horizontal]:top-1/2 data-[orientation=horizontal]:h-1 data-[orientation=horizontal]:w-px data-[orientation=horizontal]:-translate-x-1/2 data-[orientation=horizontal]:-translate-y-1/2 data-[orientation=vertical]:left-1/2 data-[orientation=vertical]:h-px data-[orientation=vertical]:w-1 data-[orientation=vertical]:-translate-x-1/2 data-[orientation=vertical]:translate-y-1/2",
|
|
25
|
+
marks: "relative h-4 w-full text-[11px] font-medium tabular-nums text-fg-secondary",
|
|
26
|
+
mark: "absolute top-0 -translate-x-1/2 whitespace-nowrap first:translate-x-0 last:-translate-x-full"
|
|
27
|
+
},
|
|
28
|
+
variants: {
|
|
29
|
+
tone: {
|
|
30
|
+
/** The brand's signature: accent → accent-2, a glow under it. */
|
|
31
|
+
gradient: { range: "bg-linear-to-r from-accent to-accent-2 shadow-glow data-[orientation=vertical]:bg-linear-to-t" },
|
|
32
|
+
/** The accent alone. */
|
|
33
|
+
solid: { range: "bg-accent" }
|
|
34
|
+
},
|
|
35
|
+
size: {
|
|
36
|
+
md: {},
|
|
37
|
+
lg: {
|
|
38
|
+
track: "data-[orientation=horizontal]:h-2.5 data-[orientation=vertical]:w-2.5",
|
|
39
|
+
thumb: "h-6 w-6",
|
|
40
|
+
control: "data-[orientation=horizontal]:h-8 data-[orientation=vertical]:w-8"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: { tone: "gradient", size: "md" }
|
|
18
45
|
});
|
|
19
46
|
var toArray = (v) => v === void 0 ? void 0 : typeof v === "number" ? [v] : v;
|
|
20
47
|
function Slider({
|
|
@@ -26,21 +53,32 @@ function Slider({
|
|
|
26
53
|
thumbLabels,
|
|
27
54
|
formatValue = String,
|
|
28
55
|
showLabel,
|
|
56
|
+
floatingValue,
|
|
29
57
|
origin,
|
|
58
|
+
ticks,
|
|
59
|
+
marks,
|
|
60
|
+
tone,
|
|
61
|
+
size,
|
|
30
62
|
min = 0,
|
|
31
63
|
max = 100,
|
|
64
|
+
step = 1,
|
|
65
|
+
orientation = "horizontal",
|
|
32
66
|
className,
|
|
33
67
|
...props
|
|
34
68
|
}) {
|
|
35
|
-
const s = slider();
|
|
69
|
+
const s = slider({ tone, size });
|
|
36
70
|
const range = Array.isArray(value ?? defaultValue);
|
|
71
|
+
const vertical = orientation === "vertical";
|
|
37
72
|
const [inner, setInner] = React.useState(() => toArray(defaultValue) ?? [min]);
|
|
38
73
|
const current = toArray(value) ?? inner;
|
|
39
74
|
const out = (next) => range ? next : next[0];
|
|
40
75
|
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;
|
|
76
|
+
const fill = origin !== void 0 && !range && !vertical ? { left: `${Math.min(pct(origin), pct(current[0]))}%`, right: `${100 - Math.max(pct(origin), pct(current[0]))}%` } : void 0;
|
|
77
|
+
const lo = range ? Math.min(...current) : origin ?? min;
|
|
78
|
+
const hi = range ? Math.max(...current) : current[0];
|
|
79
|
+
const tickValues = ticks === true ? (max - min) / step <= 40 ? Array.from({ length: Math.round((max - min) / step) + 1 }, (_, i) => min + i * step) : [] : ticks ? [...ticks] : [];
|
|
42
80
|
const id = React.useId();
|
|
43
|
-
return /* @__PURE__ */ jsxs("div", { className: s.root({ className }), "data-range": range ? "" : void 0, children: [
|
|
81
|
+
return /* @__PURE__ */ jsxs("div", { className: s.root({ className }), "data-range": range ? "" : void 0, "data-orientation": orientation, children: [
|
|
44
82
|
showLabel && /* @__PURE__ */ jsxs("div", { className: s.header(), children: [
|
|
45
83
|
/* @__PURE__ */ jsx("span", { id: `${id}-label`, children: label }),
|
|
46
84
|
/* @__PURE__ */ jsx("span", { className: s.value(), "aria-hidden": true, children: current.map(formatValue).join(" \u2013 ") })
|
|
@@ -50,6 +88,8 @@ function Slider({
|
|
|
50
88
|
{
|
|
51
89
|
min,
|
|
52
90
|
max,
|
|
91
|
+
step,
|
|
92
|
+
orientation,
|
|
53
93
|
value: current,
|
|
54
94
|
onValueChange: (next) => {
|
|
55
95
|
if (value === void 0) setInner(next);
|
|
@@ -59,20 +99,34 @@ function Slider({
|
|
|
59
99
|
className: s.control(),
|
|
60
100
|
...props,
|
|
61
101
|
children: [
|
|
62
|
-
/* @__PURE__ */
|
|
102
|
+
/* @__PURE__ */ jsxs(SliderPrimitive.Track, { className: s.track(), children: [
|
|
103
|
+
fill ? /* @__PURE__ */ jsx("span", { "data-origin": "", "data-orientation": orientation, className: s.range(), style: fill }) : /* @__PURE__ */ jsx(SliderPrimitive.Range, { className: s.range() }),
|
|
104
|
+
tickValues.length ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: s.ticks(), children: tickValues.map((t) => /* @__PURE__ */ jsx(
|
|
105
|
+
"span",
|
|
106
|
+
{
|
|
107
|
+
"data-orientation": orientation,
|
|
108
|
+
"data-on": t > lo && t < hi ? "" : void 0,
|
|
109
|
+
className: s.tick(),
|
|
110
|
+
style: vertical ? { bottom: `${pct(t)}%` } : { left: `${pct(t)}%` }
|
|
111
|
+
},
|
|
112
|
+
t
|
|
113
|
+
)) }) : null
|
|
114
|
+
] }),
|
|
63
115
|
current.map((v, i) => /* @__PURE__ */ jsx(
|
|
64
116
|
SliderPrimitive.Thumb,
|
|
65
117
|
{
|
|
66
118
|
"aria-label": range ? thumbLabels?.[i] ?? label : showLabel ? void 0 : label,
|
|
67
119
|
"aria-labelledby": !range && showLabel ? `${id}-label` : void 0,
|
|
68
120
|
"aria-valuetext": formatValue(v),
|
|
69
|
-
className: s.thumb()
|
|
121
|
+
className: s.thumb(),
|
|
122
|
+
children: floatingValue ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, "data-always": floatingValue === "always" ? "" : void 0, className: s.bubble({ className: vertical ? s.bubbleVertical() : void 0 }), children: formatValue(v) }) : null
|
|
70
123
|
},
|
|
71
124
|
i
|
|
72
125
|
))
|
|
73
126
|
]
|
|
74
127
|
}
|
|
75
|
-
)
|
|
128
|
+
),
|
|
129
|
+
marks?.length && !vertical ? /* @__PURE__ */ jsx("div", { "aria-hidden": true, className: s.marks(), children: marks.map((m) => /* @__PURE__ */ jsx("span", { className: s.mark(), style: { left: `${pct(m.value)}%` }, children: m.label }, m.value)) }) : null
|
|
76
130
|
] });
|
|
77
131
|
}
|
|
78
132
|
export {
|