@tamagui/radio-headless 1.114.4 → 1.115.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/cjs/BubbleInput.cjs +82 -0
- package/dist/cjs/index.cjs +19 -0
- package/dist/cjs/useRadioGroup.cjs +191 -0
- package/dist/cjs/utils.cjs +28 -0
- package/package.json +12 -11
- package/dist/cjs/BubbleInput.js +0 -65
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/useRadioGroup.js +0 -160
- package/dist/cjs/utils.js +0 -23
- /package/dist/cjs/{BubbleInput.js.map → BubbleInput.cjs.map} +0 -0
- /package/dist/cjs/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/{useRadioGroup.js.map → useRadioGroup.cjs.map} +0 -0
- /package/dist/cjs/{utils.js.map → utils.cjs.map} +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var BubbleInput_exports = {};
|
|
33
|
+
__export(BubbleInput_exports, {
|
|
34
|
+
BubbleInput: () => BubbleInput
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(BubbleInput_exports);
|
|
37
|
+
var import_react = __toESM(require("react")),
|
|
38
|
+
import_use_previous = require("@tamagui/use-previous"),
|
|
39
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
+
const BubbleInput = props => {
|
|
41
|
+
const {
|
|
42
|
+
checked,
|
|
43
|
+
bubbles = !0,
|
|
44
|
+
control,
|
|
45
|
+
isHidden,
|
|
46
|
+
accentColor,
|
|
47
|
+
...inputProps
|
|
48
|
+
} = props,
|
|
49
|
+
ref = import_react.default.useRef(null),
|
|
50
|
+
prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
51
|
+
return import_react.default.useEffect(() => {
|
|
52
|
+
const input = ref.current,
|
|
53
|
+
inputProto = window.HTMLInputElement.prototype,
|
|
54
|
+
setChecked = Object.getOwnPropertyDescriptor(inputProto, "checked").set;
|
|
55
|
+
if (prevChecked !== checked && setChecked) {
|
|
56
|
+
const event = new Event("click", {
|
|
57
|
+
bubbles
|
|
58
|
+
});
|
|
59
|
+
setChecked.call(input, checked), input.dispatchEvent(event);
|
|
60
|
+
}
|
|
61
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */(0, import_jsx_runtime.jsx)("input", {
|
|
62
|
+
type: "radio",
|
|
63
|
+
defaultChecked: checked,
|
|
64
|
+
...inputProps,
|
|
65
|
+
tabIndex: -1,
|
|
66
|
+
ref,
|
|
67
|
+
"aria-hidden": isHidden,
|
|
68
|
+
style: {
|
|
69
|
+
...(isHidden ? {
|
|
70
|
+
// ...controlSize,
|
|
71
|
+
position: "absolute",
|
|
72
|
+
pointerEvents: "none",
|
|
73
|
+
opacity: 0,
|
|
74
|
+
margin: 0
|
|
75
|
+
} : {
|
|
76
|
+
appearance: "auto",
|
|
77
|
+
accentColor
|
|
78
|
+
}),
|
|
79
|
+
...props.style
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
},
|
|
12
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./useRadioGroup.cjs"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./utils.cjs"), module.exports);
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var useRadioGroup_exports = {};
|
|
22
|
+
__export(useRadioGroup_exports, {
|
|
23
|
+
useRadioGroup: () => useRadioGroup,
|
|
24
|
+
useRadioGroupItem: () => useRadioGroupItem,
|
|
25
|
+
useRadioGroupItemIndicator: () => useRadioGroupItemIndicator
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useRadioGroup_exports);
|
|
28
|
+
var import_compose_refs = require("@tamagui/compose-refs"),
|
|
29
|
+
import_constants = require("@tamagui/constants"),
|
|
30
|
+
import_focusable = require("@tamagui/focusable"),
|
|
31
|
+
import_helpers = require("@tamagui/helpers"),
|
|
32
|
+
import_label = require("@tamagui/label"),
|
|
33
|
+
import_use_controllable_state = require("@tamagui/use-controllable-state"),
|
|
34
|
+
import_react = require("react"),
|
|
35
|
+
import_BubbleInput = require("./BubbleInput.cjs"),
|
|
36
|
+
import_utils = require("./utils.cjs"),
|
|
37
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
function useRadioGroup(params) {
|
|
39
|
+
const {
|
|
40
|
+
value: valueProp,
|
|
41
|
+
onValueChange,
|
|
42
|
+
defaultValue,
|
|
43
|
+
required,
|
|
44
|
+
disabled,
|
|
45
|
+
name,
|
|
46
|
+
native,
|
|
47
|
+
accentColor,
|
|
48
|
+
orientation,
|
|
49
|
+
ref
|
|
50
|
+
} = params,
|
|
51
|
+
[value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
52
|
+
prop: valueProp,
|
|
53
|
+
defaultProp: defaultValue,
|
|
54
|
+
onChange: onValueChange
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
providerValue: {
|
|
58
|
+
value,
|
|
59
|
+
onChange: setValue,
|
|
60
|
+
required,
|
|
61
|
+
disabled,
|
|
62
|
+
name,
|
|
63
|
+
native,
|
|
64
|
+
accentColor
|
|
65
|
+
},
|
|
66
|
+
frameAttrs: {
|
|
67
|
+
role: "radiogroup",
|
|
68
|
+
"aria-orientation": orientation,
|
|
69
|
+
"data-disabled": disabled ? "" : void 0
|
|
70
|
+
},
|
|
71
|
+
rovingFocusGroupAttrs: {
|
|
72
|
+
orientation,
|
|
73
|
+
loop: !0
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"],
|
|
78
|
+
useRadioGroupItem = params => {
|
|
79
|
+
const {
|
|
80
|
+
radioGroupContext,
|
|
81
|
+
value,
|
|
82
|
+
labelledBy: ariaLabelledby,
|
|
83
|
+
disabled: itemDisabled,
|
|
84
|
+
ref: refProp,
|
|
85
|
+
id,
|
|
86
|
+
onPress,
|
|
87
|
+
onKeyDown,
|
|
88
|
+
onFocus
|
|
89
|
+
} = params,
|
|
90
|
+
{
|
|
91
|
+
value: groupValue,
|
|
92
|
+
disabled,
|
|
93
|
+
required,
|
|
94
|
+
onChange,
|
|
95
|
+
name,
|
|
96
|
+
native,
|
|
97
|
+
accentColor
|
|
98
|
+
} = (0, import_react.useContext)(radioGroupContext),
|
|
99
|
+
[button, setButton] = (0, import_react.useState)(null),
|
|
100
|
+
hasConsumerStoppedPropagationRef = (0, import_react.useRef)(!1),
|
|
101
|
+
ref = (0, import_react.useRef)(null),
|
|
102
|
+
composedRefs = (0, import_compose_refs.useComposedRefs)(refProp, node => setButton(node), ref),
|
|
103
|
+
isArrowKeyPressedRef = (0, import_react.useRef)(!1),
|
|
104
|
+
isFormControl = import_constants.isWeb ? button ? !!button.closest("form") : !0 : !1,
|
|
105
|
+
checked = groupValue === value,
|
|
106
|
+
labelId = (0, import_label.useLabelContext)(button),
|
|
107
|
+
labelledBy = ariaLabelledby || labelId;
|
|
108
|
+
(0, import_react.useEffect)(() => {
|
|
109
|
+
if (import_constants.isWeb) {
|
|
110
|
+
const handleKeyDown = event => {
|
|
111
|
+
ARROW_KEYS.includes(event.key) && (isArrowKeyPressedRef.current = !0);
|
|
112
|
+
},
|
|
113
|
+
handleKeyUp = () => {
|
|
114
|
+
isArrowKeyPressedRef.current = !1;
|
|
115
|
+
};
|
|
116
|
+
return document.addEventListener("keydown", handleKeyDown), document.addEventListener("keyup", handleKeyUp), () => {
|
|
117
|
+
document.removeEventListener("keydown", handleKeyDown), document.removeEventListener("keyup", handleKeyUp);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}, []);
|
|
121
|
+
const isDisabled = disabled || itemDisabled;
|
|
122
|
+
return {
|
|
123
|
+
providerValue: {
|
|
124
|
+
checked
|
|
125
|
+
},
|
|
126
|
+
checked,
|
|
127
|
+
isFormControl,
|
|
128
|
+
bubbleInput: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_BubbleInput.BubbleInput, {
|
|
129
|
+
isHidden: !native,
|
|
130
|
+
control: button,
|
|
131
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
132
|
+
name,
|
|
133
|
+
value,
|
|
134
|
+
checked,
|
|
135
|
+
required,
|
|
136
|
+
disabled: isDisabled,
|
|
137
|
+
...(import_constants.isWeb && native && {
|
|
138
|
+
accentColor,
|
|
139
|
+
id
|
|
140
|
+
})
|
|
141
|
+
}),
|
|
142
|
+
native,
|
|
143
|
+
frameAttrs: {
|
|
144
|
+
"data-state": (0, import_utils.getState)(checked),
|
|
145
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
146
|
+
role: "radio",
|
|
147
|
+
"aria-labelledby": labelledBy,
|
|
148
|
+
"aria-checked": checked,
|
|
149
|
+
"aria-required": required,
|
|
150
|
+
disabled: isDisabled,
|
|
151
|
+
ref: composedRefs,
|
|
152
|
+
...(import_constants.isWeb && {
|
|
153
|
+
type: "button",
|
|
154
|
+
value
|
|
155
|
+
}),
|
|
156
|
+
id,
|
|
157
|
+
onPress: (0, import_helpers.composeEventHandlers)(onPress, event => {
|
|
158
|
+
checked || onChange?.(value), isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
159
|
+
}),
|
|
160
|
+
...(import_constants.isWeb && {
|
|
161
|
+
onKeyDown: (0, import_helpers.composeEventHandlers)(onKeyDown, event => {
|
|
162
|
+
event.key === "Enter" && event.preventDefault();
|
|
163
|
+
}),
|
|
164
|
+
onFocus: (0, import_helpers.composeEventHandlers)(onFocus, () => {
|
|
165
|
+
isArrowKeyPressedRef.current && ref.current?.click();
|
|
166
|
+
})
|
|
167
|
+
})
|
|
168
|
+
},
|
|
169
|
+
rovingFocusGroupAttrs: {
|
|
170
|
+
asChild: "expect-style",
|
|
171
|
+
focusable: !isDisabled,
|
|
172
|
+
active: checked
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
function useRadioGroupItemIndicator(params) {
|
|
177
|
+
const {
|
|
178
|
+
radioGroupItemContext,
|
|
179
|
+
disabled,
|
|
180
|
+
...rest
|
|
181
|
+
} = params,
|
|
182
|
+
{
|
|
183
|
+
checked
|
|
184
|
+
} = (0, import_react.useContext)(radioGroupItemContext);
|
|
185
|
+
return {
|
|
186
|
+
checked,
|
|
187
|
+
"data-state": (0, import_utils.getState)(checked),
|
|
188
|
+
"data-disabled": disabled ? "" : void 0,
|
|
189
|
+
...rest
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var utils_exports = {};
|
|
22
|
+
__export(utils_exports, {
|
|
23
|
+
getState: () => getState
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
function getState(checked) {
|
|
27
|
+
return checked ? "checked" : "unchecked";
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/radio-headless",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.115.0",
|
|
4
4
|
"removeSideEffects": "true",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css"
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"clean:build": "tamagui-build clean:build"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tamagui/compose-refs": "1.
|
|
28
|
-
"@tamagui/constants": "1.
|
|
29
|
-
"@tamagui/create-context": "1.
|
|
30
|
-
"@tamagui/focusable": "1.
|
|
31
|
-
"@tamagui/helpers": "1.
|
|
32
|
-
"@tamagui/label": "1.
|
|
33
|
-
"@tamagui/use-controllable-state": "1.
|
|
34
|
-
"@tamagui/use-previous": "1.
|
|
27
|
+
"@tamagui/compose-refs": "1.115.0",
|
|
28
|
+
"@tamagui/constants": "1.115.0",
|
|
29
|
+
"@tamagui/create-context": "1.115.0",
|
|
30
|
+
"@tamagui/focusable": "1.115.0",
|
|
31
|
+
"@tamagui/helpers": "1.115.0",
|
|
32
|
+
"@tamagui/label": "1.115.0",
|
|
33
|
+
"@tamagui/use-controllable-state": "1.115.0",
|
|
34
|
+
"@tamagui/use-previous": "1.115.0"
|
|
35
35
|
},
|
|
36
36
|
"exports": {
|
|
37
37
|
"./package.json": "./package.json",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
"react-native": "./dist/cjs/index.native.js",
|
|
41
41
|
"types": "./types/index.d.ts",
|
|
42
42
|
"import": "./dist/esm/index.mjs",
|
|
43
|
-
"require": "./dist/cjs/index.
|
|
43
|
+
"require": "./dist/cjs/index.cjs",
|
|
44
|
+
"default": "./dist/cjs/index.native.js"
|
|
44
45
|
}
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@tamagui/build": "1.
|
|
48
|
+
"@tamagui/build": "1.115.0",
|
|
48
49
|
"react": "^18.2.0 || ^19.0.0"
|
|
49
50
|
},
|
|
50
51
|
"publishConfig": {
|
package/dist/cjs/BubbleInput.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var BubbleInput_exports = {};
|
|
24
|
-
__export(BubbleInput_exports, {
|
|
25
|
-
BubbleInput: () => BubbleInput
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(BubbleInput_exports);
|
|
28
|
-
var import_react = __toESM(require("react")), import_use_previous = require("@tamagui/use-previous"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
const BubbleInput = (props) => {
|
|
30
|
-
const { checked, bubbles = !0, control, isHidden, accentColor, ...inputProps } = props, ref = import_react.default.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
31
|
-
return import_react.default.useEffect(() => {
|
|
32
|
-
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
33
|
-
inputProto,
|
|
34
|
-
"checked"
|
|
35
|
-
).set;
|
|
36
|
-
if (prevChecked !== checked && setChecked) {
|
|
37
|
-
const event = new Event("click", { bubbles });
|
|
38
|
-
setChecked.call(input, checked), input.dispatchEvent(event);
|
|
39
|
-
}
|
|
40
|
-
}, [prevChecked, checked, bubbles]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
-
"input",
|
|
42
|
-
{
|
|
43
|
-
type: "radio",
|
|
44
|
-
defaultChecked: checked,
|
|
45
|
-
...inputProps,
|
|
46
|
-
tabIndex: -1,
|
|
47
|
-
ref,
|
|
48
|
-
"aria-hidden": isHidden,
|
|
49
|
-
style: {
|
|
50
|
-
...isHidden ? {
|
|
51
|
-
// ...controlSize,
|
|
52
|
-
position: "absolute",
|
|
53
|
-
pointerEvents: "none",
|
|
54
|
-
opacity: 0,
|
|
55
|
-
margin: 0
|
|
56
|
-
} : {
|
|
57
|
-
appearance: "auto",
|
|
58
|
-
accentColor
|
|
59
|
-
},
|
|
60
|
-
...props.style
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=BubbleInput.js.map
|
package/dist/cjs/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var src_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(src_exports);
|
|
14
|
-
__reExport(src_exports, require("./useRadioGroup"), module.exports);
|
|
15
|
-
__reExport(src_exports, require("./utils"), module.exports);
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var useRadioGroup_exports = {};
|
|
16
|
-
__export(useRadioGroup_exports, {
|
|
17
|
-
useRadioGroup: () => useRadioGroup,
|
|
18
|
-
useRadioGroupItem: () => useRadioGroupItem,
|
|
19
|
-
useRadioGroupItemIndicator: () => useRadioGroupItemIndicator
|
|
20
|
-
});
|
|
21
|
-
module.exports = __toCommonJS(useRadioGroup_exports);
|
|
22
|
-
var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_focusable = require("@tamagui/focusable"), import_helpers = require("@tamagui/helpers"), import_label = require("@tamagui/label"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_react = require("react"), import_BubbleInput = require("./BubbleInput"), import_utils = require("./utils"), import_jsx_runtime = require("react/jsx-runtime");
|
|
23
|
-
function useRadioGroup(params) {
|
|
24
|
-
const {
|
|
25
|
-
value: valueProp,
|
|
26
|
-
onValueChange,
|
|
27
|
-
defaultValue,
|
|
28
|
-
required,
|
|
29
|
-
disabled,
|
|
30
|
-
name,
|
|
31
|
-
native,
|
|
32
|
-
accentColor,
|
|
33
|
-
orientation,
|
|
34
|
-
ref
|
|
35
|
-
} = params, [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
36
|
-
prop: valueProp,
|
|
37
|
-
defaultProp: defaultValue,
|
|
38
|
-
onChange: onValueChange
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
providerValue: {
|
|
42
|
-
value,
|
|
43
|
-
onChange: setValue,
|
|
44
|
-
required,
|
|
45
|
-
disabled,
|
|
46
|
-
name,
|
|
47
|
-
native,
|
|
48
|
-
accentColor
|
|
49
|
-
},
|
|
50
|
-
frameAttrs: {
|
|
51
|
-
role: "radiogroup",
|
|
52
|
-
"aria-orientation": orientation,
|
|
53
|
-
"data-disabled": disabled ? "" : void 0
|
|
54
|
-
},
|
|
55
|
-
rovingFocusGroupAttrs: {
|
|
56
|
-
orientation,
|
|
57
|
-
loop: !0
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], useRadioGroupItem = (params) => {
|
|
62
|
-
const {
|
|
63
|
-
radioGroupContext,
|
|
64
|
-
value,
|
|
65
|
-
labelledBy: ariaLabelledby,
|
|
66
|
-
disabled: itemDisabled,
|
|
67
|
-
ref: refProp,
|
|
68
|
-
id,
|
|
69
|
-
onPress,
|
|
70
|
-
onKeyDown,
|
|
71
|
-
onFocus
|
|
72
|
-
} = params, {
|
|
73
|
-
value: groupValue,
|
|
74
|
-
disabled,
|
|
75
|
-
required,
|
|
76
|
-
onChange,
|
|
77
|
-
name,
|
|
78
|
-
native,
|
|
79
|
-
accentColor
|
|
80
|
-
} = (0, import_react.useContext)(radioGroupContext), [button, setButton] = (0, import_react.useState)(null), hasConsumerStoppedPropagationRef = (0, import_react.useRef)(!1), ref = (0, import_react.useRef)(null), composedRefs = (0, import_compose_refs.useComposedRefs)(refProp, (node) => setButton(node), ref), isArrowKeyPressedRef = (0, import_react.useRef)(!1), isFormControl = import_constants.isWeb ? button ? !!button.closest("form") : !0 : !1, checked = groupValue === value, labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId;
|
|
81
|
-
(0, import_react.useEffect)(() => {
|
|
82
|
-
if (import_constants.isWeb) {
|
|
83
|
-
const handleKeyDown = (event) => {
|
|
84
|
-
ARROW_KEYS.includes(event.key) && (isArrowKeyPressedRef.current = !0);
|
|
85
|
-
}, handleKeyUp = () => {
|
|
86
|
-
isArrowKeyPressedRef.current = !1;
|
|
87
|
-
};
|
|
88
|
-
return document.addEventListener("keydown", handleKeyDown), document.addEventListener("keyup", handleKeyUp), () => {
|
|
89
|
-
document.removeEventListener("keydown", handleKeyDown), document.removeEventListener("keyup", handleKeyUp);
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}, []);
|
|
93
|
-
const isDisabled = disabled || itemDisabled;
|
|
94
|
-
return {
|
|
95
|
-
providerValue: {
|
|
96
|
-
checked
|
|
97
|
-
},
|
|
98
|
-
checked,
|
|
99
|
-
isFormControl,
|
|
100
|
-
bubbleInput: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
-
import_BubbleInput.BubbleInput,
|
|
102
|
-
{
|
|
103
|
-
isHidden: !native,
|
|
104
|
-
control: button,
|
|
105
|
-
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
106
|
-
name,
|
|
107
|
-
value,
|
|
108
|
-
checked,
|
|
109
|
-
required,
|
|
110
|
-
disabled: isDisabled,
|
|
111
|
-
...import_constants.isWeb && native && {
|
|
112
|
-
accentColor,
|
|
113
|
-
id
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
),
|
|
117
|
-
native,
|
|
118
|
-
frameAttrs: {
|
|
119
|
-
"data-state": (0, import_utils.getState)(checked),
|
|
120
|
-
"data-disabled": isDisabled ? "" : void 0,
|
|
121
|
-
role: "radio",
|
|
122
|
-
"aria-labelledby": labelledBy,
|
|
123
|
-
"aria-checked": checked,
|
|
124
|
-
"aria-required": required,
|
|
125
|
-
disabled: isDisabled,
|
|
126
|
-
ref: composedRefs,
|
|
127
|
-
...import_constants.isWeb && {
|
|
128
|
-
type: "button",
|
|
129
|
-
value
|
|
130
|
-
},
|
|
131
|
-
id,
|
|
132
|
-
onPress: (0, import_helpers.composeEventHandlers)(onPress, (event) => {
|
|
133
|
-
checked || onChange?.(value), isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
134
|
-
}),
|
|
135
|
-
...import_constants.isWeb && {
|
|
136
|
-
onKeyDown: (0, import_helpers.composeEventHandlers)(onKeyDown, (event) => {
|
|
137
|
-
event.key === "Enter" && event.preventDefault();
|
|
138
|
-
}),
|
|
139
|
-
onFocus: (0, import_helpers.composeEventHandlers)(onFocus, () => {
|
|
140
|
-
isArrowKeyPressedRef.current && ref.current?.click();
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
rovingFocusGroupAttrs: {
|
|
145
|
-
asChild: "expect-style",
|
|
146
|
-
focusable: !isDisabled,
|
|
147
|
-
active: checked
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
function useRadioGroupItemIndicator(params) {
|
|
152
|
-
const { radioGroupItemContext, disabled, ...rest } = params, { checked } = (0, import_react.useContext)(radioGroupItemContext);
|
|
153
|
-
return {
|
|
154
|
-
checked,
|
|
155
|
-
"data-state": (0, import_utils.getState)(checked),
|
|
156
|
-
"data-disabled": disabled ? "" : void 0,
|
|
157
|
-
...rest
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
//# sourceMappingURL=useRadioGroup.js.map
|
package/dist/cjs/utils.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var utils_exports = {};
|
|
16
|
-
__export(utils_exports, {
|
|
17
|
-
getState: () => getState
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(utils_exports);
|
|
20
|
-
function getState(checked) {
|
|
21
|
-
return checked ? "checked" : "unchecked";
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=utils.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|