@tamagui/radio-headless 2.7.7 → 3.0.0-beta.643.1

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.
Files changed (62) hide show
  1. package/dist/cjs/BubbleInput.cjs +57 -71
  2. package/dist/cjs/BubbleInput.native.cjs +75 -0
  3. package/dist/cjs/BubbleInput.native.js +57 -70
  4. package/dist/cjs/BubbleInput.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +10 -11
  6. package/dist/cjs/index.native.cjs +22 -0
  7. package/dist/cjs/index.native.js +10 -10
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/cjs/useRadioGroup.cjs +143 -176
  10. package/dist/cjs/useRadioGroup.native.cjs +190 -0
  11. package/dist/cjs/useRadioGroup.native.js +162 -190
  12. package/dist/cjs/useRadioGroup.native.js.map +1 -1
  13. package/dist/cjs/utils.cjs +16 -19
  14. package/dist/cjs/utils.native.cjs +29 -0
  15. package/dist/cjs/utils.native.js +16 -18
  16. package/dist/cjs/utils.native.js.map +1 -1
  17. package/dist/esm/BubbleInput.mjs +41 -45
  18. package/dist/esm/BubbleInput.mjs.map +1 -1
  19. package/dist/esm/BubbleInput.native.js +42 -46
  20. package/dist/esm/BubbleInput.native.js.map +1 -1
  21. package/dist/esm/index.js +3 -3
  22. package/dist/esm/index.mjs +3 -3
  23. package/dist/esm/index.native.js +3 -3
  24. package/dist/esm/useRadioGroup.mjs +128 -158
  25. package/dist/esm/useRadioGroup.mjs.map +1 -1
  26. package/dist/esm/useRadioGroup.native.js +147 -173
  27. package/dist/esm/useRadioGroup.native.js.map +1 -1
  28. package/dist/esm/utils.mjs +2 -1
  29. package/dist/esm/utils.mjs.map +1 -1
  30. package/dist/esm/utils.native.js +2 -1
  31. package/dist/esm/utils.native.js.map +1 -1
  32. package/dist/jsx/BubbleInput.mjs +41 -45
  33. package/dist/jsx/BubbleInput.mjs.map +1 -1
  34. package/dist/jsx/BubbleInput.native.cjs +75 -0
  35. package/dist/jsx/BubbleInput.native.js +57 -70
  36. package/dist/jsx/BubbleInput.native.js.map +1 -1
  37. package/dist/jsx/index.js +3 -3
  38. package/dist/jsx/index.mjs +3 -3
  39. package/dist/jsx/index.native.cjs +22 -0
  40. package/dist/jsx/index.native.js +10 -10
  41. package/dist/jsx/index.native.js.map +1 -1
  42. package/dist/jsx/useRadioGroup.mjs +128 -158
  43. package/dist/jsx/useRadioGroup.mjs.map +1 -1
  44. package/dist/jsx/useRadioGroup.native.cjs +190 -0
  45. package/dist/jsx/useRadioGroup.native.js +162 -190
  46. package/dist/jsx/useRadioGroup.native.js.map +1 -1
  47. package/dist/jsx/utils.mjs +2 -1
  48. package/dist/jsx/utils.mjs.map +1 -1
  49. package/dist/jsx/utils.native.cjs +29 -0
  50. package/dist/jsx/utils.native.js +16 -18
  51. package/dist/jsx/utils.native.js.map +1 -1
  52. package/package.json +12 -12
  53. package/src/useRadioGroup.tsx +1 -1
  54. package/types/BubbleInput.d.ts +1 -1
  55. package/types/BubbleInput.d.ts.map +1 -1
  56. package/types/useRadioGroup.d.ts +10 -10
  57. package/types/useRadioGroup.d.ts.map +1 -1
  58. package/dist/esm/index.js.map +0 -1
  59. package/dist/esm/index.mjs.map +0 -1
  60. package/dist/esm/index.native.js.map +0 -1
  61. package/dist/jsx/index.js.map +0 -1
  62. package/dist/jsx/index.mjs.map +0 -1
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,84 +8,70 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
14
15
  };
15
16
  var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
23
24
  };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
32
28
  }) : target, mod));
33
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
- value: true
35
- }), mod);
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
30
  var BubbleInput_exports = {};
37
- __export(BubbleInput_exports, {
38
- BubbleInput: () => BubbleInput
39
- });
31
+ __export(BubbleInput_exports, { BubbleInput: () => BubbleInput });
40
32
  module.exports = __toCommonJS(BubbleInput_exports);
41
33
  var import_jsx_runtime = require("react/jsx-runtime");
42
34
  var import_react = __toESM(require("react"), 1);
43
35
  var import_use_previous = require("@tamagui/use-previous");
