@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
package/README.md
CHANGED
|
@@ -29,12 +29,14 @@ Anta exposes four independent imports. Tokens + elements + the JSX layer are the
|
|
|
29
29
|
|
|
30
30
|
| Import | Provides | Skip if… |
|
|
31
31
|
|---|---|---|
|
|
32
|
-
| `@antadesign/anta/tokens.css` | The CSS custom properties — `--bg-
|
|
32
|
+
| `@antadesign/anta/tokens.css` | The CSS custom properties — `--bg-1…5`, `--text-1…5`, `--border-1…5`, the `.dark`-ancestor toggling, the base `font-size: 15px`. Also declares the `@layer base, anta, components, utilities;` cascade order. | You're applying your own design tokens at the same variable names. |
|
|
33
33
|
| `@antadesign/anta/reset.css` | Modern small reset (box-sizing, margin reset, replaced-element block, form-control font inheritance, text-wrap defaults) plus Anta's typography opinions for `h1-h6`, `strong`, `ul / ol / menu`, `a` / link states. Lives in `@layer anta`. | You already have a reset and don't want Anta's typography defaults. |
|
|
34
34
|
| `@antadesign/anta/elements` | Side-effect import that registers `<a-progress>`, `<a-text>`, `<a-icon>` as custom elements *and* attaches their per-element CSS (also in `@layer anta`). | You're rendering Anta only on the server (no DOM) and never hydrating. |
|
|
35
35
|
| `@antadesign/anta` | The JSX wrappers (`Progress`, `Text`, `Icon`) — typed React/Preact components that emit `<a-*>` tags. | You're writing the `<a-*>` elements by hand and don't need a JSX layer. |
|
|
36
36
|
|
|
37
|
-
The chain matters: the per-element CSS that ships with `/elements` references variables like `var(--text-1)` and `var(--bg-
|
|
37
|
+
The chain matters: the per-element CSS that ships with `/elements` references variables like `var(--text-1)` and `var(--bg-2)`. Those variables are *only defined* by `tokens.css`. Skip the tokens import and the components render with whatever the surrounding cascade provides — usually nothing styled at all.
|
|
38
|
+
|
|
39
|
+
`@antadesign/anta/elements` registers **all** elements — convenient, but it includes every element's code (and deps). To keep your bundle lean, import only the elements you use from their per-element entry points instead: `import '@antadesign/anta/elements/a-tooltip'` registers just `<a-tooltip>` **and loads just its CSS**. Unused elements — and their dependencies, e.g. `lottie-web` (needed only by `<a-sticker-animated>`) — then never enter your bundle. See [Registering elements](#registering-elements).
|
|
38
40
|
|
|
39
41
|
### Cascade layers
|
|
40
42
|
|
|
@@ -70,6 +72,15 @@ The JSX wrappers (React components) as `Progress` render custom DOM elements as
|
|
|
70
72
|
import '@antadesign/anta/elements' // auto-registers all elements
|
|
71
73
|
```
|
|
72
74
|
|
|
75
|
+
**Register only what you use.** `/elements` is the all-in-one convenience import. To trim your bundle, import the specific element entry points instead — each registers just that element and loads just its CSS:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import '@antadesign/anta/elements/a-tooltip' // only <a-tooltip> + its CSS
|
|
79
|
+
import '@antadesign/anta/elements/a-button' // only <a-button> + its CSS
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Both styles are side-effect imports (the act of importing registers the element), and both are idempotent and SSR-safe. The granular form keeps unused elements — and their dependencies, e.g. `lottie-web`, which only `<a-sticker-animated>` pulls in — out of your bundle.
|
|
83
|
+
|
|
73
84
|
The cleanest pattern is a **static, synchronous import at your app's entry file** — outside any component, outside any hook:
|
|
74
85
|
|
|
75
86
|
```ts
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { BaseProps } from "../general_types";
|
|
2
|
+
import type { IconShape } from '../elements/a-icon.shapes';
|
|
3
|
+
/** Always-allowed props, independent of content/submit/priority mode. */
|
|
4
|
+
export type BaseButtonProps = {
|
|
5
|
+
/** Semantic tone, or any literal CSS color (`'#ff1493'`, `'rebeccapurple'`)
|
|
6
|
+
* for a one-off custom tone. Primary uses the color as-is; secondary,
|
|
7
|
+
* tertiary, and quaternary take its hue and pin lightness/chroma to the
|
|
8
|
+
* brand curve so any input stays legible.
|
|
9
|
+
* @defaultValue neutral */
|
|
10
|
+
tone?: 'neutral' | 'brand' | 'critical' | 'info' | 'success' | 'warning' | (string & {});
|
|
11
|
+
/** Size variant. small=24px, medium=28px, large=32px. Omit the
|
|
12
|
+
* attribute or pass `'medium'` for the default — both render
|
|
13
|
+
* identically and emit no DOM attribute.
|
|
14
|
+
* @defaultValue medium */
|
|
15
|
+
size?: 'small' | 'medium' | 'large';
|
|
16
|
+
/** Show a rotating loading indicator. Blocks clicks. */
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
/** Disable the button. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Toggled-on / pressed state, e.g. for filter chips. */
|
|
21
|
+
selected?: boolean;
|
|
22
|
+
/** Click handler. */
|
|
23
|
+
onClick?: (e: any) => void;
|
|
24
|
+
/** Tab order. The button is keyboard-focusable by default (`0`) and
|
|
25
|
+
* becomes `-1` automatically while `disabled` — `<a-button>` and
|
|
26
|
+
* `<a role="button">` aren't focusable without an explicit tabindex.
|
|
27
|
+
* @defaultValue 0 */
|
|
28
|
+
tabIndex?: number;
|
|
29
|
+
};
|
|
30
|
+
/** Content axis — slots render in this order inside the button:
|
|
31
|
+
* `icon` → `label` → `children` → `iconTrailing`. Pass `icon` alone
|
|
32
|
+
* for an icon-only button (the CSS detects this structurally via
|
|
33
|
+
* `:has(> a-icon:only-child)` and gives the host square padding +
|
|
34
|
+
* min-size pin). */
|
|
35
|
+
export type ContentMode = {
|
|
36
|
+
/** Label text. Renders between the leading icon and `children`. */
|
|
37
|
+
label?: string;
|
|
38
|
+
/** Leading icon shape. When set alone (no `label`, no `iconTrailing`, no
|
|
39
|
+
* `children`), the button renders as a square icon-only control and
|
|
40
|
+
* the wrapper auto-supplies `aria-label={icon}` (override by passing
|
|
41
|
+
* your own `aria-label`). */
|
|
42
|
+
icon?: IconShape;
|
|
43
|
+
/** Trailing icon shape. Renders after `children`, last in the slot order. */
|
|
44
|
+
iconTrailing?: IconShape;
|
|
45
|
+
};
|
|
46
|
+
/** Submit axis — anchors (href) don't carry form-submission props; buttons
|
|
47
|
+
* don't carry anchor props. */
|
|
48
|
+
export type SubmitMode = {
|
|
49
|
+
/** Renders as `<a role="button">` instead of `<a-button>`. */
|
|
50
|
+
href: string;
|
|
51
|
+
/** Anchor target. */
|
|
52
|
+
target?: string;
|
|
53
|
+
/** Anchor rel. */
|
|
54
|
+
rel?: string;
|
|
55
|
+
/** Anchor download attribute. Empty string / `true` triggers a download with the resource's default name; a string overrides the filename. */
|
|
56
|
+
download?: string | boolean;
|
|
57
|
+
/** Space-separated URLs the browser pings on navigation. */
|
|
58
|
+
ping?: string;
|
|
59
|
+
type?: never;
|
|
60
|
+
form?: never;
|
|
61
|
+
} | {
|
|
62
|
+
href?: never;
|
|
63
|
+
target?: never;
|
|
64
|
+
rel?: never;
|
|
65
|
+
download?: never;
|
|
66
|
+
ping?: never;
|
|
67
|
+
/** Form submission type. */
|
|
68
|
+
type?: 'button' | 'submit' | 'reset';
|
|
69
|
+
/** Form id when the button isn't a descendant of its form. */
|
|
70
|
+
form?: string;
|
|
71
|
+
};
|
|
72
|
+
/** Priority axis — `underline` only on `tertiary` / `quaternary`,
|
|
73
|
+
* `paddingless` only on `quaternary`. */
|
|
74
|
+
export type PriorityMode = {
|
|
75
|
+
/** Visual emphasis.
|
|
76
|
+
* @defaultValue secondary */
|
|
77
|
+
priority?: 'primary' | 'secondary';
|
|
78
|
+
underline?: never;
|
|
79
|
+
paddingless?: never;
|
|
80
|
+
} | {
|
|
81
|
+
priority: 'tertiary';
|
|
82
|
+
/** Underline style. */
|
|
83
|
+
underline?: 'solid' | 'dashed' | 'dotted';
|
|
84
|
+
paddingless?: never;
|
|
85
|
+
} | {
|
|
86
|
+
priority: 'quaternary';
|
|
87
|
+
/** Underline style. */
|
|
88
|
+
underline?: 'solid' | 'dashed' | 'dotted';
|
|
89
|
+
/** Drops outer padding to zero. */
|
|
90
|
+
paddingless?: boolean;
|
|
91
|
+
};
|
|
92
|
+
export type ButtonProps = BaseButtonProps & PriorityMode & ContentMode & SubmitMode & BaseProps;
|
|
93
|
+
/**
|
|
94
|
+
* Action button.
|
|
95
|
+
*
|
|
96
|
+
* Renders an `<a-button>` web component (or `<a role="button">` when
|
|
97
|
+
* `href` is set) with the design system's tone × priority matrix applied
|
|
98
|
+
* via CSS attributes.
|
|
99
|
+
*
|
|
100
|
+
* Requires `@antadesign/anta/elements` to be imported (client-side only)
|
|
101
|
+
* to register the underlying custom element.
|
|
102
|
+
*
|
|
103
|
+
* @example Basic usage
|
|
104
|
+
* ```tsx
|
|
105
|
+
* <Button label="Save" onClick={save} />
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @example Anchor styled as a button
|
|
109
|
+
* ```tsx
|
|
110
|
+
* <Button href="/docs" target="_blank" label="Read the docs" />
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare const Button: ({ priority, tone, underline, icon, iconTrailing, paddingless, label, size, loading, disabled, selected, href, type, form, className, style, children, ...rest }: ButtonProps) => any;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
const NAMED_TONES = /* @__PURE__ */ new Set([
|
|
3
|
+
"brand",
|
|
4
|
+
"neutral",
|
|
5
|
+
"critical",
|
|
6
|
+
"info",
|
|
7
|
+
"success",
|
|
8
|
+
"warning"
|
|
9
|
+
]);
|
|
10
|
+
const wrapChildren = (kids) => {
|
|
11
|
+
if (kids == null) return kids;
|
|
12
|
+
const arr = Array.isArray(kids) ? kids : [kids];
|
|
13
|
+
return arr.map((child, i) => {
|
|
14
|
+
const t = typeof child;
|
|
15
|
+
if (t === "string" || t === "number") {
|
|
16
|
+
return /* @__PURE__ */ jsx("a-button-label", { children: child }, i);
|
|
17
|
+
}
|
|
18
|
+
return child;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const Button = ({
|
|
22
|
+
priority,
|
|
23
|
+
tone,
|
|
24
|
+
underline,
|
|
25
|
+
icon,
|
|
26
|
+
iconTrailing,
|
|
27
|
+
paddingless,
|
|
28
|
+
label,
|
|
29
|
+
size,
|
|
30
|
+
loading,
|
|
31
|
+
disabled,
|
|
32
|
+
selected,
|
|
33
|
+
href,
|
|
34
|
+
type,
|
|
35
|
+
form,
|
|
36
|
+
className,
|
|
37
|
+
style,
|
|
38
|
+
children,
|
|
39
|
+
...rest
|
|
40
|
+
}) => {
|
|
41
|
+
const isCustomTone = tone != null && !NAMED_TONES.has(tone);
|
|
42
|
+
const computedStyle = isCustomTone ? { ...style, ["--button-tone-source"]: tone } : style;
|
|
43
|
+
const isIconOnly = icon != null && label == null && children == null && iconTrailing == null;
|
|
44
|
+
const sharedAttrs = {
|
|
45
|
+
priority,
|
|
46
|
+
tone,
|
|
47
|
+
underline,
|
|
48
|
+
// 'medium' (and unset) is the implicit default — emit no DOM attr.
|
|
49
|
+
size: size && size !== "medium" ? size : void 0,
|
|
50
|
+
// Boolean attributes: emit a presence attribute (empty string) when on,
|
|
51
|
+
// omit when off — `attr=""` is the canonical boolean-attribute form and
|
|
52
|
+
// renders consistently across React / Preact. The CSS matches these by
|
|
53
|
+
// presence (`[disabled]`, not `[disabled="true"]`), so any present form
|
|
54
|
+
// works. (ARIA attributes below stay string-valued — ARIA needs "true".)
|
|
55
|
+
paddingless: paddingless ? "" : void 0,
|
|
56
|
+
loading: loading ? "" : void 0,
|
|
57
|
+
disabled: disabled ? "" : void 0,
|
|
58
|
+
selected: selected ? "" : void 0,
|
|
59
|
+
tabIndex: disabled ? -1 : 0,
|
|
60
|
+
"aria-disabled": disabled || loading ? "true" : void 0,
|
|
61
|
+
"aria-busy": loading ? "true" : void 0,
|
|
62
|
+
"aria-pressed": selected ? "true" : void 0,
|
|
63
|
+
// Icon-only buttons get an accessible name from the icon shape;
|
|
64
|
+
// consumer's own `aria-label` (via ...rest) wins by spread order.
|
|
65
|
+
"aria-label": isIconOnly ? icon : void 0,
|
|
66
|
+
class: className,
|
|
67
|
+
style: computedStyle
|
|
68
|
+
};
|
|
69
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
70
|
+
icon && /* @__PURE__ */ jsx("a-icon", { shape: icon, "aria-hidden": "true" }),
|
|
71
|
+
label != null && /* @__PURE__ */ jsx("a-button-label", { children: label }),
|
|
72
|
+
wrapChildren(children),
|
|
73
|
+
iconTrailing && /* @__PURE__ */ jsx("a-icon", { shape: iconTrailing, "aria-hidden": "true" })
|
|
74
|
+
] });
|
|
75
|
+
if (href != null) {
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
"a",
|
|
78
|
+
{
|
|
79
|
+
href,
|
|
80
|
+
role: "button",
|
|
81
|
+
...sharedAttrs,
|
|
82
|
+
...rest,
|
|
83
|
+
children: inner
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return /* @__PURE__ */ jsx(
|
|
88
|
+
"a-button",
|
|
89
|
+
{
|
|
90
|
+
type,
|
|
91
|
+
form,
|
|
92
|
+
...sharedAttrs,
|
|
93
|
+
...rest,
|
|
94
|
+
children: inner
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
Button
|
|
100
|
+
};
|
|
@@ -5,7 +5,8 @@ export interface IconProps extends BaseProps {
|
|
|
5
5
|
* built-in icons plus any consumer-generated shapes (via the
|
|
6
6
|
* `IconShapes` interface module augmentation). */
|
|
7
7
|
shape: IconShape;
|
|
8
|
-
/** Width and height in pixels.
|
|
8
|
+
/** Width and height in pixels.
|
|
9
|
+
* @defaultValue 16 */
|
|
9
10
|
size?: number;
|
|
10
11
|
/** Accessible name for the icon. When set, the wrapper exposes
|
|
11
12
|
* `role="img"` and `aria-label={label}` so screen readers announce
|
|
@@ -2,9 +2,11 @@ import type { BaseProps } from "../general_types";
|
|
|
2
2
|
export interface ProgressProps extends BaseProps {
|
|
3
3
|
/** Current progress value. Negative values are clamped to 0. */
|
|
4
4
|
value: number;
|
|
5
|
-
/** Upper bound of the range.
|
|
5
|
+
/** Upper bound of the range.
|
|
6
|
+
* @defaultValue 100 */
|
|
6
7
|
max?: number;
|
|
7
|
-
/** Color variant. `'info'` applies a blue tint.
|
|
8
|
+
/** Color variant. `'info'` applies a blue tint.
|
|
9
|
+
* @defaultValue neutral */
|
|
8
10
|
tone?: 'neutral' | 'info';
|
|
9
11
|
/** Text label displayed after the percentage. */
|
|
10
12
|
label?: string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BaseProps } from "../general_types";
|
|
2
|
+
/** Base public props for stickers — shared by both static and animated.
|
|
3
|
+
* Inherits `className` and `style` from `BaseProps`. The animated
|
|
4
|
+
* variant (`StickerAnimated`) extends this with `paused`. */
|
|
5
|
+
export interface StickerProps extends Omit<BaseProps, "children"> {
|
|
6
|
+
/** Edge length in pixels. Stickers are always square. Defaults to 256. */
|
|
7
|
+
size?: number;
|
|
8
|
+
label?: string;
|
|
9
|
+
}
|
|
10
|
+
/** ARIA attribute shape applied to sticker hosts — either meaningful
|
|
11
|
+
* (`role="img"` + `aria-label`) or decorative (`aria-hidden="true"`). */
|
|
12
|
+
export type StickerA11y = {
|
|
13
|
+
role?: string;
|
|
14
|
+
"aria-label"?: string;
|
|
15
|
+
"aria-hidden"?: "true";
|
|
16
|
+
};
|
|
17
|
+
/** Internal — supplied by the generated per-sticker module; the bound
|
|
18
|
+
* SVG markup is the per-sticker payload. */
|
|
19
|
+
interface StickerInternalProps extends StickerProps {
|
|
20
|
+
svg: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Internal renderer for static stickers. Generated `Sticker{Name}`
|
|
24
|
+
* exports under `@antadesign/anta/stickers` call this with their bound
|
|
25
|
+
* inline SVG markup. The `<a-sticker>` element renders the SVG into
|
|
26
|
+
* its shadow DOM; sizing is composed into the host's inline `style` as
|
|
27
|
+
* `--sticker-size` (the element doesn't mutate its own host — see the
|
|
28
|
+
* declarative-DOM rule in CLAUDE.md).
|
|
29
|
+
*/
|
|
30
|
+
export declare const Sticker: ({ svg, size, label, ...rest }: StickerInternalProps) => any;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
const Sticker = ({
|
|
3
|
+
svg,
|
|
4
|
+
size,
|
|
5
|
+
label,
|
|
6
|
+
...rest
|
|
7
|
+
}) => {
|
|
8
|
+
const a11y = label != null ? { role: "img", "aria-label": label } : { "aria-hidden": "true" };
|
|
9
|
+
const style = size != null ? {
|
|
10
|
+
...rest.style,
|
|
11
|
+
["--sticker-size"]: `${size}px`
|
|
12
|
+
} : rest.style;
|
|
13
|
+
return /* @__PURE__ */ jsx("a-sticker", { svg, ...a11y, ...rest, style });
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
Sticker
|
|
17
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StickerProps } from "./Sticker";
|
|
2
|
+
/** Public props for animated stickers — extends `StickerProps` with
|
|
3
|
+
* `paused`. The static `Sticker` variant doesn't accept `paused`. */
|
|
4
|
+
export interface StickerAnimatedProps extends StickerProps {
|
|
5
|
+
/** `true` freezes the animation at the current frame; a number freezes
|
|
6
|
+
* at that time in seconds; omit (or `false`) to play. */
|
|
7
|
+
paused?: boolean | number;
|
|
8
|
+
}
|
|
9
|
+
/** Internal — the bound Lottie animation is supplied by the generated
|
|
10
|
+
* per-sticker module as a JSON string. The element parses it once on
|
|
11
|
+
* attribute set. */
|
|
12
|
+
interface StickerAnimatedInternalProps extends StickerAnimatedProps {
|
|
13
|
+
animation: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Internal renderer for animated stickers. Generated
|
|
17
|
+
* `Sticker{Name}Animated` exports under `@antadesign/anta/stickers`
|
|
18
|
+
* call this with their bound Lottie JSON string. The
|
|
19
|
+
* `<a-sticker-animated>` element receives it as an attribute, parses
|
|
20
|
+
* it once, and drives a shadow-DOM canvas via dotLottie.
|
|
21
|
+
*/
|
|
22
|
+
export declare const StickerAnimated: ({ animation, size, paused, label, ...rest }: StickerAnimatedInternalProps) => any;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
const StickerAnimated = ({
|
|
3
|
+
animation,
|
|
4
|
+
size,
|
|
5
|
+
paused,
|
|
6
|
+
label,
|
|
7
|
+
...rest
|
|
8
|
+
}) => {
|
|
9
|
+
const a11y = label != null ? { role: "img", "aria-label": label } : { "aria-hidden": "true" };
|
|
10
|
+
const pausedAttr = paused === true ? "" : typeof paused === "number" ? String(paused) : void 0;
|
|
11
|
+
const style = size != null ? {
|
|
12
|
+
...rest.style,
|
|
13
|
+
["--sticker-size"]: `${size}px`
|
|
14
|
+
} : rest.style;
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
"a-sticker-animated",
|
|
17
|
+
{
|
|
18
|
+
animation,
|
|
19
|
+
paused: pausedAttr,
|
|
20
|
+
...a11y,
|
|
21
|
+
...rest,
|
|
22
|
+
style
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
StickerAnimated
|
|
28
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BaseProps } from "../general_types";
|
|
2
2
|
export interface TextProps extends BaseProps {
|
|
3
|
-
/** Visual priority. Maps to text-1..text-5
|
|
3
|
+
/** Visual priority. Maps to text-1..text-5 (`primary` = text-1).
|
|
4
|
+
* @defaultValue primary */
|
|
4
5
|
priority?: 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'quinary';
|
|
5
6
|
/** Color tint. Applies the matching `--text-{N}-{tone}` palette. */
|
|
6
7
|
tone?: 'brand' | 'success' | 'critical' | 'warning' | 'info';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { BaseProps } from "../general_types";
|
|
2
2
|
export interface TitleProps extends BaseProps {
|
|
3
3
|
/** Heading level, 1-6. Drives font-size, line-height, and vertical
|
|
4
|
-
* rhythm. Also surfaced to assistive tech via `aria-level
|
|
5
|
-
*
|
|
4
|
+
* rhythm. Also surfaced to assistive tech via `aria-level`
|
|
5
|
+
* (h1 is typically reserved for the page title).
|
|
6
|
+
* @defaultValue 2 */
|
|
6
7
|
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
7
|
-
/** Visual priority. Maps to text-1..text-5
|
|
8
|
+
/** Visual priority. Maps to text-1..text-5 (`primary` = text-1).
|
|
9
|
+
* @defaultValue primary */
|
|
8
10
|
priority?: 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'quinary';
|
|
9
11
|
/** Color tint. Applies the matching `--text-{N}-{tone}` palette. */
|
|
10
12
|
tone?: 'brand' | 'success' | 'critical' | 'warning' | 'info';
|
|
@@ -15,7 +17,7 @@ export interface TitleProps extends BaseProps {
|
|
|
15
17
|
* Renders an `<a-title>` styled tag (no JS, no shadow DOM) with
|
|
16
18
|
* `role="heading"` and `aria-level={level}` set by this wrapper for
|
|
17
19
|
* accessibility. Children can be anything — text, icons, badges, links
|
|
18
|
-
* — so there are no `
|
|
20
|
+
* — so there are no `icon` / `iconTrailing` props; just compose
|
|
19
21
|
* inside.
|
|
20
22
|
*
|
|
21
23
|
* Raw `<h1>`-`<h6>` get the same visual styling via `src/reset.css`,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { BaseProps } from "../general_types";
|
|
2
|
+
export interface TooltipProps extends BaseProps {
|
|
3
|
+
/** Tooltip content. Renders anything — text, markup, an icon + text.
|
|
4
|
+
* Lives in the light DOM, so it's styleable with your own plain CSS. */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** Show delay in milliseconds after hover / focus. Never use `0` — use
|
|
7
|
+
* ~`50` for a near-instant tooltip (0 has caused issues in practice).
|
|
8
|
+
* @defaultValue 250 */
|
|
9
|
+
delay?: number;
|
|
10
|
+
/** Which side of the anchor the bubble prefers. Auto-flips to the other
|
|
11
|
+
* side when there isn't room.
|
|
12
|
+
* @defaultValue bottom */
|
|
13
|
+
placement?: 'top' | 'bottom';
|
|
14
|
+
/** Pin the bubble under the anchor instead of following the cursor. */
|
|
15
|
+
static?: boolean;
|
|
16
|
+
/** Make the bubble hoverable and clickable — enables pointer events and
|
|
17
|
+
* keeps it open while the cursor is over it, so its content (links,
|
|
18
|
+
* buttons) can be interacted with. Implies `static` (an interactive
|
|
19
|
+
* bubble can't follow the cursor). */
|
|
20
|
+
interactive?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Tooltip — a small floating bubble that describes the element it's placed
|
|
24
|
+
* inside. Render `<Tooltip>` as a child of the element it annotates; it
|
|
25
|
+
* doesn't affect that element's layout.
|
|
26
|
+
*
|
|
27
|
+
* Shows on hover (after `delay`) and on keyboard focus; dismisses on mouse
|
|
28
|
+
* leave, blur, Escape, or when the anchor scrolls away. Follows the cursor
|
|
29
|
+
* by default — pass `static` to pin it under the anchor instead.
|
|
30
|
+
*
|
|
31
|
+
* Requires `@antadesign/anta/elements` to be imported (client-side only)
|
|
32
|
+
* to register the underlying custom element.
|
|
33
|
+
*
|
|
34
|
+
* @example Basic usage
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import { Tooltip } from '@antadesign/anta'
|
|
37
|
+
* import '@antadesign/anta/elements'
|
|
38
|
+
*
|
|
39
|
+
* <button>
|
|
40
|
+
* Save
|
|
41
|
+
* <Tooltip>Saves your work</Tooltip>
|
|
42
|
+
* </button>
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example Pinned above, rich content
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <span style={{ cursor: 'help' }}>
|
|
48
|
+
* Status
|
|
49
|
+
* <Tooltip placement="top" static>
|
|
50
|
+
* <strong>Healthy</strong> — last checked 2m ago
|
|
51
|
+
* </Tooltip>
|
|
52
|
+
* </span>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const Tooltip: ({ delay, placement, static: isStatic, interactive, className, children, ...rest }: TooltipProps) => any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
const Tooltip = ({
|
|
3
|
+
delay,
|
|
4
|
+
placement,
|
|
5
|
+
static: isStatic,
|
|
6
|
+
interactive,
|
|
7
|
+
className,
|
|
8
|
+
children,
|
|
9
|
+
...rest
|
|
10
|
+
}) => {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"a-tooltip",
|
|
13
|
+
{
|
|
14
|
+
delay: delay != null ? String(delay) : void 0,
|
|
15
|
+
placement: placement === "top" ? "top" : void 0,
|
|
16
|
+
static: isStatic ? "" : void 0,
|
|
17
|
+
interactive: interactive ? "" : void 0,
|
|
18
|
+
class: className,
|
|
19
|
+
...rest,
|
|
20
|
+
children
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
Tooltip
|
|
26
|
+
};
|