mdui 2.0.0 → 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 (96) hide show
  1. package/components/avatar/index.js +2 -1
  2. package/components/badge/index.js +2 -1
  3. package/components/bottom-app-bar/index.d.ts +2 -2
  4. package/components/bottom-app-bar/index.js +4 -3
  5. package/components/button/button-base.d.ts +2 -2
  6. package/components/button/button-base.js +15 -14
  7. package/components/button/index.js +2 -1
  8. package/components/button-icon/index.js +2 -1
  9. package/components/card/index.d.ts +1 -1
  10. package/components/card/index.js +5 -2
  11. package/components/checkbox/index.js +7 -10
  12. package/components/checkbox/style.js +1 -1
  13. package/components/chip/index.js +2 -1
  14. package/components/circular-progress/index.js +3 -3
  15. package/components/collapse/collapse-item-style.js +1 -1
  16. package/components/collapse/collapse-item.d.ts +2 -1
  17. package/components/collapse/collapse-item.js +23 -20
  18. package/components/collapse/collapse.d.ts +6 -6
  19. package/components/collapse/collapse.js +57 -34
  20. package/components/dialog/index.d.ts +3 -2
  21. package/components/dialog/index.js +27 -23
  22. package/components/divider/index.js +2 -1
  23. package/components/dropdown/index.d.ts +4 -5
  24. package/components/dropdown/index.js +56 -51
  25. package/components/fab/index.d.ts +1 -0
  26. package/components/fab/index.js +10 -5
  27. package/components/icon/index.js +2 -1
  28. package/components/layout/helper.d.ts +5 -6
  29. package/components/layout/helper.js +42 -48
  30. package/components/layout/layout-item-base.js +1 -2
  31. package/components/layout/layout-item.js +3 -3
  32. package/components/layout/layout-main.js +2 -1
  33. package/components/layout/layout.js +2 -1
  34. package/components/linear-progress/index.js +3 -3
  35. package/components/list/list-item.js +3 -2
  36. package/components/list/list-subheader.js +2 -1
  37. package/components/list/list.js +2 -1
  38. package/components/menu/menu-item.d.ts +1 -0
  39. package/components/menu/menu-item.js +45 -28
  40. package/components/menu/menu.d.ts +4 -1
  41. package/components/menu/menu.js +82 -56
  42. package/components/navigation-bar/navigation-bar-item-style.js +1 -1
  43. package/components/navigation-bar/navigation-bar-item.d.ts +6 -2
  44. package/components/navigation-bar/navigation-bar-item.js +26 -10
  45. package/components/navigation-bar/navigation-bar.d.ts +6 -6
  46. package/components/navigation-bar/navigation-bar.js +49 -42
  47. package/components/navigation-drawer/index.d.ts +5 -1
  48. package/components/navigation-drawer/index.js +62 -41
  49. package/components/navigation-rail/navigation-rail-item-style.js +1 -1
  50. package/components/navigation-rail/navigation-rail-item.d.ts +6 -2
  51. package/components/navigation-rail/navigation-rail-item.js +20 -8
  52. package/components/navigation-rail/navigation-rail.d.ts +4 -5
  53. package/components/navigation-rail/navigation-rail.js +51 -44
  54. package/components/radio/radio-group.d.ts +6 -4
  55. package/components/radio/radio-group.js +61 -48
  56. package/components/radio/radio-style.js +1 -1
  57. package/components/radio/radio.d.ts +3 -2
  58. package/components/radio/radio.js +24 -17
  59. package/components/range-slider/index.js +7 -9
  60. package/components/ripple/index.js +2 -1
  61. package/components/segmented-button/segmented-button-group.d.ts +6 -3
  62. package/components/segmented-button/segmented-button-group.js +84 -69
  63. package/components/segmented-button/segmented-button.d.ts +2 -2
  64. package/components/segmented-button/segmented-button.js +5 -4
  65. package/components/select/index.d.ts +2 -2
  66. package/components/select/index.js +26 -24
  67. package/components/slider/index.js +7 -9
  68. package/components/slider/slider-base-style.js +1 -1
  69. package/components/slider/slider-base.js +1 -5
  70. package/components/snackbar/index.js +2 -1
  71. package/components/switch/index.js +6 -9
  72. package/components/switch/style.js +1 -1
  73. package/components/tabs/tab-panel.js +2 -1
  74. package/components/tabs/tab-style.js +1 -1
  75. package/components/tabs/tab.js +10 -5
  76. package/components/tabs/tabs-style.js +1 -1
  77. package/components/tabs/tabs.d.ts +6 -5
  78. package/components/tabs/tabs.js +52 -38
  79. package/components/text-field/index.d.ts +2 -2
  80. package/components/text-field/index.js +32 -54
  81. package/components/text-field/style.js +1 -1
  82. package/components/tooltip/index.d.ts +5 -5
  83. package/components/tooltip/index.js +30 -25
  84. package/components/top-app-bar/top-app-bar-title-style.js +1 -1
  85. package/components/top-app-bar/top-app-bar-title.js +16 -12
  86. package/components/top-app-bar/top-app-bar.d.ts +2 -2
  87. package/components/top-app-bar/top-app-bar.js +6 -4
  88. package/custom-elements.json +3776 -3481
  89. package/functions/getTheme.js +3 -3
  90. package/functions/snackbar.js +1 -2
  91. package/functions/utils/colorScheme.js +2 -2
  92. package/html-data.zh-cn.json +727 -727
  93. package/mdui.esm.js +8 -8
  94. package/mdui.global.js +8 -8
  95. package/package.json +7 -7
  96. package/web-types.zh-cn.json +1265 -1265
