mdui 2.0.1 → 2.0.2
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.js +2 -1
- package/components/badge/index.js +2 -1
- package/components/bottom-app-bar/index.d.ts +2 -2
- package/components/bottom-app-bar/index.js +4 -3
- package/components/button/button-base.d.ts +2 -2
- package/components/button/button-base.js +15 -14
- package/components/button/index.js +2 -1
- package/components/button-icon/index.js +2 -1
- package/components/card/index.d.ts +1 -1
- package/components/card/index.js +5 -2
- package/components/checkbox/index.js +7 -10
- package/components/checkbox/style.js +1 -1
- package/components/chip/index.js +2 -1
- package/components/circular-progress/index.js +3 -3
- package/components/collapse/collapse-item-style.js +1 -1
- package/components/collapse/collapse-item.d.ts +2 -1
- package/components/collapse/collapse-item.js +23 -20
- package/components/collapse/collapse.d.ts +6 -6
- package/components/collapse/collapse.js +57 -34
- package/components/dialog/index.d.ts +3 -2
- package/components/dialog/index.js +27 -23
- package/components/divider/index.js +2 -1
- package/components/dropdown/index.d.ts +4 -5
- package/components/dropdown/index.js +56 -51
- package/components/fab/index.d.ts +1 -0
- package/components/fab/index.js +10 -5
- package/components/icon/index.js +2 -1
- package/components/layout/helper.d.ts +5 -6
- package/components/layout/helper.js +42 -48
- package/components/layout/layout-item-base.js +1 -2
- package/components/layout/layout-item.js +3 -3
- package/components/layout/layout-main.js +2 -1
- package/components/layout/layout.js +2 -1
- package/components/linear-progress/index.js +3 -3
- package/components/list/list-item.js +3 -2
- package/components/list/list-subheader.js +2 -1
- package/components/list/list.js +2 -1
- package/components/menu/menu-item.d.ts +1 -0
- package/components/menu/menu-item.js +45 -28
- package/components/menu/menu.d.ts +4 -1
- package/components/menu/menu.js +82 -56
- package/components/navigation-bar/navigation-bar-item-style.js +1 -1
- package/components/navigation-bar/navigation-bar-item.d.ts +6 -2
- package/components/navigation-bar/navigation-bar-item.js +26 -10
- package/components/navigation-bar/navigation-bar.d.ts +6 -6
- package/components/navigation-bar/navigation-bar.js +49 -42
- package/components/navigation-drawer/index.d.ts +5 -1
- package/components/navigation-drawer/index.js +62 -41
- package/components/navigation-rail/navigation-rail-item-style.js +1 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +6 -2
- package/components/navigation-rail/navigation-rail-item.js +20 -8
- package/components/navigation-rail/navigation-rail.d.ts +4 -5
- package/components/navigation-rail/navigation-rail.js +51 -44
- package/components/radio/radio-group.d.ts +6 -4
- package/components/radio/radio-group.js +61 -48
- package/components/radio/radio-style.js +1 -1
- package/components/radio/radio.d.ts +3 -2
- package/components/radio/radio.js +24 -17
- package/components/range-slider/index.js +7 -9
- package/components/ripple/index.js +2 -1
- package/components/segmented-button/segmented-button-group.d.ts +6 -3
- package/components/segmented-button/segmented-button-group.js +84 -69
- package/components/segmented-button/segmented-button.d.ts +2 -2
- package/components/segmented-button/segmented-button.js +5 -4
- package/components/select/index.d.ts +2 -2
- package/components/select/index.js +26 -24
- package/components/slider/index.js +7 -9
- package/components/slider/slider-base-style.js +1 -1
- package/components/slider/slider-base.js +1 -5
- package/components/snackbar/index.js +2 -1
- package/components/switch/index.js +6 -9
- package/components/switch/style.js +1 -1
- package/components/tabs/tab-panel.js +2 -1
- package/components/tabs/tab-style.js +1 -1
- package/components/tabs/tab.js +10 -5
- package/components/tabs/tabs-style.js +1 -1
- package/components/tabs/tabs.d.ts +6 -5
- package/components/tabs/tabs.js +52 -38
- package/components/text-field/index.d.ts +2 -2
- package/components/text-field/index.js +32 -54
- package/components/text-field/style.js +1 -1
- package/components/tooltip/index.d.ts +5 -5
- package/components/tooltip/index.js +30 -25
- package/components/top-app-bar/top-app-bar-title-style.js +1 -1
- package/components/top-app-bar/top-app-bar-title.js +16 -12
- package/components/top-app-bar/top-app-bar.d.ts +2 -2
- package/components/top-app-bar/top-app-bar.js +6 -4
- package/custom-elements.json +3421 -3126
- package/functions/getTheme.js +3 -3
- package/functions/snackbar.js +1 -2
- package/functions/utils/colorScheme.js +2 -2
- package/html-data.zh-cn.json +438 -438
- package/mdui.esm.js +8 -8
- package/mdui.global.js +8 -8
- package/package.json +7 -7
- package/web-types.zh-cn.json +770 -770
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { html, LitElement } from 'lit';
|
|
3
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
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';
|
|
6
6
|
import { $ } from '@mdui/jq/$.js';
|
|
@@ -8,6 +8,7 @@ import '@mdui/jq/methods/closest.js';
|
|
|
8
8
|
import '@mdui/jq/methods/find.js';
|
|
9
9
|
import '@mdui/jq/methods/get.js';
|
|
10
10
|
import { isNodeName } from '@mdui/jq/shared/helper.js';
|
|
11
|
+
import { DefinedController } from '@mdui/shared/controllers/defined.js';
|
|
11
12
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
12
13
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
13
14
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
@@ -31,7 +32,7 @@ import { radioGroupStyle } from './radio-group-style.js';
|
|
|
31
32
|
*
|
|
32
33
|
* @slot - `<mdui-radio>` 元素
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
+
let RadioGroup = class RadioGroup extends LitElement {
|
|
35
36
|
constructor() {
|
|
36
37
|
super(...arguments);
|
|
37
38
|
/**
|
|
@@ -58,8 +59,13 @@ export let RadioGroup = class RadioGroup extends LitElement {
|
|
|
58
59
|
* 是否验证未通过
|
|
59
60
|
*/
|
|
60
61
|
this.invalid = false;
|
|
62
|
+
// 是否是初始状态,初始状态不显示动画
|
|
63
|
+
this.isInitial = true;
|
|
61
64
|
this.inputRef = createRef();
|
|
62
65
|
this.formController = new FormController(this);
|
|
66
|
+
this.definedController = new DefinedController(this, {
|
|
67
|
+
relatedElements: ['mdui-radio'],
|
|
68
|
+
});
|
|
63
69
|
}
|
|
64
70
|
/**
|
|
65
71
|
* 表单验证状态对象
|
|
@@ -73,24 +79,26 @@ export let RadioGroup = class RadioGroup extends LitElement {
|
|
|
73
79
|
get validationMessage() {
|
|
74
80
|
return this.inputRef.value.validationMessage;
|
|
75
81
|
}
|
|
76
|
-
|
|
82
|
+
// 为了使 <mdui-radio> 可以不是该组件的直接子元素,这里不用 @queryAssignedElements()
|
|
83
|
+
get items() {
|
|
77
84
|
return $(this).find('mdui-radio').get();
|
|
78
85
|
}
|
|
79
|
-
get
|
|
86
|
+
get itemsEnabled() {
|
|
80
87
|
return $(this)
|
|
81
88
|
.find('mdui-radio:not([disabled])')
|
|
82
89
|
.get();
|
|
83
90
|
}
|
|
84
91
|
async onValueChange() {
|
|
85
|
-
|
|
92
|
+
this.isInitial = false;
|
|
93
|
+
await this.definedController.whenDefined();
|
|
86
94
|
emit(this, 'input');
|
|
87
95
|
emit(this, 'change');
|
|
88
|
-
this.
|
|
96
|
+
this.updateItems();
|
|
89
97
|
this.updateRadioFocusable();
|
|
90
98
|
await this.updateComplete;
|
|
91
99
|
// reset 引起的值变更,不执行验证;直接修改值引起的变更,需要进行验证
|
|
92
100
|
const form = this.formController.getForm();
|
|
93
|
-
if (form &&
|
|
101
|
+
if (form && formResets.get(form)?.has(this)) {
|
|
94
102
|
this.invalid = false;
|
|
95
103
|
formResets.get(form).delete(this);
|
|
96
104
|
}
|
|
@@ -98,11 +106,9 @@ export let RadioGroup = class RadioGroup extends LitElement {
|
|
|
98
106
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
99
107
|
}
|
|
100
108
|
}
|
|
101
|
-
onInvalidChange() {
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
onDisabledChange() {
|
|
105
|
-
this.radios.forEach((radio) => (radio.groupDisabled = this.disabled));
|
|
109
|
+
async onInvalidChange() {
|
|
110
|
+
await this.definedController.whenDefined();
|
|
111
|
+
this.updateItems();
|
|
106
112
|
}
|
|
107
113
|
/**
|
|
108
114
|
* 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`
|
|
@@ -149,63 +155,68 @@ export let RadioGroup = class RadioGroup extends LitElement {
|
|
|
149
155
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
150
156
|
}
|
|
151
157
|
render() {
|
|
152
|
-
return html `<fieldset><input ${ref(this.inputRef)} type="radio" class="input" name="${ifDefined(this.name)}" value="${ifDefined(this.value)}" .checked="${!!this.value}" .required="${this.required}" tabindex="-1" @keydown="${this.onKeyDown}"><slot @click="${this.
|
|
158
|
+
return html `<fieldset><input ${ref(this.inputRef)} type="radio" class="input" name="${ifDefined(this.name)}" value="${ifDefined(this.value)}" .checked="${!!this.value}" .required="${this.required}" tabindex="-1" @keydown="${this.onKeyDown}"><slot @click="${this.onClick}" @keydown="${this.onKeyDown}" @slotchange="${this.onSlotChange}" @change="${this.onCheckedChange}"></slot></fieldset>`;
|
|
153
159
|
}
|
|
154
160
|
// 更新 mdui-radio 的 checked 后,需要更新可聚焦状态
|
|
155
161
|
// 同一个 mdui-radio-group 中的多个 mdui-radio,仅有一个可聚焦
|
|
156
162
|
// 若有已选中的,则已选中的可聚焦;若没有已选中的,则第一个可聚焦
|
|
157
163
|
updateRadioFocusable() {
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
161
|
-
|
|
164
|
+
const items = this.items;
|
|
165
|
+
const itemChecked = items.find((item) => item.checked);
|
|
166
|
+
if (itemChecked) {
|
|
167
|
+
items.forEach((item) => {
|
|
168
|
+
item.focusable = item === itemChecked;
|
|
169
|
+
});
|
|
162
170
|
}
|
|
163
171
|
else {
|
|
164
|
-
this.
|
|
172
|
+
this.itemsEnabled.forEach((item, index) => {
|
|
173
|
+
item.focusable = !index;
|
|
174
|
+
});
|
|
165
175
|
}
|
|
166
176
|
}
|
|
167
|
-
async
|
|
177
|
+
async onClick(event) {
|
|
178
|
+
await this.definedController.whenDefined();
|
|
168
179
|
const target = event.target;
|
|
169
|
-
const
|
|
180
|
+
const item = isNodeName(target, 'mdui-radio')
|
|
170
181
|
? target
|
|
171
182
|
: $(target).closest('mdui-radio')[0];
|
|
172
|
-
if (
|
|
183
|
+
if (!item || item.disabled) {
|
|
173
184
|
return;
|
|
174
185
|
}
|
|
175
|
-
this.value =
|
|
186
|
+
this.value = item.value;
|
|
176
187
|
await this.updateComplete;
|
|
177
|
-
|
|
188
|
+
item.focus();
|
|
178
189
|
}
|
|
179
190
|
/**
|
|
180
191
|
* 在内部的 `<mdui-radio>` 上按下按键时,在 `<mdui-radio>` 之间切换焦点
|
|
181
192
|
*/
|
|
182
|
-
onKeyDown(event) {
|
|
183
|
-
var _a;
|
|
193
|
+
async onKeyDown(event) {
|
|
184
194
|
if (!['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].includes(event.key)) {
|
|
185
195
|
return;
|
|
186
196
|
}
|
|
187
|
-
|
|
188
|
-
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
await this.definedController.whenDefined();
|
|
199
|
+
const items = this.itemsEnabled;
|
|
200
|
+
const itemChecked = items.find((item) => item.checked) ?? items[0];
|
|
189
201
|
const incr = event.key === ' '
|
|
190
202
|
? 0
|
|
191
203
|
: ['ArrowUp', 'ArrowLeft'].includes(event.key)
|
|
192
204
|
? -1
|
|
193
205
|
: 1;
|
|
194
|
-
let index =
|
|
206
|
+
let index = items.indexOf(itemChecked) + incr;
|
|
195
207
|
if (index < 0) {
|
|
196
|
-
index =
|
|
208
|
+
index = items.length - 1;
|
|
197
209
|
}
|
|
198
|
-
if (index >
|
|
210
|
+
if (index > items.length - 1) {
|
|
199
211
|
index = 0;
|
|
200
212
|
}
|
|
201
|
-
this.value =
|
|
202
|
-
this.updateComplete
|
|
203
|
-
|
|
204
|
-
});
|
|
205
|
-
event.preventDefault();
|
|
213
|
+
this.value = items[index].value;
|
|
214
|
+
await this.updateComplete;
|
|
215
|
+
items[index].focus();
|
|
206
216
|
}
|
|
207
|
-
onSlotChange() {
|
|
208
|
-
this.
|
|
217
|
+
async onSlotChange() {
|
|
218
|
+
await this.definedController.whenDefined();
|
|
219
|
+
this.updateItems();
|
|
209
220
|
this.updateRadioFocusable();
|
|
210
221
|
}
|
|
211
222
|
/**
|
|
@@ -213,8 +224,15 @@ export let RadioGroup = class RadioGroup extends LitElement {
|
|
|
213
224
|
*/
|
|
214
225
|
onCheckedChange(event) {
|
|
215
226
|
event.stopPropagation();
|
|
216
|
-
|
|
217
|
-
|
|
227
|
+
}
|
|
228
|
+
// 更新 <mdui-radio> 的状态
|
|
229
|
+
updateItems() {
|
|
230
|
+
this.items.forEach((item) => {
|
|
231
|
+
item.checked = item.value === this.value;
|
|
232
|
+
item.invalid = this.invalid;
|
|
233
|
+
item.groupDisabled = this.disabled;
|
|
234
|
+
item.isInitial = this.isInitial;
|
|
235
|
+
});
|
|
218
236
|
}
|
|
219
237
|
};
|
|
220
238
|
RadioGroup.styles = [
|
|
@@ -248,21 +266,16 @@ __decorate([
|
|
|
248
266
|
})
|
|
249
267
|
], RadioGroup.prototype, "required", void 0);
|
|
250
268
|
__decorate([
|
|
251
|
-
|
|
252
|
-
type: Boolean,
|
|
253
|
-
reflect: true,
|
|
254
|
-
converter: booleanConverter,
|
|
255
|
-
})
|
|
269
|
+
state()
|
|
256
270
|
], RadioGroup.prototype, "invalid", void 0);
|
|
257
271
|
__decorate([
|
|
258
272
|
watch('value', true)
|
|
259
273
|
], RadioGroup.prototype, "onValueChange", null);
|
|
260
274
|
__decorate([
|
|
261
|
-
watch('invalid')
|
|
262
|
-
], RadioGroup.prototype, "onInvalidChange", null);
|
|
263
|
-
__decorate([
|
|
275
|
+
watch('invalid', true),
|
|
264
276
|
watch('disabled')
|
|
265
|
-
], RadioGroup.prototype, "
|
|
277
|
+
], RadioGroup.prototype, "onInvalidChange", null);
|
|
266
278
|
RadioGroup = __decorate([
|
|
267
279
|
customElement('mdui-radio-group')
|
|
268
280
|
], RadioGroup);
|
|
281
|
+
export { RadioGroup };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const radioStyle = css `:host{position:relative;display:inline-flex;align-items:center;cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;touch-action:manipulation;zoom:1;-webkit-user-drag:none;border-radius:.125rem;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)}.icon{display:flex;position:absolute;font-size:1.5rem
|
|
2
|
+
export const radioStyle = css `:host{position:relative;display:inline-flex;align-items:center;cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;touch-action:manipulation;zoom:1;-webkit-user-drag:none;border-radius:.125rem;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)}.icon{display:flex;position:absolute;font-size:1.5rem}:not(.initial) .icon{transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard)}.unchecked-icon{transition-property:color;color:rgb(var(--mdui-color-on-surface-variant))}:host([focused]) .unchecked-icon,:host([hover]) .unchecked-icon,:host([pressed]) .unchecked-icon{color:rgb(var(--mdui-color-on-surface))}.checked-icon{opacity:0;transform:scale(.2);transition-property:color,opacity,transform;color:rgb(var(--mdui-color-primary))}.icon .i,::slotted([slot=checked-icon]),::slotted([slot=unchecked-icon]){color:inherit;font-size:inherit}i{position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;border-radius:50%;width:2.5rem;min-width:2.5rem;height:2.5rem;--mdui-comp-ripple-state-layer-color:var(--mdui-color-on-surface)}.label{display:flex;width:100%;padding-top:.625rem;padding-bottom:.625rem;color:rgb(var(--mdui-color-on-surface))}.label:not(.initial){transition:color var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard)}:host([checked]) i{--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}:host([checked]) .icon{color:rgb(var(--mdui-color-primary))}:host([checked]) .checked-icon{opacity:1;transform:scale(.5)}i.invalid{--mdui-comp-ripple-state-layer-color:var(--mdui-color-error)}i.invalid .icon{color:rgb(var(--mdui-color-error))}.label.invalid{color:rgb(var(--mdui-color-error))}:host([disabled]),:host([group-disabled]){cursor:default;pointer-events:none}:host([disabled]) .icon,:host([group-disabled]) .icon{color:rgba(var(--mdui-color-on-surface),38%)}:host([disabled]) .label,:host([group-disabled]) .label{color:rgba(var(--mdui-color-on-surface),38%)}`;
|
|
@@ -3,7 +3,7 @@ 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
|
-
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
6
|
+
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
7
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 LitElement;
|
|
8
8
|
/**
|
|
9
9
|
* @summary 单选框组件。需与 `<mdui-radio-group>` 组件配合使用
|
|
@@ -53,13 +53,14 @@ export declare class Radio extends Radio_base {
|
|
|
53
53
|
protected invalid: boolean;
|
|
54
54
|
protected groupDisabled: boolean;
|
|
55
55
|
protected focusable: boolean;
|
|
56
|
+
protected isInitial: boolean;
|
|
56
57
|
private readonly rippleRef;
|
|
57
58
|
protected get rippleElement(): Ripple;
|
|
58
59
|
protected get rippleDisabled(): boolean;
|
|
59
60
|
protected get focusElement(): HTMLElement;
|
|
60
61
|
protected get focusDisabled(): boolean;
|
|
61
62
|
private onCheckedChange;
|
|
62
|
-
|
|
63
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
63
64
|
protected render(): TemplateResult;
|
|
64
65
|
private isDisabled;
|
|
65
66
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { html, LitElement } from 'lit';
|
|
3
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 { watch } from '@mdui/shared/decorators/watch.js';
|
|
6
7
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
@@ -35,7 +36,7 @@ import { radioStyle } from './radio-style.js';
|
|
|
35
36
|
* @csspart checked-icon 选中状态的图标
|
|
36
37
|
* @csspart label - 文本
|
|
37
38
|
*/
|
|
38
|
-
|
|
39
|
+
let Radio = class Radio extends RippleMixin(FocusableMixin(LitElement)) {
|
|
39
40
|
constructor() {
|
|
40
41
|
super(...arguments);
|
|
41
42
|
/**
|
|
@@ -50,12 +51,16 @@ export let Radio = class Radio extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
50
51
|
* 当前单选项是否已选中
|
|
51
52
|
*/
|
|
52
53
|
this.checked = false;
|
|
53
|
-
// 是否验证未通过。由 mdui-radio-group 控制该参数
|
|
54
|
+
// 是否验证未通过。由 <mdui-radio-group> 控制该参数
|
|
54
55
|
this.invalid = false;
|
|
55
|
-
// 父组件中是否设置了禁用。由 mdui-radio-group 控制该参数
|
|
56
|
+
// 父组件中是否设置了禁用。由 <mdui-radio-group> 控制该参数
|
|
56
57
|
this.groupDisabled = false;
|
|
57
|
-
//
|
|
58
|
-
|
|
58
|
+
// 是否可聚焦。
|
|
59
|
+
// 单独使用该组件时,默认可聚焦。
|
|
60
|
+
// 如果放在 <mdui-radio-group> 组件中使用,则由 <mdui-radio-group> 控制该参数
|
|
61
|
+
this.focusable = true;
|
|
62
|
+
// 是否是初始状态,不显示动画。由 <mdui-radio-group> 组件控制该参数
|
|
63
|
+
this.isInitial = true;
|
|
59
64
|
this.rippleRef = createRef();
|
|
60
65
|
}
|
|
61
66
|
get rippleElement() {
|
|
@@ -71,12 +76,10 @@ export let Radio = class Radio extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
71
76
|
return this.isDisabled() || !this.focusable;
|
|
72
77
|
}
|
|
73
78
|
onCheckedChange() {
|
|
74
|
-
|
|
75
|
-
emit(this, 'change');
|
|
76
|
-
}
|
|
79
|
+
emit(this, 'change');
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
super.
|
|
81
|
+
firstUpdated(_changedProperties) {
|
|
82
|
+
super.firstUpdated(_changedProperties);
|
|
80
83
|
this.addEventListener('click', () => {
|
|
81
84
|
if (!this.isDisabled()) {
|
|
82
85
|
this.checked = true;
|
|
@@ -84,11 +87,15 @@ export let Radio = class Radio extends RippleMixin(FocusableMixin(LitElement)) {
|
|
|
84
87
|
});
|
|
85
88
|
}
|
|
86
89
|
render() {
|
|
87
|
-
|
|
90
|
+
const className = classMap({
|
|
91
|
+
invalid: this.invalid,
|
|
92
|
+
initial: this.isInitial,
|
|
93
|
+
});
|
|
94
|
+
return html `<i part="control" class="${className}"><mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple><slot name="unchecked-icon" part="unchecked-icon" class="icon unchecked-icon">${this.uncheckedIcon
|
|
88
95
|
? html `<mdui-icon name="${this.uncheckedIcon}" class="i"></mdui-icon>`
|
|
89
96
|
: html `<mdui-icon-radio-button-unchecked class="i"></mdui-icon-radio-button-unchecked>`}</slot><slot name="checked-icon" part="checked-icon" class="icon checked-icon">${this.checkedIcon
|
|
90
97
|
? html `<mdui-icon name="${this.checkedIcon}" class="i"></mdui-icon>`
|
|
91
|
-
: html `<mdui-icon-circle class="i"></mdui-icon-circle>`}</slot></i><slot part="label" class="label"></slot>`;
|
|
98
|
+
: html `<mdui-icon-circle class="i"></mdui-icon-circle>`}</slot></i><slot part="label" class="label ${className}"></slot>`;
|
|
92
99
|
}
|
|
93
100
|
isDisabled() {
|
|
94
101
|
return this.disabled || this.groupDisabled;
|
|
@@ -119,11 +126,7 @@ __decorate([
|
|
|
119
126
|
property({ reflect: true, attribute: 'checked-icon' })
|
|
120
127
|
], Radio.prototype, "checkedIcon", void 0);
|
|
121
128
|
__decorate([
|
|
122
|
-
|
|
123
|
-
type: Boolean,
|
|
124
|
-
reflect: true,
|
|
125
|
-
converter: booleanConverter,
|
|
126
|
-
})
|
|
129
|
+
state()
|
|
127
130
|
], Radio.prototype, "invalid", void 0);
|
|
128
131
|
__decorate([
|
|
129
132
|
property({
|
|
@@ -136,9 +139,13 @@ __decorate([
|
|
|
136
139
|
__decorate([
|
|
137
140
|
state()
|
|
138
141
|
], Radio.prototype, "focusable", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
state()
|
|
144
|
+
], Radio.prototype, "isInitial", void 0);
|
|
139
145
|
__decorate([
|
|
140
146
|
watch('checked', true)
|
|
141
147
|
], Radio.prototype, "onCheckedChange", null);
|
|
142
148
|
Radio = __decorate([
|
|
143
149
|
customElement('mdui-radio')
|
|
144
150
|
], Radio);
|
|
151
|
+
export { Radio };
|
|
@@ -10,7 +10,6 @@ import { $ } from '@mdui/jq/$.js';
|
|
|
10
10
|
import '@mdui/jq/methods/css.js';
|
|
11
11
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
12
12
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
13
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
14
13
|
import { SliderBase } from '../slider/slider-base.js';
|
|
15
14
|
/**
|
|
16
15
|
* @summary 范围滑块组件
|
|
@@ -31,7 +30,7 @@ import { SliderBase } from '../slider/slider-base.js';
|
|
|
31
30
|
* @csspart label - 提示文本
|
|
32
31
|
* @csspart tickmark - 刻度标记
|
|
33
32
|
*/
|
|
34
|
-
|
|
33
|
+
let RangeSlider = class RangeSlider extends SliderBase {
|
|
35
34
|
constructor() {
|
|
36
35
|
super(...arguments);
|
|
37
36
|
/**
|
|
@@ -69,11 +68,10 @@ export let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
69
68
|
this._value = _value;
|
|
70
69
|
this.requestUpdate('value', oldValue);
|
|
71
70
|
this.updateComplete.then(() => {
|
|
72
|
-
var _a;
|
|
73
71
|
this.updateStyle();
|
|
74
72
|
// reset 引起的值变更,不执行验证;直接修改值引起的变更,需要进行验证
|
|
75
73
|
const form = this.formController.getForm();
|
|
76
|
-
if (form &&
|
|
74
|
+
if (form && formResets.get(form)?.has(this)) {
|
|
77
75
|
this.invalid = false;
|
|
78
76
|
formResets.get(form).delete(this);
|
|
79
77
|
}
|
|
@@ -91,6 +89,9 @@ export let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
91
89
|
if (!this.defaultValue.length) {
|
|
92
90
|
this.defaultValue = [...this.value];
|
|
93
91
|
}
|
|
92
|
+
}
|
|
93
|
+
firstUpdated(changedProperties) {
|
|
94
|
+
super.firstUpdated(changedProperties);
|
|
94
95
|
// 在轨道上点击时,计算出点击位置在 <input type="range"> 元素上的值
|
|
95
96
|
// 若该值在 this.value 的两个值中间位置的左侧,则表示操作的是左侧的值,否则操作的是右侧的值
|
|
96
97
|
const getCurrentHandle = (event) => {
|
|
@@ -132,9 +133,6 @@ export let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
132
133
|
this.startHover(event);
|
|
133
134
|
}
|
|
134
135
|
});
|
|
135
|
-
}
|
|
136
|
-
firstUpdated(changedProperties) {
|
|
137
|
-
super.firstUpdated(changedProperties);
|
|
138
136
|
this.updateStyle();
|
|
139
137
|
}
|
|
140
138
|
/**
|
|
@@ -142,7 +140,7 @@ export let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
142
140
|
* <input class="invalid" /> 用于提供 html5 自带的表单错误提示
|
|
143
141
|
*/
|
|
144
142
|
render() {
|
|
145
|
-
return html `<label><input ${ref(this.inputRef)} type="range" step="${this.step}" min="${this.min}" max="${this.max}" ?disabled="${this.disabled}" @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.handleStartRef)} part="handle" class="handle start" style="${styleMap({
|
|
143
|
+
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}" @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.handleStartRef)} part="handle" class="handle start" style="${styleMap({
|
|
146
144
|
'z-index': this.currentHandle === 'start' ? '2' : '1',
|
|
147
145
|
})}"><div class="elevation"></div><mdui-ripple ${ref(this.rippleStartRef)} .noRipple="${this.noRipple}"></mdui-ripple>${this.renderLabel(this.value[0])}</div><div ${ref(this.handleEndRef)} part="handle" class="handle end" style="${styleMap({
|
|
148
146
|
'z-index': this.currentHandle === 'end' ? '2' : '1',
|
|
@@ -170,7 +168,6 @@ export let RangeSlider = class RangeSlider extends SliderBase {
|
|
|
170
168
|
const startValue = this.value[0];
|
|
171
169
|
const endValue = this.value[1];
|
|
172
170
|
const doInput = () => {
|
|
173
|
-
emit(this, 'input');
|
|
174
171
|
this.updateStyle();
|
|
175
172
|
};
|
|
176
173
|
if (isStart) {
|
|
@@ -208,3 +205,4 @@ __decorate([
|
|
|
208
205
|
RangeSlider = __decorate([
|
|
209
206
|
customElement('mdui-range-slider')
|
|
210
207
|
], RangeSlider);
|
|
208
|
+
export { RangeSlider };
|
|
@@ -24,7 +24,7 @@ import { style } from './style.js';
|
|
|
24
24
|
* 背景色通过在 .surface 元素上添加对应的 class 实现
|
|
25
25
|
* 阴影在 ripple-mixin 中处理,通过在 :host 元素上添加 attribute 供 CSS 选择器添加样式
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
let Ripple = class Ripple extends LitElement {
|
|
28
28
|
constructor() {
|
|
29
29
|
super(...arguments);
|
|
30
30
|
/**
|
|
@@ -171,3 +171,4 @@ __decorate([
|
|
|
171
171
|
Ripple = __decorate([
|
|
172
172
|
customElement('mdui-ripple')
|
|
173
173
|
], Ripple);
|
|
174
|
+
export { Ripple };
|
|
@@ -70,9 +70,10 @@ export declare class SegmentedButtonGroup extends LitElement implements FormCont
|
|
|
70
70
|
* 是否验证未通过
|
|
71
71
|
*/
|
|
72
72
|
private invalid;
|
|
73
|
-
private
|
|
73
|
+
private isInitial;
|
|
74
74
|
private readonly inputRef;
|
|
75
75
|
private readonly formController;
|
|
76
|
+
private readonly definedController;
|
|
76
77
|
/**
|
|
77
78
|
* 表单验证状态对象
|
|
78
79
|
*/
|
|
@@ -90,7 +91,6 @@ export declare class SegmentedButtonGroup extends LitElement implements FormCont
|
|
|
90
91
|
private onSelectedKeysChange;
|
|
91
92
|
private onValueChange;
|
|
92
93
|
private onInvalidChange;
|
|
93
|
-
private onDisabledChange;
|
|
94
94
|
connectedCallback(): void;
|
|
95
95
|
/**
|
|
96
96
|
* 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`
|
|
@@ -109,14 +109,17 @@ export declare class SegmentedButtonGroup extends LitElement implements FormCont
|
|
|
109
109
|
*/
|
|
110
110
|
setCustomValidity(message: string): void;
|
|
111
111
|
protected render(): TemplateResult;
|
|
112
|
-
private updateSelected;
|
|
113
112
|
private selectOne;
|
|
114
113
|
private onClick;
|
|
115
114
|
/**
|
|
116
115
|
* 在隐藏的 `<input>` 或 `<select>` 上按下按键时,切换选中状态
|
|
116
|
+
* 通常为验证不通过时,默认聚焦到 `<input>` 或 `<select>` 上,此时按下按键,切换第一个元素的选中状态
|
|
117
117
|
*/
|
|
118
118
|
private onInputKeyDown;
|
|
119
119
|
private onSlotChange;
|
|
120
|
+
private setSelectedKeys;
|
|
121
|
+
private setValue;
|
|
122
|
+
private updateItems;
|
|
120
123
|
}
|
|
121
124
|
declare global {
|
|
122
125
|
interface HTMLElementTagNameMap {
|