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
|
@@ -10,7 +10,6 @@ import { when } from 'lit/directives/when.js';
|
|
|
10
10
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
11
11
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
12
12
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
13
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
14
13
|
import { SliderBase } from './slider-base.js';
|
|
15
14
|
import { style } from './style.js';
|
|
16
15
|
/**
|
|
@@ -32,7 +31,7 @@ import { style } from './style.js';
|
|
|
32
31
|
* @csspart label 提示文本
|
|
33
32
|
* @csspart tickmark - 刻度标记
|
|
34
33
|
*/
|
|
35
|
-
|
|
34
|
+
let Slider = class Slider extends SliderBase {
|
|
36
35
|
constructor() {
|
|
37
36
|
super(...arguments);
|
|
38
37
|
/**
|
|
@@ -50,29 +49,26 @@ export let Slider = class Slider extends SliderBase {
|
|
|
50
49
|
get rippleElement() {
|
|
51
50
|
return this.rippleRef.value;
|
|
52
51
|
}
|
|
53
|
-
onValueChange() {
|
|
54
|
-
|
|
52
|
+
async onValueChange() {
|
|
53
|
+
this.value = this.fixValue(this.value);
|
|
55
54
|
// reset 引起的值变更,不执行验证;直接修改值引起的变更,需要进行验证
|
|
56
55
|
const form = this.formController.getForm();
|
|
57
|
-
if (form &&
|
|
56
|
+
if (form && formResets.get(form)?.has(this)) {
|
|
58
57
|
this.invalid = false;
|
|
59
58
|
formResets.get(form).delete(this);
|
|
60
59
|
}
|
|
61
60
|
else {
|
|
61
|
+
await this.updateComplete;
|
|
62
62
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
63
63
|
}
|
|
64
|
-
this.inputRef.value.value = this.value.toString();
|
|
65
|
-
this.value = parseFloat(this.inputRef.value.value);
|
|
66
64
|
this.updateStyle();
|
|
67
65
|
}
|
|
68
66
|
connectedCallback() {
|
|
69
67
|
super.connectedCallback();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.value = this.max;
|
|
75
|
-
}
|
|
68
|
+
this.value = this.fixValue(this.value);
|
|
69
|
+
}
|
|
70
|
+
firstUpdated(changedProperties) {
|
|
71
|
+
super.firstUpdated(changedProperties);
|
|
76
72
|
const onTouchStart = () => {
|
|
77
73
|
if (!this.disabled) {
|
|
78
74
|
this.labelVisible = true;
|
|
@@ -87,9 +83,6 @@ export let Slider = class Slider extends SliderBase {
|
|
|
87
83
|
this.addEventListener('mousedown', onTouchStart);
|
|
88
84
|
this.addEventListener('touchend', onTouchEnd);
|
|
89
85
|
this.addEventListener('mouseup', onTouchEnd);
|
|
90
|
-
}
|
|
91
|
-
firstUpdated(changedProperties) {
|
|
92
|
-
super.firstUpdated(changedProperties);
|
|
93
86
|
this.updateStyle();
|
|
94
87
|
}
|
|
95
88
|
/**
|
|
@@ -97,7 +90,7 @@ export let Slider = class Slider extends SliderBase {
|
|
|
97
90
|
* <input class="invalid" /> 用于提供 html5 自带的表单错误提示
|
|
98
91
|
*/
|
|
99
92
|
render() {
|
|
100
|
-
return html `<label><input ${ref(this.inputRef)} type="range" step="${this.step}" min="${this.min}" max="${this.max}" ?disabled="${this.disabled}" .value="${live(this.value.toString())}" @input="${this.onInput}" @change="${this.onChange}"><div part="track-inactive" class="track-inactive"></div><div ${ref(this.trackActiveRef)} part="track-active" class="track-active"></div><div ${ref(this.handleRef)} part="handle" class="handle"><div class="elevation"></div><mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple>${this.renderLabel(this.value)}</div>${when(this.tickmarks, () => map(this.getCandidateValues(), (value) => html `<div part="tickmark" class="tickmark ${classMap({ active: value < this.value })}" style="${styleMap({
|
|
93
|
+
return html `<label class="${classMap({ invalid: this.invalid })}"><input ${ref(this.inputRef)} type="range" step="${this.step}" min="${this.min}" max="${this.max}" ?disabled="${this.disabled}" .value="${live(this.value.toString())}" @input="${this.onInput}" @change="${this.onChange}"><div part="track-inactive" class="track-inactive"></div><div ${ref(this.trackActiveRef)} part="track-active" class="track-active"></div><div ${ref(this.handleRef)} part="handle" class="handle"><div class="elevation"></div><mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple>${this.renderLabel(this.value)}</div>${when(this.tickmarks, () => map(this.getCandidateValues(), (value) => html `<div part="tickmark" class="tickmark ${classMap({ active: value < this.value })}" style="${styleMap({
|
|
101
94
|
left: `${((value - this.min) / this.max) * 100}%`,
|
|
102
95
|
display: value === this.value ? 'none' : 'block',
|
|
103
96
|
})}"></div>`))}</label>`;
|
|
@@ -109,7 +102,6 @@ export let Slider = class Slider extends SliderBase {
|
|
|
109
102
|
}
|
|
110
103
|
onInput() {
|
|
111
104
|
this.value = parseFloat(this.inputRef.value.value);
|
|
112
|
-
emit(this, 'input');
|
|
113
105
|
this.updateStyle();
|
|
114
106
|
}
|
|
115
107
|
};
|
|
@@ -126,3 +118,4 @@ __decorate([
|
|
|
126
118
|
Slider = __decorate([
|
|
127
119
|
customElement('mdui-slider')
|
|
128
120
|
], Slider);
|
|
121
|
+
export { Slider };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const sliderBaseStyle = css `:host{position:relative;display:block;width:100%;-webkit-tap-highlight-color:transparent;height:2.5rem;padding:0 1.25rem}label{position:relative;display:block;width:100%;height:100%}input[type=range]{position:absolute;inset:0;z-index:4;height:100%;cursor:pointer;opacity:0;-webkit-appearance:none;appearance:none;margin:0 -1.25rem;padding:0 .75rem}:host([disabled]) input[type=range]{cursor:not-allowed}.track-active,.track-inactive{position:absolute;top:50%;height:.25rem;margin-top:-.125rem}.track-inactive{left:-.125rem;right:-.125rem;border-radius:var(--mdui-shape-corner-full);background-color:rgb(var(--mdui-color-surface-container-highest))}
|
|
2
|
+
export const sliderBaseStyle = css `:host{position:relative;display:block;width:100%;-webkit-tap-highlight-color:transparent;height:2.5rem;padding:0 1.25rem}label{position:relative;display:block;width:100%;height:100%}input[type=range]{position:absolute;inset:0;z-index:4;height:100%;cursor:pointer;opacity:0;-webkit-appearance:none;appearance:none;width:calc(100% + 20rem * 2 / 16);margin:0 -1.25rem;padding:0 .75rem}:host([disabled]) input[type=range]{cursor:not-allowed}.track-active,.track-inactive{position:absolute;top:50%;height:.25rem;margin-top:-.125rem}.track-inactive{left:-.125rem;right:-.125rem;border-radius:var(--mdui-shape-corner-full);background-color:rgb(var(--mdui-color-surface-container-highest))}.invalid .track-inactive{background-color:rgba(var(--mdui-color-error),.12)}:host([disabled]) .track-inactive{background-color:rgba(var(--mdui-color-on-surface),.12)}.track-active{background-color:rgb(var(--mdui-color-primary))}.invalid .track-active{background-color:rgb(var(--mdui-color-error))}:host([disabled]) .track-active{background-color:rgba(var(--mdui-color-on-surface),.38)}.handle{position:absolute;top:50%;transform:translate(-50%);cursor:pointer;z-index:2;width:2.5rem;height:2.5rem;margin-top:-1.25rem;--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}.invalid .handle{--mdui-comp-ripple-state-layer-color:var(--mdui-color-error)}.handle .elevation,.handle::before{position:absolute;display:block;content:' ';left:.625rem;top:.625rem;width:1.25rem;height:1.25rem;border-radius:var(--mdui-shape-corner-full)}.handle .elevation{background-color:rgb(var(--mdui-color-primary));box-shadow:var(--mdui-elevation-level1)}.invalid .handle .elevation{background-color:rgb(var(--mdui-color-error))}:host([disabled]) .handle .elevation{background-color:rgba(var(--mdui-color-on-surface),.38);box-shadow:var(--mdui-elevation-level0)}.handle::before{background-color:rgb(var(--mdui-color-background))}.handle mdui-ripple{border-radius:var(--mdui-shape-corner-full)}.label{position:absolute;left:50%;transform:translateX(-50%) scale(0);transform-origin:center bottom;display:flex;align-items:center;justify-content:center;cursor:default;white-space:nowrap;-webkit-user-select:none;user-select:none;pointer-events:none;transition:transform var(--mdui-motion-duration-short2) var(--mdui-motion-easing-standard);bottom:2.5rem;min-width:1.75rem;height:1.75rem;padding:.375rem .5rem;border-radius:var(--mdui-shape-corner-full);color:rgb(var(--mdui-color-on-primary));font-size:var(--mdui-typescale-label-medium-size);font-weight:var(--mdui-typescale-label-medium-weight);letter-spacing:var(--mdui-typescale-label-medium-tracking);line-height:var(--mdui-typescale-label-medium-line-height);background-color:rgb(var(--mdui-color-primary))}.invalid .label{color:rgb(var(--mdui-color-on-error));background-color:rgb(var(--mdui-color-error))}.label::after{content:' ';position:absolute;z-index:-1;transform:rotate(45deg);width:.875rem;height:.875rem;bottom:-.125rem;background-color:rgb(var(--mdui-color-primary))}.invalid .label::after{background-color:rgb(var(--mdui-color-error))}.label-visible{transform:translateX(-50%) scale(1);transition:transform var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard)}.tickmark{position:absolute;top:50%;transform:translate(-50%);width:.125rem;height:.125rem;margin-top:-.0625rem;border-radius:var(--mdui-shape-corner-full);background-color:rgba(var(--mdui-color-on-surface-variant),.38)}.invalid .tickmark{background-color:rgba(var(--mdui-color-error),.38)}.tickmark.active{background-color:rgba(var(--mdui-color-on-primary),.38)}.invalid .tickmark.active{background-color:rgba(var(--mdui-color-on-error),.38)}:host([disabled]) .tickmark{background-color:rgba(var(--mdui-color-on-surface),.38)}`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
3
3
|
import type { Ref } from 'lit/directives/ref.js';
|
|
4
|
-
declare const SliderBase_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
|
|
5
|
-
export declare class SliderBase extends SliderBase_base {
|
|
4
|
+
declare const SliderBase_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;
|
|
5
|
+
export declare class SliderBase<E> extends SliderBase_base<E> {
|
|
6
6
|
static styles: CSSResultGroup;
|
|
7
7
|
/**
|
|
8
8
|
* 最小允许值,默认为 `0`
|
|
@@ -79,6 +79,10 @@ export declare class SliderBase extends SliderBase_base {
|
|
|
79
79
|
* @param message 自定义的提示文本
|
|
80
80
|
*/
|
|
81
81
|
setCustomValidity(message: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* value 不在 min、max 或 step 的限制范围内时,修正 value 的值
|
|
84
|
+
*/
|
|
85
|
+
protected fixValue(value: number): number;
|
|
82
86
|
/**
|
|
83
87
|
* 获取候选值组成的数组
|
|
84
88
|
*/
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { property, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { createRef } from 'lit/directives/ref.js';
|
|
6
6
|
import { when } from 'lit/directives/when.js';
|
|
7
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
7
8
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
8
9
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
9
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
10
10
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
11
11
|
import { FocusableMixin } from '@mdui/shared/mixins/focusable.js';
|
|
12
12
|
import { RippleMixin } from '../ripple/ripple-mixin.js';
|
|
13
13
|
import { sliderBaseStyle } from './slider-base-style.js';
|
|
14
|
-
export class SliderBase extends RippleMixin(FocusableMixin(
|
|
14
|
+
export class SliderBase extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
17
|
/**
|
|
@@ -87,7 +87,8 @@ export class SliderBase extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
87
87
|
checkValidity() {
|
|
88
88
|
const valid = this.inputRef.value.checkValidity();
|
|
89
89
|
if (!valid) {
|
|
90
|
-
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
this.emit('invalid', {
|
|
91
92
|
bubbles: false,
|
|
92
93
|
cancelable: true,
|
|
93
94
|
composed: false,
|
|
@@ -103,13 +104,14 @@ export class SliderBase extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
103
104
|
reportValidity() {
|
|
104
105
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
105
106
|
if (this.invalid) {
|
|
106
|
-
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
const eventProceeded = this.emit('invalid', {
|
|
107
109
|
bubbles: false,
|
|
108
110
|
cancelable: true,
|
|
109
111
|
composed: false,
|
|
110
112
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
if (!eventProceeded) {
|
|
114
|
+
// 调用了 preventDefault() 时,隐藏默认的表单错误提示
|
|
113
115
|
this.blur();
|
|
114
116
|
this.focus();
|
|
115
117
|
}
|
|
@@ -125,6 +127,22 @@ export class SliderBase extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
125
127
|
this.inputRef.value.setCustomValidity(message);
|
|
126
128
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
127
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* value 不在 min、max 或 step 的限制范围内时,修正 value 的值
|
|
132
|
+
*/
|
|
133
|
+
fixValue(value) {
|
|
134
|
+
const { min, max, step } = this;
|
|
135
|
+
// 确保 value 在 min 和 max 范围内
|
|
136
|
+
value = Math.min(Math.max(value, min), max);
|
|
137
|
+
// 计算最接近 value 的 step 值
|
|
138
|
+
const steps = Math.round((value - min) / step);
|
|
139
|
+
let fixedValue = min + steps * step;
|
|
140
|
+
// 如果修正后的值超出最大值,则减去一个 step
|
|
141
|
+
if (fixedValue > max) {
|
|
142
|
+
fixedValue -= step;
|
|
143
|
+
}
|
|
144
|
+
return fixedValue;
|
|
145
|
+
}
|
|
128
146
|
/**
|
|
129
147
|
* 获取候选值组成的数组
|
|
130
148
|
*/
|
|
@@ -138,7 +156,8 @@ export class SliderBase extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
138
156
|
return when(!this.nolabel, () => html `<div part="label" class="label ${classMap({ 'label-visible': this.labelVisible })}">${this.labelFormatter(value)}</div>`);
|
|
139
157
|
}
|
|
140
158
|
onChange() {
|
|
141
|
-
|
|
159
|
+
// @ts-ignore
|
|
160
|
+
this.emit('change');
|
|
142
161
|
}
|
|
143
162
|
}
|
|
144
163
|
SliderBase.styles = [
|
|
@@ -182,11 +201,7 @@ __decorate([
|
|
|
182
201
|
property({ reflect: true })
|
|
183
202
|
], SliderBase.prototype, "name", void 0);
|
|
184
203
|
__decorate([
|
|
185
|
-
|
|
186
|
-
type: Boolean,
|
|
187
|
-
reflect: true,
|
|
188
|
-
converter: booleanConverter,
|
|
189
|
-
})
|
|
204
|
+
state()
|
|
190
205
|
], SliderBase.prototype, "invalid", void 0);
|
|
191
206
|
__decorate([
|
|
192
207
|
state()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import '@mdui/shared/icons/clear.js';
|
|
3
3
|
import '../button-icon.js';
|
|
4
4
|
import '../button.js';
|
|
@@ -30,7 +30,7 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
30
30
|
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
31
31
|
* @cssprop --z-index - 组件的 CSS 的 `z-index` 值
|
|
32
32
|
*/
|
|
33
|
-
export declare class Snackbar extends
|
|
33
|
+
export declare class Snackbar extends MduiElement<SnackbarEventMap> {
|
|
34
34
|
static styles: CSSResultGroup;
|
|
35
35
|
/**
|
|
36
36
|
* 是否显示 Snackbar
|
|
@@ -91,6 +91,13 @@ export declare class Snackbar extends LitElement {
|
|
|
91
91
|
private onActionClick;
|
|
92
92
|
private onCloseClick;
|
|
93
93
|
}
|
|
94
|
+
export interface SnackbarEventMap {
|
|
95
|
+
open: CustomEvent<void>;
|
|
96
|
+
opened: CustomEvent<void>;
|
|
97
|
+
close: CustomEvent<void>;
|
|
98
|
+
closed: CustomEvent<void>;
|
|
99
|
+
'action-click': CustomEvent<void>;
|
|
100
|
+
}
|
|
94
101
|
declare global {
|
|
95
102
|
interface HTMLElementTagNameMap {
|
|
96
103
|
'mdui-snackbar': Snackbar;
|
|
@@ -1,12 +1,12 @@
|
|
|
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 { when } from 'lit/directives/when.js';
|
|
5
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
5
6
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
6
7
|
import { animateTo, stopAnimations } from '@mdui/shared/helpers/animate.js';
|
|
7
8
|
import { breakpoint } from '@mdui/shared/helpers/breakpoint.js';
|
|
8
9
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
9
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
10
10
|
import { getDuration, getEasing } from '@mdui/shared/helpers/motion.js';
|
|
11
11
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
12
12
|
import '@mdui/shared/icons/clear.js';
|
|
@@ -41,7 +41,7 @@ import { style } from './style.js';
|
|
|
41
41
|
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
42
42
|
* @cssprop --z-index - 组件的 CSS 的 `z-index` 值
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
let Snackbar = class Snackbar extends MduiElement {
|
|
45
45
|
constructor() {
|
|
46
46
|
super();
|
|
47
47
|
/**
|
|
@@ -97,8 +97,8 @@ export let Snackbar = class Snackbar extends LitElement {
|
|
|
97
97
|
await this.updateComplete;
|
|
98
98
|
}
|
|
99
99
|
if (hasUpdated) {
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
100
|
+
const eventProceeded = this.emit('open', { cancelable: true });
|
|
101
|
+
if (!eventProceeded) {
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -155,14 +155,14 @@ export let Snackbar = class Snackbar extends LitElement {
|
|
|
155
155
|
})),
|
|
156
156
|
]);
|
|
157
157
|
if (hasUpdated) {
|
|
158
|
-
emit(
|
|
158
|
+
this.emit('opened');
|
|
159
159
|
}
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
// 关闭
|
|
163
163
|
if (!this.open && this.hasUpdated) {
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
164
|
+
const eventProceeded = this.emit('close', { cancelable: true });
|
|
165
|
+
if (!eventProceeded) {
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
window.clearTimeout(this.closeTimeout);
|
|
@@ -191,7 +191,7 @@ export let Snackbar = class Snackbar extends LitElement {
|
|
|
191
191
|
...children.map((child) => animateTo(child, [{ opacity: 1 }, { opacity: 0, offset: 0.75 }, { opacity: 0 }], { duration, easing: easingLinear })),
|
|
192
192
|
]);
|
|
193
193
|
this.style.display = 'none';
|
|
194
|
-
emit(
|
|
194
|
+
this.emit('closed');
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -224,7 +224,7 @@ export let Snackbar = class Snackbar extends LitElement {
|
|
|
224
224
|
}
|
|
225
225
|
onActionClick(event) {
|
|
226
226
|
event.stopPropagation();
|
|
227
|
-
emit(
|
|
227
|
+
this.emit('action-click');
|
|
228
228
|
}
|
|
229
229
|
onCloseClick() {
|
|
230
230
|
this.open = false;
|
|
@@ -283,3 +283,4 @@ __decorate([
|
|
|
283
283
|
Snackbar = __decorate([
|
|
284
284
|
customElement('mdui-snackbar')
|
|
285
285
|
], Snackbar);
|
|
286
|
+
export { Snackbar };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import '@mdui/shared/icons/check.js';
|
|
3
3
|
import '../icon.js';
|
|
4
4
|
import type { Ripple } from '../ripple/index.js';
|
|
5
5
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
6
6
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
7
|
-
declare const Switch_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
|
|
7
|
+
declare const Switch_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;
|
|
8
8
|
/**
|
|
9
9
|
* @summary 开关切换组件
|
|
10
10
|
*
|
|
@@ -29,7 +29,7 @@ declare const Switch_base: import("@open-wc/dedupe-mixin").Constructor<import(".
|
|
|
29
29
|
* @cssprop --shape-corner - 组件的轨道的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
30
30
|
* @cssprop --shape-corner-thumb - 组件的图标容器的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
31
31
|
*/
|
|
32
|
-
export declare class Switch extends Switch_base implements FormControl {
|
|
32
|
+
export declare class Switch extends Switch_base<SwitchEventMap> implements FormControl {
|
|
33
33
|
static styles: CSSResultGroup;
|
|
34
34
|
/**
|
|
35
35
|
* 是否为禁用状态
|
|
@@ -115,6 +115,13 @@ export declare class Switch extends Switch_base implements FormControl {
|
|
|
115
115
|
*/
|
|
116
116
|
private onChange;
|
|
117
117
|
}
|
|
118
|
+
export interface SwitchEventMap {
|
|
119
|
+
focus: FocusEvent;
|
|
120
|
+
blur: FocusEvent;
|
|
121
|
+
change: CustomEvent<void>;
|
|
122
|
+
input: Event;
|
|
123
|
+
invalid: CustomEvent<void>;
|
|
124
|
+
}
|
|
118
125
|
declare global {
|
|
119
126
|
interface HTMLElementTagNameMap {
|
|
120
127
|
'mdui-switch': Switch;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
3
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
2
|
+
import { html } from 'lit';
|
|
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 { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
10
11
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
11
12
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
12
13
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
13
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
14
14
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
15
15
|
import '@mdui/shared/icons/check.js';
|
|
16
16
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
@@ -42,7 +42,7 @@ import { style } from './style.js';
|
|
|
42
42
|
* @cssprop --shape-corner - 组件的轨道的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
43
43
|
* @cssprop --shape-corner-thumb - 组件的图标容器的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
let Switch = class Switch extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
46
46
|
constructor() {
|
|
47
47
|
super(...arguments);
|
|
48
48
|
/**
|
|
@@ -111,11 +111,10 @@ export let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement))
|
|
|
111
111
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
112
112
|
}
|
|
113
113
|
async onCheckedChange() {
|
|
114
|
-
var _a;
|
|
115
114
|
await this.updateComplete;
|
|
116
115
|
// reset 引起的值变更,不执行验证;直接修改值引起的变更,需要进行验证
|
|
117
116
|
const form = this.formController.getForm();
|
|
118
|
-
if (form &&
|
|
117
|
+
if (form && formResets.get(form)?.has(this)) {
|
|
119
118
|
this.invalid = false;
|
|
120
119
|
formResets.get(form).delete(this);
|
|
121
120
|
}
|
|
@@ -129,7 +128,7 @@ export let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement))
|
|
|
129
128
|
checkValidity() {
|
|
130
129
|
const valid = this.inputRef.value.checkValidity();
|
|
131
130
|
if (!valid) {
|
|
132
|
-
emit(
|
|
131
|
+
this.emit('invalid', {
|
|
133
132
|
bubbles: false,
|
|
134
133
|
cancelable: true,
|
|
135
134
|
composed: false,
|
|
@@ -145,13 +144,13 @@ export let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement))
|
|
|
145
144
|
reportValidity() {
|
|
146
145
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
147
146
|
if (this.invalid) {
|
|
148
|
-
const
|
|
147
|
+
const eventProceeded = this.emit('invalid', {
|
|
149
148
|
bubbles: false,
|
|
150
149
|
cancelable: true,
|
|
151
150
|
composed: false,
|
|
152
151
|
});
|
|
153
152
|
// 调用了 preventDefault() 时,隐藏默认的表单错误提示
|
|
154
|
-
if (
|
|
153
|
+
if (!eventProceeded) {
|
|
155
154
|
this.blur();
|
|
156
155
|
this.focus();
|
|
157
156
|
}
|
|
@@ -169,6 +168,7 @@ export let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement))
|
|
|
169
168
|
}
|
|
170
169
|
render() {
|
|
171
170
|
return html `<label class="${classMap({
|
|
171
|
+
invalid: this.invalid,
|
|
172
172
|
'has-unchecked-icon': this.uncheckedIcon || this.hasSlotController.test('unchecked-icon'),
|
|
173
173
|
})}"><input ${ref(this.inputRef)} type="checkbox" name="${ifDefined(this.name)}" value="${ifDefined(this.value)}" .disabled="${this.disabled}" .checked="${live(this.checked)}" .required="${this.required}" @change="${this.onChange}"><div part="track" class="track"><div part="thumb" class="thumb"><mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple><slot name="checked-icon" part="checked-icon" class="checked-icon">${this.checkedIcon
|
|
174
174
|
? html `<mdui-icon name="${this.checkedIcon}" class="i"></mdui-icon>`
|
|
@@ -183,7 +183,7 @@ export let Switch = class Switch extends RippleMixin(FocusableMixin(LitElement))
|
|
|
183
183
|
*/
|
|
184
184
|
onChange() {
|
|
185
185
|
this.checked = this.inputRef.value.checked;
|
|
186
|
-
emit(
|
|
186
|
+
this.emit('change');
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
Switch.styles = [componentStyle, style];
|
|
@@ -227,11 +227,7 @@ __decorate([
|
|
|
227
227
|
property({ reflect: true })
|
|
228
228
|
], Switch.prototype, "value", void 0);
|
|
229
229
|
__decorate([
|
|
230
|
-
|
|
231
|
-
type: Boolean,
|
|
232
|
-
reflect: true,
|
|
233
|
-
converter: booleanConverter,
|
|
234
|
-
})
|
|
230
|
+
state()
|
|
235
231
|
], Switch.prototype, "invalid", void 0);
|
|
236
232
|
__decorate([
|
|
237
233
|
watch('disabled', true),
|
|
@@ -243,3 +239,4 @@ __decorate([
|
|
|
243
239
|
Switch = __decorate([
|
|
244
240
|
customElement('mdui-switch')
|
|
245
241
|
], Switch);
|
|
242
|
+
export { Switch };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css `:host{--shape-corner:var(--mdui-shape-corner-full);--shape-corner-thumb:var(--mdui-shape-corner-full);position:relative;display:inline-block;cursor:pointer;-webkit-tap-highlight-color:transparent;height:2.5rem}:host([disabled]){cursor:default;pointer-events:none}label{display:inline-flex;align-items:center;width:100%;height:100%;white-space:nowrap;cursor:inherit;-webkit-user-select:none;user-select:none;touch-action:manipulation;zoom:1;-webkit-user-drag:none}.track{position:relative;display:flex;align-items:center;border-radius:var(--shape-corner);transition-property:background-color,border-width;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard);height:2rem;width:3.25rem;border:.125rem solid rgb(var(--mdui-color-outline));background-color:rgb(var(--mdui-color-surface-container-highest))}:host([checked]) .track{background-color:rgb(var(--mdui-color-primary));border-width:0}
|
|
2
|
+
export const style = css `:host{--shape-corner:var(--mdui-shape-corner-full);--shape-corner-thumb:var(--mdui-shape-corner-full);position:relative;display:inline-block;cursor:pointer;-webkit-tap-highlight-color:transparent;height:2.5rem}:host([disabled]){cursor:default;pointer-events:none}label{display:inline-flex;align-items:center;width:100%;height:100%;white-space:nowrap;cursor:inherit;-webkit-user-select:none;user-select:none;touch-action:manipulation;zoom:1;-webkit-user-drag:none}.track{position:relative;display:flex;align-items:center;border-radius:var(--shape-corner);transition-property:background-color,border-width;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard);height:2rem;width:3.25rem;border:.125rem solid rgb(var(--mdui-color-outline));background-color:rgb(var(--mdui-color-surface-container-highest))}:host([checked]) .track{background-color:rgb(var(--mdui-color-primary));border-width:0}.invalid .track{background-color:rgb(var(--mdui-color-error-container));border-color:rgb(var(--mdui-color-error))}:host([disabled]) .track{background-color:rgba(var(--mdui-color-surface-container-highest),.12);border-color:rgba(var(--mdui-color-on-surface),.12)}:host([disabled][checked]) .track{background-color:rgba(var(--mdui-color-on-surface),.12)}input{position:absolute;padding:0;opacity:0;pointer-events:none;width:1.25rem;height:1.25rem;margin:0 0 0 .625rem}mdui-ripple{border-radius:50%;transition-property:left,top;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard);width:2.5rem;height:2.5rem}.thumb{position:absolute;display:flex;align-items:center;justify-content:center;border-radius:var(--shape-corner-thumb);transition-property:width,height,left,background-color;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard);height:1rem;width:1rem;left:.375rem;background-color:rgb(var(--mdui-color-outline));--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}.thumb mdui-ripple{left:-.75rem;top:-.75rem}.has-unchecked-icon .thumb{height:1.5rem;width:1.5rem;left:.125rem}.has-unchecked-icon .thumb mdui-ripple{left:-.5rem;top:-.5rem}:host([focus-visible]) .thumb,:host([hover]) .thumb,:host([pressed]) .thumb{background-color:rgb(var(--mdui-color-on-surface-variant))}:host([checked]) .thumb{height:1.5rem;width:1.5rem;left:1.5rem;background-color:rgb(var(--mdui-color-on-primary));--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}:host([checked]) .thumb mdui-ripple{left:-.5rem;top:-.5rem}:host([pressed]) .thumb{height:1.75rem;width:1.75rem;left:0}:host([pressed]) .thumb mdui-ripple{left:-.375rem;top:-.375rem}:host([pressed][checked]) .thumb{left:1.375rem}:host([focus-visible][checked]) .thumb,:host([hover][checked]) .thumb,:host([pressed][checked]) .thumb{background-color:rgb(var(--mdui-color-primary-container))}.invalid .thumb{background-color:rgb(var(--mdui-color-error));--mdui-comp-ripple-state-layer-color:var(--mdui-color-error)}:host([focus-visible]) .invalid .thumb,:host([hover]) .invalid .thumb,:host([pressed]) .invalid .thumb{background-color:rgb(var(--mdui-color-error))}:host([disabled]) .thumb{background-color:rgba(var(--mdui-color-on-surface),.38)}:host([disabled][checked]) .thumb{background-color:rgb(var(--mdui-color-surface))}.checked-icon,.unchecked-icon{display:flex;position:absolute;transition-property:opacity,transform;font-size:1rem}.unchecked-icon{opacity:1;transform:scale(1);transition-delay:var(--mdui-motion-duration-short1);transition-duration:var(--mdui-motion-duration-short3);transition-timing-function:var(--mdui-motion-easing-linear);color:rgb(var(--mdui-color-surface-container-highest))}:host([checked]) .unchecked-icon{opacity:0;transform:scale(.92);transition-delay:0s;transition-duration:var(--mdui-motion-duration-short1)}:host([disabled]) .unchecked-icon{color:rgba(var(--mdui-color-surface-container-highest),.38)}.checked-icon{opacity:0;transform:scale(.92);transition-delay:0s;transition-duration:var(--mdui-motion-duration-short1);transition-timing-function:var(--mdui-motion-easing-linear);color:rgb(var(--mdui-color-on-primary-container))}:host([checked]) .checked-icon{opacity:1;transform:scale(1);transition-delay:var(--mdui-motion-duration-short1);transition-duration:var(--mdui-motion-duration-short3)}.invalid .checked-icon{color:rgb(var(--mdui-color-error-container))}:host([disabled]) .checked-icon{color:rgba(var(--mdui-color-on-surface),.38)}.checked-icon .i,.unchecked-icon .i,::slotted([slot=checked-icon]),::slotted([slot=unchecked-icon]){font-size:inherit;color:inherit}`;
|
|
@@ -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 选项卡面板项组件。需与 `<mdui-tabs>` 和 `<mdui-tab>` 组件配合使用
|
|
@@ -17,7 +17,7 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
17
17
|
*
|
|
18
18
|
* @slot - 选项卡面板内容
|
|
19
19
|
*/
|
|
20
|
-
export declare class TabPanel extends
|
|
20
|
+
export declare class TabPanel extends MduiElement<TabPanelEventMap> {
|
|
21
21
|
static styles: CSSResultGroup;
|
|
22
22
|
/**
|
|
23
23
|
* 该选项卡面板的值
|
|
@@ -29,6 +29,8 @@ export declare class TabPanel extends LitElement {
|
|
|
29
29
|
protected active: boolean;
|
|
30
30
|
protected render(): TemplateResult;
|
|
31
31
|
}
|
|
32
|
+
export interface TabPanelEventMap {
|
|
33
|
+
}
|
|
32
34
|
declare global {
|
|
33
35
|
interface HTMLElementTagNameMap {
|
|
34
36
|
'mdui-tab-panel': TabPanel;
|
|
@@ -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 { tabPanelStyle } from './tab-panel-style.js';
|
|
@@ -21,7 +22,7 @@ import { tabPanelStyle } from './tab-panel-style.js';
|
|
|
21
22
|
*
|
|
22
23
|
* @slot - 选项卡面板内容
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
let TabPanel = class TabPanel extends MduiElement {
|
|
25
26
|
constructor() {
|
|
26
27
|
super(...arguments);
|
|
27
28
|
/**
|
|
@@ -50,3 +51,4 @@ __decorate([
|
|
|
50
51
|
TabPanel = __decorate([
|
|
51
52
|
customElement('mdui-tab-panel')
|
|
52
53
|
], TabPanel);
|
|
54
|
+
export { TabPanel };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const tabStyle = css `:host{position:relative;--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}:host([active]){--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}.container{display:flex;justify-content:center;align-items:center;cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;height:100%}.preset{flex-direction:column;min-height:3rem;padding:.625rem 1rem}:host([inline]) .preset{flex-direction:row}.icon-container,.label-container{position:relative;display:flex;align-items:center;justify-content:center}.icon-container ::slotted([slot=badge]){position:absolute;transform:translate(50%,-50%)}.icon-container ::slotted([slot=badge][variant=small]){transform:translate(.5625rem,-.5625rem)}.label-container ::slotted([slot=badge]){position:absolute;left:100%;bottom:100%;transform:translate(-.75rem,.625rem)}.label-container ::slotted([slot=badge][variant=small]){transform:translate(-.375rem,.375rem)}.icon,.label{display:flex;color:rgb(var(--mdui-color-on-surface-variant))}:host([focused]) .icon,:host([focused]) .label,:host([hover]) .icon,:host([hover]) .label,:host([pressed]) .icon,:host([pressed]) .label{color:rgb(var(--mdui-color-on-surface))}:host([active]) .icon,:host([active]) .label{color:rgb(var(--mdui-color-primary))}:host([active]
|
|
2
|
+
export const tabStyle = css `:host{position:relative;--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}:host([active]){--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}.container{display:flex;justify-content:center;align-items:center;cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;height:100%}.preset{flex-direction:column;min-height:3rem;padding:.625rem 1rem}:host([inline]) .preset{flex-direction:row}.icon-container,.label-container{position:relative;display:flex;align-items:center;justify-content:center}.icon-container ::slotted([slot=badge]){position:absolute;transform:translate(50%,-50%)}.icon-container ::slotted([slot=badge][variant=small]){transform:translate(.5625rem,-.5625rem)}.label-container ::slotted([slot=badge]){position:absolute;left:100%;bottom:100%;transform:translate(-.75rem,.625rem)}.label-container ::slotted([slot=badge][variant=small]){transform:translate(-.375rem,.375rem)}.icon,.label{display:flex;color:rgb(var(--mdui-color-on-surface-variant))}:host([focused]) .icon,:host([focused]) .label,:host([hover]) .icon,:host([hover]) .label,:host([pressed]) .icon,:host([pressed]) .label{color:rgb(var(--mdui-color-on-surface))}:host([active]) .icon,:host([active]) .label{color:rgb(var(--mdui-color-primary))}:host([active]) .variant-secondary .icon,:host([active]) .variant-secondary .label{color:rgb(var(--mdui-color-on-surface))}.icon{font-size:1.5rem}.label{font-size:var(--mdui-typescale-title-small-size);font-weight:var(--mdui-typescale-title-small-weight);letter-spacing:var(--mdui-typescale-title-small-tracking);line-height:var(--mdui-typescale-title-small-line-height)}.icon mdui-icon,::slotted([slot=icon]){font-size:inherit;color:inherit}`;
|
package/components/tabs/tab.d.ts
CHANGED
|
@@ -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 Tab_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
|
|
5
|
+
declare const Tab_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;
|
|
6
6
|
/**
|
|
7
7
|
* @summary 选项卡项组件。需与 `<mdui-tabs>` 和 `<mdui-tab-panel>` 组件配合使用
|
|
8
8
|
*
|
|
@@ -30,7 +30,7 @@ declare const Tab_base: import("@open-wc/dedupe-mixin").Constructor<import("../r
|
|
|
30
30
|
* @csspart icon - 导航项中的图标
|
|
31
31
|
* @csspart label - 导航项的文本
|
|
32
32
|
*/
|
|
33
|
-
export declare class Tab extends Tab_base {
|
|
33
|
+
export declare class Tab extends Tab_base<TabEventMap> {
|
|
34
34
|
static styles: CSSResultGroup;
|
|
35
35
|
/**
|
|
36
36
|
* 该选项卡导航项的值
|
|
@@ -61,6 +61,10 @@ export declare class Tab extends Tab_base {
|
|
|
61
61
|
protected get focusDisabled(): boolean;
|
|
62
62
|
protected render(): TemplateResult;
|
|
63
63
|
}
|
|
64
|
+
export interface TabEventMap {
|
|
65
|
+
focus: FocusEvent;
|
|
66
|
+
blur: FocusEvent;
|
|
67
|
+
}
|
|
64
68
|
declare global {
|
|
65
69
|
interface HTMLElementTagNameMap {
|
|
66
70
|
'mdui-tab': Tab;
|
package/components/tabs/tab.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
3
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
5
6
|
import { when } from 'lit/directives/when.js';
|
|
6
|
-
import
|
|
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';
|
|
@@ -40,7 +41,7 @@ import { tabStyle } from './tab-style.js';
|
|
|
40
41
|
* @csspart icon - 导航项中的图标
|
|
41
42
|
* @csspart label - 导航项的文本
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
let Tab = class Tab extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
44
45
|
constructor() {
|
|
45
46
|
super(...arguments);
|
|
46
47
|
/**
|
|
@@ -76,7 +77,11 @@ export let Tab = class Tab extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
76
77
|
const hasIcon = this.icon || this.hasSlotController.test('icon');
|
|
77
78
|
const hasCustomSlot = this.hasSlotController.test('custom');
|
|
78
79
|
const renderBadge = () => html `<slot name="badge"></slot>`;
|
|
79
|
-
return html `<mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple><div part="container" class="
|
|
80
|
+
return html `<mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple><div part="container" class="${classMap({
|
|
81
|
+
container: true,
|
|
82
|
+
preset: !hasCustomSlot,
|
|
83
|
+
'variant-secondary': this.variant === 'secondary',
|
|
84
|
+
})}"><slot name="custom"><div class="icon-container">${when(hasIcon || this.icon, renderBadge)}<slot name="icon" part="icon" class="icon">${this.icon
|
|
80
85
|
? html `<mdui-icon name="${this.icon}"></mdui-icon>`
|
|
81
86
|
: nothingTemplate}</slot></div><div class="label-container">${when(!hasIcon, renderBadge)}<slot part="label" class="label"></slot></div></slot></div>`;
|
|
82
87
|
}
|
|
@@ -103,8 +108,9 @@ __decorate([
|
|
|
103
108
|
})
|
|
104
109
|
], Tab.prototype, "active", void 0);
|
|
105
110
|
__decorate([
|
|
106
|
-
|
|
111
|
+
state()
|
|
107
112
|
], Tab.prototype, "variant", void 0);
|
|
108
113
|
Tab = __decorate([
|
|
109
114
|
customElement('mdui-tab')
|
|
110
115
|
], Tab);
|
|
116
|
+
export { Tab };
|