44
- var BubbleInput = function (props) {
45
- var {
46
- checked,
47
- bubbles = true,
48
- control,
49
- isHidden,
50
- accentColor,
51
- ...inputProps
52
- } = props;
53
- var ref = import_react.default.useRef(null);
54
- var prevChecked = (0, import_use_previous.usePrevious)(checked);
55
- import_react.default.useEffect(function () {
56
- var input = ref.current;
57
- var inputProto = window.HTMLInputElement.prototype;
58
- var descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
59
- var setChecked = descriptor.set;
60
- if (prevChecked !== checked && setChecked) {
61
- var event = new Event("click", {
62
- bubbles
63
- });
64
- setChecked.call(input, checked);
65
- input.dispatchEvent(event);
66
- }
67
- }, [prevChecked, checked, bubbles]);
68
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)("input", {
69
- type: "radio",
70
- defaultChecked: checked,
71
- ...inputProps,
72
- tabIndex: -1,
73
- ref,
74
- "aria-hidden": isHidden,
75
- style: {
76
- ...(isHidden ? {
77
- // ...controlSize,
78
- position: "absolute",
79
- pointerEvents: "none",
80
- opacity: 0,
81
- margin: 0
82
- } : {
83
- appearance: "auto",
84
- accentColor
85
- }),
86
- ...props.style
87
- }
88
- });
36
+ var BubbleInput = function(props) {
37
+ var { checked, bubbles = true, control, isHidden, accentColor, ...inputProps } = props;
38
+ var ref = import_react.default.useRef(null);
39
+ var prevChecked = (0, import_use_previous.usePrevious)(checked);
40
+ import_react.default.useEffect(function() {
41
+ var input = ref.current;
42
+ var inputProto = window.HTMLInputElement.prototype;
43
+ var descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
44
+ var setChecked = descriptor.set;
45
+ if (prevChecked !== checked && setChecked) {
46
+ var event = new Event("click", { bubbles });
47
+ setChecked.call(input, checked);
48
+ input.dispatchEvent(event);
49
+ }
50
+ }, [
51
+ prevChecked,
52
+ checked,
53
+ bubbles
54
+ ]);
55
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
56
+ type: "radio",
57
+ defaultChecked: checked,
58
+ ...inputProps,
59
+ tabIndex: -1,
60
+ ref,
61
+ "aria-hidden": isHidden,
62
+ style: {
63
+ ...isHidden ? {
64
+ position: "absolute",
65
+ pointerEvents: "none",
66
+ opacity: 0,
67
+ margin: 0
68
+ } : {
69
+ appearance: "auto",
70
+ accentColor
71
+ },
72
+ ...props.style
73
+ }
74
+ });
89
75
  };
76
+
90
77
  //# sourceMappingURL=BubbleInput.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","BubbleInput_exports","BubbleInput","module","exports","import_jsx_runtime","require","import_react","import_use_previous","props","checked","bubbles","control","isHidden","accentColor","inputProps","ref","default","useRef","prevChecked","usePrevious","useEffect","input","current","inputProto","window","HTMLInputElement","descriptor","setChecked","set"],"sources":["../../src/BubbleInput.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAO;;AACP,IAAAA,QAAS,GAAAC,MAAA,CAAAC,MAAmB;AAgCxB,IAAAC,SAAA,GAAAF,MAAA,CAAAG,cAAA;AAtBG,IAAAC,gBAAoB,GAACJ,MAAA,CAAAK,wBAA4B;AACtD,IAAAC,iBAAiB,GAAAN,MAAU,CAAAO,mBAAe;AAC1C,IAAAC,YAAY,GAAAR,MAAM,CAAAS,cAA6B;AAC/C,IAAAC,YAAM,GAAAV,MAAc,CAAAW,SAAY,CAAAC,cAAO;AAGvC,IAAAC,QAAM,GAAAA,CAAAC,MAAU,EAAMC,GAAA;EACpB,SAAMC,IAAA,IAAQD,GAAI,EAClBb,SAAM,CAAAY,MAAA,EAAAE,IAAa;IAAOC,GAAA,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAiB;EAAA;AAC3C;AAA0B,IAAAC,WACxB,GAAAA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAAC,I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EAAA,IAAAO,GAAA,GACET,YAAY,CAAAU,OAAA,CAAAC,MAAA;EAAA,IAAAC,WACZ,OAAAX,mBAAA,CAAAY,WAAA,EAAAV,OAAA;EAAAH,YACF,CAAAU,OAAA,CAAAI,SAAA;IAAA,IAEJC,KAAG,GAAAN,GAAM,CAAAO,OAAA;IAAA,IACXC,UAAA,GAAAC,MAAA,CAAAC,gBAAA,CAAA9C,SAAA;IAAA,IAAA+C,UAAA,GAAA1D,MAAA,CAAAK,wBAAA,CAAAkD,UAAA;IACF,IAAAI,UAAA,GAAAD,UAAA,CAAAE,GAAA;IAEJ,IAAAV,WAAA,KAAAT,OAAA,IAAAkB,UAAA","ignoreList":[]}
