@tamagui/radio-group 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 (65) hide show
  1. package/dist/cjs/RadioGroup.cjs +127 -116
  2. package/dist/cjs/RadioGroup.native.cjs +146 -0
  3. package/dist/cjs/RadioGroup.native.js +127 -117
  4. package/dist/cjs/RadioGroup.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +9 -28
  6. package/dist/cjs/index.native.cjs +21 -0
  7. package/dist/cjs/index.native.js +10 -28
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/esm/RadioGroup.mjs +105 -100
  10. package/dist/esm/RadioGroup.mjs.map +1 -1
  11. package/dist/esm/RadioGroup.native.js +105 -102
  12. package/dist/esm/RadioGroup.native.js.map +1 -1
  13. package/dist/esm/index.js +1 -12
  14. package/dist/esm/index.mjs +1 -12
  15. package/dist/esm/index.native.js +1 -12
  16. package/dist/jsx/RadioGroup.mjs +105 -100
  17. package/dist/jsx/RadioGroup.mjs.map +1 -1
  18. package/dist/jsx/RadioGroup.native.cjs +146 -0
  19. package/dist/jsx/RadioGroup.native.js +127 -117
  20. package/dist/jsx/RadioGroup.native.js.map +1 -1
  21. package/dist/jsx/index.js +1 -12
  22. package/dist/jsx/index.mjs +1 -12
  23. package/dist/jsx/index.native.cjs +21 -0
  24. package/dist/jsx/index.native.js +10 -28
  25. package/dist/jsx/index.native.js.map +1 -1
  26. package/package.json +5 -15
  27. package/src/RadioGroup.tsx +160 -89
  28. package/src/index.ts +0 -15
  29. package/types/RadioGroup.d.ts +145 -16
  30. package/types/RadioGroup.d.ts.map +1 -1
  31. package/types/index.d.ts +0 -251
  32. package/types/index.d.ts.map +1 -1
  33. package/dist/cjs/RadioGroupStyledContext.cjs +0 -32
  34. package/dist/cjs/RadioGroupStyledContext.native.js +0 -35
  35. package/dist/cjs/RadioGroupStyledContext.native.js.map +0 -1
  36. package/dist/cjs/createRadioGroup.cjs +0 -175
  37. package/dist/cjs/createRadioGroup.native.js +0 -178
  38. package/dist/cjs/createRadioGroup.native.js.map +0 -1
  39. package/dist/esm/RadioGroupStyledContext.mjs +0 -7
  40. package/dist/esm/RadioGroupStyledContext.mjs.map +0 -1
  41. package/dist/esm/RadioGroupStyledContext.native.js +0 -7
  42. package/dist/esm/RadioGroupStyledContext.native.js.map +0 -1
  43. package/dist/esm/createRadioGroup.mjs +0 -139
  44. package/dist/esm/createRadioGroup.mjs.map +0 -1
  45. package/dist/esm/createRadioGroup.native.js +0 -139
  46. package/dist/esm/createRadioGroup.native.js.map +0 -1
  47. package/dist/esm/index.js.map +0 -1
  48. package/dist/esm/index.mjs.map +0 -1
  49. package/dist/esm/index.native.js.map +0 -1
  50. package/dist/jsx/RadioGroupStyledContext.mjs +0 -7
  51. package/dist/jsx/RadioGroupStyledContext.mjs.map +0 -1
  52. package/dist/jsx/RadioGroupStyledContext.native.js +0 -35
  53. package/dist/jsx/RadioGroupStyledContext.native.js.map +0 -1
  54. package/dist/jsx/createRadioGroup.mjs +0 -139
  55. package/dist/jsx/createRadioGroup.mjs.map +0 -1
  56. package/dist/jsx/createRadioGroup.native.js +0 -178
  57. package/dist/jsx/createRadioGroup.native.js.map +0 -1
  58. package/dist/jsx/index.js.map +0 -1
  59. package/dist/jsx/index.mjs.map +0 -1
  60. package/src/RadioGroupStyledContext.tsx +0 -10
  61. package/src/createRadioGroup.tsx +0 -191
  62. package/types/RadioGroupStyledContext.d.ts +0 -6
  63. package/types/RadioGroupStyledContext.d.ts.map +0 -1
  64. package/types/createRadioGroup.d.ts +0 -282
  65. package/types/createRadioGroup.d.ts.map +0 -1
