@gridui/choice 1.4.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 +10 -3
- 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/use-choice.d.ts +2 -0
- package/dist/styles.css +77 -44
- package/dist/styles.local.css +77 -44
- 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 +13 -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 +7 -7
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
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-
|
|
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
9
|
|
|
10
10
|
## Styles
|
|
11
11
|
|
|
@@ -60,5 +60,12 @@ whole-control disabled appearance.
|
|
|
60
60
|
|
|
61
61
|
Shared animation policy and tempo come from `MotionConfig` in `@gridui/motion`.
|
|
62
62
|
Disabled or reduced-motion policy settles decoration without disabling interaction.
|
|
63
|
-
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)
|
|
64
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", "/**\n * @author WMXPY\n * @package Choice\n * @namespace Shared\n * @description Switch Control\n */\n\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, 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", "/**\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-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
|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BAAS,QAAQ;AAAA,YACrB;AACA,4BAAgB,QAAQ;AAAA,UAC5B;AAAA;AAAA,MACJ;AAAA;AAAA,EACJ;AACJ;;;AC3CA,SAAS,OAAAI,YAAW;AAEb,IAAM,eAAeA,KAAI,muBAAmuB;AAAA,EAC/vB,UAAU;AAAA,IACN,QAAQ;AAAA,MACJ,UAAU;AAAA,MACV,OAAO;AAAA,IACX;AAAA,EACJ;AAAA,EACA,iBAAiB;AAAA,IACb,QAAQ;AAAA,EACZ;AACJ,CAAC;;;ACRD,SAAS,MAAAC,WAAU;AACnB,YAAYC,gBAAe;AAC3B,SAA8C,kBAAkB;AAQpD,gBAAAC,YAAA;AAJL,IAAM,kBAA4C,CAAC,UAAgC;AACtF,QAAM,QAAQ,WAAW,kBAAkB;AAC3C,QAAM,EAAE,WAAW,OAAO,MAAM,MAAM,GAAG,UAAU,IAAI;AACvD,QAAM,EAAE,OAAO,IAAI;AACnB,SAAQ,gBAAAA;AAAA,IAAW;AAAA,IAAV;AAAA,MACJ,GAAG;AAAA,MACJ,aAAW;AAAA,MACX,WAAWF,IAAG,aAAa,EAAE,OAAO,CAAC,GAAG,iBAAiB,EAAE,KAAK,CAAC,GAAG,SAAS;AAAA;AAAA,EACjF;AACJ;",
|
|
6
|
+
"names": ["cva", "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"]
|
|
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/styles.css
CHANGED
|
@@ -105,7 +105,6 @@
|
|
|
105
105
|
@layer theme, base, components, utilities;
|
|
106
106
|
@layer theme {
|
|
107
107
|
:root, :host {
|
|
108
|
-
--spacing: 0.25rem;
|
|
109
108
|
--font-weight-medium: 500;
|
|
110
109
|
}
|
|
111
110
|
}
|
|
@@ -127,12 +126,8 @@
|
|
|
127
126
|
.gridui-u-choice--inline-flex {
|
|
128
127
|
display: inline-flex;
|
|
129
128
|
}
|
|
130
|
-
.gridui-u-choice--
|
|
131
|
-
|
|
132
|
-
height: calc(var(--spacing) * 5);
|
|
133
|
-
}
|
|
134
|
-
.gridui-u-choice--min-h-gridui-control {
|
|
135
|
-
min-height: var(--gridui-control-min-height);
|
|
129
|
+
.gridui-u-choice--min-h-\(--gridui-choice-target\) {
|
|
130
|
+
min-height: var(--gridui-choice-target);
|
|
136
131
|
}
|
|
137
132
|
.gridui-u-choice--w-fit {
|
|
138
133
|
width: fit-content;
|
|
@@ -143,12 +138,12 @@
|
|
|
143
138
|
.gridui-u-choice--max-w-full {
|
|
144
139
|
max-width: 100%;
|
|
145
140
|
}
|
|
141
|
+
.gridui-u-choice--min-w-\(--gridui-choice-target\) {
|
|
142
|
+
min-width: var(--gridui-choice-target);
|
|
143
|
+
}
|
|
146
144
|
.gridui-u-choice--min-w-0 {
|
|
147
145
|
min-width: 0px;
|
|
148
146
|
}
|
|
149
|
-
.gridui-u-choice--min-w-gridui-control {
|
|
150
|
-
min-width: var(--gridui-control-min-height);
|
|
151
|
-
}
|
|
152
147
|
.gridui-u-choice--shrink-0 {
|
|
153
148
|
flex-shrink: 0;
|
|
154
149
|
}
|
|
@@ -205,9 +200,6 @@
|
|
|
205
200
|
.gridui-u-choice--border-border {
|
|
206
201
|
border-color: var(--gridui-border);
|
|
207
202
|
}
|
|
208
|
-
.gridui-u-choice--border-control-border {
|
|
209
|
-
border-color: var(--gridui-control-border);
|
|
210
|
-
}
|
|
211
203
|
.gridui-u-choice--border-transparent {
|
|
212
204
|
border-color: transparent;
|
|
213
205
|
}
|
|
@@ -223,17 +215,11 @@
|
|
|
223
215
|
.gridui-u-choice--p-0 {
|
|
224
216
|
padding: 0px;
|
|
225
217
|
}
|
|
226
|
-
.gridui-u-choice--px
|
|
227
|
-
padding-inline: var(--gridui-
|
|
218
|
+
.gridui-u-choice--px-\(--gridui-choice-inline\) {
|
|
219
|
+
padding-inline: var(--gridui-choice-inline);
|
|
228
220
|
}
|
|
229
|
-
.gridui-u-choice--
|
|
230
|
-
padding-
|
|
231
|
-
}
|
|
232
|
-
.gridui-u-choice--py-gridui-8 {
|
|
233
|
-
padding-block: var(--gridui-space-8);
|
|
234
|
-
}
|
|
235
|
-
.gridui-u-choice--py-gridui-16 {
|
|
236
|
-
padding-block: var(--gridui-space-16);
|
|
221
|
+
.gridui-u-choice--py-\(--gridui-choice-block\) {
|
|
222
|
+
padding-block: var(--gridui-choice-block);
|
|
237
223
|
}
|
|
238
224
|
.gridui-u-choice--text-center {
|
|
239
225
|
text-align: center;
|
|
@@ -265,8 +251,38 @@
|
|
|
265
251
|
.gridui-u-choice--text-foreground {
|
|
266
252
|
color: var(--gridui-foreground);
|
|
267
253
|
}
|
|
268
|
-
.gridui-u-choice--
|
|
269
|
-
|
|
254
|
+
.gridui-u-choice--\[--gridui-choice-block\:var\(--gridui-space-4\)\] {
|
|
255
|
+
--gridui-choice-block: var(--gridui-space-4);
|
|
256
|
+
}
|
|
257
|
+
.gridui-u-choice--\[--gridui-choice-block\:var\(--gridui-space-8\)\] {
|
|
258
|
+
--gridui-choice-block: var(--gridui-space-8);
|
|
259
|
+
}
|
|
260
|
+
.gridui-u-choice--\[--gridui-choice-inline\:var\(--gridui-space-8\)\] {
|
|
261
|
+
--gridui-choice-inline: var(--gridui-space-8);
|
|
262
|
+
}
|
|
263
|
+
.gridui-u-choice--\[--gridui-choice-inline\:var\(--gridui-space-16\)\] {
|
|
264
|
+
--gridui-choice-inline: var(--gridui-space-16);
|
|
265
|
+
}
|
|
266
|
+
.gridui-u-choice--\[--gridui-choice-inline\:var\(--gridui-space-24\)\] {
|
|
267
|
+
--gridui-choice-inline: var(--gridui-space-24);
|
|
268
|
+
}
|
|
269
|
+
.gridui-u-choice--\[--gridui-choice-mark\:1\.5rem\] {
|
|
270
|
+
--gridui-choice-mark: 1.5rem;
|
|
271
|
+
}
|
|
272
|
+
.gridui-u-choice--\[--gridui-choice-mark\:1\.25rem\] {
|
|
273
|
+
--gridui-choice-mark: 1.25rem;
|
|
274
|
+
}
|
|
275
|
+
.gridui-u-choice--\[--gridui-choice-mark\:1rem\] {
|
|
276
|
+
--gridui-choice-mark: 1rem;
|
|
277
|
+
}
|
|
278
|
+
.gridui-u-choice--\[--gridui-choice-target\:max\(var\(--gridui-control-min-height-large\)\,var\(--gridui-target-min-size\)\)\] {
|
|
279
|
+
--gridui-choice-target: max(var(--gridui-control-min-height-large), var(--gridui-target-min-size));
|
|
280
|
+
}
|
|
281
|
+
.gridui-u-choice--\[--gridui-choice-target\:max\(var\(--gridui-control-min-height-medium\)\,var\(--gridui-target-min-size\)\)\] {
|
|
282
|
+
--gridui-choice-target: max(var(--gridui-control-min-height-medium), var(--gridui-target-min-size));
|
|
283
|
+
}
|
|
284
|
+
.gridui-u-choice--\[--gridui-choice-target\:max\(var\(--gridui-control-min-height-small\)\,var\(--gridui-target-min-size\)\)\] {
|
|
285
|
+
--gridui-choice-target: max(var(--gridui-control-min-height-small), var(--gridui-target-min-size));
|
|
270
286
|
}
|
|
271
287
|
.gridui-u-choice--data-disabled\:cursor-not-allowed[data-disabled] {
|
|
272
288
|
cursor: not-allowed;
|
|
@@ -301,18 +317,6 @@
|
|
|
301
317
|
border-bottom-style: var(--tw-border-style);
|
|
302
318
|
border-bottom-width: 0px;
|
|
303
319
|
}
|
|
304
|
-
.gridui-u-choice--data-\[state\=checked\]\:bg-accent-background[data-state="checked"] {
|
|
305
|
-
background-color: var(--gridui-accent-background);
|
|
306
|
-
}
|
|
307
|
-
.gridui-u-choice--data-\[state\=checked\]\:text-accent-foreground[data-state="checked"] {
|
|
308
|
-
color: var(--gridui-accent-foreground);
|
|
309
|
-
}
|
|
310
|
-
.gridui-u-choice--data-\[state\=indeterminate\]\:bg-accent-background[data-state="indeterminate"] {
|
|
311
|
-
background-color: var(--gridui-accent-background);
|
|
312
|
-
}
|
|
313
|
-
.gridui-u-choice--data-\[state\=indeterminate\]\:text-accent-foreground[data-state="indeterminate"] {
|
|
314
|
-
color: var(--gridui-accent-foreground);
|
|
315
|
-
}
|
|
316
320
|
.gridui-u-choice--data-\[state\=on\]\:bg-selection-background[data-state="on"] {
|
|
317
321
|
background-color: var(--gridui-selection-background);
|
|
318
322
|
}
|
|
@@ -362,12 +366,12 @@
|
|
|
362
366
|
cursor: default;
|
|
363
367
|
}
|
|
364
368
|
.gridui-switch-indicator {
|
|
365
|
-
--_gridui-switch-thumb-size:
|
|
369
|
+
--_gridui-switch-thumb-size: calc(var(--gridui-choice-mark) * 0.9);
|
|
366
370
|
display: inline-flex;
|
|
367
371
|
flex-shrink: 0;
|
|
368
372
|
align-items: center;
|
|
369
|
-
width:
|
|
370
|
-
height: 1.
|
|
373
|
+
width: calc(var(--gridui-choice-mark) * 2.4);
|
|
374
|
+
height: calc(var(--gridui-choice-mark) * 1.3);
|
|
371
375
|
padding: var(--gridui-space-2);
|
|
372
376
|
border: 1px solid var(--gridui-control-border);
|
|
373
377
|
border-radius: var(--gridui-control-radius);
|
|
@@ -400,7 +404,7 @@
|
|
|
400
404
|
min-width: min(4.5rem, 100%);
|
|
401
405
|
max-width: 100%;
|
|
402
406
|
height: auto;
|
|
403
|
-
min-height:
|
|
407
|
+
min-height: calc(var(--gridui-choice-mark) * 1.6);
|
|
404
408
|
padding: var(--gridui-space-4) var(--gridui-space-8);
|
|
405
409
|
}
|
|
406
410
|
.gridui-switch-indicator[data-variant="state"][data-state="checked"] {
|
|
@@ -427,7 +431,7 @@
|
|
|
427
431
|
gap: var(--gridui-space-16);
|
|
428
432
|
width: 100%;
|
|
429
433
|
min-width: 0;
|
|
430
|
-
min-height: var(--gridui-
|
|
434
|
+
min-height: var(--gridui-choice-target);
|
|
431
435
|
padding: var(--gridui-space-12) var(--gridui-space-16);
|
|
432
436
|
border: 0;
|
|
433
437
|
background: var(--gridui-background);
|
|
@@ -481,11 +485,11 @@
|
|
|
481
485
|
border-block-start: 1px solid var(--gridui-border);
|
|
482
486
|
}
|
|
483
487
|
.gridui-switch-group[data-density="compact"] > .gridui-switch-setting {
|
|
484
|
-
min-height:
|
|
488
|
+
min-height: var(--gridui-choice-target);
|
|
485
489
|
padding-block: var(--gridui-space-8);
|
|
486
490
|
}
|
|
487
491
|
.gridui-switch-group[data-density="comfortable"] > .gridui-switch-setting {
|
|
488
|
-
min-height:
|
|
492
|
+
min-height: var(--gridui-choice-target);
|
|
489
493
|
padding-block: var(--gridui-space-16);
|
|
490
494
|
}
|
|
491
495
|
.gridui-switch-panel {
|
|
@@ -539,6 +543,35 @@
|
|
|
539
543
|
padding: var(--gridui-space-16);
|
|
540
544
|
border-block-start: 1px solid var(--gridui-border);
|
|
541
545
|
}
|
|
546
|
+
.gridui-checkbox {
|
|
547
|
+
min-inline-size: var(--gridui-choice-target);
|
|
548
|
+
min-block-size: var(--gridui-choice-target);
|
|
549
|
+
}
|
|
550
|
+
.gridui-checkbox-mark {
|
|
551
|
+
display: inline-flex;
|
|
552
|
+
align-items: center;
|
|
553
|
+
justify-content: center;
|
|
554
|
+
inline-size: var(--gridui-choice-mark);
|
|
555
|
+
block-size: var(--gridui-choice-mark);
|
|
556
|
+
border: 1px solid var(--gridui-control-border);
|
|
557
|
+
background: var(--gridui-background);
|
|
558
|
+
border-radius: var(--gridui-control-radius);
|
|
559
|
+
}
|
|
560
|
+
.gridui-checkbox:is([data-state="checked"], [data-state="indeterminate"]) .gridui-checkbox-mark {
|
|
561
|
+
background: var(--gridui-accent-background);
|
|
562
|
+
color: var(--gridui-accent-foreground);
|
|
563
|
+
}
|
|
564
|
+
.gridui-checkbox[aria-invalid="true"] .gridui-checkbox-mark {
|
|
565
|
+
border-color: var(--gridui-status-danger-border);
|
|
566
|
+
}
|
|
567
|
+
.gridui-checkbox-mark svg {
|
|
568
|
+
inline-size: calc(var(--gridui-choice-mark) - 0.25rem);
|
|
569
|
+
block-size: calc(var(--gridui-choice-mark) - 0.25rem);
|
|
570
|
+
}
|
|
571
|
+
.gridui-checkbox-mark svg > path {
|
|
572
|
+
stroke-width: 1.5px;
|
|
573
|
+
vector-effect: non-scaling-stroke;
|
|
574
|
+
}
|
|
542
575
|
}
|
|
543
576
|
@property --tw-border-style {
|
|
544
577
|
syntax: "*";
|
package/dist/styles.local.css
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
@layer theme, base, components, utilities;
|
|
4
4
|
@layer theme {
|
|
5
5
|
:root, :host {
|
|
6
|
-
--spacing: 0.25rem;
|
|
7
6
|
--font-weight-medium: 500;
|
|
8
7
|
}
|
|
9
8
|
}
|
|
@@ -25,12 +24,8 @@
|
|
|
25
24
|
.gridui-u-choice--inline-flex {
|
|
26
25
|
display: inline-flex;
|
|
27
26
|
}
|
|
28
|
-
.gridui-u-choice--
|
|
29
|
-
|
|
30
|
-
height: calc(var(--spacing) * 5);
|
|
31
|
-
}
|
|
32
|
-
.gridui-u-choice--min-h-gridui-control {
|
|
33
|
-
min-height: var(--gridui-control-min-height);
|
|
27
|
+
.gridui-u-choice--min-h-\(--gridui-choice-target\) {
|
|
28
|
+
min-height: var(--gridui-choice-target);
|
|
34
29
|
}
|
|
35
30
|
.gridui-u-choice--w-fit {
|
|
36
31
|
width: fit-content;
|
|
@@ -41,12 +36,12 @@
|
|
|
41
36
|
.gridui-u-choice--max-w-full {
|
|
42
37
|
max-width: 100%;
|
|
43
38
|
}
|
|
39
|
+
.gridui-u-choice--min-w-\(--gridui-choice-target\) {
|
|
40
|
+
min-width: var(--gridui-choice-target);
|
|
41
|
+
}
|
|
44
42
|
.gridui-u-choice--min-w-0 {
|
|
45
43
|
min-width: 0px;
|
|
46
44
|
}
|
|
47
|
-
.gridui-u-choice--min-w-gridui-control {
|
|
48
|
-
min-width: var(--gridui-control-min-height);
|
|
49
|
-
}
|
|
50
45
|
.gridui-u-choice--shrink-0 {
|
|
51
46
|
flex-shrink: 0;
|
|
52
47
|
}
|
|
@@ -103,9 +98,6 @@
|
|
|
103
98
|
.gridui-u-choice--border-border {
|
|
104
99
|
border-color: var(--gridui-border);
|
|
105
100
|
}
|
|
106
|
-
.gridui-u-choice--border-control-border {
|
|
107
|
-
border-color: var(--gridui-control-border);
|
|
108
|
-
}
|
|
109
101
|
.gridui-u-choice--border-transparent {
|
|
110
102
|
border-color: transparent;
|
|
111
103
|
}
|
|
@@ -121,17 +113,11 @@
|
|
|
121
113
|
.gridui-u-choice--p-0 {
|
|
122
114
|
padding: 0px;
|
|
123
115
|
}
|
|
124
|
-
.gridui-u-choice--px
|
|
125
|
-
padding-inline: var(--gridui-
|
|
116
|
+
.gridui-u-choice--px-\(--gridui-choice-inline\) {
|
|
117
|
+
padding-inline: var(--gridui-choice-inline);
|
|
126
118
|
}
|
|
127
|
-
.gridui-u-choice--
|
|
128
|
-
padding-
|
|
129
|
-
}
|
|
130
|
-
.gridui-u-choice--py-gridui-8 {
|
|
131
|
-
padding-block: var(--gridui-space-8);
|
|
132
|
-
}
|
|
133
|
-
.gridui-u-choice--py-gridui-16 {
|
|
134
|
-
padding-block: var(--gridui-space-16);
|
|
119
|
+
.gridui-u-choice--py-\(--gridui-choice-block\) {
|
|
120
|
+
padding-block: var(--gridui-choice-block);
|
|
135
121
|
}
|
|
136
122
|
.gridui-u-choice--text-center {
|
|
137
123
|
text-align: center;
|
|
@@ -163,8 +149,38 @@
|
|
|
163
149
|
.gridui-u-choice--text-foreground {
|
|
164
150
|
color: var(--gridui-foreground);
|
|
165
151
|
}
|
|
166
|
-
.gridui-u-choice--
|
|
167
|
-
|
|
152
|
+
.gridui-u-choice--\[--gridui-choice-block\:var\(--gridui-space-4\)\] {
|
|
153
|
+
--gridui-choice-block: var(--gridui-space-4);
|
|
154
|
+
}
|
|
155
|
+
.gridui-u-choice--\[--gridui-choice-block\:var\(--gridui-space-8\)\] {
|
|
156
|
+
--gridui-choice-block: var(--gridui-space-8);
|
|
157
|
+
}
|
|
158
|
+
.gridui-u-choice--\[--gridui-choice-inline\:var\(--gridui-space-8\)\] {
|
|
159
|
+
--gridui-choice-inline: var(--gridui-space-8);
|
|
160
|
+
}
|
|
161
|
+
.gridui-u-choice--\[--gridui-choice-inline\:var\(--gridui-space-16\)\] {
|
|
162
|
+
--gridui-choice-inline: var(--gridui-space-16);
|
|
163
|
+
}
|
|
164
|
+
.gridui-u-choice--\[--gridui-choice-inline\:var\(--gridui-space-24\)\] {
|
|
165
|
+
--gridui-choice-inline: var(--gridui-space-24);
|
|
166
|
+
}
|
|
167
|
+
.gridui-u-choice--\[--gridui-choice-mark\:1\.5rem\] {
|
|
168
|
+
--gridui-choice-mark: 1.5rem;
|
|
169
|
+
}
|
|
170
|
+
.gridui-u-choice--\[--gridui-choice-mark\:1\.25rem\] {
|
|
171
|
+
--gridui-choice-mark: 1.25rem;
|
|
172
|
+
}
|
|
173
|
+
.gridui-u-choice--\[--gridui-choice-mark\:1rem\] {
|
|
174
|
+
--gridui-choice-mark: 1rem;
|
|
175
|
+
}
|
|
176
|
+
.gridui-u-choice--\[--gridui-choice-target\:max\(var\(--gridui-control-min-height-large\)\,var\(--gridui-target-min-size\)\)\] {
|
|
177
|
+
--gridui-choice-target: max(var(--gridui-control-min-height-large), var(--gridui-target-min-size));
|
|
178
|
+
}
|
|
179
|
+
.gridui-u-choice--\[--gridui-choice-target\:max\(var\(--gridui-control-min-height-medium\)\,var\(--gridui-target-min-size\)\)\] {
|
|
180
|
+
--gridui-choice-target: max(var(--gridui-control-min-height-medium), var(--gridui-target-min-size));
|
|
181
|
+
}
|
|
182
|
+
.gridui-u-choice--\[--gridui-choice-target\:max\(var\(--gridui-control-min-height-small\)\,var\(--gridui-target-min-size\)\)\] {
|
|
183
|
+
--gridui-choice-target: max(var(--gridui-control-min-height-small), var(--gridui-target-min-size));
|
|
168
184
|
}
|
|
169
185
|
.gridui-u-choice--data-disabled\:cursor-not-allowed[data-disabled] {
|
|
170
186
|
cursor: not-allowed;
|
|
@@ -199,18 +215,6 @@
|
|
|
199
215
|
border-bottom-style: var(--tw-border-style);
|
|
200
216
|
border-bottom-width: 0px;
|
|
201
217
|
}
|
|
202
|
-
.gridui-u-choice--data-\[state\=checked\]\:bg-accent-background[data-state="checked"] {
|
|
203
|
-
background-color: var(--gridui-accent-background);
|
|
204
|
-
}
|
|
205
|
-
.gridui-u-choice--data-\[state\=checked\]\:text-accent-foreground[data-state="checked"] {
|
|
206
|
-
color: var(--gridui-accent-foreground);
|
|
207
|
-
}
|
|
208
|
-
.gridui-u-choice--data-\[state\=indeterminate\]\:bg-accent-background[data-state="indeterminate"] {
|
|
209
|
-
background-color: var(--gridui-accent-background);
|
|
210
|
-
}
|
|
211
|
-
.gridui-u-choice--data-\[state\=indeterminate\]\:text-accent-foreground[data-state="indeterminate"] {
|
|
212
|
-
color: var(--gridui-accent-foreground);
|
|
213
|
-
}
|
|
214
218
|
.gridui-u-choice--data-\[state\=on\]\:bg-selection-background[data-state="on"] {
|
|
215
219
|
background-color: var(--gridui-selection-background);
|
|
216
220
|
}
|
|
@@ -260,12 +264,12 @@
|
|
|
260
264
|
cursor: default;
|
|
261
265
|
}
|
|
262
266
|
.gridui-switch-indicator {
|
|
263
|
-
--_gridui-switch-thumb-size:
|
|
267
|
+
--_gridui-switch-thumb-size: calc(var(--gridui-choice-mark) * 0.9);
|
|
264
268
|
display: inline-flex;
|
|
265
269
|
flex-shrink: 0;
|
|
266
270
|
align-items: center;
|
|
267
|
-
width:
|
|
268
|
-
height: 1.
|
|
271
|
+
width: calc(var(--gridui-choice-mark) * 2.4);
|
|
272
|
+
height: calc(var(--gridui-choice-mark) * 1.3);
|
|
269
273
|
padding: var(--gridui-space-2);
|
|
270
274
|
border: 1px solid var(--gridui-control-border);
|
|
271
275
|
border-radius: var(--gridui-control-radius);
|
|
@@ -298,7 +302,7 @@
|
|
|
298
302
|
min-width: min(4.5rem, 100%);
|
|
299
303
|
max-width: 100%;
|
|
300
304
|
height: auto;
|
|
301
|
-
min-height:
|
|
305
|
+
min-height: calc(var(--gridui-choice-mark) * 1.6);
|
|
302
306
|
padding: var(--gridui-space-4) var(--gridui-space-8);
|
|
303
307
|
}
|
|
304
308
|
.gridui-switch-indicator[data-variant="state"][data-state="checked"] {
|
|
@@ -325,7 +329,7 @@
|
|
|
325
329
|
gap: var(--gridui-space-16);
|
|
326
330
|
width: 100%;
|
|
327
331
|
min-width: 0;
|
|
328
|
-
min-height: var(--gridui-
|
|
332
|
+
min-height: var(--gridui-choice-target);
|
|
329
333
|
padding: var(--gridui-space-12) var(--gridui-space-16);
|
|
330
334
|
border: 0;
|
|
331
335
|
background: var(--gridui-background);
|
|
@@ -379,11 +383,11 @@
|
|
|
379
383
|
border-block-start: 1px solid var(--gridui-border);
|
|
380
384
|
}
|
|
381
385
|
.gridui-switch-group[data-density="compact"] > .gridui-switch-setting {
|
|
382
|
-
min-height:
|
|
386
|
+
min-height: var(--gridui-choice-target);
|
|
383
387
|
padding-block: var(--gridui-space-8);
|
|
384
388
|
}
|
|
385
389
|
.gridui-switch-group[data-density="comfortable"] > .gridui-switch-setting {
|
|
386
|
-
min-height:
|
|
390
|
+
min-height: var(--gridui-choice-target);
|
|
387
391
|
padding-block: var(--gridui-space-16);
|
|
388
392
|
}
|
|
389
393
|
.gridui-switch-panel {
|
|
@@ -437,6 +441,35 @@
|
|
|
437
441
|
padding: var(--gridui-space-16);
|
|
438
442
|
border-block-start: 1px solid var(--gridui-border);
|
|
439
443
|
}
|
|
444
|
+
.gridui-checkbox {
|
|
445
|
+
min-inline-size: var(--gridui-choice-target);
|
|
446
|
+
min-block-size: var(--gridui-choice-target);
|
|
447
|
+
}
|
|
448
|
+
.gridui-checkbox-mark {
|
|
449
|
+
display: inline-flex;
|
|
450
|
+
align-items: center;
|
|
451
|
+
justify-content: center;
|
|
452
|
+
inline-size: var(--gridui-choice-mark);
|
|
453
|
+
block-size: var(--gridui-choice-mark);
|
|
454
|
+
border: 1px solid var(--gridui-control-border);
|
|
455
|
+
background: var(--gridui-background);
|
|
456
|
+
border-radius: var(--gridui-control-radius);
|
|
457
|
+
}
|
|
458
|
+
.gridui-checkbox:is([data-state="checked"], [data-state="indeterminate"]) .gridui-checkbox-mark {
|
|
459
|
+
background: var(--gridui-accent-background);
|
|
460
|
+
color: var(--gridui-accent-foreground);
|
|
461
|
+
}
|
|
462
|
+
.gridui-checkbox[aria-invalid="true"] .gridui-checkbox-mark {
|
|
463
|
+
border-color: var(--gridui-status-danger-border);
|
|
464
|
+
}
|
|
465
|
+
.gridui-checkbox-mark svg {
|
|
466
|
+
inline-size: calc(var(--gridui-choice-mark) - 0.25rem);
|
|
467
|
+
block-size: calc(var(--gridui-choice-mark) - 0.25rem);
|
|
468
|
+
}
|
|
469
|
+
.gridui-checkbox-mark svg > path {
|
|
470
|
+
stroke-width: 1.5px;
|
|
471
|
+
vector-effect: non-scaling-stroke;
|
|
472
|
+
}
|
|
440
473
|
}
|
|
441
474
|
@property --tw-border-style {
|
|
442
475
|
syntax: "*";
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @namespace SwitchGroup
|
|
5
5
|
* @description Switch Group
|
|
6
6
|
*/
|
|
7
|
+
import type { Size, Density } from "@gridui/theme";
|
|
7
8
|
import type { SwitchOptions, SwitchPresentationProps, SwitchSettingCopy } from "../shared/switch-options";
|
|
8
9
|
import type { ComponentPropsWithRef, FC, ReactNode } from "react";
|
|
9
10
|
export type SwitchGroupItem = SwitchOptions & SwitchSettingCopy & {
|
|
@@ -13,6 +14,7 @@ export type SwitchGroupItem = SwitchOptions & SwitchSettingCopy & {
|
|
|
13
14
|
export type SwitchGroupProps = Omit<ComponentPropsWithRef<"fieldset">, "children"> & SwitchPresentationProps & {
|
|
14
15
|
readonly items: readonly SwitchGroupItem[];
|
|
15
16
|
readonly legend?: ReactNode;
|
|
16
|
-
readonly density?:
|
|
17
|
+
readonly density?: Density;
|
|
18
|
+
readonly size?: Size;
|
|
17
19
|
};
|
|
18
20
|
export declare const SwitchGroup: FC<SwitchGroupProps>;
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* @namespace SwitchPanel
|
|
5
5
|
* @description Switch Panel
|
|
6
6
|
*/
|
|
7
|
+
import type { Size } from "@gridui/theme";
|
|
7
8
|
import type { SwitchSettingOptions } from "../shared/switch-options";
|
|
8
9
|
import { type ComponentPropsWithRef, type FC } from "react";
|
|
9
|
-
export type SwitchPanelProps = ComponentPropsWithRef<"div"> & SwitchSettingOptions
|
|
10
|
+
export type SwitchPanelProps = ComponentPropsWithRef<"div"> & SwitchSettingOptions & {
|
|
11
|
+
readonly size?: Size;
|
|
12
|
+
};
|
|
10
13
|
export declare const SwitchPanel: FC<SwitchPanelProps>;
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* @namespace ToggleGroup
|
|
5
5
|
* @description Toggle Group
|
|
6
6
|
*/
|
|
7
|
+
import type { Size } from "@gridui/theme";
|
|
7
8
|
import * as Primitive from "@radix-ui/react-toggle-group";
|
|
8
9
|
import { type ComponentPropsWithRef, type FC } from "react";
|
|
9
10
|
export type ToggleGroupProps = Omit<ComponentPropsWithRef<typeof Primitive.Root>, "type" | "value" | "defaultValue" | "onValueChange" | "loop"> & {
|
|
11
|
+
readonly size?: Size;
|
|
10
12
|
readonly multiple?: boolean | undefined;
|
|
11
13
|
readonly value?: string[] | undefined;
|
|
12
14
|
readonly defaultValue?: string[] | undefined;
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* @namespace ToggleGroupItem
|
|
5
5
|
* @description Toggle Group Item
|
|
6
6
|
*/
|
|
7
|
+
import type { Size } from "@gridui/theme";
|
|
7
8
|
import * as Primitive from "@radix-ui/react-toggle-group";
|
|
8
9
|
import { type ComponentPropsWithRef, type FC } from "react";
|
|
9
|
-
export type ToggleGroupItemProps = ComponentPropsWithRef<typeof Primitive.Item
|
|
10
|
+
export type ToggleGroupItemProps = ComponentPropsWithRef<typeof Primitive.Item> & {
|
|
11
|
+
readonly size?: Size;
|
|
12
|
+
};
|
|
10
13
|
export declare const ToggleGroupItem: FC<ToggleGroupItemProps>;
|
package/docs/catalog.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "@gridui/choice",
|
|
4
|
-
"version": "
|
|
5
|
-
"category": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"category": "controls",
|
|
6
6
|
"description": "GridUI React choice",
|
|
7
|
-
"usage": "
|
|
7
|
+
"usage": "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.",
|
|
8
8
|
"documentation": [
|
|
9
9
|
"README.md",
|
|
10
10
|
"docs/reference/README.md",
|
|
@@ -101,15 +101,15 @@
|
|
|
101
101
|
],
|
|
102
102
|
"styledImport": "@gridui/choice/styled",
|
|
103
103
|
"examples": [
|
|
104
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
105
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
106
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
107
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
108
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
109
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
110
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
111
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
112
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
113
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
104
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/boolean-settings.mdx",
|
|
105
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/checkboxes.mdx",
|
|
106
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/getting-started.mdx",
|
|
107
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/settings-panels.mdx",
|
|
108
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/toggle-selections.mdx",
|
|
109
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/checkbox.stories.tsx",
|
|
110
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/switch-control.stories.tsx",
|
|
111
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/switch-group.stories.tsx",
|
|
112
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/switch-panel.stories.tsx",
|
|
113
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/toggle-group.stories.tsx"
|
|
114
114
|
]
|
|
115
115
|
}
|
|
@@ -11,9 +11,9 @@ import "@gridui/theme/styles.css";
|
|
|
11
11
|
import "@gridui/choice/styles.css";
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/README.md) for shared behavior and stylesheet dependencies.
|
|
15
15
|
|
|
16
|
-
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/checkbox.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
17
|
|
|
18
18
|
## API
|
|
19
19
|
|
|
@@ -51,6 +51,14 @@ Default: ``"on"``
|
|
|
51
51
|
|
|
52
52
|
Controlled value. Pair with the corresponding change callback.
|
|
53
53
|
|
|
54
|
+
### size
|
|
55
|
+
|
|
56
|
+
``Size | undefined`` · Optional
|
|
57
|
+
|
|
58
|
+
Default: ``"medium"``
|
|
59
|
+
|
|
60
|
+
Component size preset.
|
|
61
|
+
|
|
54
62
|
### checked
|
|
55
63
|
|
|
56
64
|
``boolean | undefined`` · Optional
|
|
@@ -11,9 +11,9 @@ import "@gridui/theme/styles.css";
|
|
|
11
11
|
import "@gridui/choice/styles.css";
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/README.md) for shared behavior and stylesheet dependencies.
|
|
15
15
|
|
|
16
|
-
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/switch-group.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
17
|
|
|
18
18
|
## API
|
|
19
19
|
|
|
@@ -71,7 +71,15 @@ Visible state words; the accessible name must describe the setting.
|
|
|
71
71
|
|
|
72
72
|
### density
|
|
73
73
|
|
|
74
|
-
``
|
|
74
|
+
``Density | undefined`` · Optional
|
|
75
75
|
|
|
76
|
-
Default: ``"
|
|
76
|
+
Default: ``"comfortable"``
|
|
77
|
+
|
|
78
|
+
### size
|
|
79
|
+
|
|
80
|
+
``Size | undefined`` · Optional
|
|
81
|
+
|
|
82
|
+
Default: ``"medium"``
|
|
83
|
+
|
|
84
|
+
Component size preset.
|
|
77
85
|
|
|
@@ -11,9 +11,9 @@ import "@gridui/theme/styles.css";
|
|
|
11
11
|
import "@gridui/choice/styles.css";
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/README.md) for shared behavior and stylesheet dependencies.
|
|
15
15
|
|
|
16
|
-
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/switch-panel.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
17
|
|
|
18
18
|
## API
|
|
19
19
|
|
|
@@ -69,3 +69,11 @@ Called when the corresponding interaction occurs; inspect the arguments in Actio
|
|
|
69
69
|
|
|
70
70
|
State, form attributes, accessible overrides and ref for the switch button.
|
|
71
71
|
|
|
72
|
+
### size
|
|
73
|
+
|
|
74
|
+
``Size | undefined`` · Optional
|
|
75
|
+
|
|
76
|
+
Default: ``"medium"``
|
|
77
|
+
|
|
78
|
+
Component size preset.
|
|
79
|
+
|
package/docs/reference/switch.md
CHANGED
|
@@ -11,9 +11,9 @@ import "@gridui/theme/styles.css";
|
|
|
11
11
|
import "@gridui/choice/styles.css";
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/README.md) for shared behavior and stylesheet dependencies.
|
|
15
15
|
|
|
16
|
-
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/switch-control.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
17
|
|
|
18
18
|
## API
|
|
19
19
|
|
|
@@ -43,6 +43,12 @@ Called when the corresponding interaction occurs; inspect the arguments in Actio
|
|
|
43
43
|
|
|
44
44
|
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
45
|
|
|
46
|
+
### size
|
|
47
|
+
|
|
48
|
+
``Size | undefined`` · Optional
|
|
49
|
+
|
|
50
|
+
Component size preset.
|
|
51
|
+
|
|
46
52
|
### checked
|
|
47
53
|
|
|
48
54
|
``boolean | undefined`` · Optional
|
|
@@ -11,9 +11,9 @@ import "@gridui/theme/styles.css";
|
|
|
11
11
|
import "@gridui/choice/styles.css";
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/README.md) for shared behavior and stylesheet dependencies.
|
|
15
15
|
|
|
16
|
-
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/toggle-group.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
17
|
|
|
18
18
|
## API
|
|
19
19
|
|
|
@@ -65,3 +65,11 @@ Called when the corresponding interaction occurs; inspect the arguments in Actio
|
|
|
65
65
|
|
|
66
66
|
A string value for the toggle group item. All items within a toggle group should use a unique value.
|
|
67
67
|
|
|
68
|
+
### size
|
|
69
|
+
|
|
70
|
+
``Size | undefined`` · Optional
|
|
71
|
+
|
|
72
|
+
Default: ``group.size``
|
|
73
|
+
|
|
74
|
+
Component size preset.
|
|
75
|
+
|
|
@@ -11,9 +11,9 @@ import "@gridui/theme/styles.css";
|
|
|
11
11
|
import "@gridui/choice/styles.css";
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/README.md) for shared behavior and stylesheet dependencies.
|
|
15
15
|
|
|
16
|
-
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/choice/stories/toggle-group.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
17
|
|
|
18
18
|
## API
|
|
19
19
|
|
|
@@ -79,6 +79,14 @@ Whether the group is disabled from user interaction.
|
|
|
79
79
|
|
|
80
80
|
Whether the group should maintain roving focus of its buttons.
|
|
81
81
|
|
|
82
|
+
### size
|
|
83
|
+
|
|
84
|
+
``Size | undefined`` · Optional
|
|
85
|
+
|
|
86
|
+
Default: ``"medium"``
|
|
87
|
+
|
|
88
|
+
Component size preset.
|
|
89
|
+
|
|
82
90
|
### multiple
|
|
83
91
|
|
|
84
92
|
``boolean | undefined`` · Optional
|
package/docs/switches.md
CHANGED
|
@@ -47,7 +47,7 @@ The entire row is one switch button. Labels and descriptions must contain
|
|
|
47
47
|
non-interactive content. Each gets an ID for accessible naming/description;
|
|
48
48
|
explicit ARIA names are honored and external description IDs are retained.
|
|
49
49
|
Group `variant` and `stateLabels` supply defaults; an item may override either.
|
|
50
|
-
`density="
|
|
50
|
+
`density="comfortable"` is the default; `compact` reduces spacing without changing
|
|
51
51
|
state behavior. Items own their state and form names independently. As with
|
|
52
52
|
native fieldsets, the group's `form` attribute is not inherited by its controls;
|
|
53
53
|
set `form` on each item when associating controls with an external form.
|
package/docs/tabs-and-choices.md
CHANGED
|
@@ -65,7 +65,7 @@ mode. `multiple` enables independent pressed items. An empty array means none;
|
|
|
65
65
|
pressing the sole selected item can request an empty selection. A controlled
|
|
66
66
|
application filter can retain its current value when that request is empty.
|
|
67
67
|
Use `RadioGroup` from `@gridui/radio-group` for an exclusive, required form choice. See the
|
|
68
|
-
[radio family contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
68
|
+
[radio family contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/radio-group/README.md). `orientation`, `loopFocus`,
|
|
69
69
|
and `disabled` are forwarded. Items are buttons with `aria-pressed` and do not submit a surrounding
|
|
70
70
|
form. The group does not create hidden form inputs; consumers serialize values
|
|
71
71
|
explicitly. Supply an accessible group label and labels for icon-only items.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/choice",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "GridUI React choice",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
"react-dom": "^19.2.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@gridui/form": "^4.2.
|
|
35
|
+
"@gridui/form": "^4.2.1",
|
|
36
36
|
"@gridui/interaction": "^1.3.0",
|
|
37
|
-
"@gridui/motion": "^1.0.
|
|
38
|
-
"@gridui/style-utils": "^4.
|
|
39
|
-
"@gridui/theme": "^
|
|
37
|
+
"@gridui/motion": "^1.0.3",
|
|
38
|
+
"@gridui/style-utils": "^4.1.0",
|
|
39
|
+
"@gridui/theme": "^5.0.0",
|
|
40
40
|
"@radix-ui/react-checkbox": "1.4.1",
|
|
41
41
|
"@radix-ui/react-toggle-group": "1.2.1",
|
|
42
42
|
"class-variance-authority": "0.7.1",
|
|
43
|
-
"lucide-react": "1.
|
|
43
|
+
"lucide-react": "1.73.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@gridui-internal/configuration": "0.0.0-internal",
|
|
47
|
-
"@gridui/button": "
|
|
47
|
+
"@gridui/button": "6.0.0",
|
|
48
48
|
"@jest/globals": "30.5.2",
|
|
49
49
|
"@storybook/react-vite": "10.6.7",
|
|
50
50
|
"@types/jest": "30.0.0",
|