@gridui/choice 1.2.3 → 1.2.5
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 +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +2 -2
- package/dist/shared/switch-indicator.d.ts +1 -1
- package/dist/shared/switch-options.d.ts +27 -0
- package/dist/shared/switch-setting.d.ts +3 -7
- package/dist/styles.css +93 -65
- package/dist/switch/switch.d.ts +2 -3
- package/dist/switch-group/switch-group.d.ts +2 -5
- package/dist/switch-panel/switch-panel.d.ts +3 -8
- package/docs/catalog.json +12 -1
- package/docs/reference/README.md +9 -0
- package/docs/reference/checkbox.md +95 -0
- package/docs/reference/switch-group.md +77 -0
- package/docs/reference/switch-panel.md +71 -0
- package/docs/reference/switch.md +95 -0
- package/docs/reference/toggle-group-item.md +67 -0
- package/docs/reference/toggle-group.md +117 -0
- package/package.json +5 -5
- package/dist/shared/switch-presentation.d.ts +0 -16
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# Switch
|
|
3
|
+
|
|
4
|
+
Turns a setting on or off. Use it for a boolean preference with a clearly named enabled and disabled state.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/choice`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { Switch } from "@gridui/choice";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/choice/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/choice/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/choice/stories/switch-control.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### onFocus
|
|
23
|
+
|
|
24
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
25
|
+
|
|
26
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
27
|
+
|
|
28
|
+
### onBlur
|
|
29
|
+
|
|
30
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
31
|
+
|
|
32
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
33
|
+
|
|
34
|
+
### onSubmit
|
|
35
|
+
|
|
36
|
+
``(event: SubmitEvent<HTMLButtonElement>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onClick
|
|
41
|
+
|
|
42
|
+
``(event: MouseEvent<HTMLButtonElement, MouseEvent>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### checked
|
|
47
|
+
|
|
48
|
+
``boolean | undefined`` · Optional
|
|
49
|
+
|
|
50
|
+
Controlled checked state. Pair with onCheckedChange.
|
|
51
|
+
|
|
52
|
+
### defaultChecked
|
|
53
|
+
|
|
54
|
+
``boolean | undefined`` · Optional
|
|
55
|
+
|
|
56
|
+
Initial uncontrolled checked state. Reset the story after changing it.
|
|
57
|
+
|
|
58
|
+
### readOnly
|
|
59
|
+
|
|
60
|
+
``boolean | undefined`` · Optional
|
|
61
|
+
|
|
62
|
+
Allows reading without changing the value.
|
|
63
|
+
|
|
64
|
+
### required
|
|
65
|
+
|
|
66
|
+
``boolean | undefined`` · Optional
|
|
67
|
+
|
|
68
|
+
Participates in required form validation.
|
|
69
|
+
|
|
70
|
+
### uncheckedValue
|
|
71
|
+
|
|
72
|
+
``string | undefined`` · Optional
|
|
73
|
+
|
|
74
|
+
### inputRef
|
|
75
|
+
|
|
76
|
+
``Ref<HTMLInputElement> | undefined`` · Optional
|
|
77
|
+
|
|
78
|
+
### onCheckedChange
|
|
79
|
+
|
|
80
|
+
``(checked: boolean, details: ChangeDetails): void`` · Optional
|
|
81
|
+
|
|
82
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
83
|
+
|
|
84
|
+
### variant
|
|
85
|
+
|
|
86
|
+
``SwitchVariant | undefined`` · Optional
|
|
87
|
+
|
|
88
|
+
Visual variant.
|
|
89
|
+
|
|
90
|
+
### stateLabels
|
|
91
|
+
|
|
92
|
+
``SwitchStateLabels | undefined`` · Optional
|
|
93
|
+
|
|
94
|
+
Visible state words; the accessible name must describe the setting.
|
|
95
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# ToggleGroupItem
|
|
3
|
+
|
|
4
|
+
Compose ToggleGroupItem with ToggleGroup inside the same @gridui/choice component family.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/choice`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { ToggleGroupItem } from "@gridui/choice";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/choice/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/choice/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/choice/stories/toggle-group.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### children
|
|
23
|
+
|
|
24
|
+
``ReactNode`` · Optional
|
|
25
|
+
|
|
26
|
+
Content rendered inside the component.
|
|
27
|
+
|
|
28
|
+
### onFocus
|
|
29
|
+
|
|
30
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
31
|
+
|
|
32
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
33
|
+
|
|
34
|
+
### onBlur
|
|
35
|
+
|
|
36
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onChange
|
|
41
|
+
|
|
42
|
+
``(event: ChangeEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### onSubmit
|
|
47
|
+
|
|
48
|
+
``(event: SubmitEvent<HTMLButtonElement>): void`` · Optional
|
|
49
|
+
|
|
50
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
51
|
+
|
|
52
|
+
### onClick
|
|
53
|
+
|
|
54
|
+
``(event: MouseEvent<HTMLButtonElement, MouseEvent>): void`` · Optional
|
|
55
|
+
|
|
56
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
57
|
+
|
|
58
|
+
### asChild
|
|
59
|
+
|
|
60
|
+
``boolean | undefined`` · Optional
|
|
61
|
+
|
|
62
|
+
### value
|
|
63
|
+
|
|
64
|
+
``string`` · Required
|
|
65
|
+
|
|
66
|
+
A string value for the toggle group item. All items within a toggle group should use a unique value.
|
|
67
|
+
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# ToggleGroup
|
|
3
|
+
|
|
4
|
+
Groups selectable buttons for a shared choice or a set of independent choices. Use Tabs when selecting an item changes the visible content panel.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/choice`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { ToggleGroup } from "@gridui/choice";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/choice/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/choice/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/choice/stories/toggle-group.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### children
|
|
23
|
+
|
|
24
|
+
``ReactNode`` · Optional
|
|
25
|
+
|
|
26
|
+
Content rendered inside the component.
|
|
27
|
+
|
|
28
|
+
### dir
|
|
29
|
+
|
|
30
|
+
``("ltr" | "rtl") | undefined`` · Optional
|
|
31
|
+
|
|
32
|
+
### onFocus
|
|
33
|
+
|
|
34
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
35
|
+
|
|
36
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
37
|
+
|
|
38
|
+
### onBlur
|
|
39
|
+
|
|
40
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
41
|
+
|
|
42
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
43
|
+
|
|
44
|
+
### onChange
|
|
45
|
+
|
|
46
|
+
``(event: ChangeEvent<HTMLDivElement, Element>): void`` · Optional
|
|
47
|
+
|
|
48
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
49
|
+
|
|
50
|
+
### onSubmit
|
|
51
|
+
|
|
52
|
+
``(event: SubmitEvent<HTMLDivElement>): void`` · Optional
|
|
53
|
+
|
|
54
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
55
|
+
|
|
56
|
+
### onClick
|
|
57
|
+
|
|
58
|
+
``(event: MouseEvent<HTMLDivElement, MouseEvent>): void`` · Optional
|
|
59
|
+
|
|
60
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
61
|
+
|
|
62
|
+
### asChild
|
|
63
|
+
|
|
64
|
+
``boolean | undefined`` · Optional
|
|
65
|
+
|
|
66
|
+
### disabled
|
|
67
|
+
|
|
68
|
+
``boolean | undefined`` · Optional
|
|
69
|
+
|
|
70
|
+
Whether the group is disabled from user interaction.
|
|
71
|
+
|
|
72
|
+
### rovingFocus
|
|
73
|
+
|
|
74
|
+
``boolean | undefined`` · Optional
|
|
75
|
+
|
|
76
|
+
Whether the group should maintain roving focus of its buttons.
|
|
77
|
+
|
|
78
|
+
### orientation
|
|
79
|
+
|
|
80
|
+
``("vertical" | "horizontal") | undefined`` · Optional
|
|
81
|
+
|
|
82
|
+
### multiple
|
|
83
|
+
|
|
84
|
+
``boolean | undefined`` · Optional
|
|
85
|
+
|
|
86
|
+
### value
|
|
87
|
+
|
|
88
|
+
``string[] | undefined`` · Optional
|
|
89
|
+
|
|
90
|
+
Controlled value. Pair with the corresponding change callback.
|
|
91
|
+
|
|
92
|
+
### defaultValue
|
|
93
|
+
|
|
94
|
+
``string[] | undefined`` · Optional
|
|
95
|
+
|
|
96
|
+
Initial uncontrolled value. Reset the story after changing it.
|
|
97
|
+
|
|
98
|
+
### onValueChange
|
|
99
|
+
|
|
100
|
+
``(value: string[]): void`` · Optional
|
|
101
|
+
|
|
102
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
103
|
+
|
|
104
|
+
### loopFocus
|
|
105
|
+
|
|
106
|
+
``boolean | undefined`` · Optional
|
|
107
|
+
|
|
108
|
+
Default: ``true``
|
|
109
|
+
|
|
110
|
+
### layout
|
|
111
|
+
|
|
112
|
+
``"standard" | "cells" | undefined`` · Optional
|
|
113
|
+
|
|
114
|
+
Default: ``"standard"``
|
|
115
|
+
|
|
116
|
+
Layout within the containing region.
|
|
117
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/choice",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "GridUI React choice",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"react-dom": "^19.2.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@gridui/form": "^
|
|
30
|
+
"@gridui/form": "^4.1.0",
|
|
31
31
|
"@gridui/interaction": "^1.2.1",
|
|
32
|
-
"@gridui/style-utils": "^
|
|
32
|
+
"@gridui/style-utils": "^3.0.0",
|
|
33
33
|
"@gridui/theme": "^2.5.3",
|
|
34
34
|
"@radix-ui/react-checkbox": "1.4.1",
|
|
35
35
|
"@radix-ui/react-toggle-group": "1.2.1",
|
|
36
36
|
"class-variance-authority": "0.7.1",
|
|
37
|
-
"lucide-react": "1.
|
|
37
|
+
"lucide-react": "1.70.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@gridui-internal/configuration": "0.0.0-internal",
|
|
41
|
-
"@gridui/button": "
|
|
41
|
+
"@gridui/button": "4.0.0",
|
|
42
42
|
"@jest/globals": "30.5.2",
|
|
43
43
|
"@storybook/react-vite": "10.6.6",
|
|
44
44
|
"@types/jest": "30.0.0",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author WMXPY
|
|
3
|
-
* @package Choice
|
|
4
|
-
* @namespace Shared
|
|
5
|
-
* @description Switch Presentation
|
|
6
|
-
*/
|
|
7
|
-
export type SwitchVariant = "rail" | "state";
|
|
8
|
-
export type SwitchStateLabels = {
|
|
9
|
-
readonly checked: string;
|
|
10
|
-
readonly unchecked: string;
|
|
11
|
-
};
|
|
12
|
-
export type SwitchPresentationProps = {
|
|
13
|
-
readonly variant?: SwitchVariant | undefined;
|
|
14
|
-
/** Visible state words; the accessible name must describe the setting. */
|
|
15
|
-
readonly stateLabels?: SwitchStateLabels | undefined;
|
|
16
|
-
};
|