@@ -1,133 +1,144 @@
1
+
2
+ var __create = Object.create;
1
3
  var __defProp = Object.defineProperty;
2
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
4
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
8
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
10
13
  };
11
14
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
28
  var RadioGroup_exports = {};
24
29
  __export(RadioGroup_exports, {
25
- RadioGroupFrame: () => RadioGroupFrame,
26
- RadioGroupIndicatorFrame: () => RadioGroupIndicatorFrame,
27
- RadioGroupItemFrame: () => RadioGroupItemFrame
30
+ RadioGroup: () => RadioGroup,
31
+ RadioGroupContext: () => RadioGroupContext,
32
+ RadioGroupFrame: () => RadioGroupFrame,
33
+ RadioGroupIndicatorFrame: () => RadioGroupIndicatorFrame,
34
+ RadioGroupItemContext: () => RadioGroupItemContext,
35
+ RadioGroupItemFrame: () => RadioGroupItemFrame
28
36
  });
29
37
  module.exports = __toCommonJS(RadioGroup_exports);
30
38
  var import_core = require("@tamagui/core");
31
- var import_get_token = require("@tamagui/get-token");
32
- var import_stacks = require("@tamagui/stacks");
39
+ var import_radio_headless = require("@tamagui/radio-headless");
40
+ var import_roving_focus = require("@tamagui/roving-focus");
41
+ var import_react = __toESM(require("react"), 1);
42
+ var import_jsx_runtime = require("react/jsx-runtime");
33
43
  const RADIO_GROUP_ITEM_NAME = "RadioGroupItem";
