wok-ui-ext 0.1.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/LICENSE +21 -0
- package/README.en.md +75 -0
- package/README.md +75 -0
- package/dist/alert/index.d.ts +10 -0
- package/dist/alert/index.js +48 -0
- package/dist/alert/style.css +116 -0
- package/dist/avatar/index.d.ts +9 -0
- package/dist/avatar/index.js +30 -0
- package/dist/avatar/style.css +32 -0
- package/dist/badge/index.d.ts +32 -0
- package/dist/badge/index.js +61 -0
- package/dist/badge/style.css +68 -0
- package/dist/breadcrumb/index.d.ts +25 -0
- package/dist/breadcrumb/index.js +47 -0
- package/dist/breadcrumb/style.css +35 -0
- package/dist/button/index.d.ts +34 -0
- package/dist/button/index.js +57 -0
- package/dist/button/style.css +133 -0
- package/dist/card/index.d.ts +25 -0
- package/dist/card/index.js +29 -0
- package/dist/card/style.css +23 -0
- package/dist/collapse/index.d.ts +89 -0
- package/dist/collapse/index.js +213 -0
- package/dist/collapse/style.css +76 -0
- package/dist/context-menu/context-menu.d.ts +113 -0
- package/dist/context-menu/context-menu.js +150 -0
- package/dist/context-menu/index.d.ts +30 -0
- package/dist/context-menu/index.js +42 -0
- package/dist/context-menu/style.css +46 -0
- package/dist/date-picker/calendar-panel.d.ts +44 -0
- package/dist/date-picker/calendar-panel.js +180 -0
- package/dist/date-picker/date-picker.d.ts +29 -0
- package/dist/date-picker/date-picker.js +81 -0
- package/dist/date-picker/date-utils.d.ts +63 -0
- package/dist/date-picker/date-utils.js +130 -0
- package/dist/date-picker/index.d.ts +7 -0
- package/dist/date-picker/index.js +5 -0
- package/dist/date-picker/layer.d.ts +19 -0
- package/dist/date-picker/layer.js +36 -0
- package/dist/date-picker/range-picker.d.ts +30 -0
- package/dist/date-picker/range-picker.js +117 -0
- package/dist/date-picker/style.css +161 -0
- package/dist/description-list/index.d.ts +37 -0
- package/dist/description-list/index.js +145 -0
- package/dist/description-list/style.css +63 -0
- package/dist/divider/index.d.ts +29 -0
- package/dist/divider/index.js +29 -0
- package/dist/divider/style.css +50 -0
- package/dist/drawer/index.d.ts +51 -0
- package/dist/drawer/index.js +183 -0
- package/dist/drawer/style.css +100 -0
- package/dist/dropdown/index.d.ts +38 -0
- package/dist/dropdown/index.js +97 -0
- package/dist/dropdown/style.css +39 -0
- package/dist/empty/index.d.ts +11 -0
- package/dist/empty/index.js +20 -0
- package/dist/empty/style.css +19 -0
- package/dist/floating-layer/index.d.ts +109 -0
- package/dist/floating-layer/index.js +337 -0
- package/dist/floating-layer/style.css +5 -0
- package/dist/form/form-item/index.d.ts +26 -0
- package/dist/form/form-item/index.js +21 -0
- package/dist/form/form-item/style.css +33 -0
- package/dist/form/form-modal/index.d.ts +18 -0
- package/dist/form/form-modal/index.js +38 -0
- package/dist/form/form.d.ts +21 -0
- package/dist/form/form.js +28 -0
- package/dist/form/index.d.ts +4 -0
- package/dist/form/index.js +4 -0
- package/dist/form/select/index.d.ts +48 -0
- package/dist/form/select/index.js +94 -0
- package/dist/form/select/style.css +29 -0
- package/dist/global.css +71 -0
- package/dist/i18n/de-DE.d.ts +2 -0
- package/dist/i18n/de-DE.js +36 -0
- package/dist/i18n/en-US.d.ts +2 -0
- package/dist/i18n/en-US.js +36 -0
- package/dist/i18n/es-ES.d.ts +2 -0
- package/dist/i18n/es-ES.js +36 -0
- package/dist/i18n/fr-FR.d.ts +2 -0
- package/dist/i18n/fr-FR.js +36 -0
- package/dist/i18n/index.d.ts +12 -0
- package/dist/i18n/index.js +39 -0
- package/dist/i18n/ja-JP.d.ts +2 -0
- package/dist/i18n/ja-JP.js +36 -0
- package/dist/i18n/ko-KR.d.ts +2 -0
- package/dist/i18n/ko-KR.js +36 -0
- package/dist/i18n/messages.d.ts +40 -0
- package/dist/i18n/messages.js +1 -0
- package/dist/i18n/wok-ui/de-DE.d.ts +2 -0
- package/dist/i18n/wok-ui/de-DE.js +20 -0
- package/dist/i18n/wok-ui/es-ES.d.ts +2 -0
- package/dist/i18n/wok-ui/es-ES.js +20 -0
- package/dist/i18n/wok-ui/fr-FR.d.ts +2 -0
- package/dist/i18n/wok-ui/fr-FR.js +20 -0
- package/dist/i18n/wok-ui/ja-JP.d.ts +2 -0
- package/dist/i18n/wok-ui/ja-JP.js +20 -0
- package/dist/i18n/wok-ui/ko-KR.d.ts +2 -0
- package/dist/i18n/wok-ui/ko-KR.js +20 -0
- package/dist/i18n/wok-ui/zh-TW.d.ts +2 -0
- package/dist/i18n/wok-ui/zh-TW.js +20 -0
- package/dist/i18n/zh-CN.d.ts +2 -0
- package/dist/i18n/zh-CN.js +36 -0
- package/dist/i18n/zh-TW.d.ts +2 -0
- package/dist/i18n/zh-TW.js +36 -0
- package/dist/icons.d.ts +88 -0
- package/dist/icons.js +176 -0
- package/dist/image/index.d.ts +38 -0
- package/dist/image/index.js +97 -0
- package/dist/image/style.css +72 -0
- package/dist/image-preview/index.d.ts +26 -0
- package/dist/image-preview/index.js +134 -0
- package/dist/image-preview/style.css +96 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +45 -0
- package/dist/list/index.d.ts +32 -0
- package/dist/list/index.js +42 -0
- package/dist/list/list-item.d.ts +27 -0
- package/dist/list/list-item.js +51 -0
- package/dist/list/style.css +20 -0
- package/dist/loading/index.d.ts +10 -0
- package/dist/loading/index.js +46 -0
- package/dist/loading/style.css +48 -0
- package/dist/menu/index.d.ts +38 -0
- package/dist/menu/index.js +62 -0
- package/dist/menu/leaf-item.d.ts +12 -0
- package/dist/menu/leaf-item.js +41 -0
- package/dist/menu/style.css +117 -0
- package/dist/menu/sub-menu.d.ts +21 -0
- package/dist/menu/sub-menu.js +85 -0
- package/dist/menu/types.d.ts +36 -0
- package/dist/menu/types.js +1 -0
- package/dist/menu/utils.d.ts +11 -0
- package/dist/menu/utils.js +24 -0
- package/dist/modal/index.d.ts +23 -0
- package/dist/modal/index.js +79 -0
- package/dist/modal/modal.d.ts +76 -0
- package/dist/modal/modal.js +188 -0
- package/dist/modal/style.css +90 -0
- package/dist/pagination/index.d.ts +31 -0
- package/dist/pagination/index.js +215 -0
- package/dist/pagination/style.css +50 -0
- package/dist/popconfirm/api.d.ts +43 -0
- package/dist/popconfirm/api.js +77 -0
- package/dist/popconfirm/component.d.ts +47 -0
- package/dist/popconfirm/component.js +48 -0
- package/dist/popconfirm/index.d.ts +3 -0
- package/dist/popconfirm/index.js +3 -0
- package/dist/popconfirm/style.css +22 -0
- package/dist/popover/api.d.ts +36 -0
- package/dist/popover/api.js +61 -0
- package/dist/popover/component.d.ts +38 -0
- package/dist/popover/component.js +51 -0
- package/dist/popover/index.d.ts +3 -0
- package/dist/popover/index.js +3 -0
- package/dist/popover/style.css +102 -0
- package/dist/progress/index.d.ts +34 -0
- package/dist/progress/index.js +70 -0
- package/dist/progress/style.css +37 -0
- package/dist/quick-input/index.d.ts +2 -0
- package/dist/quick-input/index.js +2 -0
- package/dist/quick-input/number.d.ts +35 -0
- package/dist/quick-input/number.js +68 -0
- package/dist/quick-input/text.d.ts +20 -0
- package/dist/quick-input/text.js +61 -0
- package/dist/result/index.d.ts +39 -0
- package/dist/result/index.js +71 -0
- package/dist/result/style.css +41 -0
- package/dist/search-box/index.d.ts +26 -0
- package/dist/search-box/index.js +60 -0
- package/dist/search-box/style.css +22 -0
- package/dist/segmented/index.d.ts +42 -0
- package/dist/segmented/index.js +61 -0
- package/dist/segmented/style.css +28 -0
- package/dist/skeleton/index.d.ts +22 -0
- package/dist/skeleton/index.js +68 -0
- package/dist/skeleton/style.css +31 -0
- package/dist/steps/index.d.ts +46 -0
- package/dist/steps/index.js +95 -0
- package/dist/steps/style.css +181 -0
- package/dist/switch/index.d.ts +32 -0
- package/dist/switch/index.js +74 -0
- package/dist/switch/style.css +52 -0
- package/dist/table/body.d.ts +21 -0
- package/dist/table/body.js +35 -0
- package/dist/table/column.d.ts +78 -0
- package/dist/table/column.js +113 -0
- package/dist/table/header.d.ts +13 -0
- package/dist/table/header.js +15 -0
- package/dist/table/index.d.ts +41 -0
- package/dist/table/index.js +84 -0
- package/dist/table/row.d.ts +25 -0
- package/dist/table/row.js +74 -0
- package/dist/table/style.css +98 -0
- package/dist/tabs/index.d.ts +49 -0
- package/dist/tabs/index.js +76 -0
- package/dist/tabs/style.css +41 -0
- package/dist/tag/index.d.ts +53 -0
- package/dist/tag/index.js +100 -0
- package/dist/tag/style.css +134 -0
- package/dist/text/index.d.ts +104 -0
- package/dist/text/index.js +143 -0
- package/dist/text/style.css +113 -0
- package/dist/theme/index.d.ts +14 -0
- package/dist/theme/index.js +94 -0
- package/dist/theme/themes.d.ts +3 -0
- package/dist/theme/themes.js +323 -0
- package/dist/theme/types.d.ts +58 -0
- package/dist/theme/types.js +1 -0
- package/dist/timeline/index.d.ts +28 -0
- package/dist/timeline/index.js +35 -0
- package/dist/timeline/style.css +53 -0
- package/dist/toast/index.d.ts +53 -0
- package/dist/toast/index.js +131 -0
- package/dist/toast/style.css +76 -0
- package/dist/tooltip/api.d.ts +44 -0
- package/dist/tooltip/api.js +103 -0
- package/dist/tooltip/component.d.ts +28 -0
- package/dist/tooltip/component.js +35 -0
- package/dist/tooltip/index.d.ts +3 -0
- package/dist/tooltip/index.js +3 -0
- package/dist/tooltip/style.css +46 -0
- package/dist/tree/dragging-img.d.ts +13 -0
- package/dist/tree/dragging-img.js +23 -0
- package/dist/tree/index.d.ts +180 -0
- package/dist/tree/index.js +385 -0
- package/dist/tree/node-info.d.ts +63 -0
- package/dist/tree/node-info.js +128 -0
- package/dist/tree/node.d.ts +132 -0
- package/dist/tree/node.js +264 -0
- package/dist/tree/style.css +99 -0
- package/dist/upload/index.d.ts +48 -0
- package/dist/upload/index.js +141 -0
- package/dist/upload/style.css +41 -0
- package/package.json +51 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
.wok-ui-ext-pagination {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
gap: 8px;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
align-items: center;
|
|
6
|
+
}
|
|
7
|
+
.wok-ui-ext-pagination .wok-ui-ext-page-total {
|
|
8
|
+
color: var(--text-secondary);
|
|
9
|
+
}
|
|
10
|
+
.wok-ui-ext-pagination .wok-ui-ext-page-item {
|
|
11
|
+
width: 40px;
|
|
12
|
+
height: 40px;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
border-radius: var(--radius-circle);
|
|
17
|
+
background: var(--bg-card);
|
|
18
|
+
border: 1px solid var(--border-medium);
|
|
19
|
+
color: var(--text-secondary);
|
|
20
|
+
font-weight: 500;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
transition: all var(--transition-speed);
|
|
23
|
+
}
|
|
24
|
+
.wok-ui-ext-pagination .wok-ui-ext-page-item:hover,
|
|
25
|
+
.wok-ui-ext-pagination .wok-ui-ext-page-item.active {
|
|
26
|
+
background: var(--color-primary);
|
|
27
|
+
border-color: var(--color-primary);
|
|
28
|
+
color: white;
|
|
29
|
+
box-shadow: var(--shadow-primary);
|
|
30
|
+
}
|
|
31
|
+
.wok-ui-ext-pagination .wok-ui-ext-page-item.disabled {
|
|
32
|
+
opacity: 0.4;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
}
|
|
35
|
+
.wok-ui-ext-pagination.wok-ui-ext-pagination-simple {
|
|
36
|
+
gap: 4px;
|
|
37
|
+
}
|
|
38
|
+
.wok-ui-ext-pagination.wok-ui-ext-pagination-simple .wok-ui-ext-page-item {
|
|
39
|
+
width: 28px;
|
|
40
|
+
height: 28px;
|
|
41
|
+
border-radius: var(--radius-sm);
|
|
42
|
+
font-size: 12px;
|
|
43
|
+
}
|
|
44
|
+
.wok-ui-ext-pagination.wok-ui-ext-pagination-simple .wok-ui-ext-page-info {
|
|
45
|
+
min-width: 60px;
|
|
46
|
+
text-align: center;
|
|
47
|
+
font-size: 14px;
|
|
48
|
+
color: var(--text-secondary);
|
|
49
|
+
white-space: nowrap;
|
|
50
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PopoverPlacement } from '../popover';
|
|
2
|
+
import './style.less';
|
|
3
|
+
export type { PopoverPlacement } from '../popover';
|
|
4
|
+
export interface ShowPopconfirmOptions {
|
|
5
|
+
/** 定位目标元素 */
|
|
6
|
+
target: HTMLElement;
|
|
7
|
+
/** 确认提示文字 */
|
|
8
|
+
title: string;
|
|
9
|
+
/** 详细描述 */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** 确认按钮文字,默认「确定」 */
|
|
12
|
+
confirmText?: string;
|
|
13
|
+
/** 取消按钮文字,默认「取消」 */
|
|
14
|
+
cancelText?: string;
|
|
15
|
+
/** 确认按钮类型,默认 primary */
|
|
16
|
+
confirmType?: 'primary' | 'danger';
|
|
17
|
+
/** 弹出位置,默认 top */
|
|
18
|
+
placement?: PopoverPlacement;
|
|
19
|
+
/** 宽度(px),默认 260 */
|
|
20
|
+
width?: number;
|
|
21
|
+
/** 确认回调 */
|
|
22
|
+
onConfirm: () => void;
|
|
23
|
+
/** 取消回调 */
|
|
24
|
+
onCancel?: () => void;
|
|
25
|
+
}
|
|
26
|
+
export interface AttachPopconfirmOptions extends ShowPopconfirmOptions {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 显示气泡确认框。
|
|
30
|
+
* @param opts 配置选项
|
|
31
|
+
* @returns 关闭控制器 { close }
|
|
32
|
+
*/
|
|
33
|
+
export declare function showPopconfirm(opts: ShowPopconfirmOptions): {
|
|
34
|
+
close: () => void;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 给目标元素绑定点击触发气泡确认框。
|
|
38
|
+
* @param opts 配置选项
|
|
39
|
+
* @returns 解绑控制器 { destroy }
|
|
40
|
+
*/
|
|
41
|
+
export declare function attachPopconfirm(opts: AttachPopconfirmOptions): {
|
|
42
|
+
destroy: () => void;
|
|
43
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Button } from '../button';
|
|
2
|
+
import { getWokUiExtI18n } from '../i18n';
|
|
3
|
+
import { showPopover } from '../popover';
|
|
4
|
+
import './style.css';
|
|
5
|
+
/**
|
|
6
|
+
* 显示气泡确认框。
|
|
7
|
+
* @param opts 配置选项
|
|
8
|
+
* @returns 关闭控制器 { close }
|
|
9
|
+
*/
|
|
10
|
+
export function showPopconfirm(opts) {
|
|
11
|
+
const i18n = getWokUiExtI18n();
|
|
12
|
+
let confirmed = false;
|
|
13
|
+
const content = add => {
|
|
14
|
+
add({
|
|
15
|
+
tag: 'div',
|
|
16
|
+
classNames: 'wok-ui-ext-popconfirm-title',
|
|
17
|
+
children: opts.title
|
|
18
|
+
});
|
|
19
|
+
if (opts.description) {
|
|
20
|
+
add({
|
|
21
|
+
tag: 'div',
|
|
22
|
+
classNames: 'wok-ui-ext-popconfirm-desc',
|
|
23
|
+
children: opts.description
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
add({
|
|
27
|
+
classNames: 'wok-ui-ext-popconfirm-btns',
|
|
28
|
+
children: [
|
|
29
|
+
new Button({
|
|
30
|
+
text: opts.cancelText || i18n.buildMsg('modal-cancel'),
|
|
31
|
+
size: 'small',
|
|
32
|
+
type: 'default',
|
|
33
|
+
onClick: () => {
|
|
34
|
+
close();
|
|
35
|
+
opts.onCancel?.();
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
new Button({
|
|
39
|
+
text: opts.confirmText || i18n.buildMsg('modal-confirm'),
|
|
40
|
+
size: 'small',
|
|
41
|
+
type: opts.confirmType || 'primary',
|
|
42
|
+
onClick: () => {
|
|
43
|
+
confirmed = true;
|
|
44
|
+
close();
|
|
45
|
+
opts.onConfirm();
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const { close } = showPopover({
|
|
52
|
+
target: opts.target,
|
|
53
|
+
content,
|
|
54
|
+
placement: opts.placement || 'top',
|
|
55
|
+
width: opts.width || 260,
|
|
56
|
+
onClose: () => {
|
|
57
|
+
if (!confirmed) {
|
|
58
|
+
opts.onCancel?.();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return { close };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 给目标元素绑定点击触发气泡确认框。
|
|
66
|
+
* @param opts 配置选项
|
|
67
|
+
* @returns 解绑控制器 { destroy }
|
|
68
|
+
*/
|
|
69
|
+
export function attachPopconfirm(opts) {
|
|
70
|
+
const clickHandler = () => showPopconfirm(opts);
|
|
71
|
+
opts.target.addEventListener('click', clickHandler);
|
|
72
|
+
return {
|
|
73
|
+
destroy: () => {
|
|
74
|
+
opts.target.removeEventListener('click', clickHandler);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DivModule, SubModulesOpt } from 'wok-ui';
|
|
2
|
+
import { PopoverPlacement } from './api';
|
|
3
|
+
interface LegacyPopconfirmOptions {
|
|
4
|
+
trigger: HTMLElement | {
|
|
5
|
+
el: HTMLElement;
|
|
6
|
+
};
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
confirmText?: string;
|
|
10
|
+
cancelText?: string;
|
|
11
|
+
confirmType?: 'primary' | 'danger';
|
|
12
|
+
onConfirm: () => void;
|
|
13
|
+
onCancel?: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 气泡确认框组件
|
|
17
|
+
*
|
|
18
|
+
* 可以作为容器使用:children 是触发元素。
|
|
19
|
+
* 也兼容旧版 trigger 参数。
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* new Popconfirm({
|
|
24
|
+
* children: new Button({ text: 'Delete', type: 'danger' }),
|
|
25
|
+
* title: '确认删除?',
|
|
26
|
+
* confirmType: 'danger',
|
|
27
|
+
* onConfirm: () => deleteItem()
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class Popconfirm extends DivModule {
|
|
32
|
+
private binding?;
|
|
33
|
+
constructor(opts: {
|
|
34
|
+
children: SubModulesOpt;
|
|
35
|
+
title: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
confirmText?: string;
|
|
38
|
+
cancelText?: string;
|
|
39
|
+
confirmType?: 'primary' | 'danger';
|
|
40
|
+
placement?: PopoverPlacement;
|
|
41
|
+
width?: number;
|
|
42
|
+
onConfirm: () => void;
|
|
43
|
+
onCancel?: () => void;
|
|
44
|
+
} | LegacyPopconfirmOptions);
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DivModule } from 'wok-ui';
|
|
2
|
+
import { attachPopconfirm } from './api';
|
|
3
|
+
/**
|
|
4
|
+
* 气泡确认框组件
|
|
5
|
+
*
|
|
6
|
+
* 可以作为容器使用:children 是触发元素。
|
|
7
|
+
* 也兼容旧版 trigger 参数。
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* new Popconfirm({
|
|
12
|
+
* children: new Button({ text: 'Delete', type: 'danger' }),
|
|
13
|
+
* title: '确认删除?',
|
|
14
|
+
* confirmType: 'danger',
|
|
15
|
+
* onConfirm: () => deleteItem()
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class Popconfirm extends DivModule {
|
|
20
|
+
constructor(opts) {
|
|
21
|
+
super('wok-ui-ext-popconfirm-trigger');
|
|
22
|
+
const options = {
|
|
23
|
+
target: null,
|
|
24
|
+
title: opts.title,
|
|
25
|
+
description: opts.description,
|
|
26
|
+
confirmText: opts.confirmText,
|
|
27
|
+
cancelText: opts.cancelText,
|
|
28
|
+
confirmType: opts.confirmType,
|
|
29
|
+
placement: opts.placement,
|
|
30
|
+
width: opts.width,
|
|
31
|
+
onConfirm: opts.onConfirm,
|
|
32
|
+
onCancel: opts.onCancel
|
|
33
|
+
};
|
|
34
|
+
if ('trigger' in opts) {
|
|
35
|
+
options.target = 'el' in opts.trigger ? opts.trigger.el : opts.trigger;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.addChild(opts.children);
|
|
39
|
+
options.target = this.el;
|
|
40
|
+
}
|
|
41
|
+
this.binding = attachPopconfirm(options);
|
|
42
|
+
}
|
|
43
|
+
destroy() {
|
|
44
|
+
this.binding?.destroy();
|
|
45
|
+
this.binding = undefined;
|
|
46
|
+
super.destroy();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.wok-ui-ext-popconfirm-body {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 12px;
|
|
5
|
+
}
|
|
6
|
+
.wok-ui-ext-popconfirm-title {
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
font-weight: var(--font-weight-semibold);
|
|
9
|
+
color: var(--text-primary);
|
|
10
|
+
line-height: 1.5;
|
|
11
|
+
}
|
|
12
|
+
.wok-ui-ext-popconfirm-desc {
|
|
13
|
+
font-size: 13px;
|
|
14
|
+
color: var(--text-tertiary);
|
|
15
|
+
line-height: 1.5;
|
|
16
|
+
}
|
|
17
|
+
.wok-ui-ext-popconfirm-btns {
|
|
18
|
+
display: flex;
|
|
19
|
+
justify-content: flex-end;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
margin-top: 4px;
|
|
22
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SubModulesOpt } from 'wok-ui';
|
|
2
|
+
import { FloatingPlacement } from '../floating-layer';
|
|
3
|
+
import './style.less';
|
|
4
|
+
/** 弹出位置,与 FloatingLayer 的定位方向一致 */
|
|
5
|
+
export type PopoverPlacement = FloatingPlacement;
|
|
6
|
+
export interface ShowPopoverOptions {
|
|
7
|
+
/** 定位目标元素 */
|
|
8
|
+
target: HTMLElement;
|
|
9
|
+
/** 弹出内容 */
|
|
10
|
+
content: SubModulesOpt;
|
|
11
|
+
/** 弹出位置,默认 bottom */
|
|
12
|
+
placement?: PopoverPlacement;
|
|
13
|
+
/** 宽度(px) */
|
|
14
|
+
width?: number;
|
|
15
|
+
/** 关闭回调 */
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export interface AttachPopoverOptions extends ShowPopoverOptions {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 显示气泡卡片浮层,挂载到 body。
|
|
22
|
+
* 点击浮层外部或按 Esc 关闭,目标元素滚动/窗口变化时自动跟随。
|
|
23
|
+
* @param opts 配置选项
|
|
24
|
+
* @returns 关闭控制器 { close }
|
|
25
|
+
*/
|
|
26
|
+
export declare function showPopover(opts: ShowPopoverOptions): {
|
|
27
|
+
close: () => void;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 给目标元素绑定点击触发气泡卡片。
|
|
31
|
+
* @param opts 配置选项
|
|
32
|
+
* @returns 解绑控制器 { destroy }
|
|
33
|
+
*/
|
|
34
|
+
export declare function attachPopover(opts: AttachPopoverOptions): {
|
|
35
|
+
destroy: () => void;
|
|
36
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { FloatingLayer } from '../floating-layer';
|
|
2
|
+
import './style.css';
|
|
3
|
+
/** 当前打开的气泡卡片,全局同时只存在一个 */
|
|
4
|
+
let activePopover = null;
|
|
5
|
+
/**
|
|
6
|
+
* 气泡卡片浮层。挂载到 body,由 FloatingLayer 提供定位、滚动跟随、自动关闭。
|
|
7
|
+
*/
|
|
8
|
+
class PopoverLayer extends FloatingLayer {
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
super({ target: opts.target, placement: opts.placement, offset: 10, onClose: opts.onClose });
|
|
11
|
+
this.el.classList.add('wok-ui-ext-popover');
|
|
12
|
+
this.el.dataset.placement = opts.placement;
|
|
13
|
+
if (opts.width) {
|
|
14
|
+
this.el.style.width = `${opts.width}px`;
|
|
15
|
+
}
|
|
16
|
+
this.content = opts.content;
|
|
17
|
+
}
|
|
18
|
+
buildContent() {
|
|
19
|
+
this.addChild(this.content);
|
|
20
|
+
}
|
|
21
|
+
destroy() {
|
|
22
|
+
if (activePopover === this) {
|
|
23
|
+
activePopover = null;
|
|
24
|
+
}
|
|
25
|
+
super.destroy();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 显示气泡卡片浮层,挂载到 body。
|
|
30
|
+
* 点击浮层外部或按 Esc 关闭,目标元素滚动/窗口变化时自动跟随。
|
|
31
|
+
* @param opts 配置选项
|
|
32
|
+
* @returns 关闭控制器 { close }
|
|
33
|
+
*/
|
|
34
|
+
export function showPopover(opts) {
|
|
35
|
+
// 先关闭已有的
|
|
36
|
+
activePopover?.destroy();
|
|
37
|
+
const layer = new PopoverLayer({
|
|
38
|
+
target: opts.target,
|
|
39
|
+
placement: opts.placement || 'bottom',
|
|
40
|
+
content: opts.content,
|
|
41
|
+
width: opts.width,
|
|
42
|
+
onClose: opts.onClose
|
|
43
|
+
});
|
|
44
|
+
activePopover = layer;
|
|
45
|
+
layer.mount(document.body);
|
|
46
|
+
return { close: () => layer.destroy() };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 给目标元素绑定点击触发气泡卡片。
|
|
50
|
+
* @param opts 配置选项
|
|
51
|
+
* @returns 解绑控制器 { destroy }
|
|
52
|
+
*/
|
|
53
|
+
export function attachPopover(opts) {
|
|
54
|
+
const clickHandler = () => showPopover(opts);
|
|
55
|
+
opts.target.addEventListener('click', clickHandler);
|
|
56
|
+
return {
|
|
57
|
+
destroy: () => {
|
|
58
|
+
opts.target.removeEventListener('click', clickHandler);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DivModule, SubModulesOpt } from 'wok-ui';
|
|
2
|
+
import { PopoverPlacement } from './api';
|
|
3
|
+
interface LegacyPopoverOptions {
|
|
4
|
+
trigger: HTMLElement | {
|
|
5
|
+
el: HTMLElement;
|
|
6
|
+
};
|
|
7
|
+
content: SubModulesOpt;
|
|
8
|
+
placement?: PopoverPlacement;
|
|
9
|
+
width?: number;
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 气泡卡片组件
|
|
14
|
+
*
|
|
15
|
+
* 可以作为容器使用:children 是触发元素,content 是浮层内容。
|
|
16
|
+
* 也兼容旧版 trigger 参数。
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* new Popover({
|
|
21
|
+
* children: new Button({ text: 'Click me' }),
|
|
22
|
+
* placement: 'bottom',
|
|
23
|
+
* content: new MyPanel()
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class Popover extends DivModule {
|
|
28
|
+
private binding?;
|
|
29
|
+
constructor(opts: {
|
|
30
|
+
children: SubModulesOpt;
|
|
31
|
+
content: SubModulesOpt;
|
|
32
|
+
placement?: PopoverPlacement;
|
|
33
|
+
width?: number;
|
|
34
|
+
onClose?: () => void;
|
|
35
|
+
} | LegacyPopoverOptions);
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DivModule } from 'wok-ui';
|
|
2
|
+
import { attachPopover } from './api';
|
|
3
|
+
/**
|
|
4
|
+
* 气泡卡片组件
|
|
5
|
+
*
|
|
6
|
+
* 可以作为容器使用:children 是触发元素,content 是浮层内容。
|
|
7
|
+
* 也兼容旧版 trigger 参数。
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* new Popover({
|
|
12
|
+
* children: new Button({ text: 'Click me' }),
|
|
13
|
+
* placement: 'bottom',
|
|
14
|
+
* content: new MyPanel()
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class Popover extends DivModule {
|
|
19
|
+
constructor(opts) {
|
|
20
|
+
super('wok-ui-ext-popover-trigger');
|
|
21
|
+
const content = opts.content;
|
|
22
|
+
const placement = opts.placement || 'bottom';
|
|
23
|
+
const width = opts.width;
|
|
24
|
+
const onClose = opts.onClose;
|
|
25
|
+
if ('trigger' in opts) {
|
|
26
|
+
const target = 'el' in opts.trigger ? opts.trigger.el : opts.trigger;
|
|
27
|
+
this.binding = attachPopover({
|
|
28
|
+
target,
|
|
29
|
+
content,
|
|
30
|
+
placement,
|
|
31
|
+
width,
|
|
32
|
+
onClose
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.addChild(opts.children);
|
|
37
|
+
this.binding = attachPopover({
|
|
38
|
+
target: this.el,
|
|
39
|
+
content,
|
|
40
|
+
placement,
|
|
41
|
+
width,
|
|
42
|
+
onClose
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
destroy() {
|
|
47
|
+
this.binding?.destroy();
|
|
48
|
+
this.binding = undefined;
|
|
49
|
+
super.destroy();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
.wok-ui-ext-popover {
|
|
2
|
+
background: var(--bg-card);
|
|
3
|
+
border: 1px solid var(--border-medium);
|
|
4
|
+
border-radius: var(--radius-md);
|
|
5
|
+
box-shadow: var(--shadow-lg);
|
|
6
|
+
padding: 12px;
|
|
7
|
+
animation: wok-ui-ext-popover-in 0.15s ease;
|
|
8
|
+
min-width: 60px;
|
|
9
|
+
}
|
|
10
|
+
.wok-ui-ext-popover::before,
|
|
11
|
+
.wok-ui-ext-popover::after {
|
|
12
|
+
content: '';
|
|
13
|
+
position: absolute;
|
|
14
|
+
width: 0;
|
|
15
|
+
height: 0;
|
|
16
|
+
border: 8px solid transparent;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
}
|
|
19
|
+
.wok-ui-ext-popover::before {
|
|
20
|
+
z-index: -1;
|
|
21
|
+
}
|
|
22
|
+
.wok-ui-ext-popover::after {
|
|
23
|
+
z-index: 1;
|
|
24
|
+
}
|
|
25
|
+
.wok-ui-ext-popover[data-placement^='bottom']::before {
|
|
26
|
+
top: -17px;
|
|
27
|
+
border-bottom-color: var(--border-medium);
|
|
28
|
+
}
|
|
29
|
+
.wok-ui-ext-popover[data-placement^='bottom']::after {
|
|
30
|
+
top: -15px;
|
|
31
|
+
border-bottom-color: var(--bg-card);
|
|
32
|
+
}
|
|
33
|
+
.wok-ui-ext-popover[data-placement='bottom']::before,
|
|
34
|
+
.wok-ui-ext-popover[data-placement='bottom']::after {
|
|
35
|
+
left: 50%;
|
|
36
|
+
transform: translateX(-50%);
|
|
37
|
+
}
|
|
38
|
+
.wok-ui-ext-popover[data-placement='bottomLeft']::before,
|
|
39
|
+
.wok-ui-ext-popover[data-placement='bottomLeft']::after {
|
|
40
|
+
left: 16px;
|
|
41
|
+
}
|
|
42
|
+
.wok-ui-ext-popover[data-placement='bottomRight']::before,
|
|
43
|
+
.wok-ui-ext-popover[data-placement='bottomRight']::after {
|
|
44
|
+
right: 16px;
|
|
45
|
+
}
|
|
46
|
+
.wok-ui-ext-popover[data-placement^='top']::before {
|
|
47
|
+
bottom: -17px;
|
|
48
|
+
border-top-color: var(--border-medium);
|
|
49
|
+
}
|
|
50
|
+
.wok-ui-ext-popover[data-placement^='top']::after {
|
|
51
|
+
bottom: -15px;
|
|
52
|
+
border-top-color: var(--bg-card);
|
|
53
|
+
}
|
|
54
|
+
.wok-ui-ext-popover[data-placement='top']::before,
|
|
55
|
+
.wok-ui-ext-popover[data-placement='top']::after {
|
|
56
|
+
left: 50%;
|
|
57
|
+
transform: translateX(-50%);
|
|
58
|
+
}
|
|
59
|
+
.wok-ui-ext-popover[data-placement='topLeft']::before,
|
|
60
|
+
.wok-ui-ext-popover[data-placement='topLeft']::after {
|
|
61
|
+
left: 16px;
|
|
62
|
+
}
|
|
63
|
+
.wok-ui-ext-popover[data-placement='topRight']::before,
|
|
64
|
+
.wok-ui-ext-popover[data-placement='topRight']::after {
|
|
65
|
+
right: 16px;
|
|
66
|
+
}
|
|
67
|
+
.wok-ui-ext-popover[data-placement='left']::before {
|
|
68
|
+
right: -17px;
|
|
69
|
+
border-left-color: var(--border-medium);
|
|
70
|
+
}
|
|
71
|
+
.wok-ui-ext-popover[data-placement='left']::after {
|
|
72
|
+
right: -15px;
|
|
73
|
+
border-left-color: var(--bg-card);
|
|
74
|
+
}
|
|
75
|
+
.wok-ui-ext-popover[data-placement='left']::before,
|
|
76
|
+
.wok-ui-ext-popover[data-placement='left']::after {
|
|
77
|
+
top: 50%;
|
|
78
|
+
transform: translateY(-50%);
|
|
79
|
+
}
|
|
80
|
+
.wok-ui-ext-popover[data-placement='right']::before {
|
|
81
|
+
left: -17px;
|
|
82
|
+
border-right-color: var(--border-medium);
|
|
83
|
+
}
|
|
84
|
+
.wok-ui-ext-popover[data-placement='right']::after {
|
|
85
|
+
left: -15px;
|
|
86
|
+
border-right-color: var(--bg-card);
|
|
87
|
+
}
|
|
88
|
+
.wok-ui-ext-popover[data-placement='right']::before,
|
|
89
|
+
.wok-ui-ext-popover[data-placement='right']::after {
|
|
90
|
+
top: 50%;
|
|
91
|
+
transform: translateY(-50%);
|
|
92
|
+
}
|
|
93
|
+
@keyframes wok-ui-ext-popover-in {
|
|
94
|
+
from {
|
|
95
|
+
opacity: 0;
|
|
96
|
+
transform: scale(0.95);
|
|
97
|
+
}
|
|
98
|
+
to {
|
|
99
|
+
opacity: 1;
|
|
100
|
+
transform: scale(1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DivModule, SubModulesOpt } from 'wok-ui';
|
|
2
|
+
import './style.less';
|
|
3
|
+
/**
|
|
4
|
+
* 进度条支持的状态颜色
|
|
5
|
+
*/
|
|
6
|
+
export type ProgressColor = 'primary' | 'success' | 'warning' | 'danger';
|
|
7
|
+
/**
|
|
8
|
+
* 进度条组件
|
|
9
|
+
*
|
|
10
|
+
<div class="progress-item">
|
|
11
|
+
<div class="progress-label"><span>任务进度</span> <span>75%</span></div>
|
|
12
|
+
<div class="progress-bar-bg">
|
|
13
|
+
<div class="progress-bar-fill" style="width:75%"></div>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
*/
|
|
17
|
+
export declare class Progress extends DivModule {
|
|
18
|
+
/**
|
|
19
|
+
* 进度条组件
|
|
20
|
+
* @param opts.label 进度条标签,支持字符串或子模块
|
|
21
|
+
* @param opts.progress 进度条进度,0-100
|
|
22
|
+
* @param opts.showProgress 是否显示进度数字
|
|
23
|
+
* @param opts.color 进度条颜色,默认 primary
|
|
24
|
+
* @param opts.text 自定义进度文本,如 "85/100分",设置后将替代百分比显示
|
|
25
|
+
*/
|
|
26
|
+
constructor(opts: {
|
|
27
|
+
label?: SubModulesOpt;
|
|
28
|
+
progress: number;
|
|
29
|
+
showProgress?: boolean;
|
|
30
|
+
color?: ProgressColor;
|
|
31
|
+
text?: string;
|
|
32
|
+
});
|
|
33
|
+
setProgress(progress: number, text?: string): void;
|
|
34
|
+
}
|