mdui 2.0.2 → 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/components/avatar/index.d.ts +4 -2
- package/components/avatar/index.js +3 -2
- package/components/badge/index.d.ts +4 -2
- package/components/badge/index.js +3 -2
- package/components/bottom-app-bar/index.d.ts +7 -1
- package/components/bottom-app-bar/index.js +5 -6
- package/components/button/button-base.d.ts +3 -3
- package/components/button/button-base.js +7 -5
- package/components/button/index.d.ts +6 -1
- package/components/button-icon/index.d.ts +7 -1
- package/components/button-icon/index.js +1 -2
- package/components/card/index.d.ts +7 -3
- package/components/card/index.js +3 -2
- package/components/checkbox/index.d.ts +10 -3
- package/components/checkbox/index.js +7 -7
- package/components/chip/index.d.ts +8 -1
- package/components/chip/index.js +3 -4
- package/components/circular-progress/index.d.ts +4 -2
- package/components/circular-progress/index.js +3 -2
- package/components/collapse/collapse-item.d.ts +13 -2
- package/components/collapse/collapse-item.js +5 -5
- package/components/collapse/collapse.d.ts +10 -2
- package/components/collapse/collapse.js +6 -6
- package/components/dialog/index.d.ts +9 -2
- package/components/dialog/index.js +10 -14
- package/components/divider/index.d.ts +4 -2
- package/components/divider/index.js +3 -2
- package/components/dropdown/index.d.ts +9 -2
- package/components/dropdown/index.js +17 -15
- package/components/fab/index.d.ts +6 -1
- 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 +4 -3
- package/components/layout/layout-main.d.ts +4 -2
- package/components/layout/layout-main.js +3 -2
- package/components/layout/layout.d.ts +4 -2
- package/components/layout/layout.js +3 -2
- package/components/linear-progress/index.d.ts +4 -2
- package/components/linear-progress/index.js +3 -2
- package/components/list/list-item-style.js +1 -1
- package/components/list/list-item.d.ts +7 -3
- package/components/list/list-item.js +3 -2
- package/components/list/list-subheader.d.ts +4 -2
- package/components/list/list-subheader.js +3 -2
- package/components/list/list.d.ts +4 -2
- package/components/list/list.js +3 -2
- package/components/menu/menu-item.d.ts +11 -3
- package/components/menu/menu-item.js +9 -13
- package/components/menu/menu.d.ts +5 -2
- package/components/menu/menu.js +5 -5
- package/components/navigation-bar/navigation-bar-item.d.ts +7 -3
- package/components/navigation-bar/navigation-bar-item.js +3 -2
- package/components/navigation-bar/navigation-bar.d.ts +8 -1
- package/components/navigation-bar/navigation-bar.js +9 -7
- package/components/navigation-drawer/index.d.ts +8 -1
- package/components/navigation-drawer/index.js +7 -8
- package/components/navigation-drawer/style.js +1 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +7 -3
- package/components/navigation-rail/navigation-rail-item.js +3 -2
- package/components/navigation-rail/navigation-rail.d.ts +4 -1
- package/components/navigation-rail/navigation-rail.js +4 -2
- package/components/radio/radio-group.d.ts +7 -2
- package/components/radio/radio-group.js +10 -13
- package/components/radio/radio.d.ts +8 -3
- package/components/radio/radio.js +4 -4
- package/components/range-slider/index.d.ts +9 -3
- package/components/range-slider/index.js +6 -2
- 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 +6 -2
- package/components/segmented-button/segmented-button-group.js +9 -9
- package/components/segmented-button/segmented-button.d.ts +6 -1
- package/components/select/index.d.ts +11 -3
- package/components/select/index.js +5 -5
- package/components/slider/index.d.ts +8 -1
- package/components/slider/index.js +4 -9
- package/components/slider/slider-base.d.ts +7 -3
- package/components/slider/slider-base.js +27 -8
- package/components/snackbar/index.d.ts +9 -2
- package/components/snackbar/index.js +10 -10
- package/components/switch/index.d.ts +10 -3
- package/components/switch/index.js +7 -7
- package/components/tabs/tab-panel.d.ts +4 -2
- package/components/tabs/tab-panel.js +3 -2
- package/components/tabs/tab.d.ts +7 -3
- package/components/tabs/tab.js +3 -2
- package/components/tabs/tabs.d.ts +5 -2
- package/components/tabs/tabs.js +7 -4
- package/components/text-field/index.d.ts +11 -3
- package/components/text-field/index.js +12 -12
- package/components/tooltip/index.d.ts +9 -2
- package/components/tooltip/index.js +17 -15
- package/components/top-app-bar/top-app-bar-title.d.ts +4 -2
- package/components/top-app-bar/top-app-bar-title.js +3 -2
- package/components/top-app-bar/top-app-bar.d.ts +7 -1
- package/components/top-app-bar/top-app-bar.js +5 -6
- package/custom-elements.json +2954 -2891
- package/html-data.zh-cn.json +439 -439
- package/mdui.esm.js +8 -8
- package/mdui.global.js +8 -8
- package/package.json +3 -2
- package/web-types.zh-cn.json +765 -765
|
@@ -1,5 +1,5 @@
|
|
|
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 { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
@@ -7,13 +7,12 @@ import { $ } from '@mdui/jq/$.js';
|
|
|
7
7
|
import '@mdui/jq/methods/closest.js';
|
|
8
8
|
import '@mdui/jq/methods/find.js';
|
|
9
9
|
import '@mdui/jq/methods/get.js';
|
|
10
|
-
import {
|
|
10
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
11
11
|
import { DefinedController } from '@mdui/shared/controllers/defined.js';
|
|
12
12
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
13
13
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
14
14
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
15
15
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
16
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
17
16
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
18
17
|
import { radioGroupStyle } from './radio-group-style.js';
|
|
19
18
|
/**
|
|
@@ -32,7 +31,7 @@ import { radioGroupStyle } from './radio-group-style.js';
|
|
|
32
31
|
*
|
|
33
32
|
* @slot - `<mdui-radio>` 元素
|
|
34
33
|
*/
|
|
35
|
-
let RadioGroup = class RadioGroup extends
|
|
34
|
+
let RadioGroup = class RadioGroup extends MduiElement {
|
|
36
35
|
constructor() {
|
|
37
36
|
super(...arguments);
|
|
38
37
|
/**
|
|
@@ -91,8 +90,8 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
91
90
|
async onValueChange() {
|
|
92
91
|
this.isInitial = false;
|
|
93
92
|
await this.definedController.whenDefined();
|
|
94
|
-
emit(
|
|
95
|
-
emit(
|
|
93
|
+
this.emit('input');
|
|
94
|
+
this.emit('change');
|
|
96
95
|
this.updateItems();
|
|
97
96
|
this.updateRadioFocusable();
|
|
98
97
|
await this.updateComplete;
|
|
@@ -116,7 +115,7 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
116
115
|
checkValidity() {
|
|
117
116
|
const valid = this.inputRef.value.checkValidity();
|
|
118
117
|
if (!valid) {
|
|
119
|
-
emit(
|
|
118
|
+
this.emit('invalid', {
|
|
120
119
|
bubbles: false,
|
|
121
120
|
cancelable: true,
|
|
122
121
|
composed: false,
|
|
@@ -132,13 +131,13 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
132
131
|
reportValidity() {
|
|
133
132
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
134
133
|
if (this.invalid) {
|
|
135
|
-
const
|
|
134
|
+
const eventProceeded = this.emit('invalid', {
|
|
136
135
|
bubbles: false,
|
|
137
136
|
cancelable: true,
|
|
138
137
|
composed: false,
|
|
139
138
|
});
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
if (!eventProceeded) {
|
|
140
|
+
// 调用了 preventDefault() 时,隐藏默认的表单错误提示
|
|
142
141
|
this.inputRef.value.blur();
|
|
143
142
|
this.inputRef.value.focus();
|
|
144
143
|
}
|
|
@@ -177,9 +176,7 @@ let RadioGroup = class RadioGroup extends LitElement {
|
|
|
177
176
|
async onClick(event) {
|
|
178
177
|
await this.definedController.whenDefined();
|
|
179
178
|
const target = event.target;
|
|
180
|
-
const item =
|
|
181
|
-
? target
|
|
182
|
-
: $(target).closest('mdui-radio')[0];
|
|
179
|
+
const item = target.closest('mdui-radio');
|
|
183
180
|
if (!item || item.disabled) {
|
|
184
181
|
return;
|
|
185
182
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
2
|
import '@mdui/shared/icons/circle.js';
|
|
3
3
|
import '@mdui/shared/icons/radio-button-unchecked.js';
|
|
4
4
|
import '../icon.js';
|
|
5
5
|
import type { Ripple } from '../ripple/index.js';
|
|
6
6
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
7
|
-
declare const Radio_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 Radio_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 单选框组件。需与 `<mdui-radio-group>` 组件配合使用
|
|
10
10
|
*
|
|
@@ -28,7 +28,7 @@ declare const Radio_base: import("@open-wc/dedupe-mixin").Constructor<import("..
|
|
|
28
28
|
* @csspart checked-icon 选中状态的图标
|
|
29
29
|
* @csspart label - 文本
|
|
30
30
|
*/
|
|
31
|
-
export declare class Radio extends Radio_base {
|
|
31
|
+
export declare class Radio extends Radio_base<RadioEventMap> {
|
|
32
32
|
static styles: CSSResultGroup;
|
|
33
33
|
/**
|
|
34
34
|
* 当前单选项的值
|
|
@@ -64,6 +64,11 @@ export declare class Radio extends Radio_base {
|
|
|
64
64
|
protected render(): TemplateResult;
|
|
65
65
|
private isDisabled;
|
|
66
66
|
}
|
|
67
|
+
export interface RadioEventMap {
|
|
68
|
+
focus: FocusEvent;
|
|
69
|
+
blur: FocusEvent;
|
|
70
|
+
change: CustomEvent<void>;
|
|
71
|
+
}
|
|
67
72
|
declare global {
|
|
68
73
|
interface HTMLElementTagNameMap {
|
|
69
74
|
'mdui-radio': Radio;
|
|
@@ -1,11 +1,11 @@
|
|
|
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 { createRef, ref } from 'lit/directives/ref.js';
|
|
6
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
6
7
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
7
8
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
8
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
9
9
|
import '@mdui/shared/icons/circle.js';
|
|
10
10
|
import '@mdui/shared/icons/radio-button-unchecked.js';
|
|
11
11
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
@@ -36,7 +36,7 @@ import { radioStyle } from './radio-style.js';
|
|
|
36
36
|
* @csspart checked-icon 选中状态的图标
|
|
37
37
|
* @csspart label - 文本
|
|
38
38
|
*/
|
|
39
|
-
let Radio = class Radio extends RippleMixin(FocusableMixin(
|
|
39
|
+
let Radio = class Radio extends RippleMixin(FocusableMixin(MduiElement)) {
|
|
40
40
|
constructor() {
|
|
41
41
|
super(...arguments);
|
|
42
42
|
/**
|
|
@@ -76,7 +76,7 @@ let Radio = class Radio extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
76
76
|
return this.isDisabled() || !this.focusable;
|
|
77
77
|
}
|
|
78
78
|
onCheckedChange() {
|
|
79
|
-
emit(
|
|
79
|
+
this.emit('change');
|
|
80
80
|
}
|
|
81
81
|
firstUpdated(_changedProperties) {
|
|
82
82
|
super.firstUpdated(_changedProperties);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { PropertyValues } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/css.js';
|
|
3
2
|
import { SliderBase } from '../slider/slider-base.js';
|
|
4
3
|
import type { Ripple } from '../ripple/index.js';
|
|
5
4
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
6
|
-
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
5
|
+
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
7
6
|
/**
|
|
8
7
|
* @summary 范围滑块组件
|
|
9
8
|
*
|
|
@@ -23,7 +22,7 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
23
22
|
* @csspart label - 提示文本
|
|
24
23
|
* @csspart tickmark - 刻度标记
|
|
25
24
|
*/
|
|
26
|
-
export declare class RangeSlider extends SliderBase implements FormControl {
|
|
25
|
+
export declare class RangeSlider extends SliderBase<RangeSliderEventMap> implements FormControl {
|
|
27
26
|
static styles: CSSResultGroup;
|
|
28
27
|
/**
|
|
29
28
|
* 默认值。在重置表单时,将重置为该默认值。该属性只能通过 JavaScript 属性设置
|
|
@@ -60,6 +59,13 @@ export declare class RangeSlider extends SliderBase implements FormControl {
|
|
|
60
59
|
private updateStyle;
|
|
61
60
|
private onInput;
|
|
62
61
|
}
|
|
62
|
+
export interface RangeSliderEventMap {
|
|
63
|
+
focus: FocusEvent;
|
|
64
|
+
blur: FocusEvent;
|
|
65
|
+
change: CustomEvent<void>;
|
|
66
|
+
input: Event;
|
|
67
|
+
invalid: CustomEvent<void>;
|
|
68
|
+
}
|
|
63
69
|
declare global {
|
|
64
70
|
interface HTMLElementTagNameMap {
|
|
65
71
|
'mdui-range-slider': RangeSlider;
|
|
@@ -65,7 +65,7 @@ let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
65
65
|
}
|
|
66
66
|
set value(_value) {
|
|
67
67
|
const oldValue = [...this._value];
|
|
68
|
-
this._value = _value;
|
|
68
|
+
this._value = [this.fixValue(_value[0]), this.fixValue(_value[1])];
|
|
69
69
|
this.requestUpdate('value', oldValue);
|
|
70
70
|
this.updateComplete.then(() => {
|
|
71
71
|
this.updateStyle();
|
|
@@ -85,7 +85,11 @@ let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
85
85
|
}
|
|
86
86
|
connectedCallback() {
|
|
87
87
|
super.connectedCallback();
|
|
88
|
-
this.value
|
|
88
|
+
if (!this.value.length) {
|
|
89
|
+
this.value = [this.min, this.max];
|
|
90
|
+
}
|
|
91
|
+
this.value[0] = this.fixValue(this.value[0]);
|
|
92
|
+
this.value[1] = this.fixValue(this.value[1]);
|
|
89
93
|
if (!this.defaultValue.length) {
|
|
90
94
|
this.defaultValue = [...this.value];
|
|
91
95
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/addClass.js';
|
|
3
2
|
import '@mdui/jq/methods/children.js';
|
|
4
3
|
import '@mdui/jq/methods/css.js';
|
|
@@ -11,13 +10,14 @@ import '@mdui/jq/methods/offset.js';
|
|
|
11
10
|
import '@mdui/jq/methods/on.js';
|
|
12
11
|
import '@mdui/jq/methods/prependTo.js';
|
|
13
12
|
import '@mdui/jq/methods/remove.js';
|
|
13
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
14
14
|
import type { TemplateResult, CSSResultGroup } from 'lit';
|
|
15
15
|
/**
|
|
16
16
|
* 处理点击时的涟漪动画;及添加 hover、focused、dragged 的背景色
|
|
17
17
|
* 背景色通过在 .surface 元素上添加对应的 class 实现
|
|
18
18
|
* 阴影在 ripple-mixin 中处理,通过在 :host 元素上添加 attribute 供 CSS 选择器添加样式
|
|
19
19
|
*/
|
|
20
|
-
export declare class Ripple extends
|
|
20
|
+
export declare class Ripple extends MduiElement<RippleEventMap> {
|
|
21
21
|
static styles: CSSResultGroup;
|
|
22
22
|
/**
|
|
23
23
|
* 是否禁用涟漪动画
|
|
@@ -37,6 +37,8 @@ export declare class Ripple extends LitElement {
|
|
|
37
37
|
endDrag(): void;
|
|
38
38
|
protected render(): TemplateResult;
|
|
39
39
|
}
|
|
40
|
+
export interface RippleEventMap {
|
|
41
|
+
}
|
|
40
42
|
declare global {
|
|
41
43
|
interface HTMLElementTagNameMap {
|
|
42
44
|
'mdui-ripple': Ripple;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
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 { createRef, ref } from 'lit/directives/ref.js';
|
|
@@ -16,6 +16,7 @@ import '@mdui/jq/methods/offset.js';
|
|
|
16
16
|
import '@mdui/jq/methods/on.js';
|
|
17
17
|
import '@mdui/jq/methods/prependTo.js';
|
|
18
18
|
import '@mdui/jq/methods/remove.js';
|
|
19
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
19
20
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
20
21
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
21
22
|
import { style } from './style.js';
|
|
@@ -24,7 +25,7 @@ import { style } from './style.js';
|
|
|
24
25
|
* 背景色通过在 .surface 元素上添加对应的 class 实现
|
|
25
26
|
* 阴影在 ripple-mixin 中处理,通过在 :host 元素上添加 attribute 供 CSS 选择器添加样式
|
|
26
27
|
*/
|
|
27
|
-
let Ripple = class Ripple extends
|
|
28
|
+
let Ripple = class Ripple extends MduiElement {
|
|
28
29
|
constructor() {
|
|
29
30
|
super(...arguments);
|
|
30
31
|
/**
|
|
@@ -3,7 +3,7 @@ import './index.js';
|
|
|
3
3
|
import type { Ripple } from './index.js';
|
|
4
4
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
5
5
|
import type { LitElement } from 'lit';
|
|
6
|
-
export declare class RippleMixinInterface
|
|
6
|
+
export declare class RippleMixinInterface {
|
|
7
7
|
noRipple: boolean;
|
|
8
8
|
protected getRippleIndex: () => number | undefined;
|
|
9
9
|
protected get rippleElement(): Ripple | Ripple[] | NodeListOf<Ripple>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const segmentedButtonGroupStyle = css `:host{--shape-corner:var(--mdui-shape-corner-full);position:relative;display:inline-flex;height:2.5rem;font-size:var(--mdui-typescale-label-large-size);font-weight:var(--mdui-typescale-label-large-weight);letter-spacing:var(--mdui-typescale-label-large-tracking);line-height:var(--mdui-typescale-label-large-line-height);color:rgb(var(--mdui-color-on-surface));--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}:host([full-width]){display:flex;flex-wrap:nowrap}input,select{position:absolute;width:100%;height:100%;padding:0;opacity:0;pointer-events:none}`;
|
|
2
|
+
export const segmentedButtonGroupStyle = css `:host{--shape-corner:var(--mdui-shape-corner-full);position:relative;display:inline-flex;vertical-align:middle;height:2.5rem;font-size:var(--mdui-typescale-label-large-size);font-weight:var(--mdui-typescale-label-large-weight);letter-spacing:var(--mdui-typescale-label-large-tracking);line-height:var(--mdui-typescale-label-large-line-height);color:rgb(var(--mdui-color-on-surface));--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}:host([full-width]){display:flex;flex-wrap:nowrap}input,select{position:absolute;width:100%;height:100%;padding:0;opacity:0;pointer-events:none}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/find.js';
|
|
3
2
|
import '@mdui/jq/methods/get.js';
|
|
3
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
4
4
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
5
5
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
6
6
|
/**
|
|
@@ -21,7 +21,7 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
21
21
|
*
|
|
22
22
|
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
23
23
|
*/
|
|
24
|
-
export declare class SegmentedButtonGroup extends
|
|
24
|
+
export declare class SegmentedButtonGroup extends MduiElement<SegmentedButtonGroupEventMap> implements FormControl {
|
|
25
25
|
static styles: CSSResultGroup;
|
|
26
26
|
/**
|
|
27
27
|
* 是否填满父元素宽度
|
|
@@ -121,6 +121,10 @@ export declare class SegmentedButtonGroup extends LitElement implements FormCont
|
|
|
121
121
|
private setValue;
|
|
122
122
|
private updateItems;
|
|
123
123
|
}
|
|
124
|
+
export interface SegmentedButtonGroupEventMap {
|
|
125
|
+
change: CustomEvent<void>;
|
|
126
|
+
invalid: CustomEvent<void>;
|
|
127
|
+
}
|
|
124
128
|
declare global {
|
|
125
129
|
interface HTMLElementTagNameMap {
|
|
126
130
|
'mdui-segmented-button-group': SegmentedButtonGroup;
|
|
@@ -1,5 +1,5 @@
|
|
|
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 { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import { map } from 'lit/directives/map.js';
|
|
@@ -9,13 +9,13 @@ import { $ } from '@mdui/jq/$.js';
|
|
|
9
9
|
import '@mdui/jq/methods/find.js';
|
|
10
10
|
import '@mdui/jq/methods/get.js';
|
|
11
11
|
import { isString } from '@mdui/jq/shared/helper.js';
|
|
12
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
12
13
|
import { DefinedController } from '@mdui/shared/controllers/defined.js';
|
|
13
14
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
14
15
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
15
16
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
16
17
|
import { arraysEqualIgnoreOrder } from '@mdui/shared/helpers/array.js';
|
|
17
18
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
18
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
19
19
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
20
20
|
import { segmentedButtonGroupStyle } from './segmented-button-group-style.js';
|
|
21
21
|
/**
|
|
@@ -36,7 +36,7 @@ import { segmentedButtonGroupStyle } from './segmented-button-group-style.js';
|
|
|
36
36
|
*
|
|
37
37
|
* @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
|
|
38
38
|
*/
|
|
39
|
-
let SegmentedButtonGroup = class SegmentedButtonGroup extends
|
|
39
|
+
let SegmentedButtonGroup = class SegmentedButtonGroup extends MduiElement {
|
|
40
40
|
constructor() {
|
|
41
41
|
super(...arguments);
|
|
42
42
|
/**
|
|
@@ -138,7 +138,7 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends LitElement {
|
|
|
138
138
|
const value = this.isMultiple ? values : values[0] || '';
|
|
139
139
|
this.setValue(value);
|
|
140
140
|
if (!this.isInitial) {
|
|
141
|
-
emit(
|
|
141
|
+
this.emit('change');
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
async onValueChange() {
|
|
@@ -200,7 +200,7 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends LitElement {
|
|
|
200
200
|
checkValidity() {
|
|
201
201
|
const valid = this.inputRef.value.checkValidity();
|
|
202
202
|
if (!valid) {
|
|
203
|
-
emit(
|
|
203
|
+
this.emit('invalid', {
|
|
204
204
|
bubbles: false,
|
|
205
205
|
cancelable: true,
|
|
206
206
|
composed: false,
|
|
@@ -216,13 +216,13 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends LitElement {
|
|
|
216
216
|
reportValidity() {
|
|
217
217
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
218
218
|
if (this.invalid) {
|
|
219
|
-
const
|
|
219
|
+
const eventProceeded = this.emit('invalid', {
|
|
220
220
|
bubbles: false,
|
|
221
221
|
cancelable: true,
|
|
222
222
|
composed: false,
|
|
223
223
|
});
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
if (!eventProceeded) {
|
|
225
|
+
// 调用了 preventDefault() 时,隐藏默认的表单错误提示
|
|
226
226
|
this.inputRef.value.blur();
|
|
227
227
|
this.inputRef.value.focus();
|
|
228
228
|
}
|
|
@@ -273,7 +273,7 @@ let SegmentedButtonGroup = class SegmentedButtonGroup extends LitElement {
|
|
|
273
273
|
await this.definedController.whenDefined();
|
|
274
274
|
const target = event.target;
|
|
275
275
|
const item = target.closest('mdui-segmented-button');
|
|
276
|
-
if (item.disabled) {
|
|
276
|
+
if (!item || item.disabled) {
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
279
279
|
if (this.isSelectable && item.value) {
|
|
@@ -30,7 +30,7 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
|
30
30
|
* @csspart label - 文本内容
|
|
31
31
|
* @csspart loading - 加载中状态的 `<mdui-circular-progress>` 元素
|
|
32
32
|
*/
|
|
33
|
-
export declare class SegmentedButton extends ButtonBase {
|
|
33
|
+
export declare class SegmentedButton extends ButtonBase<SegmentedButtonEventMap> {
|
|
34
34
|
static styles: CSSResultGroup;
|
|
35
35
|
/**
|
|
36
36
|
* 左侧的 Material Icons 图标名。也可以通过 `slot="icon"` 设置
|
|
@@ -66,6 +66,11 @@ export declare class SegmentedButton extends ButtonBase {
|
|
|
66
66
|
private renderEndIcon;
|
|
67
67
|
private renderInner;
|
|
68
68
|
}
|
|
69
|
+
export interface SegmentedButtonEventMap {
|
|
70
|
+
focus: FocusEvent;
|
|
71
|
+
blur: FocusEvent;
|
|
72
|
+
invalid: CustomEvent<void>;
|
|
73
|
+
}
|
|
69
74
|
declare global {
|
|
70
75
|
interface HTMLElementTagNameMap {
|
|
71
76
|
'mdui-segmented-button': SegmentedButton;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertyValues } from 'lit';
|
|
2
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
2
3
|
import '../chip.js';
|
|
3
4
|
import '../dropdown.js';
|
|
4
5
|
import '../menu.js';
|
|
5
6
|
import '../text-field.js';
|
|
6
7
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
7
8
|
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
8
|
-
declare const Select_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof
|
|
9
|
+
declare const Select_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
9
10
|
/**
|
|
10
11
|
* @summary 选择框组件。需与 `<mdui-menu-item>` 组件配合使用
|
|
11
12
|
*
|
|
@@ -35,7 +36,7 @@ declare const Select_base: import("@open-wc/dedupe-mixin").Constructor<import("@
|
|
|
35
36
|
* @csspart text-field - 文本框,即 [`<mdui-text-field>`](/docs/2/components/text-field) 元素
|
|
36
37
|
* @csspart menu - 下拉菜单,即 [`<mdui-menu>`](/docs/2/components/menu) 元素
|
|
37
38
|
*/
|
|
38
|
-
export declare class Select extends Select_base implements FormControl {
|
|
39
|
+
export declare class Select extends Select_base<SelectEventMap> implements FormControl {
|
|
39
40
|
static styles: CSSResultGroup;
|
|
40
41
|
/**
|
|
41
42
|
* 下拉框形状。可选值为:
|
|
@@ -192,6 +193,13 @@ export declare class Select extends Select_base implements FormControl {
|
|
|
192
193
|
*/
|
|
193
194
|
private onTextFieldKeyDown;
|
|
194
195
|
}
|
|
196
|
+
export interface SelectEventMap {
|
|
197
|
+
focus: FocusEvent;
|
|
198
|
+
blur: FocusEvent;
|
|
199
|
+
change: CustomEvent<void>;
|
|
200
|
+
invalid: CustomEvent<void>;
|
|
201
|
+
clear: CustomEvent<void>;
|
|
202
|
+
}
|
|
195
203
|
declare global {
|
|
196
204
|
interface HTMLElementTagNameMap {
|
|
197
205
|
'mdui-select': Select;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html,
|
|
2
|
+
import { html, nothing } from 'lit';
|
|
3
3
|
import { customElement, property, queryAssignedElements, state, } from 'lit/decorators.js';
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import { map } from 'lit/directives/map.js';
|
|
6
6
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
7
7
|
import { when } from 'lit/directives/when.js';
|
|
8
8
|
import { isString } from '@mdui/jq/shared/helper.js';
|
|
9
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
9
10
|
import { DefinedController } from '@mdui/shared/controllers/defined.js';
|
|
10
11
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
11
12
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
12
13
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
13
14
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
14
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
15
15
|
import { observeResize } from '@mdui/shared/helpers/observeResize.js';
|
|
16
16
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
17
17
|
import { FocusableMixin } from '@mdui/shared/mixins/focusable.js';
|
|
@@ -49,7 +49,7 @@ import { style } from './style.js';
|
|
|
49
49
|
* @csspart text-field - 文本框,即 [`<mdui-text-field>`](/docs/2/components/text-field) 元素
|
|
50
50
|
* @csspart menu - 下拉菜单,即 [`<mdui-menu>`](/docs/2/components/menu) 元素
|
|
51
51
|
*/
|
|
52
|
-
let Select = class Select extends FocusableMixin(
|
|
52
|
+
let Select = class Select extends FocusableMixin(MduiElement) {
|
|
53
53
|
constructor() {
|
|
54
54
|
super(...arguments);
|
|
55
55
|
/**
|
|
@@ -164,7 +164,7 @@ let Select = class Select extends FocusableMixin(LitElement) {
|
|
|
164
164
|
checkValidity() {
|
|
165
165
|
const valid = this.hiddenInputRef.value.checkValidity();
|
|
166
166
|
if (!valid) {
|
|
167
|
-
emit(
|
|
167
|
+
this.emit('invalid', {
|
|
168
168
|
bubbles: false,
|
|
169
169
|
cancelable: true,
|
|
170
170
|
composed: false,
|
|
@@ -180,7 +180,7 @@ let Select = class Select extends FocusableMixin(LitElement) {
|
|
|
180
180
|
reportValidity() {
|
|
181
181
|
this.invalid = !this.hiddenInputRef.value.reportValidity();
|
|
182
182
|
if (this.invalid) {
|
|
183
|
-
emit(
|
|
183
|
+
this.emit('invalid', {
|
|
184
184
|
bubbles: false,
|
|
185
185
|
cancelable: true,
|
|
186
186
|
composed: false,
|
|
@@ -21,7 +21,7 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
|
21
21
|
* @csspart label 提示文本
|
|
22
22
|
* @csspart tickmark - 刻度标记
|
|
23
23
|
*/
|
|
24
|
-
export declare class Slider extends SliderBase implements FormControl {
|
|
24
|
+
export declare class Slider extends SliderBase<SliderEventMap> implements FormControl {
|
|
25
25
|
static styles: CSSResultGroup;
|
|
26
26
|
/**
|
|
27
27
|
* 滑块的值,将于表单数据一起提交
|
|
@@ -46,6 +46,13 @@ export declare class Slider extends SliderBase implements FormControl {
|
|
|
46
46
|
private updateStyle;
|
|
47
47
|
private onInput;
|
|
48
48
|
}
|
|
49
|
+
export interface SliderEventMap {
|
|
50
|
+
focus: FocusEvent;
|
|
51
|
+
blur: FocusEvent;
|
|
52
|
+
change: CustomEvent<void>;
|
|
53
|
+
input: Event;
|
|
54
|
+
invalid: CustomEvent<void>;
|
|
55
|
+
}
|
|
49
56
|
declare global {
|
|
50
57
|
interface HTMLElementTagNameMap {
|
|
51
58
|
'mdui-slider': Slider;
|
|
@@ -49,7 +49,8 @@ let Slider = class Slider extends SliderBase {
|
|
|
49
49
|
get rippleElement() {
|
|
50
50
|
return this.rippleRef.value;
|
|
51
51
|
}
|
|
52
|
-
onValueChange() {
|
|
52
|
+
async onValueChange() {
|
|
53
|
+
this.value = this.fixValue(this.value);
|
|
53
54
|
// reset 引起的值变更,不执行验证;直接修改值引起的变更,需要进行验证
|
|
54
55
|
const form = this.formController.getForm();
|
|
55
56
|
if (form && formResets.get(form)?.has(this)) {
|
|
@@ -57,20 +58,14 @@ let Slider = class Slider extends SliderBase {
|
|
|
57
58
|
formResets.get(form).delete(this);
|
|
58
59
|
}
|
|
59
60
|
else {
|
|
61
|
+
await this.updateComplete;
|
|
60
62
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
61
63
|
}
|
|
62
|
-
this.inputRef.value.value = this.value.toString();
|
|
63
|
-
this.value = parseFloat(this.inputRef.value.value);
|
|
64
64
|
this.updateStyle();
|
|
65
65
|
}
|
|
66
66
|
connectedCallback() {
|
|
67
67
|
super.connectedCallback();
|
|
68
|
-
|
|
69
|
-
this.value = this.min;
|
|
70
|
-
}
|
|
71
|
-
if (this.value > this.max) {
|
|
72
|
-
this.value = this.max;
|
|
73
|
-
}
|
|
68
|
+
this.value = this.fixValue(this.value);
|
|
74
69
|
}
|
|
75
70
|
firstUpdated(changedProperties) {
|
|
76
71
|
super.firstUpdated(changedProperties);
|
|
@@ -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 = [
|