34
- const RadioGroupItemFrame = (0, import_core.styled)(import_stacks.YStack, {
35
- name: RADIO_GROUP_ITEM_NAME,
36
- render: "button",
37
- variants: {
38
- unstyled: {
39
- false: {
40
- size: "$true",
41
- borderRadius: 1e3,
42
- backgroundColor: "$background",
43
- alignItems: "center",
44
- justifyContent: "center",
45
- borderWidth: 1,
46
- borderColor: "$borderColor",
47
- padding: 0,
48
- hoverStyle: {
49
- borderColor: "$borderColorHover",
50
- backgroundColor: "$backgroundHover"
51
- },
52
- focusStyle: {
53
- borderColor: "$borderColorHover",
54
- backgroundColor: "$backgroundHover"
55
- },
56
- focusVisibleStyle: {
57
- outlineStyle: "solid",
58
- outlineWidth: 2,
59
- outlineColor: "$outlineColor"
60
- },
61
- pressStyle: {
62
- borderColor: "$borderColorFocus",
63
- backgroundColor: "$backgroundFocus"
64
- }
65
- }
66
- },
67
- disabled: {
68
- true: {
69
- pointerEvents: "none",
70
- userSelect: "none",
71
- cursor: "not-allowed",
72
- hoverStyle: {
73
- borderColor: "$borderColor",
74
- backgroundColor: "$background"
75
- },
76
- pressStyle: {
77
- borderColor: "$borderColor",
78
- backgroundColor: "$background"
79
- },
80
- focusVisibleStyle: {
81
- outlineWidth: 0
82
- }
83
- }
84
- },
85
- size: {
86
- "...size": (value, {
87
- props
88
- }) => {
89
- const size = Math.floor((0, import_core.getVariableValue)((0, import_get_token.getSize)(value)) * (props["scaleSize"] ?? 0.5));
90
- return {
91
- width: size,
92
- height: size
93
- };
94
- }
95
- }
96
- },
97
- defaultVariants: {
98
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
99
- }
44
+ const RadioGroupItemFrame = (0, import_core.styled)(import_core.View, {
45
+ displayName: RADIO_GROUP_ITEM_NAME,
46
+ render: "button",
47
+ alignItems: "center",
48
+ justifyContent: "center",
49
+ variants: { disabled: { true: {
50
+ pointerEvents: "none",
51
+ userSelect: "none"
52
+ } } }
100
53
  });
101
54
  const RADIO_GROUP_INDICATOR_NAME = "RadioGroupIndicator";
102
- const RadioGroupIndicatorFrame = (0, import_core.styled)(import_stacks.YStack, {
103
- name: RADIO_GROUP_INDICATOR_NAME,
104
- variants: {
105
- unstyled: {
106
- false: {
107
- width: "33%",
108
- height: "33%",
109
- borderRadius: 1e3,
110
- backgroundColor: "$color"
111
- }
112
- }
113
- },
114
- defaultVariants: {
115
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
116
- }
117
- });
55
+ const RadioGroupIndicatorFrame = (0, import_core.styled)(import_core.View, { displayName: RADIO_GROUP_INDICATOR_NAME });
118
56
  const RADIO_GROUP_NAME = "RadioGroup";
119
- const RadioGroupFrame = (0, import_core.styled)(import_stacks.YStack, {
120
- name: RADIO_GROUP_NAME,
121
- variants: {
122
- orientation: {
123
- horizontal: {
124
- flexDirection: "row",
125
- spaceDirection: "horizontal"
126
- },
127
- vertical: {
128
- flexDirection: "column",
129
- spaceDirection: "vertical"
130
- }
131
- }
132
- }
133
- });
57
+ const RadioGroupFrame = (0, import_core.styled)(import_core.View, {
58
+ displayName: RADIO_GROUP_NAME,
59
+ variants: { orientation: {
60
+ horizontal: {
61
+ flexDirection: "row",
62
+ spaceDirection: "horizontal"
63
+ },
64
+ vertical: {
65
+ flexDirection: "column",
66
+ spaceDirection: "vertical"
67
+ }
68
+ } }
69
+ });
70
+ const RadioGroupContext = import_react.default.createContext({});
71
+ const RadioGroupItemContext = import_react.default.createContext({
72
+ checked: false,
73
+ disabled: false
74
+ });
75
+ const RadioGroupComponent = (0, import_core.createStyledHOC)(RadioGroupFrame, (props, ref) => {
76
+ const { value, defaultValue, onValueChange, required = false, disabled = false, name, native, accentColor, orientation = "vertical", ...rest } = props;
77
+ const { providerValue, frameAttrs, rovingFocusGroupAttrs } = (0, import_radio_headless.useRadioGroup)({
78
+ orientation,
79
+ name,
80
+ defaultValue,
81
+ value,
82
+ onValueChange,
83
+ required,
84
+ disabled,
85
+ native,
86
+ accentColor
87
+ });
88
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupContext.Provider, {
89
+ value: providerValue,
90
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup, {
91
+ ...rovingFocusGroupAttrs,
92
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupFrame, {
93
+ ...frameAttrs,
94
+ ref,
95
+ ...rest
96
+ })
97
+ })
98
+ });
99
+ });
100
+ const RadioGroupItem = (0, import_core.createStyledHOC)(RadioGroupItemFrame, (props, ref) => {
101
+ const { value, labelledBy, onPress, onKeyDown, disabled, id, ...rest } = props;
102
+ const { providerValue, bubbleInput, rovingFocusGroupAttrs, frameAttrs, isFormControl, native } = (0, import_radio_headless.useRadioGroupItem)({
103
+ radioGroupContext: RadioGroupContext,
104
+ value,
105
+ id,
106
+ labelledBy,
107
+ disabled,
108
+ onPress,
109
+ onKeyDown
110
+ });
111
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupItemContext.Provider, {
112
+ value: providerValue,
113
+ children: import_core.isWeb && native ? bubbleInput : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup.Item, {
114
+ ...rovingFocusGroupAttrs,
115
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupItemFrame, {
116
+ ...frameAttrs,
117
+ ref,
118
+ ...rest
119
+ })
120
+ }), isFormControl && bubbleInput] })
121
+ });
122
+ });
123
+ RadioGroupItem.displayName = "RadioGroupItem";
124
+ const RadioGroupIndicator = (0, import_core.createStyledHOC)(RadioGroupIndicatorFrame, (props, forwardedRef) => {
125
+ const { forceMount, disabled, ...indicatorProps } = props;
126
+ const { checked, ...useIndicatorRest } = (0, import_radio_headless.useRadioGroupItemIndicator)({
127
+ radioGroupItemContext: RadioGroupItemContext,
128
+ disabled
129
+ });
130
+ if (forceMount || checked) {
131
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupIndicatorFrame, {
132
+ ...useIndicatorRest,
133
+ ref: forwardedRef,
134
+ ...indicatorProps
135
+ });
136
+ }
137
+ return null;
138
+ });
139
+ RadioGroupIndicator.displayName = "RadioGroupIndicator";
140
+ const RadioGroup = (0, import_core.withStaticProperties)(RadioGroupComponent, {
141
+ Item: RadioGroupItem,
142
+ Indicator: RadioGroupIndicator
143
+ });
144
+ RadioGroup.displayName = "RadioGroup";
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+
3
+
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
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;
24
+ };
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
28
+ }) : target, mod));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var RadioGroup_exports = {};
31
+ __export(RadioGroup_exports, {
32
+ RadioGroup: () => RadioGroup,
33
+ RadioGroupContext: () => RadioGroupContext,
34
+ RadioGroupFrame: () => RadioGroupFrame,
35
+ RadioGroupIndicatorFrame: () => RadioGroupIndicatorFrame,
36
+ RadioGroupItemContext: () => RadioGroupItemContext,
37
+ RadioGroupItemFrame: () => RadioGroupItemFrame
38
+ });
39
+ module.exports = __toCommonJS(RadioGroup_exports);
40
+ var import_jsx_runtime = require("react/jsx-runtime");
41
+ var import_core = require("@tamagui/core");
42
+ var import_radio_headless = require("@tamagui/radio-headless");
43
+ var import_roving_focus = require("@tamagui/roving-focus");
44
+ var import_react = __toESM(require("react"), 1);
45
+ var RADIO_GROUP_ITEM_NAME = "RadioGroupItem";
46
+ var RadioGroupItemFrame = (0, import_core.styled)(import_core.View, {
47
+ displayName: RADIO_GROUP_ITEM_NAME,
48
+ render: "button",
49
+ alignItems: "center",
50
+ justifyContent: "center",
51
+ variants: { disabled: { true: {
52
+ pointerEvents: "none",
53
+ userSelect: "none"
54
+ } } }
55
+ });
56
+ var RADIO_GROUP_INDICATOR_NAME = "RadioGroupIndicator";
57
+ var RadioGroupIndicatorFrame = (0, import_core.styled)(import_core.View, { displayName: RADIO_GROUP_INDICATOR_NAME });
58
+ var RADIO_GROUP_NAME = "RadioGroup";
59
+ var RadioGroupFrame = (0, import_core.styled)(import_core.View, {
60
+ displayName: RADIO_GROUP_NAME,
61
+ variants: { orientation: {
62
+ horizontal: {
63
+ flexDirection: "row",
64
+ spaceDirection: "horizontal"
65
+ },
66
+ vertical: {
67
+ flexDirection: "column",
68
+ spaceDirection: "vertical"
69
+ }
70
+ } }
71
+ });
72
+ var RadioGroupContext = /* @__PURE__ */ import_react.default.createContext({});
73
+ var RadioGroupItemContext = /* @__PURE__ */ import_react.default.createContext({
74
+ checked: false,
75
+ disabled: false
76
+ });
77
+ var RadioGroupComponent = (0, import_core.createStyledHOC)(RadioGroupFrame, function(props, ref) {
78
+ var { value, defaultValue, onValueChange, required = false, disabled = false, name, native, accentColor, orientation = "vertical", ...rest } = props;
79
+ var { providerValue, frameAttrs, rovingFocusGroupAttrs } = (0, import_radio_headless.useRadioGroup)({
80
+ orientation,
81
+ name,
82
+ defaultValue,
83
+ value,
84
+ onValueChange,
85
+ required,
86
+ disabled,
87
+ native,
88
+ accentColor
89
+ });
90
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupContext.Provider, {
91
+ value: providerValue,
92
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup, {
93
+ ...rovingFocusGroupAttrs,
94
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupFrame, {
95
+ ...frameAttrs,
96
+ ref,
97
+ ...rest
98
+ })
99
+ })
100
+ });
101
+ });
102
+ var RadioGroupItem = (0, import_core.createStyledHOC)(RadioGroupItemFrame, function(props, ref) {
103
+ var { value, labelledBy, onPress, onKeyDown, disabled, id, ...rest } = props;
104
+ var { providerValue, bubbleInput, rovingFocusGroupAttrs, frameAttrs, isFormControl, native } = (0, import_radio_headless.useRadioGroupItem)({
105
+ radioGroupContext: RadioGroupContext,
106
+ value,
107
+ id,
108
+ labelledBy,
109
+ disabled,
110
+ onPress,
111
+ onKeyDown
112
+ });
113
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupItemContext.Provider, {
114
+ value: providerValue,
115
+ children: import_core.isWeb && native ? bubbleInput : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup.Item, {
116
+ ...rovingFocusGroupAttrs,
117
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupItemFrame, {
118
+ ...frameAttrs,
119
+ ref,
120
+ ...rest
121
+ })
122
+ }), isFormControl && bubbleInput] })
123
+ });
124
+ });
125
+ RadioGroupItem.displayName = "RadioGroupItem";
126
+ var RadioGroupIndicator = (0, import_core.createStyledHOC)(RadioGroupIndicatorFrame, function(props, forwardedRef) {
127
+ var { forceMount, disabled, ...indicatorProps } = props;
128
+ var { checked, ...useIndicatorRest } = (0, import_radio_headless.useRadioGroupItemIndicator)({
129
+ radioGroupItemContext: RadioGroupItemContext,
130
+ disabled
131
+ });
132
+ if (forceMount || checked) {
133
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupIndicatorFrame, {
134
+ ...useIndicatorRest,
135
+ ref: forwardedRef,
136
+ ...indicatorProps
137
+ });
138
+ }
139
+ return null;
140
+ });
141
+ RadioGroupIndicator.displayName = "RadioGroupIndicator";
142
+ var RadioGroup = (0, import_core.withStaticProperties)(RadioGroupComponent, {
143
+ Item: RadioGroupItem,
144
+ Indicator: RadioGroupIndicator
145
+ });
146
+ RadioGroup.displayName = "RadioGroup";
@@ -1,138 +1,148 @@
1
1
  "use strict";