1
+ {"version":3,"file":"BubbleInput.native.js","names":[],"sources":["jsx/BubbleInput.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar BubbleInput_exports = {};\n__export(BubbleInput_exports, {\n BubbleInput: () => BubbleInput\n});\nmodule.exports = __toCommonJS(BubbleInput_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_react = __toESM(require(\"react\"), 1);\nvar import_use_previous = require(\"@tamagui/use-previous\");\nvar BubbleInput = function(props) {\n var { checked, bubbles = true, control, isHidden, accentColor, ...inputProps } = props;\n var ref = import_react.default.useRef(null);\n var prevChecked = (0, import_use_previous.usePrevious)(checked);\n import_react.default.useEffect(function() {\n var input = ref.current;\n var inputProto = window.HTMLInputElement.prototype;\n var descriptor = Object.getOwnPropertyDescriptor(inputProto, \"checked\");\n var setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n var event = new Event(\"click\", {\n bubbles\n });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [\n prevChecked,\n checked,\n bubbles\n ]);\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(\"input\", {\n type: \"radio\",\n defaultChecked: checked,\n ...inputProps,\n tabIndex: -1,\n ref,\n \"aria-hidden\": isHidden,\n style: {\n ...isHidden ? {\n // ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n } : {\n appearance: \"auto\",\n accentColor\n },\n ...props.style\n }\n });\n};\n//# sourceMappingURL=BubbleInput.js.map\n"],"mappings":";;;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,O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,WAAW,KAAK,OAAO,OAAO;GAC9B,MAAM,cAAc,KAAK;EAC3B;CACF,GAAG;EACD;EACA;EACA;CACF,CAAC;CACD,OAAuB,iBAAC,GAAG,mBAAmB,KAAK,SAAS;EAC1D,MAAM;EACN,gBAAgB;EAChB,GAAG;EACH,UAAU,CAAC;EACX;EACA,eAAe;EACf,OAAO;GACL,GAAG,WAAW;IAEZ,UAAU;IACV,eAAe;IACf,SAAS;IACT,QAAQ;GACV,IAAI;IACF,YAAY;IACZ;GACF;GACA,GAAG,MAAM;EACX;CACF,CAAC;AACH"}
package/dist/jsx/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./useRadioGroup.mjs";
2
- export * from "./utils.mjs";
3
- //# sourceMappingURL=index.js.map
1
+ export * from "./useRadioGroup.mjs"
2
+
3
+ export * from "./utils.mjs"
@@ -1,3 +1,3 @@
1
- export * from "./useRadioGroup.mjs";
2
- export * from "./utils.mjs";
3
- //# sourceMappingURL=index.mjs.map
1
+ export * from "./useRadioGroup.mjs"
2
+
3
+ export * from "./utils.mjs"
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
+ });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ module.exports = __toCommonJS(index_exports);
21
+ __reExport(index_exports, require("./useRadioGroup.native.js"), module.exports);
22
+ __reExport(index_exports, require("./utils.native.js"), module.exports);
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") {
9
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
- get: () => from[key],
11
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
- });
13
- }
14
- return to;
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
+ });
14
+ }
15
+ return to;
15
16
  };
16
17
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
18
- value: true
19
- }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
  var index_exports = {};
21
20
  module.exports = __toCommonJS(index_exports);
22
21
  __reExport(index_exports, require("./useRadioGroup.native.js"), module.exports);
23
22
  __reExport(index_exports, require("./utils.native.js"), module.exports);
23
+
24
24
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__defProp","Object","defineProperty"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;AACA,IAAAA,SAAA,GAAcC,MAAA,CAAAC,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["jsx/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./useRadioGroup\"), module.exports);\n__reExport(index_exports, require(\"./utils\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,2BAAiB,GAAG,OAAO,OAAO;AACpE,WAAW,eAAe,QAAQ,mBAAS,GAAG,OAAO,OAAO"}
@@ -7,168 +7,138 @@ import { useContext, useEffect, useRef, useState } from "react";
7
7
  import { BubbleInput } from "./BubbleInput.mjs";
8
8
  import { getState } from "./utils.mjs";
9
9
  import { jsx } from "react/jsx-runtime";
