@yamada-ui/radio 1.2.8-dev-20240915031944 → 1.2.8-dev-20240917064938
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/chunk-JUEGICB4.mjs +172 -0
- package/dist/chunk-JUEGICB4.mjs.map +1 -0
- package/dist/{chunk-Q2UUIUFI.mjs → chunk-VT4XEFV3.mjs} +16 -182
- package/dist/chunk-VT4XEFV3.mjs.map +1 -0
- package/dist/chunk-YWRIETVW.mjs +14 -0
- package/dist/chunk-YWRIETVW.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +190 -187
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/radio-context.d.mts +14 -0
- package/dist/radio-context.d.ts +14 -0
- package/dist/radio-context.js +38 -0
- package/dist/radio-context.js.map +1 -0
- package/dist/radio-context.mjs +10 -0
- package/dist/radio-context.mjs.map +1 -0
- package/dist/radio-group.d.mts +14 -21
- package/dist/radio-group.d.ts +14 -21
- package/dist/radio-group.js +43 -40
- package/dist/radio-group.js.map +1 -1
- package/dist/radio-group.mjs +5 -5
- package/dist/radio.d.mts +20 -56
- package/dist/radio.d.ts +20 -56
- package/dist/radio.js +37 -187
- package/dist/radio.js.map +1 -1
- package/dist/radio.mjs +2 -1
- package/package.json +7 -7
- package/dist/chunk-Q2UUIUFI.mjs.map +0 -1
@@ -0,0 +1,172 @@
|
|
1
|
+
"use client"
|
2
|
+
import {
|
3
|
+
Radio
|
4
|
+
} from "./chunk-VT4XEFV3.mjs";
|
5
|
+
import {
|
6
|
+
RadioGroupProvider
|
7
|
+
} from "./chunk-YWRIETVW.mjs";
|
8
|
+
|
9
|
+
// src/radio-group.tsx
|
10
|
+
import { useFormControl } from "@yamada-ui/form-control";
|
11
|
+
import { Flex } from "@yamada-ui/layouts";
|
12
|
+
import { useControllableState } from "@yamada-ui/use-controllable-state";
|
13
|
+
import {
|
14
|
+
cx,
|
15
|
+
isObject,
|
16
|
+
useCallbackRef,
|
17
|
+
getValidChildren,
|
18
|
+
mergeRefs
|
19
|
+
} from "@yamada-ui/utils";
|
20
|
+
import { useCallback, useId, useRef, forwardRef } from "react";
|
21
|
+
import { jsx } from "react/jsx-runtime";
|
22
|
+
var isEvent = (value) => value && isObject(value) && isObject(value.target);
|
23
|
+
var useRadioGroup = ({
|
24
|
+
id,
|
25
|
+
name,
|
26
|
+
isNative,
|
27
|
+
value: valueProp,
|
28
|
+
defaultValue,
|
29
|
+
onChange: onChangeProp,
|
30
|
+
...props
|
31
|
+
}) => {
|
32
|
+
id != null ? id : id = useId();
|
33
|
+
name != null ? name : name = `radio-${id}`;
|
34
|
+
const onChangeRef = useCallbackRef(onChangeProp);
|
35
|
+
const [value, setValue] = useControllableState({
|
36
|
+
value: valueProp,
|
37
|
+
defaultValue,
|
38
|
+
onChange: onChangeRef
|
39
|
+
});
|
40
|
+
const containerRef = useRef(null);
|
41
|
+
const onFocus = useCallback(() => {
|
42
|
+
const container = containerRef.current;
|
43
|
+
if (!container) return;
|
44
|
+
let query = `input:not(:disabled):checked`;
|
45
|
+
let firstInput = container.querySelector(query);
|
46
|
+
if (firstInput) {
|
47
|
+
firstInput.focus();
|
48
|
+
} else {
|
49
|
+
query = `input:not(:disabled)`;
|
50
|
+
firstInput = container.querySelector(query);
|
51
|
+
firstInput == null ? void 0 : firstInput.focus();
|
52
|
+
}
|
53
|
+
}, []);
|
54
|
+
const onChange = useCallback(
|
55
|
+
(evOrValue) => {
|
56
|
+
const nextValue = isEvent(evOrValue) ? evOrValue.target.value : evOrValue;
|
57
|
+
setValue(nextValue);
|
58
|
+
},
|
59
|
+
[setValue]
|
60
|
+
);
|
61
|
+
const getContainerProps = useCallback(
|
62
|
+
(props2 = {}, ref = null) => ({
|
63
|
+
role: "radiogroup",
|
64
|
+
...props2,
|
65
|
+
ref: mergeRefs(ref, containerRef)
|
66
|
+
}),
|
67
|
+
[]
|
68
|
+
);
|
69
|
+
const getRadioProps = useCallback(
|
70
|
+
(props2 = {}, ref = null) => {
|
71
|
+
const isChecked = props2.value === value;
|
72
|
+
return {
|
73
|
+
...props2,
|
74
|
+
ref,
|
75
|
+
name,
|
76
|
+
[isNative ? "checked" : "isChecked"]: value != null ? isChecked : void 0,
|
77
|
+
"aria-checked": isChecked,
|
78
|
+
onChange
|
79
|
+
};
|
80
|
+
},
|
81
|
+
[name, value, onChange, isNative]
|
82
|
+
);
|
83
|
+
return {
|
84
|
+
props,
|
85
|
+
id,
|
86
|
+
name,
|
87
|
+
value,
|
88
|
+
setValue,
|
89
|
+
onChange,
|
90
|
+
onFocus,
|
91
|
+
getContainerProps,
|
92
|
+
getRadioProps
|
93
|
+
};
|
94
|
+
};
|
95
|
+
var RadioGroup = forwardRef(
|
96
|
+
({
|
97
|
+
id: idProp,
|
98
|
+
className,
|
99
|
+
size,
|
100
|
+
variant,
|
101
|
+
colorScheme,
|
102
|
+
children,
|
103
|
+
items = [],
|
104
|
+
direction = "column",
|
105
|
+
gap,
|
106
|
+
...props
|
107
|
+
}, ref) => {
|
108
|
+
const {
|
109
|
+
labelId,
|
110
|
+
isRequired,
|
111
|
+
isReadOnly,
|
112
|
+
isDisabled,
|
113
|
+
isInvalid,
|
114
|
+
...computedProps
|
115
|
+
} = useFormControl({
|
116
|
+
id: idProp,
|
117
|
+
...props
|
118
|
+
});
|
119
|
+
const {
|
120
|
+
id,
|
121
|
+
name,
|
122
|
+
value,
|
123
|
+
onChange,
|
124
|
+
getContainerProps,
|
125
|
+
props: rest
|
126
|
+
} = useRadioGroup(computedProps);
|
127
|
+
const validChildren = getValidChildren(children);
|
128
|
+
let computedChildren = [];
|
129
|
+
if (!validChildren.length && items.length) {
|
130
|
+
computedChildren = items.map(({ label, value: value2, ...props2 }, i) => /* @__PURE__ */ jsx(Radio, { value: value2, ...props2, children: label }, i));
|
131
|
+
}
|
132
|
+
return /* @__PURE__ */ jsx(
|
133
|
+
RadioGroupProvider,
|
134
|
+
{
|
135
|
+
value: {
|
136
|
+
size,
|
137
|
+
variant,
|
138
|
+
colorScheme,
|
139
|
+
isRequired,
|
140
|
+
isReadOnly,
|
141
|
+
isDisabled,
|
142
|
+
isInvalid,
|
143
|
+
name,
|
144
|
+
value,
|
145
|
+
onChange
|
146
|
+
},
|
147
|
+
children: /* @__PURE__ */ jsx(
|
148
|
+
Flex,
|
149
|
+
{
|
150
|
+
ref,
|
151
|
+
className: cx("ui-radio-group", className),
|
152
|
+
gap: gap != null ? gap : direction === "row" ? "1rem" : void 0,
|
153
|
+
...getContainerProps({
|
154
|
+
id,
|
155
|
+
"aria-labelledby": labelId,
|
156
|
+
...rest
|
157
|
+
}),
|
158
|
+
direction,
|
159
|
+
children: children != null ? children : computedChildren
|
160
|
+
}
|
161
|
+
)
|
162
|
+
}
|
163
|
+
);
|
164
|
+
}
|
165
|
+
);
|
166
|
+
RadioGroup.displayName = "RadioGroup";
|
167
|
+
|
168
|
+
export {
|
169
|
+
useRadioGroup,
|
170
|
+
RadioGroup
|
171
|
+
};
|
172
|
+
//# sourceMappingURL=chunk-JUEGICB4.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/radio-group.tsx"],"sourcesContent":["import type { ComponentArgs, ThemeProps, PropGetter } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport { useFormControl } from \"@yamada-ui/form-control\"\nimport type { FlexProps } from \"@yamada-ui/layouts\"\nimport { Flex } from \"@yamada-ui/layouts\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport {\n cx,\n isObject,\n useCallbackRef,\n getValidChildren,\n mergeRefs,\n} from \"@yamada-ui/utils\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type {\n ChangeEvent,\n ForwardedRef,\n ReactElement,\n RefAttributes,\n} from \"react\"\nimport { useCallback, useId, useRef, forwardRef } from \"react\"\nimport type { RadioProps } from \"./radio\"\nimport { Radio } from \"./radio\"\nimport type { RadioGroupContext } from \"./radio-context\"\nimport { RadioGroupProvider } from \"./radio-context\"\n\nexport type RadioItem<Y extends string | number = string> = RadioProps<Y> & {\n label?: string\n}\n\nconst isEvent = (value: any): value is { target: HTMLInputElement } =>\n value && isObject(value) && isObject(value.target)\n\nexport interface UseRadioGroupProps<Y extends string | number = string> {\n /**\n * The top-level id string that will be applied to the radios.\n * The index of the radio will be appended to this top-level id.\n */\n id?: string\n /**\n * The HTML `name` attribute used for forms.\n */\n name?: string\n /**\n * The value of the radio group.\n */\n value?: Y\n /**\n * The initial value of the radio group.\n */\n defaultValue?: Y\n /**\n * The callback fired when any children radio is checked or unchecked.\n */\n onChange?: (value: Y) => void\n /**\n * If `true`, input elements will receive `checked` attribute instead of `isChecked`.\n *\n * This assumes, you're using native radio inputs.\n *\n * @default false\n */\n isNative?: boolean\n}\n\nexport const useRadioGroup = <\n Y extends string | number,\n M extends Dict = Dict,\n>({\n id,\n name,\n isNative,\n value: valueProp,\n defaultValue,\n onChange: onChangeProp,\n ...props\n}: UseRadioGroupProps<Y> & M) => {\n id ??= useId()\n name ??= `radio-${id}`\n\n const onChangeRef = useCallbackRef(onChangeProp)\n\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue,\n onChange: onChangeRef,\n })\n\n const containerRef = useRef<any>(null)\n\n const onFocus = useCallback(() => {\n const container = containerRef.current\n\n if (!container) return\n\n let query = `input:not(:disabled):checked`\n\n let firstInput = container.querySelector(query) as HTMLElement | undefined\n\n if (firstInput) {\n firstInput.focus()\n } else {\n query = `input:not(:disabled)`\n firstInput = container.querySelector(query) as HTMLElement | undefined\n\n firstInput?.focus()\n }\n }, [])\n\n const onChange = useCallback(\n (evOrValue: ChangeEvent<HTMLInputElement> | Y) => {\n const nextValue = (\n isEvent(evOrValue) ? evOrValue.target.value : evOrValue\n ) as Y\n\n setValue(nextValue)\n },\n [setValue],\n )\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n role: \"radiogroup\",\n ...props,\n ref: mergeRefs(ref, containerRef),\n }),\n [],\n )\n\n const getRadioProps: PropGetter<\n { value?: Y },\n { value?: Y; checked?: boolean; isChecked?: boolean }\n > = useCallback(\n (props = {}, ref = null) => {\n const isChecked = props.value === value\n\n return {\n ...props,\n ref,\n name,\n [isNative ? \"checked\" : \"isChecked\"]:\n value != null ? isChecked : undefined,\n \"aria-checked\": isChecked,\n onChange,\n }\n },\n [name, value, onChange, isNative],\n )\n\n return {\n props,\n id,\n name,\n value,\n setValue,\n onChange,\n onFocus,\n getContainerProps,\n getRadioProps,\n }\n}\n\nexport type UseRadioGroupReturn<Y extends string | number = string> =\n ReturnType<typeof useRadioGroup<Y>>\n\nexport interface RadioGroupProps<Y extends string | number = string>\n extends ThemeProps<\"Radio\">,\n Omit<FlexProps, \"defaultValue\" | \"onChange\">,\n UseRadioGroupProps<Y>,\n FormControlOptions {\n /**\n * If provided, generate radios based on items.\n *\n * @default '[]'\n */\n items?: RadioItem<Y>[]\n}\n\nexport const RadioGroup = forwardRef(\n <Y extends string | number = string>(\n {\n id: idProp,\n className,\n size,\n variant,\n colorScheme,\n children,\n items = [],\n direction = \"column\",\n gap,\n ...props\n }: RadioGroupProps<Y>,\n ref: ForwardedRef<HTMLDivElement>,\n ) => {\n const {\n labelId,\n isRequired,\n isReadOnly,\n isDisabled,\n isInvalid,\n ...computedProps\n } = useFormControl({\n id: idProp,\n ...props,\n })\n const {\n id,\n name,\n value,\n onChange,\n getContainerProps,\n props: rest,\n } = useRadioGroup(computedProps)\n\n const validChildren = getValidChildren(children)\n let computedChildren: ReactElement[] = []\n\n if (!validChildren.length && items.length) {\n computedChildren = items.map(({ label, value, ...props }, i) => (\n <Radio key={i} value={value} {...props}>\n {label}\n </Radio>\n ))\n }\n\n return (\n <RadioGroupProvider\n value={\n {\n size,\n variant,\n colorScheme,\n isRequired,\n isReadOnly,\n isDisabled,\n isInvalid,\n name,\n value,\n onChange,\n } as RadioGroupContext\n }\n >\n <Flex\n ref={ref}\n className={cx(\"ui-radio-group\", className)}\n gap={gap ?? (direction === \"row\" ? \"1rem\" : undefined)}\n {...getContainerProps({\n id,\n \"aria-labelledby\": labelId,\n ...rest,\n })}\n direction={direction}\n >\n {children ?? computedChildren}\n </Flex>\n </RadioGroupProvider>\n )\n },\n) as {\n <Y extends string | number = string>(\n props: RadioGroupProps<Y> & RefAttributes<HTMLDivElement>,\n ): JSX.Element\n} & ComponentArgs\n\nRadioGroup.displayName = \"RadioGroup\"\n"],"mappings":";;;;;;;;;AAEA,SAAS,sBAAsB;AAE/B,SAAS,YAAY;AACrB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,SAAS,aAAa,OAAO,QAAQ,kBAAkB;AAuM/C;AA7LR,IAAM,UAAU,CAAC,UACf,SAAS,SAAS,KAAK,KAAK,SAAS,MAAM,MAAM;AAkC5C,IAAM,gBAAgB,CAG3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA,UAAU;AAAA,EACV,GAAG;AACL,MAAiC;AAC/B,yBAAO,MAAM;AACb,+BAAS,SAAS,EAAE;AAEpB,QAAM,cAAc,eAAe,YAAY;AAE/C,QAAM,CAAC,OAAO,QAAQ,IAAI,qBAAqB;AAAA,IAC7C,OAAO;AAAA,IACP;AAAA,IACA,UAAU;AAAA,EACZ,CAAC;AAED,QAAM,eAAe,OAAY,IAAI;AAErC,QAAM,UAAU,YAAY,MAAM;AAChC,UAAM,YAAY,aAAa;AAE/B,QAAI,CAAC,UAAW;AAEhB,QAAI,QAAQ;AAEZ,QAAI,aAAa,UAAU,cAAc,KAAK;AAE9C,QAAI,YAAY;AACd,iBAAW,MAAM;AAAA,IACnB,OAAO;AACL,cAAQ;AACR,mBAAa,UAAU,cAAc,KAAK;AAE1C,+CAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,WAAW;AAAA,IACf,CAAC,cAAiD;AAChD,YAAM,YACJ,QAAQ,SAAS,IAAI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,mBAAmC,CAAC;AAExC,QAAI,CAAC,cAAc,UAAU,MAAM,QAAQ;AACzC,yBAAmB,MAAM,IAAI,CAAC,EAAE,OAAO,OAAAC,QAAO,GAAGD,OAAM,GAAG,MACxD,oBAAC,SAAc,OAAOC,QAAQ,GAAGD,QAC9B,mBADS,CAEZ,CACD;AAAA,IACH;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,OACE;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QAGF;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,WAAW,GAAG,kBAAkB,SAAS;AAAA,YACzC,KAAK,oBAAQ,cAAc,QAAQ,SAAS;AAAA,YAC3C,GAAG,kBAAkB;AAAA,cACpB;AAAA,cACA,mBAAmB;AAAA,cACnB,GAAG;AAAA,YACL,CAAC;AAAA,YACD;AAAA,YAEC,wCAAY;AAAA;AAAA,QACf;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAMA,WAAW,cAAc;","names":["props","value"]}
|
@@ -1,21 +1,10 @@
|
|
1
1
|
"use client"
|
2
|
-
|
3
|
-
// src/radio-group.tsx
|
4
|
-
import { useFormControl as useFormControl2 } from "@yamada-ui/form-control";
|
5
|
-
import { Flex } from "@yamada-ui/layouts";
|
6
|
-
import { useControllableState } from "@yamada-ui/use-controllable-state";
|
7
2
|
import {
|
8
|
-
|
9
|
-
|
10
|
-
isObject,
|
11
|
-
mergeRefs,
|
12
|
-
useCallbackRef as useCallbackRef2,
|
13
|
-
getValidChildren
|
14
|
-
} from "@yamada-ui/utils";
|
15
|
-
import { useCallback as useCallback2, useId as useId2, useRef, forwardRef as forwardRef2 } from "react";
|
3
|
+
useRadioGroupContext
|
4
|
+
} from "./chunk-YWRIETVW.mjs";
|
16
5
|
|
17
6
|
// src/radio.tsx
|
18
|
-
import { ui,
|
7
|
+
import { ui, useComponentMultiStyle, omitThemeProps } from "@yamada-ui/core";
|
19
8
|
import {
|
20
9
|
useFormControl,
|
21
10
|
useFormControlProps,
|
@@ -113,10 +102,10 @@ var useRadio = ({
|
|
113
102
|
"data-focus": dataAttr(isFocused),
|
114
103
|
"data-focus-visible": dataAttr(isFocused && isFocusVisible),
|
115
104
|
"aria-hidden": true,
|
116
|
-
onMouseDown: handlerAll(props2.onMouseDown, () => setActive(true)),
|
117
|
-
onMouseUp: handlerAll(props2.onMouseUp, () => setActive(false)),
|
118
|
-
onMouseEnter: handlerAll(props2.onMouseEnter, () => setHovered(true)),
|
119
|
-
onMouseLeave: handlerAll(props2.onMouseLeave, () => setHovered(false))
|
105
|
+
onMouseDown: handlerAll(props2 == null ? void 0 : props2.onMouseDown, () => setActive(true)),
|
106
|
+
onMouseUp: handlerAll(props2 == null ? void 0 : props2.onMouseUp, () => setActive(false)),
|
107
|
+
onMouseEnter: handlerAll(props2 == null ? void 0 : props2.onMouseEnter, () => setHovered(true)),
|
108
|
+
onMouseLeave: handlerAll(props2 == null ? void 0 : props2.onMouseLeave, () => setHovered(false))
|
120
109
|
}),
|
121
110
|
[checked, isActive, isFocused, isFocusVisible, isHovered, formControlProps]
|
122
111
|
);
|
@@ -145,11 +134,11 @@ var useRadio = ({
|
|
145
134
|
whiteSpace: "nowrap",
|
146
135
|
position: "absolute"
|
147
136
|
},
|
148
|
-
onChange: handlerAll(props2.onChange, onChange),
|
149
|
-
onBlur: handlerAll(props2.onBlur, onBlur, () => setFocused(false)),
|
150
|
-
onFocus: handlerAll(props2.onFocus, onFocus, () => setFocused(true)),
|
151
|
-
onKeyDown: handlerAll(props2.onKeyDown, onKeyDown),
|
152
|
-
onKeyUp: handlerAll(props2.onKeyUp, onKeyUp)
|
137
|
+
onChange: handlerAll(props2 == null ? void 0 : props2.onChange, onChange),
|
138
|
+
onBlur: handlerAll(props2 == null ? void 0 : props2.onBlur, onBlur, () => setFocused(false)),
|
139
|
+
onFocus: handlerAll(props2 == null ? void 0 : props2.onFocus, onFocus, () => setFocused(true)),
|
140
|
+
onKeyDown: handlerAll(props2 == null ? void 0 : props2.onKeyDown, onKeyDown),
|
141
|
+
onKeyUp: handlerAll(props2 == null ? void 0 : props2.onKeyUp, onKeyUp)
|
153
142
|
}),
|
154
143
|
[
|
155
144
|
formControlProps,
|
@@ -172,11 +161,11 @@ var useRadio = ({
|
|
172
161
|
...formControlProps,
|
173
162
|
...props2,
|
174
163
|
ref,
|
175
|
-
onMouseDown: handlerAll(props2.onMouseDown, (ev) => {
|
164
|
+
onMouseDown: handlerAll(props2 == null ? void 0 : props2.onMouseDown, (ev) => {
|
176
165
|
ev.preventDefault();
|
177
166
|
ev.stopPropagation();
|
178
167
|
}),
|
179
|
-
onTouchStart: handlerAll(props2.onTouchStart, (ev) => {
|
168
|
+
onTouchStart: handlerAll(props2 == null ? void 0 : props2.onTouchStart, (ev) => {
|
180
169
|
ev.preventDefault();
|
181
170
|
ev.stopPropagation();
|
182
171
|
}),
|
@@ -203,7 +192,7 @@ var Radio = forwardRef(
|
|
203
192
|
const group = useRadioGroupContext();
|
204
193
|
const { value: groupValue, ...groupProps } = { ...group };
|
205
194
|
const control = useFormControl(props);
|
206
|
-
const [styles, mergedProps] =
|
195
|
+
const [styles, mergedProps] = useComponentMultiStyle("Radio", {
|
207
196
|
...groupProps,
|
208
197
|
...props
|
209
198
|
});
|
@@ -296,163 +285,8 @@ var Radio = forwardRef(
|
|
296
285
|
);
|
297
286
|
Radio.displayName = "Radio";
|
298
287
|
|
299
|
-
// src/radio-group.tsx
|
300
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
301
|
-
var isEvent = (value) => value && isObject(value) && isObject(value.target);
|
302
|
-
var useRadioGroup = ({
|
303
|
-
id,
|
304
|
-
name,
|
305
|
-
isNative,
|
306
|
-
value: valueProp,
|
307
|
-
defaultValue,
|
308
|
-
onChange: onChangeProp,
|
309
|
-
...props
|
310
|
-
}) => {
|
311
|
-
id != null ? id : id = useId2();
|
312
|
-
name != null ? name : name = `radio-${id}`;
|
313
|
-
const onChangeRef = useCallbackRef2(onChangeProp);
|
314
|
-
const [value, setValue] = useControllableState({
|
315
|
-
value: valueProp,
|
316
|
-
defaultValue,
|
317
|
-
onChange: onChangeRef
|
318
|
-
});
|
319
|
-
const containerRef = useRef(null);
|
320
|
-
const onFocus = useCallback2(() => {
|
321
|
-
const container = containerRef.current;
|
322
|
-
if (!container) return;
|
323
|
-
let query = `input:not(:disabled):checked`;
|
324
|
-
let firstInput = container.querySelector(query);
|
325
|
-
if (firstInput) {
|
326
|
-
firstInput.focus();
|
327
|
-
} else {
|
328
|
-
query = `input:not(:disabled)`;
|
329
|
-
firstInput = container.querySelector(query);
|
330
|
-
firstInput == null ? void 0 : firstInput.focus();
|
331
|
-
}
|
332
|
-
}, []);
|
333
|
-
const onChange = useCallback2(
|
334
|
-
(evOrValue) => {
|
335
|
-
const nextValue = isEvent(evOrValue) ? evOrValue.target.value : evOrValue;
|
336
|
-
setValue(nextValue);
|
337
|
-
},
|
338
|
-
[setValue]
|
339
|
-
);
|
340
|
-
const getContainerProps = useCallback2(
|
341
|
-
(props2 = {}, ref = null) => ({
|
342
|
-
role: "radiogroup",
|
343
|
-
...props2,
|
344
|
-
ref: mergeRefs(ref, containerRef)
|
345
|
-
}),
|
346
|
-
[]
|
347
|
-
);
|
348
|
-
const getRadioProps = useCallback2(
|
349
|
-
(props2 = {}, ref = null) => {
|
350
|
-
const isChecked = props2.value === value;
|
351
|
-
return {
|
352
|
-
...props2,
|
353
|
-
ref,
|
354
|
-
name,
|
355
|
-
[isNative ? "checked" : "isChecked"]: value != null ? isChecked : void 0,
|
356
|
-
"aria-checked": isChecked,
|
357
|
-
onChange
|
358
|
-
};
|
359
|
-
},
|
360
|
-
[name, value, onChange, isNative]
|
361
|
-
);
|
362
|
-
return {
|
363
|
-
props,
|
364
|
-
id,
|
365
|
-
name,
|
366
|
-
value,
|
367
|
-
setValue,
|
368
|
-
onChange,
|
369
|
-
onFocus,
|
370
|
-
getContainerProps,
|
371
|
-
getRadioProps
|
372
|
-
};
|
373
|
-
};
|
374
|
-
var [RadioGroupProvider, useRadioGroupContext] = createContext({
|
375
|
-
strict: false,
|
376
|
-
name: "RadioGroupContext"
|
377
|
-
});
|
378
|
-
var RadioGroup = forwardRef2(
|
379
|
-
({
|
380
|
-
id: idProp,
|
381
|
-
className,
|
382
|
-
size,
|
383
|
-
variant,
|
384
|
-
colorScheme,
|
385
|
-
children,
|
386
|
-
items = [],
|
387
|
-
direction = "column",
|
388
|
-
gap,
|
389
|
-
...props
|
390
|
-
}, ref) => {
|
391
|
-
const {
|
392
|
-
labelId,
|
393
|
-
isRequired,
|
394
|
-
isReadOnly,
|
395
|
-
isDisabled,
|
396
|
-
isInvalid,
|
397
|
-
...computedProps
|
398
|
-
} = useFormControl2({
|
399
|
-
id: idProp,
|
400
|
-
...props
|
401
|
-
});
|
402
|
-
const {
|
403
|
-
id,
|
404
|
-
name,
|
405
|
-
value,
|
406
|
-
onChange,
|
407
|
-
getContainerProps,
|
408
|
-
props: rest
|
409
|
-
} = useRadioGroup(computedProps);
|
410
|
-
const validChildren = getValidChildren(children);
|
411
|
-
let computedChildren = [];
|
412
|
-
if (!validChildren.length && items.length) {
|
413
|
-
computedChildren = items.map(({ label, value: value2, ...props2 }, i) => /* @__PURE__ */ jsx2(Radio, { value: value2, ...props2, children: label }, i));
|
414
|
-
}
|
415
|
-
return /* @__PURE__ */ jsx2(
|
416
|
-
RadioGroupProvider,
|
417
|
-
{
|
418
|
-
value: {
|
419
|
-
size,
|
420
|
-
variant,
|
421
|
-
colorScheme,
|
422
|
-
isRequired,
|
423
|
-
isReadOnly,
|
424
|
-
isDisabled,
|
425
|
-
isInvalid,
|
426
|
-
name,
|
427
|
-
value,
|
428
|
-
onChange
|
429
|
-
},
|
430
|
-
children: /* @__PURE__ */ jsx2(
|
431
|
-
Flex,
|
432
|
-
{
|
433
|
-
ref,
|
434
|
-
className: cx2("ui-radio-group", className),
|
435
|
-
gap: gap != null ? gap : direction === "row" ? "1rem" : void 0,
|
436
|
-
...getContainerProps({
|
437
|
-
id,
|
438
|
-
"aria-labelledby": labelId,
|
439
|
-
...rest
|
440
|
-
}),
|
441
|
-
direction,
|
442
|
-
children: children != null ? children : computedChildren
|
443
|
-
}
|
444
|
-
)
|
445
|
-
}
|
446
|
-
);
|
447
|
-
}
|
448
|
-
);
|
449
|
-
RadioGroup.displayName = "RadioGroup";
|
450
|
-
|
451
288
|
export {
|
452
|
-
useRadioGroup,
|
453
|
-
useRadioGroupContext,
|
454
|
-
RadioGroup,
|
455
289
|
useRadio,
|
456
290
|
Radio
|
457
291
|
};
|
458
|
-
//# sourceMappingURL=chunk-
|
292
|
+
//# sourceMappingURL=chunk-VT4XEFV3.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/radio.tsx"],"sourcesContent":["import type {\n HTMLUIProps,\n ThemeProps,\n ComponentArgs,\n PropGetter,\n} from \"@yamada-ui/core\"\nimport { ui, useComponentMultiStyle, omitThemeProps } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport {\n useFormControl,\n useFormControlProps,\n formControlProperties,\n} from \"@yamada-ui/form-control\"\nimport { trackFocusVisible } from \"@yamada-ui/use-focus-visible\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport {\n cx,\n useCallbackRef,\n funcAll,\n handlerAll,\n dataAttr,\n splitObject,\n} from \"@yamada-ui/utils\"\nimport type {\n ForwardedRef,\n ChangeEvent,\n ChangeEventHandler,\n InputHTMLAttributes,\n KeyboardEvent,\n SyntheticEvent,\n RefAttributes,\n} from \"react\"\nimport { forwardRef, useCallback, useEffect, useId, useState } from \"react\"\nimport { useRadioGroupContext } from \"./radio-context\"\n\nexport interface UseRadioProps<Y extends string | number = string>\n extends FormControlOptions {\n /**\n * id assigned to input.\n */\n id?: string\n /**\n * The name of the input field in a radio.\n */\n name?: string\n /**\n * The value to be used in the radio button.\n */\n value?: Y\n /**\n * If `true`, the radio will be initially checked.\n *\n * @default false\n */\n defaultIsChecked?: boolean\n /**\n * If `true`, the radio will be checked.\n *\n * @default false\n */\n isChecked?: boolean\n /**\n * The callback invoked when the checked state changes.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>\n}\n\nexport const useRadio = <\n Y extends string | number = string,\n M extends Dict = Dict,\n>({\n id,\n ...props\n}: UseRadioProps<Y> & M) => {\n id ??= useId()\n const {\n id: _id,\n name,\n value,\n isChecked: isCheckedProp,\n defaultIsChecked,\n onChange: onChangeProp,\n ...computedProps\n } = useFormControlProps({ id, ...props })\n const [\n {\n \"aria-readonly\": _ariaReadonly,\n required,\n disabled,\n readOnly,\n onFocus: onFocusProp,\n onBlur: onBlurProp,\n ...formControlProps\n },\n rest,\n ] = splitObject(computedProps, formControlProperties)\n\n const [isFocusVisible, setIsFocusVisible] = useState<boolean>(false)\n const [isFocused, setFocused] = useState<boolean>(false)\n const [isHovered, setHovered] = useState<boolean>(false)\n const [isActive, setActive] = useState<boolean>(false)\n\n const [isChecked, setIsChecked] = useState<boolean>(!!defaultIsChecked)\n\n const isControlled = isCheckedProp !== undefined\n const checked = isControlled ? (isCheckedProp as boolean) : isChecked\n\n useEffect(() => {\n return trackFocusVisible(setIsFocusVisible)\n }, [])\n\n const onChange = useCallbackRef(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (readOnly || disabled) {\n ev.preventDefault()\n\n return\n }\n\n if (!isControlled) setIsChecked(ev.target.checked)\n\n onChangeProp?.(ev)\n },\n [readOnly, disabled, isControlled],\n )\n const onFocus = useCallbackRef(onFocusProp)\n const onBlur = useCallbackRef(onBlurProp)\n\n const onKeyDown = useCallback(\n ({ key }: KeyboardEvent) => {\n if (key === \" \") setActive(true)\n },\n [setActive],\n )\n\n const onKeyUp = useCallback(\n ({ key }: KeyboardEvent) => {\n if (key === \" \") setActive(false)\n },\n [setActive],\n )\n\n const getContainerProps: PropGetter<\"label\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref,\n \"data-checked\": dataAttr(checked),\n }),\n [checked, formControlProps],\n )\n\n const getIconProps: PropGetter<\"span\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref,\n \"data-active\": dataAttr(isActive),\n \"data-hover\": dataAttr(isHovered),\n \"data-checked\": dataAttr(checked),\n \"data-focus\": dataAttr(isFocused),\n \"data-focus-visible\": dataAttr(isFocused && isFocusVisible),\n \"aria-hidden\": true,\n onMouseDown: handlerAll(props?.onMouseDown, () => setActive(true)),\n onMouseUp: handlerAll(props?.onMouseUp, () => setActive(false)),\n onMouseEnter: handlerAll(props?.onMouseEnter, () => setHovered(true)),\n onMouseLeave: handlerAll(props?.onMouseLeave, () => setHovered(false)),\n }),\n [checked, isActive, isFocused, isFocusVisible, isHovered, formControlProps],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref,\n id,\n type: \"radio\",\n name,\n value,\n required,\n disabled,\n readOnly,\n checked,\n \"aria-checked\": checked,\n style: {\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n width: \"1px\",\n margin: \"-1px\",\n padding: \"0px\",\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n position: \"absolute\",\n },\n onChange: handlerAll(props?.onChange, onChange),\n onBlur: handlerAll(props?.onBlur, onBlur, () => setFocused(false)),\n onFocus: handlerAll(props?.onFocus, onFocus, () => setFocused(true)),\n onKeyDown: handlerAll(props?.onKeyDown, onKeyDown),\n onKeyUp: handlerAll(props?.onKeyUp, onKeyUp),\n }),\n [\n formControlProps,\n id,\n name,\n value,\n required,\n disabled,\n readOnly,\n checked,\n onChange,\n onBlur,\n onFocus,\n onKeyDown,\n onKeyUp,\n ],\n )\n\n const getLabelProps: PropGetter<\"span\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref,\n onMouseDown: handlerAll(props?.onMouseDown, (ev: SyntheticEvent) => {\n ev.preventDefault()\n ev.stopPropagation()\n }),\n onTouchStart: handlerAll(props?.onTouchStart, (ev: SyntheticEvent) => {\n ev.preventDefault()\n ev.stopPropagation()\n }),\n \"data-checked\": dataAttr(checked),\n }),\n [checked, formControlProps],\n )\n\n return {\n props: rest,\n isFocusVisible,\n isFocused,\n isHovered,\n isActive,\n isChecked: checked,\n getContainerProps,\n getInputProps,\n getIconProps,\n getLabelProps,\n }\n}\n\nexport type UseRadioReturn = ReturnType<typeof useRadio>\n\ninterface RadioOptions {\n iconProps?: HTMLUIProps<\"span\">\n inputProps?: InputHTMLAttributes<HTMLInputElement>\n labelProps?: HTMLUIProps<\"span\">\n}\n\nexport interface RadioProps<Y extends string | number = string>\n extends Omit<HTMLUIProps<\"label\">, keyof UseRadioProps>,\n ThemeProps<\"Radio\">,\n UseRadioProps<Y>,\n RadioOptions {}\n\n/**\n * `Radio` is a component used for allowing users to select one option from multiple choices.\n *\n * @see Docs https://yamada-ui.com/components/forms/radio\n */\nexport const Radio = forwardRef(\n <Y extends string | number = string>(\n props: RadioProps<Y>,\n ref: ForwardedRef<HTMLInputElement>,\n ) => {\n const group = useRadioGroupContext()\n const { value: groupValue, ...groupProps } = { ...group }\n const control = useFormControl(props)\n const [styles, mergedProps] = useComponentMultiStyle(\"Radio\", {\n ...groupProps,\n ...props,\n })\n const {\n className,\n gap = \"0.5rem\",\n isRequired = groupProps.isRequired ?? control.isRequired,\n isReadOnly = groupProps.isReadOnly ?? control.isReadOnly,\n isDisabled = groupProps.isDisabled ?? control.isDisabled,\n isInvalid = groupProps.isInvalid ?? control.isInvalid,\n iconProps,\n inputProps,\n labelProps,\n children,\n ...computedProps\n } = omitThemeProps(mergedProps)\n\n const isCheckedProp =\n groupValue && computedProps.value\n ? groupValue === computedProps.value\n : computedProps.isChecked\n\n const onChange =\n groupProps.onChange && computedProps.value\n ? funcAll(groupProps.onChange, computedProps.onChange)\n : computedProps.onChange\n\n const {\n isChecked,\n getContainerProps,\n getInputProps,\n getIconProps,\n getLabelProps,\n props: rest,\n } = useRadio({\n ...computedProps,\n isRequired,\n isReadOnly,\n isDisabled,\n isInvalid,\n isChecked: isCheckedProp,\n onChange,\n })\n\n const tabIndex = !groupValue ? 0 : isChecked ? 0 : -1\n\n return (\n <ui.label\n className={cx(\"ui-radio\", className)}\n {...getContainerProps(rest)}\n __css={{\n cursor: \"pointer\",\n position: \"relative\",\n display: \"inline-flex\",\n alignItems: \"center\",\n verticalAlign: \"top\",\n gap,\n ...styles.container,\n }}\n >\n <ui.input\n className=\"ui-radio__input\"\n {...getInputProps(\n {\n ...inputProps,\n tabIndex,\n },\n ref,\n )}\n />\n\n <ui.span\n className=\"ui-radio__icon\"\n {...getIconProps(iconProps)}\n __css={{\n position: \"relative\",\n display: \"inline-block\",\n userSelect: \"none\",\n ...styles.icon,\n }}\n />\n\n <ui.span\n className=\"ui-radio__label\"\n {...getLabelProps(labelProps)}\n __css={{ ...styles.label }}\n >\n {children}\n </ui.span>\n </ui.label>\n )\n },\n) as {\n <Y extends string | number = string>(\n props: RadioProps<Y> & RefAttributes<HTMLInputElement>,\n ): JSX.Element\n} & ComponentArgs\n\nRadio.displayName = \"Radio\"\n"],"mappings":";;;;;;AAMA,SAAS,IAAI,wBAAwB,sBAAsB;AAE3D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAElC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP,SAAS,YAAY,aAAa,WAAW,OAAO,gBAAgB;AAsS9D,SAaE,KAbF;AAnQC,IAAM,WAAW,CAGtB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA4B;AAC1B,yBAAO,MAAM;AACb,QAAM;AAAA,IACJ,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,UAAU;AAAA,IACV,GA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A;AAAA;AAAA,YAAC,GAAG;AAAA,YAAH;AAAA,cACC,WAAU;AAAA,cACT,GAAG;AAAA,gBACF;AAAA,kBACE,GAAG;AAAA,kBACH;AAAA,gBACF;AAAA,gBACA;AAAA,cACF;AAAA;AAAA,UACF;AAAA,UAEA;AAAA,YAAC,GAAG;AAAA,YAAH;AAAA,cACC,WAAU;AAAA,cACT,GAAG,aAAa,SAAS;AAAA,cAC1B,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,SAAS;AAAA,gBACT,YAAY;AAAA,gBACZ,GAAG,OAAO;AAAA,cACZ;AAAA;AAAA,UACF;AAAA,UAEA;AAAA,YAAC,GAAG;AAAA,YAAH;AAAA,cACC,WAAU;AAAA,cACT,GAAG,cAAc,UAAU;AAAA,cAC5B,OAAO,EAAE,GAAG,OAAO,MAAM;AAAA,cAExB;AAAA;AAAA,UACH;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAMA,MAAM,cAAc;","names":["props"]}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use client"
|
2
|
+
|
3
|
+
// src/radio-context.ts
|
4
|
+
import { createContext } from "@yamada-ui/utils";
|
5
|
+
var [RadioGroupProvider, useRadioGroupContext] = createContext({
|
6
|
+
strict: false,
|
7
|
+
name: "RadioGroupContext"
|
8
|
+
});
|
9
|
+
|
10
|
+
export {
|
11
|
+
RadioGroupProvider,
|
12
|
+
useRadioGroupContext
|
13
|
+
};
|
14
|
+
//# sourceMappingURL=chunk-YWRIETVW.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/radio-context.ts"],"sourcesContent":["import type { ThemeProps } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport { createContext } from \"@yamada-ui/utils\"\nimport type { ChangeEvent } from \"react\"\n\nexport interface RadioGroupContext\n extends ThemeProps<\"Radio\">,\n FormControlOptions {\n name: string\n value: string | number\n onChange: (evOrValue: ChangeEvent<HTMLInputElement> | string | number) => void\n}\n\nexport const [RadioGroupProvider, useRadioGroupContext] = createContext<\n RadioGroupContext | undefined\n>({\n strict: false,\n name: \"RadioGroupContext\",\n})\n"],"mappings":";;;AAEA,SAAS,qBAAqB;AAWvB,IAAM,CAAC,oBAAoB,oBAAoB,IAAI,cAExD;AAAA,EACA,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;","names":[]}
|
package/dist/index.d.mts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export { Radio, RadioProps, UseRadioProps, UseRadioReturn, useRadio } from './radio.mjs';
|
2
2
|
export { RadioGroup, RadioGroupProps, RadioItem, UseRadioGroupProps, UseRadioGroupReturn, useRadioGroup } from './radio-group.mjs';
|
3
|
+
import '@yamada-ui/form-control';
|
3
4
|
import 'react';
|
4
5
|
import '@yamada-ui/core';
|
5
|
-
import '@yamada-ui/form-control';
|
6
6
|
import '@yamada-ui/utils';
|
7
7
|
import '@yamada-ui/layouts';
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export { Radio, RadioProps, UseRadioProps, UseRadioReturn, useRadio } from './radio.js';
|
2
2
|
export { RadioGroup, RadioGroupProps, RadioItem, UseRadioGroupProps, UseRadioGroupReturn, useRadioGroup } from './radio-group.js';
|
3
|
+
import '@yamada-ui/form-control';
|
3
4
|
import 'react';
|
4
5
|
import '@yamada-ui/core';
|
5
|
-
import '@yamada-ui/form-control';
|
6
6
|
import '@yamada-ui/utils';
|
7
7
|
import '@yamada-ui/layouts';
|