@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.
- package/LICENSE.md +14 -1
- package/README.md +9 -0
- package/dist/anta_helpers.d.ts +46 -30
- package/dist/anta_helpers.js +66 -25
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +2 -1353
- package/dist/components/Banner.d.ts +25 -40
- package/dist/components/Banner.js +15 -17
- package/dist/components/Breadcrumbs.d.ts +0 -1
- package/dist/components/Breadcrumbs.js +0 -1
- package/dist/components/Button.d.ts +2 -3
- package/dist/components/Button.js +1 -0
- package/dist/components/ButtonCopy.js +3 -2
- package/dist/components/Calendar.js +13 -13
- package/dist/components/Card.d.ts +9 -17
- package/dist/components/Card.js +50 -46
- package/dist/components/Dialog.d.ts +1 -0
- package/dist/components/Dialog.js +16 -10
- package/dist/components/Expander.d.ts +6 -21
- package/dist/components/Expander.js +24 -23
- package/dist/components/Icon.d.ts +8 -14
- package/dist/components/Input.d.ts +77 -96
- package/dist/components/Input.js +23 -27
- package/dist/components/InputAutocomplete.d.ts +29 -10
- package/dist/components/InputAutocomplete.js +25 -8
- package/dist/components/InputDate.d.ts +0 -1
- package/dist/components/InputDate.js +2 -3
- package/dist/components/InputTime.d.ts +10 -4
- package/dist/components/InputTime.js +20 -16
- package/dist/components/Loader.d.ts +2 -2
- package/dist/components/Menu.d.ts +5 -4
- package/dist/components/Menu.js +13 -8
- package/dist/components/MenuItem.js +1 -14
- package/dist/components/MenuItemCopy.js +2 -2
- package/dist/components/Panel.d.ts +3 -1
- package/dist/components/Panel.js +17 -11
- package/dist/components/Progress.d.ts +21 -23
- package/dist/components/Progress.js +13 -9
- package/dist/components/RadioGroup.js +6 -8
- package/dist/components/{select-parts.css → Select.css} +1 -1
- package/dist/components/Select.d.ts +53 -36
- package/dist/components/Select.js +53 -98
- package/dist/components/SelectFaceted.d.ts +7 -4
- package/dist/components/SelectFaceted.js +21 -10
- package/dist/components/Slider.d.ts +28 -11
- package/dist/components/Slider.js +20 -20
- package/dist/components/Steps.css +1 -1
- package/dist/components/Steps.d.ts +0 -1
- package/dist/components/Steps.js +1 -12
- package/dist/components/Tabs.d.ts +17 -20
- package/dist/components/Tabs.js +7 -9
- package/dist/components/Text.d.ts +55 -36
- package/dist/components/Text.js +35 -22
- package/dist/components/Title.d.ts +19 -27
- package/dist/components/Title.js +2 -1
- package/dist/components/Toaster.js +9 -2
- package/dist/components/Tooltip.d.ts +10 -15
- package/dist/components/copy-props.d.ts +14 -3
- package/dist/components/copy-props.js +14 -3
- package/dist/components/select-tree.d.ts +24 -0
- package/dist/components/select-tree.js +35 -0
- package/dist/element-base.d.ts +10 -0
- package/dist/element-base.js +15 -0
- package/dist/elements/a-avatar.css +1 -1
- package/dist/elements/a-avatar.js +2 -28
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-banner.d.ts +4 -1
- package/dist/elements/a-banner.js +22 -112
- package/dist/elements/a-breadcrumbs.d.ts +1 -0
- package/dist/elements/a-breadcrumbs.js +1 -0
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-button.d.ts +10 -7
- package/dist/elements/a-button.js +18 -1
- package/dist/elements/a-calendar.d.ts +14 -13
- package/dist/elements/a-calendar.js +29 -24
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-card.d.ts +0 -9
- package/dist/elements/a-card.js +0 -184
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-copy.css +1 -1
- package/dist/elements/a-copy.d.ts +1 -5
- package/dist/elements/a-copy.js +129 -108
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-dialog.d.ts +1 -1
- package/dist/elements/a-dialog.js +68 -194
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.d.ts +4 -30
- package/dist/elements/a-expander.js +85 -344
- package/dist/elements/a-icon.d.ts +5 -23
- package/dist/elements/a-icon.js +1 -2
- package/dist/elements/a-input-date.d.ts +1 -0
- package/dist/elements/a-input-date.js +1 -0
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.d.ts +2 -1
- package/dist/elements/a-input-time.js +101 -168
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.d.ts +10 -8
- package/dist/elements/a-input.js +155 -230
- package/dist/elements/a-loader.d.ts +5 -8
- package/dist/elements/a-loader.js +1 -2
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.d.ts +5 -3
- package/dist/elements/a-menu-item.js +5 -1
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.d.ts +5 -7
- package/dist/elements/a-menu.js +383 -299
- package/dist/elements/a-panel.css +1 -1
- package/dist/elements/a-panel.js +19 -37
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-progress.d.ts +0 -22
- package/dist/elements/a-progress.js +0 -100
- package/dist/elements/a-radio-group.d.ts +1 -1
- package/dist/elements/a-radio-group.js +6 -4
- package/dist/elements/a-select-faceted.d.ts +1 -0
- package/dist/elements/a-select-faceted.js +1 -0
- package/dist/elements/a-select.d.ts +1 -0
- package/dist/elements/a-select.js +1 -0
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-slider.d.ts +11 -3
- package/dist/elements/a-slider.js +244 -242
- package/dist/elements/a-steps.d.ts +1 -0
- package/dist/elements/a-steps.js +1 -0
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-tab.css +1 -1
- package/dist/elements/a-tabpanel.d.ts +2 -2
- package/dist/elements/a-tabpanel.js +13 -3
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.d.ts +1 -1
- package/dist/elements/a-tabs.js +6 -4
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-tag.d.ts +1 -0
- package/dist/elements/a-tag.js +1 -0
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-text.d.ts +6 -43
- package/dist/elements/a-text.js +110 -193
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-title.d.ts +1 -0
- package/dist/elements/a-title.js +1 -0
- package/dist/elements/a-toast.css +1 -1
- package/dist/elements/a-toast.d.ts +10 -45
- package/dist/elements/a-toast.js +80 -66
- package/dist/elements/a-toaster.css +1 -1
- package/dist/elements/a-toaster.js +9 -44
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +1 -1
- package/dist/elements/a-tooltip.js +142 -136
- package/dist/elements/copy-behavior.d.ts +1 -1
- package/dist/elements/copy-behavior.js +21 -21
- package/dist/elements/index.d.ts +9 -3
- package/dist/elements/index.js +6 -6
- package/dist/elements/input-focus-modality.d.ts +15 -0
- package/dist/elements/input-focus-modality.js +44 -0
- package/dist/elements/input-trailing-actions.d.ts +5 -0
- package/dist/elements/input-trailing-actions.js +38 -0
- package/dist/elements/shadow-aria.d.ts +2 -0
- package/dist/elements/shadow-aria.js +2 -1
- package/dist/elements/value-input.d.ts +3 -0
- package/dist/elements/value-input.js +12 -0
- package/dist/general_types.d.ts +103 -96
- package/dist/index.d.ts +1 -1
- package/dist/input-events.d.ts +4 -0
- package/dist/input-events.js +15 -0
- package/dist/jsx-runtime.d.ts +70 -23
- package/dist/jsx-runtime.js +26 -19
- package/dist/native-event-props.d.ts +2 -0
- package/dist/native-event-props.js +10 -0
- package/dist/reset.css +1 -1
- package/dist/theme-antithesis.css +10 -1
- package/dist/theme-antune.css +1 -1
- package/docs/accessibility.md +17 -3
- package/docs/changelog.md +384 -2
- package/docs/comparison.md +2 -2
- package/docs/components/avatar.md +5 -0
- package/docs/components/banner.md +117 -187
- package/docs/components/breadcrumbs.md +9 -6
- package/docs/components/button.md +22 -0
- package/docs/components/card.md +74 -28
- package/docs/components/checkbox.md +9 -10
- package/docs/components/dialog.md +83 -32
- package/docs/components/expander.md +198 -435
- package/docs/components/icon.md +11 -17
- package/docs/components/input-autocomplete.md +152 -52
- package/docs/components/input-date.md +175 -148
- package/docs/components/input-time.md +81 -38
- package/docs/components/input.md +343 -349
- package/docs/components/loader.md +2 -1
- package/docs/components/menu.md +35 -6
- package/docs/components/panel.md +18 -0
- package/docs/components/progress.md +83 -49
- package/docs/components/radio.md +39 -43
- package/docs/components/select-faceted.md +54 -7
- package/docs/components/select.md +390 -386
- package/docs/components/slider.md +136 -19
- package/docs/components/steps.md +6 -3
- package/docs/components/switch.md +8 -9
- package/docs/components/tabs.md +110 -104
- package/docs/components/text.md +110 -86
- package/docs/components/title.md +47 -33
- package/docs/components/toaster.md +242 -84
- package/docs/components/tooltip.md +204 -113
- package/docs/install-config.md +461 -96
- package/docs/packages/plot.md +228 -143
- package/docs/theming.md +29 -13
- package/package.json +43 -4
- package/theme-antithesis-license.md +66 -0
package/dist/elements/a-text.js
CHANGED
|
@@ -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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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.
|
|
124
|
-
|
|
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.
|
|
128
|
-
this.
|
|
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
|
|
133
|
-
this.
|
|
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 #
|
|
39
|
+
get #canExpand() {
|
|
140
40
|
return this.hasAttribute("truncate") && this.hasAttribute("expandable");
|
|
141
41
|
}
|
|
142
|
-
|
|
143
|
-
|
|
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
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this
|
|
162
|
-
this.
|
|
163
|
-
|
|
164
|
-
this
|
|
165
|
-
|
|
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
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
this
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
this.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this
|
|
183
|
-
this
|
|
184
|
-
this
|
|
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
|
-
|
|
188
|
-
this
|
|
189
|
-
this
|
|
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
|
-
|
|
193
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (!
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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:
|
|
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
|
-
*
|
|
5
|
-
*
|
|
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
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
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;
|