@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
package/dist/radio.d.mts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import * as
|
2
|
-
import { ChangeEventHandler, Ref, InputHTMLAttributes } from 'react';
|
3
|
-
import { UIPropGetter, HTMLUIProps, ThemeProps, ComponentArgs } from '@yamada-ui/core';
|
1
|
+
import * as _yamada_ui_form_control from '@yamada-ui/form-control';
|
4
2
|
import { FormControlOptions } from '@yamada-ui/form-control';
|
5
|
-
import
|
3
|
+
import * as react from 'react';
|
4
|
+
import { ChangeEventHandler, RefAttributes, InputHTMLAttributes } from 'react';
|
5
|
+
import { PropGetter, HTMLUIProps, ThemeProps, ComponentArgs } from '@yamada-ui/core';
|
6
|
+
import { Dict } from '@yamada-ui/utils';
|
6
7
|
|
7
|
-
|
8
|
+
interface UseRadioProps<Y extends string | number = string> extends FormControlOptions {
|
8
9
|
/**
|
9
10
|
* id assigned to input.
|
10
11
|
*/
|
@@ -33,8 +34,8 @@ type UseRadioProps<Y extends string | number = string> = FormControlOptions & {
|
|
33
34
|
* The callback invoked when the checked state changes.
|
34
35
|
*/
|
35
36
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
36
|
-
}
|
37
|
-
declare const useRadio: <Y extends string | number = string, M extends Dict = Dict
|
37
|
+
}
|
38
|
+
declare const useRadio: <Y extends string | number = string, M extends Dict = Dict<any>>({ id, ...props }: UseRadioProps<Y> & M) => {
|
38
39
|
props: Omit<Omit<{
|
39
40
|
_hover?: {} | undefined;
|
40
41
|
_active?: {} | undefined;
|
@@ -49,74 +50,37 @@ declare const useRadio: <Y extends string | number = string, M extends Dict = Di
|
|
49
50
|
"aria-readonly": boolean | undefined;
|
50
51
|
"aria-required": boolean | undefined;
|
51
52
|
"aria-invalid": boolean | undefined;
|
52
|
-
"data-readonly": boolean | "
|
53
|
+
"data-readonly": boolean | "false" | "true";
|
53
54
|
onFocus: (event: react.FocusEvent<HTMLElement, Element>) => void;
|
54
55
|
onBlur: (event: react.FocusEvent<HTMLElement, Element>) => void;
|
55
|
-
} & Omit<
|
56
|
-
id?: string;
|
57
|
-
onFocus?: react.FocusEventHandler<HTMLElement> | undefined;
|
58
|
-
onBlur?: react.FocusEventHandler<HTMLElement> | undefined;
|
59
|
-
disabled?: boolean;
|
60
|
-
readOnly?: boolean;
|
61
|
-
required?: boolean;
|
62
|
-
} & {
|
56
|
+
} & Omit<_yamada_ui_form_control.UseFormControlProps<HTMLElement> & {
|
63
57
|
id: string;
|
64
|
-
} & Omit<
|
65
|
-
/**
|
66
|
-
* id assigned to input.
|
67
|
-
*/
|
68
|
-
id?: string;
|
69
|
-
/**
|
70
|
-
* The name of the input field in a radio.
|
71
|
-
*/
|
72
|
-
name?: string;
|
73
|
-
/**
|
74
|
-
* The value to be used in the radio button.
|
75
|
-
*/
|
76
|
-
value?: Y | undefined;
|
77
|
-
/**
|
78
|
-
* If `true`, the radio will be initially checked.
|
79
|
-
*
|
80
|
-
* @default false
|
81
|
-
*/
|
82
|
-
defaultIsChecked?: boolean;
|
83
|
-
/**
|
84
|
-
* If `true`, the radio will be checked.
|
85
|
-
*
|
86
|
-
* @default false
|
87
|
-
*/
|
88
|
-
isChecked?: boolean;
|
89
|
-
/**
|
90
|
-
* The callback invoked when the checked state changes.
|
91
|
-
*/
|
92
|
-
onChange?: ChangeEventHandler<HTMLInputElement>;
|
93
|
-
} & M, "id">, "disabled" | "isDisabled" | "id" | "onFocus" | "onBlur" | "readOnly" | "required" | "isRequired" | "isInvalid" | "isReadOnly">, "value" | "name" | "id" | "onChange" | "defaultIsChecked" | "isChecked">, "disabled" | "aria-disabled" | "_invalid" | "_hover" | "_active" | "_focus" | "_focusVisible" | "aria-invalid" | "aria-readonly" | "aria-required" | "onFocus" | "onBlur" | "readOnly" | "required" | "data-readonly">;
|
58
|
+
} & Omit<UseRadioProps<Y> & M, "id">, "disabled" | "isDisabled" | "id" | "onFocus" | "onBlur" | "readOnly" | "required" | "isRequired" | "isInvalid" | "isReadOnly">, "value" | "name" | "id" | "onChange" | "defaultIsChecked" | "isChecked">, "disabled" | "aria-disabled" | "_invalid" | "_hover" | "_active" | "_focus" | "_focusVisible" | "aria-invalid" | "aria-readonly" | "aria-required" | "onFocus" | "onBlur" | "readOnly" | "required" | "data-readonly">;
|
94
59
|
isFocusVisible: boolean;
|
95
60
|
isFocused: boolean;
|
96
61
|
isHovered: boolean;
|
97
62
|
isActive: boolean;
|
98
63
|
isChecked: boolean;
|
99
|
-
getContainerProps:
|
100
|
-
getInputProps: PropGetter
|
101
|
-
getIconProps:
|
102
|
-
getLabelProps: PropGetter
|
64
|
+
getContainerProps: PropGetter<"label", undefined>;
|
65
|
+
getInputProps: PropGetter<"input", undefined>;
|
66
|
+
getIconProps: PropGetter<"span", undefined>;
|
67
|
+
getLabelProps: PropGetter<"span", undefined>;
|
103
68
|
};
|
104
69
|
type UseRadioReturn = ReturnType<typeof useRadio>;
|
105
|
-
|
70
|
+
interface RadioOptions {
|
106
71
|
iconProps?: HTMLUIProps<"span">;
|
107
72
|
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
108
73
|
labelProps?: HTMLUIProps<"span">;
|
109
|
-
}
|
110
|
-
|
74
|
+
}
|
75
|
+
interface RadioProps<Y extends string | number = string> extends Omit<HTMLUIProps<"label">, keyof UseRadioProps>, ThemeProps<"Radio">, UseRadioProps<Y>, RadioOptions {
|
76
|
+
}
|
111
77
|
/**
|
112
78
|
* `Radio` is a component used for allowing users to select one option from multiple choices.
|
113
79
|
*
|
114
80
|
* @see Docs https://yamada-ui.com/components/forms/radio
|
115
81
|
*/
|
116
82
|
declare const Radio: {
|
117
|
-
<Y extends string | number = string>(props: RadioProps<Y> &
|
118
|
-
ref?: Ref<HTMLInputElement>;
|
119
|
-
}): JSX.Element;
|
83
|
+
<Y extends string | number = string>(props: RadioProps<Y> & RefAttributes<HTMLInputElement>): JSX.Element;
|
120
84
|
} & ComponentArgs;
|
121
85
|
|
122
86
|
export { Radio, type RadioProps, type UseRadioProps, type UseRadioReturn, useRadio };
|
package/dist/radio.d.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import * as
|
2
|
-
import { ChangeEventHandler, Ref, InputHTMLAttributes } from 'react';
|
3
|
-
import { UIPropGetter, HTMLUIProps, ThemeProps, ComponentArgs } from '@yamada-ui/core';
|
1
|
+
import * as _yamada_ui_form_control from '@yamada-ui/form-control';
|
4
2
|
import { FormControlOptions } from '@yamada-ui/form-control';
|
5
|
-
import
|
3
|
+
import * as react from 'react';
|
4
|
+
import { ChangeEventHandler, RefAttributes, InputHTMLAttributes } from 'react';
|
5
|
+
import { PropGetter, HTMLUIProps, ThemeProps, ComponentArgs } from '@yamada-ui/core';
|
6
|
+
import { Dict } from '@yamada-ui/utils';
|
6
7
|
|
7
|
-
|
8
|
+
interface UseRadioProps<Y extends string | number = string> extends FormControlOptions {
|
8
9
|
/**
|
9
10
|
* id assigned to input.
|
10
11
|
*/
|
@@ -33,8 +34,8 @@ type UseRadioProps<Y extends string | number = string> = FormControlOptions & {
|
|
33
34
|
* The callback invoked when the checked state changes.
|
34
35
|
*/
|
35
36
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
36
|
-
}
|
37
|
-
declare const useRadio: <Y extends string | number = string, M extends Dict = Dict
|
37
|
+
}
|
38
|
+
declare const useRadio: <Y extends string | number = string, M extends Dict = Dict<any>>({ id, ...props }: UseRadioProps<Y> & M) => {
|
38
39
|
props: Omit<Omit<{
|
39
40
|
_hover?: {} | undefined;
|
40
41
|
_active?: {} | undefined;
|
@@ -49,74 +50,37 @@ declare const useRadio: <Y extends string | number = string, M extends Dict = Di
|
|
49
50
|
"aria-readonly": boolean | undefined;
|
50
51
|
"aria-required": boolean | undefined;
|
51
52
|
"aria-invalid": boolean | undefined;
|
52
|
-
"data-readonly": boolean | "
|
53
|
+
"data-readonly": boolean | "false" | "true";
|
53
54
|
onFocus: (event: react.FocusEvent<HTMLElement, Element>) => void;
|
54
55
|
onBlur: (event: react.FocusEvent<HTMLElement, Element>) => void;
|
55
|
-
} & Omit<
|
56
|
-
id?: string;
|
57
|
-
onFocus?: react.FocusEventHandler<HTMLElement> | undefined;
|
58
|
-
onBlur?: react.FocusEventHandler<HTMLElement> | undefined;
|
59
|
-
disabled?: boolean;
|
60
|
-
readOnly?: boolean;
|
61
|
-
required?: boolean;
|
62
|
-
} & {
|
56
|
+
} & Omit<_yamada_ui_form_control.UseFormControlProps<HTMLElement> & {
|
63
57
|
id: string;
|
64
|
-
} & Omit<
|
65
|
-
/**
|
66
|
-
* id assigned to input.
|
67
|
-
*/
|
68
|
-
id?: string;
|
69
|
-
/**
|
70
|
-
* The name of the input field in a radio.
|
71
|
-
*/
|
72
|
-
name?: string;
|
73
|
-
/**
|
74
|
-
* The value to be used in the radio button.
|
75
|
-
*/
|
76
|
-
value?: Y | undefined;
|
77
|
-
/**
|
78
|
-
* If `true`, the radio will be initially checked.
|
79
|
-
*
|
80
|
-
* @default false
|
81
|
-
*/
|
82
|
-
defaultIsChecked?: boolean;
|
83
|
-
/**
|
84
|
-
* If `true`, the radio will be checked.
|
85
|
-
*
|
86
|
-
* @default false
|
87
|
-
*/
|
88
|
-
isChecked?: boolean;
|
89
|
-
/**
|
90
|
-
* The callback invoked when the checked state changes.
|
91
|
-
*/
|
92
|
-
onChange?: ChangeEventHandler<HTMLInputElement>;
|
93
|
-
} & M, "id">, "disabled" | "isDisabled" | "id" | "onFocus" | "onBlur" | "readOnly" | "required" | "isRequired" | "isInvalid" | "isReadOnly">, "value" | "name" | "id" | "onChange" | "defaultIsChecked" | "isChecked">, "disabled" | "aria-disabled" | "_invalid" | "_hover" | "_active" | "_focus" | "_focusVisible" | "aria-invalid" | "aria-readonly" | "aria-required" | "onFocus" | "onBlur" | "readOnly" | "required" | "data-readonly">;
|
58
|
+
} & Omit<UseRadioProps<Y> & M, "id">, "disabled" | "isDisabled" | "id" | "onFocus" | "onBlur" | "readOnly" | "required" | "isRequired" | "isInvalid" | "isReadOnly">, "value" | "name" | "id" | "onChange" | "defaultIsChecked" | "isChecked">, "disabled" | "aria-disabled" | "_invalid" | "_hover" | "_active" | "_focus" | "_focusVisible" | "aria-invalid" | "aria-readonly" | "aria-required" | "onFocus" | "onBlur" | "readOnly" | "required" | "data-readonly">;
|
94
59
|
isFocusVisible: boolean;
|
95
60
|
isFocused: boolean;
|
96
61
|
isHovered: boolean;
|
97
62
|
isActive: boolean;
|
98
63
|
isChecked: boolean;
|
99
|
-
getContainerProps:
|
100
|
-
getInputProps: PropGetter
|
101
|
-
getIconProps:
|
102
|
-
getLabelProps: PropGetter
|
64
|
+
getContainerProps: PropGetter<"label", undefined>;
|
65
|
+
getInputProps: PropGetter<"input", undefined>;
|
66
|
+
getIconProps: PropGetter<"span", undefined>;
|
67
|
+
getLabelProps: PropGetter<"span", undefined>;
|
103
68
|
};
|
104
69
|
type UseRadioReturn = ReturnType<typeof useRadio>;
|
105
|
-
|
70
|
+
interface RadioOptions {
|
106
71
|
iconProps?: HTMLUIProps<"span">;
|
107
72
|
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
108
73
|
labelProps?: HTMLUIProps<"span">;
|
109
|
-
}
|
110
|
-
|
74
|
+
}
|
75
|
+
interface RadioProps<Y extends string | number = string> extends Omit<HTMLUIProps<"label">, keyof UseRadioProps>, ThemeProps<"Radio">, UseRadioProps<Y>, RadioOptions {
|
76
|
+
}
|
111
77
|
/**
|
112
78
|
* `Radio` is a component used for allowing users to select one option from multiple choices.
|
113
79
|
*
|
114
80
|
* @see Docs https://yamada-ui.com/components/forms/radio
|
115
81
|
*/
|
116
82
|
declare const Radio: {
|
117
|
-
<Y extends string | number = string>(props: RadioProps<Y> &
|
118
|
-
ref?: Ref<HTMLInputElement>;
|
119
|
-
}): JSX.Element;
|
83
|
+
<Y extends string | number = string>(props: RadioProps<Y> & RefAttributes<HTMLInputElement>): JSX.Element;
|
120
84
|
} & ComponentArgs;
|
121
85
|
|
122
86
|
export { Radio, type RadioProps, type UseRadioProps, type UseRadioReturn, useRadio };
|
package/dist/radio.js
CHANGED
@@ -26,175 +26,25 @@ __export(radio_exports, {
|
|
26
26
|
});
|
27
27
|
module.exports = __toCommonJS(radio_exports);
|
28
28
|
var import_core = require("@yamada-ui/core");
|
29
|
-
var
|
29
|
+
var import_form_control = require("@yamada-ui/form-control");
|
30
30
|
var import_use_focus_visible = require("@yamada-ui/use-focus-visible");
|
31
31
|
var import_utils2 = require("@yamada-ui/utils");
|
32
|
-
var
|
32
|
+
var import_react = require("react");
|
33
33
|
|
34
|
-
// src/radio-
|
35
|
-
var import_form_control = require("@yamada-ui/form-control");
|
36
|
-
var import_layouts = require("@yamada-ui/layouts");
|
37
|
-
var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
|
34
|
+
// src/radio-context.ts
|
38
35
|
var import_utils = require("@yamada-ui/utils");
|
39
|
-
var import_react = require("react");
|
40
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
41
|
-
var isEvent = (value) => value && (0, import_utils.isObject)(value) && (0, import_utils.isObject)(value.target);
|
42
|
-
var useRadioGroup = ({
|
43
|
-
id,
|
44
|
-
name,
|
45
|
-
isNative,
|
46
|
-
value: valueProp,
|
47
|
-
defaultValue,
|
48
|
-
onChange: onChangeProp,
|
49
|
-
...props
|
50
|
-
}) => {
|
51
|
-
id != null ? id : id = (0, import_react.useId)();
|
52
|
-
name != null ? name : name = `radio-${id}`;
|
53
|
-
const onChangeRef = (0, import_utils.useCallbackRef)(onChangeProp);
|
54
|
-
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
55
|
-
value: valueProp,
|
56
|
-
defaultValue,
|
57
|
-
onChange: onChangeRef
|
58
|
-
});
|
59
|
-
const containerRef = (0, import_react.useRef)(null);
|
60
|
-
const onFocus = (0, import_react.useCallback)(() => {
|
61
|
-
const container = containerRef.current;
|
62
|
-
if (!container) return;
|
63
|
-
let query = `input:not(:disabled):checked`;
|
64
|
-
let firstInput = container.querySelector(query);
|
65
|
-
if (firstInput) {
|
66
|
-
firstInput.focus();
|
67
|
-
} else {
|
68
|
-
query = `input:not(:disabled)`;
|
69
|
-
firstInput = container.querySelector(query);
|
70
|
-
firstInput == null ? void 0 : firstInput.focus();
|
71
|
-
}
|
72
|
-
}, []);
|
73
|
-
const onChange = (0, import_react.useCallback)(
|
74
|
-
(evOrValue) => {
|
75
|
-
const nextValue = isEvent(evOrValue) ? evOrValue.target.value : evOrValue;
|
76
|
-
setValue(nextValue);
|
77
|
-
},
|
78
|
-
[setValue]
|
79
|
-
);
|
80
|
-
const getContainerProps = (0, import_react.useCallback)(
|
81
|
-
(props2 = {}, ref = null) => ({
|
82
|
-
role: "radiogroup",
|
83
|
-
...props2,
|
84
|
-
ref: (0, import_utils.mergeRefs)(ref, containerRef)
|
85
|
-
}),
|
86
|
-
[]
|
87
|
-
);
|
88
|
-
const getRadioProps = (0, import_react.useCallback)(
|
89
|
-
(props2 = {}, ref = null) => {
|
90
|
-
const isChecked = props2.value === value;
|
91
|
-
return {
|
92
|
-
...props2,
|
93
|
-
ref,
|
94
|
-
name,
|
95
|
-
[isNative ? "checked" : "isChecked"]: value != null ? isChecked : void 0,
|
96
|
-
"aria-checked": isChecked,
|
97
|
-
onChange
|
98
|
-
};
|
99
|
-
},
|
100
|
-
[name, value, onChange, isNative]
|
101
|
-
);
|
102
|
-
return {
|
103
|
-
props,
|
104
|
-
id,
|
105
|
-
name,
|
106
|
-
value,
|
107
|
-
setValue,
|
108
|
-
onChange,
|
109
|
-
onFocus,
|
110
|
-
getContainerProps,
|
111
|
-
getRadioProps
|
112
|
-
};
|
113
|
-
};
|
114
36
|
var [RadioGroupProvider, useRadioGroupContext] = (0, import_utils.createContext)({
|
115
37
|
strict: false,
|
116
38
|
name: "RadioGroupContext"
|
117
39
|
});
|
118
|
-
var RadioGroup = (0, import_react.forwardRef)(
|
119
|
-
({
|
120
|
-
id: idProp,
|
121
|
-
className,
|
122
|
-
size,
|
123
|
-
variant,
|
124
|
-
colorScheme,
|
125
|
-
children,
|
126
|
-
items = [],
|
127
|
-
direction = "column",
|
128
|
-
gap,
|
129
|
-
...props
|
130
|
-
}, ref) => {
|
131
|
-
const {
|
132
|
-
labelId,
|
133
|
-
isRequired,
|
134
|
-
isReadOnly,
|
135
|
-
isDisabled,
|
136
|
-
isInvalid,
|
137
|
-
...computedProps
|
138
|
-
} = (0, import_form_control.useFormControl)({
|
139
|
-
id: idProp,
|
140
|
-
...props
|
141
|
-
});
|
142
|
-
const {
|
143
|
-
id,
|
144
|
-
name,
|
145
|
-
value,
|
146
|
-
onChange,
|
147
|
-
getContainerProps,
|
148
|
-
props: rest
|
149
|
-
} = useRadioGroup(computedProps);
|
150
|
-
const validChildren = (0, import_utils.getValidChildren)(children);
|
151
|
-
let computedChildren = [];
|
152
|
-
if (!validChildren.length && items.length) {
|
153
|
-
computedChildren = items.map(({ label, value: value2, ...props2 }, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Radio, { value: value2, ...props2, children: label }, i));
|
154
|
-
}
|
155
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
156
|
-
RadioGroupProvider,
|
157
|
-
{
|
158
|
-
value: {
|
159
|
-
size,
|
160
|
-
variant,
|
161
|
-
colorScheme,
|
162
|
-
isRequired,
|
163
|
-
isReadOnly,
|
164
|
-
isDisabled,
|
165
|
-
isInvalid,
|
166
|
-
name,
|
167
|
-
value,
|
168
|
-
onChange
|
169
|
-
},
|
170
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
171
|
-
import_layouts.Flex,
|
172
|
-
{
|
173
|
-
ref,
|
174
|
-
className: (0, import_utils.cx)("ui-radio-group", className),
|
175
|
-
gap: gap != null ? gap : direction === "row" ? "1rem" : void 0,
|
176
|
-
...getContainerProps({
|
177
|
-
id,
|
178
|
-
"aria-labelledby": labelId,
|
179
|
-
...rest
|
180
|
-
}),
|
181
|
-
direction,
|
182
|
-
children: children != null ? children : computedChildren
|
183
|
-
}
|
184
|
-
)
|
185
|
-
}
|
186
|
-
);
|
187
|
-
}
|
188
|
-
);
|
189
|
-
RadioGroup.displayName = "RadioGroup";
|
190
40
|
|
191
41
|
// src/radio.tsx
|
192
|
-
var
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
193
43
|
var useRadio = ({
|
194
44
|
id,
|
195
45
|
...props
|
196
46
|
}) => {
|
197
|
-
id != null ? id : id = (0,
|
47
|
+
id != null ? id : id = (0, import_react.useId)();
|
198
48
|
const {
|
199
49
|
id: _id,
|
200
50
|
name,
|
@@ -203,7 +53,7 @@ var useRadio = ({
|
|
203
53
|
defaultIsChecked,
|
204
54
|
onChange: onChangeProp,
|
205
55
|
...computedProps
|
206
|
-
} = (0,
|
56
|
+
} = (0, import_form_control.useFormControlProps)({ id, ...props });
|
207
57
|
const [
|
208
58
|
{
|
209
59
|
"aria-readonly": _ariaReadonly,
|
@@ -215,15 +65,15 @@ var useRadio = ({
|
|
215
65
|
...formControlProps
|
216
66
|
},
|
217
67
|
rest
|
218
|
-
] = (0, import_utils2.splitObject)(computedProps,
|
219
|
-
const [isFocusVisible, setIsFocusVisible] = (0,
|
220
|
-
const [isFocused, setFocused] = (0,
|
221
|
-
const [isHovered, setHovered] = (0,
|
222
|
-
const [isActive, setActive] = (0,
|
223
|
-
const [isChecked, setIsChecked] = (0,
|
68
|
+
] = (0, import_utils2.splitObject)(computedProps, import_form_control.formControlProperties);
|
69
|
+
const [isFocusVisible, setIsFocusVisible] = (0, import_react.useState)(false);
|
70
|
+
const [isFocused, setFocused] = (0, import_react.useState)(false);
|
71
|
+
const [isHovered, setHovered] = (0, import_react.useState)(false);
|
72
|
+
const [isActive, setActive] = (0, import_react.useState)(false);
|
73
|
+
const [isChecked, setIsChecked] = (0, import_react.useState)(!!defaultIsChecked);
|
224
74
|
const isControlled = isCheckedProp !== void 0;
|
225
75
|
const checked = isControlled ? isCheckedProp : isChecked;
|
226
|
-
(0,
|
76
|
+
(0, import_react.useEffect)(() => {
|
227
77
|
return (0, import_use_focus_visible.trackFocusVisible)(setIsFocusVisible);
|
228
78
|
}, []);
|
229
79
|
const onChange = (0, import_utils2.useCallbackRef)(
|
@@ -239,19 +89,19 @@ var useRadio = ({
|
|
239
89
|
);
|
240
90
|
const onFocus = (0, import_utils2.useCallbackRef)(onFocusProp);
|
241
91
|
const onBlur = (0, import_utils2.useCallbackRef)(onBlurProp);
|
242
|
-
const onKeyDown = (0,
|
92
|
+
const onKeyDown = (0, import_react.useCallback)(
|
243
93
|
({ key }) => {
|
244
94
|
if (key === " ") setActive(true);
|
245
95
|
},
|
246
96
|
[setActive]
|
247
97
|
);
|
248
|
-
const onKeyUp = (0,
|
98
|
+
const onKeyUp = (0, import_react.useCallback)(
|
249
99
|
({ key }) => {
|
250
100
|
if (key === " ") setActive(false);
|
251
101
|
},
|
252
102
|
[setActive]
|
253
103
|
);
|
254
|
-
const getContainerProps = (0,
|
104
|
+
const getContainerProps = (0, import_react.useCallback)(
|
255
105
|
(props2 = {}, ref = null) => ({
|
256
106
|
...formControlProps,
|
257
107
|
...props2,
|
@@ -260,7 +110,7 @@ var useRadio = ({
|
|
260
110
|
}),
|
261
111
|
[checked, formControlProps]
|
262
112
|
);
|
263
|
-
const getIconProps = (0,
|
113
|
+
const getIconProps = (0, import_react.useCallback)(
|
264
114
|
(props2 = {}, ref = null) => ({
|
265
115
|
...formControlProps,
|
266
116
|
...props2,
|
@@ -271,14 +121,14 @@ var useRadio = ({
|
|
271
121
|
"data-focus": (0, import_utils2.dataAttr)(isFocused),
|
272
122
|
"data-focus-visible": (0, import_utils2.dataAttr)(isFocused && isFocusVisible),
|
273
123
|
"aria-hidden": true,
|
274
|
-
onMouseDown: (0, import_utils2.handlerAll)(props2.onMouseDown, () => setActive(true)),
|
275
|
-
onMouseUp: (0, import_utils2.handlerAll)(props2.onMouseUp, () => setActive(false)),
|
276
|
-
onMouseEnter: (0, import_utils2.handlerAll)(props2.onMouseEnter, () => setHovered(true)),
|
277
|
-
onMouseLeave: (0, import_utils2.handlerAll)(props2.onMouseLeave, () => setHovered(false))
|
124
|
+
onMouseDown: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseDown, () => setActive(true)),
|
125
|
+
onMouseUp: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseUp, () => setActive(false)),
|
126
|
+
onMouseEnter: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseEnter, () => setHovered(true)),
|
127
|
+
onMouseLeave: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseLeave, () => setHovered(false))
|
278
128
|
}),
|
279
129
|
[checked, isActive, isFocused, isFocusVisible, isHovered, formControlProps]
|
280
130
|
);
|
281
|
-
const getInputProps = (0,
|
131
|
+
const getInputProps = (0, import_react.useCallback)(
|
282
132
|
(props2 = {}, ref = null) => ({
|
283
133
|
...formControlProps,
|
284
134
|
...props2,
|
@@ -303,11 +153,11 @@ var useRadio = ({
|
|
303
153
|
whiteSpace: "nowrap",
|
304
154
|
position: "absolute"
|
305
155
|
},
|
306
|
-
onChange: (0, import_utils2.handlerAll)(props2.onChange, onChange),
|
307
|
-
onBlur: (0, import_utils2.handlerAll)(props2.onBlur, onBlur, () => setFocused(false)),
|
308
|
-
onFocus: (0, import_utils2.handlerAll)(props2.onFocus, onFocus, () => setFocused(true)),
|
309
|
-
onKeyDown: (0, import_utils2.handlerAll)(props2.onKeyDown, onKeyDown),
|
310
|
-
onKeyUp: (0, import_utils2.handlerAll)(props2.onKeyUp, onKeyUp)
|
156
|
+
onChange: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onChange, onChange),
|
157
|
+
onBlur: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onBlur, onBlur, () => setFocused(false)),
|
158
|
+
onFocus: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onFocus, onFocus, () => setFocused(true)),
|
159
|
+
onKeyDown: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onKeyDown, onKeyDown),
|
160
|
+
onKeyUp: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onKeyUp, onKeyUp)
|
311
161
|
}),
|
312
162
|
[
|
313
163
|
formControlProps,
|
@@ -325,16 +175,16 @@ var useRadio = ({
|
|
325
175
|
onKeyUp
|
326
176
|
]
|
327
177
|
);
|
328
|
-
const getLabelProps = (0,
|
178
|
+
const getLabelProps = (0, import_react.useCallback)(
|
329
179
|
(props2 = {}, ref = null) => ({
|
330
180
|
...formControlProps,
|
331
181
|
...props2,
|
332
182
|
ref,
|
333
|
-
onMouseDown: (0, import_utils2.handlerAll)(props2.onMouseDown, (ev) => {
|
183
|
+
onMouseDown: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onMouseDown, (ev) => {
|
334
184
|
ev.preventDefault();
|
335
185
|
ev.stopPropagation();
|
336
186
|
}),
|
337
|
-
onTouchStart: (0, import_utils2.handlerAll)(props2.onTouchStart, (ev) => {
|
187
|
+
onTouchStart: (0, import_utils2.handlerAll)(props2 == null ? void 0 : props2.onTouchStart, (ev) => {
|
338
188
|
ev.preventDefault();
|
339
189
|
ev.stopPropagation();
|
340
190
|
}),
|
@@ -355,13 +205,13 @@ var useRadio = ({
|
|
355
205
|
getLabelProps
|
356
206
|
};
|
357
207
|
};
|
358
|
-
var Radio = (0,
|
208
|
+
var Radio = (0, import_react.forwardRef)(
|
359
209
|
(props, ref) => {
|
360
210
|
var _a, _b, _c, _d;
|
361
211
|
const group = useRadioGroupContext();
|
362
212
|
const { value: groupValue, ...groupProps } = { ...group };
|
363
|
-
const control = (0,
|
364
|
-
const [styles, mergedProps] = (0, import_core.
|
213
|
+
const control = (0, import_form_control.useFormControl)(props);
|
214
|
+
const [styles, mergedProps] = (0, import_core.useComponentMultiStyle)("Radio", {
|
365
215
|
...groupProps,
|
366
216
|
...props
|
367
217
|
});
|
@@ -397,7 +247,7 @@ var Radio = (0, import_react2.forwardRef)(
|
|
397
247
|
onChange
|
398
248
|
});
|
399
249
|
const tabIndex = !groupValue ? 0 : isChecked ? 0 : -1;
|
400
|
-
return /* @__PURE__ */ (0,
|
250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
401
251
|
import_core.ui.label,
|
402
252
|
{
|
403
253
|
className: (0, import_utils2.cx)("ui-radio", className),
|
@@ -412,7 +262,7 @@ var Radio = (0, import_react2.forwardRef)(
|
|
412
262
|
...styles.container
|
413
263
|
},
|
414
264
|
children: [
|
415
|
-
/* @__PURE__ */ (0,
|
265
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
416
266
|
import_core.ui.input,
|
417
267
|
{
|
418
268
|
className: "ui-radio__input",
|
@@ -425,7 +275,7 @@ var Radio = (0, import_react2.forwardRef)(
|
|
425
275
|
)
|
426
276
|
}
|
427
277
|
),
|
428
|
-
/* @__PURE__ */ (0,
|
278
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
429
279
|
import_core.ui.span,
|
430
280
|
{
|
431
281
|
className: "ui-radio__icon",
|
@@ -438,7 +288,7 @@ var Radio = (0, import_react2.forwardRef)(
|
|
438
288
|
}
|
439
289
|
}
|
440
290
|
),
|
441
|
-
/* @__PURE__ */ (0,
|
291
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
442
292
|
import_core.ui.span,
|
443
293
|
{
|
444
294
|
className: "ui-radio__label",
|