@antadesign/anta 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/README.md +40 -1
  2. package/dist/components/Button.js +6 -3
  3. package/dist/components/Progress.module.css +0 -5
  4. package/dist/components/Text.module.css +0 -6
  5. package/dist/components/Tooltip.d.ts +19 -9
  6. package/dist/components/Tooltip.js +2 -2
  7. package/dist/elements/a-button.css +1 -756
  8. package/dist/elements/a-icon.css +1 -43
  9. package/dist/elements/a-icon.shapes.css +1 -377
  10. package/dist/elements/a-icon.shapes.d.ts +2 -2
  11. package/dist/elements/a-icon.shapes.js +2 -2
  12. package/dist/elements/a-progress.css +1 -68
  13. package/dist/elements/a-tag.css +1 -196
  14. package/dist/elements/a-text.css +1 -90
  15. package/dist/elements/a-title.css +1 -64
  16. package/dist/elements/a-tooltip.css +1 -62
  17. package/dist/elements/a-tooltip.d.ts +25 -7
  18. package/dist/elements/a-tooltip.js +114 -69
  19. package/dist/general_types.d.ts +4 -4
  20. package/dist/index.d.ts +1 -0
  21. package/dist/jsx-runtime.d.ts +17 -15
  22. package/dist/reset.css +1 -209
  23. package/dist/tokens.css +1 -285
  24. package/package.json +6 -4
  25. package/dist/components/Button.module.css +0 -2
  26. package/dist/components/Menu.d.ts +0 -61
  27. package/dist/components/Menu.js +0 -34
  28. package/dist/components/MenuGroup.d.ts +0 -24
  29. package/dist/components/MenuGroup.js +0 -19
  30. package/dist/components/MenuItem.d.ts +0 -49
  31. package/dist/components/MenuItem.js +0 -40
  32. package/dist/components/MenuSeparator.d.ts +0 -14
  33. package/dist/components/MenuSeparator.js +0 -7
  34. package/dist/components/Sticker.d.ts +0 -31
  35. package/dist/components/Sticker.js +0 -17
  36. package/dist/components/StickerAnimated.d.ts +0 -23
  37. package/dist/components/StickerAnimated.js +0 -28
  38. package/dist/components/__generated__/stickers/angry-animated.d.ts +0 -3
  39. package/dist/components/__generated__/stickers/angry-animated.js +0 -7
  40. package/dist/components/__generated__/stickers/angry.d.ts +0 -3
  41. package/dist/components/__generated__/stickers/angry.js +0 -7
  42. package/dist/components/__generated__/stickers/ask-animated.d.ts +0 -3
  43. package/dist/components/__generated__/stickers/ask-animated.js +0 -7
  44. package/dist/components/__generated__/stickers/ask.d.ts +0 -3
  45. package/dist/components/__generated__/stickers/ask.js +0 -7
  46. package/dist/components/__generated__/stickers/balance-animated.d.ts +0 -3
  47. package/dist/components/__generated__/stickers/balance-animated.js +0 -7
  48. package/dist/components/__generated__/stickers/balance.d.ts +0 -3
  49. package/dist/components/__generated__/stickers/balance.js +0 -7
  50. package/dist/components/__generated__/stickers/butterfly-animated.d.ts +0 -3
  51. package/dist/components/__generated__/stickers/butterfly-animated.js +0 -7
  52. package/dist/components/__generated__/stickers/butterfly-snake-animated.d.ts +0 -3
  53. package/dist/components/__generated__/stickers/butterfly-snake-animated.js +0 -7
  54. package/dist/components/__generated__/stickers/butterfly-snake.d.ts +0 -3
  55. package/dist/components/__generated__/stickers/butterfly-snake.js +0 -7
  56. package/dist/components/__generated__/stickers/butterfly.d.ts +0 -3
  57. package/dist/components/__generated__/stickers/butterfly.js +0 -7
  58. package/dist/components/__generated__/stickers/catch-animated.d.ts +0 -3
  59. package/dist/components/__generated__/stickers/catch-animated.js +0 -7
  60. package/dist/components/__generated__/stickers/catch.d.ts +0 -3
  61. package/dist/components/__generated__/stickers/catch.js +0 -7
  62. package/dist/components/__generated__/stickers/clap-animated.d.ts +0 -3
  63. package/dist/components/__generated__/stickers/clap-animated.js +0 -7
  64. package/dist/components/__generated__/stickers/clap.d.ts +0 -3
  65. package/dist/components/__generated__/stickers/clap.js +0 -7
  66. package/dist/components/__generated__/stickers/coding-animated.d.ts +0 -3
  67. package/dist/components/__generated__/stickers/coding-animated.js +0 -7
  68. package/dist/components/__generated__/stickers/coding.d.ts +0 -3
  69. package/dist/components/__generated__/stickers/coding.js +0 -7
  70. package/dist/components/__generated__/stickers/cowboy-animated.d.ts +0 -3
  71. package/dist/components/__generated__/stickers/cowboy-animated.js +0 -7
  72. package/dist/components/__generated__/stickers/cowboy.d.ts +0 -3
  73. package/dist/components/__generated__/stickers/cowboy.js +0 -7
  74. package/dist/components/__generated__/stickers/dance-animated.d.ts +0 -3
  75. package/dist/components/__generated__/stickers/dance-animated.js +0 -7
  76. package/dist/components/__generated__/stickers/dance.d.ts +0 -3
  77. package/dist/components/__generated__/stickers/dance.js +0 -7
  78. package/dist/components/__generated__/stickers/detective-animated.d.ts +0 -3
  79. package/dist/components/__generated__/stickers/detective-animated.js +0 -7
  80. package/dist/components/__generated__/stickers/detective.d.ts +0 -3
  81. package/dist/components/__generated__/stickers/detective.js +0 -7
  82. package/dist/components/__generated__/stickers/disapprove-animated.d.ts +0 -3
  83. package/dist/components/__generated__/stickers/disapprove-animated.js +0 -7
  84. package/dist/components/__generated__/stickers/disapprove.d.ts +0 -3
  85. package/dist/components/__generated__/stickers/disapprove.js +0 -7
  86. package/dist/components/__generated__/stickers/distracted-animated.d.ts +0 -3
  87. package/dist/components/__generated__/stickers/distracted-animated.js +0 -7
  88. package/dist/components/__generated__/stickers/distracted.d.ts +0 -3
  89. package/dist/components/__generated__/stickers/distracted.js +0 -7
  90. package/dist/components/__generated__/stickers/dive-animated.d.ts +0 -3
  91. package/dist/components/__generated__/stickers/dive-animated.js +0 -7
  92. package/dist/components/__generated__/stickers/dive.d.ts +0 -3
  93. package/dist/components/__generated__/stickers/dive.js +0 -7
  94. package/dist/components/__generated__/stickers/eat-animated.d.ts +0 -3
  95. package/dist/components/__generated__/stickers/eat-animated.js +0 -7
  96. package/dist/components/__generated__/stickers/eat.d.ts +0 -3
  97. package/dist/components/__generated__/stickers/eat.js +0 -7
  98. package/dist/components/__generated__/stickers/facepalm-animated.d.ts +0 -3
  99. package/dist/components/__generated__/stickers/facepalm-animated.js +0 -7
  100. package/dist/components/__generated__/stickers/facepalm.d.ts +0 -3
  101. package/dist/components/__generated__/stickers/facepalm.js +0 -7
  102. package/dist/components/__generated__/stickers/failed-animated.d.ts +0 -3
  103. package/dist/components/__generated__/stickers/failed-animated.js +0 -7
  104. package/dist/components/__generated__/stickers/failed.d.ts +0 -3
  105. package/dist/components/__generated__/stickers/failed.js +0 -7
  106. package/dist/components/__generated__/stickers/found-animated.d.ts +0 -3
  107. package/dist/components/__generated__/stickers/found-animated.js +0 -7
  108. package/dist/components/__generated__/stickers/found.d.ts +0 -3
  109. package/dist/components/__generated__/stickers/found.js +0 -7
  110. package/dist/components/__generated__/stickers/grow-animated.d.ts +0 -3
  111. package/dist/components/__generated__/stickers/grow-animated.js +0 -7
  112. package/dist/components/__generated__/stickers/grow.d.ts +0 -3
  113. package/dist/components/__generated__/stickers/grow.js +0 -7
  114. package/dist/components/__generated__/stickers/handstand-animated.d.ts +0 -3
  115. package/dist/components/__generated__/stickers/handstand-animated.js +0 -7
  116. package/dist/components/__generated__/stickers/handstand.d.ts +0 -3
  117. package/dist/components/__generated__/stickers/handstand.js +0 -7
  118. package/dist/components/__generated__/stickers/heart-animated.d.ts +0 -3
  119. package/dist/components/__generated__/stickers/heart-animated.js +0 -7
  120. package/dist/components/__generated__/stickers/heart.d.ts +0 -3
  121. package/dist/components/__generated__/stickers/heart.js +0 -7
  122. package/dist/components/__generated__/stickers/hello-animated.d.ts +0 -3
  123. package/dist/components/__generated__/stickers/hello-animated.js +0 -7
  124. package/dist/components/__generated__/stickers/hello.d.ts +0 -3
  125. package/dist/components/__generated__/stickers/hello.js +0 -7
  126. package/dist/components/__generated__/stickers/idea-animated.d.ts +0 -3
  127. package/dist/components/__generated__/stickers/idea-animated.js +0 -7
  128. package/dist/components/__generated__/stickers/idea.d.ts +0 -3
  129. package/dist/components/__generated__/stickers/idea.js +0 -7
  130. package/dist/components/__generated__/stickers/index.d.ts +0 -99
  131. package/dist/components/__generated__/stickers/index.js +0 -198
  132. package/dist/components/__generated__/stickers/laugh-animated.d.ts +0 -3
  133. package/dist/components/__generated__/stickers/laugh-animated.js +0 -7
  134. package/dist/components/__generated__/stickers/laugh.d.ts +0 -3
  135. package/dist/components/__generated__/stickers/laugh.js +0 -7
  136. package/dist/components/__generated__/stickers/love-animated.d.ts +0 -3
  137. package/dist/components/__generated__/stickers/love-animated.js +0 -7
  138. package/dist/components/__generated__/stickers/love.d.ts +0 -3
  139. package/dist/components/__generated__/stickers/love.js +0 -7
  140. package/dist/components/__generated__/stickers/nap-animated.d.ts +0 -3
  141. package/dist/components/__generated__/stickers/nap-animated.js +0 -7
  142. package/dist/components/__generated__/stickers/nap.d.ts +0 -3
  143. package/dist/components/__generated__/stickers/nap.js +0 -7
  144. package/dist/components/__generated__/stickers/party-animated.d.ts +0 -3
  145. package/dist/components/__generated__/stickers/party-animated.js +0 -7
  146. package/dist/components/__generated__/stickers/party.d.ts +0 -3
  147. package/dist/components/__generated__/stickers/party.js +0 -7
  148. package/dist/components/__generated__/stickers/passed-animated.d.ts +0 -3
  149. package/dist/components/__generated__/stickers/passed-animated.js +0 -7
  150. package/dist/components/__generated__/stickers/passed.d.ts +0 -3
  151. package/dist/components/__generated__/stickers/passed.js +0 -7
  152. package/dist/components/__generated__/stickers/peekaboo-animated.d.ts +0 -3
  153. package/dist/components/__generated__/stickers/peekaboo-animated.js +0 -7
  154. package/dist/components/__generated__/stickers/peekaboo.d.ts +0 -3
  155. package/dist/components/__generated__/stickers/peekaboo.js +0 -7
  156. package/dist/components/__generated__/stickers/pizza-animated.d.ts +0 -3
  157. package/dist/components/__generated__/stickers/pizza-animated.js +0 -7
  158. package/dist/components/__generated__/stickers/pizza.d.ts +0 -3
  159. package/dist/components/__generated__/stickers/pizza.js +0 -7
  160. package/dist/components/__generated__/stickers/puzzle-animated.d.ts +0 -3
  161. package/dist/components/__generated__/stickers/puzzle-animated.js +0 -7
  162. package/dist/components/__generated__/stickers/puzzle.d.ts +0 -3
  163. package/dist/components/__generated__/stickers/puzzle.js +0 -7
  164. package/dist/components/__generated__/stickers/sad-animated.d.ts +0 -3
  165. package/dist/components/__generated__/stickers/sad-animated.js +0 -7
  166. package/dist/components/__generated__/stickers/sad.d.ts +0 -3
  167. package/dist/components/__generated__/stickers/sad.js +0 -7
  168. package/dist/components/__generated__/stickers/scared-animated.d.ts +0 -3
  169. package/dist/components/__generated__/stickers/scared-animated.js +0 -7
  170. package/dist/components/__generated__/stickers/scared.d.ts +0 -3
  171. package/dist/components/__generated__/stickers/scared.js +0 -7
  172. package/dist/components/__generated__/stickers/scroll-animated.d.ts +0 -3
  173. package/dist/components/__generated__/stickers/scroll-animated.js +0 -7
  174. package/dist/components/__generated__/stickers/scroll.d.ts +0 -3
  175. package/dist/components/__generated__/stickers/scroll.js +0 -7
  176. package/dist/components/__generated__/stickers/search-animated.d.ts +0 -3
  177. package/dist/components/__generated__/stickers/search-animated.js +0 -7
  178. package/dist/components/__generated__/stickers/search.d.ts +0 -3
  179. package/dist/components/__generated__/stickers/search.js +0 -7
  180. package/dist/components/__generated__/stickers/shield-animated.d.ts +0 -3
  181. package/dist/components/__generated__/stickers/shield-animated.js +0 -7
  182. package/dist/components/__generated__/stickers/shield.d.ts +0 -3
  183. package/dist/components/__generated__/stickers/shield.js +0 -7
  184. package/dist/components/__generated__/stickers/shocked-animated.d.ts +0 -3
  185. package/dist/components/__generated__/stickers/shocked-animated.js +0 -7
  186. package/dist/components/__generated__/stickers/shocked.d.ts +0 -3
  187. package/dist/components/__generated__/stickers/shocked.js +0 -7
  188. package/dist/components/__generated__/stickers/sleep-animated.d.ts +0 -3
  189. package/dist/components/__generated__/stickers/sleep-animated.js +0 -7
  190. package/dist/components/__generated__/stickers/sleep.d.ts +0 -3
  191. package/dist/components/__generated__/stickers/sleep.js +0 -7
  192. package/dist/components/__generated__/stickers/stressed-animated.d.ts +0 -3
  193. package/dist/components/__generated__/stickers/stressed-animated.js +0 -7
  194. package/dist/components/__generated__/stickers/stressed.d.ts +0 -3
  195. package/dist/components/__generated__/stickers/stressed.js +0 -7
  196. package/dist/components/__generated__/stickers/suspicious-animated.d.ts +0 -3
  197. package/dist/components/__generated__/stickers/suspicious-animated.js +0 -7
  198. package/dist/components/__generated__/stickers/suspicious.d.ts +0 -3
  199. package/dist/components/__generated__/stickers/suspicious.js +0 -7
  200. package/dist/components/__generated__/stickers/thanks-animated.d.ts +0 -3
  201. package/dist/components/__generated__/stickers/thanks-animated.js +0 -7
  202. package/dist/components/__generated__/stickers/thanks.d.ts +0 -3
  203. package/dist/components/__generated__/stickers/thanks.js +0 -7
  204. package/dist/components/__generated__/stickers/think-animated.d.ts +0 -3
  205. package/dist/components/__generated__/stickers/think-animated.js +0 -7
  206. package/dist/components/__generated__/stickers/think-of-you-animated.d.ts +0 -3
  207. package/dist/components/__generated__/stickers/think-of-you-animated.js +0 -7
  208. package/dist/components/__generated__/stickers/think-of-you.d.ts +0 -3
  209. package/dist/components/__generated__/stickers/think-of-you.js +0 -7
  210. package/dist/components/__generated__/stickers/think.d.ts +0 -3
  211. package/dist/components/__generated__/stickers/think.js +0 -7
  212. package/dist/components/__generated__/stickers/thumbs-up-animated.d.ts +0 -3
  213. package/dist/components/__generated__/stickers/thumbs-up-animated.js +0 -7
  214. package/dist/components/__generated__/stickers/thumbs-up.d.ts +0 -3
  215. package/dist/components/__generated__/stickers/thumbs-up.js +0 -7
  216. package/dist/components/__generated__/stickers/vacation-animated.d.ts +0 -3
  217. package/dist/components/__generated__/stickers/vacation-animated.js +0 -7
  218. package/dist/components/__generated__/stickers/vacation.d.ts +0 -3
  219. package/dist/components/__generated__/stickers/vacation.js +0 -7
  220. package/dist/components/__generated__/stickers/wait-animated.d.ts +0 -3
  221. package/dist/components/__generated__/stickers/wait-animated.js +0 -7
  222. package/dist/components/__generated__/stickers/wait.d.ts +0 -3
  223. package/dist/components/__generated__/stickers/wait.js +0 -7
  224. package/dist/components/__generated__/stickers/wink-animated.d.ts +0 -3
  225. package/dist/components/__generated__/stickers/wink-animated.js +0 -7
  226. package/dist/components/__generated__/stickers/wink.d.ts +0 -3
  227. package/dist/components/__generated__/stickers/wink.js +0 -7
  228. package/dist/components/__generated__/stickers/work-animated.d.ts +0 -3
  229. package/dist/components/__generated__/stickers/work-animated.js +0 -7
  230. package/dist/components/__generated__/stickers/work.d.ts +0 -3
  231. package/dist/components/__generated__/stickers/work.js +0 -7
  232. package/dist/components/__generated__/stickers/zen-animated.d.ts +0 -3
  233. package/dist/components/__generated__/stickers/zen-animated.js +0 -7
  234. package/dist/components/__generated__/stickers/zen.d.ts +0 -3
  235. package/dist/components/__generated__/stickers/zen.js +0 -7
  236. package/dist/elements/a-menu-group.css +0 -21
  237. package/dist/elements/a-menu-group.d.ts +0 -13
  238. package/dist/elements/a-menu-group.js +0 -15
  239. package/dist/elements/a-menu-item.css +0 -162
  240. package/dist/elements/a-menu-item.d.ts +0 -27
  241. package/dist/elements/a-menu-item.js +0 -29
  242. package/dist/elements/a-menu-separator.css +0 -15
  243. package/dist/elements/a-menu-separator.d.ts +0 -12
  244. package/dist/elements/a-menu-separator.js +0 -15
  245. package/dist/elements/a-menu.css +0 -34
  246. package/dist/elements/a-menu.d.ts +0 -120
  247. package/dist/elements/a-menu.js +0 -649
  248. package/dist/elements/a-sticker-animated.css +0 -9
  249. package/dist/elements/a-sticker-animated.d.ts +0 -39
  250. package/dist/elements/a-sticker-animated.js +0 -81
  251. package/dist/elements/a-sticker.css +0 -9
  252. package/dist/elements/a-sticker.d.ts +0 -19
  253. package/dist/elements/a-sticker.js +0 -32
  254. package/dist/generate-stickers.mjs +0 -293
