@vollowx/seele 0.14.3 → 0.14.4

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 (82) hide show
  1. package/README.md +6 -5
  2. package/package.json +5 -5
  3. package/src/all.d.ts +2 -0
  4. package/src/all.js +2 -0
  5. package/src/base/anchor.d.ts +21 -0
  6. package/src/base/anchor.js +60 -0
  7. package/src/base/autocomplete.d.ts +2 -2
  8. package/src/base/composed-menu.d.ts +2 -2
  9. package/src/base/composed-menu.js +6 -3
  10. package/src/base/controllers/list-controller.d.ts +1 -1
  11. package/src/base/controllers/list-controller.js +1 -1
  12. package/src/base/dialog.d.ts +1 -1
  13. package/src/base/dialog.js +2 -0
  14. package/src/base/input.d.ts +1 -1
  15. package/src/base/list.d.ts +1 -1
  16. package/src/base/menu.d.ts +1 -1
  17. package/src/base/menu.js +2 -1
  18. package/src/base/mixins/internals-attached.d.ts +1 -1
  19. package/src/base/mixins/internals-attached.js +4 -1
  20. package/src/base/popup.d.ts +1 -1
  21. package/src/base/select.d.ts +5 -6
  22. package/src/base/slider.d.ts +1 -1
  23. package/src/base/tab-panel.d.ts +1 -1
  24. package/src/base/tab.d.ts +1 -1
  25. package/src/base/tabs.d.ts +1 -1
  26. package/src/base/tooltip.d.ts +1 -1
  27. package/src/base/tooltip.js +3 -5
  28. package/src/core/ensure-ready.js +1 -1
  29. package/src/m3/autocomplete/autocomplete.d.ts +1 -1
  30. package/src/m3/badge/badge.d.ts +2 -2
  31. package/src/m3/button/common-button-link.d.ts +30 -0
  32. package/src/m3/button/common-button-link.js +62 -0
  33. package/src/m3/button/common-button-toggle.d.ts +1 -1
  34. package/src/m3/button/common-button.d.ts +2 -2
  35. package/src/m3/button/common-button.js +1 -0
  36. package/src/m3/button/icon-button-link.d.ts +24 -0
  37. package/src/m3/button/icon-button-link.js +53 -0
  38. package/src/m3/button/icon-button-toggle.d.ts +1 -1
  39. package/src/m3/button/icon-button.d.ts +1 -1
  40. package/src/m3/button/shared-button-link-styles.css.js +2 -0
  41. package/src/m3/button-group/connected-button-group.d.ts +1 -1
  42. package/src/m3/button-group/standard-button-group.d.ts +7 -2
  43. package/src/m3/button-group/standard-button-group.js +3 -1
  44. package/src/m3/checkbox/checkbox-styles.css.js +1 -1
  45. package/src/m3/checkbox/checkbox.d.ts +3 -3
  46. package/src/m3/dialog/dialog.d.ts +20 -18
  47. package/src/m3/dialog/dialog.js +135 -85
  48. package/src/m3/fab/fab.d.ts +1 -1
  49. package/src/m3/field/field.d.ts +7 -12
  50. package/src/m3/field/field.js +5 -10
  51. package/src/m3/field/filled-field.d.ts +1 -1
  52. package/src/m3/field/outlined-field.d.ts +2 -2
  53. package/src/m3/focus-ring/focus-ring.js +3 -2
  54. package/src/m3/item/item.d.ts +3 -3
  55. package/src/m3/item/item.js +2 -3
  56. package/src/m3/list/list-item.d.ts +3 -3
  57. package/src/m3/list/list-item.js +2 -2
  58. package/src/m3/loading/loading.d.ts +2 -2
  59. package/src/m3/loading/loading.js +1 -1
  60. package/src/m3/navigation/navigation-rail-item.d.ts +3 -3
  61. package/src/m3/navigation/navigation-rail-item.js +2 -1
  62. package/src/m3/navigation/navigation-rail.d.ts +1 -1
  63. package/src/m3/progress/circular-progress.d.ts +1 -1
  64. package/src/m3/progress/linear-progress.d.ts +1 -1
  65. package/src/m3/radio/radio-styles.css.js +1 -1
  66. package/src/m3/radio/radio.d.ts +2 -2
  67. package/src/m3/ripple/ripple.js +3 -0
  68. package/src/m3/select/filled-select.d.ts +1 -1
  69. package/src/m3/select/outlined-select.d.ts +1 -1
  70. package/src/m3/select/select.d.ts +1 -1
  71. package/src/m3/slider/slider.d.ts +1 -1
  72. package/src/m3/switch/switch.d.ts +5 -5
  73. package/src/m3/tab/tab.d.ts +3 -4
  74. package/src/m3/tab/tab.js +2 -4
  75. package/src/m3/text-field/filled-text-field.d.ts +1 -1
  76. package/src/m3/text-field/outlined-text-field.d.ts +1 -1
  77. package/src/m3/toolbar/toolbar.d.ts +1 -1
  78. package/src/win98/button/button.d.ts +1 -1
  79. package/src/base/field.d.ts +0 -3
  80. package/src/base/field.js +0 -3
  81. package/src/base/item.d.ts +0 -7
  82. package/src/base/item.js +0 -7
