@vollowx/seele 0.13.5 → 0.13.6

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 (146) hide show
  1. package/custom-elements.json +1256 -115
  2. package/package.json +22 -14
  3. package/src/all.d.ts +34 -0
  4. package/src/base/autocomplete.d.ts +56 -0
  5. package/src/base/autocomplete.js +75 -87
  6. package/src/base/button.d.ts +13 -0
  7. package/src/base/button.js +21 -19
  8. package/src/base/checkbox.d.ts +18 -0
  9. package/src/base/checkbox.js +39 -34
  10. package/src/base/controllers/list-controller.d.ts +37 -0
  11. package/src/base/controllers/list-controller.js +23 -15
  12. package/src/base/controllers/popover-controller.d.ts +35 -0
  13. package/src/base/controllers/popover-controller.js +37 -29
  14. package/src/base/dialog.d.ts +20 -0
  15. package/src/base/dialog.js +11 -9
  16. package/src/base/field.d.ts +3 -0
  17. package/src/base/input.d.ts +44 -0
  18. package/src/base/input.js +57 -65
  19. package/src/base/item.d.ts +7 -0
  20. package/src/base/item.js +2 -1
  21. package/src/base/list-item.d.ts +15 -0
  22. package/src/base/list-item.js +22 -22
  23. package/src/base/list.d.ts +54 -0
  24. package/src/base/list.js +69 -55
  25. package/src/base/menu-item.d.ts +6 -0
  26. package/src/base/menu-item.js +4 -3
  27. package/src/base/menu.d.ts +76 -0
  28. package/src/base/menu.js +135 -143
  29. package/src/base/mixins/attachable.d.ts +9 -0
  30. package/src/base/mixins/attachable.js +22 -18
  31. package/src/base/mixins/focus-delegated.d.ts +5 -0
  32. package/src/base/mixins/focus-delegated.js +6 -8
  33. package/src/base/mixins/form-associated.d.ts +15 -0
  34. package/src/base/mixins/form-associated.js +11 -18
  35. package/src/base/mixins/internals-attached.d.ts +6 -0
  36. package/src/base/mixins/internals-attached.js +1 -1
  37. package/src/base/option.d.ts +9 -0
  38. package/src/base/option.js +7 -8
  39. package/src/base/radio.d.ts +13 -0
  40. package/src/base/radio.js +49 -42
  41. package/src/base/select.d.ts +116 -0
  42. package/src/base/select.js +130 -128
  43. package/src/base/slider.d.ts +75 -0
  44. package/src/base/slider.js +115 -118
  45. package/src/base/tab-panel.d.ts +9 -0
  46. package/src/base/tab-panel.js +11 -11
  47. package/src/base/tab.d.ts +18 -0
  48. package/src/base/tab.js +25 -24
  49. package/src/base/tabs.d.ts +19 -0
  50. package/src/base/tabs.js +84 -81
  51. package/src/base/toggle-button.d.ts +47 -0
  52. package/src/base/toggle-button.js +56 -52
  53. package/src/base/tooltip.d.ts +37 -0
  54. package/src/base/tooltip.js +70 -65
  55. package/src/core/decorators.d.ts +2 -0
  56. package/src/core/decorators.js +4 -3
  57. package/src/core/focus-visible.d.ts +2 -0
  58. package/src/core/focus-visible.js +4 -4
  59. package/src/core/shared.d.ts +1 -0
  60. package/src/core/unique-id.d.ts +4 -0
  61. package/src/core/unique-id.js +2 -1
  62. package/src/m3/autocomplete/autocomplete.d.ts +8 -0
  63. package/src/m3/autocomplete/autocomplete.js +10 -10
  64. package/src/m3/badge/badge.d.ts +12 -0
  65. package/src/m3/badge/badge.js +24 -37
  66. package/src/m3/button/common-button-toggle.d.ts +31 -0
  67. package/src/m3/button/common-button-toggle.js +44 -41
  68. package/src/m3/button/common-button.d.ts +29 -0
  69. package/src/m3/button/common-button.js +40 -40
  70. package/src/m3/button/icon-button-toggle.d.ts +24 -0
  71. package/src/m3/button/icon-button-toggle.js +35 -32
  72. package/src/m3/button/icon-button.d.ts +23 -0
  73. package/src/m3/button/icon-button.js +33 -31
  74. package/src/m3/button-group/connected-button-group.d.ts +19 -0
  75. package/src/m3/button-group/connected-button-group.js +26 -24
  76. package/src/m3/button-group/standard-button-group.d.ts +24 -0
  77. package/src/m3/button-group/standard-button-group.js +71 -65
  78. package/src/m3/checkbox/checkbox.d.ts +25 -0
  79. package/src/m3/checkbox/checkbox.js +23 -22
  80. package/src/m3/dialog/dialog-spring.d.ts +45 -0
  81. package/src/m3/dialog/dialog-spring.js +83 -86
  82. package/src/m3/dialog/dialog.d.ts +46 -0
  83. package/src/m3/dialog/dialog.js +90 -117
  84. package/src/m3/divider/divider.d.ts +13 -0
  85. package/src/m3/divider/divider.js +20 -33
  86. package/src/m3/fab/fab.d.ts +23 -0
  87. package/src/m3/fab/fab.js +24 -23
  88. package/src/m3/field/field.d.ts +28 -0
  89. package/src/m3/field/field.js +40 -55
  90. package/src/m3/field/filled-field.d.ts +11 -0
  91. package/src/m3/field/filled-field.js +7 -11
  92. package/src/m3/field/outlined-field.d.ts +11 -0
  93. package/src/m3/field/outlined-field.js +8 -12
  94. package/src/m3/focus-ring/focus-ring.d.ts +32 -0
  95. package/src/m3/focus-ring/focus-ring.js +38 -23
  96. package/src/m3/item/item.d.ts +31 -0
  97. package/src/m3/item/item.js +32 -17
  98. package/src/m3/list/list-item.d.ts +22 -0
  99. package/src/m3/list/list-item.js +18 -16
  100. package/src/m3/list/list.d.ts +15 -0
  101. package/src/m3/list/list.js +16 -15
  102. package/src/m3/loading-indicator/loading-indicator.d.ts +26 -0
  103. package/src/m3/loading-indicator/loading-indicator.js +113 -161
  104. package/src/m3/menu/menu-item.d.ts +15 -0
  105. package/src/m3/menu/menu-item.js +10 -4
  106. package/src/m3/menu/menu.d.ts +22 -0
  107. package/src/m3/menu/menu.js +20 -18
  108. package/src/m3/radio/radio-styles.css.js +1 -1
  109. package/src/m3/radio/radio.d.ts +17 -0
  110. package/src/m3/radio/radio.js +22 -11
  111. package/src/m3/ripple/ripple.d.ts +43 -0
  112. package/src/m3/ripple/ripple.js +82 -89
  113. package/src/m3/select/filled-select.d.ts +16 -0
  114. package/src/m3/select/filled-select.js +12 -10
  115. package/src/m3/select/option.d.ts +15 -0
  116. package/src/m3/select/option.js +10 -4
  117. package/src/m3/select/outlined-select.d.ts +16 -0
  118. package/src/m3/select/outlined-select.js +12 -10
  119. package/src/m3/select/select.d.ts +13 -0
  120. package/src/m3/select/select.js +16 -16
  121. package/src/m3/slider/slider.d.ts +20 -0
  122. package/src/m3/slider/slider.js +32 -26
  123. package/src/m3/switch/switch.d.ts +27 -0
  124. package/src/m3/switch/switch.js +62 -53
  125. package/src/m3/system/motion.d.ts +12 -0
  126. package/src/m3/system/motion.js +16 -9
  127. package/src/m3/tab/tab-panel.d.ts +9 -0
  128. package/src/m3/tab/tab-panel.js +6 -9
  129. package/src/m3/tab/tab.d.ts +19 -0
  130. package/src/m3/tab/tab.js +14 -12
  131. package/src/m3/tab/tabs.d.ts +25 -0
  132. package/src/m3/tab/tabs.js +34 -30
  133. package/src/m3/text-field/filled-text-field.d.ts +13 -0
  134. package/src/m3/text-field/filled-text-field.js +15 -20
  135. package/src/m3/text-field/outlined-text-field.d.ts +13 -0
  136. package/src/m3/text-field/outlined-text-field.js +15 -20
  137. package/src/m3/toolbar/toolbar.d.ts +26 -0
  138. package/src/m3/toolbar/toolbar.js +28 -25
  139. package/src/m3/tooltip/tooltip.d.ts +19 -0
  140. package/src/m3/tooltip/tooltip.js +15 -14
  141. package/src/win98/button/button.d.ts +13 -0
  142. package/src/win98/button/button.js +13 -11
  143. package/src/win98/button/radio.d.ts +3 -0
  144. package/src/win98/button/radio.js +5 -4
  145. package/src/win98/radio/radio.d.ts +3 -0
  146. package/src/win98/radio/radio.js +5 -4