@@ -8,6 +8,9 @@ const DEFAULT_DELAY = 250;
8
8
  const FADE_MS = 150;
9
9
  const GRACE_MS = 300;
10
10
  const CLOSE_DELAY = 120;
11
+ const PROX_NEAR = 10;
12
+ const PROX_FAR = 100;
13
+ const PROX_FADE_MS = 60;
11
14
  const ENTER_TOUCH_DELAY = 500;
12
15
  const LEAVE_TOUCH_DELAY = 1500;
13
16
  const TOUCH_SLOP = 10;
@@ -26,7 +29,10 @@ function clearGrace() {
26
29
  }
27
30
  }
28
31
  function claimOpen(el) {
29
- if (currentOpen && currentOpen !== el) currentOpen.hide();
32
+ if (currentOpen && currentOpen !== el) {
33
+ if (currentOpen.isConnected) currentOpen.hide();
34
+ else currentOpen.cleanup();
35
+ }
30
36
  currentOpen = el;
31
37
  clearGrace();
32
38
  }
@@ -58,6 +64,10 @@ class ATooltipElement extends HTMLElementBase {
58
64
  static observedAttributes = ["delay"];
59
65
  /** Shadow-internal popover surface — the only thing we ever mutate. */
60
66
  container;
67
+ /** Inner bubble inside `.container`. Holds the slot + all visual chrome and
68
+ * carries the proximity (distance-from-anchor) opacity, kept separate from
69
+ * the container's enter/exit/cross-fade opacity. */
70
+ bubble;
61
71
  anchor = null;
62
72
  listening = false;
63
73
  shown = false;
@@ -81,38 +91,47 @@ class ATooltipElement extends HTMLElementBase {
81
91
 
82
92
  .container {
83
93
  --_dur: ${FADE_MS}ms;
84
-
85
94
  position: fixed;
86
95
  left: 0;
87
96
  top: 0;
88
97
  margin: 0;
98
+ padding: 0;
99
+ border: 0;
100
+ background: transparent;
101
+ color: inherit;
102
+ overflow: visible;
103
+ box-sizing: border-box;
104
+ width: fit-content;
105
+ pointer-events: none;
106
+ opacity: 0;
107
+ transition:
108
+ opacity var(--_dur) ease,
109
+ overlay var(--_dur) ease allow-discrete,
110
+ display var(--_dur) ease allow-discrete;
111
+ }
112
+
113
+ .container:popover-open { opacity: 1; }
114
+
115
+ @starting-style {
116
+ .container:popover-open { opacity: 0; }
117
+ }
118
+
119
+ .bubble {
89
120
  box-sizing: border-box;
90
121
  width: fit-content;
91
122
  max-width: var(--tooltip-max-width, min(calc(100vw - 20px), 80ch));
92
123
  max-height: calc(100vh - 20px);
93
124
  overflow: clip;
94
- pointer-events: none;
95
125
  text-align: left;
96
-
97
126
  background: var(--tooltip-bg, Canvas);
98
127
  color: var(--text-3, CanvasText);
99
128
  box-shadow: var(--tooltip-shadow, 0 1px 8px rgba(0, 0, 0, 0.2));
100
129
  -webkit-backdrop-filter: var(--tooltip-backdrop-filter, blur(8px));
101
130
  backdrop-filter: var(--tooltip-backdrop-filter, blur(8px));
102
- padding: 5px 8px;
131
+ padding: var(--tooltip-padding, 4px 8px);
103
132
  border: var(--tooltip-border, none);
104
133
  border-radius: var(--tooltip-radius, 3px);
105
134
  outline: none;
106
-
107
- /* The bubble establishes its own text baseline so inheritable text
108
- properties from the anchor (e.g. a Button's condensed "wdth" 88
109
- axis, its 0.05ch letter-spacing, an uppercase transform, a custom
110
- font) don't bleed into the slotted content. The content is slotted
111
- light DOM, so it inherits these *from this container* \u2014 making this
112
- the single choke point. Values mirror Anta's body text. Consumers
113
- still customise a single tooltip by styling their own content
114
- element directly (a class on the content overrides what it inherits
115
- \u2014 see the Tooltip docs). */
116
135
  font-family: var(--sans-serif, system-ui, sans-serif);
117
136
  font-size: 14px;
118
137
  font-weight: 400;
@@ -126,34 +145,21 @@ class ATooltipElement extends HTMLElementBase {
126
145
  white-space: break-spaces;
127
146
  word-break: break-word;
128
147
  overflow-wrap: break-word;
129
-
130
- /* Clean enter/exit fade. allow-discrete keeps the bubble rendered
131
- through its fade-out after hidePopover(), and @starting-style
132
- gives every open a from-opacity:0 \u2014 so the first paint at a
133
- not-yet-computed transform is invisible (no flash at a stale
134
- spot), and re-appearing is always clean. */
135
- opacity: 0;
136
- transition:
137
- opacity var(--_dur) ease,
138
- overlay var(--_dur) ease allow-discrete,
139
- display var(--_dur) ease allow-discrete;
148
+ opacity: 1;
149
+ transition: opacity ${PROX_FADE_MS}ms linear;
140
150
  }
141
151
 
142
- .container:popover-open { opacity: 1; }
143
-
144
- @starting-style {
145
- .container:popover-open { opacity: 0; }
146
- }
147
-
148
- /* Interactive tooltips accept pointer events so their content (links,
149
- buttons) is clickable; the default click-through bubble does not. */
150
152
  :host([interactive]) .container { pointer-events: auto; }
151
153
  `;
152
154
  this.container = document.createElement("div");
153
155
  this.container.className = "container";
154
156
  this.container.setAttribute("popover", "manual");
155
157
  this.container.setAttribute("role", "tooltip");
156
- this.container.append(document.createElement("slot"));
158
+ this.bubble = document.createElement("div");
159
+ this.bubble.className = "bubble";
160
+ this.bubble.setAttribute("part", "bubble");
161
+ this.bubble.append(document.createElement("slot"));
162
+ this.container.append(this.bubble);
157
163
  this.container.addEventListener("mouseenter", () => {
158
164
  if (this.isInteractive) this.cancelHide();
159
165
  });
@@ -170,17 +176,7 @@ class ATooltipElement extends HTMLElementBase {
170
176
  lazyObserver?.observe(parent);
171
177
  }
172
178
  disconnectedCallback() {
173
- this.hide();
174
- if (this.fadeTimer !== void 0) {
175
- clearTimeout(this.fadeTimer);
176
- this.fadeTimer = void 0;
177
- }
178
- this.fading = false;
179
- if (this.docMoveBound) {
180
- this.doc.removeEventListener("mousemove", this.onDocMove);
181
- this.docMoveBound = false;
182
- }
183
- this.teardownListeners();
179
+ this.cleanup();
184
180
  if (this.anchor) {
185
181
  if (anchorToTooltip.get(this.anchor) === this) {
186
182
  anchorToTooltip.delete(this.anchor);
@@ -215,15 +211,13 @@ class ATooltipElement extends HTMLElementBase {
215
211
  get isInteractive() {
216
212
  return this.hasAttribute("interactive");
217
213
  }
218
- /** Pinned under the anchor (no cursor-following). Interactive implies this
219
- * you can't move into a bubble that's chasing the cursor. */
220
- get isStatic() {
221
- return this.hasAttribute("static") || this.isInteractive;
222
- }
223
- /** Pinned to the anchor for any reason: the `static`/`interactive` attrs, or
224
- * a touch long-press (a finger can't track a following bubble). */
214
+ /** Pinned under the anchor (no cursor-following) the DEFAULT. Following the
215
+ * cursor is opt-in via the `follow` attribute. `interactive` (you can't move
216
+ * into a bubble that chases the cursor) and a touch long-press (a finger
217
+ * can't track one) force pinned regardless of `follow`. */
225
218
  get isPinned() {
226
- return this.isStatic || this.touchOpen;
219
+ if (this.isInteractive || this.touchOpen) return true;
220
+ return !this.hasAttribute("follow");
227
221
  }
228
222
  get prefersTop() {
229
223
  return this.getAttribute("placement") === "top";
@@ -284,6 +278,19 @@ class ATooltipElement extends HTMLElementBase {
284
278
  if (!this.isPinned && e) this.positionToMouse(e);
285
279
  else this.positionToTarget();
286
280
  }
281
+ /** Opacity for the inner bubble from the cursor's distance to the anchor rect
282
+ * (0 inside the rect): 1 within PROX_NEAR, a linear ramp to 0 at PROX_FAR.
283
+ * Cursor-follow only — drives the "fade as you move away" behaviour. */
284
+ proximityOpacity(e) {
285
+ if (!this.anchor) return 1;
286
+ const r = this.anchor.getBoundingClientRect();
287
+ const dx = Math.max(r.left - e.clientX, 0, e.clientX - r.right);
288
+ const dy = Math.max(r.top - e.clientY, 0, e.clientY - r.bottom);
289
+ const dist = Math.hypot(dx, dy);
290
+ if (dist <= PROX_NEAR) return 1;
291
+ if (dist >= PROX_FAR) return 0;
292
+ return 1 - (dist - PROX_NEAR) / (PROX_FAR - PROX_NEAR);
293
+ }
287
294
  // --- show / hide ---
288
295
  show = (e) => {
289
296
  if (!this.anchor) return;
@@ -295,6 +302,7 @@ class ATooltipElement extends HTMLElementBase {
295
302
  if (!this.shown) {
296
303
  this.shown = true;
297
304
  this.fading = false;
305
+ this.bubble.style.opacity = "1";
298
306
  if (this.fadeTimer !== void 0) {
299
307
  clearTimeout(this.fadeTimer);
300
308
  this.fadeTimer = void 0;
@@ -315,28 +323,65 @@ class ATooltipElement extends HTMLElementBase {
315
323
  this.shown = false;
316
324
  this.touchOpen = false;
317
325
  this.container.hidePopover();
318
- this.view.removeEventListener("scroll", this.hide, { capture: true });
319
- this.doc.removeEventListener("keydown", this.onKeyDown, true);
320
326
  this.fading = true;
321
327
  if (this.fadeTimer !== void 0) clearTimeout(this.fadeTimer);
322
- this.fadeTimer = setTimeout(() => {
323
- this.fading = false;
324
- this.fadeTimer = void 0;
325
- if (this.docMoveBound) {
326
- this.doc.removeEventListener("mousemove", this.onDocMove);
327
- this.docMoveBound = false;
328
- }
329
- }, FADE_MS);
328
+ this.fadeTimer = setTimeout(() => this.detachGlobals(), FADE_MS);
330
329
  releaseOpen(this);
331
330
  };
331
+ /** Remove every document / window listener this element binds and stop the
332
+ * fade timer. Used by hide() (after the exit fade) and by cleanup()
333
+ * (immediately). Idempotent. */
334
+ detachGlobals() {
335
+ if (this.fadeTimer !== void 0) {
336
+ clearTimeout(this.fadeTimer);
337
+ this.fadeTimer = void 0;
338
+ }
339
+ this.fading = false;
340
+ this.view.removeEventListener("scroll", this.hide, { capture: true });
341
+ this.doc.removeEventListener("keydown", this.onKeyDown, true);
342
+ if (this.docMoveBound) {
343
+ this.doc.removeEventListener("mousemove", this.onDocMove);
344
+ this.docMoveBound = false;
345
+ }
346
+ }
347
+ /** Full, immediate teardown: close the popover now (no fade), detach every
348
+ * listener, clear all timers, release the coordinator slot, reset state.
349
+ * Idempotent. Called from disconnectedCallback, and from the orphan safety
350
+ * net (claimOpen / onDocMove) when the element is gone but
351
+ * disconnectedCallback didn't fire. Not `private` — the module coordinator
352
+ * calls it. */
353
+ cleanup() {
354
+ this.cancelHide();
355
+ if (this.shown) {
356
+ this.shown = false;
357
+ this.touchOpen = false;
358
+ if (this.container.matches(":popover-open")) this.container.hidePopover();
359
+ }
360
+ this.detachGlobals();
361
+ this.teardownListeners();
362
+ releaseOpen(this);
363
+ this.bubble.style.opacity = "";
364
+ }
332
365
  /** While shown, track the cursor even after it has left the anchor (during
333
- * the close delay). Cursor-following onlystatic/interactive bubbles
334
- * stay pinned. */
366
+ * the close delay). Only runs for `follow` tooltips pinned bubbles
367
+ * (the default, `interactive`, touch) stay put. */
335
368
  onDocMove = (e) => {
336
- if ((this.shown || this.fading) && !this.isPinned) {
337
- this.lastMouse = e;
338
- this.positionToMouse(e);
369
+ if (!this.isConnected) {
370
+ this.cleanup();
371
+ return;
372
+ }
373
+ if (!(this.shown || this.fading) || this.isPinned) return;
374
+ this.lastMouse = e;
375
+ const o = this.proximityOpacity(e);
376
+ if (o === 0) {
377
+ this.bubble.style.transition = "none";
378
+ this.bubble.style.opacity = "0";
379
+ if (this.shown) this.hide();
380
+ return;
339
381
  }
382
+ this.positionToMouse(e);
383
+ this.bubble.style.transition = "";
384
+ this.bubble.style.opacity = String(o);
340
385
  };
341
386
  /** Hide after CLOSE_DELAY unless something cancels it first (re-enter, or
342
387
  * another tooltip claiming the slot). Lets the bubble bridge the gap to a
@@ -163,11 +163,11 @@ export interface ATooltipAttributes extends BaseAttributes {
163
163
  delay?: number | string;
164
164
  /** Preferred side; auto-flips when there's no room. Defaults to `'bottom'`. */
165
165
  placement?: 'top' | 'bottom';
166
- /** Pin under the anchor instead of following the cursor. Presence-based
167
- * (`''` on, omit off). */
168
- static?: boolean | '';
166
+ /** Follow the cursor instead of pinning under the anchor (pinned is the
167
+ * default). Presence-based (`''` on, omit off). */
168
+ follow?: boolean | '';
169
169
  /** Make the bubble hoverable/clickable (pointer events on, stays open while
170
- * hovered). Implies `static`. Presence-based (`''` on, omit off). */
170
+ * hovered). Always pinned. Presence-based (`''` on, omit off). */
171
171
  interactive?: boolean | '';
172
172
  /** HTML `id`. */
173
173
  id?: string;
package/dist/index.d.ts CHANGED
@@ -33,6 +33,7 @@ export { Tooltip } from './components/Tooltip';
33
33
  export type { TooltipProps } from './components/Tooltip';
34
34
  export type { BaseProps, BaseAttributes } from './general_types';
35
35
  export { configure } from './jsx-runtime';
36
+ export type { AntaIntrinsicElements } from './jsx-runtime';
36
37
  /**
37
38
  * Seed interface for the icon shape registry. The generated
38
39
  * `a-icon.shapes.d.ts` augments this interface with one key per
@@ -24,20 +24,22 @@ export declare function jsxs(type: ComponentType, props: Record<string, unknown>
24
24
  export { _Fragment as Fragment };
25
25
  import type { AProgressAttributes, ATextAttributes, ATitleAttributes, ATagAttributes, AIconAttributes, AButtonAttributes, ATooltipAttributes, BaseAttributes } from './general_types';
26
26
  export declare namespace JSX {
27
- interface IntrinsicElements extends React.JSX.IntrinsicElements {
28
- 'a-progress': AProgressAttributes;
29
- 'a-progress-label': BaseAttributes;
30
- 'a-progress-number': BaseAttributes;
31
- 'a-progress-text': BaseAttributes;
32
- 'a-progress-hint': BaseAttributes;
33
- 'a-text': ATextAttributes;
34
- 'a-title': ATitleAttributes;
35
- 'a-tag': ATagAttributes;
36
- 'a-tag-label': BaseAttributes;
37
- 'a-tag-value': BaseAttributes;
38
- 'a-icon': AIconAttributes;
39
- 'a-button': AButtonAttributes;
40
- 'a-button-label': BaseAttributes;
41
- 'a-tooltip': ATooltipAttributes;
27
+ interface IntrinsicElements extends React.JSX.IntrinsicElements, AntaIntrinsicElements {
42
28
  }
43
29
  }
30
+ export interface AntaIntrinsicElements {
31
+ 'a-progress': AProgressAttributes;
32
+ 'a-progress-label': BaseAttributes;
33
+ 'a-progress-number': BaseAttributes;
34
+ 'a-progress-text': BaseAttributes;
35
+ 'a-progress-hint': BaseAttributes;
36
+ 'a-text': ATextAttributes;
37
+ 'a-title': ATitleAttributes;
38
+ 'a-tag': ATagAttributes;
39
+ 'a-tag-label': BaseAttributes;
40
+ 'a-tag-value': BaseAttributes;
41
+ 'a-icon': AIconAttributes;
42
+ 'a-button': AButtonAttributes;
43
+ 'a-button-label': BaseAttributes;
44
+ 'a-tooltip': ATooltipAttributes;
45
+ }
package/dist/reset.css CHANGED
@@ -1,209 +1 @@
1
- /* Anta's reset + typography defaults. All rules live in `@layer anta`
2
- so consumer-owned components (in `@layer components`) and utility
3
- frameworks (in `@layer utilities`) can override on demand. The
4
- layer-order declaration in `tokens.css` (`@layer base, anta,
5
- components, utilities;`) keeps Anta above any preflight resets in
6
- `@layer base` so a Tailwind import doesn't wipe Anta's typography. */
7
-
8
- @layer anta {
9
- /* ───── Structural reset ─────────────────────────────────────── */
10
-
11
- /* Modern box-sizing — pads and borders count inside the declared
12
- width/height. Universal selectors so `::before` / `::after`
13
- pseudo-elements follow the host. */
14
- *, *::before, *::after {
15
- box-sizing: border-box;
16
- }
17
-
18
- /* Zero out browser-default margins on every element. Apps build
19
- up their own spacing from explicit values rather than fighting
20
- the user-agent stylesheet. */
21
- * {
22
- margin: 0;
23
- }
24
-
25
- /* Replaced elements as block-level by default + cap to their
26
- container so a misplaced large image doesn't blow out the
27
- layout. Consumers re-inline them with `display: inline-block`
28
- where needed. */
29
- img, picture, video, canvas, svg {
30
- display: block;
31
- max-width: 100%;
32
- }
33
-
34
- /* Inherit typography into form controls — by default browsers
35
- reset font on these. */
36
- input, button, textarea, select {
37
- font: inherit;
38
- }
39
-
40
- /* Wrap long words rather than overflow; `text-wrap: pretty`
41
- balances widows on paragraphs, `text-wrap: balance` evens
42
- headlines across lines. */
43
- p, h1, h2, h3, h4, h5, h6 {
44
- overflow-wrap: break-word;
45
- }
46
- p {
47
- text-wrap: pretty;
48
- }
49
- h1, h2, h3, h4, h5, h6 {
50
- text-wrap: balance;
51
- }
52
-
53
- /* ───── Typography defaults — Anta opinion ───────────────────── */
54
-
55
- /* Raw headings adopt the same visual scale as `<Title level={n}>`
56
- so plain markup matches the component. Values are duplicated in
57
- `src/elements/a-title.css`; keep the two in lockstep. */
58
- h1, h2, h3, h4, h5, h6 {
59
- color: var(--text-1);
60
- font-weight: 584.62;
61
- letter-spacing: 0;
62
- }
63
-
64
- h1 { font-size: 28px; line-height: 32px; margin-block: 0 16px; }
65
- h2 { font-size: 24px; line-height: 28px; margin-block: 32px 12px; }
66
- h3 { font-size: 20px; line-height: 24px; margin-block: 24px 12px; }
67
- h4 { font-size: 17px; line-height: 20px; margin-block: 20px 8px; }
68
- h5 { font-size: 15px; line-height: 20px; margin-block: 16px 8px; }
69
- h6 { font-size: 13px; line-height: 16px; margin-block: 16px 4px; }
70
-
71
- strong {
72
- font-weight: 600;
73
- }
74
-
75
- /* Keep inline `<code>` from inflating the line box of the prose it
76
- sits in — `1em` pins its line height to its own font size. */
77
- code {
78
- line-height: 1em;
79
- }
80
-
81
- /* Prose lists (ul, ol) get a tight 3ch left padding so markers
82
- hug the text, and items get a small bottom margin so
83
- consecutive ones breathe. Markers are toned all the way down
84
- to --text-5 since they are visual scaffolding, not content. */
85
- ul, ol {
86
- padding-left: 3ch;
87
- }
88
- :is(ul, ol) > li {
89
- margin-bottom: 0.5em;
90
- }
91
- :is(ul, ol) > li::marker {
92
- color: var(--text-5);
93
- }
94
-
95
- /* `<menu>` is for command/option lists, not prose. By default
96
- browsers render it like a `<ul>` (disc markers, 40px padding);
97
- strip all of that so it's a clean semantic container ready to
98
- be styled. */
99
- menu {
100
- list-style: none;
101
- padding: 0;
102
- margin: 0;
103
- }
104
- menu > li {
105
- margin: 0;
106
- }
107
-
108
- /* Global link defaults. Hairline underline at 75% alpha;
109
- underline goes to currentColor (100%) and 1px on hover. Color
110
- comes from --link-color tokens, which auto-flip in dark mode.
111
- `:not(:where([role="button"]))` excludes anchor-buttons (`<a role="button">`,
112
- e.g. `<Button href>`): `a:link`/`a:visited` are pseudo-classes with the
113
- same (0,1,1) specificity as `a[role="button"]`, so without the exclusion
114
- they'd tie and win on source order, giving buttons link colour +
115
- underline. The `:where()` keeps the exclusion specificity-neutral so this
116
- base rule stays at (0,0,1)/(0,1,1) — a bare `:not([role="button"])` would
117
- add an attribute selector's weight and out-specify prose-link overrides
118
- like `a-text a` / the <Button> prose-link rule, leaving their links stuck
119
- on the global blue. Other contexts (nav, headings) still override as needed. */
120
- a:not(:where([role="button"])),
121
- a:not(:where([role="button"])):link,
122
- a:not(:where([role="button"])):visited {
123
- color: var(--link-color);
124
- text-decoration: underline;
125
- text-decoration-style: solid;
126
- text-decoration-color: color-mix(in srgb, currentColor 75%, transparent);
127
- text-decoration-thickness: 0.5px;
128
- text-underline-offset: 3px;
129
- }
130
- /* Hover only on real-pointer devices — gating avoids the sticky hover
131
- color that lingers after a tap on touch screens. */
132
- @media (hover: hover) and (pointer: fine) {
133
- a:not(:where([role="button"])):hover {
134
- color: var(--link-color-hover);
135
- /* Underline color is left as the resting hairline (the base rule's
136
- `currentColor` mix) — only the thickness grows on hover. */
137
- text-decoration-thickness: 1px;
138
- }
139
- }
140
- a:not(:where([role="button"])):active {
141
- text-decoration-color: color-mix(in srgb, currentColor 75%, transparent);
142
- }
143
-
144
- /* Text selection — brand color at 15% alpha. */
145
- ::selection {
146
- background: color-mix(in srgb, var(--text-1-brand), transparent 85%);
147
- }
148
-
149
- /* ───── Tables ───────────────────────────────────────────────── */
150
-
151
- /* Polite, element-level baseline. Rules live in `@layer anta`, so
152
- any consumer rule outside a layer — or in `components` /
153
- `utilities` — overrides without effort. Width is intentionally
154
- left untouched so app tables stay inline-sized; full-bleed is a
155
- decision for the surrounding page. */
156
- table {
157
- border-collapse: collapse;
158
- font-variant-numeric: tabular-nums;
159
- }
160
-
161
- caption {
162
- text-align: left;
163
- color: var(--text-3);
164
- padding-left: 10px;
165
- margin-bottom: 0.25em;
166
- }
167
-
168
- th, td {
169
- padding: 5px 10px;
170
- text-align: left;
171
- vertical-align: top;
172
- border-bottom: 1px solid var(--border-5);
173
- }
174
-
175
- thead th {
176
- font-weight: 600;
177
- }
178
-
179
- /* Drop the trailing hairline under the table's last row so the
180
- table doesn't end with an orphan line. Handles both "tbody is
181
- the final section" and "tfoot is the final section". */
182
- tfoot tr:last-child > :is(th, td),
183
- table:not(:has(tfoot)) tbody tr:last-child > :is(th, td) {
184
- border-bottom: none;
185
- }
186
-
187
- /* Opt-in: outer frame + vertical column dividers + 3px rounded
188
- corners. Switches to separate borders because `border-radius`
189
- doesn't render reliably under `border-collapse: collapse` — the
190
- collapsed borders override the radius. Cells draw their own
191
- right edges to build the internal grid; the last cell in each
192
- row drops its right border so the table's own border supplies
193
- the outer frame. Row separators come from the baseline
194
- `border-bottom` and continue to work under separate-collapse. */
195
- table[data-bordered] {
196
- border-collapse: separate;
197
- border-spacing: 0;
198
- border: 1px solid var(--border-5);
199
- border-radius: 3px;
200
- }
201
-
202
- table[data-bordered] :is(th, td) {
203
- border-right: 1px solid var(--border-5);
204
- }
205
-
206
- table[data-bordered] tr > :is(th, td):last-child {
207
- border-right: 0;
208
- }
209
- }
1
+ @layer anta{*,*:before,*:after{box-sizing:border-box}*{margin:0}img,picture,video,canvas,svg{display:block;max-width:100%}input,button,textarea,select{font:inherit}p,h1,h2,h3,h4,h5,h6{overflow-wrap:break-word}p{text-wrap:pretty}h1,h2,h3,h4,h5,h6{text-wrap:balance}h1,h2,h3,h4,h5,h6{color:var(--text-1);font-weight:584.62;letter-spacing:0}h1{font-size:28px;line-height:32px;margin-block:0 16px}h2{font-size:24px;line-height:28px;margin-block:32px 12px}h3{font-size:20px;line-height:24px;margin-block:24px 12px}h4{font-size:17px;line-height:20px;margin-block:20px 8px}h5{font-size:15px;line-height:20px;margin-block:16px 8px}h6{font-size:13px;line-height:16px;margin-block:16px 4px}strong{font-weight:600}code{line-height:1em}code,kbd,samp,pre{letter-spacing:0}ul,ol{padding-left:3ch}:is(ul,ol)>li{margin-bottom:.5em}:is(ul,ol)>li::marker{color:var(--text-5)}menu{list-style:none;padding:0;margin:0}menu>li{margin:0}a:not(:where([role=button])),a:not(:where([role=button])):link,a:not(:where([role=button])):visited{color:var(--link-color);text-decoration:underline;text-decoration-style:solid;text-decoration-color:color-mix(in srgb,currentColor 75%,transparent);text-decoration-thickness:.5px;text-underline-offset:3px}@media(hover:hover)and (pointer:fine){a:not(:where([role=button])):hover{color:var(--link-color-hover);text-decoration-thickness:1px}}a:not(:where([role=button])):active{text-decoration-color:color-mix(in srgb,currentColor 75%,transparent)}::selection{background:color-mix(in srgb,var(--text-1-brand),transparent 85%)}table{border-collapse:collapse;font-variant-numeric:tabular-nums}caption{text-align:left;color:var(--text-3);padding-left:10px;margin-bottom:.25em}th,td{padding:5px 10px;text-align:left;vertical-align:top;border-bottom:1px solid var(--border-4)}thead th{font-weight:600}tfoot tr:last-child>:is(th,td),table:not(:has(tfoot)) tbody tr:last-child>:is(th,td){border-bottom:none}table[data-bordered]{border-collapse:separate;border-spacing:0;border:1px solid var(--border-4);border-radius:3px}table[data-bordered] :is(th,td){border-right:1px solid var(--border-4)}table[data-bordered] tr>:is(th,td):last-child{border-right:0}}