@zag-js/radio-group 0.10.2 → 0.10.3
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 +24 -29
- 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 -91
- package/dist/radio-group.machine.mjs +128 -7
- package/dist/radio-group.types.d.ts +10 -12
- package/package.json +10 -15
- 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/chunk-UMCKI3BN.mjs
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
dom
|
|
3
|
-
} from "./chunk-DVMAGSYZ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/radio-group.machine.ts
|
|
6
|
-
import { createMachine } from "@zag-js/core";
|
|
7
|
-
import { nextTick } from "@zag-js/dom-query";
|
|
8
|
-
import { trackElementRect } from "@zag-js/element-rect";
|
|
9
|
-
import { trackFormControl } from "@zag-js/form-utils";
|
|
10
|
-
import { compact, isString } from "@zag-js/utils";
|
|
11
|
-
function machine(userContext) {
|
|
12
|
-
const ctx = compact(userContext);
|
|
13
|
-
return createMachine(
|
|
14
|
-
{
|
|
15
|
-
id: "radio",
|
|
16
|
-
initial: "idle",
|
|
17
|
-
context: {
|
|
18
|
-
previousValue: null,
|
|
19
|
-
value: null,
|
|
20
|
-
activeId: null,
|
|
21
|
-
focusedId: null,
|
|
22
|
-
hoveredId: null,
|
|
23
|
-
indicatorRect: {},
|
|
24
|
-
canIndicatorTransition: false,
|
|
25
|
-
...ctx
|
|
26
|
-
},
|
|
27
|
-
entry: ["syncIndicatorRect"],
|
|
28
|
-
exit: ["cleanupObserver"],
|
|
29
|
-
activities: ["trackFormControlState"],
|
|
30
|
-
watch: {
|
|
31
|
-
value: [
|
|
32
|
-
"setIndicatorTransition",
|
|
33
|
-
// important to set this after `setIndicatorTransition`
|
|
34
|
-
"setPreviousValue",
|
|
35
|
-
"invokeOnChange",
|
|
36
|
-
"syncIndicatorRect",
|
|
37
|
-
"syncInputElements"
|
|
38
|
-
]
|
|
39
|
-
},
|
|
40
|
-
on: {
|
|
41
|
-
SET_VALUE: {
|
|
42
|
-
actions: ["setValue"]
|
|
43
|
-
},
|
|
44
|
-
SET_HOVERED: {
|
|
45
|
-
actions: "setHovered"
|
|
46
|
-
},
|
|
47
|
-
SET_ACTIVE: {
|
|
48
|
-
actions: "setActive"
|
|
49
|
-
},
|
|
50
|
-
SET_FOCUSED: {
|
|
51
|
-
actions: "setFocused"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
states: {
|
|
55
|
-
idle: {}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
activities: {
|
|
60
|
-
trackFormControlState(ctx2, _evt, { send, initialContext }) {
|
|
61
|
-
return trackFormControl(dom.getRootEl(ctx2), {
|
|
62
|
-
onFieldsetDisabled() {
|
|
63
|
-
ctx2.disabled = true;
|
|
64
|
-
},
|
|
65
|
-
onFormReset() {
|
|
66
|
-
send({ type: "SET_VALUE", value: initialContext.value });
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
actions: {
|
|
72
|
-
setValue(ctx2, evt) {
|
|
73
|
-
ctx2.value = evt.value;
|
|
74
|
-
},
|
|
75
|
-
setHovered(ctx2, evt) {
|
|
76
|
-
ctx2.hoveredId = evt.value;
|
|
77
|
-
},
|
|
78
|
-
setActive(ctx2, evt) {
|
|
79
|
-
ctx2.activeId = evt.value;
|
|
80
|
-
},
|
|
81
|
-
setFocused(ctx2, evt) {
|
|
82
|
-
ctx2.focusedId = evt.value;
|
|
83
|
-
},
|
|
84
|
-
invokeOnChange(ctx2, evt) {
|
|
85
|
-
ctx2.onChange?.({ value: evt.value });
|
|
86
|
-
},
|
|
87
|
-
syncInputElements(ctx2) {
|
|
88
|
-
const inputs = dom.getInputEls(ctx2);
|
|
89
|
-
inputs.forEach((input) => {
|
|
90
|
-
input.checked = input.value === ctx2.value;
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
setPreviousValue(ctx2) {
|
|
94
|
-
ctx2.previousValue = ctx2.value;
|
|
95
|
-
},
|
|
96
|
-
setIndicatorTransition(ctx2) {
|
|
97
|
-
ctx2.canIndicatorTransition = isString(ctx2.previousValue) && isString(ctx2.value);
|
|
98
|
-
},
|
|
99
|
-
cleanupObserver(ctx2) {
|
|
100
|
-
ctx2.indicatorCleanup?.();
|
|
101
|
-
},
|
|
102
|
-
syncIndicatorRect(ctx2) {
|
|
103
|
-
ctx2.indicatorCleanup?.();
|
|
104
|
-
if (!dom.getIndicatorEl(ctx2))
|
|
105
|
-
return;
|
|
106
|
-
const value = ctx2.value;
|
|
107
|
-
if (value == null) {
|
|
108
|
-
ctx2.indicatorRect = {};
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const radioEl = dom.getActiveRadioEl(ctx2);
|
|
112
|
-
if (!radioEl)
|
|
113
|
-
return;
|
|
114
|
-
ctx2.indicatorCleanup = trackElementRect(radioEl, {
|
|
115
|
-
getRect(el) {
|
|
116
|
-
return dom.getOffsetRect(el);
|
|
117
|
-
},
|
|
118
|
-
onChange(rect) {
|
|
119
|
-
ctx2.indicatorRect = dom.resolveRect(rect);
|
|
120
|
-
nextTick(() => {
|
|
121
|
-
ctx2.canIndicatorTransition = false;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export {
|
|
132
|
-
machine
|
|
133
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|