@antadesign/anta 0.1.1-dev.6 → 0.1.1-dev.8
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/README.md +13 -2
- package/dist/components/Button.d.ts +113 -0
- package/dist/components/Button.js +100 -0
- package/dist/components/Button.module.css +2 -0
- package/dist/components/Icon.d.ts +2 -1
- package/dist/components/Progress.d.ts +4 -2
- package/dist/components/Sticker.d.ts +31 -0
- package/dist/components/Sticker.js +17 -0
- package/dist/components/StickerAnimated.d.ts +23 -0
- package/dist/components/StickerAnimated.js +28 -0
- package/dist/components/Text.d.ts +2 -1
- package/dist/components/Title.d.ts +6 -4
- package/dist/components/Tooltip.d.ts +55 -0
- package/dist/components/Tooltip.js +26 -0
- package/dist/components/__generated__/stickers/angry-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/angry-animated.js +7 -0
- package/dist/components/__generated__/stickers/angry.d.ts +3 -0
- package/dist/components/__generated__/stickers/angry.js +7 -0
- package/dist/components/__generated__/stickers/ask-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/ask-animated.js +7 -0
- package/dist/components/__generated__/stickers/ask.d.ts +3 -0
- package/dist/components/__generated__/stickers/ask.js +7 -0
- package/dist/components/__generated__/stickers/balance-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/balance-animated.js +7 -0
- package/dist/components/__generated__/stickers/balance.d.ts +3 -0
- package/dist/components/__generated__/stickers/balance.js +7 -0
- package/dist/components/__generated__/stickers/butterfly-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/butterfly-animated.js +7 -0
- package/dist/components/__generated__/stickers/butterfly-snake-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/butterfly-snake-animated.js +7 -0
- package/dist/components/__generated__/stickers/butterfly-snake.d.ts +3 -0
- package/dist/components/__generated__/stickers/butterfly-snake.js +7 -0
- package/dist/components/__generated__/stickers/butterfly.d.ts +3 -0
- package/dist/components/__generated__/stickers/butterfly.js +7 -0
- package/dist/components/__generated__/stickers/catch-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/catch-animated.js +7 -0
- package/dist/components/__generated__/stickers/catch.d.ts +3 -0
- package/dist/components/__generated__/stickers/catch.js +7 -0
- package/dist/components/__generated__/stickers/clap-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/clap-animated.js +7 -0
- package/dist/components/__generated__/stickers/clap.d.ts +3 -0
- package/dist/components/__generated__/stickers/clap.js +7 -0
- package/dist/components/__generated__/stickers/coding-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/coding-animated.js +7 -0
- package/dist/components/__generated__/stickers/coding.d.ts +3 -0
- package/dist/components/__generated__/stickers/coding.js +7 -0
- package/dist/components/__generated__/stickers/cowboy-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/cowboy-animated.js +7 -0
- package/dist/components/__generated__/stickers/cowboy.d.ts +3 -0
- package/dist/components/__generated__/stickers/cowboy.js +7 -0
- package/dist/components/__generated__/stickers/dance-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/dance-animated.js +7 -0
- package/dist/components/__generated__/stickers/dance.d.ts +3 -0
- package/dist/components/__generated__/stickers/dance.js +7 -0
- package/dist/components/__generated__/stickers/detective-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/detective-animated.js +7 -0
- package/dist/components/__generated__/stickers/detective.d.ts +3 -0
- package/dist/components/__generated__/stickers/detective.js +7 -0
- package/dist/components/__generated__/stickers/disapprove-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/disapprove-animated.js +7 -0
- package/dist/components/__generated__/stickers/disapprove.d.ts +3 -0
- package/dist/components/__generated__/stickers/disapprove.js +7 -0
- package/dist/components/__generated__/stickers/distracted-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/distracted-animated.js +7 -0
- package/dist/components/__generated__/stickers/distracted.d.ts +3 -0
- package/dist/components/__generated__/stickers/distracted.js +7 -0
- package/dist/components/__generated__/stickers/dive-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/dive-animated.js +7 -0
- package/dist/components/__generated__/stickers/dive.d.ts +3 -0
- package/dist/components/__generated__/stickers/dive.js +7 -0
- package/dist/components/__generated__/stickers/eat-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/eat-animated.js +7 -0
- package/dist/components/__generated__/stickers/eat.d.ts +3 -0
- package/dist/components/__generated__/stickers/eat.js +7 -0
- package/dist/components/__generated__/stickers/facepalm-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/facepalm-animated.js +7 -0
- package/dist/components/__generated__/stickers/facepalm.d.ts +3 -0
- package/dist/components/__generated__/stickers/facepalm.js +7 -0
- package/dist/components/__generated__/stickers/failed-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/failed-animated.js +7 -0
- package/dist/components/__generated__/stickers/failed.d.ts +3 -0
- package/dist/components/__generated__/stickers/failed.js +7 -0
- package/dist/components/__generated__/stickers/found-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/found-animated.js +7 -0
- package/dist/components/__generated__/stickers/found.d.ts +3 -0
- package/dist/components/__generated__/stickers/found.js +7 -0
- package/dist/components/__generated__/stickers/grow-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/grow-animated.js +7 -0
- package/dist/components/__generated__/stickers/grow.d.ts +3 -0
- package/dist/components/__generated__/stickers/grow.js +7 -0
- package/dist/components/__generated__/stickers/handstand-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/handstand-animated.js +7 -0
- package/dist/components/__generated__/stickers/handstand.d.ts +3 -0
- package/dist/components/__generated__/stickers/handstand.js +7 -0
- package/dist/components/__generated__/stickers/heart-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/heart-animated.js +7 -0
- package/dist/components/__generated__/stickers/heart.d.ts +3 -0
- package/dist/components/__generated__/stickers/heart.js +7 -0
- package/dist/components/__generated__/stickers/hello-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/hello-animated.js +7 -0
- package/dist/components/__generated__/stickers/hello.d.ts +3 -0
- package/dist/components/__generated__/stickers/hello.js +7 -0
- package/dist/components/__generated__/stickers/idea-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/idea-animated.js +7 -0
- package/dist/components/__generated__/stickers/idea.d.ts +3 -0
- package/dist/components/__generated__/stickers/idea.js +7 -0
- package/dist/components/__generated__/stickers/index.d.ts +99 -0
- package/dist/components/__generated__/stickers/index.js +198 -0
- package/dist/components/__generated__/stickers/laugh-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/laugh-animated.js +7 -0
- package/dist/components/__generated__/stickers/laugh.d.ts +3 -0
- package/dist/components/__generated__/stickers/laugh.js +7 -0
- package/dist/components/__generated__/stickers/love-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/love-animated.js +7 -0
- package/dist/components/__generated__/stickers/love.d.ts +3 -0
- package/dist/components/__generated__/stickers/love.js +7 -0
- package/dist/components/__generated__/stickers/nap-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/nap-animated.js +7 -0
- package/dist/components/__generated__/stickers/nap.d.ts +3 -0
- package/dist/components/__generated__/stickers/nap.js +7 -0
- package/dist/components/__generated__/stickers/party-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/party-animated.js +7 -0
- package/dist/components/__generated__/stickers/party.d.ts +3 -0
- package/dist/components/__generated__/stickers/party.js +7 -0
- package/dist/components/__generated__/stickers/passed-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/passed-animated.js +7 -0
- package/dist/components/__generated__/stickers/passed.d.ts +3 -0
- package/dist/components/__generated__/stickers/passed.js +7 -0
- package/dist/components/__generated__/stickers/peekaboo-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/peekaboo-animated.js +7 -0
- package/dist/components/__generated__/stickers/peekaboo.d.ts +3 -0
- package/dist/components/__generated__/stickers/peekaboo.js +7 -0
- package/dist/components/__generated__/stickers/pizza-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/pizza-animated.js +7 -0
- package/dist/components/__generated__/stickers/pizza.d.ts +3 -0
- package/dist/components/__generated__/stickers/pizza.js +7 -0
- package/dist/components/__generated__/stickers/puzzle-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/puzzle-animated.js +7 -0
- package/dist/components/__generated__/stickers/puzzle.d.ts +3 -0
- package/dist/components/__generated__/stickers/puzzle.js +7 -0
- package/dist/components/__generated__/stickers/sad-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/sad-animated.js +7 -0
- package/dist/components/__generated__/stickers/sad.d.ts +3 -0
- package/dist/components/__generated__/stickers/sad.js +7 -0
- package/dist/components/__generated__/stickers/scared-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/scared-animated.js +7 -0
- package/dist/components/__generated__/stickers/scared.d.ts +3 -0
- package/dist/components/__generated__/stickers/scared.js +7 -0
- package/dist/components/__generated__/stickers/scroll-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/scroll-animated.js +7 -0
- package/dist/components/__generated__/stickers/scroll.d.ts +3 -0
- package/dist/components/__generated__/stickers/scroll.js +7 -0
- package/dist/components/__generated__/stickers/search-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/search-animated.js +7 -0
- package/dist/components/__generated__/stickers/search.d.ts +3 -0
- package/dist/components/__generated__/stickers/search.js +7 -0
- package/dist/components/__generated__/stickers/shield-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/shield-animated.js +7 -0
- package/dist/components/__generated__/stickers/shield.d.ts +3 -0
- package/dist/components/__generated__/stickers/shield.js +7 -0
- package/dist/components/__generated__/stickers/shocked-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/shocked-animated.js +7 -0
- package/dist/components/__generated__/stickers/shocked.d.ts +3 -0
- package/dist/components/__generated__/stickers/shocked.js +7 -0
- package/dist/components/__generated__/stickers/sleep-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/sleep-animated.js +7 -0
- package/dist/components/__generated__/stickers/sleep.d.ts +3 -0
- package/dist/components/__generated__/stickers/sleep.js +7 -0
- package/dist/components/__generated__/stickers/stressed-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/stressed-animated.js +7 -0
- package/dist/components/__generated__/stickers/stressed.d.ts +3 -0
- package/dist/components/__generated__/stickers/stressed.js +7 -0
- package/dist/components/__generated__/stickers/suspicious-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/suspicious-animated.js +7 -0
- package/dist/components/__generated__/stickers/suspicious.d.ts +3 -0
- package/dist/components/__generated__/stickers/suspicious.js +7 -0
- package/dist/components/__generated__/stickers/thanks-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/thanks-animated.js +7 -0
- package/dist/components/__generated__/stickers/thanks.d.ts +3 -0
- package/dist/components/__generated__/stickers/thanks.js +7 -0
- package/dist/components/__generated__/stickers/think-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/think-animated.js +7 -0
- package/dist/components/__generated__/stickers/think-of-you-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/think-of-you-animated.js +7 -0
- package/dist/components/__generated__/stickers/think-of-you.d.ts +3 -0
- package/dist/components/__generated__/stickers/think-of-you.js +7 -0
- package/dist/components/__generated__/stickers/think.d.ts +3 -0
- package/dist/components/__generated__/stickers/think.js +7 -0
- package/dist/components/__generated__/stickers/thumbs-up-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/thumbs-up-animated.js +7 -0
- package/dist/components/__generated__/stickers/thumbs-up.d.ts +3 -0
- package/dist/components/__generated__/stickers/thumbs-up.js +7 -0
- package/dist/components/__generated__/stickers/vacation-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/vacation-animated.js +7 -0
- package/dist/components/__generated__/stickers/vacation.d.ts +3 -0
- package/dist/components/__generated__/stickers/vacation.js +7 -0
- package/dist/components/__generated__/stickers/wait-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/wait-animated.js +7 -0
- package/dist/components/__generated__/stickers/wait.d.ts +3 -0
- package/dist/components/__generated__/stickers/wait.js +7 -0
- package/dist/components/__generated__/stickers/wink-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/wink-animated.js +7 -0
- package/dist/components/__generated__/stickers/wink.d.ts +3 -0
- package/dist/components/__generated__/stickers/wink.js +7 -0
- package/dist/components/__generated__/stickers/work-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/work-animated.js +7 -0
- package/dist/components/__generated__/stickers/work.d.ts +3 -0
- package/dist/components/__generated__/stickers/work.js +7 -0
- package/dist/components/__generated__/stickers/zen-animated.d.ts +3 -0
- package/dist/components/__generated__/stickers/zen-animated.js +7 -0
- package/dist/components/__generated__/stickers/zen.d.ts +3 -0
- package/dist/components/__generated__/stickers/zen.js +7 -0
- package/dist/elements/a-button.css +733 -0
- package/dist/elements/a-button.d.ts +11 -0
- package/dist/elements/a-button.js +78 -0
- package/dist/elements/a-icon.css +30 -10
- package/dist/elements/a-icon.d.ts +2 -0
- package/dist/elements/a-icon.js +3 -0
- package/dist/elements/a-icon.shapes.css +9 -1
- package/dist/elements/a-icon.shapes.d.ts +3 -1
- package/dist/elements/a-icon.shapes.js +2 -0
- package/dist/elements/a-progress.css +7 -9
- package/dist/elements/a-progress.d.ts +1 -0
- package/dist/elements/a-progress.js +2 -0
- package/dist/elements/a-sticker-animated.css +9 -0
- package/dist/elements/a-sticker-animated.d.ts +39 -0
- package/dist/elements/a-sticker-animated.js +81 -0
- package/dist/elements/a-sticker.css +9 -0
- package/dist/elements/a-sticker.d.ts +19 -0
- package/dist/elements/a-sticker.js +32 -0
- package/dist/elements/a-text.css +6 -3
- package/dist/elements/a-text.d.ts +1 -0
- package/dist/elements/a-text.js +2 -0
- package/dist/elements/a-tooltip.css +42 -0
- package/dist/elements/a-tooltip.d.ts +61 -0
- package/dist/elements/a-tooltip.js +411 -0
- package/dist/elements/index.d.ts +21 -5
- package/dist/elements/index.js +18 -18
- package/dist/general_types.d.ts +110 -6
- package/dist/generate-stickers.mjs +293 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/jsx-runtime.d.ts +6 -1
- package/dist/reset.css +31 -28
- package/dist/tokens.css +186 -182
- package/package.json +18 -4
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { HTMLElementBase } from "../anta_helpers";
|
|
2
|
+
import { debounce } from "es-toolkit";
|
|
3
|
+
import "./a-tooltip.css";
|
|
4
|
+
const MARGIN = 4;
|
|
5
|
+
const CURSOR_SIZE = 16;
|
|
6
|
+
const PADDING_X = 8;
|
|
7
|
+
const DEFAULT_DELAY = 250;
|
|
8
|
+
const FADE_MS = 150;
|
|
9
|
+
const GRACE_MS = 300;
|
|
10
|
+
const CLOSE_DELAY = 120;
|
|
11
|
+
let currentOpen = null;
|
|
12
|
+
let graceTimer;
|
|
13
|
+
function graceActive() {
|
|
14
|
+
return graceTimer !== void 0;
|
|
15
|
+
}
|
|
16
|
+
function isHot() {
|
|
17
|
+
return currentOpen !== null || graceActive();
|
|
18
|
+
}
|
|
19
|
+
function clearGrace() {
|
|
20
|
+
if (graceTimer !== void 0) {
|
|
21
|
+
clearTimeout(graceTimer);
|
|
22
|
+
graceTimer = void 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function claimOpen(el) {
|
|
26
|
+
if (currentOpen && currentOpen !== el) currentOpen.hide();
|
|
27
|
+
currentOpen = el;
|
|
28
|
+
clearGrace();
|
|
29
|
+
}
|
|
30
|
+
function releaseOpen(el) {
|
|
31
|
+
if (currentOpen !== el) return;
|
|
32
|
+
currentOpen = null;
|
|
33
|
+
clearGrace();
|
|
34
|
+
graceTimer = setTimeout(() => {
|
|
35
|
+
graceTimer = void 0;
|
|
36
|
+
}, GRACE_MS);
|
|
37
|
+
}
|
|
38
|
+
const anchorToTooltip = /* @__PURE__ */ new WeakMap();
|
|
39
|
+
function handleIntersection(entries) {
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
const tooltip = anchorToTooltip.get(entry.target);
|
|
42
|
+
if (!tooltip) continue;
|
|
43
|
+
if (!tooltip.listening && entry.isIntersecting) {
|
|
44
|
+
requestAnimationFrame(() => tooltip.setupListeners());
|
|
45
|
+
} else if (tooltip.listening && !entry.isIntersecting) {
|
|
46
|
+
requestAnimationFrame(() => tooltip.teardownListeners());
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const lazyObserver = typeof IntersectionObserver !== "undefined" ? new IntersectionObserver(handleIntersection, { root: null, rootMargin: "0px", threshold: 0 }) : null;
|
|
51
|
+
class ATooltipElement extends HTMLElementBase {
|
|
52
|
+
// Observe `delay` so changing it at runtime — e.g. the docs playground
|
|
53
|
+
// patches the attribute on the live element — rebuilds the show debounce
|
|
54
|
+
// with the new value instead of keeping the one captured at setup.
|
|
55
|
+
static observedAttributes = ["delay"];
|
|
56
|
+
/** Shadow-internal popover surface — the only thing we ever mutate. */
|
|
57
|
+
container;
|
|
58
|
+
anchor = null;
|
|
59
|
+
listening = false;
|
|
60
|
+
shown = false;
|
|
61
|
+
lastMouse;
|
|
62
|
+
debouncedShow;
|
|
63
|
+
teardown;
|
|
64
|
+
closeTimer;
|
|
65
|
+
fading = false;
|
|
66
|
+
fadeTimer;
|
|
67
|
+
docMoveBound = false;
|
|
68
|
+
constructor() {
|
|
69
|
+
super();
|
|
70
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
71
|
+
const style = document.createElement("style");
|
|
72
|
+
style.textContent = `
|
|
73
|
+
:host { display: contents; }
|
|
74
|
+
|
|
75
|
+
.container {
|
|
76
|
+
--_dur: ${FADE_MS}ms;
|
|
77
|
+
|
|
78
|
+
position: fixed;
|
|
79
|
+
left: 0;
|
|
80
|
+
top: 0;
|
|
81
|
+
margin: 0;
|
|
82
|
+
box-sizing: border-box;
|
|
83
|
+
width: fit-content;
|
|
84
|
+
max-width: var(--tooltip-max-width, min(calc(100vw - 20px), 80ch));
|
|
85
|
+
max-height: calc(100vh - 20px);
|
|
86
|
+
overflow: clip;
|
|
87
|
+
pointer-events: none;
|
|
88
|
+
text-align: left;
|
|
89
|
+
|
|
90
|
+
background: var(--tooltip-bg, Canvas);
|
|
91
|
+
color: var(--text-1, CanvasText);
|
|
92
|
+
box-shadow: var(--tooltip-shadow, 0 1px 8px rgba(0, 0, 0, 0.2));
|
|
93
|
+
backdrop-filter: blur(8px);
|
|
94
|
+
padding: 5px 8px;
|
|
95
|
+
border: none;
|
|
96
|
+
border-radius: var(--tooltip-radius, 3px);
|
|
97
|
+
outline: none;
|
|
98
|
+
|
|
99
|
+
font-size: 14px;
|
|
100
|
+
line-height: 130%;
|
|
101
|
+
font-weight: 400;
|
|
102
|
+
white-space: break-spaces;
|
|
103
|
+
word-break: break-word;
|
|
104
|
+
overflow-wrap: break-word;
|
|
105
|
+
|
|
106
|
+
/* Clean enter/exit fade. allow-discrete keeps the bubble rendered
|
|
107
|
+
through its fade-out after hidePopover(), and @starting-style
|
|
108
|
+
gives every open a from-opacity:0 \u2014 so the first paint at a
|
|
109
|
+
not-yet-computed transform is invisible (no flash at a stale
|
|
110
|
+
spot), and re-appearing is always clean. */
|
|
111
|
+
opacity: 0;
|
|
112
|
+
transition:
|
|
113
|
+
opacity var(--_dur) ease,
|
|
114
|
+
overlay var(--_dur) ease allow-discrete,
|
|
115
|
+
display var(--_dur) ease allow-discrete;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.container:popover-open { opacity: 1; }
|
|
119
|
+
|
|
120
|
+
@starting-style {
|
|
121
|
+
.container:popover-open { opacity: 0; }
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* Interactive tooltips accept pointer events so their content (links,
|
|
125
|
+
buttons) is clickable; the default click-through bubble does not. */
|
|
126
|
+
:host([interactive]) .container { pointer-events: auto; }
|
|
127
|
+
`;
|
|
128
|
+
this.container = document.createElement("div");
|
|
129
|
+
this.container.className = "container";
|
|
130
|
+
this.container.setAttribute("popover", "manual");
|
|
131
|
+
this.container.setAttribute("role", "tooltip");
|
|
132
|
+
this.container.append(document.createElement("slot"));
|
|
133
|
+
this.container.addEventListener("mouseenter", () => {
|
|
134
|
+
if (this.isInteractive) this.cancelHide();
|
|
135
|
+
});
|
|
136
|
+
this.container.addEventListener("mouseleave", () => {
|
|
137
|
+
if (this.isInteractive && this.shown) this.scheduleHide();
|
|
138
|
+
});
|
|
139
|
+
shadow.append(style, this.container);
|
|
140
|
+
}
|
|
141
|
+
connectedCallback() {
|
|
142
|
+
const parent = this.parentElement;
|
|
143
|
+
if (!parent) return;
|
|
144
|
+
this.anchor = parent;
|
|
145
|
+
anchorToTooltip.set(parent, this);
|
|
146
|
+
lazyObserver?.observe(parent);
|
|
147
|
+
}
|
|
148
|
+
disconnectedCallback() {
|
|
149
|
+
this.hide();
|
|
150
|
+
if (this.fadeTimer !== void 0) {
|
|
151
|
+
clearTimeout(this.fadeTimer);
|
|
152
|
+
this.fadeTimer = void 0;
|
|
153
|
+
}
|
|
154
|
+
this.fading = false;
|
|
155
|
+
if (this.docMoveBound) {
|
|
156
|
+
this.doc.removeEventListener("mousemove", this.onDocMove);
|
|
157
|
+
this.docMoveBound = false;
|
|
158
|
+
}
|
|
159
|
+
this.teardownListeners();
|
|
160
|
+
if (this.anchor) {
|
|
161
|
+
if (anchorToTooltip.get(this.anchor) === this) {
|
|
162
|
+
anchorToTooltip.delete(this.anchor);
|
|
163
|
+
lazyObserver?.unobserve(this.anchor);
|
|
164
|
+
}
|
|
165
|
+
this.anchor = null;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
attributeChangedCallback(name) {
|
|
169
|
+
if (name === "delay" && this.listening) this.makeDebouncedShow();
|
|
170
|
+
}
|
|
171
|
+
/** (Re)build the show debounce with the CURRENT `delay` (rebuilt when the
|
|
172
|
+
* `delay` attribute changes). Re-armed on each hover move (trailing), and
|
|
173
|
+
* fed the latest cursor event, so it shows at the cursor and so moving back
|
|
174
|
+
* onto an anchor after the tooltip was dismissed re-arms it. */
|
|
175
|
+
makeDebouncedShow() {
|
|
176
|
+
this.debouncedShow?.cancel();
|
|
177
|
+
this.debouncedShow = debounce((e) => this.show(e), this.delay);
|
|
178
|
+
}
|
|
179
|
+
/** The element's OWN window / document. The class may be defined in a
|
|
180
|
+
* different realm than the element lives in (e.g. the docs playground
|
|
181
|
+
* renders into an iframe but reuses the parent page's element class), so
|
|
182
|
+
* the module-global `window`/`document` can point at the wrong frame.
|
|
183
|
+
* Everything viewport- or document-scoped (clamping, scroll/key/move
|
|
184
|
+
* listeners) must go through these so it's correct in any frame. */
|
|
185
|
+
get view() {
|
|
186
|
+
return this.ownerDocument?.defaultView ?? window;
|
|
187
|
+
}
|
|
188
|
+
get doc() {
|
|
189
|
+
return this.ownerDocument ?? document;
|
|
190
|
+
}
|
|
191
|
+
get isInteractive() {
|
|
192
|
+
return this.hasAttribute("interactive");
|
|
193
|
+
}
|
|
194
|
+
/** Pinned under the anchor (no cursor-following). Interactive implies this —
|
|
195
|
+
* you can't move into a bubble that's chasing the cursor. */
|
|
196
|
+
get isStatic() {
|
|
197
|
+
return this.hasAttribute("static") || this.isInteractive;
|
|
198
|
+
}
|
|
199
|
+
get prefersTop() {
|
|
200
|
+
return this.getAttribute("placement") === "top";
|
|
201
|
+
}
|
|
202
|
+
get delay() {
|
|
203
|
+
const attr = this.getAttribute("delay");
|
|
204
|
+
if (attr == null) return DEFAULT_DELAY;
|
|
205
|
+
const n = parseInt(attr, 10);
|
|
206
|
+
return Number.isFinite(n) ? n : DEFAULT_DELAY;
|
|
207
|
+
}
|
|
208
|
+
// --- positioning (sets only the shadow container's own transform) ---
|
|
209
|
+
positionToTarget = () => {
|
|
210
|
+
requestAnimationFrame(() => {
|
|
211
|
+
if (!this.anchor || !this.shown) return;
|
|
212
|
+
const a = this.anchor.getBoundingClientRect();
|
|
213
|
+
const box = this.container.getBoundingClientRect();
|
|
214
|
+
const view = this.view;
|
|
215
|
+
const vw = view.innerWidth;
|
|
216
|
+
const vh = view.innerHeight;
|
|
217
|
+
let left = a.left;
|
|
218
|
+
if (left + box.width > vw) left = vw - box.width - MARGIN;
|
|
219
|
+
left = Math.max(MARGIN, left);
|
|
220
|
+
let top;
|
|
221
|
+
if (this.prefersTop) {
|
|
222
|
+
top = a.top - box.height - MARGIN;
|
|
223
|
+
if (top < MARGIN) top = a.bottom + MARGIN;
|
|
224
|
+
} else {
|
|
225
|
+
top = a.bottom + MARGIN;
|
|
226
|
+
if (top + box.height > vh) top = a.top - box.height - MARGIN;
|
|
227
|
+
}
|
|
228
|
+
top = Math.max(MARGIN, top);
|
|
229
|
+
this.container.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
positionToMouse = (e) => {
|
|
233
|
+
requestAnimationFrame(() => {
|
|
234
|
+
if (!this.shown && !this.fading) return;
|
|
235
|
+
const box = this.container.getBoundingClientRect();
|
|
236
|
+
const view = this.view;
|
|
237
|
+
const vw = view.innerWidth;
|
|
238
|
+
const vh = view.innerHeight;
|
|
239
|
+
let left = e.clientX - PADDING_X;
|
|
240
|
+
if (left + box.width > vw) left = vw - box.width - MARGIN;
|
|
241
|
+
left = Math.max(MARGIN, left);
|
|
242
|
+
let top;
|
|
243
|
+
if (this.prefersTop) {
|
|
244
|
+
top = e.clientY - box.height - MARGIN * 2;
|
|
245
|
+
if (top < MARGIN) top = e.clientY + CURSOR_SIZE;
|
|
246
|
+
} else {
|
|
247
|
+
top = e.clientY + CURSOR_SIZE;
|
|
248
|
+
if (top + box.height > vh) top = e.clientY - box.height - MARGIN * 2;
|
|
249
|
+
}
|
|
250
|
+
top = Math.max(MARGIN, top);
|
|
251
|
+
this.container.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
position(e) {
|
|
255
|
+
if (!this.isStatic && e) this.positionToMouse(e);
|
|
256
|
+
else this.positionToTarget();
|
|
257
|
+
}
|
|
258
|
+
// --- show / hide ---
|
|
259
|
+
show = (e) => {
|
|
260
|
+
if (!this.anchor) return;
|
|
261
|
+
this.cancelHide();
|
|
262
|
+
if (currentOpen && currentOpen !== this && this.anchor.contains(currentOpen.anchor)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
claimOpen(this);
|
|
266
|
+
if (!this.shown) {
|
|
267
|
+
this.shown = true;
|
|
268
|
+
this.fading = false;
|
|
269
|
+
if (this.fadeTimer !== void 0) {
|
|
270
|
+
clearTimeout(this.fadeTimer);
|
|
271
|
+
this.fadeTimer = void 0;
|
|
272
|
+
}
|
|
273
|
+
this.container.showPopover();
|
|
274
|
+
this.view.addEventListener("scroll", this.hide, { capture: true, passive: true });
|
|
275
|
+
this.doc.addEventListener("keydown", this.onKeyDown, true);
|
|
276
|
+
if (!this.docMoveBound) {
|
|
277
|
+
this.doc.addEventListener("mousemove", this.onDocMove);
|
|
278
|
+
this.docMoveBound = true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
this.position(e);
|
|
282
|
+
};
|
|
283
|
+
hide = () => {
|
|
284
|
+
this.cancelHide();
|
|
285
|
+
if (!this.shown) return;
|
|
286
|
+
this.shown = false;
|
|
287
|
+
this.container.hidePopover();
|
|
288
|
+
this.view.removeEventListener("scroll", this.hide, { capture: true });
|
|
289
|
+
this.doc.removeEventListener("keydown", this.onKeyDown, true);
|
|
290
|
+
this.fading = true;
|
|
291
|
+
if (this.fadeTimer !== void 0) clearTimeout(this.fadeTimer);
|
|
292
|
+
this.fadeTimer = setTimeout(() => {
|
|
293
|
+
this.fading = false;
|
|
294
|
+
this.fadeTimer = void 0;
|
|
295
|
+
if (this.docMoveBound) {
|
|
296
|
+
this.doc.removeEventListener("mousemove", this.onDocMove);
|
|
297
|
+
this.docMoveBound = false;
|
|
298
|
+
}
|
|
299
|
+
}, FADE_MS);
|
|
300
|
+
releaseOpen(this);
|
|
301
|
+
};
|
|
302
|
+
/** While shown, track the cursor even after it has left the anchor (during
|
|
303
|
+
* the close delay). Cursor-following only — static/interactive bubbles
|
|
304
|
+
* stay pinned. */
|
|
305
|
+
onDocMove = (e) => {
|
|
306
|
+
if ((this.shown || this.fading) && !this.isStatic) {
|
|
307
|
+
this.lastMouse = e;
|
|
308
|
+
this.positionToMouse(e);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
/** Hide after CLOSE_DELAY unless something cancels it first (re-enter, or
|
|
312
|
+
* another tooltip claiming the slot). Lets the bubble bridge the gap to a
|
|
313
|
+
* neighbouring anchor — and survive the trip into an interactive bubble. */
|
|
314
|
+
scheduleHide = () => {
|
|
315
|
+
this.cancelHide();
|
|
316
|
+
this.closeTimer = setTimeout(() => {
|
|
317
|
+
this.closeTimer = void 0;
|
|
318
|
+
this.hide();
|
|
319
|
+
}, CLOSE_DELAY);
|
|
320
|
+
};
|
|
321
|
+
cancelHide() {
|
|
322
|
+
if (this.closeTimer !== void 0) {
|
|
323
|
+
clearTimeout(this.closeTimer);
|
|
324
|
+
this.closeTimer = void 0;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
onKeyDown = (e) => {
|
|
328
|
+
if (e.key === "Escape") this.hide();
|
|
329
|
+
};
|
|
330
|
+
/** Open now if another tooltip is hot (skip delay), else (re)arm the delayed
|
|
331
|
+
* show with the latest cursor event. */
|
|
332
|
+
trigger(e) {
|
|
333
|
+
if (isHot()) {
|
|
334
|
+
this.debouncedShow?.cancel();
|
|
335
|
+
this.show(e);
|
|
336
|
+
} else {
|
|
337
|
+
this.debouncedShow?.(e);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
// --- lazy listener wiring (called by the intersection observer) ---
|
|
341
|
+
setupListeners() {
|
|
342
|
+
if (this.listening || !this.anchor) {
|
|
343
|
+
this.listening = true;
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
const anchor = this.anchor;
|
|
347
|
+
const view = this.view;
|
|
348
|
+
const doc = this.doc;
|
|
349
|
+
this.makeDebouncedShow();
|
|
350
|
+
const onMouseMove = (e) => {
|
|
351
|
+
this.lastMouse = e;
|
|
352
|
+
if (this.shown) {
|
|
353
|
+
if (!this.isStatic) this.positionToMouse(e);
|
|
354
|
+
} else {
|
|
355
|
+
this.trigger(e);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const onLeave = () => {
|
|
359
|
+
this.debouncedShow?.cancel();
|
|
360
|
+
anchor.removeEventListener("mousemove", onMouseMove);
|
|
361
|
+
anchor.removeEventListener("mouseleave", onLeave);
|
|
362
|
+
anchor.removeEventListener("blur", onLeave);
|
|
363
|
+
view.removeEventListener("pagehide", onLeave);
|
|
364
|
+
doc.removeEventListener("visibilitychange", onLeave);
|
|
365
|
+
this.scheduleHide();
|
|
366
|
+
};
|
|
367
|
+
const onEnter = (e) => {
|
|
368
|
+
this.lastMouse = e;
|
|
369
|
+
anchor.addEventListener("mousemove", onMouseMove);
|
|
370
|
+
anchor.addEventListener("mouseleave", onLeave);
|
|
371
|
+
view.addEventListener("pagehide", onLeave);
|
|
372
|
+
doc.addEventListener("visibilitychange", onLeave);
|
|
373
|
+
this.trigger(e);
|
|
374
|
+
};
|
|
375
|
+
const onFocus = () => {
|
|
376
|
+
anchor.addEventListener("blur", onLeave);
|
|
377
|
+
view.addEventListener("pagehide", onLeave);
|
|
378
|
+
doc.addEventListener("visibilitychange", onLeave);
|
|
379
|
+
this.trigger();
|
|
380
|
+
};
|
|
381
|
+
anchor.addEventListener("mouseenter", onEnter);
|
|
382
|
+
anchor.addEventListener("focus", onFocus);
|
|
383
|
+
this.teardown = () => {
|
|
384
|
+
this.debouncedShow?.cancel();
|
|
385
|
+
anchor.removeEventListener("mousemove", onMouseMove);
|
|
386
|
+
anchor.removeEventListener("mouseenter", onEnter);
|
|
387
|
+
anchor.removeEventListener("mouseleave", onLeave);
|
|
388
|
+
anchor.removeEventListener("focus", onFocus);
|
|
389
|
+
anchor.removeEventListener("blur", onLeave);
|
|
390
|
+
view.removeEventListener("pagehide", onLeave);
|
|
391
|
+
doc.removeEventListener("visibilitychange", onLeave);
|
|
392
|
+
this.listening = false;
|
|
393
|
+
};
|
|
394
|
+
this.listening = true;
|
|
395
|
+
}
|
|
396
|
+
teardownListeners() {
|
|
397
|
+
this.teardown?.();
|
|
398
|
+
this.teardown = void 0;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
function register_a_tooltip() {
|
|
402
|
+
if (typeof customElements === "undefined") return;
|
|
403
|
+
if (!customElements.get("a-tooltip")) {
|
|
404
|
+
customElements.define("a-tooltip", ATooltipElement);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
register_a_tooltip();
|
|
408
|
+
export {
|
|
409
|
+
ATooltipElement,
|
|
410
|
+
register_a_tooltip
|
|
411
|
+
};
|
package/dist/elements/index.d.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Barrel: registers ALL Anta custom elements (the convenience path).
|
|
3
|
+
*
|
|
4
|
+
* Each `a-{name}` module self-registers and imports its own CSS when loaded,
|
|
5
|
+
* so re-exporting them here (which evaluates each module) registers the whole
|
|
6
|
+
* set + injects every element's CSS. Importing this barrel for side effects —
|
|
7
|
+
* `import '@antadesign/anta/elements'` — gives you everything.
|
|
8
|
+
*
|
|
9
|
+
* For a SMALLER footprint, import just the element(s) you use instead:
|
|
10
|
+
* import '@antadesign/anta/elements/a-tooltip' // registers a-tooltip + its CSS, nothing else
|
|
11
|
+
* That granular path pulls in only that element's code (e.g. it won't drag in
|
|
12
|
+
* `lottie-web`, which only `a-sticker-animated` needs).
|
|
13
|
+
*
|
|
14
|
+
* Must only be imported client-side — registration is guarded against missing
|
|
15
|
+
* `customElements` (SSR), but there's no reason to load it server-side.
|
|
16
|
+
*/
|
|
6
17
|
export { AProgressElement, register_a_progress } from './a-progress';
|
|
7
18
|
export { ATextElement, register_a_text } from './a-text';
|
|
8
19
|
export { AIconElement, register_a_icon } from './a-icon';
|
|
20
|
+
export { AButtonElement, register_a_button } from './a-button';
|
|
21
|
+
export { AStickerElement, register_a_sticker } from './a-sticker';
|
|
22
|
+
export { AStickerAnimatedElement, register_a_sticker_animated } from './a-sticker-animated';
|
|
23
|
+
export { ATooltipElement, register_a_tooltip } from './a-tooltip';
|
|
24
|
+
import './a-title.css';
|
package/dist/elements/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { register_a_progress } from "./a-progress";
|
|
2
|
-
import { register_a_text } from "./a-text";
|
|
3
|
-
import { register_a_icon } from "./a-icon";
|
|
4
|
-
import "./a-
|
|
5
|
-
import "./a-
|
|
1
|
+
import { AProgressElement, register_a_progress } from "./a-progress";
|
|
2
|
+
import { ATextElement, register_a_text } from "./a-text";
|
|
3
|
+
import { AIconElement, register_a_icon } from "./a-icon";
|
|
4
|
+
import { AButtonElement, register_a_button } from "./a-button";
|
|
5
|
+
import { AStickerElement, register_a_sticker } from "./a-sticker";
|
|
6
|
+
import { AStickerAnimatedElement, register_a_sticker_animated } from "./a-sticker-animated";
|
|
7
|
+
import { ATooltipElement, register_a_tooltip } from "./a-tooltip";
|
|
6
8
|
import "./a-title.css";
|
|
7
|
-
import "./a-icon.css";
|
|
8
|
-
import "./a-icon.shapes.css";
|
|
9
|
-
import { AProgressElement, register_a_progress as register_a_progress2 } from "./a-progress";
|
|
10
|
-
import { ATextElement, register_a_text as register_a_text2 } from "./a-text";
|
|
11
|
-
import { AIconElement, register_a_icon as register_a_icon2 } from "./a-icon";
|
|
12
|
-
if (typeof customElements !== "undefined") {
|
|
13
|
-
register_a_progress();
|
|
14
|
-
register_a_text();
|
|
15
|
-
register_a_icon();
|
|
16
|
-
}
|
|
17
9
|
export {
|
|
10
|
+
AButtonElement,
|
|
18
11
|
AIconElement,
|
|
19
12
|
AProgressElement,
|
|
13
|
+
AStickerAnimatedElement,
|
|
14
|
+
AStickerElement,
|
|
20
15
|
ATextElement,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
ATooltipElement,
|
|
17
|
+
register_a_button,
|
|
18
|
+
register_a_icon,
|
|
19
|
+
register_a_progress,
|
|
20
|
+
register_a_sticker,
|
|
21
|
+
register_a_sticker_animated,
|
|
22
|
+
register_a_text,
|
|
23
|
+
register_a_tooltip
|
|
24
24
|
};
|
package/dist/general_types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IconShape } from './elements/a-icon.shapes';
|
|
1
2
|
/** Common props for JSX component wrappers. */
|
|
2
3
|
export interface BaseProps {
|
|
3
4
|
/** CSS class name. Merged with any internal classes by the component. */
|
|
@@ -6,9 +7,21 @@ export interface BaseProps {
|
|
|
6
7
|
style?: React.CSSProperties;
|
|
7
8
|
/** Child elements. When provided, replaces the component's default label/content. */
|
|
8
9
|
children?: React.ReactNode;
|
|
10
|
+
/** HTML `id` attribute. */
|
|
11
|
+
id?: string;
|
|
12
|
+
/** HTML `title` attribute — native browser tooltip on hover. */
|
|
13
|
+
title?: string;
|
|
14
|
+
/** Tab order. Set to `-1` to skip the element when tabbing. */
|
|
15
|
+
tabIndex?: number;
|
|
16
|
+
/** Any `data-*` attribute is forwarded to the rendered element. */
|
|
17
|
+
[key: `data-${string}`]: unknown;
|
|
18
|
+
/** Any `aria-*` attribute is forwarded to the rendered element. */
|
|
19
|
+
[key: `aria-${string}`]: unknown;
|
|
9
20
|
}
|
|
10
21
|
/** Attributes for intrinsic custom elements (`<a-*>` tags) in JSX. */
|
|
11
22
|
export interface BaseAttributes {
|
|
23
|
+
/** React/Preact reconciliation key when rendered inside a list. */
|
|
24
|
+
key?: string | number | null;
|
|
12
25
|
/** HTML `class` attribute (standard DOM). */
|
|
13
26
|
class?: string;
|
|
14
27
|
/** React/Preact-style class name. Alias for `class`. */
|
|
@@ -63,7 +76,7 @@ export interface ATextAttributes extends BaseAttributes {
|
|
|
63
76
|
/** Type scale. `small` = 13/16, `medium` (default) = 15/20, `large` = 17/24. */
|
|
64
77
|
size?: 'small' | 'medium' | 'large';
|
|
65
78
|
/** Render as inline-block instead of the default block. */
|
|
66
|
-
inline?: boolean |
|
|
79
|
+
inline?: boolean | '';
|
|
67
80
|
/** Truncate to N lines with a trailing ellipsis. The attribute value
|
|
68
81
|
* carries the line count (e.g. `"1"`, `"3"`); the count is also
|
|
69
82
|
* available via the `--line-clamp` CSS custom property set inline. */
|
|
@@ -71,7 +84,7 @@ export interface ATextAttributes extends BaseAttributes {
|
|
|
71
84
|
/** Marks the host as expandable when paired with `truncate`. Adds
|
|
72
85
|
* the fade-out mask; the JSX wrapper renders the chevron and owns
|
|
73
86
|
* the click/keyboard expansion logic. */
|
|
74
|
-
expandable?: boolean |
|
|
87
|
+
expandable?: boolean | '';
|
|
75
88
|
/** ARIA disclosure state, mirrors the JSX wrapper's `expanded` flag. */
|
|
76
89
|
'aria-expanded'?: boolean | 'true' | 'false';
|
|
77
90
|
}
|
|
@@ -95,13 +108,54 @@ export interface ATitleAttributes extends BaseAttributes {
|
|
|
95
108
|
'aria-level'?: number | string;
|
|
96
109
|
}
|
|
97
110
|
/**
|
|
98
|
-
* Attributes for the `<a-
|
|
99
|
-
*
|
|
100
|
-
*
|
|
111
|
+
* Attributes for the `<a-sticker>` static sticker carrier.
|
|
112
|
+
*
|
|
113
|
+
* The SVG payload is passed as the `svg` attribute — a markup string.
|
|
114
|
+
* On change, the element writes it into its shadow DOM (no light-DOM
|
|
115
|
+
* `<slot>`, so children aren't rendered). The JSX wrapper
|
|
116
|
+
* (`Sticker{Name}`) sets it from the per-sticker module's inlined SVG.
|
|
117
|
+
* Sizing comes from `--sticker-size`.
|
|
118
|
+
*/
|
|
119
|
+
export interface AStickerAttributes extends BaseAttributes {
|
|
120
|
+
/** SVG markup string. On change the element drops it into its shadow
|
|
121
|
+
* DOM (`innerHTML`). */
|
|
122
|
+
svg?: string;
|
|
123
|
+
role?: string;
|
|
124
|
+
'aria-label'?: string;
|
|
125
|
+
'aria-hidden'?: 'true' | 'false' | boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Attributes for the `<a-sticker-animated>` Lottie sticker carrier.
|
|
129
|
+
*
|
|
130
|
+
* The Lottie payload is passed as the `animation` attribute — a JSON
|
|
131
|
+
* string. On change the element `JSON.parse`s it once and drives a
|
|
132
|
+
* `lottie-web` player (SVG renderer) inside its shadow DOM. The JSX
|
|
133
|
+
* wrapper (`Sticker{Name}Animated`) sets it from the per-sticker
|
|
134
|
+
* module's inlined JSON. Sizing comes from the `--sticker-size` CSS
|
|
135
|
+
* variable; `paused` controls playback.
|
|
136
|
+
*/
|
|
137
|
+
export interface AStickerAnimatedAttributes extends BaseAttributes {
|
|
138
|
+
/** Lottie payload as a JSON string. The element parses it once on
|
|
139
|
+
* change. */
|
|
140
|
+
animation?: string;
|
|
141
|
+
/** Present (any string value, including `""`) freezes the animation.
|
|
142
|
+
* A numeric string is parsed as seconds and the player seeks to
|
|
143
|
+
* that time before pausing. Omit to play. */
|
|
144
|
+
paused?: string | boolean | number;
|
|
145
|
+
role?: string;
|
|
146
|
+
'aria-label'?: string;
|
|
147
|
+
'aria-hidden'?: 'true' | 'false' | boolean;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Attributes for the `<a-icon>` custom element. `shape` is typed as
|
|
151
|
+
* `IconShape` (`keyof IconShapes`); the `IconShapes` interface is
|
|
152
|
+
* module-augmentable, so consumers who generate their own shape sets
|
|
153
|
+
* via `declare module '@antadesign/anta' { interface IconShapes { … } }`
|
|
154
|
+
* get those keys accepted automatically.
|
|
101
155
|
*/
|
|
102
156
|
export interface AIconAttributes extends BaseAttributes {
|
|
103
157
|
/** Which icon to render. */
|
|
104
|
-
shape?:
|
|
158
|
+
shape?: IconShape;
|
|
105
159
|
/** Width and height in pixels. Mapped to the `--icon-size` custom
|
|
106
160
|
* property via the CSS Values 5 typed `attr()` function — Chrome
|
|
107
161
|
* 133+ and Safari 18.2+ only. Firefox hasn't shipped typed
|
|
@@ -119,3 +173,53 @@ export interface AIconAttributes extends BaseAttributes {
|
|
|
119
173
|
/** Hides decorative icons from screen readers. */
|
|
120
174
|
'aria-hidden'?: 'true' | 'false' | boolean;
|
|
121
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Attributes for the `<a-tooltip>` custom element. Placed as a child of the
|
|
178
|
+
* element it annotates (content as children). For the typed JSX wrapper use
|
|
179
|
+
* `Tooltip` from `@antadesign/anta`.
|
|
180
|
+
*/
|
|
181
|
+
export interface ATooltipAttributes extends BaseAttributes {
|
|
182
|
+
/** Show delay in milliseconds. Never use `0` — use ~`50`. Defaults to 250. */
|
|
183
|
+
delay?: number | string;
|
|
184
|
+
/** Preferred side; auto-flips when there's no room. Defaults to `'bottom'`. */
|
|
185
|
+
placement?: 'top' | 'bottom';
|
|
186
|
+
/** Pin under the anchor instead of following the cursor. Presence-based
|
|
187
|
+
* (`''` on, omit off). */
|
|
188
|
+
static?: boolean | '';
|
|
189
|
+
/** Make the bubble hoverable/clickable (pointer events on, stays open while
|
|
190
|
+
* hovered). Implies `static`. Presence-based (`''` on, omit off). */
|
|
191
|
+
interactive?: boolean | '';
|
|
192
|
+
/** HTML `id`. */
|
|
193
|
+
id?: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Attributes for the `<a-button>` custom element. For the typed JSX
|
|
197
|
+
* wrapper use `Button` from `@antadesign/anta`.
|
|
198
|
+
*/
|
|
199
|
+
export interface AButtonAttributes extends BaseAttributes {
|
|
200
|
+
/** Visual emphasis. */
|
|
201
|
+
priority?: 'primary' | 'secondary' | 'tertiary' | 'quaternary';
|
|
202
|
+
/** Semantic tone, or any literal CSS color for a one-off custom tone. */
|
|
203
|
+
tone?: 'neutral' | 'brand' | 'critical' | 'info' | 'success' | 'warning' | (string & {});
|
|
204
|
+
/** Underline style. Only renders on `priority="tertiary" | "quaternary"`. */
|
|
205
|
+
underline?: 'solid' | 'dashed' | 'dotted';
|
|
206
|
+
/** Size variant. small=22px, medium=26px, large=30px. */
|
|
207
|
+
size?: 'small' | 'medium' | 'large';
|
|
208
|
+
/** Drop outer padding to zero. Only takes effect on `priority="quaternary"`.
|
|
209
|
+
* Presence-based: `''` (or any value) turns it on; omit to turn off. */
|
|
210
|
+
paddingless?: boolean | '';
|
|
211
|
+
/** Loading state. Presence-based (`''` on, omit off). */
|
|
212
|
+
loading?: boolean | '';
|
|
213
|
+
/** Disabled state. Presence-based (`''` on, omit off). */
|
|
214
|
+
disabled?: boolean | '';
|
|
215
|
+
/** Toggled-on / pressed state. Presence-based (`''` on, omit off). */
|
|
216
|
+
selected?: boolean | '';
|
|
217
|
+
/** Submit/reset semantics. */
|
|
218
|
+
type?: 'button' | 'submit' | 'reset';
|
|
219
|
+
/** Associate with a form by id when not nested inside it. */
|
|
220
|
+
form?: string;
|
|
221
|
+
/** Custom event name dispatched (bubbling) on click. */
|
|
222
|
+
'data-custom-event'?: string;
|
|
223
|
+
'aria-disabled'?: 'true' | 'false' | boolean;
|
|
224
|
+
'aria-busy'?: 'true' | 'false' | boolean;
|
|
225
|
+
}
|