@zag-js/radio-group 0.82.2 → 1.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/dist/index.d.mts +77 -22
- package/dist/index.d.ts +77 -22
- package/dist/index.js +231 -218
- package/dist/index.mjs +235 -222
- package/package.json +16 -11
package/dist/index.js
CHANGED
|
@@ -18,87 +18,80 @@ var anatomy = anatomy$1.createAnatomy("radio-group").parts(
|
|
|
18
18
|
"indicator"
|
|
19
19
|
);
|
|
20
20
|
var parts = anatomy.build();
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return dom.resolveRect(dom.getOffsetRect(radioEl));
|
|
53
|
-
},
|
|
54
|
-
resolveRect: (rect) => ({
|
|
55
|
-
width: `${rect.width}px`,
|
|
56
|
-
height: `${rect.height}px`,
|
|
57
|
-
left: `${rect.left}px`,
|
|
58
|
-
top: `${rect.top}px`
|
|
59
|
-
})
|
|
21
|
+
var getRootId = (ctx) => ctx.ids?.root ?? `radio-group:${ctx.id}`;
|
|
22
|
+
var getLabelId = (ctx) => ctx.ids?.label ?? `radio-group:${ctx.id}:label`;
|
|
23
|
+
var getItemId = (ctx, value) => ctx.ids?.item?.(value) ?? `radio-group:${ctx.id}:radio:${value}`;
|
|
24
|
+
var getItemHiddenInputId = (ctx, value) => ctx.ids?.itemHiddenInput?.(value) ?? `radio-group:${ctx.id}:radio:input:${value}`;
|
|
25
|
+
var getItemControlId = (ctx, value) => ctx.ids?.itemControl?.(value) ?? `radio-group:${ctx.id}:radio:control:${value}`;
|
|
26
|
+
var getItemLabelId = (ctx, value) => ctx.ids?.itemLabel?.(value) ?? `radio-group:${ctx.id}:radio:label:${value}`;
|
|
27
|
+
var getIndicatorId = (ctx) => ctx.ids?.indicator ?? `radio-group:${ctx.id}:indicator`;
|
|
28
|
+
var getRootEl = (ctx) => ctx.getById(getRootId(ctx));
|
|
29
|
+
var getIndicatorEl = (ctx) => ctx.getById(getIndicatorId(ctx));
|
|
30
|
+
var getFirstEnabledInputEl = (ctx) => getRootEl(ctx)?.querySelector("input:not(:disabled)");
|
|
31
|
+
var getFirstEnabledAndCheckedInputEl = (ctx) => getRootEl(ctx)?.querySelector("input:not(:disabled):checked");
|
|
32
|
+
var getInputEls = (ctx) => {
|
|
33
|
+
const ownerId = CSS.escape(getRootId(ctx));
|
|
34
|
+
const selector = `input[type=radio][data-ownedby='${ownerId}']:not([disabled])`;
|
|
35
|
+
return domQuery.queryAll(getRootEl(ctx), selector);
|
|
36
|
+
};
|
|
37
|
+
var getRadioEl = (ctx, value) => {
|
|
38
|
+
if (!value) return;
|
|
39
|
+
return ctx.getById(getItemId(ctx, value));
|
|
40
|
+
};
|
|
41
|
+
var getOffsetRect = (el) => ({
|
|
42
|
+
left: el?.offsetLeft ?? 0,
|
|
43
|
+
top: el?.offsetTop ?? 0,
|
|
44
|
+
width: el?.offsetWidth ?? 0,
|
|
45
|
+
height: el?.offsetHeight ?? 0
|
|
46
|
+
});
|
|
47
|
+
var resolveRect = (rect) => ({
|
|
48
|
+
width: `${rect.width}px`,
|
|
49
|
+
height: `${rect.height}px`,
|
|
50
|
+
left: `${rect.left}px`,
|
|
51
|
+
top: `${rect.top}px`
|
|
60
52
|
});
|
|
61
53
|
|
|
62
54
|
// src/radio-group.connect.ts
|
|
63
|
-
function connect(
|
|
64
|
-
const
|
|
65
|
-
const
|
|
55
|
+
function connect(service, normalize) {
|
|
56
|
+
const { context, send, computed, prop, scope } = service;
|
|
57
|
+
const groupDisabled = computed("isDisabled");
|
|
58
|
+
const readOnly = prop("readOnly");
|
|
66
59
|
function getItemState(props2) {
|
|
67
60
|
return {
|
|
68
61
|
invalid: !!props2.invalid,
|
|
69
62
|
disabled: !!props2.disabled || groupDisabled,
|
|
70
|
-
checked:
|
|
71
|
-
focused:
|
|
72
|
-
hovered:
|
|
73
|
-
active:
|
|
63
|
+
checked: context.get("value") === props2.value,
|
|
64
|
+
focused: context.get("focusedValue") === props2.value,
|
|
65
|
+
hovered: context.get("hoveredValue") === props2.value,
|
|
66
|
+
active: context.get("activeValue") === props2.value
|
|
74
67
|
};
|
|
75
68
|
}
|
|
76
69
|
function getItemDataAttrs(props2) {
|
|
77
70
|
const radioState = getItemState(props2);
|
|
78
71
|
return {
|
|
79
72
|
"data-focus": domQuery.dataAttr(radioState.focused),
|
|
80
|
-
"data-focus-visible": domQuery.dataAttr(radioState.focused &&
|
|
73
|
+
"data-focus-visible": domQuery.dataAttr(radioState.focused && context.get("focusVisible")),
|
|
81
74
|
"data-disabled": domQuery.dataAttr(radioState.disabled),
|
|
82
75
|
"data-readonly": domQuery.dataAttr(readOnly),
|
|
83
76
|
"data-state": radioState.checked ? "checked" : "unchecked",
|
|
84
77
|
"data-hover": domQuery.dataAttr(radioState.hovered),
|
|
85
78
|
"data-invalid": domQuery.dataAttr(radioState.invalid),
|
|
86
|
-
"data-orientation":
|
|
87
|
-
"data-ssr": domQuery.dataAttr(
|
|
79
|
+
"data-orientation": prop("orientation"),
|
|
80
|
+
"data-ssr": domQuery.dataAttr(context.get("ssr"))
|
|
88
81
|
};
|
|
89
82
|
}
|
|
90
83
|
const focus = () => {
|
|
91
|
-
const firstEnabledAndCheckedInput =
|
|
84
|
+
const firstEnabledAndCheckedInput = getFirstEnabledAndCheckedInputEl(scope);
|
|
92
85
|
if (firstEnabledAndCheckedInput) {
|
|
93
86
|
firstEnabledAndCheckedInput.focus();
|
|
94
87
|
return;
|
|
95
88
|
}
|
|
96
|
-
const firstEnabledInput =
|
|
89
|
+
const firstEnabledInput = getFirstEnabledInputEl(scope);
|
|
97
90
|
firstEnabledInput?.focus();
|
|
98
91
|
};
|
|
99
92
|
return {
|
|
100
93
|
focus,
|
|
101
|
-
value:
|
|
94
|
+
value: context.get("value"),
|
|
102
95
|
setValue(value) {
|
|
103
96
|
send({ type: "SET_VALUE", value, isTrusted: false });
|
|
104
97
|
},
|
|
@@ -109,12 +102,12 @@ function connect(state, send, normalize) {
|
|
|
109
102
|
return normalize.element({
|
|
110
103
|
...parts.root.attrs,
|
|
111
104
|
role: "radiogroup",
|
|
112
|
-
id:
|
|
113
|
-
"aria-labelledby":
|
|
114
|
-
"data-orientation":
|
|
105
|
+
id: getRootId(scope),
|
|
106
|
+
"aria-labelledby": getLabelId(scope),
|
|
107
|
+
"data-orientation": prop("orientation"),
|
|
115
108
|
"data-disabled": domQuery.dataAttr(groupDisabled),
|
|
116
|
-
"aria-orientation":
|
|
117
|
-
dir:
|
|
109
|
+
"aria-orientation": prop("orientation"),
|
|
110
|
+
dir: prop("dir"),
|
|
118
111
|
style: {
|
|
119
112
|
position: "relative"
|
|
120
113
|
}
|
|
@@ -123,10 +116,10 @@ function connect(state, send, normalize) {
|
|
|
123
116
|
getLabelProps() {
|
|
124
117
|
return normalize.element({
|
|
125
118
|
...parts.label.attrs,
|
|
126
|
-
dir:
|
|
127
|
-
"data-orientation":
|
|
119
|
+
dir: prop("dir"),
|
|
120
|
+
"data-orientation": prop("orientation"),
|
|
128
121
|
"data-disabled": domQuery.dataAttr(groupDisabled),
|
|
129
|
-
id:
|
|
122
|
+
id: getLabelId(scope),
|
|
130
123
|
onClick: focus
|
|
131
124
|
});
|
|
132
125
|
},
|
|
@@ -135,9 +128,9 @@ function connect(state, send, normalize) {
|
|
|
135
128
|
const itemState = getItemState(props2);
|
|
136
129
|
return normalize.label({
|
|
137
130
|
...parts.item.attrs,
|
|
138
|
-
dir:
|
|
139
|
-
id:
|
|
140
|
-
htmlFor:
|
|
131
|
+
dir: prop("dir"),
|
|
132
|
+
id: getItemId(scope, props2.value),
|
|
133
|
+
htmlFor: getItemHiddenInputId(scope, props2.value),
|
|
141
134
|
...getItemDataAttrs(props2),
|
|
142
135
|
onPointerMove() {
|
|
143
136
|
if (itemState.disabled) return;
|
|
@@ -164,8 +157,8 @@ function connect(state, send, normalize) {
|
|
|
164
157
|
getItemTextProps(props2) {
|
|
165
158
|
return normalize.element({
|
|
166
159
|
...parts.itemText.attrs,
|
|
167
|
-
dir:
|
|
168
|
-
id:
|
|
160
|
+
dir: prop("dir"),
|
|
161
|
+
id: getItemLabelId(scope, props2.value),
|
|
169
162
|
...getItemDataAttrs(props2)
|
|
170
163
|
});
|
|
171
164
|
},
|
|
@@ -173,8 +166,8 @@ function connect(state, send, normalize) {
|
|
|
173
166
|
const controlState = getItemState(props2);
|
|
174
167
|
return normalize.element({
|
|
175
168
|
...parts.itemControl.attrs,
|
|
176
|
-
dir:
|
|
177
|
-
id:
|
|
169
|
+
dir: prop("dir"),
|
|
170
|
+
id: getItemControlId(scope, props2.value),
|
|
178
171
|
"data-active": domQuery.dataAttr(controlState.active),
|
|
179
172
|
"aria-hidden": true,
|
|
180
173
|
...getItemDataAttrs(props2)
|
|
@@ -183,11 +176,11 @@ function connect(state, send, normalize) {
|
|
|
183
176
|
getItemHiddenInputProps(props2) {
|
|
184
177
|
const inputState = getItemState(props2);
|
|
185
178
|
return normalize.input({
|
|
186
|
-
"data-ownedby":
|
|
187
|
-
id:
|
|
179
|
+
"data-ownedby": getRootId(scope),
|
|
180
|
+
id: getItemHiddenInputId(scope, props2.value),
|
|
188
181
|
type: "radio",
|
|
189
|
-
name:
|
|
190
|
-
form:
|
|
182
|
+
name: prop("name") || prop("id"),
|
|
183
|
+
form: prop("form"),
|
|
191
184
|
value: props2.value,
|
|
192
185
|
onClick(event) {
|
|
193
186
|
if (readOnly) {
|
|
@@ -223,178 +216,197 @@ function connect(state, send, normalize) {
|
|
|
223
216
|
});
|
|
224
217
|
},
|
|
225
218
|
getIndicatorProps() {
|
|
219
|
+
const rect = context.get("indicatorRect");
|
|
226
220
|
return normalize.element({
|
|
227
|
-
id:
|
|
221
|
+
id: getIndicatorId(scope),
|
|
228
222
|
...parts.indicator.attrs,
|
|
229
|
-
dir:
|
|
230
|
-
hidden:
|
|
223
|
+
dir: prop("dir"),
|
|
224
|
+
hidden: context.get("value") == null,
|
|
231
225
|
"data-disabled": domQuery.dataAttr(groupDisabled),
|
|
232
|
-
"data-orientation":
|
|
226
|
+
"data-orientation": prop("orientation"),
|
|
233
227
|
style: {
|
|
234
228
|
"--transition-property": "left, top, width, height",
|
|
235
|
-
"--left":
|
|
236
|
-
"--top":
|
|
237
|
-
"--width":
|
|
238
|
-
"--height":
|
|
229
|
+
"--left": rect?.left,
|
|
230
|
+
"--top": rect?.top,
|
|
231
|
+
"--width": rect?.width,
|
|
232
|
+
"--height": rect?.height,
|
|
239
233
|
position: "absolute",
|
|
240
234
|
willChange: "var(--transition-property)",
|
|
241
235
|
transitionProperty: "var(--transition-property)",
|
|
242
|
-
transitionDuration:
|
|
236
|
+
transitionDuration: context.get("canIndicatorTransition") ? "var(--transition-duration, 150ms)" : "0ms",
|
|
243
237
|
transitionTimingFunction: "var(--transition-timing-function)",
|
|
244
|
-
[
|
|
238
|
+
[prop("orientation") === "horizontal" ? "left" : "top"]: prop("orientation") === "horizontal" ? "var(--left)" : "var(--top)"
|
|
245
239
|
}
|
|
246
240
|
});
|
|
247
241
|
}
|
|
248
242
|
};
|
|
249
243
|
}
|
|
250
|
-
var { not } = core.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
244
|
+
var { not } = core.createGuards();
|
|
245
|
+
var machine = core.createMachine({
|
|
246
|
+
props({ props: props2 }) {
|
|
247
|
+
return {
|
|
248
|
+
orientation: "vertical",
|
|
249
|
+
...props2
|
|
250
|
+
};
|
|
251
|
+
},
|
|
252
|
+
initialState() {
|
|
253
|
+
return "idle";
|
|
254
|
+
},
|
|
255
|
+
context({ prop, bindable }) {
|
|
256
|
+
return {
|
|
257
|
+
value: bindable(() => ({
|
|
258
|
+
defaultValue: prop("defaultValue"),
|
|
259
|
+
value: prop("value"),
|
|
260
|
+
onChange(value) {
|
|
261
|
+
prop("onValueChange")?.({ value });
|
|
262
|
+
}
|
|
263
|
+
})),
|
|
264
|
+
activeValue: bindable(() => ({
|
|
265
|
+
defaultValue: null
|
|
266
|
+
})),
|
|
267
|
+
focusedValue: bindable(() => ({
|
|
268
|
+
defaultValue: null
|
|
269
|
+
})),
|
|
270
|
+
hoveredValue: bindable(() => ({
|
|
271
|
+
defaultValue: null
|
|
272
|
+
})),
|
|
273
|
+
indicatorRect: bindable(() => ({
|
|
274
|
+
defaultValue: {}
|
|
275
|
+
})),
|
|
276
|
+
canIndicatorTransition: bindable(() => ({
|
|
277
|
+
defaultValue: false
|
|
278
|
+
})),
|
|
279
|
+
fieldsetDisabled: bindable(() => ({
|
|
280
|
+
defaultValue: false
|
|
281
|
+
})),
|
|
282
|
+
focusVisible: bindable(() => ({
|
|
283
|
+
defaultValue: false
|
|
284
|
+
})),
|
|
285
|
+
ssr: bindable(() => ({
|
|
286
|
+
defaultValue: true
|
|
287
|
+
}))
|
|
288
|
+
};
|
|
289
|
+
},
|
|
290
|
+
refs() {
|
|
291
|
+
return {
|
|
292
|
+
indicatorCleanup: null
|
|
293
|
+
};
|
|
294
|
+
},
|
|
295
|
+
computed: {
|
|
296
|
+
isDisabled: ({ prop, context }) => !!prop("disabled") || context.get("fieldsetDisabled")
|
|
297
|
+
},
|
|
298
|
+
entry: ["syncIndicatorRect", "syncSsr"],
|
|
299
|
+
exit: ["cleanupObserver"],
|
|
300
|
+
effects: ["trackFormControlState", "trackFocusVisible"],
|
|
301
|
+
watch({ track, action, context }) {
|
|
302
|
+
track([() => context.get("value")], () => {
|
|
303
|
+
action(["setIndicatorTransition", "syncIndicatorRect", "syncInputElements"]);
|
|
304
|
+
});
|
|
305
|
+
},
|
|
306
|
+
on: {
|
|
307
|
+
SET_VALUE: [
|
|
308
|
+
{
|
|
309
|
+
guard: not("isTrusted"),
|
|
310
|
+
actions: ["setValue", "dispatchChangeEvent"]
|
|
279
311
|
},
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
312
|
+
{
|
|
313
|
+
actions: ["setValue"]
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
SET_HOVERED: {
|
|
317
|
+
actions: ["setHovered"]
|
|
318
|
+
},
|
|
319
|
+
SET_ACTIVE: {
|
|
320
|
+
actions: ["setActive"]
|
|
321
|
+
},
|
|
322
|
+
SET_FOCUSED: {
|
|
323
|
+
actions: ["setFocused"]
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
states: {
|
|
327
|
+
idle: {}
|
|
328
|
+
},
|
|
329
|
+
implementations: {
|
|
330
|
+
guards: {
|
|
331
|
+
isTrusted: ({ event }) => !!event.isTrusted
|
|
332
|
+
},
|
|
333
|
+
effects: {
|
|
334
|
+
trackFormControlState({ context, scope }) {
|
|
335
|
+
return domQuery.trackFormControl(getRootEl(scope), {
|
|
336
|
+
onFieldsetDisabledChange(disabled) {
|
|
337
|
+
context.set("fieldsetDisabled", disabled);
|
|
285
338
|
},
|
|
286
|
-
{
|
|
287
|
-
|
|
339
|
+
onFormReset() {
|
|
340
|
+
context.set("value", context.initial("value"));
|
|
288
341
|
}
|
|
289
|
-
|
|
290
|
-
SET_HOVERED: {
|
|
291
|
-
actions: "setHovered"
|
|
292
|
-
},
|
|
293
|
-
SET_ACTIVE: {
|
|
294
|
-
actions: "setActive"
|
|
295
|
-
},
|
|
296
|
-
SET_FOCUSED: {
|
|
297
|
-
actions: "setFocused"
|
|
298
|
-
}
|
|
342
|
+
});
|
|
299
343
|
},
|
|
300
|
-
|
|
301
|
-
|
|
344
|
+
trackFocusVisible({ scope }) {
|
|
345
|
+
return focusVisible.trackFocusVisible({ root: scope.getRootNode?.() });
|
|
302
346
|
}
|
|
303
347
|
},
|
|
304
|
-
{
|
|
305
|
-
|
|
306
|
-
|
|
348
|
+
actions: {
|
|
349
|
+
setValue({ context, event }) {
|
|
350
|
+
context.set("value", event.value);
|
|
307
351
|
},
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return domQuery.trackFormControl(dom.getRootEl(ctx2), {
|
|
311
|
-
onFieldsetDisabledChange(disabled) {
|
|
312
|
-
ctx2.fieldsetDisabled = disabled;
|
|
313
|
-
},
|
|
314
|
-
onFormReset() {
|
|
315
|
-
send({ type: "SET_VALUE", value: initialContext.value });
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
},
|
|
319
|
-
trackFocusVisible(ctx2) {
|
|
320
|
-
return focusVisible.trackFocusVisible({ root: dom.getRootNode(ctx2) });
|
|
321
|
-
}
|
|
352
|
+
setHovered({ context, event }) {
|
|
353
|
+
context.set("hoveredValue", event.value);
|
|
322
354
|
},
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
ctx2.indicatorCleanup?.();
|
|
354
|
-
if (!dom.getIndicatorEl(ctx2)) return;
|
|
355
|
-
const value = ctx2.value;
|
|
356
|
-
const radioEl = dom.getActiveRadioEl(ctx2);
|
|
357
|
-
if (value == null || !radioEl) {
|
|
358
|
-
ctx2.indicatorRect = {};
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
ctx2.indicatorCleanup = elementRect.trackElementRect(radioEl, {
|
|
362
|
-
getRect(el) {
|
|
363
|
-
return dom.getOffsetRect(el);
|
|
364
|
-
},
|
|
365
|
-
onChange(rect) {
|
|
366
|
-
ctx2.indicatorRect = dom.resolveRect(rect);
|
|
367
|
-
domQuery.nextTick(() => {
|
|
368
|
-
ctx2.canIndicatorTransition = false;
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
},
|
|
373
|
-
dispatchChangeEvent(ctx2) {
|
|
374
|
-
const inputEls = dom.getInputEls(ctx2);
|
|
375
|
-
inputEls.forEach((inputEl) => {
|
|
376
|
-
const checked = inputEl.value === ctx2.value;
|
|
377
|
-
if (checked === inputEl.checked) return;
|
|
378
|
-
domQuery.dispatchInputCheckedEvent(inputEl, { checked });
|
|
379
|
-
});
|
|
355
|
+
setActive({ context, event }) {
|
|
356
|
+
context.set("activeValue", event.value);
|
|
357
|
+
},
|
|
358
|
+
setFocused({ context, event }) {
|
|
359
|
+
context.set("focusedValue", event.value);
|
|
360
|
+
context.set("focusVisible", event.focusVisible);
|
|
361
|
+
},
|
|
362
|
+
syncInputElements({ context, scope }) {
|
|
363
|
+
const inputs = getInputEls(scope);
|
|
364
|
+
inputs.forEach((input) => {
|
|
365
|
+
input.checked = input.value === context.get("value");
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
setIndicatorTransition({ context }) {
|
|
369
|
+
context.set("canIndicatorTransition", utils.isString(context.get("value")));
|
|
370
|
+
},
|
|
371
|
+
cleanupObserver({ refs }) {
|
|
372
|
+
refs.get("indicatorCleanup")?.();
|
|
373
|
+
},
|
|
374
|
+
syncSsr({ context }) {
|
|
375
|
+
context.set("ssr", false);
|
|
376
|
+
},
|
|
377
|
+
syncIndicatorRect({ context, scope, refs }) {
|
|
378
|
+
refs.get("indicatorCleanup")?.();
|
|
379
|
+
if (!getIndicatorEl(scope)) return;
|
|
380
|
+
const value = context.get("value");
|
|
381
|
+
const radioEl = getRadioEl(scope, value);
|
|
382
|
+
if (value == null || !radioEl) {
|
|
383
|
+
context.set("indicatorRect", {});
|
|
384
|
+
return;
|
|
380
385
|
}
|
|
386
|
+
const indicatorCleanup = elementRect.trackElementRect(radioEl, {
|
|
387
|
+
getRect(el) {
|
|
388
|
+
return getOffsetRect(el);
|
|
389
|
+
},
|
|
390
|
+
onChange(rect) {
|
|
391
|
+
context.set("indicatorRect", resolveRect(rect));
|
|
392
|
+
domQuery.nextTick(() => {
|
|
393
|
+
context.set("canIndicatorTransition", false);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
refs.set("indicatorCleanup", indicatorCleanup);
|
|
398
|
+
},
|
|
399
|
+
dispatchChangeEvent({ context, scope }) {
|
|
400
|
+
const inputEls = getInputEls(scope);
|
|
401
|
+
inputEls.forEach((inputEl) => {
|
|
402
|
+
const checked = inputEl.value === context.get("value");
|
|
403
|
+
if (checked === inputEl.checked) return;
|
|
404
|
+
domQuery.dispatchInputCheckedEvent(inputEl, { checked });
|
|
405
|
+
});
|
|
381
406
|
}
|
|
382
407
|
}
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
var invoke = {
|
|
386
|
-
change: (ctx) => {
|
|
387
|
-
if (ctx.value == null) return;
|
|
388
|
-
ctx.onValueChange?.({ value: ctx.value });
|
|
389
408
|
}
|
|
390
|
-
};
|
|
391
|
-
var set = {
|
|
392
|
-
value: (ctx, value) => {
|
|
393
|
-
if (utils.isEqual(ctx.value, value)) return;
|
|
394
|
-
ctx.value = value;
|
|
395
|
-
invoke.change(ctx);
|
|
396
|
-
}
|
|
397
|
-
};
|
|
409
|
+
});
|
|
398
410
|
var props = types.createProps()([
|
|
399
411
|
"dir",
|
|
400
412
|
"disabled",
|
|
@@ -406,7 +418,8 @@ var props = types.createProps()([
|
|
|
406
418
|
"onValueChange",
|
|
407
419
|
"orientation",
|
|
408
420
|
"readOnly",
|
|
409
|
-
"value"
|
|
421
|
+
"value",
|
|
422
|
+
"defaultValue"
|
|
410
423
|
]);
|
|
411
424
|
var splitProps = utils.createSplitProps(props);
|
|
412
425
|
var itemProps = types.createProps()(["value", "disabled", "invalid"]);
|