@antadesign/anta 0.3.33 → 0.3.35

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 (205) hide show
  1. package/LICENSE.md +14 -1
  2. package/README.md +9 -0
  3. package/dist/anta_helpers.d.ts +46 -30
  4. package/dist/anta_helpers.js +66 -25
  5. package/dist/bundle.css +1 -1
  6. package/dist/bundle.js +2 -1353
  7. package/dist/components/Banner.d.ts +25 -40
  8. package/dist/components/Banner.js +15 -17
  9. package/dist/components/Breadcrumbs.d.ts +0 -1
  10. package/dist/components/Breadcrumbs.js +0 -1
  11. package/dist/components/Button.d.ts +2 -3
  12. package/dist/components/Button.js +1 -0
  13. package/dist/components/ButtonCopy.js +3 -2
  14. package/dist/components/Calendar.js +13 -13
  15. package/dist/components/Card.d.ts +9 -17
  16. package/dist/components/Card.js +50 -46
  17. package/dist/components/Dialog.d.ts +1 -0
  18. package/dist/components/Dialog.js +16 -10
  19. package/dist/components/Expander.d.ts +6 -21
  20. package/dist/components/Expander.js +24 -23
  21. package/dist/components/Icon.d.ts +8 -14
  22. package/dist/components/Input.d.ts +77 -96
  23. package/dist/components/Input.js +23 -27
  24. package/dist/components/InputAutocomplete.d.ts +29 -10
  25. package/dist/components/InputAutocomplete.js +25 -8
  26. package/dist/components/InputDate.d.ts +0 -1
  27. package/dist/components/InputDate.js +2 -3
  28. package/dist/components/InputTime.d.ts +10 -4
  29. package/dist/components/InputTime.js +20 -16
  30. package/dist/components/Loader.d.ts +2 -2
  31. package/dist/components/Menu.d.ts +5 -4
  32. package/dist/components/Menu.js +13 -8
  33. package/dist/components/MenuItem.js +1 -14
  34. package/dist/components/MenuItemCopy.js +2 -2
  35. package/dist/components/Panel.d.ts +3 -1
  36. package/dist/components/Panel.js +17 -11
  37. package/dist/components/Progress.d.ts +21 -23
  38. package/dist/components/Progress.js +13 -9
  39. package/dist/components/RadioGroup.js +6 -8
  40. package/dist/components/{select-parts.css → Select.css} +1 -1
  41. package/dist/components/Select.d.ts +53 -36
  42. package/dist/components/Select.js +53 -98
  43. package/dist/components/SelectFaceted.d.ts +7 -4
  44. package/dist/components/SelectFaceted.js +21 -10
  45. package/dist/components/Slider.d.ts +28 -11
  46. package/dist/components/Slider.js +20 -20
  47. package/dist/components/Steps.css +1 -1
  48. package/dist/components/Steps.d.ts +0 -1
  49. package/dist/components/Steps.js +1 -12
  50. package/dist/components/Tabs.d.ts +17 -20
  51. package/dist/components/Tabs.js +7 -9
  52. package/dist/components/Text.d.ts +55 -36
  53. package/dist/components/Text.js +35 -22
  54. package/dist/components/Title.d.ts +19 -27
  55. package/dist/components/Title.js +2 -1
  56. package/dist/components/Toaster.js +9 -2
  57. package/dist/components/Tooltip.d.ts +10 -15
  58. package/dist/components/copy-props.d.ts +14 -3
  59. package/dist/components/copy-props.js +14 -3
  60. package/dist/components/select-tree.d.ts +24 -0
  61. package/dist/components/select-tree.js +35 -0
  62. package/dist/element-base.d.ts +10 -0
  63. package/dist/element-base.js +15 -0
  64. package/dist/elements/a-avatar.css +1 -1
  65. package/dist/elements/a-avatar.js +2 -28
  66. package/dist/elements/a-banner.css +1 -1
  67. package/dist/elements/a-banner.d.ts +4 -1
  68. package/dist/elements/a-banner.js +22 -112
  69. package/dist/elements/a-breadcrumbs.d.ts +1 -0
  70. package/dist/elements/a-breadcrumbs.js +1 -0
  71. package/dist/elements/a-button.css +1 -1
  72. package/dist/elements/a-button.d.ts +10 -7
  73. package/dist/elements/a-button.js +18 -1
  74. package/dist/elements/a-calendar.d.ts +14 -13
  75. package/dist/elements/a-calendar.js +29 -24
  76. package/dist/elements/a-card.css +1 -1
  77. package/dist/elements/a-card.d.ts +0 -9
  78. package/dist/elements/a-card.js +0 -184
  79. package/dist/elements/a-checkbox.css +1 -1
  80. package/dist/elements/a-copy.css +1 -1
  81. package/dist/elements/a-copy.d.ts +1 -5
  82. package/dist/elements/a-copy.js +129 -108
  83. package/dist/elements/a-dialog.css +1 -1
  84. package/dist/elements/a-dialog.d.ts +1 -1
  85. package/dist/elements/a-dialog.js +68 -194
  86. package/dist/elements/a-expander.css +1 -1
  87. package/dist/elements/a-expander.d.ts +4 -30
  88. package/dist/elements/a-expander.js +85 -344
  89. package/dist/elements/a-icon.d.ts +5 -23
  90. package/dist/elements/a-icon.js +1 -2
  91. package/dist/elements/a-input-date.d.ts +1 -0
  92. package/dist/elements/a-input-date.js +1 -0
  93. package/dist/elements/a-input-time.css +1 -1
  94. package/dist/elements/a-input-time.d.ts +2 -1
  95. package/dist/elements/a-input-time.js +101 -168
  96. package/dist/elements/a-input.css +1 -1
  97. package/dist/elements/a-input.d.ts +10 -8
  98. package/dist/elements/a-input.js +155 -230
  99. package/dist/elements/a-loader.d.ts +5 -8
  100. package/dist/elements/a-loader.js +1 -2
  101. package/dist/elements/a-menu-item.css +1 -1
  102. package/dist/elements/a-menu-item.d.ts +5 -3
  103. package/dist/elements/a-menu-item.js +5 -1
  104. package/dist/elements/a-menu.css +1 -1
  105. package/dist/elements/a-menu.d.ts +5 -7
  106. package/dist/elements/a-menu.js +383 -299
  107. package/dist/elements/a-panel.css +1 -1
  108. package/dist/elements/a-panel.js +19 -37
  109. package/dist/elements/a-progress.css +1 -1
  110. package/dist/elements/a-progress.d.ts +0 -22
  111. package/dist/elements/a-progress.js +0 -100
  112. package/dist/elements/a-radio-group.d.ts +1 -1
  113. package/dist/elements/a-radio-group.js +6 -4
  114. package/dist/elements/a-select-faceted.d.ts +1 -0
  115. package/dist/elements/a-select-faceted.js +1 -0
  116. package/dist/elements/a-select.d.ts +1 -0
  117. package/dist/elements/a-select.js +1 -0
  118. package/dist/elements/a-slider.css +1 -1
  119. package/dist/elements/a-slider.d.ts +11 -3
  120. package/dist/elements/a-slider.js +244 -242
  121. package/dist/elements/a-steps.d.ts +1 -0
  122. package/dist/elements/a-steps.js +1 -0
  123. package/dist/elements/a-switch.css +1 -1
  124. package/dist/elements/a-tab.css +1 -1
  125. package/dist/elements/a-tabpanel.d.ts +2 -2
  126. package/dist/elements/a-tabpanel.js +13 -3
  127. package/dist/elements/a-tabs.css +1 -1
  128. package/dist/elements/a-tabs.d.ts +1 -1
  129. package/dist/elements/a-tabs.js +6 -4
  130. package/dist/elements/a-tag.css +1 -1
  131. package/dist/elements/a-tag.d.ts +1 -0
  132. package/dist/elements/a-tag.js +1 -0
  133. package/dist/elements/a-text.css +1 -1
  134. package/dist/elements/a-text.d.ts +6 -43
  135. package/dist/elements/a-text.js +110 -193
  136. package/dist/elements/a-title.css +1 -1
  137. package/dist/elements/a-title.d.ts +1 -0
  138. package/dist/elements/a-title.js +1 -0
  139. package/dist/elements/a-toast.css +1 -1
  140. package/dist/elements/a-toast.d.ts +10 -45
  141. package/dist/elements/a-toast.js +80 -66
  142. package/dist/elements/a-toaster.css +1 -1
  143. package/dist/elements/a-toaster.js +9 -44
  144. package/dist/elements/a-tooltip.css +1 -1
  145. package/dist/elements/a-tooltip.d.ts +1 -1
  146. package/dist/elements/a-tooltip.js +142 -136
  147. package/dist/elements/copy-behavior.d.ts +1 -1
  148. package/dist/elements/copy-behavior.js +21 -21
  149. package/dist/elements/index.d.ts +9 -3
  150. package/dist/elements/index.js +6 -6
  151. package/dist/elements/input-focus-modality.d.ts +15 -0
  152. package/dist/elements/input-focus-modality.js +44 -0
  153. package/dist/elements/input-trailing-actions.d.ts +5 -0
  154. package/dist/elements/input-trailing-actions.js +38 -0
  155. package/dist/elements/shadow-aria.d.ts +2 -0
  156. package/dist/elements/shadow-aria.js +2 -1
  157. package/dist/elements/value-input.d.ts +3 -0
  158. package/dist/elements/value-input.js +12 -0
  159. package/dist/general_types.d.ts +103 -96
  160. package/dist/index.d.ts +1 -1
  161. package/dist/input-events.d.ts +4 -0
  162. package/dist/input-events.js +15 -0
  163. package/dist/jsx-runtime.d.ts +70 -23
  164. package/dist/jsx-runtime.js +26 -19
  165. package/dist/native-event-props.d.ts +2 -0
  166. package/dist/native-event-props.js +10 -0
  167. package/dist/reset.css +1 -1
  168. package/dist/theme-antithesis.css +10 -1
  169. package/dist/theme-antune.css +1 -1
  170. package/docs/accessibility.md +17 -3
  171. package/docs/changelog.md +384 -2
  172. package/docs/comparison.md +2 -2
  173. package/docs/components/avatar.md +5 -0
  174. package/docs/components/banner.md +117 -187
  175. package/docs/components/breadcrumbs.md +9 -6
  176. package/docs/components/button.md +22 -0
  177. package/docs/components/card.md +74 -28
  178. package/docs/components/checkbox.md +9 -10
  179. package/docs/components/dialog.md +83 -32
  180. package/docs/components/expander.md +198 -435
  181. package/docs/components/icon.md +11 -17
  182. package/docs/components/input-autocomplete.md +152 -52
  183. package/docs/components/input-date.md +175 -148
  184. package/docs/components/input-time.md +81 -38
  185. package/docs/components/input.md +343 -349
  186. package/docs/components/loader.md +2 -1
  187. package/docs/components/menu.md +35 -6
  188. package/docs/components/panel.md +18 -0
  189. package/docs/components/progress.md +83 -49
  190. package/docs/components/radio.md +39 -43
  191. package/docs/components/select-faceted.md +54 -7
  192. package/docs/components/select.md +390 -386
  193. package/docs/components/slider.md +136 -19
  194. package/docs/components/steps.md +6 -3
  195. package/docs/components/switch.md +8 -9
  196. package/docs/components/tabs.md +110 -104
  197. package/docs/components/text.md +110 -86
  198. package/docs/components/title.md +47 -33
  199. package/docs/components/toaster.md +242 -84
  200. package/docs/components/tooltip.md +204 -113
  201. package/docs/install-config.md +461 -96
  202. package/docs/packages/plot.md +228 -143
  203. package/docs/theming.md +29 -13
  204. package/package.json +43 -4
  205. package/theme-antithesis-license.md +66 -0