2
2
 
3
+
4
+ var __create = Object.create;
3
5
  var __defProp = Object.defineProperty;
4
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
6
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
10
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
12
15
  };
13
16
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- 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;
21
24
  };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
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
28
+ }) : target, mod));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
30
  var RadioGroup_exports = {};
26
31
  __export(RadioGroup_exports, {
27
- RadioGroupFrame: () => RadioGroupFrame,
28
- RadioGroupIndicatorFrame: () => RadioGroupIndicatorFrame,
29
- RadioGroupItemFrame: () => RadioGroupItemFrame
32
+ RadioGroup: () => RadioGroup,
33
+ RadioGroupContext: () => RadioGroupContext,
34
+ RadioGroupFrame: () => RadioGroupFrame,
35
+ RadioGroupIndicatorFrame: () => RadioGroupIndicatorFrame,
36
+ RadioGroupItemContext: () => RadioGroupItemContext,
37
+ RadioGroupItemFrame: () => RadioGroupItemFrame
30
38
  });
31
39
  module.exports = __toCommonJS(RadioGroup_exports);
40
+ var import_jsx_runtime = require("react/jsx-runtime");
32
41
  var import_core = require("@tamagui/core");
33
- var import_get_token = require("@tamagui/get-token");
34
- var import_stacks = require("@tamagui/stacks");
42
+ var import_radio_headless = require("@tamagui/radio-headless");
43
+ var import_roving_focus = require("@tamagui/roving-focus");
44
+ var import_react = __toESM(require("react"), 1);
35
45
  var RADIO_GROUP_ITEM_NAME = "RadioGroupItem";
