@yamada-ui/radio 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -0
- package/dist/radio-group.d.mts +72 -0
- package/dist/radio.d.mts +87 -0
- package/package.json +7 -7
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Radio, RadioProps, UseRadioProps, UseRadioReturn, useRadio } from './radio.mjs';
|
|
2
|
+
export { RadioGroup, RadioGroupProps, UseRadioGroupProps, UseRadioGroupReturn, useRadioGroup } from './radio-group.mjs';
|
|
3
|
+
import '@yamada-ui/core';
|
|
4
|
+
import '@yamada-ui/form-control';
|
|
5
|
+
import '@yamada-ui/utils';
|
|
6
|
+
import 'react';
|
|
7
|
+
import '@yamada-ui/layouts';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ChangeEvent, Ref } from 'react';
|
|
3
|
+
import { ThemeProps, ComponentArgs } from '@yamada-ui/core';
|
|
4
|
+
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
5
|
+
import { FlexProps } from '@yamada-ui/layouts';
|
|
6
|
+
import { PropGetter, DOMAttributes } from '@yamada-ui/utils';
|
|
7
|
+
|
|
8
|
+
type UseRadioGroupProps<Y extends string | number = string> = {
|
|
9
|
+
/**
|
|
10
|
+
* The top-level id string that will be applied to the radios.
|
|
11
|
+
* The index of the radio will be appended to this top-level id.
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The HTML `name` attribute used for forms.
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The value of the radio group.
|
|
20
|
+
*/
|
|
21
|
+
value?: Y;
|
|
22
|
+
/**
|
|
23
|
+
* The initial value of the radio group.
|
|
24
|
+
*/
|
|
25
|
+
defaultValue?: Y;
|
|
26
|
+
/**
|
|
27
|
+
* The callback fired when any children radio is checked or unchecked.
|
|
28
|
+
*/
|
|
29
|
+
onChange?: (value: Y) => void;
|
|
30
|
+
/**
|
|
31
|
+
* If `true`, input elements will receive `checked` attribute instead of `isChecked`.
|
|
32
|
+
*
|
|
33
|
+
* This assumes, you're using native radio inputs.
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
isNative?: boolean;
|
|
38
|
+
};
|
|
39
|
+
declare const useRadioGroup: <Y extends string | number = string>({ id, name, isNative, ...props }: UseRadioGroupProps<Y>) => {
|
|
40
|
+
name: string;
|
|
41
|
+
value: Y;
|
|
42
|
+
setValue: react.Dispatch<react.SetStateAction<Y>>;
|
|
43
|
+
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | Y) => void;
|
|
44
|
+
onFocus: () => void;
|
|
45
|
+
getContainerProps: PropGetter;
|
|
46
|
+
getRadioProps: PropGetter<react.AriaAttributes & react.DOMAttributes<HTMLInputElement> & {
|
|
47
|
+
[dataAttr: string]: any;
|
|
48
|
+
} & {
|
|
49
|
+
id?: string | undefined;
|
|
50
|
+
role?: react.AriaRole | undefined;
|
|
51
|
+
tabIndex?: number | undefined;
|
|
52
|
+
style?: react.CSSProperties | undefined;
|
|
53
|
+
} & {
|
|
54
|
+
isChecked?: boolean | undefined;
|
|
55
|
+
}, Omit<DOMAttributes<HTMLInputElement>, "onChange"> & {
|
|
56
|
+
onChange: (ev: ChangeEvent<HTMLInputElement> | Y) => void;
|
|
57
|
+
}>;
|
|
58
|
+
};
|
|
59
|
+
type UseRadioGroupReturn = ReturnType<typeof useRadioGroup>;
|
|
60
|
+
type RadioGroupProps<Y extends string | number = string> = ThemeProps<'Radio'> & Omit<FlexProps, 'onChange'> & UseRadioGroupProps<Y> & FormControlOptions;
|
|
61
|
+
type RadioGroupContext = ThemeProps<'Radio'> & FormControlOptions & {
|
|
62
|
+
name: string;
|
|
63
|
+
value: string | number;
|
|
64
|
+
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | string | number) => void;
|
|
65
|
+
};
|
|
66
|
+
declare const useRadioGroupContenxt: () => RadioGroupContext | undefined;
|
|
67
|
+
|
|
68
|
+
declare const RadioGroup: (<Y extends string | number = string>(props: ThemeProps<"Radio"> & Omit<FlexProps, "onChange"> & UseRadioGroupProps<Y> & FormControlOptions & {
|
|
69
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
70
|
+
}) => JSX.Element) & ComponentArgs;
|
|
71
|
+
|
|
72
|
+
export { RadioGroup, RadioGroupProps, UseRadioGroupProps, UseRadioGroupReturn, useRadioGroup, useRadioGroupContenxt };
|
package/dist/radio.d.mts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { HTMLUIProps, ThemeProps, ComponentArgs } from '@yamada-ui/core';
|
|
2
|
+
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
3
|
+
import { PropGetter } from '@yamada-ui/utils';
|
|
4
|
+
import { ChangeEventHandler, Ref, InputHTMLAttributes } from 'react';
|
|
5
|
+
|
|
6
|
+
type UseRadioProps<Y extends string | number = string> = FormControlOptions & {
|
|
7
|
+
/**
|
|
8
|
+
* id assigned to input.
|
|
9
|
+
*/
|
|
10
|
+
id?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The name of the input field in a radio.
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The value to be used in the radio button.
|
|
17
|
+
*/
|
|
18
|
+
value?: Y;
|
|
19
|
+
/**
|
|
20
|
+
* If `true`, the radio will be initially checked.
|
|
21
|
+
*
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
defaultChecked?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* If `true`, the radio will be checked.
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
isChecked?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The callback invoked when the checked state changes.
|
|
33
|
+
*/
|
|
34
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
35
|
+
};
|
|
36
|
+
declare const useRadio: <Y extends string | number = string>(props: UseRadioProps<Y>) => {
|
|
37
|
+
isFocusVisible: boolean;
|
|
38
|
+
isFocused: boolean;
|
|
39
|
+
isHovered: boolean;
|
|
40
|
+
isActive: boolean;
|
|
41
|
+
isChecked: boolean;
|
|
42
|
+
getContainerProps: PropGetter;
|
|
43
|
+
getInputProps: PropGetter;
|
|
44
|
+
getIconProps: PropGetter;
|
|
45
|
+
getLabelProps: PropGetter;
|
|
46
|
+
};
|
|
47
|
+
type UseRadioReturn = ReturnType<typeof useRadio>;
|
|
48
|
+
type RadioOptions = {
|
|
49
|
+
iconProps?: HTMLUIProps<'span'>;
|
|
50
|
+
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
51
|
+
labelProps?: HTMLUIProps<'span'>;
|
|
52
|
+
};
|
|
53
|
+
type RadioProps<Y extends string | number = string> = Omit<HTMLUIProps<'label'>, keyof UseRadioProps> & ThemeProps<'Radio'> & UseRadioProps<Y> & RadioOptions;
|
|
54
|
+
declare const Radio: (<Y extends string | number = string>(props: Omit<HTMLUIProps<"label">, "value" | "name" | "id" | "onChange" | "defaultChecked" | keyof FormControlOptions | "isChecked"> & ThemeProps<"Radio"> & FormControlOptions & {
|
|
55
|
+
/**
|
|
56
|
+
* id assigned to input.
|
|
57
|
+
*/
|
|
58
|
+
id?: string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* The name of the input field in a radio.
|
|
61
|
+
*/
|
|
62
|
+
name?: string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* The value to be used in the radio button.
|
|
65
|
+
*/
|
|
66
|
+
value?: Y | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* If `true`, the radio will be initially checked.
|
|
69
|
+
*
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
defaultChecked?: boolean | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* If `true`, the radio will be checked.
|
|
75
|
+
*
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
isChecked?: boolean | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* The callback invoked when the checked state changes.
|
|
81
|
+
*/
|
|
82
|
+
onChange?: ChangeEventHandler<HTMLInputElement> | undefined;
|
|
83
|
+
} & RadioOptions & {
|
|
84
|
+
ref?: Ref<HTMLInputElement> | undefined;
|
|
85
|
+
}) => JSX.Element) & ComponentArgs;
|
|
86
|
+
|
|
87
|
+
export { Radio, RadioProps, UseRadioProps, UseRadioReturn, useRadio };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/radio",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Yamada UI radio component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yamada",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"url": "https://github.com/hirotomoyamada/yamada-ui/issues"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@yamada-ui/core": "0.
|
|
39
|
-
"@yamada-ui/utils": "0.1.
|
|
40
|
-
"@yamada-ui/form-control": "0.2.
|
|
41
|
-
"@yamada-ui/layouts": "0.2.
|
|
42
|
-
"@yamada-ui/use-controllable-state": "0.1.
|
|
43
|
-
"@yamada-ui/use-focus-visible": "0.1.
|
|
38
|
+
"@yamada-ui/core": "0.5.0",
|
|
39
|
+
"@yamada-ui/utils": "0.1.3",
|
|
40
|
+
"@yamada-ui/form-control": "0.2.5",
|
|
41
|
+
"@yamada-ui/layouts": "0.2.5",
|
|
42
|
+
"@yamada-ui/use-controllable-state": "0.1.4",
|
|
43
|
+
"@yamada-ui/use-focus-visible": "0.1.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"react": "^18.0.0",
|