10
+
10
11
  function useRadioGroup(params) {
11
- const {
12
- value: valueProp,
13
- onValueChange,
14
- defaultValue,
15
- required,
16
- disabled,
17
- name,
18
- native,
19
- accentColor,
20
- orientation,
21
- ref
22
- } = params;
23
- const [value, setValue] = useControllableState({
24
- prop: valueProp,
25
- defaultProp: defaultValue,
26
- onChange: onValueChange
27
- });
28
- return {
29
- providerValue: {
30
- value,
31
- onChange: setValue,
32
- required,
33
- disabled,
34
- name,
35
- native,
36
- accentColor
37
- },
38
- frameAttrs: {
39
- role: "radiogroup",
40
- "aria-orientation": orientation,
41
- "data-disabled": disabled ? "" : void 0
42
- },
43
- rovingFocusGroupAttrs: {
44
- orientation,
45
- loop: true
46
- }
47
- };
12
+ const { value: valueProp, onValueChange, defaultValue, required, disabled, name, native, accentColor, orientation, ref } = params;
13
+ const [value, setValue] = useControllableState({
14
+ prop: valueProp,
15
+ defaultProp: defaultValue,
16
+ onChange: onValueChange
17
+ });
18
+ return {
19
+ providerValue: {
20
+ value,
21
+ onChange: setValue,
22
+ required,
23
+ disabled,
24
+ name,
25
+ native,
26
+ accentColor
27
+ },
28
+ frameAttrs: {
29
+ role: "radiogroup",
30
+ "aria-orientation": orientation,
31
+ "data-disabled": disabled ? "" : void 0
32
+ },
33
+ rovingFocusGroupAttrs: {
34
+ orientation,
35
+ loop: true
36
+ }
37
+ };
48
38
  }