package/src/base/tabs.js CHANGED
@@ -1,83 +1,37 @@
1
- import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
1
+ import { __decorate } from "tslib";
2
2
  import { LitElement, html } from 'lit';
3
3
  import { property, queryAssignedElements } from 'lit/decorators.js';
4
4
  import { internals } from './mixins/internals-attached.js';
5
5
  /**
6
6
  * @fires {CustomEvent} tab-select
7
- */ export class Tabs extends LitElement {
8
- get $tabs() {
9
- return this.$slotItems.filter((item)=>item[internals].role === 'tab');
10
- }
11
- get $parent() {
12
- return this.parentNode instanceof ShadowRoot ? this.parentNode.host : this.parentElement;
13
- }
14
- render() {
15
- return html`<div part="tablist" role="tablist"><slot @slotchange="${this.#handleSlotChange}"></slot></div>`;
16
- }
17
- connectedCallback() {
18
- super.connectedCallback();
19
- this.addEventListener('keydown', this.#handleKeyDown.bind(this));
20
- this.addEventListener('click', this.#handleClick.bind(this));
21
- }
22
- updated(changed) {
23
- if (changed.has('selected') && this.selected) {
24
- const targetTab = this.$tabs.find((t)=>t.value === this.selected);
25
- if (targetTab && !targetTab.selected) {
26
- this.selectTab(targetTab);
27
- }
28
- }
29
- }
30
- #handleSlotChange;
31
- #handleKeyDown;
32
- #handleClick;
33
- focusTab(tab) {
34
- this.$tabs.forEach((t)=>{
35
- t.blur();
36
- t.tabIndex = -1;
37
- });
38
- tab.tabIndex = 0;
39
- tab.focus();
40
- }
41
- selectTab(selectedTab) {
42
- this.selected = selectedTab.value;
43
- const parent = this.$parent;
44
- const panels = Array.from(parent.querySelectorAll('[seele-base="tabpanel"]'));
45
- this.$tabs.forEach((tab)=>{
46
- tab.selected = tab === selectedTab;
47
- tab.tabIndex = tab === selectedTab ? 0 : -1;
48
- });
49
- panels.forEach((panel)=>{
50
- if (panel.value && selectedTab.value) {
51
- panel.hidden = panel.value !== selectedTab.value;
52
- }
53
- });
54
- this.dispatchEvent(new CustomEvent('tab-select', {
55
- detail: {
56
- tab: selectedTab,
57
- value: this.selected
58
- },
59
- bubbles: true,
60
- composed: true
61
- }));
62
- }
63
- constructor(...args){
64
- super(...args), this._role = 'tablist', this.switch = 'manual', this.selected = '', this.#handleSlotChange = (_)=>{
7
+ */
8
+ export class Tabs extends LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this._role = 'tablist';
12
+ this.switch = 'manual';
13
+ this.selected = '';
14
+ this.#handleSlotChange = (_) => {
65
15
  const parent = this.$parent;
66
- this.$tabs.forEach((tab)=>{
16
+ this.$tabs.forEach((tab) => {
67
17
  const panel = parent.querySelector(`[seele-base="tab"][value="${tab.value}"]`);
68
- if (!panel) console.error('[seele] cannot find a matching panel for tab ', tab);
18
+ if (!panel)
19
+ console.error('[seele] cannot find a matching panel for tab ', tab);
69
20
  // TODO: ariaLabelledByElements
70
21
  tab.setAttribute('aria-controls', panel.id);
71
22
  panel.setAttribute('aria-labelledby', tab.id);
72
23
  });
73
- }, this.#handleKeyDown = (event)=>{
24
+ };
25
+ this.#handleKeyDown = (event) => {
74
26
  const tabs = this.$tabs;
75
- if (!tabs.length) return;
76
- const activeElement = this.getRootNode().activeElement;
77
- const currentIndex = tabs.findIndex((t)=>t === activeElement || t.focused);
27
+ if (!tabs.length)
28
+ return;
29
+ const activeElement = this.getRootNode()
30
+ .activeElement;
31
+ const currentIndex = tabs.findIndex((t) => t === activeElement || t.focused);
78
32
  let nextIndex = currentIndex !== -1 ? currentIndex : 0;
79
33
  let handled = false;
80
- switch(event.key){
34
+ switch (event.key) {
81
35
  case 'ArrowLeft':
82
36
  nextIndex = currentIndex <= 0 ? tabs.length - 1 : currentIndex - 1;
83
37
  handled = true;
@@ -107,10 +61,12 @@ import { internals } from './mixins/internals-attached.js';
107
61
  event.stopPropagation();
108
62
  if (event.key !== 'Enter' && event.key !== ' ') {
109
63
  this.focusTab(tabs[nextIndex]);
110
- if (this.switch === 'auto') this.selectTab(tabs[nextIndex]);
64
+ if (this.switch === 'auto')
65
+ this.selectTab(tabs[nextIndex]);
111
66
  }
112
67
  }
113
- }, this.#handleClick = (event)=>{
68
+ };
69
+ this.#handleClick = (event) => {
114
70
  const target = event.target;
115
71
  const tab = target.closest('md-tab');
116
72
  if (tab && this.$tabs.includes(tab)) {
@@ -119,20 +75,67 @@ import { internals } from './mixins/internals-attached.js';
119
75
  }
120
76
  };
121
77
  }
78
+ get $tabs() {
79
+ return this.$slotItems.filter((item) => item[internals].role === 'tab');
80
+ }
81
+ get $parent() {
82
+ return this.parentNode instanceof ShadowRoot
83
+ ? this.parentNode.host
84
+ : this.parentElement;
85
+ }
86
+ render() {
87
+ return html `<div part="tablist" role="tablist"><slot @slotchange="${this.#handleSlotChange}"></slot></div>`;
88
+ }
89
+ connectedCallback() {
90
+ super.connectedCallback();
91
+ this.addEventListener('keydown', this.#handleKeyDown.bind(this));
92
+ this.addEventListener('click', this.#handleClick.bind(this));
93
+ }
94
+ updated(changed) {
95
+ if (changed.has('selected') && this.selected) {
96
+ const targetTab = this.$tabs.find((t) => t.value === this.selected);
97
+ if (targetTab && !targetTab.selected) {
98
+ this.selectTab(targetTab);
99
+ }
100
+ }
101
+ }
102
+ #handleSlotChange;
103
+ #handleKeyDown;
104
+ #handleClick;
105
+ focusTab(tab) {
106
+ this.$tabs.forEach((t) => {
107
+ t.blur();
108
+ t.tabIndex = -1;
109
+ });
110
+ tab.tabIndex = 0;
111
+ tab.focus();
112
+ }
113
+ selectTab(selectedTab) {
114
+ this.selected = selectedTab.value;
115
+ const parent = this.$parent;
116
+ const panels = Array.from(parent.querySelectorAll('[seele-base="tabpanel"]'));
117
+ this.$tabs.forEach((tab) => {
118
+ tab.selected = tab === selectedTab;
119
+ tab.tabIndex = tab === selectedTab ? 0 : -1;
120
+ });
121
+ panels.forEach((panel) => {
122
+ if (panel.value && selectedTab.value) {
123
+ panel.hidden = panel.value !== selectedTab.value;
124
+ }
125
+ });
126
+ this.dispatchEvent(new CustomEvent('tab-select', {
127
+ detail: { tab: selectedTab, value: this.selected },
128
+ bubbles: true,
129
+ composed: true,
130
+ }));
131
+ }
122
132
  }
123
- _ts_decorate([
124
- property({
125
- type: String
126
- })
133
+ __decorate([
134
+ property({ type: String })
127
135
  ], Tabs.prototype, "switch", void 0);
128
- _ts_decorate([
129
- property({
130
- type: String,
131
- reflect: true
132
- })
136
+ __decorate([
137
+ property({ type: String, reflect: true })
133
138
  ], Tabs.prototype, "selected", void 0);
134
- _ts_decorate([
135
- queryAssignedElements({
136
- flatten: true
137
- })
139
+ __decorate([
140
+ queryAssignedElements({ flatten: true })
138
141
  ], Tabs.prototype, "$slotItems", void 0);
@@ -0,0 +1,47 @@
1
+ import { LitElement } from 'lit';
2
+ declare const Base: Constructor<import("./mixins/form-associated.js").FormAssociatedInterface> & Constructor<import("./mixins/internals-attached.js").InternalsAttachedInterface> & typeof LitElement;
3
+ export declare class ToggleButton extends Base {
4
+ #private;
5
+ static styles: any[];
6
+ checked: boolean;
7
+ constructor();
8
+ connectedCallback(): void;
9
+ disconnectedCallback(): void;
10
+ protected updated(changed: Map<string, any>): void;
11
+ protected _updateInternals(): void;
12
+ /**
13
+ * --> Drag-and-drop to the other side
14
+ *
15
+ * `checked` is supposed to be changed once
16
+ *
17
+ * 1. `pointerdown`: _ignoreClick = false
18
+ * 2. `pointermove`: _ignoreClick = true
19
+ * 3. `pointerup`: `checked` changed
20
+ * 4. `click`: ignored, _ignoreClick = false
21
+ *
22
+ * --> Drag-and-drop to the other side, then click
23
+ *
24
+ * `checked` is supposed to be changed twice
25
+ *
26
+ * 1. `pointerdown`: _ignoreClick = false
27
+ * 2. `pointermove`: _ignoreClick = true
28
+ * 3. `pointerup`: `checked` changed(1)
29
+ * 4. `click`: ignored, _ignoreClick = false
30
+ * 5. `click`: `checked` changed(2)
31
+ *
32
+ * --> Drag-and-drop to the other side, then click the label
33
+ *
34
+ * `checked` is supposed to be changed twice
35
+ *
36
+ * 1. `pointerdown`: _ignoreClick = false
37
+ * 2. `pointermove`: _ignoreClick = true
38
+ * 3. `pointerup`: `checked` changed(1)
39
+ * 4. `click` on label: _ignoreClick = false
40
+ * 5. `click` on switch: `checked` changed(2)
41
+ */
42
+ protected _ignoreClick: boolean;
43
+ protected toggleChecked(): void;
44
+ formResetCallback(): void;
45
+ formStateRestoreCallback(state: string, _reason: string): void;
46
+ }
47
+ export {};
@@ -1,4 +1,4 @@
1
- import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
1
+ import { __decorate } from "tslib";
2
2
  import { LitElement } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
4
  import { InternalsAttached, internals } from './mixins/internals-attached.js';
@@ -6,48 +6,49 @@ import { FormAssociated } from './mixins/form-associated.js';
6
6
  import { hiddenStyles } from './hidden-styles.css.js';
7
7
  const PROPERTY_FROM_ARIA_PRESSED = {
8
8
  true: 'checked',
9
- false: 'unchecked'
9
+ false: 'unchecked',
10
10
  };
11
11
  const Base = FormAssociated(InternalsAttached(LitElement));
12
12
  export class ToggleButton extends Base {
13
- static{
14
- this.styles = [
15
- hiddenStyles
16
- ];
17
- }
18
- constructor(){
19
- super(), this.checked = false, /**
20
- * --> Drag-and-drop to the other side
21
- *
22
- * `checked` is supposed to be changed once
23
- *
24
- * 1. `pointerdown`: _ignoreClick = false
25
- * 2. `pointermove`: _ignoreClick = true
26
- * 3. `pointerup`: `checked` changed
27
- * 4. `click`: ignored, _ignoreClick = false
28
- *
29
- * --> Drag-and-drop to the other side, then click
30
- *
31
- * `checked` is supposed to be changed twice
32
- *
33
- * 1. `pointerdown`: _ignoreClick = false
34
- * 2. `pointermove`: _ignoreClick = true
35
- * 3. `pointerup`: `checked` changed(1)
36
- * 4. `click`: ignored, _ignoreClick = false
37
- * 5. `click`: `checked` changed(2)
38
- *
39
- * --> Drag-and-drop to the other side, then click the label
40
- *
41
- * `checked` is supposed to be changed twice
42
- *
43
- * 1. `pointerdown`: _ignoreClick = false
44
- * 2. `pointermove`: _ignoreClick = true
45
- * 3. `pointerup`: `checked` changed(1)
46
- * 4. `click` on label: _ignoreClick = false
47
- * 5. `click` on switch: `checked` changed(2)
48
- */ this._ignoreClick = false, this.#handleLabelClick = ()=>{
13
+ static { this.styles = [hiddenStyles]; }
14
+ constructor() {
15
+ super();
16
+ this.checked = false;
17
+ /**
18
+ * --> Drag-and-drop to the other side
19
+ *
20
+ * `checked` is supposed to be changed once
21
+ *
22
+ * 1. `pointerdown`: _ignoreClick = false
23
+ * 2. `pointermove`: _ignoreClick = true
24
+ * 3. `pointerup`: `checked` changed
25
+ * 4. `click`: ignored, _ignoreClick = false
26
+ *
27
+ * --> Drag-and-drop to the other side, then click
28
+ *
29
+ * `checked` is supposed to be changed twice
30
+ *
31
+ * 1. `pointerdown`: _ignoreClick = false
32
+ * 2. `pointermove`: _ignoreClick = true
33
+ * 3. `pointerup`: `checked` changed(1)
34
+ * 4. `click`: ignored, _ignoreClick = false
35
+ * 5. `click`: `checked` changed(2)
36
+ *
37
+ * --> Drag-and-drop to the other side, then click the label
38
+ *
39
+ * `checked` is supposed to be changed twice
40
+ *
41
+ * 1. `pointerdown`: _ignoreClick = false
42
+ * 2. `pointermove`: _ignoreClick = true
43
+ * 3. `pointerup`: `checked` changed(1)
44
+ * 4. `click` on label: _ignoreClick = false
45
+ * 5. `click` on switch: `checked` changed(2)
46
+ */
47
+ this._ignoreClick = false;
48
+ this.#handleLabelClick = () => {
49
49
  this._ignoreClick = false;
50
- }, this.#handleClick = (e)=>{
50
+ };
51
+ this.#handleClick = (e) => {
51
52
  e.stopPropagation();
52
53
  e.preventDefault();
53
54
  if (this._ignoreClick) {
@@ -55,12 +56,16 @@ export class ToggleButton extends Base {
55
56
  return;
56
57
  }
57
58
  this.toggleChecked();
58
- }, this.#handleKeyDown = (e)=>{
59
- if (e.key !== ' ' && e.key !== 'Enter') return;
59
+ };
60
+ this.#handleKeyDown = (e) => {
61
+ if (e.key !== ' ' && e.key !== 'Enter')
62
+ return;
60
63
  e.preventDefault();
61
64
  e.stopPropagation();
62
- if (e.key === 'Enter') this.toggleChecked();
63
- }, this.#handleKeyUp = (e)=>{
65
+ if (e.key === 'Enter')
66
+ this.toggleChecked();
67
+ };
68
+ this.#handleKeyUp = (e) => {
64
69
  if (e.key === ' ') {
65
70
  e.preventDefault();
66
71
  e.stopPropagation();
@@ -77,16 +82,16 @@ export class ToggleButton extends Base {
77
82
  this.addEventListener('click', this.#handleClick);
78
83
  this.addEventListener('keydown', this.#handleKeyDown);
79
84
  this.addEventListener('keyup', this.#handleKeyUp);
80
- this.labels.forEach((label)=>{
85
+ this.labels.forEach((label) => {
81
86
  label.addEventListener('click', this.#handleLabelClick);
82
87
  });
83
- requestAnimationFrame(()=>requestAnimationFrame(()=>this.removeAttribute('notransition')));
88
+ requestAnimationFrame(() => requestAnimationFrame(() => this.removeAttribute('notransition')));
84
89
  }
85
90
  disconnectedCallback() {
86
91
  this.removeEventListener('click', this.#handleClick);
87
92
  this.removeEventListener('keydown', this.#handleKeyDown);
88
93
  this.removeEventListener('keyup', this.#handleKeyUp);
89
- this.labels.forEach((label)=>{
94
+ this.labels.forEach((label) => {
90
95
  label.removeEventListener('click', this.#handleLabelClick);
91
96
  });
92
97
  super.disconnectedCallback();
@@ -110,12 +115,13 @@ export class ToggleButton extends Base {
110
115
  #handleKeyDown;
111
116
  #handleKeyUp;
112
117
  toggleChecked() {
113
- if (this.disabled) return;
118
+ if (this.disabled)
119
+ return;
114
120
  this.checked = !this.checked;
115
121
  this.dispatchEvent(new CustomEvent('change', {
116
122
  bubbles: true,
117
123
  composed: true,
118
- detail: this.checked
124
+ detail: this.checked,
119
125
  }));
120
126
  }
121
127
  formResetCallback() {
@@ -125,8 +131,6 @@ export class ToggleButton extends Base {
125
131
  this.checked = state === 'on';
126
132
  }
127
133
  }
128
- _ts_decorate([
129
- property({
130
- type: Boolean
131
- })
134
+ __decorate([
135
+ property({ type: Boolean })
132
136
  ], ToggleButton.prototype, "checked", void 0);
@@ -0,0 +1,37 @@
1
+ import { LitElement } from 'lit';
2
+ declare const Base: Constructor<import("./mixins/attachable.js").AttachableInterface> & Constructor<import("./mixins/internals-attached.js").InternalsAttachedInterface> & typeof LitElement;
3
+ /**
4
+ * TODO: Check if $control controls a menu/popover and keep hidden when it is open.
5
+ */
6
+ export declare class Tooltip extends Base {
7
+ #private;
8
+ readonly _delays: {
9
+ mouse: {
10
+ show: number;
11
+ hide: number;
12
+ };
13
+ focus: {
14
+ show: number;
15
+ hide: number;
16
+ };
17
+ touch: {
18
+ show: number;
19
+ hide: number;
20
+ };
21
+ recentlyShowed: number;
22
+ };
23
+ readonly _durations: {
24
+ show: number;
25
+ hide: number;
26
+ };
27
+ align: import('@floating-ui/dom').Placement;
28
+ offset: number;
29
+ forceInvisible: boolean;
30
+ $slot: HTMLSlotElement;
31
+ render(): import("lit-html").TemplateResult<1>;
32
+ private readonly popoverController;
33
+ constructor();
34
+ handleControlChange(prev?: HTMLElement | null, next?: HTMLElement | null): void;
35
+ set visible(value: boolean);
36
+ }
37
+ export {};
@@ -1,4 +1,4 @@
1
- import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
1
+ import { __decorate } from "tslib";
2
2
  import { LitElement, html } from 'lit';
3
3
  import { property, query } from 'lit/decorators.js';
4
4
  import { focusVisible } from '../core/focus-visible.js';
@@ -9,66 +9,76 @@ let lastHidingTime = 0;
9
9
  const Base = Attachable(InternalsAttached(LitElement));
10
10
  /**
11
11
  * TODO: Check if $control controls a menu/popover and keep hidden when it is open.
12
- */ export class Tooltip extends Base {
12
+ */
13
+ export class Tooltip extends Base {
13
14
  render() {
14
- return html`<slot @slotchange="${this.#handleSlotChange}"></slot>`;
15
+ return html `<slot @slotchange="${this.#handleSlotChange}"></slot>`;
15
16
  }
16
17
  // Different from those in the popoverController, these timers are used to
17
18
  // manage the delay before showing/hiding the tooltip.
18
19
  #openTimer;
19
20
  #closeTimer;
20
- constructor(){
21
- super(), this._delays = {
22
- mouse: {
23
- show: 500,
24
- hide: 0
25
- },
26
- focus: {
27
- show: 100,
28
- hide: 0
29
- },
30
- touch: {
31
- show: 700,
32
- hide: 1500
33
- },
34
- recentlyShowed: 800
35
- }, this._durations = {
36
- show: 100,
37
- hide: 100
38
- }, this.align = 'top', this.offset = 4, this.forceInvisible = false, this.#openTimer = null, this.#closeTimer = null, this.popoverController = new PopoverController(this, {
39
- popover: ()=>this,
40
- trigger: ()=>this.$control,
21
+ constructor() {
22
+ super();
23
+ this._delays = {
24
+ mouse: { show: 500, hide: 0 },
25
+ focus: { show: 100, hide: 0 },
26
+ touch: { show: 700, hide: 1500 },
27
+ recentlyShowed: 800,
28
+ };
29
+ this._durations = { show: 100, hide: 100 };
30
+ this.align = 'top';
31
+ this.offset = 4;
32
+ this.forceInvisible = false;
33
+ // Different from those in the popoverController, these timers are used to
34
+ // manage the delay before showing/hiding the tooltip.
35
+ this.#openTimer = null;
36
+ this.#closeTimer = null;
37
+ this.popoverController = new PopoverController(this, {
38
+ popover: () => this,
39
+ trigger: () => this.$control,
41
40
  positioning: {
42
- placement: ()=>this.align,
43
- strategy: ()=>'absolute',
44
- offset: ()=>this.offset,
45
- windowPadding: ()=>16
41
+ placement: () => this.align,
42
+ strategy: () => 'absolute',
43
+ offset: () => this.offset,
44
+ windowPadding: () => 16,
46
45
  },
47
46
  durations: {
48
- open: ()=>this._durations.show,
49
- close: ()=>this._durations.hide
47
+ open: () => this._durations.show,
48
+ close: () => this._durations.hide,
50
49
  },
51
- onClickAway: ()=>{
50
+ onClickAway: () => {
52
51
  this.visible = false;
53
- }
54
- }), this.#handleSlotChange = ()=>{
55
- if (!this.visible) this.$control.setAttribute('aria-label', this.textContent ?? '');
56
- }, this.#handleFocusIn = ()=>{
57
- if (!focusVisible) return;
52
+ },
53
+ });
54
+ this.#handleSlotChange = () => {
55
+ if (!this.visible)
56
+ this.$control.setAttribute('aria-label', this.textContent ?? '');
57
+ };
58
+ this.#handleFocusIn = () => {
59
+ if (!focusVisible)
60
+ return;
58
61
  this.#show(this._delays.focus.show);
59
- }, this.#handleFocusOut = ()=>{
62
+ };
63
+ this.#handleFocusOut = () => {
60
64
  this.#hide(this._delays.focus.hide);
61
- }, this.#handlePointerEnter = (e)=>{
65
+ };
66
+ this.#handlePointerEnter = (e) => {
62
67
  const evt = e;
63
- if (evt.pointerType === 'touch') return;
68
+ if (evt.pointerType === 'touch')
69
+ return;
64
70
  this.#show(this._delays.mouse.show);
65
- }, this.#handlePointerLeave = (e)=>{
71
+ };
72
+ this.#handlePointerLeave = (e) => {
66
73
  const evt = e;
67
- if (evt.pointerType === 'touch') return;
74
+ if (evt.pointerType === 'touch')
75
+ return;
68
76
  this.#hide(this._delays.mouse.hide);
69
- }, this.#handleTouchStart = ()=>{
77
+ };
78
+ this.#handleTouchStart = () => {
70
79
  this.#show(this._delays.touch.show);
71
- }, this.#handleTouchEnd = ()=>{
80
+ };
81
+ this.#handleTouchEnd = () => {
72
82
  this.#hide(this._delays.touch.hide);
73
83
  };
74
84
  this[internals].role = 'tooltip';
@@ -80,19 +90,22 @@ const Base = Attachable(InternalsAttached(LitElement));
80
90
  pointerenter: this.#handlePointerEnter,
81
91
  pointerleave: this.#handlePointerLeave,
82
92
  touchstart: this.#handleTouchStart,
83
- touchend: this.#handleTouchEnd
93
+ touchend: this.#handleTouchEnd,
84
94
  };
85
- Object.keys(eventHandlers).forEach((key)=>{
95
+ Object.keys(eventHandlers).forEach((key) => {
86
96
  prev?.removeEventListener(key, eventHandlers[key]);
87
97
  next?.addEventListener(key, eventHandlers[key]);
88
98
  });
89
- if (prev) prev.removeAttribute('aria-label');
90
- if (next) next.setAttribute('aria-label', this.textContent ?? '');
99
+ if (prev)
100
+ prev.removeAttribute('aria-label');
101
+ if (next)
102
+ next.setAttribute('aria-label', this.textContent ?? '');
91
103
  }
92
104
  set visible(value) {
93
105
  if (value) {
94
106
  this.popoverController.animateOpen();
95
- } else {
107
+ }
108
+ else {
96
109
  this.popoverController.animateClose();
97
110
  }
98
111
  }
@@ -105,7 +118,7 @@ const Base = Attachable(InternalsAttached(LitElement));
105
118
  #handleTouchEnd;
106
119
  #show(delay) {
107
120
  clearTimeout(this.#closeTimer);
108
- this.#openTimer = setTimeout(()=>{
121
+ this.#openTimer = setTimeout(() => {
109
122
  this.visible = true;
110
123
  }, Math.max(Date.now() - lastHidingTime < this._delays.recentlyShowed ? 0 : delay));
111
124
  }
@@ -114,28 +127,20 @@ const Base = Attachable(InternalsAttached(LitElement));
114
127
  lastHidingTime = Date.now();
115
128
  }
116
129
  clearTimeout(this.#openTimer);
117
- this.#closeTimer = setTimeout(()=>{
130
+ this.#closeTimer = setTimeout(() => {
118
131
  this.visible = false;
119
132
  }, delay);
120
133
  }
121
134
  }
122
- _ts_decorate([
123
- property({
124
- reflect: true
125
- })
135
+ __decorate([
136
+ property({ reflect: true })
126
137
  ], Tooltip.prototype, "align", void 0);
127
- _ts_decorate([
128
- property({
129
- type: Number,
130
- reflect: true
131
- })
138
+ __decorate([
139
+ property({ type: Number, reflect: true })
132
140
  ], Tooltip.prototype, "offset", void 0);
133
- _ts_decorate([
134
- property({
135
- type: Boolean,
136
- reflect: true
137
- })
141
+ __decorate([
142
+ property({ type: Boolean, reflect: true })
138
143
  ], Tooltip.prototype, "forceInvisible", void 0);
139
- _ts_decorate([
144
+ __decorate([
140
145
  query('slot')
141
146
  ], Tooltip.prototype, "$slot", void 0);
@@ -0,0 +1,2 @@
1
+ declare const wrappedCustomElement: (tagName: string, allowSSR?: boolean) => import("lit/decorators.js").CustomElementDecorator;
2
+ export { wrappedCustomElement as customElement };
@@ -1,10 +1,11 @@
1
1
  import { isServer } from 'lit';
2
2
  import { customElement } from 'lit/decorators.js';
3
- const wrappedCustomElement = (tagName, allowSSR = true)=>{
3
+ const wrappedCustomElement = (tagName, allowSSR = true) => {
4
4
  if (isServer && !allowSSR) {
5
5
  console.log(`[seele] <${tagName}> will not be rendered server-side`);
6
- return (cls)=>cls;
7
- } else {
6
+ return (cls) => cls;
7
+ }
8
+ else {
8
9
  return customElement(tagName);
9
10
  }
10
11
  };
@@ -0,0 +1,2 @@
1
+ export declare let focusVisible: boolean;
2
+ export declare function setFocusVisible(value: boolean): void;