x-ui-design 0.2.12 → 0.2.13
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/lib/components/Form/Form.client.tsx +93 -0
- package/lib/components/Form/Form.tsx +13 -79
- package/lib/components/Form/Item/{Item.tsx → FormItem.client.tsx} +7 -21
- package/lib/components/Form/Item/FormItem.tsx +42 -0
- package/lib/components/Form/Item/index.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.json +1 -1
- package/dist/esm/types/components/Button/Button.client.d.ts +0 -3
- package/dist/esm/types/components/Button/Button.d.ts +0 -8
- package/dist/esm/types/components/Button/index.d.ts +0 -1
- package/dist/esm/types/components/Checkbox/Checkbox.client.d.ts +0 -23
- package/dist/esm/types/components/Checkbox/Checkbox.d.ts +0 -7
- package/dist/esm/types/components/Checkbox/index.d.ts +0 -1
- package/dist/esm/types/components/Empty/Empty.d.ts +0 -4
- package/dist/esm/types/components/Empty/index.d.ts +0 -1
- package/dist/esm/types/components/Form/Form.d.ts +0 -7
- package/dist/esm/types/components/Form/Item/Item.d.ts +0 -7
- package/dist/esm/types/components/Form/Item/index.d.ts +0 -1
- package/dist/esm/types/components/Form/index.d.ts +0 -1
- package/dist/esm/types/helpers/index.d.ts +0 -4
- package/dist/esm/types/hooks/useForm.d.ts +0 -4
- package/dist/esm/types/hooks/useWatch.d.ts +0 -9
- package/dist/esm/types/index.d.ts +0 -4
- package/dist/esm/types/types/button.d.ts +0 -42
- package/dist/esm/types/types/checkbox.d.ts +0 -22
- package/dist/esm/types/types/datepicker.d.ts +0 -119
- package/dist/esm/types/types/empty.d.ts +0 -7
- package/dist/esm/types/types/form.d.ts +0 -107
- package/dist/esm/types/types/index.d.ts +0 -25
- package/dist/esm/types/types/input.d.ts +0 -47
- package/dist/esm/types/types/radio.d.ts +0 -57
- package/dist/esm/types/types/select.d.ts +0 -97
- package/dist/esm/types/types/skeleton.d.ts +0 -50
- package/dist/esm/types/types/upload.d.ts +0 -54
- package/dist/esm/types/utils/index.d.ts +0 -14
- package/dist/index.d.ts +0 -98
- package/dist/index.esm.js +0 -303
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -307
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Children,
|
|
5
|
+
FC,
|
|
6
|
+
Fragment,
|
|
7
|
+
isValidElement,
|
|
8
|
+
SyntheticEvent,
|
|
9
|
+
useEffect,
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef
|
|
12
|
+
} from 'react';
|
|
13
|
+
import { useForm } from '@/hooks/useForm';
|
|
14
|
+
import { FormProps } from '../../types/form';
|
|
15
|
+
import { FormContext } from './Form';
|
|
16
|
+
|
|
17
|
+
const FormClient: FC<FormProps> = ({
|
|
18
|
+
children,
|
|
19
|
+
form,
|
|
20
|
+
style = {},
|
|
21
|
+
prefixCls,
|
|
22
|
+
className = '',
|
|
23
|
+
onFinish,
|
|
24
|
+
onFinishFailed,
|
|
25
|
+
initialValues = {},
|
|
26
|
+
onValuesChange,
|
|
27
|
+
onFieldsChange,
|
|
28
|
+
layout = 'horizontal',
|
|
29
|
+
...rest
|
|
30
|
+
}) => {
|
|
31
|
+
const internalForm = useForm(initialValues, onFieldsChange, onValuesChange);
|
|
32
|
+
const formInstance = form || internalForm;
|
|
33
|
+
const formRef = useRef<HTMLFormElement>(null);
|
|
34
|
+
|
|
35
|
+
const handleSubmit = async (e: SyntheticEvent) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
|
|
38
|
+
if (await formInstance.validateFields()) {
|
|
39
|
+
onFinish?.(formInstance.getFieldsValue());
|
|
40
|
+
} else if (onFinishFailed) {
|
|
41
|
+
const errorFields = formInstance.getFieldsError();
|
|
42
|
+
onFinishFailed({ values: formInstance.getFieldsValue(), errorFields });
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const childrenList = useMemo(
|
|
47
|
+
() => (Array.isArray(children) ? children : [children]).filter(Boolean),
|
|
48
|
+
[children]
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (onFieldsChange) {
|
|
53
|
+
formInstance.onFieldsChange = onFieldsChange;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (onValuesChange) {
|
|
57
|
+
formInstance.onValuesChange = onValuesChange;
|
|
58
|
+
}
|
|
59
|
+
}, [formInstance, onFieldsChange, onValuesChange]);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<FormContext.Provider value={formInstance}>
|
|
63
|
+
<form
|
|
64
|
+
style={style}
|
|
65
|
+
ref={formRef}
|
|
66
|
+
onSubmit={handleSubmit}
|
|
67
|
+
className={`${prefixCls} ${className}`}
|
|
68
|
+
{...rest}
|
|
69
|
+
>
|
|
70
|
+
{Children.map(childrenList, child => {
|
|
71
|
+
if (isValidElement(child) && child.type !== Fragment) {
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
73
|
+
// @ts-expect-error
|
|
74
|
+
const { ...childProps } = child.props;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<child.type
|
|
78
|
+
{...childProps}
|
|
79
|
+
child={child}
|
|
80
|
+
size={childProps.size || rest.size}
|
|
81
|
+
layout={childProps.layout || layout}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return child;
|
|
87
|
+
})}
|
|
88
|
+
</form>
|
|
89
|
+
</FormContext.Provider>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default FormClient;
|
|
@@ -1,98 +1,32 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Children,
|
|
5
|
-
createContext,
|
|
6
|
-
FC,
|
|
7
|
-
Fragment,
|
|
8
|
-
isValidElement,
|
|
9
|
-
SyntheticEvent,
|
|
10
|
-
useEffect,
|
|
11
|
-
useMemo,
|
|
12
|
-
useRef
|
|
13
|
-
} from 'react';
|
|
14
|
-
import { useForm } from '@/hooks/useForm';
|
|
15
1
|
import { FormInstance, FormItemProps, FormProps } from '../../types/form';
|
|
16
2
|
import { prefixClsForm } from '../../utils';
|
|
17
|
-
import FormItem from './Item/
|
|
3
|
+
import FormItem from './Item/FormItem';
|
|
4
|
+
import FormClient from './Form.client';
|
|
5
|
+
import { createContext, FC } from 'react';
|
|
18
6
|
|
|
19
7
|
export const FormContext = createContext<FormInstance | null>(null);
|
|
20
8
|
|
|
21
9
|
const Form: FC<FormProps> & { Item: FC<FormItemProps> } = ({
|
|
22
10
|
children,
|
|
23
|
-
form,
|
|
24
11
|
style = {},
|
|
25
12
|
prefixCls = prefixClsForm,
|
|
26
13
|
className = '',
|
|
27
|
-
onFinish,
|
|
28
|
-
onFinishFailed,
|
|
29
|
-
initialValues = {},
|
|
30
|
-
onValuesChange,
|
|
31
|
-
onFieldsChange,
|
|
32
14
|
layout = 'horizontal',
|
|
33
15
|
...rest
|
|
34
16
|
}) => {
|
|
35
|
-
const internalForm = useForm(initialValues, onFieldsChange, onValuesChange);
|
|
36
|
-
const formInstance = form || internalForm;
|
|
37
|
-
const formRef = useRef<HTMLFormElement>(null);
|
|
38
|
-
|
|
39
|
-
const handleSubmit = async (e: SyntheticEvent) => {
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
|
|
42
|
-
if (await formInstance.validateFields()) {
|
|
43
|
-
onFinish?.(formInstance.getFieldsValue());
|
|
44
|
-
} else if (onFinishFailed) {
|
|
45
|
-
const errorFields = formInstance.getFieldsError();
|
|
46
|
-
onFinishFailed({ values: formInstance.getFieldsValue(), errorFields });
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const childrenList = useMemo(
|
|
51
|
-
() => (Array.isArray(children) ? children : [children]).filter(Boolean),
|
|
52
|
-
[children]
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (onFieldsChange) {
|
|
57
|
-
formInstance.onFieldsChange = onFieldsChange;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (onValuesChange) {
|
|
61
|
-
formInstance.onValuesChange = onValuesChange;
|
|
62
|
-
}
|
|
63
|
-
}, [formInstance, onFieldsChange, onValuesChange]);
|
|
64
|
-
|
|
65
17
|
return (
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
76
|
-
// @ts-expect-error
|
|
77
|
-
const { ...childProps } = child.props;
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<child.type
|
|
81
|
-
{...childProps}
|
|
82
|
-
child={child}
|
|
83
|
-
size={childProps.size || rest.size}
|
|
84
|
-
layout={childProps.layout || layout}
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return child;
|
|
90
|
-
})}
|
|
91
|
-
</form>
|
|
92
|
-
</FormContext.Provider>
|
|
18
|
+
<FormClient
|
|
19
|
+
style={style}
|
|
20
|
+
prefixCls={prefixCls}
|
|
21
|
+
className={className}
|
|
22
|
+
layout={layout}
|
|
23
|
+
{...rest}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</FormClient>
|
|
93
27
|
);
|
|
94
28
|
};
|
|
95
29
|
|
|
96
30
|
Form.Item = FormItem;
|
|
97
31
|
|
|
98
|
-
export default Form;
|
|
32
|
+
export default Form;
|
|
@@ -23,7 +23,7 @@ import { FormContext } from '../Form';
|
|
|
23
23
|
|
|
24
24
|
const REF_CLIENT_HEIGHT = 24;
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const FormItemClient = ({
|
|
27
27
|
prefixCls = prefixClsFormItem,
|
|
28
28
|
name,
|
|
29
29
|
label,
|
|
@@ -39,7 +39,6 @@ const FormItem = ({
|
|
|
39
39
|
...props
|
|
40
40
|
}: FormItemProps) => {
|
|
41
41
|
const formContext = useContext(FormContext);
|
|
42
|
-
|
|
43
42
|
const errorRef = useRef<HTMLSpanElement>(null);
|
|
44
43
|
|
|
45
44
|
if (!formContext) {
|
|
@@ -87,10 +86,7 @@ const FormItem = ({
|
|
|
87
86
|
}, [dependencies, name]);
|
|
88
87
|
|
|
89
88
|
useEffect(() => {
|
|
90
|
-
if (
|
|
91
|
-
errorRef.current &&
|
|
92
|
-
errorRef.current?.clientHeight >= REF_CLIENT_HEIGHT
|
|
93
|
-
) {
|
|
89
|
+
if (errorRef.current && errorRef.current?.clientHeight >= REF_CLIENT_HEIGHT) {
|
|
94
90
|
errorRef.current.style.position = 'relative';
|
|
95
91
|
errorRef.current.style.marginTop = '-16px';
|
|
96
92
|
}
|
|
@@ -119,15 +115,13 @@ const FormItem = ({
|
|
|
119
115
|
<label className={`${prefixCls}-label`} htmlFor={name}>
|
|
120
116
|
{label || name}:
|
|
121
117
|
{isRequired && <span className={`${prefixCls}-required`}>*</span>}
|
|
122
|
-
{/* @Todo need to add Tooltip like Ant design */}
|
|
123
118
|
</label>
|
|
124
119
|
)}
|
|
125
120
|
|
|
126
121
|
{Children.map(childrenList, (child, key) => {
|
|
127
122
|
if (isValidElement(child) && child.type !== Fragment) {
|
|
128
123
|
const { value, ...childProps } = child.props;
|
|
129
|
-
const fieldValue =
|
|
130
|
-
getFieldValue(valuePropName || name) ?? initialValue;
|
|
124
|
+
const fieldValue = getFieldValue(valuePropName || name) ?? initialValue;
|
|
131
125
|
|
|
132
126
|
return (
|
|
133
127
|
<FormItemChildComponent
|
|
@@ -174,15 +168,11 @@ const FormItemChildComponent = ({
|
|
|
174
168
|
...props
|
|
175
169
|
}: FormItemChildComponentProps) => {
|
|
176
170
|
const formContext = useContext(FormContext);
|
|
177
|
-
|
|
178
171
|
const [wasNormalize, setWasNormalize] = useState(false);
|
|
179
|
-
|
|
180
172
|
const { getFieldsValue } = formContext || {};
|
|
181
173
|
|
|
182
174
|
const handleChange = (e: SyntheticBaseEvent, option?: OptionProps) => {
|
|
183
|
-
let rawValue: RuleType | SyntheticBaseEvent = e?.target
|
|
184
|
-
? e.target.value
|
|
185
|
-
: e;
|
|
175
|
+
let rawValue: RuleType | SyntheticBaseEvent = e?.target ? e.target.value : e;
|
|
186
176
|
|
|
187
177
|
if (normalize) {
|
|
188
178
|
const prevValue = fieldValue ?? props.value;
|
|
@@ -192,14 +182,10 @@ const FormItemChildComponent = ({
|
|
|
192
182
|
|
|
193
183
|
if (rawValue === prevValue) {
|
|
194
184
|
e.target.value = rawValue;
|
|
195
|
-
|
|
196
185
|
setWasNormalize(prev => !prev);
|
|
197
186
|
|
|
198
187
|
const timeout = setTimeout(() => {
|
|
199
|
-
(
|
|
200
|
-
document.querySelector(`[name='${name}']`) as HTMLInputElement
|
|
201
|
-
)?.focus();
|
|
202
|
-
|
|
188
|
+
(document.querySelector(`[name='${name}']`) as HTMLInputElement)?.focus();
|
|
203
189
|
clearTimeout(timeout);
|
|
204
190
|
}, 0);
|
|
205
191
|
|
|
@@ -223,6 +209,6 @@ const FormItemChildComponent = ({
|
|
|
223
209
|
);
|
|
224
210
|
};
|
|
225
211
|
|
|
226
|
-
|
|
212
|
+
FormItemClient.displayName = 'FormItemClient';
|
|
227
213
|
|
|
228
|
-
export default
|
|
214
|
+
export default FormItemClient;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FormItemProps } from '../../../types/form';
|
|
2
|
+
import { prefixClsFormItem } from '../../../utils';
|
|
3
|
+
import FormItemClient from './FormItem.client';
|
|
4
|
+
|
|
5
|
+
const FormItem = ({
|
|
6
|
+
prefixCls = prefixClsFormItem,
|
|
7
|
+
name,
|
|
8
|
+
label,
|
|
9
|
+
rules = [],
|
|
10
|
+
children,
|
|
11
|
+
className = '',
|
|
12
|
+
layout = 'vertical',
|
|
13
|
+
style = {},
|
|
14
|
+
valuePropName,
|
|
15
|
+
dependencies = [],
|
|
16
|
+
initialValue,
|
|
17
|
+
feedbackIcons,
|
|
18
|
+
...props
|
|
19
|
+
}: FormItemProps) => {
|
|
20
|
+
return (
|
|
21
|
+
<FormItemClient
|
|
22
|
+
prefixCls={prefixCls}
|
|
23
|
+
name={name}
|
|
24
|
+
label={label}
|
|
25
|
+
rules={rules}
|
|
26
|
+
className={className}
|
|
27
|
+
layout={layout}
|
|
28
|
+
style={style}
|
|
29
|
+
valuePropName={valuePropName}
|
|
30
|
+
dependencies={dependencies}
|
|
31
|
+
initialValue={initialValue}
|
|
32
|
+
feedbackIcons={feedbackIcons}
|
|
33
|
+
{...props}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</FormItemClient>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
FormItem.displayName = 'FormItem';
|
|
41
|
+
|
|
42
|
+
export default FormItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Item } from './
|
|
1
|
+
export { default as Item } from './FormItem'
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { ButtonProps } from '../../types/button';
|
|
3
|
-
import './style.css';
|
|
4
|
-
declare const Button: ({ type, variant, color, shape, size, htmlType, className, rootClassName, classNames: customClassNames, styles, prefixCls, iconPosition, disabled, ghost, danger, block, children, href, iconNode, isLoading, ...restProps }: ButtonProps & {
|
|
5
|
-
iconNode?: ReactNode;
|
|
6
|
-
isLoading?: boolean;
|
|
7
|
-
}) => ReactElement;
|
|
8
|
-
export default Button;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Button } from './Button';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { MouseEvent } from 'react';
|
|
2
|
-
import './style.css';
|
|
3
|
-
declare const CheckboxClient: import("react").ForwardRefExoticComponent<import("../../types").DefaultProps & {
|
|
4
|
-
disabled?: boolean;
|
|
5
|
-
onChange?: (e: MouseEvent<HTMLInputElement> & import("../../types").TargetProps) => void;
|
|
6
|
-
onClick?: import("react").MouseEventHandler<HTMLElement>;
|
|
7
|
-
onMouseEnter?: import("react").MouseEventHandler<HTMLElement>;
|
|
8
|
-
onMouseLeave?: import("react").MouseEventHandler<HTMLElement>;
|
|
9
|
-
onKeyPress?: import("react").KeyboardEventHandler<HTMLElement>;
|
|
10
|
-
onKeyDown?: import("react").KeyboardEventHandler<HTMLElement>;
|
|
11
|
-
value?: boolean;
|
|
12
|
-
tabIndex?: number;
|
|
13
|
-
name?: string;
|
|
14
|
-
children?: import("react").ReactNode;
|
|
15
|
-
id?: string;
|
|
16
|
-
autoFocus?: boolean;
|
|
17
|
-
type?: string;
|
|
18
|
-
skipGroup?: boolean;
|
|
19
|
-
required?: boolean;
|
|
20
|
-
defaultChecked?: boolean;
|
|
21
|
-
checked?: boolean;
|
|
22
|
-
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
23
|
-
export default CheckboxClient;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { CheckboxProps } from '../../types/checkbox';
|
|
3
|
-
declare const Checkbox: {
|
|
4
|
-
({ prefixCls, className, defaultChecked, checked, style, disabled, onChange, onClick, onMouseEnter, onMouseLeave, onKeyPress, onKeyDown, tabIndex, name, children, id, autoFocus, type, value, required, noStyle }: CheckboxProps): ReactElement;
|
|
5
|
-
displayName: string;
|
|
6
|
-
};
|
|
7
|
-
export default Checkbox;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Checkbox } from './Checkbox';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Empty } from '@/components/Empty/Empty';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { FormInstance, FormItemProps, FormProps } from '../../types/form';
|
|
3
|
-
export declare const FormContext: import("react").Context<FormInstance | null>;
|
|
4
|
-
declare const Form: FC<FormProps> & {
|
|
5
|
-
Item: FC<FormItemProps>;
|
|
6
|
-
};
|
|
7
|
-
export default Form;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FormItemProps } from '../../../types/form';
|
|
2
|
-
import './style.css';
|
|
3
|
-
declare const FormItem: {
|
|
4
|
-
({ prefixCls, name, label, rules, children, className, layout, style, valuePropName, dependencies, initialValue, feedbackIcons, ...props }: FormItemProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
displayName: string;
|
|
6
|
-
};
|
|
7
|
-
export default FormItem;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Item } from './Item';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Form } from './Form';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { RuleTypes } from '../types';
|
|
2
|
-
import type { FieldData, FormInstance } from '../types/form';
|
|
3
|
-
declare const useForm: (initialValues?: Record<string, RuleTypes>, onFieldsChange?: (changedFields: FieldData[]) => void, onValuesChange?: (changedValues: Record<string, RuleTypes>, allValues: Record<string, RuleTypes>) => void) => FormInstance;
|
|
4
|
-
export { useForm };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { RuleType } from '../types';
|
|
2
|
-
import { FormInstance } from '../types/form';
|
|
3
|
-
type UseWatchProps = {
|
|
4
|
-
name?: string;
|
|
5
|
-
defaultValue?: RuleType;
|
|
6
|
-
form?: FormInstance;
|
|
7
|
-
};
|
|
8
|
-
export declare const useWatch: ({ name, defaultValue, form }: UseWatchProps) => any;
|
|
9
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes, CSSProperties, ReactNode } from 'react';
|
|
2
|
-
export declare const ButtonTypes: readonly ["default", "primary", "dashed", "link", "text", "ghost"];
|
|
3
|
-
export declare const ButtonShapes: readonly ["default", "circle", "round"];
|
|
4
|
-
export declare const ButtonVariantTypes: readonly ["outlined", "dashed", "solid", "filled", "text", "link"];
|
|
5
|
-
export declare const ButtonColorTypes: readonly ["default", "primary", "danger", "blue", "purple", "cyan", "green", "magenta", "pink", "red", "orange", "yellow", "volcano", "geekblue", "lime", "gold"];
|
|
6
|
-
export type ButtonType = (typeof ButtonTypes)[number];
|
|
7
|
-
export type ButtonShape = (typeof ButtonShapes)[number];
|
|
8
|
-
export type ButtonVariantType = (typeof ButtonVariantTypes)[number];
|
|
9
|
-
export type ButtonColorType = (typeof ButtonColorTypes)[number];
|
|
10
|
-
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
|
11
|
-
export type ButtonHTMLType = 'button' | 'submit' | 'reset';
|
|
12
|
-
export interface BaseButtonProps {
|
|
13
|
-
type?: ButtonType;
|
|
14
|
-
color?: ButtonColorType;
|
|
15
|
-
variant?: ButtonVariantType;
|
|
16
|
-
icon?: ReactNode;
|
|
17
|
-
iconPosition?: 'start' | 'end';
|
|
18
|
-
shape?: ButtonShape;
|
|
19
|
-
size?: SizeType;
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
loading?: boolean | {
|
|
22
|
-
delay?: number;
|
|
23
|
-
icon?: ReactNode;
|
|
24
|
-
};
|
|
25
|
-
prefixCls?: string;
|
|
26
|
-
className?: string;
|
|
27
|
-
rootClassName?: string;
|
|
28
|
-
ghost?: boolean;
|
|
29
|
-
danger?: boolean;
|
|
30
|
-
block?: boolean;
|
|
31
|
-
children?: ReactNode;
|
|
32
|
-
classNames?: {
|
|
33
|
-
icon?: string;
|
|
34
|
-
};
|
|
35
|
-
styles?: {
|
|
36
|
-
icon?: CSSProperties;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export interface ButtonProps extends BaseButtonProps, Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'type'> {
|
|
40
|
-
href?: string;
|
|
41
|
-
htmlType?: ButtonHTMLType;
|
|
42
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { KeyboardEventHandler, MouseEvent, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
-
import { DefaultProps, TargetProps } from '.';
|
|
3
|
-
export type CheckboxProps = DefaultProps & {
|
|
4
|
-
disabled?: boolean;
|
|
5
|
-
onChange?: (e: MouseEvent<HTMLInputElement> & TargetProps) => void;
|
|
6
|
-
onClick?: MouseEventHandler<HTMLElement>;
|
|
7
|
-
onMouseEnter?: MouseEventHandler<HTMLElement>;
|
|
8
|
-
onMouseLeave?: MouseEventHandler<HTMLElement>;
|
|
9
|
-
onKeyPress?: KeyboardEventHandler<HTMLElement>;
|
|
10
|
-
onKeyDown?: KeyboardEventHandler<HTMLElement>;
|
|
11
|
-
value?: boolean;
|
|
12
|
-
tabIndex?: number;
|
|
13
|
-
name?: string;
|
|
14
|
-
children?: ReactNode;
|
|
15
|
-
id?: string;
|
|
16
|
-
autoFocus?: boolean;
|
|
17
|
-
type?: string;
|
|
18
|
-
skipGroup?: boolean;
|
|
19
|
-
required?: boolean;
|
|
20
|
-
defaultChecked?: boolean;
|
|
21
|
-
checked?: boolean;
|
|
22
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { FocusEvent, ReactNode } from 'react';
|
|
2
|
-
import { DefaultProps, RuleType, SizeType } from '.';
|
|
3
|
-
export interface BaseInfo {
|
|
4
|
-
range?: 'start' | 'end';
|
|
5
|
-
source?: string;
|
|
6
|
-
}
|
|
7
|
-
export type CustomFormat<RuleType> = (value: RuleType) => string;
|
|
8
|
-
export type FormatType<DateType = RuleType> = string | CustomFormat<DateType>;
|
|
9
|
-
export type PanelMode = 'time' | 'date' | 'week' | 'month' | 'quarter' | 'year' | 'decade';
|
|
10
|
-
export type TDatePickerProps = DefaultProps & {
|
|
11
|
-
value?: Date;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
placeholder?: string;
|
|
14
|
-
error?: boolean;
|
|
15
|
-
feedbackIcons?: boolean;
|
|
16
|
-
locale?: Locale;
|
|
17
|
-
placement?: string;
|
|
18
|
-
defaultOpen?: boolean;
|
|
19
|
-
allowClear?: boolean | {
|
|
20
|
-
clearIcon?: ReactNode;
|
|
21
|
-
};
|
|
22
|
-
defaultValue?: Date;
|
|
23
|
-
disabledDate?: (date: RuleType, info: {
|
|
24
|
-
to: RuleType;
|
|
25
|
-
from?: RuleType;
|
|
26
|
-
}) => boolean;
|
|
27
|
-
suffixIcon?: ReactNode;
|
|
28
|
-
prefix?: ReactNode;
|
|
29
|
-
size?: SizeType;
|
|
30
|
-
format?: FormatType<RuleType> | FormatType<RuleType>[] | {
|
|
31
|
-
format: string;
|
|
32
|
-
type?: 'mask';
|
|
33
|
-
};
|
|
34
|
-
onChange?: (date: RuleType | RuleType[], dateString: string | string[]) => void;
|
|
35
|
-
onCalendarChange?: (date: RuleType | RuleType[], dateString: string | string[], info: BaseInfo) => void;
|
|
36
|
-
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
37
|
-
showToday?: boolean;
|
|
38
|
-
inputReadOnly?: boolean;
|
|
39
|
-
picker?: PanelMode;
|
|
40
|
-
bordered?: boolean;
|
|
41
|
-
};
|
|
42
|
-
export type TRangePickerProps = Omit<TDatePickerProps, 'placeholder' | 'value' | 'defaultValue'> & {
|
|
43
|
-
placeholder?: string[];
|
|
44
|
-
value?: Date[];
|
|
45
|
-
defaultValue?: Date[];
|
|
46
|
-
separator?: ReactNode;
|
|
47
|
-
};
|
|
48
|
-
export type Locale = {
|
|
49
|
-
locale: string;
|
|
50
|
-
dateFormat?: string;
|
|
51
|
-
dateTimeFormat?: string;
|
|
52
|
-
fieldDateTimeFormat?: string;
|
|
53
|
-
fieldDateFormat?: string;
|
|
54
|
-
fieldTimeFormat?: string;
|
|
55
|
-
fieldMonthFormat?: string;
|
|
56
|
-
fieldYearFormat?: string;
|
|
57
|
-
fieldWeekFormat?: string;
|
|
58
|
-
fieldQuarterFormat?: string;
|
|
59
|
-
monthBeforeYear?: boolean;
|
|
60
|
-
yearFormat?: string;
|
|
61
|
-
monthFormat?: string;
|
|
62
|
-
cellYearFormat?: string;
|
|
63
|
-
cellQuarterFormat?: string;
|
|
64
|
-
dayFormat?: string;
|
|
65
|
-
cellDateFormat?: string;
|
|
66
|
-
cellMeridiemFormat?: string;
|
|
67
|
-
today: string;
|
|
68
|
-
now: string;
|
|
69
|
-
backToToday: string;
|
|
70
|
-
ok: string;
|
|
71
|
-
timeSelect: string;
|
|
72
|
-
dateSelect: string;
|
|
73
|
-
weekSelect?: string;
|
|
74
|
-
clear: string;
|
|
75
|
-
week: string;
|
|
76
|
-
month: string;
|
|
77
|
-
year: string;
|
|
78
|
-
previousMonth: string;
|
|
79
|
-
nextMonth: string;
|
|
80
|
-
monthSelect: string;
|
|
81
|
-
yearSelect: string;
|
|
82
|
-
decadeSelect: string;
|
|
83
|
-
previousYear: string;
|
|
84
|
-
nextYear: string;
|
|
85
|
-
previousDecade: string;
|
|
86
|
-
nextDecade: string;
|
|
87
|
-
previousCentury: string;
|
|
88
|
-
nextCentury: string;
|
|
89
|
-
shortWeekDays?: string[];
|
|
90
|
-
shortMonths?: string[];
|
|
91
|
-
};
|
|
92
|
-
export interface DisabledTimes {
|
|
93
|
-
disabledHours?: () => number[];
|
|
94
|
-
disabledMinutes?: (hour: number) => number[];
|
|
95
|
-
disabledSeconds?: (hour: number, minute: number) => number[];
|
|
96
|
-
}
|
|
97
|
-
export type PickerFocusEventHandler = (e: FocusEvent<HTMLElement>, info: BaseInfo) => void;
|
|
98
|
-
export type DisabledDate<DateType = RuleType> = (date: DateType, info: {
|
|
99
|
-
type: PanelMode;
|
|
100
|
-
from?: DateType;
|
|
101
|
-
}) => boolean;
|
|
102
|
-
export type TimePickerProps = DefaultProps & {
|
|
103
|
-
disabledTime?: (date: RuleType) => DisabledTimes;
|
|
104
|
-
inputReadOnly?: boolean;
|
|
105
|
-
format?: FormatType<RuleType> | FormatType<RuleType>[] | {
|
|
106
|
-
format: string;
|
|
107
|
-
type?: 'mask';
|
|
108
|
-
};
|
|
109
|
-
defaultValue?: RuleType | null;
|
|
110
|
-
value?: RuleType | null;
|
|
111
|
-
onChange?: (date: RuleType, dateString: string | string[]) => void;
|
|
112
|
-
onBlur?: PickerFocusEventHandler;
|
|
113
|
-
onSelect?: ((value: Date | null) => void) | undefined;
|
|
114
|
-
showNow?: boolean;
|
|
115
|
-
clearIcon?: ReactNode;
|
|
116
|
-
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
117
|
-
suffixIcon?: ReactNode;
|
|
118
|
-
placeholder?: string;
|
|
119
|
-
};
|