@tamagui/radio-group 1.4.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.
@@ -0,0 +1,382 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], 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", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var RadioGroup_exports = {};
30
+ __export(RadioGroup_exports, {
31
+ RadioGroup: () => RadioGroup,
32
+ createRadioGroupScope: () => createRadioGroupScope
33
+ });
34
+ module.exports = __toCommonJS(RadioGroup_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_react_use_previous = require("@radix-ui/react-use-previous");
37
+ var import_core = require("@tamagui/core");
38
+ var import_create_context = require("@tamagui/create-context");
39
+ var import_focusable = require("@tamagui/focusable");
40
+ var import_get_size = require("@tamagui/get-size");
41
+ var import_label = require("@tamagui/label");
42
+ var import_stacks = require("@tamagui/stacks");
43
+ var import_use_controllable_state = require("@tamagui/use-controllable-state");
44
+ var React = __toESM(require("react"));
45
+ const RADIO_GROUP_NAME = "RadioGroup";
46
+ const ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
47
+ const [createRadioGroupContext, createRadioGroupScope] = (0, import_create_context.createContextScope)(RADIO_GROUP_NAME);
48
+ const [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME);
49
+ const getState = (checked) => {
50
+ return checked ? "checked" : "unchecked";
51
+ };
52
+ const RADIO_GROUP_INDICATOR_NAME = "RadioGroupIndicator";
53
+ const RadioIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
54
+ name: RADIO_GROUP_INDICATOR_NAME,
55
+ pointerEvents: "none",
56
+ variants: {
57
+ unstyled: {
58
+ false: {
59
+ w: "60%",
60
+ h: "60%",
61
+ br: 1e3,
62
+ backgroundColor: "$color"
63
+ }
64
+ }
65
+ },
66
+ defaultVariants: {
67
+ unstyled: false
68
+ }
69
+ });
70
+ const RadioIndicator = RadioIndicatorFrame.extractable(
71
+ React.forwardRef(
72
+ (props, forwardedRef) => {
73
+ const { __scopeRadioGroupItem, forceMount, disabled, ...indicatorProps } = props;
74
+ const { checked } = useRadioGroupItemContext(
75
+ RADIO_GROUP_INDICATOR_NAME,
76
+ __scopeRadioGroupItem
77
+ );
78
+ if (forceMount || checked) {
79
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
+ RadioIndicatorFrame,
81
+ {
82
+ theme: "active",
83
+ "data-state": getState(checked),
84
+ "data-disabled": disabled ? "" : void 0,
85
+ ...indicatorProps,
86
+ ref: forwardedRef
87
+ }
88
+ );
89
+ }
90
+ return null;
91
+ }
92
+ )
93
+ );
94
+ RadioIndicator.displayName = RADIO_GROUP_INDICATOR_NAME;
95
+ const RADIO_GROUP_ITEM_NAME = "RadioGroupItem";
96
+ const [RadioGroupItemProvider, useRadioGroupItemContext] = createRadioGroupContext(RADIO_GROUP_NAME);
97
+ const RadioGroupItemFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
98
+ name: RADIO_GROUP_ITEM_NAME,
99
+ tag: "button",
100
+ debug: "verbose",
101
+ variants: {
102
+ unstyled: {
103
+ false: {
104
+ borderRadius: 9999,
105
+ backgroundColor: "$background",
106
+ alignItems: "center",
107
+ justifyContent: "center",
108
+ borderWidth: 2,
109
+ borderColor: "transparent",
110
+ focusStyle: {
111
+ borderColor: "$borderColorFocus"
112
+ }
113
+ }
114
+ },
115
+ size: {
116
+ "...size": (value, { props }) => {
117
+ const size = Math.floor(
118
+ (0, import_core.getVariableValue)((0, import_get_size.getSize)(value)) * (props["scaleSize"] ?? 0.5)
119
+ );
120
+ return {
121
+ width: size,
122
+ height: size
123
+ };
124
+ }
125
+ }
126
+ },
127
+ defaultVariants: {
128
+ size: "$true",
129
+ unstyled: false
130
+ }
131
+ });
132
+ const RadioGroupItem = RadioGroupItemFrame.extractable(
133
+ React.forwardRef(
134
+ (props, forwardedRef) => {
135
+ const {
136
+ __scopeRadioGroup,
137
+ value,
138
+ labelledBy: ariaLabelledby,
139
+ disabled: itemDisabled,
140
+ ...itemProps
141
+ } = props;
142
+ const {
143
+ value: groupValue,
144
+ disabled,
145
+ required,
146
+ onChange,
147
+ name,
148
+ native,
149
+ accentColor
150
+ } = useRadioGroupContext(RADIO_GROUP_ITEM_NAME, __scopeRadioGroup);
151
+ const [button, setButton] = React.useState(null);
152
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
153
+ const ref = React.useRef(null);
154
+ const composedRefs = (0, import_core.useComposedRefs)(forwardedRef, (node) => setButton(node), ref);
155
+ const isArrowKeyPressedRef = React.useRef(false);
156
+ const isFormControl = import_core.isWeb ? button ? Boolean(button.closest("form")) : true : false;
157
+ const checked = groupValue === value;
158
+ const labelId = (0, import_label.useLabelContext)(button);
159
+ const labelledBy = ariaLabelledby || labelId;
160
+ React.useEffect(() => {
161
+ if (import_core.isWeb) {
162
+ const handleKeyDown = (event) => {
163
+ if (ARROW_KEYS.includes(event.key)) {
164
+ isArrowKeyPressedRef.current = true;
165
+ }
166
+ };
167
+ const handleKeyUp = () => isArrowKeyPressedRef.current = false;
168
+ document.addEventListener("keydown", handleKeyDown);
169
+ document.addEventListener("keyup", handleKeyUp);
170
+ return () => {
171
+ document.removeEventListener("keydown", handleKeyDown);
172
+ document.removeEventListener("keyup", handleKeyUp);
173
+ };
174
+ }
175
+ }, []);
176
+ if (process.env.TAMAGUI_TARGET === "native") {
177
+ React.useEffect(() => {
178
+ if (!props.id)
179
+ return;
180
+ return (0, import_focusable.registerFocusable)(props.id, {
181
+ focusAndSelect: () => {
182
+ onChange == null ? void 0 : onChange(value);
183
+ },
184
+ focus: () => {
185
+ }
186
+ });
187
+ }, [props.id, value]);
188
+ }
189
+ const isDisabled = disabled || itemDisabled;
190
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupItemProvider, { checked, scope: __scopeRadioGroup, children: import_core.isWeb && native ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
191
+ BubbleInput,
192
+ {
193
+ control: button,
194
+ bubbles: !hasConsumerStoppedPropagationRef.current,
195
+ name,
196
+ value,
197
+ checked,
198
+ required,
199
+ disabled: isDisabled,
200
+ id: props.id,
201
+ accentColor
202
+ }
203
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
204
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
205
+ RadioGroupItemFrame,
206
+ {
207
+ "data-state": getState(checked),
208
+ "data-disabled": isDisabled ? "" : void 0,
209
+ role: "radio",
210
+ "aria-labelledby": labelledBy,
211
+ "aria-checked": checked,
212
+ "aria-required": required,
213
+ disabled: isDisabled,
214
+ ref: composedRefs,
215
+ ...import_core.isWeb && {
216
+ type: "button",
217
+ value
218
+ },
219
+ ...itemProps,
220
+ onPress: (0, import_core.composeEventHandlers)(props.onPress, (event) => {
221
+ if (!checked) {
222
+ onChange == null ? void 0 : onChange(value);
223
+ }
224
+ if (isFormControl) {
225
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
226
+ if (!hasConsumerStoppedPropagationRef.current)
227
+ event.stopPropagation();
228
+ }
229
+ }),
230
+ ...import_core.isWeb && {
231
+ onKeyDown: (0, import_core.composeEventHandlers)(
232
+ props.onKeyDown,
233
+ (event) => {
234
+ if (event.key === "Enter")
235
+ event.preventDefault();
236
+ }
237
+ ),
238
+ onFocus: (0, import_core.composeEventHandlers)(itemProps.onFocus, () => {
239
+ var _a;
240
+ if (isArrowKeyPressedRef.current)
241
+ (_a = ref.current) == null ? void 0 : _a.click();
242
+ })
243
+ }
244
+ }
245
+ ),
246
+ isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
247
+ BubbleInput,
248
+ {
249
+ isHidden: true,
250
+ control: button,
251
+ bubbles: !hasConsumerStoppedPropagationRef.current,
252
+ name,
253
+ value,
254
+ checked,
255
+ required,
256
+ disabled: isDisabled
257
+ }
258
+ )
259
+ ] }) });
260
+ }
261
+ )
262
+ );
263
+ const BubbleInput = (props) => {
264
+ const { checked, bubbles = true, control, isHidden, accentColor, ...inputProps } = props;
265
+ const ref = React.useRef(null);
266
+ const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
267
+ React.useEffect(() => {
268
+ const input = ref.current;
269
+ const inputProto = window.HTMLInputElement.prototype;
270
+ const descriptor = Object.getOwnPropertyDescriptor(
271
+ inputProto,
272
+ "checked"
273
+ );
274
+ const setChecked = descriptor.set;
275
+ if (prevChecked !== checked && setChecked) {
276
+ const event = new Event("click", { bubbles });
277
+ setChecked.call(input, checked);
278
+ input.dispatchEvent(event);
279
+ }
280
+ }, [prevChecked, checked, bubbles]);
281
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
282
+ "input",
283
+ {
284
+ type: "radio",
285
+ defaultChecked: checked,
286
+ ...inputProps,
287
+ tabIndex: -1,
288
+ ref,
289
+ "aria-hidden": isHidden,
290
+ style: {
291
+ ...isHidden ? {
292
+ // ...controlSize,
293
+ position: "absolute",
294
+ pointerEvents: "none",
295
+ opacity: 0,
296
+ margin: 0
297
+ } : {
298
+ appearance: "auto",
299
+ accentColor
300
+ },
301
+ ...props.style
302
+ }
303
+ }
304
+ );
305
+ };
306
+ const RadioGroupFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
307
+ name: RADIO_GROUP_NAME,
308
+ variants: {
309
+ orientation: {
310
+ horizontal: {
311
+ flexDirection: "row",
312
+ spaceDirection: "horizontal"
313
+ },
314
+ vertical: {
315
+ flexDirection: "column",
316
+ spaceDirection: "vertical"
317
+ }
318
+ }
319
+ }
320
+ });
321
+ const RadioGroup = (0, import_core.withStaticProperties)(
322
+ RadioGroupFrame.extractable(
323
+ React.forwardRef(
324
+ (props, forwardedRef) => {
325
+ const {
326
+ __scopeRadioGroup,
327
+ value: valueProp,
328
+ defaultValue,
329
+ onValueChange,
330
+ disabled = false,
331
+ required = false,
332
+ name,
333
+ orientation,
334
+ native,
335
+ accentColor,
336
+ ...radioGroupProps
337
+ } = props;
338
+ const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
339
+ prop: valueProp,
340
+ defaultProp: defaultValue,
341
+ onChange: onValueChange
342
+ });
343
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
344
+ RadioGroupProvider,
345
+ {
346
+ scope: __scopeRadioGroup,
347
+ value,
348
+ required,
349
+ onChange: setValue,
350
+ disabled,
351
+ name,
352
+ native,
353
+ accentColor,
354
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
355
+ RadioGroupFrame,
356
+ {
357
+ "aria-valuetext": value,
358
+ role: "radiogroup",
359
+ "aria-orientation": orientation,
360
+ ref: forwardedRef,
361
+ orientation,
362
+ "data-disabled": disabled ? "" : void 0,
363
+ ...radioGroupProps
364
+ }
365
+ )
366
+ }
367
+ );
368
+ }
369
+ )
370
+ ),
371
+ {
372
+ Indicator: RadioIndicator,
373
+ Item: RadioGroupItem
374
+ }
375
+ );
376
+ RadioGroup.displayName = RADIO_GROUP_NAME;
377
+ // Annotate the CommonJS export names for ESM import in node:
378
+ 0 && (module.exports = {
379
+ RadioGroup,
380
+ createRadioGroupScope
381
+ });
382
+ //# sourceMappingURL=RadioGroup.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/RadioGroup.tsx"],
4
+ "sourcesContent": ["// forked from Radix UI\n// https://github.com/radix-ui/primitives/blob/main/packages/react/radio-group/src/RadioGroup.tsx\n\nimport { usePrevious } from '@radix-ui/react-use-previous'\nimport {\n GetProps,\n composeEventHandlers,\n getVariableValue,\n isWeb,\n styled,\n useComposedRefs,\n withStaticProperties,\n} from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { registerFocusable } from '@tamagui/focusable'\nimport { getSize, stepTokenUpOrDown } from '@tamagui/get-size'\nimport { useLabelContext } from '@tamagui/label'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst RADIO_GROUP_NAME = 'RadioGroup'\n\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']\n\nconst [createRadioGroupContext, createRadioGroupScope] =\n createContextScope(RADIO_GROUP_NAME)\ntype RadioGroupContextValue = {\n value?: string\n disabled?: boolean\n required?: boolean\n onChange?: (value: string) => void\n name?: string\n native?: boolean\n accentColor?: string\n}\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContext<RadioGroupContextValue>(RADIO_GROUP_NAME)\n\nconst getState = (checked: boolean) => {\n return checked ? 'checked' : 'unchecked'\n}\n\n/* -------------------------------------------------------------------------\n * RadioIndicator\n * ------------------------------------------------------------------------ */\n\nconst RADIO_GROUP_INDICATOR_NAME = 'RadioGroupIndicator'\n\nconst RadioIndicatorFrame = styled(ThemeableStack, {\n name: RADIO_GROUP_INDICATOR_NAME,\n pointerEvents: 'none',\n\n variants: {\n unstyled: {\n false: {\n w: '60%',\n h: '60%',\n br: 1000,\n backgroundColor: '$color',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\ntype RadioIndicatorProps = GetProps<typeof RadioIndicatorFrame> & {\n forceMount?: boolean\n unstyled?: boolean\n}\n\ntype RadioIndicatorElement = TamaguiElement\n\nconst RadioIndicator = RadioIndicatorFrame.extractable(\n React.forwardRef<RadioIndicatorElement, RadioIndicatorProps>(\n (props: ScopedRadioGroupItemProps<RadioIndicatorProps>, forwardedRef) => {\n const { __scopeRadioGroupItem, forceMount, disabled, ...indicatorProps } = props\n const { checked } = useRadioGroupItemContext(\n RADIO_GROUP_INDICATOR_NAME,\n __scopeRadioGroupItem\n )\n\n if (forceMount || checked) {\n return (\n <RadioIndicatorFrame\n theme=\"active\"\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n />\n )\n }\n\n return null\n }\n )\n)\n\nRadioIndicator.displayName = RADIO_GROUP_INDICATOR_NAME\n\n/* -------------------------------------------------------------------------\n * RadioGroupItem\n * ------------------------------------------------------------------------ */\n\nconst RADIO_GROUP_ITEM_NAME = 'RadioGroupItem'\n\ntype RadioGroupItemContextValue = {\n checked: boolean\n disabled?: boolean\n}\n\nconst [RadioGroupItemProvider, useRadioGroupItemContext] =\n createRadioGroupContext<RadioGroupItemContextValue>(RADIO_GROUP_NAME)\n\nconst RadioGroupItemFrame = styled(ThemeableStack, {\n name: RADIO_GROUP_ITEM_NAME,\n tag: 'button',\n debug: 'verbose',\n\n variants: {\n unstyled: {\n false: {\n borderRadius: 9999,\n backgroundColor: '$background',\n alignItems: 'center',\n justifyContent: 'center',\n borderWidth: 2,\n borderColor: 'transparent',\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n },\n },\n\n size: {\n '...size': (value, { props }) => {\n const size = Math.floor(\n getVariableValue(getSize(value)) * (props['scaleSize'] ?? 0.5)\n )\n return {\n width: size,\n height: size,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$true',\n unstyled: false,\n },\n})\n\ntype RadioGroupItemProps = GetProps<typeof RadioGroupItemFrame> & {\n value: string\n id?: string\n labelledBy?: string\n disabled?: boolean\n}\n\ntype RadioGroupItemElement = HTMLButtonElement\n\ntype ScopedRadioGroupItemProps<P> = P & {\n __scopeRadioGroupItem?: Scope\n}\n\nconst RadioGroupItem = RadioGroupItemFrame.extractable(\n React.forwardRef<RadioGroupItemElement, RadioGroupItemProps>(\n (props: ScopedProps<RadioGroupItemProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n value,\n labelledBy: ariaLabelledby,\n disabled: itemDisabled,\n ...itemProps\n } = props\n const {\n value: groupValue,\n disabled,\n required,\n onChange,\n name,\n native,\n accentColor,\n } = useRadioGroupContext(RADIO_GROUP_ITEM_NAME, __scopeRadioGroup)\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null)\n const hasConsumerStoppedPropagationRef = React.useRef(false)\n const ref = React.useRef<HTMLButtonElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node), ref)\n const isArrowKeyPressedRef = React.useRef(false)\n\n const isFormControl = isWeb\n ? button\n ? Boolean(button.closest('form'))\n : true\n : false\n\n const checked = groupValue === value\n\n const labelId = useLabelContext(button)\n const labelledBy = ariaLabelledby || labelId\n\n React.useEffect(() => {\n if (isWeb) {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (ARROW_KEYS.includes(event.key)) {\n isArrowKeyPressedRef.current = true\n }\n }\n const handleKeyUp = () => (isArrowKeyPressedRef.current = false)\n document.addEventListener('keydown', handleKeyDown)\n document.addEventListener('keyup', handleKeyUp)\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n document.removeEventListener('keyup', handleKeyUp)\n }\n }\n }, [])\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (!props.id) return\n return registerFocusable(props.id, {\n focusAndSelect: () => {\n onChange?.(value)\n },\n focus: () => {},\n })\n }, [props.id, value])\n }\n\n const isDisabled = disabled || itemDisabled\n\n return (\n <RadioGroupItemProvider checked={checked} scope={__scopeRadioGroup}>\n {isWeb && native ? (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={isDisabled}\n id={props.id}\n accentColor={accentColor}\n />\n ) : (\n <>\n <RadioGroupItemFrame\n // theme={checked ? 'active' : undefined}\n data-state={getState(checked)}\n data-disabled={isDisabled ? '' : undefined}\n role=\"radio\"\n aria-labelledby={labelledBy}\n aria-checked={checked}\n aria-required={required}\n disabled={isDisabled}\n ref={composedRefs}\n {...(isWeb && {\n type: 'button',\n value: value,\n })}\n // allow them to override all but the handlers that already compose:\n {...itemProps}\n onPress={composeEventHandlers(props.onPress as any, (event) => {\n if (!checked) {\n onChange?.(value)\n }\n\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current =\n event.isPropagationStopped()\n // if radio is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation()\n }\n })}\n {...(isWeb && {\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n // According to WAI ARIA, Checkboxes don't activate on enter keypress\n if (event.key === 'Enter') event.preventDefault()\n }\n ),\n onFocus: composeEventHandlers(itemProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with arrow keys\n * and we need to \"check\" it in that case. We click it to \"check\" it (instead\n * of updating `context.value`) so that the radio change event fires.\n */\n if (isArrowKeyPressedRef.current)\n (ref.current as HTMLButtonElement)?.click()\n }),\n })}\n />\n {isFormControl && (\n <BubbleInput\n isHidden\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={isDisabled}\n />\n )}\n </>\n )}\n </RadioGroupItemProvider>\n )\n }\n )\n)\n\n/* -------------------------------------------------------------------------\n * BubbleInput\n * ------------------------------------------------------------------------ */\n\ninterface BubbleInputProps extends Omit<React.HTMLProps<HTMLInputElement>, 'checked'> {\n checked: boolean\n control: HTMLElement | null\n bubbles: boolean\n isHidden?: boolean\n accentColor?: string\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { checked, bubbles = true, control, isHidden, accentColor, ...inputProps } = props\n const ref = React.useRef<HTMLInputElement>(null)\n const prevChecked = usePrevious(checked)\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!\n const inputProto = window.HTMLInputElement.prototype\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked'\n ) as PropertyDescriptor\n const setChecked = descriptor.set\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles })\n setChecked.call(input, checked)\n input.dispatchEvent(event)\n }\n }, [prevChecked, checked, bubbles])\n\n return (\n <input\n type=\"radio\"\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n aria-hidden={isHidden}\n style={{\n ...(isHidden\n ? {\n // ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }\n : {\n appearance: 'auto',\n accentColor,\n }),\n\n ...props.style,\n }}\n />\n )\n}\n\n/* -------------------------------------------------------------------------\n * RadioGroup\n * ----------------------------------------------------------------------- */\n\ntype ScopedProps<P> = P & { __scopeRadioGroup?: Scope }\n\ntype TamaguiElement = HTMLElement | View\n\ntype RadioGroupElement = TamaguiElement\n\nconst RadioGroupFrame = styled(ThemeableStack, {\n name: RADIO_GROUP_NAME,\n\n variants: {\n orientation: {\n horizontal: {\n flexDirection: 'row',\n spaceDirection: 'horizontal',\n },\n vertical: {\n flexDirection: 'column',\n spaceDirection: 'vertical',\n },\n },\n } as const,\n})\n\ntype RadioGroupProps = GetProps<typeof RadioGroupFrame> & {\n value?: string\n defaultValue?: string\n onValueChange?: (value: string) => void\n required?: boolean\n disabled?: boolean\n name?: string\n native?: boolean\n accentColor?: string\n}\n\nconst RadioGroup = withStaticProperties(\n RadioGroupFrame.extractable(\n React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n value: valueProp,\n defaultValue,\n onValueChange,\n disabled = false,\n required = false,\n name,\n orientation,\n native,\n accentColor,\n ...radioGroupProps\n } = props\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue!,\n onChange: onValueChange,\n })\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n value={value}\n required={required}\n onChange={setValue}\n disabled={disabled}\n name={name}\n native={native}\n accentColor={accentColor}\n >\n <RadioGroupFrame\n aria-valuetext={value}\n role=\"radiogroup\"\n aria-orientation={orientation}\n ref={forwardedRef}\n orientation={orientation}\n data-disabled={disabled ? '' : undefined}\n {...radioGroupProps}\n />\n </RadioGroupProvider>\n )\n }\n )\n ),\n {\n Indicator: RadioIndicator,\n Item: RadioGroupItem,\n }\n)\n\nRadioGroup.displayName = RADIO_GROUP_NAME\n\nexport { createRadioGroupScope, RadioGroup }\nexport type { RadioGroupProps }\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwFU;AArFV,gCAA4B;AAC5B,kBAQO;AACP,4BAA0C;AAC1C,uBAAkC;AAClC,sBAA2C;AAC3C,mBAAgC;AAChC,oBAA+B;AAC/B,oCAAqC;AACrC,YAAuB;AAGvB,MAAM,mBAAmB;AAEzB,MAAM,aAAa,CAAC,WAAW,aAAa,aAAa,YAAY;AAErE,MAAM,CAAC,yBAAyB,qBAAqB,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kB;AAAA,gBAClB,KAAK;AAAA,gBACL;AAAA,gBACA,iBAAe,WAAW,KAAK;AAAA,gBAC9B,GAAG;AAAA;AAAA,YACN;AAAA;AAAA,QACF;AAAA,MAEJ;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,MAAM;AAAA,EACR;AACF;AAEA,WAAW,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./RadioGroup"), module.exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './RadioGroup'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,yBAAd;",
6
+ "names": []
7
+ }