@zag-js/radio-group 1.34.1 → 1.35.1

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.
@@ -0,0 +1,193 @@
1
+ import { Machine, EventObject, Service } from '@zag-js/core';
2
+ import { PropTypes, RequiredBy, DirectionProperty, CommonProperties, Rect } from '@zag-js/types';
3
+
4
+ interface ValueChangeDetails {
5
+ value: string | null;
6
+ }
7
+ type ElementIds = Partial<{
8
+ root: string;
9
+ label: string;
10
+ indicator: string;
11
+ item: (value: string) => string;
12
+ itemLabel: (value: string) => string;
13
+ itemControl: (value: string) => string;
14
+ itemHiddenInput: (value: string) => string;
15
+ }>;
16
+ interface RadioGroupProps extends DirectionProperty, CommonProperties {
17
+ /**
18
+ * The ids of the elements in the radio. Useful for composition.
19
+ */
20
+ ids?: ElementIds | undefined;
21
+ /**
22
+ * The controlled value of the radio group
23
+ */
24
+ value?: string | null | undefined;
25
+ /**
26
+ * The initial value of the checked radio when rendered.
27
+ * Use when you don't need to control the value of the radio group.
28
+ */
29
+ defaultValue?: string | null | undefined;
30
+ /**
31
+ * The name of the input fields in the radio
32
+ * (Useful for form submission).
33
+ */
34
+ name?: string | undefined;
35
+ /**
36
+ * The associate form of the underlying input.
37
+ */
38
+ form?: string | undefined;
39
+ /**
40
+ * If `true`, the radio group will be disabled
41
+ */
42
+ disabled?: boolean | undefined;
43
+ /**
44
+ * If `true`, the radio group is marked as invalid.
45
+ */
46
+ invalid?: boolean | undefined;
47
+ /**
48
+ * If `true`, the radio group is marked as required.
49
+ */
50
+ required?: boolean | undefined;
51
+ /**
52
+ * Whether the radio group is read-only
53
+ */
54
+ readOnly?: boolean | undefined;
55
+ /**
56
+ * Function called once a radio is checked
57
+ */
58
+ onValueChange?: ((details: ValueChangeDetails) => void) | undefined;
59
+ /**
60
+ * Orientation of the radio group
61
+ */
62
+ orientation?: "horizontal" | "vertical" | undefined;
63
+ }
64
+ interface PrivateContext {
65
+ /**
66
+ * The value of the checked radio
67
+ */
68
+ value: string | null;
69
+ /**
70
+ * The id of the active radio
71
+ */
72
+ activeValue: string | null;
73
+ /**
74
+ * The id of the focused radio
75
+ */
76
+ focusedValue: string | null;
77
+ /**
78
+ * The id of the radio that has focus-visible
79
+ */
80
+ focusVisibleValue: string | null;
81
+ /**
82
+ * The id of the hovered radio
83
+ */
84
+ hoveredValue: string | null;
85
+ /**
86
+ * The active tab indicator's dom rect
87
+ */
88
+ indicatorRect: Rect | null;
89
+ /**
90
+ * Whether the radio group's fieldset is disabled
91
+ */
92
+ fieldsetDisabled: boolean;
93
+ /**
94
+ * Whether the radio group is in server-side rendering
95
+ */
96
+ ssr: boolean;
97
+ }
98
+ type PropsWithDefault = "orientation";
99
+ type ComputedContext = Readonly<{
100
+ /**
101
+ * Whether the radio group is disabled
102
+ */
103
+ isDisabled: boolean;
104
+ }>;
105
+ interface Refs {
106
+ /**
107
+ * Function to clean up the observer for the active tab's rect
108
+ */
109
+ indicatorCleanup: VoidFunction | null;
110
+ }
111
+ interface RadioGroupSchema {
112
+ state: "idle";
113
+ props: RequiredBy<RadioGroupProps, PropsWithDefault>;
114
+ context: PrivateContext;
115
+ computed: ComputedContext;
116
+ refs: Refs;
117
+ event: EventObject;
118
+ action: string;
119
+ effect: string;
120
+ guard: string;
121
+ }
122
+ type RadioGroupService = Service<RadioGroupSchema>;
123
+ type RadioGroupMachine = Machine<RadioGroupSchema>;
124
+ interface ItemProps {
125
+ value: string;
126
+ disabled?: boolean | undefined;
127
+ invalid?: boolean | undefined;
128
+ }
129
+ interface ItemState {
130
+ /**
131
+ * The value of the item
132
+ */
133
+ value: string;
134
+ /**
135
+ * Whether the item is invalid
136
+ */
137
+ invalid: boolean;
138
+ /**
139
+ * Whether the item is disabled
140
+ */
141
+ disabled: boolean;
142
+ /**
143
+ * Whether the item is checked
144
+ */
145
+ checked: boolean;
146
+ /**
147
+ * Whether the item is focused
148
+ */
149
+ focused: boolean;
150
+ /**
151
+ * Whether the item is focused and the focus is visible
152
+ */
153
+ focusVisible: boolean;
154
+ /**
155
+ * Whether the item is hovered
156
+ */
157
+ hovered: boolean;
158
+ /**
159
+ * Whether the item is active or pressed
160
+ */
161
+ active: boolean;
162
+ }
163
+ interface RadioGroupApi<T extends PropTypes = PropTypes> {
164
+ /**
165
+ * The current value of the radio group
166
+ */
167
+ value: string | null;
168
+ /**
169
+ * Function to set the value of the radio group
170
+ */
171
+ setValue: (value: string) => void;
172
+ /**
173
+ * Function to clear the value of the radio group
174
+ */
175
+ clearValue: VoidFunction;
176
+ /**
177
+ * Function to focus the radio group
178
+ */
179
+ focus: VoidFunction;
180
+ /**
181
+ * Returns the state details of a radio input
182
+ */
183
+ getItemState: (props: ItemProps) => ItemState;
184
+ getRootProps: () => T["element"];
185
+ getLabelProps: () => T["element"];
186
+ getItemProps: (props: ItemProps) => T["label"];
187
+ getItemTextProps: (props: ItemProps) => T["element"];
188
+ getItemControlProps: (props: ItemProps) => T["element"];
189
+ getItemHiddenInputProps: (props: ItemProps) => T["input"];
190
+ getIndicatorProps: () => T["element"];
191
+ }
192
+
193
+ export type { ElementIds, ItemProps, ItemState, RadioGroupApi, RadioGroupMachine, RadioGroupProps, RadioGroupSchema, RadioGroupService, ValueChangeDetails };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/radio-group.types.ts
17
+ var radio_group_types_exports = {};
18
+ module.exports = __toCommonJS(radio_group_types_exports);
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/radio-group",
3
- "version": "1.34.1",
3
+ "version": "1.35.1",
4
4
  "description": "Core logic for the radio group widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,17 +27,17 @@