@@ -1,220 +1,137 @@
1
- import { HTMLElementBase } from "../anta_helpers";
1
+ import { HTMLElementBase, isTextToggleReceiver, SYNC_TEXT_TOGGLE } from "../anta_helpers";
2
2
  import "./a-text.css";
3
- const SHADOW_STYLE = `
4
- :host {
5
- display: block;
6
- position: relative;
7
- }
8
- :host([inline]) {
9
- display: inline-block;
10
- }
11
-
12
- slot {
13
- display: contents;
14
- }
15
-
16
- :host([truncate]) slot {
17
- display: -webkit-box;
18
- -webkit-box-orient: vertical;
19
- -webkit-line-clamp: var(--line-clamp, 1);
20
- overflow: hidden;
21
- }
22
-
23
- :host([truncate][expandable]) slot.overflowing:not(.expanded) {
24
- -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 2em), transparent 97%);
25
- mask-image: linear-gradient(to bottom, black calc(100% - 2em), transparent 97%);
26
- }
27
-
28
- :host([truncate="1"][expandable]) slot.overflowing:not(.expanded) {
29
- -webkit-mask-image: linear-gradient(to right, black calc(100% - 7ch), transparent 97%);
30
- mask-image: linear-gradient(to right, black calc(100% - 7ch), transparent 97%);
31
- }
32
-
33
- :host([truncate]) slot.expanded {
34
- display: block;
35
- -webkit-line-clamp: unset;
36
- overflow: visible;
37
- }
38
-
39
- .expand-btn {
40
- appearance: none;
41
- background: transparent;
42
- border: none;
43
- margin: 0;
44
- padding: 0;
45
- color: var(--text-3);
46
- cursor: pointer;
47
- font: inherit;
48
- font-variation-settings: inherit;
49
- display: none;
50
- position: absolute;
51
- z-index: 1;
52
- opacity: 0;
53
- transition: opacity 150ms ease-out, color 150ms ease-out;
54
- }
55
- .expand-btn:hover {
56
- color: var(--text-1);
57
- }
58
- .expand-btn::before {
59
- content: '';
60
- position: absolute;
61
- right: -1px;
62
- bottom: -1px;
63
- width: 14px;
64
- height: 14px;
65
- background-color: currentColor;
66
- -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
67
- mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
68
- -webkit-mask-position: center;
69
- mask-position: center;
70
- -webkit-mask-repeat: no-repeat;
71
- mask-repeat: no-repeat;
72
- -webkit-mask-size: contain;
73
- mask-size: contain;
74
- transition: transform 150ms ease-out;
75
- }
76
-
77
- :host([truncate][expandable]) slot.overflowing ~ .expand-btn {
78
- display: block;
79
- left: 0;
80
- right: 0;
81
- bottom: 0;
82
- height: 1.5em;
83
- }
84
-
85
- :host([truncate="1"][expandable]) slot.overflowing ~ .expand-btn {
86
- left: auto;
87
- top: 0;
88
- bottom: 0;
89
- width: 3em;
90
- }
91
-
92
- :host([truncate][expandable]:hover) slot.overflowing ~ .expand-btn,
93
- :host([truncate][expandable]:focus-within) slot.overflowing ~ .expand-btn,
94
- .expand-btn.expanded {
95
- opacity: 1;
96
- }
97
-
98
- .expand-btn.expanded::before {
99
- transform: rotate(180deg);
100
- }
101
- `;
102
3
  class ATextElement extends HTMLElementBase {
103
4
  static observedAttributes = ["expandable", "truncate", "collapsible"];
104
- slotEl;
105
- /** The chevron — built only while expandable, removed on drop or one-way expand. */
106
- expandBtn;
107
- /** Expanded state lives on the element — a stateless wrapper can't hold it. */
108
- expanded = false;
109
- // Re-sync `slot.overflowing`: the resize observer watches the box (width),
110
- // the mutation observer watches the slotted content — the clamped box never
111
- // resizes as content grows, so resize alone misses added lines.
112
- overflowObserver;
113
- contentObserver;
5
+ #internals;
6
+ #expanded = false;
7
+ #resizeObserver;
8
+ #contentObserver;
9
+ #content;
10
+ #control;
11
+ #reportQueued = false;
12
+ #reported;
114
13
  constructor() {
115
14
  super();
116
- const shadow = this.attachShadow({ mode: "open" });
117
- const style = document.createElement("style");
118
- style.textContent = SHADOW_STYLE;
119
- this.slotEl = document.createElement("slot");
120
- shadow.append(style, this.slotEl);
15
+ this.#internals = this.attachInternals();
16
+ }
17
+ addEventListener(type, callback, options) {
18
+ if (callback) super.addEventListener(type, callback, options);
19
+ if (type === "textpresentationchange" && callback) this.#reportPresentation(true);
121
20
  }
122
21
  connectedCallback() {
123
- this.syncExpandButton();
124
- if (this.#isExpandable) this.startOverflowObserver();
22
+ this.addEventListener("click", this.#onToggle);
23
+ this.addEventListener("anta-text-control-ready", this.#onControlReady);
24
+ this.#sync();
125
25
  }
126
26
  disconnectedCallback() {
127
- this.overflowObserver?.disconnect();
128
- this.contentObserver?.disconnect();
27
+ this.removeEventListener("click", this.#onToggle);
28
+ this.removeEventListener("anta-text-control-ready", this.#onControlReady);
29
+ this.#resizeObserver?.disconnect();
30
+ this.#contentObserver?.disconnect();
31
+ this.#content = void 0;
32
+ this.#clearControl();
129
33
  }
130
34
  attributeChangedCallback(name, oldValue, newValue) {
131
35
  if (oldValue === newValue) return;
132
- if (name === "truncate" || name === "expandable") this.setExpanded(false);
133
- this.syncExpandButton();
134
- if (name === "truncate" || name === "expandable") {
135
- if (this.#isExpandable) this.startOverflowObserver();
136
- else this.stopOverflowObserver();
137
- }
36
+ if (name === "truncate" || name === "expandable") this.#setExpanded(false);
37
+ if (this.isConnected) this.#sync();
138
38
  }
139
- get #isExpandable() {
39
+ get #canExpand() {
140
40
  return this.hasAttribute("truncate") && this.hasAttribute("expandable");
141
41
  }
142
- get #isCollapsible() {
143
- return this.hasAttribute("collapsible");
144
- }
145
- /** True when `truncate` currently hides some of the slotted content. This is
146
- * a UI-thread layout read, used by a nested `a-tooltip`; it never writes to
147
- * the host or light DOM. */
42
+ /** Whether the current clamp hides content. Also used by truncated-only
43
+ * tooltips. This layout read changes neither markup nor accessibility. */
148
44
  get isTruncated() {
149
- if (!this.hasAttribute("truncate") || this.expanded) return false;
150
- const s = this.slotEl;
151
- if (s.clientWidth === 0 && s.clientHeight === 0) return false;
152
- return s.scrollHeight > s.clientHeight + 1 || s.scrollWidth > s.clientWidth + 1;
153
- }
154
- /** Create or remove the chevron to match `expandable`, then refresh it. */
155
- syncExpandButton() {
156
- if (this.#isExpandable && !this.expandBtn) {
157
- const btn = document.createElement("button");
158
- btn.className = "expand-btn";
159
- btn.type = "button";
160
- btn.addEventListener("click", this.handleToggle);
161
- this.shadowRoot.append(btn);
162
- this.expandBtn = btn;
163
- } else if (!this.#isExpandable && this.expandBtn) {
164
- this.expandBtn.remove();
165
- this.expandBtn = void 0;
45
+ if (!this.hasAttribute("truncate") || this.#expanded) return false;
46
+ const content = this.#clampBox();
47
+ if (!content || content.clientWidth === 0 && content.clientHeight === 0) return false;
48
+ return content.scrollHeight > content.clientHeight + 1 || content.scrollWidth > content.clientWidth + 1;
49
+ }
50
+ #clampBox() {
51
+ return this.#canExpand ? this.querySelector(":scope > a-text-content") : this;
52
+ }
53
+ #sync() {
54
+ if (!this.#canExpand) {
55
+ this.#resizeObserver?.disconnect();
56
+ this.#contentObserver?.disconnect();
57
+ this.#content = void 0;
58
+ this.#internals.states.delete("overflowing");
59
+ this.#clearControl();
60
+ this.#reportPresentation();
61
+ return;
166
62
  }
167
- this.refreshButton();
168
- }
169
- handleToggle = () => {
170
- this.setExpanded(!this.expanded);
171
- };
172
- setExpanded(next) {
173
- if (next === this.expanded) return;
174
- this.expanded = next;
175
- this.slotEl.classList.toggle("expanded", next);
176
- this.refreshButton();
177
- if (!next) this.measureOverflow();
178
- }
179
- startOverflowObserver() {
180
- if (!this.#isExpandable) return;
181
- this.overflowObserver ??= new ResizeObserver(() => this.measureOverflow());
182
- this.contentObserver ??= new MutationObserver(() => this.measureOverflow());
183
- this.overflowObserver.observe(this.slotEl);
184
- this.contentObserver.observe(this, { childList: true, subtree: true, characterData: true });
185
- this.measureOverflow();
63
+ this.#contentObserver ??= new MutationObserver(() => this.#sync());
64
+ this.#contentObserver.observe(this, { childList: true, subtree: true, characterData: true });
65
+ const content = this.#clampBox();
66
+ this.#resizeObserver ??= new ResizeObserver(() => this.#measureOverflow());
67
+ if (content !== this.#content) {
68
+ this.#resizeObserver.disconnect();
69
+ if (content) this.#resizeObserver.observe(content);
70
+ this.#content = content ?? void 0;
71
+ }
72
+ const control = this.querySelector(":scope > a-button");
73
+ const receiver = isTextToggleReceiver(control) ? control : void 0;
74
+ if (receiver !== this.#control) {
75
+ this.#clearControl();
76
+ this.#control = receiver;
77
+ }
78
+ this.#syncControl();
79
+ this.#reportPresentation();
80
+ this.#measureOverflow();
186
81
  }
187
- stopOverflowObserver() {
188
- this.overflowObserver?.disconnect();
189
- this.contentObserver?.disconnect();
190
- this.slotEl.classList.remove("overflowing");
82
+ #clearControl() {
83
+ this.#control?.[SYNC_TEXT_TOGGLE]({ source: this, clear: true });
84
+ this.#control = void 0;
191
85
  }
192
- /** Toggle `slot.overflowing` (gates the fade + chevron) to whether the clamp
193
- * clips. Frozen on while expanded; height catches wrapped text, width a long word. */
194
- measureOverflow() {
195
- if (!this.#isExpandable || this.expanded) return;
196
- this.slotEl.classList.toggle("overflowing", this.isTruncated);
86
+ #syncControl() {
87
+ this.#control?.[SYNC_TEXT_TOGGLE]({ source: this, expanded: this.#expanded });
197
88
  }
198
- /** Reflect state onto the button (label + `aria-expanded` + `.expanded`); a
199
- * one-way expand removes it once open. */
200
- refreshButton() {
201
- const btn = this.expandBtn;
202
- if (!btn) return;
203
- if (this.expanded && !this.#isCollapsible) {
204
- btn.remove();
205
- this.expandBtn = void 0;
206
- return;
207
- }
208
- btn.setAttribute("aria-expanded", this.expanded ? "true" : "false");
209
- btn.setAttribute("aria-label", this.expanded ? "Show less" : "Show more");
210
- btn.classList.toggle("expanded", this.expanded);
89
+ #onControlReady = (event) => {
90
+ if (event.target.parentElement === this) this.#sync();
91
+ };
92
+ #onToggle = (event) => {
93
+ if (!this.#canExpand || event.defaultPrevented) return;
94
+ const control = this.querySelector(":scope > a-button");
95
+ if (!control || !event.composedPath().includes(control)) return;
96
+ if (control.hasAttribute("disabled") || control.hasAttribute("loading")) return;
97
+ if (this.#expanded && !this.hasAttribute("collapsible")) return;
98
+ if (!this.#expanded && !this.isTruncated) return;
99
+ this.#setExpanded(!this.#expanded);
100
+ if (!this.#expanded) this.#measureOverflow();
101
+ };
102
+ #setExpanded(next) {
103
+ this.#expanded = next;
104
+ if (next) this.#internals.states.add("expanded");
105
+ else this.#internals.states.delete("expanded");
106
+ this.#syncControl();
107
+ this.#reportPresentation();
108
+ }
109
+ #measureOverflow() {
110
+ if (this.#expanded) return;
111
+ if (this.isTruncated) this.#internals.states.add("overflowing");
112
+ else this.#internals.states.delete("overflowing");
113
+ this.#reportPresentation();
114
+ }
115
+ #reportPresentation(replay = false) {
116
+ if (replay) this.#reported = void 0;
117
+ if (this.#reportQueued) return;
118
+ this.#reportQueued = true;
119
+ this.view.queueMicrotask(() => {
120
+ this.#reportQueued = false;
121
+ if (!this.isConnected) return;
122
+ const detail = {
123
+ expanded: this.#expanded,
124
+ overflowing: this.#internals.states.has("overflowing")
125
+ };
126
+ if (this.#reported?.expanded === detail.expanded && this.#reported.overflowing === detail.overflowing) return;
127
+ this.#reported = { ...detail };
128
+ this.dispatchEvent(new this.view.CustomEvent("textpresentationchange", { detail }));
129
+ });
211
130
  }
212
131
  }
213
132
  function register_a_text() {
214
133
  if (typeof customElements === "undefined") return;
215
- if (!customElements.get("a-text")) {
216
- customElements.define("a-text", ATextElement);
217
- }
134
+ if (!customElements.get("a-text")) customElements.define("a-text", ATextElement);
218
135
  }
219
136
  register_a_text();
220
137
  export {
@@ -1 +1 @@
1
- @layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-title{display:block;font-family:var(--sans-serif);color:var(--text-1);font-weight:584.62;letter-spacing:0;text-wrap:balance}a-title a-icon{transform:translateY(-.05em)}a-title[truncate]{min-width:0;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--line-clamp, 1);overflow:hidden}a-title[level="1"]{font-size:28px;line-height:32px}a-title[level="2"]{font-size:24px;line-height:28px}a-title[level="3"]{font-size:20px;line-height:24px}a-title[level="4"]{font-size:17px;line-height:20px}a-title[level="5"]{font-size:15px;line-height:20px}a-title[level="6"]{font-size:13px;line-height:16px}a-title[priority=secondary]{color:var(--text-2)}a-title[priority=tertiary]{color:var(--text-3)}a-title[priority=quaternary]{color:var(--text-4)}a-title[tone=brand]{color:var(--text-1-brand)}a-title[tone=brand][priority=secondary]{color:var(--text-2-brand)}a-title[tone=brand][priority=tertiary]{color:var(--text-3-brand)}a-title[tone=brand][priority=quaternary]{color:var(--text-4-brand)}a-title[tone=success]{color:var(--text-1-success)}a-title[tone=success][priority=secondary]{color:var(--text-2-success)}a-title[tone=success][priority=tertiary]{color:var(--text-3-success)}a-title[tone=success][priority=quaternary]{color:var(--text-4-success)}a-title[tone=critical]{color:var(--text-1-critical)}a-title[tone=critical][priority=secondary]{color:var(--text-2-critical)}a-title[tone=critical][priority=tertiary]{color:var(--text-3-critical)}a-title[tone=critical][priority=quaternary]{color:var(--text-4-critical)}a-title[tone=warning]{color:var(--text-1-warning)}a-title[tone=warning][priority=secondary]{color:var(--text-2-warning)}a-title[tone=warning][priority=tertiary]{color:var(--text-3-warning)}a-title[tone=warning][priority=quaternary]{color:var(--text-4-warning)}a-title[tone=info]{color:var(--text-1-info)}a-title[tone=info][priority=secondary]{color:var(--text-2-info)}a-title[tone=info][priority=tertiary]{color:var(--text-3-info)}a-title[tone=info][priority=quaternary]{color:var(--text-4-info)}a-title[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--title-tone-source: currentColor;--_title-tone: light-dark(oklch(from var(--title-tone-source) .41 .15 h), oklch(from var(--title-tone-source) .75 .11 h));color:light-dark(oklch(from var(--title-tone-source) .33 .15 h),oklch(from var(--title-tone-source) .82 .1 h));@supports (color: attr(probe type(<color>),red)){--title-tone-source: attr(tone type(<color>), currentColor)}}a-title[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical])[priority=secondary]{color:var(--_title-tone)}a-title[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical])[priority=tertiary]{color:color-mix(in oklch,var(--_title-tone) 80%,transparent)}a-title[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical])[priority=quaternary]{color:color-mix(in oklch,var(--_title-tone) 60%,transparent)}}
1
+ @layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-title{display:block;font-family:var(--sans-serif);color:var(--text-1);font-weight:584.62;letter-spacing:0;text-wrap:balance}a-title a-icon{transform:translateY(-.05em)}a-title[truncate]{min-width:0;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--line-clamp, 1);overflow:hidden}a-title[level="1"]{font-size:28px;line-height:32px}a-title[level="2"]{font-size:24px;line-height:28px}a-title[level="3"]{font-size:20px;line-height:24px}a-title[level="4"]{font-size:17px;line-height:22px}a-title[level="5"]{font-size:15px;line-height:20px}a-title[level="6"]{font-size:13px;line-height:16px}a-title[font=serif]{font-family:var(--serif)}a-title[font=monospace]{font-family:var(--monospace)}a-title[priority=secondary]{color:var(--text-2)}a-title[priority=tertiary]{color:var(--text-3)}a-title[priority=quaternary]{color:var(--text-4)}a-title[tone=brand]{color:var(--text-1-brand)}a-title[tone=brand][priority=secondary]{color:var(--text-2-brand)}a-title[tone=brand][priority=tertiary]{color:var(--text-3-brand)}a-title[tone=brand][priority=quaternary]{color:var(--text-4-brand)}a-title[tone=success]{color:var(--text-1-success)}a-title[tone=success][priority=secondary]{color:var(--text-2-success)}a-title[tone=success][priority=tertiary]{color:var(--text-3-success)}a-title[tone=success][priority=quaternary]{color:var(--text-4-success)}a-title[tone=critical]{color:var(--text-1-critical)}a-title[tone=critical][priority=secondary]{color:var(--text-2-critical)}a-title[tone=critical][priority=tertiary]{color:var(--text-3-critical)}a-title[tone=critical][priority=quaternary]{color:var(--text-4-critical)}a-title[tone=warning]{color:var(--text-1-warning)}a-title[tone=warning][priority=secondary]{color:var(--text-2-warning)}a-title[tone=warning][priority=tertiary]{color:var(--text-3-warning)}a-title[tone=warning][priority=quaternary]{color:var(--text-4-warning)}a-title[tone=info]{color:var(--text-1-info)}a-title[tone=info][priority=secondary]{color:var(--text-2-info)}a-title[tone=info][priority=tertiary]{color:var(--text-3-info)}a-title[tone=info][priority=quaternary]{color:var(--text-4-info)}a-title[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--title-tone-source: currentColor;--_title-tone: light-dark(oklch(from var(--title-tone-source) .41 .15 h), oklch(from var(--title-tone-source) .75 .11 h));color:light-dark(oklch(from var(--title-tone-source) .33 .15 h),oklch(from var(--title-tone-source) .82 .1 h));@supports (color: attr(probe type(<color>),red)){--title-tone-source: attr(tone type(<color>), currentColor)}}a-title[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical])[priority=secondary]{color:var(--_title-tone)}a-title[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical])[priority=tertiary]{color:color-mix(in oklch,var(--_title-tone) 80%,transparent)}a-title[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical])[priority=quaternary]{color:color-mix(in oklch,var(--_title-tone) 60%,transparent)}}
@@ -0,0 +1 @@
1
+ import './a-title.css';
@@ -0,0 +1 @@
1
+ import "./a-title.css";
@@ -1 +1 @@
1
- @layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@property --toast-remaining{syntax: "<number>"; inherits: true; initial-value: 1;}@layer anta.components{a-toast{--toast-dur: .22s}a-toast:not(:defined){display:none}}
1
+ @layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@property --toast-remaining{syntax: "<number>"; inherits: true; initial-value: 1;}@layer anta.components{a-toast{--toast-dur: .22s;display:block;opacity:1;translate:0 0}a-toast:not(:defined){display:none}a-toast:state(leaving){opacity:0}@starting-style{a-toast{opacity:0;translate:0 12px}}@media(prefers-reduced-motion:no-preference){a-toast{transition:opacity var(--toast-dur, .22s) ease,translate var(--toast-dur, .22s) ease}}a-toast::part(content){--_toast-countdown-from: 1;--_toast-countdown-to: 0;--toast-remaining: 1;display:block}}
@@ -1,51 +1,16 @@
1
1
  import { HTMLElementBase } from '../anta_helpers';
