@theweekendprojects/emvb-daisyui 0.0.0-stage → 0.2.0
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 +12397 -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,430 @@
|
|
|
1
|
+
import type { DaisyComponentDefinition, DaisyVNode } from "../types.ts";
|
|
2
|
+
|
|
3
|
+
const sizes = ["xs", "sm", "md", "lg", "xl"] as const;
|
|
4
|
+
const tones = [
|
|
5
|
+
"neutral",
|
|
6
|
+
"primary",
|
|
7
|
+
"secondary",
|
|
8
|
+
"accent",
|
|
9
|
+
"success",
|
|
10
|
+
"info",
|
|
11
|
+
"warning",
|
|
12
|
+
"error",
|
|
13
|
+
] as const;
|
|
14
|
+
const classMap = (prefix: string, values: readonly string[]) =>
|
|
15
|
+
Object.fromEntries(values.map((value) => [value, `${prefix}-${value}`]));
|
|
16
|
+
const safeHref = (value: unknown) => {
|
|
17
|
+
const href = String(value ?? "").trim();
|
|
18
|
+
if (
|
|
19
|
+
(href.startsWith("/") && !href.startsWith("//")) ||
|
|
20
|
+
href.startsWith("#") ||
|
|
21
|
+
href.startsWith("mailto:") ||
|
|
22
|
+
href.startsWith("tel:")
|
|
23
|
+
)
|
|
24
|
+
return href;
|
|
25
|
+
try {
|
|
26
|
+
const url = new URL(href);
|
|
27
|
+
return ["http:", "https:"].includes(url.protocol) ? href : "#";
|
|
28
|
+
} catch {
|
|
29
|
+
return "#";
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const safeImage = (value: unknown) => {
|
|
33
|
+
const url = safeHref(value);
|
|
34
|
+
return url.startsWith("javascript:") || (url === "#" && !String(value).startsWith("#"))
|
|
35
|
+
? ""
|
|
36
|
+
: url;
|
|
37
|
+
};
|
|
38
|
+
const lines = (value: unknown, max: number) =>
|
|
39
|
+
String(value ?? "")
|
|
40
|
+
.split(/\r?\n/)
|
|
41
|
+
.map((item) => item.trim())
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.slice(0, max);
|
|
44
|
+
|
|
45
|
+
export const AURA: DaisyComponentDefinition = {
|
|
46
|
+
id: "aura",
|
|
47
|
+
label: "Aura",
|
|
48
|
+
category: "Layout",
|
|
49
|
+
tag: "div",
|
|
50
|
+
rootClass: "aura",
|
|
51
|
+
container: true,
|
|
52
|
+
fields: [
|
|
53
|
+
{
|
|
54
|
+
key: "style",
|
|
55
|
+
label: "Style",
|
|
56
|
+
kind: "select",
|
|
57
|
+
default: "default",
|
|
58
|
+
options: ["default", "dual", "rainbow", "holo", "gold", "silver", "glow"],
|
|
59
|
+
classMap: {
|
|
60
|
+
default: "",
|
|
61
|
+
dual: "aura-dual",
|
|
62
|
+
rainbow: "aura-rainbow",
|
|
63
|
+
holo: "aura-holo",
|
|
64
|
+
gold: "aura-gold",
|
|
65
|
+
silver: "aura-silver",
|
|
66
|
+
glow: "aura-glow",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: "size",
|
|
71
|
+
label: "Size",
|
|
72
|
+
kind: "select",
|
|
73
|
+
default: "md",
|
|
74
|
+
options: sizes,
|
|
75
|
+
classMap: classMap("aura", sizes),
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
build(_node, classes, children) {
|
|
79
|
+
// opacity-60: at full strength the glow is a harsh white block on the dark theme.
|
|
80
|
+
// With a child, the glow hugs it: the aura shrinks to the child and the child's own vertical
|
|
81
|
+
// margin is reset (`[&>*]:my-0!`), so the ring meets the element like daisyUI's example.
|
|
82
|
+
if (children.length)
|
|
83
|
+
return {
|
|
84
|
+
tag: "div",
|
|
85
|
+
attrs: { class: `${classes.join(" ")} w-fit opacity-60 [&>*]:my-0!` },
|
|
86
|
+
children,
|
|
87
|
+
};
|
|
88
|
+
// Empty: a placeholder box gives the glow a height. The root needs a width: shrunk to its
|
|
89
|
+
// content in a centred flex column it became a 4px streak.
|
|
90
|
+
return {
|
|
91
|
+
tag: "div",
|
|
92
|
+
attrs: { class: `${classes.join(" ")} w-full max-w-md opacity-60` },
|
|
93
|
+
children: [{ tag: "div", attrs: { class: "min-h-24 w-full" }, children: [] }],
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
export const CALENDAR: DaisyComponentDefinition = {
|
|
98
|
+
id: "calendar",
|
|
99
|
+
label: "Calendar",
|
|
100
|
+
category: "Actions",
|
|
101
|
+
tag: "input",
|
|
102
|
+
rootClass: "input",
|
|
103
|
+
fields: [
|
|
104
|
+
{ key: "label", label: "Accessible label", kind: "text", default: "Choose date" },
|
|
105
|
+
{ key: "name", label: "Name", kind: "text", default: "date" },
|
|
106
|
+
{ key: "value", label: "Date", kind: "text", default: "" },
|
|
107
|
+
{ key: "required", label: "Required", kind: "boolean", default: false },
|
|
108
|
+
],
|
|
109
|
+
build: (node, classes) => ({
|
|
110
|
+
tag: "input",
|
|
111
|
+
attrs: {
|
|
112
|
+
type: "date",
|
|
113
|
+
class: classes.join(" "),
|
|
114
|
+
name: String(node.props.name),
|
|
115
|
+
"aria-label": String(node.props.label),
|
|
116
|
+
...(node.props.value ? { value: String(node.props.value) } : {}),
|
|
117
|
+
...(node.props.required ? { required: "required" } : {}),
|
|
118
|
+
},
|
|
119
|
+
children: [],
|
|
120
|
+
}),
|
|
121
|
+
};
|
|
122
|
+
export const FAB: DaisyComponentDefinition = {
|
|
123
|
+
id: "fab",
|
|
124
|
+
label: "FAB / Speed Dial",
|
|
125
|
+
category: "Actions",
|
|
126
|
+
tag: "div",
|
|
127
|
+
rootClass: "fab",
|
|
128
|
+
fields: [
|
|
129
|
+
{ key: "label", label: "Main label", kind: "text", default: "Open actions" },
|
|
130
|
+
{ key: "symbol", label: "Main symbol", kind: "text", default: "+" },
|
|
131
|
+
{ key: "actions", label: "Actions", kind: "textarea", default: "Create\nUpload\nShare" },
|
|
132
|
+
{
|
|
133
|
+
key: "flower",
|
|
134
|
+
label: "Flower layout",
|
|
135
|
+
kind: "boolean",
|
|
136
|
+
default: false,
|
|
137
|
+
classMap: { true: "fab-flower", false: "" },
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
build: (node, classes) => ({
|
|
141
|
+
tag: "div",
|
|
142
|
+
attrs: { class: classes.join(" ") },
|
|
143
|
+
children: [
|
|
144
|
+
{
|
|
145
|
+
tag: "div",
|
|
146
|
+
attrs: {
|
|
147
|
+
tabindex: "0",
|
|
148
|
+
role: "button",
|
|
149
|
+
class: "btn btn-lg btn-circle btn-primary",
|
|
150
|
+
"aria-label": String(node.props.label),
|
|
151
|
+
},
|
|
152
|
+
children: [String(node.props.symbol)],
|
|
153
|
+
},
|
|
154
|
+
...lines(node.props.actions, 6).map((label): DaisyVNode => ({
|
|
155
|
+
tag: "button",
|
|
156
|
+
attrs: { type: "button", class: "btn btn-lg btn-circle", "aria-label": label },
|
|
157
|
+
children: [label.slice(0, 1).toUpperCase()],
|
|
158
|
+
})),
|
|
159
|
+
],
|
|
160
|
+
}),
|
|
161
|
+
};
|
|
162
|
+
export const HOVER_3D: DaisyComponentDefinition = {
|
|
163
|
+
id: "hover-3d",
|
|
164
|
+
label: "Hover 3D Card",
|
|
165
|
+
category: "Layout",
|
|
166
|
+
tag: "div",
|
|
167
|
+
rootClass: "hover-3d",
|
|
168
|
+
container: true,
|
|
169
|
+
fields: [{ key: "label", label: "Accessible label", kind: "text", default: "3D card" }],
|
|
170
|
+
build: (node, classes, children) => ({
|
|
171
|
+
tag: "div",
|
|
172
|
+
attrs: { class: classes.join(" "), "aria-label": String(node.props.label) },
|
|
173
|
+
children: [
|
|
174
|
+
// With no content, a placeholder figure gives the card its size.
|
|
175
|
+
...(children.length
|
|
176
|
+
? children
|
|
177
|
+
: [{ tag: "figure", attrs: { class: "w-64 h-48 rounded-2xl bg-base-200" }, children: [] }]),
|
|
178
|
+
...Array.from({ length: 8 }, (): DaisyVNode => ({
|
|
179
|
+
tag: "div",
|
|
180
|
+
attrs: { "aria-hidden": "true" },
|
|
181
|
+
children: [],
|
|
182
|
+
})),
|
|
183
|
+
],
|
|
184
|
+
}),
|
|
185
|
+
};
|
|
186
|
+
export const HOVER_GALLERY: DaisyComponentDefinition = {
|
|
187
|
+
id: "hover-gallery",
|
|
188
|
+
label: "Hover Gallery",
|
|
189
|
+
category: "Data display",
|
|
190
|
+
tag: "figure",
|
|
191
|
+
rootClass: "hover-gallery",
|
|
192
|
+
fields: [
|
|
193
|
+
{ key: "images", label: "Image URLs", kind: "textarea", default: "" },
|
|
194
|
+
{ key: "alt", label: "Alternative text", kind: "text", default: "Product gallery" },
|
|
195
|
+
],
|
|
196
|
+
build: (node, classes, _children, options) => {
|
|
197
|
+
const urls = lines(node.props.images, 10);
|
|
198
|
+
if (urls.length === 0)
|
|
199
|
+
return {
|
|
200
|
+
tag: "figure",
|
|
201
|
+
attrs: { class: classes.join(" ") },
|
|
202
|
+
// Labelled slots on the canvas only, so there is something to see while building. The public
|
|
203
|
+
// page shows no empty slots.
|
|
204
|
+
children:
|
|
205
|
+
options?.mode !== "editor"
|
|
206
|
+
? []
|
|
207
|
+
: [1, 2].map((n): DaisyVNode => ({
|
|
208
|
+
tag: "div",
|
|
209
|
+
attrs: {
|
|
210
|
+
class:
|
|
211
|
+
"bg-base-300 aspect-video w-full max-w-xs flex items-center justify-center rounded-box text-base-content/60",
|
|
212
|
+
},
|
|
213
|
+
children: [`Image ${n}`],
|
|
214
|
+
})),
|
|
215
|
+
};
|
|
216
|
+
return {
|
|
217
|
+
tag: "figure",
|
|
218
|
+
attrs: { class: classes.join(" ") },
|
|
219
|
+
children: urls.map((src): DaisyVNode => ({
|
|
220
|
+
tag: "img",
|
|
221
|
+
attrs: {
|
|
222
|
+
src: safeImage(src),
|
|
223
|
+
alt: String(node.props.alt),
|
|
224
|
+
loading: "lazy",
|
|
225
|
+
class: "w-full h-48 object-cover",
|
|
226
|
+
},
|
|
227
|
+
children: [],
|
|
228
|
+
})),
|
|
229
|
+
};
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
export const MEGAMENU: DaisyComponentDefinition = {
|
|
233
|
+
id: "megamenu",
|
|
234
|
+
label: "Megamenu",
|
|
235
|
+
category: "Navigation",
|
|
236
|
+
tag: "nav",
|
|
237
|
+
rootClass: "megamenu",
|
|
238
|
+
fields: [
|
|
239
|
+
{ key: "label", label: "Accessible label", kind: "text", default: "Main navigation" },
|
|
240
|
+
{
|
|
241
|
+
key: "items",
|
|
242
|
+
label: "Sections",
|
|
243
|
+
kind: "textarea",
|
|
244
|
+
default: "Products|Overview,Features,Pricing\nCompany|About,Careers,Contact",
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
{
|
|
248
|
+
key: "size",
|
|
249
|
+
label: "Size",
|
|
250
|
+
kind: "select",
|
|
251
|
+
default: "md",
|
|
252
|
+
options: sizes,
|
|
253
|
+
classMap: classMap("megamenu", sizes),
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
key: "width",
|
|
257
|
+
label: "Popover width",
|
|
258
|
+
kind: "select",
|
|
259
|
+
default: "normal",
|
|
260
|
+
options: ["normal", "wide", "full"],
|
|
261
|
+
classMap: { normal: "", wide: "megamenu-wide", full: "megamenu-full" },
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
key: "orientation",
|
|
265
|
+
label: "Orientation",
|
|
266
|
+
kind: "select",
|
|
267
|
+
default: "horizontal",
|
|
268
|
+
options: ["horizontal", "vertical"],
|
|
269
|
+
classMap: { horizontal: "", vertical: "megamenu-vertical" },
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
build: (node, classes) => {
|
|
273
|
+
const items = lines(node.props.items, 10).map((line, index) => {
|
|
274
|
+
const [label, links = ""] = line.split("|");
|
|
275
|
+
return {
|
|
276
|
+
label: label || `Section ${index + 1}`,
|
|
277
|
+
links: links
|
|
278
|
+
.split(",")
|
|
279
|
+
.map((x) => x.trim())
|
|
280
|
+
.filter(Boolean),
|
|
281
|
+
id: `${node.id}-mega-${index + 1}`,
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
return {
|
|
285
|
+
tag: "nav",
|
|
286
|
+
attrs: { "aria-label": String(node.props.label) },
|
|
287
|
+
children: [
|
|
288
|
+
{
|
|
289
|
+
tag: "button",
|
|
290
|
+
attrs: { type: "button", class: "btn sm:hidden", popovertarget: `${node.id}-menu` },
|
|
291
|
+
children: ["Menu"],
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
tag: "div",
|
|
295
|
+
attrs: {
|
|
296
|
+
id: `${node.id}-menu`,
|
|
297
|
+
class: `${classes.join(" ")} max-sm:megamenu-vertical`,
|
|
298
|
+
popover: "",
|
|
299
|
+
},
|
|
300
|
+
children: [
|
|
301
|
+
{
|
|
302
|
+
tag: "span",
|
|
303
|
+
attrs: { class: "megamenu-active", "aria-hidden": "true" },
|
|
304
|
+
children: [],
|
|
305
|
+
},
|
|
306
|
+
...items.flatMap((item): DaisyVNode[] => [
|
|
307
|
+
{
|
|
308
|
+
tag: "button",
|
|
309
|
+
attrs: { type: "button", popovertarget: item.id },
|
|
310
|
+
children: [item.label],
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
tag: "div",
|
|
314
|
+
attrs: { id: item.id, popover: "" },
|
|
315
|
+
children: [
|
|
316
|
+
{
|
|
317
|
+
tag: "ul",
|
|
318
|
+
attrs: { class: "menu" },
|
|
319
|
+
children: item.links.map((label): DaisyVNode => ({
|
|
320
|
+
tag: "li",
|
|
321
|
+
attrs: {},
|
|
322
|
+
children: [{ tag: "a", attrs: { href: "#" }, children: [label] }],
|
|
323
|
+
})),
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
},
|
|
327
|
+
]),
|
|
328
|
+
],
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
};
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
export const OTP: DaisyComponentDefinition = {
|
|
335
|
+
id: "otp",
|
|
336
|
+
label: "OTP",
|
|
337
|
+
category: "Actions",
|
|
338
|
+
tag: "label",
|
|
339
|
+
rootClass: "otp",
|
|
340
|
+
fields: [
|
|
341
|
+
{ key: "label", label: "Accessible label", kind: "text", default: "Verification code" },
|
|
342
|
+
{ key: "length", label: "Digits", kind: "select", default: "6", options: ["4", "5", "6"] },
|
|
343
|
+
{
|
|
344
|
+
key: "joined",
|
|
345
|
+
label: "Joined",
|
|
346
|
+
kind: "boolean",
|
|
347
|
+
default: false,
|
|
348
|
+
classMap: { true: "otp-joined", false: "" },
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
key: "size",
|
|
352
|
+
label: "Size",
|
|
353
|
+
kind: "select",
|
|
354
|
+
default: "md",
|
|
355
|
+
options: sizes,
|
|
356
|
+
classMap: classMap("otp", sizes),
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
key: "tone",
|
|
360
|
+
label: "Color",
|
|
361
|
+
kind: "select",
|
|
362
|
+
default: "primary",
|
|
363
|
+
options: tones,
|
|
364
|
+
classMap: classMap("otp", tones),
|
|
365
|
+
},
|
|
366
|
+
],
|
|
367
|
+
build: (node, classes) => {
|
|
368
|
+
const length = Math.min(6, Math.max(4, Number(node.props.length) || 6));
|
|
369
|
+
return {
|
|
370
|
+
tag: "label",
|
|
371
|
+
attrs: { class: classes.join(" "), "aria-label": String(node.props.label) },
|
|
372
|
+
children: [
|
|
373
|
+
...Array.from({ length }, (): DaisyVNode => ({
|
|
374
|
+
tag: "span",
|
|
375
|
+
attrs: { "aria-hidden": "true" },
|
|
376
|
+
children: [],
|
|
377
|
+
})),
|
|
378
|
+
{
|
|
379
|
+
tag: "input",
|
|
380
|
+
attrs: {
|
|
381
|
+
type: "text",
|
|
382
|
+
autocomplete: "one-time-code",
|
|
383
|
+
inputmode: "numeric",
|
|
384
|
+
maxlength: String(length),
|
|
385
|
+
pattern: `[0-9]{${length}}`,
|
|
386
|
+
required: "required",
|
|
387
|
+
"aria-label": String(node.props.label),
|
|
388
|
+
},
|
|
389
|
+
children: [],
|
|
390
|
+
},
|
|
391
|
+
],
|
|
392
|
+
};
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
export const TEXT_ROTATE: DaisyComponentDefinition = {
|
|
396
|
+
id: "text-rotate",
|
|
397
|
+
label: "Text Rotate",
|
|
398
|
+
category: "Data display",
|
|
399
|
+
tag: "span",
|
|
400
|
+
rootClass: "text-rotate",
|
|
401
|
+
fields: [
|
|
402
|
+
{ key: "items", label: "Lines", kind: "textarea", default: "DESIGN\nDEVELOP\nDEPLOY" },
|
|
403
|
+
{ key: "label", label: "Accessible label", kind: "text", default: "Rotating text" },
|
|
404
|
+
],
|
|
405
|
+
build: (node, classes) => ({
|
|
406
|
+
tag: "span",
|
|
407
|
+
attrs: { class: classes.join(" "), "aria-label": String(node.props.label) },
|
|
408
|
+
children: [
|
|
409
|
+
{
|
|
410
|
+
tag: "span",
|
|
411
|
+
attrs: { "aria-hidden": "true" },
|
|
412
|
+
children: lines(node.props.items, 6).map((text): DaisyVNode => ({
|
|
413
|
+
tag: "span",
|
|
414
|
+
attrs: {},
|
|
415
|
+
children: [text],
|
|
416
|
+
})),
|
|
417
|
+
},
|
|
418
|
+
],
|
|
419
|
+
}),
|
|
420
|
+
};
|
|
421
|
+
export const MISSING_COMPLEX_COMPONENTS = [
|
|
422
|
+
AURA,
|
|
423
|
+
CALENDAR,
|
|
424
|
+
FAB,
|
|
425
|
+
HOVER_3D,
|
|
426
|
+
HOVER_GALLERY,
|
|
427
|
+
MEGAMENU,
|
|
428
|
+
OTP,
|
|
429
|
+
TEXT_ROTATE,
|
|
430
|
+
] as const;
|