@rainbow-oh/yee-c 0.3.0 → 0.4.1
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/Anchor/anchor.js +29 -14
- package/dist/cjs/Form/demo/basic.js +56 -81
- package/dist/cjs/Form/demo/form-table.js +68 -67
- package/dist/cjs/Menu/style/index.less +2 -0
- package/dist/cjs/Segmented/demo/variant.d.ts +3 -0
- package/dist/cjs/Segmented/demo/variant.js +50 -0
- package/dist/cjs/Segmented/interface.d.ts +5 -0
- package/dist/cjs/Segmented/segmented.js +3 -0
- package/dist/cjs/Segmented/style/index.less +24 -0
- package/dist/cjs/Tag/demo/variant.d.ts +3 -0
- package/dist/cjs/Tag/demo/variant.js +39 -0
- package/dist/cjs/Tag/interface.d.ts +5 -0
- package/dist/cjs/Tag/style/index.less +108 -25
- package/dist/cjs/Tag/tag.js +3 -0
- package/dist/cjs/style/color.css +3 -3
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +4 -4
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Anchor/anchor.js +37 -15
- package/dist/esm/Form/demo/basic.js +2 -18
- package/dist/esm/Form/demo/form-table.js +4 -10
- package/dist/esm/Menu/style/index.less +2 -0
- package/dist/esm/Segmented/demo/variant.d.ts +3 -0
- package/dist/esm/Segmented/demo/variant.js +49 -0
- package/dist/esm/Segmented/interface.d.ts +5 -0
- package/dist/esm/Segmented/segmented.js +4 -2
- package/dist/esm/Segmented/style/index.less +24 -0
- package/dist/esm/Tag/demo/variant.d.ts +3 -0
- package/dist/esm/Tag/demo/variant.js +48 -0
- package/dist/esm/Tag/interface.d.ts +5 -0
- package/dist/esm/Tag/style/index.less +108 -25
- package/dist/esm/Tag/tag.js +4 -2
- package/dist/esm/style/color.css +3 -3
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +4 -4
- 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/Anchor/anchor.tsx +35 -16
- package/src/Form/demo/basic.tsx +2 -24
- package/src/Form/demo/form-table.tsx +16 -13
- package/src/Menu/style/index.less +2 -0
- package/src/Segmented/demo/variant.tsx +28 -0
- package/src/Segmented/index.en-US.md +2 -0
- package/src/Segmented/index.zh-CN.md +2 -0
- package/src/Segmented/interface.ts +5 -0
- package/src/Segmented/segmented.tsx +2 -0
- package/src/Segmented/style/index.less +24 -0
- package/src/Tag/demo/variant.tsx +47 -0
- package/src/Tag/index.en-US.md +2 -0
- package/src/Tag/index.zh-CN.md +2 -0
- package/src/Tag/interface.ts +5 -0
- package/src/Tag/style/index.less +108 -25
- package/src/Tag/tag.tsx +2 -0
- package/src/style/color.css +3 -3
- package/src/version.ts +1 -1
package/package.json
CHANGED
package/src/Anchor/anchor.tsx
CHANGED
|
@@ -6,13 +6,11 @@ import React, {
|
|
|
6
6
|
useCallback,
|
|
7
7
|
useContext,
|
|
8
8
|
useEffect,
|
|
9
|
-
useLayoutEffect,
|
|
10
9
|
useRef,
|
|
11
10
|
useState,
|
|
12
11
|
} from 'react';
|
|
13
12
|
import { GlobalContext } from '../Config-Provider';
|
|
14
13
|
import useMergedState from '../hooks/useMergedState';
|
|
15
|
-
import debounce from '../utils/debounce';
|
|
16
14
|
import mergeContextToProps from '../utils/mergeContextToProps';
|
|
17
15
|
import AnchorItem from './anchor-item';
|
|
18
16
|
import type {
|
|
@@ -124,6 +122,8 @@ const Anchor = forwardRef<HTMLDivElement, AnchorProps>((baseprops, ref) => {
|
|
|
124
122
|
// Empty array guard
|
|
125
123
|
if (!currentItems || currentItems.length === 0) return;
|
|
126
124
|
|
|
125
|
+
// Pick the last anchor whose top has crossed the activation line.
|
|
126
|
+
let nextActiveKey: string | undefined;
|
|
127
127
|
for (let i = currentItems.length - 1; i >= 0; i--) {
|
|
128
128
|
const item = currentItems[i];
|
|
129
129
|
const target = document.getElementById(item.key);
|
|
@@ -131,27 +131,50 @@ const Anchor = forwardRef<HTMLDivElement, AnchorProps>((baseprops, ref) => {
|
|
|
131
131
|
if (target) {
|
|
132
132
|
const targetTop = getTargetOffsetTop(target);
|
|
133
133
|
if (scrollTop + offsetTop >= targetTop) {
|
|
134
|
-
|
|
135
|
-
setMergedActiveKey(item.key);
|
|
136
|
-
onChange?.(item.key);
|
|
137
|
-
}
|
|
134
|
+
nextActiveKey = item.key;
|
|
138
135
|
break;
|
|
139
136
|
}
|
|
140
137
|
}
|
|
141
138
|
}
|
|
139
|
+
|
|
140
|
+
// Scrolled above the first anchor — reset to the top item.
|
|
141
|
+
if (nextActiveKey === undefined) {
|
|
142
|
+
const first = currentItems.find(
|
|
143
|
+
(item) => document.getElementById(item.key),
|
|
144
|
+
);
|
|
145
|
+
nextActiveKey = first?.key;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (nextActiveKey && activeKeyRef.current !== nextActiveKey) {
|
|
149
|
+
setMergedActiveKey(nextActiveKey);
|
|
150
|
+
onChange?.(nextActiveKey);
|
|
151
|
+
}
|
|
142
152
|
}, [auto, anchorList, items, offsetTop, onChange, getTargetOffsetTop]);
|
|
143
153
|
|
|
144
154
|
useEffect(() => {
|
|
145
|
-
|
|
155
|
+
// Resolve in a passive effect: parent-owned refs passed via `getContainer`
|
|
156
|
+
// aren't attached until after child layout effects run.
|
|
157
|
+
const container = getContainer ? getContainer() : window;
|
|
158
|
+
containerRef.current = container;
|
|
146
159
|
if (!container) return;
|
|
147
160
|
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
// rAF throttle so the active key tracks scroll live.
|
|
162
|
+
let rafId: ReturnType<typeof requestAnimationFrame> | null = null;
|
|
163
|
+
const onScroll = () => {
|
|
164
|
+
if (rafId !== null) return;
|
|
165
|
+
rafId = requestAnimationFrame(() => {
|
|
166
|
+
rafId = null;
|
|
167
|
+
handleScroll();
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
container.addEventListener('scroll', onScroll as EventListener);
|
|
150
171
|
handleScroll();
|
|
151
172
|
|
|
152
173
|
return () => {
|
|
153
|
-
container.removeEventListener('scroll',
|
|
154
|
-
|
|
174
|
+
container.removeEventListener('scroll', onScroll as EventListener);
|
|
175
|
+
if (rafId !== null) {
|
|
176
|
+
cancelAnimationFrame(rafId);
|
|
177
|
+
}
|
|
155
178
|
};
|
|
156
179
|
}, [getContainer, handleScroll]);
|
|
157
180
|
|
|
@@ -178,11 +201,7 @@ const Anchor = forwardRef<HTMLDivElement, AnchorProps>((baseprops, ref) => {
|
|
|
178
201
|
[offsetTop, getTargetOffsetTop],
|
|
179
202
|
);
|
|
180
203
|
|
|
181
|
-
|
|
182
|
-
containerRef.current = getContainer ? getContainer() : window;
|
|
183
|
-
}, [getContainer]);
|
|
184
|
-
|
|
185
|
-
useLayoutEffect(() => {
|
|
204
|
+
useEffect(() => {
|
|
186
205
|
if (defaultActiveKey) {
|
|
187
206
|
scrollToAnchor(defaultActiveKey);
|
|
188
207
|
}
|
package/src/Form/demo/basic.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
Space,
|
|
9
9
|
TextArea,
|
|
10
10
|
} from '@rainbow-oh/yee-c';
|
|
11
|
-
import React
|
|
11
|
+
import React from 'react';
|
|
12
12
|
|
|
13
13
|
export default () => {
|
|
14
14
|
const [form] = Form.useForm();
|
|
@@ -17,30 +17,8 @@ export default () => {
|
|
|
17
17
|
console.log('Received values:', values);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const [, setState] = React.useState({});
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
setTimeout(() => {
|
|
24
|
-
form.setFieldsValue({
|
|
25
|
-
address: [
|
|
26
|
-
{
|
|
27
|
-
one: '123 Main St',
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
});
|
|
31
|
-
}, 2000);
|
|
32
|
-
}, []);
|
|
33
|
-
|
|
34
20
|
return (
|
|
35
|
-
<Form
|
|
36
|
-
form={form}
|
|
37
|
-
onFinish={onFinish}
|
|
38
|
-
layout="vertical"
|
|
39
|
-
data-testid="basic-form"
|
|
40
|
-
onValuesChange={(field) => {
|
|
41
|
-
setState(field);
|
|
42
|
-
}}
|
|
43
|
-
>
|
|
21
|
+
<Form form={form} onFinish={onFinish} data-testid="basic-form">
|
|
44
22
|
<Grid>
|
|
45
23
|
<Grid.Item>
|
|
46
24
|
<Form.Field
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { ColumnProps } from '@rainbow-oh/yee-c';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Form,
|
|
5
|
+
Input,
|
|
6
|
+
InputNumber,
|
|
7
|
+
Space,
|
|
8
|
+
Table,
|
|
9
|
+
TextArea,
|
|
10
|
+
} from '@rainbow-oh/yee-c';
|
|
3
11
|
import React from 'react';
|
|
4
12
|
|
|
5
13
|
export default () => {
|
|
@@ -13,16 +21,7 @@ export default () => {
|
|
|
13
21
|
<div style={{ padding: '24px' }}>
|
|
14
22
|
<h2>Form + Table Dynamic Form Example</h2>
|
|
15
23
|
<Form form={form} onFinish={onFinish} layout="vertical">
|
|
16
|
-
<Form.List
|
|
17
|
-
name="users"
|
|
18
|
-
// initialValue={[
|
|
19
|
-
// {
|
|
20
|
-
// name: '',
|
|
21
|
-
// age: '',
|
|
22
|
-
// address: '',
|
|
23
|
-
// },
|
|
24
|
-
// ]}
|
|
25
|
-
>
|
|
24
|
+
<Form.List name="users">
|
|
26
25
|
{(fields, operations) => {
|
|
27
26
|
// Define column config - operations are accessible here
|
|
28
27
|
const columns: ColumnProps[] = [
|
|
@@ -44,7 +43,11 @@ export default () => {
|
|
|
44
43
|
width: '20%',
|
|
45
44
|
render: (_record, index) => (
|
|
46
45
|
<Form.Field name={[index, 'age']} required>
|
|
47
|
-
<
|
|
46
|
+
<InputNumber
|
|
47
|
+
controls={false}
|
|
48
|
+
placeholder="Please enter age"
|
|
49
|
+
type="number"
|
|
50
|
+
/>
|
|
48
51
|
</Form.Field>
|
|
49
52
|
),
|
|
50
53
|
},
|
|
@@ -55,7 +58,7 @@ export default () => {
|
|
|
55
58
|
width: '40%',
|
|
56
59
|
render: (_record, index) => (
|
|
57
60
|
<Form.Field name={[index, 'address']}>
|
|
58
|
-
<
|
|
61
|
+
<TextArea placeholder="Please enter address" />
|
|
59
62
|
</Form.Field>
|
|
60
63
|
),
|
|
61
64
|
},
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
// -------- item --------
|
|
31
31
|
&-item {
|
|
32
32
|
display: flex;
|
|
33
|
+
flex-shrink: 0;
|
|
33
34
|
align-items: center;
|
|
34
35
|
box-sizing: border-box;
|
|
35
36
|
width: 100%;
|
|
@@ -119,6 +120,7 @@
|
|
|
119
120
|
&-title {
|
|
120
121
|
display: flex;
|
|
121
122
|
align-items: center;
|
|
123
|
+
flex-shrink: 0;
|
|
122
124
|
justify-content: space-between;
|
|
123
125
|
padding: var(--yee-menu-item-padding);
|
|
124
126
|
border-radius: var(--yee-menu-item-border-radius);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Segmented, Space } from '@rainbow-oh/yee-c';
|
|
2
|
+
import { LayoutGrid, List } from 'lucide-react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
export default () => (
|
|
6
|
+
<Space direction="vertical">
|
|
7
|
+
<Space block>
|
|
8
|
+
<Segmented options={['Daily', 'Weekly', 'Monthly']} />
|
|
9
|
+
<Segmented variant="pill" options={['Daily', 'Weekly', 'Monthly']} />
|
|
10
|
+
</Space>
|
|
11
|
+
<Space block>
|
|
12
|
+
<Segmented variant="pill" size="small" options={['Small', 'Default', 'Large']} />
|
|
13
|
+
<Segmented variant="pill" size="large" options={['Small', 'Default', 'Large']} />
|
|
14
|
+
</Space>
|
|
15
|
+
<div style={{ width: 480 }}>
|
|
16
|
+
<Segmented
|
|
17
|
+
variant="pill"
|
|
18
|
+
block
|
|
19
|
+
defaultValue="list"
|
|
20
|
+
options={[
|
|
21
|
+
{ label: 'List', value: 'list', icon: <List size={16} /> },
|
|
22
|
+
{ label: 'Grid', value: 'grid', icon: <LayoutGrid size={16} /> },
|
|
23
|
+
{ label: 'Detail', value: 'detail' },
|
|
24
|
+
]}
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
</Space>
|
|
28
|
+
);
|
|
@@ -18,6 +18,7 @@ Displays a group of mutually exclusive options, with the selected item highlight
|
|
|
18
18
|
<code src="./demo/disabled.tsx" title="Disabled" description="Disable a single option or the whole group"></code>
|
|
19
19
|
<code src="./demo/size.tsx" title="Size" description="small / default / large"></code>
|
|
20
20
|
<code src="./demo/block.tsx" title="Block & Icon" description="block fills the container width, options can carry icons"></code>
|
|
21
|
+
<code src="./demo/variant.tsx" title="Variant" description="pill style: selected item highlighted as a colored capsule, no container background"></code>
|
|
21
22
|
|
|
22
23
|
## API
|
|
23
24
|
|
|
@@ -36,6 +37,7 @@ Displays a group of mutually exclusive options, with the selected item highlight
|
|
|
36
37
|
| onChange | `(value: string \| number) => void` | Callback when selected value changes | - |
|
|
37
38
|
| disabled | `boolean` | Whether to disable all options | - |
|
|
38
39
|
| size | `'small' \| 'default' \| 'large'` | Size | - |
|
|
40
|
+
| variant | `'default' \| 'pill'` | Visual style variant, `pill` renders a capsule style | `default` |
|
|
39
41
|
| block | `boolean` | Whether to fill the container width, options share the space equally | - |
|
|
40
42
|
| name | `string` | Name of the underlying radio input, for form grouping | - |
|
|
41
43
|
|
|
@@ -18,6 +18,7 @@ toc: 'content'
|
|
|
18
18
|
<code src="./demo/disabled.tsx" title="禁用" description="禁用单个选项或整组"></code>
|
|
19
19
|
<code src="./demo/size.tsx" title="尺寸" description="small / default / large 三种尺寸"></code>
|
|
20
20
|
<code src="./demo/block.tsx" title="撑满与图标" description="block 撑满容器宽度,选项可带图标"></code>
|
|
21
|
+
<code src="./demo/variant.tsx" title="变体" description="pill 胶囊风格:选中项以主色胶囊高亮,容器无底色"></code>
|
|
21
22
|
|
|
22
23
|
## API
|
|
23
24
|
|
|
@@ -36,6 +37,7 @@ toc: 'content'
|
|
|
36
37
|
| onChange | `(value: string \| number) => void` | 值改变时的回调 | - |
|
|
37
38
|
| disabled | `boolean` | 是否禁用所有选项 | - |
|
|
38
39
|
| size | `'small' \| 'default' \| 'large'` | 尺寸 | - |
|
|
40
|
+
| variant | `'default' \| 'pill'` | 视觉风格变体,`pill` 为胶囊药丸风格 | `default` |
|
|
39
41
|
| block | `boolean` | 是否撑满容器宽度,选项等分 | - |
|
|
40
42
|
| name | `string` | 底层 radio input 的 name,用于表单分组 | - |
|
|
41
43
|
|
|
@@ -76,6 +76,11 @@ export interface SegmentedProps extends DataAttributeProps {
|
|
|
76
76
|
* Size
|
|
77
77
|
*/
|
|
78
78
|
size?: 'small' | 'default' | 'large';
|
|
79
|
+
/**
|
|
80
|
+
* Visual style variant. `pill` renders the selected item as a colored capsule with no container background
|
|
81
|
+
* @default default
|
|
82
|
+
*/
|
|
83
|
+
variant?: 'default' | 'pill';
|
|
79
84
|
/**
|
|
80
85
|
* Whether to fill the container width, options share the space equally
|
|
81
86
|
*/
|
|
@@ -40,6 +40,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
|
|
|
40
40
|
defaultValue,
|
|
41
41
|
disabled,
|
|
42
42
|
size,
|
|
43
|
+
variant = 'default',
|
|
43
44
|
block,
|
|
44
45
|
name = uid,
|
|
45
46
|
onChange,
|
|
@@ -64,6 +65,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
|
|
|
64
65
|
prefixCls,
|
|
65
66
|
{
|
|
66
67
|
[`${prefixCls}-${size}`]: size,
|
|
68
|
+
[`${prefixCls}-${variant}`]: variant && variant !== 'default',
|
|
67
69
|
[`${prefixCls}-block`]: block,
|
|
68
70
|
[`${prefixCls}-disabled`]: disabled,
|
|
69
71
|
},
|
|
@@ -88,6 +88,30 @@
|
|
|
88
88
|
box-shadow: 0 0 0 2px var(--yee-primary-color);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// 变体:胶囊风格,选中项以主色胶囊高亮,容器无底色
|
|
92
|
+
&-pill {
|
|
93
|
+
padding: 0;
|
|
94
|
+
background-color: transparent;
|
|
95
|
+
gap: var(--yee-segmented-item-gap);
|
|
96
|
+
|
|
97
|
+
@{pls}-item {
|
|
98
|
+
border-radius: 999px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@{pls}-item-selected {
|
|
102
|
+
color: var(--yee-segmented-pill-color, #fff);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@{pls}-thumb {
|
|
106
|
+
border-radius: 999px;
|
|
107
|
+
background-color: var(
|
|
108
|
+
--yee-segmented-pill-bg-color,
|
|
109
|
+
var(--yee-primary-color)
|
|
110
|
+
);
|
|
111
|
+
box-shadow: none;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
91
115
|
&-small {
|
|
92
116
|
@{pls}-item {
|
|
93
117
|
padding: var(--yee-segmented-item-small-padding);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Space, Tag } from '@rainbow-oh/yee-c';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
return (
|
|
6
|
+
<Space direction="vertical">
|
|
7
|
+
<Space block>
|
|
8
|
+
<Tag variant="filled">Filled</Tag>
|
|
9
|
+
<Tag variant="solid">Solid</Tag>
|
|
10
|
+
<Tag variant="outlined">Outlined</Tag>
|
|
11
|
+
</Space>
|
|
12
|
+
<Space block>
|
|
13
|
+
<Tag variant="filled" status="success">
|
|
14
|
+
Success
|
|
15
|
+
</Tag>
|
|
16
|
+
<Tag variant="solid" status="success">
|
|
17
|
+
Success
|
|
18
|
+
</Tag>
|
|
19
|
+
<Tag variant="outlined" status="success">
|
|
20
|
+
Success
|
|
21
|
+
</Tag>
|
|
22
|
+
</Space>
|
|
23
|
+
<Space block>
|
|
24
|
+
<Tag variant="filled" status="warning">
|
|
25
|
+
Warning
|
|
26
|
+
</Tag>
|
|
27
|
+
<Tag variant="solid" status="warning">
|
|
28
|
+
Warning
|
|
29
|
+
</Tag>
|
|
30
|
+
<Tag variant="outlined" status="warning">
|
|
31
|
+
Warning
|
|
32
|
+
</Tag>
|
|
33
|
+
</Space>
|
|
34
|
+
<Space block>
|
|
35
|
+
<Tag variant="filled" status="error">
|
|
36
|
+
Error
|
|
37
|
+
</Tag>
|
|
38
|
+
<Tag variant="solid" status="error">
|
|
39
|
+
Error
|
|
40
|
+
</Tag>
|
|
41
|
+
<Tag variant="outlined" status="error">
|
|
42
|
+
Error
|
|
43
|
+
</Tag>
|
|
44
|
+
</Space>
|
|
45
|
+
</Space>
|
|
46
|
+
);
|
|
47
|
+
};
|
package/src/Tag/index.en-US.md
CHANGED
|
@@ -16,6 +16,7 @@ Tag for categorizing or markup.
|
|
|
16
16
|
|
|
17
17
|
<code src="./demo/basic.tsx" title="Basic" description="Basic usage of Tag"></code>
|
|
18
18
|
<code src="./demo/type.tsx" title="Type" description="Different types of Tag"></code>
|
|
19
|
+
<code src="./demo/variant.tsx" title="Variant" description="Three tag styles: filled, solid, outlined"></code>
|
|
19
20
|
<code src="./demo/closable.tsx" title="Closable" description="Closable Tag"></code>
|
|
20
21
|
<code src="./demo/size.tsx" title="Size" description="Different sizes of Tag"></code>
|
|
21
22
|
<code src="./demo/checkable.tsx" title="Checkable" description="Checkable Tag"></code>
|
|
@@ -37,6 +38,7 @@ Tag for categorizing or markup.
|
|
|
37
38
|
| closable | `boolean \| React.ReactNode` | Whether closable or custom close icon | - |
|
|
38
39
|
| status | `TagType` | Built-in status | - |
|
|
39
40
|
| dashed | `boolean` | Whether dashed border | - |
|
|
41
|
+
| variant | `'filled' \| 'solid' \| 'outlined'` | Tag style variant | `filled` |
|
|
40
42
|
| size | `'small' \| 'default' \| 'large'` | Size | `default` |
|
|
41
43
|
| icon | `React.ReactNode` | Icon | - |
|
|
42
44
|
| checkable | `boolean` | Whether checkable | - |
|
package/src/Tag/index.zh-CN.md
CHANGED
|
@@ -16,6 +16,7 @@ toc: 'content'
|
|
|
16
16
|
|
|
17
17
|
<code src="./demo/basic.tsx" title="基础用法" description="Tag的基础用法"></code>
|
|
18
18
|
<code src="./demo/type.tsx" title="类型" description="不同类型的标签"></code>
|
|
19
|
+
<code src="./demo/variant.tsx" title="变体" description="三种风格的标签:filled、solid、outlined"></code>
|
|
19
20
|
<code src="./demo/closable.tsx" title="可关闭" description="可关闭的标签"></code>
|
|
20
21
|
<code src="./demo/size.tsx" title="尺寸" description="不同尺寸的标签"></code>
|
|
21
22
|
<code src="./demo/checkable.tsx" title="可选择" description="可选择的标签"></code>
|
|
@@ -37,6 +38,7 @@ toc: 'content'
|
|
|
37
38
|
| closable | `boolean \| React.ReactNode` | 是否可关闭,也可自定义关闭图标 | - |
|
|
38
39
|
| status | `TagType` | 内置状态 | - |
|
|
39
40
|
| dashed | `boolean` | 是否为虚线 | - |
|
|
41
|
+
| variant | `'filled' \| 'solid' \| 'outlined'` | 标签风格变体 | `filled` |
|
|
40
42
|
| size | `'small' \| 'default' \| 'large'` | 尺寸 | `default` |
|
|
41
43
|
| icon | `React.ReactNode` | 设置图标 | - |
|
|
42
44
|
| checkable | `boolean` | 是否可选中 | - |
|
package/src/Tag/interface.ts
CHANGED
package/src/Tag/style/index.less
CHANGED
|
@@ -8,45 +8,128 @@
|
|
|
8
8
|
white-space: nowrap;
|
|
9
9
|
height: var(--yee-tag-height);
|
|
10
10
|
padding: var(--yee-tag-padding);
|
|
11
|
-
color: var(--yee-tag-color);
|
|
12
11
|
font-size: var(--yee-tag-font-size);
|
|
13
12
|
line-height: var(--yee-tag-line-height);
|
|
14
|
-
background-color: var(--yee-tag-item-bg-color);
|
|
15
13
|
background-clip: padding-box;
|
|
16
14
|
border: var(--yee-tag-border-width) solid var(--yee-tag-border-color);
|
|
17
15
|
border-radius: var(--yee-tag-border-radius);
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
// ============ 变体 variant ============
|
|
18
|
+
// filled:浅色底 + 彩色字(默认)
|
|
19
|
+
&-filled {
|
|
20
|
+
color: var(--yee-tag-color);
|
|
21
|
+
background-color: var(--yee-tag-item-bg-color);
|
|
22
|
+
border-color: var(--yee-tag-border-color);
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
&@{pls}-info {
|
|
25
|
+
color: var(--yee-tag-info-color);
|
|
26
|
+
background-color: var(--yee-tag-info-bg-color);
|
|
27
|
+
border-color: var(--yee-tag-info-border-color);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&@{pls}-success {
|
|
31
|
+
color: var(--yee-tag-success-color);
|
|
32
|
+
background-color: var(--yee-tag-success-bg-color);
|
|
33
|
+
border-color: var(--yee-tag-success-border-color);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&@{pls}-warning {
|
|
37
|
+
color: var(--yee-tag-warning-color);
|
|
38
|
+
background-color: var(--yee-tag-warning-bg-color);
|
|
39
|
+
border-color: var(--yee-tag-warning-border-color);
|
|
40
|
+
}
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
&@{pls}-error {
|
|
43
|
+
color: var(--yee-tag-error-color);
|
|
44
|
+
background-color: var(--yee-tag-error-bg-color);
|
|
45
|
+
border-color: var(--yee-tag-error-border-color);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&@{pls}-disabled {
|
|
49
|
+
color: var(--yee-tag-disabled-color);
|
|
50
|
+
background-color: var(--yee-tag-disabled-bg-color);
|
|
51
|
+
border-color: var(--yee-tag-disabled-border-color);
|
|
52
|
+
cursor: not-allowed;
|
|
53
|
+
}
|
|
35
54
|
}
|
|
36
55
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
// solid:纯色底 + 白字
|
|
57
|
+
&-solid {
|
|
58
|
+
color: var(--yee-tag-solid-color, #fff);
|
|
59
|
+
background-color: var(--yee-tag-color);
|
|
60
|
+
border-color: transparent;
|
|
61
|
+
|
|
62
|
+
&@{pls}-info {
|
|
63
|
+
color: var(--yee-tag-solid-color, #fff);
|
|
64
|
+
background-color: var(--yee-tag-info-color);
|
|
65
|
+
border-color: transparent;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&@{pls}-success {
|
|
69
|
+
color: var(--yee-tag-solid-color, #fff);
|
|
70
|
+
background-color: var(--yee-tag-success-color);
|
|
71
|
+
border-color: transparent;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&@{pls}-warning {
|
|
75
|
+
color: var(--yee-tag-solid-color, #fff);
|
|
76
|
+
background-color: var(--yee-tag-warning-color);
|
|
77
|
+
border-color: transparent;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&@{pls}-error {
|
|
81
|
+
color: var(--yee-tag-solid-color, #fff);
|
|
82
|
+
background-color: var(--yee-tag-error-color);
|
|
83
|
+
border-color: transparent;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&@{pls}-disabled {
|
|
87
|
+
color: var(--yee-tag-solid-color, #fff);
|
|
88
|
+
background-color: var(--yee-tag-disabled-color);
|
|
89
|
+
border-color: transparent;
|
|
90
|
+
cursor: not-allowed;
|
|
91
|
+
}
|
|
41
92
|
}
|
|
42
93
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
94
|
+
// outlined:透明底 + 彩色字 + 彩色描边
|
|
95
|
+
&-outlined {
|
|
96
|
+
color: var(--yee-tag-color);
|
|
97
|
+
background-color: transparent;
|
|
98
|
+
border-color: var(--yee-tag-border-color);
|
|
99
|
+
|
|
100
|
+
&@{pls}-info {
|
|
101
|
+
color: var(--yee-tag-info-color);
|
|
102
|
+
background-color: transparent;
|
|
103
|
+
border-color: var(--yee-tag-info-color);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&@{pls}-success {
|
|
107
|
+
color: var(--yee-tag-success-color);
|
|
108
|
+
background-color: transparent;
|
|
109
|
+
border-color: var(--yee-tag-success-color);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&@{pls}-warning {
|
|
113
|
+
color: var(--yee-tag-warning-color);
|
|
114
|
+
background-color: transparent;
|
|
115
|
+
border-color: var(--yee-tag-warning-color);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&@{pls}-error {
|
|
119
|
+
color: var(--yee-tag-error-color);
|
|
120
|
+
background-color: transparent;
|
|
121
|
+
border-color: var(--yee-tag-error-color);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&@{pls}-disabled {
|
|
125
|
+
color: var(--yee-tag-disabled-color);
|
|
126
|
+
background-color: transparent;
|
|
127
|
+
border-color: var(--yee-tag-disabled-color);
|
|
128
|
+
cursor: not-allowed;
|
|
129
|
+
}
|
|
48
130
|
}
|
|
49
131
|
|
|
132
|
+
// ============ 其他修饰 ============
|
|
50
133
|
&-dashed {
|
|
51
134
|
background-color: var(--yee-tag-item-dashed-bg-color);
|
|
52
135
|
border-style: dashed;
|
package/src/Tag/tag.tsx
CHANGED
|
@@ -24,6 +24,7 @@ const Tag = forwardRef(
|
|
|
24
24
|
icon,
|
|
25
25
|
classNames,
|
|
26
26
|
styles,
|
|
27
|
+
variant = 'filled',
|
|
27
28
|
onClose,
|
|
28
29
|
onChange,
|
|
29
30
|
...rest
|
|
@@ -37,6 +38,7 @@ const Tag = forwardRef(
|
|
|
37
38
|
|
|
38
39
|
const cls = clsx(
|
|
39
40
|
prefixCls,
|
|
41
|
+
[`${prefixCls}-${variant}`],
|
|
40
42
|
{
|
|
41
43
|
[`${prefixCls}-${status}`]: status,
|
|
42
44
|
[`${prefixCls}-dashed`]: dashed,
|
package/src/style/color.css
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
|
|
58
58
|
/* --global-- */
|
|
59
59
|
--yee-global-font-color: var(--yee-text-color);
|
|
60
|
-
--yee-placeholder-color: var(--yee-text-color-
|
|
60
|
+
--yee-placeholder-color: var(--yee-text-color-secondary);
|
|
61
61
|
--yee-title-prefix-bg-color: var(--yee-primary-color);
|
|
62
62
|
--yee-remove-icon: var(--yee-text-color-auxiliary);
|
|
63
63
|
--yee-remove-icon-hover: var(--yee-text-color-auxiliary);
|
|
@@ -264,8 +264,8 @@
|
|
|
264
264
|
--yee-menu-item-hover-color: var(--yee-color-option-hover);
|
|
265
265
|
--yee-menu-item-selected-color: var(--yee-color-option-active);
|
|
266
266
|
--yee-menu-item-selected-bg-color: var(--yee-color-option-active-bg);
|
|
267
|
-
--yee-menu-item-arrow-color: var(--yee-text-color
|
|
268
|
-
--yee-menu-item-arrow-hover-color: var(--yee-text-color-
|
|
267
|
+
--yee-menu-item-arrow-color: var(--yee-text-color);
|
|
268
|
+
--yee-menu-item-arrow-hover-color: var(--yee-text-color-secondary);
|
|
269
269
|
--yee-menu-item-arrow-selected-color: var(--yee-primary-color);
|
|
270
270
|
--yee-menu-item-bg-color: #fff;
|
|
271
271
|
--yee-menu-item-title-bg-color: #f0f0f0;
|