@exhaustive-ui/core 22.0.0-alpha.11 → 22.0.0-alpha.12
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exhaustive-ui/core",
|
|
3
|
-
"version": "22.0.0-alpha.
|
|
3
|
+
"version": "22.0.0-alpha.12",
|
|
4
4
|
"author": "e-xiste",
|
|
5
5
|
"description": "ExhaustiveUI is a community-maintained, MIT licensed UI library for Angular with 80+ accessible components and design-agnostic theming, including Aura, Material, Lara and Nora presets.",
|
|
6
6
|
"homepage": "https://exhaustive-ui.com/",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"tslib": "^2.3.0",
|
|
59
|
-
"@exhaustive-ui/motion": "22.0.0-alpha.
|
|
60
|
-
"@exhaustive-ui/styled": "22.0.0-alpha.
|
|
61
|
-
"@exhaustive-ui/
|
|
62
|
-
"@exhaustive-ui/
|
|
59
|
+
"@exhaustive-ui/motion": "22.0.0-alpha.12",
|
|
60
|
+
"@exhaustive-ui/styled": "22.0.0-alpha.12",
|
|
61
|
+
"@exhaustive-ui/utils": "22.0.0-alpha.12",
|
|
62
|
+
"@exhaustive-ui/styles": "22.0.0-alpha.12"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
65
65
|
"chart.js": {
|
|
@@ -25,13 +25,15 @@ function migrateFromPrimeflex(options) {
|
|
|
25
25
|
const scope = normalizeScope(options.path);
|
|
26
26
|
let htmlChanged = 0;
|
|
27
27
|
let tsChanged = 0;
|
|
28
|
+
const tailwindVersion = options.tailwindVersion ?? (0, primeflex_1.detectTailwindVersion)((0, package_json_1.findTailwindRange)(tree));
|
|
29
|
+
context.logger.info(`Translating PrimeFlex classes for Tailwind CSS v${tailwindVersion}.`);
|
|
28
30
|
tree.visit((path) => {
|
|
29
31
|
if (package_json_1.SKIP_DIRS.test(path) || !inScope(path, scope)) {
|
|
30
32
|
return;
|
|
31
33
|
}
|
|
32
34
|
if (path.endsWith('.html')) {
|
|
33
35
|
const original = tree.read(path).toString();
|
|
34
|
-
const { text, changed } = (0, primeflex_1.translateHtml)(original);
|
|
36
|
+
const { text, changed } = (0, primeflex_1.translateHtml)(original, tailwindVersion);
|
|
35
37
|
if (changed) {
|
|
36
38
|
tree.overwrite(path, text);
|
|
37
39
|
htmlChanged++;
|
|
@@ -40,7 +42,7 @@ function migrateFromPrimeflex(options) {
|
|
|
40
42
|
}
|
|
41
43
|
else if (path.endsWith('.ts') || path.endsWith('.mts')) {
|
|
42
44
|
const original = tree.read(path).toString();
|
|
43
|
-
const { text, changed } = (0, primeflex_1.translateTypeScript)(path, original);
|
|
45
|
+
const { text, changed } = (0, primeflex_1.translateTypeScript)(path, original, tailwindVersion);
|
|
44
46
|
if (changed) {
|
|
45
47
|
tree.overwrite(path, text);
|
|
46
48
|
tsChanged++;
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
"path": {
|
|
8
8
|
"type": "string",
|
|
9
9
|
"description": "Restrict the translation to files under this workspace path (e.g. \"src/app\"). Defaults to the whole workspace."
|
|
10
|
+
},
|
|
11
|
+
"tailwindVersion": {
|
|
12
|
+
"type": "number",
|
|
13
|
+
"enum": [3, 4],
|
|
14
|
+
"description": "The Tailwind CSS major version to produce class names for. Tailwind v4 renamed the shadow and border-radius scales. Defaults to the version of the tailwindcss dependency, or 4 when Tailwind is not installed yet."
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
17
|
}
|
|
@@ -7,6 +7,7 @@ exports.getPrimengMajor = getPrimengMajor;
|
|
|
7
7
|
exports.findPrimengMajor = findPrimengMajor;
|
|
8
8
|
exports.hasPrimeng = hasPrimeng;
|
|
9
9
|
exports.hasPrimeflex = hasPrimeflex;
|
|
10
|
+
exports.findTailwindRange = findTailwindRange;
|
|
10
11
|
const mappings_1 = require("./mappings");
|
|
11
12
|
const workspace_files_1 = require("./workspace-files");
|
|
12
13
|
exports.SKIP_DIRS = /(^|\/)(node_modules|dist|\.angular|\.git|out-tsc)(\/|$)/;
|
|
@@ -187,6 +188,22 @@ function hasPrimeflex(tree) {
|
|
|
187
188
|
* Walks every package.json in the workspace tree (skipping node_modules/dist/.angular/.git/out-tsc),
|
|
188
189
|
* invoking `visitor` with each successfully-parsed package.json contents.
|
|
189
190
|
*/
|
|
191
|
+
/**
|
|
192
|
+
* The `tailwindcss` version range declared by the workspace's package.json files (the first one
|
|
193
|
+
* found), or `undefined` when Tailwind is not a direct dependency.
|
|
194
|
+
*/
|
|
195
|
+
function findTailwindRange(tree) {
|
|
196
|
+
let range;
|
|
197
|
+
visitWorkspacePackageJsons(tree, (pkg) => {
|
|
198
|
+
for (const section of DIRECT_DEPENDENCY_SECTIONS) {
|
|
199
|
+
const deps = pkg[section];
|
|
200
|
+
if (range === undefined && isRecord(deps) && typeof deps['tailwindcss'] === 'string') {
|
|
201
|
+
range = deps['tailwindcss'];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
return range;
|
|
206
|
+
}
|
|
190
207
|
function visitWorkspacePackageJsons(tree, visitor) {
|
|
191
208
|
(0, workspace_files_1.visitWorkspaceFiles)(tree, (path, read) => {
|
|
192
209
|
const content = read();
|
|
@@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.detectTailwindVersion = detectTailwindVersion;
|
|
39
40
|
exports.translateClassList = translateClassList;
|
|
40
41
|
exports.translateHtml = translateHtml;
|
|
41
42
|
exports.translateTypeScript = translateTypeScript;
|
|
@@ -49,6 +50,39 @@ const primeflex_translations_json_1 = __importDefault(require("./primeflex-trans
|
|
|
49
50
|
* (`grid-nogutter` -> ``), meaning the token is dropped.
|
|
50
51
|
*/
|
|
51
52
|
const TRANSLATIONS = primeflex_translations_json_1.default;
|
|
53
|
+
/**
|
|
54
|
+
* The dictionary produces Tailwind v3 names. Tailwind v4 renamed the shadow and border-radius
|
|
55
|
+
* scales one step down (v3 `shadow-sm` is v4 `shadow-xs`, v3 `rounded` is v4 `rounded-sm`), so
|
|
56
|
+
* keeping the v3 names on a v4 project would silently change the rendering.
|
|
57
|
+
*/
|
|
58
|
+
const V4_RENAMES = {
|
|
59
|
+
'shadow-sm': 'shadow-xs',
|
|
60
|
+
shadow: 'shadow-sm',
|
|
61
|
+
'rounded-sm': 'rounded-xs',
|
|
62
|
+
rounded: 'rounded-sm',
|
|
63
|
+
...Object.fromEntries(['t', 'r', 'b', 'l'].flatMap((side) => [
|
|
64
|
+
[`rounded-${side}-sm`, `rounded-${side}-xs`],
|
|
65
|
+
[`rounded-${side}`, `rounded-${side}-sm`]
|
|
66
|
+
]))
|
|
67
|
+
};
|
|
68
|
+
function toV4(classes) {
|
|
69
|
+
return classes
|
|
70
|
+
.split(' ')
|
|
71
|
+
.map((token) => {
|
|
72
|
+
const index = token.lastIndexOf(':') + 1;
|
|
73
|
+
const renamed = V4_RENAMES[token.slice(index)];
|
|
74
|
+
return renamed === undefined ? token : token.slice(0, index) + renamed;
|
|
75
|
+
})
|
|
76
|
+
.join(' ');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Reads the Tailwind CSS major version from a package.json `tailwindcss` range (`^3.4.1` -> 3).
|
|
80
|
+
* Defaults to 4, the current major, when Tailwind is not installed yet or the range is not a plain version.
|
|
81
|
+
*/
|
|
82
|
+
function detectTailwindVersion(range) {
|
|
83
|
+
const major = range?.match(/^\s*[\^~>=v]*\s*(\d+)/)?.[1];
|
|
84
|
+
return major !== undefined && Number(major) <= 3 ? 3 : 4;
|
|
85
|
+
}
|
|
52
86
|
/**
|
|
53
87
|
* Translates a whitespace-separated class list (the value of a `class` attribute or of a string
|
|
54
88
|
* literal inside a class binding). Each token is looked up in the PrimeFlex dictionary and, when
|
|
@@ -56,7 +90,7 @@ const TRANSLATIONS = primeflex_translations_json_1.default;
|
|
|
56
90
|
* interpolations like `{{ x }}`, arbitrary text) are left untouched. Inter-token whitespace is
|
|
57
91
|
* preserved so diffs stay minimal.
|
|
58
92
|
*/
|
|
59
|
-
function translateClassList(value) {
|
|
93
|
+
function translateClassList(value, tailwindVersion = 4) {
|
|
60
94
|
let changed = false;
|
|
61
95
|
// Split keeping the whitespace runs so the original spacing is preserved on rebuild.
|
|
62
96
|
const parts = value.split(/(\s+)/);
|
|
@@ -64,10 +98,11 @@ function translateClassList(value) {
|
|
|
64
98
|
if (index % 2 === 1 || part.length === 0) {
|
|
65
99
|
return part; // whitespace run or empty edge
|
|
66
100
|
}
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
101
|
+
const translated = TRANSLATIONS[part];
|
|
102
|
+
if (translated === undefined) {
|
|
69
103
|
return part;
|
|
70
104
|
}
|
|
105
|
+
const mapped = tailwindVersion === 4 ? toV4(translated) : translated;
|
|
71
106
|
if (mapped !== part) {
|
|
72
107
|
changed = true;
|
|
73
108
|
}
|
|
@@ -84,10 +119,10 @@ function translateClassList(value) {
|
|
|
84
119
|
* Only the contents of the string literals are touched; identifiers and the surrounding
|
|
85
120
|
* expression structure are left exactly as-is.
|
|
86
121
|
*/
|
|
87
|
-
function translateBindingExpression(expr) {
|
|
122
|
+
function translateBindingExpression(expr, tailwindVersion) {
|
|
88
123
|
let changed = false;
|
|
89
124
|
const rebuilt = expr.replace(/(['"])((?:\\.|(?!\1).)*)\1/g, (_match, quote, inner) => {
|
|
90
|
-
const translated = translateClassList(inner);
|
|
125
|
+
const translated = translateClassList(inner, tailwindVersion);
|
|
91
126
|
if (translated.changed) {
|
|
92
127
|
changed = true;
|
|
93
128
|
}
|
|
@@ -107,10 +142,10 @@ const CLASS_BINDING_RE = /(\[(?:ngClass|class)\]\s*=\s*)(["'])((?:\\.|(?!\2).)*)
|
|
|
107
142
|
* `class`/`ngClass` attribute values and `[class]`/`[ngClass]` binding expressions. All other markup
|
|
108
143
|
* — text, unrelated attributes, single-class bindings like `[class.active]` — is left untouched.
|
|
109
144
|
*/
|
|
110
|
-
function translateHtml(html) {
|
|
145
|
+
function translateHtml(html, tailwindVersion = 4) {
|
|
111
146
|
let changed = false;
|
|
112
147
|
let text = html.replace(STATIC_CLASS_RE, (match, lead, name, eq, quote, inner) => {
|
|
113
|
-
const translated = translateClassList(inner);
|
|
148
|
+
const translated = translateClassList(inner, tailwindVersion);
|
|
114
149
|
if (!translated.changed) {
|
|
115
150
|
return match;
|
|
116
151
|
}
|
|
@@ -118,7 +153,7 @@ function translateHtml(html) {
|
|
|
118
153
|
return `${lead}${name}${eq}${quote}${translated.value}${quote}`;
|
|
119
154
|
});
|
|
120
155
|
text = text.replace(CLASS_BINDING_RE, (match, prefix, quote, inner) => {
|
|
121
|
-
const translated = translateBindingExpression(inner);
|
|
156
|
+
const translated = translateBindingExpression(inner, tailwindVersion);
|
|
122
157
|
if (!translated.changed) {
|
|
123
158
|
return match;
|
|
124
159
|
}
|
|
@@ -137,7 +172,7 @@ function translateHtml(html) {
|
|
|
137
172
|
* single `NoSubstitutionTemplateLiteral` (or `StringLiteral`) to the TypeScript parser and its full
|
|
138
173
|
* body can be handed to `translateHtml`.
|
|
139
174
|
*/
|
|
140
|
-
function translateTypeScript(fileName, text) {
|
|
175
|
+
function translateTypeScript(fileName, text, tailwindVersion = 4) {
|
|
141
176
|
const sourceFile = ts.createSourceFile(fileName, text, ts.ScriptTarget.Latest, true);
|
|
142
177
|
const edits = [];
|
|
143
178
|
const visit = (node) => {
|
|
@@ -147,7 +182,7 @@ function translateTypeScript(fileName, text) {
|
|
|
147
182
|
const raw = initializer.getText(sourceFile);
|
|
148
183
|
const quote = raw[0];
|
|
149
184
|
const body = raw.slice(1, -1);
|
|
150
|
-
const translated = translateHtml(body);
|
|
185
|
+
const translated = translateHtml(body, tailwindVersion);
|
|
151
186
|
if (translated.changed) {
|
|
152
187
|
edits.push({
|
|
153
188
|
start: initializer.getStart(sourceFile),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@exhaustive-ui/core": "^22.0.0-alpha.
|
|
3
|
-
"@exhaustive-ui/locale": "^22.0.0-alpha.
|
|
4
|
-
"@exhaustive-ui/motion": "^22.0.0-alpha.
|
|
5
|
-
"@exhaustive-ui/styled": "^22.0.0-alpha.
|
|
6
|
-
"@exhaustive-ui/styles": "^22.0.0-alpha.
|
|
7
|
-
"@exhaustive-ui/tailwindcss": "^22.0.0-alpha.
|
|
8
|
-
"@exhaustive-ui/themes": "^22.0.0-alpha.
|
|
9
|
-
"@exhaustive-ui/utils": "^22.0.0-alpha.
|
|
2
|
+
"@exhaustive-ui/core": "^22.0.0-alpha.12",
|
|
3
|
+
"@exhaustive-ui/locale": "^22.0.0-alpha.12",
|
|
4
|
+
"@exhaustive-ui/motion": "^22.0.0-alpha.12",
|
|
5
|
+
"@exhaustive-ui/styled": "^22.0.0-alpha.12",
|
|
6
|
+
"@exhaustive-ui/styles": "^22.0.0-alpha.12",
|
|
7
|
+
"@exhaustive-ui/tailwindcss": "^22.0.0-alpha.12",
|
|
8
|
+
"@exhaustive-ui/themes": "^22.0.0-alpha.12",
|
|
9
|
+
"@exhaustive-ui/utils": "^22.0.0-alpha.12",
|
|
10
10
|
"@openng/icons": "^1.0.0"
|
|
11
11
|
}
|