uswds-extended 3.14.0 → 3.14.2

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 (59) hide show
  1. package/README.md +5 -2
  2. package/gulpfile.js +4 -1
  3. package/package.json +5 -2
  4. package/packages/uswds-core/src/styles/functions/_index.scss +1 -0
  5. package/packages/uswds-core/src/styles/functions/theme/_index.scss +3 -0
  6. package/packages/uswds-core/src/styles/functions/theme/theme.scss +360 -0
  7. package/packages/uswds-utilities/src/styles/rules/_index.scss +37 -0
  8. package/packages/uswds-utilities/src/styles/rules/_package.scss +227 -1
  9. package/packages/uswds-utilities/src/styles/rules/accessibility.scss +91 -0
  10. package/packages/uswds-utilities/src/styles/rules/animation-keyframes.scss +167 -0
  11. package/packages/uswds-utilities/src/styles/rules/animation.scss +372 -0
  12. package/packages/uswds-utilities/src/styles/rules/aspect-ratio.scss +48 -0
  13. package/packages/uswds-utilities/src/styles/rules/backdrop-filters.scss +255 -0
  14. package/packages/uswds-utilities/src/styles/rules/background-extended.scss +171 -0
  15. package/packages/uswds-utilities/src/styles/rules/blend-modes.scss +72 -0
  16. package/packages/uswds-utilities/src/styles/rules/columns.scss +134 -0
  17. package/packages/uswds-utilities/src/styles/rules/container.scss +83 -0
  18. package/packages/uswds-utilities/src/styles/rules/content.scss +76 -0
  19. package/packages/uswds-utilities/src/styles/rules/divide.scss +128 -0
  20. package/packages/uswds-utilities/src/styles/rules/effects-extended.scss +246 -0
  21. package/packages/uswds-utilities/src/styles/rules/filters.scss +247 -0
  22. package/packages/uswds-utilities/src/styles/rules/flex-extended.scss +133 -0
  23. package/packages/uswds-utilities/src/styles/rules/gradients.scss +121 -0
  24. package/packages/uswds-utilities/src/styles/rules/grid-extended.scss +188 -0
  25. package/packages/uswds-utilities/src/styles/rules/interactivity-extended.scss +236 -0
  26. package/packages/uswds-utilities/src/styles/rules/interactivity.scss +300 -0
  27. package/packages/uswds-utilities/src/styles/rules/isolation.scss +40 -0
  28. package/packages/uswds-utilities/src/styles/rules/logical-properties.scss +444 -0
  29. package/packages/uswds-utilities/src/styles/rules/object-fit.scss +66 -0
  30. package/packages/uswds-utilities/src/styles/rules/outline-extended.scss +61 -0
  31. package/packages/uswds-utilities/src/styles/rules/overscroll.scss +44 -0
  32. package/packages/uswds-utilities/src/styles/rules/place.scss +88 -0
  33. package/packages/uswds-utilities/src/styles/rules/ring-base.scss +119 -0
  34. package/packages/uswds-utilities/src/styles/rules/ring.scss +153 -0
  35. package/packages/uswds-utilities/src/styles/rules/size.scss +117 -0
  36. package/packages/uswds-utilities/src/styles/rules/space.scss +93 -0
  37. package/packages/uswds-utilities/src/styles/rules/svg.scss +144 -0
  38. package/packages/uswds-utilities/src/styles/rules/tables.scss +126 -0
  39. package/packages/uswds-utilities/src/styles/rules/transforms-extended.scss +128 -0
  40. package/packages/uswds-utilities/src/styles/rules/transition-extended.scss +34 -0
  41. package/packages/uswds-utilities/src/styles/rules/typography-advanced.scss +163 -0
  42. package/packages/uswds-utilities/src/styles/rules/typography-extras.scss +230 -0
  43. package/packages/uswds-utilities/src/styles/rules/visibility.scss +37 -0
  44. package/scripts/postinstall.js +22 -0
  45. package/tasks/jit/generator.js +330 -0
  46. package/tasks/jit/index.js +161 -0
  47. package/tasks/jit/scanner.js +274 -0
  48. package/tasks/jit/utility-definitions.js +1586 -0
  49. package/tasks/jit-scanner.js +224 -0
  50. package/tasks/postcss-plugins/container-queries.js +108 -0
  51. package/tasks/postcss-plugins/css-layers.js +177 -0
  52. package/tasks/postcss-plugins/dark-mode.js +121 -0
  53. package/tasks/sass.js +74 -4
  54. package/tasks/watch.js +24 -3
  55. package/uswds.config.js +59 -0
  56. package/dist/css/uswds.css +0 -52678
  57. package/dist/css/uswds.min.css +0 -4
  58. package/dist/css/uswds.min.css.map +0 -1
  59. package/uswds-extended.config.js +0 -59