@@ -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
  }
@@ -1,12 +1,12 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { html, LitElement } from 'lit';
3
- import { customElement, property, state } from 'lit/decorators.js';
3
+ import { customElement, property, queryAssignedElements, state, } from 'lit/decorators.js';
4
4
  import { $ } from '@mdui/jq/$.js';
5
- import '@mdui/jq/methods/find.js';
6
- import '@mdui/jq/methods/get.js';
7
5
  import '@mdui/jq/methods/is.js';
8
- import { isElement } from '@mdui/jq/shared/helper.js';
6
+ import { isElement, isUndefined } from '@mdui/jq/shared/helper.js';
7
+ import { DefinedController } from '@mdui/shared/controllers/defined.js';
9
8
  import { watch } from '@mdui/shared/decorators/watch.js';
9
+ import { arraysEqualIgnoreOrder } from '@mdui/shared/helpers/array.js';
10
10
  import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
11
11
  import { emit } from '@mdui/shared/helpers/event.js';
12
12
  import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
@@ -25,7 +25,7 @@ import { collapseStyle } from './collapse-style.js';
25
25
  *
26
26
  * @slot - `<mdui-collapse-item>` 组件
27
27
  */
28
- export let Collapse = class Collapse extends LitElement {
28
+ let Collapse = class Collapse extends LitElement {
29
29
  constructor() {
30
30
  super(...arguments);
31
31
  /**
@@ -38,53 +38,67 @@ export let Collapse = class Collapse extends LitElement {
38
38
  this.disabled = false;
39
39
  // 因为 collapse-item 的 value 可能会重复,所以在每个 collapse-item 元素上都添加了一个唯一的 key,通过 activeKey 来记录激活状态的 key
40
40
  this.activeKeys = [];
41
- this.items = [];
41
+ // 是否是初始状态,初始状态不触发 change 事件,没有动画
42
+ this.isInitial = true;
43
+ this.definedController = new DefinedController(this, {
44
+ relatedElements: ['mdui-collapse-item'],
45
+ });
42
46
  }
43
- onActiveKeysChange() {
44
- var _a;
47
+ async onActiveKeysChange() {
48
+ await this.definedController.whenDefined();
45
49
  // 根据 activeKeys 读取对应 collapse-item 的值
46
- this.value = this.accordion
47
- ? (_a = this.items.find((item) => this.activeKeys.includes(item.key))) === null || _a === void 0 ? void 0 : _a.value
50
+ const value = this.accordion
51
+ ? this.items.find((item) => this.activeKeys.includes(item.key))?.value
48
52
  : this.items
49
53
  .filter((item) => this.activeKeys.includes(item.key))
50
54
  .map((item) => item.value);
51
- emit(this, 'change');
55
+ this.setValue(value);
56
+ if (!this.isInitial) {
57
+ emit(this, 'change');
58
+ }
52
59
  }
53
- onValueChange() {
60
+ async onValueChange() {
61
+ this.isInitial = !this.hasUpdated;
62
+ await this.definedController.whenDefined();
54
63
  if (this.accordion) {
55
64
  const value = this.value;
56
65
  if (!value) {
57
- this.activeKeys = [];
66
+ this.setActiveKeys([]);
58
67
  }
59
68
  else {
60
69
  const item = this.items.find((item) => item.value === value);
61
- this.activeKeys = item ? [item.key] : [];
70
+ this.setActiveKeys(item ? [item.key] : []);
62
71
  }
63
72
  }
64
73
  else {
65
74
  const value = this.value;
66
75
  if (!value.length) {
67
- this.activeKeys = [];
76
+ this.setActiveKeys([]);
68
77
  }
69
78
  else {
70
- this.activeKeys = this.items
79
+ const activeKeys = this.items
71
80
  .filter((item) => value.includes(item.value))
72
81
  .map((item) => item.key);
82
+ this.setActiveKeys(activeKeys);
73
83
  }
74
84
  }
75
- this.updateActive();
76
- }
77
- connectedCallback() {
78
- super.connectedCallback();
79
- this.syncItems();
85
+ this.updateItems();
80
86
  }
81
87
  render() {
82
88
  return html `<slot @slotchange="${this.onSlotChange}" @click="${this.onClick}"></slot>`;
83
89
  }
84
- syncItems() {
85
- this.items = $(this)
86
- .find('mdui-collapse-item')
87
- .get();
90
+ setActiveKeys(activeKeys) {
91
+ if (!arraysEqualIgnoreOrder(this.activeKeys, activeKeys)) {
92
+ this.activeKeys = activeKeys;
93
+ }
94
+ }
95
+ setValue(value) {
96
+ if (this.accordion || isUndefined(this.value) || isUndefined(value)) {
97
+ this.value = value;
98
+ }
99
+ else if (!arraysEqualIgnoreOrder(this.value, value)) {
100
+ this.value = value;
101
+ }
88
102
  }
89
103
  onClick(event) {
90
104
  // 全部禁用
@@ -113,10 +127,10 @@ export let Collapse = class Collapse extends LitElement {
113
127
  }
114
128
  if (this.accordion) {
115
129
  if (this.activeKeys.includes(item.key)) {
116
- this.activeKeys = [];
130
+ this.setActiveKeys([]);
117
131
  }
118
132
  else {
119
- this.activeKeys = [item.key];
133
+ this.setActiveKeys([item.key]);
120
134
  }
121
135
  }
122
136
  else {
@@ -128,16 +142,21 @@ export let Collapse = class Collapse extends LitElement {
128
142
  else {
129
143
  activeKeys.push(item.key);
130
144
  }
131
- this.activeKeys = activeKeys;
145
+ this.setActiveKeys(activeKeys);
132
146
  }
133
- this.updateActive();
147
+ this.isInitial = false;
148
+ this.updateItems();
134
149
  }
135
- onSlotChange() {
136
- this.syncItems();
137
- this.updateActive();
150
+ async onSlotChange() {
151
+ await this.definedController.whenDefined();
152
+ this.updateItems();
138
153
  }
139
- updateActive() {
140
- this.items.forEach((item) => (item.active = this.activeKeys.includes(item.key)));
154
+ // 更新 <mdui-collapse-item> 的状态
155
+ updateItems() {
156
+ this.items.forEach((item) => {
157
+ item.active = this.activeKeys.includes(item.key);
158
+ item.isInitial = this.isInitial;
159
+ });
141
160
  }
142
161
  };
143
162
  Collapse.styles = [
@@ -164,6 +183,9 @@ __decorate([
164
183
  __decorate([
165
184
  state()
166
185
  ], Collapse.prototype, "activeKeys", void 0);
186
+ __decorate([
187
+ queryAssignedElements({ selector: 'mdui-collapse-item', flatten: true })
188
+ ], Collapse.prototype, "items", void 0);
167
189
  __decorate([
168
190
  watch('activeKeys', true)
169
191
  ], Collapse.prototype, "onActiveKeysChange", null);
@@ -173,3 +195,4 @@ __decorate([
173
195
  Collapse = __decorate([
174
196
  customElement('mdui-collapse')
175
197
  ], Collapse);
198
+ export { Collapse };