@@ -0,0 +1,53 @@
1
+ import { __decorate } from "tslib";
2
+ import { html } from 'lit';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ import { Anchor } from '../../base/anchor.js';
5
+ import '../focus-ring/focus-ring.js';
6
+ import '../ripple/ripple.js';
7
+ import { targetStyles } from '../target-styles.css.js';
8
+ import { iconButtonStyles } from './icon-button-styles.css.js';
9
+ import { sharedButtonLinkStyles } from './shared-button-link-styles.css.js';
10
+ import { sharedButtonStyles } from './shared-button-styles.css.js';
11
+ /**
12
+ * @tag md-icon-button-link
13
+ *
14
+ * @csspart anchor
15
+ * @csspart icon
16
+ *
17
+ * @slot - icon
18
+ */
19
+ let M3IconButtonLink = class M3IconButtonLink extends Anchor {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.size = 's';
23
+ this.color = 'primary';
24
+ this.variant = 'text';
25
+ this.width = 'standard';
26
+ }
27
+ static { this.styles = [
28
+ ...super.styles,
29
+ targetStyles,
30
+ sharedButtonStyles,
31
+ sharedButtonLinkStyles,
32
+ iconButtonStyles,
33
+ ]; }
34
+ render() {
35
+ return this._renderAnchor(html `<md-focus-ring></md-focus-ring><md-ripple></md-ripple><span part="target"></span><slot part="icon"></slot>`);
36
+ }
37
+ };
38
+ __decorate([
39
+ property({ reflect: true })
40
+ ], M3IconButtonLink.prototype, "size", void 0);
41
+ __decorate([
42
+ property({ reflect: true })
43
+ ], M3IconButtonLink.prototype, "color", void 0);
44
+ __decorate([
45
+ property({ reflect: true })
46
+ ], M3IconButtonLink.prototype, "variant", void 0);
47
+ __decorate([
48
+ property({ reflect: true })
49
+ ], M3IconButtonLink.prototype, "width", void 0);
50
+ M3IconButtonLink = __decorate([
51
+ customElement('md-icon-button-link')
52
+ ], M3IconButtonLink);
53
+ export { M3IconButtonLink };
@@ -12,7 +12,7 @@ declare const M3IconButtonToggle_base: Constructor<import("../../base/mixins/but
12
12
  */
13
13
  export declare class M3IconButtonToggle extends M3IconButtonToggle_base {
14
14
  static styles: any[];
15
- render(): import("lit-html").TemplateResult<1>;
15
+ render(): import("lit").TemplateResult<1>;
16
16
  }
17
17
  declare global {
18
18
  interface HTMLElementTagNameMap {
@@ -14,7 +14,7 @@ export declare class M3IconButton extends Button {
14
14
  variant: 'text' | 'filled' | 'tonal' | 'outlined';
15
15
  width: 'standard' | 'narrow' | 'wide';
16
16
  static styles: any[];
17
- render(): import("lit-html").TemplateResult<1>;
17
+ render(): import("lit").TemplateResult<1>;
18
18
  }
19
19
  declare global {
20
20
  interface HTMLElementTagNameMap {
@@ -0,0 +1,2 @@
1
+ import { css } from 'lit';
2
+ export const sharedButtonLinkStyles = css`@layer main{a{all:inherit;justify-content:center;display:inline-flex}}@layer override{:host{display:contents}}`;
@@ -10,7 +10,7 @@ export declare class M3ConnectedButtonGroup extends LitElement {
10
10
  multiple: boolean;
11
11
  $buttons: Array<ToggleButton>;
12
12
  static styles: any[];
13
- render(): import("lit-html").TemplateResult<1>;
13
+ render(): import("lit").TemplateResult<1>;
14
14
  }
15
15
  declare global {
16
16
  interface HTMLElementTagNameMap {
@@ -1,4 +1,8 @@
1
1
  import { LitElement } from 'lit';
2
+ declare const shapeAnimation: unique symbol;
3
+ type ShapeAnimatedElement = HTMLElement & {
4
+ [shapeAnimation]?: Animation;
5
+ };
2
6
  /**
3
7
  * @tag md-button-group
4
8
  *
@@ -7,9 +11,9 @@ import { LitElement } from 'lit';
7
11
  export declare class M3StandardButtonGroup extends LitElement {
8
12
  #private;
9
13
  size: 'xs' | 's' | '';
10
- $buttons: Array<HTMLElement>;
14
+ $buttons: Array<ShapeAnimatedElement>;
11
15
  static styles: any[];
12
- render(): import("lit-html").TemplateResult<1>;
16
+ render(): import("lit").TemplateResult<1>;
13
17
  constructor();
14
18
  connectedCallback(): void;
15
19
  firstUpdated(): Promise<void>;
@@ -24,3 +28,4 @@ declare global {
24
28
  'md-button-group': M3StandardButtonGroup;
25
29
  }
26
30
  }
31
+ export {};
@@ -97,7 +97,9 @@ let M3StandardButtonGroup = class M3StandardButtonGroup extends LitElement {
97
97
  * Passing no element resets all shape changes
98
98
  */
99
99
  updateLayout(target = null) {
100
- const pressedIndex = target ? this.$buttons.indexOf(target) : -1;
100
+ const pressedIndex = target
101
+ ? this.$buttons.indexOf(target)
102
+ : -1;
101
103
  this.#activeIndex = pressedIndex;
102
104
  const pressedBaseWidth = pressedIndex !== -1 ? this.#baseWidths[pressedIndex] : 0;
103
105
  const isPressedAtEdge = pressedIndex === 0 || pressedIndex === this.$buttons.length - 1;
@@ -1,2 +1,2 @@
1
1
  import { css } from 'lit';
2
- export const checkboxStyles = css`:host{--md-focus-ring-radius:9999px;--_container-color:transparent;--_outline-color:var(--md-sys-color-on-surface-variant);--_mark-color:var(--md-sys-color-surface-container-highest);--_ripple-color:var(--md-sys-color-on-surface);--_checkbox-size:18px;background-color:color-mix(in srgb, var(--_container-color) var(--_container-opacity,100%), transparent);border-color:color-mix(in srgb, var(--_outline-color) var(--_outline-opacity,100%), transparent);border-style:solid;border-width:var(--md-checkbox-outline-width,2px);box-sizing:border-box;cursor:pointer;height:var(--_checkbox-size);-webkit-tap-highlight-color:transparent;transition:background-color var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast), border-color var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast);-webkit-user-select:none;user-select:none;vertical-align:top;width:var(--_checkbox-size);border-radius:2px;outline:0;place-content:center;place-items:center;margin:15px;display:inline-grid;position:relative}:host(:state(checked)),:host(:state(indeterminate)){--_container-color:var(--md-sys-color-primary);--_outline-color:var(--md-sys-color-primary);--_mark-color:var(--md-sys-color-on-primary);--_mark-opacity:100%;--_ripple-color:var(--md-sys-color-primary)}:host([error]){--_outline-color:var(--md-sys-color-error);--_mark-color:var(--md-sys-color-surface-container-highest);--_ripple-color:var(--md-sys-color-error)}:host([error]:state(checked)),:host([error]:state(indeterminate)){--_container-color:var(--md-sys-color-error);--_outline-color:var(--md-sys-color-error);--_mark-color:var(--md-sys-color-on-error);--_ripple-color:var(--md-sys-color-error)}:host(:disabled){--_outline-color:var(--md-sys-color-on-surface);--_outline-opacity:38%;--_mark-color:var(--md-sys-color-surface-container-highest);cursor:default;pointer-events:none}:host(:disabled:state(checked)),:host(:disabled:state(indeterminate)){--_container-color:var(--md-sys-color-on-surface);--_container-opacity:38%;--_outline-color:var(--md-sys-color-surface);--_outline-opacity:0%;--_mark-color:var(--md-sys-color-surface)}@media (hover:hover) and (pointer:fine){:host(:hover){--_unchecked-outline-color:var(--md-sys-color-on-surface)}}@media (forced-colors:active){:host{forced-color-adjust:none}}:host(:disabled){--_unchecked-container-opacity:38%}[part~=icon]{fill:color-mix(in srgb, var(--_mark-color) var(--_mark-opacity,0%), transparent);height:18px;transition:fill var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast);width:18px;position:absolute;inset:-2px}[part~=mark]{transition-duration:var(--md-sys-motion-effects-default-duration);transition-timing-function:var(--md-sys-motion-effects-default);transform:scaleY(-1)translate(7px,-14px)rotate(45deg)}:host(:state(indeterminate)) [part~=mark]{transform:scaleY(-1)translate(4px,-10px)rotate(0)}:host(:state(checked)) [part~=mark],:host(:state(indeterminate)) [part~=mark]{transition-duration:var(--md-sys-motion-effects-default-duration);transition-timing-function:var(--md-sys-motion-effects-default)}[part~=mark-short]{width:2px;height:0;transition-property:transform,height}[part~=mark-long]{width:0;height:2px;transition-property:transform,width}:host(:not(:state(checked)):not(:state(indeterminate)):state(was-checked)) [part~=mark],:host(:not(:state(checked)):not(:state(indeterminate)):state(was-indeterminate)) [part~=mark]{transition-delay:var(--md-sys-motion-effects-fast-duration)}:host(:state(checked)) [part~=mark-short]{height:5.65685px}:host(:state(checked)) [part~=mark-long]{width:11.3137px}:host(:state(checked):state(was-unchecked)) [part~=mark-short]{transition-property:none}:host(:state(indeterminate)) [part~=mark-short]{height:2px}:host(:state(indeterminate)) [part~=mark-long]{width:10px}:host(:state(indeterminate):state(was-unchecked)) [part~=mark-short]{transition-property:height}:host(:state(indeterminate):state(was-unchecked)) [part~=mark-long]{transition-property:width}md-focus-ring{height:44px;inset:unset;width:44px}md-ripple{--md-ripple-color:var(--_ripple-color);height:40px;inset:unset;border-radius:9999px;width:40px}@media (forced-colors:active){:host{--_outline-color:CanvasText;--_ripple-color:CanvasText}:host(:is(:state(checked),:state(indeterminate))){--md-sys-color-primary:SelectedItem;--_mark-color:SelectedItemText}}`;
2
+ export const checkboxStyles = css`:host{--md-focus-ring-radius:9999px;--_container-color:transparent;--_outline-color:var(--md-sys-color-on-surface-variant);--_mark-color:var(--md-sys-color-surface-container-highest);--_ripple-color:var(--md-sys-color-on-surface);--_checkbox-size:18px;background-color:color-mix(in srgb, var(--_container-color) var(--_container-opacity,100%), transparent);border-color:color-mix(in srgb, var(--_outline-color) var(--_outline-opacity,100%), transparent);border-style:solid;border-width:var(--md-checkbox-outline-width,2px);box-sizing:border-box;cursor:pointer;height:var(--_checkbox-size);margin:calc((40px - var(--_checkbox-size)) / 2);-webkit-tap-highlight-color:transparent;transition:background-color var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast), border-color var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast);-webkit-user-select:none;user-select:none;vertical-align:top;width:var(--_checkbox-size);border-radius:2px;outline:0;place-content:center;place-items:center;display:inline-grid;position:relative}:host(:state(checked)),:host(:state(indeterminate)){--_container-color:var(--md-sys-color-primary);--_outline-color:var(--md-sys-color-primary);--_mark-color:var(--md-sys-color-on-primary);--_mark-opacity:100%;--_ripple-color:var(--md-sys-color-primary)}:host([error]){--_outline-color:var(--md-sys-color-error);--_mark-color:var(--md-sys-color-surface-container-highest);--_ripple-color:var(--md-sys-color-error)}:host([error]:state(checked)),:host([error]:state(indeterminate)){--_container-color:var(--md-sys-color-error);--_outline-color:var(--md-sys-color-error);--_mark-color:var(--md-sys-color-on-error);--_ripple-color:var(--md-sys-color-error)}:host(:disabled){--_outline-color:var(--md-sys-color-on-surface);--_outline-opacity:38%;--_mark-color:var(--md-sys-color-surface-container-highest);cursor:default;pointer-events:none}:host(:disabled:state(checked)),:host(:disabled:state(indeterminate)){--_container-color:var(--md-sys-color-on-surface);--_container-opacity:38%;--_outline-color:var(--md-sys-color-surface);--_outline-opacity:0%;--_mark-color:var(--md-sys-color-surface)}@media (hover:hover) and (pointer:fine){:host(:hover){--_unchecked-outline-color:var(--md-sys-color-on-surface)}}@media (forced-colors:active){:host{forced-color-adjust:none}}:host(:disabled){--_unchecked-container-opacity:38%}[part~=icon]{fill:color-mix(in srgb, var(--_mark-color) var(--_mark-opacity,0%), transparent);height:18px;transition:fill var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast);width:18px;position:absolute;inset:-2px}[part~=mark]{transition-duration:var(--md-sys-motion-effects-default-duration);transition-timing-function:var(--md-sys-motion-effects-default);transform:scaleY(-1)translate(7px,-14px)rotate(45deg)}:host(:state(indeterminate)) [part~=mark]{transform:scaleY(-1)translate(4px,-10px)rotate(0)}:host(:state(checked)) [part~=mark],:host(:state(indeterminate)) [part~=mark]{transition-duration:var(--md-sys-motion-effects-default-duration);transition-timing-function:var(--md-sys-motion-effects-default)}[part~=mark-short]{width:2px;height:0;transition-property:transform,height}[part~=mark-long]{width:0;height:2px;transition-property:transform,width}:host(:not(:state(checked)):not(:state(indeterminate)):state(was-checked)) [part~=mark],:host(:not(:state(checked)):not(:state(indeterminate)):state(was-indeterminate)) [part~=mark]{transition-delay:var(--md-sys-motion-effects-fast-duration)}:host(:state(checked)) [part~=mark-short]{height:5.65685px}:host(:state(checked)) [part~=mark-long]{width:11.3137px}:host(:state(checked):state(was-unchecked)) [part~=mark-short]{transition-property:none}:host(:state(indeterminate)) [part~=mark-short]{height:2px}:host(:state(indeterminate)) [part~=mark-long]{width:10px}:host(:state(indeterminate):state(was-unchecked)) [part~=mark-short]{transition-property:height}:host(:state(indeterminate):state(was-unchecked)) [part~=mark-long]{transition-property:width}md-focus-ring{height:44px;inset:unset;width:44px}md-ripple{--md-ripple-color:var(--_ripple-color);height:40px;inset:unset;border-radius:9999px;width:40px}@media (forced-colors:active){:host{--_outline-color:CanvasText;--_ripple-color:CanvasText}:host(:is(:state(checked),:state(indeterminate))){--md-sys-color-primary:SelectedItem;--_mark-color:SelectedItemText}}`;
@@ -12,10 +12,10 @@ import type { M3Ripple } from '../ripple/ripple.js';
12
12
  */
13
13
  export declare class M3Checkbox extends Checkbox {
14
14
  error: boolean;
15
- $ripple: M3Ripple;
15
+ $ripple: M3Ripple | null;
16
16
  static styles: any[];
17
- render(): import("lit-html").TemplateResult<1>;
18
- renderIcon(): import("lit-html").TemplateResult<1>;
17
+ render(): import("lit").TemplateResult<1>;
18
+ renderIcon(): import("lit").TemplateResult<1>;
19
19
  firstUpdated(): void;
20
20
  }
21
21
  declare global {
@@ -1,9 +1,18 @@
1
1
  import { Dialog } from '../../base/dialog.js';
2
+ type AnimationPart = 'container' | 'effects' | 'scrim' | 'body' | 'actions';
3
+ type AnimationRecipe = {
4
+ keyframes: Keyframe[];
5
+ options: KeyframeAnimationOptions;
6
+ };
7
+ type DialogAnimations = {
8
+ open: Partial<Record<AnimationPart, AnimationRecipe>>;
9
+ close: Partial<Record<AnimationPart, AnimationRecipe>>;
10
+ };
11
+ export declare const getFadeAnimations: (host: M3Dialog) => DialogAnimations;
12
+ export declare const getDefaultAnimations: (host: M3Dialog) => DialogAnimations;
2
13
  /**
3
14
  * TODO: test if form actions `cancel` and other things related work - no,
4
15
  * event listener needed
5
- * FIXME: on Firefox, the focus is not autoatically set to the first tabbable
6
- * element
7
16
  *
8
17
  * @tag md-dialog
9
18
  *
@@ -19,25 +28,17 @@ import { Dialog } from '../../base/dialog.js';
19
28
  */
20
29
  export declare class M3Dialog extends Dialog {
21
30
  #private;
22
- _config: {
23
- openEase: string;
24
- closeEase: string;
25
- vertSlide: number;
26
- openDur: number;
27
- closeDur: number;
28
- bodyFadeInDur: number;
29
- bodyFadeOutDur: number;
30
- };
31
31
  private hasIcon;
32
- $container: HTMLDivElement;
33
- $body: HTMLDivElement;
34
- $icon: HTMLSlotElement;
35
- $actions: HTMLDivElement;
36
- $actionsPlaceholder: HTMLDivElement;
37
- $scrim: HTMLDivElement;
32
+ $container: HTMLDivElement | null;
33
+ $body: HTMLDivElement | null;
34
+ $icon: HTMLSlotElement | null;
35
+ $actions: HTMLDivElement | null;
36
+ $actionsPlaceholder: HTMLDivElement | null;
37
+ $scrim: HTMLDivElement | null;
38
38
  static styles: any[];
39
- render(): import("lit-html").TemplateResult<1>;
39
+ render(): import("lit").TemplateResult<1>;
40
40
  firstUpdated(): Promise<void>;
41
+ _fullHeight: number;
41
42
  show(): Promise<void>;
42
43
  close(): Promise<void>;
43
44
  }
@@ -46,3 +47,4 @@ declare global {
46
47
  'md-dialog': M3Dialog;
47
48
  }
48
49
  }
50
+ export {};
@@ -3,12 +3,111 @@ import { html } from 'lit';
3
3
  import { query, state, customElement } from 'lit/decorators.js';
4
4
  import { ensureSlottedReady } from '../../core/ensure-ready.js';
5
5
  import { Dialog } from '../../base/dialog.js';
6
+ import { getSpring } from '../styles/motion.js';
6
7
  import { dialogStyles } from './dialog-styles.css.js';
8
+ // Was based on https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration#e5b958f0-435d-4e84-aed4-8d1ea395fa5c
9
+ // TODO: use curves and durations from motion physics
10
+ const options = {
11
+ openEase: 'cubic-bezier(0, 0, 0, 1)',
12
+ closeEase: 'cubic-bezier(0.3, 0, 1, 1)',
13
+ vertSlide: 40,
14
+ openDur: 500,
15
+ closeDur: 200,
16
+ bodyFadeInDur: 200,
17
+ bodyFadeOutDur: 100,
18
+ };
19
+ const opacity = (from, to, options) => ({
20
+ keyframes: [{ opacity: from }, { opacity: to }],
21
+ options,
22
+ });
23
+ export const getFadeAnimations = (host) => {
24
+ const effectsFast = getSpring(host, 'effects', 'fast');
25
+ const fade = (from, to) => opacity(from, to, { ...effectsFast, fill: 'forwards' });
26
+ const container = getComputedStyle(host.$container), scrim = getComputedStyle(host.$scrim);
27
+ return {
28
+ open: {
29
+ container: fade('0', '1'),
30
+ scrim: fade('0', '0.32'),
31
+ },
32
+ close: {
33
+ container: fade(container.opacity, '0'),
34
+ scrim: fade(scrim.opacity, '0'),
35
+ },
36
+ };
37
+ };
38
+ export const getDefaultAnimations = (host) => {
39
+ const container = getComputedStyle(host.$container), scrim = getComputedStyle(host.$scrim), body = getComputedStyle(host.$body), actions = getComputedStyle(host.$actions);
40
+ return {
41
+ open: {
42
+ container: {
43
+ keyframes: [
44
+ {
45
+ height: '0px',
46
+ minHeight: '0px',
47
+ transform: `translateY(-${options.vertSlide}px)`,
48
+ },
49
+ {
50
+ height: `${host._fullHeight}px`,
51
+ minHeight: '0px',
52
+ transform: 'translateY(0px)',
53
+ },
54
+ ],
55
+ options: { duration: options.openDur, easing: options.openEase },
56
+ },
57
+ scrim: opacity('0', '0.32', {
58
+ duration: options.openDur,
59
+ easing: options.openEase,
60
+ fill: 'forwards',
61
+ }),
62
+ body: opacity('0.2', '1', {
63
+ duration: options.bodyFadeInDur,
64
+ fill: 'forwards',
65
+ }),
66
+ actions: opacity('0.5', '1', {
67
+ duration: options.bodyFadeInDur,
68
+ fill: 'forwards',
69
+ }),
70
+ },
71
+ close: {
72
+ container: {
73
+ keyframes: [
74
+ {
75
+ height: container.height,
76
+ minHeight: '0px',
77
+ transform: container.transform,
78
+ },
79
+ {
80
+ height: `${host._fullHeight * 0.35}px`,
81
+ minHeight: '0px',
82
+ transform: `translateY(-${options.vertSlide}px)`,
83
+ },
84
+ ],
85
+ options: { duration: options.closeDur, easing: options.closeEase },
86
+ },
87
+ effects: opacity(container.opacity, '0', {
88
+ duration: options.closeDur - options.bodyFadeOutDur,
89
+ delay: options.bodyFadeOutDur,
90
+ fill: 'forwards',
91
+ }),
92
+ scrim: opacity(scrim.opacity, '0', {
93
+ duration: options.closeDur,
94
+ easing: options.closeEase,
95
+ fill: 'forwards',
96
+ }),
97
+ body: opacity(body.opacity, '0', {
98
+ duration: options.bodyFadeOutDur,
99
+ fill: 'forwards',
100
+ }),
101
+ actions: opacity(actions.opacity, '0', {
102
+ duration: options.bodyFadeOutDur,
103
+ fill: 'forwards',
104
+ }),
105
+ },
106
+ };
107
+ };
7
108
  /**
8
109
  * TODO: test if form actions `cancel` and other things related work - no,
9
110
  * event listener needed
10
- * FIXME: on Firefox, the focus is not autoatically set to the first tabbable
11
- * element
12
111
  *
13
112
  * @tag md-dialog
14
113
  *
@@ -25,19 +124,9 @@ import { dialogStyles } from './dialog-styles.css.js';
25
124
  let M3Dialog = class M3Dialog extends Dialog {
26
125
  constructor() {
27
126
  super(...arguments);
28
- // Was based on https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration#e5b958f0-435d-4e84-aed4-8d1ea395fa5c
29
- // TODO: use curves and durations from motion physics
30
- this._config = {
31
- openEase: 'cubic-bezier(0, 0, 0, 1)',
32
- closeEase: 'cubic-bezier(0.3, 0, 1, 1)',
33
- vertSlide: 40,
34
- openDur: 500,
35
- closeDur: 200,
36
- bodyFadeInDur: 200,
37
- bodyFadeOutDur: 100,
38
- };
39
127
  this.hasIcon = false;
40
128
  this.#activeAnimations = [];
129
+ this._fullHeight = 0;
41
130
  this.#handleClick = (e) => {
42
131
  const target = e.target;
43
132
  if (!this.$container.contains(target) && !this.contains(target))
@@ -63,103 +152,64 @@ let M3Dialog = class M3Dialog extends Dialog {
63
152
  this.#activeAnimations = [];
64
153
  this.#opening = this.#closing = false;
65
154
  }
155
+ #animate(recipes) {
156
+ const targets = {
157
+ container: this.$container,
158
+ effects: this.$container,
159
+ scrim: this.$scrim,
160
+ body: this.$body,
161
+ actions: this.$actions,
162
+ };
163
+ const animations = {};
164
+ for (const [name, recipe] of Object.entries(recipes)) {
165
+ animations[name] = targets[name].animate(recipe.keyframes, recipe.options);
166
+ this.#activeAnimations.push(animations[name]);
167
+ }
168
+ return animations;
169
+ }
170
+ get #fade() {
171
+ return (window.matchMedia('(prefers-reduced-motion: reduce)').matches ||
172
+ getComputedStyle(this)
173
+ .getPropertyValue('--md-dialog-animation')
174
+ .trim() === 'fade');
175
+ }
66
176
  #handleClick;
67
177
  #handleIconSlotChange;
68
178
  #opening;
69
179
  async show() {
70
180
  if (this.#opening)
71
181
  return;
182
+ await this.updateComplete;
72
183
  this.#clearAnimations();
73
184
  this.#opening = true;
74
185
  // Reset margins to allow browser centering
75
186
  this.$dialog.style.marginTop = 'auto';
76
187
  this.$dialog.style.marginBottom = 'auto';
77
- super.show();
188
+ await super.show();
78
189
  const actionsHeight = this.$actions.offsetHeight;
79
190
  this.$actionsPlaceholder.style.height = `${actionsHeight}px`;
80
191
  this.$container.style.height = 'auto';
81
- const startHeight = 0;
82
- const endHeight = this.$container.offsetHeight;
192
+ this._fullHeight = this.$container.offsetHeight;
83
193
  // Lock the position to prevent auto-centering during animation
84
194
  const rect = this.$container.getBoundingClientRect();
85
195
  this.$dialog.style.marginTop = `${rect.top}px`;
86
196
  this.$dialog.style.marginBottom = 'auto';
87
- this.$container.style.minHeight = '0px';
88
- const container = this.$container.animate([
89
- {
90
- height: `${startHeight}px`,
91
- transform: `translateY(-${this._config.vertSlide}px)`,
92
- },
93
- {
94
- height: `${endHeight}px`,
95
- transform: 'translateY(0px)',
96
- },
97
- ], { duration: this._config.openDur, easing: this._config.openEase });
98
- const scrim = this.$scrim.animate([{ opacity: 0 }, { opacity: 0.32 }], {
99
- duration: this._config.openDur,
100
- easing: this._config.openEase,
101
- fill: 'forwards',
102
- });
103
- const body = this.$body.animate([{ opacity: 0.2 }, { opacity: 1 }], {
104
- duration: this._config.bodyFadeInDur,
105
- easing: 'linear',
106
- fill: 'forwards',
107
- });
108
- const actions = this.$actions.animate([{ opacity: 0.5 }, { opacity: 1 }], {
109
- duration: this._config.bodyFadeInDur,
110
- easing: 'linear',
111
- fill: 'forwards',
112
- });
113
- this.#activeAnimations.push(container, scrim, body, actions);
114
- container.onfinish = () => {
115
- this.$container.style.minHeight = '';
116
- this.#clearAnimations();
117
- };
197
+ const getAnimations = this.#fade ? getFadeAnimations : getDefaultAnimations;
198
+ const animations = this.#animate(getAnimations(this).open);
199
+ animations.container.onfinish = () => this.#clearAnimations();
118
200
  }
119
201
  #closing;
120
202
  async close() {
121
203
  if (this.#closing)
122
204
  return;
205
+ await this.updateComplete;
206
+ const getAnimations = this.#fade ? getFadeAnimations : getDefaultAnimations;
207
+ const recipes = getAnimations(this).close;
123
208
  this.#clearAnimations();
124
209
  this.#closing = true;
125
- const startHeight = this.$container.offsetHeight;
126
- const endHeight = startHeight * 0.35;
127
- this.$container.style.minHeight = '0px';
128
- const containerSpatial = this.$container.animate([
129
- { height: `${startHeight}px`, transform: 'translateY(0px)' },
130
- {
131
- height: `${endHeight}px`,
132
- transform: `translateY(-${this._config.vertSlide}px)`,
133
- },
134
- ], {
135
- duration: this._config.closeDur,
136
- easing: this._config.closeEase,
137
- });
138
- const containerEffects = this.$container.animate([{ opacity: 1 }, { opacity: 0 }], {
139
- duration: this._config.closeDur - this._config.bodyFadeOutDur,
140
- delay: this._config.bodyFadeOutDur,
141
- easing: 'linear',
142
- fill: 'forwards',
143
- });
144
- const scrim = this.$scrim.animate([{ opacity: 0.32 }, { opacity: 0 }], {
145
- duration: this._config.closeDur,
146
- easing: this._config.closeEase,
147
- fill: 'forwards',
148
- });
149
- const body = this.$body.animate([{ opacity: 1 }, { opacity: 0 }], {
150
- duration: this._config.bodyFadeOutDur,
151
- easing: 'linear',
152
- fill: 'forwards',
153
- });
154
- const actions = this.$actions.animate([{ opacity: 1 }, { opacity: 0 }], {
155
- duration: this._config.bodyFadeOutDur,
156
- easing: 'linear',
157
- fill: 'forwards',
158
- });
159
- this.#activeAnimations.push(containerSpatial, containerEffects, scrim, body, actions);
160
- containerSpatial.onfinish = () => {
161
- this.$container.style.minHeight = '';
162
- super.close();
210
+ const animations = this.#animate(recipes);
211
+ animations.container.onfinish = async () => {
212
+ await super.close();
163
213
  this.#clearAnimations();
164
214
  };
165
215
  }
@@ -14,7 +14,7 @@ export declare class M3Fab extends Button {
14
14
  size: 's' | 'm' | 'l';
15
15
  color: 'surface' | 'primary-container' | 'secondary-container' | 'tertiary-container' | 'primary' | 'secondary' | 'tertiary';
16
16
  static styles: any[];
17
- render(): import("lit-html").TemplateResult<1>;
17
+ render(): import("lit").TemplateResult<1>;
18
18
  }
19
19
  declare global {
20
20
  interface HTMLElementTagNameMap {
@@ -1,10 +1,6 @@
1
- import { PropertyValues, TemplateResult } from 'lit';
2
- import { Field } from '../../base/field.js';
3
- /**
4
- * @fires {Event} change - Fired when the selected value has changed.
5
- * @fires {Event} input - Fired when the selected value has changed.
6
- */
7
- export declare abstract class M3Field extends Field {
1
+ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
+ export declare abstract class M3Field extends LitElement {
3
+ #private;
8
4
  label: string;
9
5
  supportingText: string;
10
6
  disabled: boolean;
@@ -19,10 +15,9 @@ export declare abstract class M3Field extends Field {
19
15
  /**
20
16
  * Should be implemented by subclasses.
21
17
  */
22
- protected abstract renderContainerContent(): TemplateResult;
23
- protected renderSupportingText(): "" | TemplateResult<1>;
24
- protected renderStart(): TemplateResult<1>;
25
- protected renderEnd(): TemplateResult<1>;
18
+ abstract renderContainerContent(): TemplateResult;
19
+ renderSupportingText(): "" | TemplateResult<1>;
20
+ renderStart(): TemplateResult<1>;
21
+ renderEnd(): TemplateResult<1>;
26
22
  update(changedProperties: PropertyValues): void;
27
- protected handleSlotChange(e: Event): void;
28
23
  }
@@ -1,13 +1,8 @@
1
1
  import { __decorate } from "tslib";
2
- import { html } from 'lit';
2
+ import { html, LitElement } from 'lit';
3
3
  import { property, state } from 'lit/decorators.js';
4
- import { Field } from '../../base/field.js';
5
4
  import { fieldStyles } from './field-styles.css.js';
6
- /**
7
- * @fires {Event} change - Fired when the selected value has changed.
8
- * @fires {Event} input - Fired when the selected value has changed.
9
- */
10
- export class M3Field extends Field {
5
+ export class M3Field extends LitElement {
11
6
  constructor() {
12
7
  super(...arguments);
13
8
  this.label = '';
@@ -31,10 +26,10 @@ export class M3Field extends Field {
31
26
  return html `<div class="supporting-text">${this.supportingText}</div>`;
32
27
  }
33
28
  renderStart() {
34
- return html `<slot name="start" class="start" ?hidden="${!this.hasStart}" @slotchange="${this.handleSlotChange}"></slot>`;
29
+ return html `<slot name="start" class="start" ?hidden="${!this.hasStart}" @slotchange="${this.#handleSlotChange}"></slot>`;
35
30
  }
36
31
  renderEnd() {
37
- return html `<slot name="end" class="end" ?hidden="${!this.hasEnd}" @slotchange="${this.handleSlotChange}"></slot>`;
32
+ return html `<slot name="end" class="end" ?hidden="${!this.hasEnd}" @slotchange="${this.#handleSlotChange}"></slot>`;
38
33
  }
39
34
  update(changedProperties) {
40
35
  if (changedProperties.has('label')) {
@@ -42,7 +37,7 @@ export class M3Field extends Field {
42
37
  }
43
38
  super.update(changedProperties);
44
39
  }
45
- handleSlotChange(e) {
40
+ #handleSlotChange(e) {
46
41
  const slot = e.target;
47
42
  const hasContent = slot.assignedNodes({ flatten: true }).length > 0;
48
43
  if (slot.name === 'start')
@@ -2,7 +2,7 @@ import { M3Field } from './field.js';
2
2
  import '../ripple/ripple.js';
3
3
  export declare class M3FilledField extends M3Field {
4
4
  static styles: any[];
5
- protected renderContainerContent(): import("lit-html").TemplateResult<1>;
5
+ renderContainerContent(): import("lit").TemplateResult<1>;
6
6
  }
7
7
  declare global {
8
8
  interface HTMLElementTagNameMap {
@@ -1,8 +1,8 @@
1
1
  import { M3Field } from './field.js';
2
2
  export declare class M3OutlinedField extends M3Field {
3
3
  static styles: any[];
4
- protected renderContainerContent(): import("lit-html").TemplateResult<1>;
5
- protected renderOutline(): import("lit-html").TemplateResult<1>;
4
+ renderContainerContent(): import("lit").TemplateResult<1>;
5
+ renderOutline(): import("lit").TemplateResult<1>;
6
6
  }
7
7
  declare global {
8
8
  interface HTMLElementTagNameMap {
@@ -53,8 +53,9 @@ let M3FocusRing = class M3FocusRing extends Attachable(InternalsAttached(LitElem
53
53
  pointerdown: this.#handlePointerDown,
54
54
  };
55
55
  Object.keys(eventHandlers).forEach((eventName) => {
56
- prev?.removeEventListener(eventName, eventHandlers[eventName]);
57
- next?.addEventListener(eventName, eventHandlers[eventName]);
56
+ const handler = eventHandlers[eventName];
57
+ prev?.removeEventListener(eventName, handler);
58
+ next?.addEventListener(eventName, handler);
58
59
  });
59
60
  }
60
61
  };
@@ -1,4 +1,4 @@
1
- import { Item } from '../../base/item.js';
1
+ import { LitElement } from 'lit';
2
2
  /**
3
3
  * @tag md-item
4
4
  *
@@ -19,10 +19,10 @@ import { Item } from '../../base/item.js';
19
19
  * @slot trailing-supporting-text - trailing supporting text
20
20
  * @slot end - end content
21
21
  */
22
- export declare class M3Item extends Item {
22
+ export declare class M3Item extends LitElement {
23
23
  multiline: boolean;
24
24
  static styles: any[];
25
- render(): import("lit-html").TemplateResult<1>;
25
+ render(): import("lit").TemplateResult<1>;
26
26
  }
27
27
  declare global {
28
28
  interface HTMLElementTagNameMap {
@@ -1,7 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
- import { html } from 'lit';
2
+ import { html, LitElement } from 'lit';
3
3
  import { customElement, property } from 'lit/decorators.js';
4
- import { Item } from '../../base/item.js';
5
4
  import { itemStyles } from './item-styles.css.js';
6
5
  /**
7
6
  * @tag md-item
@@ -23,7 +22,7 @@ import { itemStyles } from './item-styles.css.js';
23
22
  * @slot trailing-supporting-text - trailing supporting text
24
23
  * @slot end - end content
25
24
  */
26
- let M3Item = class M3Item extends Item {
25
+ let M3Item = class M3Item extends LitElement {
27
26
  constructor() {
28
27
  super(...arguments);
29
28
  this.multiline = false;
@@ -10,10 +10,10 @@ import type { M3FocusRing } from '../focus-ring/focus-ring.js';
10
10
  * @slot - contents in md-item
11
11
  */
12
12
  export declare class M3ListItem extends ListItem {
13
- $ripple: M3Ripple;
14
- $focusRing: M3FocusRing;
13
+ $ripple: M3Ripple | null;
14
+ $focusRing: M3FocusRing | null;
15
15
  static styles: any[];
16
- render(): import("lit-html").TemplateResult<1>;
16
+ render(): import("lit").TemplateResult<1>;
17
17
  constructor();
18
18
  protected updated(changed: Map<string, any>): void;
19
19
  }