mdui 2.0.2 → 2.0.4
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/components/avatar/index.d.ts +17 -15
- package/components/avatar/index.js +7 -6
- package/components/badge/index.d.ts +11 -8
- package/components/badge/index.js +9 -7
- package/components/bottom-app-bar/index.d.ts +11 -4
- package/components/bottom-app-bar/index.js +8 -9
- package/components/button/button-base-style.js +1 -1
- package/components/button/button-base.d.ts +46 -47
- package/components/button/button-base.js +27 -25
- package/components/button/index.d.ts +19 -14
- package/components/button/index.js +12 -12
- package/components/button-icon/index.d.ts +15 -9
- package/components/button-icon/index.js +8 -9
- package/components/card/index.d.ts +15 -11
- package/components/card/index.js +10 -9
- package/components/checkbox/index.d.ts +30 -23
- package/components/checkbox/index.js +25 -25
- package/components/chip/index.d.ts +27 -20
- package/components/chip/index.js +19 -20
- package/components/circular-progress/index.d.ts +6 -4
- package/components/circular-progress/index.js +4 -3
- package/components/collapse/collapse-item.d.ts +17 -6
- package/components/collapse/collapse-item.js +7 -7
- package/components/collapse/collapse.d.ts +16 -11
- package/components/collapse/collapse.js +10 -10
- package/components/dialog/index.d.ts +22 -15
- package/components/dialog/index.js +23 -27
- package/components/divider/index.d.ts +7 -5
- package/components/divider/index.js +6 -5
- package/components/dropdown/index.d.ts +44 -37
- package/components/dropdown/index.js +50 -48
- package/components/fab/index.d.ts +12 -7
- package/components/fab/index.js +6 -6
- package/components/icon/index.d.ts +4 -2
- package/components/icon/index.js +3 -2
- package/components/layout/layout-item-base.d.ts +3 -2
- package/components/layout/layout-item-base.js +2 -2
- package/components/layout/layout-item.d.ts +11 -10
- package/components/layout/layout-item.js +6 -6
- package/components/layout/layout-main.d.ts +6 -4
- package/components/layout/layout-main.js +5 -4
- package/components/layout/layout.d.ts +6 -4
- package/components/layout/layout.js +5 -4
- package/components/linear-progress/index.d.ts +8 -6
- package/components/linear-progress/index.js +6 -5
- package/components/list/list-item-style.js +1 -1
- package/components/list/list-item.d.ts +24 -20
- package/components/list/list-item.js +10 -9
- package/components/list/list-subheader.d.ts +6 -4
- package/components/list/list-subheader.js +5 -4
- package/components/list/list.d.ts +5 -3
- package/components/list/list.js +4 -3
- package/components/menu/menu-item.d.ts +15 -7
- package/components/menu/menu-item.js +11 -15
- package/components/menu/menu.d.ts +20 -20
- package/components/menu/menu.js +13 -13
- package/components/navigation-bar/navigation-bar-item.d.ts +12 -8
- package/components/navigation-bar/navigation-bar-item.js +7 -6
- package/components/navigation-bar/navigation-bar.d.ts +17 -9
- package/components/navigation-bar/navigation-bar.js +15 -13
- package/components/navigation-drawer/index.d.ts +27 -21
- package/components/navigation-drawer/index.js +51 -38
- package/components/navigation-drawer/style.js +1 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +13 -9
- package/components/navigation-rail/navigation-rail-item.js +7 -6
- package/components/navigation-rail/navigation-rail.d.ts +14 -12
- package/components/navigation-rail/navigation-rail.js +13 -12
- package/components/radio/radio-group.d.ts +20 -15
- package/components/radio/radio-group.js +21 -24
- package/components/radio/radio.d.ts +11 -6
- package/components/radio/radio.js +7 -7
- package/components/range-slider/index.d.ts +13 -8
- package/components/range-slider/index.js +10 -7
- package/components/ripple/index.d.ts +4 -2
- package/components/ripple/index.js +3 -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 +23 -22
- package/components/segmented-button/segmented-button-group.js +20 -23
- package/components/segmented-button/segmented-button.d.ts +9 -4
- package/components/segmented-button/segmented-button.js +3 -3
- package/components/select/index.d.ts +42 -35
- package/components/select/index.js +24 -25
- package/components/slider/index.d.ts +9 -2
- package/components/slider/index.js +5 -10
- package/components/slider/slider-base.d.ts +22 -18
- package/components/slider/slider-base.js +40 -21
- package/components/snackbar/index.d.ts +30 -23
- package/components/snackbar/index.js +25 -25
- package/components/switch/index.d.ts +24 -17
- package/components/switch/index.js +18 -18
- package/components/tabs/tab-panel.d.ts +7 -5
- package/components/tabs/tab-panel.js +5 -4
- package/components/tabs/tab.d.ts +13 -9
- package/components/tabs/tab.js +8 -7
- package/components/tabs/tabs.d.ts +24 -21
- package/components/tabs/tabs.js +24 -21
- package/components/text-field/index.d.ts +62 -54
- package/components/text-field/index.js +37 -37
- package/components/tooltip/index.d.ts +40 -33
- package/components/tooltip/index.js +45 -43
- package/components/top-app-bar/top-app-bar-title.d.ts +8 -6
- package/components/top-app-bar/top-app-bar-title.js +7 -6
- package/components/top-app-bar/top-app-bar.d.ts +12 -6
- package/components/top-app-bar/top-app-bar.js +9 -10
- package/css-data.en.json +2826 -0
- package/css-data.zh-cn.json +374 -367
- package/custom-elements.json +3844 -3824
- package/html-data.en.json +6551 -0
- package/html-data.zh-cn.json +1621 -1636
- package/jsx.en.d.ts +3303 -0
- package/jsx.zh-cn.d.ts +3351 -0
- package/mdui.esm.js +9 -9
- package/mdui.global.js +9 -9
- package/package.json +7 -5
- package/web-types.en.json +11718 -0
- package/web-types.zh-cn.json +3613 -3623
|
@@ -14,29 +14,29 @@ import type { TemplateResult, CSSResultGroup } from 'lit';
|
|
|
14
14
|
* @event invalid - 表单字段验证未通过时触发
|
|
15
15
|
*
|
|
16
16
|
* @slot - 按钮的文本
|
|
17
|
-
* @slot icon -
|
|
18
|
-
* @slot end-icon -
|
|
17
|
+
* @slot icon - 按钮左侧的元素
|
|
18
|
+
* @slot end-icon - 按钮右侧的元素
|
|
19
19
|
*
|
|
20
20
|
* @csspart button - 内部的 `<button>` 或 `<a>` 元素
|
|
21
|
-
* @csspart label -
|
|
22
|
-
* @csspart icon -
|
|
23
|
-
* @csspart end-icon -
|
|
21
|
+
* @csspart label - 按钮的文本
|
|
22
|
+
* @csspart icon - 按钮左侧的图标
|
|
23
|
+
* @csspart end-icon - 按钮右侧的图标
|
|
24
24
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
25
25
|
*
|
|
26
|
-
* @cssprop --shape-corner -
|
|
26
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
27
27
|
*/
|
|
28
|
-
export declare class Button extends ButtonBase {
|
|
28
|
+
export declare class Button extends ButtonBase<ButtonEventMap> {
|
|
29
29
|
static styles: CSSResultGroup;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* 按钮的形状。可选值包括:
|
|
32
32
|
*
|
|
33
|
-
* * `elevated
|
|
34
|
-
* * `filled
|
|
35
|
-
* * `tonal`:视觉效果介于 `filled` 和 `outlined`
|
|
36
|
-
* * `outlined
|
|
37
|
-
* * `text
|
|
33
|
+
* * `elevated`:带阴影的按钮,适用于需要将按钮与背景视觉分离的场景
|
|
34
|
+
* * `filled`:视觉效果强烈,适用于重要流程的最终操作,如“保存”、“确认”等
|
|
35
|
+
* * `tonal`:视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作,如流程中的“下一步”
|
|
36
|
+
* * `outlined`:带边框的按钮,适用于中等优先级,且次要的操作,如“返回”
|
|
37
|
+
* * `text`:文本按钮,适用于最低优先级的操作
|
|
38
38
|
*/
|
|
39
|
-
variant:
|
|
39
|
+
variant: /*带阴影的按钮,适用于需要将按钮与背景视觉分离的场景*/ 'elevated' | /*视觉效果强烈,适用于重要流程的最终操作,如“保存”、“确认”等*/ 'filled' | /*视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作,如流程中的“下一步”*/ 'tonal' | /*带边框的按钮,适用于中等优先级,且次要的操作,如“返回”*/ 'outlined' | /*文本按钮,适用于最低优先级的操作*/ 'text';
|
|
40
40
|
/**
|
|
41
41
|
* 是否填满父元素宽度
|
|
42
42
|
*/
|
|
@@ -57,6 +57,11 @@ export declare class Button extends ButtonBase {
|
|
|
57
57
|
private renderEndIcon;
|
|
58
58
|
private renderInner;
|
|
59
59
|
}
|
|
60
|
+
export interface ButtonEventMap {
|
|
61
|
+
focus: FocusEvent;
|
|
62
|
+
blur: FocusEvent;
|
|
63
|
+
invalid: CustomEvent<void>;
|
|
64
|
+
}
|
|
60
65
|
declare global {
|
|
61
66
|
interface HTMLElementTagNameMap {
|
|
62
67
|
'mdui-button': Button;
|
|
@@ -19,28 +19,28 @@ import { style } from './style.js';
|
|
|
19
19
|
* @event invalid - 表单字段验证未通过时触发
|
|
20
20
|
*
|
|
21
21
|
* @slot - 按钮的文本
|
|
22
|
-
* @slot icon -
|
|
23
|
-
* @slot end-icon -
|
|
22
|
+
* @slot icon - 按钮左侧的元素
|
|
23
|
+
* @slot end-icon - 按钮右侧的元素
|
|
24
24
|
*
|
|
25
25
|
* @csspart button - 内部的 `<button>` 或 `<a>` 元素
|
|
26
|
-
* @csspart label -
|
|
27
|
-
* @csspart icon -
|
|
28
|
-
* @csspart end-icon -
|
|
26
|
+
* @csspart label - 按钮的文本
|
|
27
|
+
* @csspart icon - 按钮左侧的图标
|
|
28
|
+
* @csspart end-icon - 按钮右侧的图标
|
|
29
29
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
30
30
|
*
|
|
31
|
-
* @cssprop --shape-corner -
|
|
31
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
32
32
|
*/
|
|
33
33
|
let Button = class Button extends ButtonBase {
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments);
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* 按钮的形状。可选值包括:
|
|
38
38
|
*
|
|
39
|
-
* * `elevated
|
|
40
|
-
* * `filled
|
|
41
|
-
* * `tonal`:视觉效果介于 `filled` 和 `outlined`
|
|
42
|
-
* * `outlined
|
|
43
|
-
* * `text
|
|
39
|
+
* * `elevated`:带阴影的按钮,适用于需要将按钮与背景视觉分离的场景
|
|
40
|
+
* * `filled`:视觉效果强烈,适用于重要流程的最终操作,如“保存”、“确认”等
|
|
41
|
+
* * `tonal`:视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作,如流程中的“下一步”
|
|
42
|
+
* * `outlined`:带边框的按钮,适用于中等优先级,且次要的操作,如“返回”
|
|
43
|
+
* * `text`:文本按钮,适用于最低优先级的操作
|
|
44
44
|
*/
|
|
45
45
|
this.variant = 'filled';
|
|
46
46
|
/**
|
|
@@ -22,19 +22,19 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
22
22
|
* @csspart selected-icon 选中状态的图标
|
|
23
23
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
24
24
|
*
|
|
25
|
-
* @cssprop --shape-corner -
|
|
25
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
26
26
|
*/
|
|
27
|
-
export declare class ButtonIcon extends ButtonBase {
|
|
27
|
+
export declare class ButtonIcon extends ButtonBase<ButtonIconEventMap> {
|
|
28
28
|
static styles: CSSResultGroup;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* 图标按钮的形状。可选值包括:
|
|
31
31
|
*
|
|
32
|
-
* * `standard
|
|
33
|
-
* * `filled
|
|
34
|
-
* * `tonal`:视觉效果介于 `filled` 和 `outlined`
|
|
35
|
-
* * `outlined
|
|
32
|
+
* * `standard`:适用于最低优先级的操作
|
|
33
|
+
* * `filled`:视觉效果强烈,适用于高优先级的操作
|
|
34
|
+
* * `tonal`:视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作
|
|
35
|
+
* * `outlined`:适用于中等优先级的操作
|
|
36
36
|
*/
|
|
37
|
-
variant:
|
|
37
|
+
variant: /*适用于最低优先级的操作*/ 'standard' | /*视觉效果强烈,适用于高优先级的操作*/ 'filled' | /*视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作*/ 'tonal' | /*适用于中等优先级的操作*/ 'outlined';
|
|
38
38
|
/**
|
|
39
39
|
* Material Icons 图标名。也可以通过 default slot 设置
|
|
40
40
|
*/
|
|
@@ -48,7 +48,7 @@ export declare class ButtonIcon extends ButtonBase {
|
|
|
48
48
|
*/
|
|
49
49
|
selectable: boolean;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* 是否已被选中
|
|
52
52
|
*/
|
|
53
53
|
selected: boolean;
|
|
54
54
|
private readonly rippleRef;
|
|
@@ -59,6 +59,12 @@ export declare class ButtonIcon extends ButtonBase {
|
|
|
59
59
|
protected render(): TemplateResult;
|
|
60
60
|
private renderIcon;
|
|
61
61
|
}
|
|
62
|
+
export interface ButtonIconEventMap {
|
|
63
|
+
focus: FocusEvent;
|
|
64
|
+
blur: FocusEvent;
|
|
65
|
+
change: CustomEvent<void>;
|
|
66
|
+
invalid: CustomEvent<void>;
|
|
67
|
+
}
|
|
62
68
|
declare global {
|
|
63
69
|
interface HTMLElementTagNameMap {
|
|
64
70
|
'mdui-button-icon': ButtonIcon;
|
|
@@ -5,7 +5,6 @@ import { createRef, ref } from 'lit/directives/ref.js';
|
|
|
5
5
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
6
6
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
7
7
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
8
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
9
8
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
10
9
|
import { ButtonBase } from '../button/button-base.js';
|
|
11
10
|
import '../icon.js';
|
|
@@ -30,18 +29,18 @@ import { style } from './style.js';
|
|
|
30
29
|
* @csspart selected-icon 选中状态的图标
|
|
31
30
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
32
31
|
*
|
|
33
|
-
* @cssprop --shape-corner -
|
|
32
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
34
33
|
*/
|
|
35
34
|
let ButtonIcon = class ButtonIcon extends ButtonBase {
|
|
36
35
|
constructor() {
|
|
37
36
|
super(...arguments);
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
38
|
+
* 图标按钮的形状。可选值包括:
|
|
40
39
|
*
|
|
41
|
-
* * `standard
|
|
42
|
-
* * `filled
|
|
43
|
-
* * `tonal`:视觉效果介于 `filled` 和 `outlined`
|
|
44
|
-
* * `outlined
|
|
40
|
+
* * `standard`:适用于最低优先级的操作
|
|
41
|
+
* * `filled`:视觉效果强烈,适用于高优先级的操作
|
|
42
|
+
* * `tonal`:视觉效果介于 `filled` 和 `outlined` 之间,适用于中高优先级的操作
|
|
43
|
+
* * `outlined`:适用于中等优先级的操作
|
|
45
44
|
*/
|
|
46
45
|
this.variant = 'standard';
|
|
47
46
|
/**
|
|
@@ -49,7 +48,7 @@ let ButtonIcon = class ButtonIcon extends ButtonBase {
|
|
|
49
48
|
*/
|
|
50
49
|
this.selectable = false;
|
|
51
50
|
/**
|
|
52
|
-
*
|
|
51
|
+
* 是否已被选中
|
|
53
52
|
*/
|
|
54
53
|
this.selected = false;
|
|
55
54
|
this.rippleRef = createRef();
|
|
@@ -59,7 +58,7 @@ let ButtonIcon = class ButtonIcon extends ButtonBase {
|
|
|
59
58
|
return this.rippleRef.value;
|
|
60
59
|
}
|
|
61
60
|
onSelectedChange() {
|
|
62
|
-
emit(
|
|
61
|
+
this.emit('change');
|
|
63
62
|
}
|
|
64
63
|
firstUpdated(changedProperties) {
|
|
65
64
|
super.firstUpdated(changedProperties);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { Ripple } from '../ripple/index.js';
|
|
3
3
|
import type { TemplateResult, CSSResultGroup } from 'lit';
|
|
4
|
-
declare const Card_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
|
|
4
|
+
declare const Card_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;
|
|
5
5
|
/**
|
|
6
6
|
* @summary 卡片组件
|
|
7
7
|
*
|
|
@@ -12,22 +12,22 @@ declare const Card_base: import("@open-wc/dedupe-mixin").Constructor<import("@md
|
|
|
12
12
|
* @event focus - 获得焦点时触发
|
|
13
13
|
* @event blur - 失去焦点时触发
|
|
14
14
|
*
|
|
15
|
-
* @slot -
|
|
15
|
+
* @slot - 卡片的内容
|
|
16
16
|
*
|
|
17
|
-
* @cssprop --shape-corner -
|
|
17
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
18
18
|
*/
|
|
19
|
-
export declare class Card extends Card_base {
|
|
19
|
+
export declare class Card extends Card_base<CardEventMap> {
|
|
20
20
|
static styles: CSSResultGroup;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* 卡片的形状。可选值包括:
|
|
23
23
|
*
|
|
24
|
-
* * `elevated
|
|
25
|
-
* * `filled
|
|
26
|
-
* * `outlined
|
|
24
|
+
* * `elevated`:带阴影的卡片,与背景的视觉分离度较高
|
|
25
|
+
* * `filled`:带填充色的卡片,与背景的视觉分离度较低
|
|
26
|
+
* * `outlined`:带边框的卡片,与背景的视觉分离度最高
|
|
27
27
|
*/
|
|
28
|
-
variant:
|
|
28
|
+
variant: /*带阴影的卡片,与背景的视觉分离度较高*/ 'elevated' | /*带填充色的卡片,与背景的视觉分离度较低*/ 'filled' | /*带边框的卡片,与背景的视觉分离度最高*/ 'outlined';
|
|
29
29
|
/**
|
|
30
|
-
* 是否可点击。为 `true`
|
|
30
|
+
* 是否可点击。为 `true` 时,卡片将具有鼠标悬浮效果和点击涟漪效果
|
|
31
31
|
*/
|
|
32
32
|
clickable: boolean;
|
|
33
33
|
/**
|
|
@@ -41,6 +41,10 @@ export declare class Card extends Card_base {
|
|
|
41
41
|
protected get focusDisabled(): boolean;
|
|
42
42
|
protected render(): TemplateResult;
|
|
43
43
|
}
|
|
44
|
+
export interface CardEventMap {
|
|
45
|
+
focus: FocusEvent;
|
|
46
|
+
blur: FocusEvent;
|
|
47
|
+
}
|
|
44
48
|
declare global {
|
|
45
49
|
interface HTMLElementTagNameMap {
|
|
46
50
|
'mdui-card': Card;
|
package/components/card/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
5
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
5
6
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
6
7
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
7
8
|
import { AnchorMixin } from '@mdui/shared/mixins/anchor.js';
|
|
@@ -18,23 +19,23 @@ import { style } from './style.js';
|
|
|
18
19
|
* @event focus - 获得焦点时触发
|
|
19
20
|
* @event blur - 失去焦点时触发
|
|
20
21
|
*
|
|
21
|
-
* @slot -
|
|
22
|
+
* @slot - 卡片的内容
|
|
22
23
|
*
|
|
23
|
-
* @cssprop --shape-corner -
|
|
24
|
+
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐引用[设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
24
25
|
*/
|
|
25
|
-
let Card = class Card extends AnchorMixin(RippleMixin(FocusableMixin(
|
|
26
|
+
let Card = class Card extends AnchorMixin(RippleMixin(FocusableMixin(MduiElement))) {
|
|
26
27
|
constructor() {
|
|
27
28
|
super(...arguments);
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
+
* 卡片的形状。可选值包括:
|
|
30
31
|
*
|
|
31
|
-
* * `elevated
|
|
32
|
-
* * `filled
|
|
33
|
-
* * `outlined
|
|
32
|
+
* * `elevated`:带阴影的卡片,与背景的视觉分离度较高
|
|
33
|
+
* * `filled`:带填充色的卡片,与背景的视觉分离度较低
|
|
34
|
+
* * `outlined`:带边框的卡片,与背景的视觉分离度最高
|
|
34
35
|
*/
|
|
35
36
|
this.variant = 'elevated';
|
|
36
37
|
/**
|
|
37
|
-
* 是否可点击。为 `true`
|
|
38
|
+
* 是否可点击。为 `true` 时,卡片将具有鼠标悬浮效果和点击涟漪效果
|
|
38
39
|
*/
|
|
39
40
|
this.clickable = false;
|
|
40
41
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import '@mdui/shared/icons/check-box-outline-blank.js';
|
|
3
3
|
import '@mdui/shared/icons/check-box.js';
|
|
4
4
|
import '@mdui/shared/icons/indeterminate-check-box.js';
|
|
@@ -6,7 +6,7 @@ import '../icon.js';
|
|
|
6
6
|
import type { Ripple } from '../ripple/index.js';
|
|
7
7
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
8
8
|
import type { TemplateResult, CSSResultGroup } from 'lit';
|
|
9
|
-
declare const Checkbox_base: 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
|
|
9
|
+
declare const Checkbox_base: 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;
|
|
10
10
|
/**
|
|
11
11
|
* @summary 复选框组件
|
|
12
12
|
*
|
|
@@ -20,18 +20,18 @@ declare const Checkbox_base: import("@open-wc/dedupe-mixin").Constructor<import(
|
|
|
20
20
|
* @event input - 选中状态变更时触发
|
|
21
21
|
* @event invalid - 表单字段验证未通过时触发
|
|
22
22
|
*
|
|
23
|
-
* @slot -
|
|
24
|
-
* @slot unchecked-icon -
|
|
25
|
-
* @slot checked-icon -
|
|
26
|
-
* @slot indeterminate-icon -
|
|
23
|
+
* @slot - 复选框文本
|
|
24
|
+
* @slot unchecked-icon - 未选中状态的图标
|
|
25
|
+
* @slot checked-icon - 选中状态的图标
|
|
26
|
+
* @slot indeterminate-icon - 不确定状态的图标
|
|
27
27
|
*
|
|
28
28
|
* @csspart control - 左侧图标容器
|
|
29
|
-
* @csspart unchecked-icon -
|
|
30
|
-
* @csspart checked-icon -
|
|
31
|
-
* @csspart indeterminate-icon -
|
|
32
|
-
* @csspart label -
|
|
29
|
+
* @csspart unchecked-icon - 未选中状态的图标
|
|
30
|
+
* @csspart checked-icon - 选中状态的图标
|
|
31
|
+
* @csspart indeterminate-icon - 不确定状态的图标
|
|
32
|
+
* @csspart label - 复选框文本
|
|
33
33
|
*/
|
|
34
|
-
export declare class Checkbox extends Checkbox_base implements FormControl {
|
|
34
|
+
export declare class Checkbox extends Checkbox_base<CheckboxEventMap> implements FormControl {
|
|
35
35
|
static styles: CSSResultGroup;
|
|
36
36
|
/**
|
|
37
37
|
* 是否为禁用状态
|
|
@@ -42,21 +42,21 @@ export declare class Checkbox extends Checkbox_base implements FormControl {
|
|
|
42
42
|
*/
|
|
43
43
|
checked: boolean;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* 默认选中状态。在重置表单时,将恢复为此状态。此属性只能通过 JavaScript 属性设置
|
|
46
46
|
*/
|
|
47
47
|
defaultChecked: boolean;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* 是否处于不确定状态
|
|
50
50
|
*/
|
|
51
51
|
indeterminate: boolean;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* 提交表单时,是否必须选中此复选框
|
|
54
54
|
*/
|
|
55
55
|
required: boolean;
|
|
56
56
|
/**
|
|
57
|
-
* 关联的
|
|
57
|
+
* 关联的 `<form>` 元素。此属性值应为同一页面中的一个 `<form>` 元素的 `id`。
|
|
58
58
|
*
|
|
59
|
-
*
|
|
59
|
+
* 如果未指定此属性,则该元素必须是 `<form>` 元素的子元素。通过此属性,你可以将元素放置在页面的任何位置,而不仅仅是 `<form>` 元素的子元素。
|
|
60
60
|
*/
|
|
61
61
|
form?: string;
|
|
62
62
|
/**
|
|
@@ -87,11 +87,11 @@ export declare class Checkbox extends Checkbox_base implements FormControl {
|
|
|
87
87
|
private readonly rippleRef;
|
|
88
88
|
private readonly formController;
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
90
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
91
91
|
*/
|
|
92
92
|
get validity(): ValidityState;
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
94
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
95
95
|
*/
|
|
96
96
|
get validationMessage(): string;
|
|
97
97
|
protected get rippleElement(): Ripple;
|
|
@@ -101,19 +101,19 @@ export declare class Checkbox extends Checkbox_base implements FormControl {
|
|
|
101
101
|
private onDisabledChange;
|
|
102
102
|
private onCheckedChange;
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
105
105
|
*/
|
|
106
106
|
checkValidity(): boolean;
|
|
107
107
|
/**
|
|
108
|
-
*
|
|
108
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
109
109
|
*
|
|
110
|
-
*
|
|
110
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
111
111
|
*/
|
|
112
112
|
reportValidity(): boolean;
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
115
115
|
*
|
|
116
|
-
* @param message
|
|
116
|
+
* @param message 自定义的错误提示文本
|
|
117
117
|
*/
|
|
118
118
|
setCustomValidity(message: string): void;
|
|
119
119
|
protected render(): TemplateResult;
|
|
@@ -122,6 +122,13 @@ export declare class Checkbox extends Checkbox_base implements FormControl {
|
|
|
122
122
|
*/
|
|
123
123
|
private onChange;
|
|
124
124
|
}
|
|
125
|
+
export interface CheckboxEventMap {
|
|
126
|
+
focus: FocusEvent;
|
|
127
|
+
blur: FocusEvent;
|
|
128
|
+
change: CustomEvent<void>;
|
|
129
|
+
input: Event;
|
|
130
|
+
invalid: CustomEvent<void>;
|
|
131
|
+
}
|
|
125
132
|
declare global {
|
|
126
133
|
interface HTMLElementTagNameMap {
|
|
127
134
|
'mdui-checkbox': Checkbox;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
6
|
import { live } from 'lit/directives/live.js';
|
|
7
7
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
8
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
8
9
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
9
10
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
10
11
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
11
12
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
12
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
13
13
|
import '@mdui/shared/icons/check-box-outline-blank.js';
|
|
14
14
|
import '@mdui/shared/icons/check-box.js';
|
|
15
15
|
import '@mdui/shared/icons/indeterminate-check-box.js';
|
|
@@ -31,18 +31,18 @@ import { style } from './style.js';
|
|
|
31
31
|
* @event input - 选中状态变更时触发
|
|
32
32
|
* @event invalid - 表单字段验证未通过时触发
|
|
33
33
|
*
|
|
34
|
-
* @slot -
|
|
35
|
-
* @slot unchecked-icon -
|
|
36
|
-
* @slot checked-icon -
|
|
37
|
-
* @slot indeterminate-icon -
|
|
34
|
+
* @slot - 复选框文本
|
|
35
|
+
* @slot unchecked-icon - 未选中状态的图标
|
|
36
|
+
* @slot checked-icon - 选中状态的图标
|
|
37
|
+
* @slot indeterminate-icon - 不确定状态的图标
|
|
38
38
|
*
|
|
39
39
|
* @csspart control - 左侧图标容器
|
|
40
|
-
* @csspart unchecked-icon -
|
|
41
|
-
* @csspart checked-icon -
|
|
42
|
-
* @csspart indeterminate-icon -
|
|
43
|
-
* @csspart label -
|
|
40
|
+
* @csspart unchecked-icon - 未选中状态的图标
|
|
41
|
+
* @csspart checked-icon - 选中状态的图标
|
|
42
|
+
* @csspart indeterminate-icon - 不确定状态的图标
|
|
43
|
+
* @csspart label - 复选框文本
|
|
44
44
|
*/
|
|
45
|
-
let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(
|
|
45
|
+
let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
46
46
|
constructor() {
|
|
47
47
|
super(...arguments);
|
|
48
48
|
/**
|
|
@@ -54,15 +54,15 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
54
54
|
*/
|
|
55
55
|
this.checked = false;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* 默认选中状态。在重置表单时,将恢复为此状态。此属性只能通过 JavaScript 属性设置
|
|
58
58
|
*/
|
|
59
59
|
this.defaultChecked = false;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* 是否处于不确定状态
|
|
62
62
|
*/
|
|
63
63
|
this.indeterminate = false;
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* 提交表单时,是否必须选中此复选框
|
|
66
66
|
*/
|
|
67
67
|
this.required = false;
|
|
68
68
|
/**
|
|
@@ -86,13 +86,13 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
90
90
|
*/
|
|
91
91
|
get validity() {
|
|
92
92
|
return this.inputRef.value.validity;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
95
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
96
96
|
*/
|
|
97
97
|
get validationMessage() {
|
|
98
98
|
return this.inputRef.value.validationMessage;
|
|
@@ -126,12 +126,12 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
129
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
130
130
|
*/
|
|
131
131
|
checkValidity() {
|
|
132
132
|
const valid = this.inputRef.value.checkValidity();
|
|
133
133
|
if (!valid) {
|
|
134
|
-
emit(
|
|
134
|
+
this.emit('invalid', {
|
|
135
135
|
bubbles: false,
|
|
136
136
|
cancelable: true,
|
|
137
137
|
composed: false,
|
|
@@ -140,20 +140,20 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
140
140
|
return valid;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
143
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
144
144
|
*
|
|
145
|
-
*
|
|
145
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
146
146
|
*/
|
|
147
147
|
reportValidity() {
|
|
148
148
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
149
149
|
if (this.invalid) {
|
|
150
|
-
const
|
|
150
|
+
const eventProceeded = this.emit('invalid', {
|
|
151
151
|
bubbles: false,
|
|
152
152
|
cancelable: true,
|
|
153
153
|
composed: false,
|
|
154
154
|
});
|
|
155
155
|
// 调用了 preventDefault() 时,隐藏默认的表单错误提示
|
|
156
|
-
if (
|
|
156
|
+
if (!eventProceeded) {
|
|
157
157
|
this.blur();
|
|
158
158
|
this.focus();
|
|
159
159
|
}
|
|
@@ -161,9 +161,9 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
161
161
|
return !this.invalid;
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
164
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
165
165
|
*
|
|
166
|
-
* @param message
|
|
166
|
+
* @param message 自定义的错误提示文本
|
|
167
167
|
*/
|
|
168
168
|
setCustomValidity(message) {
|
|
169
169
|
this.inputRef.value.setCustomValidity(message);
|
|
@@ -184,7 +184,7 @@ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
184
184
|
onChange() {
|
|
185
185
|
this.checked = this.inputRef.value.checked;
|
|
186
186
|
this.indeterminate = false;
|
|
187
|
-
emit(
|
|
187
|
+
this.emit('change');
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
Checkbox.styles = [componentStyle, style];
|