@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,567 @@
|
|
|
1
|
+
import type { DaisyComponentDefinition, DaisyVNode } from "../types.ts";
|
|
2
|
+
import { safeHref } from "../render/href.ts";
|
|
3
|
+
|
|
4
|
+
const sizes = ["xs", "sm", "md", "lg", "xl"] as const;
|
|
5
|
+
const sizeMap = (prefix: string) =>
|
|
6
|
+
Object.fromEntries(sizes.map((size) => [size, `${prefix}-${size}`]));
|
|
7
|
+
|
|
8
|
+
const lines = (value: unknown) =>
|
|
9
|
+
String(value ?? "")
|
|
10
|
+
.split(/\r?\n/)
|
|
11
|
+
.map((item) => item.trim())
|
|
12
|
+
.filter(Boolean);
|
|
13
|
+
const clamp = (value: unknown, min: number, max: number) =>
|
|
14
|
+
Math.min(max, Math.max(min, Number(value)));
|
|
15
|
+
|
|
16
|
+
export const TABS: DaisyComponentDefinition = {
|
|
17
|
+
id: "tabs",
|
|
18
|
+
label: "Tabs",
|
|
19
|
+
category: "Navigation",
|
|
20
|
+
tag: "div",
|
|
21
|
+
rootClass: "tabs",
|
|
22
|
+
fields: [
|
|
23
|
+
{ key: "label", label: "Tabs label", kind: "text", default: "Content tabs" },
|
|
24
|
+
{
|
|
25
|
+
key: "items",
|
|
26
|
+
label: "Tabs, Label|Content per line",
|
|
27
|
+
kind: "textarea",
|
|
28
|
+
default: "Overview|Overview content\nDetails|Details content\nReviews|Reviews content",
|
|
29
|
+
},
|
|
30
|
+
{ key: "active", label: "Active tab", kind: "number", default: 1 },
|
|
31
|
+
{
|
|
32
|
+
key: "style",
|
|
33
|
+
label: "Style",
|
|
34
|
+
kind: "select",
|
|
35
|
+
default: "box",
|
|
36
|
+
options: ["box", "border", "lift"],
|
|
37
|
+
classMap: { box: "tabs-box", border: "tabs-border", lift: "tabs-lift" },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: "size",
|
|
41
|
+
label: "Size",
|
|
42
|
+
kind: "select",
|
|
43
|
+
default: "md",
|
|
44
|
+
options: sizes,
|
|
45
|
+
classMap: sizeMap("tabs"),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: "placement",
|
|
49
|
+
label: "Placement",
|
|
50
|
+
kind: "select",
|
|
51
|
+
default: "top",
|
|
52
|
+
options: ["top", "bottom"],
|
|
53
|
+
classMap: { top: "tabs-top", bottom: "tabs-bottom" },
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
build(node, classes) {
|
|
57
|
+
const items = lines(node.props.items)
|
|
58
|
+
.slice(0, 12)
|
|
59
|
+
.map((entry) => {
|
|
60
|
+
const [label, content = ""] = entry.split("|");
|
|
61
|
+
return { label: label || "Tab", content };
|
|
62
|
+
});
|
|
63
|
+
const active = clamp(node.props.active, 1, Math.max(1, items.length));
|
|
64
|
+
const group = `tabs-${node.id}`;
|
|
65
|
+
const children: DaisyVNode[] = [];
|
|
66
|
+
items.forEach((item, index) => {
|
|
67
|
+
const selected = index + 1 === active;
|
|
68
|
+
children.push({
|
|
69
|
+
tag: "input",
|
|
70
|
+
attrs: {
|
|
71
|
+
type: "radio",
|
|
72
|
+
name: group,
|
|
73
|
+
class: "tab",
|
|
74
|
+
"aria-label": item.label,
|
|
75
|
+
...(selected ? { checked: "checked" } : {}),
|
|
76
|
+
},
|
|
77
|
+
children: [],
|
|
78
|
+
});
|
|
79
|
+
children.push({
|
|
80
|
+
tag: "div",
|
|
81
|
+
attrs: { class: "tab-content border-base-300 bg-base-100 p-6", role: "tabpanel" },
|
|
82
|
+
children: [item.content],
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
tag: "div",
|
|
87
|
+
attrs: { class: classes.join(" "), role: "tablist", "aria-label": String(node.props.label) },
|
|
88
|
+
children,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const ACCORDION: DaisyComponentDefinition = {
|
|
94
|
+
id: "accordion",
|
|
95
|
+
label: "Accordion",
|
|
96
|
+
category: "Layout",
|
|
97
|
+
tag: "div",
|
|
98
|
+
rootClass: "join join-vertical",
|
|
99
|
+
container: true,
|
|
100
|
+
fields: [
|
|
101
|
+
{ key: "label", label: "Accordion label", kind: "text", default: "Frequently asked questions" },
|
|
102
|
+
{
|
|
103
|
+
key: "items",
|
|
104
|
+
label: "Items, Title|Content per line",
|
|
105
|
+
kind: "textarea",
|
|
106
|
+
default:
|
|
107
|
+
"What is EmVB?|A visual editor for EmDash.\nDoes it support themes?|Yes, through daisyUI themes.",
|
|
108
|
+
},
|
|
109
|
+
{ key: "open", label: "Open item", kind: "number", default: 1 },
|
|
110
|
+
{
|
|
111
|
+
key: "icon",
|
|
112
|
+
label: "Icon",
|
|
113
|
+
kind: "select",
|
|
114
|
+
default: "arrow",
|
|
115
|
+
options: ["arrow", "plus"],
|
|
116
|
+
classMap: { arrow: "collapse-arrow", plus: "collapse-plus" },
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
build(node, classes, children) {
|
|
120
|
+
const items = lines(node.props.items).slice(0, 20);
|
|
121
|
+
const open = clamp(node.props.open, 0, items.length);
|
|
122
|
+
return {
|
|
123
|
+
tag: "div",
|
|
124
|
+
attrs: { class: classes.join(" "), "aria-label": String(node.props.label) },
|
|
125
|
+
children: [
|
|
126
|
+
...items.map((entry, index): DaisyVNode => {
|
|
127
|
+
const [title, content = ""] = entry.split("|");
|
|
128
|
+
return {
|
|
129
|
+
tag: "details",
|
|
130
|
+
attrs: {
|
|
131
|
+
class: "collapse join-item border-base-300 border",
|
|
132
|
+
...(index + 1 === open ? { open: "open" } : {}),
|
|
133
|
+
},
|
|
134
|
+
children: [
|
|
135
|
+
{
|
|
136
|
+
tag: "summary",
|
|
137
|
+
attrs: { class: "collapse-title font-semibold" },
|
|
138
|
+
children: [title || "Item"],
|
|
139
|
+
},
|
|
140
|
+
{ tag: "div", attrs: { class: "collapse-content text-sm" }, children: [content] },
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
}),
|
|
144
|
+
...children,
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const DROPDOWN: DaisyComponentDefinition = {
|
|
151
|
+
id: "dropdown",
|
|
152
|
+
label: "Dropdown",
|
|
153
|
+
category: "Navigation",
|
|
154
|
+
tag: "details",
|
|
155
|
+
rootClass: "dropdown",
|
|
156
|
+
fields: [
|
|
157
|
+
{ key: "label", label: "Button label", kind: "text", default: "Open menu" },
|
|
158
|
+
{
|
|
159
|
+
key: "items",
|
|
160
|
+
label: "Items, Label|URL per line",
|
|
161
|
+
kind: "textarea",
|
|
162
|
+
default: "Profile|/profile\nSettings|/settings\nSign out|/logout",
|
|
163
|
+
},
|
|
164
|
+
{ key: "open", label: "Open in editor", kind: "boolean", default: false, attribute: "open" },
|
|
165
|
+
{
|
|
166
|
+
key: "align",
|
|
167
|
+
label: "Alignment",
|
|
168
|
+
kind: "select",
|
|
169
|
+
default: "start",
|
|
170
|
+
options: ["start", "center", "end", "top", "bottom", "left", "right"],
|
|
171
|
+
classMap: {
|
|
172
|
+
start: "dropdown-start",
|
|
173
|
+
center: "dropdown-center",
|
|
174
|
+
end: "dropdown-end",
|
|
175
|
+
top: "dropdown-top",
|
|
176
|
+
bottom: "dropdown-bottom",
|
|
177
|
+
left: "dropdown-left",
|
|
178
|
+
right: "dropdown-right",
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
key: "hover",
|
|
183
|
+
label: "Open on hover",
|
|
184
|
+
kind: "boolean",
|
|
185
|
+
default: false,
|
|
186
|
+
classMap: { true: "dropdown-hover", false: "" },
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
build(node, classes) {
|
|
190
|
+
return {
|
|
191
|
+
tag: "details",
|
|
192
|
+
attrs: { class: classes.join(" "), ...(node.props.open ? { open: "open" } : {}) },
|
|
193
|
+
children: [
|
|
194
|
+
{ tag: "summary", attrs: { class: "btn m-1" }, children: [String(node.props.label)] },
|
|
195
|
+
{
|
|
196
|
+
tag: "ul",
|
|
197
|
+
attrs: {
|
|
198
|
+
class: "menu dropdown-content bg-base-100 rounded-box z-10 w-52 p-2 shadow",
|
|
199
|
+
role: "menu",
|
|
200
|
+
},
|
|
201
|
+
children: lines(node.props.items)
|
|
202
|
+
.slice(0, 20)
|
|
203
|
+
.map((entry) => {
|
|
204
|
+
const [label, href = "#"] = entry.split("|");
|
|
205
|
+
return {
|
|
206
|
+
tag: "li",
|
|
207
|
+
attrs: { role: "none" },
|
|
208
|
+
children: [
|
|
209
|
+
{
|
|
210
|
+
tag: "a",
|
|
211
|
+
attrs: { href: safeHref(href), role: "menuitem" },
|
|
212
|
+
children: [label || "Item"],
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
};
|
|
216
|
+
}),
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export const MODAL: DaisyComponentDefinition = {
|
|
224
|
+
id: "modal",
|
|
225
|
+
label: "Modal",
|
|
226
|
+
category: "Feedback",
|
|
227
|
+
tag: "dialog",
|
|
228
|
+
rootClass: "modal",
|
|
229
|
+
container: true,
|
|
230
|
+
fields: [
|
|
231
|
+
{ key: "title", label: "Title", kind: "text", default: "Confirm action" },
|
|
232
|
+
{
|
|
233
|
+
key: "body",
|
|
234
|
+
label: "Body",
|
|
235
|
+
kind: "textarea",
|
|
236
|
+
default: "Review the information before continuing.",
|
|
237
|
+
},
|
|
238
|
+
{ key: "open", label: "Open in editor", kind: "boolean", default: true, attribute: "open" },
|
|
239
|
+
{ key: "closeLabel", label: "Close label", kind: "text", default: "Close" },
|
|
240
|
+
{
|
|
241
|
+
key: "position",
|
|
242
|
+
label: "Position",
|
|
243
|
+
kind: "select",
|
|
244
|
+
default: "middle",
|
|
245
|
+
options: ["middle", "top", "bottom", "start", "end"],
|
|
246
|
+
classMap: {
|
|
247
|
+
middle: "modal-middle",
|
|
248
|
+
top: "modal-top",
|
|
249
|
+
bottom: "modal-bottom",
|
|
250
|
+
start: "modal-start",
|
|
251
|
+
end: "modal-end",
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
build(node, classes, children, options) {
|
|
256
|
+
const titleId = `${node.id}-title`;
|
|
257
|
+
const content: DaisyVNode[] = [
|
|
258
|
+
{
|
|
259
|
+
tag: "h2",
|
|
260
|
+
attrs: { id: titleId, class: "text-lg font-bold" },
|
|
261
|
+
children: [String(node.props.title)],
|
|
262
|
+
},
|
|
263
|
+
{ tag: "p", attrs: { class: "py-4" }, children: [String(node.props.body)] },
|
|
264
|
+
...children,
|
|
265
|
+
{
|
|
266
|
+
tag: "form",
|
|
267
|
+
attrs: { method: "dialog", class: "modal-action" },
|
|
268
|
+
children: [
|
|
269
|
+
{ tag: "button", attrs: { class: "btn" }, children: [String(node.props.closeLabel)] },
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
];
|
|
273
|
+
// On the canvas an open modal is shown as its box in the page. An open <dialog> makes daisyUI
|
|
274
|
+
// lock the page's scrolling, so the canvas could no longer be scrolled with the wheel.
|
|
275
|
+
if (options?.mode === "editor" && node.props.open)
|
|
276
|
+
return {
|
|
277
|
+
tag: "div",
|
|
278
|
+
attrs: { class: "modal-box mx-auto my-4 w-full max-w-md", "aria-labelledby": titleId },
|
|
279
|
+
children: content,
|
|
280
|
+
};
|
|
281
|
+
return {
|
|
282
|
+
tag: "dialog",
|
|
283
|
+
attrs: {
|
|
284
|
+
// daisyUI slides a drawer (start or end) in only with modal-open; the open attribute alone
|
|
285
|
+
// leaves it off the page.
|
|
286
|
+
class: [...classes, ...(node.props.open ? ["modal-open"] : [])].join(" "),
|
|
287
|
+
"aria-labelledby": titleId,
|
|
288
|
+
...(node.props.open ? { open: "open" } : {}),
|
|
289
|
+
},
|
|
290
|
+
children: [
|
|
291
|
+
{ tag: "div", attrs: { class: "modal-box" }, children: content },
|
|
292
|
+
{
|
|
293
|
+
tag: "form",
|
|
294
|
+
attrs: { method: "dialog", class: "modal-backdrop" },
|
|
295
|
+
children: [
|
|
296
|
+
{
|
|
297
|
+
tag: "button",
|
|
298
|
+
attrs: { "aria-label": String(node.props.closeLabel) },
|
|
299
|
+
children: ["close"],
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
};
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export const DRAWER: DaisyComponentDefinition = {
|
|
309
|
+
id: "drawer",
|
|
310
|
+
label: "Drawer",
|
|
311
|
+
category: "Layout",
|
|
312
|
+
tag: "div",
|
|
313
|
+
rootClass: "drawer",
|
|
314
|
+
container: true,
|
|
315
|
+
fields: [
|
|
316
|
+
{ key: "label", label: "Drawer label", kind: "text", default: "Navigation drawer" },
|
|
317
|
+
{ key: "buttonLabel", label: "Button label", kind: "text", default: "Open drawer" },
|
|
318
|
+
{
|
|
319
|
+
key: "side",
|
|
320
|
+
label: "Side",
|
|
321
|
+
kind: "select",
|
|
322
|
+
default: "start",
|
|
323
|
+
options: ["start", "end"],
|
|
324
|
+
classMap: { start: "", end: "drawer-end" },
|
|
325
|
+
},
|
|
326
|
+
{ key: "open", label: "Open in editor", kind: "boolean", default: false },
|
|
327
|
+
],
|
|
328
|
+
build(node, classes, children) {
|
|
329
|
+
const controlId = `${node.id}-control`;
|
|
330
|
+
return {
|
|
331
|
+
tag: "div",
|
|
332
|
+
attrs: { class: classes.join(" ") },
|
|
333
|
+
children: [
|
|
334
|
+
{
|
|
335
|
+
tag: "input",
|
|
336
|
+
attrs: {
|
|
337
|
+
id: controlId,
|
|
338
|
+
type: "checkbox",
|
|
339
|
+
class: "drawer-toggle",
|
|
340
|
+
"aria-label": String(node.props.label),
|
|
341
|
+
...(node.props.open ? { checked: "checked" } : {}),
|
|
342
|
+
},
|
|
343
|
+
children: [],
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
tag: "div",
|
|
347
|
+
attrs: { class: "drawer-content" },
|
|
348
|
+
children: [
|
|
349
|
+
{
|
|
350
|
+
tag: "label",
|
|
351
|
+
attrs: { for: controlId, class: "btn drawer-button" },
|
|
352
|
+
children: [String(node.props.buttonLabel)],
|
|
353
|
+
},
|
|
354
|
+
...children,
|
|
355
|
+
],
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
tag: "div",
|
|
359
|
+
attrs: { class: "drawer-side" },
|
|
360
|
+
children: [
|
|
361
|
+
{
|
|
362
|
+
tag: "label",
|
|
363
|
+
attrs: { for: controlId, "aria-label": "Close drawer", class: "drawer-overlay" },
|
|
364
|
+
children: [],
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
tag: "div",
|
|
368
|
+
attrs: { class: "bg-base-200 min-h-full w-80 p-4" },
|
|
369
|
+
children: [String(node.props.label)],
|
|
370
|
+
},
|
|
371
|
+
],
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
};
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
export const CAROUSEL: DaisyComponentDefinition = {
|
|
379
|
+
id: "carousel",
|
|
380
|
+
label: "Carousel",
|
|
381
|
+
category: "Layout",
|
|
382
|
+
tag: "section",
|
|
383
|
+
rootClass: "carousel",
|
|
384
|
+
container: true,
|
|
385
|
+
fields: [
|
|
386
|
+
{ key: "label", label: "Carousel label", kind: "text", default: "Featured content" },
|
|
387
|
+
{
|
|
388
|
+
key: "slides",
|
|
389
|
+
label: "Slides, Title|Description per line",
|
|
390
|
+
kind: "textarea",
|
|
391
|
+
default:
|
|
392
|
+
"First slide|Welcome to EmVB\nSecond slide|Build with daisyUI\nThird slide|Publish with Astro",
|
|
393
|
+
},
|
|
394
|
+
{ key: "current", label: "Current slide", kind: "number", default: 1 },
|
|
395
|
+
{
|
|
396
|
+
key: "align",
|
|
397
|
+
label: "Slide alignment",
|
|
398
|
+
kind: "select",
|
|
399
|
+
default: "start",
|
|
400
|
+
options: ["start", "center", "end"],
|
|
401
|
+
classMap: { start: "carousel-start", center: "carousel-center", end: "carousel-end" },
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
key: "width",
|
|
405
|
+
label: "Width",
|
|
406
|
+
kind: "select",
|
|
407
|
+
default: "full",
|
|
408
|
+
options: ["full", "compact"],
|
|
409
|
+
classMap: { full: "w-full", compact: "max-w-2xl" },
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
key: "direction",
|
|
413
|
+
label: "Direction",
|
|
414
|
+
kind: "select",
|
|
415
|
+
default: "horizontal",
|
|
416
|
+
options: ["horizontal", "vertical"],
|
|
417
|
+
classMap: { horizontal: "carousel-horizontal", vertical: "carousel-vertical" },
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
build(node, classes, children) {
|
|
421
|
+
const slides = lines(node.props.slides).slice(0, 20);
|
|
422
|
+
const current = clamp(node.props.current, 1, Math.max(1, slides.length));
|
|
423
|
+
return {
|
|
424
|
+
tag: "section",
|
|
425
|
+
attrs: {
|
|
426
|
+
class: classes.join(" "),
|
|
427
|
+
"aria-label": String(node.props.label),
|
|
428
|
+
"aria-roledescription": "carousel",
|
|
429
|
+
},
|
|
430
|
+
children: [
|
|
431
|
+
...slides.map((entry, index): DaisyVNode => {
|
|
432
|
+
const [title, description = ""] = entry.split("|");
|
|
433
|
+
return {
|
|
434
|
+
tag: "article",
|
|
435
|
+
attrs: {
|
|
436
|
+
id: `${node.id}-slide-${index + 1}`,
|
|
437
|
+
class: "carousel-item relative w-full",
|
|
438
|
+
role: "group",
|
|
439
|
+
"aria-label": `${index + 1} of ${slides.length}`,
|
|
440
|
+
...(index + 1 !== current ? { "aria-hidden": "true" } : {}),
|
|
441
|
+
},
|
|
442
|
+
children: [
|
|
443
|
+
{
|
|
444
|
+
tag: "div",
|
|
445
|
+
attrs: { class: "hero min-h-64 bg-base-200" },
|
|
446
|
+
children: [
|
|
447
|
+
{
|
|
448
|
+
tag: "div",
|
|
449
|
+
attrs: { class: "hero-content text-center" },
|
|
450
|
+
children: [
|
|
451
|
+
{
|
|
452
|
+
tag: "div",
|
|
453
|
+
attrs: {},
|
|
454
|
+
children: [
|
|
455
|
+
{
|
|
456
|
+
tag: "h2",
|
|
457
|
+
attrs: { class: "text-3xl font-bold" },
|
|
458
|
+
children: [title || "Slide"],
|
|
459
|
+
},
|
|
460
|
+
{ tag: "p", attrs: { class: "py-4" }, children: [description] },
|
|
461
|
+
],
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
},
|
|
465
|
+
],
|
|
466
|
+
},
|
|
467
|
+
],
|
|
468
|
+
};
|
|
469
|
+
}),
|
|
470
|
+
...children,
|
|
471
|
+
],
|
|
472
|
+
};
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
export const COLLAPSE: DaisyComponentDefinition = {
|
|
477
|
+
id: "collapse",
|
|
478
|
+
label: "Collapse",
|
|
479
|
+
category: "Layout",
|
|
480
|
+
tag: "details",
|
|
481
|
+
rootClass: "collapse bg-base-100 border-base-300 border",
|
|
482
|
+
container: true,
|
|
483
|
+
fields: [
|
|
484
|
+
{ key: "title", label: "Title", kind: "text", default: "More information" },
|
|
485
|
+
{
|
|
486
|
+
key: "content",
|
|
487
|
+
label: "Content",
|
|
488
|
+
kind: "textarea",
|
|
489
|
+
default: "Additional details appear here.",
|
|
490
|
+
},
|
|
491
|
+
{ key: "open", label: "Open", kind: "boolean", default: false, attribute: "open" },
|
|
492
|
+
{
|
|
493
|
+
key: "icon",
|
|
494
|
+
label: "Icon",
|
|
495
|
+
kind: "select",
|
|
496
|
+
default: "arrow",
|
|
497
|
+
options: ["arrow", "plus"],
|
|
498
|
+
classMap: { arrow: "collapse-arrow", plus: "collapse-plus" },
|
|
499
|
+
},
|
|
500
|
+
],
|
|
501
|
+
build(node, classes, children) {
|
|
502
|
+
return {
|
|
503
|
+
tag: "details",
|
|
504
|
+
attrs: { class: classes.join(" "), ...(node.props.open ? { open: "open" } : {}) },
|
|
505
|
+
children: [
|
|
506
|
+
{
|
|
507
|
+
tag: "summary",
|
|
508
|
+
attrs: { class: "collapse-title font-semibold" },
|
|
509
|
+
children: [String(node.props.title)],
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
tag: "div",
|
|
513
|
+
attrs: { class: "collapse-content text-sm" },
|
|
514
|
+
children: [String(node.props.content), ...children],
|
|
515
|
+
},
|
|
516
|
+
],
|
|
517
|
+
};
|
|
518
|
+
},
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
export const SWAP: DaisyComponentDefinition = {
|
|
522
|
+
id: "swap",
|
|
523
|
+
label: "Swap",
|
|
524
|
+
category: "Actions",
|
|
525
|
+
tag: "label",
|
|
526
|
+
rootClass: "swap",
|
|
527
|
+
fields: [
|
|
528
|
+
{ key: "label", label: "Accessible label", kind: "text", default: "Toggle state" },
|
|
529
|
+
{ key: "on", label: "On text", kind: "text", default: "ON" },
|
|
530
|
+
{ key: "off", label: "Off text", kind: "text", default: "OFF" },
|
|
531
|
+
{ key: "active", label: "Active", kind: "boolean", default: false },
|
|
532
|
+
{
|
|
533
|
+
key: "effect",
|
|
534
|
+
label: "Effect",
|
|
535
|
+
kind: "select",
|
|
536
|
+
default: "rotate",
|
|
537
|
+
options: ["rotate", "flip"],
|
|
538
|
+
classMap: { rotate: "swap-rotate", flip: "swap-flip" },
|
|
539
|
+
},
|
|
540
|
+
],
|
|
541
|
+
build(node, classes) {
|
|
542
|
+
return {
|
|
543
|
+
tag: "label",
|
|
544
|
+
attrs: { class: classes.join(" "), "aria-label": String(node.props.label) },
|
|
545
|
+
children: [
|
|
546
|
+
{
|
|
547
|
+
tag: "input",
|
|
548
|
+
attrs: { type: "checkbox", ...(node.props.active ? { checked: "checked" } : {}) },
|
|
549
|
+
children: [],
|
|
550
|
+
},
|
|
551
|
+
{ tag: "span", attrs: { class: "swap-on" }, children: [String(node.props.on)] },
|
|
552
|
+
{ tag: "span", attrs: { class: "swap-off" }, children: [String(node.props.off)] },
|
|
553
|
+
],
|
|
554
|
+
};
|
|
555
|
+
},
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
export const INTERACTIVE_DAISY_COMPONENTS = [
|
|
559
|
+
TABS,
|
|
560
|
+
ACCORDION,
|
|
561
|
+
DROPDOWN,
|
|
562
|
+
MODAL,
|
|
563
|
+
DRAWER,
|
|
564
|
+
CAROUSEL,
|
|
565
|
+
COLLAPSE,
|
|
566
|
+
SWAP,
|
|
567
|
+
] as const;
|