@type-dom/ui 0.0.7 → 0.0.8
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/package.json +1 -1
- package/src/components/basic/td-button/td-button.abstract.js +1 -1
- package/src/components/basic/td-button-group/td-button-group.class.js +1 -1
- package/src/components/basic/td-container/td-aside/td-aside.class.js +1 -1
- package/src/components/basic/td-container/td-container.class.js +1 -1
- package/src/components/basic/td-container/td-footer/td-footer.class.js +1 -1
- package/src/components/basic/td-container/td-header/td-header.class.js +1 -2
- package/src/components/basic/td-container/td-main/td-main.class.js +1 -1
- package/src/components/basic/td-icon/td-icon.class.js +1 -1
- package/src/components/basic/td-layout/td-col/td-col.class.js +3 -3
- package/src/components/basic/td-layout/td-row/td-row.class.js +1 -1
- package/src/components/basic/td-link/td-link.class.js +1 -1
- package/src/components/basic/td-scrollbar/bar/bar.class.js +1 -1
- package/src/components/basic/td-scrollbar/td-scrollbar.class.js +1 -1
- package/src/components/basic/td-scrollbar/thumb/thumb.class.js +1 -1
- package/src/components/basic/td-space/td-space.class.js +1 -1
- package/src/components/basic/td-text/td-text.class.js +1 -1
- package/src/components/data/td-avatar/td-avatar.class.js +2 -2
- package/src/components/data/td-badge/td-badge.class.d.ts +1 -0
- package/src/components/data/td-badge/td-badge.class.js +9 -6
- package/src/components/data/td-card/td-card.class.js +1 -1
- package/src/components/data/td-check-tag/td-check-tag.class.js +1 -1
- package/src/components/data/td-collapse/td-collapse.class.js +1 -2
- package/src/components/data/td-collapse/td-collapse.interface.d.ts +1 -0
- package/src/components/data/td-collapse-item/td-collapse-item.class.js +2 -2
- package/src/components/data/td-count-down/td-count-down.class.js +1 -1
- package/src/components/data/td-descriptions/td-descriptions-row.js +2 -2
- package/src/components/data/td-descriptions/td-descriptions.class.js +2 -2
- package/src/components/data/td-descriptions/td-descritions-cell.js +1 -1
- package/src/components/data/td-descriptions-item/td-descriptions-item.class.js +1 -1
- package/src/components/data/td-empty/img-empty.class.js +1 -1
- package/src/components/data/td-empty/td-empty.class.js +1 -1
- package/src/components/data/td-image/td-image.class.js +2 -2
- package/src/components/data/td-image-viewer/td-image-viewer.class.js +2 -1
- package/src/components/data/td-result/td-result.class.js +1 -1
- package/src/components/data/td-segmented/td-segmented.class.js +13 -14
- package/src/components/data/td-statistic/td-statistic.abstract.js +1 -1
- package/src/components/data/td-tag/td-tag.class.js +2 -2
- package/src/components/feedback/dialog/dialog.class.js +1 -1
- package/src/components/feedback/message-box/message-box.js +1 -1
- package/src/components/feedback/overlay/container/container.js +5 -4
- package/src/components/feedback/overlay/container/footer/cancel-button/cancel-button.js +6 -5
- package/src/components/feedback/overlay/container/footer/confirm-button/confirm-button.js +6 -5
- package/src/components/feedback/overlay/container/header/close-button/close-button.js +6 -5
- package/src/components/feedback/overlay/overlay.abstract.js +5 -4
- package/src/components/feedback/td-alert/td-alert.class.js +1 -1
- package/src/components/feedback/td-dialog/td-dialog.class.js +2 -2
- package/src/components/feedback/td-dialog-content/td-dialog-content.class.js +1 -1
- package/src/components/feedback/td-drawer/td-drawer.class.js +12 -10
- package/src/components/feedback/td-focus-trap/td-focus-trap.class.js +1 -1
- package/src/components/feedback/td-focus-trap/utils.d.ts +1 -1
- package/src/components/feedback/td-loading/td-loading.class.js +1 -1
- package/src/components/feedback/td-message/td-message.class.d.ts +1 -0
- package/src/components/feedback/td-message/td-message.class.js +18 -11
- package/src/components/feedback/td-message-box/td-message-box.class.js +2 -3
- package/src/components/feedback/td-notification/td-notification.class.js +4 -4
- package/src/components/feedback/td-overlay/td-overlay.class.js +1 -1
- package/src/components/feedback/td-popper/arrow/arrow.class.js +1 -1
- package/src/components/feedback/td-popper/content/content.class.js +1 -1
- package/src/components/feedback/td-popper/td-popper.class.js +1 -1
- package/src/components/feedback/td-popper/trigger/trigger.class.js +1 -1
- package/src/components/feedback/td-tooltip/content/content.class.js +1 -1
- package/src/components/feedback/td-tooltip/td-tooltip.class.js +1 -1
- package/src/components/feedback/td-tooltip/trigger/trigger.class.js +1 -1
- package/src/components/form/checkbox-group/checkbox-option/checkbox-option.class.js +19 -18
- package/src/components/form/field-item/cascade/field-cascade.abstract.js +40 -35
- package/src/components/form/field-item/input/field-input.abstract.js +7 -6
- package/src/components/form/field-item/options/field-options.abstract.js +19 -18
- package/src/components/form/field-item/radio/field-radio.abstract.js +2 -3
- package/src/components/form/field-item/select/field-select.abstract.js +14 -14
- package/src/components/form/field-select/field-select.class.js +16 -16
- package/src/components/form/radio-group/radio-group.class.js +1 -1
- package/src/components/form/radio-group/radio-option/radio-option.class.js +9 -8
- package/src/components/form/select/select.class.js +17 -16
- package/src/components/form/td-checkbox/td-checkbox.class.js +1 -1
- package/src/components/form/td-checkbox-button/td-checkbox-button.class.js +1 -1
- package/src/components/form/td-checkbox-group/td-checkbox-group.class.js +1 -1
- package/src/components/form/td-form/td-form.class.js +1 -1
- package/src/components/form/td-form-item/td-form-item.class.js +1 -1
- package/src/components/form/td-input/td-input.class.js +1 -1
- package/src/components/form/td-input/widget/td-input-wrapper.class.js +1 -1
- package/src/components/form/td-input/widget/td-textarea-wrapper.js +1 -1
- package/src/components/form/td-option/td-option.class.js +1 -1
- package/src/components/form/td-option-group/td-option-group.class.js +1 -1
- package/src/components/form/td-radio/td-radio.class.js +1 -2
- package/src/components/form/td-radio-button/td-radio-button.class.js +1 -2
- package/src/components/form/td-radio-group/td-radio-group.class.js +1 -1
- package/src/components/form/td-select/dropdown/dropdown.class.js +1 -1
- package/src/components/form/td-select/td-select.class.js +1 -1
- package/src/components/form/td-switch/td-switch.class.js +7 -8
- package/src/components/form/td-switch/widget/td-switch-core.js +1 -1
- package/src/components/form/td-switch/widget/td-switch-left.js +1 -1
- package/src/components/form/td-switch/widget/td-switch-right.js +1 -1
- package/src/components/navigation/td-affix/td-affix.class.js +1 -1
- package/src/components/navigation/td-anchor/td-anchor-link/td-anchor-link.class.js +1 -1
- package/src/components/navigation/td-anchor/td-anchor.class.js +1 -1
- package/src/components/navigation/td-backtop/td-backtop.class.js +4 -5
- package/src/components/navigation/td-breadcrumb/td-breadcrumb.class.js +1 -1
- package/src/components/navigation/td-breadcrumb-item/td-breadcrumb-item.class.js +1 -1
- package/src/components/navigation/td-menu/td-menu.class.js +1 -1
- package/src/components/navigation/td-tabs/td-tab-bar.class.js +1 -1
- package/src/components/navigation/td-tabs/td-tab-nav.class.js +1 -1
- package/src/components/navigation/td-tabs/td-tab-pane.class.js +1 -1
- package/src/components/navigation/td-tabs/td-tabs.class.js +19 -22
- package/src/components/others/collapsible-box/heading/expand-heading.js +24 -23
- package/src/components/others/custom-block/custom-block.d.ts +11 -0
- package/src/components/others/custom-block/custom-block.js +58 -0
- package/src/components/others/example/example-float-control.d.ts +8 -0
- package/src/components/others/example/example-float-control.js +63 -0
- package/src/components/others/example/example-showcase.d.ts +7 -0
- package/src/components/others/example/example-showcase.js +20 -0
- package/src/components/others/example/example-source-wrapper.d.ts +5 -0
- package/src/components/others/example/example-source-wrapper.js +30 -0
- package/src/components/others/example/example.d.ts +15 -0
- package/src/components/others/example/example.js +77 -0
- package/src/components/others/example/index.d.ts +5 -0
- package/src/components/others/example/index.js +13 -0
- package/src/components/others/example/op-btns.d.ts +7 -0
- package/src/components/others/example/op-btns.js +96 -0
- package/src/components/others/index.d.ts +4 -0
- package/src/components/others/index.js +9 -1
- package/src/components/others/menus/menu.d.ts +16 -0
- package/src/components/others/menus/menu.js +123 -0
- package/src/components/others/menus/menus.d.ts +10 -0
- package/src/components/others/menus/menus.js +79 -0
- package/src/components/others/td-divider/td-divider.class.js +1 -1
- package/src/ui/ui.abstract.js +1 -1
- package/src/ui/ui.interface.d.ts +3 -3
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Menu = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const framework_1 = require("@type-dom/framework");
|
|
6
|
+
const svgs_1 = require("@type-dom/svgs");
|
|
7
|
+
const td_icon_class_1 = require("../../basic/td-icon/td-icon.class");
|
|
8
|
+
class Menu extends framework_1.TypeMenu {
|
|
9
|
+
constructor(route, router) {
|
|
10
|
+
super();
|
|
11
|
+
this.className = 'Menu';
|
|
12
|
+
this.route = route;
|
|
13
|
+
this.router = router;
|
|
14
|
+
this.ctrl.addStyleObj({
|
|
15
|
+
paddingInlineStart: '20px'
|
|
16
|
+
// display: 'flex',
|
|
17
|
+
// flexDirection: 'column',
|
|
18
|
+
});
|
|
19
|
+
const div = new framework_1.Div({
|
|
20
|
+
parent: this,
|
|
21
|
+
styleObj: {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center'
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
if (route.svgObj) {
|
|
27
|
+
div.addChild(new td_icon_class_1.TdIcon({
|
|
28
|
+
svgObj: route.svgObj,
|
|
29
|
+
styleObj: {
|
|
30
|
+
paddingRight: '5px'
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
div.addChild(new framework_1.Div({
|
|
35
|
+
text: route.name,
|
|
36
|
+
attrObj: {
|
|
37
|
+
name: 'route-name'
|
|
38
|
+
},
|
|
39
|
+
styleObj: {
|
|
40
|
+
width: '160px'
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
if (route.children) {
|
|
44
|
+
const caret = new td_icon_class_1.TdIcon({
|
|
45
|
+
svgObj: new svgs_1.ElCaretBottomSvg(),
|
|
46
|
+
size: '30px'
|
|
47
|
+
});
|
|
48
|
+
caret.appendParent(div);
|
|
49
|
+
this.caret = caret;
|
|
50
|
+
}
|
|
51
|
+
div.appendParent(this);
|
|
52
|
+
this.contentItem = div;
|
|
53
|
+
this.menuItems = [];
|
|
54
|
+
}
|
|
55
|
+
get menuRoot() {
|
|
56
|
+
var _a;
|
|
57
|
+
return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.menuRoot;
|
|
58
|
+
}
|
|
59
|
+
initEvents() {
|
|
60
|
+
if (this.route.redirect === undefined) {
|
|
61
|
+
// todo addEvent 如何pipe ??
|
|
62
|
+
(0, rxjs_1.fromEvent)(this.contentItem.dom, 'click')
|
|
63
|
+
.pipe((0, rxjs_1.filter)(() => {
|
|
64
|
+
var _a;
|
|
65
|
+
return ((_a = this.menuRoot) === null || _a === void 0 ? void 0 : _a.selectedMenu) !== this;
|
|
66
|
+
}))
|
|
67
|
+
.subscribe((event) => {
|
|
68
|
+
var _a;
|
|
69
|
+
// if (this.menuRoot.selectedMenu === this) {
|
|
70
|
+
// return;
|
|
71
|
+
// }
|
|
72
|
+
this.router.push(this.route.path);
|
|
73
|
+
(_a = this.menuRoot) === null || _a === void 0 ? void 0 : _a.setSelectedMenu(this);
|
|
74
|
+
document.title = 'UI - ' + this.route.name;
|
|
75
|
+
event.stopPropagation(); // 防止冒泡
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// todo 添加展开、收起的监听
|
|
81
|
+
const leftSvg = new svgs_1.ElCaretLeftSvg();
|
|
82
|
+
// console.log(' leftSvg.resetSize ');
|
|
83
|
+
// leftSvg.resetSize('1.5em', '1.5em');
|
|
84
|
+
// leftSvg.ctrl.setStyleObj({
|
|
85
|
+
// width: '1.5em',
|
|
86
|
+
// height: '1.5em'
|
|
87
|
+
// })
|
|
88
|
+
const bottomSvg = new svgs_1.ElCaretBottomSvg();
|
|
89
|
+
// bottomSvg.ctrl.setStyleObj({
|
|
90
|
+
// width: '1.5em',
|
|
91
|
+
// height: '1.5em'
|
|
92
|
+
// })
|
|
93
|
+
// bottomSvg.resetSize('1.5em', '1.5em');
|
|
94
|
+
this.addEvent('click', this.contentItem.dom, (event) => {
|
|
95
|
+
var _a, _b, _c;
|
|
96
|
+
if (((_a = this.menuRoot) === null || _a === void 0 ? void 0 : _a.selectedMenu) === this) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (this.collapsed === undefined || this.collapsed === false) {
|
|
100
|
+
this.collapsed = true;
|
|
101
|
+
this.menuItems.forEach((menu) => {
|
|
102
|
+
menu.ctrl.setStyleObj({
|
|
103
|
+
display: 'none'
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
(_b = this.caret) === null || _b === void 0 ? void 0 : _b.replaceSvg(leftSvg); // 左三角
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.collapsed = false;
|
|
110
|
+
this.menuItems.forEach((menu) => {
|
|
111
|
+
menu.ctrl.setStyleObj({
|
|
112
|
+
display: 'block'
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
(_c = this.caret) === null || _c === void 0 ? void 0 : _c.replaceSvg(bottomSvg); // 向下三角
|
|
116
|
+
}
|
|
117
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation(); // 防止冒泡
|
|
118
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.Menu = Menu;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IRoute, ITypeConfig, Router, TypeDiv } from '@type-dom/framework';
|
|
2
|
+
import { Menu } from './menu';
|
|
3
|
+
export declare class Menus extends TypeDiv {
|
|
4
|
+
className: 'Menus';
|
|
5
|
+
selectedMenu?: Menu;
|
|
6
|
+
constructor(params?: ITypeConfig);
|
|
7
|
+
get menuRoot(): Menus;
|
|
8
|
+
createMenus(parent: Menus | Menu, routes: IRoute[], router: Router): void;
|
|
9
|
+
setSelectedMenu(menu: Menu): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Menus = void 0;
|
|
4
|
+
// 基于router创建的菜单
|
|
5
|
+
const framework_1 = require("@type-dom/framework");
|
|
6
|
+
const menu_1 = require("./menu");
|
|
7
|
+
class Menus extends framework_1.TypeDiv {
|
|
8
|
+
constructor(params = {}) {
|
|
9
|
+
super();
|
|
10
|
+
this.className = 'Menus';
|
|
11
|
+
this.ctrl.addAttrName('menus');
|
|
12
|
+
// 默认样式
|
|
13
|
+
this.ctrl.addStyleObj({
|
|
14
|
+
userSelect: 'none',
|
|
15
|
+
// overflow: 'auto',
|
|
16
|
+
boxSizing: 'border-box',
|
|
17
|
+
flexShrink: 0,
|
|
18
|
+
maxHeight: 'calc(100vh - 40px)'
|
|
19
|
+
});
|
|
20
|
+
this.setProps(params);
|
|
21
|
+
const router = params.router;
|
|
22
|
+
console.log('ui-doc routerUI.routes is ', router);
|
|
23
|
+
this.createMenus(this, router.routes, router);
|
|
24
|
+
console.log('menus is ', this);
|
|
25
|
+
}
|
|
26
|
+
get menuRoot() {
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
// /home '' '/' 首页菜单要单独处理
|
|
30
|
+
createMenus(parent, routes, router) {
|
|
31
|
+
console.log('createMenus . ');
|
|
32
|
+
routes.forEach((route) => {
|
|
33
|
+
if (route.hidden) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if ((route === null || route === void 0 ? void 0 : route.path) === '/' && route.redirect) {
|
|
37
|
+
route = route.children.find((item) => item.path === route.redirect);
|
|
38
|
+
// todo 没有的话,要报错的。
|
|
39
|
+
}
|
|
40
|
+
const menuItem = new menu_1.Menu(route, router);
|
|
41
|
+
if (parent instanceof menu_1.Menu) {
|
|
42
|
+
parent.menuItems.push(menuItem);
|
|
43
|
+
}
|
|
44
|
+
menuItem.appendParent(parent);
|
|
45
|
+
// hash路由和history路由要分别判断
|
|
46
|
+
if (router.mode === 'hash') {
|
|
47
|
+
if (window.location.hash.slice(1) === route.path) {
|
|
48
|
+
// 当前路由与菜单绑定路由一致,则选中状态
|
|
49
|
+
this.setSelectedMenu(menuItem);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (router.mode === 'history') {
|
|
53
|
+
if (window.location.pathname === route.path) {
|
|
54
|
+
// 当前路由与菜单绑定路由一致,则选中状态
|
|
55
|
+
this.setSelectedMenu(menuItem);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (route.children) {
|
|
59
|
+
this.createMenus(menuItem, route.children, router);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
setSelectedMenu(menu) {
|
|
64
|
+
if (menu !== this.selectedMenu) {
|
|
65
|
+
if (this.selectedMenu) {
|
|
66
|
+
this.selectedMenu.ctrl.setStyleObj({
|
|
67
|
+
backgroundColor: ''
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
this.selectedMenu = menu;
|
|
71
|
+
if (menu.route.redirect === undefined) {
|
|
72
|
+
menu.ctrl.setStyleObj({
|
|
73
|
+
backgroundColor: '#ccc'
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.Menus = Menus;
|
package/src/ui/ui.abstract.js
CHANGED
|
@@ -20,7 +20,7 @@ class UI extends framework_1.TypeElement {
|
|
|
20
20
|
this.dom = document.createElement(this.nodeName.trim());
|
|
21
21
|
}
|
|
22
22
|
this.slotNodes = {
|
|
23
|
-
|
|
23
|
+
// default: new SlotNode('default'),
|
|
24
24
|
};
|
|
25
25
|
// todo 统一处理,还是在各个类中处理
|
|
26
26
|
this.useSlots(params);
|
package/src/ui/ui.interface.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ISlotNodes, ITypeConfig, ITypeElement, SlotNode } from '@type-dom/framework';
|
|
1
|
+
import { ISlotNodes, ITypeConfig, ITypeElement, SlotNode, TypeElement } from '@type-dom/framework';
|
|
2
2
|
export interface IUI extends ITypeElement {
|
|
3
3
|
componentId?: string | number;
|
|
4
4
|
}
|
|
5
5
|
export interface IUIConfig extends ITypeConfig {
|
|
6
6
|
tag?: string;
|
|
7
7
|
items?: ITypeConfig[];
|
|
8
|
-
childNodes?: undefined;
|
|
8
|
+
childNodes?: TypeElement[] | undefined;
|
|
9
9
|
}
|
|
10
10
|
export interface IUISlotNodes extends ISlotNodes {
|
|
11
|
-
default
|
|
11
|
+
default?: SlotNode;
|
|
12
12
|
}
|