@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,330 @@
1
+ import { usePrevious } from "@radix-ui/react-use-previous";
2
+ import {
3
+ composeEventHandlers,
4
+ getVariableValue,
5
+ isWeb,
6
+ styled,
7
+ useComposedRefs,
8
+ withStaticProperties
9
+ } from "@tamagui/core";
10
+ import { createContextScope } from "@tamagui/create-context";
11
+ import { registerFocusable } from "@tamagui/focusable";
12
+ import { getSize } from "@tamagui/get-size";
13
+ import { useLabelContext } from "@tamagui/label";
14
+ import { ThemeableStack } from "@tamagui/stacks";
15
+ import { useControllableState } from "@tamagui/use-controllable-state";
16
+ import * as React from "react";
17
+ const RADIO_GROUP_NAME = "RadioGroup";
18
+ const ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
19
+ const [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME);
20
+ const [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME);
21
+ const getState = (checked) => {
22
+ return checked ? "checked" : "unchecked";
23
+ };
24
+ const RADIO_GROUP_INDICATOR_NAME = "RadioGroupIndicator";
25
+ const RadioIndicatorFrame = styled(ThemeableStack, {
26
+ name: RADIO_GROUP_INDICATOR_NAME,
27
+ pointerEvents: "none",
28
+ variants: {
29
+ unstyled: {
30
+ false: {
31
+ w: "60%",
32
+ h: "60%",
33
+ br: 1e3,
34
+ backgroundColor: "$color"
35
+ }
36
+ }
37
+ },
38
+ defaultVariants: {
39
+ unstyled: false
40
+ }
41
+ });
42
+ const RadioIndicator = RadioIndicatorFrame.extractable(
43
+ React.forwardRef(
44
+ (props, forwardedRef) => {
45
+ const { __scopeRadioGroupItem, forceMount, disabled, ...indicatorProps } = props;
46
+ const { checked } = useRadioGroupItemContext(
47
+ RADIO_GROUP_INDICATOR_NAME,
48
+ __scopeRadioGroupItem
49
+ );
50
+ if (forceMount || checked) {
51
+ return <RadioIndicatorFrame
52
+ theme="active"
53
+ data-state={getState(checked)}
54
+ data-disabled={disabled ? "" : void 0}
55
+ {...indicatorProps}
56
+ ref={forwardedRef}
57
+ />;
58
+ }
59
+ return null;
60
+ }
61
+ )
62
+ );
63
+ RadioIndicator.displayName = RADIO_GROUP_INDICATOR_NAME;
64
+ const RADIO_GROUP_ITEM_NAME = "RadioGroupItem";
65
+ const [RadioGroupItemProvider, useRadioGroupItemContext] = createRadioGroupContext(RADIO_GROUP_NAME);
66
+ const RadioGroupItemFrame = styled(ThemeableStack, {
67
+ name: RADIO_GROUP_ITEM_NAME,
68
+ tag: "button",
69
+ debug: "verbose",
70
+ variants: {
71
+ unstyled: {
72
+ false: {
73
+ borderRadius: 9999,
74
+ backgroundColor: "$background",
75
+ alignItems: "center",
76
+ justifyContent: "center",
77
+ borderWidth: 2,
78
+ borderColor: "transparent",
79
+ focusStyle: {
80
+ borderColor: "$borderColorFocus"
81
+ }
82
+ }
83
+ },
84
+ size: {
85
+ "...size": (value, { props }) => {
86
+ const size = Math.floor(
87
+ getVariableValue(getSize(value)) * (props["scaleSize"] ?? 0.5)
88
+ );
89
+ return {
90
+ width: size,
91
+ height: size
92
+ };
93
+ }
94
+ }
95
+ },
96
+ defaultVariants: {
97
+ size: "$true",
98
+ unstyled: false
99
+ }
100
+ });
101
+ const RadioGroupItem = RadioGroupItemFrame.extractable(
102
+ React.forwardRef(
103
+ (props, forwardedRef) => {
104
+ const {
105
+ __scopeRadioGroup,
106
+ value,
107
+ labelledBy: ariaLabelledby,
108
+ disabled: itemDisabled,
109
+ ...itemProps
110
+ } = props;
111
+ const {
112
+ value: groupValue,
113
+ disabled,
114
+ required,
115
+ onChange,
116
+ name,
117
+ native,
118
+ accentColor
119
+ } = useRadioGroupContext(RADIO_GROUP_ITEM_NAME, __scopeRadioGroup);
120
+ const [button, setButton] = React.useState(null);
121
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
122
+ const ref = React.useRef(null);
123
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node), ref);
124
+ const isArrowKeyPressedRef = React.useRef(false);
125
+ const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
126
+ const checked = groupValue === value;
127
+ const labelId = useLabelContext(button);
128
+ const labelledBy = ariaLabelledby || labelId;
129
+ React.useEffect(() => {
130
+ if (isWeb) {
131
+ const handleKeyDown = (event) => {
132
+ if (ARROW_KEYS.includes(event.key)) {
133
+ isArrowKeyPressedRef.current = true;
134
+ }
135
+ };
136
+ const handleKeyUp = () => isArrowKeyPressedRef.current = false;
137
+ document.addEventListener("keydown", handleKeyDown);
138
+ document.addEventListener("keyup", handleKeyUp);
139
+ return () => {
140
+ document.removeEventListener("keydown", handleKeyDown);
141
+ document.removeEventListener("keyup", handleKeyUp);
142
+ };
143
+ }
144
+ }, []);
145
+ if (process.env.TAMAGUI_TARGET === "native") {
146
+ React.useEffect(() => {
147
+ if (!props.id)
148
+ return;
149
+ return registerFocusable(props.id, {
150
+ focusAndSelect: () => {
151
+ onChange?.(value);
152
+ },
153
+ focus: () => {
154
+ }
155
+ });
156
+ }, [props.id, value]);
157
+ }
158
+ const isDisabled = disabled || itemDisabled;
159
+ return <RadioGroupItemProvider checked={checked} scope={__scopeRadioGroup}>{isWeb && native ? <BubbleInput
160
+ control={button}
161
+ bubbles={!hasConsumerStoppedPropagationRef.current}
162
+ name={name}
163
+ value={value}
164
+ checked={checked}
165
+ required={required}
166
+ disabled={isDisabled}
167
+ id={props.id}
168
+ accentColor={accentColor}
169
+ /> : <>
170
+ <RadioGroupItemFrame
171
+ data-state={getState(checked)}
172
+ data-disabled={isDisabled ? "" : void 0}
173
+ role="radio"
174
+ aria-labelledby={labelledBy}
175
+ aria-checked={checked}
176
+ aria-required={required}
177
+ disabled={isDisabled}
178
+ ref={composedRefs}
179
+ {...isWeb && {
180
+ type: "button",
181
+ value
182
+ }}
183
+ {...itemProps}
184
+ onPress={composeEventHandlers(props.onPress, (event) => {
185
+ if (!checked) {
186
+ onChange?.(value);
187
+ }
188
+ if (isFormControl) {
189
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
190
+ if (!hasConsumerStoppedPropagationRef.current)
191
+ event.stopPropagation();
192
+ }
193
+ })}
194
+ {...isWeb && {
195
+ onKeyDown: composeEventHandlers(
196
+ props.onKeyDown,
197
+ (event) => {
198
+ if (event.key === "Enter")
199
+ event.preventDefault();
200
+ }
201
+ ),
202
+ onFocus: composeEventHandlers(itemProps.onFocus, () => {
203
+ if (isArrowKeyPressedRef.current)
204
+ ref.current?.click();
205
+ })
206
+ }}
207
+ />
208
+ {isFormControl && <BubbleInput
209
+ isHidden
210
+ control={button}
211
+ bubbles={!hasConsumerStoppedPropagationRef.current}
212
+ name={name}
213
+ value={value}
214
+ checked={checked}
215
+ required={required}
216
+ disabled={isDisabled}
217
+ />}
218
+ </>}</RadioGroupItemProvider>;
219
+ }
220
+ )
221
+ );
222
+ const BubbleInput = (props) => {
223
+ const { checked, bubbles = true, control, isHidden, accentColor, ...inputProps } = props;
224
+ const ref = React.useRef(null);
225
+ const prevChecked = usePrevious(checked);
226
+ React.useEffect(() => {
227
+ const input = ref.current;
228
+ const inputProto = window.HTMLInputElement.prototype;
229
+ const descriptor = Object.getOwnPropertyDescriptor(
230
+ inputProto,
231
+ "checked"
232
+ );
233
+ const setChecked = descriptor.set;
234
+ if (prevChecked !== checked && setChecked) {
235
+ const event = new Event("click", { bubbles });
236
+ setChecked.call(input, checked);
237
+ input.dispatchEvent(event);
238
+ }
239
+ }, [prevChecked, checked, bubbles]);
240
+ return <input
241
+ type="radio"
242
+ defaultChecked={checked}
243
+ {...inputProps}
244
+ tabIndex={-1}
245
+ ref={ref}
246
+ aria-hidden={isHidden}
247
+ style={{
248
+ ...isHidden ? {
249
+ // ...controlSize,
250
+ position: "absolute",
251
+ pointerEvents: "none",
252
+ opacity: 0,
253
+ margin: 0
254
+ } : {
255
+ appearance: "auto",
256
+ accentColor
257
+ },
258
+ ...props.style
259
+ }}
260
+ />;
261
+ };
262
+ const RadioGroupFrame = styled(ThemeableStack, {
263
+ name: RADIO_GROUP_NAME,
264
+ variants: {
265
+ orientation: {
266
+ horizontal: {
267
+ flexDirection: "row",
268
+ spaceDirection: "horizontal"
269
+ },
270
+ vertical: {
271
+ flexDirection: "column",
272
+ spaceDirection: "vertical"
273
+ }
274
+ }
275
+ }
276
+ });
277
+ const RadioGroup = withStaticProperties(
278
+ RadioGroupFrame.extractable(
279
+ React.forwardRef(
280
+ (props, forwardedRef) => {
281
+ const {
282
+ __scopeRadioGroup,
283
+ value: valueProp,
284
+ defaultValue,
285
+ onValueChange,
286
+ disabled = false,
287
+ required = false,
288
+ name,
289
+ orientation,
290
+ native,
291
+ accentColor,
292
+ ...radioGroupProps
293
+ } = props;
294
+ const [value, setValue] = useControllableState({
295
+ prop: valueProp,
296
+ defaultProp: defaultValue,
297
+ onChange: onValueChange
298
+ });
299
+ return <RadioGroupProvider
300
+ scope={__scopeRadioGroup}
301
+ value={value}
302
+ required={required}
303
+ onChange={setValue}
304
+ disabled={disabled}
305
+ name={name}
306
+ native={native}
307
+ accentColor={accentColor}
308
+ ><RadioGroupFrame
309
+ aria-valuetext={value}
310
+ role="radiogroup"
311
+ aria-orientation={orientation}
312
+ ref={forwardedRef}
313
+ orientation={orientation}
314
+ data-disabled={disabled ? "" : void 0}
315
+ {...radioGroupProps}
316
+ /></RadioGroupProvider>;
317
+ }
318
+ )
319
+ ),
320
+ {
321
+ Indicator: RadioIndicator,
322
+ Item: RadioGroupItem
323
+ }
324
+ );
325
+ RadioGroup.displayName = RADIO_GROUP_NAME;
326
+ export {
327
+ RadioGroup,
328
+ createRadioGroupScope
329
+ };
330
+ //# sourceMappingURL=RadioGroup.mjs.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": "AAGA,SAAS,mBAAmB;AAC5B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAgB,0BAA0B;AAC1C,SAAS,yBAAyB;AAClC,SAAS,eAAkC;AAC3C,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,YAAY,WAAW;AAGvB,MAAM,mBAAmB;AAEzB,MAAM,aAAa,CAAC,WAAW,aAAa,aAAa,YAAY;AAErE,MAAM,CAAC,yBAAyB,qBAAqB,IACnD,mBAAmB,gBAAgB;AAUrC,MAAM,CAAC,oBAAoB,oBAAoB,IAC7C,wBAAgD,gBAAgB;AAElE,MAAM,WAAW,CAAC,YAAqB;AACrC,SAAO,UAAU,YAAY;AAC/B;AAMA,MAAM,6BAA6B;AAEnC,MAAM,sBAAsB,OAAO,gBAAgB;AAAA,EACjD,MAAM;AAAA,EACN,eAAe;AAAA,EAEf,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG;AAAA,QACH,IAAI;AAAA,QACJ,iBAAiB;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AAM;AAAA,EAEN,UAAU;AAAA,IACR,aAAa;AAAA,MACX,YAAY;AAAA,QACV,eAAe;AAAA,QACf,gBAAgB;AAAA,MAClB;AAAA,MACA,UAAU;AAAA,QACR,eAAe;AAAA,QACf,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAaD,MAAM,aAAa;AAAA,EACjB,gBAAgB;AAAA,IACd,MAAM;AAAA,MACJ,CAAC,OAAqC,iBAAiB;AACrD,cAAM;AAAA,UACJ;AAAA,UACA,OAAO;AAAA,UACP;AAAA,UACA;AAAA,UACA,WAAW;AAAA,UACX,WAAW;AAAA,UACX;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,GAAG;AAAA,QACL,IAAI;AACJ,cAAM,CAAC,OAAO,QAAQ,IAAI,qBAAqB;AAAA,UAC7C,MAAM;AAAA,UACN,aAAa;AAAA,UACb,UAAU;AAAA,QACZ,CAAC;AAED,eACE,CAAC;AAAA,UACC,OAAO;AAAA,UACP,OAAO;AAAA,UACP,UAAU;AAAA,UACV,UAAU;AAAA,UACV,UAAU;AAAA,UACV,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,aAAa;AAAA,SAEb,CAAC;AAAA,UACC,gBAAgB;AAAA,UAChB,KAAK;AAAA,UACL,kBAAkB;AAAA,UAClB,KAAK;AAAA,UACL,aAAa;AAAA,UACb,eAAe,WAAW,KAAK;AAAA,cAC3B;AAAA,QACN,EACF,EAnBC;AAAA,MAqBL;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,MAAM;AAAA,EACR;AACF;AAEA,WAAW,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./RadioGroup";
2
+ //# 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,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./RadioGroup";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './RadioGroup'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@tamagui/radio-group",
3
+ "version": "1.4.0",
4
+ "sideEffects": [
5
+ "*.css"
6
+ ],
7
+ "source": "src/index.ts",
8
+ "types": "./types/index.d.ts",
9
+ "main": "dist/cjs",
10
+ "module": "dist/esm",
11
+ "module:jsx": "dist/jsx",
12
+ "files": [
13
+ "src",
14
+ "types",
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tamagui-build",
19
+ "watch": "tamagui-build --watch",
20
+ "lint": "../../node_modules/.bin/rome check src",
21
+ "lint:fix": "../../node_modules/.bin/rome check --apply-suggested src",
22
+ "clean": "tamagui-build clean",
23
+ "clean:build": "tamagui-build clean:build"
24
+ },
25
+ "dependencies": {
26
+ "@radix-ui/react-use-previous": "^0.1.1",
27
+ "@tamagui/compose-refs": "^1.4.0",
28
+ "@tamagui/core": "^1.4.0",
29
+ "@tamagui/create-context": "^1.4.0",
30
+ "@tamagui/focusable": "^1.4.0",
31
+ "@tamagui/get-size": "^1.4.0",
32
+ "@tamagui/label": "^1.4.0",
33
+ "@tamagui/stacks": "^1.4.0",
34
+ "@tamagui/use-controllable-state": "^1.4.0"
35
+ },
36
+ "peerDependencies": {
37
+ "react": "*",
38
+ "react-dom": "*"
39
+ },
40
+ "devDependencies": {
41
+ "@tamagui/build": "^1.4.0",
42
+ "react": "^18.2.0",
43
+ "react-dom": "^18.2.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }