@antadesign/anta 0.3.25 → 0.3.26
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/dist/anta_helpers.js +3 -3
- package/dist/box-types.d.ts +161 -0
- package/dist/box-types.js +0 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +25 -25
- package/dist/components/Box.d.ts +37 -0
- package/dist/components/Box.js +63 -0
- package/dist/elements/a-avatar.css +1 -1
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-banner.js +4 -4
- package/dist/elements/a-box.css +1 -0
- package/dist/elements/a-box.d.ts +41 -0
- package/dist/elements/a-box.js +576 -0
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-calendar.js +2 -2
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.js +2 -2
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.js +3 -3
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.js +6 -6
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.js +3 -3
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.js +2 -2
- package/dist/elements/a-radio-group.js +3 -3
- package/dist/elements/a-radio.css +1 -1
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-switch.js +2 -2
- package/dist/elements/a-tabpanel.js +2 -2
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.js +6 -6
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-toast.js +2 -2
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +4 -3
- package/dist/elements/a-tooltip.js +9 -5
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/index.js +3 -0
- package/dist/general_types.d.ts +36 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/jsx-runtime.d.ts +2 -1
- package/docs/changelog.md +23 -3
- package/docs/components/avatar.md +368 -0
- package/docs/components/box.md +282 -0
- package/docs/index.md +4 -3
- package/package.json +1 -1
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
import { HTMLElementBase } from "../anta_helpers";
|
|
2
|
+
import "./a-box.css";
|
|
3
|
+
const stores = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
const MODE_CLASS = /(?:^|\s)(?:dark|light)(?:\s|$)/;
|
|
5
|
+
function hasModeClass(element) {
|
|
6
|
+
return element.classList.contains("dark") || element.classList.contains("light");
|
|
7
|
+
}
|
|
8
|
+
class BoxWindowStore {
|
|
9
|
+
constructor(view, doc) {
|
|
10
|
+
this.view = view;
|
|
11
|
+
this.doc = doc;
|
|
12
|
+
this.#dark = view.matchMedia("(prefers-color-scheme: dark)");
|
|
13
|
+
this.#finePointer = view.matchMedia("(pointer: fine)");
|
|
14
|
+
this.#coarsePointer = view.matchMedia("(pointer: coarse)");
|
|
15
|
+
this.#hover = view.matchMedia("(hover: hover)");
|
|
16
|
+
this.#reducedMotion = view.matchMedia("(prefers-reduced-motion: reduce)");
|
|
17
|
+
this.#queries = [this.#dark, this.#finePointer, this.#coarsePointer, this.#hover, this.#reducedMotion];
|
|
18
|
+
this.#device = deviceSnapshot(view.navigator);
|
|
19
|
+
}
|
|
20
|
+
#contextBoxes = /* @__PURE__ */ new Set();
|
|
21
|
+
#observedBoxes = /* @__PURE__ */ new Set();
|
|
22
|
+
#dark;
|
|
23
|
+
#finePointer;
|
|
24
|
+
#coarsePointer;
|
|
25
|
+
#hover;
|
|
26
|
+
#reducedMotion;
|
|
27
|
+
#queries;
|
|
28
|
+
#classObserver;
|
|
29
|
+
#visibility;
|
|
30
|
+
#pixelRatio;
|
|
31
|
+
#lastPixelRatio = 0;
|
|
32
|
+
#device;
|
|
33
|
+
/** Only a box with a `contextchange` listener subscribes, so a page that never
|
|
34
|
+
* reads context pays for no media listeners and no document observer. */
|
|
35
|
+
subscribeContext(box) {
|
|
36
|
+
if (this.#contextBoxes.size === 0) this.#startWatching();
|
|
37
|
+
this.#contextBoxes.add(box);
|
|
38
|
+
}
|
|
39
|
+
unsubscribeContext(box) {
|
|
40
|
+
if (!this.#contextBoxes.delete(box)) return;
|
|
41
|
+
if (this.#contextBoxes.size === 0) this.#stopWatching();
|
|
42
|
+
this.#collect();
|
|
43
|
+
}
|
|
44
|
+
/** Only a box that measures is tracked, and it measures only while on screen. */
|
|
45
|
+
observeVisibility(box) {
|
|
46
|
+
if (this.#observedBoxes.has(box)) return;
|
|
47
|
+
if (typeof this.view.IntersectionObserver === "undefined") {
|
|
48
|
+
box.visibilityDidChange(true);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.#visibility ??= new this.view.IntersectionObserver(
|
|
52
|
+
(entries) => {
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
const box2 = entry.target;
|
|
55
|
+
if (this.#observedBoxes.has(box2)) box2.visibilityDidChange(entry.isIntersecting);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{ root: null, rootMargin: "0px", threshold: 0 }
|
|
59
|
+
);
|
|
60
|
+
this.#observedBoxes.add(box);
|
|
61
|
+
this.#visibility.observe(box);
|
|
62
|
+
}
|
|
63
|
+
unobserveVisibility(box) {
|
|
64
|
+
if (!this.#observedBoxes.delete(box)) return;
|
|
65
|
+
this.#visibility?.unobserve(box);
|
|
66
|
+
if (this.#observedBoxes.size === 0) {
|
|
67
|
+
this.#visibility?.disconnect();
|
|
68
|
+
this.#visibility = void 0;
|
|
69
|
+
}
|
|
70
|
+
this.#collect();
|
|
71
|
+
}
|
|
72
|
+
snapshot() {
|
|
73
|
+
return {
|
|
74
|
+
globalMode: modeFromElement(this.doc.documentElement),
|
|
75
|
+
systemAppearance: this.#dark.matches ? "dark" : "light",
|
|
76
|
+
...this.#device,
|
|
77
|
+
pointer: this.#finePointer.matches ? "fine" : this.#coarsePointer.matches ? "coarse" : "none",
|
|
78
|
+
hover: this.#hover.matches,
|
|
79
|
+
reducedMotion: this.#reducedMotion.matches,
|
|
80
|
+
devicePixelRatio: this.view.devicePixelRatio
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/* devicePixelRatio has no change event of its own, so two signals cover it.
|
|
84
|
+
A resolution query pinned to the current value stops matching the moment
|
|
85
|
+
the ratio moves; each fire re-arms against the new value. Page zoom also
|
|
86
|
+
resizes the CSS viewport, and `resize` catches the engines and paths where
|
|
87
|
+
the query stays quiet. Both funnel through the same guard, so whichever
|
|
88
|
+
arrives first reports and the other is a no-op. */
|
|
89
|
+
#watchPixelRatio() {
|
|
90
|
+
this.#pixelRatio?.removeEventListener("change", this.#pixelRatioDidChange);
|
|
91
|
+
this.#pixelRatio = this.view.matchMedia(`(resolution: ${this.view.devicePixelRatio}dppx)`);
|
|
92
|
+
this.#pixelRatio.addEventListener("change", this.#pixelRatioDidChange, { once: true });
|
|
93
|
+
this.#lastPixelRatio = this.view.devicePixelRatio;
|
|
94
|
+
}
|
|
95
|
+
#pixelRatioDidChange = () => {
|
|
96
|
+
if (this.view.devicePixelRatio === this.#lastPixelRatio) return;
|
|
97
|
+
this.#watchPixelRatio();
|
|
98
|
+
this.#notifyAll();
|
|
99
|
+
};
|
|
100
|
+
#startWatching() {
|
|
101
|
+
for (const query of this.#queries) query.addEventListener("change", this.#notifyAll);
|
|
102
|
+
this.#watchPixelRatio();
|
|
103
|
+
this.view.addEventListener("resize", this.#pixelRatioDidChange, { passive: true });
|
|
104
|
+
const root = this.doc.documentElement;
|
|
105
|
+
if (!root) return;
|
|
106
|
+
this.#classObserver = new this.view.MutationObserver(this.#handleClassChange);
|
|
107
|
+
this.#classObserver.observe(root, {
|
|
108
|
+
subtree: true,
|
|
109
|
+
attributes: true,
|
|
110
|
+
attributeOldValue: true,
|
|
111
|
+
attributeFilter: ["class"]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
#stopWatching() {
|
|
115
|
+
for (const query of this.#queries) query.removeEventListener("change", this.#notifyAll);
|
|
116
|
+
this.#pixelRatio?.removeEventListener("change", this.#pixelRatioDidChange);
|
|
117
|
+
this.#pixelRatio = void 0;
|
|
118
|
+
this.view.removeEventListener("resize", this.#pixelRatioDidChange);
|
|
119
|
+
this.#classObserver?.disconnect();
|
|
120
|
+
this.#classObserver = void 0;
|
|
121
|
+
}
|
|
122
|
+
#collect() {
|
|
123
|
+
if (this.#contextBoxes.size === 0 && this.#observedBoxes.size === 0) stores.delete(this.view);
|
|
124
|
+
}
|
|
125
|
+
/* Only `dark` and `light` change what a box reports. Every other class toggle
|
|
126
|
+
on the page — a route class, a scroll lock, a theme-unrelated modifier —
|
|
127
|
+
is dropped here, before the ancestor scan runs. */
|
|
128
|
+
#handleClassChange = (records) => {
|
|
129
|
+
const affected = /* @__PURE__ */ new Set();
|
|
130
|
+
for (const record of records) {
|
|
131
|
+
const target = record.target;
|
|
132
|
+
if (!(target instanceof this.view.Element)) continue;
|
|
133
|
+
if (!hasModeClass(target) && !MODE_CLASS.test(record.oldValue ?? "")) continue;
|
|
134
|
+
for (const box of this.#contextBoxes) {
|
|
135
|
+
if (target === box || target.contains(box)) affected.add(box);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
for (const box of affected) box.contextStoreDidChange();
|
|
139
|
+
};
|
|
140
|
+
#notifyAll = () => {
|
|
141
|
+
for (const box of this.#contextBoxes) box.contextStoreDidChange();
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function windowStore(view, doc) {
|
|
145
|
+
let store = stores.get(view);
|
|
146
|
+
if (!store) {
|
|
147
|
+
store = new BoxWindowStore(view, doc);
|
|
148
|
+
stores.set(view, store);
|
|
149
|
+
}
|
|
150
|
+
return store;
|
|
151
|
+
}
|
|
152
|
+
function modeFromElement(element) {
|
|
153
|
+
return element?.classList.contains("dark") ? "dark" : "light";
|
|
154
|
+
}
|
|
155
|
+
function localMode(element) {
|
|
156
|
+
for (let current = element; current; current = current.parentElement) {
|
|
157
|
+
if (current.classList.contains("dark")) return "dark";
|
|
158
|
+
if (current.classList.contains("light")) return "light";
|
|
159
|
+
}
|
|
160
|
+
return modeFromElement(element.ownerDocument.documentElement);
|
|
161
|
+
}
|
|
162
|
+
const BROWSER_VERSION = {
|
|
163
|
+
edge: /edg[ea]?\/(\d+)/,
|
|
164
|
+
opera: /opr\/(\d+)/,
|
|
165
|
+
firefox: /(?:firefox|fxios)\/(\d+)/,
|
|
166
|
+
chrome: /(?:chrome|crios)\/(\d+)/,
|
|
167
|
+
safari: /version\/(\d+)/,
|
|
168
|
+
unknown: /(?!)/
|
|
169
|
+
};
|
|
170
|
+
const OS_VERSION = {
|
|
171
|
+
windows: /windows nt ([\d.]+)/,
|
|
172
|
+
macos: /mac os x (\d+[._]\d+(?:[._]\d+)?)/,
|
|
173
|
+
ios: /os (\d+[._]\d+(?:[._]\d+)?)/,
|
|
174
|
+
android: /android (\d+(?:\.\d+)*)/
|
|
175
|
+
};
|
|
176
|
+
function deviceSnapshot(navigator) {
|
|
177
|
+
const uaData = navigator;
|
|
178
|
+
const ua = (navigator.userAgent ?? "").toLowerCase();
|
|
179
|
+
const source = `${uaData.userAgentData?.platform ?? ""} ${navigator.platform ?? ""} ${ua}`.toLowerCase();
|
|
180
|
+
const os = /android/.test(source) ? "android" : /iphone|ipad|ipod|ios/.test(source) ? "ios" : /mac/.test(source) ? "macos" : /win/.test(source) ? "windows" : /linux/.test(source) ? "linux" : "unknown";
|
|
181
|
+
const browser = /edg[ea]?\//.test(ua) ? "edge" : /opr\/|opera/.test(ua) ? "opera" : /firefox\/|fxios\//.test(ua) ? "firefox" : /chrome\/|crios\//.test(ua) ? "chrome" : /safari\//.test(ua) ? "safari" : "unknown";
|
|
182
|
+
const brands = uaData.userAgentData?.brands ?? [];
|
|
183
|
+
const branded = brands.filter((b) => !/not.a.brand/i.test(b.brand)).sort((a, b) => Number(/chromium/i.test(a.brand)) - Number(/chromium/i.test(b.brand)))[0];
|
|
184
|
+
return {
|
|
185
|
+
os,
|
|
186
|
+
osVersion: parseInt(ua.match(OS_VERSION[os] ?? /(?!)/)?.[1] ?? "", 10) || 0,
|
|
187
|
+
browser,
|
|
188
|
+
browserVersion: Number(branded?.version ?? ua.match(BROWSER_VERSION[browser])?.[1]) || 0,
|
|
189
|
+
mobile: uaData.userAgentData?.mobile ?? /android|mobi|iphone|ipad|ipod/.test(source)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function equal(a, b) {
|
|
193
|
+
if (a === b) return true;
|
|
194
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
195
|
+
const left = a;
|
|
196
|
+
const right = b;
|
|
197
|
+
const keys = Object.keys(left);
|
|
198
|
+
return keys.length === Object.keys(right).length && keys.every((key) => left[key] === right[key]);
|
|
199
|
+
}
|
|
200
|
+
function same(a, b) {
|
|
201
|
+
return a !== void 0 && Object.keys(b).every((key) => equal(a[key], b[key]));
|
|
202
|
+
}
|
|
203
|
+
function changed(previous, current) {
|
|
204
|
+
if (!previous) return { ...current };
|
|
205
|
+
return Object.fromEntries(
|
|
206
|
+
Object.entries(current).filter(([key, value]) => !equal(previous[key], value))
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
function px(value) {
|
|
210
|
+
return parseFloat(value) || 0;
|
|
211
|
+
}
|
|
212
|
+
function readInset(styles) {
|
|
213
|
+
return {
|
|
214
|
+
paddingTop: px(styles.paddingTop),
|
|
215
|
+
paddingRight: px(styles.paddingRight),
|
|
216
|
+
paddingBottom: px(styles.paddingBottom),
|
|
217
|
+
paddingLeft: px(styles.paddingLeft),
|
|
218
|
+
borderTop: px(styles.borderTopWidth),
|
|
219
|
+
borderRight: px(styles.borderRightWidth),
|
|
220
|
+
borderBottom: px(styles.borderBottomWidth),
|
|
221
|
+
borderLeft: px(styles.borderLeftWidth)
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function spacing(value) {
|
|
225
|
+
return value === "normal" ? "0px" : value;
|
|
226
|
+
}
|
|
227
|
+
function readFont(styles) {
|
|
228
|
+
const lineHeightPx = parseFloat(styles.lineHeight);
|
|
229
|
+
const lineHeight = Number.isFinite(lineHeightPx) ? lineHeightPx : null;
|
|
230
|
+
const style = styles.fontStyle && styles.fontStyle !== "normal" ? `${styles.fontStyle} ` : "";
|
|
231
|
+
const weight = styles.fontWeight && styles.fontWeight !== "400" ? `${styles.fontWeight} ` : "";
|
|
232
|
+
const height = lineHeight != null ? `/${lineHeight}px` : "";
|
|
233
|
+
return {
|
|
234
|
+
shorthand: `${style}${weight}${styles.fontSize}${height} ${styles.fontFamily}`,
|
|
235
|
+
family: styles.fontFamily,
|
|
236
|
+
size: parseFloat(styles.fontSize) || 0,
|
|
237
|
+
weight: parseFloat(styles.fontWeight) || 400,
|
|
238
|
+
style: styles.fontStyle,
|
|
239
|
+
stretch: styles.fontStretch,
|
|
240
|
+
lineHeight,
|
|
241
|
+
letterSpacing: spacing(styles.letterSpacing),
|
|
242
|
+
wordSpacing: spacing(styles.wordSpacing),
|
|
243
|
+
color: styles.color,
|
|
244
|
+
featureSettings: styles.fontFeatureSettings,
|
|
245
|
+
variationSettings: styles.fontVariationSettings,
|
|
246
|
+
kerning: styles.fontKerning,
|
|
247
|
+
variantCaps: styles.fontVariantCaps,
|
|
248
|
+
textRendering: styles.textRendering,
|
|
249
|
+
direction: styles.direction
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function rounded(value) {
|
|
253
|
+
return Math.round(value * 100) / 100;
|
|
254
|
+
}
|
|
255
|
+
class ABoxElement extends HTMLElementBase {
|
|
256
|
+
static observedAttributes = ["fade", "observe"];
|
|
257
|
+
#internals = this.attachInternals?.();
|
|
258
|
+
#store;
|
|
259
|
+
#resizeObserver;
|
|
260
|
+
#contentObserver;
|
|
261
|
+
#hostObserver;
|
|
262
|
+
#frame;
|
|
263
|
+
#contextQueued = false;
|
|
264
|
+
#measurement;
|
|
265
|
+
#context;
|
|
266
|
+
#measuring = false;
|
|
267
|
+
#clips = false;
|
|
268
|
+
#observedChildren = /* @__PURE__ */ new Set();
|
|
269
|
+
#reportingContext = false;
|
|
270
|
+
/* Undefined until the visibility observer first reports. `fade` is the one
|
|
271
|
+
thing that cannot wait for it — the mask is painted from the CSS states, so
|
|
272
|
+
a box that deferred its first measurement would flash unmasked. Everything
|
|
273
|
+
else stays idle until it is known to be on screen, which keeps a page of
|
|
274
|
+
hundreds of boxes from measuring every one of them once at connect only to
|
|
275
|
+
tear it all down a frame later. */
|
|
276
|
+
#visible;
|
|
277
|
+
#initialMeasurement = false;
|
|
278
|
+
#initialContext = false;
|
|
279
|
+
connectedCallback() {
|
|
280
|
+
this.#store = windowStore(this.view, this.doc);
|
|
281
|
+
this.#sync();
|
|
282
|
+
}
|
|
283
|
+
disconnectedCallback() {
|
|
284
|
+
this.#stopMeasuring();
|
|
285
|
+
this.#stopReportingContext();
|
|
286
|
+
this.#store?.unobserveVisibility(this);
|
|
287
|
+
this.#store = void 0;
|
|
288
|
+
this.#visible = void 0;
|
|
289
|
+
}
|
|
290
|
+
/* Guarded on the store, not on `isConnected`: upgrading an element that is
|
|
291
|
+
already in the document runs this for every present attribute *before*
|
|
292
|
+
connectedCallback, when there is no store yet. Syncing then would flip the
|
|
293
|
+
started flags while `this.#store?.subscribeContext` silently did nothing,
|
|
294
|
+
and the later connect would see the flags already set and skip it. */
|
|
295
|
+
attributeChangedCallback() {
|
|
296
|
+
if (this.#store) this.#sync();
|
|
297
|
+
}
|
|
298
|
+
/** A fresh measurement snapshot. For notifications, prefer `measurechange`:
|
|
299
|
+
* it batches browser observers and includes the field-level delta. */
|
|
300
|
+
get measurement() {
|
|
301
|
+
return this.#readMeasurement();
|
|
302
|
+
}
|
|
303
|
+
/** A fresh context snapshot. For changes, prefer `contextchange`. */
|
|
304
|
+
get context() {
|
|
305
|
+
return this.#readContext();
|
|
306
|
+
}
|
|
307
|
+
/** Allows a nested `Tooltip truncatedOnly` to use Box's clipping decision. */
|
|
308
|
+
get isTruncated() {
|
|
309
|
+
const measurement = this.#readMeasurement();
|
|
310
|
+
return measurement.clippedX || measurement.clippedY;
|
|
311
|
+
}
|
|
312
|
+
/** Called by the per-window context cache. It is intentionally not a JSX prop. */
|
|
313
|
+
contextStoreDidChange() {
|
|
314
|
+
this.#queueContext();
|
|
315
|
+
this.#queueMeasurement();
|
|
316
|
+
}
|
|
317
|
+
/** Called by the per-window visibility observer. Also not a JSX prop. */
|
|
318
|
+
visibilityDidChange(visible) {
|
|
319
|
+
if (this.#visible === visible) return;
|
|
320
|
+
this.#visible = visible;
|
|
321
|
+
this.#sync();
|
|
322
|
+
}
|
|
323
|
+
/* Nothing observes until something wants the answer, and a box scrolled off
|
|
324
|
+
screen wants nothing until it comes back. Context reporting ignores
|
|
325
|
+
visibility: a mode change has to reach an off-screen box too, and the store
|
|
326
|
+
it subscribes to is already refcounted down to nothing. */
|
|
327
|
+
#sync() {
|
|
328
|
+
const observe = this.getAttribute("observe");
|
|
329
|
+
const both = observe === "" || observe === "all";
|
|
330
|
+
const wantsMeasurement = this.hasAttribute("fade") || both || observe === "size";
|
|
331
|
+
const wantsContext = both || observe === "context";
|
|
332
|
+
const measure = this.isConnected && wantsMeasurement && (this.#visible ?? this.hasAttribute("fade"));
|
|
333
|
+
if (measure) this.#startMeasuring();
|
|
334
|
+
else this.#stopMeasuring();
|
|
335
|
+
if (this.isConnected && wantsMeasurement) this.#store?.observeVisibility(this);
|
|
336
|
+
else this.#store?.unobserveVisibility(this);
|
|
337
|
+
if (this.isConnected && wantsContext) this.#startReportingContext();
|
|
338
|
+
else this.#stopReportingContext();
|
|
339
|
+
this.#syncHostObserver();
|
|
340
|
+
}
|
|
341
|
+
/* The host's own attributes need their own observer: one observer cannot take
|
|
342
|
+
`subtree: true` for childList and `subtree: false` for attributes on the
|
|
343
|
+
same target. A class on this box can flip it to `overflow: auto` without
|
|
344
|
+
changing its size, and can restyle its text, so both halves want to know. */
|
|
345
|
+
#syncHostObserver() {
|
|
346
|
+
const wanted = this.#measuring || this.#reportingContext;
|
|
347
|
+
if (wanted === Boolean(this.#hostObserver)) return;
|
|
348
|
+
if (wanted) {
|
|
349
|
+
this.#hostObserver = new this.view.MutationObserver(this.#hostDidChange);
|
|
350
|
+
this.#hostObserver.observe(this, { attributes: true });
|
|
351
|
+
} else {
|
|
352
|
+
this.#hostObserver?.disconnect();
|
|
353
|
+
this.#hostObserver = void 0;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
#hostDidChange = () => {
|
|
357
|
+
this.#queueMeasurement();
|
|
358
|
+
this.#queueContext();
|
|
359
|
+
};
|
|
360
|
+
#startMeasuring() {
|
|
361
|
+
if (this.#measuring) return;
|
|
362
|
+
this.#measuring = true;
|
|
363
|
+
this.#resizeObserver = new this.view.ResizeObserver(this.#queueMeasurement);
|
|
364
|
+
this.#resizeObserver.observe(this);
|
|
365
|
+
this.#contentObserver = new this.view.MutationObserver(this.#queueMeasurement);
|
|
366
|
+
this.#contentObserver.observe(this, {
|
|
367
|
+
subtree: true,
|
|
368
|
+
childList: true,
|
|
369
|
+
characterData: true
|
|
370
|
+
});
|
|
371
|
+
this.addEventListener("input", this.#queueMeasurement);
|
|
372
|
+
this.addEventListener("scroll", this.#queueMeasurement, { passive: true });
|
|
373
|
+
this.addEventListener("load", this.#queueMeasurement, true);
|
|
374
|
+
this.doc.fonts?.addEventListener("loadingdone", this.#queueMeasurement);
|
|
375
|
+
this.#measurement = this.#readMeasurement();
|
|
376
|
+
this.#setMeasurementStates(this.#measurement);
|
|
377
|
+
this.#syncChildObservation();
|
|
378
|
+
this.#initialMeasurement = true;
|
|
379
|
+
this.#queueMeasurement();
|
|
380
|
+
}
|
|
381
|
+
/* A clipping box's scroll size can move because a child's own size moved for
|
|
382
|
+
a reason nothing else here can see: a late upgrade attaching a shadow root,
|
|
383
|
+
or a child resizing from its own internal state (an Expander opening).
|
|
384
|
+
Neither is a light-DOM mutation, and a fixed-size box never resizes, so the
|
|
385
|
+
direct children go into the same ResizeObserver. A box with visible
|
|
386
|
+
overflow hides nothing — a growing child just grows the box, which its own
|
|
387
|
+
entry already reports — so it observes no children at all. */
|
|
388
|
+
#syncChildObservation() {
|
|
389
|
+
if (!this.#clips || !this.#measuring) {
|
|
390
|
+
for (const child of this.#observedChildren) this.#resizeObserver?.unobserve(child);
|
|
391
|
+
this.#observedChildren.clear();
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const current = new Set(this.children);
|
|
395
|
+
for (const child of this.#observedChildren) {
|
|
396
|
+
if (current.has(child)) continue;
|
|
397
|
+
this.#resizeObserver?.unobserve(child);
|
|
398
|
+
this.#observedChildren.delete(child);
|
|
399
|
+
}
|
|
400
|
+
for (const child of current) {
|
|
401
|
+
if (this.#observedChildren.has(child)) continue;
|
|
402
|
+
this.#resizeObserver?.observe(child);
|
|
403
|
+
this.#observedChildren.add(child);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
#stopMeasuring() {
|
|
407
|
+
if (!this.#measuring) return;
|
|
408
|
+
this.#measuring = false;
|
|
409
|
+
this.#observedChildren.clear();
|
|
410
|
+
this.#resizeObserver?.disconnect();
|
|
411
|
+
this.#resizeObserver = void 0;
|
|
412
|
+
this.#contentObserver?.disconnect();
|
|
413
|
+
this.#contentObserver = void 0;
|
|
414
|
+
if (this.#frame != null) this.view.cancelAnimationFrame(this.#frame);
|
|
415
|
+
this.#frame = void 0;
|
|
416
|
+
this.removeEventListener("input", this.#queueMeasurement);
|
|
417
|
+
this.removeEventListener("scroll", this.#queueMeasurement);
|
|
418
|
+
this.removeEventListener("load", this.#queueMeasurement, true);
|
|
419
|
+
this.doc.fonts?.removeEventListener("loadingdone", this.#queueMeasurement);
|
|
420
|
+
}
|
|
421
|
+
#startReportingContext() {
|
|
422
|
+
if (this.#reportingContext) return;
|
|
423
|
+
this.#reportingContext = true;
|
|
424
|
+
this.#store?.subscribeContext(this);
|
|
425
|
+
this.addEventListener("focusin", this.#queueContext);
|
|
426
|
+
this.addEventListener("focusout", this.#handleFocusOut);
|
|
427
|
+
this.doc.fonts?.addEventListener("loadingdone", this.#queueContext);
|
|
428
|
+
this.#initialContext = true;
|
|
429
|
+
this.#queueContext();
|
|
430
|
+
}
|
|
431
|
+
#stopReportingContext() {
|
|
432
|
+
if (!this.#reportingContext) return;
|
|
433
|
+
this.#reportingContext = false;
|
|
434
|
+
this.#store?.unsubscribeContext(this);
|
|
435
|
+
this.removeEventListener("focusin", this.#queueContext);
|
|
436
|
+
this.removeEventListener("focusout", this.#handleFocusOut);
|
|
437
|
+
this.doc.fonts?.removeEventListener("loadingdone", this.#queueContext);
|
|
438
|
+
}
|
|
439
|
+
/* Tabbing between two descendants fires focusout then focusin, and WebKit runs
|
|
440
|
+
a microtask checkpoint between the two — long enough to report a
|
|
441
|
+
focusWithin: false that was never true for the reader. `relatedTarget` is
|
|
442
|
+
where focus is heading (retargeted to the host for a shadow child), so a
|
|
443
|
+
move that stays inside is not a change at all. */
|
|
444
|
+
#handleFocusOut = (event) => {
|
|
445
|
+
const next = event.relatedTarget;
|
|
446
|
+
if (next instanceof this.view.Node && this.contains(next)) return;
|
|
447
|
+
this.#queueContext();
|
|
448
|
+
};
|
|
449
|
+
#queueMeasurement = () => {
|
|
450
|
+
if (!this.#measuring || this.#frame != null) return;
|
|
451
|
+
this.#frame = this.view.requestAnimationFrame(() => {
|
|
452
|
+
this.#frame = void 0;
|
|
453
|
+
if (!this.#measuring) return;
|
|
454
|
+
const initial = this.#initialMeasurement;
|
|
455
|
+
this.#initialMeasurement = false;
|
|
456
|
+
this.#reportMeasurement(initial);
|
|
457
|
+
});
|
|
458
|
+
};
|
|
459
|
+
#queueContext = () => {
|
|
460
|
+
if (!this.#reportingContext || this.#contextQueued) return;
|
|
461
|
+
this.#contextQueued = true;
|
|
462
|
+
queueMicrotask(() => {
|
|
463
|
+
this.#contextQueued = false;
|
|
464
|
+
if (!this.#reportingContext) return;
|
|
465
|
+
const initial = this.#initialContext;
|
|
466
|
+
this.#initialContext = false;
|
|
467
|
+
this.#reportContext(initial);
|
|
468
|
+
});
|
|
469
|
+
};
|
|
470
|
+
#readMeasurement() {
|
|
471
|
+
const rect = this.getBoundingClientRect();
|
|
472
|
+
const clientWidth = this.clientWidth;
|
|
473
|
+
const clientHeight = this.clientHeight;
|
|
474
|
+
const scrollWidth = this.scrollWidth;
|
|
475
|
+
const scrollHeight = this.scrollHeight;
|
|
476
|
+
const hasBox = clientWidth > 0 || clientHeight > 0;
|
|
477
|
+
const overflowX = hasBox && scrollWidth > clientWidth + 1;
|
|
478
|
+
const overflowY = hasBox && scrollHeight > clientHeight + 1;
|
|
479
|
+
const styles = this.view.getComputedStyle(this);
|
|
480
|
+
this.#clips = styles.overflowX !== "visible" || styles.overflowY !== "visible";
|
|
481
|
+
const clippedX = overflowX && styles.overflowX !== "visible";
|
|
482
|
+
const clippedY = overflowY && styles.overflowY !== "visible";
|
|
483
|
+
const scrollableX = overflowX && (styles.overflowX === "auto" || styles.overflowX === "scroll");
|
|
484
|
+
const scrollableY = overflowY && (styles.overflowY === "auto" || styles.overflowY === "scroll");
|
|
485
|
+
const scrollLeft = Math.round(this.scrollLeft);
|
|
486
|
+
const scrollTop = Math.round(this.scrollTop);
|
|
487
|
+
const fromStartX = Math.max(0, styles.direction === "rtl" ? -scrollLeft : scrollLeft);
|
|
488
|
+
const fromStartY = Math.max(0, scrollTop);
|
|
489
|
+
return {
|
|
490
|
+
width: rounded(rect.width),
|
|
491
|
+
height: rounded(rect.height),
|
|
492
|
+
clientWidth,
|
|
493
|
+
clientHeight,
|
|
494
|
+
scrollWidth,
|
|
495
|
+
scrollHeight,
|
|
496
|
+
overflowX,
|
|
497
|
+
overflowY,
|
|
498
|
+
clippedX,
|
|
499
|
+
clippedY,
|
|
500
|
+
scrollableX,
|
|
501
|
+
scrollableY,
|
|
502
|
+
scrollLeft,
|
|
503
|
+
scrollTop,
|
|
504
|
+
hiddenStartX: clippedX && fromStartX > 1,
|
|
505
|
+
hiddenEndX: clippedX && fromStartX < scrollWidth - clientWidth - 1,
|
|
506
|
+
hiddenStartY: clippedY && fromStartY > 1,
|
|
507
|
+
hiddenEndY: clippedY && fromStartY < scrollHeight - clientHeight - 1
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
#readContext() {
|
|
511
|
+
const shared = (this.#store ?? windowStore(this.view, this.doc)).snapshot();
|
|
512
|
+
const styles = this.view.getComputedStyle(this);
|
|
513
|
+
return {
|
|
514
|
+
...shared,
|
|
515
|
+
mode: localMode(this),
|
|
516
|
+
focusWithin: this.matches(":focus-within"),
|
|
517
|
+
font: readFont(styles),
|
|
518
|
+
inset: readInset(styles),
|
|
519
|
+
backgroundColor: styles.backgroundColor
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
#reportMeasurement(initial) {
|
|
523
|
+
const current = this.#readMeasurement();
|
|
524
|
+
const previous = this.#measurement;
|
|
525
|
+
this.#measurement = current;
|
|
526
|
+
this.#setMeasurementStates(current);
|
|
527
|
+
this.#syncChildObservation();
|
|
528
|
+
if (!initial && same(previous, current)) return;
|
|
529
|
+
const detail = {
|
|
530
|
+
changed: initial ? { ...current } : changed(previous, current),
|
|
531
|
+
current
|
|
532
|
+
};
|
|
533
|
+
this.dispatchEvent(new this.view.CustomEvent("measurechange", { detail }));
|
|
534
|
+
}
|
|
535
|
+
#reportContext(initial) {
|
|
536
|
+
const current = this.#readContext();
|
|
537
|
+
const previous = this.#context;
|
|
538
|
+
this.#context = current;
|
|
539
|
+
if (!initial && same(previous, current)) return;
|
|
540
|
+
const detail = {
|
|
541
|
+
changed: initial ? { ...current } : changed(previous, current),
|
|
542
|
+
current
|
|
543
|
+
};
|
|
544
|
+
this.dispatchEvent(new this.view.CustomEvent("contextchange", { detail }));
|
|
545
|
+
}
|
|
546
|
+
/* Only measurement states exist. Everything the context reports has a native
|
|
547
|
+
CSS equivalent — `:focus-within` for focus, the `.dark` ancestor class for
|
|
548
|
+
mode, `prefers-color-scheme` / `pointer` / `hover` / `prefers-reduced-motion`
|
|
549
|
+
media queries for the rest — so `contextchange` is a JS-side event only.
|
|
550
|
+
Overflow is the one thing CSS cannot ask about, which is what these are for. */
|
|
551
|
+
#setMeasurementStates(measurement) {
|
|
552
|
+
this.#setState("overflow-x", measurement.overflowX);
|
|
553
|
+
this.#setState("overflow-y", measurement.overflowY);
|
|
554
|
+
this.#setState("clipped-x", measurement.clippedX);
|
|
555
|
+
this.#setState("clipped-y", measurement.clippedY);
|
|
556
|
+
this.#setState("scrollable-x", measurement.scrollableX);
|
|
557
|
+
this.#setState("scrollable-y", measurement.scrollableY);
|
|
558
|
+
this.#setState("hidden-start-x", measurement.hiddenStartX);
|
|
559
|
+
this.#setState("hidden-end-x", measurement.hiddenEndX);
|
|
560
|
+
this.#setState("hidden-start-y", measurement.hiddenStartY);
|
|
561
|
+
this.#setState("hidden-end-y", measurement.hiddenEndY);
|
|
562
|
+
}
|
|
563
|
+
#setState(name, active) {
|
|
564
|
+
if (active) this.#internals?.states?.add(name);
|
|
565
|
+
else this.#internals?.states?.delete(name);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function register_a_box() {
|
|
569
|
+
if (typeof customElements === "undefined") return;
|
|
570
|
+
if (!customElements.get("a-box")) customElements.define("a-box", ABoxElement);
|
|
571
|
+
}
|
|
572
|
+
register_a_box();
|
|
573
|
+
export {
|
|
574
|
+
ABoxElement,
|
|
575
|
+
register_a_box
|
|
576
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer anta.components{a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]){--button-primary-fg: #ffffff;--bg-primary-disabled: #ece9ec;--bg-secondary-disabled: #f6f4f6;--fg-disabled-primary: #afa9b1;--fg-disabled: #afa9b1;--button-loading-stripe: 14px;--button-loading-stripe-gap: 16px;--button-loading-period: calc( var(--button-loading-stripe) + var(--button-loading-stripe-gap) );--button-loading-angle: 125deg;--button-loading-x-period: calc( var(--button-loading-period) / cos(var(--button-loading-angle) - 90deg) );--button-loading-opacity: .15;--button-loading-blur: 5px;--_src: var(--anta-seed-neutral);--_tone-pl-rest: .5;--_tone-pl-hover: .45;--_tone-pl-active: .4;--_tone-pl-c: .02;--_tone-fg-l: .46;--_tone-fg-strong-l: .4;--_tone-fg-c: .008;--_tone-fg-shift: .05;--_tone-bg-l: .54;--_tone-bg-c: .03;--_tone-a-rest: .1;--_tone-a-hover: .15;--_tone-a-active: .2;--_tone-quat-hover-l: .38;--_tone-quat-rest-a: .85;--button-bg-primary-rest: oklch(from var(--_src) var(--_tone-pl-rest) var(--_tone-pl-c) h);--button-bg-primary-hover: oklch(from var(--_src) var(--_tone-pl-hover) var(--_tone-pl-c) h);--button-bg-primary-active: oklch(from var(--_src) var(--_tone-pl-active) var(--_tone-pl-c) h);--button-fg-primary-rest: var(--button-primary-fg);--button-fg-secondary-rest: oklch(from var(--_src) var(--_tone-fg-l) var(--_tone-fg-c) h);--button-fg-secondary-hover: oklch(from var(--_src) var(--_tone-fg-strong-l) var(--_tone-fg-c) h);--button-fg-secondary-l-shift: var(--_tone-fg-shift);--button-fg-tertiary-rest: oklch(from var(--_src) var(--_tone-fg-l) var(--_tone-fg-c) h);--button-fg-tertiary-hover: oklch(from var(--_src) var(--_tone-fg-strong-l) var(--_tone-fg-c) h);--button-bg-tertiary-hover: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-rest));--button-bg-tertiary-active: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-hover));--button-fg-quaternary-rest: oklch(from var(--_src) var(--_tone-fg-l) var(--_tone-fg-c) h / var(--_tone-quat-rest-a));--button-fg-quaternary-hover: oklch(from var(--_src) var(--_tone-quat-hover-l) var(--_tone-fg-c) h);--button-bg-secondary-rest: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-rest));--button-bg-secondary-hover: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-hover));--button-bg-secondary-active: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-active));--_fs: 15px;--_lh: 20px;--_pb: 1px;--_radius: 4px;--button-padding-x: 9px;--button-padding-y: calc((8px - var(--_pb)) / 2);--button-timing-in: 75ms ease-in;--button-timing-active: 50ms linear;--button-timing-out: .15s ease-out;--button-loading-duration: .5s}a-button[round],a[role=button][data-anta][round],button[data-anta][round],input[data-anta]:is([type=reset],[type=submit])[round]{--button-round: attr(round type(<length>), 999px);--_radius: var(--button-round, 999px)}a-button[tone]:not([tone=""],[tone=neutral]),a[role=button][data-anta][tone]:not([tone=""],[tone=neutral]),button[data-anta][tone]:not([tone=""],[tone=neutral]),input[data-anta]:is([type=reset],[type=submit])[tone]:not([tone=""],[tone=neutral]){--_tone-pl-rest: .51;--_tone-pl-hover: .46;--_tone-pl-active: .41;--_tone-pl-c: .17;--_tone-fg-l: .46;--_tone-fg-strong-l: .4;--_tone-fg-c: .17;--_tone-fg-shift: .05;--_tone-bg-l: .54;--_tone-bg-c: .17;--_tone-a-rest: .1;--_tone-a-hover: .15;--_tone-a-active: .2;--_tone-quat-hover-l: .38;--_tone-quat-rest-a: .85}a-button[tone=brand],a[role=button][data-anta][tone=brand],button[data-anta][tone=brand],input[data-anta]:is([type=reset],[type=submit])[tone=brand]{--_src: var(--anta-seed-brand)}a-button[tone=info],a[role=button][data-anta][tone=info],button[data-anta][tone=info],input[data-anta]:is([type=reset],[type=submit])[tone=info]{--_src: var(--anta-seed-info)}a-button[tone=success],a[role=button][data-anta][tone=success],button[data-anta][tone=success],input[data-anta]:is([type=reset],[type=submit])[tone=success]{--_src: var(--anta-seed-success)}a-button[tone=warning],a[role=button][data-anta][tone=warning],button[data-anta][tone=warning],input[data-anta]:is([type=reset],[type=submit])[tone=warning]{--_src: var(--anta-seed-warning)}a-button[tone=critical],a[role=button][data-anta][tone=critical],button[data-anta][tone=critical],input[data-anta]:is([type=reset],[type=submit])[tone=critical]{--_src: var(--anta-seed-critical)}a-button[tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]),a[role=button][data-anta][tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]),button[data-anta][tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]),input[data-anta]:is([type=reset],[type=submit])[tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--_src: var(--button-tone-source, attr(tone type(<color>), transparent))}.dark a-button,.dark a[role=button][data-anta],.dark button[data-anta],.dark input[data-anta]:is([type=reset],[type=submit]){--bg-primary-disabled: #272329;--bg-secondary-disabled: #1d1a1e;--fg-disabled-primary: #776e77;--fg-disabled: #635b65;--_tone-pl-rest: .4;--_tone-pl-hover: .44;--_tone-pl-active: .48;--_tone-pl-c: .015;--_tone-fg-l: .86;--_tone-fg-strong-l: .86;--_tone-fg-c: .015;--_tone-fg-shift: 0;--_tone-bg-l: .44;--_tone-bg-c: .01;--_tone-a-rest: .24;--_tone-a-hover: .34;--_tone-a-active: .44;--_tone-quat-hover-l: .9;--_tone-quat-rest-a: .85}.dark a-button[tone]:not([tone=""],[tone=neutral]),.dark a[role=button][data-anta][tone]:not([tone=""],[tone=neutral]),.dark button[data-anta][tone]:not([tone=""],[tone=neutral]),.dark input[data-anta]:is([type=reset],[type=submit])[tone]:not([tone=""],[tone=neutral]){--_tone-pl-rest: .4;--_tone-pl-hover: .44;--_tone-pl-active: .48;--_tone-pl-c: .16;--_tone-fg-l: .86;--_tone-fg-strong-l: .86;--_tone-fg-c: .13;--_tone-fg-shift: 0;--_tone-bg-l: .58;--_tone-bg-c: .16;--_tone-a-rest: .215;--_tone-a-hover: .29;--_tone-a-active: .34;--_tone-quat-hover-l: .9;--_tone-quat-rest-a: .85}button[data-anta],input[data-anta]:is([type=reset],[type=submit]){box-sizing:border-box;margin:0;appearance:none;-webkit-appearance:none;border:none}a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]){user-select:none;display:inline-flex;align-items:center;gap:.5ch;cursor:pointer;&:has(>a-copy):not(:has(>a-icon)){cursor:copy}flex-shrink:0;color:var(--button-fg);background-color:var(--button-bg);border-radius:var(--_radius);text-decoration:none;box-shadow:inset 0 0 1px color-mix(in oklch,currentColor,transparent 90%);font-size:var(--_fs);font-family:var(--sans-serif);font-weight:450;font-variation-settings:"wdth" 88,"slnt" 0,"ital" 0;font-feature-settings:"ss02","ss05","tnum";line-height:var(--_lh);letter-spacing:.05ch;text-overflow:ellipsis;text-wrap:nowrap;white-space:nowrap;max-width:100%;padding-inline:var(--button-padding-x);padding-block:var(--button-padding-y);min-height:28px;>a-button-label{display:inline-block;text-overflow:ellipsis;text-wrap:nowrap;white-space:nowrap;overflow:hidden;min-width:0;line-height:var(--_lh);padding-bottom:var(--_pb);&:has(>*){display:inline-flex;gap:.25ch}}>*{pointer-events:none}& a-icon{transition:color var(--button-timing-out)}transition:color var(--button-timing-out),background-color var(--button-timing-out);&:hover,&:focus-visible{transition:color var(--button-timing-in),background-color var(--button-timing-in);& a-icon{transition:color var(--button-timing-in)}}&:active,&[selected]{transition:color var(--button-timing-active),background-color var(--button-timing-active);& a-icon{transition:color var(--button-timing-active)}}&[disabled]{pointer-events:none;cursor:not-allowed;transition:none;& a-icon{transition:none}}&:focus-visible{outline:1px solid var(--focus-ring);outline-offset:1px}&[priority=quaternary]{--button-timing-in: 0s;--button-timing-active: 0s;--button-timing-out: 0s}&[size=small]{--button-padding-x: 7px;--_fs: 13px;--_lh: 16px;--_pb: .5px;min-height:24px;& a-icon{--icon-size: 14px}}&[size=large]{--button-padding-x: 13px;--_fs: 17px;--_lh: 24px;--_pb: 1.5px;min-height:32px;& a-icon{--icon-size: 18px}}&[priority=tertiary],&[priority=quaternary]{&[underline=solid]{text-decoration:underline solid}&[underline=dashed]{text-decoration:underline dashed}&[underline=dotted]{text-decoration:underline dotted}&[underline]{text-decoration-color:color-mix(in oklch,currentColor 75%,transparent);text-decoration-thickness:1px;text-underline-offset:3px;&[selected]{text-decoration-color:var(--button-fg);text-decoration-thickness:1px}@media(hover:hover)and (pointer:fine){&:hover{text-decoration-color:var(--button-fg);text-decoration-thickness:1px}}}&[underline][underline-on-hover]{text-decoration-color:transparent;&[selected]{text-decoration-color:transparent}@media(hover:hover)and (pointer:fine){&:hover{text-decoration-color:var(--button-fg)}}}}&[priority=quaternary][paddingless]{--button-padding-x: 0;--button-padding-y: 0;min-height:0}&:has(>a-icon):not(:has(>a-icon~a-icon)):not(:has(>:not(a-icon):not(a-tooltip):not(a-copy))){--button-padding-y: 5px;--button-padding-x: 5px;min-width:28px;justify-content:center;&[size=small]{--button-padding-y: 3px;--button-padding-x: 3px;min-width:24px}&[size=large]{--button-padding-y: 7px;--button-padding-x: 7px;min-width:32px}}&:is(:has(>a-icon:first-child),:has(>a-tooltip:first-child+a-icon)):is(:has(>a-icon~a-icon),:has(>:not(a-icon):not(a-tooltip):not(a-copy))){padding-inline-start:max(0px,var(--button-padding-x) - 2px)}&:is(:has(>a-icon:last-child),:has(>a-icon+a-tooltip:last-child)):is(:has(>a-icon~a-icon),:has(>:not(a-icon):not(a-tooltip):not(a-copy))){padding-inline-end:max(0px,var(--button-padding-x) - 2px)}&[loading]{position:relative;pointer-events:none;cursor:wait;&:before{content:"";position:absolute;inset:0;pointer-events:none;clip-path:inset(0 round var(--_radius));background:repeating-linear-gradient(var(--button-loading-angle),transparent 0,transparent var(--button-loading-stripe-gap),currentColor var(--button-loading-stripe-gap),currentColor calc(var(--button-loading-stripe-gap) + var(--button-loading-stripe)));background-position-x:calc(0px - var(--button-loading-x-period));opacity:var(--button-loading-opacity);filter:blur(var(--button-loading-blur));will-change:background-position;animation:btn-loading-slide var(--button-loading-duration) linear infinite;animation-delay:-9999s}}--button-fg: oklch(from var(--button-fg-secondary-rest) calc(l - var(--button-fg-secondary-l-shift)) c h);--button-bg: var(--button-bg-secondary-rest);@media(hover:hover)and (pointer:fine){&:hover{--button-fg: var(--button-fg-secondary-hover);--button-bg: var(--button-bg-secondary-hover)}}&:active{--button-fg: var(--button-fg-secondary-hover);--button-bg: var(--button-bg-secondary-active)}&[selected]{--button-fg: var(--button-fg-secondary-hover);--button-bg: var(--button-bg-secondary-hover)}&[priority=primary]{--button-fg: var(--button-fg-primary-rest);--button-bg: var(--button-bg-primary-rest);box-shadow:none;@media(hover:hover)and (pointer:fine){&:hover{--button-bg: var(--button-bg-primary-hover)}}&:active{--button-bg: var(--button-bg-primary-active)}&[selected]{--button-bg: var(--button-bg-primary-hover)}}&[priority=tertiary]{--button-fg: var(--button-fg-tertiary-rest);--button-bg: transparent;box-shadow:none;@media(hover:hover)and (pointer:fine){&:hover{--button-fg: var(--button-fg-tertiary-hover);--button-bg: var(--button-bg-tertiary-hover)}}&:active{--button-fg: var(--button-fg-tertiary-hover);--button-bg: var(--button-bg-tertiary-active)}&[selected]{--button-fg: var(--button-fg-tertiary-hover);--button-bg: var(--button-bg-tertiary-hover)}}&[priority=quaternary]{--button-fg: var(--button-fg-quaternary-rest);--button-bg: transparent;box-shadow:none;font-weight:400;letter-spacing:.06ch;@media(hover:hover)and (pointer:fine){&:hover{--button-fg: var(--button-fg-quaternary-hover)}}&:active{--button-fg: var(--button-fg-quaternary-rest)}&[selected]{--button-fg: var(--button-fg-quaternary-hover)}}&[selected]{box-shadow:inset 0 0 0 .5px currentColor}&[disabled]{background-color:var(--bg-secondary-disabled);color:var(--fg-disabled);&[priority=primary]{background-color:var(--bg-primary-disabled);color:var(--fg-disabled-primary)}&[priority=tertiary],&[priority=quaternary]{background-color:transparent;color:var(--fg-disabled)}}}@media(forced-colors:active){:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit])){--anta-forced-foreground: ButtonText;color:ButtonText;background-color:ButtonFace;border:1px solid ButtonText;box-shadow:none}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[priority=primary]{--anta-forced-foreground: ButtonFace;color:ButtonFace;background-color:ButtonText;border-color:ButtonText}a-button:is([priority=primary],[selected]){forced-color-adjust:none}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[priority=tertiary]{--anta-forced-foreground: CanvasText;color:CanvasText;background-color:Canvas;border:0}@media(hover:hover)and (pointer:fine){:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[priority=tertiary]:hover:not(:focus-visible){outline:1px solid ButtonText;outline-offset:0}}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[priority=quaternary]{--anta-forced-foreground: LinkText;color:LinkText;background-color:ButtonFace;border:0;text-decoration:none}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[selected]{--anta-forced-foreground: HighlightText;color:HighlightText;background-color:Highlight;border-color:Highlight}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[disabled]{--anta-forced-foreground: GrayText;color:GrayText;background-color:Canvas;border-color:GrayText;text-decoration-color:GrayText}}}@keyframes btn-loading-slide{to{background-position-x:0}}
|
|
1
|
+
@layer anta.components{a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]){--button-primary-fg: #ffffff;--bg-primary-disabled: #ece9ec;--bg-secondary-disabled: #f6f4f6;--fg-disabled-primary: #afa9b1;--fg-disabled: #afa9b1;--button-loading-stripe: 14px;--button-loading-stripe-gap: 16px;--button-loading-period: calc( var(--button-loading-stripe) + var(--button-loading-stripe-gap) );--button-loading-angle: 125deg;--button-loading-x-period: calc( var(--button-loading-period) / cos(var(--button-loading-angle) - 90deg) );--button-loading-opacity: .15;--button-loading-blur: 5px;--_src: var(--anta-seed-neutral);--_tone-pl-rest: .5;--_tone-pl-hover: .45;--_tone-pl-active: .4;--_tone-pl-c: .02;--_tone-fg-l: .46;--_tone-fg-strong-l: .4;--_tone-fg-c: .008;--_tone-fg-shift: .05;--_tone-bg-l: .54;--_tone-bg-c: .03;--_tone-a-rest: .1;--_tone-a-hover: .15;--_tone-a-active: .2;--_tone-quat-hover-l: .38;--_tone-quat-rest-a: .85;--button-bg-primary-rest: oklch(from var(--_src) var(--_tone-pl-rest) var(--_tone-pl-c) h);--button-bg-primary-hover: oklch(from var(--_src) var(--_tone-pl-hover) var(--_tone-pl-c) h);--button-bg-primary-active: oklch(from var(--_src) var(--_tone-pl-active) var(--_tone-pl-c) h);--button-fg-primary-rest: var(--button-primary-fg);--button-fg-secondary-rest: oklch(from var(--_src) var(--_tone-fg-l) var(--_tone-fg-c) h);--button-fg-secondary-hover: oklch(from var(--_src) var(--_tone-fg-strong-l) var(--_tone-fg-c) h);--button-fg-secondary-l-shift: var(--_tone-fg-shift);--button-fg-tertiary-rest: oklch(from var(--_src) var(--_tone-fg-l) var(--_tone-fg-c) h);--button-fg-tertiary-hover: oklch(from var(--_src) var(--_tone-fg-strong-l) var(--_tone-fg-c) h);--button-bg-tertiary-hover: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-rest));--button-bg-tertiary-active: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-hover));--button-fg-quaternary-rest: oklch(from var(--_src) var(--_tone-fg-l) var(--_tone-fg-c) h / var(--_tone-quat-rest-a));--button-fg-quaternary-hover: oklch(from var(--_src) var(--_tone-quat-hover-l) var(--_tone-fg-c) h);--button-bg-secondary-rest: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-rest));--button-bg-secondary-hover: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-hover));--button-bg-secondary-active: oklch(from var(--_src) var(--_tone-bg-l) var(--_tone-bg-c) h / var(--_tone-a-active));--_fs: 15px;--_lh: 20px;--_pb: 1px;--_radius: 4px;--button-padding-x: 9px;--button-padding-y: calc((8px - var(--_pb)) / 2);--button-timing-in: 75ms ease-in;--button-timing-active: 50ms linear;--button-timing-out: .15s ease-out;--button-loading-duration: .5s}a-button[round],a[role=button][data-anta][round],button[data-anta][round],input[data-anta]:is([type=reset],[type=submit])[round]{--button-round: 999px;--_radius: var(--button-round, 999px);@supports (border-radius: attr(probe type(<length>),1px)){--button-round: attr(round type(<length>), 999px)}}a-button[tone]:not([tone=""],[tone=neutral]),a[role=button][data-anta][tone]:not([tone=""],[tone=neutral]),button[data-anta][tone]:not([tone=""],[tone=neutral]),input[data-anta]:is([type=reset],[type=submit])[tone]:not([tone=""],[tone=neutral]){--_tone-pl-rest: .51;--_tone-pl-hover: .46;--_tone-pl-active: .41;--_tone-pl-c: .17;--_tone-fg-l: .46;--_tone-fg-strong-l: .4;--_tone-fg-c: .17;--_tone-fg-shift: .05;--_tone-bg-l: .54;--_tone-bg-c: .17;--_tone-a-rest: .1;--_tone-a-hover: .15;--_tone-a-active: .2;--_tone-quat-hover-l: .38;--_tone-quat-rest-a: .85}a-button[tone=brand],a[role=button][data-anta][tone=brand],button[data-anta][tone=brand],input[data-anta]:is([type=reset],[type=submit])[tone=brand]{--_src: var(--anta-seed-brand)}a-button[tone=info],a[role=button][data-anta][tone=info],button[data-anta][tone=info],input[data-anta]:is([type=reset],[type=submit])[tone=info]{--_src: var(--anta-seed-info)}a-button[tone=success],a[role=button][data-anta][tone=success],button[data-anta][tone=success],input[data-anta]:is([type=reset],[type=submit])[tone=success]{--_src: var(--anta-seed-success)}a-button[tone=warning],a[role=button][data-anta][tone=warning],button[data-anta][tone=warning],input[data-anta]:is([type=reset],[type=submit])[tone=warning]{--_src: var(--anta-seed-warning)}a-button[tone=critical],a[role=button][data-anta][tone=critical],button[data-anta][tone=critical],input[data-anta]:is([type=reset],[type=submit])[tone=critical]{--_src: var(--anta-seed-critical)}a-button[tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]),a[role=button][data-anta][tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]),button[data-anta][tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]),input[data-anta]:is([type=reset],[type=submit])[tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--_src: var(--button-tone-source, transparent);@supports (color: attr(probe type(<color>),red)){--_src: var(--button-tone-source, attr(tone type(<color>), transparent))}}.dark a-button,.dark a[role=button][data-anta],.dark button[data-anta],.dark input[data-anta]:is([type=reset],[type=submit]){--bg-primary-disabled: #272329;--bg-secondary-disabled: #1d1a1e;--fg-disabled-primary: #776e77;--fg-disabled: #635b65;--_tone-pl-rest: .4;--_tone-pl-hover: .44;--_tone-pl-active: .48;--_tone-pl-c: .015;--_tone-fg-l: .86;--_tone-fg-strong-l: .86;--_tone-fg-c: .015;--_tone-fg-shift: 0;--_tone-bg-l: .44;--_tone-bg-c: .01;--_tone-a-rest: .24;--_tone-a-hover: .34;--_tone-a-active: .44;--_tone-quat-hover-l: .9;--_tone-quat-rest-a: .85}.dark a-button[tone]:not([tone=""],[tone=neutral]),.dark a[role=button][data-anta][tone]:not([tone=""],[tone=neutral]),.dark button[data-anta][tone]:not([tone=""],[tone=neutral]),.dark input[data-anta]:is([type=reset],[type=submit])[tone]:not([tone=""],[tone=neutral]){--_tone-pl-rest: .4;--_tone-pl-hover: .44;--_tone-pl-active: .48;--_tone-pl-c: .16;--_tone-fg-l: .86;--_tone-fg-strong-l: .86;--_tone-fg-c: .13;--_tone-fg-shift: 0;--_tone-bg-l: .58;--_tone-bg-c: .16;--_tone-a-rest: .215;--_tone-a-hover: .29;--_tone-a-active: .34;--_tone-quat-hover-l: .9;--_tone-quat-rest-a: .85}button[data-anta],input[data-anta]:is([type=reset],[type=submit]){box-sizing:border-box;margin:0;appearance:none;-webkit-appearance:none;border:none}a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]){user-select:none;display:inline-flex;align-items:center;gap:.5ch;cursor:pointer;&:has(>a-copy):not(:has(>a-icon)){cursor:copy}flex-shrink:0;color:var(--button-fg);background-color:var(--button-bg);border-radius:var(--_radius);text-decoration:none;box-shadow:inset 0 0 1px color-mix(in oklch,currentColor,transparent 90%);font-size:var(--_fs);font-family:var(--sans-serif);font-weight:450;font-variation-settings:"wdth" 88,"slnt" 0,"ital" 0;font-feature-settings:"ss02","ss05","tnum";line-height:var(--_lh);letter-spacing:.05ch;text-overflow:ellipsis;text-wrap:nowrap;white-space:nowrap;max-width:100%;padding-inline:var(--button-padding-x);padding-block:var(--button-padding-y);min-height:28px;>a-button-label{display:inline-block;text-overflow:ellipsis;text-wrap:nowrap;white-space:nowrap;overflow:hidden;min-width:0;line-height:var(--_lh);padding-bottom:var(--_pb);&:has(>*){display:inline-flex;gap:.25ch}}>*{pointer-events:none}& a-icon{transition:color var(--button-timing-out)}transition:color var(--button-timing-out),background-color var(--button-timing-out);&:hover,&:focus-visible{transition:color var(--button-timing-in),background-color var(--button-timing-in);& a-icon{transition:color var(--button-timing-in)}}&:active,&[selected]{transition:color var(--button-timing-active),background-color var(--button-timing-active);& a-icon{transition:color var(--button-timing-active)}}&[disabled]{pointer-events:none;cursor:not-allowed;transition:none;& a-icon{transition:none}}&:focus-visible{outline:1px solid var(--focus-ring);outline-offset:1px}&[priority=quaternary]{--button-timing-in: 0s;--button-timing-active: 0s;--button-timing-out: 0s}&[size=small]{--button-padding-x: 7px;--_fs: 13px;--_lh: 16px;--_pb: .5px;min-height:24px;& a-icon{--icon-size: 14px}}&[size=large]{--button-padding-x: 13px;--_fs: 17px;--_lh: 24px;--_pb: 1.5px;min-height:32px;& a-icon{--icon-size: 18px}}&[priority=tertiary],&[priority=quaternary]{&[underline=solid]{text-decoration:underline solid}&[underline=dashed]{text-decoration:underline dashed}&[underline=dotted]{text-decoration:underline dotted}&[underline]{text-decoration-color:color-mix(in oklch,currentColor 75%,transparent);text-decoration-thickness:1px;text-underline-offset:3px;&[selected]{text-decoration-color:var(--button-fg);text-decoration-thickness:1px}@media(hover:hover)and (pointer:fine){&:hover{text-decoration-color:var(--button-fg);text-decoration-thickness:1px}}}&[underline][underline-on-hover]{text-decoration-color:transparent;&[selected]{text-decoration-color:transparent}@media(hover:hover)and (pointer:fine){&:hover{text-decoration-color:var(--button-fg)}}}}&[priority=quaternary][paddingless]{--button-padding-x: 0;--button-padding-y: 0;min-height:0}&:has(>a-icon):not(:has(>a-icon~a-icon)):not(:has(>:not(a-icon):not(a-tooltip):not(a-copy))){--button-padding-y: 5px;--button-padding-x: 5px;min-width:28px;justify-content:center;&[size=small]{--button-padding-y: 3px;--button-padding-x: 3px;min-width:24px}&[size=large]{--button-padding-y: 7px;--button-padding-x: 7px;min-width:32px}}&:is(:has(>a-icon:first-child),:has(>a-tooltip:first-child+a-icon)):is(:has(>a-icon~a-icon),:has(>:not(a-icon):not(a-tooltip):not(a-copy))){padding-inline-start:max(0px,var(--button-padding-x) - 2px)}&:is(:has(>a-icon:last-child),:has(>a-icon+a-tooltip:last-child)):is(:has(>a-icon~a-icon),:has(>:not(a-icon):not(a-tooltip):not(a-copy))){padding-inline-end:max(0px,var(--button-padding-x) - 2px)}&[loading]{position:relative;pointer-events:none;cursor:wait;&:before{content:"";position:absolute;inset:0;pointer-events:none;clip-path:inset(0 round var(--_radius));background:repeating-linear-gradient(var(--button-loading-angle),transparent 0,transparent var(--button-loading-stripe-gap),currentColor var(--button-loading-stripe-gap),currentColor calc(var(--button-loading-stripe-gap) + var(--button-loading-stripe)));background-position-x:calc(0px - var(--button-loading-x-period));opacity:var(--button-loading-opacity);filter:blur(var(--button-loading-blur));will-change:background-position;animation:btn-loading-slide var(--button-loading-duration) linear infinite;animation-delay:-9999s}}--button-fg: oklch(from var(--button-fg-secondary-rest) calc(l - var(--button-fg-secondary-l-shift)) c h);--button-bg: var(--button-bg-secondary-rest);@media(hover:hover)and (pointer:fine){&:hover{--button-fg: var(--button-fg-secondary-hover);--button-bg: var(--button-bg-secondary-hover)}}&:active{--button-fg: var(--button-fg-secondary-hover);--button-bg: var(--button-bg-secondary-active)}&[selected]{--button-fg: var(--button-fg-secondary-hover);--button-bg: var(--button-bg-secondary-hover)}&[priority=primary]{--button-fg: var(--button-fg-primary-rest);--button-bg: var(--button-bg-primary-rest);box-shadow:none;@media(hover:hover)and (pointer:fine){&:hover{--button-bg: var(--button-bg-primary-hover)}}&:active{--button-bg: var(--button-bg-primary-active)}&[selected]{--button-bg: var(--button-bg-primary-hover)}}&[priority=tertiary]{--button-fg: var(--button-fg-tertiary-rest);--button-bg: transparent;box-shadow:none;@media(hover:hover)and (pointer:fine){&:hover{--button-fg: var(--button-fg-tertiary-hover);--button-bg: var(--button-bg-tertiary-hover)}}&:active{--button-fg: var(--button-fg-tertiary-hover);--button-bg: var(--button-bg-tertiary-active)}&[selected]{--button-fg: var(--button-fg-tertiary-hover);--button-bg: var(--button-bg-tertiary-hover)}}&[priority=quaternary]{--button-fg: var(--button-fg-quaternary-rest);--button-bg: transparent;box-shadow:none;font-weight:400;letter-spacing:.06ch;@media(hover:hover)and (pointer:fine){&:hover{--button-fg: var(--button-fg-quaternary-hover)}}&:active{--button-fg: var(--button-fg-quaternary-rest)}&[selected]{--button-fg: var(--button-fg-quaternary-hover)}}&[selected]{box-shadow:inset 0 0 0 .5px currentColor}&[disabled]{background-color:var(--bg-secondary-disabled);color:var(--fg-disabled);&[priority=primary]{background-color:var(--bg-primary-disabled);color:var(--fg-disabled-primary)}&[priority=tertiary],&[priority=quaternary]{background-color:transparent;color:var(--fg-disabled)}}}@media(forced-colors:active){:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit])){--anta-forced-foreground: ButtonText;color:ButtonText;background-color:ButtonFace;border:1px solid ButtonText;box-shadow:none}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[priority=primary]{--anta-forced-foreground: ButtonFace;color:ButtonFace;background-color:ButtonText;border-color:ButtonText}a-button:is([priority=primary],[selected]){forced-color-adjust:none}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[priority=tertiary]{--anta-forced-foreground: CanvasText;color:CanvasText;background-color:Canvas;border:0}@media(hover:hover)and (pointer:fine){:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[priority=tertiary]:hover:not(:focus-visible){outline:1px solid ButtonText;outline-offset:0}}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[priority=quaternary]{--anta-forced-foreground: LinkText;color:LinkText;background-color:ButtonFace;border:0;text-decoration:none}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[selected]{--anta-forced-foreground: HighlightText;color:HighlightText;background-color:Highlight;border-color:Highlight}:is(a-button,a[role=button][data-anta],button[data-anta],input[data-anta]:is([type=reset],[type=submit]))[disabled]{--anta-forced-foreground: GrayText;color:GrayText;background-color:Canvas;border-color:GrayText;text-decoration-color:GrayText}}}@keyframes btn-loading-slide{to{background-position-x:0}}
|
|
@@ -46,8 +46,8 @@ class ACalendarElement extends HTMLElementBase {
|
|
|
46
46
|
applyFormValue(value) {
|
|
47
47
|
this.internals?.setFormValue(value || null);
|
|
48
48
|
try {
|
|
49
|
-
if (value) this.internals?.states
|
|
50
|
-
else this.internals?.states
|
|
49
|
+
if (value) this.internals?.states?.add("filled");
|
|
50
|
+
else this.internals?.states?.delete("filled");
|
|
51
51
|
} catch {
|
|
52
52
|
}
|
|
53
53
|
}
|