@valiify/dashboard-ui 0.2.1 → 0.5.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +1025 -12
  2. package/COMPONENTS.md +185 -79
  3. package/GETTING_STARTED.md +138 -38
  4. package/QUICK_REFERENCE.md +48 -30
  5. package/README.md +134 -83
  6. package/TROUBLESHOOTING.md +52 -34
  7. package/class-manifest.json +140 -71
  8. package/design-methodology/dashboard.md +92 -80
  9. package/dist/dashboard-ui.css +1525 -1078
  10. package/dist/index.css +1246 -732
  11. package/package.json +19 -10
  12. package/scripts/codemods/0.5.0-chip-sizes.mjs +437 -0
  13. package/src/build/utilities.css +7 -10
  14. package/src/components/_template.css +12 -8
  15. package/src/components/alert.css +35 -8
  16. package/src/components/avatar.css +42 -30
  17. package/src/components/breadcrumbs.css +39 -22
  18. package/src/components/button.css +84 -14
  19. package/src/components/card.css +2 -2
  20. package/src/components/checkbox.css +16 -11
  21. package/src/components/chip.css +155 -79
  22. package/src/components/composer.css +145 -0
  23. package/src/components/data-row.css +10 -6
  24. package/src/components/divider.css +17 -22
  25. package/src/components/dropdown-field.css +83 -43
  26. package/src/components/dropdown-menu.css +80 -14
  27. package/src/components/field-verification.css +21 -5
  28. package/src/components/filter-segment.css +27 -8
  29. package/src/components/icon-button.css +49 -10
  30. package/src/components/index.css +2 -0
  31. package/src/components/input.css +88 -32
  32. package/src/components/link.css +27 -16
  33. package/src/components/loading-inline.css +15 -21
  34. package/src/components/menu-item.css +149 -49
  35. package/src/components/modal.css +8 -5
  36. package/src/components/navigation-rail.css +67 -31
  37. package/src/components/pagination-item.css +29 -28
  38. package/src/components/pagination.css +9 -14
  39. package/src/components/pill.css +16 -10
  40. package/src/components/progress-bar.css +8 -10
  41. package/src/components/radio-select.css +9 -2
  42. package/src/components/recipient-input.css +119 -0
  43. package/src/components/section-marker.css +5 -5
  44. package/src/components/segment-selector.css +9 -3
  45. package/src/components/sensitive-data.css +7 -5
  46. package/src/components/skeleton.css +18 -6
  47. package/src/components/step.css +15 -4
  48. package/src/components/stepper.css +3 -2
  49. package/src/components/switch.css +7 -0
  50. package/src/components/tabs.css +108 -28
  51. package/src/components/tag.css +156 -51
  52. package/src/components/text-button.css +54 -59
  53. package/src/components/textarea.css +87 -22
  54. package/src/components/toast.css +41 -15
  55. package/src/components/tooltip.css +13 -2
  56. package/src/fonts.css +2 -1
  57. package/src/library.css +1 -1
  58. package/src/reset.css +213 -0
  59. package/src/themes/valiify-tokens.css +101 -126
  60. package/src/themes/valiify.css +258 -157
  61. package/src/utility-surface.css +51 -49
  62. package/types/components.d.ts +142 -24
  63. package/CLAUDE.md +0 -3694
  64. package/examples/README.md +0 -198
  65. package/examples/basic/index.html +0 -155
  66. package/examples/daisyui-starter/README.md +0 -58
  67. package/examples/daisyui-starter/check-no-bleed.mjs +0 -249
  68. package/examples/daisyui-starter/index.html +0 -72
  69. package/examples/daisyui-starter/linked.html +0 -74
  70. package/examples/daisyui-starter/package-lock.json +0 -2221
  71. package/examples/daisyui-starter/package.json +0 -22
  72. package/examples/daisyui-starter/postcss.config.js +0 -1
  73. package/examples/daisyui-starter/src/host.css +0 -14
  74. package/examples/daisyui-starter/src/only-import.css +0 -4
  75. package/examples/daisyui-starter/src/styles.css +0 -36
  76. package/examples/daisyui-starter/tailwind.config.js +0 -13
  77. package/examples/postcss-starter/README.md +0 -47
  78. package/examples/postcss-starter/index.html +0 -54
  79. package/examples/postcss-starter/package.json +0 -19
  80. package/examples/postcss-starter/postcss.config.js +0 -5
  81. package/examples/postcss-starter/src/styles.css +0 -17
  82. package/examples/sveltekit-starter/README.md +0 -32
  83. package/examples/sveltekit-starter/check-scoped-styles.mjs +0 -103
  84. package/examples/sveltekit-starter/package-lock.json +0 -1300
  85. package/examples/sveltekit-starter/package.json +0 -24
  86. package/examples/sveltekit-starter/src/app.css +0 -17
  87. package/examples/sveltekit-starter/src/app.html +0 -11
  88. package/examples/sveltekit-starter/src/lib/GlobalReset.svelte +0 -20
  89. package/examples/sveltekit-starter/src/lib/ScopedRemedy.svelte +0 -27
  90. package/examples/sveltekit-starter/src/lib/ScopedReset.svelte +0 -22
  91. package/examples/sveltekit-starter/src/routes/+layout.svelte +0 -6
  92. package/examples/sveltekit-starter/src/routes/+page.svelte +0 -10
  93. package/examples/sveltekit-starter/svelte.config.js +0 -4
  94. package/examples/sveltekit-starter/vite.config.js +0 -6
  95. package/examples/vite-starter/README.md +0 -125
  96. package/examples/vite-starter/index.html +0 -12
  97. package/examples/vite-starter/package.json +0 -19
  98. package/examples/vite-starter/src/main.js +0 -188
  99. package/examples/vite-starter/src/styles.css +0 -22
  100. package/examples/vite-starter/vite.config.js +0 -6
  101. package/src/themes/valiify-type-prefixed.css +0 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valiify/dashboard-ui",
