trix-ui 0.0.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.md +21 -0
- package/README.md +215 -0
- package/dist/commands/add-section.d.ts +2 -0
- package/dist/commands/add-section.js +94 -0
- package/dist/commands/add-section.js.map +1 -0
- package/dist/commands/add-wrapper.d.ts +2 -0
- package/dist/commands/add-wrapper.js +94 -0
- package/dist/commands/add-wrapper.js.map +1 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.js +53 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/build.js +105 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +63 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +44 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list-sections.d.ts +2 -0
- package/dist/commands/list-sections.js +25 -0
- package/dist/commands/list-sections.js.map +1 -0
- package/dist/commands/list-wrappers.d.ts +2 -0
- package/dist/commands/list-wrappers.js +25 -0
- package/dist/commands/list-wrappers.js.map +1 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.js +20 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/remove-section.d.ts +2 -0
- package/dist/commands/remove-section.js +62 -0
- package/dist/commands/remove-section.js.map +1 -0
- package/dist/commands/remove-wrapper.d.ts +2 -0
- package/dist/commands/remove-wrapper.js +62 -0
- package/dist/commands/remove-wrapper.js.map +1 -0
- package/dist/commands/remove.d.ts +2 -0
- package/dist/commands/remove.js +61 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +2 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/icons/libraries.d.ts +37 -0
- package/dist/icons/libraries.js +35 -0
- package/dist/icons/libraries.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/config.d.ts +21 -0
- package/dist/lib/config.js +61 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/fs.d.ts +6 -0
- package/dist/lib/fs.js +43 -0
- package/dist/lib/fs.js.map +1 -0
- package/dist/lib/install.d.ts +19 -0
- package/dist/lib/install.js +48 -0
- package/dist/lib/install.js.map +1 -0
- package/dist/lib/lockfile.d.ts +16 -0
- package/dist/lib/lockfile.js +44 -0
- package/dist/lib/lockfile.js.map +1 -0
- package/dist/lib/paths.d.ts +11 -0
- package/dist/lib/paths.js +25 -0
- package/dist/lib/paths.js.map +1 -0
- package/dist/lib/registry.d.ts +26 -0
- package/dist/lib/registry.js +20 -0
- package/dist/lib/registry.js.map +1 -0
- package/dist/schema/index.d.ts +1128 -0
- package/dist/schema/index.js +239 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/styles/create-style-map.d.ts +4 -0
- package/dist/styles/create-style-map.js +69 -0
- package/dist/styles/create-style-map.js.map +1 -0
- package/dist/styles/transform-style-map.d.ts +3 -0
- package/dist/styles/transform-style-map.js +429 -0
- package/dist/styles/transform-style-map.js.map +1 -0
- package/dist/styles/transform.d.ts +10 -0
- package/dist/styles/transform.js +16 -0
- package/dist/styles/transform.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/transformers/transform-icons.d.ts +2 -0
- package/dist/utils/transformers/transform-icons.js +165 -0
- package/dist/utils/transformers/transform-icons.js.map +1 -0
- package/dist/utils/transformers/transform-menu.d.ts +2 -0
- package/dist/utils/transformers/transform-menu.js +40 -0
- package/dist/utils/transformers/transform-menu.js.map +1 -0
- package/dist/utils/transformers/transform-render.d.ts +2 -0
- package/dist/utils/transformers/transform-render.js +98 -0
- package/dist/utils/transformers/transform-render.js.map +1 -0
- package/dist/utils/transformers/types.d.ts +14 -0
- package/dist/utils/transformers/types.js +2 -0
- package/dist/utils/transformers/types.js.map +1 -0
- package/package.json +59 -0
- package/registry/index.json +242 -0
- package/tailwind.css +95 -0
- package/templates/components/ui/badge.tsx +32 -0
- package/templates/components/ui/button.tsx +44 -0
- package/templates/components/ui/card.tsx +75 -0
- package/templates/components/ui/checkbox.tsx +33 -0
- package/templates/components/ui/dialog.tsx +92 -0
- package/templates/components/ui/dropdown.tsx +75 -0
- package/templates/components/ui/input.tsx +23 -0
- package/templates/components/ui/select.tsx +24 -0
- package/templates/components/ui/switch.tsx +27 -0
- package/templates/components/ui/tabs.tsx +50 -0
- package/templates/components/ui/textarea.tsx +22 -0
- package/templates/components/ui/toast.tsx +100 -0
- package/templates/lib/utils.ts +6 -0
- package/templates/sections/cta.tsx +22 -0
- package/templates/sections/feature-grid.tsx +62 -0
- package/templates/sections/hero.tsx +63 -0
- package/templates/styles/globals.css +75 -0
- package/templates/wrappers/border-wrapper.tsx +34 -0
- package/templates/wrappers/glow-wrapper.tsx +31 -0
- package/templates/wrappers/lift-wrapper.tsx +27 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { iconLibraries } from "../../icons/libraries.js";
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
export const transformIcons = async ({ sourceFile, config }) => {
|
|
4
|
+
const iconLibrary = config.iconLibrary;
|
|
5
|
+
// Fail silently if the icon library is not supported.
|
|
6
|
+
// This is for legacy icon libraries.
|
|
7
|
+
if (!iconLibrary || !(iconLibrary in iconLibraries)) {
|
|
8
|
+
return sourceFile;
|
|
9
|
+
}
|
|
10
|
+
const targetLibrary = iconLibrary;
|
|
11
|
+
const libraryConfig = iconLibraries[targetLibrary];
|
|
12
|
+
let transformedIcons = [];
|
|
13
|
+
for (const element of sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)) {
|
|
14
|
+
if (element.getTagNameNode()?.getText() !== "IconPlaceholder") {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
// Find the library-specific prop (e.g., "lucide", "tabler", "hugeicons")
|
|
18
|
+
const libraryPropAttr = element.getAttributes().find((attr) => {
|
|
19
|
+
if (attr.getKind() !== SyntaxKind.JsxAttribute) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const jsxAttr = attr.asKindOrThrow(SyntaxKind.JsxAttribute);
|
|
23
|
+
return jsxAttr.getNameNode().getText() === targetLibrary;
|
|
24
|
+
});
|
|
25
|
+
if (!libraryPropAttr) {
|
|
26
|
+
continue; // No icon specified for this library
|
|
27
|
+
}
|
|
28
|
+
const jsxIconAttr = libraryPropAttr.asKindOrThrow(SyntaxKind.JsxAttribute);
|
|
29
|
+
const targetIconName = jsxIconAttr
|
|
30
|
+
.getInitializer()
|
|
31
|
+
?.getText()
|
|
32
|
+
.replace(/^["']|["']$/g, "");
|
|
33
|
+
if (!targetIconName) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (!transformedIcons.includes(targetIconName)) {
|
|
37
|
+
transformedIcons.push(targetIconName);
|
|
38
|
+
}
|
|
39
|
+
const usage = libraryConfig.usage;
|
|
40
|
+
const usageMatch = usage.match(/<(\w+)([^>]*)\s*\/>/);
|
|
41
|
+
// Remove the library-specific prop
|
|
42
|
+
jsxIconAttr.remove();
|
|
43
|
+
// Remove all other library-specific props
|
|
44
|
+
for (const attr of element.getAttributes()) {
|
|
45
|
+
if (attr.getKind() !== SyntaxKind.JsxAttribute) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const jsxAttr = attr.asKindOrThrow(SyntaxKind.JsxAttribute);
|
|
49
|
+
const attrName = jsxAttr.getNameNode().getText();
|
|
50
|
+
// Filter out library-specific props (lucide, tabler, hugeicons, etc.)
|
|
51
|
+
if (attrName in iconLibraries) {
|
|
52
|
+
jsxAttr.remove();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!usageMatch) {
|
|
56
|
+
element.getTagNameNode()?.replaceWithText(targetIconName);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const [, componentName, defaultPropsStr] = usageMatch;
|
|
60
|
+
if (componentName === "ICON") {
|
|
61
|
+
// Get remaining user attributes (non-library props)
|
|
62
|
+
const userAttributes = element
|
|
63
|
+
.getAttributes()
|
|
64
|
+
.filter((attr) => {
|
|
65
|
+
if (attr.getKind() !== SyntaxKind.JsxAttribute) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
const jsxAttr = attr.asKindOrThrow(SyntaxKind.JsxAttribute);
|
|
69
|
+
const attrName = jsxAttr.getNameNode().getText();
|
|
70
|
+
// Filter out library-specific props (lucide, tabler, hugeicons, etc.)
|
|
71
|
+
return !(attrName in iconLibraries);
|
|
72
|
+
})
|
|
73
|
+
.map((attr) => attr.getText())
|
|
74
|
+
.join(" ");
|
|
75
|
+
if (userAttributes.trim()) {
|
|
76
|
+
element.replaceWithText(`<${targetIconName} ${userAttributes} />`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
element.getTagNameNode()?.replaceWithText(targetIconName);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const existingPropNames = new Set(element
|
|
84
|
+
.getAttributes()
|
|
85
|
+
.filter((attr) => attr.getKind() === SyntaxKind.JsxAttribute)
|
|
86
|
+
.map((attr) => attr.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()));
|
|
87
|
+
// Replace ICON placeholder in defaultPropsStr with actual icon name
|
|
88
|
+
const defaultPropsWithIcon = defaultPropsStr.replace(/\{ICON\}/g, `{${targetIconName}}`);
|
|
89
|
+
const defaultPropsToAdd = defaultPropsWithIcon
|
|
90
|
+
.trim()
|
|
91
|
+
.split(/\s+(?=\w+=)/)
|
|
92
|
+
.filter((prop) => prop)
|
|
93
|
+
.map((prop) => {
|
|
94
|
+
const propName = prop.split("=")[0];
|
|
95
|
+
return propName && !existingPropNames.has(propName) ? prop : null;
|
|
96
|
+
})
|
|
97
|
+
.filter(Boolean);
|
|
98
|
+
const userAttributes = element
|
|
99
|
+
.getAttributes()
|
|
100
|
+
.filter((attr) => {
|
|
101
|
+
if (attr.getKind() !== SyntaxKind.JsxAttribute) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
const jsxAttr = attr.asKindOrThrow(SyntaxKind.JsxAttribute);
|
|
105
|
+
const attrName = jsxAttr.getNameNode().getText();
|
|
106
|
+
// Filter out library-specific props (lucide, tabler, hugeicons, etc.)
|
|
107
|
+
return !(attrName in iconLibraries);
|
|
108
|
+
})
|
|
109
|
+
.map((attr) => attr.getText())
|
|
110
|
+
.join(" ");
|
|
111
|
+
const allProps = [...defaultPropsToAdd, userAttributes]
|
|
112
|
+
.filter(Boolean)
|
|
113
|
+
.join(" ");
|
|
114
|
+
element.replaceWithText(`<${componentName} ${allProps} />`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
for (const importDeclaration of sourceFile.getImportDeclarations() ?? []) {
|
|
118
|
+
const moduleSpecifier = importDeclaration.getModuleSpecifier()?.getText();
|
|
119
|
+
if (moduleSpecifier?.includes("icon-placeholder")) {
|
|
120
|
+
const namedImports = importDeclaration.getNamedImports() ?? [];
|
|
121
|
+
const iconPlaceholderImport = namedImports.find((specifier) => specifier.getName() === "IconPlaceholder");
|
|
122
|
+
if (iconPlaceholderImport) {
|
|
123
|
+
iconPlaceholderImport.remove();
|
|
124
|
+
}
|
|
125
|
+
if (importDeclaration.getNamedImports()?.length === 0) {
|
|
126
|
+
importDeclaration.remove();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (transformedIcons.length > 0) {
|
|
131
|
+
const importStatements = libraryConfig.import.split("\n");
|
|
132
|
+
const addedImports = [];
|
|
133
|
+
for (const importStmt of importStatements) {
|
|
134
|
+
const importMatch = importStmt.match(/import\s+{([^}]+)}\s+from\s+['"]([^'"]+)['"]/);
|
|
135
|
+
if (!importMatch)
|
|
136
|
+
continue;
|
|
137
|
+
const [, importedNames, modulePath] = importMatch;
|
|
138
|
+
const namedImports = importedNames
|
|
139
|
+
.split(",")
|
|
140
|
+
.map((name) => name.trim())
|
|
141
|
+
.map((name) => {
|
|
142
|
+
if (name === "ICON") {
|
|
143
|
+
return transformedIcons.map((icon) => ({ name: icon }));
|
|
144
|
+
}
|
|
145
|
+
return { name };
|
|
146
|
+
})
|
|
147
|
+
.flat();
|
|
148
|
+
const newImport = sourceFile.addImportDeclaration({
|
|
149
|
+
moduleSpecifier: modulePath,
|
|
150
|
+
namedImports,
|
|
151
|
+
});
|
|
152
|
+
addedImports.push(newImport);
|
|
153
|
+
}
|
|
154
|
+
if (!_useSemicolon(sourceFile)) {
|
|
155
|
+
for (const importDecl of addedImports) {
|
|
156
|
+
importDecl.replaceWithText(importDecl.getText().replace(";", ""));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return sourceFile;
|
|
161
|
+
};
|
|
162
|
+
function _useSemicolon(sourceFile) {
|
|
163
|
+
return (sourceFile.getImportDeclarations()?.[0]?.getText().endsWith(";") ?? false);
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=transform-icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-icons.js","sourceRoot":"","sources":["../../../src/utils/transformers/transform-icons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAwB,MAAM,0BAA0B,CAAA;AAE9E,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAA;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAgB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE;IAC1E,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;IAEtC,sDAAsD;IACtD,qCAAqC;IACrC,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,IAAI,aAAa,CAAC,EAAE,CAAC;QACpD,OAAO,UAAU,CAAA;IACnB,CAA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YAEF,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;gBACtC,UAAU,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAA;YACnE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED,SAAS,aAAa,CAAC,UAAsB;IAC3C,OAAO,CACL,UAAU,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAC1E,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SyntaxKind } from "ts-morph";
|
|
2
|
+
// Transforms cn-menu-target class based on config.menuColor.
|
|
3
|
+
// If menuColor is "inverted", replaces cn-menu-target with "dark".
|
|
4
|
+
// Otherwise, removes cn-menu-target entirely.
|
|
5
|
+
export const transformMenu = async ({ sourceFile, config }) => {
|
|
6
|
+
const menuColor = config.menuColor;
|
|
7
|
+
// If menuColor is not set or is "default", we remove the placeholder.
|
|
8
|
+
const replacement = menuColor === "inverted" ? "dark" : "";
|
|
9
|
+
for (const attr of sourceFile.getDescendantsOfKind(SyntaxKind.JsxAttribute)) {
|
|
10
|
+
const attrName = attr.getNameNode().getText();
|
|
11
|
+
if (attrName !== "className") {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const initializer = attr.getInitializer();
|
|
15
|
+
if (!initializer) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const text = initializer.getText();
|
|
19
|
+
if (!text.includes("cn-menu-target")) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
// Replace cn-menu-target with the replacement value.
|
|
23
|
+
let newText = text.replace(/cn-menu-target/g, replacement);
|
|
24
|
+
// Clean up extra spaces if we removed the class.
|
|
25
|
+
if (!replacement) {
|
|
26
|
+
// Remove double spaces.
|
|
27
|
+
newText = newText.replace(/\s{2,}/g, " ");
|
|
28
|
+
// Clean up leading/trailing spaces in strings.
|
|
29
|
+
newText = newText.replace(/"\s+/g, '"');
|
|
30
|
+
newText = newText.replace(/\s+"/g, '"');
|
|
31
|
+
// Clean up empty strings in cn() calls.
|
|
32
|
+
newText = newText.replace(/,\s*""\s*,/g, ",");
|
|
33
|
+
newText = newText.replace(/\(\s*""\s*,/g, "(");
|
|
34
|
+
newText = newText.replace(/,\s*""\s*\)/g, ")");
|
|
35
|
+
}
|
|
36
|
+
attr.setInitializer(newText);
|
|
37
|
+
}
|
|
38
|
+
return sourceFile;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=transform-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-menu.js","sourceRoot":"","sources":["../../../src/utils/transformers/transform-menu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,6DAA6D;AAC7D,mEAAmE;AACnE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAgB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE;IACzE,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;IAElC,sEAAsE;IACtE,MAAM,WAAW,GAAG,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;IAE1D,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAA;QAC7C,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;YAC7B,SAAQ;QACV,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;QACzC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,SAAQ;QACV,CAAC;QAED,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,EAAE,CAAA;QAClC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACrC,SAAQ;QACV,CAAC;QAED,qDAAqD;QACrD,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAA;QAE1D,iDAAiD;QACjD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,wBAAwB;YACxB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;YACzC,+CAA+C;YAC/C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;YACvC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;YACvC,wCAAwC;YACxC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;YAC7C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;YAC9C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;QAChD,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IAC9B,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { SyntaxKind } from "ts-morph";
|
|
2
|
+
export const transformRender = async ({ sourceFile, config }) => {
|
|
3
|
+
// Only run for base- styles.
|
|
4
|
+
if (!config.style?.startsWith("base-")) {
|
|
5
|
+
return sourceFile;
|
|
6
|
+
}
|
|
7
|
+
// Collect all transformations first, then apply them in reverse order.
|
|
8
|
+
// This prevents issues with invalidated nodes when modifying the tree.
|
|
9
|
+
const transformations = [];
|
|
10
|
+
// Find all JSX elements with render attribute.
|
|
11
|
+
const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxElement);
|
|
12
|
+
for (const jsxElement of jsxElements) {
|
|
13
|
+
const openingElement = jsxElement.getOpeningElement();
|
|
14
|
+
const renderAttr = openingElement.getAttribute("render");
|
|
15
|
+
if (!renderAttr) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
// Get the children of the parent element.
|
|
19
|
+
const children = jsxElement.getJsxChildren();
|
|
20
|
+
const childrenText = children
|
|
21
|
+
.map((c) => c.getText())
|
|
22
|
+
.join("")
|
|
23
|
+
.trim();
|
|
24
|
+
// If there are no children, nothing to transform.
|
|
25
|
+
if (!childrenText) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
// Get the render attribute value.
|
|
29
|
+
if (renderAttr.getKind() !== SyntaxKind.JsxAttribute) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const jsxAttr = renderAttr.asKindOrThrow(SyntaxKind.JsxAttribute);
|
|
33
|
+
const initializer = jsxAttr.getInitializer();
|
|
34
|
+
if (!initializer) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// The render value should be a JSX expression like {<Button />}.
|
|
38
|
+
if (initializer.getKind() !== SyntaxKind.JsxExpression) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const jsxExpression = initializer.asKindOrThrow(SyntaxKind.JsxExpression);
|
|
42
|
+
const expression = jsxExpression.getExpression();
|
|
43
|
+
if (!expression) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
// Check if the expression is a self-closing JSX element.
|
|
47
|
+
if (expression.getKind() !== SyntaxKind.JsxSelfClosingElement) {
|
|
48
|
+
// If it's already a full JSX element with children, skip it.
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const selfClosingElement = expression.asKindOrThrow(SyntaxKind.JsxSelfClosingElement);
|
|
52
|
+
const tagName = selfClosingElement.getTagNameNode().getText();
|
|
53
|
+
const attributes = selfClosingElement
|
|
54
|
+
.getAttributes()
|
|
55
|
+
.map((attr) => attr.getText())
|
|
56
|
+
.join(" ");
|
|
57
|
+
// Build new render prop value with children moved inside.
|
|
58
|
+
const newRenderValue = attributes
|
|
59
|
+
? `{<${tagName} ${attributes}>${childrenText}</${tagName}>}`
|
|
60
|
+
: `{<${tagName}>${childrenText}</${tagName}>}`;
|
|
61
|
+
// Get the parent tag name and other attributes.
|
|
62
|
+
const parentTagName = openingElement.getTagNameNode().getText();
|
|
63
|
+
const otherAttrs = openingElement
|
|
64
|
+
.getAttributes()
|
|
65
|
+
.filter((attr) => {
|
|
66
|
+
if (attr.getKind() === SyntaxKind.JsxAttribute) {
|
|
67
|
+
const attrName = attr
|
|
68
|
+
.asKindOrThrow(SyntaxKind.JsxAttribute)
|
|
69
|
+
.getNameNode()
|
|
70
|
+
.getText();
|
|
71
|
+
return attrName !== "render";
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
})
|
|
75
|
+
.map((attr) => attr.getText())
|
|
76
|
+
.join(" ");
|
|
77
|
+
// Build new element text as self-closing since children are now in render.
|
|
78
|
+
const newAttrs = otherAttrs
|
|
79
|
+
? `${otherAttrs} render=${newRenderValue}`
|
|
80
|
+
: `render=${newRenderValue}`;
|
|
81
|
+
const newElementText = `<${parentTagName} ${newAttrs} />`;
|
|
82
|
+
transformations.push({
|
|
83
|
+
elementStart: jsxElement.getStart(),
|
|
84
|
+
elementEnd: jsxElement.getEnd(),
|
|
85
|
+
newText: newElementText,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
// Apply transformations in reverse order to preserve positions.
|
|
89
|
+
for (const info of transformations.reverse()) {
|
|
90
|
+
const fullText = sourceFile.getFullText();
|
|
91
|
+
const newFullText = fullText.substring(0, info.elementStart) +
|
|
92
|
+
info.newText +
|
|
93
|
+
fullText.substring(info.elementEnd);
|
|
94
|
+
sourceFile.replaceWithText(newFullText);
|
|
95
|
+
}
|
|
96
|
+
return sourceFile;
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=transform-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-render.js","sourceRoot":"","sources":["../../../src/utils/transformers/transform-render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAQrC,MAAM,CAAC,MAAM,eAAe,GAAgB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE;IAC3E,6BAA6B;IAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,uEAAuE;IACvE,uEAAuE;IACvE,MAAM,eAAe,GAAoB,EAAE,CAAA;IAE3C,+CAA+C;IAC/C,MAAM,WAAW,GAAG,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IAE1E,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,cAAc,GAAG,UAAU,CAAC,iBAAiB,EAAE,CAAA;QACrD,MAAM,UAAU,GAAG,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QAExD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,SAAQ;QACV,CAAC;QAED,0CAA0C;QAC1C,MAAM,QAAQ,GAAG,UAAU,CAAC,cAAc,EAAE,CAAA;QAC5C,MAAM,YAAY,GAAG,QAAQ;aAC1B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;aACvB,IAAI,CAAC,EAAE,CAAC;aACR,IAAI,EAAE,CAAA;QAET,kDAAkD;QAClD,IAAI,CAAC,YA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,CAAC,OAAO;YACZ,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACrC,UAAU,CAAC,eAAe,CAAC,WAAW,CAAC,CAAA;IACzC,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SourceFile } from "ts-morph";
|
|
2
|
+
export type TransformConfig = {
|
|
3
|
+
iconLibrary?: string;
|
|
4
|
+
menuColor?: string;
|
|
5
|
+
style?: string;
|
|
6
|
+
};
|
|
7
|
+
export type TransformOpts = {
|
|
8
|
+
filename: string;
|
|
9
|
+
raw: string;
|
|
10
|
+
config: TransformConfig;
|
|
11
|
+
};
|
|
12
|
+
export type Transformer<Output = SourceFile> = (opts: TransformOpts & {
|
|
13
|
+
sourceFile: SourceFile;
|
|
14
|
+
}) => Promise<Output>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/transformers/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "trix-ui",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Lite UI CLI, registry tooling, and templates.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./schema": {
|
|
13
|
+
"types": "./dist/schema/index.d.ts",
|
|
14
|
+
"default": "./dist/schema/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./icons": {
|
|
17
|
+
"types": "./dist/icons/index.d.ts",
|
|
18
|
+
"default": "./dist/icons/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./utils": {
|
|
21
|
+
"types": "./dist/utils/index.d.ts",
|
|
22
|
+
"default": "./dist/utils/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./tailwind.css": {
|
|
25
|
+
"style": "./tailwind.css"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"bin": {
|
|
29
|
+
"ui": "dist/index.js",
|
|
30
|
+
"trix-ui": "dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"registry",
|
|
35
|
+
"templates",
|
|
36
|
+
"tailwind.css",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"commander": "^14.0.2",
|
|
41
|
+
"eslint-plugin-tailwindcss": "3.18.2",
|
|
42
|
+
"postcss": "^8.5.6",
|
|
43
|
+
"postcss-selector-parser": "^7.1.1",
|
|
44
|
+
"ts-morph": "^27.0.2",
|
|
45
|
+
"zod": "^4.3.5"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^25.0.9",
|
|
49
|
+
"tsx": "^4.21.0",
|
|
50
|
+
"typescript": "^5.9.3"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc -p tsconfig.json",
|
|
54
|
+
"dev": "node --enable-source-maps --import tsx src/index.ts",
|
|
55
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
56
|
+
"pub:beta": "pnpm build && pnpm publish --no-git-checks --access public --tag beta",
|
|
57
|
+
"pub:release": "pnpm build && pnpm publish --access public"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"components": [
|
|
4
|
+
{
|
|
5
|
+
"name": "button",
|
|
6
|
+
"description": "Button with variants and focus ring.",
|
|
7
|
+
"files": [
|
|
8
|
+
{
|
|
9
|
+
"source": "components/ui/button.tsx",
|
|
10
|
+
"target": "{{components}}/button.tsx"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"npm": ["clsx", "tailwind-merge"]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "input",
|
|
19
|
+
"description": "Text input with consistent focus styles.",
|
|
20
|
+
"files": [
|
|
21
|
+
{
|
|
22
|
+
"source": "components/ui/input.tsx",
|
|
23
|
+
"target": "{{components}}/input.tsx"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"npm": ["clsx", "tailwind-merge"]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "textarea",
|
|
32
|
+
"description": "Textarea with consistent focus styles.",
|
|
33
|
+
"files": [
|
|
34
|
+
{
|
|
35
|
+
"source": "components/ui/textarea.tsx",
|
|
36
|
+
"target": "{{components}}/textarea.tsx"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"npm": ["clsx", "tailwind-merge"]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "select",
|
|
45
|
+
"description": "Native select styled for Tailwind.",
|
|
46
|
+
"files": [
|
|
47
|
+
{
|
|
48
|
+
"source": "components/ui/select.tsx",
|
|
49
|
+
"target": "{{components}}/select.tsx"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"npm": ["clsx", "tailwind-merge"]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "checkbox",
|
|
58
|
+
"description": "Accessible checkbox built on Radix.",
|
|
59
|
+
"files": [
|
|
60
|
+
{
|
|
61
|
+
"source": "components/ui/checkbox.tsx",
|
|
62
|
+
"target": "{{components}}/checkbox.tsx"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"npm": [
|
|
67
|
+
"@radix-ui/react-checkbox",
|
|
68
|
+
"clsx",
|
|
69
|
+
"tailwind-merge"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "switch",
|
|
75
|
+
"description": "Accessible switch built on Radix.",
|
|
76
|
+
"files": [
|
|
77
|
+
{
|
|
78
|
+
"source": "components/ui/switch.tsx",
|
|
79
|
+
"target": "{{components}}/switch.tsx"
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"npm": ["@radix-ui/react-switch", "clsx", "tailwind-merge"]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "card",
|
|
88
|
+
"description": "Card container with header/content/footer.",
|
|
89
|
+
"files": [
|
|
90
|
+
{
|
|
91
|
+
"source": "components/ui/card.tsx",
|
|
92
|
+
"target": "{{components}}/card.tsx"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"npm": ["clsx", "tailwind-merge"]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "badge",
|
|
101
|
+
"description": "Badge with variants.",
|
|
102
|
+
"files": [
|
|
103
|
+
{
|
|
104
|
+
"source": "components/ui/badge.tsx",
|
|
105
|
+
"target": "{{components}}/badge.tsx"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"dependencies": {
|
|
109
|
+
"npm": ["clsx", "tailwind-merge"]
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "dialog",
|
|
114
|
+
"description": "Dialog using Radix primitives.",
|
|
115
|
+
"files": [
|
|
116
|
+
{
|
|
117
|
+
"source": "components/ui/dialog.tsx",
|
|
118
|
+
"target": "{{components}}/dialog.tsx"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"dependencies": {
|
|
122
|
+
"npm": ["@radix-ui/react-dialog", "clsx", "tailwind-merge"]
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "dropdown",
|
|
127
|
+
"description": "Dropdown menu using Radix primitives.",
|
|
128
|
+
"files": [
|
|
129
|
+
{
|
|
130
|
+
"source": "components/ui/dropdown.tsx",
|
|
131
|
+
"target": "{{components}}/dropdown.tsx"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"dependencies": {
|
|
135
|
+
"npm": [
|
|
136
|
+
"@radix-ui/react-dropdown-menu",
|
|
137
|
+
"clsx",
|
|
138
|
+
"tailwind-merge"
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "tabs",
|
|
144
|
+
"description": "Tabs using Radix primitives.",
|
|
145
|
+
"files": [
|
|
146
|
+
{
|
|
147
|
+
"source": "components/ui/tabs.tsx",
|
|
148
|
+
"target": "{{components}}/tabs.tsx"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"dependencies": {
|
|
152
|
+
"npm": ["@radix-ui/react-tabs", "clsx", "tailwind-merge"]
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "toast",
|
|
157
|
+
"description": "Toast primitives using Radix.",
|
|
158
|
+
"files": [
|
|
159
|
+
{
|
|
160
|
+
"source": "components/ui/toast.tsx",
|
|
161
|
+
"target": "{{components}}/toast.tsx"
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
"dependencies": {
|
|
165
|
+
"npm": ["@radix-ui/react-toast", "clsx", "tailwind-merge"]
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"sections": [
|
|
170
|
+
{
|
|
171
|
+
"name": "hero",
|
|
172
|
+
"description": "Hero section with headline, bullets, and CTAs.",
|
|
173
|
+
"files": [
|
|
174
|
+
{
|
|
175
|
+
"source": "sections/hero.tsx",
|
|
176
|
+
"target": "{{sections}}/hero.tsx"
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"dependencies": {
|
|
180
|
+
"local": ["badge", "button"]
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "feature-grid",
|
|
185
|
+
"description": "Feature grid with cards and headline copy.",
|
|
186
|
+
"files": [
|
|
187
|
+
{
|
|
188
|
+
"source": "sections/feature-grid.tsx",
|
|
189
|
+
"target": "{{sections}}/feature-grid.tsx"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"dependencies": {
|
|
193
|
+
"local": ["badge", "card"]
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"name": "cta",
|
|
198
|
+
"description": "Call-to-action block with headline and buttons.",
|
|
199
|
+
"files": [
|
|
200
|
+
{
|
|
201
|
+
"source": "sections/cta.tsx",
|
|
202
|
+
"target": "{{sections}}/cta.tsx"
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"dependencies": {
|
|
206
|
+
"local": ["button"]
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"wrappers": [
|
|
211
|
+
{
|
|
212
|
+
"name": "glow-wrapper",
|
|
213
|
+
"description": "Glow effect wrapper for highlighting key components.",
|
|
214
|
+
"files": [
|
|
215
|
+
{
|
|
216
|
+
"source": "wrappers/glow-wrapper.tsx",
|
|
217
|
+
"target": "{{wrappers}}/glow-wrapper.tsx"
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "lift-wrapper",
|
|
223
|
+
"description": "Hover lift wrapper for subtle depth on interaction.",
|
|
224
|
+
"files": [
|
|
225
|
+
{
|
|
226
|
+
"source": "wrappers/lift-wrapper.tsx",
|
|
227
|
+
"target": "{{wrappers}}/lift-wrapper.tsx"
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "border-wrapper",
|
|
233
|
+
"description": "Gradient border wrapper for featured content blocks.",
|
|
234
|
+
"files": [
|
|
235
|
+
{
|
|
236
|
+
"source": "wrappers/border-wrapper.tsx",
|
|
237
|
+
"target": "{{wrappers}}/border-wrapper.tsx"
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
}
|