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.
Files changed (97) hide show
  1. package/LICENSE +21 -21
  2. package/components/avatar/index.js +2 -1
  3. package/components/badge/index.js +2 -1
  4. package/components/bottom-app-bar/index.d.ts +2 -2
  5. package/components/bottom-app-bar/index.js +4 -3
  6. package/components/button/button-base.d.ts +2 -2
  7. package/components/button/button-base.js +15 -14
  8. package/components/button/index.js +2 -1
  9. package/components/button-icon/index.js +2 -1
  10. package/components/card/index.d.ts +1 -1
  11. package/components/card/index.js +5 -2
  12. package/components/checkbox/index.js +7 -10
  13. package/components/checkbox/style.js +1 -1
  14. package/components/chip/index.js +2 -1
  15. package/components/circular-progress/index.js +3 -3
  16. package/components/collapse/collapse-item-style.js +1 -1
  17. package/components/collapse/collapse-item.d.ts +2 -1
  18. package/components/collapse/collapse-item.js +23 -20
  19. package/components/collapse/collapse.d.ts +6 -6
  20. package/components/collapse/collapse.js +57 -34
  21. package/components/dialog/index.d.ts +3 -2
  22. package/components/dialog/index.js +27 -23
  23. package/components/divider/index.js +2 -1
  24. package/components/dropdown/index.d.ts +4 -5
  25. package/components/dropdown/index.js +56 -51
  26. package/components/fab/index.d.ts +1 -0
  27. package/components/fab/index.js +10 -5
  28. package/components/icon/index.js +2 -1
  29. package/components/layout/helper.d.ts +5 -6
  30. package/components/layout/helper.js +42 -48
  31. package/components/layout/layout-item-base.js +1 -2
  32. package/components/layout/layout-item.js +3 -3
  33. package/components/layout/layout-main.js +2 -1
  34. package/components/layout/layout.js +2 -1
  35. package/components/linear-progress/index.js +3 -3
  36. package/components/list/list-item.js +3 -2
  37. package/components/list/list-subheader.js +2 -1
  38. package/components/list/list.js +2 -1
  39. package/components/menu/menu-item.d.ts +1 -0
  40. package/components/menu/menu-item.js +45 -28
  41. package/components/menu/menu.d.ts +4 -1
  42. package/components/menu/menu.js +82 -56
  43. package/components/navigation-bar/navigation-bar-item-style.js +1 -1
  44. package/components/navigation-bar/navigation-bar-item.d.ts +6 -2
  45. package/components/navigation-bar/navigation-bar-item.js +26 -10
  46. package/components/navigation-bar/navigation-bar.d.ts +6 -6
  47. package/components/navigation-bar/navigation-bar.js +49 -42
  48. package/components/navigation-drawer/index.d.ts +5 -1
  49. package/components/navigation-drawer/index.js +62 -41
  50. package/components/navigation-rail/navigation-rail-item-style.js +1 -1
  51. package/components/navigation-rail/navigation-rail-item.d.ts +6 -2
  52. package/components/navigation-rail/navigation-rail-item.js +20 -8
  53. package/components/navigation-rail/navigation-rail.d.ts +4 -5
  54. package/components/navigation-rail/navigation-rail.js +51 -44
  55. package/components/radio/radio-group.d.ts +6 -4
  56. package/components/radio/radio-group.js +61 -48
  57. package/components/radio/radio-style.js +1 -1
  58. package/components/radio/radio.d.ts +3 -2
  59. package/components/radio/radio.js +24 -17
  60. package/components/range-slider/index.js +7 -9
  61. package/components/ripple/index.js +2 -1
  62. package/components/segmented-button/segmented-button-group.d.ts +6 -3
  63. package/components/segmented-button/segmented-button-group.js +84 -69
  64. package/components/segmented-button/segmented-button.d.ts +2 -2
  65. package/components/segmented-button/segmented-button.js +5 -4
  66. package/components/select/index.d.ts +2 -2
  67. package/components/select/index.js +26 -24
  68. package/components/slider/index.js +7 -9
  69. package/components/slider/slider-base-style.js +1 -1
  70. package/components/slider/slider-base.js +1 -5
  71. package/components/snackbar/index.js +2 -1
  72. package/components/switch/index.js +6 -9
  73. package/components/switch/style.js +1 -1
  74. package/components/tabs/tab-panel.js +2 -1
  75. package/components/tabs/tab-style.js +1 -1
  76. package/components/tabs/tab.js +10 -5
  77. package/components/tabs/tabs-style.js +1 -1
  78. package/components/tabs/tabs.d.ts +6 -5
  79. package/components/tabs/tabs.js +52 -38
  80. package/components/text-field/index.d.ts +2 -2
  81. package/components/text-field/index.js +32 -54
  82. package/components/text-field/style.js +1 -1
  83. package/components/tooltip/index.d.ts +5 -5
  84. package/components/tooltip/index.js +30 -25
  85. package/components/top-app-bar/top-app-bar-title-style.js +1 -1
  86. package/components/top-app-bar/top-app-bar-title.js +16 -12
  87. package/components/top-app-bar/top-app-bar.d.ts +2 -2
  88. package/components/top-app-bar/top-app-bar.js +6 -4
  89. package/custom-elements.json +3421 -3126
  90. package/functions/getTheme.js +3 -3
  91. package/functions/snackbar.js +1 -2
  92. package/functions/utils/colorScheme.js +2 -2
  93. package/html-data.zh-cn.json +438 -438
  94. package/mdui.esm.js +8 -8
  95. package/mdui.global.js +8 -8
  96. package/package.json +7 -7
  97. package/web-types.zh-cn.json +770 -770
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016-present zdhxiong@gmail.com
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016-present zdhxiong@gmail.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -22,7 +22,7 @@ import { style } from './style.js';
22
22
  *