3
- "version": "0.2.1",
3
+ "version": "0.5.0",
4
4
  "description": "Tailwind CSS component library for Valiify Dashboard applications",
5
5
  "style": "dist/index.css",
6
6
  "types": "types/index.d.ts",
@@ -11,6 +11,7 @@
11
11
  ".": "./dist/index.css",
12
12
  "./index.css": "./dist/index.css",
13
13
  "./styles.css": "./dist/dashboard-ui.css",
14
+ "./reset.css": "./src/reset.css",
14
15
  "./fonts": "./src/fonts.css",
15
16
  "./source": "./src/library.css",
16
17
  "./icons/sprite.svg": "./src/icons/sprite.svg",
@@ -21,22 +22,19 @@
21
22
  "dist",
22
23
  "class-manifest.json",
23
24
  "src",
25
+ "scripts/codemods",
24
26
  "types",
25
- "examples",
26
27
  "design-methodology",
27
28
  "README.md",
28
29
  "GETTING_STARTED.md",
29
30
  "COMPONENTS.md",
30
31
  "TROUBLESHOOTING.md",
31
32
  "QUICK_REFERENCE.md",
32
- "CHANGELOG.md",
33
- "CLAUDE.md"
33
+ "CHANGELOG.md"
34
34
  ],
35
35
  "scripts": {
36
36
  "build": "npm run build:theme && npm run build:icons && npm run build:utility-surface && postcss src/index.css -o dist/index.css && npm run build:styles && npm run build:manifest",
37
- "prepack": "npm run build && npm run fix-examples",
38
- "fix-examples": "node scripts/fix-example-deps.mjs",
39
- "restore-examples": "node scripts/restore-example-deps.mjs",
37
+ "prepack": "npm run build",
40
38
  "build:theme": "node scripts/build-theme.mjs",
41
39
  "build:icons": "node scripts/build-sprite.mjs",
42
40
  "build:manifest": "node scripts/build-manifest.mjs",
@@ -53,10 +51,16 @@
53
51
  "verify:utility-precedence": "node scripts/verify-utility-precedence.mjs",
54
52
  "verify:vocabulary": "node scripts/verify-vocabulary.mjs",
55
53
  "verify:bundle": "node scripts/verify-bundle.mjs",
54
+ "verify:reset": "node scripts/verify-reset.mjs",
56
55
  "verify:markup": "node scripts/verify-markup.mjs",
57
56
  "verify:package": "node scripts/verify-package.mjs",
57
+ "verify:height-scale": "node scripts/verify-height-scale.mjs",
58
+ "verify:codemod": "node scripts/verify-codemod.mjs",
59
+ "verify:registry": "node scripts/verify-registry.mjs",
60
+ "verify:snippets": "node scripts/verify-snippets.mjs",
61
+ "build:registry": "node scripts/build-registry.mjs",
58
62
  "storybook": "storybook dev -p 6006",
59
- "build-storybook": "storybook build",
63
+ "build-storybook": "node scripts/build-storybook.mjs",
60
64
  "verify:visual": "node scripts/visual-verify.mjs",
61
65
  "verify:a11y": "node scripts/a11y-scan.mjs",
62
66
  "audit": "node scripts/audit-components.mjs",
@@ -91,7 +95,7 @@
91
95
  "@storybook/addon-themes": "^10.5.10",
92
96
  "@storybook/html-vite": "^10.5.10",
93
97
  "@tailwindcss/postcss": "^4.3.3",
94
- "@valiify/val-core": "^0.6.0",
98
+ "@valiify/val-core": "^0.8.0",
95
99
  "chromatic": "^18.7.2",
96
100
  "lucide-static": "^1.33.0",
97
101
  "pixelmatch": "^7.2.0",
@@ -106,6 +110,11 @@
106
110
  "typescript": "^5.9.3"
107
111
  },
108
112
  "peerDependencies": {
109
- "tailwindcss": ">=4.0.0"
113
+ "tailwindcss": ">=3.0.0"
114
+ },
115
+ "peerDependenciesMeta": {
116
+ "tailwindcss": {
117
+ "optional": true
118
+ }
110
119
  }
111
120
  }
