@antadesign/anta 0.1.1-dev.5 → 0.1.1-dev.7
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 +15 -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 +6 -2
- package/dist/components/Text.js +2 -1
- package/dist/components/Title.d.ts +43 -0
- package/dist/components/Title.js +20 -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 +10 -0
- package/dist/elements/a-button.js +76 -0
- package/dist/elements/a-icon.css +31 -6
- package/dist/elements/a-icon.shapes.css +9 -1
- package/dist/elements/a-icon.shapes.d.ts +5 -2
- package/dist/elements/a-icon.shapes.js +2 -0
- package/dist/elements/a-progress.css +7 -9
- package/dist/elements/a-sticker-animated.css +9 -0
- package/dist/elements/a-sticker-animated.d.ts +38 -0
- package/dist/elements/a-sticker-animated.js +79 -0
- package/dist/elements/a-sticker.css +9 -0
- package/dist/elements/a-sticker.d.ts +18 -0
- package/dist/elements/a-sticker.js +30 -0
- package/dist/elements/a-text.css +14 -5
- package/dist/elements/a-title.css +64 -0
- package/dist/elements/index.d.ts +7 -0
- package/dist/elements/index.js +19 -0
- package/dist/general_types.d.ts +120 -4
- package/dist/generate-icons.mjs +5 -3
- 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 +96 -11
- package/dist/tokens.css +186 -182
- package/package.json +17 -4
package/README.md
CHANGED
|
@@ -29,12 +29,12 @@ 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
38
|
|
|
39
39
|
### Cascade layers
|
|
40
40
|
|
|
@@ -49,6 +49,19 @@ If you need a different order, declare it in your *own* CSS file that loads **be
|
|
|
49
49
|
|
|
50
50
|
CSS custom properties (the `:root { --… }` declarations in `tokens.css`) stay unlayered so they take effect everywhere unconditionally.
|
|
51
51
|
|
|
52
|
+
> **Gotcha: unlayered hard resets defeat Anta's element rules.**
|
|
53
|
+
>
|
|
54
|
+
> A snippet like this in your global CSS — common copy-paste from older reset guides — silently overrides every element rule Anta ships:
|
|
55
|
+
>
|
|
56
|
+
> ```css
|
|
57
|
+
> *, *::before, *::after { box-sizing: border-box; }
|
|
58
|
+
> * { margin: 0; }
|
|
59
|
+
> ```
|
|
60
|
+
>
|
|
61
|
+
> Unlayered styles **always** beat layered ones in the cascade, regardless of specificity. So `* { margin: 0 }` outranks Anta's `caption { margin-bottom: 0.25em }`, `p { margin: 0 0 1em }`, `ul / ol` padding, and any other per-element default Anta provides — even though those use stronger selectors.
|
|
62
|
+
>
|
|
63
|
+
> If you're importing `@antadesign/anta/reset.css`, Anta already does the same universal `box-sizing` and margin reset, *inside* `@layer anta`. The element-level rules sitting on top are intentionally polite defaults — sensible out of the box, trivially overridable when you want something else (any rule in `@layer components` / `@layer utilities`, or any unlayered rule of your own that targets specific elements, wins automatically). **Delete the duplicate hard reset from your global CSS** so those defaults can apply. If you want to keep your own reset, wrap it in `@layer base { … }` so it sits below `anta` in the declared order and Anta's rules still win element-by-element.
|
|
64
|
+
|
|
52
65
|
## Registering elements
|
|
53
66
|
|
|
54
67
|
The JSX wrappers (React components) as `Progress` render custom DOM elements as `<a-progress>`. The custom elements themselves must be registered with the browser **before** they appear in the DOM, and registration only works where `HTMLElement` exists — i.e. the UI thread of a real browser. **Node.js (SSR) and Worker threads don't have `HTMLElement`**, so the import is harmless in those environments: it does nothing — registration is skipped silently and the class uses a stand-in base instead of crashing — though it might extend your worker's bundle size a bit.
|
|
@@ -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,9 +1,13 @@
|
|
|
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';
|
|
8
|
+
/** Type scale. `small` = 13/16, `medium` = 15/20, `large` = 17/24.
|
|
9
|
+
* @defaultValue medium */
|
|
10
|
+
size?: 'small' | 'medium' | 'large';
|
|
7
11
|
/** Render as inline-block instead of the default block element. */
|
|
8
12
|
inline?: boolean;
|
|
9
13
|
/** Truncate with a trailing ellipsis. `true` (or `1`) clamps to a
|
|
@@ -39,4 +43,4 @@ export interface TextProps extends BaseProps {
|
|
|
39
43
|
* <Text truncate={3} expandable>…long paragraph…</Text>
|
|
40
44
|
* ```
|
|
41
45
|
*/
|
|
42
|
-
export declare const Text: ({ priority, tone, inline, truncate, expandable, className, style, children, ...rest }: TextProps) => any;
|
|
46
|
+
export declare const Text: ({ priority, tone, size, inline, truncate, expandable, className, style, children, ...rest }: TextProps) => any;
|
package/dist/components/Text.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
|
-
const Text = ({ priority, tone, inline, truncate, expandable, className, style, children, ...rest }) => {
|
|
2
|
+
const Text = ({ priority, tone, size, inline, truncate, expandable, className, style, children, ...rest }) => {
|
|
3
3
|
const lineCount = typeof truncate === "number" ? truncate : truncate ? 1 : null;
|
|
4
4
|
const computedStyle = lineCount != null ? { ...style, ["--line-clamp"]: lineCount } : style;
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
@@ -7,6 +7,7 @@ const Text = ({ priority, tone, inline, truncate, expandable, className, style,
|
|
|
7
7
|
{
|
|
8
8
|
priority,
|
|
9
9
|
tone,
|
|
10
|
+
size,
|
|
10
11
|
inline: inline ? "" : void 0,
|
|
11
12
|
truncate: lineCount != null ? String(lineCount) : void 0,
|
|
12
13
|
expandable: expandable && truncate ? "" : void 0,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BaseProps } from "../general_types";
|
|
2
|
+
export interface TitleProps extends BaseProps {
|
|
3
|
+
/** Heading level, 1-6. Drives font-size, line-height, and vertical
|
|
4
|
+
* rhythm. Also surfaced to assistive tech via `aria-level`
|
|
5
|
+
* (h1 is typically reserved for the page title).
|
|
6
|
+
* @defaultValue 2 */
|
|
7
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
8
|
+
/** Visual priority. Maps to text-1..text-5 (`primary` = text-1).
|
|
9
|
+
* @defaultValue primary */
|
|
10
|
+
priority?: 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'quinary';
|
|
11
|
+
/** Color tint. Applies the matching `--text-{N}-{tone}` palette. */
|
|
12
|
+
tone?: 'brand' | 'success' | 'critical' | 'warning' | 'info';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Block-level heading with level 1-6, priority, and tone.
|
|
16
|
+
*
|
|
17
|
+
* Renders an `<a-title>` styled tag (no JS, no shadow DOM) with
|
|
18
|
+
* `role="heading"` and `aria-level={level}` set by this wrapper for
|
|
19
|
+
* accessibility. Children can be anything — text, icons, badges, links
|
|
20
|
+
* — so there are no `icon` / `iconTrailing` props; just compose
|
|
21
|
+
* inside.
|
|
22
|
+
*
|
|
23
|
+
* Raw `<h1>`-`<h6>` get the same visual styling via `src/reset.css`,
|
|
24
|
+
* so use a real heading tag if SEO matters and you don't need the
|
|
25
|
+
* `tone` / `priority` props.
|
|
26
|
+
*
|
|
27
|
+
* Requires `@antadesign/anta/elements` to be imported (client-side only)
|
|
28
|
+
* so the CSS ships with the page.
|
|
29
|
+
*
|
|
30
|
+
* @example Basic usage
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <Title level={1}>Page title</Title>
|
|
33
|
+
* <Title level={2} tone="brand">Section</Title>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example With children beyond text
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <Title level={3}>
|
|
39
|
+
* <Icon shape="bookmark" /> Saved items
|
|
40
|
+
* </Title>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const Title: ({ level, priority, tone, className, style, children, ...rest }: TitleProps) => any;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
const Title = ({ level = 2, priority, tone, className, style, children, ...rest }) => {
|
|
3
|
+
return /* @__PURE__ */ jsx(
|
|
4
|
+
"a-title",
|
|
5
|
+
{
|
|
6
|
+
level: String(level),
|
|
7
|
+
priority,
|
|
8
|
+
tone,
|
|
9
|
+
role: "heading",
|
|
10
|
+
"aria-level": level,
|
|
11
|
+
class: className,
|
|
12
|
+
style,
|
|
13
|
+
...rest,
|
|
14
|
+
children
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
Title
|
|
20
|
+
};
|