mdui 2.0.1 → 2.0.3
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 -21
- package/components/avatar/index.d.ts +4 -2
- package/components/avatar/index.js +4 -2
- package/components/badge/index.d.ts +4 -2
- package/components/badge/index.js +4 -2
- package/components/bottom-app-bar/index.d.ts +9 -3
- package/components/bottom-app-bar/index.js +9 -9
- package/components/button/button-base.d.ts +5 -5
- package/components/button/button-base.js +22 -19
- package/components/button/index.d.ts +6 -1
- package/components/button/index.js +2 -1
- package/components/button-icon/index.d.ts +7 -1
- package/components/button-icon/index.js +3 -3
- package/components/card/index.d.ts +8 -4
- package/components/card/index.js +7 -3
- package/components/checkbox/index.d.ts +10 -3
- package/components/checkbox/index.js +13 -16
- package/components/checkbox/style.js +1 -1
- package/components/chip/index.d.ts +8 -1
- package/components/chip/index.js +5 -5
- package/components/circular-progress/index.d.ts +4 -2
- package/components/circular-progress/index.js +5 -4
- package/components/collapse/collapse-item-style.js +1 -1
- package/components/collapse/collapse-item.d.ts +15 -3
- package/components/collapse/collapse-item.js +26 -23
- package/components/collapse/collapse.d.ts +16 -8
- package/components/collapse/collapse.js +61 -38
- package/components/dialog/index.d.ts +12 -4
- package/components/dialog/index.js +36 -36
- package/components/divider/index.d.ts +4 -2
- package/components/divider/index.js +4 -2
- package/components/dropdown/index.d.ts +13 -7
- package/components/dropdown/index.js +70 -63
- package/components/fab/index.d.ts +7 -1
- package/components/fab/index.js +10 -5
- package/components/icon/index.d.ts +4 -2
- package/components/icon/index.js +4 -2
- package/components/layout/helper.d.ts +5 -6
- package/components/layout/helper.js +42 -48
- package/components/layout/layout-item-base.d.ts +3 -2
- package/components/layout/layout-item-base.js +3 -4
- package/components/layout/layout-item.d.ts +4 -3
- package/components/layout/layout-item.js +3 -3
- package/components/layout/layout-main.d.ts +4 -2
- package/components/layout/layout-main.js +4 -2
- package/components/layout/layout.d.ts +4 -2
- package/components/layout/layout.js +4 -2
- package/components/linear-progress/index.d.ts +4 -2
- package/components/linear-progress/index.js +5 -4
- package/components/list/list-item-style.js +1 -1
- package/components/list/list-item.d.ts +7 -3
- package/components/list/list-item.js +5 -3
- package/components/list/list-subheader.d.ts +4 -2
- package/components/list/list-subheader.js +4 -2
- package/components/list/list.d.ts +4 -2
- package/components/list/list.js +4 -2
- package/components/menu/menu-item.d.ts +12 -3
- package/components/menu/menu-item.js +53 -40
- package/components/menu/menu.d.ts +9 -3
- package/components/menu/menu.js +85 -59
- package/components/navigation-bar/navigation-bar-item-style.js +1 -1
- package/components/navigation-bar/navigation-bar-item.d.ts +13 -5
- package/components/navigation-bar/navigation-bar-item.js +28 -11
- package/components/navigation-bar/navigation-bar.d.ts +14 -7
- package/components/navigation-bar/navigation-bar.js +58 -49
- package/components/navigation-drawer/index.d.ts +13 -2
- package/components/navigation-drawer/index.js +69 -49
- package/components/navigation-drawer/style.js +1 -1
- package/components/navigation-rail/navigation-rail-item-style.js +1 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +13 -5
- package/components/navigation-rail/navigation-rail-item.js +22 -9
- package/components/navigation-rail/navigation-rail.d.ts +8 -6
- package/components/navigation-rail/navigation-rail.js +55 -46
- package/components/radio/radio-group.d.ts +13 -6
- package/components/radio/radio-group.js +69 -59
- package/components/radio/radio-style.js +1 -1
- package/components/radio/radio.d.ts +11 -5
- package/components/radio/radio.js +26 -19
- package/components/range-slider/index.d.ts +9 -3
- package/components/range-slider/index.js +13 -11
- package/components/ripple/index.d.ts +4 -2
- package/components/ripple/index.js +4 -2
- package/components/ripple/ripple-mixin.d.ts +1 -1
- package/components/ripple/ripple-mixin.js +0 -1
- package/components/segmented-button/segmented-button-group-style.js +1 -1
- package/components/segmented-button/segmented-button-group.d.ts +12 -5
- package/components/segmented-button/segmented-button-group.js +92 -77
- package/components/segmented-button/segmented-button.d.ts +8 -3
- package/components/segmented-button/segmented-button.js +5 -4
- package/components/select/index.d.ts +13 -5
- package/components/select/index.js +30 -28
- package/components/slider/index.d.ts +8 -1
- package/components/slider/index.js +11 -18
- package/components/slider/slider-base-style.js +1 -1
- package/components/slider/slider-base.d.ts +7 -3
- package/components/slider/slider-base.js +28 -13
- package/components/snackbar/index.d.ts +9 -2
- package/components/snackbar/index.js +11 -10
- package/components/switch/index.d.ts +10 -3
- package/components/switch/index.js +12 -15
- package/components/switch/style.js +1 -1
- package/components/tabs/tab-panel.d.ts +4 -2
- package/components/tabs/tab-panel.js +4 -2
- package/components/tabs/tab-style.js +1 -1
- package/components/tabs/tab.d.ts +7 -3
- package/components/tabs/tab.js +12 -6
- package/components/tabs/tabs-style.js +1 -1
- package/components/tabs/tabs.d.ts +11 -7
- package/components/tabs/tabs.js +57 -40
- package/components/text-field/index.d.ts +13 -5
- package/components/text-field/index.js +43 -65
- package/components/text-field/style.js +1 -1
- package/components/tooltip/index.d.ts +14 -7
- package/components/tooltip/index.js +45 -38
- package/components/top-app-bar/top-app-bar-title-style.js +1 -1
- package/components/top-app-bar/top-app-bar-title.d.ts +4 -2
- package/components/top-app-bar/top-app-bar-title.js +18 -13
- package/components/top-app-bar/top-app-bar.d.ts +9 -3
- package/components/top-app-bar/top-app-bar.js +11 -10
- package/custom-elements.json +904 -546
- package/functions/getTheme.js +3 -3
- package/functions/snackbar.js +1 -2
- package/functions/utils/colorScheme.js +2 -2
- package/mdui.esm.js +8 -8
- package/mdui.global.js +8 -8
- package/package.json +8 -7
- package/web-types.zh-cn.json +1 -1
package/components/fab/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { html } from 'lit';
|
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
5
5
|
import cc from 'classcat';
|
|
6
|
+
import { DefinedController } from '@mdui/shared/controllers/defined.js';
|
|
6
7
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
7
8
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
8
9
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
@@ -34,7 +35,7 @@ import { style } from './style.js';
|
|
|
34
35
|
* @cssprop --shape-corner-normal - `size="normal"` 时,组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
35
36
|
* @cssprop --shape-corner-large - `size="large"` 时,组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
let Fab = class Fab extends ButtonBase {
|
|
38
39
|
constructor() {
|
|
39
40
|
super(...arguments);
|
|
40
41
|
/**
|
|
@@ -59,6 +60,9 @@ export let Fab = class Fab extends ButtonBase {
|
|
|
59
60
|
this.extended = false;
|
|
60
61
|
this.rippleRef = createRef();
|
|
61
62
|
this.hasSlotController = new HasSlotController(this, 'icon');
|
|
63
|
+
this.definedController = new DefinedController(this, {
|
|
64
|
+
relatedElements: [''],
|
|
65
|
+
});
|
|
62
66
|
}
|
|
63
67
|
get rippleElement() {
|
|
64
68
|
return this.rippleRef.value;
|
|
@@ -68,15 +72,15 @@ export let Fab = class Fab extends ButtonBase {
|
|
|
68
72
|
*/
|
|
69
73
|
async onExtendedChange() {
|
|
70
74
|
const hasUpdated = this.hasUpdated;
|
|
71
|
-
if (
|
|
72
|
-
this.style.width =
|
|
75
|
+
if (this.extended) {
|
|
76
|
+
this.style.width = `${this.scrollWidth}px`;
|
|
73
77
|
}
|
|
74
78
|
else {
|
|
75
|
-
this.style.width =
|
|
79
|
+
this.style.width = '';
|
|
76
80
|
}
|
|
81
|
+
await this.definedController.whenDefined();
|
|
77
82
|
await this.updateComplete;
|
|
78
83
|
if (this.extended && !hasUpdated) {
|
|
79
|
-
await delay();
|
|
80
84
|
this.style.width = `${this.scrollWidth}px`;
|
|
81
85
|
}
|
|
82
86
|
if (!hasUpdated) {
|
|
@@ -142,3 +146,4 @@ __decorate([
|
|
|
142
146
|
Fab = __decorate([
|
|
143
147
|
customElement('mdui-fab')
|
|
144
148
|
], Fab);
|
|
149
|
+
export { Fab };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { TemplateResult, CSSResultGroup } from 'lit';
|
|
3
3
|
/**
|
|
4
4
|
* @summary 图标组件
|
|
@@ -9,7 +9,7 @@ import type { TemplateResult, CSSResultGroup } from 'lit';
|
|
|
9
9
|
*
|
|
10
10
|
* @slot - `svg` 图标的内容
|
|
11
11
|
*/
|
|
12
|
-
export declare class Icon extends
|
|
12
|
+
export declare class Icon extends MduiElement<IconEventMap> {
|
|
13
13
|
static styles: CSSResultGroup;
|
|
14
14
|
/**
|
|
15
15
|
* Material Icons 图标名
|
|
@@ -22,6 +22,8 @@ export declare class Icon extends LitElement {
|
|
|
22
22
|
private readonly hasSlotController;
|
|
23
23
|
protected render(): TemplateResult;
|
|
24
24
|
}
|
|
25
|
+
export interface IconEventMap {
|
|
26
|
+
}
|
|
25
27
|
declare global {
|
|
26
28
|
interface HTMLElementTagNameMap {
|
|
27
29
|
'mdui-icon': Icon;
|
package/components/icon/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
5
5
|
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
|
6
6
|
import { until } from 'lit/directives/until.js';
|
|
7
7
|
import { ajax } from '@mdui/jq/functions/ajax.js';
|
|
8
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
8
9
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
9
10
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
10
11
|
import { style } from './style.js';
|
|
@@ -17,7 +18,7 @@ import { style } from './style.js';
|
|
|
17
18
|
*
|
|
18
19
|
* @slot - `svg` 图标的内容
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
let Icon = class Icon extends MduiElement {
|
|
21
22
|
constructor() {
|
|
22
23
|
super(...arguments);
|
|
23
24
|
this.hasSlotController = new HasSlotController(this, '[default]');
|
|
@@ -55,3 +56,4 @@ __decorate([
|
|
|
55
56
|
Icon = __decorate([
|
|
56
57
|
customElement('mdui-icon')
|
|
57
58
|
], Icon);
|
|
59
|
+
export { Icon };
|
|
@@ -6,11 +6,9 @@ import type { LayoutMain } from './layout-main.js';
|
|
|
6
6
|
import type { Layout } from './layout.js';
|
|
7
7
|
export type LayoutPlacement = 'top' | 'left' | 'right' | 'bottom';
|
|
8
8
|
export declare class LayoutManager {
|
|
9
|
-
private $layout;
|
|
10
9
|
private $main?;
|
|
11
10
|
private states;
|
|
12
11
|
private items?;
|
|
13
|
-
constructor(element: Layout);
|
|
14
12
|
/**
|
|
15
13
|
* 注册 `<mdui-layout-main>`
|
|
16
14
|
*/
|
|
@@ -39,10 +37,6 @@ export declare class LayoutManager {
|
|
|
39
37
|
* 获取 `<mdui-layout-item>` 及 `<mdui-layout-main>` 元素
|
|
40
38
|
*/
|
|
41
39
|
getItemsAndMain(): (LayoutItemBase | LayoutMain)[];
|
|
42
|
-
/**
|
|
43
|
-
* 检查指定 `<mdui-layout-item>` 元素是否已注册
|
|
44
|
-
*/
|
|
45
|
-
hasItem(element: LayoutItemBase): boolean;
|
|
46
40
|
/**
|
|
47
41
|
* 更新 `order` 值,更新完后重新计算布局
|
|
48
42
|
*/
|
|
@@ -60,6 +54,11 @@ export declare class LayoutManager {
|
|
|
60
54
|
* 按 order 排序,order 相同时,按在 DOM 中的顺序排序
|
|
61
55
|
*/
|
|
62
56
|
private resort;
|
|
57
|
+
/**
|
|
58
|
+
* 组件宽度是否为 0
|
|
59
|
+
* mdui-navigation-drawer 较为特殊,在为模态化时,占据的宽度为 0
|
|
60
|
+
*/
|
|
61
|
+
private isNoWidth;
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
64
|
* 获取 layout 实例
|
|
@@ -5,9 +5,8 @@ import '@mdui/jq/methods/get.js';
|
|
|
5
5
|
import { isNodeName } from '@mdui/jq/shared/helper.js';
|
|
6
6
|
import { observeResize } from '@mdui/shared/helpers/observeResize.js';
|
|
7
7
|
export class LayoutManager {
|
|
8
|
-
constructor(
|
|
8
|
+
constructor() {
|
|
9
9
|
this.states = [];
|
|
10
|
-
this.$layout = $(element);
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
12
|
* 注册 `<mdui-layout-main>`
|
|
@@ -29,15 +28,9 @@ export class LayoutManager {
|
|
|
29
28
|
this.states.push(state);
|
|
30
29
|
// 监听元素尺寸变化
|
|
31
30
|
state.observeResize = observeResize(state.element, () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
state.element.isModal) {
|
|
36
|
-
this.updateLayout(state.element, { width: 0 });
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
this.updateLayout(state.element);
|
|
40
|
-
}
|
|
31
|
+
this.updateLayout(state.element, {
|
|
32
|
+
width: this.isNoWidth(state) ? 0 : undefined,
|
|
33
|
+
});
|
|
41
34
|
});
|
|
42
35
|
this.items = undefined;
|
|
43
36
|
this.resort();
|
|
@@ -48,14 +41,13 @@ export class LayoutManager {
|
|
|
48
41
|
* 取消注册 `<mdui-layout-item>`
|
|
49
42
|
*/
|
|
50
43
|
unregisterItem(element) {
|
|
51
|
-
var _a;
|
|
52
44
|
const index = this.states.findIndex((item) => item.element === element);
|
|
53
45
|
if (index < 0) {
|
|
54
46
|
return;
|
|
55
47
|
}
|
|
56
48
|
// 取消监听尺寸变化
|
|
57
49
|
const item = this.states[index];
|
|
58
|
-
|
|
50
|
+
item.observeResize?.unobserve();
|
|
59
51
|
this.items = undefined;
|
|
60
52
|
// 移除一个元素,并从下一个元素开始更新
|
|
61
53
|
this.states.splice(index, 1);
|
|
@@ -68,16 +60,19 @@ export class LayoutManager {
|
|
|
68
60
|
*/
|
|
69
61
|
getItems() {
|
|
70
62
|
if (!this.items) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
63
|
+
const items = this.states.map((state) => state.element);
|
|
64
|
+
this.items = items.sort((a, b) => {
|
|
65
|
+
const position = a.compareDocumentPosition(b);
|
|
66
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
67
|
+
return -1;
|
|
68
|
+
}
|
|
69
|
+
else if (position & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
70
|
+
return 1;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
81
76
|
}
|
|
82
77
|
return this.items;
|
|
83
78
|
}
|
|
@@ -93,12 +88,6 @@ export class LayoutManager {
|
|
|
93
88
|
getItemsAndMain() {
|
|
94
89
|
return [...this.getItems(), this.getMain()].filter((i) => i);
|
|
95
90
|
}
|
|
96
|
-
/**
|
|
97
|
-
* 检查指定 `<mdui-layout-item>` 元素是否已注册
|
|
98
|
-
*/
|
|
99
|
-
hasItem(element) {
|
|
100
|
-
return this.getItems().includes(element);
|
|
101
|
-
}
|
|
102
91
|
/**
|
|
103
92
|
* 更新 `order` 值,更新完后重新计算布局
|
|
104
93
|
*/
|
|
@@ -115,8 +104,8 @@ export class LayoutManager {
|
|
|
115
104
|
const state = element
|
|
116
105
|
? {
|
|
117
106
|
element,
|
|
118
|
-
width: size
|
|
119
|
-
height: size
|
|
107
|
+
width: size?.width,
|
|
108
|
+
height: size?.height,
|
|
120
109
|
}
|
|
121
110
|
: undefined;
|
|
122
111
|
const index = state
|
|
@@ -127,7 +116,6 @@ export class LayoutManager {
|
|
|
127
116
|
}
|
|
128
117
|
Object.assign(this.states[index], state);
|
|
129
118
|
this.states.forEach((currState, currIndex) => {
|
|
130
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
131
119
|
if (currIndex < index) {
|
|
132
120
|
return;
|
|
133
121
|
}
|
|
@@ -135,24 +123,22 @@ export class LayoutManager {
|
|
|
135
123
|
const placement = currState.element.layoutPlacement;
|
|
136
124
|
// 前一个元素
|
|
137
125
|
const prevState = currIndex > 0 ? this.states[currIndex - 1] : undefined;
|
|
138
|
-
const top =
|
|
139
|
-
const right =
|
|
140
|
-
const bottom =
|
|
141
|
-
const left =
|
|
126
|
+
const top = prevState?.top ?? 0;
|
|
127
|
+
const right = prevState?.right ?? 0;
|
|
128
|
+
const bottom = prevState?.bottom ?? 0;
|
|
129
|
+
const left = prevState?.left ?? 0;
|
|
142
130
|
Object.assign(currState, { top, right, bottom, left });
|
|
143
131
|
switch (placement) {
|
|
144
132
|
case 'top':
|
|
145
|
-
currState.top += (_e = currState.height) !== null && _e !== void 0 ? _e : currState.element.offsetHeight;
|
|
146
|
-
break;
|
|
147
|
-
case 'right':
|
|
148
|
-
currState.right += (_f = currState.width) !== null && _f !== void 0 ? _f : currState.element.offsetWidth;
|
|
149
|
-
break;
|
|
150
133
|
case 'bottom':
|
|
151
|
-
currState
|
|
152
|
-
|
|
134
|
+
currState[placement] +=
|
|
135
|
+
currState.height ?? currState.element.offsetHeight;
|
|
153
136
|
break;
|
|
137
|
+
case 'right':
|
|
154
138
|
case 'left':
|
|
155
|
-
currState
|
|
139
|
+
currState[placement] +=
|
|
140
|
+
(this.isNoWidth(currState) ? 0 : currState.width) ??
|
|
141
|
+
currState.element.offsetWidth;
|
|
156
142
|
break;
|
|
157
143
|
}
|
|
158
144
|
currState.height = currState.width = undefined;
|
|
@@ -181,9 +167,8 @@ export class LayoutManager {
|
|
|
181
167
|
resort() {
|
|
182
168
|
const items = this.getItems();
|
|
183
169
|
this.states.sort((a, b) => {
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
const bOrder = (_b = b.element.order) !== null && _b !== void 0 ? _b : 0;
|
|
170
|
+
const aOrder = a.element.order ?? 0;
|
|
171
|
+
const bOrder = b.element.order ?? 0;
|
|
187
172
|
if (aOrder > bOrder) {
|
|
188
173
|
return 1;
|
|
189
174
|
}
|
|
@@ -199,6 +184,15 @@ export class LayoutManager {
|
|
|
199
184
|
return 0;
|
|
200
185
|
});
|
|
201
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* 组件宽度是否为 0
|
|
189
|
+
* mdui-navigation-drawer 较为特殊,在为模态化时,占据的宽度为 0
|
|
190
|
+
*/
|
|
191
|
+
isNoWidth(state) {
|
|
192
|
+
return (isNodeName(state.element, 'mdui-navigation-drawer') &&
|
|
193
|
+
// @ts-ignore
|
|
194
|
+
state.element.isModal);
|
|
195
|
+
}
|
|
202
196
|
}
|
|
203
197
|
const layoutManagerMap = new WeakMap();
|
|
204
198
|
/**
|
|
@@ -206,7 +200,7 @@ const layoutManagerMap = new WeakMap();
|
|
|
206
200
|
*/
|
|
207
201
|
export const getLayout = (element) => {
|
|
208
202
|
if (!layoutManagerMap.has(element)) {
|
|
209
|
-
layoutManagerMap.set(element, new LayoutManager(
|
|
203
|
+
layoutManagerMap.set(element, new LayoutManager());
|
|
210
204
|
}
|
|
211
205
|
return layoutManagerMap.get(element);
|
|
212
206
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { LayoutManager, LayoutPlacement } from './helper.js';
|
|
3
|
-
|
|
3
|
+
import type { PlainObject } from '@mdui/jq/shared/helper.js';
|
|
4
|
+
export declare class LayoutItemBase<E = PlainObject> extends MduiElement<E> {
|
|
4
5
|
/**
|
|
5
6
|
* 该组件在 [`<mdui-layout>`](/docs/2/components/layout) 中的布局顺序,按从小到大排序。默认为 `0`
|
|
6
7
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { LitElement } from 'lit';
|
|
3
2
|
import { property } from 'lit/decorators.js';
|
|
4
3
|
import { isNodeName } from '@mdui/jq/shared/helper.js';
|
|
4
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
5
5
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
6
6
|
import { getLayout } from './helper.js';
|
|
7
|
-
export class LayoutItemBase extends
|
|
7
|
+
export class LayoutItemBase extends MduiElement {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
10
|
// 父元素是否是 `mdui-layout`
|
|
@@ -18,8 +18,7 @@ export class LayoutItemBase extends LitElement {
|
|
|
18
18
|
}
|
|
19
19
|
// order 变更时,需要重新调整布局
|
|
20
20
|
onOrderChange() {
|
|
21
|
-
|
|
22
|
-
(_a = this.layoutManager) === null || _a === void 0 ? void 0 : _a.updateOrder();
|
|
21
|
+
this.layoutManager?.updateOrder();
|
|
23
22
|
}
|
|
24
23
|
connectedCallback() {
|
|
25
24
|
super.connectedCallback();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { CSSResultGroup } from 'lit';
|
|
2
1
|
import { LayoutItemBase } from './layout-item-base.js';
|
|
3
2
|
import type { LayoutPlacement } from './helper.js';
|
|
4
|
-
import type { TemplateResult } from 'lit';
|
|
3
|
+
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
5
4
|
/**
|
|
6
5
|
* @summary 布局项组件
|
|
7
6
|
*
|
|
@@ -15,7 +14,7 @@ import type { TemplateResult } from 'lit';
|
|
|
15
14
|
*
|
|
16
15
|
* @slot - 可以是任意内容
|
|
17
16
|
*/
|
|
18
|
-
export declare class LayoutItem extends LayoutItemBase {
|
|
17
|
+
export declare class LayoutItem extends LayoutItemBase<LayoutItemEventMap> {
|
|
19
18
|
static styles: CSSResultGroup;
|
|
20
19
|
/**
|
|
21
20
|
* 该组件所处位置。可选值为:
|
|
@@ -30,6 +29,8 @@ export declare class LayoutItem extends LayoutItemBase {
|
|
|
30
29
|
private onPlacementChange;
|
|
31
30
|
protected render(): TemplateResult;
|
|
32
31
|
}
|
|
32
|
+
export interface LayoutItemEventMap {
|
|
33
|
+
}
|
|
33
34
|
declare global {
|
|
34
35
|
interface HTMLElementTagNameMap {
|
|
35
36
|
'mdui-layout-item': LayoutItem;
|
|
@@ -18,7 +18,7 @@ import { layoutItemStyle } from './layout-item-style.js';
|
|
|
18
18
|
*
|
|
19
19
|
* @slot - 可以是任意内容
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
let LayoutItem = class LayoutItem extends LayoutItemBase {
|
|
22
22
|
constructor() {
|
|
23
23
|
super(...arguments);
|
|
24
24
|
/**
|
|
@@ -36,8 +36,7 @@ export let LayoutItem = class LayoutItem extends LayoutItemBase {
|
|
|
36
36
|
}
|
|
37
37
|
// placement 变更时,需要重新调整布局
|
|
38
38
|
onPlacementChange() {
|
|
39
|
-
|
|
40
|
-
(_a = this.layoutManager) === null || _a === void 0 ? void 0 : _a.updateLayout(this);
|
|
39
|
+
this.layoutManager?.updateLayout(this);
|
|
41
40
|
}
|
|
42
41
|
render() {
|
|
43
42
|
return html `<slot></slot>`;
|
|
@@ -56,3 +55,4 @@ __decorate([
|
|
|
56
55
|
LayoutItem = __decorate([
|
|
57
56
|
customElement('mdui-layout-item')
|
|
58
57
|
], LayoutItem);
|
|
58
|
+
export { LayoutItem };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
3
3
|
/**
|
|
4
4
|
* @summary 布局主内容组件
|
|
@@ -13,13 +13,15 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
13
13
|
*
|
|
14
14
|
* @slot - 可以是任意内容
|
|
15
15
|
*/
|
|
16
|
-
export declare class LayoutMain extends
|
|
16
|
+
export declare class LayoutMain extends MduiElement<LayoutMainEventMap> {
|
|
17
17
|
static styles: CSSResultGroup;
|
|
18
18
|
private layoutManager?;
|
|
19
19
|
connectedCallback(): void;
|
|
20
20
|
disconnectedCallback(): void;
|
|
21
21
|
protected render(): TemplateResult;
|
|
22
22
|
}
|
|
23
|
+
export interface LayoutMainEventMap {
|
|
24
|
+
}
|
|
23
25
|
declare global {
|
|
24
26
|
interface HTMLElementTagNameMap {
|
|
25
27
|
'mdui-layout-main': LayoutMain;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
4
|
import { isNodeName } from '@mdui/jq/shared/helper.js';
|
|
5
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
5
6
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
6
7
|
import { getLayout } from './helper.js';
|
|
7
8
|
import { layoutMainStyle } from './layout-main-style.js';
|
|
@@ -18,7 +19,7 @@ import { layoutMainStyle } from './layout-main-style.js';
|
|
|
18
19
|
*
|
|
19
20
|
* @slot - 可以是任意内容
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
let LayoutMain = class LayoutMain extends MduiElement {
|
|
22
23
|
connectedCallback() {
|
|
23
24
|
super.connectedCallback();
|
|
24
25
|
const parentElement = this.parentElement;
|
|
@@ -44,3 +45,4 @@ LayoutMain.styles = [
|
|
|
44
45
|
LayoutMain = __decorate([
|
|
45
46
|
customElement('mdui-layout-main')
|
|
46
47
|
], LayoutMain);
|
|
48
|
+
export { LayoutMain };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
3
3
|
/**
|
|
4
4
|
* @summary 布局组件
|
|
@@ -13,7 +13,7 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
13
13
|
*
|
|
14
14
|
* @slot - 可以是 [`<mdui-top-app-bar>`](/docs/2/components/top-app-bar)、[`<mdui-bottom-app-bar>`](/docs/2/components/bottom-app-bar)、[`<mdui-navigation-bar>`](/docs/2/components/navigation-bar)、[`<mdui-navigation-drawer>`](/docs/2/components/navigation-drawer)、[`<mdui-navigation-rail>`](/docs/2/components/navigation-rail)、`<mdui-layout-item>`、`<mdui-layout-main>` 元素
|
|
15
15
|
*/
|
|
16
|
-
export declare class Layout extends
|
|
16
|
+
export declare class Layout extends MduiElement<LayoutEventMap> {
|
|
17
17
|
static styles: CSSResultGroup;
|
|
18
18
|
/**
|
|
19
19
|
* 把当前布局的高度设为 100%
|
|
@@ -21,6 +21,8 @@ export declare class Layout extends LitElement {
|
|
|
21
21
|
fullHeight: boolean;
|
|
22
22
|
protected render(): TemplateResult;
|
|
23
23
|
}
|
|
24
|
+
export interface LayoutEventMap {
|
|
25
|
+
}
|
|
24
26
|
declare global {
|
|
25
27
|
interface HTMLElementTagNameMap {
|
|
26
28
|
'mdui-layout': Layout;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
4
5
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
5
6
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
6
7
|
import { layoutStyle } from './layout-style.js';
|
|
@@ -17,7 +18,7 @@ import { layoutStyle } from './layout-style.js';
|
|
|
17
18
|
*
|
|
18
19
|
* @slot - 可以是 [`<mdui-top-app-bar>`](/docs/2/components/top-app-bar)、[`<mdui-bottom-app-bar>`](/docs/2/components/bottom-app-bar)、[`<mdui-navigation-bar>`](/docs/2/components/navigation-bar)、[`<mdui-navigation-drawer>`](/docs/2/components/navigation-drawer)、[`<mdui-navigation-rail>`](/docs/2/components/navigation-rail)、`<mdui-layout-item>`、`<mdui-layout-main>` 元素
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
let Layout = class Layout extends MduiElement {
|
|
21
22
|
constructor() {
|
|
22
23
|
super(...arguments);
|
|
23
24
|
/**
|
|
@@ -41,3 +42,4 @@ __decorate([
|
|
|
41
42
|
Layout = __decorate([
|
|
42
43
|
customElement('mdui-layout')
|
|
43
44
|
], Layout);
|
|
45
|
+
export { Layout };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
3
3
|
/**
|
|
4
4
|
* @summary 线性进度指示器组件
|
|
@@ -11,7 +11,7 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
11
11
|
*
|
|
12
12
|
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
13
13
|
*/
|
|
14
|
-
export declare class LinearProgress extends
|
|
14
|
+
export declare class LinearProgress extends MduiElement<LinearProgressEventMap> {
|
|
15
15
|
static styles: CSSResultGroup;
|
|
16
16
|
/**
|
|
17
17
|
* 进度指示器的最大值,默认为 1
|
|
@@ -23,6 +23,8 @@ export declare class LinearProgress extends LitElement {
|
|
|
23
23
|
value?: number;
|
|
24
24
|
protected render(): TemplateResult;
|
|
25
25
|
}
|
|
26
|
+
export interface LinearProgressEventMap {
|
|
27
|
+
}
|
|
26
28
|
declare global {
|
|
27
29
|
interface HTMLElementTagNameMap {
|
|
28
30
|
'mdui-linear-progress': LinearProgress;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
5
5
|
import { isUndefined } from '@mdui/jq/shared/helper.js';
|
|
6
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
6
7
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
7
8
|
import { style } from './style.js';
|
|
8
9
|
/**
|
|
@@ -16,7 +17,7 @@ import { style } from './style.js';
|
|
|
16
17
|
*
|
|
17
18
|
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
let LinearProgress = class LinearProgress extends MduiElement {
|
|
20
21
|
constructor() {
|
|
21
22
|
super(...arguments);
|
|
22
23
|
/**
|
|
@@ -25,12 +26,11 @@ export let LinearProgress = class LinearProgress extends LitElement {
|
|
|
25
26
|
this.max = 1;
|
|
26
27
|
}
|
|
27
28
|
render() {
|
|
28
|
-
var _a;
|
|
29
29
|
const isDeterminate = !isUndefined(this.value);
|
|
30
30
|
if (isDeterminate) {
|
|
31
31
|
const value = this.value;
|
|
32
32
|
return html `<div part="indicator" class="determinate" style="${styleMap({
|
|
33
|
-
width: `${(value / Math.max(
|
|
33
|
+
width: `${(value / Math.max(this.max ?? value, value)) * 100}%`,
|
|
34
34
|
})}"></div>`;
|
|
35
35
|
}
|
|
36
36
|
return html `<div part="indicator" class="indeterminate"></div>`;
|
|
@@ -46,3 +46,4 @@ __decorate([
|
|
|
46
46
|
LinearProgress = __decorate([
|
|
47
47
|
customElement('mdui-linear-progress')
|
|
48
48
|
], LinearProgress);
|
|
49
|
+
export { LinearProgress };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
2
|
export const listItemStyle = css `:host{--shape-corner:var(--mdui-shape-corner-none);--shape-corner-rounded:var(--mdui-shape-corner-extra-large);position:relative;display:block;border-radius:var(--shape-corner);--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}:host([rounded]),:host([rounded]) mdui-ripple{border-radius:var(--shape-corner-rounded)}:host([active]){background-color:rgb(var(--mdui-color-secondary-container));--mdui-comp-ripple-state-layer-color:var(
|
|
3
3
|
--mdui-color-on-secondary-container
|
|
4
|
-
)}:host([disabled]){pointer-events:none}.container{cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}:host([disabled]) .container{cursor:default;opacity:.38}:host([nonclickable]:not([href])) .container{cursor:auto;-webkit-user-select:auto;user-select:auto}.preset{display:flex;align-items:center;
|
|
4
|
+
)}:host([disabled]){pointer-events:none}.container{cursor:pointer;-webkit-user-select:none;user-select:none;text-decoration:none;color:inherit;-webkit-tap-highlight-color:transparent}:host([disabled]) .container{cursor:default;opacity:.38}:host([nonclickable]:not([href])) .container{cursor:auto;-webkit-user-select:auto;user-select:auto}.preset{display:flex;align-items:center;padding:.5rem 1.5rem .5rem 1rem;min-height:3.5rem}:host([alignment=start]) .preset{align-items:flex-start}:host([alignment=end]) .preset{align-items:flex-end}.body{display:flex;flex:1 1 100%;flex-direction:column;justify-content:center;min-width:0}.headline{display:block;color:rgb(var(--mdui-color-on-surface));font-size:var(--mdui-typescale-body-large-size);font-weight:var(--mdui-typescale-body-large-weight);letter-spacing:var(--mdui-typescale-body-large-tracking);line-height:var(--mdui-typescale-body-large-line-height)}:host([active]) .headline{color:rgb(var(--mdui-color-on-secondary-container))}.description{display:none;color:rgb(var(--mdui-color-on-surface-variant));font-size:var(--mdui-typescale-body-medium-size);font-weight:var(--mdui-typescale-body-medium-weight);letter-spacing:var(--mdui-typescale-body-medium-tracking);line-height:var(--mdui-typescale-body-medium-line-height)}:host([disabled]) .description,:host([focused]) .description,:host([hover]) .description,:host([pressed]) .description{color:rgb(var(--mdui-color-on-surface))}.has-description .description{display:block}:host([description-line='1']) .description,:host([headline-line='1']) .headline{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([description-line='2']) .description,:host([description-line='3']) .description,:host([headline-line='2']) .headline,:host([headline-line='3']) .headline{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}:host([description-line='2']) .description,:host([headline-line='2']) .headline{-webkit-line-clamp:2}:host([description-line='3']) .description,:host([headline-line='3']) .headline{-webkit-line-clamp:3}.end-icon,.icon{display:flex;flex:0 0 auto;font-size:var(--mdui-typescale-label-small-size);font-weight:var(--mdui-typescale-label-small-weight);letter-spacing:var(--mdui-typescale-label-small-tracking);line-height:var(--mdui-typescale-label-small-line-height);color:rgb(var(--mdui-color-on-surface-variant))}:host([disabled]) .end-icon,:host([disabled]) .icon,:host([focused]) .end-icon,:host([focused]) .icon,:host([hover]) .end-icon,:host([hover]) .icon,:host([pressed]) .end-icon,:host([pressed]) .icon{color:rgb(var(--mdui-color-on-surface))}:host([active]) .end-icon,:host([active]) .icon{color:rgb(var(--mdui-color-on-secondary-container))}.end-icon mdui-icon,.icon mdui-icon,.is-end-icon ::slotted([slot=end-icon]),.is-icon ::slotted([slot=icon]){font-size:1.5rem}.has-icon .icon{margin-right:1rem}.has-icon ::slotted(mdui-checkbox[slot=icon]),.has-icon ::slotted(mdui-radio[slot=icon]){margin-left:-.5rem}.has-end-icon .end-icon{margin-left:1rem}.has-end-icon ::slotted(mdui-checkbox[slot=end-icon]),.has-end-icon ::slotted(mdui-radio[slot=end-icon]){margin-right:-.5rem}`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import '../icon.js';
|
|
3
3
|
import type { Ripple } from '../ripple/index.js';
|
|
4
4
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
5
|
-
declare const ListItem_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/anchor.js").AnchorMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof
|
|
5
|
+
declare const ListItem_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/anchor.js").AnchorMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
6
6
|
/**
|
|
7
7
|
* @summary 列表项组件。需与 `<mdui-list>` 组件配合使用
|
|
8
8
|
*
|
|
@@ -33,7 +33,7 @@ declare const ListItem_base: import("@open-wc/dedupe-mixin").Constructor<import(
|
|
|
33
33
|
* @cssprop --shape-corner - 列表项的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
34
34
|
* @cssprop --shape-corner-rounded - 指定了 `rounded` 时,列表项的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
35
35
|
*/
|
|
36
|
-
export declare class ListItem extends ListItem_base {
|
|
36
|
+
export declare class ListItem extends ListItem_base<ListItemEventMap> {
|
|
37
37
|
static styles: CSSResultGroup;
|
|
38
38
|
/**
|
|
39
39
|
* 主文本。也可以通过 default slot 设置
|
|
@@ -103,6 +103,10 @@ export declare class ListItem extends ListItem_base {
|
|
|
103
103
|
protected render(): TemplateResult;
|
|
104
104
|
private renderInner;
|
|
105
105
|
}
|
|
106
|
+
export interface ListItemEventMap {
|
|
107
|
+
focus: FocusEvent;
|
|
108
|
+
blur: FocusEvent;
|
|
109
|
+
}
|
|
106
110
|
declare global {
|
|
107
111
|
interface HTMLElementTagNameMap {
|
|
108
112
|
'mdui-list-item': ListItem;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property, queryAssignedElements, } from 'lit/decorators.js';
|
|
4
4
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
5
5
|
import cc from 'classcat';
|
|
6
6
|
import { isNodeName, getNodeName } from '@mdui/jq/shared/helper.js';
|
|
7
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
7
8
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
8
9
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
9
10
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
@@ -43,7 +44,7 @@ import { listItemStyle } from './list-item-style.js';
|
|
|
43
44
|
* @cssprop --shape-corner - 列表项的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
44
45
|
* @cssprop --shape-corner-rounded - 指定了 `rounded` 时,列表项的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
let ListItem = class ListItem extends AnchorMixin(RippleMixin(FocusableMixin(MduiElement))) {
|
|
47
48
|
constructor() {
|
|
48
49
|
super(...arguments);
|
|
49
50
|
/**
|
|
@@ -81,7 +82,7 @@ export let ListItem = class ListItem extends AnchorMixin(RippleMixin(FocusableMi
|
|
|
81
82
|
return this.focusDisabled;
|
|
82
83
|
}
|
|
83
84
|
get focusElement() {
|
|
84
|
-
return this.href ? this.itemRef.value : this;
|
|
85
|
+
return this.href && !this.disabled ? this.itemRef.value : this;
|
|
85
86
|
}
|
|
86
87
|
get focusDisabled() {
|
|
87
88
|
return this.href ? this.disabled : this.disabled || this.nonclickable;
|
|
@@ -184,3 +185,4 @@ __decorate([
|
|
|
184
185
|
ListItem = __decorate([
|
|
185
186
|
customElement('mdui-list-item')
|
|
186
187
|
], ListItem);
|
|
188
|
+
export { ListItem };
|