mdui 2.1.1 → 2.1.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/style.js +1 -1
- package/components/badge/style.js +1 -1
- package/components/bottom-app-bar/index.d.ts +1 -1
- package/components/bottom-app-bar/style.js +1 -1
- package/components/button/button-base.d.ts +1 -1
- package/components/button/style.js +2 -2
- package/components/button-icon/style.js +2 -2
- package/components/card/index.d.ts +1 -1
- package/components/card/style.js +1 -1
- package/components/checkbox/index.d.ts +1 -1
- package/components/checkbox/style.js +1 -1
- package/components/chip/style.js +2 -2
- package/components/circular-progress/style.js +1 -1
- package/components/dialog/style.js +1 -1
- package/components/divider/style.js +1 -1
- package/components/dropdown/index.js +9 -4
- package/components/fab/style.js +2 -2
- package/components/icon/style.js +1 -1
- package/components/layout/layout-style.js +1 -1
- package/components/list/list-item-style.js +2 -2
- package/components/list/list-item.d.ts +1 -1
- package/components/menu/menu-item-style.js +1 -1
- package/components/menu/menu-item.d.ts +1 -1
- package/components/navigation-bar/navigation-bar-item.d.ts +1 -1
- package/components/navigation-bar/navigation-bar-style.js +1 -1
- package/components/navigation-bar/navigation-bar.d.ts +1 -1
- package/components/navigation-drawer/index.d.ts +1 -0
- package/components/navigation-drawer/index.js +17 -11
- package/components/navigation-drawer/style.js +1 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +1 -1
- package/components/navigation-rail/navigation-rail-style.js +1 -1
- package/components/radio/radio-style.js +1 -1
- package/components/radio/radio.d.ts +1 -1
- package/components/ripple/ripple-mixin.d.ts +1 -1
- package/components/segmented-button/segmented-button-group-style.js +1 -1
- package/components/segmented-button/segmented-button-style.js +1 -1
- package/components/select/index.d.ts +1 -3
- package/components/select/index.js +6 -6
- package/components/slider/slider-base-style.js +1 -1
- package/components/slider/slider-base.d.ts +1 -1
- package/components/snackbar/index.d.ts +12 -0
- package/components/snackbar/index.js +105 -46
- package/components/snackbar/style.js +1 -1
- package/components/switch/index.d.ts +1 -1
- package/components/switch/style.js +1 -1
- package/components/tabs/tab-style.js +1 -1
- package/components/tabs/tab.d.ts +1 -1
- package/components/tabs/tabs-style.js +1 -1
- package/components/tabs/tabs.d.ts +2 -2
- package/components/tabs/tabs.js +6 -4
- package/components/text-field/index.d.ts +6 -8
- package/components/text-field/index.js +35 -31
- package/components/text-field/style.js +1 -1
- package/components/tooltip/index.js +6 -4
- package/components/top-app-bar/top-app-bar-style.js +1 -1
- package/components/top-app-bar/top-app-bar.d.ts +1 -1
- package/components/top-app-bar/top-app-bar.js +1 -1
- package/custom-elements.json +5920 -7207
- package/functions/alert.js +5 -3
- package/functions/confirm.js +5 -3
- package/functions/dialog.js +8 -3
- package/functions/prompt.js +5 -3
- package/functions/snackbar.js +8 -2
- package/html-data.en.json +580 -586
- package/html-data.zh-cn.json +580 -586
- package/jsx.en.d.ts +424 -427
- package/jsx.zh-cn.d.ts +424 -427
- package/mdui.esm.js +8 -8
- package/mdui.global.js +8 -8
- package/package.json +9 -10
- package/web-types.en.json +1285 -1275
- package/web-types.zh-cn.json +1285 -1275
|
@@ -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
|
|
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;appearance:none;width:calc(100% + 20rem * 2 / 16);margin:0 -1.25rem;padding:0 .75rem}:host([disabled]:not([disabled=false i])) 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]:not([disabled=false i])) .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]:not([disabled=false i])) .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]:not([disabled=false i])) .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]:not([disabled=false i])) .tickmark{background-color:rgba(var(--mdui-color-on-surface),.38)}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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("@
|
|
4
|
+
declare const SliderBase_base: import("@lit/reactive-element/decorators/base.js").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@lit/reactive-element/decorators/base.js").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
5
5
|
export declare class SliderBase<E> extends SliderBase_base<E> {
|
|
6
6
|
static styles: CSSResultGroup;
|
|
7
7
|
/**
|
|
@@ -78,12 +78,24 @@ export declare class Snackbar extends MduiElement<SnackbarEventMap> {
|
|
|
78
78
|
* 点击或触摸 Snackbar 以外的区域时,是否关闭 Snackbar
|
|
79
79
|
*/
|
|
80
80
|
closeOnOutsideClick: boolean;
|
|
81
|
+
private mobile;
|
|
81
82
|
private closeTimeout;
|
|
83
|
+
private observeResize?;
|
|
82
84
|
constructor();
|
|
83
85
|
private onOpenChange;
|
|
86
|
+
/**
|
|
87
|
+
* 这两个属性变更时,需要重新排序该组件后面的 snackbar
|
|
88
|
+
*/
|
|
89
|
+
private onStackChange;
|
|
84
90
|
connectedCallback(): void;
|
|
85
91
|
disconnectedCallback(): void;
|
|
86
92
|
protected render(): TemplateResult;
|
|
93
|
+
/**
|
|
94
|
+
* 重新排序 snackbar 堆叠
|
|
95
|
+
* @param startSnackbar 从哪个 snackbar 开始重新排列,默认从第一个开始
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
private reorderStack;
|
|
87
99
|
/**
|
|
88
100
|
* 在 document 上点击时,根据条件判断是否要关闭 snackbar
|
|
89
101
|
*/
|
|
@@ -8,6 +8,7 @@ import { animateTo, stopAnimations } from '@mdui/shared/helpers/animate.js';
|
|
|
8
8
|
import { breakpoint } from '@mdui/shared/helpers/breakpoint.js';
|
|
9
9
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
10
10
|
import { getDuration, getEasing } from '@mdui/shared/helpers/motion.js';
|
|
11
|
+
import { observeResize } from '@mdui/shared/helpers/observeResize.js';
|
|
11
12
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
12
13
|
import '@mdui/shared/icons/clear.js';
|
|
13
14
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
@@ -15,6 +16,10 @@ import '../button-icon.js';
|
|
|
15
16
|
import '../button.js';
|
|
16
17
|
import '../icon.js';
|
|
17
18
|
import { style } from './style.js';
|
|
19
|
+
// snackbar 堆叠时的数组
|
|
20
|
+
const stacks = [];
|
|
21
|
+
// 是否重新排序中,mobile 变化时,仅重新排序一次
|
|
22
|
+
let reordering = false;
|
|
18
23
|
/**
|
|
19
24
|
* @summary 消息条组件
|
|
20
25
|
*
|
|
@@ -75,20 +80,12 @@ let Snackbar = class Snackbar extends MduiElement {
|
|
|
75
80
|
* 点击或触摸 Snackbar 以外的区域时,是否关闭 Snackbar
|
|
76
81
|
*/
|
|
77
82
|
this.closeOnOutsideClick = false;
|
|
83
|
+
this.mobile = false;
|
|
78
84
|
this.onDocumentClick = this.onDocumentClick.bind(this);
|
|
79
85
|
}
|
|
80
86
|
async onOpenChange() {
|
|
81
|
-
const isMobile = breakpoint().down('sm');
|
|
82
|
-
const isCenteredHorizontally = ['top', 'bottom'].includes(this.placement);
|
|
83
87
|
const easingLinear = getEasing(this, 'linear');
|
|
84
|
-
const easingEmphasizedDecelerate = getEasing(this, 'emphasized-decelerate');
|
|
85
88
|
const children = Array.from(this.renderRoot.querySelectorAll('.message, .action-group'));
|
|
86
|
-
// 手机上始终使用全宽的样式,但 @media 选择器中无法使用 CSS 变量,所以使用 js 来设置样式
|
|
87
|
-
const commonStyle = isMobile
|
|
88
|
-
? { left: '1rem', right: '1rem', minWidth: 0 }
|
|
89
|
-
: isCenteredHorizontally
|
|
90
|
-
? { left: '50%' }
|
|
91
|
-
: {};
|
|
92
89
|
// 打开
|
|
93
90
|
// 要区分是否首次渲染,首次渲染时不触发事件,不执行动画;非首次渲染,触发事件,执行动画
|
|
94
91
|
if (this.open) {
|
|
@@ -113,32 +110,13 @@ let Snackbar = class Snackbar extends MduiElement {
|
|
|
113
110
|
stopAnimations(this),
|
|
114
111
|
...children.map((child) => stopAnimations(child)),
|
|
115
112
|
]);
|
|
113
|
+
stacks.push({
|
|
114
|
+
height: this.clientHeight,
|
|
115
|
+
snackbar: this,
|
|
116
|
+
});
|
|
117
|
+
await this.reorderStack(this);
|
|
116
118
|
const duration = getDuration(this, 'medium4');
|
|
117
|
-
const getOpenStyle = (ident) => {
|
|
118
|
-
const scaleY = `scaleY(${ident === 'start' ? 0 : 1})`;
|
|
119
|
-
if (isMobile) {
|
|
120
|
-
return { transform: scaleY };
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
return {
|
|
124
|
-
transform: [
|
|
125
|
-
scaleY,
|
|
126
|
-
isCenteredHorizontally ? 'translateX(-50%)' : '',
|
|
127
|
-
]
|
|
128
|
-
.filter((i) => i)
|
|
129
|
-
.join(' '),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
119
|
await Promise.all([
|
|
134
|
-
animateTo(this, [
|
|
135
|
-
{ ...getOpenStyle('start'), ...commonStyle },
|
|
136
|
-
{ ...getOpenStyle('end'), ...commonStyle },
|
|
137
|
-
], {
|
|
138
|
-
duration: hasUpdated ? duration : 0,
|
|
139
|
-
easing: easingEmphasizedDecelerate,
|
|
140
|
-
fill: 'forwards',
|
|
141
|
-
}),
|
|
142
120
|
animateTo(this, [{ opacity: 0 }, { opacity: 1, offset: 0.5 }, { opacity: 1 }], {
|
|
143
121
|
duration: hasUpdated ? duration : 0,
|
|
144
122
|
easing: easingLinear,
|
|
@@ -171,37 +149,58 @@ let Snackbar = class Snackbar extends MduiElement {
|
|
|
171
149
|
...children.map((child) => stopAnimations(child)),
|
|
172
150
|
]);
|
|
173
151
|
const duration = getDuration(this, 'short4');
|
|
174
|
-
const getCloseStyle = (ident) => {
|
|
175
|
-
const opacity = ident === 'start' ? 1 : 0;
|
|
176
|
-
const styles = { opacity };
|
|
177
|
-
if (!isMobile && isCenteredHorizontally) {
|
|
178
|
-
Object.assign(styles, { transform: 'translateX(-50%)' });
|
|
179
|
-
}
|
|
180
|
-
return styles;
|
|
181
|
-
};
|
|
182
152
|
await Promise.all([
|
|
183
|
-
animateTo(this, [
|
|
184
|
-
{ ...getCloseStyle('start'), ...commonStyle },
|
|
185
|
-
{ ...getCloseStyle('end'), ...commonStyle },
|
|
186
|
-
], {
|
|
153
|
+
animateTo(this, [{ opacity: 1 }, { opacity: 0 }], {
|
|
187
154
|
duration,
|
|
188
155
|
easing: easingLinear,
|
|
189
156
|
fill: 'forwards',
|
|
190
157
|
}),
|
|
191
|
-
...children.map((child) => animateTo(child, [{ opacity: 1 }, { opacity: 0, offset: 0.75 }, { opacity: 0 }], {
|
|
158
|
+
...children.map((child) => animateTo(child, [{ opacity: 1 }, { opacity: 0, offset: 0.75 }, { opacity: 0 }], {
|
|
159
|
+
duration,
|
|
160
|
+
easing: easingLinear,
|
|
161
|
+
})),
|
|
192
162
|
]);
|
|
193
163
|
this.style.display = 'none';
|
|
194
164
|
this.emit('closed');
|
|
165
|
+
const stackIndex = stacks.findIndex((stack) => stack.snackbar === this);
|
|
166
|
+
stacks.splice(stackIndex, 1);
|
|
167
|
+
if (stacks[stackIndex]) {
|
|
168
|
+
await this.reorderStack(stacks[stackIndex].snackbar);
|
|
169
|
+
}
|
|
195
170
|
return;
|
|
196
171
|
}
|
|
197
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* 这两个属性变更时,需要重新排序该组件后面的 snackbar
|
|
175
|
+
*/
|
|
176
|
+
async onStackChange() {
|
|
177
|
+
await this.reorderStack(this);
|
|
178
|
+
}
|
|
198
179
|
connectedCallback() {
|
|
199
180
|
super.connectedCallback();
|
|
200
181
|
document.addEventListener('pointerdown', this.onDocumentClick);
|
|
182
|
+
// 先立即计算一次,避免在首次 open 时还未计算完成
|
|
183
|
+
this.mobile = breakpoint().down('sm');
|
|
184
|
+
this.observeResize = observeResize(document.documentElement, async () => {
|
|
185
|
+
const mobile = breakpoint().down('sm');
|
|
186
|
+
if (this.mobile !== mobile) {
|
|
187
|
+
this.mobile = mobile;
|
|
188
|
+
if (!reordering) {
|
|
189
|
+
reordering = true;
|
|
190
|
+
await this.reorderStack();
|
|
191
|
+
reordering = false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
201
195
|
}
|
|
202
196
|
disconnectedCallback() {
|
|
203
197
|
super.disconnectedCallback();
|
|
204
198
|
document.removeEventListener('pointerdown', this.onDocumentClick);
|
|
199
|
+
window.clearTimeout(this.closeTimeout);
|
|
200
|
+
if (this.open) {
|
|
201
|
+
this.open = false;
|
|
202
|
+
}
|
|
203
|
+
this.observeResize?.unobserve();
|
|
205
204
|
}
|
|
206
205
|
render() {
|
|
207
206
|
return html `<slot part="message" class="message"></slot><div class="action-group"><slot name="action" part="action" class="action" @click="${this.onActionClick}">${this.action
|
|
@@ -210,6 +209,55 @@ let Snackbar = class Snackbar extends MduiElement {
|
|
|
210
209
|
? html `<mdui-icon name="${this.closeIcon}" class="i"></mdui-icon>`
|
|
211
210
|
: html `<mdui-icon-clear class="i"></mdui-icon-clear>`}</slot></mdui-button-icon></slot>`)}</div>`;
|
|
212
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* 重新排序 snackbar 堆叠
|
|
214
|
+
* @param startSnackbar 从哪个 snackbar 开始重新排列,默认从第一个开始
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
217
|
+
async reorderStack(startSnackbar) {
|
|
218
|
+
const stackIndex = startSnackbar
|
|
219
|
+
? stacks.findIndex((stack) => stack.snackbar === startSnackbar)
|
|
220
|
+
: 0;
|
|
221
|
+
for (let i = stackIndex; i < stacks.length; i++) {
|
|
222
|
+
const stack = stacks[i];
|
|
223
|
+
const snackbar = stack.snackbar;
|
|
224
|
+
if (this.mobile) {
|
|
225
|
+
['top', 'bottom'].forEach((placement) => {
|
|
226
|
+
if (snackbar.placement.startsWith(placement)) {
|
|
227
|
+
const prevStacks = stacks.filter((stack, index) => {
|
|
228
|
+
return (index < i && stack.snackbar.placement.startsWith(placement));
|
|
229
|
+
});
|
|
230
|
+
const prevHeight = prevStacks.reduce((prev, current) => prev + current.height, 0);
|
|
231
|
+
// @ts-ignore
|
|
232
|
+
snackbar.style[placement] =
|
|
233
|
+
`calc(${prevHeight}px + ${prevStacks.length + 1}rem)`;
|
|
234
|
+
snackbar.style[placement === 'top' ? 'bottom' : 'top'] = 'auto';
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
[
|
|
240
|
+
'top',
|
|
241
|
+
'top-start',
|
|
242
|
+
'top-end',
|
|
243
|
+
'bottom',
|
|
244
|
+
'bottom-start',
|
|
245
|
+
'bottom-end',
|
|
246
|
+
].forEach((placement) => {
|
|
247
|
+
if (snackbar.placement === placement) {
|
|
248
|
+
const prevStacks = stacks.filter((stack, index) => {
|
|
249
|
+
return index < i && stack.snackbar.placement === placement;
|
|
250
|
+
});
|
|
251
|
+
const prevHeight = prevStacks.reduce((prev, current) => prev + current.height, 0);
|
|
252
|
+
snackbar.style[placement.startsWith('top') ? 'top' : 'bottom'] =
|
|
253
|
+
`calc(${prevHeight}px + ${prevStacks.length + 1}rem)`;
|
|
254
|
+
snackbar.style[placement.startsWith('top') ? 'bottom' : 'top'] =
|
|
255
|
+
'auto';
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
213
261
|
/**
|
|
214
262
|
* 在 document 上点击时,根据条件判断是否要关闭 snackbar
|
|
215
263
|
*/
|
|
@@ -277,9 +325,20 @@ __decorate([
|
|
|
277
325
|
converter: booleanConverter,
|
|
278
326
|
})
|
|
279
327
|
], Snackbar.prototype, "closeOnOutsideClick", void 0);
|
|
328
|
+
__decorate([
|
|
329
|
+
property({
|
|
330
|
+
type: Boolean,
|
|
331
|
+
reflect: true,
|
|
332
|
+
converter: booleanConverter,
|
|
333
|
+
})
|
|
334
|
+
], Snackbar.prototype, "mobile", void 0);
|
|
280
335
|
__decorate([
|
|
281
336
|
watch('open')
|
|
282
337
|
], Snackbar.prototype, "onOpenChange", null);
|
|
338
|
+
__decorate([
|
|
339
|
+
watch('placement', true),
|
|
340
|
+
watch('messageLine', true)
|
|
341
|
+
], Snackbar.prototype, "onStackChange", null);
|
|
283
342
|
Snackbar = __decorate([
|
|
284
343
|
customElement('mdui-snackbar')
|
|
285
344
|
], Snackbar);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css `:host{--shape-corner:var(--mdui-shape-corner-extra-small);--z-index:2400;position:fixed;z-index:var(--z-index);display:none;align-items:center;flex-wrap:wrap;border-radius:var(--shape-corner);min-width:20rem;max-width:36rem;padding:.25rem 0;box-shadow:var(--mdui-elevation-level3);background-color:rgb(var(--mdui-color-inverse-surface));color:rgb(var(--mdui-color-inverse-on-surface));font-size:var(--mdui-typescale-body-medium-size);font-weight:var(--mdui-typescale-body-medium-weight);letter-spacing:var(--mdui-typescale-body-medium-tracking);line-height:var(--mdui-typescale-body-medium-line-height)}:host([placement^=top]){transform-origin:top
|
|
2
|
+
export const style = css `:host{--shape-corner:var(--mdui-shape-corner-extra-small);--z-index:2400;position:fixed;z-index:var(--z-index);display:none;align-items:center;flex-wrap:wrap;border-radius:var(--shape-corner);transform:scaleY(0);transition:transform 0s var(--mdui-motion-easing-linear) var(--mdui-motion-duration-short4);min-width:20rem;max-width:36rem;padding:.25rem 0;box-shadow:var(--mdui-elevation-level3);background-color:rgb(var(--mdui-color-inverse-surface));color:rgb(var(--mdui-color-inverse-on-surface));font-size:var(--mdui-typescale-body-medium-size);font-weight:var(--mdui-typescale-body-medium-weight);letter-spacing:var(--mdui-typescale-body-medium-tracking);line-height:var(--mdui-typescale-body-medium-line-height)}:host([placement^=top]){transform-origin:top}:host([placement^=bottom]){transform-origin:bottom}:host([placement=bottom-start]:not([mobile])),:host([placement=top-start]:not([mobile])){left:1rem}:host([placement=bottom-end]:not([mobile])),:host([placement=top-end]:not([mobile])){right:1rem}:host([placement=bottom]:not([mobile])),:host([placement=top]:not([mobile])){left:50%;transform:scaleY(0) translateX(-50%)}:host([mobile]){min-width:0;left:1rem;right:1rem}:host([open]){transform:scaleY(1);transition:top var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard),bottom var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard),transform var(--mdui-motion-duration-medium4) var(--mdui-motion-easing-emphasized-decelerate)}:host([placement=bottom][open]:not([mobile])),:host([placement=top][open]:not([mobile])){transform:scaleY(1) translateX(-50%)}.message{display:block;margin:.625rem 1rem}:host([message-line='1']) .message{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([message-line='2']) .message{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical;-webkit-line-clamp:2}.action-group{display:flex;align-items:center;margin-left:auto;padding-right:.5rem}.action,.close-button{display:inline-flex;align-items:center;justify-content:center}.action{color:rgb(var(--mdui-color-inverse-primary));font-size:var(--mdui-typescale-label-large-size);font-weight:var(--mdui-typescale-label-large-weight);letter-spacing:var(--mdui-typescale-label-large-tracking)}.action mdui-button,::slotted(mdui-button[slot=action][variant=outlined]),::slotted(mdui-button[slot=action][variant=text]){color:inherit;font-size:inherit;font-weight:inherit;letter-spacing:inherit;--mdui-comp-ripple-state-layer-color:var(--mdui-color-inverse-primary)}.action mdui-button::part(button){padding:0 .5rem}.close-button{margin:0 -.25rem 0 .25rem;font-size:1.5rem;color:rgb(var(--mdui-color-inverse-on-surface))}.close-button mdui-button-icon,::slotted(mdui-button-icon[slot=close-button][variant=outlined]),::slotted(mdui-button-icon[slot=close-button][variant=standard]){font-size:inherit;color:inherit;--mdui-comp-ripple-state-layer-color:var(--mdui-color-inverse-on-surface)}.close-button .i,::slotted([slot=close-icon]){font-size:inherit}`;
|
|
@@ -4,7 +4,7 @@ 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("@
|
|
7
|
+
declare const Switch_base: import("@lit/reactive-element/decorators/base.js").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@lit/reactive-element/decorators/base.js").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
8
8
|
/**
|
|
9
9
|
* @summary 开关切换组件
|
|
10
10
|
*
|
|
@@ -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}.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}`;
|
|
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]:not([disabled=false i])){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]:not([checked=false i])) .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]:not([disabled=false i])) .track{background-color:rgba(var(--mdui-color-surface-container-highest),.12);border-color:rgba(var(--mdui-color-on-surface),.12)}:host([disabled][checked]:not([disabled=false i],[checked=false i])) .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]:not([checked=false i])) .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]:not([checked=false i])) .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]:not([checked=false i])) .thumb{left:1.375rem}:host([focus-visible][checked]:not([checked=false i])) .thumb,:host([hover][checked]:not([checked=false i])) .thumb,:host([pressed][checked]:not([checked=false i])) .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]:not([disabled=false i])) .thumb{background-color:rgba(var(--mdui-color-on-surface),.38)}:host([disabled][checked]:not([disabled=false i],[checked=false i])) .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]:not([checked=false i])) .unchecked-icon{opacity:0;transform:scale(.92);transition-delay:0s;transition-duration:var(--mdui-motion-duration-short1)}:host([disabled]:not([disabled=false i])) .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]:not([checked=false i])) .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]:not([disabled=false i])) .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,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]) .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}`;
|
|
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]:not([inline=false i])) .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
|
@@ -2,7 +2,7 @@ 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("@
|
|
5
|
+
declare const Tab_base: import("@lit/reactive-element/decorators/base.js").Constructor<import("../ripple/ripple-mixin.js").RippleMixinInterface> & import("@lit/reactive-element/decorators/base.js").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
6
6
|
/**
|
|
7
7
|
* @summary 选项卡导航项组件。需配合 `<mdui-tabs>` 和 `<mdui-tab-panel>` 组件使用
|
|
8
8
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const tabsStyle = css `:host{position:relative;display:flex}:host([placement^=top]){flex-direction:column}:host([placement^=bottom]){flex-direction:column-reverse}:host([placement^=left]){flex-direction:row}:host([placement^=right]){flex-direction:row-reverse}.container{position:relative;display:flex;flex:0 0 auto;overflow-x:auto;background-color:rgb(var(--mdui-color-surface))}:host([placement^=bottom]) .container,:host([placement^=top]) .container{flex-direction:row}:host([placement^=left]) .container,:host([placement^=right]) .container{flex-direction:column}:host([placement$='-start']) .container{justify-content:flex-start}:host([placement=bottom]) .container,:host([placement=left]) .container,:host([placement=right]) .container,:host([placement=top]) .container{justify-content:center}:host([placement$='-end']) .container{justify-content:flex-end}.container::after{content:' ';position:absolute;background-color:rgb(var(--mdui-color-surface-variant))}:host([placement^=bottom]) .container::after,:host([placement^=top]) .container::after{left:0;width:100%;height:.0625rem}:host([placement^=top]) .container::after{bottom:0}:host([placement^=bottom]) .container::after{top:0}:host([placement^=left]) .container::after,:host([placement^=right]) .container::after{top:0;height:100%;width:.0625rem}:host([placement^=left]) .container::after{right:0}:host([placement^=right]) .container::after{left:0}.indicator{position:absolute;z-index:1;background-color:rgb(var(--mdui-color-primary))}.container:not(.initial) .indicator{transition-duration:var(--mdui-motion-duration-medium2);transition-timing-function:var(--mdui-motion-easing-standard-decelerate)}:host([placement^=bottom]) .indicator,:host([placement^=top]) .indicator{transition-property:transform,left,width}:host([placement^=left]) .indicator,:host([placement^=right]) .indicator{transition-property:transform,top,height}:host([placement^=top]) .indicator{bottom:0}:host([placement^=bottom]) .indicator{top:0}:host([placement^=left]) .indicator{right:0}:host([placement^=right]) .indicator{left:0}:host([placement^=bottom][variant=primary]) .indicator,:host([placement^=top][variant=primary]) .indicator{height:.1875rem}:host([placement^=bottom][variant=secondary]) .indicator,:host([placement^=top][variant=secondary]) .indicator{height:.125rem}:host([placement^=left][variant=primary]) .indicator,:host([placement^=right][variant=primary]) .indicator{width:.1875rem}:host([placement^=left][variant=secondary]) .indicator,:host([placement^=right][variant=secondary]) .indicator{width:.125rem}:host([placement^=top][variant=primary]) .indicator{border-top-left-radius:.1875rem;border-top-right-radius:.1875rem}:host([placement^=bottom][variant=primary]) .indicator{border-bottom-right-radius:.1875rem;border-bottom-left-radius:.1875rem}:host([placement^=left][variant=primary]) .indicator{border-top-left-radius:.1875rem;border-bottom-left-radius:.1875rem}:host([placement^=right][variant=primary]) .indicator{border-top-right-radius:.1875rem;border-bottom-right-radius:.1875rem}:host([full-width]) ::slotted(mdui-tab){flex:1}`;
|
|
2
|
+
export const tabsStyle = css `:host{position:relative;display:flex}:host([placement^=top]){flex-direction:column}:host([placement^=bottom]){flex-direction:column-reverse}:host([placement^=left]){flex-direction:row}:host([placement^=right]){flex-direction:row-reverse}.container{position:relative;display:flex;flex:0 0 auto;overflow-x:auto;background-color:rgb(var(--mdui-color-surface))}:host([placement^=bottom]) .container,:host([placement^=top]) .container{flex-direction:row}:host([placement^=left]) .container,:host([placement^=right]) .container{flex-direction:column}:host([placement$='-start']) .container{justify-content:flex-start}:host([placement=bottom]) .container,:host([placement=left]) .container,:host([placement=right]) .container,:host([placement=top]) .container{justify-content:center}:host([placement$='-end']) .container{justify-content:flex-end}.container::after{content:' ';position:absolute;background-color:rgb(var(--mdui-color-surface-variant))}:host([placement^=bottom]) .container::after,:host([placement^=top]) .container::after{left:0;width:100%;height:.0625rem}:host([placement^=top]) .container::after{bottom:0}:host([placement^=bottom]) .container::after{top:0}:host([placement^=left]) .container::after,:host([placement^=right]) .container::after{top:0;height:100%;width:.0625rem}:host([placement^=left]) .container::after{right:0}:host([placement^=right]) .container::after{left:0}.indicator{position:absolute;z-index:1;background-color:rgb(var(--mdui-color-primary))}.container:not(.initial) .indicator{transition-duration:var(--mdui-motion-duration-medium2);transition-timing-function:var(--mdui-motion-easing-standard-decelerate)}:host([placement^=bottom]) .indicator,:host([placement^=top]) .indicator{transition-property:transform,left,width}:host([placement^=left]) .indicator,:host([placement^=right]) .indicator{transition-property:transform,top,height}:host([placement^=top]) .indicator{bottom:0}:host([placement^=bottom]) .indicator{top:0}:host([placement^=left]) .indicator{right:0}:host([placement^=right]) .indicator{left:0}:host([placement^=bottom][variant=primary]) .indicator,:host([placement^=top][variant=primary]) .indicator{height:.1875rem}:host([placement^=bottom][variant=secondary]) .indicator,:host([placement^=top][variant=secondary]) .indicator{height:.125rem}:host([placement^=left][variant=primary]) .indicator,:host([placement^=right][variant=primary]) .indicator{width:.1875rem}:host([placement^=left][variant=secondary]) .indicator,:host([placement^=right][variant=secondary]) .indicator{width:.125rem}:host([placement^=top][variant=primary]) .indicator{border-top-left-radius:.1875rem;border-top-right-radius:.1875rem}:host([placement^=bottom][variant=primary]) .indicator{border-bottom-right-radius:.1875rem;border-bottom-left-radius:.1875rem}:host([placement^=left][variant=primary]) .indicator{border-top-left-radius:.1875rem;border-bottom-left-radius:.1875rem}:host([placement^=right][variant=primary]) .indicator{border-top-right-radius:.1875rem;border-bottom-right-radius:.1875rem}:host([full-width]:not([full-width=false i])) ::slotted(mdui-tab){flex:1}`;
|
|
@@ -3,7 +3,7 @@ import '@mdui/jq/methods/css.js';
|
|
|
3
3
|
import '@mdui/jq/methods/find.js';
|
|
4
4
|
import '@mdui/jq/methods/get.js';
|
|
5
5
|
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
6
|
-
import type { CSSResultGroup,
|
|
6
|
+
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
7
7
|
/**
|
|
8
8
|
* @summary 选项卡组件。需配合 `<mdui-tab>` 和 `<mdui-tab-panel>` 组件使用
|
|
9
9
|
*
|
|
@@ -73,8 +73,8 @@ export declare class Tabs extends MduiElement<TabsEventMap> {
|
|
|
73
73
|
private onActiveKeyChange;
|
|
74
74
|
private onValueChange;
|
|
75
75
|
private onIndicatorChange;
|
|
76
|
+
connectedCallback(): void;
|
|
76
77
|
disconnectedCallback(): void;
|
|
77
|
-
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
78
78
|
protected render(): TemplateResult;
|
|
79
79
|
private onSlotChange;
|
|
80
80
|
private onClick;
|
package/components/tabs/tabs.js
CHANGED
|
@@ -98,14 +98,16 @@ let Tabs = class Tabs extends MduiElement {
|
|
|
98
98
|
await this.updateComplete;
|
|
99
99
|
this.updateIndicator();
|
|
100
100
|
}
|
|
101
|
+
connectedCallback() {
|
|
102
|
+
super.connectedCallback();
|
|
103
|
+
this.updateComplete.then(() => {
|
|
104
|
+
this.observeResize = observeResize(this.containerRef.value, () => this.updateIndicator());
|
|
105
|
+
});
|
|
106
|
+
}
|
|
101
107
|
disconnectedCallback() {
|
|
102
108
|
super.disconnectedCallback();
|
|
103
109
|
this.observeResize?.unobserve();
|
|
104
110
|
}
|
|
105
|
-
firstUpdated(_changedProperties) {
|
|
106
|
-
super.firstUpdated(_changedProperties);
|
|
107
|
-
this.observeResize = observeResize(this.containerRef.value, () => this.updateIndicator());
|
|
108
|
-
}
|
|
109
111
|
render() {
|
|
110
112
|
return html `<div ${ref(this.containerRef)} part="container" class="container ${classMap({ initial: this.isInitial })}"><slot @slotchange="${this.onSlotChange}" @click="${this.onClick}"></slot><div ${ref(this.indicatorRef)} part="indicator" class="indicator"></div></div><slot name="panel" @slotchange="${this.onSlotChange}"></slot>`;
|
|
111
113
|
}
|
|
@@ -7,8 +7,8 @@ import '@mdui/shared/icons/visibility.js';
|
|
|
7
7
|
import '../button-icon.js';
|
|
8
8
|
import '../icon.js';
|
|
9
9
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
10
|
-
import type { CSSResultGroup,
|
|
11
|
-
declare const TextField_base: import("@
|
|
10
|
+
import type { CSSResultGroup, TemplateResult } from 'lit';
|
|
11
|
+
declare const TextField_base: import("@lit/reactive-element/decorators/base.js").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
12
12
|
/**
|
|
13
13
|
* @summary 文本框组件
|
|
14
14
|
*
|
|
@@ -228,12 +228,9 @@ export declare class TextField extends TextField_base<TextFieldEventMap> impleme
|
|
|
228
228
|
*/
|
|
229
229
|
autocorrect?: string;
|
|
230
230
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
* * `off`:禁用浏览器的自动填充,使用者必须输入他们想要输入的所有内容。或者网页提供了自己的自动填充方法
|
|
234
|
-
* * `on`:浏览器根据用户之前输入的内容或者习惯,在用户输入的时候给出相应输入提示
|
|
231
|
+
* `input` 元素的 `autocomplete` 属性
|
|
235
232
|
*/
|
|
236
|
-
autocomplete?:
|
|
233
|
+
autocomplete?: string;
|
|
237
234
|
/**
|
|
238
235
|
* `input` 元素的 `enterkeyhint` 属性,用于定制虚拟键盘上的 Enter 键的显示文本或图标。具体显示效果取决于用户使用的设备和语言。可选值包括:
|
|
239
236
|
*
|
|
@@ -324,6 +321,7 @@ export declare class TextField extends TextField_base<TextFieldEventMap> impleme
|
|
|
324
321
|
private onRowsChange;
|
|
325
322
|
private onMaxRowsChange;
|
|
326
323
|
private onMinRowsChange;
|
|
324
|
+
connectedCallback(): void;
|
|
327
325
|
disconnectedCallback(): void;
|
|
328
326
|
/**
|
|
329
327
|
* 选中文本框中的文本
|
|
@@ -365,7 +363,6 @@ export declare class TextField extends TextField_base<TextFieldEventMap> impleme
|
|
|
365
363
|
* @param message 自定义的错误提示文本
|
|
366
364
|
*/
|
|
367
365
|
setCustomValidity(message: string): void;
|
|
368
|
-
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
369
366
|
protected render(): TemplateResult;
|
|
370
367
|
private setCustomValidityInternal;
|
|
371
368
|
private onChange;
|
|
@@ -383,6 +380,7 @@ export declare class TextField extends TextField_base<TextFieldEventMap> impleme
|
|
|
383
380
|
private renderLabel;
|
|
384
381
|
private renderPrefix;
|
|
385
382
|
private renderSuffix;
|
|
383
|
+
private renderRightIcon;
|
|
386
384
|
private renderClearButton;
|
|
387
385
|
private renderTogglePasswordButton;
|
|
388
386
|
private renderInput;
|
|
@@ -7,7 +7,6 @@ import { live } from 'lit/directives/live.js';
|
|
|
7
7
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
8
8
|
import { when } from 'lit/directives/when.js';
|
|
9
9
|
import { msg } from '@lit/localize';
|
|
10
|
-
import { animate } from '@lit-labs/motion';
|
|
11
10
|
import { $ } from '@mdui/jq/$.js';
|
|
12
11
|
import '@mdui/jq/methods/css.js';
|
|
13
12
|
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
@@ -16,7 +15,6 @@ import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
|
16
15
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
17
16
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
18
17
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
19
|
-
import { getDuration, getEasing } from '@mdui/shared/helpers/motion.js';
|
|
20
18
|
import { observeResize } from '@mdui/shared/helpers/observeResize.js';
|
|
21
19
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
22
20
|
import '@mdui/shared/icons/cancel--outlined.js';
|
|
@@ -236,9 +234,10 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
236
234
|
this.invalid = !this.inputRef.value.checkValidity();
|
|
237
235
|
}
|
|
238
236
|
async onValueChange() {
|
|
239
|
-
this.hasValue =
|
|
237
|
+
this.hasValue = !['', null].includes(this.value);
|
|
240
238
|
if (this.hasUpdated) {
|
|
241
239
|
await this.updateComplete;
|
|
240
|
+
this.setTextareaHeight();
|
|
242
241
|
// reset 引起的值变更,不执行验证;直接修改值引起的变更,需要进行验证
|
|
243
242
|
const form = this.formController.getForm();
|
|
244
243
|
if (form && formResets.get(form)?.has(this)) {
|
|
@@ -279,6 +278,13 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
279
278
|
parseFloat($input.css('padding-top')) +
|
|
280
279
|
parseFloat($input.css('padding-bottom')));
|
|
281
280
|
}
|
|
281
|
+
connectedCallback() {
|
|
282
|
+
super.connectedCallback();
|
|
283
|
+
this.updateComplete.then(() => {
|
|
284
|
+
this.setTextareaHeight();
|
|
285
|
+
this.observeResize = observeResize(this.inputRef.value, () => this.setTextareaHeight());
|
|
286
|
+
});
|
|
287
|
+
}
|
|
282
288
|
disconnectedCallback() {
|
|
283
289
|
super.disconnectedCallback();
|
|
284
290
|
this.observeResize?.unobserve();
|
|
@@ -361,15 +367,17 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
361
367
|
// 外部调用 setCustomValidity 时,不再使用内置的验证规则,所以需要移除监听语言变更事件
|
|
362
368
|
offLocaleReady(this);
|
|
363
369
|
}
|
|
364
|
-
firstUpdated(_changedProperties) {
|
|
365
|
-
super.firstUpdated(_changedProperties);
|
|
366
|
-
this.setTextareaHeight();
|
|
367
|
-
this.observeResize = observeResize(this.inputRef.value, () => this.setTextareaHeight());
|
|
368
|
-
}
|
|
369
370
|
render() {
|
|
370
371
|
const hasIcon = !!this.icon || this.hasSlotController.test('icon');
|
|
371
372
|
const hasEndIcon = !!this.endIcon || this.hasSlotController.test('end-icon');
|
|
372
373
|
const hasErrorIcon = this.invalid || this.invalidStyle;
|
|
374
|
+
const hasTogglePasswordButton = this.type === 'password' && this.togglePassword && !this.disabled;
|
|
375
|
+
const hasClearButton = this.clearable &&
|
|
376
|
+
!this.disabled &&
|
|
377
|
+
(!this.readonly || this.readonlyButClearable) &&
|
|
378
|
+
(typeof this.value === 'number' || this.value.length > 0);
|
|
379
|
+
const hasPrefix = !!this.prefix || this.hasSlotController.test('prefix');
|
|
380
|
+
const hasSuffix = !!this.suffix || this.hasSlotController.test('suffix');
|
|
373
381
|
const hasHelper = !!this.helper || this.hasSlotController.test('helper');
|
|
374
382
|
const hasError = hasErrorIcon && !!(this.error || this.inputRef.value.validationMessage);
|
|
375
383
|
const hasCounter = this.counter && !!this.maxlength;
|
|
@@ -383,14 +391,16 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
383
391
|
container: true,
|
|
384
392
|
'has-value': this.hasValue,
|
|
385
393
|
'has-icon': hasIcon,
|
|
386
|
-
'has-
|
|
387
|
-
'has-
|
|
394
|
+
'has-right-icon': hasEndIcon || hasErrorIcon,
|
|
395
|
+
'has-action': hasClearButton || hasTogglePasswordButton,
|
|
396
|
+
'has-prefix': hasPrefix,
|
|
397
|
+
'has-suffix': hasSuffix,
|
|
388
398
|
'is-firefox': navigator.userAgent.includes('Firefox'),
|
|
389
399
|
...invalidClassNameObj,
|
|
390
400
|
});
|
|
391
401
|
return html `<div part="container" class="${className}">${this.renderPrefix()}<div class="input-container">${this.renderLabel()} ${this.isTextarea
|
|
392
402
|
? this.renderTextArea(hasInputSlot)
|
|
393
|
-
: this.renderInput(hasInputSlot)} ${when(hasInputSlot, () => html `<slot name="input" class="input"></slot>`)}</div>${this.renderClearButton()}${this.renderTogglePasswordButton()} ${this.
|
|
403
|
+
: this.renderInput(hasInputSlot)} ${when(hasInputSlot, () => html `<slot name="input" class="input"></slot>`)}</div>${this.renderSuffix()}${this.renderClearButton(hasClearButton)} ${this.renderTogglePasswordButton(hasTogglePasswordButton)} ${this.renderRightIcon(hasErrorIcon)}</div>${when(hasError || hasHelper || hasCounter, () => html `<div part="supporting" class="${classMap({ supporting: true, ...invalidClassNameObj })}">${this.renderHelper(hasError, hasHelper)} ${this.renderCounter(hasCounter)}</div>`)}`;
|
|
394
404
|
}
|
|
395
405
|
setCustomValidityInternal(message) {
|
|
396
406
|
this.inputRef.value.setCustomValidity(message);
|
|
@@ -412,7 +422,8 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
412
422
|
this.focus();
|
|
413
423
|
event.stopPropagation();
|
|
414
424
|
}
|
|
415
|
-
onInput() {
|
|
425
|
+
onInput(event) {
|
|
426
|
+
event.stopPropagation();
|
|
416
427
|
this.value = this.inputRef.value.value;
|
|
417
428
|
if (this.isTextarea) {
|
|
418
429
|
this.setTextareaHeight();
|
|
@@ -471,12 +482,7 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
471
482
|
}
|
|
472
483
|
renderLabel() {
|
|
473
484
|
return this.label
|
|
474
|
-
? html `<label part="label" class="label"
|
|
475
|
-
keyframeOptions: {
|
|
476
|
-
duration: getDuration(this, 'short4'),
|
|
477
|
-
easing: getEasing(this, 'standard'),
|
|
478
|
-
},
|
|
479
|
-
})}>${this.label}</label>`
|
|
485
|
+
? html `<label part="label" class="label">${this.label}</label>`
|
|
480
486
|
: nothingTemplate;
|
|
481
487
|
}
|
|
482
488
|
renderPrefix() {
|
|
@@ -484,27 +490,25 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
484
490
|
? html `<mdui-icon name="${this.icon}" class="i"></mdui-icon>`
|
|
485
491
|
: nothingTemplate}</slot><slot name="prefix" part="prefix" class="prefix">${this.prefix}</slot>`;
|
|
486
492
|
}
|
|
487
|
-
renderSuffix(
|
|
488
|
-
return html `<slot name="suffix" part="suffix" class="suffix">${this.suffix}</slot
|
|
493
|
+
renderSuffix() {
|
|
494
|
+
return html `<slot name="suffix" part="suffix" class="suffix">${this.suffix}</slot>`;
|
|
495
|
+
}
|
|
496
|
+
renderRightIcon(hasErrorIcon) {
|
|
497
|
+
return hasErrorIcon
|
|
489
498
|
? html `<slot name="error-icon" part="error-icon" class="right-icon">${this.errorIcon
|
|
490
499
|
? html `<mdui-icon name="${this.errorIcon}" class="i"></mdui-icon>`
|
|
491
500
|
: html `<mdui-icon-error class="i"></mdui-icon-error>`}</slot>`
|
|
492
501
|
: html `<slot name="end-icon" part="end-icon" class="end-icon right-icon">${this.endIcon
|
|
493
502
|
? html `<mdui-icon name="${this.endIcon}" class="i"></mdui-icon>`
|
|
494
|
-
: nothingTemplate}</slot
|
|
503
|
+
: nothingTemplate}</slot>`;
|
|
495
504
|
}
|
|
496
|
-
renderClearButton() {
|
|
497
|
-
|
|
498
|
-
!this.disabled &&
|
|
499
|
-
(!this.readonly || this.readonlyButClearable) &&
|
|
500
|
-
(typeof this.value === 'number' || this.value.length > 0);
|
|
501
|
-
return when(hasClearButton, () => html `<slot name="clear-button" part="clear-button" class="right-icon" @click="${this.onClear}"><mdui-button-icon tabindex="-1"><slot name="clear-icon" part="clear-icon">${this.clearIcon
|
|
505
|
+
renderClearButton(hasClearButton) {
|
|
506
|
+
return when(hasClearButton, () => html `<slot name="clear-button" part="clear-button" class="action" @click="${this.onClear}"><mdui-button-icon tabindex="-1"><slot name="clear-icon" part="clear-icon">${this.clearIcon
|
|
502
507
|
? html `<mdui-icon name="${this.clearIcon}" class="i"></mdui-icon>`
|
|
503
508
|
: html `<mdui-icon-cancel--outlined class="i"></mdui-icon-cancel--outlined>`}</slot></mdui-button-icon></slot>`);
|
|
504
509
|
}
|
|
505
|
-
renderTogglePasswordButton() {
|
|
506
|
-
|
|
507
|
-
return when(hasTogglePasswordButton, () => html `<slot name="toggle-password-button" part="toggle-password-button" class="right-icon" @click="${this.onTogglePassword}"><mdui-button-icon tabindex="-1">${this.isPasswordVisible
|
|
510
|
+
renderTogglePasswordButton(hasTogglePasswordButton) {
|
|
511
|
+
return when(hasTogglePasswordButton, () => html `<slot name="toggle-password-button" part="toggle-password-button" class="action" @click="${this.onTogglePassword}"><mdui-button-icon tabindex="-1">${this.isPasswordVisible
|
|
508
512
|
? html `<slot name="show-password-icon" part="show-password-icon">${this.showPasswordIcon
|
|
509
513
|
? html `<mdui-icon name="${this.showPasswordIcon}" class="i"></mdui-icon>`
|
|
510
514
|
: html `<mdui-icon-visibility-off class="i"></mdui-icon-visibility-off>`}</slot>`
|
|
@@ -519,7 +523,7 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
519
523
|
// @ts-ignore
|
|
520
524
|
!this.label || this.isFocusedStyle || this.hasValue
|
|
521
525
|
? this.placeholder
|
|
522
|
-
: undefined)}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" ?required="${this.required}" minlength="${ifDefined(this.minlength)}" maxlength="${ifDefined(this.maxlength)}" min="${ifDefined(this.min)}" max="${ifDefined(this.max)}" step="${ifDefined(this.step)}" autocapitalize="${ifDefined(this.type === 'password' ? 'off' : this.autocapitalize)}" autocomplete="${
|
|
526
|
+
: undefined)}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" ?required="${this.required}" minlength="${ifDefined(this.minlength)}" maxlength="${ifDefined(this.maxlength)}" min="${ifDefined(this.min)}" max="${ifDefined(this.max)}" step="${ifDefined(this.step)}" autocapitalize="${ifDefined(this.type === 'password' ? 'off' : this.autocapitalize)}" autocomplete="${this.autocomplete}" autocorrect="${ifDefined(this.type === 'password' ? 'off' : this.autocorrect)}" spellcheck="${ifDefined(this.spellcheck)}" pattern="${ifDefined(this.pattern)}" enterkeyhint="${ifDefined(this.enterkeyhint)}" inputmode="${ifDefined(this.inputmode)}" @change="${this.onChange}" @input="${this.onInput}" @invalid="${this.onInvalid}" @keydown="${this.onKeyDown}">`;
|
|
523
527
|
}
|
|
524
528
|
renderTextArea(hasInputSlot) {
|
|
525
529
|
return html `<textarea ${ref(this.inputRef)} part="input" class="input ${classMap({ 'hide-input': hasInputSlot })}" name="${ifDefined(this.name)}" .value="${live(this.value)}" placeholder="${ifDefined(
|