vaderjs-daisyui 0.0.2 → 0.0.4
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/Components/Actions/Button/index.tsx +4 -4
- package/Components/Actions/Dropdown/index.tsx +1 -1
- package/Components/Actions/Fab/index.tsx +1 -1
- package/Components/Actions/Modal/index.tsx +5 -4
- package/Components/Actions/Swap/index.tsx +4 -4
- package/Components/Actions/ThemeController/index.tsx +1 -1
- package/Components/Data/Display/Accordion/index.tsx +2 -2
- package/Components/Data/Display/Avatar/index.tsx +1 -1
- package/Components/Data/Display/Badge/index.tsx +1 -1
- package/Components/Data/Display/Card/index.tsx +8 -5
- package/Components/Data/Display/Carousel/index.tsx +1 -1
- package/Components/Data/Display/ChatBubble/index.tsx +1 -1
- package/Components/Data/Display/Collapse/index.tsx +1 -1
- package/Components/Data/Display/Countdown/index.tsx +1 -1
- package/Components/Data/Display/Diff/index.tsx +1 -1
- package/Components/Data/Display/Hover/Card/index.tsx +2 -4
- package/Components/Data/Display/Hover/Gallery/index.tsx +1 -1
- package/Components/Data/Display/Keyboard/index.tsx +1 -1
- package/Components/Data/Display/List/index.tsx +1 -1
- package/Components/Data/Display/Stat/index.tsx +1 -1
- package/Components/Data/Display/Table/index.tsx +1 -1
- package/Components/Data/Display/TextRotate/index.tsx +1 -1
- package/Components/Data/Display/Timeline/index.tsx +1 -1
- package/Components/Navigation/BreadCrumbs/index.tsx +1 -1
- package/Components/Navigation/Doc/index.tsx +1 -1
- package/Components/Navigation/Link/index.tsx +1 -1
- package/index.ts +109 -31
- package/jsconfig.json +16 -0
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const { createElement, component, VNode } = window.Vader;
|
|
2
2
|
|
|
3
3
|
export type ButtonProps = {
|
|
4
4
|
color?: "neutral" | "primary" | "secondary" | "accent" | "info" | "success" | "warning" | "error";
|
|
@@ -9,11 +9,11 @@ export type ButtonProps = {
|
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
className?: string;
|
|
11
11
|
onClick?: (e: MouseEvent) => void;
|
|
12
|
-
children?:
|
|
12
|
+
children?:VNode |VNode[] | string;
|
|
13
13
|
ariaLabel?: string;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
const Button = component<ButtonProps>((props):
|
|
15
|
+
|
|
16
|
+
const Button = component<ButtonProps>((props):VNode => {
|
|
17
17
|
const {
|
|
18
18
|
color,
|
|
19
19
|
style,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const { component, createElement, useState, useRef, useOnClickOutside, useEffect } = window.Vader
|
|
2
2
|
|
|
3
3
|
export type DropdownProps = {
|
|
4
4
|
method?: "details" | "popover" | "focus";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import Button from "../Button";
|
|
1
|
+
const { useState, useEffect, component, createElement } = window.Vader
|
|
2
|
+
import Button from "../Button/index";
|
|
3
3
|
|
|
4
4
|
export function useModal(initialOpen = false) {
|
|
5
5
|
const [isOpen, setIsOpen] = useState(initialOpen);
|
|
@@ -13,7 +13,7 @@ interface ModalProps {
|
|
|
13
13
|
isOpen: boolean;
|
|
14
14
|
onClose?: () => void;
|
|
15
15
|
title?: string;
|
|
16
|
-
children?:
|
|
16
|
+
children?:VNode |VNode[] | string;
|
|
17
17
|
size?: string; // DaisyUI sizes: w-11/12 max-w-md etc.
|
|
18
18
|
placement?: "top" | "middle" | "bottom";
|
|
19
19
|
horizontal?: "start" | "center" | "end"; // horizontal alignment
|
|
@@ -22,7 +22,7 @@ interface ModalProps {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
interface ModalActionProps {
|
|
25
|
-
children:
|
|
25
|
+
children:VNode |VNode[] | string;
|
|
26
26
|
onClick?: () => void;
|
|
27
27
|
closeModal?: boolean;
|
|
28
28
|
close?: () => void;
|
|
@@ -30,6 +30,7 @@ interface ModalActionProps {
|
|
|
30
30
|
|
|
31
31
|
// Utility to get focusable elements inside the modal
|
|
32
32
|
function getFocusableElements(container: HTMLElement): HTMLElement[] {
|
|
33
|
+
//@ts-ignore
|
|
33
34
|
return Array.from(
|
|
34
35
|
container.querySelectorAll(
|
|
35
36
|
'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
const { useState, component, createElement } = window.Vader
|
|
2
2
|
|
|
3
3
|
export type SwapProps = {
|
|
4
|
-
on?:
|
|
5
|
-
off?:
|
|
6
|
-
indeterminate?:
|
|
4
|
+
on?:VNode |VNode[] | string;
|
|
5
|
+
off?:VNode |VNode[] | string;
|
|
6
|
+
indeterminate?:VNode |VNode[] | string;
|
|
7
7
|
active?: boolean; // Controlled toggle
|
|
8
8
|
rotate?: boolean;
|
|
9
9
|
flip?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
const { component, createElement } = window.Vader
|
|
2
2
|
|
|
3
3
|
export type AccordionItem = {
|
|
4
|
-
title: string |
|
|
4
|
+
title: string | VNode;
|
|
5
5
|
content: string | VNode;
|
|
6
6
|
value?: string; // for radio inputs
|
|
7
7
|
open?: boolean; // for details
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { Badge, BadgeProps } from "../Badge";
|
|
1
|
+
const { component, createElement } = window.Vader
|
|
2
|
+
import { Badge, BadgeProps } from "../Badge/index";
|
|
3
3
|
|
|
4
4
|
export type CardProps = {
|
|
5
5
|
title?: string | VNode;
|
|
@@ -8,10 +8,11 @@ export type CardProps = {
|
|
|
8
8
|
figure?: VNode;
|
|
9
9
|
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
10
10
|
style?: "border" | "dash";
|
|
11
|
-
side?: boolean;
|
|
12
|
-
imageFull?: boolean;
|
|
13
|
-
center?: boolean;
|
|
11
|
+
side?: boolean;
|
|
12
|
+
imageFull?: boolean;
|
|
13
|
+
center?: boolean;
|
|
14
14
|
className?: string;
|
|
15
|
+
children?: VNode | VNode[]; // ✅ ADD THIS
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export const Card = component((props: CardProps) => {
|
|
@@ -26,6 +27,7 @@ export const Card = component((props: CardProps) => {
|
|
|
26
27
|
imageFull,
|
|
27
28
|
center,
|
|
28
29
|
className,
|
|
30
|
+
children
|
|
29
31
|
} = props;
|
|
30
32
|
|
|
31
33
|
const classes = ["card"];
|
|
@@ -48,6 +50,7 @@ export const Card = component((props: CardProps) => {
|
|
|
48
50
|
{ className: bodyClasses.join(" ") },
|
|
49
51
|
title ? (typeof title === "string" ? createElement("h2", { className: "card-title" }, title) : title) : null,
|
|
50
52
|
body ? (typeof body === "string" ? createElement("p", {}, body) : body) : null,
|
|
53
|
+
children ? (Array.isArray(children) ? children : [children]) : null, // ✅
|
|
51
54
|
actions ? (Array.isArray(actions) ? actions.map(a => a) : actions) : null
|
|
52
55
|
)
|
|
53
56
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const { component, createElement } = window.Vader
|
|
2
2
|
|
|
3
3
|
export interface Hover3DProps {
|
|
4
4
|
children: any;
|
|
@@ -16,9 +16,7 @@ const Hover3D = component(
|
|
|
16
16
|
{
|
|
17
17
|
class: `hover-3d ${className}`.trim(),
|
|
18
18
|
...(Tag === "a" && href ? { href } : {}),
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
// ✅ IMPORTANT: spread children
|
|
19
|
+
},
|
|
22
20
|
children,
|
|
23
21
|
|
|
24
22
|
// required 8 hover zones
|
package/index.ts
CHANGED
|
@@ -1,10 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
//@ts-nocheck
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import { spawn } from "child_process";
|
|
5
|
-
|
|
6
5
|
const PROJECT_ROOT = process.cwd();
|
|
7
6
|
|
|
7
|
+
/* --------------------------- Platform Detection --------------------------- */
|
|
8
|
+
|
|
9
|
+
interface ProjectInfo {
|
|
10
|
+
isVaderJS: boolean;
|
|
11
|
+
isVaderNative: boolean;
|
|
12
|
+
platform: "vaderjs" | "vaderjs-native" | "unknown";
|
|
13
|
+
packageJson: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function detectPlatform(): ProjectInfo {
|
|
17
|
+
const packageJsonPath = path.join(PROJECT_ROOT, "package.json");
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
20
|
+
return {
|
|
21
|
+
isVaderJS: false,
|
|
22
|
+
isVaderNative: false,
|
|
23
|
+
platform: "unknown",
|
|
24
|
+
packageJson: {}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
29
|
+
const deps = {
|
|
30
|
+
...packageJson.dependencies,
|
|
31
|
+
...packageJson.devDependencies
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const isVaderJS = "vaderjs" in deps;
|
|
35
|
+
const isVaderNative = "vaderjs-native" in deps;
|
|
36
|
+
|
|
37
|
+
let platform: "vaderjs" | "vaderjs-native" | "unknown" = "unknown";
|
|
38
|
+
if (isVaderJS && !isVaderNative) {
|
|
39
|
+
platform = "vaderjs";
|
|
40
|
+
} else if (isVaderNative && !isVaderJS) {
|
|
41
|
+
platform = "vaderjs-native";
|
|
42
|
+
} else if (isVaderJS && isVaderNative) {
|
|
43
|
+
// Both installed, prioritize native for native projects
|
|
44
|
+
platform = "vaderjs-native";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
isVaderJS,
|
|
49
|
+
isVaderNative,
|
|
50
|
+
platform,
|
|
51
|
+
packageJson
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* --------------------------- Dynamic Import --------------------------- */
|
|
56
|
+
|
|
57
|
+
async function getVaderPlugin(): Promise<any> {
|
|
58
|
+
const { platform } = detectPlatform();
|
|
59
|
+
|
|
60
|
+
if (platform === "vaderjs-native") {
|
|
61
|
+
try {
|
|
62
|
+
//@ts-ignore
|
|
63
|
+
return await import("vaderjs-native/plugins");
|
|
64
|
+
} catch (e) {
|
|
65
|
+
console.warn("Failed to import from vaderjs-native/plugins, falling back to vaderjs/plugins");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Default to vaderjs
|
|
70
|
+
try {
|
|
71
|
+
//@ts-ignore
|
|
72
|
+
return await import("vaderjs/plugins");
|
|
73
|
+
} catch (e) {
|
|
74
|
+
throw new Error(`Cannot find Vader.js plugins module. Install either vaderjs or vaderjs-native.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
8
78
|
/* --------------------------- utils --------------------------- */
|
|
9
79
|
|
|
10
80
|
function spawnSync(cmd: string, args: string[], opts: any = {}) {
|
|
@@ -64,7 +134,7 @@ function ensureTailwindConfig() {
|
|
|
64
134
|
async function runTailwind(input: string, output: string) {
|
|
65
135
|
return new Promise<void>((resolve, reject) => {
|
|
66
136
|
const proc = spawn("bunx", ["tailwindcss", "-i", input, "-o", output], { stdio: "inherit" });
|
|
67
|
-
proc.on("close", (code) => {
|
|
137
|
+
proc.on("close", (code: number) => {
|
|
68
138
|
if (code !== 0) reject(new Error(`Tailwind exited with ${code}`));
|
|
69
139
|
else resolve();
|
|
70
140
|
});
|
|
@@ -91,40 +161,48 @@ async function autoInstallDeps() {
|
|
|
91
161
|
console.log("✅ Dependencies installed.");
|
|
92
162
|
}
|
|
93
163
|
|
|
94
|
-
/* ---------------------------
|
|
164
|
+
/* --------------------------- Plugin Factory --------------------------- */
|
|
95
165
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
166
|
+
async function createPlugin() {
|
|
167
|
+
const { platform } = detectPlatform();
|
|
168
|
+
const { VaderPlugin } = await getVaderPlugin();
|
|
169
|
+
|
|
170
|
+
const plugin: InstanceType<typeof VaderPlugin> = {
|
|
171
|
+
name: "Vader Aria",
|
|
172
|
+
version: "0.1.0",
|
|
173
|
+
description: `Tailwind + DaisyUI integration for ${platform}`,
|
|
100
174
|
|
|
101
|
-
|
|
102
|
-
|
|
175
|
+
async onBuildStart(api: any) {
|
|
176
|
+
const rootCss = path.join(PROJECT_ROOT, "root.css");
|
|
103
177
|
|
|
104
|
-
|
|
105
|
-
|
|
178
|
+
// Ensure root CSS exists
|
|
179
|
+
ensureStyles(rootCss);
|
|
106
180
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
181
|
+
// Auto-install deps if Tailwind is not available
|
|
182
|
+
if (!tailwindInstalled()) {
|
|
183
|
+
await autoInstallDeps();
|
|
184
|
+
}
|
|
111
185
|
|
|
112
|
-
|
|
113
|
-
|
|
186
|
+
// Ensure tailwind.config.js exists
|
|
187
|
+
ensureTailwindConfig();
|
|
114
188
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
189
|
+
// Run Tailwind build
|
|
190
|
+
console.log(`🚀 Running TailwindCSS build for ${platform}...`);
|
|
191
|
+
const output = path.join(PROJECT_ROOT, "public/styles.css");
|
|
192
|
+
await runTailwind(rootCss, output);
|
|
119
193
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
194
|
+
// Inject link into HTML
|
|
195
|
+
api.injectHTML(`<link rel="stylesheet" href="/styles.css" />`);
|
|
196
|
+
console.log(`✅ TailwindCSS + DaisyUI loaded for ${platform}`);
|
|
197
|
+
},
|
|
124
198
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
};
|
|
199
|
+
onBuildFinish(api: any) {
|
|
200
|
+
// Optional cleanup
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return plugin;
|
|
205
|
+
}
|
|
129
206
|
|
|
130
|
-
|
|
207
|
+
// Export as default function that creates the plugin
|
|
208
|
+
export default createPlugin;
|
package/jsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"jsx": "react",
|
|
4
|
+
"jsxFactory": "Vader.createElement",
|
|
5
|
+
"baseUrl": ".",
|
|
6
|
+
"target": "es2024",
|
|
7
|
+
"paths": {
|
|
8
|
+
"vader": ["./global.d.ts"],
|
|
9
|
+
"vader/*": ["./global.d.ts"]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"Components/**/*",
|
|
14
|
+
"*.d.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
"name": "vaderjs-daisyui",
|
|
3
3
|
"description": "Lightweight React-like components wrapping DaisyUI classes. Zero dependencies, fully typed, and ready to ship.",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"vaderjs": "
|
|
5
|
+
"vaderjs-types": "^1.0.0"
|
|
6
6
|
},
|
|
7
|
+
"types": "./vader.d.ts",
|
|
7
8
|
"devDependencies": {
|
|
8
9
|
"@tailwindcss/cli": "^4.1.18",
|
|
9
10
|
"autoprefixer": "^10.4.23",
|
|
@@ -11,5 +12,5 @@
|
|
|
11
12
|
"postcss": "^8.5.6",
|
|
12
13
|
"tailwindcss": "^4.1.18"
|
|
13
14
|
},
|
|
14
|
-
"version": "0.0.
|
|
15
|
+
"version": "0.0.4"
|
|
15
16
|
}
|