@zag-js/radio-group 0.10.2 → 0.10.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.
- package/dist/index.d.ts +4 -7
- package/dist/index.js +8 -422
- package/dist/index.mjs +3 -15
- package/dist/radio-group.anatomy.d.ts +3 -6
- package/dist/radio-group.anatomy.js +10 -33
- package/dist/radio-group.anatomy.mjs +14 -8
- package/dist/radio-group.connect.d.ts +3 -7
- package/dist/radio-group.connect.js +43 -125
- package/dist/radio-group.connect.mjs +209 -8
- package/dist/radio-group.dom.d.ts +17 -22
- package/dist/radio-group.dom.js +9 -31
- package/dist/radio-group.dom.mjs +48 -6
- package/dist/radio-group.machine.d.ts +3 -7
- package/dist/radio-group.machine.js +21 -95
- package/dist/radio-group.machine.mjs +124 -7
- package/dist/radio-group.types.d.ts +10 -12
- package/package.json +10 -15
- package/src/radio-group.machine.ts +1 -5
- package/src/radio-group.types.ts +0 -5
- package/dist/chunk-DM5GVJFW.mjs +0 -216
- package/dist/chunk-DVMAGSYZ.mjs +0 -50
- package/dist/chunk-R5YJZPCP.mjs +0 -17
- package/dist/chunk-UMCKI3BN.mjs +0 -133
- package/dist/radio-group.types.js +0 -18
- package/dist/radio-group.types.mjs +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export { anatomy } from
|
|
2
|
-
export { connect } from
|
|
3
|
-
export { machine } from
|
|
4
|
-
export { UserDefinedContext as Context } from
|
|
5
|
-
import '@zag-js/anatomy';
|
|
6
|
-
import '@zag-js/types';
|
|
7
|
-
import '@zag-js/core';
|
|
1
|
+
export { anatomy } from "./radio-group.anatomy";
|
|
2
|
+
export { connect } from "./radio-group.connect";
|
|
3
|
+
export { machine } from "./radio-group.machine";
|
|
4
|
+
export type { UserDefinedContext as Context } from "./radio-group.types";
|
package/dist/index.js
CHANGED
|
@@ -1,427 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
anatomy: () => anatomy,
|
|
24
|
-
connect: () => connect,
|
|
25
|
-
machine: () => machine
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(src_exports);
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
28
4
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"root",
|
|
33
|
-
"label",
|
|
34
|
-
"radio",
|
|
35
|
-
"radioLabel",
|
|
36
|
-
"radioControl",
|
|
37
|
-
"radioInput",
|
|
38
|
-
"indicator"
|
|
39
|
-
);
|
|
40
|
-
var parts = anatomy.build();
|
|
5
|
+
const radioGroup_anatomy = require('./radio-group.anatomy.js');
|
|
6
|
+
const radioGroup_connect = require('./radio-group.connect.js');
|
|
7
|
+
const radioGroup_machine = require('./radio-group.machine.js');
|
|
41
8
|
|
|
42
|
-
// src/radio-group.connect.ts
|
|
43
|
-
var import_dom_query2 = require("@zag-js/dom-query");
|
|
44
|
-
var import_visually_hidden = require("@zag-js/visually-hidden");
|
|
45
9
|
|
|
46
|
-
// src/radio-group.dom.ts
|
|
47
|
-
var import_dom_query = require("@zag-js/dom-query");
|
|
48
|
-
var dom = (0, import_dom_query.createScope)({
|
|
49
|
-
getRootId: (ctx) => ctx.ids?.root ?? `radio-group:${ctx.id}`,
|
|
50
|
-
getLabelId: (ctx) => ctx.ids?.label ?? `radio-group:${ctx.id}:label`,
|
|
51
|
-
getRadioId: (ctx, value) => ctx.ids?.radio?.(value) ?? `radio-group:${ctx.id}:radio:${value}`,
|
|
52
|
-
getRadioInputId: (ctx, value) => ctx.ids?.radioInput?.(value) ?? `radio-group:${ctx.id}:radio:input:${value}`,
|
|
53
|
-
getRadioControlId: (ctx, value) => ctx.ids?.radioControl?.(value) ?? `radio-group:${ctx.id}:radio:control:${value}`,
|
|
54
|
-
getRadioLabelId: (ctx, value) => ctx.ids?.radioLabel?.(value) ?? `radio-group:${ctx.id}:radio:label:${value}`,
|
|
55
|
-
getIndicatorId: (ctx) => ctx.ids?.indicator ?? `tabs:${ctx.id}:indicator`,
|
|
56
|
-
getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
|
|
57
|
-
getRadioInputEl: (ctx, value) => dom.getById(ctx, dom.getRadioInputId(ctx, value)),
|
|
58
|
-
getIndicatorEl: (ctx) => dom.getById(ctx, dom.getIndicatorId(ctx)),
|
|
59
|
-
getFirstEnabledInputEl: (ctx) => dom.getRootEl(ctx)?.querySelector("input:not(:disabled)"),
|
|
60
|
-
getFirstEnabledAndCheckedInputEl: (ctx) => dom.getRootEl(ctx)?.querySelector("input:not(:disabled):checked"),
|
|
61
|
-
getInputEls: (ctx) => {
|
|
62
|
-
const ownerId = CSS.escape(dom.getRootId(ctx));
|
|
63
|
-
const selector = `input[type=radio][data-ownedby='${ownerId}']:not([disabled])`;
|
|
64
|
-
return (0, import_dom_query.queryAll)(dom.getRootEl(ctx), selector);
|
|
65
|
-
},
|
|
66
|
-
getActiveRadioEl: (ctx) => {
|
|
67
|
-
if (!ctx.value)
|
|
68
|
-
return;
|
|
69
|
-
return dom.getById(ctx, dom.getRadioId(ctx, ctx.value));
|
|
70
|
-
},
|
|
71
|
-
getOffsetRect: (el) => {
|
|
72
|
-
return {
|
|
73
|
-
left: el?.offsetLeft ?? 0,
|
|
74
|
-
top: el?.offsetTop ?? 0,
|
|
75
|
-
width: el?.offsetWidth ?? 0,
|
|
76
|
-
height: el?.offsetHeight ?? 0
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
getRectById: (ctx, id) => {
|
|
80
|
-
const tab = dom.queryById(ctx, dom.getRadioId(ctx, id));
|
|
81
|
-
return dom.resolveRect(dom.getOffsetRect(tab));
|
|
82
|
-
},
|
|
83
|
-
resolveRect(rect) {
|
|
84
|
-
return {
|
|
85
|
-
width: `${rect.width}px`,
|
|
86
|
-
height: `${rect.height}px`,
|
|
87
|
-
left: `${rect.left}px`,
|
|
88
|
-
top: `${rect.top}px`
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
10
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const isGroupReadOnly = state.context.readOnly;
|
|
97
|
-
function getRadioState(props) {
|
|
98
|
-
const radioState = {
|
|
99
|
-
isReadOnly: props.readOnly || isGroupReadOnly,
|
|
100
|
-
isInvalid: props.invalid,
|
|
101
|
-
isDisabled: props.disabled || isGroupDisabled,
|
|
102
|
-
isChecked: state.context.value === props.value,
|
|
103
|
-
isFocused: state.context.focusedId === props.value,
|
|
104
|
-
isHovered: state.context.hoveredId === props.value,
|
|
105
|
-
isActive: state.context.activeId === props.value
|
|
106
|
-
};
|
|
107
|
-
return {
|
|
108
|
-
...radioState,
|
|
109
|
-
isInteractive: !(radioState.isReadOnly || radioState.isDisabled)
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function getRadioDataAttrs(props) {
|
|
113
|
-
const radioState = getRadioState(props);
|
|
114
|
-
return {
|
|
115
|
-
"data-focus": (0, import_dom_query2.dataAttr)(radioState.isFocused),
|
|
116
|
-
"data-disabled": (0, import_dom_query2.dataAttr)(radioState.isDisabled),
|
|
117
|
-
"data-checked": (0, import_dom_query2.dataAttr)(radioState.isChecked),
|
|
118
|
-
"data-hover": (0, import_dom_query2.dataAttr)(radioState.isHovered),
|
|
119
|
-
"data-invalid": (0, import_dom_query2.dataAttr)(radioState.isInvalid),
|
|
120
|
-
"data-readonly": (0, import_dom_query2.dataAttr)(radioState.isReadOnly)
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
const focus = () => {
|
|
124
|
-
const firstEnabledAndCheckedInput = dom.getFirstEnabledAndCheckedInputEl(state.context);
|
|
125
|
-
if (firstEnabledAndCheckedInput) {
|
|
126
|
-
firstEnabledAndCheckedInput.focus();
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const firstEnabledInput = dom.getFirstEnabledInputEl(state.context);
|
|
130
|
-
firstEnabledInput?.focus();
|
|
131
|
-
};
|
|
132
|
-
return {
|
|
133
|
-
/**
|
|
134
|
-
* The current value of the radio group
|
|
135
|
-
*/
|
|
136
|
-
value: state.context.value,
|
|
137
|
-
/**
|
|
138
|
-
* Function to set the value of the radio group
|
|
139
|
-
*/
|
|
140
|
-
setValue(value) {
|
|
141
|
-
send({ type: "SET_VALUE", value, manual: true });
|
|
142
|
-
},
|
|
143
|
-
/**
|
|
144
|
-
* Function to clear the value of the radio group
|
|
145
|
-
*/
|
|
146
|
-
clearValue() {
|
|
147
|
-
send({ type: "SET_VALUE", value: null, manual: true });
|
|
148
|
-
},
|
|
149
|
-
/**
|
|
150
|
-
* Function to focus the radio group
|
|
151
|
-
*/
|
|
152
|
-
focus,
|
|
153
|
-
/**
|
|
154
|
-
* Function to blur the currently focused radio input in the radio group
|
|
155
|
-
*/
|
|
156
|
-
blur() {
|
|
157
|
-
const focusedElement = dom.getActiveElement(state.context);
|
|
158
|
-
const inputEls = dom.getInputEls(state.context);
|
|
159
|
-
const radioInputIsFocused = inputEls.some((el) => el === focusedElement);
|
|
160
|
-
if (radioInputIsFocused)
|
|
161
|
-
focusedElement?.blur();
|
|
162
|
-
},
|
|
163
|
-
/**
|
|
164
|
-
* Returns the state details of a radio input
|
|
165
|
-
*/
|
|
166
|
-
getRadioState,
|
|
167
|
-
rootProps: normalize.element({
|
|
168
|
-
...parts.root.attrs,
|
|
169
|
-
role: "radiogroup",
|
|
170
|
-
id: dom.getRootId(state.context),
|
|
171
|
-
"aria-labelledby": dom.getLabelId(state.context),
|
|
172
|
-
"data-orientation": state.context.orientation,
|
|
173
|
-
"aria-orientation": state.context.orientation,
|
|
174
|
-
dir: state.context.dir
|
|
175
|
-
}),
|
|
176
|
-
labelProps: normalize.element({
|
|
177
|
-
...parts.label.attrs,
|
|
178
|
-
id: dom.getLabelId(state.context),
|
|
179
|
-
onClick: focus
|
|
180
|
-
}),
|
|
181
|
-
getRadioProps(props) {
|
|
182
|
-
const rootState = getRadioState(props);
|
|
183
|
-
return normalize.label({
|
|
184
|
-
...parts.radio.attrs,
|
|
185
|
-
id: dom.getRadioId(state.context, props.value),
|
|
186
|
-
htmlFor: dom.getRadioInputId(state.context, props.value),
|
|
187
|
-
...getRadioDataAttrs(props),
|
|
188
|
-
onPointerMove() {
|
|
189
|
-
if (!rootState.isInteractive)
|
|
190
|
-
return;
|
|
191
|
-
send({ type: "SET_HOVERED", value: props.value, hovered: true });
|
|
192
|
-
},
|
|
193
|
-
onPointerLeave() {
|
|
194
|
-
if (!rootState.isInteractive)
|
|
195
|
-
return;
|
|
196
|
-
send({ type: "SET_HOVERED", value: null });
|
|
197
|
-
},
|
|
198
|
-
onPointerDown(event) {
|
|
199
|
-
if (!rootState.isInteractive)
|
|
200
|
-
return;
|
|
201
|
-
if (rootState.isFocused && event.pointerType === "mouse") {
|
|
202
|
-
event.preventDefault();
|
|
203
|
-
}
|
|
204
|
-
send({ type: "SET_ACTIVE", value: props.value, active: true });
|
|
205
|
-
},
|
|
206
|
-
onPointerUp() {
|
|
207
|
-
if (!rootState.isInteractive)
|
|
208
|
-
return;
|
|
209
|
-
send({ type: "SET_ACTIVE", value: null });
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
},
|
|
213
|
-
getRadioLabelProps(props) {
|
|
214
|
-
return normalize.element({
|
|
215
|
-
...parts.radioLabel.attrs,
|
|
216
|
-
id: dom.getRadioLabelId(state.context, props.value),
|
|
217
|
-
...getRadioDataAttrs(props)
|
|
218
|
-
});
|
|
219
|
-
},
|
|
220
|
-
getRadioControlProps(props) {
|
|
221
|
-
const controlState = getRadioState(props);
|
|
222
|
-
return normalize.element({
|
|
223
|
-
...parts.radioControl.attrs,
|
|
224
|
-
id: dom.getRadioControlId(state.context, props.value),
|
|
225
|
-
"data-active": (0, import_dom_query2.dataAttr)(controlState.isActive),
|
|
226
|
-
"aria-hidden": true,
|
|
227
|
-
...getRadioDataAttrs(props)
|
|
228
|
-
});
|
|
229
|
-
},
|
|
230
|
-
getRadioInputProps(props) {
|
|
231
|
-
const inputState = getRadioState(props);
|
|
232
|
-
const isRequired = props.required;
|
|
233
|
-
const trulyDisabled = inputState.isDisabled && !props.focusable;
|
|
234
|
-
return normalize.input({
|
|
235
|
-
...parts.radioInput.attrs,
|
|
236
|
-
"data-ownedby": dom.getRootId(state.context),
|
|
237
|
-
id: dom.getRadioInputId(state.context, props.value),
|
|
238
|
-
type: "radio",
|
|
239
|
-
name: state.context.name || state.context.id,
|
|
240
|
-
form: state.context.form,
|
|
241
|
-
value: props.value,
|
|
242
|
-
onChange(event) {
|
|
243
|
-
if (inputState.isReadOnly || inputState.isDisabled) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (event.target.checked) {
|
|
247
|
-
send({ type: "SET_VALUE", value: props.value });
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
onBlur() {
|
|
251
|
-
send({ type: "SET_FOCUSED", value: null });
|
|
252
|
-
},
|
|
253
|
-
onFocus() {
|
|
254
|
-
send({ type: "SET_FOCUSED", value: props.value, focused: true });
|
|
255
|
-
},
|
|
256
|
-
onKeyDown(event) {
|
|
257
|
-
if (event.key === " ") {
|
|
258
|
-
send({ type: "SET_ACTIVE", value: props.value, active: true });
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
onKeyUp(event) {
|
|
262
|
-
if (event.key === " ") {
|
|
263
|
-
send({ type: "SET_ACTIVE", value: null });
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
disabled: trulyDisabled,
|
|
267
|
-
required: isRequired,
|
|
268
|
-
defaultChecked: inputState.isChecked,
|
|
269
|
-
"data-disabled": (0, import_dom_query2.dataAttr)(inputState.isDisabled),
|
|
270
|
-
"aria-required": (0, import_dom_query2.ariaAttr)(isRequired),
|
|
271
|
-
"aria-invalid": (0, import_dom_query2.ariaAttr)(inputState.isInvalid),
|
|
272
|
-
readOnly: inputState.isReadOnly,
|
|
273
|
-
"data-readonly": (0, import_dom_query2.dataAttr)(inputState.isReadOnly),
|
|
274
|
-
"aria-disabled": (0, import_dom_query2.ariaAttr)(trulyDisabled),
|
|
275
|
-
"aria-checked": (0, import_dom_query2.ariaAttr)(inputState.isChecked),
|
|
276
|
-
style: import_visually_hidden.visuallyHiddenStyle
|
|
277
|
-
});
|
|
278
|
-
},
|
|
279
|
-
indicatorProps: normalize.element({
|
|
280
|
-
id: dom.getIndicatorId(state.context),
|
|
281
|
-
...parts.indicator.attrs,
|
|
282
|
-
"data-orientation": state.context.orientation,
|
|
283
|
-
style: {
|
|
284
|
-
"--transition-duration": "150ms",
|
|
285
|
-
"--transition-property": "left, top, width, height",
|
|
286
|
-
position: "absolute",
|
|
287
|
-
willChange: "var(--transition-property)",
|
|
288
|
-
transitionProperty: "var(--transition-property)",
|
|
289
|
-
transitionDuration: state.context.canIndicatorTransition ? "var(--transition-duration)" : "0ms",
|
|
290
|
-
transitionTimingFunction: "var(--transition-timing-function)",
|
|
291
|
-
...state.context.indicatorRect
|
|
292
|
-
}
|
|
293
|
-
})
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// src/radio-group.machine.ts
|
|
298
|
-
var import_core = require("@zag-js/core");
|
|
299
|
-
var import_dom_query3 = require("@zag-js/dom-query");
|
|
300
|
-
var import_element_rect = require("@zag-js/element-rect");
|
|
301
|
-
var import_form_utils = require("@zag-js/form-utils");
|
|
302
|
-
var import_utils = require("@zag-js/utils");
|
|
303
|
-
function machine(userContext) {
|
|
304
|
-
const ctx = (0, import_utils.compact)(userContext);
|
|
305
|
-
return (0, import_core.createMachine)(
|
|
306
|
-
{
|
|
307
|
-
id: "radio",
|
|
308
|
-
initial: "idle",
|
|
309
|
-
context: {
|
|
310
|
-
previousValue: null,
|
|
311
|
-
value: null,
|
|
312
|
-
activeId: null,
|
|
313
|
-
focusedId: null,
|
|
314
|
-
hoveredId: null,
|
|
315
|
-
indicatorRect: {},
|
|
316
|
-
canIndicatorTransition: false,
|
|
317
|
-
...ctx
|
|
318
|
-
},
|
|
319
|
-
entry: ["syncIndicatorRect"],
|
|
320
|
-
exit: ["cleanupObserver"],
|
|
321
|
-
activities: ["trackFormControlState"],
|
|
322
|
-
watch: {
|
|
323
|
-
value: [
|
|
324
|
-
"setIndicatorTransition",
|
|
325
|
-
// important to set this after `setIndicatorTransition`
|
|
326
|
-
"setPreviousValue",
|
|
327
|
-
"invokeOnChange",
|
|
328
|
-
"syncIndicatorRect",
|
|
329
|
-
"syncInputElements"
|
|
330
|
-
]
|
|
331
|
-
},
|
|
332
|
-
on: {
|
|
333
|
-
SET_VALUE: {
|
|
334
|
-
actions: ["setValue"]
|
|
335
|
-
},
|
|
336
|
-
SET_HOVERED: {
|
|
337
|
-
actions: "setHovered"
|
|
338
|
-
},
|
|
339
|
-
SET_ACTIVE: {
|
|
340
|
-
actions: "setActive"
|
|
341
|
-
},
|
|
342
|
-
SET_FOCUSED: {
|
|
343
|
-
actions: "setFocused"
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
states: {
|
|
347
|
-
idle: {}
|
|
348
|
-
}
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
activities: {
|
|
352
|
-
trackFormControlState(ctx2, _evt, { send, initialContext }) {
|
|
353
|
-
return (0, import_form_utils.trackFormControl)(dom.getRootEl(ctx2), {
|
|
354
|
-
onFieldsetDisabled() {
|
|
355
|
-
ctx2.disabled = true;
|
|
356
|
-
},
|
|
357
|
-
onFormReset() {
|
|
358
|
-
send({ type: "SET_VALUE", value: initialContext.value });
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
actions: {
|
|
364
|
-
setValue(ctx2, evt) {
|
|
365
|
-
ctx2.value = evt.value;
|
|
366
|
-
},
|
|
367
|
-
setHovered(ctx2, evt) {
|
|
368
|
-
ctx2.hoveredId = evt.value;
|
|
369
|
-
},
|
|
370
|
-
setActive(ctx2, evt) {
|
|
371
|
-
ctx2.activeId = evt.value;
|
|
372
|
-
},
|
|
373
|
-
setFocused(ctx2, evt) {
|
|
374
|
-
ctx2.focusedId = evt.value;
|
|
375
|
-
},
|
|
376
|
-
invokeOnChange(ctx2, evt) {
|
|
377
|
-
ctx2.onChange?.({ value: evt.value });
|
|
378
|
-
},
|
|
379
|
-
syncInputElements(ctx2) {
|
|
380
|
-
const inputs = dom.getInputEls(ctx2);
|
|
381
|
-
inputs.forEach((input) => {
|
|
382
|
-
input.checked = input.value === ctx2.value;
|
|
383
|
-
});
|
|
384
|
-
},
|
|
385
|
-
setPreviousValue(ctx2) {
|
|
386
|
-
ctx2.previousValue = ctx2.value;
|
|
387
|
-
},
|
|
388
|
-
setIndicatorTransition(ctx2) {
|
|
389
|
-
ctx2.canIndicatorTransition = (0, import_utils.isString)(ctx2.previousValue) && (0, import_utils.isString)(ctx2.value);
|
|
390
|
-
},
|
|
391
|
-
cleanupObserver(ctx2) {
|
|
392
|
-
ctx2.indicatorCleanup?.();
|
|
393
|
-
},
|
|
394
|
-
syncIndicatorRect(ctx2) {
|
|
395
|
-
ctx2.indicatorCleanup?.();
|
|
396
|
-
if (!dom.getIndicatorEl(ctx2))
|
|
397
|
-
return;
|
|
398
|
-
const value = ctx2.value;
|
|
399
|
-
if (value == null) {
|
|
400
|
-
ctx2.indicatorRect = {};
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
const radioEl = dom.getActiveRadioEl(ctx2);
|
|
404
|
-
if (!radioEl)
|
|
405
|
-
return;
|
|
406
|
-
ctx2.indicatorCleanup = (0, import_element_rect.trackElementRect)(radioEl, {
|
|
407
|
-
getRect(el) {
|
|
408
|
-
return dom.getOffsetRect(el);
|
|
409
|
-
},
|
|
410
|
-
onChange(rect) {
|
|
411
|
-
ctx2.indicatorRect = dom.resolveRect(rect);
|
|
412
|
-
(0, import_dom_query3.nextTick)(() => {
|
|
413
|
-
ctx2.canIndicatorTransition = false;
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
423
|
-
0 && (module.exports = {
|
|
424
|
-
anatomy,
|
|
425
|
-
connect,
|
|
426
|
-
machine
|
|
427
|
-
});
|
|
11
|
+
exports.anatomy = radioGroup_anatomy.anatomy;
|
|
12
|
+
exports.connect = radioGroup_connect.connect;
|
|
13
|
+
exports.machine = radioGroup_machine.machine;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
} from
|
|
4
|
-
import {
|
|
5
|
-
anatomy
|
|
6
|
-
} from "./chunk-R5YJZPCP.mjs";
|
|
7
|
-
import {
|
|
8
|
-
machine
|
|
9
|
-
} from "./chunk-UMCKI3BN.mjs";
|
|
10
|
-
import "./chunk-DVMAGSYZ.mjs";
|
|
11
|
-
export {
|
|
12
|
-
anatomy,
|
|
13
|
-
connect,
|
|
14
|
-
machine
|
|
15
|
-
};
|
|
1
|
+
export { anatomy } from './radio-group.anatomy.mjs';
|
|
2
|
+
export { connect } from './radio-group.connect.mjs';
|
|
3
|
+
export { machine } from './radio-group.machine.mjs';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const parts: Record<"root" | "label" | "radio" | "radioLabel" | "radioControl" | "radioInput" | "indicator", _zag_js_anatomy.AnatomyPart>;
|
|
5
|
-
|
|
6
|
-
export { anatomy, parts };
|
|
1
|
+
import { AnatomyInstance, AnatomyPart } from '@zag-js/anatomy';
|
|
2
|
+
export declare const anatomy: AnatomyInstance<"root" | "label" | "radio" | "radioLabel" | "radioControl" | "radioInput" | "indicator">;
|
|
3
|
+
export declare const parts: Record<"root" | "label" | "radio" | "radioLabel" | "radioControl" | "radioInput" | "indicator", AnatomyPart>;
|
|
@@ -1,31 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(radio_group_anatomy_exports);
|
|
27
|
-
var import_anatomy = require("@zag-js/anatomy");
|
|
28
|
-
var anatomy = (0, import_anatomy.createAnatomy)("radio-group").parts(
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const anatomy$1 = require('@zag-js/anatomy');
|
|
6
|
+
|
|
7
|
+
const anatomy = anatomy$1.createAnatomy("radio-group").parts(
|
|
29
8
|
"root",
|
|
30
9
|
"label",
|
|
31
10
|
"radio",
|
|
@@ -34,9 +13,7 @@ var anatomy = (0, import_anatomy.createAnatomy)("radio-group").parts(
|
|
|
34
13
|
"radioInput",
|
|
35
14
|
"indicator"
|
|
36
15
|
);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
parts
|
|
42
|
-
});
|
|
16
|
+
const parts = anatomy.build();
|
|
17
|
+
|
|
18
|
+
exports.anatomy = anatomy;
|
|
19
|
+
exports.parts = parts;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { createAnatomy } from '@zag-js/anatomy';
|
|
2
|
+
|
|
3
|
+
const anatomy = createAnatomy("radio-group").parts(
|
|
4
|
+
"root",
|
|
5
|
+
"label",
|
|
6
|
+
"radio",
|
|
7
|
+
"radioLabel",
|
|
8
|
+
"radioControl",
|
|
9
|
+
"radioInput",
|
|
10
|
+
"indicator"
|
|
11
|
+
);
|
|
12
|
+
const parts = anatomy.build();
|
|
13
|
+
|
|
14
|
+
export { anatomy, parts };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
1
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
2
|
+
import type { InputProps, RadioProps, Send, State } from "./radio-group.types";
|
|
3
|
+
export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
6
4
|
/**
|
|
7
5
|
* The current value of the radio group
|
|
8
6
|
*/
|
|
@@ -44,5 +42,3 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
|
|
|
44
42
|
getRadioInputProps(props: InputProps): T["input"];
|
|
45
43
|
indicatorProps: T["element"];
|
|
46
44
|
};
|
|
47
|
-
|
|
48
|
-
export { connect };
|