@maz-ui/upgrade 5.0.0-beta.28 → 5.0.0-beta.29

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/README.md CHANGED
@@ -156,6 +156,14 @@ ambiguous (`variant=`, `color="background"`) are rewritten **only inside
156
156
  | `active-color="background"` | `active-color="surface"` |
157
157
  | `rounded-size="base"` | `rounded-size="md"` |
158
158
  | `.--has-left-icon` / `.--has-right-icon` (CSS selectors) | `.--has-start-icon` / `.--has-end-icon` |
159
+ | `<MazAvatar size="2rem">` (static CSS unit) | `<MazAvatar size="6rem">` (value ×3, render preserved) |
160
+
161
+ The `MazAvatar` rewrite targets only `<MazAvatar>` / `<maz-avatar>` opening
162
+ tags. v5 fixed the avatar size scale (a CSS-unit `size` no longer renders 3x
163
+ too large), so the numeric value is multiplied by 3 to keep the exact same
164
+ render. Every CSS unit is supported. `MazSize` keywords (`mini`..`xl`) and
165
+ bound `:size="…"` expressions are left untouched - the latter is reported as
166
+ a warning at the end of the run.
159
167
 
160
168
  ### `css`
161
169
 
package/dist/cli.mjs CHANGED
@@ -5,7 +5,7 @@ import { resolve, dirname } from 'node:path';
5
5
  import process from 'node:process';
6
6
  import { logger } from '@maz-ui/node';
7
7
  import { globby } from 'globby';
8
- import { A as ALL_GROUPS, h as hasFoundationRadius, t as transformFile, a as hasMazUiRootImport } from './shared/upgrade.DtUNapPx.mjs';
8
+ import { A as ALL_GROUPS, h as hasFoundationRadius, a as hasMazAvatarBoundSize, t as transformFile, b as hasMazUiRootImport } from './shared/upgrade.C55csr01.mjs';
9
9
 
