@yamada-ui/radio 1.2.8-dev-20240915031944 → 1.2.8-dev-20240917033401
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
package/dist/index.js
CHANGED
@@ -30,175 +30,25 @@ module.exports = __toCommonJS(src_exports);
|
|
30
30
|
|
31
31
|
// src/radio.tsx
|
32
32
|
var import_core = require("@yamada-ui/core");
|
33
|
-
var
|
33
|
+
var import_form_control = require("@yamada-ui/form-control");
|
34
34
|
var import_use_focus_visible = require("@yamada-ui/use-focus-visible");
|
35
35
|
var import_utils2 = require("@yamada-ui/utils");
|
36
|
-
var
|
36
|
+
var import_react = require("react");
|
37
37
|
|
38
|
-
// src/radio-
|
39
|
-
var import_form_control = require("@yamada-ui/form-control");
|
40
|
-
var import_layouts = require("@yamada-ui/layouts");
|
41
|
-
var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
|
38
|
+
// src/radio-context.ts
|
42
39
|
var import_utils = require("@yamada-ui/utils");
|
43
|
-
var import_react = require("react");
|
44
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
45
|
-
var isEvent = (value) => value && (0, import_utils.isObject)(value) && (0, import_utils.isObject)(value.target);
|
46
|
-
var useRadioGroup = ({
|
47
|
-
id,
|
48
|
-
name,
|
49
|
-
isNative,
|
50
|
-
value: valueProp,
|
51
|
-
defaultValue,
|
52
|
-
onChange: onChangeProp,
|
53
|
-
...props
|
54
|
-
}) => {
|
55
|
-
id != null ? id : id = (0, import_react.useId)();
|
56
|
-
name != null ? name : name = `radio-${id}`;
|
57
|
-
const onChangeRef = (0, import_utils.useCallbackRef)(onChangeProp);
|
58
|
-
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
59
|
-
value: valueProp,
|
60
|
-
defaultValue,
|
61
|
-
onChange: onChangeRef
|
62
|
-
});
|
63
|
-
const containerRef = (0, import_react.useRef)(null);
|
64
|
-
const onFocus = (0, import_react.useCallback)(() => {
|
65
|
-
const container = containerRef.current;
|
66
|
-
if (!container) return;
|
67
|
-
let query = `input:not(:disabled):checked`;
|
68
|
-
let firstInput = container.querySelector(query);
|
69
|
-
if (firstInput) {
|
70
|
-
firstInput.focus();
|
71
|
-
} else {
|
72
|
-
query = `input:not(:disabled)`;
|
73
|
-
firstInput = container.querySelector(query);
|
74
|
-
firstInput == null ? void 0 : firstInput.focus();
|
75
|
-
}
|
76
|
-
}, []);
|
77
|
-
const onChange = (0, import_react.useCallback)(
|
78
|
-
(evOrValue) => {
|
79
|
-
const nextValue = isEvent(evOrValue) ? evOrValue.target.value : evOrValue;
|
80
|
-
setValue(nextValue);
|
81
|
-
},
|
82
|
-
[setValue]
|
83
|
-
);
|
84
|
-
const getContainerProps = (0, import_react.useCallback)(
|
85
|
-
(props2 = {}, ref = null) => ({
|
86
|
-
role: "radiogroup",
|
87
|
-
...props2,
|
88
|
-
ref: (0, import_utils.mergeRefs)(ref, containerRef)
|
89
|
-
}),
|
90
|
-
[]
|
91
|
-
);
|
92
|
-
const getRadioProps = (0, import_react.useCallback)(
|
93
|
-
(props2 = {}, ref = null) => {
|
94
|
-
const isChecked = props2.value === value;
|
95
|
-
return {
|
96
|
-
...props2,
|
97
|
-
ref,
|
98
|
-
name,
|
99
|
-
[isNative ? "checked" : "isChecked"]: value != null ? isChecked : void 0,
|
100
|
-
"aria-checked": isChecked,
|
101
|
-
onChange
|
102
|
-
};
|
103
|
-
},
|
104
|
-
[name, value, onChange, isNative]
|
105
|
-
);
|
106
|
-
return {
|
107
|
-
props,
|
108
|
-
id,
|
109
|
-
name,
|
110
|
-
value,
|
111
|
-
setValue,
|
112
|
-
onChange,
|
113
|
-
onFocus,
|
114
|
-
getContainerProps,
|
115
|
-
getRadioProps
|
116
|
-
};
|
117
|
-
};
|
118
40
|
var [RadioGroupProvider, useRadioGroupContext] = (0, import_utils.createContext)({
|
119
41
|
strict: false,
|
120
42
|
name: "RadioGroupContext"
|
121
43
|
});
|
122
|
-
var RadioGroup = (0, import_react.forwardRef)(
|
123
|
-
({
|
124
|
-
id: idProp,
|
125
|
-
className,
|
126
|
-
size,
|
127
|
-
variant,
|
128
|
-
colorScheme,
|
129
|
-
children,
|
130
|
-
items = [],
|
131
|
-
direction = "column",
|
132
|
-
gap,
|
133
|
-
...props
|
134
|
-
}, ref) => {
|
135
|
-
const {
|
136
|
-
labelId,
|
137
|
-
isRequired,
|
138
|
-
isReadOnly,
|
139
|
-
isDisabled,
|
140
|
-
isInvalid,
|
141
|
-
...computedProps
|
142
|
-
} = (0, import_form_control.useFormControl)({
|
143
|
-
id: idProp,
|
144
|
-
...props
|
145
|
-
});
|
146
|
-
const {
|
147
|
-
id,
|
148
|
-
name,
|
149
|
-
value,
|
150
|
-
onChange,
|
151
|
-
getContainerProps,
|
152
|
-
props: rest
|
153
|
-
} = useRadioGroup(computedProps);
|
154
|
-
const validChildren = (0, import_utils.getValidChildren)(children);
|
155
|
-
let computedChildren = [];
|
156
|
-
if (!validChildren.length && items.length) {
|
157
|
-
computedChildren = items.map(({ label, value: value2, ...props2 }, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Radio, { value: value2, ...props2, children: label }, i));
|
158
|
-
}
|
159
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
160
|
-
RadioGroupProvider,
|
161
|
-
{
|
162
|
-
value: {
|
163
|
-
size,
|
164
|
-
variant,
|
165
|
-
colorScheme,
|
166
|
-
isRequired,
|
167
|
-
isReadOnly,
|
168
|
-
isDisabled,
|
169
|
-
isInvalid,
|
170
|
-
name,
|
171
|
-
value,
|
172
|
-
onChange
|
173
|
-
},
|
174
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
175
|
-
import_layouts.Flex,
|
176
|
-
{
|
177
|
-
ref,
|
178
|
-
className: (0, import_utils.cx)("ui-radio-group", className),
|
179
|
-
gap: gap != null ? gap : direction === "row" ? "1rem" : void 0,
|
180
|
-
...getContainerProps({
|
181
|
-
id,
|
182
|
-
"aria-labelledby": labelId,
|
183
|
-
...rest
|
184
|
-
}),
|
185
|
-
direction,
|
186
|
-
children: children != null ? children : computedChildren
|
187
|
-
}
|
188
|
-
)
|
189
|
-
}
|
190
|
-
);
|
191
|
-
}
|
192
|
-
);
|
193
|
-
RadioGroup.displayName = "RadioGroup";
|
194
44
|
|
195
45
|
// src/radio.tsx
|
196
|
-
var
|
46
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
197
47
|
var useRadio = ({
|
198
48
|
id,
|
199
49
|
...props
|
200
50
|
}) => {
|
201
|
-
id != null ? id : id = (0,
|
51
|
+
id != null ? id : id = (0, import_react.useId)();
|
202
52
|
const {
|
203
53
|
id: _id,
|
204
54
|
name,
|
@@ -207,7 +57,7 @@ var useRadio = ({
|
|
207
57
|
defaultIsChecked,
|
208
58
|
onChange: onChangeProp,
|
209
59
|
...computedProps
|
210
|
-
} = (0,
|
60
|
+
} = (0, import_form_control.useFormControlProps)({ id, ...props });
|
211
61
|
const [
|
212
62
|
{
|
213
63
|
"aria-readonly": _ariaReadonly,
|
@@ -219,15 +69,15 @@ var useRadio = ({
|
|
219
69
|
...formControlProps
|
220
70
|
},
|
221
71
|
rest
|
222
|
-
] = (0, import_utils2.splitObject)(computedProps,
|
223
|
-
const [isFocusVisible, setIsFocusVisible] = (0,
|
224
|
-
const [isFocused, setFocused] = (0,
|
225
|
-
const [isHovered, setHovered] = (0,
|
226
|
-
const [isActive, setActive] = (0,
|
227
|
-
const [isChecked, setIsChecked] = (0,
|
72
|
+
] = (0, import_utils2.splitObject)(computedProps, import_form_control.formControlProperties);
|
73
|
+
const [isFocusVisible, setIsFocusVisible] = (0, import_react.useState)(false);
|
74
|
+
const [isFocused, setFocused] = (0, import_react.useState)(false);
|
75
|
+
const [isHovered, setHovered] = (0, import_react.useState)(false);
|
76
|
+
const [isActive, setActive] = (0, import_react.useState)(false);
|
77
|
+
const [isChecked, setIsChecked] = (0, import_react.useState)(!!defaultIsChecked);
|
228
78
|
const isControlled = isCheckedProp !== void 0;
|
229
79
|
const checked = isControlled ? isCheckedProp : isChecked;
|
230
|
-
(0,
|
80
|
+
(0, import_react.useEffect)(() => {
|
231
81
|
return (0, import_use_focus_visible.trackFocusVisible)(setIsFocusVisible);
|
232
82
|
}, []);
|
233
83
|
const onChange = (0, import_utils2.useCallbackRef)(
|
@@ -243,19 +93,19 @@ var useRadio = ({
|
|
243
93
|
);
|
244
94
|
const onFocus = (0, import_utils2.useCallbackRef)(onFocusProp);
|
245
95
|
const onBlur = (0, import_utils2.useCallbackRef)(onBlurProp);
|
246
|
-
const onKeyDown = (0,
|
96
|
+
const onKeyDown = (0, import_react.useCallback)(
|
247
97
|
({ key }) => {
|
248
98
|
if (key === " ") setActive(true);
|
249
99
|
},
|
250
100
|
[setActive]
|
251
101
|
);
|
252
|
-
const onKeyUp = (0,
|
102
|
+
const onKeyUp = (0, import_react.useCallback)(
|
253
103
|
({ key }) => {
|
254
104
|
if (key === " ") setActive(false);
|
255
105
|
},
|
256
106
|
[setActive]
|
257
107
|
);
|
258
|
-
const getContainerProps = (0,
|
108
|
+
const getContainerProps = (0, import_react.useCallback)(
|
259
109
|
(props2 = {}, ref = null) => ({
|
260
110
|
...formControlProps,
|
261
111
|
...props2,
|
@@ -264,7 +114,7 @@ var useRadio = ({
|
|
264
114
|
}),
|
265
115
|
[checked, formControlProps]
|
266
116
|
);
|
267
|
-
const getIconProps = (0,
|
117
|
+
const getIconProps = (0, import_react.useCallback)(
|
268
118
|
(props2 = {}, ref = null) => ({
|
269
119
|
...formControlProps,
|
270
120
|
...props2,
|
@@ -275,14 +125,14 @@ var useRadio = ({
|
|
275
125
|
"data-focus": (0, import_utils2.dataAttr)(isFocused),
|
276
126
|
"data-focus-visible": (0, import_utils2.dataAttr)(isFocused && isFocusVisible),
|
277
127
|
"aria-hidden": true,
|
278
|
-
onMouseDown: (0, import_utils2.handlerAll)(props2.onMouseDown, () => setActive(true)),
|
279
|
-
onMouseUp: (0, import_utils2.handlerAll)(props2.onMouseUp, () => setActive(false)),
|
280
|
-
onMouseEnter: (0, import_utils2.handlerAll)(props2.onMouseEnter, () => setHovered(true)),
|
281
|
-
onMouseLeave: (0, import_utils2.handlerAll)(props2.onMouseLeave, () => setHovered(false))
|
128
|
+
onMouseDown: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseDown, () => setActive(true)),
|
129
|
+
onMouseUp: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseUp, () => setActive(false)),
|
130
|
+
onMouseEnter: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseEnter, () => setHovered(true)),
|
131
|
+
onMouseLeave: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseLeave, () => setHovered(false))
|
282
132
|
}),
|
283
133
|
[checked, isActive, isFocused, isFocusVisible, isHovered, formControlProps]
|
284
134
|
);
|
285
|
-
const getInputProps = (0,
|
135
|
+
const getInputProps = (0, import_react.useCallback)(
|
286
136
|
(props2 = {}, ref = null) => ({
|
287
137
|
...formControlProps,
|
288
138
|
...props2,
|
@@ -307,11 +157,11 @@ var useRadio = ({
|
|
307
157
|
whiteSpace: "nowrap",
|
308
158
|
position: "absolute"
|
309
159
|
},
|
310
|
-
onChange: (0, import_utils2.handlerAll)(props2.onChange, onChange),
|
311
|
-
onBlur: (0, import_utils2.handlerAll)(props2.onBlur, onBlur, () => setFocused(false)),
|
312
|
-
onFocus: (0, import_utils2.handlerAll)(props2.onFocus, onFocus, () => setFocused(true)),
|
313
|
-
onKeyDown: (0, import_utils2.handlerAll)(props2.onKeyDown, onKeyDown),
|
314
|
-
onKeyUp: (0, import_utils2.handlerAll)(props2.onKeyUp, onKeyUp)
|
160
|
+
onChange: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onChange, onChange),
|
161
|
+
onBlur: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onBlur, onBlur, () => setFocused(false)),
|
162
|
+
onFocus: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onFocus, onFocus, () => setFocused(true)),
|
163
|
+
onKeyDown: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onKeyDown, onKeyDown),
|
164
|
+
onKeyUp: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onKeyUp, onKeyUp)
|
315
165
|
}),
|
316
166
|
[
|
317
167
|
formControlProps,
|
@@ -329,16 +179,16 @@ var useRadio = ({
|
|
329
179
|
onKeyUp
|
330
180
|
]
|
331
181
|
);
|
332
|
-
const getLabelProps = (0,
|
182
|
+
const getLabelProps = (0, import_react.useCallback)(
|
333
183
|
(props2 = {}, ref = null) => ({
|
334
184
|
...formControlProps,
|
335
185
|
...props2,
|
336
186
|
ref,
|
337
|
-
onMouseDown: (0, import_utils2.handlerAll)(props2.onMouseDown, (ev) => {
|
187
|
+
onMouseDown: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseDown, (ev) => {
|
338
188
|
ev.preventDefault();
|
339
189
|
ev.stopPropagation();
|
340
190
|
}),
|
341
|
-
onTouchStart: (0, import_utils2.handlerAll)(props2.onTouchStart, (ev) => {
|
191
|
+
onTouchStart: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onTouchStart, (ev) => {
|
342
192
|
ev.preventDefault();
|
343
193
|
ev.stopPropagation();
|
344
194
|
}),
|
@@ -359,13 +209,13 @@ var useRadio = ({
|
|
359
209
|
getLabelProps
|
360
210
|
};
|
361
211
|
};
|
362
|
-
var Radio = (0,
|
212
|
+
var Radio = (0, import_react.forwardRef)(
|
363
213
|
(props, ref) => {
|
364
214
|
var _a, _b, _c, _d;
|
365
215
|
const group = useRadioGroupContext();
|
366
216
|
const { value: groupValue, ...groupProps } = { ...group };
|
367
|
-
const control = (0,
|
368
|
-
const [styles, mergedProps] = (0, import_core.
|
217
|
+
const control = (0, import_form_control.useFormControl)(props);
|
218
|
+
const [styles, mergedProps] = (0, import_core.useComponentMultiStyle)("Radio", {
|
369
219
|
...groupProps,
|
370
220
|
...props
|
371
221
|
});
|
@@ -401,7 +251,7 @@ var Radio = (0, import_react2.forwardRef)(
|
|
401
251
|
onChange
|
402
252
|
});
|
403
253
|
const tabIndex = !groupValue ? 0 : isChecked ? 0 : -1;
|
404
|
-
return /* @__PURE__ */ (0,
|
254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
405
255
|
import_core.ui.label,
|
406
256
|
{
|
407
257
|
className: (0, import_utils2.cx)("ui-radio", className),
|
@@ -416,7 +266,7 @@ var Radio = (0, import_react2.forwardRef)(
|
|
416
266
|
...styles.container
|
417
267
|
},
|
418
268
|
children: [
|
419
|
-
/* @__PURE__ */ (0,
|
269
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
420
270
|
import_core.ui.input,
|
421
271
|
{
|
422
272
|
className: "ui-radio__input",
|
@@ -429,7 +279,7 @@ var Radio = (0, import_react2.forwardRef)(
|
|
429
279
|
)
|
430
280
|
}
|
431
281
|
),
|
432
|
-
/* @__PURE__ */ (0,
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
433
283
|
import_core.ui.span,
|
434
284
|
{
|
435
285
|
className: "ui-radio__icon",
|
@@ -442,7 +292,7 @@ var Radio = (0, import_react2.forwardRef)(
|
|
442
292
|
}
|
443
293
|
}
|
444
294
|
),
|
445
|
-
/* @__PURE__ */ (0,
|
295
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
446
296
|
import_core.ui.span,
|
447
297
|
{
|
448
298
|
className: "ui-radio__label",
|
@@ -457,6 +307,159 @@ var Radio = (0, import_react2.forwardRef)(
|
|
457
307
|
}
|
458
308
|
);
|
459
309
|
Radio.displayName = "Radio";
|
310
|
+
|
311
|
+
// src/radio-group.tsx
|
312
|
+
var import_form_control2 = require("@yamada-ui/form-control");
|
313
|
+
var import_layouts = require("@yamada-ui/layouts");
|
314
|
+
var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
|
315
|
+
var import_utils3 = require("@yamada-ui/utils");
|
316
|
+
var import_react2 = require("react");
|
317
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
318
|
+
var isEvent = (value) => value && (0, import_utils3.isObject)(value) && (0, import_utils3.isObject)(value.target);
|
319
|
+
var useRadioGroup = ({
|
320
|
+
id,
|
321
|
+
name,
|
322
|
+
isNative,
|
323
|
+
value: valueProp,
|
324
|
+
defaultValue,
|
325
|
+
onChange: onChangeProp,
|
326
|
+
...props
|
327
|
+
}) => {
|
328
|
+
id != null ? id : id = (0, import_react2.useId)();
|
329
|
+
name != null ? name : name = `radio-${id}`;
|
330
|
+
const onChangeRef = (0, import_utils3.useCallbackRef)(onChangeProp);
|
331
|
+
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
332
|
+
value: valueProp,
|
333
|
+
defaultValue,
|
334
|
+
onChange: onChangeRef
|
335
|
+
});
|
336
|
+
const containerRef = (0, import_react2.useRef)(null);
|
337
|
+
const onFocus = (0, import_react2.useCallback)(() => {
|
338
|
+
const container = containerRef.current;
|
339
|
+
if (!container) return;
|
340
|
+
let query = `input:not(:disabled):checked`;
|
341
|
+
let firstInput = container.querySelector(query);
|
342
|
+
if (firstInput) {
|
343
|
+
firstInput.focus();
|
344
|
+
} else {
|
345
|
+
query = `input:not(:disabled)`;
|
346
|
+
firstInput = container.querySelector(query);
|
347
|
+
firstInput == null ? void 0 : firstInput.focus();
|
348
|
+
}
|
349
|
+
}, []);
|
350
|
+
const onChange = (0, import_react2.useCallback)(
|
351
|
+
(evOrValue) => {
|
352
|
+
const nextValue = isEvent(evOrValue) ? evOrValue.target.value : evOrValue;
|
353
|
+
setValue(nextValue);
|
354
|
+
},
|
355
|
+
[setValue]
|
356
|
+
);
|
357
|
+
const getContainerProps = (0, import_react2.useCallback)(
|
358
|
+
(props2 = {}, ref = null) => ({
|
359
|
+
role: "radiogroup",
|
360
|
+
...props2,
|
361
|
+
ref: (0, import_utils3.mergeRefs)(ref, containerRef)
|
362
|
+
}),
|
363
|
+
[]
|
364
|
+
);
|
365
|
+
const getRadioProps = (0, import_react2.useCallback)(
|
366
|
+
(props2 = {}, ref = null) => {
|
367
|
+
const isChecked = props2.value === value;
|
368
|
+
return {
|
369
|
+
...props2,
|
370
|
+
ref,
|
371
|
+
name,
|
372
|
+
[isNative ? "checked" : "isChecked"]: value != null ? isChecked : void 0,
|
373
|
+
"aria-checked": isChecked,
|
374
|
+
onChange
|
375
|
+
};
|
376
|
+
},
|
377
|
+
[name, value, onChange, isNative]
|
378
|
+
);
|
379
|
+
return {
|
380
|
+
props,
|
381
|
+
id,
|
382
|
+
name,
|
383
|
+
value,
|
384
|
+
setValue,
|
385
|
+
onChange,
|
386
|
+
onFocus,
|
387
|
+
getContainerProps,
|
388
|
+
getRadioProps
|
389
|
+
};
|
390
|
+
};
|
391
|
+
var RadioGroup = (0, import_react2.forwardRef)(
|
392
|
+
({
|
393
|
+
id: idProp,
|
394
|
+
className,
|
395
|
+
size,
|
396
|
+
variant,
|
397
|
+
colorScheme,
|
398
|
+
children,
|
399
|
+
items = [],
|
400
|
+
direction = "column",
|
401
|
+
gap,
|
402
|
+
...props
|
403
|
+
}, ref) => {
|
404
|
+
const {
|
405
|
+
labelId,
|
406
|
+
isRequired,
|
407
|
+
isReadOnly,
|
408
|
+
isDisabled,
|
409
|
+
isInvalid,
|
410
|
+
...computedProps
|
411
|
+
} = (0, import_form_control2.useFormControl)({
|
412
|
+
id: idProp,
|
413
|
+
...props
|
414
|
+
});
|
415
|
+
const {
|
416
|
+
id,
|
417
|
+
name,
|
418
|
+
value,
|
419
|
+
onChange,
|
420
|
+
getContainerProps,
|
421
|
+
props: rest
|
422
|
+
} = useRadioGroup(computedProps);
|
423
|
+
const validChildren = (0, import_utils3.getValidChildren)(children);
|
424
|
+
let computedChildren = [];
|
425
|
+
if (!validChildren.length && items.length) {
|
426
|
+
computedChildren = items.map(({ label, value: value2, ...props2 }, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Radio, { value: value2, ...props2, children: label }, i));
|
427
|
+
}
|
428
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
429
|
+
RadioGroupProvider,
|
430
|
+
{
|
431
|
+
value: {
|
432
|
+
size,
|
433
|
+
variant,
|
434
|
+
colorScheme,
|
435
|
+
isRequired,
|
436
|
+
isReadOnly,
|
437
|
+
isDisabled,
|
438
|
+
isInvalid,
|
439
|
+
name,
|
440
|
+
value,
|
441
|
+
onChange
|
442
|
+
},
|
443
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
444
|
+
import_layouts.Flex,
|
445
|
+
{
|
446
|
+
ref,
|
447
|
+
className: (0, import_utils3.cx)("ui-radio-group", className),
|
448
|
+
gap: gap != null ? gap : direction === "row" ? "1rem" : void 0,
|
449
|
+
...getContainerProps({
|
450
|
+
id,
|
451
|
+
"aria-labelledby": labelId,
|
452
|
+
...rest
|
453
|
+
}),
|
454
|
+
direction,
|
455
|
+
children: children != null ? children : computedChildren
|
456
|
+
}
|
457
|
+
)
|
458
|
+
}
|
459
|
+
);
|
460
|
+
}
|
461
|
+
);
|
462
|
+
RadioGroup.displayName = "RadioGroup";
|
460
463
|
// Annotate the CommonJS export names for ESM import in node:
|
461
464
|
0 && (module.exports = {
|
462
465
|
Radio,
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/radio.tsx","../src/radio-group.tsx"],"sourcesContent":["export { Radio, useRadio } from \"./radio\"\nexport type { RadioProps, UseRadioProps, UseRadioReturn } from \"./radio\"\nexport { RadioGroup, useRadioGroup } from \"./radio-group\"\nexport type {\n RadioItem,\n RadioGroupProps,\n UseRadioGroupProps,\n UseRadioGroupReturn,\n} from \"./radio-group\"\n","import type {\n HTMLUIProps,\n ThemeProps,\n ComponentArgs,\n UIPropGetter,\n} from \"@yamada-ui/core\"\nimport { ui, useMultiComponentStyle, 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, PropGetter } 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 Ref,\n ChangeEvent,\n ChangeEventHandler,\n InputHTMLAttributes,\n KeyboardEvent,\n SyntheticEvent,\n DOMAttributes,\n} from \"react\"\nimport { forwardRef, useCallback, useEffect, useId, useState } from \"react\"\nimport { useRadioGroupContext } from \"./radio-group\"\n\nexport type UseRadioProps<Y extends string | number = string> =\n 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<Element>) => {\n if (key === \" \") setActive(true)\n },\n [setActive],\n )\n\n const onKeyUp = useCallback(\n ({ key }: KeyboardEvent<Element>) => {\n if (key === \" \") setActive(false)\n },\n [setActive],\n )\n\n const getContainerProps: UIPropGetter<\"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: UIPropGetter<\"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 = 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 = 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\ntype RadioOptions = {\n iconProps?: HTMLUIProps<\"span\">\n inputProps?: InputHTMLAttributes<HTMLInputElement>\n labelProps?: HTMLUIProps<\"span\">\n}\n\nexport type RadioProps<Y extends string | number = string> = Omit<\n HTMLUIProps<\"label\">,\n keyof UseRadioProps\n> &\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] = useMultiComponentStyle(\"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 as DOMAttributes<HTMLElement>)}\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> & { ref?: Ref<HTMLInputElement> },\n ): JSX.Element\n} & ComponentArgs\n\nRadio.displayName = \"Radio\"\n","import type { ComponentArgs, ThemeProps, UIPropGetter } 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 type { DOMAttributes, Dict, PropGetter } from \"@yamada-ui/utils\"\nimport {\n createContext,\n cx,\n isObject,\n mergeRefs,\n useCallbackRef,\n getValidChildren,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent, ForwardedRef, Ref, ReactElement } from \"react\"\nimport { useCallback, useId, useRef, forwardRef } from \"react\"\nimport type { RadioProps } from \"./radio\"\nimport { Radio } from \"./radio\"\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 type 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 = string,\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: UIPropGetter<\"input\", { value?: Y }, { value?: Y }> =\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 type RadioGroupProps<Y extends string | number = string> =\n ThemeProps<\"Radio\"> &\n Omit<FlexProps, \"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\ntype RadioGroupContext = ThemeProps<\"Radio\"> &\n FormControlOptions & {\n name: string\n value: string | number\n onChange: (\n evOrValue: ChangeEvent<HTMLInputElement> | string | number,\n ) => void\n }\n\nconst [RadioGroupProvider, useRadioGroupContext] = createContext<\n RadioGroupContext | undefined\n>({\n strict: false,\n name: \"RadioGroupContext\",\n})\n\nexport { useRadioGroupContext }\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 } as DOMAttributes<HTMLElement>)}\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> & { ref?: Ref<HTMLDivElement> },\n ): JSX.Element\n} & ComponentArgs\n\nRadioGroup.displayName = \"RadioGroup\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,kBAA2D;AAE3D,IAAAA,uBAIO;AACP,+BAAkC;AAElC,IAAAC,gBAOO;AAWP,IAAAC,gBAAoE;;;AC/BpE,0BAA+B;AAE/B,qBAAqB;AACrB,oCAAqC;AAErC,mBAOO;AAEP,mBAAuD;AAqN/C;AA7MR,IAAM,UAAU,CAAC,UACf,aAAS,uBAAS,KAAK,SAAK,uBAAS,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,6BAAO,oBAAM;AACb,+BAAS,SAAS,EAAE;AAEpB,QAAM,kBAAc,6BAAe,YAAY;AAE/C,QAAM,CAAC,OAAO,QAAQ,QAAI,oDAAqB;AAAA,IAC7C,OAAO;AAAA,IACP;AAAA,IACA,UAAU;AAAA,EACZ,CAAC;AAED,QAAM,mBAAe,qBAAY,IAAI;AAErC,QAAM,cAAU,0BAAY,MAAM;AAChC,UAAM,YAAY,aAAa;AAE/B,QA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AG;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,eAAG;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,eAAG;AAAA,YAAH;AAAA,cACC,WAAU;AAAA,cACT,GAAG,cAAc,UAAwC;AAAA,cAC1D,OAAO,EAAE,GAAG,OAAO,MAAM;AAAA,cAExB;AAAA;AAAA,UACH;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAMA,MAAM,cAAc;","names":["import_form_control","import_utils","import_react","props","value","props","import_jsx_runtime","props"]}
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/radio.tsx","../src/radio-context.ts","../src/radio-group.tsx"],"sourcesContent":["export { Radio, useRadio } from \"./radio\"\nexport type { RadioProps, UseRadioProps, UseRadioReturn } from \"./radio\"\nexport { RadioGroup, useRadioGroup } from \"./radio-group\"\nexport type {\n RadioItem,\n RadioGroupProps,\n UseRadioGroupProps,\n UseRadioGroupReturn,\n} from \"./radio-group\"\n","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","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","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":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,kBAA2D;AAE3D,0BAIO;AACP,+BAAkC;AAElC,IAAAA,gBAOO;AAUP,mBAAoE;;;AC9BpE,mBAA8B;AAWvB,IAAM,CAAC,oBAAoB,oBAAoB,QAAI,4BAExD;AAAA,EACA,QAAQ;AAAA,EAC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AA,EAEJ;AACF;AAMA,WAAW,cAAc;","names":["import_utils","props","import_form_control","import_utils","import_react","import_jsx_runtime","props","value"]}
|
package/dist/index.mjs
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
|
-
Radio,
|
4
3
|
RadioGroup,
|
5
|
-
useRadio,
|
6
4
|
useRadioGroup
|
7
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-JUEGICB4.mjs";
|
6
|
+
import {
|
7
|
+
Radio,
|
8
|
+
useRadio
|
9
|
+
} from "./chunk-VT4XEFV3.mjs";
|
10
|
+
import "./chunk-YWRIETVW.mjs";
|
8
11
|
export {
|
9
12
|
Radio,
|
10
13
|
RadioGroup,
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import * as react from 'react';
|
2
|
+
import { ChangeEvent } from 'react';
|
3
|
+
import { ThemeProps } from '@yamada-ui/core';
|
4
|
+
import { FormControlOptions } from '@yamada-ui/form-control';
|
5
|
+
|
6
|
+
interface RadioGroupContext extends ThemeProps<"Radio">, FormControlOptions {
|
7
|
+
name: string;
|
8
|
+
value: string | number;
|
9
|
+
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | string | number) => void;
|
10
|
+
}
|
11
|
+
declare const RadioGroupProvider: react.Provider<RadioGroupContext | undefined>;
|
12
|
+
declare const useRadioGroupContext: () => RadioGroupContext | undefined;
|
13
|
+
|
14
|
+
export { type RadioGroupContext, RadioGroupProvider, useRadioGroupContext };
|