@gridui/choice 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -4
- package/dist/index.js +37 -22
- package/dist/index.js.map +4 -4
- package/dist/shared/context.d.ts +5 -1
- package/dist/shared/size.d.ts +3 -0
- package/dist/shared/switch-control.d.ts +6 -0
- package/dist/shared/switch-indicator.d.ts +6 -0
- package/dist/shared/use-choice.d.ts +2 -0
- package/dist/styled.js +3 -0
- package/dist/styles.css +178 -43
- package/dist/styles.local.css +490 -0
- package/dist/switch-group/switch-group.d.ts +3 -1
- package/dist/switch-panel/switch-panel.d.ts +4 -1
- package/dist/toggle-group/toggle-group.d.ts +2 -0
- package/dist/toggle-group-item/toggle-group-item.d.ts +4 -1
- package/docs/catalog.json +14 -13
- package/docs/reference/checkbox.md +10 -2
- package/docs/reference/switch-group.md +12 -4
- package/docs/reference/switch-panel.md +10 -2
- package/docs/reference/switch.md +8 -2
- package/docs/reference/toggle-group-item.md +10 -2
- package/docs/reference/toggle-group.md +10 -2
- package/docs/switches.md +1 -1
- package/docs/tabs-and-choices.md +1 -1
- package/package.json +14 -9
package/README.md
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
# @gridui/choice
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Controls family. Public components: `Checkbox`, `Switch`, `SwitchGroup`, `SwitchPanel`, `ToggleGroup`, and `ToggleGroupItem`. Each exports its named Props contract. Switch presentation types and `SwitchGroupItem` describe their supported configuration.
|
|
4
4
|
|
|
5
5
|
Import components from `@gridui/choice` and load `@gridui/choice/styles.css` after Theme.
|
|
6
|
-
|
|
6
|
+
Applications own routes, labels, state persistence, and branding.
|
|
7
|
+
|
|
8
|
+
See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-controls/choice/.changeset/history).
|
|
9
|
+
|
|
10
|
+
## Styles
|
|
11
|
+
|
|
12
|
+
Load Theme once. Use `@gridui/choice/styled` for automatic component CSS in
|
|
13
|
+
CSS-aware bundlers, or keep the CSS-free root import and load `@gridui/choice/styles.css`.
|
|
14
|
+
Both entries expose the same root API. The standalone stylesheet includes component
|
|
15
|
+
dependency styles; Theme/reset remain separate. See the
|
|
16
|
+
[integration guide](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/usage/integration.md)
|
|
17
|
+
for static HTML loading, SSR limits, and avoiding duplicate CSS.
|
|
7
18
|
|
|
8
|
-
See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-core/choice/.changeset/history).
|
|
9
19
|
|
|
10
20
|
## Full-width choice cells
|
|
11
21
|
|
|
@@ -50,5 +60,12 @@ whole-control disabled appearance.
|
|
|
50
60
|
|
|
51
61
|
Shared animation policy and tempo come from `MotionConfig` in `@gridui/motion`.
|
|
52
62
|
Disabled or reduced-motion policy settles decoration without disabling interaction.
|
|
53
|
-
See the [motion guide](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-
|
|
63
|
+
See the [motion guide](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-foundation/motion)
|
|
54
64
|
for CSS scopes, portal behavior, and specialized timing contracts.
|
|
65
|
+
|
|
66
|
+
## Sizing and density
|
|
67
|
+
|
|
68
|
+
Checkbox, Switch and ToggleGroup use size small, medium (default) or large. ToggleGroup supplies item defaults. Visible marks and hit targets are separate. Checkbox keeps a consistent check and mixed-state stroke across sizes. SwitchGroup independently accepts size for indicators and density compact/comfortable for setting rows; comfortable is the default. SwitchPanel size supplies a default to control.size; an explicit control size wins.
|
|
69
|
+
|
|
70
|
+
See the [shared sizing contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/usage/sizing.md)
|
|
71
|
+
for native attributes, scope precedence, tokens and target behavior.
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
// src/shared/size.ts
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
var choiceSizeStyles = cva("gridui-choice-sized", { variants: { size: {
|
|
4
|
+
small: "gridui-u-choice--[--gridui-choice-target:max(var(--gridui-control-min-height-small),var(--gridui-target-min-size))] gridui-u-choice--[--gridui-choice-mark:1rem] gridui-u-choice--[--gridui-choice-inline:var(--gridui-space-8)] gridui-u-choice--[--gridui-choice-block:var(--gridui-space-4)]",
|
|
5
|
+
medium: "gridui-u-choice--[--gridui-choice-target:max(var(--gridui-control-min-height-medium),var(--gridui-target-min-size))] gridui-u-choice--[--gridui-choice-mark:1.25rem] gridui-u-choice--[--gridui-choice-inline:var(--gridui-space-16)] gridui-u-choice--[--gridui-choice-block:var(--gridui-space-8)]",
|
|
6
|
+
large: "gridui-u-choice--[--gridui-choice-target:max(var(--gridui-control-min-height-large),var(--gridui-target-min-size))] gridui-u-choice--[--gridui-choice-mark:1.5rem] gridui-u-choice--[--gridui-choice-inline:var(--gridui-space-24)] gridui-u-choice--[--gridui-choice-block:var(--gridui-space-8)]"
|
|
7
|
+
} }, defaultVariants: { size: "medium" } });
|
|
8
|
+
|
|
1
9
|
// src/shared/use-choice.ts
|
|
2
10
|
import { focusInvalidControl, useFormReset } from "@gridui/form";
|
|
3
11
|
import { changeDetails } from "@gridui/interaction";
|
|
@@ -48,8 +56,8 @@ var useChoice = (props) => {
|
|
|
48
56
|
};
|
|
49
57
|
|
|
50
58
|
// src/checkbox/style.ts
|
|
51
|
-
import { cva } from "class-variance-authority";
|
|
52
|
-
var choiceStyles =
|
|
59
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
60
|
+
var choiceStyles = cva2("gridui-checkbox gridui-u-choice--inline-flex gridui-u-choice--shrink-0 gridui-u-choice--cursor-pointer gridui-u-choice--items-center gridui-u-choice--justify-center gridui-u-choice--border-0 gridui-u-choice--bg-transparent gridui-u-choice--p-0 gridui-u-choice--text-foreground gridui-u-choice--align-middle gridui-u-choice--rounded-control gridui-u-choice--data-disabled:cursor-not-allowed gridui-u-choice--data-disabled:opacity-50 gridui-u-choice--data-readonly:cursor-default");
|
|
53
61
|
|
|
54
62
|
// src/checkbox/checkbox.tsx
|
|
55
63
|
import { cn } from "@gridui/style-utils";
|
|
@@ -59,6 +67,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
59
67
|
var Checkbox = (props) => {
|
|
60
68
|
const {
|
|
61
69
|
className,
|
|
70
|
+
size = "medium",
|
|
62
71
|
indeterminate,
|
|
63
72
|
inputRef,
|
|
64
73
|
onCheckedChange,
|
|
@@ -97,8 +106,9 @@ var Checkbox = (props) => {
|
|
|
97
106
|
}
|
|
98
107
|
event.preventDefault();
|
|
99
108
|
},
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
"data-size": size,
|
|
110
|
+
className: cn(choiceStyles(), choiceSizeStyles({ size }), className),
|
|
111
|
+
children: /* @__PURE__ */ jsx("span", { className: "gridui-checkbox-mark", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Primitive.Indicator, { children: indeterminate ? /* @__PURE__ */ jsx(
|
|
102
112
|
Minus,
|
|
103
113
|
{
|
|
104
114
|
size: 16,
|
|
@@ -110,7 +120,7 @@ var Checkbox = (props) => {
|
|
|
110
120
|
size: 16,
|
|
111
121
|
"aria-hidden": "true"
|
|
112
122
|
}
|
|
113
|
-
) })
|
|
123
|
+
) }) })
|
|
114
124
|
}
|
|
115
125
|
),
|
|
116
126
|
/* @__PURE__ */ jsx(
|
|
@@ -156,6 +166,7 @@ var SwitchControl = (props) => {
|
|
|
156
166
|
const {
|
|
157
167
|
children,
|
|
158
168
|
className,
|
|
169
|
+
size = "medium",
|
|
159
170
|
inputRef,
|
|
160
171
|
onCheckedChange,
|
|
161
172
|
checked,
|
|
@@ -198,7 +209,8 @@ var SwitchControl = (props) => {
|
|
|
198
209
|
}
|
|
199
210
|
event.preventDefault();
|
|
200
211
|
},
|
|
201
|
-
|
|
212
|
+
"data-size": size,
|
|
213
|
+
className: cn2("gridui-switch-control", choiceSizeStyles({ size }), className),
|
|
202
214
|
style: { ...props.style, ...motionStyle },
|
|
203
215
|
children: children(current)
|
|
204
216
|
}
|
|
@@ -285,8 +297,8 @@ var SwitchIndicator = (props) => {
|
|
|
285
297
|
};
|
|
286
298
|
|
|
287
299
|
// src/switch/style.ts
|
|
288
|
-
import { cva as
|
|
289
|
-
var switchStyles =
|
|
300
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
301
|
+
var switchStyles = cva3("gridui-switch gridui-u-choice--inline-flex gridui-u-choice--w-fit gridui-u-choice--max-w-full gridui-u-choice--min-h-(--gridui-choice-target) gridui-u-choice--min-w-(--gridui-choice-target) gridui-u-choice--shrink-0 gridui-u-choice--items-center gridui-u-choice--justify-center gridui-u-choice--border-0 gridui-u-choice--bg-transparent gridui-u-choice--p-0 gridui-u-choice--align-middle gridui-u-choice--rounded-control");
|
|
290
302
|
|
|
291
303
|
// src/switch/switch.tsx
|
|
292
304
|
import { cn as cn3 } from "@gridui/style-utils";
|
|
@@ -384,7 +396,7 @@ var SwitchSetting = (props) => {
|
|
|
384
396
|
import { cn as cn5 } from "@gridui/style-utils";
|
|
385
397
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
386
398
|
var SwitchGroup = (props) => {
|
|
387
|
-
const { items, legend, density = "
|
|
399
|
+
const { items, legend, density = "comfortable", size = "medium", variant, stateLabels, className, ...restProps } = props;
|
|
388
400
|
return /* @__PURE__ */ jsxs5(
|
|
389
401
|
"fieldset",
|
|
390
402
|
{
|
|
@@ -408,6 +420,7 @@ var SwitchGroup = (props) => {
|
|
|
408
420
|
description,
|
|
409
421
|
control: {
|
|
410
422
|
...control,
|
|
423
|
+
size: control.size ?? size,
|
|
411
424
|
variant: item.variant ?? variant,
|
|
412
425
|
stateLabels: item.stateLabels ?? stateLabels
|
|
413
426
|
}
|
|
@@ -425,7 +438,7 @@ import { cn as cn6 } from "@gridui/style-utils";
|
|
|
425
438
|
import { Children } from "react";
|
|
426
439
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
427
440
|
var SwitchPanel = (props) => {
|
|
428
|
-
const { label, description, control, children, className, ...restProps } = props;
|
|
441
|
+
const { label, description, control, size = "medium", children, className, ...restProps } = props;
|
|
429
442
|
const hasContent = Children.toArray(children).some((child) => {
|
|
430
443
|
return child !== "";
|
|
431
444
|
});
|
|
@@ -440,7 +453,7 @@ var SwitchPanel = (props) => {
|
|
|
440
453
|
{
|
|
441
454
|
label,
|
|
442
455
|
description,
|
|
443
|
-
control
|
|
456
|
+
control: { ...control, size: control.size ?? size }
|
|
444
457
|
}
|
|
445
458
|
),
|
|
446
459
|
hasContent && /* @__PURE__ */ jsx7(
|
|
@@ -457,11 +470,11 @@ var SwitchPanel = (props) => {
|
|
|
457
470
|
|
|
458
471
|
// src/shared/context.ts
|
|
459
472
|
import { createContext } from "react";
|
|
460
|
-
var ToggleGroupContext = createContext("standard");
|
|
473
|
+
var ToggleGroupContext = createContext({ layout: "standard", size: "medium" });
|
|
461
474
|
|
|
462
475
|
// src/toggle-group/style.ts
|
|
463
|
-
import { cva as
|
|
464
|
-
var toggleGroupStyles =
|
|
476
|
+
import { cva as cva4 } from "class-variance-authority";
|
|
477
|
+
var toggleGroupStyles = cva4("gridui-toggle-group gridui-u-choice--inline-flex gridui-u-choice--max-w-full gridui-u-choice--flex-wrap gridui-u-choice--gap-px gridui-u-choice--border gridui-u-choice--border-border gridui-u-choice--bg-border gridui-u-choice--data-[orientation=vertical]:flex-col", {
|
|
465
478
|
variants: {
|
|
466
479
|
layout: {
|
|
467
480
|
standard: "",
|
|
@@ -477,7 +490,7 @@ import * as Primitive2 from "@radix-ui/react-toggle-group";
|
|
|
477
490
|
import { useState as useState2 } from "react";
|
|
478
491
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
479
492
|
var ToggleGroup = (props) => {
|
|
480
|
-
const { className, multiple, value, defaultValue, onValueChange, loopFocus = true, layout = "standard", ...restProps } = props;
|
|
493
|
+
const { className, multiple, value, defaultValue, onValueChange, loopFocus = true, layout = "standard", size = "medium", ...restProps } = props;
|
|
481
494
|
const [
|
|
482
495
|
local,
|
|
483
496
|
setLocal
|
|
@@ -486,7 +499,7 @@ var ToggleGroup = (props) => {
|
|
|
486
499
|
return /* @__PURE__ */ jsx8(
|
|
487
500
|
ToggleGroupContext.Provider,
|
|
488
501
|
{
|
|
489
|
-
value: layout,
|
|
502
|
+
value: { layout, size },
|
|
490
503
|
children: /* @__PURE__ */ jsx8(
|
|
491
504
|
Primitive2.Root,
|
|
492
505
|
{
|
|
@@ -510,12 +523,12 @@ var ToggleGroup = (props) => {
|
|
|
510
523
|
};
|
|
511
524
|
|
|
512
525
|
// src/toggle-group-item/style.ts
|
|
513
|
-
import { cva as
|
|
514
|
-
var toggleStyles =
|
|
526
|
+
import { cva as cva5 } from "class-variance-authority";
|
|
527
|
+
var toggleStyles = cva5("gridui-u-choice--min-h-(--gridui-choice-target) gridui-u-choice--cursor-pointer gridui-u-choice--border-0 gridui-u-choice--bg-background gridui-u-choice--px-(--gridui-choice-inline) gridui-u-choice--py-(--gridui-choice-block) gridui-u-choice--text-foreground gridui-u-choice--type-ui gridui-u-choice--data-[state=on]:bg-selection-background gridui-u-choice--data-[state=on]:text-foreground gridui-u-choice--data-disabled:cursor-not-allowed gridui-u-choice--data-disabled:opacity-50 gridui-u-choice--forced-colors:data-[state=on]:forced-color-adjust-none gridui-u-choice--forced-colors:data-[state=on]:bg-[Highlight] gridui-u-choice--forced-colors:data-[state=on]:text-[HighlightText] gridui-u-choice--forced-colors:outline-[CanvasText]", {
|
|
515
528
|
variants: {
|
|
516
529
|
layout: {
|
|
517
530
|
standard: "gridui-u-choice--grow gridui-u-choice--basis-auto gridui-u-choice--min-w-0 gridui-u-choice--max-w-full gridui-u-choice--whitespace-normal gridui-u-choice--wrap-anywhere",
|
|
518
|
-
cells: "gridui-u-choice--w-full gridui-u-choice--min-w-0 gridui-u-choice--whitespace-normal gridui-u-choice--wrap-anywhere gridui-u-choice--border-x-0 gridui-u-choice--border-t-0 gridui-u-choice--border-solid gridui-u-choice--border-transparent gridui-u-choice--px-gridui-
|
|
531
|
+
cells: "gridui-u-choice--w-full gridui-u-choice--min-w-0 gridui-u-choice--whitespace-normal gridui-u-choice--wrap-anywhere gridui-u-choice--border-x-0 gridui-u-choice--border-t-0 gridui-u-choice--border-solid gridui-u-choice--border-transparent gridui-u-choice--px-(--gridui-choice-inline) gridui-u-choice--py-(--gridui-choice-block) gridui-u-choice--text-center gridui-u-choice--data-[orientation=horizontal]:border-b-2 gridui-u-choice--data-[orientation=vertical]:border-b-0 gridui-u-choice--data-[orientation=vertical]:border-r-2 gridui-u-choice--rtl:data-[orientation=vertical]:border-r-0 gridui-u-choice--rtl:data-[orientation=vertical]:border-l-2 gridui-u-choice--data-[state=on]:font-medium"
|
|
519
532
|
}
|
|
520
533
|
},
|
|
521
534
|
defaultVariants: {
|
|
@@ -529,13 +542,15 @@ import * as Primitive3 from "@radix-ui/react-toggle-group";
|
|
|
529
542
|
import { useContext } from "react";
|
|
530
543
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
531
544
|
var ToggleGroupItem = (props) => {
|
|
532
|
-
const
|
|
533
|
-
const
|
|
545
|
+
const group = useContext(ToggleGroupContext);
|
|
546
|
+
const { className, size = group.size, ...restProps } = props;
|
|
547
|
+
const { layout } = group;
|
|
534
548
|
return /* @__PURE__ */ jsx9(
|
|
535
549
|
Primitive3.Item,
|
|
536
550
|
{
|
|
537
551
|
...restProps,
|
|
538
|
-
|
|
552
|
+
"data-size": size,
|
|
553
|
+
className: cn8(toggleStyles({ layout }), choiceSizeStyles({ size }), className)
|
|
539
554
|
}
|
|
540
555
|
);
|
|
541
556
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/shared/use-choice.ts", "../src/checkbox/style.ts", "../src/checkbox/checkbox.tsx", "../src/shared/switch-control.tsx", "../src/shared/switch-indicator.tsx", "../src/switch/style.ts", "../src/switch/switch.tsx", "../src/shared/switch-setting.tsx", "../src/switch-group/switch-group.tsx", "../src/switch-panel/switch-panel.tsx", "../src/shared/context.ts", "../src/toggle-group/style.ts", "../src/toggle-group/toggle-group.tsx", "../src/toggle-group-item/style.ts", "../src/toggle-group-item/toggle-group-item.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Use Choice\n */\n\nimport { focusInvalidControl, useFormReset } from \"@gridui/form\";\nimport { type ChangeDetails, changeDetails } from \"@gridui/interaction\";\nimport { type ComponentPropsWithRef, type Ref, type SyntheticEvent, useImperativeHandle, useRef, useState } from \"react\";\n\nexport type ChoiceProps = Omit<ComponentPropsWithRef<\"button\">, \"children\" | \"onChange\" | \"defaultChecked\"> & {\n readonly checked?: boolean | undefined;\n readonly defaultChecked?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly required?: boolean | undefined;\n readonly uncheckedValue?: string | undefined;\n readonly inputRef?: Ref<HTMLInputElement> | undefined;\n readonly onCheckedChange?: ((checked: boolean, details: ChangeDetails) => void) | undefined;\n};\n\nexport const useChoice = (props: ChoiceProps) => {\n const { checked, defaultChecked = false, onCheckedChange, readOnly, disabled, inputRef, form } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultChecked);\n const input = useRef<HTMLInputElement>(null);\n const control = useRef<HTMLButtonElement>(null);\n const initial = useRef(defaultChecked);\n useImperativeHandle(props.ref, () => {\n return control.current as HTMLButtonElement;\n });\n useImperativeHandle(inputRef, () => {\n return input.current as HTMLInputElement;\n });\n useFormReset(input, () => {\n if (checked === undefined) {\n setLocal(initial.current);\n }\n }, form);\n const current = checked ?? local;\n const invalid = (event: SyntheticEvent<HTMLInputElement>) => {\n focusInvalidControl(event, () => {\n control.current?.focus();\n });\n };\n const change = (next: boolean, event: Event) => {\n if (readOnly || disabled || input.current?.matches(\":disabled\")) {\n return;\n }\n const details = changeDetails(event);\n onCheckedChange?.(next, details);\n if (!details.isCanceled && checked === undefined) {\n setLocal(next);\n }\n };\n return {\n current,\n input,\n control,\n change,\n invalid,\n };\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Checkbox\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const choiceStyles = cva(\"gridui-u-choice--inline-flex gridui-u-choice--size-5 gridui-u-choice--shrink-0 gridui-u-choice--cursor-pointer gridui-u-choice--items-center gridui-u-choice--justify-center gridui-u-choice--rounded-control gridui-u-choice--border gridui-u-choice--border-control-border gridui-u-choice--bg-background gridui-u-choice--text-foreground gridui-u-choice--align-middle gridui-u-choice--data-[state=checked]:bg-accent-background gridui-u-choice--data-[state=checked]:text-accent-foreground gridui-u-choice--data-[state=indeterminate]:bg-accent-background gridui-u-choice--data-[state=indeterminate]:text-accent-foreground gridui-u-choice--data-disabled:cursor-not-allowed gridui-u-choice--data-disabled:opacity-50 gridui-u-choice--data-readonly:cursor-default gridui-u-choice--aria-invalid:border-status-danger-border\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Checkbox\n * @description Checkbox\n */\n\nimport { type ChoiceProps, useChoice } from \"../shared/use-choice\";\nimport { choiceStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-checkbox\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type CheckboxProps = ChoiceProps & {\n readonly indeterminate?: boolean | undefined;\n};\n\nexport const Checkbox: FC<CheckboxProps> = (props: CheckboxProps) => {\n const { className, indeterminate, inputRef, onCheckedChange, checked, defaultChecked,\n readOnly, uncheckedValue, name, value = \"on\", form, required, onClick, ...restProps } = props;\n const { current, input, control, change, invalid } = useChoice({\n ...props,\n inputRef,\n onCheckedChange,\n checked,\n defaultChecked,\n });\n return (<>\n <Primitive.Root\n {...restProps}\n ref={control}\n checked={indeterminate ? \"indeterminate\" : current}\n aria-required={required}\n aria-readonly={readOnly}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n change(indeterminate ? true : !current, event.nativeEvent);\n }\n event.preventDefault();\n }}\n className={cn(choiceStyles(), className)}\n >\n <Primitive.Indicator>\n {indeterminate ? (<Minus\n size={16}\n aria-hidden=\"true\"\n />) : (<Check\n size={16}\n aria-hidden=\"true\"\n />)}\n </Primitive.Indicator>\n </Primitive.Root>\n <input\n ref={input}\n type=\"checkbox\"\n className=\"gridui-u-choice--sr-only\"\n tabIndex={-1}\n aria-hidden=\"true\"\n name={name}\n value={value}\n form={form}\n required={required}\n disabled={props.disabled}\n checked={current}\n readOnly={readOnly}\n onInvalid={invalid}\n onChange={(event) => {\n change(event.target.checked, event.nativeEvent);\n }}\n />\n {!current && uncheckedValue !== undefined && (<input\n type=\"hidden\"\n name={name}\n form={form}\n value={uncheckedValue}\n disabled={props.disabled}\n />)}\n </>);\n};\n", "import { useMotionStyle } from \"@gridui/motion/policy\";\n/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Switch Control\n */\n\nimport { type ChoiceProps, useChoice } from \"./use-choice\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC, ReactNode } from \"react\";\n\nexport type SwitchControlProps = ChoiceProps & {\n readonly children: (checked: boolean) => ReactNode;\n};\n\nexport const SwitchControl: FC<SwitchControlProps> = (props: SwitchControlProps) => {\n const motionStyle = useMotionStyle();\n const { children, className, inputRef, onCheckedChange, checked, defaultChecked,\n readOnly, uncheckedValue, name, value = \"on\", form, required, onClick, type = \"button\", ...restProps } = props;\n const { current, input, control, change, invalid } = useChoice({\n ...props,\n inputRef,\n onCheckedChange,\n checked,\n defaultChecked,\n });\n return (<>\n <button\n {...restProps}\n ref={control}\n type={type}\n role=\"switch\"\n aria-checked={current}\n data-state={current ? \"checked\" : \"unchecked\"}\n data-disabled={props.disabled ? \"\" : undefined}\n aria-required={required}\n aria-readonly={readOnly}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n change(!current, event.nativeEvent);\n }\n event.preventDefault();\n }}\n className={cn(\"gridui-switch-control\", className)}\n style={{ ...(props.style), ...motionStyle }}\n >\n {children(current)}\n </button>\n <input\n ref={input}\n type=\"checkbox\"\n className=\"gridui-u-choice--sr-only\"\n tabIndex={-1}\n aria-hidden=\"true\"\n name={name}\n value={value}\n form={form}\n required={required}\n disabled={props.disabled}\n checked={current}\n readOnly={readOnly}\n onInvalid={invalid}\n onChange={(event) => {\n change(event.target.checked, event.nativeEvent);\n }}\n />\n {!current && uncheckedValue !== undefined && (<input\n type=\"hidden\"\n name={name}\n form={form}\n value={uncheckedValue}\n disabled={props.disabled}\n />)}\n </>);\n};\n", "import { useMotionStyle } from \"@gridui/motion/policy\";\n/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Switch Indicator\n */\n\nimport type { SwitchPresentationProps } from \"./switch-options\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type SwitchIndicatorProps = SwitchPresentationProps & {\n readonly checked: boolean;\n};\n\nexport const SwitchIndicator: FC<SwitchIndicatorProps> = (props: SwitchIndicatorProps) => {\n const motionStyle = useMotionStyle();\n const { checked, variant = \"rail\", stateLabels = {\n checked: \"On\",\n unchecked: \"Off\",\n } } = props;\n return (<span\n className=\"gridui-switch-indicator gridui-u-choice--type-caption\"\n data-variant={variant}\n data-state={checked ? \"checked\" : \"unchecked\"}\n aria-hidden=\"true\"\n style={motionStyle}\n >\n {variant === \"rail\" ? (<span\n className=\"gridui-switch-thumb\"\n />) : (<>\n {checked ? (<Check\n className=\"gridui-switch-state-icon\"\n />) : (<Minus\n className=\"gridui-switch-state-icon\"\n />)}\n <span\n className=\"gridui-switch-state-label\"\n >\n {checked ? stateLabels.checked : stateLabels.unchecked}\n </span>\n </>)}\n </span>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Switch\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const switchStyles = cva(\"gridui-switch gridui-u-choice--inline-flex gridui-u-choice--w-fit gridui-u-choice--max-w-full gridui-u-choice--min-h-gridui-control gridui-u-choice--min-w-gridui-control gridui-u-choice--shrink-0 gridui-u-choice--items-center gridui-u-choice--justify-center gridui-u-choice--border-0 gridui-u-choice--bg-transparent gridui-u-choice--p-0 gridui-u-choice--align-middle gridui-u-choice--rounded-control\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Switch\n * @description Switch\n */\n\nimport { SwitchControl } from \"../shared/switch-control\";\nimport { SwitchIndicator } from \"../shared/switch-indicator\";\nimport type { SwitchOptions } from \"../shared/switch-options\";\nimport { switchStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type SwitchProps = SwitchOptions;\n\nexport const Switch: FC<SwitchProps> = (props: SwitchProps) => {\n const { variant, stateLabels, className, ...restProps } = props;\n return (<SwitchControl\n {...restProps}\n className={cn(switchStyles(), className)}\n >\n {(checked) => {\n return (<SwitchIndicator\n checked={checked}\n variant={variant}\n stateLabels={stateLabels}\n />);\n }}\n </SwitchControl>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Switch Setting\n */\n\nimport { SwitchControl } from \"./switch-control\";\nimport { SwitchIndicator } from \"./switch-indicator\";\nimport type { SwitchSettingOptions } from \"./switch-options\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type FC, useId } from \"react\";\n\nexport type SwitchSettingProps = SwitchSettingOptions;\n\nexport const SwitchSetting: FC<SwitchSettingProps> = (props: SwitchSettingProps) => {\n const { control, label, description } = props;\n const { variant, stateLabels, className, ...controlProps } = control;\n const id = useId();\n const labelId = `${id}-label`;\n const descriptionId = `${id}-description`;\n const hasDescription = description !== undefined && description !== null;\n const describedBy = [\n controlProps[\"aria-describedby\"],\n hasDescription ? descriptionId : undefined,\n ].filter(Boolean).join(\" \") || undefined;\n return (<SwitchControl\n {...controlProps}\n className={cn(\"gridui-switch-setting\", className)}\n aria-labelledby={controlProps[\"aria-labelledby\"] ?? (controlProps[\"aria-label\"] ? undefined : labelId)}\n aria-describedby={describedBy}\n >\n {(checked) => {\n return (<>\n <span\n className=\"gridui-switch-setting-copy\"\n >\n <span\n id={labelId}\n className=\"gridui-u-choice--type-ui\"\n >\n {label}\n </span>\n {hasDescription && (<span\n id={descriptionId}\n className=\"gridui-switch-setting-description gridui-u-choice--type-supporting\"\n >\n {description}\n </span>)}\n </span>\n <span\n className=\"gridui-switch-setting-end\"\n >\n <SwitchIndicator\n checked={checked}\n variant={variant}\n stateLabels={stateLabels}\n />\n </span>\n </>);\n }}\n </SwitchControl>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace SwitchGroup\n * @description Switch Group\n */\n\nimport type { SwitchOptions, SwitchPresentationProps, SwitchSettingCopy } from \"../shared/switch-options\";\nimport { SwitchSetting } from \"../shared/switch-setting\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC, ReactNode } from \"react\";\n\nexport type SwitchGroupItem = SwitchOptions & SwitchSettingCopy & {\n /** Stable item identity and native control ID. */\n readonly id: string;\n};\n\nexport type SwitchGroupProps = Omit<ComponentPropsWithRef<\"fieldset\">, \"children\"> & SwitchPresentationProps & {\n readonly items: readonly SwitchGroupItem[];\n readonly legend?: ReactNode;\n readonly density?: \"compact\" | \"comfortable\";\n};\n\nexport const SwitchGroup: FC<SwitchGroupProps> = (props: SwitchGroupProps) => {\n const { items, legend, density = \"compact\", variant, stateLabels, className, ...restProps } = props;\n return (<fieldset\n {...restProps}\n className={cn(\"gridui-switch-group\", className)}\n data-density={density}\n >\n {legend !== undefined && legend !== null && (<legend\n className=\"gridui-switch-group-legend gridui-u-choice--type-ui\"\n >\n {legend}\n </legend>)}\n {items.map((item) => {\n const { label, description, ...control } = item;\n return (<SwitchSetting\n key={item.id}\n label={label}\n description={description}\n control={{\n ...control,\n variant: item.variant ?? variant,\n stateLabels: item.stateLabels ?? stateLabels,\n }}\n />);\n })}\n </fieldset>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace SwitchPanel\n * @description Switch Panel\n */\n\nimport type { SwitchSettingOptions } from \"../shared/switch-options\";\nimport { SwitchSetting } from \"../shared/switch-setting\";\nimport { cn } from \"@gridui/style-utils\";\nimport { Children, type ComponentPropsWithRef, type FC } from \"react\";\n\nexport type SwitchPanelProps = ComponentPropsWithRef<\"div\"> & SwitchSettingOptions;\n\nexport const SwitchPanel: FC<SwitchPanelProps> = (props: SwitchPanelProps) => {\n const { label, description, control, children, className, ...restProps } = props;\n const hasContent = Children.toArray(children).some((child) => {\n return child !== \"\";\n });\n return (<div\n {...restProps}\n className={cn(\"gridui-switch-panel\", className)}\n >\n <SwitchSetting\n label={label}\n description={description}\n control={control}\n />\n {hasContent && (<div\n className=\"gridui-switch-panel-content\"\n >\n {children}\n </div>)}\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Context\n */\n\nimport { createContext } from \"react\";\n\nexport const ToggleGroupContext = createContext<\"standard\" | \"cells\">(\"standard\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroup\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const toggleGroupStyles = cva(\"gridui-toggle-group gridui-u-choice--inline-flex gridui-u-choice--max-w-full gridui-u-choice--flex-wrap gridui-u-choice--gap-px gridui-u-choice--border gridui-u-choice--border-border gridui-u-choice--bg-border gridui-u-choice--data-[orientation=vertical]:flex-col\", {\n variants: {\n layout: {\n standard: \"\",\n cells: \"gridui-u-choice--grid gridui-u-choice--w-full gridui-u-choice--grid-flow-col gridui-u-choice--auto-cols-fr gridui-u-choice--data-[orientation=vertical]:grid-flow-row gridui-u-choice--data-[orientation=vertical]:auto-rows-fr gridui-u-choice--data-[orientation=vertical]:grid-cols-1\",\n },\n },\n defaultVariants: { layout: \"standard\" },\n});\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroup\n * @description Toggle Group\n */\n\nimport { ToggleGroupContext } from \"../shared/context\";\nimport { toggleGroupStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-toggle-group\";\nimport { type ComponentPropsWithRef, type FC, useState } from \"react\";\n\nexport type ToggleGroupProps = Omit<ComponentPropsWithRef<typeof Primitive.Root>, \"type\" | \"value\" | \"defaultValue\" | \"onValueChange\" | \"loop\"> & {\n readonly multiple?: boolean | undefined;\n readonly value?: string[] | undefined;\n readonly defaultValue?: string[] | undefined;\n readonly onValueChange?: ((value: string[]) => void) | undefined;\n readonly loopFocus?: boolean | undefined;\n readonly layout?: \"standard\" | \"cells\" | undefined;\n};\n\nexport const ToggleGroup: FC<ToggleGroupProps> = (props: ToggleGroupProps) => {\n const { className, multiple, value, defaultValue, onValueChange, loopFocus = true, layout = \"standard\", ...restProps } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultValue ?? []);\n const current = value ?? local;\n return (<ToggleGroupContext.Provider\n value={layout}\n >\n <Primitive.Root\n {...restProps}\n loop={loopFocus}\n className={cn(toggleGroupStyles({ layout }), className)}\n data-layout={layout}\n type=\"multiple\"\n value={multiple ? current : current.slice(-1)}\n onValueChange={(next) => {\n const selected = multiple ? next : next.slice(-1);\n if (value === undefined) {\n setLocal(selected);\n }\n onValueChange?.(selected);\n }}\n />\n </ToggleGroupContext.Provider>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroupItem\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const toggleStyles = cva(\"gridui-u-choice--min-h-gridui-control gridui-u-choice--cursor-pointer gridui-u-choice--border-0 gridui-u-choice--bg-background gridui-u-choice--px-gridui-16 gridui-u-choice--py-gridui-8 gridui-u-choice--text-foreground gridui-u-choice--type-ui gridui-u-choice--data-[state=on]:bg-selection-background gridui-u-choice--data-[state=on]:text-foreground gridui-u-choice--data-disabled:cursor-not-allowed gridui-u-choice--data-disabled:opacity-50 gridui-u-choice--forced-colors:data-[state=on]:forced-color-adjust-none gridui-u-choice--forced-colors:data-[state=on]:bg-[Highlight] gridui-u-choice--forced-colors:data-[state=on]:text-[HighlightText] gridui-u-choice--forced-colors:outline-[CanvasText]\", {\n variants: {\n layout: {\n standard: \"gridui-u-choice--grow gridui-u-choice--basis-auto gridui-u-choice--min-w-0 gridui-u-choice--max-w-full gridui-u-choice--whitespace-normal gridui-u-choice--wrap-anywhere\",\n cells: \"gridui-u-choice--w-full gridui-u-choice--min-w-0 gridui-u-choice--whitespace-normal gridui-u-choice--wrap-anywhere gridui-u-choice--border-x-0 gridui-u-choice--border-t-0 gridui-u-choice--border-solid gridui-u-choice--border-transparent gridui-u-choice--px-gridui-8 gridui-u-choice--py-gridui-16 gridui-u-choice--text-center gridui-u-choice--data-[orientation=horizontal]:border-b-2 gridui-u-choice--data-[orientation=vertical]:border-b-0 gridui-u-choice--data-[orientation=vertical]:border-r-2 gridui-u-choice--rtl:data-[orientation=vertical]:border-r-0 gridui-u-choice--rtl:data-[orientation=vertical]:border-l-2 gridui-u-choice--data-[state=on]:font-medium\",\n },\n },\n defaultVariants: {\n layout: \"standard\",\n },\n});\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroupItem\n * @description Toggle Group Item\n */\n\nimport { ToggleGroupContext } from \"../shared/context\";\nimport { toggleStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-toggle-group\";\nimport { type ComponentPropsWithRef, type FC, useContext } from \"react\";\n\nexport type ToggleGroupItemProps = ComponentPropsWithRef<typeof Primitive.Item>;\n\nexport const ToggleGroupItem: FC<ToggleGroupItemProps> = (props: ToggleGroupItemProps) => {\n const { className, ...restProps } = props;\n const layout = useContext(ToggleGroupContext);\n return (<Primitive.Item\n {...restProps}\n className={cn(toggleStyles({ layout }), className)}\n />);\n};\n"],
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": ["cn", "Fragment", "jsx", "jsxs", "useMotionStyle", "Check", "Minus", "Fragment", "jsx", "jsxs", "cva", "cn", "jsx", "cn", "Fragment", "jsx", "jsxs", "cn", "jsx", "jsxs", "cn", "jsx", "jsxs", "cva", "cn", "Primitive", "useState", "jsx", "cva", "cn", "Primitive", "jsx"]
|
|
3
|
+
"sources": ["../src/shared/size.ts", "../src/shared/use-choice.ts", "../src/checkbox/style.ts", "../src/checkbox/checkbox.tsx", "../src/shared/switch-control.tsx", "../src/shared/switch-indicator.tsx", "../src/switch/style.ts", "../src/switch/switch.tsx", "../src/shared/switch-setting.tsx", "../src/switch-group/switch-group.tsx", "../src/switch-panel/switch-panel.tsx", "../src/shared/context.ts", "../src/toggle-group/style.ts", "../src/toggle-group/toggle-group.tsx", "../src/toggle-group-item/style.ts", "../src/toggle-group-item/toggle-group-item.tsx"],
|
|
4
|
+
"sourcesContent": ["import { cva } from \"class-variance-authority\";\n\nexport const choiceSizeStyles = cva(\"gridui-choice-sized\", { variants: { size: {\n small: \"gridui-u-choice--[--gridui-choice-target:max(var(--gridui-control-min-height-small),var(--gridui-target-min-size))] gridui-u-choice--[--gridui-choice-mark:1rem] gridui-u-choice--[--gridui-choice-inline:var(--gridui-space-8)] gridui-u-choice--[--gridui-choice-block:var(--gridui-space-4)]\",\n medium: \"gridui-u-choice--[--gridui-choice-target:max(var(--gridui-control-min-height-medium),var(--gridui-target-min-size))] gridui-u-choice--[--gridui-choice-mark:1.25rem] gridui-u-choice--[--gridui-choice-inline:var(--gridui-space-16)] gridui-u-choice--[--gridui-choice-block:var(--gridui-space-8)]\",\n large: \"gridui-u-choice--[--gridui-choice-target:max(var(--gridui-control-min-height-large),var(--gridui-target-min-size))] gridui-u-choice--[--gridui-choice-mark:1.5rem] gridui-u-choice--[--gridui-choice-inline:var(--gridui-space-24)] gridui-u-choice--[--gridui-choice-block:var(--gridui-space-8)]\",\n} }, defaultVariants: { size: \"medium\" } });\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Use Choice\n */\n\nimport type { Size } from \"@gridui/theme\";\nimport { focusInvalidControl, useFormReset } from \"@gridui/form\";\nimport { type ChangeDetails, changeDetails } from \"@gridui/interaction\";\nimport { type ComponentPropsWithRef, type Ref, type SyntheticEvent, useImperativeHandle, useRef, useState } from \"react\";\n\nexport type ChoiceProps = Omit<ComponentPropsWithRef<\"button\">, \"children\" | \"onChange\" | \"defaultChecked\"> & {\n readonly size?: Size | undefined;\n readonly checked?: boolean | undefined;\n readonly defaultChecked?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly required?: boolean | undefined;\n readonly uncheckedValue?: string | undefined;\n readonly inputRef?: Ref<HTMLInputElement> | undefined;\n readonly onCheckedChange?: ((checked: boolean, details: ChangeDetails) => void) | undefined;\n};\n\nexport const useChoice = (props: ChoiceProps) => {\n const { checked, defaultChecked = false, onCheckedChange, readOnly, disabled, inputRef, form } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultChecked);\n const input = useRef<HTMLInputElement>(null);\n const control = useRef<HTMLButtonElement>(null);\n const initial = useRef(defaultChecked);\n useImperativeHandle(props.ref, () => {\n return control.current as HTMLButtonElement;\n });\n useImperativeHandle(inputRef, () => {\n return input.current as HTMLInputElement;\n });\n useFormReset(input, () => {\n if (checked === undefined) {\n setLocal(initial.current);\n }\n }, form);\n const current = checked ?? local;\n const invalid = (event: SyntheticEvent<HTMLInputElement>) => {\n focusInvalidControl(event, () => {\n control.current?.focus();\n });\n };\n const change = (next: boolean, event: Event) => {\n if (readOnly || disabled || input.current?.matches(\":disabled\")) {\n return;\n }\n const details = changeDetails(event);\n onCheckedChange?.(next, details);\n if (!details.isCanceled && checked === undefined) {\n setLocal(next);\n }\n };\n return {\n current,\n input,\n control,\n change,\n invalid,\n };\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Checkbox\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const choiceStyles = cva(\"gridui-checkbox gridui-u-choice--inline-flex gridui-u-choice--shrink-0 gridui-u-choice--cursor-pointer gridui-u-choice--items-center gridui-u-choice--justify-center gridui-u-choice--border-0 gridui-u-choice--bg-transparent gridui-u-choice--p-0 gridui-u-choice--text-foreground gridui-u-choice--align-middle gridui-u-choice--rounded-control gridui-u-choice--data-disabled:cursor-not-allowed gridui-u-choice--data-disabled:opacity-50 gridui-u-choice--data-readonly:cursor-default\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Checkbox\n * @description Checkbox\n */\n\nimport { choiceSizeStyles } from \"../shared/size\";\nimport { type ChoiceProps, useChoice } from \"../shared/use-choice\";\nimport { choiceStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-checkbox\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type CheckboxProps = ChoiceProps & {\n readonly indeterminate?: boolean | undefined;\n};\n\nexport const Checkbox: FC<CheckboxProps> = (props: CheckboxProps) => {\n const { className, size = \"medium\", indeterminate, inputRef, onCheckedChange, checked, defaultChecked,\n readOnly, uncheckedValue, name, value = \"on\", form, required, onClick, ...restProps } = props;\n const { current, input, control, change, invalid } = useChoice({\n ...props,\n inputRef,\n onCheckedChange,\n checked,\n defaultChecked,\n });\n return (<>\n <Primitive.Root\n {...restProps}\n ref={control}\n checked={indeterminate ? \"indeterminate\" : current}\n aria-required={required}\n aria-readonly={readOnly}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n change(indeterminate ? true : !current, event.nativeEvent);\n }\n event.preventDefault();\n }}\n data-size={size}\n className={cn(choiceStyles(), choiceSizeStyles({ size }), className)}\n >\n <span className=\"gridui-checkbox-mark\" aria-hidden=\"true\"><Primitive.Indicator>\n {indeterminate ? (<Minus\n size={16}\n aria-hidden=\"true\"\n />) : (<Check\n size={16}\n aria-hidden=\"true\"\n />)}\n </Primitive.Indicator></span>\n </Primitive.Root>\n <input\n ref={input}\n type=\"checkbox\"\n className=\"gridui-u-choice--sr-only\"\n tabIndex={-1}\n aria-hidden=\"true\"\n name={name}\n value={value}\n form={form}\n required={required}\n disabled={props.disabled}\n checked={current}\n readOnly={readOnly}\n onInvalid={invalid}\n onChange={(event) => {\n change(event.target.checked, event.nativeEvent);\n }}\n />\n {!current && uncheckedValue !== undefined && (<input\n type=\"hidden\"\n name={name}\n form={form}\n value={uncheckedValue}\n disabled={props.disabled}\n />)}\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Switch Control\n */\n\nimport { choiceSizeStyles } from \"./size\";\nimport { useMotionStyle } from \"@gridui/motion/policy\";\n/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Switch Control\n */\n\nimport { type ChoiceProps, useChoice } from \"./use-choice\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC, ReactNode } from \"react\";\n\nexport type SwitchControlProps = ChoiceProps & {\n readonly children: (checked: boolean) => ReactNode;\n};\n\nexport const SwitchControl: FC<SwitchControlProps> = (props: SwitchControlProps) => {\n const motionStyle = useMotionStyle();\n const { children, className, size = \"medium\", inputRef, onCheckedChange, checked, defaultChecked,\n readOnly, uncheckedValue, name, value = \"on\", form, required, onClick, type = \"button\", ...restProps } = props;\n const { current, input, control, change, invalid } = useChoice({\n ...props,\n inputRef,\n onCheckedChange,\n checked,\n defaultChecked,\n });\n return (<>\n <button\n {...restProps}\n ref={control}\n type={type}\n role=\"switch\"\n aria-checked={current}\n data-state={current ? \"checked\" : \"unchecked\"}\n data-disabled={props.disabled ? \"\" : undefined}\n aria-required={required}\n aria-readonly={readOnly}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n change(!current, event.nativeEvent);\n }\n event.preventDefault();\n }}\n data-size={size}\n className={cn(\"gridui-switch-control\", choiceSizeStyles({ size }), className)}\n style={{ ...(props.style), ...motionStyle }}\n >\n {children(current)}\n </button>\n <input\n ref={input}\n type=\"checkbox\"\n className=\"gridui-u-choice--sr-only\"\n tabIndex={-1}\n aria-hidden=\"true\"\n name={name}\n value={value}\n form={form}\n required={required}\n disabled={props.disabled}\n checked={current}\n readOnly={readOnly}\n onInvalid={invalid}\n onChange={(event) => {\n change(event.target.checked, event.nativeEvent);\n }}\n />\n {!current && uncheckedValue !== undefined && (<input\n type=\"hidden\"\n name={name}\n form={form}\n value={uncheckedValue}\n disabled={props.disabled}\n />)}\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Switch Indicator\n */\n\nimport { useMotionStyle } from \"@gridui/motion/policy\";\n/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Switch Indicator\n */\n\nimport type { SwitchPresentationProps } from \"./switch-options\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type SwitchIndicatorProps = SwitchPresentationProps & {\n readonly checked: boolean;\n};\n\nexport const SwitchIndicator: FC<SwitchIndicatorProps> = (props: SwitchIndicatorProps) => {\n const motionStyle = useMotionStyle();\n const { checked, variant = \"rail\", stateLabels = {\n checked: \"On\",\n unchecked: \"Off\",\n } } = props;\n return (<span\n className=\"gridui-switch-indicator gridui-u-choice--type-caption\"\n data-variant={variant}\n data-state={checked ? \"checked\" : \"unchecked\"}\n aria-hidden=\"true\"\n style={motionStyle}\n >\n {variant === \"rail\" ? (<span\n className=\"gridui-switch-thumb\"\n />) : (<>\n {checked ? (<Check\n className=\"gridui-switch-state-icon\"\n />) : (<Minus\n className=\"gridui-switch-state-icon\"\n />)}\n <span\n className=\"gridui-switch-state-label\"\n >\n {checked ? stateLabels.checked : stateLabels.unchecked}\n </span>\n </>)}\n </span>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Switch\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const switchStyles = cva(\"gridui-switch gridui-u-choice--inline-flex gridui-u-choice--w-fit gridui-u-choice--max-w-full gridui-u-choice--min-h-(--gridui-choice-target) gridui-u-choice--min-w-(--gridui-choice-target) gridui-u-choice--shrink-0 gridui-u-choice--items-center gridui-u-choice--justify-center gridui-u-choice--border-0 gridui-u-choice--bg-transparent gridui-u-choice--p-0 gridui-u-choice--align-middle gridui-u-choice--rounded-control\");\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Switch\n * @description Switch\n */\n\nimport { SwitchControl } from \"../shared/switch-control\";\nimport { SwitchIndicator } from \"../shared/switch-indicator\";\nimport type { SwitchOptions } from \"../shared/switch-options\";\nimport { switchStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type SwitchProps = SwitchOptions;\n\nexport const Switch: FC<SwitchProps> = (props: SwitchProps) => {\n const { variant, stateLabels, className, ...restProps } = props;\n return (<SwitchControl\n {...restProps}\n className={cn(switchStyles(), className)}\n >\n {(checked) => {\n return (<SwitchIndicator\n checked={checked}\n variant={variant}\n stateLabels={stateLabels}\n />);\n }}\n </SwitchControl>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Switch Setting\n */\n\nimport { SwitchControl } from \"./switch-control\";\nimport { SwitchIndicator } from \"./switch-indicator\";\nimport type { SwitchSettingOptions } from \"./switch-options\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type FC, useId } from \"react\";\n\nexport type SwitchSettingProps = SwitchSettingOptions;\n\nexport const SwitchSetting: FC<SwitchSettingProps> = (props: SwitchSettingProps) => {\n const { control, label, description } = props;\n const { variant, stateLabels, className, ...controlProps } = control;\n const id = useId();\n const labelId = `${id}-label`;\n const descriptionId = `${id}-description`;\n const hasDescription = description !== undefined && description !== null;\n const describedBy = [\n controlProps[\"aria-describedby\"],\n hasDescription ? descriptionId : undefined,\n ].filter(Boolean).join(\" \") || undefined;\n return (<SwitchControl\n {...controlProps}\n className={cn(\"gridui-switch-setting\", className)}\n aria-labelledby={controlProps[\"aria-labelledby\"] ?? (controlProps[\"aria-label\"] ? undefined : labelId)}\n aria-describedby={describedBy}\n >\n {(checked) => {\n return (<>\n <span\n className=\"gridui-switch-setting-copy\"\n >\n <span\n id={labelId}\n className=\"gridui-u-choice--type-ui\"\n >\n {label}\n </span>\n {hasDescription && (<span\n id={descriptionId}\n className=\"gridui-switch-setting-description gridui-u-choice--type-supporting\"\n >\n {description}\n </span>)}\n </span>\n <span\n className=\"gridui-switch-setting-end\"\n >\n <SwitchIndicator\n checked={checked}\n variant={variant}\n stateLabels={stateLabels}\n />\n </span>\n </>);\n }}\n </SwitchControl>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace SwitchGroup\n * @description Switch Group\n */\n\nimport type { Size, Density } from \"@gridui/theme\";\nimport type { SwitchOptions, SwitchPresentationProps, SwitchSettingCopy } from \"../shared/switch-options\";\nimport { SwitchSetting } from \"../shared/switch-setting\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC, ReactNode } from \"react\";\n\nexport type SwitchGroupItem = SwitchOptions & SwitchSettingCopy & {\n /** Stable item identity and native control ID. */\n readonly id: string;\n};\n\nexport type SwitchGroupProps = Omit<ComponentPropsWithRef<\"fieldset\">, \"children\"> & SwitchPresentationProps & {\n readonly items: readonly SwitchGroupItem[];\n readonly legend?: ReactNode;\n readonly density?: Density;\n readonly size?: Size;\n};\n\nexport const SwitchGroup: FC<SwitchGroupProps> = (props: SwitchGroupProps) => {\n const { items, legend, density = \"comfortable\", size = \"medium\", variant, stateLabels, className, ...restProps } = props;\n return (<fieldset\n {...restProps}\n className={cn(\"gridui-switch-group\", className)}\n data-density={density}\n >\n {legend !== undefined && legend !== null && (<legend\n className=\"gridui-switch-group-legend gridui-u-choice--type-ui\"\n >\n {legend}\n </legend>)}\n {items.map((item) => {\n const { label, description, ...control } = item;\n return (<SwitchSetting\n key={item.id}\n label={label}\n description={description}\n control={{\n ...control,\n size: control.size ?? size,\n variant: item.variant ?? variant,\n stateLabels: item.stateLabels ?? stateLabels,\n }}\n />);\n })}\n </fieldset>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace SwitchPanel\n * @description Switch Panel\n */\n\nimport type { Size } from \"@gridui/theme\";\nimport type { SwitchSettingOptions } from \"../shared/switch-options\";\nimport { SwitchSetting } from \"../shared/switch-setting\";\nimport { cn } from \"@gridui/style-utils\";\nimport { Children, type ComponentPropsWithRef, type FC } from \"react\";\n\nexport type SwitchPanelProps = ComponentPropsWithRef<\"div\"> & SwitchSettingOptions & { readonly size?: Size };\n\nexport const SwitchPanel: FC<SwitchPanelProps> = (props: SwitchPanelProps) => {\n const { label, description, control, size = \"medium\", children, className, ...restProps } = props;\n const hasContent = Children.toArray(children).some((child) => {\n return child !== \"\";\n });\n return (<div\n {...restProps}\n className={cn(\"gridui-switch-panel\", className)}\n >\n <SwitchSetting\n label={label}\n description={description}\n control={{ ...control, size: control.size ?? size }}\n />\n {hasContent && (<div\n className=\"gridui-switch-panel-content\"\n >\n {children}\n </div>)}\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Context\n */\n\nimport type { Size } from \"@gridui/theme\";\nimport { createContext } from \"react\";\n\nexport const ToggleGroupContext = createContext<{ readonly layout: \"standard\" | \"cells\"; readonly size: Size }>({ layout: \"standard\", size: \"medium\" });\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroup\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const toggleGroupStyles = cva(\"gridui-toggle-group gridui-u-choice--inline-flex gridui-u-choice--max-w-full gridui-u-choice--flex-wrap gridui-u-choice--gap-px gridui-u-choice--border gridui-u-choice--border-border gridui-u-choice--bg-border gridui-u-choice--data-[orientation=vertical]:flex-col\", {\n variants: {\n layout: {\n standard: \"\",\n cells: \"gridui-u-choice--grid gridui-u-choice--w-full gridui-u-choice--grid-flow-col gridui-u-choice--auto-cols-fr gridui-u-choice--data-[orientation=vertical]:grid-flow-row gridui-u-choice--data-[orientation=vertical]:auto-rows-fr gridui-u-choice--data-[orientation=vertical]:grid-cols-1\",\n },\n },\n defaultVariants: { layout: \"standard\" },\n});\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroup\n * @description Toggle Group\n */\n\nimport type { Size } from \"@gridui/theme\";\nimport { ToggleGroupContext } from \"../shared/context\";\nimport { toggleGroupStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-toggle-group\";\nimport { type ComponentPropsWithRef, type FC, useState } from \"react\";\n\nexport type ToggleGroupProps = Omit<ComponentPropsWithRef<typeof Primitive.Root>, \"type\" | \"value\" | \"defaultValue\" | \"onValueChange\" | \"loop\"> & {\n readonly size?: Size;\n readonly multiple?: boolean | undefined;\n readonly value?: string[] | undefined;\n readonly defaultValue?: string[] | undefined;\n readonly onValueChange?: ((value: string[]) => void) | undefined;\n readonly loopFocus?: boolean | undefined;\n readonly layout?: \"standard\" | \"cells\" | undefined;\n};\n\nexport const ToggleGroup: FC<ToggleGroupProps> = (props: ToggleGroupProps) => {\n const { className, multiple, value, defaultValue, onValueChange, loopFocus = true, layout = \"standard\", size = \"medium\", ...restProps } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultValue ?? []);\n const current = value ?? local;\n return (<ToggleGroupContext.Provider\n value={{ layout, size }}\n >\n <Primitive.Root\n {...restProps}\n loop={loopFocus}\n className={cn(toggleGroupStyles({ layout }), className)}\n data-layout={layout}\n type=\"multiple\"\n value={multiple ? current : current.slice(-1)}\n onValueChange={(next) => {\n const selected = multiple ? next : next.slice(-1);\n if (value === undefined) {\n setLocal(selected);\n }\n onValueChange?.(selected);\n }}\n />\n </ToggleGroupContext.Provider>);\n};\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroupItem\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const toggleStyles = cva(\"gridui-u-choice--min-h-(--gridui-choice-target) gridui-u-choice--cursor-pointer gridui-u-choice--border-0 gridui-u-choice--bg-background gridui-u-choice--px-(--gridui-choice-inline) gridui-u-choice--py-(--gridui-choice-block) gridui-u-choice--text-foreground gridui-u-choice--type-ui gridui-u-choice--data-[state=on]:bg-selection-background gridui-u-choice--data-[state=on]:text-foreground gridui-u-choice--data-disabled:cursor-not-allowed gridui-u-choice--data-disabled:opacity-50 gridui-u-choice--forced-colors:data-[state=on]:forced-color-adjust-none gridui-u-choice--forced-colors:data-[state=on]:bg-[Highlight] gridui-u-choice--forced-colors:data-[state=on]:text-[HighlightText] gridui-u-choice--forced-colors:outline-[CanvasText]\", {\n variants: {\n layout: {\n standard: \"gridui-u-choice--grow gridui-u-choice--basis-auto gridui-u-choice--min-w-0 gridui-u-choice--max-w-full gridui-u-choice--whitespace-normal gridui-u-choice--wrap-anywhere\",\n cells: \"gridui-u-choice--w-full gridui-u-choice--min-w-0 gridui-u-choice--whitespace-normal gridui-u-choice--wrap-anywhere gridui-u-choice--border-x-0 gridui-u-choice--border-t-0 gridui-u-choice--border-solid gridui-u-choice--border-transparent gridui-u-choice--px-(--gridui-choice-inline) gridui-u-choice--py-(--gridui-choice-block) gridui-u-choice--text-center gridui-u-choice--data-[orientation=horizontal]:border-b-2 gridui-u-choice--data-[orientation=vertical]:border-b-0 gridui-u-choice--data-[orientation=vertical]:border-r-2 gridui-u-choice--rtl:data-[orientation=vertical]:border-r-0 gridui-u-choice--rtl:data-[orientation=vertical]:border-l-2 gridui-u-choice--data-[state=on]:font-medium\",\n },\n },\n defaultVariants: {\n layout: \"standard\",\n },\n});\n", "/**\n * @author WMXPY\n * @package Choice\n * @namespace ToggleGroupItem\n * @description Toggle Group Item\n */\n\nimport { choiceSizeStyles } from \"../shared/size\";\nimport type { Size } from \"@gridui/theme\";\nimport { ToggleGroupContext } from \"../shared/context\";\nimport { toggleStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport * as Primitive from \"@radix-ui/react-toggle-group\";\nimport { type ComponentPropsWithRef, type FC, useContext } from \"react\";\n\nexport type ToggleGroupItemProps = ComponentPropsWithRef<typeof Primitive.Item> & { readonly size?: Size };\n\nexport const ToggleGroupItem: FC<ToggleGroupItemProps> = (props: ToggleGroupItemProps) => {\n const group = useContext(ToggleGroupContext);\n const { className, size = group.size, ...restProps } = props;\n const { layout } = group;\n return (<Primitive.Item\n {...restProps}\n data-size={size}\n className={cn(toggleStyles({ layout }), choiceSizeStyles({ size }), className)}\n />);\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,WAAW;AAEb,IAAM,mBAAmB,IAAI,uBAAuB,EAAE,UAAU,EAAE,MAAM;AAAA,EAC3E,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,EAAE,GAAG,iBAAiB,EAAE,MAAM,SAAS,EAAE,CAAC;;;ACE1C,SAAS,qBAAqB,oBAAoB;AAClD,SAA6B,qBAAqB;AAClD,SAAoE,qBAAqB,QAAQ,gBAAgB;AAa1G,IAAM,YAAY,CAAC,UAAuB;AAC7C,QAAM,EAAE,SAAS,iBAAiB,OAAO,iBAAiB,UAAU,UAAU,UAAU,KAAK,IAAI;AACjG,QAAM;AAAA,IACF;AAAA,IACA;AAAA,EACJ,IAAI,SAAS,cAAc;AAC3B,QAAM,QAAQ,OAAyB,IAAI;AAC3C,QAAM,UAAU,OAA0B,IAAI;AAC9C,QAAM,UAAU,OAAO,cAAc;AACrC,sBAAoB,MAAM,KAAK,MAAM;AACjC,WAAO,QAAQ;AAAA,EACnB,CAAC;AACD,sBAAoB,UAAU,MAAM;AAChC,WAAO,MAAM;AAAA,EACjB,CAAC;AACD,eAAa,OAAO,MAAM;AACtB,QAAI,YAAY,QAAW;AACvB,eAAS,QAAQ,OAAO;AAAA,IAC5B;AAAA,EACJ,GAAG,IAAI;AACP,QAAM,UAAU,WAAW;AAC3B,QAAM,UAAU,CAAC,UAA4C;AACzD,wBAAoB,OAAO,MA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cn", "Fragment", "jsx", "jsxs", "cn", "jsx", "jsxs", "cn", "jsx", "jsxs", "cva", "cn", "Primitive", "useState", "jsx", "cva", "cn", "Primitive", "jsx"]
|
|
7
7
|
}
|
package/dist/shared/context.d.ts
CHANGED
|
@@ -4,4 +4,8 @@
|
|
|
4
4
|
* @namespace Shared
|
|
5
5
|
* @description Context
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
import type { Size } from "@gridui/theme";
|
|
8
|
+
export declare const ToggleGroupContext: import("react").Context<{
|
|
9
|
+
readonly layout: "standard" | "cells";
|
|
10
|
+
readonly size: Size;
|
|
11
|
+
}>;
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* @namespace Shared
|
|
5
5
|
* @description Use Choice
|
|
6
6
|
*/
|
|
7
|
+
import type { Size } from "@gridui/theme";
|
|
7
8
|
import { type ChangeDetails } from "@gridui/interaction";
|
|
8
9
|
import { type ComponentPropsWithRef, type Ref, type SyntheticEvent } from "react";
|
|
9
10
|
export type ChoiceProps = Omit<ComponentPropsWithRef<"button">, "children" | "onChange" | "defaultChecked"> & {
|
|
11
|
+
readonly size?: Size | undefined;
|
|
10
12
|
readonly checked?: boolean | undefined;
|
|
11
13
|
readonly defaultChecked?: boolean | undefined;
|
|
12
14
|
readonly readOnly?: boolean | undefined;
|
package/dist/styled.js
ADDED