2
2
  import './a-toast.css';
3
- /**
4
- * `<a-toast>` — one item inside an `<a-toaster>`. A style-neutral container around
5
- * slotted content (a `Banner`, `Card`, `Sticker`, a string, or a raw DOM node):
6
- * it owns the enter / exit animation and the auto-dismiss timer (paused while
7
- * hovered or focused), nothing else. No chrome of its own — no ✕, no surface; the
8
- * toasted content brings its own look and its own dismiss affordance. Its `slot`
9
- * attribute (`slot="bottom-right"`, …) routes it to a placement zone.
3
+ /** One notification in a Toaster placement slot. The host owns entry/exit motion;
4
+ * its shadow content slot carries the inherited `--toast-remaining` countdown.
5
+ * The timer and countdown pause while hovered or focused. `Infinity` is sticky.
10
6
  *
11
- * Content arrives one of two ways: as slotted light-DOM children (a string / JSX
12
- * the `<Toaster>` renders through the reconciler), or as a live DOM node set on
13
- * the `content` property (the wrapper's DOM-node branch), which the element slots
14
- * into its own light DOM. Either way it projects through the shadow `<slot>`.
7
+ * JSX/raw authors own host attributes and children. Setting `content` transfers
8
+ * insertion ownership of that exact node to the element, without cloning it or
9
+ * changing authored siblings. Content must not belong to another reconciler.
15
10
  *
16
- * ## Time left — `--toast-remaining`
17
- *
18
- * While the auto-dismiss timer runs, the element animates `--toast-remaining` from
19
- * `1` to `0` on the slot (paused in lockstep with the timer on hover / focus).
20
- * It's a registered `@property` (see `a-toast.css`) with `inherits: true`, so
21
- * slotted content inherits the live value and can draw a countdown with one CSS
22
- * rule — `transform: scaleX(var(--toast-remaining))` — with no timer of its own
23
- * and no re-render. Display only: the real dismiss is the JS timer, so it degrades
24
- * to a full bar where custom-property animation is unsupported. Sticky
25
- * (`duration="0"`) runs no countdown; the var stays `1`.
26
- *
27
- * ## Dismiss from an action — `data-toast-dismiss`
28
- *
29
- * Any element inside the toast carrying `data-toast-dismiss` dismisses it on click
30
- * — the same convention as `<a-banner>`'s `data-banner-dismiss` and `<a-dialog>`'s
31
- * `data-dialog-close`. It's a click listener (a light-DOM READ, declarative-safe),
32
- * so it catches any activated control — native `<button>`, `<a>`, `<a-button>`,
33
- * `<a-menu-item>` — and keyboard activation for free. A toasted `<Banner>` instead
34
- * dismisses through its own `onDismiss` (wire it to `manager.dismiss(id)`); its
35
- * built-in ✕ and any `data-banner-dismiss` action ride that channel.
36
- *
37
- * It **never removes itself**. Dismissal — from the timer, a `data-toast-dismiss`
38
- * control, or the `leaving` attribute the wrapper sets for a programmatic
39
- * `dismiss` — fades the host out (an off-DOM `:state(leaving)`), then emits a
40
- * bubbling **`dismiss`**; the owner removes the node on that event. So the element
41
- * writes only its own shadow + internals, reads its own attributes (and, read-only,
42
- * the light DOM for the dismiss trigger), appends only its own (wrapper-supplied)
43
- * content node, and dispatches events.
44
- *
45
- * Shadow structure — the host IS the box (no wrappers):
46
- *
47
- * :host ← the fade/slide layer
48
- * <slot> ← the content
11
+ * A `data-toast-dismiss` control, timer expiry, or authored `leaving` attribute
12
+ * starts the exit. After it finishes, the element emits bubbling `dismiss` and
13
+ * its owner removes the toast. The element never removes itself.
49
14
  */
50
15
  export declare class AToastElement extends HTMLElementBase {
51
16
  #private;
@@ -64,7 +29,7 @@ export declare class AToastElement extends HTMLElementBase {
64
29
  restart(): void;
65
30
  /** Play the exit (shadow only), then emit a bubbling `dismiss`. The owner
66
31
  * removes the node on that event — the element never removes itself.
67
- * Idempotent. */
32
+ * Idempotent within each connection. */
68
33
  dismiss(): void;
69
34
  }
70
35
  export declare function register_a_toast(): void;