36
- var RadioGroupItemFrame = (0, import_core.styled)(import_stacks.YStack, {
37
- name: RADIO_GROUP_ITEM_NAME,
38
- render: "button",
39
- variants: {
40
- unstyled: {
41
- false: {
42
- size: "$true",
43
- borderRadius: 1e3,
44
- backgroundColor: "$background",
45
- alignItems: "center",
46
- justifyContent: "center",
47
- borderWidth: 1,
48
- borderColor: "$borderColor",
49
- padding: 0,
50
- hoverStyle: {
51
- borderColor: "$borderColorHover",
52
- backgroundColor: "$backgroundHover"
53
- },
54
- focusStyle: {
55
- borderColor: "$borderColorHover",
56
- backgroundColor: "$backgroundHover"
57
- },
58
- focusVisibleStyle: {
59
- outlineStyle: "solid",
60
- outlineWidth: 2,
61
- outlineColor: "$outlineColor"
62
- },
63
- pressStyle: {
64
- borderColor: "$borderColorFocus",
65
- backgroundColor: "$backgroundFocus"
66
- }
67
- }
68
- },
69
- disabled: {
70
- true: {
71
- pointerEvents: "none",
72
- userSelect: "none",
73
- cursor: "not-allowed",
74
- hoverStyle: {
75
- borderColor: "$borderColor",
76
- backgroundColor: "$background"
77
- },
78
- pressStyle: {
79
- borderColor: "$borderColor",
80
- backgroundColor: "$background"
81
- },
82
- focusVisibleStyle: {
83
- outlineWidth: 0
84
- }
85
- }
86
- },
87
- size: {
88
- "...size": function (value, param) {
89
- var {
90
- props
91
- } = param;
92
- var _props_scaleSize;
93
- var size = Math.floor((0, import_core.getVariableValue)((0, import_get_token.getSize)(value)) * ((_props_scaleSize = props["scaleSize"]) !== null && _props_scaleSize !== void 0 ? _props_scaleSize : 0.5));
94
- return {
95
- width: size,
96
- height: size
97
- };
98
- }
99
- }
100
- },
101
- defaultVariants: {
102
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
103
- }
46
+ var RadioGroupItemFrame = (0, import_core.styled)(import_core.View, {
47
+ displayName: RADIO_GROUP_ITEM_NAME,
48
+ render: "button",
49
+ alignItems: "center",
50
+ justifyContent: "center",
51
+ variants: { disabled: { true: {
52
+ pointerEvents: "none",
53
+ userSelect: "none"
54
+ } } }
104
55
  });
105
56
  var RADIO_GROUP_INDICATOR_NAME = "RadioGroupIndicator";
106
- var RadioGroupIndicatorFrame = (0, import_core.styled)(import_stacks.YStack, {
107
- name: RADIO_GROUP_INDICATOR_NAME,
108
- variants: {
109
- unstyled: {
110
- false: {
111
- width: "33%",
112
- height: "33%",
113
- borderRadius: 1e3,
114
- backgroundColor: "$color"
115
- }
116
- }
117
- },
118
- defaultVariants: {
119
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
120
- }
121
- });
57
+ var RadioGroupIndicatorFrame = (0, import_core.styled)(import_core.View, { displayName: RADIO_GROUP_INDICATOR_NAME });
122
58
  var RADIO_GROUP_NAME = "RadioGroup";
123
- var RadioGroupFrame = (0, import_core.styled)(import_stacks.YStack, {
124
- name: RADIO_GROUP_NAME,
125
- variants: {
126
- orientation: {
127
- horizontal: {
128
- flexDirection: "row",
129
- spaceDirection: "horizontal"
130
- },
131
- vertical: {
132
- flexDirection: "column",
133
- spaceDirection: "vertical"
134
- }
135
- }
136
- }
59
+ var RadioGroupFrame = (0, import_core.styled)(import_core.View, {
60
+ displayName: RADIO_GROUP_NAME,
61
+ variants: { orientation: {
62
+ horizontal: {
63
+ flexDirection: "row",
64
+ spaceDirection: "horizontal"
65
+ },
66
+ vertical: {
67
+ flexDirection: "column",
68
+ spaceDirection: "vertical"
69
+ }
70
+ } }
71
+ });
72
+ var RadioGroupContext = /* @__PURE__ */ import_react.default.createContext({});
73
+ var RadioGroupItemContext = /* @__PURE__ */ import_react.default.createContext({
74
+ checked: false,
75
+ disabled: false
76
+ });
77
+ var RadioGroupComponent = (0, import_core.createStyledHOC)(RadioGroupFrame, function(props, ref) {
78
+ var { value, defaultValue, onValueChange, required = false, disabled = false, name, native, accentColor, orientation = "vertical", ...rest } = props;
79
+ var { providerValue, frameAttrs, rovingFocusGroupAttrs } = (0, import_radio_headless.useRadioGroup)({
80
+ orientation,
81
+ name,
82
+ defaultValue,
83
+ value,
84
+ onValueChange,
85
+ required,
86
+ disabled,
87
+ native,
88
+ accentColor
89
+ });
90
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupContext.Provider, {
91
+ value: providerValue,
92
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup, {
93
+ ...rovingFocusGroupAttrs,
94
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupFrame, {
95
+ ...frameAttrs,
96
+ ref,
97
+ ...rest
98
+ })
99
+ })
100
+ });
137
101
  });
102
+ var RadioGroupItem = (0, import_core.createStyledHOC)(RadioGroupItemFrame, function(props, ref) {
103
+ var { value, labelledBy, onPress, onKeyDown, disabled, id, ...rest } = props;
104
+ var { providerValue, bubbleInput, rovingFocusGroupAttrs, frameAttrs, isFormControl, native } = (0, import_radio_headless.useRadioGroupItem)({
105
+ radioGroupContext: RadioGroupContext,
106
+ value,
107
+ id,
108
+ labelledBy,
109
+ disabled,
110
+ onPress,
111
+ onKeyDown
112
+ });
113
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupItemContext.Provider, {
114
+ value: providerValue,
115
+ children: import_core.isWeb && native ? bubbleInput : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup.Item, {
116
+ ...rovingFocusGroupAttrs,
117
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupItemFrame, {
118
+ ...frameAttrs,
119
+ ref,
120
+ ...rest
121
+ })
122
+ }), isFormControl && bubbleInput] })
123
+ });
124
+ });
125
+ RadioGroupItem.displayName = "RadioGroupItem";
126
+ var RadioGroupIndicator = (0, import_core.createStyledHOC)(RadioGroupIndicatorFrame, function(props, forwardedRef) {
127
+ var { forceMount, disabled, ...indicatorProps } = props;
128
+ var { checked, ...useIndicatorRest } = (0, import_radio_headless.useRadioGroupItemIndicator)({
129
+ radioGroupItemContext: RadioGroupItemContext,
130
+ disabled
131
+ });
132
+ if (forceMount || checked) {
133
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupIndicatorFrame, {
134
+ ...useIndicatorRest,
135
+ ref: forwardedRef,
136
+ ...indicatorProps
137
+ });
138
+ }
139
+ return null;
140
+ });
141
+ RadioGroupIndicator.displayName = "RadioGroupIndicator";
142
+ var RadioGroup = (0, import_core.withStaticProperties)(RadioGroupComponent, {
143
+ Item: RadioGroupItem,
144
+ Indicator: RadioGroupIndicator
145
+ });
146
+ RadioGroup.displayName = "RadioGroup";
147
+
138
148
  //# sourceMappingURL=RadioGroup.native.js.map