@zag-js/radio-group 2.0.0-next.2 → 2.0.0-next.4

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.
@@ -1,228 +1,227 @@
1
- import { Machine, EventObject, Service } from '@zag-js/core';
2
- import { PropTypes, DirectionProperty, CommonProperties, Rect } from '@zag-js/types';
3
-
4
- interface ValueChangeDetails {
5
- value: string | null;
1
+ import { CommonProperties, DirectionProperty, PropTypes, Rect } from "@zag-js/types";
2
+ import { EventObject, Machine, Service } from "@zag-js/core";
3
+ import { AnimationFrame } from "@zag-js/dom-query";
4
+ export interface ValueChangeDetails {
5
+ value: string | null;
6
6
  }
7
- interface ElementIds {
8
- root?: string | undefined;
9
- label?: string | undefined;
10
- indicator?: string | undefined;
11
- item?: ((value: string) => string) | undefined;
12
- itemLabel?: ((value: string) => string) | undefined;
13
- itemControl?: ((value: string) => string) | undefined;
14
- itemHiddenInput?: ((value: string) => string) | undefined;
7
+ export interface ElementIds {
8
+ root?: string | undefined;
9
+ label?: string | undefined;
10
+ indicator?: string | undefined;
11
+ item?: ((value: string) => string) | undefined;
12
+ itemLabel?: ((value: string) => string) | undefined;
13
+ itemControl?: ((value: string) => string) | undefined;
14
+ itemHiddenInput?: ((value: string) => string) | undefined;
15
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;
16
+ export 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
63
  }
64
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 indicator transitions should be animated
91
- */
92
- animateIndicator: boolean;
93
- /**
94
- * Whether the radio group's fieldset is disabled
95
- */
96
- fieldsetDisabled: boolean;
97
- /**
98
- * Whether the radio group is in server-side rendering
99
- */
100
- ssr: boolean;
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 indicator should skip transitions for the current frame
91
+ */
92
+ indicatorInstant: boolean;
93
+ /**
94
+ * Whether the radio group's fieldset is disabled
95
+ */
96
+ fieldsetDisabled: boolean;
97
+ /**
98
+ * Whether the radio group is in server-side rendering
99
+ */
100
+ ssr: boolean;
101
101
  }
102
102
  type PropsWithDefault = "orientation";
103
103
  type ComputedContext = Readonly<{
104
- /**
105
- * Whether the radio group is disabled
106
- */
107
- isDisabled: boolean;
104
+ /**
105
+ * Whether the radio group is disabled
106
+ */
107
+ isDisabled: boolean;
108
108
  }>;
109
109
  interface Refs {
110
- /**
111
- * Function to clean up the observer for the active tab's rect
112
- */
113
- indicatorCleanup: VoidFunction | null;
114
- /**
115
- * Previous selected value, used to detect real value transitions
116
- */
117
- prevValue: string | null;
110
+ /**
111
+ * Function to clean up the observer for the active tab's rect
112
+ */
113
+ indicatorCleanup: VoidFunction | null;
114
+ /**
115
+ * Frame that clears `indicatorInstant`
116
+ */
117
+ indicatorFrame: AnimationFrame;
118
118
  }
119
- interface RadioGroupSchema {
120
- state: "idle";
121
- props: RadioGroupProps;
122
- defaultPropKey: PropsWithDefault;
123
- context: PrivateContext;
124
- computed: ComputedContext;
125
- refs: Refs;
126
- event: EventObject;
127
- action: string;
128
- effect: string;
129
- guard: string;
119
+ export interface RadioGroupSchema {
120
+ state: "idle";
121
+ props: RadioGroupProps;
122
+ defaultPropKey: PropsWithDefault;
123
+ context: PrivateContext;
124
+ computed: ComputedContext;
125
+ refs: Refs;
126
+ event: EventObject;
127
+ action: string;
128
+ effect: string;
129
+ guard: string;
130
130
  }
131
- type RadioGroupService = Service<RadioGroupSchema>;
132
- type RadioGroupMachine = Machine<RadioGroupSchema>;
133
- interface ItemProps {
134
- value: string;
135
- disabled?: boolean | undefined;
136
- invalid?: boolean | undefined;
131
+ export type RadioGroupService = Service<RadioGroupSchema>;
132
+ export type RadioGroupMachine = Machine<RadioGroupSchema>;
133
+ export interface ItemProps {
134
+ value: string;
135
+ disabled?: boolean | undefined;
136
+ invalid?: boolean | undefined;
137
137
  }
138
- interface ItemState {
139
- /**
140
- * The value of the item
141
- */
142
- value: string;
143
- /**
144
- * Whether the item is invalid
145
- */
146
- invalid: boolean;
147
- /**
148
- * Whether the item is disabled
149
- */
150
- disabled: boolean;
151
- /**
152
- * Whether the item is checked
153
- */
154
- checked: boolean;
155
- /**
156
- * Whether the item is focused
157
- */
158
- focused: boolean;
159
- /**
160
- * Whether the item is focused and the focus is visible
161
- */
162
- focusVisible: boolean;
163
- /**
164
- * Whether the item is hovered
165
- */
166
- hovered: boolean;
167
- /**
168
- * Whether the item is active or pressed
169
- */
170
- active: boolean;
138
+ export interface ItemState {
139
+ /**
140
+ * The value of the item
141
+ */
142
+ value: string;
143
+ /**
144
+ * Whether the item is invalid
145
+ */
146
+ invalid: boolean;
147
+ /**
148
+ * Whether the item is disabled
149
+ */
150
+ disabled: boolean;
151
+ /**
152
+ * Whether the item is checked
153
+ */
154
+ checked: boolean;
155
+ /**
156
+ * Whether the item is focused
157
+ */
158
+ focused: boolean;
159
+ /**
160
+ * Whether the item is focused and the focus is visible
161
+ */
162
+ focusVisible: boolean;
163
+ /**
164
+ * Whether the item is hovered
165
+ */
166
+ hovered: boolean;
167
+ /**
168
+ * Whether the item is active or pressed
169
+ */
170
+ active: boolean;
171
171
  }
172
- interface RootState {
173
- /**
174
- * Whether the radio group is disabled
175
- */
176
- disabled: boolean;
177
- /**
178
- * Whether the radio group is invalid
179
- */
180
- invalid: boolean;
181
- /**
182
- * Whether the radio group is required
183
- */
184
- required: boolean;
185
- /**
186
- * Whether the radio group is read-only
187
- */
188
- readOnly: boolean;
189
- /**
190
- * The orientation of the radio group
191
- */
192
- orientation: "horizontal" | "vertical" | undefined;
172
+ export interface RootState {
173
+ /**
174
+ * Whether the radio group is disabled
175
+ */
176
+ disabled: boolean;
177
+ /**
178
+ * Whether the radio group is invalid
179
+ */
180
+ invalid: boolean;
181
+ /**
182
+ * Whether the radio group is required
183
+ */
184
+ required: boolean;
185
+ /**
186
+ * Whether the radio group is read-only
187
+ */
188
+ readOnly: boolean;
189
+ /**
190
+ * The orientation of the radio group
191
+ */
192
+ orientation: "horizontal" | "vertical" | undefined;
193
193
  }
194
- interface RadioGroupApi<T extends PropTypes = PropTypes> {
195
- /**
196
- * The current value of the radio group
197
- */
198
- value: string | null;
199
- /**
200
- * Function to set the value of the radio group
201
- */
202
- setValue: (value: string) => void;
203
- /**
204
- * Function to clear the value of the radio group
205
- */
206
- clearValue: VoidFunction;
207
- /**
208
- * Function to focus the radio group
209
- */
210
- focus: VoidFunction;
211
- /**
212
- * Returns the state details of a radio input
213
- */
214
- getItemState: (props: ItemProps) => ItemState;
215
- /**
216
- * Returns the state of the radio group
217
- */
218
- getRootState: () => RootState;
219
- getRootProps: () => T["element"];
220
- getLabelProps: () => T["element"];
221
- getItemProps: (props: ItemProps) => T["label"];
222
- getItemTextProps: (props: ItemProps) => T["element"];
223
- getItemControlProps: (props: ItemProps) => T["element"];
224
- getItemHiddenInputProps: (props: ItemProps) => T["input"];
225
- getIndicatorProps: () => T["element"];
194
+ export interface RadioGroupApi<T extends PropTypes = PropTypes> {
195
+ /**
196
+ * The current value of the radio group
197
+ */
198
+ value: string | null;
199
+ /**
200
+ * Function to set the value of the radio group
201
+ */
202
+ setValue: (value: string) => void;
203
+ /**
204
+ * Function to clear the value of the radio group
205
+ */
206
+ clearValue: VoidFunction;
207
+ /**
208
+ * Function to focus the radio group
209
+ */
210
+ focus: VoidFunction;
211
+ /**
212
+ * Returns the state details of a radio input
213
+ */
214
+ getItemState: (props: ItemProps) => ItemState;
215
+ /**
216
+ * Returns the state of the radio group
217
+ */
218
+ getRootState: () => RootState;
219
+ getRootProps: () => T["element"];
220
+ getLabelProps: () => T["element"];
221
+ getItemProps: (props: ItemProps) => T["label"];
222
+ getItemTextProps: (props: ItemProps) => T["element"];
223
+ getItemControlProps: (props: ItemProps) => T["element"];
224
+ getItemHiddenInputProps: (props: ItemProps) => T["input"];
225
+ getIndicatorProps: () => T["element"];
226
226
  }
227
-
228
- export type { ElementIds, ItemProps, ItemState, RadioGroupApi, RadioGroupMachine, RadioGroupProps, RadioGroupSchema, RadioGroupService, RootState, ValueChangeDetails };
227
+ export {};
@@ -1,18 +1,4 @@
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);
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/radio-group",
3
- "version": "2.0.0-next.2",
3
+ "version": "2.0.0-next.4",
4
4
  "description": "Core logic for the radio group widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -30,12 +30,12 @@
30
30
  "url": "https://github.com/chakra-ui/zag/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@zag-js/anatomy": "2.0.0-next.2",
34
- "@zag-js/dom-query": "2.0.0-next.2",
35
- "@zag-js/focus-visible": "2.0.0-next.2",
36
- "@zag-js/utils": "2.0.0-next.2",
37
- "@zag-js/core": "2.0.0-next.2",
38
- "@zag-js/types": "2.0.0-next.2"
33
+ "@zag-js/anatomy": "2.0.0-next.4",
34
+ "@zag-js/dom-query": "2.0.0-next.4",
35
+ "@zag-js/focus-visible": "2.0.0-next.4",
36
+ "@zag-js/utils": "2.0.0-next.4",
37
+ "@zag-js/core": "2.0.0-next.4",
38
+ "@zag-js/types": "2.0.0-next.4"
39
39
  },
40
40
  "devDependencies": {
41
41
  "clean-package": "2.2.0"
@@ -68,7 +68,7 @@
68
68
  "./package.json": "./package.json"
69
69
  },
70
70
  "scripts": {
71
- "build": "tsup",
71
+ "build": "tsdown",
72
72
  "lint": "oxlint src",
73
73
  "typecheck": "tsc --noEmit"
74
74
  }