@valiify/dashboard-ui 0.3.0 → 0.5.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +948 -10
  2. package/COMPONENTS.md +199 -79
  3. package/GETTING_STARTED.md +116 -54
  4. package/QUICK_REFERENCE.md +48 -30
  5. package/README.md +107 -85
  6. package/TROUBLESHOOTING.md +52 -34
  7. package/class-manifest.json +141 -71
  8. package/design-methodology/dashboard.md +92 -80
  9. package/dist/dashboard-ui.css +1529 -1078
  10. package/dist/index.css +1250 -732
  11. package/package.json +17 -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 +122 -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 +1 -1
  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 +145 -25
  63. package/CLAUDE.md +0 -3740
  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
@@ -1,198 +0,0 @@
1
- # Examples
2
-
3
- Working reference implementations for different build setups.
4
-
5
- ## Quick Start
6
-
7
- **New project?** Copy the Vite starter:
8
-
9
- ```bash
10
- npx degit BubbaCoop/Valiify-dashboard-ui/examples/vite-starter my-app
11
- cd my-app
12
- npm install
13
- npm run dev
14
- ```
15
-
16
- Open [http://localhost:5173](http://localhost:5173) - you should see styled components with working icons.
17
-
18
- ## Available Examples
19
-
20
- ### [vite-starter/](vite-starter/) - Recommended
21
-
22
- **Best for:** New projects, React/Vue/Svelte apps, any modern frontend.
23
-
24
- - ✅ Complete working setup
25
- - ✅ Shows all critical setup steps
26
- - ✅ Includes interactive dropdown with minimal JavaScript
27
- - ✅ Demonstrates icon sprite loading
28
- - ✅ Examples of common components
29
-
30
- **Includes:**
31
- - Vite configuration with `@tailwindcss/vite`
32
- - Correct CSS import structure
33
- - Icon sprite loading
34
- - Component examples
35
- - Minimal dropdown behavior implementation
36
-
37
- ### [postcss-starter/](postcss-starter/)
38
-
39
- **Best for:** PostCSS CLI users, webpack projects, minimal setups.
40
-
41
- - ✅ PostCSS configuration
42
- - ✅ Works without a bundler
43
- - ✅ Shows manual build process
44
-
45
- **Includes:**
46
- - PostCSS config with `@tailwindcss/postcss`
47
- - Build scripts
48
- - Static HTML output
49
-
50
- ### [basic/](basic/)
51
-
52
- **Best for:** Standalone HTML pages, email previews, static prototypes.
53
-
54
- Uses the **prebuilt** entry (`dist/index.css`), not `/source`.
55
-
56
- - ✅ No build process required
57
- - ❌ No token utilities (`bg-approved`, etc. don't work)
58
- - ❌ Includes Tailwind Preflight (CSS reset)
59
-
60
- **When to use:** Only when you have no build tool at all.
61
-
62
- ### [daisyui-starter/](daisyui-starter/) - The host-collision test
63
-
64
- **Best for:** proving the prebuilt bundle inside the dashboard app's stack —
65
- **Tailwind 3 + daisyUI 4**, no Tailwind 4 anywhere.
66
-
67
- Imports `@valiify/dashboard-ui/styles.css` as a plain stylesheet. `npm run check`
68
- renders the page in headless Chromium and asserts **computed styles**, which no
69
- manifest-based gate can see, in two directions and over three load paths:
70
-
71
- - **A — class-name collisions** (daisyUI's `btn` vs our `.vd-btn`), fixed by the `vd-` namespace.
72
- - **B — the host's element reset** defeating our component rules: Tailwind 3
73
- preflight's `* { border-width: 0 }`, `button { background-color: transparent }`,
74
- `input, textarea { … }`. Asserted per control — button, input, select, textarea.
75
- - Load paths: `@import` inside the host's `@tailwind` file (the host's Tailwind 3
76
- consumes our `@layer` blocks and emits the rules unlayered), a raw `<link>` to
77
- the bundle as shipped (layers intact — where 0.2.0 lost), and a lone `@import`
78
- through the host PostCSS (which Tailwind 3 refused for 0.2.0).
79
-
80
- The layer-defeat fingerprint the check names: the focus ring survives while the
81
- border, fill and padding do not, on the same control.
82
-
83
- ### [sveltekit-starter/](sveltekit-starter/) - The scoped-style test
84
-
85
- **Best for:** proving the prebuilt bundle against **SvelteKit + Svelte 5** component
86
- styles, which compile to unlayered CSS that Vite injects after the app stylesheet.
87
-
88
- No Tailwind. `npm run check` asserts three real components against the compiled
89
- selectors read off the served CSS: a `:global(button)` reset (the bundle must win),
90
- a scoped `button { }` (compiles to `button.svelte-hash`, 0,1,1 — the bundle
91
- **cannot** win; asserted as a loss so the contract's second clause stays pinned to a
92
- measurement), and the remedy `button:not([class*="vd-"])`.
93
-
94
- ## How to Choose
95
-
96
- | You have... | Use... |
97
- | ------------------------------- | -------------------------------------------------- |
98
- | Vite project | [vite-starter/](vite-starter/) |
99
- | React/Vue/Svelte/Next.js app | [vite-starter/](vite-starter/) |
100
- | webpack project | [postcss-starter/](postcss-starter/) (adapt config) |
101
- | PostCSS CLI setup | [postcss-starter/](postcss-starter/) |
102
- | Plain HTML, no build | [basic/](basic/) |
103
- | Email template or static export | [basic/](basic/) |
104
- | Tailwind 3 + daisyUI host | [daisyui-starter/](daisyui-starter/) — `./styles.css` |
105
- | SvelteKit host, no Tailwind | [sveltekit-starter/](sveltekit-starter/) — `./styles.css` |
106
-
107
- ## Testing an Example Locally
108
-
109
- All examples reference the library via `file:../..` (the parent repo), so you can test against local changes.
110
-
111
- **Vite starter:**
112
-
113
- ```bash
114
- cd examples/vite-starter
115
- npm install
116
- npm run dev
117
- ```
118
-
119
- **PostCSS starter:**
120
-
121
- ```bash
122
- cd examples/postcss-starter
123
- npm install
124
- npm run build
125
- npm run serve # or open index.html directly
126
- ```
127
-
128
- **Basic:**
129
-
130
- ```bash
131
- # From repo root
132
- npm run build # Build dist/index.css first
133
-
134
- # Then open in browser
135
- open examples/basic/index.html
136
- ```
137
-
138
- **Host checks (daisyUI, SvelteKit):**
139
-
140
- ```bash
141
- npm run build # dist/dashboard-ui.css first
142
- cd examples/daisyui-starter && npm install && npm run check
143
- cd examples/sveltekit-starter && npm install && npm run check
144
- ```
145
-
146
- ## What Each Example Shows
147
-
148
- ### vite-starter
149
-
150
- - **Vite config** - `@tailwindcss/vite` plugin
151
- - **CSS imports** - Correct order, no import from JS
152
- - **Icon sprite** - How to load and inline
153
- - **Interactive component** - Minimal dropdown with JavaScript
154
- - **Token utilities** - Uses `bg-approved`, `text-content-secondary`, etc.
155
- - **All component categories** - Buttons, inputs, alerts, chips, dropdown
156
-
157
- ### postcss-starter
158
-
159
- - **PostCSS config** - `@tailwindcss/postcss` plugin
160
- - **Build scripts** - Manual build vs watch
161
- - **No bundler** - Shows PostCSS CLI approach
162
- - **Static output** - index.html links to built CSS
163
-
164
- ### basic
165
-
166
- - **Prebuilt entry** - `dist/index.css` directly
167
- - **No build** - Plain HTML, open in browser
168
- - **CSS custom properties** - Uses `var(--color-*)` instead of utilities
169
- - **Inline styles** - Since no utilities, layout uses inline styles
170
-
171
- ## Common Issues
172
-
173
- ### "npm install" fails in an example
174
-
175
- The examples reference `@valiify/dashboard-ui` via `file:../..`, which expects the parent repo to exist. Make sure you've cloned/downloaded the full repo, not just the examples folder.
176
-
177
- ### Styles don't apply in vite-starter
178
-
179
- 1. Check `vite.config.js` has `@tailwindcss/vite` registered
180
- 2. Check `src/styles.css` imports in correct order (Tailwind first, then library)
181
- 3. Check `src/main.js` imports `./styles.css`, not the library directly
182
-
183
- ### Icons don't show
184
-
185
- The sprite needs to load. Check:
186
- 1. `src/main.js` has the sprite loading code
187
- 2. Browser DevTools Network tab shows `sprite.svg` loaded (not 404)
188
- 3. Inspect `<body>` - you should see a hidden `<div>` with `<svg>` inside
189
-
190
- ### postcss-starter build fails
191
-
192
- Make sure you ran `npm install` in the example directory, not just the parent repo. The example needs its own `@tailwindcss/postcss` dependency.
193
-
194
- ## Need More Help?
195
-
196
- - [GETTING_STARTED.md](../GETTING_STARTED.md) - Complete installation guide
197
- - [TROUBLESHOOTING.md](../TROUBLESHOOTING.md) - Debug common issues
198
- - [COMPONENTS.md](../COMPONENTS.md) - Full component markup reference
@@ -1,155 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Valiify Dashboard UI - Basic Example</title>
7
-
8
- <!--
9
- Loads only the built library. dist/index.css is self-contained: it carries
10
- the design tokens and every component class.
11
-
12
- Two things this example deliberately does NOT do:
13
- * No Tailwind CDN. The CDN ships v3, this library is built with v4, and
14
- mixing them produces conflicting output.
15
- * No Tailwind utility classes for layout. dist/index.css intentionally
16
- ships no utilities (see CLAUDE.md), so layout below uses plain inline
17
- styles. A real app generates utilities from its own Tailwind build.
18
-
19
- Run `npm run build` first, or this page will be unstyled.
20
- -->
21
- <!-- Fonts are not bundled into dist/index.css; load them yourself. -->
22
- <link
23
- rel="stylesheet"
24
- href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap"
25
- />
26
- <link rel="stylesheet" href="../../dist/index.css" />
27
-
28
- <style>
29
- body {
30
- min-height: 100vh;
31
- display: flex;
32
- align-items: center;
33
- justify-content: center;
34
- padding: 2rem;
35
- }
36
- </style>
37
- </head>
38
- <body>
39
- <!-- Example: Sign-in Form Card -->
40
- <div class="vd-card" style="max-width: 400px; width: 100%">
41
- <h1 class="vd-card-title" style="font-size: 24px; margin-bottom: 8px">
42
- Welcome Back
43
- </h1>
44
- <p class="vd-card-body" style="margin-bottom: 24px">
45
- Sign in to your Valiify Dashboard account.
46
- </p>
47
-
48
- <div style="display: flex; flex-direction: column; gap: 16px">
49
- <!-- Email Input -->
50
- <div>
51
- <label
52
- style="
53
- display: block;
54
- margin-bottom: 4px;
55
- font-size: 14px;
56
- font-weight: 500;
57
- color: var(--color-content-primary);
58
- "
59
- >
60
- Email
61
- </label>
62
- <input
63
- type="email"
64
- class="vd-input"
65
- placeholder="Enter your email"
66
- value="user@valiify.com"
67
- />
68
- </div>
69
-
70
- <!-- Password Input -->
71
- <div>
72
- <label
73
- style="
74
- display: block;
75
- margin-bottom: 4px;
76
- font-size: 14px;
77
- font-weight: 500;
78
- color: var(--color-content-primary);
79
- "
80
- >
81
- Password
82
- </label>
83
- <input
84
- type="password"
85
- class="vd-input"
86
- placeholder="Enter your password"
87
- />
88
- </div>
89
-
90
- <!-- Remember Me Checkbox (using HTML checkbox with custom label) -->
91
- <div style="display: flex; align-items: center; gap: 8px">
92
- <input
93
- type="checkbox"
94
- id="remember"
95
- style="width: 16px; height: 16px"
96
- />
97
- <label
98
- for="remember"
99
- style="
100
- font-size: 14px;
101
- color: var(--color-content-secondary);
102
- cursor: pointer;
103
- "
104
- >
105
- Remember me
106
- </label>
107
- </div>
108
-
109
- <!-- Action Buttons -->
110
- <div style="display: flex; gap: 8px; margin-top: 8px">
111
- <button
112
- class="vd-btn vd-btn-primary"
113
- style="flex: 1"
114
- onclick="alert('Sign in clicked')"
115
- >
116
- Sign In
117
- </button>
118
- <button class="vd-btn vd-btn-outline" onclick="alert('Cancel clicked')">
119
- Cancel
120
- </button>
121
- </div>
122
-
123
- <!-- Forgot Password Link -->
124
- <div style="text-align: center; margin-top: 8px">
125
- <a
126
- href="#"
127
- style="
128
- font-size: 14px;
129
- color: var(--color-primary);
130
- text-decoration: none;
131
- "
132
- >
133
- Forgot password?
134
- </a>
135
- </div>
136
- </div>
137
- </div>
138
-
139
- <!-- Demo Controls -->
140
- <div
141
- style="
142
- position: fixed;
143
- bottom: 20px;
144
- right: 20px;
145
- display: flex;
146
- flex-direction: column;
147
- gap: 8px;
148
- "
149
- >
150
- <button class="vd-btn vd-btn-sm vd-btn-outline" onclick="alert('This is a demo!')">
151
- View Demo Info
152
- </button>
153
- </div>
154
- </body>
155
- </html>
@@ -1,58 +0,0 @@
1
- # dashboard-ui + Tailwind 3 + daisyUI 4
2
-
3
- The host-collision test. The host runs **Tailwind 3 + daisyUI 4** — the dashboard
4
- app's stack — and imports `@valiify/dashboard-ui/styles.css`, the prebuilt bundle,
5
- as a plain stylesheet. No Tailwind 4 anywhere in this example; the bundle needs none.
6
-
7
- `npm run check` renders the page in headless Chromium and asserts **computed
8
- styles** in two directions. They are different bugs:
9
-
10
- - **A — class-name collisions.** daisyUI owns `.btn`, `.badge`, `.card`, `.input`,
11
- `.alert`, `.tab(s)`, `.modal`, `.toast`, `.tooltip`, `.avatar`, `.checkbox`,
12
- `.skeleton`, `.link`, `.divider`, `.step`, `.textarea`, `.dropdown` and
13
- `.breadcrumbs`; ours carry `vd-`. Each pair must keep its own look. The `vd-`
14
- namespace (0.2.0) is what fixes this.
15
- - **B — the host's element reset.** `@tailwind base` emits Tailwind 3's preflight,
16
- unlayered and after our import: `* { border-width: 0 }`, `button {
17
- background-color: transparent }`, `button, input, textarea { font-size: 100%;
18
- line-height: inherit; color: inherit; padding: 0 }`. A component rule inside a
19
- cascade layer loses to every one of those before specificity or source order is
20
- consulted. This is asserted per control — **button, input, select, textarea** —
21
- because those are the elements preflight touches. The library ships no select
22
- component (DropdownField is a `<button>`); the check asserts that from the
23
- manifest so the gap cannot go quiet when one lands.
24
-
25
- The previous revision of this check asserted only direction A, on one load path,
26
- and only properties preflight never touches. It passed 10/10 with the 0.2.0 layer
27
- defeat present.
28
-
29
- Three load paths, because the answer depends on it:
30
-
31
- | path | what the browser gets | layered bundle (0.2.0) |
32
- | --- | --- | --- |
33
- | `/` — `@import` inside the host's `@tailwind` file | Tailwind 3 consumes our `@layer components` blocks and re-emits the rules unlayered, after preflight | passes by accident |
34
- | `/linked.html` — `<link>` to the bundle after the host CSS | the file exactly as shipped, layers intact | **fails** — every direction-B assertion |
35
- | `src/only-import.css` — a lone `@import` through the host PostCSS | Tailwind 3 refuses any file carrying its layer names without a matching `@tailwind` directive | **refused** |
36
-
37
- The fingerprint of a layer defeat, which this check names when it sees it:
38
- preflight never touches `outline`, so the **focus ring survives while the border
39
- does not**, on the same control.
40
-
41
- The host body is deliberately set to 17px / line-height 2 / purple. Preflight makes
42
- form controls inherit those, so if our input rule loses the input visibly reads
43
- the host's values. With the library's own 13px there, the defeat would be
44
- invisible by coincidence.
45
-
46
- We import `@valiify/dashboard-ui/styles.css`, not `/source` and not `.`. That
47
- bundle carries **no preflight and no `html` rule** — the host owns its reset.
48
- Importing `.` (`dist/index.css`) here would be wrong: it ships full Preflight and
49
- would reset every element on the host's page.
50
-
51
- ```bash
52
- npm install
53
- npm run check
54
- npm run dev
55
- ```
56
-
57
- The `@import` must come first in `src/styles.css`; CSS discards an `@import` that
58
- follows other rules, and the symptom looks exactly like a namespace failure.
@@ -1,249 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * No-bleed assertion: dashboard-ui and Tailwind 3 + daisyUI 4 in one document.
4
- *
5
- * npm run check
6
- *
7
- * Every other gate in the library checks class NAMES against a manifest. This one
8
- * renders the bundle inside the host stack it was built for and measures COMPUTED
9
- * styles — the only way to observe either kind of collision, because neither
10
- * errors: a shared name silently hands one library's node the other's declarations,
11
- * and a cascade layer silently hands a host element reset the win over our class.
12
- *
13
- * Two directions, and they are different bugs:
14
- *
15
- * A class-name collision — daisyUI's `.btn` vs our `.vd-btn`. Fixed by the vd-
16
- * namespace (0.2.0). Asserted both ways.
17
- *
18
- * B host ELEMENT RESET defeating our component — Tailwind 3 preflight's
19
- * `* { border-width: 0 }`, `button { background-color: transparent }`,
20
- * `button, input, textarea { font-size: 100%; line-height: inherit; color:
21
- * inherit; padding: 0 }`. Unlayered, and it loads after our bundle. A component
22
- * rule inside `@layer components` loses to all of it regardless of specificity
23
- * or order; an unlayered one wins on specificity. The rename could not fix this
24
- * and did not. Asserted per control: button, input, select, textarea — the
25
- * elements preflight touches.
26
- *
27
- * The previous revision of this check asserted only direction A, on one load path,
28
- * and only properties preflight never touches (height, radius, the tooltip fill). It
29
- * passed 10/10 with the 0.2.0 layer defeat present. It could not fail on that bug.
30
- *
31
- * TWO LOAD PATHS, because the answer depends on it (measured, not assumed):
32
- *
33
- * / src/styles.css `@import`s the bundle INTO the host's Tailwind 3
34
- * stylesheet. Tailwind 3 treats `@layer components { }` as its own
35
- * directive, hoists the rules to its `@tailwind components` slot and
36
- * emits them UNLAYERED — after preflight. The host's pipeline strips
37
- * our layers by accident, so a layered bundle passes here.
38
- * /linked.html <link> to the bundle file after the host's compiled CSS. The bundle
39
- * reaches the browser exactly as shipped, layers intact. This is the
40
- * path a host that "never compiles our classes" is most likely to use,
41
- * and the one where a layered bundle loses.
42
- *
43
- * A third shape — the bundle as its own CSS file through the host's PostCSS with
44
- * no @tailwind directives — is probed and asserted: a bundle Tailwind 3 refuses to
45
- * process cannot be the host's own CSS entry.
46
- *
47
- * The fingerprint that identifies a layer defeat: preflight never touches
48
- * `outline`, so under a layer defeat the focus ring SURVIVES while the border,
49
- * fill and padding do not. The check reads both on every control and names the
50
- * signature when it sees it.
51
- */
52
- import { readFileSync } from "node:fs";
53
- import { chromium } from "playwright";
54
- import { createServer } from "vite";
55
-
56
- const RED = "\x1b[31m", GRN = "\x1b[32m", YEL = "\x1b[33m", DIM = "\x1b[2m", BOLD = "\x1b[1m", OFF = "\x1b[0m";
57
- // Vite runs every .css request through its pipeline — including the host's Tailwind 3,
58
- // which would consume (or refuse) a file carrying its layer names. So /bundle.css is
59
- // served RAW from disk: the bundle exactly as the package ships it.
60
- const PKG = new URL("./node_modules/@valiify/dashboard-ui/", import.meta.url);
61
- const BUNDLE = new URL("./dist/dashboard-ui.css", PKG);
62
- const rawBundle = {
63
- name: "serve-bundle-as-shipped",
64
- configureServer(s) {
65
- s.middlewares.use((req, res, next) => {
66
- if (req.url !== "/bundle.css") return next();
67
- res.setHeader("content-type", "text/css");
68
- res.end(readFileSync(BUNDLE));
69
- });
70
- },
71
- };
72
- const server = await createServer({ plugins: [rawBundle], server: { port: 5199 }, logLevel: "silent" });
73
- await server.listen();
74
- const browser = await chromium.launch();
75
- const page = await browser.newPage();
76
-
77
- const PAGES = [
78
- { path: "/", tag: "import", label: "@import through the host's Tailwind 3 pipeline (host strips our layers)" },
79
- { path: "/linked.html", tag: "link", label: "<link> to the bundle as shipped, after the host's CSS (layers intact)" },
80
- ];
81
-
82
- // Probe the third shape and record what the host pipeline does to a lone import.
83
- const probe = async (url) => {
84
- const css = await (await fetch(`http://localhost:5199${url}`, { headers: { accept: "text/css" } })).text();
85
- const err = css.match(/"message"\s*:\s*"((?:[^"\\]|\\.)*)"/);
86
- return { layers: (css.match(/@layer (components|base)\s*\{/g) || []).length, bytes: css.length, error: err ? JSON.parse(`"${err[1]}"`).split("\n")[0] : null };
87
- };
88
-
89
- const style = (sel, prop) =>
90
- page.evaluate(([s, p]) => {
91
- const el = document.querySelector(s);
92
- return el ? getComputedStyle(el).getPropertyValue(p) : null;
93
- }, [sel, prop]);
94
-
95
- /** The computed colour a token resolves to on this page — never a literal. */
96
- const token = (name) =>
97
- page.evaluate((n) => {
98
- const probe = document.createElement("span");
99
- probe.style.color = `var(${n})`;
100
- document.body.append(probe);
101
- const v = getComputedStyle(probe).color;
102
- probe.remove();
103
- return v;
104
- }, name);
105
-
106
- const results = [];
107
- const check = async (dir, label, sel, prop, assert, want, why) => {
108
- const got = await style(sel, prop);
109
- results.push({ dir, label, prop, got, want, ok: got !== null && assert(got), why });
110
- };
111
- const eq = (want) => (v) => v === want;
112
- const px = (want) => (v) => Math.abs(parseFloat(v) - want) < 0.5;
113
-
114
- // Let a transition settle before reading a colour or an outline (CLAUDE.md).
115
- const settle = () => page.waitForTimeout(400);
116
-
117
- for (const pg of PAGES) {
118
- await page.goto(`http://localhost:5199${pg.path}`, { waitUntil: "networkidle" });
119
- results.push({ dir: "", label: `── ${pg.label}`, heading: true, ok: true });
120
- // ── B host element reset vs our controls ────────────────────────────────────
121
- const primary = await token("--color-primary");
122
- const inkPrimary = await token("--color-content-primary");
123
- const contrast = await token("--color-content-contrast");
124
-
125
- // button — .vd-dropdown-field and .vd-btn-primary. The hairline is authored 0.5px;
126
- // Chrome computes it as 1px (CLAUDE.md, the hairline trap). 0px is the defeat.
127
- await check(`${pg.tag} B/button`, ".vd-dropdown-field keeps its hairline", "#vd-trigger", "border-top-width", px(1), "1px",
128
- "preflight `* { border-width: 0 }` won — the bundle's rule is inside a cascade layer");
129
- await check(`${pg.tag} B/button`, ".vd-dropdown-field keeps its 12px x-padding", "#vd-trigger", "padding-left", px(12), "12px",
130
- "preflight `button { padding: 0 }` won — layer defeat");
131
- await check(`${pg.tag} B/button`, ".vd-btn-primary keeps its Primary/Main fill", "#vd-btn-primary", "background-color", eq(primary), primary,
132
- "preflight `button { background-color: transparent }` won — layer defeat");
133
- await check(`${pg.tag} B/button`, ".vd-btn-primary keeps its Content/Contrast ink", "#vd-btn-primary", "color", eq(contrast), contrast,
134
- "preflight `button { color: inherit }` won — the label inherited the host's purple onto the blue fill");
135
- await check(`${pg.tag} B/button`, ".vd-btn-primary is 12.5px Action M, not the host body's 17px", "#vd-btn-primary", "font-size", px(12.5), "12.5px",
136
- "preflight `button { font-size: 100% }` won — layer defeat");
137
-
138
- // input — .vd-input inside .vd-input-field. The host body is 17px / 2 / purple.
139
- await check(`${pg.tag} B/input`, ".vd-input is 13px Body 1, not the host body's 17px", "#vd-input", "font-size", px(13), "13px",
140
- "preflight `input { font-size: 100% }` won — layer defeat (or the field wrapper lost its own type, which the input inherits)");
141
- await check(`${pg.tag} B/input`, ".vd-input line-height is 19.5px, not the host's 34px", "#vd-input", "line-height", px(19.5), "19.5px",
142
- "preflight `input { line-height: inherit }` won — layer defeat");
143
- await check(`${pg.tag} B/input`, ".vd-input ink is Content/Primary, not the host's purple", "#vd-input", "color", eq(inkPrimary), inkPrimary,
144
- "preflight `input { color: inherit }` won — layer defeat");
145
- await check(`${pg.tag} B/input`, ".vd-input-field keeps its hairline", "#vd-input-box", "border-top-width", px(1), "1px",
146
- "preflight `* { border-width: 0 }` won — layer defeat");
147
-
148
- // textarea — .vd-textarea inside .vd-textarea-field
149
- await check(`${pg.tag} B/textarea`, ".vd-textarea-field keeps its hairline", "#vd-textarea-box", "border-top-width", px(1), "1px",
150
- "preflight `* { border-width: 0 }` won — layer defeat");
151
- await check(`${pg.tag} B/textarea`, ".vd-textarea is 13px Body 1, not the host body's 17px", "#vd-textarea", "font-size", px(13), "13px",
152
- "preflight `textarea { font-size: 100% }` won — layer defeat");
153
- await check(`${pg.tag} B/textarea`, ".vd-textarea line-height is 19.5px, not the host's 34px", "#vd-textarea", "line-height", px(19.5), "19.5px",
154
- "preflight `textarea { line-height: inherit }` won — layer defeat");
155
- await check(`${pg.tag} B/textarea`, ".vd-textarea ink is Content/Primary, not the host's purple", "#vd-textarea", "color", eq(inkPrimary), inkPrimary,
156
- "preflight `textarea { color: inherit }` won — layer defeat");
157
-
158
- // select — the library ships no <select> component (DropdownField is a <button>), so
159
- // there is nothing preflight can defeat. Assert THAT from the manifest, so this line
160
- // fails the day one lands and demands a real assertion here instead of silently
161
- // leaving select uncovered.
162
- if (pg.tag === "import") {
163
- const manifest = JSON.parse(readFileSync(new URL("./class-manifest.json", PKG), "utf8"));
164
- const KNOWN_NOT_SELECTS = /^vd-(radio-select|segment-selector)(-|$)/; // a <label> radio and a <div> radiogroup frame
165
- const selectish = manifest.components.filter((n) => /select/.test(n) && !KNOWN_NOT_SELECTS.test(n));
166
- results.push({ dir: "import B/select", label: "no shipped component targets a native <select> (manifest scan)", prop: "manifest",
167
- got: selectish.length ? selectish.join(" ") : "none", want: "none", ok: selectish.length === 0,
168
- why: "a select component now exists — add its border/padding/font assertions to this check before shipping it" });
169
- }
170
-
171
- // The fingerprint — Tab through the three controls and read the ring where each
172
- // component paints it. Preflight never touches outline, so the ring survives even
173
- // when the border does not; seeing both on one control is the layer-defeat signature.
174
- await page.click("body", { position: { x: 1, y: 1 } });
175
- const rings = [
176
- ["button", "#vd-trigger", ".vd-dropdown-field:focus-visible ring"],
177
- ["input", "#vd-input-box", ".vd-input-field:focus-within ring"],
178
- ["textarea", "#vd-textarea-box", ".vd-textarea-field:focus-within ring"],
179
- ];
180
- for (const [ctrl, sel, label] of rings) {
181
- await page.keyboard.press("Tab");
182
- await settle();
183
- await check(`${pg.tag} B/${ctrl}`, `${label} is 2px`, sel, "outline-width", px(2), "2px",
184
- "the focus ring itself is missing — a different bug from the layer defeat");
185
- }
186
-
187
- // ── A class-name collisions, both ways ──────────────────────────────────────
188
- await check(`${pg.tag} A`, "daisyUI .btn keeps its own fill", "#daisy-btn", "background-color", (v) => v !== "rgba(0, 0, 0, 0)", "not transparent",
189
- "a transparent daisyUI button means our .vd-btn rules reached it");
190
- await check(`${pg.tag} A`, "daisyUI .badge is not our 15px circle", "#daisy-badge", "height", (v) => !px(15)(v), "≠15px",
191
- "15px is .vd-badge's height — ours bled into daisyUI's badge");
192
- await check(`${pg.tag} A`, "daisyUI .input is not our 35px field", "#daisy-input", "height", (v) => !px(35)(v), "≠35px",
193
- "35px is .vd-input-field's lg height");
194
- await check(`${pg.tag} A`, "daisyUI .alert keeps a fill", "#daisy-alert", "background-color", (v) => v !== "rgba(0, 0, 0, 0)", "not transparent",
195
- "a bare .vd-alert is transparent — ours reached the host's alert");
196
- await check(`${pg.tag} A`, "our .vd-btn is 28px (Figma medium), not daisyUI's 48px", "#vd-btn", "height", px(28), "28px",
197
- "daisyUI's .btn is 48px; if we read ~48 the host reached us");
198
- await check(`${pg.tag} A`, "our .vd-badge is a 15px circle", "#vd-badge", "height", px(15), "15px", "daisyUI's .badge is taller");
199
- await check(`${pg.tag} A`, "our .vd-card has our radius", "#vd-card", "border-radius", (v) => v !== "0px", "≠0px", "");
200
- await check(`${pg.tag} A`, "our .vd-tooltip is the dark surface", "#vd-tooltip", "background-color", (v) => v !== "rgba(0, 0, 0, 0)", "not transparent",
201
- "the only dark surface in the library");
202
-
203
- // ── the prefixed utility layer resolves, and the host's does too ─────────────
204
- await check(`${pg.tag} utils`, "vd:type-label-l-bold applies uppercase", "#vd-util", "text-transform", eq("uppercase"), "uppercase",
205
- "the methodology uses this utility precisely so nobody writes a bare vd:uppercase");
206
- await check(`${pg.tag} utils`, "host's bare `text-center` still works", "#host-util", "text-align", eq("center"), "center",
207
- "our prefix must not disturb the host's own utilities");
208
- }
209
-
210
- const probes = { styles: await probe("/src/styles.css"), linked: await probe("/bundle.css"), onlyImport: await probe("/src/only-import.css") };
211
- // The third load path, asserted: the bundle as the host's OWN CSS entry through
212
- // Tailwind 3's PostCSS. Tailwind 3 refuses a file carrying `@layer components {` or
213
- // `@layer base {` without the matching `@tailwind` directive — so a layered bundle
214
- // cannot be imported on its own at all.
215
- results.push({ dir: "", label: "── the bundle as a lone @import through the host's PostCSS (no @tailwind directives)", heading: true, ok: true });
216
- results.push({ dir: "lone import", label: "Tailwind 3 processes the file instead of refusing it", prop: "postcss",
217
- got: probes.onlyImport.error ? `REFUSED — ${probes.onlyImport.error}` : `${probes.onlyImport.bytes} B served`, want: "served", ok: !probes.onlyImport.error,
218
- why: "the bundle carries a Tailwind-3 layer name (`@layer components {` / `@layer base {`) with no matching @tailwind directive, so it cannot be the host's own CSS entry" });
219
-
220
- await browser.close();
221
- await server.close();
222
-
223
- console.log(`\n${BOLD}dashboard-ui inside Tailwind 3 + daisyUI 4${OFF}\n`);
224
- let dir = "";
225
- for (const r of results) {
226
- if (r.heading) { console.log(`\n ${BOLD}${r.label}${OFF}`); dir = ""; continue; }
227
- if (r.dir !== dir) { dir = r.dir; console.log(` ${DIM}${dir}${OFF}`); }
228
- console.log(` ${r.ok ? GRN + "PASS" : RED + "FAIL"}${OFF} ${r.label} ${DIM}${r.prop}=${r.got} (want ${r.want})${OFF}`);
229
- if (!r.ok && r.why) console.log(`${DIM} ${r.why}${OFF}`);
230
- }
231
-
232
- console.log(`\n ${DIM}what reached the browser:${OFF}`);
233
- console.log(` ${DIM} /src/styles.css import inside the @tailwind file → ${probes.styles.layers} native @layer components/base block(s), ${probes.styles.bytes} B${OFF}`);
234
- console.log(` ${DIM} /bundle.css <link>, served raw → ${probes.linked.layers} native @layer components/base block(s), ${probes.linked.bytes} B${OFF}`);
235
- console.log(` ${DIM} /src/only-import.css lone import through the pipeline → ${probes.onlyImport.error ? "REFUSED — " + probes.onlyImport.error : probes.onlyImport.layers + " native @layer components/base block(s), " + probes.onlyImport.bytes + " B"}${OFF}`);
236
-
237
- // Name the signature when it is present: ring intact, border gone, same control.
238
- for (const pg of PAGES) for (const ctrl of ["button", "input", "textarea"]) {
239
- const mine = results.filter((r) => r.dir === `${pg.tag} B/${ctrl}`);
240
- const ring = mine.find((r) => r.prop === "outline-width");
241
- const border = mine.find((r) => r.prop === "border-top-width");
242
- if (ring?.ok && border && !border.ok)
243
- console.log(`\n ${YEL}layer-defeat signature on ${ctrl} (${pg.tag}):${OFF} focus ring survives (${ring.got}) while the border is gone (${border.got}). Preflight never touches outline; it zeroes border-width on \`*\`. The component rule is inside a cascade layer.`);
244
- }
245
-
246
- const real = results.filter((r) => !r.heading);
247
- const failed = real.filter((r) => !r.ok);
248
- console.log(`\n ${failed.length ? RED : GRN}${real.length - failed.length}/${real.length} passed${OFF}\n`);
249
- process.exit(failed.length ? 1 : 0);