23
23
  * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
24
24
  */
25
- export let Avatar = class Avatar extends LitElement {
25
+ let Avatar = class Avatar extends LitElement {
26
26
  constructor() {
27
27
  super(...arguments);
28
28
  this.hasSlotController = new HasSlotController(this, '[default]');
@@ -53,3 +53,4 @@ __decorate([
53
53
  Avatar = __decorate([
54
54
  customElement('mdui-avatar')
55
55
  ], Avatar);
56
+ export { Avatar };
@@ -15,7 +15,7 @@ import { style } from './style.js';
15
15
  *
16
16
  * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
17
17
  */
18
- export let Badge = class Badge extends LitElement {
18
+ let Badge = class Badge extends LitElement {
19
19
  constructor() {
20
20
  super(...arguments);
21
21
  /**
@@ -39,3 +39,4 @@ __decorate([
39
39
  Badge = __decorate([
40
40
  customElement('mdui-badge')
41
41
  ], Badge);
42
+ export { Badge };
@@ -1,7 +1,7 @@
1
1
  import { LayoutItemBase } from '../layout/layout-item-base.js';
2
2
  import type { LayoutPlacement } from '../layout/helper.js';
3
3
  import type { ScrollPaddingPosition } from '@mdui/shared/mixins/scrollBehavior.js';
4
- import type { CSSResultGroup, TemplateResult } from 'lit';
4
+ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
5
5
  declare const BottomAppBar_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/scrollBehavior.js").ScrollBehaviorMixinInterface> & typeof LayoutItemBase;
6
6
  /**
7
7
  * @summary 底部应用栏组件
@@ -44,7 +44,7 @@ export declare class BottomAppBar extends BottomAppBar_base {
44
44
  scrollBehavior?: 'hide';
45
45
  protected get scrollPaddingPosition(): ScrollPaddingPosition;
46
46
  protected get layoutPlacement(): LayoutPlacement;
47
- connectedCallback(): void;
47
+ protected firstUpdated(_changedProperties: PropertyValues): void;
48
48
  protected render(): TemplateResult;
49
49
  /**
50
50
  * 滚动行为
@@ -31,7 +31,7 @@ import { style } from './style.js';
31
31
  * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
32
32
  * @cssprop --z-index - 组件的 CSS 的 `z-index` 值
33
33
  */
34
- export let BottomAppBar = class BottomAppBar extends ScrollBehaviorMixin(LayoutItemBase) {
34
+ let BottomAppBar = class BottomAppBar extends ScrollBehaviorMixin(LayoutItemBase) {
35
35
  constructor() {
36
36
  super(...arguments);
37
37
  /**
@@ -49,8 +49,8 @@ export let BottomAppBar = class BottomAppBar extends ScrollBehaviorMixin(LayoutI
49
49
  get layoutPlacement() {
50
50
  return 'bottom';
51
51
  }
52
- connectedCallback() {
53
- super.connectedCallback();
52
+ firstUpdated(_changedProperties) {
53
+ super.firstUpdated(_changedProperties);
54
54
  this.addEventListener('transitionend', (event) => {
55
55
  if (event.target === this) {
56
56
  emit(this, this.hide ? 'hidden' : 'shown');
@@ -103,3 +103,4 @@ __decorate([
103
103
  BottomAppBar = __decorate([
104
104
  customElement('mdui-bottom-app-bar')
105
105
  ], BottomAppBar);
106
+ export { BottomAppBar };
@@ -1,6 +1,6 @@
1
1
  import { LitElement } from 'lit';
2
2
  import '../circular-progress.js';
3
- import type { CSSResultGroup, TemplateResult } from 'lit';
3
+ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
4
4
  type RenderButtonOptions = {
5
5
  id?: string;
6
6
  className?: string;
@@ -114,7 +114,6 @@ export declare class ButtonBase extends ButtonBase_base {
114
114
  protected get rippleDisabled(): boolean;
115
115
  protected get focusElement(): HTMLElement | null;
116
116
  protected get focusDisabled(): boolean;
117
- connectedCallback(): void;
118
117
  /**
119
118
  * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`
120
119
  */
@@ -131,6 +130,7 @@ export declare class ButtonBase extends ButtonBase_base {
131
130
  * @param message 自定义的提示文本
132
131
  */
133
132
  setCustomValidity(message: string): void;
133
+ protected firstUpdated(_changedProperties: PropertyValues): void;
134
134
  protected renderLoading(): TemplateResult;
135
135
  protected renderButton({ id, className, part, content, }: RenderButtonOptions): TemplateResult;
136
136
  protected isButton(): boolean;
@@ -76,25 +76,15 @@ export class ButtonBase extends AnchorMixin(RippleMixin(FocusableMixin(LitElemen
76
76
  return this.disabled || this.loading;
77
77
  }
78
78
  get focusElement() {
79
- var _a, _b;
80
79
  return this.isButton()
81
- ? (_a = this.renderRoot) === null || _a === void 0 ? void 0 : _a.querySelector('._button')
82
- : (_b = this.renderRoot) === null || _b === void 0 ? void 0 : _b.querySelector('._a');
80
+ ? this.renderRoot?.querySelector('._button')
81
+ : !this.focusDisabled
82
+ ? this.renderRoot?.querySelector('._a')
83
+ : this;
83
84
  }
84
85
  get focusDisabled() {
85
86
  return this.disabled || this.loading;
86
87
  }
87
- connectedCallback() {
88
- super.connectedCallback();
89
- this.addEventListener('click', () => {
90
- if (this.type === 'submit') {
91
- this.formController.submit(this);
92
- }
93
- if (this.type === 'reset') {
94
- this.formController.reset(this);
95
- }
96
- });
97
- }
98
88
  /**
99
89
  * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`
100
90
  */
@@ -142,6 +132,17 @@ export class ButtonBase extends AnchorMixin(RippleMixin(FocusableMixin(LitElemen
142
132
  this.focusElement.setCustomValidity(message);
143
133
  }
144
134
  }
135
+ firstUpdated(_changedProperties) {
136
+ super.firstUpdated(_changedProperties);
137
+ this.addEventListener('click', () => {
138
+ if (this.type === 'submit') {
139
+ this.formController.submit(this);
140
+ }
141
+ if (this.type === 'reset') {
142
+ this.formController.reset(this);
143
+ }
144
+ });
145
+ }
145
146
  renderLoading() {
146
147
  return this.loading
147
148
  ? html `<mdui-circular-progress part="loading"></mdui-circular-progress>`
@@ -30,7 +30,7 @@ import { style } from './style.js';
30
30
  *
31
31
  * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
32
32
  */
33
- export let Button = class Button extends ButtonBase {
33
+ let Button = class Button extends ButtonBase {
34
34
  constructor() {
35
35
  super(...arguments);
36
36
  /**
@@ -108,3 +108,4 @@ __decorate([
108
108
  Button = __decorate([
109
109
  customElement('mdui-button')
110
110
  ], Button);
111
+ export { Button };
@@ -32,7 +32,7 @@ import { style } from './style.js';
32
32
  *
33
33
  * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
34
34
  */
35
- export let ButtonIcon = class ButtonIcon extends ButtonBase {
35
+ let ButtonIcon = class ButtonIcon extends ButtonBase {
36
36
  constructor() {
37
37
  super(...arguments);
38
38
  /**
@@ -127,3 +127,4 @@ __decorate([
127
127
  ButtonIcon = __decorate([
128
128
  customElement('mdui-button-icon')
129
129
  ], ButtonIcon);
130
+ export { ButtonIcon };
@@ -37,7 +37,7 @@ export declare class Card extends Card_base {
37
37
  private readonly rippleRef;
38
38
  protected get rippleElement(): Ripple;
39
39
  protected get rippleDisabled(): boolean;
40
- protected get focusElement(): HTMLElement;
40
+ protected get focusElement(): HTMLElement | null;
41
41
  protected get focusDisabled(): boolean;
42
42
  protected render(): TemplateResult;
43
43
  }
@@ -22,7 +22,7 @@ import { style } from './style.js';
22
22
  *
23
23
  * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
24
24
  */
25
- export let Card = class Card extends AnchorMixin(RippleMixin(FocusableMixin(LitElement))) {
25
+ let Card = class Card extends AnchorMixin(RippleMixin(FocusableMixin(LitElement))) {
26
26
  constructor() {
27
27
  super(...arguments);
28
28
  /**
@@ -50,7 +50,9 @@ export let Card = class Card extends AnchorMixin(RippleMixin(FocusableMixin(LitE
50
50
  return this.disabled || (!this.href && !this.clickable);
51
51
  }
52
52
  get focusElement() {
53
- return this;
53
+ return this.href && !this.disabled
54
+ ? this.renderRoot.querySelector('._a')
55
+ : this;
54
56
  }
55
57
  get focusDisabled() {
56
58
  return this.rippleDisabled;
@@ -85,3 +87,4 @@ __decorate([
85
87
  Card = __decorate([
86
88
  customElement('mdui-card')
87
89
  ], Card);
90
+ export { Card };
@@ -1,6 +1,7 @@
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
+ import { classMap } from 'lit/directives/class-map.js';
4
5
  import { ifDefined } from 'lit/directives/if-defined.js';
5
6
  import { live } from 'lit/directives/live.js';
6
7
  import { createRef, ref } from 'lit/directives/ref.js';
@@ -41,7 +42,7 @@ import { style } from './style.js';
41
42
  * @csspart indeterminate-icon - 不确定状态图标
42
43
  * @csspart label - 文本
43
44
  */
44
- export let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitElement)) {
45
+ let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitElement)) {
45
46
  constructor() {
46
47
  super(...arguments);
47
48
  /**
@@ -113,11 +114,10 @@ export let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitEleme
113
114
  this.invalid = !this.inputRef.value.checkValidity();
114
115
  }
115
116
  async onCheckedChange() {
116
- var _a;
117
117
  await this.updateComplete;
118
118
  // reset 引起的值变更,不执行验证;直接修改值引起的变更,需要进行验证
119
119
  const form = this.formController.getForm();
120
- if (form && ((_a = formResets.get(form)) === null || _a === void 0 ? void 0 : _a.has(this))) {
120
+ if (form && formResets.get(form)?.has(this)) {
121
121
  this.invalid = false;
122
122
  formResets.get(form).delete(this);
123
123
  }
@@ -170,7 +170,7 @@ export let Checkbox = class Checkbox extends RippleMixin(FocusableMixin(LitEleme
170
170
  this.invalid = !this.inputRef.value.checkValidity();
171
171
  }
172
172
  render() {
173
- return html `<label><input ${ref(this.inputRef)} type="checkbox" name="${ifDefined(this.name)}" value="${ifDefined(this.value)}" .indeterminate="${live(this.indeterminate)}" .disabled="${this.disabled}" .checked="${live(this.checked)}" .required="${this.required}" @change="${this.onChange}"> <i part="control"><mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple><slot name="unchecked-icon" part="unchecked-icon" class="icon unchecked-icon">${this.uncheckedIcon
173
+ return html `<label class="${classMap({ invalid: this.invalid })}"><input ${ref(this.inputRef)} type="checkbox" name="${ifDefined(this.name)}" value="${ifDefined(this.value)}" .indeterminate="${live(this.indeterminate)}" .disabled="${this.disabled}" .checked="${live(this.checked)}" .required="${this.required}" @change="${this.onChange}"> <i part="control"><mdui-ripple ${ref(this.rippleRef)} .noRipple="${this.noRipple}"></mdui-ripple><slot name="unchecked-icon" part="unchecked-icon" class="icon unchecked-icon">${this.uncheckedIcon
174
174
  ? html `<mdui-icon name="${this.uncheckedIcon}" class="i"></mdui-icon>`
175
175
  : html `<mdui-icon-check-box-outline-blank class="i"></mdui-icon-check-box-outline-blank>`}</slot><slot name="checked-icon" part="checked-icon" class="icon checked-icon">${this.checkedIcon
176
176
  ? html `<mdui-icon name="${this.checkedIcon}" class="i"></mdui-icon>`
@@ -238,11 +238,7 @@ __decorate([
238
238
  property({ reflect: true, attribute: 'indeterminate-icon' })
239
239
  ], Checkbox.prototype, "indeterminateIcon", void 0);
240
240
  __decorate([
241
- property({
242
- type: Boolean,
243
- reflect: true,
244
- converter: booleanConverter,
245
- })
241
+ state()
246
242
  ], Checkbox.prototype, "invalid", void 0);
247
243
  __decorate([
248
244
  watch('disabled', true),
@@ -255,3 +251,4 @@ __decorate([
255
251
  Checkbox = __decorate([
256
252
  customElement('mdui-checkbox')
257
253
  ], Checkbox);
254
+ export { Checkbox };
@@ -1,2 +1,2 @@
1
1
  import { css } from 'lit';
2
- export const style = css `:host{position:relative;display:inline-flex;cursor:pointer;-webkit-tap-highlight-color:transparent;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)}label{display:inline-flex;align-items:center;width:100%;cursor:inherit;-webkit-user-select:none;user-select:none;touch-action:manipulation;zoom:1;-webkit-user-drag:none}input{position:absolute;padding:0;opacity:0;pointer-events:none;width:1.125rem;height:1.125rem;margin:0 0 0 .6875rem}.icon{display:flex;position:absolute;opacity:1;transform:scale(1);color:rgb(var(--mdui-color-on-surface));font-size:1.5rem;transition:color var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard)}.checked-icon,.indeterminate-icon{opacity:0;transform:scale(.5);transition-property:color,opacity,transform;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard)}.icon .i,::slotted([slot=checked-icon]),::slotted([slot=indeterminate-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));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]) .indeterminate-icon{opacity:0;transform:scale(.5)}:host([checked]) .checked-icon{opacity:1;transform:scale(1)}:host([indeterminate]) i{--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}:host([indeterminate]) .icon{color:rgb(var(--mdui-color-primary))}:host([indeterminate]) .checked-icon{opacity:0;transform:scale(.5)}:host([indeterminate]) .indeterminate-icon{opacity:1;transform:scale(1)}:host([invalid]) i{--mdui-comp-ripple-state-layer-color:var(--mdui-color-error)}:host([invalid]) .icon{color:rgb(var(--mdui-color-error))}:host([invalid]) .label{color:rgb(var(--mdui-color-error))}:host([disabled]){cursor:default;pointer-events:none}:host([disabled]) .icon{color:rgba(var(--mdui-color-on-surface),38%)}:host([disabled]) .label{color:rgba(var(--mdui-color-on-surface),38%)}:host([disabled][checked]) .unchecked-icon,:host([disabled][indeterminate]) .unchecked-icon{opacity:0}`;
2
+ export const style = css `:host{position:relative;display:inline-flex;cursor:pointer;-webkit-tap-highlight-color:transparent;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)}label{display:inline-flex;align-items:center;width:100%;cursor:inherit;-webkit-user-select:none;user-select:none;touch-action:manipulation;zoom:1;-webkit-user-drag:none}input{position:absolute;padding:0;opacity:0;pointer-events:none;width:1.125rem;height:1.125rem;margin:0 0 0 .6875rem}.icon{display:flex;position:absolute;opacity:1;transform:scale(1);color:rgb(var(--mdui-color-on-surface));font-size:1.5rem;transition:color var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard)}.checked-icon,.indeterminate-icon{opacity:0;transform:scale(.5);transition-property:color,opacity,transform;transition-duration:var(--mdui-motion-duration-short4);transition-timing-function:var(--mdui-motion-easing-standard)}.icon .i,::slotted([slot=checked-icon]),::slotted([slot=indeterminate-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));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]) .indeterminate-icon{opacity:0;transform:scale(.5)}:host([checked]) .checked-icon{opacity:1;transform:scale(1)}:host([indeterminate]) i{--mdui-comp-ripple-state-layer-color:var(--mdui-color-primary)}:host([indeterminate]) .icon{color:rgb(var(--mdui-color-primary))}:host([indeterminate]) .checked-icon{opacity:0;transform:scale(.5)}:host([indeterminate]) .indeterminate-icon{opacity:1;transform:scale(1)}.invalid i{--mdui-comp-ripple-state-layer-color:var(--mdui-color-error)}.invalid .icon{color:rgb(var(--mdui-color-error))}.invalid .label{color:rgb(var(--mdui-color-error))}:host([disabled]){cursor:default;pointer-events:none}:host([disabled]) .icon{color:rgba(var(--mdui-color-on-surface),38%)}:host([disabled]) .label{color:rgba(var(--mdui-color-on-surface),38%)}:host([disabled][checked]) .unchecked-icon,:host([disabled][indeterminate]) .unchecked-icon{opacity:0}`;
@@ -42,7 +42,7 @@ import { style } from './style.js';
42
42
  *
43
43
  * @cssprop --shape-corner - 组件的圆角大小。可以指定一个具体的像素值;但更推荐[引用设计令牌](/docs/2/styles/design-tokens#shape-corner)
44
44
  */
45
- export let Chip = class Chip extends ButtonBase {
45
+ let Chip = class Chip extends ButtonBase {
46
46
  constructor() {
47
47
  super();
48
48
  /**
@@ -241,3 +241,4 @@ __decorate([
241
241
  Chip = __decorate([
242
242
  customElement('mdui-chip')
243
243
  ], Chip);
244
+ export { Chip };
@@ -12,7 +12,7 @@ import { style } from './style.js';
12
12
  * <mdui-circular-progress></mdui-circular-progress>
13
13
  * ```
14
14
  */
15
- export let CircularProgress = class CircularProgress extends LitElement {
15
+ let CircularProgress = class CircularProgress extends LitElement {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  /**
@@ -28,14 +28,13 @@ export let CircularProgress = class CircularProgress extends LitElement {
28
28
  })}">${isDeterminate ? this.renderDeterminate() : this.renderInDeterminate()}</div>`;
29
29
  }
30
30
  renderDeterminate() {
31
- var _a;
32
31
  const value = this.value;
33
32
  const strokeWidth = 4; // 圆环宽度
34
33
  const circleRadius = 18; // 圆环宽度中心点的半径
35
34
  const π = 3.1415926;
36
35
  const center = circleRadius + strokeWidth / 2;
37
36
  const circumference = 2 * π * circleRadius;
38
- const determinateStrokeDashOffset = (1 - value / Math.max((_a = this.max) !== null && _a !== void 0 ? _a : value, value)) * circumference;
37
+ const determinateStrokeDashOffset = (1 - value / Math.max(this.max ?? value, value)) * circumference;
39
38
  return html `<svg viewBox="0 0 ${center * 2} ${center * 2}"><circle class="track" cx="${center}" cy="${center}" r="${circleRadius}" stroke-width="${strokeWidth}"></circle><circle class="circle" cx="${center}" cy="${center}" r="${circleRadius}" stroke-dasharray="${2 * π * circleRadius}" stroke-dashoffset="${determinateStrokeDashOffset}" stroke-width="${strokeWidth}"></circle></svg>`;
40
39
  }
41
40
  renderInDeterminate() {
@@ -59,3 +58,4 @@ __decorate([
59
58
  CircularProgress = __decorate([
60
59
  customElement('mdui-circular-progress')
61
60
  ], CircularProgress);
61
+ export { CircularProgress };
@@ -1,2 +1,2 @@
1
1
  import { css } from 'lit';
2
- export const collapseItemStyle = css `:host{display:flex;flex-direction:column}.header{display:block}.body{display:block;overflow:hidden;transition:height var(--mdui-motion-duration-short4) var(--mdui-motion-easing-emphasized)}.body.opened{overflow:visible}:host([active]) .body{transition-duration:var(--mdui-motion-duration-medium4)}`;
2
+ export const collapseItemStyle = css `:host{display:flex;flex-direction:column}.header{display:block}.body{display:block;overflow:hidden;transition:height var(--mdui-motion-duration-short4) var(--mdui-motion-easing-emphasized)}.body.opened{overflow:visible}.body.active{transition-duration:var(--mdui-motion-duration-medium4)}`;
@@ -1,6 +1,5 @@
1
1
  import { LitElement } from 'lit';
2
2
  import '@mdui/jq/methods/height.js';
3
- import '@mdui/jq/methods/on.js';
4
3
  import type { JQ } from '@mdui/jq/shared/core.js';
5
4
  import type { CSSResultGroup, TemplateResult, PropertyValues } from 'lit';
6
5
  /**
@@ -47,10 +46,12 @@ export declare class CollapseItem extends LitElement {
47
46
  */
48
47
  protected active: boolean;
49
48
  private state;
49
+ protected isInitial: boolean;
50
50
  protected readonly key: number;
51
51
  private readonly bodyRef;
52
52
  private onActiveChange;
53
53
  protected firstUpdated(changedProperties: PropertyValues): void;
54
54
  protected render(): TemplateResult;
55
+ private onTransitionEnd;
55
56
  private updateBodyHeight;
56
57
  }
@@ -5,7 +5,6 @@ import { classMap } from 'lit/directives/class-map.js';
5
5
  import { createRef, ref } from 'lit/directives/ref.js';
6
6
  import { $ } from '@mdui/jq/$.js';
7
7
  import '@mdui/jq/methods/height.js';
8
- import '@mdui/jq/methods/on.js';
9
8
  import { watch } from '@mdui/shared/decorators/watch.js';
10
9
  import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
11
10
  import { emit } from '@mdui/shared/helpers/event.js';
@@ -33,7 +32,7 @@ import { collapseItemStyle } from './collapse-item-style.js';
33
32
  * @csspart header - 折叠面板的头部内容
34
33
  * @csspart body - 折叠面板的正文内容
35
34
  */
36
- export let CollapseItem = class CollapseItem extends LitElement {
35
+ let CollapseItem = class CollapseItem extends LitElement {
37
36
  constructor() {
38
37
  super(...arguments);
39
38
  /**
@@ -45,34 +44,41 @@ export let CollapseItem = class CollapseItem extends LitElement {
45
44
  */
46
45
  this.active = false;
47
46
  this.state = 'closed';
47
+ // 是否是初始状态,不显示动画
48
+ this.isInitial = true;
48
49
  // 每一个 `collapse-item` 元素都添加一个唯一的 key
49
50
  this.key = uniqueId();
50
51
  this.bodyRef = createRef();
51
52
  }
52
53
  onActiveChange() {
53
- if (this.hasUpdated) {
54
+ if (this.isInitial) {
55
+ this.state = this.active ? 'opened' : 'closed';
56
+ if (this.hasUpdated) {
57
+ this.updateBodyHeight();
58
+ }
59
+ }
60
+ else {
54
61
  this.state = this.active ? 'open' : 'close';
55
62
  emit(this, this.state);
56
63
  this.updateBodyHeight();
57
64
  }
58
- else {
59
- this.state = this.active ? 'opened' : 'closed';
60
- }
61
65
  }
62
66
  firstUpdated(changedProperties) {
63
67
  super.firstUpdated(changedProperties);
64
- $(this.bodyRef.value).on('transitionend', (e) => {
65
- const event = e;
66
- if (event.target === this.bodyRef.value) {
67
- this.state = this.active ? 'opened' : 'closed';
68
- emit(this, this.state);
69
- this.updateBodyHeight();
70
- }
71
- });
72
68
  this.updateBodyHeight();
73
69
  }
74
70
  render() {
75
- return html `<slot name="header" part="header" class="header">${this.header}</slot><slot part="body" class="body ${classMap({ opened: this.state === 'opened' })}" ${ref(this.bodyRef)}></slot>`;
71
+ return html `<slot name="header" part="header" class="header">${this.header}</slot><slot part="body" class="body ${classMap({
72
+ opened: this.state === 'opened',
73
+ active: this.active,
74
+ })}" ${ref(this.bodyRef)} @transitionend="${this.onTransitionEnd}"></slot>`;
75
+ }
76
+ onTransitionEnd(event) {
77
+ if (event.target === this.bodyRef.value) {
78
+ this.state = this.active ? 'opened' : 'closed';
79
+ emit(this, this.state);
80
+ this.updateBodyHeight();
81
+ }
76
82
  }
77
83
  updateBodyHeight() {
78
84
  const scrollHeight = this.bodyRef.value.scrollHeight;
@@ -109,11 +115,7 @@ __decorate([
109
115
  property()
110
116
  ], CollapseItem.prototype, "trigger", void 0);
111
117
  __decorate([
112
- property({
113
- type: Boolean,
114
- reflect: true,
115
- converter: booleanConverter,
116
- })
118
+ state()
117
119
  ], CollapseItem.prototype, "active", void 0);
118
120
  __decorate([
119
121
  state()
@@ -124,3 +126,4 @@ __decorate([
124
126
  CollapseItem = __decorate([
125
127
  customElement('mdui-collapse-item')
126
128
  ], CollapseItem);
129
+ export { CollapseItem };
@@ -1,6 +1,4 @@
1
1
  import { LitElement } from 'lit';
2
- import '@mdui/jq/methods/find.js';
3
- import '@mdui/jq/methods/get.js';
4
2
  import '@mdui/jq/methods/is.js';
5
3
  import type { CSSResultGroup, TemplateResult } from 'lit';
6
4
  /**
@@ -37,13 +35,15 @@ export declare class Collapse extends LitElement {
37
35
  */
38
36
  disabled: boolean;
39
37
  private activeKeys;
40
- private items;
38
+ private readonly items;
39
+ private isInitial;
40
+ private definedController;
41
41
  private onActiveKeysChange;
42
42
  private onValueChange;
43
- connectedCallback(): void;
44
43
  protected render(): TemplateResult;
45
- private syncItems;
44
+ private setActiveKeys;
45
+ private setValue;
46
46
  private onClick;
47
47
  private onSlotChange;
48
- private updateActive;
48
+ private updateItems;
49
49
  }