@rainbow-oh/yee-c 0.8.19 → 0.9.0
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 +4 -1
- package/dist/cjs/Checkbox/checkbox.js +2 -1
- package/dist/cjs/Checkbox/style/index.less +3 -0
- package/dist/cjs/Form/Field.js +6 -6
- package/dist/cjs/Form/demo/field-status.d.ts +3 -0
- package/dist/cjs/Form/demo/field-status.js +116 -0
- package/dist/cjs/Form/form-store.d.ts +6 -1
- package/dist/cjs/Form/form-store.js +74 -2
- package/dist/cjs/Form/index.d.ts +1 -1
- package/dist/cjs/Form/interface.d.ts +17 -1
- package/dist/cjs/Form/style/index.less +26 -0
- package/dist/cjs/Progress/circle.js +46 -35
- package/dist/cjs/Progress/line.js +20 -11
- package/dist/cjs/Search/demo/basic.js +38 -3
- package/dist/cjs/Search/interface.d.ts +2 -2
- package/dist/cjs/Search/search.js +52 -32
- package/dist/cjs/Search/style/index.less +20 -3
- package/dist/cjs/Table/style/index.less +4 -2
- package/dist/cjs/Table/tbody/cell.js +2 -2
- package/dist/cjs/Transfer/interface.d.ts +0 -1
- package/dist/cjs/Transfer/style/index.less +4 -0
- package/dist/cjs/Transfer/transfer-list.js +1 -0
- package/dist/cjs/message/use-message.js +1 -3
- package/dist/cjs/notice/notice.js +1 -1
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Checkbox/checkbox.js +2 -1
- package/dist/esm/Checkbox/style/index.less +3 -0
- package/dist/esm/Form/Field.js +6 -6
- package/dist/esm/Form/demo/field-status.d.ts +3 -0
- package/dist/esm/Form/demo/field-status.js +104 -0
- package/dist/esm/Form/form-store.d.ts +6 -1
- package/dist/esm/Form/form-store.js +88 -6
- package/dist/esm/Form/index.d.ts +1 -1
- package/dist/esm/Form/interface.d.ts +17 -1
- package/dist/esm/Form/style/index.less +26 -0
- package/dist/esm/Search/demo/basic.js +61 -7
- package/dist/esm/Search/interface.d.ts +2 -2
- package/dist/esm/Search/search.js +22 -15
- package/dist/esm/Search/style/index.less +20 -3
- package/dist/esm/Table/style/index.less +4 -2
- package/dist/esm/Table/tbody/cell.js +2 -2
- package/dist/esm/Transfer/interface.d.ts +0 -1
- package/dist/esm/Transfer/style/index.less +4 -0
- package/dist/esm/Transfer/transfer-list.js +1 -0
- package/dist/esm/notice/notice.js +1 -1
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +1 -1
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Anchor/anchor.tsx +9 -5
- package/src/Checkbox/checkbox.tsx +1 -0
- package/src/Checkbox/style/index.less +3 -0
- package/src/Form/Field.tsx +7 -8
- package/src/Form/demo/field-status.tsx +108 -0
- package/src/Form/form-store.ts +92 -2
- package/src/Form/index.en-US.md +6 -1
- package/src/Form/index.ts +2 -0
- package/src/Form/index.zh-CN.md +6 -1
- package/src/Form/interface.ts +19 -1
- package/src/Form/style/index.less +26 -0
- package/src/Progress/circle.tsx +5 -1
- package/src/Progress/line.tsx +5 -1
- package/src/Progress/progress.tsx +5 -1
- package/src/Search/demo/basic.tsx +43 -7
- package/src/Search/index.en-US.md +1 -1
- package/src/Search/index.zh-CN.md +1 -1
- package/src/Search/interface.ts +2 -2
- package/src/Search/search.tsx +40 -23
- package/src/Search/style/index.less +20 -3
- package/src/Spin/indicator.tsx +1 -1
- package/src/Table/style/index.less +4 -2
- package/src/Table/tbody/cell.tsx +2 -2
- package/src/Transfer/interface.ts +0 -1
- package/src/Transfer/style/index.less +4 -0
- package/src/Transfer/transfer-list.tsx +1 -0
- package/src/Tree/interface.ts +6 -1
- package/src/Tree/tree-node.tsx +7 -6
- package/src/Tree/utils/tree-tools.ts +4 -1
- package/src/Trigger/interface.ts +2 -1
- package/src/message/demo/base.tsx +1 -1
- package/src/message/interface.ts +1 -5
- package/src/message/message.test.tsx +15 -5
- package/src/message/message.tsx +10 -4
- package/src/message/use-message.tsx +2 -8
- package/src/message/wrapper.tsx +1 -2
- package/src/notice/interface.ts +1 -5
- package/src/notice/notice.test.tsx +14 -6
- package/src/notice/notice.tsx +12 -6
- package/src/notice/wrapper.tsx +1 -2
- package/src/version.ts +1 -1
- package/dist/cjs/Search/style/index.d.ts +0 -1
- package/dist/cjs/Search/style/index.js +0 -2
- package/dist/esm/Search/style/index.d.ts +0 -1
- package/dist/esm/Search/style/index.js +0 -1
- package/src/Search/style/index.ts +0 -1
package/src/Search/search.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import { X } from 'lucide-react';
|
|
2
|
+
import { Search as SearchIcon, X } from 'lucide-react';
|
|
3
3
|
import React, {
|
|
4
4
|
startTransition,
|
|
5
5
|
useContext,
|
|
@@ -86,25 +86,12 @@ const Search = React.forwardRef<HTMLInputElement, SearchProps>(
|
|
|
86
86
|
}
|
|
87
87
|
}, [open]);
|
|
88
88
|
|
|
89
|
-
const handleSearch = (
|
|
90
|
-
e?:
|
|
91
|
-
| React.ChangeEvent<HTMLInputElement>
|
|
92
|
-
| React.MouseEvent<HTMLSpanElement>
|
|
93
|
-
| React.KeyboardEvent<HTMLInputElement>,
|
|
94
|
-
) => {
|
|
95
|
-
if (disabled) return;
|
|
96
|
-
onSearch?.(searchValue);
|
|
97
|
-
if (e?.type === 'click') {
|
|
98
|
-
(e.target as HTMLElement).blur?.();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
89
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
103
90
|
const newValue = e.target.value;
|
|
104
91
|
setSearchValue(newValue);
|
|
105
92
|
startTransition(() => {
|
|
106
93
|
if (searchOnAction === 'typing') {
|
|
107
|
-
|
|
94
|
+
onSearch?.(newValue);
|
|
108
95
|
}
|
|
109
96
|
});
|
|
110
97
|
};
|
|
@@ -116,10 +103,28 @@ const Search = React.forwardRef<HTMLInputElement, SearchProps>(
|
|
|
116
103
|
onSearch?.('');
|
|
117
104
|
};
|
|
118
105
|
|
|
106
|
+
const handleSearchClick = (e: React.MouseEvent<HTMLSpanElement>) => {
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
if (searchOnAction === 'button') {
|
|
109
|
+
onSearch?.(searchValue);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const renderSearchIcon = () => {
|
|
114
|
+
if (suffix === false) return null;
|
|
115
|
+
return (
|
|
116
|
+
<span
|
|
117
|
+
className={`${prefixCls}-search-icon`}
|
|
118
|
+
onClick={handleSearchClick}
|
|
119
|
+
>
|
|
120
|
+
{suffix || <SearchIcon size={14} />}
|
|
121
|
+
</span>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
119
125
|
const renderSuffix = () => {
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
const showSuffix = suffix || showClearIcon;
|
|
126
|
+
const showClearIcon = allowClear && !disabled && !rest.readOnly;
|
|
127
|
+
const showSuffix = suffix !== false || suffix !== null || showClearIcon;
|
|
123
128
|
|
|
124
129
|
if (!showSuffix) {
|
|
125
130
|
return null;
|
|
@@ -138,14 +143,16 @@ const Search = React.forwardRef<HTMLInputElement, SearchProps>(
|
|
|
138
143
|
onKeyDown={(e) => {
|
|
139
144
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
140
145
|
e.preventDefault();
|
|
141
|
-
handleClear(
|
|
146
|
+
handleClear(
|
|
147
|
+
e as unknown as React.MouseEvent<HTMLSpanElement>,
|
|
148
|
+
);
|
|
142
149
|
}
|
|
143
150
|
}}
|
|
144
151
|
>
|
|
145
152
|
<X size={14} aria-hidden="true" />
|
|
146
153
|
</span>
|
|
147
154
|
)}
|
|
148
|
-
{
|
|
155
|
+
{renderSearchIcon()}
|
|
149
156
|
</div>
|
|
150
157
|
);
|
|
151
158
|
};
|
|
@@ -177,6 +184,7 @@ const Search = React.forwardRef<HTMLInputElement, SearchProps>(
|
|
|
177
184
|
prefixCls,
|
|
178
185
|
{
|
|
179
186
|
[`${prefixCls}-disabled`]: disabled,
|
|
187
|
+
[`${prefixCls}-with-clear`]: allowClear && searchValue,
|
|
180
188
|
[`${prefixCls}-borderless`]: !bordered,
|
|
181
189
|
[`${prefixCls}-small`]: size === 'small',
|
|
182
190
|
[`${prefixCls}-large`]: size === 'large',
|
|
@@ -188,7 +196,12 @@ const Search = React.forwardRef<HTMLInputElement, SearchProps>(
|
|
|
188
196
|
const hasPopup = Array.isArray(options) || Array.isArray(suggestions);
|
|
189
197
|
|
|
190
198
|
const popup = (
|
|
191
|
-
<div
|
|
199
|
+
<div
|
|
200
|
+
className={`${prefixCls}-popup`}
|
|
201
|
+
tabIndex={0}
|
|
202
|
+
id={listboxId}
|
|
203
|
+
role="listbox"
|
|
204
|
+
>
|
|
192
205
|
{Array.isArray(options) ? (
|
|
193
206
|
<List
|
|
194
207
|
focusedKey={focusedKey}
|
|
@@ -208,7 +221,7 @@ const Search = React.forwardRef<HTMLInputElement, SearchProps>(
|
|
|
208
221
|
);
|
|
209
222
|
|
|
210
223
|
return (
|
|
211
|
-
<Trigger popup={popup} open={open} onOpenChange={setOpen}>
|
|
224
|
+
<Trigger popup={popup} open={open} stretch="width" onOpenChange={setOpen}>
|
|
212
225
|
<div
|
|
213
226
|
className={getRootClassName()}
|
|
214
227
|
style={style}
|
|
@@ -238,7 +251,11 @@ const Search = React.forwardRef<HTMLInputElement, SearchProps>(
|
|
|
238
251
|
: undefined
|
|
239
252
|
}
|
|
240
253
|
/>
|
|
241
|
-
{loading ?
|
|
254
|
+
{loading ? (
|
|
255
|
+
<Spin variant="ring" size="small" aria-label="Loading" />
|
|
256
|
+
) : (
|
|
257
|
+
renderSuffix()
|
|
258
|
+
)}
|
|
242
259
|
</div>
|
|
243
260
|
</Trigger>
|
|
244
261
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @import '../../style/index.less';
|
|
2
2
|
|
|
3
|
-
@
|
|
3
|
+
@cls: ~'yee-search';
|
|
4
4
|
|
|
5
|
-
.@{
|
|
5
|
+
.@{cls} {
|
|
6
6
|
position: relative;
|
|
7
7
|
display: inline-flex;
|
|
8
8
|
align-items: center;
|
|
@@ -69,9 +69,10 @@
|
|
|
69
69
|
border: none;
|
|
70
70
|
outline: none;
|
|
71
71
|
transition: all 0.2s;
|
|
72
|
+
line-height: var(--yee-input-line-height);
|
|
72
73
|
|
|
73
74
|
&::placeholder {
|
|
74
|
-
color: var(--yee-
|
|
75
|
+
color: var(--yee-placeholder-color);
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
&-disabled {
|
|
@@ -99,7 +100,17 @@
|
|
|
99
100
|
color: var(--yee-input-fix-icon-color);
|
|
100
101
|
}
|
|
101
102
|
|
|
103
|
+
&-search-icon {
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
}
|
|
106
|
+
|
|
102
107
|
&-clear-icon {
|
|
108
|
+
display: inline-flex;
|
|
109
|
+
padding: var(--yee-input-clear-padding);
|
|
110
|
+
color: var(--yee-input-clear-color);
|
|
111
|
+
background-color: var(--yee-input-clear-bg-color);
|
|
112
|
+
border-radius: 50%;
|
|
113
|
+
visibility: hidden;
|
|
103
114
|
cursor: pointer;
|
|
104
115
|
transition: color 0.2s;
|
|
105
116
|
|
|
@@ -108,6 +119,12 @@
|
|
|
108
119
|
}
|
|
109
120
|
}
|
|
110
121
|
|
|
122
|
+
&&-with-clear:not(.@{cls}-disabled):hover {
|
|
123
|
+
.@{cls}-clear-icon {
|
|
124
|
+
visibility: visible;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
111
128
|
&-button {
|
|
112
129
|
display: flex;
|
|
113
130
|
align-items: center;
|
package/src/Spin/indicator.tsx
CHANGED
|
@@ -97,7 +97,8 @@
|
|
|
97
97
|
width: 15px;
|
|
98
98
|
right: -15px;
|
|
99
99
|
top: 0;
|
|
100
|
-
box-shadow: inset 4px 0 8px -4px
|
|
100
|
+
box-shadow: inset 4px 0 8px -4px
|
|
101
|
+
var(--yee-table-fixed-left-after-bs-color);
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
|
|
@@ -111,7 +112,8 @@
|
|
|
111
112
|
width: 15px;
|
|
112
113
|
left: -15px;
|
|
113
114
|
top: 0;
|
|
114
|
-
box-shadow: inset -4px 0 8px -4px
|
|
115
|
+
box-shadow: inset -4px 0 8px -4px
|
|
116
|
+
var(--yee-table-fixed-right-after-bs-color);
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
}
|
package/src/Table/tbody/cell.tsx
CHANGED
|
@@ -66,13 +66,13 @@ const TableCell: React.FC<BodyCellProps> = (props) => {
|
|
|
66
66
|
className,
|
|
67
67
|
);
|
|
68
68
|
|
|
69
|
-
const
|
|
69
|
+
const _style = { ...style, width, maxWidth: width, textAlign: align };
|
|
70
70
|
const _title = typeof title === 'string' ? title : undefined;
|
|
71
71
|
|
|
72
72
|
return {
|
|
73
73
|
...cellProperty,
|
|
74
74
|
className: cls,
|
|
75
|
-
style:
|
|
75
|
+
style: _style,
|
|
76
76
|
title: _title,
|
|
77
77
|
};
|
|
78
78
|
};
|
|
@@ -124,7 +124,6 @@ export interface TransferListProps {
|
|
|
124
124
|
oneWay?: boolean;
|
|
125
125
|
pagination?: Omit<PaginationProps, 'total'> & { total?: number };
|
|
126
126
|
draggable?: boolean;
|
|
127
|
-
targetMinCountLimit?: number;
|
|
128
127
|
onDrop?: (dropObj: Record<string, any>, dataSource: DataSource[]) => void;
|
|
129
128
|
onDelete?: (key: string | number) => void;
|
|
130
129
|
onItemSelect: (keys: Array<string | number>) => void;
|
|
@@ -66,6 +66,10 @@
|
|
|
66
66
|
line-height: var(--yee-transfer-list-item-height, 32px);
|
|
67
67
|
padding: var(--yee-transfer-list-item-padding, 0 11px);
|
|
68
68
|
|
|
69
|
+
&-checkbox {
|
|
70
|
+
width: 100%;
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
&:hover:not(.yee-one-way):not(.disabled) {
|
|
70
74
|
color: var(--yee-transfer-list-content-item-hover-color);
|
|
71
75
|
background-color: var(--yee-transfer-list-content-item-hover-bg-color);
|
|
@@ -199,6 +199,7 @@ const TransferList: React.FC<TransferListProps> = (props) => {
|
|
|
199
199
|
{checkboxOptions.map((option, index) => (
|
|
200
200
|
<li className={`${prefixCls}-list-item`} key={option.value || index}>
|
|
201
201
|
<Checkbox
|
|
202
|
+
className={`${prefixCls}-list-item-checkbox`}
|
|
202
203
|
value={option.value}
|
|
203
204
|
disabled={option.disabled || disabled}
|
|
204
205
|
checked={checkedKeys.includes(option.value)}
|
package/src/Tree/interface.ts
CHANGED
|
@@ -180,7 +180,12 @@ export interface TreeProps<T> extends DataAttributeProps {
|
|
|
180
180
|
/**
|
|
181
181
|
* Customize node key, title, children field names
|
|
182
182
|
*/
|
|
183
|
-
fieldNames?: {
|
|
183
|
+
fieldNames?: {
|
|
184
|
+
key?: keyof T;
|
|
185
|
+
label?: keyof T;
|
|
186
|
+
children?: keyof T;
|
|
187
|
+
extra?: keyof T;
|
|
188
|
+
};
|
|
184
189
|
/**
|
|
185
190
|
* Asynchronous data loading
|
|
186
191
|
*/
|
package/src/Tree/tree-node.tsx
CHANGED
|
@@ -111,9 +111,12 @@ const Node = <T extends Record<string, unknown> = any>(
|
|
|
111
111
|
const content = labelRender ? labelRender(node) : label;
|
|
112
112
|
|
|
113
113
|
// extra: appended after the label content (only when labelRender is NOT used)
|
|
114
|
-
const _extra =
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
const _extra =
|
|
115
|
+
!labelRender && extra
|
|
116
|
+
? typeof extra === 'function'
|
|
117
|
+
? extra(original)
|
|
118
|
+
: extra
|
|
119
|
+
: null;
|
|
117
120
|
|
|
118
121
|
return (
|
|
119
122
|
<Button
|
|
@@ -127,9 +130,7 @@ const Node = <T extends Record<string, unknown> = any>(
|
|
|
127
130
|
onClick={disabled ? undefined : () => onSelect(uid)}
|
|
128
131
|
>
|
|
129
132
|
{content}
|
|
130
|
-
{_extra &&
|
|
131
|
-
<span className={`${prefixCls}-node-extra`}>{_extra}</span>
|
|
132
|
-
)}
|
|
133
|
+
{_extra && <span className={`${prefixCls}-node-extra`}>{_extra}</span>}
|
|
133
134
|
</Button>
|
|
134
135
|
);
|
|
135
136
|
};
|
|
@@ -229,7 +229,10 @@ export function tree2array<T extends Record<string, unknown>>(
|
|
|
229
229
|
key: rawKey,
|
|
230
230
|
label: _label as string,
|
|
231
231
|
title: node.title as string | undefined,
|
|
232
|
-
extra: _extra as
|
|
232
|
+
extra: _extra as
|
|
233
|
+
| React.ReactNode
|
|
234
|
+
| ((node: T) => React.ReactNode)
|
|
235
|
+
| undefined,
|
|
233
236
|
path,
|
|
234
237
|
pUid,
|
|
235
238
|
depth,
|
package/src/Trigger/interface.ts
CHANGED
|
@@ -32,7 +32,8 @@ export type Point =
|
|
|
32
32
|
| 'cl'
|
|
33
33
|
| 'cr';
|
|
34
34
|
|
|
35
|
-
export interface TriggerProps
|
|
35
|
+
export interface TriggerProps
|
|
36
|
+
extends Omit<RcTriggerProps, 'children'>, DataAttributeProps {
|
|
36
37
|
/**
|
|
37
38
|
* Custom class name prefix
|
|
38
39
|
*/
|
|
@@ -6,7 +6,7 @@ const BaseDemo = () => {
|
|
|
6
6
|
const showMessage = (type: string) => {
|
|
7
7
|
switch (type) {
|
|
8
8
|
case 'info':
|
|
9
|
-
messageApi.open({content: 'This is an info message', duration: 0});
|
|
9
|
+
messageApi.open({ content: 'This is an info message', duration: 0 });
|
|
10
10
|
break;
|
|
11
11
|
case 'success':
|
|
12
12
|
message.success('This is a success message');
|
package/src/message/interface.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
act,
|
|
5
|
+
cleanup,
|
|
6
|
+
render,
|
|
7
|
+
renderHook,
|
|
8
|
+
screen,
|
|
9
|
+
} from '@testing-library/react';
|
|
4
10
|
import React from 'react';
|
|
5
11
|
import { renderToString } from 'react-dom/server';
|
|
6
12
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
@@ -227,7 +233,11 @@ describe('message', () => {
|
|
|
227
233
|
|
|
228
234
|
act(() => {
|
|
229
235
|
currentApi.info({ content: 'first', duration: 0, onClose: firstOnClose });
|
|
230
|
-
currentApi.info({
|
|
236
|
+
currentApi.info({
|
|
237
|
+
content: 'second',
|
|
238
|
+
duration: 0,
|
|
239
|
+
onClose: secondOnClose,
|
|
240
|
+
});
|
|
231
241
|
currentApi.clear();
|
|
232
242
|
});
|
|
233
243
|
|
|
@@ -276,8 +286,8 @@ describe('message', () => {
|
|
|
276
286
|
expect(element?.getAttribute('role')).toBe('alert');
|
|
277
287
|
expect(element?.getAttribute('aria-live')).toBe('assertive');
|
|
278
288
|
expect(element?.querySelector('.yee-message-content')?.tagName).toBe('DIV');
|
|
279
|
-
expect(
|
|
280
|
-
'
|
|
281
|
-
);
|
|
289
|
+
expect(
|
|
290
|
+
element?.querySelector('.yee-message-icon')?.getAttribute('aria-hidden'),
|
|
291
|
+
).toBe('true');
|
|
282
292
|
});
|
|
283
293
|
});
|
package/src/message/message.tsx
CHANGED
|
@@ -5,10 +5,16 @@ import Spin from '../Spin';
|
|
|
5
5
|
import type { MessageProps } from './interface';
|
|
6
6
|
|
|
7
7
|
const icons = {
|
|
8
|
-
info: <Info size={22} fill=
|
|
9
|
-
success:
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
info: <Info size={22} fill="currentColor" stroke="#FFF" strokeWidth={2} />,
|
|
9
|
+
success: (
|
|
10
|
+
<CircleCheck size={22} fill="currentColor" stroke="#FFF" strokeWidth={2} />
|
|
11
|
+
),
|
|
12
|
+
warning: (
|
|
13
|
+
<CircleAlert size={22} fill="currentColor" stroke="#FFF" strokeWidth={2} />
|
|
14
|
+
),
|
|
15
|
+
error: (
|
|
16
|
+
<CircleX size={22} fill="currentColor" stroke="#FFF" strokeWidth={2} />
|
|
17
|
+
),
|
|
12
18
|
loading: <Spin className="loading" type="spin" size="small" height="auto" />,
|
|
13
19
|
};
|
|
14
20
|
|
|
@@ -6,11 +6,7 @@ import React, {
|
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { createPortal } from 'react-dom';
|
|
9
|
-
import {
|
|
10
|
-
MessageApi,
|
|
11
|
-
MessageType,
|
|
12
|
-
WrapperedMessageConfig,
|
|
13
|
-
} from './interface';
|
|
9
|
+
import { MessageApi, MessageType, WrapperedMessageConfig } from './interface';
|
|
14
10
|
import Message from './message';
|
|
15
11
|
|
|
16
12
|
const useMessage = () => {
|
|
@@ -78,9 +74,7 @@ const useMessage = () => {
|
|
|
78
74
|
updateMessages((current) => {
|
|
79
75
|
const exists = current.some((item) => item.key === key);
|
|
80
76
|
if (exists) {
|
|
81
|
-
return current.map((item) =>
|
|
82
|
-
item.key === key ? nextMessage : item,
|
|
83
|
-
);
|
|
77
|
+
return current.map((item) => (item.key === key ? nextMessage : item));
|
|
84
78
|
}
|
|
85
79
|
return [...current, nextMessage];
|
|
86
80
|
});
|
package/src/message/wrapper.tsx
CHANGED
|
@@ -93,8 +93,7 @@ class MessageWrapper {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
const key = params.key ?? this.uuid();
|
|
96
|
-
const keyGeneration =
|
|
97
|
-
this.generationByKey.get(key) ?? this.generation++;
|
|
96
|
+
const keyGeneration = this.generationByKey.get(key) ?? this.generation++;
|
|
98
97
|
this.generationByKey.set(key, keyGeneration);
|
|
99
98
|
const nextMessage = {
|
|
100
99
|
...params,
|
package/src/notice/interface.ts
CHANGED
|
@@ -7,11 +7,7 @@ export type PlacementType =
|
|
|
7
7
|
| 'bottom';
|
|
8
8
|
|
|
9
9
|
export type NoticeConfig = {
|
|
10
|
-
[dataAttribute: `data-${string}`]:
|
|
11
|
-
| string
|
|
12
|
-
| number
|
|
13
|
-
| boolean
|
|
14
|
-
| undefined;
|
|
10
|
+
[dataAttribute: `data-${string}`]: string | number | boolean | undefined;
|
|
15
11
|
/**
|
|
16
12
|
* Custom prefix class name
|
|
17
13
|
*/
|
|
@@ -90,7 +90,11 @@ describe('notice', () => {
|
|
|
90
90
|
render(<NoticeHarness />);
|
|
91
91
|
|
|
92
92
|
act(() => {
|
|
93
|
-
currentApi.info({
|
|
93
|
+
currentApi.info({
|
|
94
|
+
content: 'first',
|
|
95
|
+
duration: 300,
|
|
96
|
+
onClose: firstOnClose,
|
|
97
|
+
});
|
|
94
98
|
});
|
|
95
99
|
act(() => vi.advanceTimersByTime(200));
|
|
96
100
|
act(() => {
|
|
@@ -295,7 +299,9 @@ describe('notice', () => {
|
|
|
295
299
|
expect(screen.queryByText('still paused')).not.toBeNull();
|
|
296
300
|
expect(onClose).not.toHaveBeenCalled();
|
|
297
301
|
|
|
298
|
-
fireEvent.mouseLeave(
|
|
302
|
+
fireEvent.mouseLeave(
|
|
303
|
+
screen.getByText('still paused').closest('.yee-notice')!,
|
|
304
|
+
);
|
|
299
305
|
act(() => vi.advanceTimersByTime(300));
|
|
300
306
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
301
307
|
});
|
|
@@ -365,7 +371,9 @@ describe('notice', () => {
|
|
|
365
371
|
expect(screen.queryByText('pause enabled')).not.toBeNull();
|
|
366
372
|
expect(onClose).not.toHaveBeenCalled();
|
|
367
373
|
|
|
368
|
-
fireEvent.mouseLeave(
|
|
374
|
+
fireEvent.mouseLeave(
|
|
375
|
+
screen.getByText('pause enabled').closest('.yee-notice')!,
|
|
376
|
+
);
|
|
369
377
|
act(() => vi.advanceTimersByTime(300));
|
|
370
378
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
371
379
|
});
|
|
@@ -439,9 +447,9 @@ describe('notice', () => {
|
|
|
439
447
|
expect(element.getAttribute('role')).toBe('button');
|
|
440
448
|
expect(element.getAttribute('aria-live')).toBe('assertive');
|
|
441
449
|
expect(element.getAttribute('tabindex')).toBe('0');
|
|
442
|
-
expect(
|
|
443
|
-
'
|
|
444
|
-
);
|
|
450
|
+
expect(
|
|
451
|
+
element.querySelector('.yee-notice-icon')?.getAttribute('aria-hidden'),
|
|
452
|
+
).toBe('true');
|
|
445
453
|
|
|
446
454
|
fireEvent.keyDown(element, { key: 'Enter' });
|
|
447
455
|
fireEvent.keyDown(element, { key: ' ' });
|
package/src/notice/notice.tsx
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import { CircleAlert, CircleCheck, CircleX, Info, X } from 'lucide-react';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import Button from '../Button';
|
|
4
5
|
import Progress from '../Progress';
|
|
5
6
|
import useCountdown from '../hooks/useCountdown';
|
|
6
7
|
import { NoticeProps } from './interface';
|
|
7
|
-
import Button from '../Button';
|
|
8
8
|
|
|
9
9
|
const icons = {
|
|
10
|
-
info: <Info size={22} fill=
|
|
11
|
-
success:
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
info: <Info size={22} fill="currentColor" stroke="#FFF" strokeWidth={2} />,
|
|
11
|
+
success: (
|
|
12
|
+
<CircleCheck size={22} fill="currentColor" stroke="#FFF" strokeWidth={2} />
|
|
13
|
+
),
|
|
14
|
+
warning: (
|
|
15
|
+
<CircleAlert size={22} fill="currentColor" stroke="#FFF" strokeWidth={2} />
|
|
16
|
+
),
|
|
17
|
+
error: (
|
|
18
|
+
<CircleX size={22} fill="currentColor" stroke="#FFF" strokeWidth={2} />
|
|
19
|
+
),
|
|
14
20
|
};
|
|
15
21
|
|
|
16
22
|
const Notice: React.FC<NoticeProps & { id: string | number }> = (props) => {
|
|
@@ -102,7 +108,7 @@ const Notice: React.FC<NoticeProps & { id: string | number }> = (props) => {
|
|
|
102
108
|
|
|
103
109
|
return (
|
|
104
110
|
<Button
|
|
105
|
-
variant=
|
|
111
|
+
variant="text"
|
|
106
112
|
size="small"
|
|
107
113
|
className={`${prefixCls}-close`}
|
|
108
114
|
onClick={handleClose}
|
package/src/notice/wrapper.tsx
CHANGED
|
@@ -146,8 +146,7 @@ class NoticeWrapper {
|
|
|
146
146
|
|
|
147
147
|
const placement = params.placement ?? 'topRight';
|
|
148
148
|
const key = params.key ?? this.uuid();
|
|
149
|
-
const keyGeneration =
|
|
150
|
-
this.generationByKey.get(key) ?? this.generation++;
|
|
149
|
+
const keyGeneration = this.generationByKey.get(key) ?? this.generation++;
|
|
151
150
|
this.generationByKey.set(key, keyGeneration);
|
|
152
151
|
|
|
153
152
|
const affectedPlacements = new Set<PlacementType>([placement]);
|
package/src/version.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './index.less';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './index.less';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./index.less";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './index.less';
|