27
27
  "url": "https://github.com/chakra-ui/zag/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@zag-js/anatomy": "1.34.1",
31
- "@zag-js/dom-query": "1.34.1",
32
- "@zag-js/focus-visible": "1.34.1",
33
- "@zag-js/utils": "1.34.1",
34
- "@zag-js/core": "1.34.1",
35
- "@zag-js/types": "1.34.1"
30
+ "@zag-js/anatomy": "1.35.1",
31
+ "@zag-js/dom-query": "1.35.1",
32
+ "@zag-js/focus-visible": "1.35.1",
33
+ "@zag-js/utils": "1.35.1",
34
+ "@zag-js/core": "1.35.1",
35
+ "@zag-js/types": "1.35.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "clean-package": "2.2.0"
39
39
  },
40
- "clean-package": "../../../clean-package.config.json",
40
+ "clean-package": "./clean-package.config.json",
41
41
  "main": "dist/index.js",
42
42
  "module": "dist/index.mjs",
43
43
  "types": "dist/index.d.ts",
@@ -52,6 +52,16 @@
52
52
  "default": "./dist/index.js"
53
53
  }
54
54
  },
55
+ "./anatomy": {
56
+ "import": {
57
+ "types": "./dist/radio-group.anatomy.d.mts",
58
+ "default": "./dist/radio-group.anatomy.mjs"
59
+ },
60
+ "require": {
61
+ "types": "./dist/radio-group.anatomy.d.ts",
62
+ "default": "./dist/radio-group.anatomy.js"
63
+ }
64
+ },
55
65
  "./package.json": "./package.json"
56
66
  },
57
67
  "scripts": {