@@ -0,0 +1,437 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 0.5.0 size codemod — the Rev3 Chip/Badge/Dot and Avatar rescales.
4
+ * (The filename predates the Avatar rescale; it is kept so links still work.)
5
+ *
6
+ * The chip Size axis was re-cut in 0.5.0 and BOTH old size names now mean new
7
+ * things, so a naive sequential find-and-replace corrupts markup (renaming
8
+ * md -> sm after sm -> xs is fine; the reverse collapses every md into xs).
9
+ * This script does the renames in ONE pass — each occurrence is matched once
10
+ * against a simultaneous map, so ordering cannot go wrong:
11
+ *
12
+ * vd-chip-sm -> vd-chip-xs (the 20px chip keeps its height)
13
+ * vd-chip-md -> vd-chip-sm (23 -> 24, a 1px visual change)
14
+ *
15
+ * Badge and dot sizes keep their names (values moved: badge 15/19 -> 16/20,
16
+ * dot 5/7 -> 6/8) and each gained a `-xs`, so no rename is needed for them.
17
+ * Bare `.vd-chip` / `.vd-badge` / `.vd-dot` re-point to XS and keep working —
18
+ * note the chip label grows 8px -> 12px even where the box height holds.
19
+ *
20
+ * AVATAR (added 2026-10-01). Figma's Size axis became XS/S/M/LG/XL = 12/16/
21
+ * 20/28/34, so two names changed meaning, renamed in the same single pass:
22
+ *
23
+ * vd-avatar-lg -> vd-avatar-xl (34px keeps its size; lg means 28 now)
24
+ * vd-avatar-xs -> vd-avatar-sm (16px keeps its size; xs means 12 now)
25
+ *
26
+ * The old 18px `vd-avatar-sm` CANNOT be renamed — its name survives with a new
27
+ * size (16) — so it is not touched; it shrinks 2px wherever it was used.
28
+ *
29
+ * THE 0.4.0 DEPRECATIONS, removed in 0.5.0, in the same class pass:
30
+ *
31
+ * vd-menu-item-badge -> vd-menu-item-tile (an identical rule)
32
+ * vd-menu-item-combined REPORTED: no one-class successor
33
+ * (a tile + subtitle at default tone)
34
+ *
35
+ * and, REPORTED by --utilities: vd:h-[26px] (use vd:h-control-sm — 24, so the
36
+ * box shrinks 2px; reported like vd:py-1.25 because it changes geometry).
37
+ *
38
+ * RUN IT EXACTLY ONCE, ON PRE-0.5.0 MARKUP. The maps are not idempotent: over
39
+ * markup that already speaks 0.5.0 they would turn a new 12px `vd-avatar-xs`
40
+ * into 16 and a new 24px `vd-chip-sm` into 20. So the script refuses when the
41
+ * tree already contains `vd-chip-xs` or `vd-avatar-xl` — names that cannot
42
+ * exist before 0.5.0 — unless you pass --force (e.g. a partly migrated repo
43
+ * whose remaining old files you have listed explicitly). --dry-run only warns.
44
+ *
45
+ * THE `--utilities` FLAG (opt-in, for pages on the prebuilt `./styles.css`
46
+ * bundle and Val-built markup). 0.5.0 also retired three utilities from the
47
+ * closed vd: set — markup using them renders unstyled with nothing failing.
48
+ * The flag rewrites the two with exact replacements, in the same single pass:
49
+ *
50
+ * vd:text-micro-s-bold -> vd:text-action-compact (and the vd:md: twin)
51
+ * vd:px-2.25 -> vd:px-1.5 (and the vd:md: twin)
52
+ *
53
+ * These track the old-sm -> XS mapping exactly. The third, `vd:py-1.25`, is
54
+ * REPORTED but never rewritten: on a DIY non-flex chip that padding is what
55
+ * vertically centres the label, so neither removal nor replacement is safe
56
+ * sight-unseen — each occurrence needs eyes. It is opt-in because, unlike the
57
+ * class renames, the padding rewrite changes geometry (9px -> 6px) anywhere
58
+ * the utility was used off-recipe.
59
+ *
60
+ * THE LEGACY TYPE UTILITIES (added 2026-10-01, with --utilities). The Rev3
61
+ * type migration retired the old scale. A name is rewritten ONLY when it has a
62
+ * same-family, same-size, same-weight successor — then the change is at most
63
+ * a line-height step, whatever the role:
64
+ *
65
+ * vd:text-data-xs -> vd:text-data-compact identical metrics
66
+ * vd:text-caption -> vd:text-supporting-caption identical metrics
67
+ * vd:text-data-s -> vd:text-data-dense identical metrics
68
+ * vd:text-body-1 -> vd:text-body-dense line 19.5 -> 18
69
+ * vd:text-body-1-bold -> vd:text-body-dense-strong line 19.5 -> 18
70
+ * vd:text-h1 -> vd:text-heading-page line 21.8 -> 24
71
+ * vd:text-h2 -> vd:text-heading-section line 19.5 -> 22
72
+ * vd:text-display -> vd:text-display-metric line 39 -> 52
73
+ * vd:type-label-l-bold -> vd:text-label-compact 10.5 -> 12, NO uppercase
74
+ * (the type-label-s-bold precedent: every Rev3
75
+ * module label binds Label/Compact, typed as-cased)
76
+ *
77
+ * The rest have NO same-size successor, so the right replacement depends on
78
+ * the role — the Rev3 file maps, say, Body 2 to Body/Dense in a table cell but
79
+ * to Label/Compact in a metric strip. Those are REPORTED, never rewritten:
80
+ * vd:text-body-2, vd:text-body-2-bold, vd:text-micro-l, vd:text-statecap,
81
+ * vd:text-help-caption, vd:text-action-m (12.5px — no Rev3 12.5) and
82
+ * vd:py-1.25 (above). Together the two lists cover every utility that left
83
+ * the closed vd: set during 0.5.0.
84
+ *
85
+ * --utilities-only applies JUST the utility map and skips both the class
86
+ * renames and the run-once guard. The utility map is idempotent (no target is
87
+ * also a source), so this is the safe way to pick up mappings added after you
88
+ * first ran the codemod — re-running the class renames would corrupt already
89
+ * migrated markup.
90
+ *
91
+ * THE `--source` FLAG (opt-in, for code on the `./source` entry). There the
92
+ * token utilities are UNPREFIXED — `text-caption`, `md:text-data-xs`,
93
+ * `@apply text-body-1-bold`, `type-label-l-bold` — and the legacy ones stop
94
+ * being generated when 0.5.0 removes the old tokens, silently, like a retired
95
+ * vd: utility. --source applies the same safe/report split to every legacy
96
+ * type utility the theme ever generated (37 tokens + 6 type-label-*):
97
+ *
98
+ * rewritten (same family, size and weight — at most a line-height step):
99
+ * text-data-xs -> text-data-compact text-caption -> text-supporting-caption
100
+ * text-data-s -> text-data-dense text-caption-bold -> text-supporting-caption-strong
101
+ * text-data-m -> text-data-emphasis text-data-l -> text-data-large (21.6 -> 22)
102
+ * text-body-1 -> text-body-dense text-body-1-bold -> text-body-dense-strong
103
+ * text-h1 -> text-heading-page text-h2 -> text-heading-section
104
+ * text-display -> text-display-metric text-subtitle -> text-body-default-strong (19.6 -> 20)
105
+ * text-action-l -> text-action-default text-action-l-bold -> text-action-default-active
106
+ * text-action-s -> text-action-compact text-action-s-bold -> text-action-compact-active
107
+ * and, on the same evidence as the vd: map (every Rev3 label binds
108
+ * Label/Compact; 10 / 10.5 -> 12, NO uppercase):
109
+ * type-label-l-bold, type-label-s-bold, text-label-l-bold, text-label-s-bold -> text-label-compact
110
+ *
111
+ * reported, never rewritten (no same-size successor, or the Rev3 file moved
112
+ * the role somewhere else): text-body-2(-bold), text-action-m(-bold) (12.5),
113
+ * text-micro-l/m/s(-bold), text-data-micro-l/m/s, text-statecap,
114
+ * text-help-caption (the file moved it to Action/Compact 500, not the same-
115
+ * metric Caption), text-label-l, text-label-l-mono, text-label-s,
116
+ * text-label-s-mono, type-label-l, type-label-l-mono, type-label-s,
117
+ * type-label-s-mono — and any `--text-<legacy>` custom-property reference
118
+ * (`var(--text-caption)`), which no class rename can fix.
119
+ *
120
+ * Two deliberate differences from --utilities: spacing is untouched (px-2.25
121
+ * and py-1.25 only left the closed vd: set; on ./source they still exist),
122
+ * and text-micro-s-bold is REPORTED — the vd: rewrite to Action/Compact was
123
+ * the chip recipe's, and off-recipe the metric twin is Utility/Avatar
124
+ * Initials, so the role decides. Variant chains are kept (`md:`, `hover:`,
125
+ * `!`, Svelte's `class:`); a chain that starts with `vd:` is left to
126
+ * --utilities. --source-only is to --source what --utilities-only is to
127
+ * --utilities: idempotent, skips the class renames and the run-once guard.
128
+ *
129
+ * PREBUILT LIBRARY BUNDLES ARE NEVER TOUCHED. A vendored dist/index.css or
130
+ * dashboard-ui.css defines the OLD class selectors; renaming them corrupts
131
+ * the bundle (two rules for one name, none for another). Upgrade a vendored
132
+ * bundle by replacing the file. A stylesheet is treated as a bundle when it
133
+ * OPENS with the library banner (`/*! @valiify/dashboard-ui`; a file that
134
+ * only mentions or imports the package is consumer code), or when it defines the design tokens
135
+ * (`--color-content-primary:`) AND at least 40 `.vd-` selectors — no
136
+ * consumer stylesheet does both. Every skipped file is listed.
137
+ *
138
+ * node node_modules/@valiify/dashboard-ui/scripts/codemods/0.5.0-chip-sizes.mjs [--dry-run] [--utilities | --utilities-only] [--source | --source-only] [--force] [paths...]
139
+ *
140
+ * --utilities and --source combine. With no paths it walks the current directory. Only files with these
141
+ * extensions are touched: html, htm, js, jsx, ts, tsx, vue, svelte, astro,
142
+ * mdx, md, css, scss, less, twig, erb, php, py, rb. node_modules, .git and
143
+ * common build-output directories are skipped. --dry-run prints what would
144
+ * change without writing.
145
+ */
146
+ import { readFileSync, writeFileSync, readdirSync, statSync } from "node:fs";
147
+ import { join, extname } from "node:path";
148
+
149
+ const CLASS_RENAMES = new Map([
150
+ ["vd-chip-sm", "vd-chip-xs"],
151
+ ["vd-chip-md", "vd-chip-sm"],
152
+ ["vd-avatar-lg", "vd-avatar-xl"],
153
+ ["vd-avatar-xs", "vd-avatar-sm"],
154
+ // Removed in 0.5.0 (deprecated in 0.4.0): an identical rule under the new name.
155
+ ["vd-menu-item-badge", "vd-menu-item-tile"],
156
+ ]);
157
+
158
+ // Removed classes with no one-class successor — reported by every class pass.
159
+ // The old emphasised Combined row is a tile + the subtitle at default tone now;
160
+ // renaming it would silently drop its primary colour and title weight.
161
+ const CLASS_REPORT_ONLY = ["vd-menu-item-combined"];
162
+
163
+ // Names that only 0.5.0 markup can contain — their presence means the tree is
164
+ // already (partly) migrated, and a second pass would corrupt it. See header.
165
+ const MIGRATED_MARKERS = ["vd-chip-xs", "vd-avatar-xl"];
166
+
167
+ const UTILITY_RENAMES = new Map([
168
+ ["vd:md:text-micro-s-bold", "vd:md:text-action-compact"],
169
+ ["vd:text-micro-s-bold", "vd:text-action-compact"],
170
+ ["vd:md:px-2.25", "vd:md:px-1.5"],
171
+ ["vd:px-2.25", "vd:px-1.5"],
172
+ // Field labels (Rev3): Label S Bold died with the scale. NOTE the target
173
+ // carries NO text-transform — labels stop being uppercase (the casing was
174
+ // the utility's, not the strings'); see the 0.5.0 CHANGELOG.
175
+ ["vd:md:type-label-s-bold", "vd:md:text-label-compact"],
176
+ ["vd:type-label-s-bold", "vd:text-label-compact"],
177
+ // Rev3 nav pass: the retired 12px Action S maps onto Action/Compact
178
+ // (12/16/500 — the line grew 14 -> 16).
179
+ ["vd:md:text-action-s", "vd:md:text-action-compact"],
180
+ ["vd:text-action-s", "vd:text-action-compact"],
181
+ // Rev3 type migration — same-family/size/weight successors only (header).
182
+ ["vd:md:text-data-xs", "vd:md:text-data-compact"],
183
+ ["vd:text-data-xs", "vd:text-data-compact"],
184
+ ["vd:md:text-caption", "vd:md:text-supporting-caption"],
185
+ ["vd:text-caption", "vd:text-supporting-caption"],
186
+ ["vd:md:text-data-s", "vd:md:text-data-dense"],
187
+ ["vd:text-data-s", "vd:text-data-dense"],
188
+ ["vd:md:text-body-1", "vd:md:text-body-dense"],
189
+ ["vd:text-body-1", "vd:text-body-dense"],
190
+ ["vd:md:text-body-1-bold", "vd:md:text-body-dense-strong"],
191
+ ["vd:text-body-1-bold", "vd:text-body-dense-strong"],
192
+ ["vd:md:text-h1", "vd:md:text-heading-page"],
193
+ ["vd:text-h1", "vd:text-heading-page"],
194
+ ["vd:md:text-h2", "vd:md:text-heading-section"],
195
+ ["vd:text-h2", "vd:text-heading-section"],
196
+ ["vd:md:text-display", "vd:md:text-display-metric"],
197
+ ["vd:text-display", "vd:text-display-metric"],
198
+ ["vd:md:type-label-l-bold", "vd:md:text-label-compact"],
199
+ ["vd:type-label-l-bold", "vd:text-label-compact"],
200
+ ]);
201
+
202
+ // Reported, never rewritten — see the header.
203
+ const REPORT_ONLY = [
204
+ "vd:md:py-1.25", "vd:py-1.25",
205
+ // Removed in 0.5.0 (deprecated in 0.4.0): the old 26px chip-tab height. The
206
+ // successor, vd:h-control-sm, is 24 — a geometry change, so never automatic.
207
+ "vd:md:h-[26px]", "vd:h-[26px]",
208
+ // Left the closed set in 0.5.0: on a .vd-text-button (the methodology's only
209
+ // use) the button's own (0,4,0) hover rule always beat it, so it never applied.
210
+ "vd:md:hover:text-warning", "vd:hover:text-warning",
211
+ // Rev3 type names with no same-size successor — role-dependent (header).
212
+ "vd:md:text-body-2-bold", "vd:text-body-2-bold",
213
+ "vd:md:text-body-2", "vd:text-body-2",
214
+ "vd:md:text-micro-l", "vd:text-micro-l",
215
+ "vd:md:text-statecap", "vd:text-statecap",
216
+ "vd:md:text-help-caption", "vd:text-help-caption",
217
+ // Left the closed set with the Button migration; 12.5px has no Rev3 step.
218
+ "vd:md:text-action-m", "vd:text-action-m",
219
+ ];
220
+
221
+ // --source: unprefixed legacy type utilities (header). Keys are BASE names;
222
+ // the matcher keeps any variant chain in front of them.
223
+ const SOURCE_RENAMES = new Map([
224
+ ["text-data-xs", "text-data-compact"],
225
+ ["text-data-s", "text-data-dense"],
226
+ ["text-data-m", "text-data-emphasis"],
227
+ ["text-data-l", "text-data-large"],
228
+ ["text-caption", "text-supporting-caption"],
229
+ ["text-caption-bold", "text-supporting-caption-strong"],
230
+ ["text-body-1", "text-body-dense"],
231
+ ["text-body-1-bold", "text-body-dense-strong"],
232
+ ["text-h1", "text-heading-page"],
233
+ ["text-h2", "text-heading-section"],
234
+ ["text-display", "text-display-metric"],
235
+ ["text-subtitle", "text-body-default-strong"],
236
+ ["text-action-l", "text-action-default"],
237
+ ["text-action-l-bold", "text-action-default-active"],
238
+ ["text-action-s", "text-action-compact"],
239
+ ["text-action-s-bold", "text-action-compact-active"],
240
+ ["type-label-l-bold", "text-label-compact"],
241
+ ["type-label-s-bold", "text-label-compact"],
242
+ ["text-label-l-bold", "text-label-compact"],
243
+ ["text-label-s-bold", "text-label-compact"],
244
+ ]);
245
+ const SOURCE_REPORT_ONLY = [
246
+ "text-body-2", "text-body-2-bold", "text-action-m", "text-action-m-bold",
247
+ "text-micro-l", "text-micro-l-bold", "text-micro-m", "text-micro-m-bold",
248
+ "text-micro-s", "text-micro-s-bold", "text-data-micro-l", "text-data-micro-m",
249
+ "text-data-micro-s", "text-statecap", "text-help-caption",
250
+ "text-label-l", "text-label-l-mono", "text-label-s", "text-label-s-mono",
251
+ "type-label-l", "type-label-l-mono", "type-label-s", "type-label-s-mono",
252
+ ];
253
+ const LEGACY_TOKEN_BASES = [
254
+ ...SOURCE_RENAMES.keys(), ...SOURCE_REPORT_ONLY,
255
+ ].filter((n) => n.startsWith("text-")).map((n) => n.slice("text-".length));
256
+
257
+ const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
258
+
259
+ // One alternation, longest-first, bounded so `vd-chip-sm` never matches inside
260
+ // a longer identifier (class names are [-A-Za-z0-9_:.] tokens; anything beyond
261
+ // that boundary is not this class). Built per run from the active maps.
262
+ const buildPattern = (keys) =>
263
+ new RegExp(
264
+ `(${keys.sort((a, b) => b.length - a.length).map(esc).join("|")})(?![A-Za-z0-9_-])`,
265
+ "g",
266
+ );
267
+
268
+ // A class token: start of string or a delimiter, an optional `!`, a variant
269
+ // chain (`md:hover:` — kept as-is), then the base name, bounded on the right.
270
+ // A chain starting with `vd:` is the prefixed form, which --utilities owns.
271
+ const buildSourcePattern = (keys) =>
272
+ new RegExp(
273
+ `(^|[\\s"'\`{(,>=])(!?)((?:[A-Za-z0-9_-]+:)*)(${keys
274
+ .sort((a, b) => b.length - a.length)
275
+ .map(esc)
276
+ .join("|")})(?![A-Za-z0-9_-])`,
277
+ "g",
278
+ );
279
+ const isPrefixedChain = (chain) => chain.startsWith("vd:");
280
+ // `var(--text-caption)` and friends — a custom-property reference no rename fixes.
281
+ const LEGACY_VAR_PATTERN = new RegExp(
282
+ `--text-(?:${LEGACY_TOKEN_BASES.sort((a, b) => b.length - a.length).map(esc).join("|")})(?![A-Za-z0-9_])`,
283
+ "g",
284
+ );
285
+
286
+ // Prebuilt library bundles — never rewritten (header).
287
+ // The banner is the file's FIRST token. A consumer stylesheet that merely
288
+ // mentions or imports the package (`@import "@valiify/dashboard-ui/source"`)
289
+ // is consumer code and must be scanned.
290
+ const BUNDLE_BANNER = /^\uFEFF?\s*\/\*!\s*@valiify\/dashboard-ui\b/;
291
+ const isLibraryBundle = (file, src) => {
292
+ if (![".css", ".scss", ".less"].includes(extname(file).toLowerCase())) return null;
293
+ if (BUNDLE_BANNER.test(src)) return "library banner";
294
+ if (src.includes("--color-content-primary:")) {
295
+ const selectors = new Set(src.match(/\.vd-[A-Za-z0-9_-]+/g) ?? []);
296
+ if (selectors.size >= 40) return `defines the tokens and ${selectors.size} .vd- selectors`;
297
+ }
298
+ return null;
299
+ };
300
+
301
+ const EXTS = new Set(
302
+ ".html .htm .js .jsx .ts .tsx .vue .svelte .astro .mdx .md .css .scss .less .twig .erb .php .py .rb".split(" "),
303
+ );
304
+ const SKIP_DIRS = new Set([
305
+ "node_modules", ".git", "dist", "build", "out", ".next", ".svelte-kit",
306
+ ".astro", "coverage", "storybook-static", ".turbo", ".cache",
307
+ ]);
308
+
309
+ const args = process.argv.slice(2);
310
+ const dryRun = args.includes("--dry-run");
311
+ const utilitiesOnly = args.includes("--utilities-only");
312
+ const utilities = utilitiesOnly || args.includes("--utilities");
313
+ const sourceOnly = args.includes("--source-only");
314
+ const source = sourceOnly || args.includes("--source");
315
+ const force = args.includes("--force");
316
+ const FLAGS = ["--dry-run", "--utilities", "--utilities-only", "--source", "--source-only", "--force"];
317
+ const roots = args.filter((a) => !FLAGS.includes(a));
318
+ if (!roots.length) roots.push(".");
319
+
320
+ // The class renames run unless every requested mode is an -only mode.
321
+ const classPass = !(utilitiesOnly || sourceOnly) || (utilities && !utilitiesOnly) || (source && !sourceOnly);
322
+ const RENAMES = new Map([
323
+ ...(classPass ? CLASS_RENAMES : []),
324
+ ...(utilities ? UTILITY_RENAMES : []),
325
+ ]);
326
+ const PATTERN = RENAMES.size ? buildPattern([...RENAMES.keys()]) : null;
327
+ const REPORT_PATTERN = buildPattern([...REPORT_ONLY]);
328
+ const CLASS_REPORT_PATTERN = buildPattern([...CLASS_REPORT_ONLY]);
329
+ const SOURCE_PATTERN = buildSourcePattern([...SOURCE_RENAMES.keys()]);
330
+ const SOURCE_REPORT_PATTERN = buildSourcePattern([...SOURCE_REPORT_ONLY]);
331
+
332
+ function* walk(path) {
333
+ const st = statSync(path);
334
+ if (st.isFile()) {
335
+ if (EXTS.has(extname(path).toLowerCase())) yield path;
336
+ return;
337
+ }
338
+ if (!st.isDirectory()) return;
339
+ for (const entry of readdirSync(path)) {
340
+ if (SKIP_DIRS.has(entry)) continue;
341
+ yield* walk(join(path, entry));
342
+ }
343
+ }
344
+
345
+ const skippedBundles = [];
346
+ const files = roots
347
+ .flatMap((root) => [...walk(root)])
348
+ .filter((f) => {
349
+ const why = isLibraryBundle(f, readFileSync(f, "utf8"));
350
+ if (why) skippedBundles.push(` ${f} (${why})`);
351
+ return !why;
352
+ });
353
+
354
+ // Refuse a second pass — see "RUN IT EXACTLY ONCE" in the header.
355
+ const MARKER_PATTERN = buildPattern([...MIGRATED_MARKERS]);
356
+ // String#match, not RegExp#test — the pattern is global, and test() would carry
357
+ // lastIndex from one file into the next and miss matches.
358
+ const migrated = files.filter((f) => readFileSync(f, "utf8").match(MARKER_PATTERN));
359
+ // --utilities-only never runs the class renames, so it cannot double-apply them.
360
+ if (migrated.length && !force && classPass) {
361
+ const list = migrated.slice(0, 10).map((f) => ` ${f}`).join("\n");
362
+ const msg =
363
+ `\n ${migrated.length} file(s) already contain 0.5.0-only classes (${MIGRATED_MARKERS.join(", ")}):\n${list}` +
364
+ (migrated.length > 10 ? `\n … and ${migrated.length - 10} more` : "") +
365
+ `\n\n This tree looks already migrated — a second pass would shrink new 12px avatars to\n` +
366
+ ` 16 and new 24px chips to 20. Pass only the unmigrated paths, or --force.\n`;
367
+ if (!dryRun) {
368
+ console.error(msg);
369
+ process.exit(1);
370
+ }
371
+ console.error(msg.replace("\n This tree", "\n [dry run — would refuse] This tree"));
372
+ }
373
+
374
+ let filesChanged = 0;
375
+ let totalRenames = 0;
376
+ const reportHits = [];
377
+ {
378
+ for (const file of files) {
379
+ const src = readFileSync(file, "utf8");
380
+ let count = 0;
381
+ let out = PATTERN
382
+ ? src.replace(PATTERN, (m) => {
383
+ count++;
384
+ return RENAMES.get(m);
385
+ })
386
+ : src;
387
+ if (source) {
388
+ out = out.replace(SOURCE_PATTERN, (m, lead, bang, chain, name) => {
389
+ if (isPrefixedChain(chain)) return m;
390
+ count++;
391
+ return `${lead}${bang}${chain}${SOURCE_RENAMES.get(name)}`;
392
+ });
393
+ }
394
+ const flagged = [];
395
+ if (classPass) flagged.push(...(src.match(CLASS_REPORT_PATTERN) ?? []));
396
+ if (utilities) flagged.push(...(src.match(REPORT_PATTERN) ?? []));
397
+ if (source) {
398
+ for (const m of src.matchAll(SOURCE_REPORT_PATTERN))
399
+ if (!isPrefixedChain(m[3])) flagged.push(`${m[2]}${m[3]}${m[4]}`);
400
+ flagged.push(...(src.match(LEGACY_VAR_PATTERN) ?? []));
401
+ }
402
+ if (flagged.length)
403
+ reportHits.push(` ${file} (${flagged.length}x ${[...new Set(flagged)].join(", ")})`);
404
+ if (count) {
405
+ filesChanged++;
406
+ totalRenames += count;
407
+ console.log(` ${dryRun ? "would change" : "changed"} ${file} (${count})`);
408
+ if (!dryRun) writeFileSync(file, out);
409
+ }
410
+ }
411
+ }
412
+
413
+ console.log(
414
+ `\n ${dryRun ? "[dry run] " : ""}${totalRenames} rename(s) in ${filesChanged} file(s).` +
415
+ (totalRenames && classPass
416
+ ? "\n Reminder: vd-chip-sm markup now renders 24px (was 23 as vd-chip-md); bare chips keep 20px but their label grew 8px -> 12px." +
417
+ "\n Reminder: any vd-avatar-sm left in place shrinks 18px -> 16px (the name could not be renamed); every avatar's initials are now 8px."
418
+ : ""),
419
+ );
420
+ if (skippedBundles.length) {
421
+ console.log(
422
+ `\n SKIPPED — prebuilt library bundles are never rewritten; replace the file with` +
423
+ `\n the 0.5.0 one instead (renaming its selectors would corrupt it):`,
424
+ );
425
+ for (const line of skippedBundles) console.log(line);
426
+ }
427
+ if (reportHits.length) {
428
+ console.log(
429
+ `\n NEEDS EYES — these are retired or retiring, and are NOT auto-rewritten:` +
430
+ `\n vd:py-1.25 may be what vertically centres a DIY chip's label; vd:h-[26px] is` +
431
+ `\n removed — vd:h-control-sm is 24px, so check the box can shrink 2px; the legacy type` +
432
+ `\n names listed have no same-size Rev3 successor, so the right one depends on the` +
433
+ `\n role; a var(--text-…) reference has no rename at all; and vd-menu-item-combined` +
434
+ `\n (removed) becomes a .vd-menu-item-tile + subtitle at default tone. Fix each by hand:`,
435
+ );
436
+ for (const line of reportHits) console.log(line);
437
+ }
@@ -10,18 +10,16 @@
10
10
  * and `space-x-*` mean different things than they do here. `vd:` makes our utilities
11
11
  * unable to collide with the host's.
12
12
  *
13
- * Why valiify-tokens.css and valiify-type-prefixed.css rather than valiify.css:
14
- * that file carries the @theme block AND `@utility type-label-* { @apply text-label-* }`.
15
- * `@apply` resolves at compile time, so under prefix(vd) the payload is a HARD failure —
16
- * "Cannot apply unprefixed utility class `text-label-l`". The generated theme is split
17
- * so the tokens can take the prefix while the type utilities import without it, their
18
- * payloads already spelled `vd:`. scripts/build-theme.mjs asserts the two spellings
19
- * are the same utility.
13
+ * Why valiify-tokens.css rather than valiify.css: the full theme also carries the
14
+ * .vd-text-* classes, which are plain classes — they ignore Tailwind's prefix() and
15
+ * would land in the bundle twice. (Until 0.5.0 it also carried `@utility type-label-*`
16
+ * bodies that `@apply` legacy text tokens, which needed a separately generated prefixed
17
+ * twin; the legacy scale and those utilities were removed.)
20
18
  *
21
19
  * ../utilities/index.css imports UNCHANGED. `@utility focus-ring` has no @apply, and
22
20
  * its var(--ring-focus-width) resolves against pass A's definitions once the two passes
23
- * are concatenated — so it needs no prefixed twin. Only @utility blocks whose bodies
24
- * use @apply do.
21
+ * are concatenated — so it imports as-is. An @utility whose body used @apply would
22
+ * need its payload respelled with the prefix; none does.
25
23
  *
26
24
  * The utilities land UNLAYERED, and that is deliberate. `tailwindcss/utilities.css` is
27
25
  * a bare `@tailwind utilities;` — unlike `tailwindcss/index.css`, which wraps it in
@@ -39,7 +37,6 @@
39
37
 
40
38
  @import "tailwindcss/theme.css" prefix(vd);
41
39
  @import "../themes/valiify-tokens.css" prefix(vd);
42
- @import "../themes/valiify-type-prefixed.css";
43
40
  @import "../utilities/index.css";
44
41
  @import "../utility-surface.css";
45
42
 
@@ -33,15 +33,19 @@
33
33
  * Do NOT use rounded-xs / rounded-sm / rounded-md — those are Tailwind's
34
34
  * own defaults and are not part of the Valiify design system.
35
35
  *
36
- * 4. Type comes from the composite text tokens, which carry size, line-height,
37
- * weight and tracking in one utility:
38
- * @apply text-action-m; controls
39
- * @apply text-body-1; body copy
40
- * @apply text-h1; headings
36
+ * 4. Type comes from the Revision 3 composite text tokens, which carry size,
37
+ * line-height, weight and tracking in one utility — map from the style
38
+ * Figma BINDS, never by nearest size:
39
+ * @apply text-action-default; controls (md and up; xs/sm: text-action-compact)
40
+ * @apply text-body-dense; body copy (13 / 18)
41
+ * @apply text-heading-page; headings
42
+ *
43
+ * The pre-Rev3 scale is deprecated for removal in 0.5.0 — use only the
44
+ * Revision 3 names (CLAUDE.md, Typography) in new components.
41
45
  *
42
46
  * Tailwind's --text-* cannot carry font-family, so the JetBrains Mono
43
47
  * styles MUST be paired with font-mono or they render in Inter:
44
- * @apply text-data-m font-mono;
48
+ * @apply text-data-compact font-mono;
45
49
  *
46
50
  * 5. Border widths need an explicit var(), because --border-* has no Tailwind
47
51
  * namespace to generate a utility from:
@@ -74,8 +78,8 @@
74
78
  @apply rounded-control;
75
79
  @apply border border-[length:var(--border-thin)];
76
80
 
77
- /* Type */
78
- @apply text-body-1;
81
+ /* Type — Rev3 Body/Dense; replace with the style Figma binds */
82
+ @apply text-body-dense;
79
83
 
80
84
  /* Colors */
81
85
  @apply border-stroke-divider bg-surface-paper text-content-primary;