@rainbow-oh/yee-c 0.4.1 → 0.4.2
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/cjs/Button/demo/basic.js +1 -1
- package/dist/cjs/Button/demo/variant.d.ts +3 -0
- package/dist/cjs/Button/demo/variant.js +59 -0
- package/dist/cjs/Button/style/index.less +49 -11
- package/dist/cjs/DatePicker/date-picker-mobile.js +1 -1
- package/dist/cjs/Ellipsis/ellipsis.js +4 -2
- package/dist/cjs/Form/Form.js +1 -1
- package/dist/cjs/Form/form-store.js +2 -2
- package/dist/cjs/Form/{useForm.d.ts → hooks/useForm.d.ts} +1 -1
- package/dist/cjs/Form/{useForm.js → hooks/useForm.js} +4 -7
- package/dist/cjs/Form/hooks/useFormInstance.d.ts +1 -0
- package/dist/cjs/Form/hooks/useFormInstance.js +43 -0
- package/dist/{esm/Form → cjs/Form/hooks}/useWatch.d.ts +1 -1
- package/dist/cjs/Form/{useWatch.js → hooks/useWatch.js} +2 -2
- package/dist/cjs/Form/index.d.ts +4 -2
- package/dist/cjs/Form/index.js +4 -2
- package/dist/cjs/Input/password.js +5 -2
- package/dist/cjs/Pagination/pagination.js +4 -1
- package/dist/cjs/RangePicker/range-picker-mobile.js +3 -3
- package/dist/cjs/Space/compact.js +1 -1
- package/dist/cjs/Space/demo/compact.js +1 -13
- package/dist/cjs/Space/space.js +3 -1
- package/dist/cjs/Space/style/index.less +29 -9
- package/dist/cjs/Table/tbody/index.js +4 -1
- package/dist/cjs/Table/theader/filter.js +10 -5
- package/dist/cjs/TextArea/textarea.js +2 -1
- package/dist/cjs/Transfer/transfer-list.js +4 -1
- package/dist/cjs/locale/interface.d.ts +15 -0
- package/dist/cjs/locale/lang/en_US.js +12 -0
- package/dist/cjs/locale/lang/ja_JP.js +12 -0
- package/dist/cjs/locale/lang/zh_CN.js +12 -0
- package/dist/cjs/locale/lang/zh_TW.js +12 -0
- package/dist/cjs/style/size.css +1 -1
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +2 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Button/demo/basic.js +1 -0
- package/dist/esm/Button/demo/variant.d.ts +3 -0
- package/dist/esm/Button/demo/variant.js +49 -0
- package/dist/esm/Button/style/index.less +49 -11
- package/dist/esm/DatePicker/date-picker-mobile.js +1 -1
- package/dist/esm/Ellipsis/ellipsis.js +5 -2
- package/dist/esm/Form/Form.js +1 -1
- package/dist/esm/Form/form-store.js +2 -2
- package/dist/esm/Form/{useForm.d.ts → hooks/useForm.d.ts} +1 -1
- package/dist/esm/Form/{useForm.js → hooks/useForm.js} +3 -4
- package/dist/esm/Form/hooks/useFormInstance.d.ts +1 -0
- package/dist/esm/Form/hooks/useFormInstance.js +9 -0
- package/dist/{cjs/Form → esm/Form/hooks}/useWatch.d.ts +1 -1
- package/dist/esm/Form/{useWatch.js → hooks/useWatch.js} +1 -1
- package/dist/esm/Form/index.d.ts +4 -2
- package/dist/esm/Form/index.js +4 -2
- package/dist/esm/Input/password.js +6 -2
- package/dist/esm/Pagination/pagination.js +5 -1
- package/dist/esm/RangePicker/range-picker-mobile.js +3 -3
- package/dist/esm/Space/compact.js +1 -1
- package/dist/esm/Space/demo/compact.js +5 -14
- package/dist/esm/Space/space.js +3 -1
- package/dist/esm/Space/style/index.less +29 -9
- package/dist/esm/Table/tbody/index.js +5 -1
- package/dist/esm/Table/theader/filter.js +18 -13
- package/dist/esm/TextArea/textarea.js +2 -1
- package/dist/esm/Transfer/transfer-list.js +5 -1
- package/dist/esm/locale/interface.d.ts +15 -0
- package/dist/esm/locale/lang/en_US.js +12 -0
- package/dist/esm/locale/lang/ja_JP.js +12 -0
- package/dist/esm/locale/lang/zh_CN.js +12 -0
- package/dist/esm/locale/lang/zh_TW.js +12 -0
- package/dist/esm/style/size.css +1 -1
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +2 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +2 -2
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Button/demo/basic.tsx +3 -1
- package/src/Button/demo/variant.tsx +55 -0
- package/src/Button/index.en-US.md +1 -0
- package/src/Button/index.zh-CN.md +1 -0
- package/src/Button/style/index.less +49 -11
- package/src/DatePicker/date-picker-mobile.tsx +1 -1
- package/src/Ellipsis/ellipsis.tsx +6 -6
- package/src/Form/Form.tsx +1 -1
- package/src/Form/form-store.ts +2 -2
- package/src/Form/{useForm.ts → hooks/useForm.ts} +4 -6
- package/src/Form/hooks/useFormInstance.ts +12 -0
- package/src/Form/{useWatch.ts → hooks/useWatch.ts} +2 -2
- package/src/Form/index.en-US.md +2 -0
- package/src/Form/index.ts +5 -2
- package/src/Form/index.zh-CN.md +2 -0
- package/src/Input/password.tsx +5 -2
- package/src/Pagination/pagination.tsx +4 -1
- package/src/RangePicker/range-picker-mobile.tsx +4 -4
- package/src/Space/compact.tsx +1 -1
- package/src/Space/demo/compact.tsx +3 -13
- package/src/Space/space.tsx +4 -1
- package/src/Space/style/index.less +29 -9
- package/src/Table/tbody/index.tsx +4 -1
- package/src/Table/theader/filter.tsx +14 -11
- package/src/TextArea/textarea.tsx +3 -1
- package/src/Transfer/transfer-list.tsx +4 -1
- package/src/locale/interface.ts +21 -0
- package/src/locale/lang/en_US.ts +15 -0
- package/src/locale/lang/ja_JP.ts +15 -0
- package/src/locale/lang/zh_CN.ts +15 -0
- package/src/locale/lang/zh_TW.ts +15 -0
- package/src/style/size.css +1 -1
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -8,7 +8,9 @@ export default () => {
|
|
|
8
8
|
<Button>Children Button</Button>
|
|
9
9
|
<Button>Default Button</Button>
|
|
10
10
|
<Button type="dashed">Dashed Button</Button>
|
|
11
|
-
<Button type="text">
|
|
11
|
+
<Button variant="filled" type="text">
|
|
12
|
+
Text Button
|
|
13
|
+
</Button>
|
|
12
14
|
<Button type="link">Link Button</Button>
|
|
13
15
|
</Space>
|
|
14
16
|
);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Button, Space } from '@rainbow-oh/yee-c';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const types = ['primary', 'default', 'dashed', 'text', 'link'] as const;
|
|
5
|
+
const colors = ['default', 'primary', 'success', 'danger', 'warning'] as const;
|
|
6
|
+
const variants = [
|
|
7
|
+
'solid',
|
|
8
|
+
'outlined',
|
|
9
|
+
'dashed',
|
|
10
|
+
'filled',
|
|
11
|
+
'text',
|
|
12
|
+
'link',
|
|
13
|
+
] as const;
|
|
14
|
+
|
|
15
|
+
const labelStyle: React.CSSProperties = {
|
|
16
|
+
flex: '0 0 80px',
|
|
17
|
+
color: '#969696',
|
|
18
|
+
fontSize: 14,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const rowStyle: React.CSSProperties = {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
gap: 12,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default () => {
|
|
28
|
+
return (
|
|
29
|
+
<Space direction="horizontal" block gap={12} wrap>
|
|
30
|
+
<div style={rowStyle}>
|
|
31
|
+
<span style={labelStyle}>type</span>
|
|
32
|
+
<Space wrap>
|
|
33
|
+
{types.map((t) => (
|
|
34
|
+
<Button key={t} type={t}>
|
|
35
|
+
{t}
|
|
36
|
+
</Button>
|
|
37
|
+
))}
|
|
38
|
+
</Space>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
{variants.map((variant) => (
|
|
42
|
+
<div key={variant} style={rowStyle}>
|
|
43
|
+
<span style={labelStyle}>{variant}</span>
|
|
44
|
+
<Space wrap>
|
|
45
|
+
{colors.map((color) => (
|
|
46
|
+
<Button key={color} color={color} variant={variant}>
|
|
47
|
+
{color}
|
|
48
|
+
</Button>
|
|
49
|
+
))}
|
|
50
|
+
</Space>
|
|
51
|
+
</div>
|
|
52
|
+
))}
|
|
53
|
+
</Space>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -17,6 +17,7 @@ Buttons are used to start an immediate action.
|
|
|
17
17
|
## Code Demo
|
|
18
18
|
|
|
19
19
|
<code src="./demo/basic.tsx" title="Basic" description="Basic usage of Button"></code>
|
|
20
|
+
<code src="./demo/variant.tsx" title="Variant & Color" description="All combinations of type / color / variant"></code>
|
|
20
21
|
<code src="./demo/size.tsx" title="Size" description="Different button sizes"></code>
|
|
21
22
|
<code src="./demo/disabled.tsx" title="Disabled" description="Disabled button"></code>
|
|
22
23
|
<code src="./demo/loading.tsx" title="Loading" description="Loading button"></code>
|
|
@@ -17,6 +17,7 @@ demo:
|
|
|
17
17
|
## 代码演示
|
|
18
18
|
|
|
19
19
|
<code src="./demo/basic.tsx" title="基础用法" description="Button的基础用法"></code>
|
|
20
|
+
<code src="./demo/variant.tsx" title="变体与颜色" description="type / color / variant 的全部组合"></code>
|
|
20
21
|
<code src="./demo/size.tsx" title="尺寸" description="不同尺寸的按钮"></code>
|
|
21
22
|
<code src="./demo/disabled.tsx" title="禁用" description="禁用状态的按钮"></code>
|
|
22
23
|
<code src="./demo/loading.tsx" title="加载中" description="加载状态的按钮"></code>
|
|
@@ -66,19 +66,28 @@
|
|
|
66
66
|
background-color: var(--m-btn-color);
|
|
67
67
|
|
|
68
68
|
&:not(@{pls}-disabled):hover {
|
|
69
|
-
background-color: var(--m-btn-
|
|
69
|
+
background-color: color-mix(in srgb, var(--m-btn-color), black 12%);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
&:not(@{pls}-disabled):active {
|
|
73
|
-
background-color: var(--m-btn-
|
|
74
|
-
box-shadow: var(--yee-btn-solid-active-box-shadow)
|
|
73
|
+
background-color: color-mix(in srgb, var(--m-btn-color), black 20%);
|
|
74
|
+
box-shadow: var(--yee-btn-solid-active-box-shadow)
|
|
75
|
+
var(--m-btn-active-shadow-color);
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
// 字体颜色,背景是字体颜色的浅色
|
|
79
80
|
&-filled {
|
|
80
|
-
color: var(--
|
|
81
|
-
background-color: var(--m-btn-color);
|
|
81
|
+
color: var(--m-btn-color);
|
|
82
|
+
background-color: color-mix(in srgb, var(--m-btn-color) 10%, transparent);
|
|
83
|
+
|
|
84
|
+
&:not(@{pls}-disabled):hover {
|
|
85
|
+
background-color: color-mix(in srgb, var(--m-btn-color) 16%, transparent);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&:not(@{pls}-disabled):active {
|
|
89
|
+
background-color: color-mix(in srgb, var(--m-btn-color) 22%, transparent);
|
|
90
|
+
}
|
|
82
91
|
}
|
|
83
92
|
|
|
84
93
|
&-outlined {
|
|
@@ -154,27 +163,56 @@
|
|
|
154
163
|
--m-btn-border-active-color: var(--yee-primary-color-active);
|
|
155
164
|
--m-btn-active-color: var(--yee-primary-color-active);
|
|
156
165
|
--m-btn-active-bg-color: var(--yee-text-color-auxiliary);
|
|
166
|
+
--m-btn-active-shadow-color: var(--yee-primary-color-active);
|
|
157
167
|
}
|
|
158
168
|
|
|
159
169
|
&-primary {
|
|
160
170
|
--m-btn-color: var(--yee-primary-color);
|
|
161
171
|
--m-btn-hover-color: var(--yee-primary-color-hover);
|
|
162
172
|
--m-btn-active-color: var(--yee-primary-color-active);
|
|
163
|
-
--m-btn-bg-color: var(--yee-btn-
|
|
164
|
-
--m-btn-hover-bg-color: var(--yee-
|
|
165
|
-
--m-btn-active-bg-color: var(--yee-
|
|
173
|
+
--m-btn-bg-color: var(--yee-btn-primary-bg-color);
|
|
174
|
+
--m-btn-hover-bg-color: var(--yee-primary-color-hover);
|
|
175
|
+
--m-btn-active-bg-color: var(--yee-primary-color-active);
|
|
176
|
+
--m-btn-border-color: var(--yee-primary-color);
|
|
177
|
+
--m-btn-border-hover-color: var(--yee-primary-color-hover);
|
|
178
|
+
--m-btn-border-active-color: var(--yee-primary-color-active);
|
|
179
|
+
--m-btn-active-shadow-color: var(--yee-primary-color-active);
|
|
166
180
|
}
|
|
167
181
|
|
|
168
182
|
&-success {
|
|
169
|
-
--m-btn-color: var(--yee-
|
|
183
|
+
--m-btn-color: var(--yee-success-color);
|
|
184
|
+
--m-btn-hover-color: var(--yee-success-color-hover);
|
|
185
|
+
--m-btn-active-color: var(--yee-success-color-active);
|
|
186
|
+
--m-btn-border-color: var(--yee-success-color);
|
|
187
|
+
--m-btn-border-hover-color: var(--yee-success-color-hover);
|
|
188
|
+
--m-btn-border-active-color: var(--yee-success-color-active);
|
|
189
|
+
--m-btn-hover-bg-color: var(--yee-success-color-hover);
|
|
190
|
+
--m-btn-active-bg-color: var(--yee-success-color-active);
|
|
191
|
+
--m-btn-active-shadow-color: var(--yee-success-color-active);
|
|
170
192
|
}
|
|
171
193
|
|
|
172
194
|
&-danger {
|
|
173
|
-
--m-btn-color: var(--yee-
|
|
195
|
+
--m-btn-color: var(--yee-error-color);
|
|
196
|
+
--m-btn-hover-color: var(--yee-error-color-hover);
|
|
197
|
+
--m-btn-active-color: var(--yee-error-color-active);
|
|
198
|
+
--m-btn-border-color: var(--yee-error-color);
|
|
199
|
+
--m-btn-border-hover-color: var(--yee-error-color-hover);
|
|
200
|
+
--m-btn-border-active-color: var(--yee-error-color-active);
|
|
201
|
+
--m-btn-hover-bg-color: var(--yee-error-color-hover);
|
|
202
|
+
--m-btn-active-bg-color: var(--yee-error-color-active);
|
|
203
|
+
--m-btn-active-shadow-color: var(--yee-error-color-active);
|
|
174
204
|
}
|
|
175
205
|
|
|
176
206
|
&-warning {
|
|
177
|
-
--m-btn-color: var(--yee-
|
|
207
|
+
--m-btn-color: var(--yee-warning-color);
|
|
208
|
+
--m-btn-hover-color: var(--yee-warning-color-hover);
|
|
209
|
+
--m-btn-active-color: var(--yee-warning-color-active);
|
|
210
|
+
--m-btn-border-color: var(--yee-warning-color);
|
|
211
|
+
--m-btn-border-hover-color: var(--yee-warning-color-hover);
|
|
212
|
+
--m-btn-border-active-color: var(--yee-warning-color-active);
|
|
213
|
+
--m-btn-hover-bg-color: var(--yee-warning-color-hover);
|
|
214
|
+
--m-btn-active-bg-color: var(--yee-warning-color-active);
|
|
215
|
+
--m-btn-active-shadow-color: var(--yee-warning-color-active);
|
|
178
216
|
}
|
|
179
217
|
|
|
180
218
|
&-disabled {
|
|
@@ -3,6 +3,7 @@ import { motion } from 'motion/react';
|
|
|
3
3
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import Button from '../Button';
|
|
5
5
|
import useMergedState from '../hooks/useMergedState';
|
|
6
|
+
import { useLocale } from '../locale';
|
|
6
7
|
import type { EllipsisProps } from './interface';
|
|
7
8
|
|
|
8
9
|
import './style/index.less';
|
|
@@ -32,6 +33,9 @@ const Ellipsis: React.FC<EllipsisProps> = (props) => {
|
|
|
32
33
|
const [needEllipsis, setNeedEllipsis] = useState(false);
|
|
33
34
|
const [maxHeight, setMaxHeight] = useState<number>(0);
|
|
34
35
|
|
|
36
|
+
const { locale } = useLocale();
|
|
37
|
+
const { ellipsis: ellipsisLocale } = locale;
|
|
38
|
+
|
|
35
39
|
const [mergedExpanded, setMergedExpanded] = useMergedState(defaultExpanded, {
|
|
36
40
|
value: controlledExpanded,
|
|
37
41
|
});
|
|
@@ -65,14 +69,10 @@ const Ellipsis: React.FC<EllipsisProps> = (props) => {
|
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
const isCollapsed = !mergedExpanded && needEllipsis;
|
|
68
|
-
const isZhCN =
|
|
69
|
-
typeof document !== 'undefined'
|
|
70
|
-
? (document.documentElement.lang || 'zh-CN').startsWith('zh')
|
|
71
|
-
: true;
|
|
72
72
|
|
|
73
73
|
const buttonText = mergedExpanded
|
|
74
|
-
? (collapseText ??
|
|
75
|
-
: (expandText ??
|
|
74
|
+
? (collapseText ?? ellipsisLocale.collapse)
|
|
75
|
+
: (expandText ?? ellipsisLocale.expand);
|
|
76
76
|
|
|
77
77
|
const renderButton = () => {
|
|
78
78
|
if (!showExpandButton || !needEllipsis) return null;
|
package/src/Form/Form.tsx
CHANGED
|
@@ -5,8 +5,8 @@ import useEvent from '../hooks/useEvent';
|
|
|
5
5
|
import mergeContextToProps from '../utils/mergeContextToProps';
|
|
6
6
|
import FieldContext from './FieldContext';
|
|
7
7
|
import FormContext from './FormContext';
|
|
8
|
+
import useForm from './hooks/useForm';
|
|
8
9
|
import type { FormProps } from './interface';
|
|
9
|
-
import useForm from './useForm';
|
|
10
10
|
|
|
11
11
|
import './style/index.less';
|
|
12
12
|
|
package/src/Form/form-store.ts
CHANGED
|
@@ -43,8 +43,8 @@ export class FormStore {
|
|
|
43
43
|
// List key manager
|
|
44
44
|
private listKeyManagers: Map<string, { keys: number[]; id: number }> =
|
|
45
45
|
new Map();
|
|
46
|
-
// Default validation message
|
|
47
|
-
private defaultValidateMessage = '
|
|
46
|
+
// Default validation message (overridden by useForm via locale)
|
|
47
|
+
private defaultValidateMessage = '';
|
|
48
48
|
// useWatch subscription management
|
|
49
49
|
private watchers: Map<string, Set<() => void>> = new Map();
|
|
50
50
|
// Field.Group group validators
|
|
@@ -174,9 +174,9 @@
|
|
|
174
174
|
// }
|
|
175
175
|
|
|
176
176
|
import { useRef } from 'react';
|
|
177
|
-
import { useLocale } from '
|
|
178
|
-
import { FormStore } from '
|
|
179
|
-
import { FormInstance } from '
|
|
177
|
+
import { useLocale } from '../../locale';
|
|
178
|
+
import { FormStore } from '../form-store';
|
|
179
|
+
import { FormInstance } from '../interface';
|
|
180
180
|
|
|
181
181
|
export default function useForm<Values = any>(
|
|
182
182
|
form?: FormInstance<Values>,
|
|
@@ -189,9 +189,7 @@ export default function useForm<Values = any>(
|
|
|
189
189
|
} else {
|
|
190
190
|
const formStore = new FormStore();
|
|
191
191
|
// 设置默认验证消息
|
|
192
|
-
formStore.setDefaultValidateMessage(
|
|
193
|
-
locale.form?.defaultRequiredMessage || '该项为必填项',
|
|
194
|
-
);
|
|
192
|
+
formStore.setDefaultValidateMessage(locale.form.defaultRequiredMessage);
|
|
195
193
|
formRef.current = formStore.getForm();
|
|
196
194
|
}
|
|
197
195
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import FieldContext from '../FieldContext';
|
|
3
|
+
|
|
4
|
+
export default function useFormInstance() {
|
|
5
|
+
const form = useContext(FieldContext);
|
|
6
|
+
|
|
7
|
+
if (typeof form.getFieldsValue !== 'function') {
|
|
8
|
+
throw new Error('useFormInstance must be used inside a <Form>');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return form;
|
|
12
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext, useLayoutEffect, useState } from 'react';
|
|
2
|
-
import FieldContext from '
|
|
3
|
-
import type { FormInstance, NamePath } from '
|
|
2
|
+
import FieldContext from '../FieldContext';
|
|
3
|
+
import type { FormInstance, NamePath } from '../interface';
|
|
4
4
|
|
|
5
5
|
function useWatch<T = any>(
|
|
6
6
|
namePath?: NamePath,
|
package/src/Form/index.en-US.md
CHANGED
|
@@ -71,7 +71,9 @@ High performance form component with data scope management.
|
|
|
71
71
|
|
|
72
72
|
| Method | Type | Description |
|
|
73
73
|
| --------------- | ------------------------------------------------------- | ---------------------------------------- |
|
|
74
|
+
| Form.useForm | `(form?: FormInstance) => [FormInstance]` | Create a Form instance; pass an external form for controlled usage |
|
|
74
75
|
| Form.useWatch | `(namePath?: NamePath, form?: FormInstance) => T \| undefined` | Watch form field value changes, omit namePath to get all values |
|
|
76
|
+
| Form.useFormInstance | `() => FormInstance` | Get the nearest Form instance from context, must be used inside a `<Form>` |
|
|
75
77
|
|
|
76
78
|
### Field.GroupProps
|
|
77
79
|
|
package/src/Form/index.ts
CHANGED
|
@@ -2,8 +2,9 @@ import Field from './Field';
|
|
|
2
2
|
import InternalForm from './Form';
|
|
3
3
|
import Group from './Group';
|
|
4
4
|
import List from './List';
|
|
5
|
-
import useForm from './useForm';
|
|
6
|
-
import
|
|
5
|
+
import useForm from './hooks/useForm';
|
|
6
|
+
import useFormInstance from './hooks/useFormInstance';
|
|
7
|
+
import useWatch from './hooks/useWatch';
|
|
7
8
|
|
|
8
9
|
type FieldInterface = typeof Field & {
|
|
9
10
|
Group: typeof Group;
|
|
@@ -12,6 +13,7 @@ type FieldInterface = typeof Field & {
|
|
|
12
13
|
type FormInterface = typeof InternalForm & {
|
|
13
14
|
useForm: typeof useForm;
|
|
14
15
|
useWatch: typeof useWatch;
|
|
16
|
+
useFormInstance: typeof useFormInstance;
|
|
15
17
|
Field: FieldInterface;
|
|
16
18
|
List: typeof List;
|
|
17
19
|
};
|
|
@@ -19,6 +21,7 @@ type FormInterface = typeof InternalForm & {
|
|
|
19
21
|
const Form = InternalForm as FormInterface;
|
|
20
22
|
Form.useForm = useForm;
|
|
21
23
|
Form.useWatch = useWatch;
|
|
24
|
+
Form.useFormInstance = useFormInstance;
|
|
22
25
|
const FormField = Field as FieldInterface;
|
|
23
26
|
FormField.Group = Group;
|
|
24
27
|
Form.Field = FormField;
|
package/src/Form/index.zh-CN.md
CHANGED
|
@@ -70,7 +70,9 @@ toc: 'content'
|
|
|
70
70
|
|
|
71
71
|
| 方法名 | 类型 | 描述 |
|
|
72
72
|
| ------------- | -------------------------------------------------------------- | -------------------------------------------- |
|
|
73
|
+
| Form.useForm | `(form?: FormInstance) => [FormInstance]` | 创建 Form 实例,传入外部 form 可受控使用 |
|
|
73
74
|
| Form.useWatch | `(namePath?: NamePath, form?: FormInstance) => T \| undefined` | 监听表单字段值变化,不传 namePath 返回所有值 |
|
|
75
|
+
| Form.useFormInstance | `() => FormInstance` | 获取当前上下文中最近的 Form 实例,须在 `<Form>` 内调用 |
|
|
74
76
|
|
|
75
77
|
### Field.GroupProps
|
|
76
78
|
|
package/src/Input/password.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Eye, EyeOff } from 'lucide-react';
|
|
2
2
|
import React, { forwardRef, useContext } from 'react';
|
|
3
3
|
import { GlobalContext } from '../Config-Provider';
|
|
4
|
+
import { useLocale } from '../locale';
|
|
4
5
|
import mergeContextToProps from '../utils/mergeContextToProps';
|
|
5
6
|
import Input from './input';
|
|
6
7
|
import type { PasswordProps } from './interface';
|
|
@@ -11,6 +12,8 @@ const Password = forwardRef<HTMLInputElement, PasswordProps>(
|
|
|
11
12
|
(baseProps, ref) => {
|
|
12
13
|
const { password } = useContext(GlobalContext);
|
|
13
14
|
const props = mergeContextToProps(baseProps, password);
|
|
15
|
+
const { locale } = useLocale();
|
|
16
|
+
const { input: inputLocale } = locale;
|
|
14
17
|
|
|
15
18
|
const {
|
|
16
19
|
visibilityToggle = true,
|
|
@@ -45,7 +48,7 @@ const Password = forwardRef<HTMLInputElement, PasswordProps>(
|
|
|
45
48
|
onKeyDown={handleKeyDown}
|
|
46
49
|
tabIndex={0}
|
|
47
50
|
role="button"
|
|
48
|
-
aria-label=
|
|
51
|
+
aria-label={inputLocale.hidePassword}
|
|
49
52
|
/>
|
|
50
53
|
) : (
|
|
51
54
|
<Eye
|
|
@@ -55,7 +58,7 @@ const Password = forwardRef<HTMLInputElement, PasswordProps>(
|
|
|
55
58
|
onKeyDown={handleKeyDown}
|
|
56
59
|
tabIndex={0}
|
|
57
60
|
role="button"
|
|
58
|
-
aria-label=
|
|
61
|
+
aria-label={inputLocale.showPassword}
|
|
59
62
|
/>
|
|
60
63
|
);
|
|
61
64
|
|
|
@@ -5,6 +5,7 @@ import { GlobalContext } from '../Config-Provider';
|
|
|
5
5
|
import Input from '../Input';
|
|
6
6
|
import Select from '../Select';
|
|
7
7
|
import useMergedState from '../hooks/useMergedState';
|
|
8
|
+
import { useLocale } from '../locale';
|
|
8
9
|
import mergeContextToProps from '../utils/mergeContextToProps';
|
|
9
10
|
import type { PaginationProps } from './interface';
|
|
10
11
|
import Items from './items';
|
|
@@ -15,6 +16,8 @@ const Pagination = React.forwardRef(
|
|
|
15
16
|
(baseprops: PaginationProps, ref: React.Ref<HTMLUListElement>) => {
|
|
16
17
|
const { pagination } = useContext(GlobalContext);
|
|
17
18
|
const props = mergeContextToProps(baseprops, pagination);
|
|
19
|
+
const { locale } = useLocale();
|
|
20
|
+
const { pagination: paginationLocale } = locale;
|
|
18
21
|
const {
|
|
19
22
|
prefixCls = 'yee-pagination',
|
|
20
23
|
disabled,
|
|
@@ -235,7 +238,7 @@ const Pagination = React.forwardRef(
|
|
|
235
238
|
|
|
236
239
|
return (
|
|
237
240
|
<li className={`${prefixCls}-quick-jumper`} key="quick-jumper">
|
|
238
|
-
<span>{
|
|
241
|
+
<span>{paginationLocale.jumpTo}</span>
|
|
239
242
|
{renderNumber(clear)}
|
|
240
243
|
</li>
|
|
241
244
|
);
|
|
@@ -307,8 +307,8 @@ const RangePickerMobile: FC<RangePickerProps> = (props) => {
|
|
|
307
307
|
)}
|
|
308
308
|
<Button block type="primary" onClick={handleTabConfirm}>
|
|
309
309
|
{activeTab === 'start'
|
|
310
|
-
? rangepicker
|
|
311
|
-
: rangepicker
|
|
310
|
+
? rangepicker.next
|
|
311
|
+
: rangepicker.confirm}
|
|
312
312
|
</Button>
|
|
313
313
|
</div>
|
|
314
314
|
}
|
|
@@ -323,7 +323,7 @@ const RangePickerMobile: FC<RangePickerProps> = (props) => {
|
|
|
323
323
|
onClick={() => setActiveTab('start')}
|
|
324
324
|
type="button"
|
|
325
325
|
>
|
|
326
|
-
{rangepicker
|
|
326
|
+
{rangepicker.startPlaceholder}
|
|
327
327
|
</button>
|
|
328
328
|
<button
|
|
329
329
|
className={clsx(
|
|
@@ -333,7 +333,7 @@ const RangePickerMobile: FC<RangePickerProps> = (props) => {
|
|
|
333
333
|
onClick={() => setActiveTab('end')}
|
|
334
334
|
type="button"
|
|
335
335
|
>
|
|
336
|
-
{rangepicker
|
|
336
|
+
{rangepicker.endPlaceholder}
|
|
337
337
|
</button>
|
|
338
338
|
</div>
|
|
339
339
|
|
package/src/Space/compact.tsx
CHANGED
|
@@ -20,7 +20,7 @@ const Compact = forwardRef<HTMLDivElement, SpaceCompactProps>((props, ref) => {
|
|
|
20
20
|
(child: React.ReactElement, index) => {
|
|
21
21
|
if (React.isValidElement(child)) {
|
|
22
22
|
const first = index === 0;
|
|
23
|
-
const middle = index > 0 && index < total;
|
|
23
|
+
const middle = index > 0 && index < total - 1;
|
|
24
24
|
const last = index > 0 && index === total - 1;
|
|
25
25
|
const props = child.props as any;
|
|
26
26
|
return React.cloneElement(child as any, {
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import { Space } from '@rainbow-oh/yee-c';
|
|
1
|
+
import { Button, Input, Space } from '@rainbow-oh/yee-c';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
export default () => {
|
|
5
5
|
return (
|
|
6
6
|
<Space.Compact>
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
type="button"
|
|
10
|
-
style={{
|
|
11
|
-
background: '#1890ff',
|
|
12
|
-
color: 'white',
|
|
13
|
-
border: 'none',
|
|
14
|
-
padding: '4px 11px',
|
|
15
|
-
}}
|
|
16
|
-
>
|
|
17
|
-
Submit
|
|
18
|
-
</button>
|
|
7
|
+
<Input placeholder="Enter name" />
|
|
8
|
+
<Button type="primary">Submit</Button>
|
|
19
9
|
</Space.Compact>
|
|
20
10
|
);
|
|
21
11
|
};
|
package/src/Space/space.tsx
CHANGED
|
@@ -47,6 +47,8 @@ const Space = forwardRef<HTMLDivElement, SpaceProps>((baseprops, ref) => {
|
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
let loopCount = 1;
|
|
51
|
+
|
|
50
52
|
const loop = (childs: React.ReactNode[]) => {
|
|
51
53
|
let res = [] as React.ReactElement[];
|
|
52
54
|
|
|
@@ -60,6 +62,7 @@ const Space = forwardRef<HTMLDivElement, SpaceProps>((baseprops, ref) => {
|
|
|
60
62
|
const itemChildren = isItem ? (child.props as any).children : child;
|
|
61
63
|
|
|
62
64
|
if (React.isValidElement(child) && child.type === React.Fragment) {
|
|
65
|
+
loopCount++;
|
|
63
66
|
res = res.concat(
|
|
64
67
|
loop(React.Children.toArray((child.props as any).children)),
|
|
65
68
|
);
|
|
@@ -72,7 +75,7 @@ const Space = forwardRef<HTMLDivElement, SpaceProps>((baseprops, ref) => {
|
|
|
72
75
|
itemClassName,
|
|
73
76
|
)}
|
|
74
77
|
style={{ ...styles?.item, ...itemStyle }}
|
|
75
|
-
key={index}
|
|
78
|
+
key={`${loopCount}-${index}`}
|
|
76
79
|
>
|
|
77
80
|
{itemChildren}
|
|
78
81
|
</div>,
|
|
@@ -18,12 +18,22 @@
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
&-compact {
|
|
21
|
+
display: inline-flex;
|
|
21
22
|
align-items: flex-end;
|
|
22
23
|
|
|
23
24
|
&-first-item {
|
|
24
25
|
margin-inline-end: -1px;
|
|
26
|
+
border-top-right-radius: 0;
|
|
27
|
+
border-bottom-right-radius: 0;
|
|
28
|
+
|
|
29
|
+
&:hover,
|
|
30
|
+
&:active {
|
|
31
|
+
position: relative;
|
|
32
|
+
z-index: 1;
|
|
33
|
+
}
|
|
25
34
|
|
|
26
35
|
.yee-input-wrapper,
|
|
36
|
+
.yee-input,
|
|
27
37
|
.yee-tags,
|
|
28
38
|
&.yee-btn {
|
|
29
39
|
border-top-right-radius: 0;
|
|
@@ -39,6 +49,13 @@
|
|
|
39
49
|
|
|
40
50
|
&-middle-item {
|
|
41
51
|
margin-inline-end: -1px;
|
|
52
|
+
border-radius: 0;
|
|
53
|
+
|
|
54
|
+
&:hover,
|
|
55
|
+
&:active {
|
|
56
|
+
position: relative;
|
|
57
|
+
z-index: 1;
|
|
58
|
+
}
|
|
42
59
|
|
|
43
60
|
.yee-input-wrapper,
|
|
44
61
|
.yee-tags,
|
|
@@ -52,19 +69,22 @@
|
|
|
52
69
|
z-index: 1;
|
|
53
70
|
}
|
|
54
71
|
}
|
|
72
|
+
|
|
73
|
+
&-last-item {
|
|
74
|
+
border-top-left-radius: 0;
|
|
75
|
+
border-bottom-left-radius: 0;
|
|
76
|
+
|
|
77
|
+
.yee-input-wrapper,
|
|
78
|
+
.yee-tags,
|
|
79
|
+
&.yee-btn {
|
|
80
|
+
border-top-left-radius: 0;
|
|
81
|
+
border-bottom-left-radius: 0;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
55
84
|
}
|
|
56
85
|
|
|
57
86
|
&-item {
|
|
58
87
|
// flex: 1 1 auto;
|
|
59
88
|
display: inline-flex;
|
|
60
89
|
}
|
|
61
|
-
|
|
62
|
-
&-last-item {
|
|
63
|
-
.yee-input-wrapper,
|
|
64
|
-
.yee-tags,
|
|
65
|
-
&.yee-btn {
|
|
66
|
-
border-top-left-radius: 0;
|
|
67
|
-
border-bottom-left-radius: 0;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
90
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useLocale } from '../../locale';
|
|
2
3
|
import { TableBodyProps } from '../interface';
|
|
3
4
|
import { TableCtx } from '../table';
|
|
4
5
|
import LazyRow from './lazy-row';
|
|
@@ -8,11 +9,13 @@ const TableBody: React.FC<TableBodyProps> = (props) => {
|
|
|
8
9
|
const { columns, pageData, lazyLoad, ...rest } = props;
|
|
9
10
|
|
|
10
11
|
const { prefixCls } = React.useContext(TableCtx);
|
|
12
|
+
const { locale } = useLocale();
|
|
13
|
+
const { table: tableLocale } = locale;
|
|
11
14
|
|
|
12
15
|
const empty = (
|
|
13
16
|
<tbody className={`${prefixCls}-tbody`}>
|
|
14
17
|
<tr className={`${prefixCls}-no-record`}>
|
|
15
|
-
<td colSpan={999}>{
|
|
18
|
+
<td colSpan={999}>{tableLocale.emptyText}</td>
|
|
16
19
|
</tr>
|
|
17
20
|
</tbody>
|
|
18
21
|
);
|