package/README.md CHANGED
@@ -27,6 +27,9 @@ Based on the [U.S. Web Design System (USWDS)](https://designsystem.digital.gov),
27
27
 
28
28
  ```bash
29
29
  npm install uswds-extended
30
+
31
+ # Or as a drop-in replacement for @uswds/uswds:
32
+ npm install uswds@npm:uswds-extended
30
33
  ```
31
34
 
32
35
  ### Usage
@@ -53,7 +56,7 @@ npm install uswds-extended
53
56
  <h2 class="group-hover:text-primary">Hover the card</h2>
54
57
  </div>
55
58
 
56
- <!-- Arbitrary values (configure in uswds-extended.config.js) -->
59
+ <!-- Arbitrary values (configure in uswds.config.js) -->
57
60
  <div class="w-[137px] h-[calc(100vh-60px)]">Custom size</div>
58
61
  ```
59
62
 
@@ -80,7 +83,7 @@ npx gulp reportPurgeStats
80
83
 
81
84
  ## Configuration
82
85
 
83
- **`uswds-extended.config.js`** - Configure arbitrary values and opacity steps:
86
+ **`uswds.config.js`** - Configure arbitrary values and opacity steps:
84
87
 
85
88
  ```js
86
89
  module.exports = {
package/gulpfile.js CHANGED
@@ -13,10 +13,11 @@ const { lintSass, typecheck } = require("./tasks/lint");
13
13
  const { build } = require("./tasks/build");
14
14
  const { release } = require("./tasks/release");
15
15
  const { watch } = require("./tasks/watch");
16
- const { compileSass } = require("./tasks/sass");
16
+ const { compileSass, jitScan } = require("./tasks/sass");
17
17
  const { compileCustomCSS } = require("./tasks/custom-css");
18
18
  const { purgeSass, reportPurgeStats } = require("./tasks/purge");
19
19
  const { cleanDist } = require("./tasks/clean");
20
+ const { gulpJIT } = require("./tasks/jit");
20
21
 
21
22
  /**
22
23
  * *Flags*
@@ -63,9 +64,11 @@ exports.test = series(
63
64
  exports.buildSpriteStandalone = buildSpriteStandalone;
64
65
  exports.buildSprite = buildSprite;
65
66
  exports.compileSass = compileSass;
67
+ exports.jitScan = jitScan;
66
68
  exports.compileCustomCSS = compileCustomCSS;
67
69
  exports.purgeSass = purgeSass;
68
70
  exports.reportPurgeStats = reportPurgeStats;
71
+ exports.jitBuild = gulpJIT; // Full JIT mode - generates only used utilities
69
72
  exports.buildSass = series(lintSass, compileSass);
70
73
  exports.buildJS = series(typeCheck, compileJS);
71
74
  exports.buildUSWDS = build;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uswds-extended",
3
- "version": "3.14.0",
3
+ "version": "3.14.2",
4
4
  "description": "USWDS with Tailwind-style utilities: color opacity, arbitrary values, @apply directive, and more",
5
5
  "engines": {
6
6
  "node": ">= 18"
@@ -25,6 +25,7 @@
25
25
  ".storybook",
26
26
  "dist",
27
27
  "packages",
28
+ "scripts",
28
29
  "src",
29
30
  "tasks",
30
31
  ".browserslistrc",
@@ -34,7 +35,7 @@
34
35
  "vite.config.js",
35
36
  "vite.config.banner.cdn.js",
36
37
  "vite.config.components.js",
37
- "uswds-extended.config.js",
38
+ "uswds.config.js",
38
39
  "purgecss.config.js"
39
40
  ],
40
41
  "module": "./dist/js/uswds.min.js",
@@ -64,6 +65,7 @@
64
65
  "config": "src/utils/test/.mocharc.json"
65
66
  },
66
67
  "scripts": {
68
+ "postinstall": "node scripts/postinstall.js",
67
69
  "build": "gulp && npm run build:web-components",
68
70
  "build:web-components": "vite build --config='./vite.config.banner.cdn.js'",
69
71
  "lint": "npm run lint:js && npm run lint:sass",
@@ -163,6 +165,7 @@
163
165
  "eslint-plugin-no-unsanitized": "4.1.2",
164
166
  "fancy-log": "2.0.0",
165
167
  "file-loader": "6.2.0",
168
+ "glob": "^13.0.0",
166
169
  "gulp": "4.0.2",
167
170
  "gulp-concat": "^2.6.1",
168
171
  "gulp-mocha": "9.0.0",
@@ -4,5 +4,6 @@
4
4
  @forward "grid";
5
5
  @forward "math";
6
6
  @forward "output";
7
+ @forward "theme";
7
8
  @forward "units";
8
9
  @forward "utilities";
@@ -0,0 +1,3 @@
1
+ // Theme functions - Tailwind-style token access
2
+ // All helper functions are prefixed with theme- to avoid conflicts with existing USWDS functions
3
+ @forward "theme" show theme, theme-spacing, theme-font-size, theme-radius, theme-shadow, theme-z, theme-breakpoint, theme-duration, theme-easing;
@@ -0,0 +1,360 @@
1
+ // theme() - Unified token access function
2
+ // Similar to Tailwind's theme() function
3
+ //
4
+ // Usage:
5
+ // theme('colors.primary') -> #005ea2
6
+ // theme('colors.primary-light') -> #73b3e7
7
+ // theme('spacing.2') -> 1rem
8
+ // theme('spacing.4') -> 2rem
9
+ // theme('font-size.lg') -> 1.22rem
10
+ // theme('font-weight.bold') -> 700
11
+ // theme('border-radius.lg') -> 0.5rem
12
+ // theme('z-index.500') -> 500
13
+ // theme('breakpoints.tablet') -> 40em
14
+
15
+ @use "sass:list";
16
+ @use "sass:map";
17
+ @use "sass:meta";
18
+ @use "sass:string";
19
+ @use "../../functions/general/str-split" as *;
20
+ @use "../../functions/utilities/color" as *;
21
+ @use "../../functions/units/units" as *;
22
+ @use "../../tokens/color/shortcodes-color-all" as *;
23
+ @use "../../variables/project-spacing" as spacing-vars;
24
+
25
+ // Token registry - maps token paths to their values
26
+ // This is the central registry of all available tokens
27
+
28
+ $-font-sizes: (
29
+ "3xs": 0.69rem,
30
+ "2xs": 0.79rem,
31
+ "xs": 0.87rem,
32
+ "sm": 0.93rem,
33
+ "md": 1rem,
34
+ "lg": 1.22rem,
35
+ "xl": 1.34rem,
36
+ "2xl": 1.49rem,
37
+ "3xl": 1.76rem,
38
+ );
39
+
40
+ $-font-weights: (
41
+ "thin": 100,
42
+ "light": 300,
43
+ "normal": 400,
44
+ "medium": 500,
45
+ "semibold": 600,
46
+ "bold": 700,
47
+ "black": 900,
48
+ );
49
+
50
+ $-line-heights: (
51
+ "1": 1,
52
+ "2": 1.15,
53
+ "3": 1.35,
54
+ "4": 1.5,
55
+ "5": 1.62,
56
+ "6": 1.75,
57
+ );
58
+
59
+ $-letter-spacing: (
60
+ "tightest": -0.03em,
61
+ "tighter": -0.02em,
62
+ "tight": -0.01em,
63
+ "auto": initial,
64
+ "wide": 0.025em,
65
+ "wider": 0.05em,
66
+ "widest": 0.1em,
67
+ );
68
+
69
+ $-border-radius: (
70
+ "0": 0,
71
+ "sm": 0.125rem,
72
+ "md": 0.25rem,
73
+ "lg": 0.5rem,
74
+ "xl": 1rem,
75
+ "2xl": 1.5rem,
76
+ "full": 9999px,
77
+ "pill": 99rem,
78
+ );
79
+
80
+ $-border-widths: (
81
+ "0": 0,
82
+ "1px": 1px,
83
+ "2px": 2px,
84
+ "05": 0.25rem,
85
+ "1": 0.5rem,
86
+ );
87
+
88
+ $-z-index: (
89
+ "auto": auto,
90
+ "0": 0,
91
+ "100": 100,
92
+ "200": 200,
93
+ "300": 300,
94
+ "400": 400,
95
+ "500": 500,
96
+ );
97
+
98
+ $-opacity: (
99
+ "0": 0,
100
+ "5": 0.05,
101
+ "10": 0.1,
102
+ "20": 0.2,
103
+ "25": 0.25,
104
+ "30": 0.3,
105
+ "40": 0.4,
106
+ "50": 0.5,
107
+ "60": 0.6,
108
+ "70": 0.7,
109
+ "75": 0.75,
110
+ "80": 0.8,
111
+ "90": 0.9,
112
+ "95": 0.95,
113
+ "100": 1,
114
+ );
115
+
116
+ $-shadows: (
117
+ "none": none,
118
+ "1": 0 1px 4px 0 rgba(0, 0, 0, 0.1),
119
+ "2": 0 4px 8px 0 rgba(0, 0, 0, 0.1),
120
+ "3": 0 8px 16px 0 rgba(0, 0, 0, 0.1),
121
+ "4": 0 12px 24px 0 rgba(0, 0, 0, 0.1),
122
+ "5": 0 16px 32px 0 rgba(0, 0, 0, 0.1),
123
+ );
124
+
125
+ $-breakpoints: (
126
+ "mobile-lg": 30em,
127
+ "tablet": 40em,
128
+ "tablet-lg": 55em,
129
+ "desktop": 64em,
130
+ "desktop-lg": 75em,
131
+ "widescreen": 87.5em,
132
+ );
133
+
134
+ $-transitions: (
135
+ "none": none,
136
+ "all": all 150ms ease-in-out,
137
+ "colors": color 150ms ease-in-out#{","} background-color 150ms ease-in-out#{","} border-color 150ms ease-in-out,
138
+ "opacity": opacity 150ms ease-in-out,
139
+ "shadow": box-shadow 150ms ease-in-out,
140
+ "transform": transform 150ms ease-in-out,
141
+ );
142
+
143
+ $-duration: (
144
+ "75": 75ms,
145
+ "100": 100ms,
146
+ "150": 150ms,
147
+ "200": 200ms,
148
+ "300": 300ms,
149
+ "500": 500ms,
150
+ "700": 700ms,
151
+ "1000": 1000ms,
152
+ );
153
+
154
+ $-easing: (
155
+ "linear": linear,
156
+ "ease": ease,
157
+ "ease-in": ease-in,
158
+ "ease-out": ease-out,
159
+ "ease-in-out": ease-in-out,
160
+ );
161
+
162
+ // Main theme function
163
+ @function theme($path) {
164
+ // Parse the path (e.g., "colors.primary" or "spacing.2")
165
+ $parts: str-split($path, ".");
166
+ $category: list.nth($parts, 1);
167
+
168
+ // Get the key (everything after the first dot)
169
+ $key: null;
170
+ @if list.length($parts) > 1 {
171
+ $key: list.nth($parts, 2);
172
+ // Handle nested keys like "colors.primary.light"
173
+ @if list.length($parts) > 2 {
174
+ @for $i from 3 through list.length($parts) {
175
+ $key: $key + "-" + list.nth($parts, $i);
176
+ }
177
+ }
178
+ }
179
+
180
+ // Route to appropriate token map
181
+ @if $category == "colors" or $category == "color" {
182
+ @if $key == null {
183
+ @error "theme(): color requires a key, e.g., theme('colors.primary')";
184
+ }
185
+ @return color($key);
186
+ }
187
+
188
+ @if $category == "spacing" or $category == "space" {
189
+ @if $key == null {
190
+ @error "theme(): spacing requires a key, e.g., theme('spacing.2')";
191
+ }
192
+ @return units($key);
193
+ }
194
+
195
+ @if $category == "font-size" or $category == "fontSize" {
196
+ @if $key == null {
197
+ @return $-font-sizes;
198
+ }
199
+ @if not map.has-key($-font-sizes, $key) {
200
+ @error "theme(): Unknown font-size '#{$key}'. Available: #{map.keys($-font-sizes)}";
201
+ }
202
+ @return map.get($-font-sizes, $key);
203
+ }
204
+
205
+ @if $category == "font-weight" or $category == "fontWeight" {
206
+ @if $key == null {
207
+ @return $-font-weights;
208
+ }
209
+ @if not map.has-key($-font-weights, $key) {
210
+ @error "theme(): Unknown font-weight '#{$key}'. Available: #{map.keys($-font-weights)}";
211
+ }
212
+ @return map.get($-font-weights, $key);
213
+ }
214
+
215
+ @if $category == "line-height" or $category == "lineHeight" {
216
+ @if $key == null {
217
+ @return $-line-heights;
218
+ }
219
+ @if not map.has-key($-line-heights, $key) {
220
+ @error "theme(): Unknown line-height '#{$key}'. Available: #{map.keys($-line-heights)}";
221
+ }
222
+ @return map.get($-line-heights, $key);
223
+ }
224
+
225
+ @if $category == "letter-spacing" or $category == "letterSpacing" {
226
+ @if $key == null {
227
+ @return $-letter-spacing;
228
+ }
229
+ @if not map.has-key($-letter-spacing, $key) {
230
+ @error "theme(): Unknown letter-spacing '#{$key}'. Available: #{map.keys($-letter-spacing)}";
231
+ }
232
+ @return map.get($-letter-spacing, $key);
233
+ }
234
+
235
+ @if $category == "border-radius" or $category == "borderRadius" or $category == "radius" {
236
+ @if $key == null {
237
+ @return $-border-radius;
238
+ }
239
+ @if not map.has-key($-border-radius, $key) {
240
+ @error "theme(): Unknown border-radius '#{$key}'. Available: #{map.keys($-border-radius)}";
241
+ }
242
+ @return map.get($-border-radius, $key);
243
+ }
244
+
245
+ @if $category == "border-width" or $category == "borderWidth" {
246
+ @if $key == null {
247
+ @return $-border-widths;
248
+ }
249
+ @if not map.has-key($-border-widths, $key) {
250
+ @error "theme(): Unknown border-width '#{$key}'. Available: #{map.keys($-border-widths)}";
251
+ }
252
+ @return map.get($-border-widths, $key);
253
+ }
254
+
255
+ @if $category == "z-index" or $category == "zIndex" {
256
+ @if $key == null {
257
+ @return $-z-index;
258
+ }
259
+ @if not map.has-key($-z-index, $key) {
260
+ @error "theme(): Unknown z-index '#{$key}'. Available: #{map.keys($-z-index)}";
261
+ }
262
+ @return map.get($-z-index, $key);
263
+ }
264
+
265
+ @if $category == "opacity" {
266
+ @if $key == null {
267
+ @return $-opacity;
268
+ }
269
+ @if not map.has-key($-opacity, $key) {
270
+ @error "theme(): Unknown opacity '#{$key}'. Available: #{map.keys($-opacity)}";
271
+ }
272
+ @return map.get($-opacity, $key);
273
+ }
274
+
275
+ @if $category == "shadow" or $category == "shadows" or $category == "boxShadow" {
276
+ @if $key == null {
277
+ @return $-shadows;
278
+ }
279
+ @if not map.has-key($-shadows, $key) {
280
+ @error "theme(): Unknown shadow '#{$key}'. Available: #{map.keys($-shadows)}";
281
+ }
282
+ @return map.get($-shadows, $key);
283
+ }
284
+
285
+ @if $category == "breakpoints" or $category == "screens" {
286
+ @if $key == null {
287
+ @return $-breakpoints;
288
+ }
289
+ @if not map.has-key($-breakpoints, $key) {
290
+ @error "theme(): Unknown breakpoint '#{$key}'. Available: #{map.keys($-breakpoints)}";
291
+ }
292
+ @return map.get($-breakpoints, $key);
293
+ }
294
+
295
+ @if $category == "transition" or $category == "transitions" {
296
+ @if $key == null {
297
+ @return $-transitions;
298
+ }
299
+ @if not map.has-key($-transitions, $key) {
300
+ @error "theme(): Unknown transition '#{$key}'. Available: #{map.keys($-transitions)}";
301
+ }
302
+ @return map.get($-transitions, $key);
303
+ }
304
+
305
+ @if $category == "duration" {
306
+ @if $key == null {
307
+ @return $-duration;
308
+ }
309
+ @if not map.has-key($-duration, $key) {
310
+ @error "theme(): Unknown duration '#{$key}'. Available: #{map.keys($-duration)}";
311
+ }
312
+ @return map.get($-duration, $key);
313
+ }
314
+
315
+ @if $category == "easing" or $category == "timing" {
316
+ @if $key == null {
317
+ @return $-easing;
318
+ }
319
+ @if not map.has-key($-easing, $key) {
320
+ @error "theme(): Unknown easing '#{$key}'. Available: #{map.keys($-easing)}";
321
+ }
322
+ @return map.get($-easing, $key);
323
+ }
324
+
325
+ @error "theme(): Unknown category '#{$category}'. Available categories: colors, spacing, font-size, font-weight, line-height, letter-spacing, border-radius, border-width, z-index, opacity, shadow, breakpoints, transition, duration, easing";
326
+ }
327
+
328
+ // Alias functions for common token access
329
+ // All prefixed with theme- to avoid conflicts with existing USWDS functions
330
+ @function theme-spacing($key) {
331
+ @return theme("spacing.#{$key}");
332
+ }
333
+
334
+ @function theme-font-size($key) {
335
+ @return theme("font-size.#{$key}");
336
+ }
337
+
338
+ @function theme-radius($key) {
339
+ @return theme("border-radius.#{$key}");
340
+ }
341
+
342
+ @function theme-shadow($key) {
343
+ @return theme("shadow.#{$key}");
344
+ }
345
+
346
+ @function theme-z($key) {
347
+ @return theme("z-index.#{$key}");
348
+ }
349
+
350
+ @function theme-breakpoint($key) {
351
+ @return theme("breakpoints.#{$key}");
352
+ }
353
+
354
+ @function theme-duration($key) {
355
+ @return theme("duration.#{$key}");
356
+ }
357
+
358
+ @function theme-easing($key) {
359
+ @return theme("easing.#{$key}");
360
+ }
@@ -57,3 +57,40 @@
57
57
  @forward "whitespace";
58
58
  @forward "width";
59
59
  @forward "z-index";
60
+
61
+ // Extended utilities
62
+ @forward "accessibility";
63
+ @forward "animation";
64
+ @forward "animation-keyframes";
65
+ @forward "aspect-ratio";
66
+ @forward "backdrop-filters";
67
+ @forward "background-extended";
68
+ @forward "blend-modes";
69
+ @forward "columns";
70
+ @forward "container";
71
+ @forward "content";
72
+ @forward "divide";
73
+ @forward "effects-extended";
74
+ @forward "filters";
75
+ @forward "flex-extended";
76
+ @forward "gradients";
77
+ @forward "grid-extended";
78
+ @forward "interactivity";
79
+ @forward "interactivity-extended";
80
+ @forward "isolation";
81
+ @forward "logical-properties";
82
+ @forward "object-fit";
83
+ @forward "outline-extended";
84
+ @forward "overscroll";
85
+ @forward "place";
86
+ @forward "ring";
87
+ @forward "ring-base";
88
+ @forward "size";
89
+ @forward "space";
90
+ @forward "svg";
91
+ @forward "tables";
92
+ @forward "transforms-extended";
93
+ @forward "transition-extended";
94
+ @forward "typography-advanced";
95
+ @forward "typography-extras";
96
+ @forward "visibility";