10
10
  const DEFAULT_IGNORES = [
11
11
  "**/node_modules/**",
@@ -94,7 +94,8 @@ Transform groups:
94
94
  also added to package.json next to maz-ui.
95
95
  props left-icon/right-icon \u2192 start-icon/end-icon (props, slots,
96
96
  #icon-left/#icon-right, --has-*-icon classes), footer-align,
97
- variant, color="background", active-color, rounded-size="base"
97
+ variant, color="background", active-color, rounded-size="base",
98
+ MazAvatar static size unit x3 (scale fix, render preserved)
98
99
  css --maz-background \u2192 --maz-surface, --maz-border \u2192 --maz-divider,
99
100
  hsl(var(--maz-X)) collapse (incl. alpha \u2192 color-mix)
100
101
  config Nuxt injectMainCss \u2192 injectCss, theme strategy 'hybrid' \u2192 'runtime',
@@ -187,6 +188,7 @@ async function processSourceFiles(opts, cwd, packageJsonFiles) {
187
188
  let changed = 0;
188
189
  let needsUtilsDep = false;
189
190
  const radiusFiles = [];
191
+ const avatarSizeFiles = [];
190
192
  for (const root of opts.roots) {
191
193
  const absoluteRoot = resolve(cwd, root);
192
194
  const files = await globby(
@@ -215,13 +217,15 @@ async function processSourceFiles(opts, cwd, packageJsonFiles) {
215
217
  needsUtilsDep = true;
216
218
  if (hasFoundationRadius(before))
217
219
  radiusFiles.push(file);
220
+ if (hasMazAvatarBoundSize(before))
221
+ avatarSizeFiles.push(file);
218
222
  if (after === before)
219
223
  continue;
220
224
  changed += 1;
221
225
  reportAndWrite(file, after, opts, cwd);
222
226
  }
223
227
  }
224
- return { scanned, changed, needsUtilsDep, radiusFiles };
228
+ return { scanned, changed, needsUtilsDep, radiusFiles, avatarSizeFiles };
225
229
  }
226
230
  function processPackageJsonFiles(files, opts, cwd, needsUtilsDep) {
227
231
  let scanned = 0;
@@ -260,6 +264,14 @@ Scanned ${scanned} files, ${prefix} ${changed}.`);
260
264
  logger.log(` - ${file.replace(cwdPrefix, "")}`);
261
265
  logger.log(` \u2192 Move the value to scales.rounded.md (other rounded keys are now derived from it via calc).`);
262
266
  }
267
+ if (sources.avatarSizeFiles.length > 0) {
268
+ const cwdPrefix = `${cwd}/`;
269
+ logger.log(`
270
+ \u26A0 MazAvatar bound :size detected in ${sources.avatarSizeFiles.length} file(s) - manual check required:`);
271
+ for (const file of sources.avatarSizeFiles)
272
+ logger.log(` - ${file.replace(cwdPrefix, "")}`);
273
+ logger.log(` \u2192 The size scale was fixed (no more x3). Multiply the CSS unit value by 3 to keep the same render, or use a MazSize keyword. Static size="<unit>" values were already rewritten.`);
274
+ }
263
275
  logger.log(`
264
276
  Next: see https://maz-ui.com/guide/migration-v5 for the manual steps`);
265
277
  logger.log(`(foundation.radius \u2192 scales.rounded.md, MazIcon API, MazBadge sizes, MazChart update-mode).`);
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { A as ALL_GROUPS, b as transformConfig, c as transformCssVars, d as transformDeps, t as transformFile, e as transformHslVar, f as transformImports, g as transformPresetColors, i as transformProps } from './shared/upgrade.DtUNapPx.mjs';
1
+ export { A as ALL_GROUPS, c as transformConfig, d as transformCssVars, e as transformDeps, t as transformFile, f as transformHslVar, g as transformImports, i as transformPresetColors, j as transformProps } from './shared/upgrade.C55csr01.mjs';
@@ -29,8 +29,25 @@ function transformProps(content) {
29
29
  out = out.replace(ACTIVE_COLOR_BG, (_, p, s) => `${p}surface${s}`);
30
30
  out = out.replace(HAS_ICON_CLASS, (_, dir) => `.--has-${flipDirection(dir)}-icon`);
31
31
  out = out.replace(MAZ_OPEN_TAG, (tag) => tag.replace(VARIANT_LR, (_, p, dir, s) => `${p}${flipDirection(dir)}${s}`).replace(COLOR_BG, (_, p, s) => `${p}surface${s}`));
32
+ out = transformAvatarSize(out);
32
33
  return out;
33
34
  }
35
+ const MAZ_AVATAR_OPEN_TAG = /<(?:MazAvatar|maz-avatar)\b[^>]*>/g;
36
+ const AVATAR_SIZE_UNIT = /(?<![:\w-])(size\s*=\s*(["']))(\d*\.?\d+)([a-z%]+)\2/gi;
37
+ function tripleLength(value) {
38
+ return String(Number.parseFloat((Number.parseFloat(value) * 3).toFixed(4)));
39
+ }
40
+ function transformAvatarSize(content) {
41
+ return content.replace(MAZ_AVATAR_OPEN_TAG, (tag) => tag.replace(AVATAR_SIZE_UNIT, (_, prefix, quote, num, unit) => `${prefix}${tripleLength(num)}${unit}${quote}`));
42
+ }
43
+ const AVATAR_BOUND_SIZE = /(?:^|\s)(?::|v-bind:)size\s*=/;
44
+ function hasMazAvatarBoundSize(content) {
45
+ for (const match of content.matchAll(MAZ_AVATAR_OPEN_TAG)) {
46
+ if (AVATAR_BOUND_SIZE.test(match[0]))
47
+ return true;
48
+ }
49
+ return false;
50
+ }
34
51
  const MAZ_BACKGROUND = /--maz-background(?:(?![-\w])|(?=-(?:foreground|\d)))/g;
35
52
  const MAZ_BORDER_COLOR = /--maz-border(?:(?![-\w])|(?=-(?:foreground|\d)))/g;
36
53
  const MAZ_VAR = String.raw`var\(--(?:maz|m)-[\w-]+\)`;
@@ -169,4 +186,4 @@ function transformFile(filename, content, options = {}) {
169
186
  return out;
170
187
  }
171
188
 
172
- export { ALL_GROUPS as A, hasMazUiRootImport as a, transformConfig as b, transformCssVars as c, transformDeps as d, transformHslVar as e, transformImports as f, transformPresetColors as g, hasFoundationRadius as h, transformProps as i, transformFile as t };
189
+ export { ALL_GROUPS as A, hasMazAvatarBoundSize as a, hasMazUiRootImport as b, transformConfig as c, transformCssVars as d, transformDeps as e, transformHslVar as f, transformImports as g, hasFoundationRadius as h, transformPresetColors as i, transformProps as j, transformFile as t };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/upgrade",
3
3
  "type": "module",
4
- "version": "5.0.0-beta.28",
4
+ "version": "5.0.0-beta.29",
5
5
  "description": "Automated source rewrites for migrating a project from Maz-UI v4 to v5.",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",