@antadesign/anta 0.1.1-dev.1 → 0.1.1-dev.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.
- package/NOTICES.md +279 -0
- package/README.md +90 -24
- package/dist/anta_global_tokens.css +329 -0
- package/dist/anta_helpers.d.ts +8 -0
- package/dist/anta_helpers.js +3 -0
- package/dist/components/Icon.d.ts +40 -0
- package/dist/components/Icon.js +18 -0
- package/dist/components/Progress.d.ts +33 -4
- package/dist/components/Progress.js +5 -0
- package/dist/components/Text.d.ts +42 -0
- package/dist/components/Text.js +22 -0
- package/dist/components/Text.module.css +6 -0
- package/dist/elements/a-icon.css +16 -0
- package/dist/elements/a-icon.d.ts +12 -0
- package/dist/elements/a-icon.js +13 -0
- package/dist/elements/a-icon.shapes.css +345 -0
- package/dist/elements/a-icon.shapes.d.ts +93 -0
- package/dist/elements/a-icon.shapes.js +179 -0
- package/dist/elements/a-progress.css +4 -4
- package/dist/elements/a-progress.d.ts +2 -1
- package/dist/elements/a-progress.js +3 -1
- package/dist/elements/a-text.css +75 -0
- package/dist/elements/a-text.d.ts +10 -0
- package/dist/elements/a-text.js +143 -0
- package/dist/elements/index.d.ts +5 -0
- package/dist/elements/index.js +14 -1
- package/dist/general_types.d.ts +74 -0
- package/dist/generate-icons.mjs +181 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +7 -0
- package/dist/jsx-runtime.d.ts +17 -1
- package/package.json +11 -4
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
const ICON_SHAPES = [
|
|
2
|
+
"arrow-left-to-line",
|
|
3
|
+
"arrow-left",
|
|
4
|
+
"arrow-narrow-down",
|
|
5
|
+
"arrow-narrow-up-down",
|
|
6
|
+
"arrow-narrow-up",
|
|
7
|
+
"arrow-right",
|
|
8
|
+
"arrow-top-right",
|
|
9
|
+
"asterisk",
|
|
10
|
+
"book-open",
|
|
11
|
+
"braces",
|
|
12
|
+
"bug",
|
|
13
|
+
"calendar",
|
|
14
|
+
"case-sensitive",
|
|
15
|
+
"chat",
|
|
16
|
+
"check",
|
|
17
|
+
"chevron-down",
|
|
18
|
+
"chevron-left",
|
|
19
|
+
"chevron-right",
|
|
20
|
+
"chevron-up",
|
|
21
|
+
"chevrons-right",
|
|
22
|
+
"circle-check",
|
|
23
|
+
"circle-large",
|
|
24
|
+
"circle",
|
|
25
|
+
"click",
|
|
26
|
+
"clock",
|
|
27
|
+
"cloud-upload",
|
|
28
|
+
"copy",
|
|
29
|
+
"corner-down-right",
|
|
30
|
+
"cube",
|
|
31
|
+
"dots-vertical",
|
|
32
|
+
"download",
|
|
33
|
+
"edit",
|
|
34
|
+
"education-disk",
|
|
35
|
+
"external-link",
|
|
36
|
+
"file-down",
|
|
37
|
+
"file",
|
|
38
|
+
"filter",
|
|
39
|
+
"folder-close",
|
|
40
|
+
"folder-open",
|
|
41
|
+
"folder-tree",
|
|
42
|
+
"github-logo",
|
|
43
|
+
"gitlab-logo",
|
|
44
|
+
"hat-glasses",
|
|
45
|
+
"heart-handshake",
|
|
46
|
+
"help-disk",
|
|
47
|
+
"history-tree",
|
|
48
|
+
"history",
|
|
49
|
+
"home",
|
|
50
|
+
"hourglass",
|
|
51
|
+
"info",
|
|
52
|
+
"jira-logo",
|
|
53
|
+
"linear-logo",
|
|
54
|
+
"link",
|
|
55
|
+
"list-detail-view",
|
|
56
|
+
"maximize",
|
|
57
|
+
"megaphone",
|
|
58
|
+
"menu",
|
|
59
|
+
"minimize",
|
|
60
|
+
"minus",
|
|
61
|
+
"more",
|
|
62
|
+
"move-horizontal",
|
|
63
|
+
"not-equal",
|
|
64
|
+
"play",
|
|
65
|
+
"plus",
|
|
66
|
+
"presentation",
|
|
67
|
+
"refresh",
|
|
68
|
+
"regex",
|
|
69
|
+
"repeat",
|
|
70
|
+
"rss",
|
|
71
|
+
"runs-history",
|
|
72
|
+
"scroll-text",
|
|
73
|
+
"search-check",
|
|
74
|
+
"search",
|
|
75
|
+
"send",
|
|
76
|
+
"sparkles",
|
|
77
|
+
"swatch-book",
|
|
78
|
+
"text-highlight",
|
|
79
|
+
"text-initial",
|
|
80
|
+
"timer",
|
|
81
|
+
"trash",
|
|
82
|
+
"trello-logo",
|
|
83
|
+
"view",
|
|
84
|
+
"warning-triangle",
|
|
85
|
+
"webhook",
|
|
86
|
+
"workflow",
|
|
87
|
+
"x"
|
|
88
|
+
];
|
|
89
|
+
const ICON_SYNONYMS = {
|
|
90
|
+
"swatch-book": ["palette", "color", "swatch", "paint", "design"],
|
|
91
|
+
"hat-glasses": ["accessibility", "vision", "disguise", "person"],
|
|
92
|
+
"heart-handshake": ["credits", "thanks", "agreement", "deal", "partnership"],
|
|
93
|
+
"hourglass": ["progress", "time", "wait", "loading", "timer"],
|
|
94
|
+
"text-initial": ["text", "typography", "letter", "a"],
|
|
95
|
+
"chevron-down": ["arrow", "expand", "open", "down"],
|
|
96
|
+
"chevron-up": ["arrow", "collapse", "close", "up"],
|
|
97
|
+
"chevron-left": ["arrow", "back", "previous"],
|
|
98
|
+
"chevron-right": ["arrow", "forward", "next"],
|
|
99
|
+
"chevrons-right": ["skip", "fast forward"],
|
|
100
|
+
"arrow-narrow-down": ["download", "fall", "down"],
|
|
101
|
+
"arrow-narrow-up": ["upload", "rise", "up"],
|
|
102
|
+
"arrow-left": ["back", "previous", "prev"],
|
|
103
|
+
"arrow-right": ["forward", "next"],
|
|
104
|
+
"arrow-narrow-up-down": ["sort", "swap", "transfer", "reorder"],
|
|
105
|
+
"arrow-top-right": ["external", "open", "leave"],
|
|
106
|
+
"arrow-left-to-line": ["dock", "snap", "align"],
|
|
107
|
+
"move-horizontal": ["resize", "swap", "horizontal"],
|
|
108
|
+
"external-link": ["open", "link", "share", "outbound"],
|
|
109
|
+
"check": ["tick", "ok", "done", "confirm", "approve"],
|
|
110
|
+
"circle-check": ["success", "ok", "done"],
|
|
111
|
+
"x": ["close", "cancel", "dismiss", "remove", "no"],
|
|
112
|
+
"plus": ["add", "new", "create"],
|
|
113
|
+
"minus": ["remove", "subtract"],
|
|
114
|
+
"menu": ["hamburger", "list", "more"],
|
|
115
|
+
"dots-vertical": ["more", "kebab", "options"],
|
|
116
|
+
"search": ["find", "magnify", "lookup"],
|
|
117
|
+
"search-check": ["found", "validated"],
|
|
118
|
+
"copy": ["duplicate", "clone"],
|
|
119
|
+
"trash": ["delete", "remove", "bin"],
|
|
120
|
+
"edit": ["pencil", "modify", "rename"],
|
|
121
|
+
"view": ["eye", "show", "display", "preview"],
|
|
122
|
+
"click": ["tap", "press", "touch"],
|
|
123
|
+
"send": ["submit", "share", "deliver"],
|
|
124
|
+
"play": ["start", "run", "execute"],
|
|
125
|
+
"refresh": ["reload", "sync", "update"],
|
|
126
|
+
"regex": ["pattern", "match"],
|
|
127
|
+
"repeat": ["loop", "retry", "rerun"],
|
|
128
|
+
"info": ["information", "about", "i"],
|
|
129
|
+
"warning-triangle": ["alert", "danger", "caution"],
|
|
130
|
+
"bug": ["defect", "issue", "error"],
|
|
131
|
+
"asterisk": ["star", "wildcard"],
|
|
132
|
+
"braces": ["code", "brackets", "json"],
|
|
133
|
+
"case-sensitive": ["aA", "capitalize", "case"],
|
|
134
|
+
"text-highlight": ["mark", "highlight"],
|
|
135
|
+
"list-detail-view": ["list", "items"],
|
|
136
|
+
"folder-open": ["directory", "browse"],
|
|
137
|
+
"folder-close": ["directory"],
|
|
138
|
+
"folder-tree": ["hierarchy", "structure", "tree"],
|
|
139
|
+
"file": ["document", "page"],
|
|
140
|
+
"file-down": ["download", "save"],
|
|
141
|
+
"calendar": ["date", "schedule"],
|
|
142
|
+
"clock": ["time"],
|
|
143
|
+
"timer": ["stopwatch", "countdown", "time"],
|
|
144
|
+
"history": ["log", "past"],
|
|
145
|
+
"history-tree": ["log", "past"],
|
|
146
|
+
"runs-history": ["log", "past"],
|
|
147
|
+
"github-logo": ["github", "git", "repo"],
|
|
148
|
+
"gitlab-logo": ["gitlab", "git", "repo"],
|
|
149
|
+
"trello-logo": ["trello", "board", "kanban"],
|
|
150
|
+
"jira-logo": ["jira", "ticket", "issue"],
|
|
151
|
+
"linear-logo": ["linear", "ticket", "issue"],
|
|
152
|
+
"chat": ["message", "comment", "discuss"],
|
|
153
|
+
"presentation": ["slides", "deck"],
|
|
154
|
+
"education-disk": ["learn", "school", "academic"],
|
|
155
|
+
"book-open": ["read", "docs", "documentation"],
|
|
156
|
+
"help-disk": ["question", "faq", "support", "help"],
|
|
157
|
+
"sparkles": ["ai", "magic", "generate"],
|
|
158
|
+
"cube": ["box", "package"],
|
|
159
|
+
"circle": ["dot", "point"],
|
|
160
|
+
"circle-large": ["dot", "marker"],
|
|
161
|
+
"not-equal": ["neq", "different"],
|
|
162
|
+
"corner-down-right": ["branch", "indent", "return"],
|
|
163
|
+
"rss": ["feed", "subscribe"],
|
|
164
|
+
"scroll-text": ["log", "output", "console"],
|
|
165
|
+
"workflow": ["pipeline", "process", "flow"],
|
|
166
|
+
"webhook": ["integration", "hook"],
|
|
167
|
+
"megaphone": ["announcement", "broadcast"],
|
|
168
|
+
"maximize": ["fullscreen", "expand"],
|
|
169
|
+
"minimize": ["collapse", "shrink"],
|
|
170
|
+
"filter": ["sort", "narrow"],
|
|
171
|
+
"download": ["save", "import"],
|
|
172
|
+
"cloud-upload": ["save", "sync", "upload", "send", "export"],
|
|
173
|
+
"link": ["url", "href", "anchor"],
|
|
174
|
+
"more": ["options", "extra"]
|
|
175
|
+
};
|
|
176
|
+
export {
|
|
177
|
+
ICON_SHAPES,
|
|
178
|
+
ICON_SYNONYMS
|
|
179
|
+
};
|
|
@@ -3,7 +3,7 @@ a-progress {
|
|
|
3
3
|
--progress-border-color: hsla(300, 6%, 87%, 1);
|
|
4
4
|
--progress-indicator-bg: hsla(300, 7%, 92%, 1);
|
|
5
5
|
--progress-indicator-edge: linear-gradient(90deg, hsla(300, 6%, 87%, 0) 0%, hsla(300, 6%, 87%, 1) 100%);
|
|
6
|
-
--progress-label-color: var(--
|
|
6
|
+
--progress-label-color: var(--text-1);
|
|
7
7
|
|
|
8
8
|
display: block;
|
|
9
9
|
container-type: inline-size;
|
|
@@ -26,7 +26,7 @@ a-progress[tone="info"] {
|
|
|
26
26
|
--progress-border-color: #B8DCF6;
|
|
27
27
|
--progress-indicator-bg: #DBEDFA;
|
|
28
28
|
--progress-indicator-edge: linear-gradient(90deg, hsla(205, 79%, 85%, 0) 0%, hsla(205, 79%, 85%, 1) 100%);
|
|
29
|
-
--progress-label-color: var(--
|
|
29
|
+
--progress-label-color: var(--text-1-info);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
.dark a-progress[tone="info"] {
|
|
@@ -55,11 +55,11 @@ a-progress-number {
|
|
|
55
55
|
a-progress-text {
|
|
56
56
|
flex: 1 1 auto;
|
|
57
57
|
min-width: 0;
|
|
58
|
-
color: var(--
|
|
58
|
+
color: var(--text-2);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
a-progress-hint {
|
|
62
62
|
flex-shrink: 0;
|
|
63
63
|
margin-left: auto;
|
|
64
|
-
color: var(--
|
|
64
|
+
color: var(--text-3);
|
|
65
65
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { HTMLElementBase } from "../anta_helpers";
|
|
2
|
+
class AProgressElement extends HTMLElementBase {
|
|
2
3
|
static observedAttributes = ["value", "max", "tone"];
|
|
3
4
|
indicator;
|
|
4
5
|
constructor() {
|
|
@@ -54,6 +55,7 @@ class AProgressElement extends HTMLElement {
|
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
function register_a_progress() {
|
|
58
|
+
if (typeof customElements === "undefined") return;
|
|
57
59
|
if (!customElements.get("a-progress")) {
|
|
58
60
|
customElements.define("a-progress", AProgressElement);
|
|
59
61
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
a-text {
|
|
2
|
+
--text-color: var(--text-1);
|
|
3
|
+
--text-link-color: var(--link-color);
|
|
4
|
+
--text-link-hover: var(--link-color-hover);
|
|
5
|
+
|
|
6
|
+
display: block;
|
|
7
|
+
color: var(--text-color);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
a-text[inline] {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Truncation, the expandable mask, the chevron button, and the
|
|
15
|
+
expanded-state toggle live in shadow DOM — see
|
|
16
|
+
src/elements/a-text.ts. The one external concern is `min-width: 0`:
|
|
17
|
+
the host needs it to shrink inside flex/grid parents so the inner
|
|
18
|
+
clamp can actually clip content. */
|
|
19
|
+
a-text[truncate] {
|
|
20
|
+
min-width: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Neutral priority overrides. Levels 1 & 2 keep the brand link color;
|
|
24
|
+
levels 3-5 mute the link to currentColor and step the hover up by one
|
|
25
|
+
level (3→2, 4→3, 5→4). */
|
|
26
|
+
a-text[priority="secondary"] { --text-color: var(--text-2); }
|
|
27
|
+
a-text[priority="tertiary"] { --text-color: var(--text-3); --text-link-color: currentColor; --text-link-hover: var(--text-2); }
|
|
28
|
+
a-text[priority="quaternary"] { --text-color: var(--text-4); --text-link-color: currentColor; --text-link-hover: var(--text-3); }
|
|
29
|
+
a-text[priority="quinary"] { --text-color: var(--text-5); --text-link-color: currentColor; --text-link-hover: var(--text-4); }
|
|
30
|
+
|
|
31
|
+
/* Tinted — text color uses --text-{N}-{tone} tokens; links are always
|
|
32
|
+
muted (currentColor) and hover steps up one level of the same tint.
|
|
33
|
+
Level 1 has no level above; hover keeps the color, only the underline
|
|
34
|
+
alpha changes. */
|
|
35
|
+
a-text[tone="brand"] { --text-color: var(--text-1-brand); --text-link-color: currentColor; --text-link-hover: var(--text-1-brand); }
|
|
36
|
+
a-text[tone="brand"][priority="secondary"] { --text-color: var(--text-2-brand); --text-link-hover: var(--text-1-brand); }
|
|
37
|
+
a-text[tone="brand"][priority="tertiary"] { --text-color: var(--text-3-brand); --text-link-hover: var(--text-2-brand); }
|
|
38
|
+
a-text[tone="brand"][priority="quaternary"] { --text-color: var(--text-4-brand); --text-link-hover: var(--text-3-brand); }
|
|
39
|
+
a-text[tone="brand"][priority="quinary"] { --text-color: var(--text-5-brand); --text-link-hover: var(--text-4-brand); }
|
|
40
|
+
|
|
41
|
+
a-text[tone="success"] { --text-color: var(--text-1-success); --text-link-color: currentColor; --text-link-hover: var(--text-1-success); }
|
|
42
|
+
a-text[tone="success"][priority="secondary"] { --text-color: var(--text-2-success); --text-link-hover: var(--text-1-success); }
|
|
43
|
+
a-text[tone="success"][priority="tertiary"] { --text-color: var(--text-3-success); --text-link-hover: var(--text-2-success); }
|
|
44
|
+
a-text[tone="success"][priority="quaternary"] { --text-color: var(--text-4-success); --text-link-hover: var(--text-3-success); }
|
|
45
|
+
a-text[tone="success"][priority="quinary"] { --text-color: var(--text-5-success); --text-link-hover: var(--text-4-success); }
|
|
46
|
+
|
|
47
|
+
a-text[tone="critical"] { --text-color: var(--text-1-critical); --text-link-color: currentColor; --text-link-hover: var(--text-1-critical); }
|
|
48
|
+
a-text[tone="critical"][priority="secondary"] { --text-color: var(--text-2-critical); --text-link-hover: var(--text-1-critical); }
|
|
49
|
+
a-text[tone="critical"][priority="tertiary"] { --text-color: var(--text-3-critical); --text-link-hover: var(--text-2-critical); }
|
|
50
|
+
a-text[tone="critical"][priority="quaternary"] { --text-color: var(--text-4-critical); --text-link-hover: var(--text-3-critical); }
|
|
51
|
+
a-text[tone="critical"][priority="quinary"] { --text-color: var(--text-5-critical); --text-link-hover: var(--text-4-critical); }
|
|
52
|
+
|
|
53
|
+
a-text[tone="warning"] { --text-color: var(--text-1-warning); --text-link-color: currentColor; --text-link-hover: var(--text-1-warning); }
|
|
54
|
+
a-text[tone="warning"][priority="secondary"] { --text-color: var(--text-2-warning); --text-link-hover: var(--text-1-warning); }
|
|
55
|
+
a-text[tone="warning"][priority="tertiary"] { --text-color: var(--text-3-warning); --text-link-hover: var(--text-2-warning); }
|
|
56
|
+
a-text[tone="warning"][priority="quaternary"] { --text-color: var(--text-4-warning); --text-link-hover: var(--text-3-warning); }
|
|
57
|
+
a-text[tone="warning"][priority="quinary"] { --text-color: var(--text-5-warning); --text-link-hover: var(--text-4-warning); }
|
|
58
|
+
|
|
59
|
+
a-text[tone="info"] { --text-color: var(--text-1-info); --text-link-color: currentColor; --text-link-hover: var(--text-1-info); }
|
|
60
|
+
a-text[tone="info"][priority="secondary"] { --text-color: var(--text-2-info); --text-link-hover: var(--text-1-info); }
|
|
61
|
+
a-text[tone="info"][priority="tertiary"] { --text-color: var(--text-3-info); --text-link-hover: var(--text-2-info); }
|
|
62
|
+
a-text[tone="info"][priority="quaternary"] { --text-color: var(--text-4-info); --text-link-hover: var(--text-3-info); }
|
|
63
|
+
a-text[tone="info"][priority="quinary"] { --text-color: var(--text-5-info); --text-link-hover: var(--text-4-info); }
|
|
64
|
+
|
|
65
|
+
/* Link colors layered on top of anta's global `a` defaults — only
|
|
66
|
+
overriding what the priority/tone cascade dictates (color and the
|
|
67
|
+
one-step-up hover color). Underline / thickness / offset / alpha
|
|
68
|
+
are inherited from the global rule in anta_global_tokens.css.
|
|
69
|
+
On hover the underline color is repeated so it tracks the priority
|
|
70
|
+
color rather than the global --link-color-hover. */
|
|
71
|
+
a-text a, a-text a:link, a-text a:visited { color: var(--text-link-color); }
|
|
72
|
+
a-text a:hover {
|
|
73
|
+
color: var(--text-link-hover);
|
|
74
|
+
text-decoration-color: var(--text-link-hover);
|
|
75
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTMLElementBase } from '../anta_helpers';
|
|
2
|
+
export declare class ATextElement extends HTMLElementBase {
|
|
3
|
+
static observedAttributes: string[];
|
|
4
|
+
private slotEl;
|
|
5
|
+
private expandBtn;
|
|
6
|
+
constructor();
|
|
7
|
+
attributeChangedCallback(): void;
|
|
8
|
+
private handleExpand;
|
|
9
|
+
}
|
|
10
|
+
export declare function register_a_text(): void;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { HTMLElementBase } from "../anta_helpers";
|
|
2
|
+
const SHADOW_STYLE = `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
position: relative;
|
|
6
|
+
}
|
|
7
|
+
:host([inline]) {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* Default: slot disappears from layout so slotted nodes flow as
|
|
12
|
+
direct children of the host. Truncation rules below give the slot
|
|
13
|
+
a real display so it becomes the wrapper that holds the clamp. */
|
|
14
|
+
slot {
|
|
15
|
+
display: contents;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:host([truncate]) slot {
|
|
19
|
+
display: -webkit-box;
|
|
20
|
+
-webkit-box-orient: vertical;
|
|
21
|
+
-webkit-line-clamp: var(--line-clamp, 1);
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Expandable \u2014 vertical fade for multi-line. */
|
|
26
|
+
:host([truncate][expandable]) slot:not(.expanded) {
|
|
27
|
+
-webkit-mask-image: linear-gradient(to bottom, black calc(100% - 2em), transparent 97%);
|
|
28
|
+
mask-image: linear-gradient(to bottom, black calc(100% - 2em), transparent 97%);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Expandable \u2014 horizontal right-edge fade for single-line. */
|
|
32
|
+
:host([truncate="1"][expandable]) slot:not(.expanded) {
|
|
33
|
+
-webkit-mask-image: linear-gradient(to right, black calc(100% - 7ch), transparent 97%);
|
|
34
|
+
mask-image: linear-gradient(to right, black calc(100% - 7ch), transparent 97%);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Expanded \u2014 drop truncation entirely. */
|
|
38
|
+
:host([truncate]) slot.expanded {
|
|
39
|
+
display: block;
|
|
40
|
+
-webkit-line-clamp: unset;
|
|
41
|
+
overflow: visible;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Expand button. The whole button is the click target; the chevron
|
|
45
|
+
icon is positioned absolutely in the button's bottom-right corner. */
|
|
46
|
+
.expand-btn {
|
|
47
|
+
appearance: none;
|
|
48
|
+
background: transparent;
|
|
49
|
+
border: none;
|
|
50
|
+
margin: 0;
|
|
51
|
+
padding: 0;
|
|
52
|
+
color: var(--text-3);
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
font: inherit;
|
|
55
|
+
display: none;
|
|
56
|
+
position: absolute;
|
|
57
|
+
z-index: 1;
|
|
58
|
+
opacity: 0;
|
|
59
|
+
transition: opacity 150ms ease-out, color 150ms ease-out;
|
|
60
|
+
}
|
|
61
|
+
.expand-btn:hover {
|
|
62
|
+
color: var(--text-1);
|
|
63
|
+
}
|
|
64
|
+
.expand-btn::before {
|
|
65
|
+
content: '';
|
|
66
|
+
position: absolute;
|
|
67
|
+
right: -1px;
|
|
68
|
+
bottom: -1px;
|
|
69
|
+
width: 14px;
|
|
70
|
+
height: 14px;
|
|
71
|
+
background-color: currentColor;
|
|
72
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
|
|
73
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
|
|
74
|
+
-webkit-mask-position: center;
|
|
75
|
+
mask-position: center;
|
|
76
|
+
-webkit-mask-repeat: no-repeat;
|
|
77
|
+
mask-repeat: no-repeat;
|
|
78
|
+
-webkit-mask-size: contain;
|
|
79
|
+
mask-size: contain;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Multi-line \u2014 full-width strip pinned to the bottom of the host. */
|
|
83
|
+
:host([truncate][expandable]) .expand-btn:not(.hidden) {
|
|
84
|
+
display: block;
|
|
85
|
+
left: 0;
|
|
86
|
+
right: 0;
|
|
87
|
+
bottom: 0;
|
|
88
|
+
height: 1.5em;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Single-line \u2014 narrow region pinned to the right side. */
|
|
92
|
+
:host([truncate="1"][expandable]) .expand-btn:not(.hidden) {
|
|
93
|
+
left: auto;
|
|
94
|
+
top: 0;
|
|
95
|
+
bottom: 0;
|
|
96
|
+
width: 3em;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host([truncate][expandable]:hover) .expand-btn:not(.hidden),
|
|
100
|
+
:host([truncate][expandable]:focus-within) .expand-btn:not(.hidden) {
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
class ATextElement extends HTMLElementBase {
|
|
105
|
+
static observedAttributes = ["expandable", "truncate"];
|
|
106
|
+
slotEl;
|
|
107
|
+
expandBtn;
|
|
108
|
+
constructor() {
|
|
109
|
+
super();
|
|
110
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
111
|
+
const style = document.createElement("style");
|
|
112
|
+
style.textContent = SHADOW_STYLE;
|
|
113
|
+
this.slotEl = document.createElement("slot");
|
|
114
|
+
this.expandBtn = document.createElement("button");
|
|
115
|
+
this.expandBtn.className = "expand-btn";
|
|
116
|
+
this.expandBtn.type = "button";
|
|
117
|
+
this.expandBtn.setAttribute("aria-label", "Show more");
|
|
118
|
+
this.expandBtn.setAttribute("aria-expanded", "false");
|
|
119
|
+
this.expandBtn.addEventListener("click", this.handleExpand);
|
|
120
|
+
shadow.append(style, this.slotEl, this.expandBtn);
|
|
121
|
+
}
|
|
122
|
+
attributeChangedCallback() {
|
|
123
|
+
this.slotEl.classList.remove("expanded");
|
|
124
|
+
this.expandBtn.classList.remove("hidden");
|
|
125
|
+
this.expandBtn.setAttribute("aria-expanded", "false");
|
|
126
|
+
}
|
|
127
|
+
handleExpand = () => {
|
|
128
|
+
if (this.slotEl.classList.contains("expanded")) return;
|
|
129
|
+
this.slotEl.classList.add("expanded");
|
|
130
|
+
this.expandBtn.classList.add("hidden");
|
|
131
|
+
this.expandBtn.setAttribute("aria-expanded", "true");
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function register_a_text() {
|
|
135
|
+
if (typeof customElements === "undefined") return;
|
|
136
|
+
if (!customElements.get("a-text")) {
|
|
137
|
+
customElements.define("a-text", ATextElement);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
ATextElement,
|
|
142
|
+
register_a_text
|
|
143
|
+
};
|
package/dist/elements/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import './a-progress.css';
|
|
2
|
+
import './a-text.css';
|
|
3
|
+
import './a-icon.css';
|
|
4
|
+
import './a-icon.shapes.css';
|
|
2
5
|
export { AProgressElement, register_a_progress } from './a-progress';
|
|
6
|
+
export { ATextElement, register_a_text } from './a-text';
|
|
7
|
+
export { AIconElement, register_a_icon } from './a-icon';
|
package/dist/elements/index.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { register_a_progress } from "./a-progress";
|
|
2
|
+
import { register_a_text } from "./a-text";
|
|
3
|
+
import { register_a_icon } from "./a-icon";
|
|
2
4
|
import "./a-progress.css";
|
|
5
|
+
import "./a-text.css";
|
|
6
|
+
import "./a-icon.css";
|
|
7
|
+
import "./a-icon.shapes.css";
|
|
3
8
|
import { AProgressElement, register_a_progress as register_a_progress2 } from "./a-progress";
|
|
9
|
+
import { ATextElement, register_a_text as register_a_text2 } from "./a-text";
|
|
10
|
+
import { AIconElement, register_a_icon as register_a_icon2 } from "./a-icon";
|
|
4
11
|
if (typeof customElements !== "undefined") {
|
|
5
12
|
register_a_progress();
|
|
13
|
+
register_a_text();
|
|
14
|
+
register_a_icon();
|
|
6
15
|
}
|
|
7
16
|
export {
|
|
17
|
+
AIconElement,
|
|
8
18
|
AProgressElement,
|
|
9
|
-
|
|
19
|
+
ATextElement,
|
|
20
|
+
register_a_icon2 as register_a_icon,
|
|
21
|
+
register_a_progress2 as register_a_progress,
|
|
22
|
+
register_a_text2 as register_a_text
|
|
10
23
|
};
|
package/dist/general_types.d.ts
CHANGED
|
@@ -1,16 +1,90 @@
|
|
|
1
|
+
/** Common props for JSX component wrappers. */
|
|
1
2
|
export interface BaseProps {
|
|
3
|
+
/** CSS class name. Merged with any internal classes by the component. */
|
|
2
4
|
className?: string;
|
|
5
|
+
/** Inline styles applied to the root element. */
|
|
3
6
|
style?: React.CSSProperties;
|
|
7
|
+
/** Child elements. When provided, replaces the component's default label/content. */
|
|
4
8
|
children?: React.ReactNode;
|
|
5
9
|
}
|
|
10
|
+
/** Attributes for intrinsic custom elements (`<a-*>` tags) in JSX. */
|
|
6
11
|
export interface BaseAttributes {
|
|
12
|
+
/** HTML `class` attribute (standard DOM). */
|
|
7
13
|
class?: string;
|
|
14
|
+
/** React/Preact-style class name. Alias for `class`. */
|
|
8
15
|
className?: string;
|
|
16
|
+
/** Inline styles applied to the element. */
|
|
9
17
|
style?: React.CSSProperties;
|
|
10
18
|
children?: React.ReactNode;
|
|
19
|
+
/** Tab order. Set to `0` to make the element keyboard-focusable. */
|
|
20
|
+
tabIndex?: number;
|
|
21
|
+
/** ARIA role override. */
|
|
22
|
+
role?: string;
|
|
23
|
+
/** Keydown handler — used for keyboard-driven interactions. */
|
|
24
|
+
onKeyDown?: (e: any) => void;
|
|
25
|
+
/** Click handler — used for mouse / tap activation. */
|
|
26
|
+
onClick?: (e: any) => void;
|
|
11
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Attributes for the `<a-progress>` custom element.
|
|
30
|
+
*
|
|
31
|
+
* These are the low-level web component attributes. For the JSX wrapper with
|
|
32
|
+
* typed props and computed labels, use `Progress` from `@antadesign/anta`.
|
|
33
|
+
*/
|
|
12
34
|
export interface AProgressAttributes extends BaseAttributes {
|
|
35
|
+
/** Current progress value. */
|
|
13
36
|
value?: number | string;
|
|
37
|
+
/** Maximum value. Defaults to 100. */
|
|
14
38
|
max?: number | string;
|
|
39
|
+
/** Color variant. `'neutral'` is the default gray; `'info'` is blue. */
|
|
15
40
|
tone?: 'neutral' | 'info';
|
|
41
|
+
/** ARIA role — the JSX wrapper sets this to `'progressbar'`. */
|
|
42
|
+
role?: string;
|
|
43
|
+
/** ARIA value-now (current). */
|
|
44
|
+
'aria-valuenow'?: number | string;
|
|
45
|
+
/** ARIA value-max. */
|
|
46
|
+
'aria-valuemax'?: number | string;
|
|
47
|
+
/** ARIA value-min (defaults to 0). */
|
|
48
|
+
'aria-valuemin'?: number | string;
|
|
49
|
+
/** ARIA accessible name. */
|
|
50
|
+
'aria-label'?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Attributes for the `<a-text>` custom element.
|
|
54
|
+
*
|
|
55
|
+
* Low-level web component attributes; for the JSX wrapper use `Text`
|
|
56
|
+
* from `@antadesign/anta`.
|
|
57
|
+
*/
|
|
58
|
+
export interface ATextAttributes extends BaseAttributes {
|
|
59
|
+
/** Visual priority. Maps to text-1..text-5. */
|
|
60
|
+
priority?: 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'quinary';
|
|
61
|
+
/** Color tint. Applies the matching `--text-{N}-{tone}` palette. */
|
|
62
|
+
tone?: 'brand' | 'success' | 'critical' | 'warning' | 'info';
|
|
63
|
+
/** Render as inline-block instead of the default block. */
|
|
64
|
+
inline?: boolean | string;
|
|
65
|
+
/** Truncate to N lines with a trailing ellipsis. The attribute value
|
|
66
|
+
* carries the line count (e.g. `"1"`, `"3"`); the count is also
|
|
67
|
+
* available via the `--line-clamp` CSS custom property set inline. */
|
|
68
|
+
truncate?: boolean | string | number;
|
|
69
|
+
/** Marks the host as expandable when paired with `truncate`. Adds
|
|
70
|
+
* the fade-out mask; the JSX wrapper renders the chevron and owns
|
|
71
|
+
* the click/keyboard expansion logic. */
|
|
72
|
+
expandable?: boolean | string;
|
|
73
|
+
/** ARIA disclosure state, mirrors the JSX wrapper's `expanded` flag. */
|
|
74
|
+
'aria-expanded'?: boolean | 'true' | 'false';
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Attributes for the `<a-icon>` custom element. The `shape` attribute
|
|
78
|
+
* value is typed as `string` here so the element accepts any consumer's
|
|
79
|
+
* generated shapes. The JSX wrapper (`Icon`) narrows it to `IconShape`.
|
|
80
|
+
*/
|
|
81
|
+
export interface AIconAttributes extends BaseAttributes {
|
|
82
|
+
/** Which icon to render. */
|
|
83
|
+
shape?: string;
|
|
84
|
+
/** ARIA role — the JSX wrapper sets `'img'` when a label is provided. */
|
|
85
|
+
role?: string;
|
|
86
|
+
/** ARIA accessible name when the icon carries meaning. */
|
|
87
|
+
'aria-label'?: string;
|
|
88
|
+
/** Hides decorative icons from screen readers. */
|
|
89
|
+
'aria-hidden'?: 'true' | 'false' | boolean;
|
|
16
90
|
}
|