49
- const ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
50
- const useRadioGroupItem = params => {
51
- const {
52
- radioGroupContext,
53
- value,
54
- labelledBy: ariaLabelledby,
55
- disabled: itemDisabled,
56
- ref: refProp,
57
- id,
58
- onPress,
59
- onKeyDown,
60
- onFocus
61
- } = params;
62
- const {
63
- value: groupValue,
64
- disabled,
65
- required,
66
- onChange,
67
- name,
68
- native,
69
- accentColor
70
- } = useContext(radioGroupContext);
71
- const [button, setButton] = useState(null);
72
- const hasConsumerStoppedPropagationRef = useRef(false);
73
- const ref = useRef(null);
74
- const composedRefs = useComposedRefs(refProp, node => setButton(node), ref);
75
- const isArrowKeyPressedRef = useRef(false);
76
- const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
77
- const checked = groupValue === value;
78
- const labelId = useLabelContext(button);
79
- const labelledBy = ariaLabelledby || labelId;
80
- useEffect(() => {
81
- if (isWeb) {
82
- const handleKeyDown = event => {
83
- if (ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
84
- };
85
- const handleKeyUp = () => {
86
- isArrowKeyPressedRef.current = false;
87
- };
88
- document.addEventListener("keydown", handleKeyDown);
89
- document.addEventListener("keyup", handleKeyUp);
90
- return () => {
91
- document.removeEventListener("keydown", handleKeyDown);
92
- document.removeEventListener("keyup", handleKeyUp);
93
- };
94
- }
95
- }, []);
96
- const isDisabled = disabled || itemDisabled;
97
- return {
98
- providerValue: {
99
- checked
100
- },
101
- checked,
102
- isFormControl,
103
- bubbleInput: /* @__PURE__ */jsx(BubbleInput, {
104
- isHidden: !native,
105
- control: button,
106
- bubbles: !hasConsumerStoppedPropagationRef.current,
107
- name,
108
- value,
109
- checked,
110
- required,
111
- disabled: isDisabled,
112
- ...(isWeb && native && {
113
- accentColor,
114
- id
115
- })
116
- }),
117
- native,
118
- frameAttrs: {
119
- "data-state": 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
- ...(isWeb && {
128
- type: "button",
129
- value
130
- }),
131
- id,
132
- onPress: composeEventHandlers(onPress, event => {
133
- if (!checked) onChange?.(value);
134
- if (isFormControl) {
135
- hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
136
- if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
137
- }
138
- }),
139
- ...(isWeb && {
140
- onKeyDown: composeEventHandlers(onKeyDown, event => {
141
- if (event.key === "Enter" || event.key === " ") {
142
- if (!checked) onChange?.(value);
143
- }
144
- }),
145
- onFocus: composeEventHandlers(onFocus, () => {
146
- if (isArrowKeyPressedRef.current) ref.current?.click();
147
- })
148
- })
149
- },
150
- rovingFocusGroupAttrs: {
151
- asChild: "except-style",
152
- focusable: !isDisabled,
153
- active: checked
154
- }
155
- };
39
+ const ARROW_KEYS = [
40
+ "ArrowUp",
41
+ "ArrowDown",
42
+ "ArrowLeft",
43
+ "ArrowRight"
44
+ ];
45
+ const useRadioGroupItem = (params) => {
46
+ const { radioGroupContext, value, labelledBy: ariaLabelledby, disabled: itemDisabled, ref: refProp, id, onPress, onKeyDown, onFocus } = params;
47
+ const { value: groupValue, disabled, required, onChange, name, native, accentColor } = useContext(radioGroupContext);
48
+ const [button, setButton] = useState(null);
49
+ const hasConsumerStoppedPropagationRef = useRef(false);
50
+ const ref = useRef(null);
51
+ const composedRefs = useComposedRefs(refProp, (node) => setButton(node), ref);
52
+ const isArrowKeyPressedRef = useRef(false);
53
+ const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
54
+ const checked = groupValue === value;
55
+ const labelId = useLabelContext(button);
56
+ const labelledBy = ariaLabelledby || labelId;
57
+ useEffect(() => {
58
+ if (isWeb) {
59
+ const handleKeyDown = (event) => {
60
+ if (ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
61
+ };
62
+ const handleKeyUp = () => {
63
+ isArrowKeyPressedRef.current = false;
64
+ };
65
+ document.addEventListener("keydown", handleKeyDown);
66
+ document.addEventListener("keyup", handleKeyUp);
67
+ return () => {
68
+ document.removeEventListener("keydown", handleKeyDown);
69
+ document.removeEventListener("keyup", handleKeyUp);
70
+ };
71
+ }
72
+ }, []);
73
+ const isDisabled = disabled || itemDisabled;
74
+ return {
75
+ providerValue: { checked },
76
+ checked,
77
+ isFormControl,
78
+ bubbleInput: /* @__PURE__ */ jsx(BubbleInput, {
79
+ isHidden: !native,
80
+ control: button,
81
+ bubbles: !hasConsumerStoppedPropagationRef.current,
82
+ name,
83
+ value,
84
+ checked,
85
+ required,
86
+ disabled: isDisabled,
87
+ ...isWeb && native && {
88
+ accentColor,
89
+ id
90
+ }
91
+ }),
92
+ native,
93
+ frameAttrs: {
94
+ "data-state": getState(checked),
95
+ "data-disabled": isDisabled ? "" : void 0,
96
+ role: "radio",
97
+ "aria-labelledby": labelledBy,
98
+ "aria-checked": checked,
99
+ "aria-required": required,
100
+ disabled: isDisabled,
101
+ ref: composedRefs,
102
+ ...isWeb && {
103
+ type: "button",
104
+ value
105
+ },
106
+ id,
107
+ onPress: composeEventHandlers(onPress, (event) => {
108
+ if (!checked) onChange?.(value);
109
+ if (isFormControl) {
110
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
111
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
112
+ }
113
+ }),
114
+ ...isWeb && {
115
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
116
+ if (event.key === "Enter" || event.key === " ") {
117
+ if (!checked) onChange?.(value);
118
+ }
119
+ }),
120
+ onFocus: composeEventHandlers(onFocus, () => {
121
+ if (isArrowKeyPressedRef.current) ref.current?.click();
122
+ })
123
+ }
124
+ },
125
+ rovingFocusGroupAttrs: {
126
+ asChild: "except-style",
127
+ tabIndex: isDisabled ? -1 : 0,
128
+ active: checked
129
+ }
130
+ };
156
131
  };
157
132
  function useRadioGroupItemIndicator(params) {
158
- const {
159
- radioGroupItemContext,
160
- disabled,
161
- ...rest
162
- } = params;
163
- const {
164
- checked
165
- } = useContext(radioGroupItemContext);
166
- return {
167
- checked,
168
- "data-state": getState(checked),
169
- "data-disabled": disabled ? "" : void 0,
170
- ...rest
171
- };
133
+ const { radioGroupItemContext, disabled, ...rest } = params;
134
+ const { checked } = useContext(radioGroupItemContext);
135
+ return {
136
+ checked,
137
+ "data-state": getState(checked),
138
+ "data-disabled": disabled ? "" : void 0,
139
+ ...rest
140
+ };
172
141
  }
142
+
173
143
  export { useRadioGroup, useRadioGroupItem, useRadioGroupItemIndicator };
174
144
  //# sourceMappingURL=useRadioGroup.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["useComposedRefs","isWeb","composeEventHandlers","useLabelContext","useControllableState","useContext","useEffect","useRef","useState","BubbleInput","getState","jsx","useRadioGroup","params","value","valueProp","onValueChange","defaultValue","required","disabled","name","native","accentColor","orientation","ref","setValue","prop","defaultProp","onChange","providerValue","frameAttrs","role","rovingFocusGroupAttrs","loop","ARROW_KEYS","useRadioGroupItem","radioGroupContext","labelledBy","ariaLabelledby","itemDisabled","refProp","id","onPress","onKeyDown","onFocus","groupValue","button","setButton","hasConsumerStoppedPropagationRef","composedRefs","node","isArrowKeyPressedRef","isFormControl","Boolean","closest","checked","labelId","handleKeyDown","event","includes","key","current","handleKeyUp","document","addEventListener","removeEventListener","isDisabled","bubbleInput","isHidden","control","bubbles","type","isPropagationStopped","stopPropagation","click","asChild","focusable","active","useRadioGroupItemIndicator","radioGroupItemContext","rest"],"sources":["useRadioGroup.mjs"],"sourcesContent":["import { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb } from \"@tamagui/constants\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport { useLabelContext } from \"@tamagui/label\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport { useContext, useEffect, useRef, useState } from \"react\";\nimport { BubbleInput } from \"./BubbleInput\";\nimport { getState } from \"./utils\";\nimport { jsx } from \"react/jsx-runtime\";\n\nfunction useRadioGroup(params) {\n\tconst { value: valueProp, onValueChange, defaultValue, required, disabled, name, native, accentColor, orientation, ref } = params;\n\tconst [value, setValue] = useControllableState({\n\t\tprop: valueProp,\n\t\tdefaultProp: defaultValue,\n\t\tonChange: onValueChange\n\t});\n\treturn {\n\t\tproviderValue: {\n\t\t\tvalue,\n\t\t\tonChange: setValue,\n\t\t\trequired,\n\t\t\tdisabled,\n\t\t\tname,\n\t\t\tnative,\n\t\t\taccentColor\n\t\t},\n\t\tframeAttrs: {\n\t\t\trole: \"radiogroup\",\n\t\t\t\"aria-orientation\": orientation,\n\t\t\t\"data-disabled\": disabled ? \"\" : void 0\n\t\t},\n\t\trovingFocusGroupAttrs: {\n\t\t\torientation,\n\t\t\tloop: true\n\t\t}\n\t};\n}\nconst ARROW_KEYS = [\n\t\"ArrowUp\",\n\t\"ArrowDown\",\n\t\"ArrowLeft\",\n\t\"ArrowRight\"\n];\nconst useRadioGroupItem = (params) => {\n\tconst { radioGroupContext, value, labelledBy: ariaLabelledby, disabled: itemDisabled, ref: refProp, id, onPress, onKeyDown, onFocus } = params;\n\tconst { value: groupValue, disabled, required, onChange, name, native, accentColor } = useContext(radioGroupContext);\n\tconst [button, setButton] = useState(null);\n\tconst hasConsumerStoppedPropagationRef = useRef(false);\n\tconst ref = useRef(null);\n\tconst composedRefs = useComposedRefs(refProp, (node) => setButton(node), ref);\n\tconst isArrowKeyPressedRef = useRef(false);\n\tconst isFormControl = isWeb ? button ? Boolean(button.closest(\"form\")) : true : false;\n\tconst checked = groupValue === value;\n\tconst labelId = useLabelContext(button);\n\tconst labelledBy = ariaLabelledby || labelId;\n\tuseEffect(() => {\n\t\tif (isWeb) {\n\t\t\tconst handleKeyDown = (event) => {\n\t\t\t\tif (ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;\n\t\t\t};\n\t\t\tconst handleKeyUp = () => {\n\t\t\t\tisArrowKeyPressedRef.current = false;\n\t\t\t};\n\t\t\tdocument.addEventListener(\"keydown\", handleKeyDown);\n\t\t\tdocument.addEventListener(\"keyup\", handleKeyUp);\n\t\t\treturn () => {\n\t\t\t\tdocument.removeEventListener(\"keydown\", handleKeyDown);\n\t\t\t\tdocument.removeEventListener(\"keyup\", handleKeyUp);\n\t\t\t};\n\t\t}\n\t}, []);\n\tconst isDisabled = disabled || itemDisabled;\n\treturn {\n\t\tproviderValue: { checked },\n\t\tchecked,\n\t\tisFormControl,\n\t\tbubbleInput: /* @__PURE__ */ jsx(BubbleInput, {\n\t\t\tisHidden: !native,\n\t\t\tcontrol: button,\n\t\t\tbubbles: !hasConsumerStoppedPropagationRef.current,\n\t\t\tname,\n\t\t\tvalue,\n\t\t\tchecked,\n\t\t\trequired,\n\t\t\tdisabled: isDisabled,\n\t\t\t...isWeb && native && {\n\t\t\t\taccentColor,\n\t\t\t\tid\n\t\t\t}\n\t\t}),\n\t\tnative,\n\t\tframeAttrs: {\n\t\t\t\"data-state\": getState(checked),\n\t\t\t\"data-disabled\": isDisabled ? \"\" : void 0,\n\t\t\trole: \"radio\",\n\t\t\t\"aria-labelledby\": labelledBy,\n\t\t\t\"aria-checked\": checked,\n\t\t\t\"aria-required\": required,\n\t\t\tdisabled: isDisabled,\n\t\t\tref: composedRefs,\n\t\t\t...isWeb && {\n\t\t\t\ttype: \"button\",\n\t\t\t\tvalue\n\t\t\t},\n\t\t\tid,\n\t\t\tonPress: composeEventHandlers(onPress, (event) => {\n\t\t\t\tif (!checked) onChange?.(value);\n\t\t\t\tif (isFormControl) {\n\t\t\t\t\thasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n\t\t\t\t\tif (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n\t\t\t\t}\n\t\t\t}),\n\t\t\t...isWeb && {\n\t\t\t\tonKeyDown: composeEventHandlers(onKeyDown, (event) => {\n\t\t\t\t\tif (event.key === \"Enter\" || event.key === \" \") {\n\t\t\t\t\t\tif (!checked) onChange?.(value);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tonFocus: composeEventHandlers(onFocus, () => {\n\t\t\t\t\tif (isArrowKeyPressedRef.current) ref.current?.click();\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\t\trovingFocusGroupAttrs: {\n\t\t\tasChild: \"except-style\",\n\t\t\tfocusable: !isDisabled,\n\t\t\tactive: checked\n\t\t}\n\t};\n};\nfunction useRadioGroupItemIndicator(params) {\n\tconst { radioGroupItemContext, disabled, ...rest } = params;\n\tconst { checked } = useContext(radioGroupItemContext);\n\treturn {\n\t\tchecked,\n\t\t\"data-state\": getState(checked),\n\t\t\"data-disabled\": disabled ? \"\" : void 0,\n\t\t...rest\n\t};\n}\n\nexport { useRadioGroup, useRadioGroupItem, useRadioGroupItemIndicator };"],"mappings":"AAAA,SAASA,eAAe,QAAQ,uBAAuB;AACvD,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,oBAAoB,QAAQ,kBAAkB;AACvD,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,oBAAoB,QAAQ,iCAAiC;AACtE,SAASC,UAAU,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,WAAW,QAAQ,mBAAe;AAC3C,SAASC,QAAQ,QAAQ,aAAS;AAClC,SAASC,GAAG,QAAQ,mBAAmB;AAEvC,SAASC,aAAaA,CAACC,MAAM,EAAE;EAC9B,MAAM;IAAEC,KAAK,EAAEC,SAAS;IAAEC,aAAa;IAAEC,YAAY;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,MAAM;IAAEC,WAAW;IAAEC,WAAW;IAAEC;EAAI,CAAC,GAAGX,MAAM;EACjI,MAAM,CAACC,KAAK,EAAEW,QAAQ,CAAC,GAAGrB,oBAAoB,CAAC;IAC9CsB,IAAI,EAAEX,SAAS;IACfY,WAAW,EAAEV,YAAY;IACzBW,QAAQ,EAAEZ;EACX,CAAC,CAAC;EACF,OAAO;IACNa,aAAa,EAAE;MACdf,KAAK;MACLc,QAAQ,EAAEH,QAAQ;MAClBP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EACD,CAAC;AACF,CAAC;AACD,SAASuB,0BAA0BA,CAACjE,MAAM,EAAE;EAC3C,MAAM;IAAEkE,qBAAqB;IAAE5D,QAAQ;IAAE,GAAG6D;EAAK,CAAC,GAAGnE,MAAM;EAC3D,MAAM;IAAE0C;EAAQ,CAAC,GAAGlD,UAAU,CAAC0E,qBAAqB,CAAC;EACrD,OAAO;IACNxB,OAAO;IACP,YAAY,EAAE7C,QAAQ,CAAC6C,OAAO,CAAC;IAC/B,eAAe,EAAEpC,QAAQ,GAAG,EAAE,GAAG,KAAK,CAAC;IACvC,GAAG6D;EACJ,CAAC;AACF;AAEA,SAASpE,aAAa,EAAEuB,iBAAiB,EAAE2C,0BAA0B","ignoreList":[]}
1
+ {"version":3,"file":"useRadioGroup.js","names":[],"sources":["jsx/useRadioGroup.js"],"sourcesContent":["import { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb } from \"@tamagui/constants\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport { useLabelContext } from \"@tamagui/label\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport { useContext, useEffect, useRef, useState } from \"react\";\nimport { BubbleInput } from \"./BubbleInput\";\nimport { getState } from \"./utils\";\nimport { jsx } from \"react/jsx-runtime\";\n\nfunction useRadioGroup(params) {\n\tconst { value: valueProp, onValueChange, defaultValue, required, disabled, name, native, accentColor, orientation, ref } = params;\n\tconst [value, setValue] = useControllableState({\n\t\tprop: valueProp,\n\t\tdefaultProp: defaultValue,\n\t\tonChange: onValueChange\n\t});\n\treturn {\n\t\tproviderValue: {\n\t\t\tvalue,\n\t\t\tonChange: setValue,\n\t\t\trequired,\n\t\t\tdisabled,\n\t\t\tname,\n\t\t\tnative,\n\t\t\taccentColor\n\t\t},\n\t\tframeAttrs: {\n\t\t\trole: \"radiogroup\",\n\t\t\t\"aria-orientation\": orientation,\n\t\t\t\"data-disabled\": disabled ? \"\" : void 0\n\t\t},\n\t\trovingFocusGroupAttrs: {\n\t\t\torientation,\n\t\t\tloop: true\n\t\t}\n\t};\n}\nconst ARROW_KEYS = [\n\t\"ArrowUp\",\n\t\"ArrowDown\",\n\t\"ArrowLeft\",\n\t\"ArrowRight\"\n];\nconst useRadioGroupItem = (params) => {\n\tconst { radioGroupContext, value, labelledBy: ariaLabelledby, disabled: itemDisabled, ref: refProp, id, onPress, onKeyDown, onFocus } = params;\n\tconst { value: groupValue, disabled, required, onChange, name, native, accentColor } = useContext(radioGroupContext);\n\tconst [button, setButton] = useState(null);\n\tconst hasConsumerStoppedPropagationRef = useRef(false);\n\tconst ref = useRef(null);\n\tconst composedRefs = useComposedRefs(refProp, (node) => setButton(node), ref);\n\tconst isArrowKeyPressedRef = useRef(false);\n\tconst isFormControl = isWeb ? button ? Boolean(button.closest(\"form\")) : true : false;\n\tconst checked = groupValue === value;\n\tconst labelId = useLabelContext(button);\n\tconst labelledBy = ariaLabelledby || labelId;\n\tuseEffect(() => {\n\t\tif (isWeb) {\n\t\t\tconst handleKeyDown = (event) => {\n\t\t\t\tif (ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;\n\t\t\t};\n\t\t\tconst handleKeyUp = () => {\n\t\t\t\tisArrowKeyPressedRef.current = false;\n\t\t\t};\n\t\t\tdocument.addEventListener(\"keydown\", handleKeyDown);\n\t\t\tdocument.addEventListener(\"keyup\", handleKeyUp);\n\t\t\treturn () => {\n\t\t\t\tdocument.removeEventListener(\"keydown\", handleKeyDown);\n\t\t\t\tdocument.removeEventListener(\"keyup\", handleKeyUp);\n\t\t\t};\n\t\t}\n\t}, []);\n\tconst isDisabled = disabled || itemDisabled;\n\treturn {\n\t\tproviderValue: { checked },\n\t\tchecked,\n\t\tisFormControl,\n\t\tbubbleInput: /* @__PURE__ */ jsx(BubbleInput, {\n\t\t\tisHidden: !native,\n\t\t\tcontrol: button,\n\t\t\tbubbles: !hasConsumerStoppedPropagationRef.current,\n\t\t\tname,\n\t\t\tvalue,\n\t\t\tchecked,\n\t\t\trequired,\n\t\t\tdisabled: isDisabled,\n\t\t\t...isWeb && native && {\n\t\t\t\taccentColor,\n\t\t\t\tid\n\t\t\t}\n\t\t}),\n\t\tnative,\n\t\tframeAttrs: {\n\t\t\t\"data-state\": getState(checked),\n\t\t\t\"data-disabled\": isDisabled ? \"\" : void 0,\n\t\t\trole: \"radio\",\n\t\t\t\"aria-labelledby\": labelledBy,\n\t\t\t\"aria-checked\": checked,\n\t\t\t\"aria-required\": required,\n\t\t\tdisabled: isDisabled,\n\t\t\tref: composedRefs,\n\t\t\t...isWeb && {\n\t\t\t\ttype: \"button\",\n\t\t\t\tvalue\n\t\t\t},\n\t\t\tid,\n\t\t\tonPress: composeEventHandlers(onPress, (event) => {\n\t\t\t\tif (!checked) onChange?.(value);\n\t\t\t\tif (isFormControl) {\n\t\t\t\t\thasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n\t\t\t\t\tif (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n\t\t\t\t}\n\t\t\t}),\n\t\t\t...isWeb && {\n\t\t\t\tonKeyDown: composeEventHandlers(onKeyDown, (event) => {\n\t\t\t\t\tif (event.key === \"Enter\" || event.key === \" \") {\n\t\t\t\t\t\tif (!checked) onChange?.(value);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tonFocus: composeEventHandlers(onFocus, () => {\n\t\t\t\t\tif (isArrowKeyPressedRef.current) ref.current?.click();\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\t\trovingFocusGroupAttrs: {\n\t\t\tasChild: \"except-style\",\n\t\t\ttabIndex: isDisabled ? -1 : 0,\n\t\t\tactive: checked\n\t\t}\n\t};\n};\nfunction useRadioGroupItemIndicator(params) {\n\tconst { radioGroupItemContext, disabled, ...rest } = params;\n\tconst { checked } = useContext(radioGroupItemContext);\n\treturn {\n\t\tchecked,\n\t\t\"data-state\": getState(checked),\n\t\t\"data-disabled\": disabled ? \"\" : void 0,\n\t\t...rest\n\t};\n}\n\nexport { useRadioGroup, useRadioGroupItem, use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