@theweekendprojects/emvb-daisyui 0.0.0-stage → 0.2.1
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/LICENSE +21 -0
- package/README.md +106 -2
- package/licenses/daisyui-MIT.txt +3 -0
- package/package.json +55 -4
- package/src/catalog/basic.ts +407 -0
- package/src/catalog/class-names.ts +623 -0
- package/src/catalog/countdown.ts +392 -0
- package/src/catalog/data-display.ts +563 -0
- package/src/catalog/forms.ts +433 -0
- package/src/catalog/index.ts +77 -0
- package/src/catalog/interactive.ts +567 -0
- package/src/catalog/layout-marketing.ts +641 -0
- package/src/catalog/missing-complex.ts +430 -0
- package/src/catalog/missing-primitives.ts +409 -0
- package/src/catalog/navigation.ts +438 -0
- package/src/catalog/value-class.ts +20 -0
- package/src/compatibility/index.ts +104 -0
- package/src/compound/editor.ts +299 -0
- package/src/compound/index.ts +157 -0
- package/src/conformance/cli.ts +9 -0
- package/src/conformance/compile.ts +77 -0
- package/src/conformance/index.ts +4 -0
- package/src/conformance/manifest.ts +39 -0
- package/src/conformance/official-inventory.ts +135 -0
- package/src/conformance/report-cli.ts +5 -0
- package/src/conformance/report.ts +59 -0
- package/src/conformance/verify-css.ts +22 -0
- package/src/extension/class-token.ts +11 -0
- package/src/extension/classes.ts +636 -0
- package/src/extension/collect-classes.ts +73 -0
- package/src/extension/content.ts +93 -0
- package/src/extension/daisy.css +12441 -0
- package/src/extension/daisy.js +1 -0
- package/src/extension/elements.ts +262 -0
- package/src/extension/index.ts +39 -0
- package/src/extension/to-output.ts +113 -0
- package/src/generator/artifacts.ts +81 -0
- package/src/generator/class-names.ts +35 -0
- package/src/generator/cli.ts +21 -0
- package/src/generator/generate.ts +122 -0
- package/src/generator/index.ts +2 -0
- package/src/generator/write-class-names.ts +10 -0
- package/src/index.ts +12 -0
- package/src/render/classes.ts +48 -0
- package/src/render/href.ts +19 -0
- package/src/render/index.ts +3 -0
- package/src/render/provider.ts +37 -0
- package/src/renderer.ts +6 -0
- package/src/runtime/browser.ts +11 -0
- package/src/runtime/index.ts +41 -0
- package/src/test-support.ts +13 -0
- package/src/themes/index.ts +72 -0
- package/src/types.ts +116 -0
- package/src/validation/index.ts +153 -0
- package/src/verified/primitives.ts +62 -0
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import type { DaisyComponentDefinition, DaisyVNode } from "../types.ts";
|
|
2
|
+
import { safeHref } from "../render/href.ts";
|
|
3
|
+
import { COUNTDOWN } from "./countdown.ts";
|
|
4
|
+
|
|
5
|
+
export { COUNTDOWN };
|
|
6
|
+
|
|
7
|
+
/** Up to two initials from the alternative text, for a placeholder avatar. */
|
|
8
|
+
const initialsOf = (alt: unknown) =>
|
|
9
|
+
String(alt ?? "")
|
|
10
|
+
.trim()
|
|
11
|
+
.split(/\s+/)
|
|
12
|
+
.map((word) => word[0]?.toUpperCase() ?? "")
|
|
13
|
+
.filter(Boolean)
|
|
14
|
+
.slice(0, 2)
|
|
15
|
+
.join("") || "?";
|
|
16
|
+
const lines = (value: unknown, max = 50) =>
|
|
17
|
+
String(value ?? "")
|
|
18
|
+
.split(/\r?\n/)
|
|
19
|
+
.map((item) => item.trim())
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.slice(0, max);
|
|
22
|
+
export const TABLE: DaisyComponentDefinition = {
|
|
23
|
+
id: "table",
|
|
24
|
+
label: "Table",
|
|
25
|
+
category: "Data display",
|
|
26
|
+
tag: "div",
|
|
27
|
+
rootClass: "overflow-x-auto",
|
|
28
|
+
fields: [
|
|
29
|
+
{ key: "caption", label: "Caption", kind: "text", default: "Data table" },
|
|
30
|
+
{ key: "headers", label: "Headers, separated by |", kind: "text", default: "Name|Role|Status" },
|
|
31
|
+
{
|
|
32
|
+
key: "rows",
|
|
33
|
+
label: "Rows, cells separated by |",
|
|
34
|
+
kind: "textarea",
|
|
35
|
+
default: "Jane|Designer|Active\nJohn|Developer|Away",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: "style",
|
|
39
|
+
label: "Style",
|
|
40
|
+
kind: "select",
|
|
41
|
+
default: "zebra",
|
|
42
|
+
options: ["plain", "zebra", "pin-rows", "pin-cols"],
|
|
43
|
+
classMap: {
|
|
44
|
+
plain: "",
|
|
45
|
+
zebra: "table-zebra",
|
|
46
|
+
"pin-rows": "table-pin-rows",
|
|
47
|
+
"pin-cols": "table-pin-cols",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: "size",
|
|
52
|
+
label: "Size",
|
|
53
|
+
kind: "select",
|
|
54
|
+
default: "md",
|
|
55
|
+
options: ["xs", "sm", "md", "lg", "xl"],
|
|
56
|
+
classMap: { xs: "table-xs", sm: "table-sm", md: "table-md", lg: "table-lg", xl: "table-xl" },
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
build(node, classes) {
|
|
60
|
+
const headers = String(node.props.headers ?? "")
|
|
61
|
+
.split("|")
|
|
62
|
+
.map((v) => v.trim())
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.slice(0, 12);
|
|
65
|
+
const rows = lines(node.props.rows, 100).map((row) =>
|
|
66
|
+
row
|
|
67
|
+
.split("|")
|
|
68
|
+
.map((v) => v.trim())
|
|
69
|
+
.slice(0, headers.length || 12),
|
|
70
|
+
);
|
|
71
|
+
return {
|
|
72
|
+
tag: "div",
|
|
73
|
+
attrs: { class: "overflow-x-auto" },
|
|
74
|
+
children: [
|
|
75
|
+
{
|
|
76
|
+
tag: "table",
|
|
77
|
+
attrs: {
|
|
78
|
+
class: ["table", ...classes.filter((c) => c !== "overflow-x-auto")]
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.join(" "),
|
|
81
|
+
},
|
|
82
|
+
children: [
|
|
83
|
+
{ tag: "caption", attrs: { class: "sr-only" }, children: [String(node.props.caption)] },
|
|
84
|
+
{
|
|
85
|
+
tag: "thead",
|
|
86
|
+
attrs: {},
|
|
87
|
+
children: [
|
|
88
|
+
{
|
|
89
|
+
tag: "tr",
|
|
90
|
+
attrs: {},
|
|
91
|
+
children: headers.map((h) => ({
|
|
92
|
+
tag: "th",
|
|
93
|
+
attrs: { scope: "col" },
|
|
94
|
+
children: [h],
|
|
95
|
+
})),
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
tag: "tbody",
|
|
101
|
+
attrs: {},
|
|
102
|
+
children: rows.map((cells) => ({
|
|
103
|
+
tag: "tr",
|
|
104
|
+
attrs: {},
|
|
105
|
+
children: cells.map((cell, index) => ({
|
|
106
|
+
tag: index === 0 ? "th" : "td",
|
|
107
|
+
attrs: index === 0 ? { scope: "row" } : {},
|
|
108
|
+
children: [cell],
|
|
109
|
+
})),
|
|
110
|
+
})),
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const TIMELINE: DaisyComponentDefinition = {
|
|
120
|
+
id: "timeline",
|
|
121
|
+
label: "Timeline",
|
|
122
|
+
category: "Data display",
|
|
123
|
+
tag: "ul",
|
|
124
|
+
rootClass: "timeline",
|
|
125
|
+
fields: [
|
|
126
|
+
{ key: "label", label: "Timeline label", kind: "text", default: "Project milestones" },
|
|
127
|
+
{
|
|
128
|
+
key: "items",
|
|
129
|
+
label: "Items, Date|Title|Description",
|
|
130
|
+
kind: "textarea",
|
|
131
|
+
default: "2024|Started|Initial release\n2025|Expanded|New components",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
key: "direction",
|
|
135
|
+
label: "Direction",
|
|
136
|
+
kind: "select",
|
|
137
|
+
default: "horizontal",
|
|
138
|
+
options: ["vertical", "horizontal"],
|
|
139
|
+
classMap: { vertical: "timeline-vertical", horizontal: "timeline-horizontal" },
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
key: "snap",
|
|
143
|
+
label: "Snap the icon to the line",
|
|
144
|
+
kind: "boolean",
|
|
145
|
+
default: false,
|
|
146
|
+
classMap: { true: "timeline-snap-icon", false: "" },
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: "compact",
|
|
150
|
+
label: "Compact",
|
|
151
|
+
kind: "boolean",
|
|
152
|
+
default: false,
|
|
153
|
+
classMap: { true: "timeline-compact", false: "" },
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
key: "boxed",
|
|
157
|
+
label: "Boxed milestones",
|
|
158
|
+
kind: "boolean",
|
|
159
|
+
default: true,
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
build(node, classes) {
|
|
163
|
+
return {
|
|
164
|
+
tag: "ul",
|
|
165
|
+
// Horizontal is the default, but a phone cannot fit a row of milestones: fall back to the
|
|
166
|
+
// vertical list below the small breakpoint, the same way the megamenu does.
|
|
167
|
+
attrs: {
|
|
168
|
+
class:
|
|
169
|
+
node.props.direction === "vertical"
|
|
170
|
+
? classes.join(" ")
|
|
171
|
+
: `${classes.join(" ")} max-sm:timeline-vertical`,
|
|
172
|
+
"aria-label": String(node.props.label),
|
|
173
|
+
},
|
|
174
|
+
children: lines(node.props.items, 30).map((entry, index, all) => {
|
|
175
|
+
const [date, title, description = ""] = entry.split("|");
|
|
176
|
+
// daisyUI joins the items with a line on each side of the marker: every item but the last
|
|
177
|
+
// ends with one, and every item but the first starts with one (the official examples).
|
|
178
|
+
const last = index === all.length - 1;
|
|
179
|
+
return {
|
|
180
|
+
tag: "li",
|
|
181
|
+
attrs: {},
|
|
182
|
+
children: [
|
|
183
|
+
index ? { tag: "hr", attrs: {}, children: [] } : "",
|
|
184
|
+
{ tag: "div", attrs: { class: "timeline-start" }, children: [date || ""] },
|
|
185
|
+
{
|
|
186
|
+
tag: "div",
|
|
187
|
+
attrs: { class: "timeline-middle", "aria-hidden": "true" },
|
|
188
|
+
children: ["●"],
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
tag: "div",
|
|
192
|
+
// daisyUI's box paints base-100, which is white in the light theme this renderer
|
|
193
|
+
// ships; the text inherits from the page, so the box is transparent like a card.
|
|
194
|
+
attrs: {
|
|
195
|
+
class:
|
|
196
|
+
node.props.boxed === false
|
|
197
|
+
? "timeline-end"
|
|
198
|
+
: "timeline-end timeline-box bg-transparent",
|
|
199
|
+
},
|
|
200
|
+
children: [
|
|
201
|
+
{ tag: "strong", attrs: {}, children: [title || "Milestone"] },
|
|
202
|
+
{ tag: "p", attrs: {}, children: [description] },
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
last ? "" : { tag: "hr", attrs: {}, children: [] },
|
|
206
|
+
].filter(Boolean) as Array<DaisyVNode | string>,
|
|
207
|
+
};
|
|
208
|
+
}),
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export const AVATAR: DaisyComponentDefinition = {
|
|
214
|
+
id: "avatar",
|
|
215
|
+
label: "Avatar",
|
|
216
|
+
category: "Data display",
|
|
217
|
+
tag: "div",
|
|
218
|
+
rootClass: "avatar",
|
|
219
|
+
fields: [
|
|
220
|
+
{ key: "src", label: "Image", kind: "media", default: "" },
|
|
221
|
+
{ key: "alt", label: "Alternative text", kind: "text", default: "User avatar" },
|
|
222
|
+
{
|
|
223
|
+
key: "size",
|
|
224
|
+
label: "Size",
|
|
225
|
+
kind: "select",
|
|
226
|
+
default: "md",
|
|
227
|
+
options: ["xs", "sm", "md", "lg", "xl"],
|
|
228
|
+
classMap: { xs: "w-8", sm: "w-12", md: "w-16", lg: "w-24", xl: "w-32" },
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
key: "status",
|
|
232
|
+
label: "Status",
|
|
233
|
+
kind: "select",
|
|
234
|
+
default: "none",
|
|
235
|
+
options: ["none", "online", "offline"],
|
|
236
|
+
classMap: { none: "", online: "avatar-online", offline: "avatar-offline" },
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
key: "shape",
|
|
240
|
+
label: "Shape",
|
|
241
|
+
kind: "select",
|
|
242
|
+
default: "round",
|
|
243
|
+
options: ["round", "square"],
|
|
244
|
+
classMap: { round: "rounded-full", square: "rounded" },
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
build(node, classes) {
|
|
248
|
+
const wrapper = classes.filter((c) => !c.startsWith("w-") && !c.startsWith("rounded"));
|
|
249
|
+
const image = classes.filter((c) => c.startsWith("w-") || c.startsWith("rounded"));
|
|
250
|
+
// No picture: daisyUI's placeholder avatar shows initials from the alternative text.
|
|
251
|
+
if (!String(node.props.src ?? "").trim()) {
|
|
252
|
+
return {
|
|
253
|
+
tag: "div",
|
|
254
|
+
// daisyUI 5 names the empty-image avatar `avatar-placeholder` (the old `placeholder` is not styled).
|
|
255
|
+
attrs: { class: [...wrapper, "avatar-placeholder"].join(" ") },
|
|
256
|
+
children: [
|
|
257
|
+
{
|
|
258
|
+
tag: "div",
|
|
259
|
+
// Primary, not neutral: a neutral disc is near-black and reads as a hole on the dark theme.
|
|
260
|
+
// grid + place-items-center puts the initials in the middle of the disc, not its corner.
|
|
261
|
+
attrs: {
|
|
262
|
+
class: ["grid place-items-center bg-primary text-primary-content", ...image].join(
|
|
263
|
+
" ",
|
|
264
|
+
),
|
|
265
|
+
},
|
|
266
|
+
children: [{ tag: "span", attrs: {}, children: [initialsOf(node.props.alt)] }],
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
tag: "div",
|
|
273
|
+
attrs: { class: wrapper.join(" ") },
|
|
274
|
+
children: [
|
|
275
|
+
{
|
|
276
|
+
tag: "div",
|
|
277
|
+
attrs: { class: image.join(" ") },
|
|
278
|
+
children: [
|
|
279
|
+
{
|
|
280
|
+
tag: "img",
|
|
281
|
+
attrs: {
|
|
282
|
+
src: safeHref(node.props.src),
|
|
283
|
+
alt: String(node.props.alt),
|
|
284
|
+
loading: "lazy",
|
|
285
|
+
},
|
|
286
|
+
children: [],
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
};
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export const CHAT_BUBBLE: DaisyComponentDefinition = {
|
|
296
|
+
id: "chat-bubble",
|
|
297
|
+
label: "Chat Bubble",
|
|
298
|
+
category: "Data display",
|
|
299
|
+
tag: "article",
|
|
300
|
+
rootClass: "chat",
|
|
301
|
+
fields: [
|
|
302
|
+
{ key: "name", label: "Name", kind: "text", default: "Alice" },
|
|
303
|
+
{ key: "message", label: "Message", kind: "textarea", default: "Hello from EmVB!" },
|
|
304
|
+
{ key: "time", label: "Time", kind: "text", default: "12:45" },
|
|
305
|
+
{
|
|
306
|
+
key: "side",
|
|
307
|
+
label: "Side",
|
|
308
|
+
kind: "select",
|
|
309
|
+
default: "start",
|
|
310
|
+
options: ["start", "end"],
|
|
311
|
+
classMap: { start: "chat-start", end: "chat-end" },
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
key: "tone",
|
|
315
|
+
label: "Color",
|
|
316
|
+
kind: "select",
|
|
317
|
+
default: "primary",
|
|
318
|
+
options: ["neutral", "primary", "secondary", "accent", "info", "success", "warning", "error"],
|
|
319
|
+
classMap: {
|
|
320
|
+
neutral: "chat-bubble-neutral",
|
|
321
|
+
primary: "chat-bubble-primary",
|
|
322
|
+
secondary: "chat-bubble-secondary",
|
|
323
|
+
accent: "chat-bubble-accent",
|
|
324
|
+
info: "chat-bubble-info",
|
|
325
|
+
success: "chat-bubble-success",
|
|
326
|
+
warning: "chat-bubble-warning",
|
|
327
|
+
error: "chat-bubble-error",
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
build(node, classes) {
|
|
332
|
+
const bubble = classes.filter((c) => c.startsWith("chat-bubble-"));
|
|
333
|
+
const root = classes.filter((c) => !c.startsWith("chat-bubble-"));
|
|
334
|
+
return {
|
|
335
|
+
tag: "article",
|
|
336
|
+
attrs: { class: root.join(" ") },
|
|
337
|
+
children: [
|
|
338
|
+
{
|
|
339
|
+
tag: "header",
|
|
340
|
+
attrs: { class: "chat-header" },
|
|
341
|
+
children: [
|
|
342
|
+
String(node.props.name),
|
|
343
|
+
{
|
|
344
|
+
tag: "time",
|
|
345
|
+
attrs: { class: "text-xs opacity-50" },
|
|
346
|
+
children: [String(node.props.time)],
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
tag: "div",
|
|
352
|
+
attrs: { class: ["chat-bubble", ...bubble].join(" ") },
|
|
353
|
+
children: [String(node.props.message)],
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
};
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
export const LIST: DaisyComponentDefinition = {
|
|
361
|
+
id: "list",
|
|
362
|
+
label: "List",
|
|
363
|
+
category: "Data display",
|
|
364
|
+
tag: "ul",
|
|
365
|
+
rootClass: "list",
|
|
366
|
+
fields: [
|
|
367
|
+
{ key: "label", label: "List label", kind: "text", default: "Items" },
|
|
368
|
+
{
|
|
369
|
+
key: "items",
|
|
370
|
+
label: "Items, Title|Description|URL",
|
|
371
|
+
kind: "textarea",
|
|
372
|
+
default: "First|Description|/first\nSecond|Description|/second",
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
key: "striped",
|
|
376
|
+
label: "Striped",
|
|
377
|
+
kind: "boolean",
|
|
378
|
+
default: false,
|
|
379
|
+
classMap: { true: "bg-base-200", false: "" },
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
key: "wrap",
|
|
383
|
+
label: "Wrap long text",
|
|
384
|
+
kind: "boolean",
|
|
385
|
+
default: false,
|
|
386
|
+
classMap: { true: "list-col-wrap", false: "" },
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
key: "grow",
|
|
390
|
+
label: "Grow the text column",
|
|
391
|
+
kind: "boolean",
|
|
392
|
+
default: false,
|
|
393
|
+
classMap: { true: "list-col-grow", false: "" },
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
build(node, classes) {
|
|
397
|
+
return {
|
|
398
|
+
tag: "ul",
|
|
399
|
+
attrs: { class: classes.join(" "), "aria-label": String(node.props.label) },
|
|
400
|
+
children: lines(node.props.items, 50).map((entry) => {
|
|
401
|
+
const [title, description = "", href = ""] = entry.split("|");
|
|
402
|
+
const content: DaisyVNode = {
|
|
403
|
+
tag: "div",
|
|
404
|
+
attrs: {},
|
|
405
|
+
children: [
|
|
406
|
+
{ tag: "strong", attrs: {}, children: [title || "Item"] },
|
|
407
|
+
{ tag: "p", attrs: { class: "text-xs opacity-60" }, children: [description] },
|
|
408
|
+
],
|
|
409
|
+
};
|
|
410
|
+
return {
|
|
411
|
+
tag: "li",
|
|
412
|
+
attrs: { class: "list-row" },
|
|
413
|
+
children: href
|
|
414
|
+
? [
|
|
415
|
+
{
|
|
416
|
+
tag: "a",
|
|
417
|
+
attrs: { href: safeHref(href), class: "contents" },
|
|
418
|
+
children: [content],
|
|
419
|
+
},
|
|
420
|
+
]
|
|
421
|
+
: [content],
|
|
422
|
+
};
|
|
423
|
+
}),
|
|
424
|
+
};
|
|
425
|
+
},
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
export const STATUS: DaisyComponentDefinition = {
|
|
429
|
+
id: "status",
|
|
430
|
+
label: "Status",
|
|
431
|
+
category: "Data display",
|
|
432
|
+
tag: "span",
|
|
433
|
+
rootClass: "status",
|
|
434
|
+
fields: [
|
|
435
|
+
{ key: "label", label: "Accessible label", kind: "text", default: "Online" },
|
|
436
|
+
{
|
|
437
|
+
key: "tone",
|
|
438
|
+
label: "Color",
|
|
439
|
+
kind: "select",
|
|
440
|
+
default: "success",
|
|
441
|
+
options: ["neutral", "primary", "secondary", "accent", "info", "success", "warning", "error"],
|
|
442
|
+
classMap: {
|
|
443
|
+
neutral: "status-neutral",
|
|
444
|
+
primary: "status-primary",
|
|
445
|
+
secondary: "status-secondary",
|
|
446
|
+
accent: "status-accent",
|
|
447
|
+
info: "status-info",
|
|
448
|
+
success: "status-success",
|
|
449
|
+
warning: "status-warning",
|
|
450
|
+
error: "status-error",
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
key: "size",
|
|
455
|
+
label: "Size",
|
|
456
|
+
kind: "select",
|
|
457
|
+
default: "md",
|
|
458
|
+
options: ["xs", "sm", "md", "lg", "xl"],
|
|
459
|
+
classMap: {
|
|
460
|
+
xs: "status-xs",
|
|
461
|
+
sm: "status-sm",
|
|
462
|
+
md: "status-md",
|
|
463
|
+
lg: "status-lg",
|
|
464
|
+
xl: "status-xl",
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
key: "animate",
|
|
469
|
+
label: "Pulse",
|
|
470
|
+
kind: "boolean",
|
|
471
|
+
default: false,
|
|
472
|
+
classMap: { true: "animate-ping", false: "" },
|
|
473
|
+
},
|
|
474
|
+
],
|
|
475
|
+
build(node, classes) {
|
|
476
|
+
return {
|
|
477
|
+
tag: "span",
|
|
478
|
+
attrs: { class: classes.join(" "), role: "status", "aria-label": String(node.props.label) },
|
|
479
|
+
children: [],
|
|
480
|
+
};
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
export const TOOLTIP: DaisyComponentDefinition = {
|
|
485
|
+
id: "tooltip",
|
|
486
|
+
label: "Tooltip",
|
|
487
|
+
category: "Data display",
|
|
488
|
+
tag: "span",
|
|
489
|
+
rootClass: "tooltip",
|
|
490
|
+
container: true,
|
|
491
|
+
fields: [
|
|
492
|
+
{ key: "tip", label: "Tooltip text", kind: "text", default: "Helpful information" },
|
|
493
|
+
{ key: "content", label: "Visible text", kind: "text", default: "Hover me" },
|
|
494
|
+
{
|
|
495
|
+
key: "position",
|
|
496
|
+
label: "Position",
|
|
497
|
+
kind: "select",
|
|
498
|
+
default: "top",
|
|
499
|
+
options: ["top", "bottom", "left", "right"],
|
|
500
|
+
classMap: {
|
|
501
|
+
top: "tooltip-top",
|
|
502
|
+
bottom: "tooltip-bottom",
|
|
503
|
+
left: "tooltip-left",
|
|
504
|
+
right: "tooltip-right",
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
key: "alignment",
|
|
509
|
+
label: "Alignment",
|
|
510
|
+
kind: "select",
|
|
511
|
+
default: "center",
|
|
512
|
+
options: ["start", "center", "end"],
|
|
513
|
+
classMap: { start: "tooltip-start", center: "tooltip-center", end: "tooltip-end" },
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
key: "tone",
|
|
517
|
+
label: "Color",
|
|
518
|
+
kind: "select",
|
|
519
|
+
default: "neutral",
|
|
520
|
+
options: ["neutral", "primary", "secondary", "accent", "info", "success", "warning", "error"],
|
|
521
|
+
classMap: {
|
|
522
|
+
neutral: "",
|
|
523
|
+
primary: "tooltip-primary",
|
|
524
|
+
secondary: "tooltip-secondary",
|
|
525
|
+
accent: "tooltip-accent",
|
|
526
|
+
info: "tooltip-info",
|
|
527
|
+
success: "tooltip-success",
|
|
528
|
+
warning: "tooltip-warning",
|
|
529
|
+
error: "tooltip-error",
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
key: "open",
|
|
534
|
+
label: "Open in editor",
|
|
535
|
+
kind: "boolean",
|
|
536
|
+
default: false,
|
|
537
|
+
classMap: { true: "tooltip-open", false: "" },
|
|
538
|
+
},
|
|
539
|
+
],
|
|
540
|
+
build(node, classes, children) {
|
|
541
|
+
return {
|
|
542
|
+
tag: "span",
|
|
543
|
+
attrs: {
|
|
544
|
+
class: classes.join(" "),
|
|
545
|
+
"data-tip": String(node.props.tip),
|
|
546
|
+
tabindex: "0",
|
|
547
|
+
"aria-label": String(node.props.tip),
|
|
548
|
+
},
|
|
549
|
+
children: [String(node.props.content), ...children],
|
|
550
|
+
};
|
|
551
|
+
},
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
export const DATA_DISPLAY_DAISY_COMPONENTS = [
|
|
555
|
+
TABLE,
|
|
556
|
+
TIMELINE,
|
|
557
|
+
AVATAR,
|
|
558
|
+
CHAT_BUBBLE,
|
|
559
|
+
LIST,
|
|
560
|
+
STATUS,
|
|
561
|
+
TOOLTIP,
|
|
562
|
+
COUNTDOWN,
|
|
563
|
+
] as const;
|