@iress-oss/ids-theme-preset 6.0.0-alpha.1 → 6.0.0-alpha.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.
package/README.md CHANGED
@@ -69,6 +69,7 @@ import idsPreset from '@iress-oss/ids-theme-preset';
69
69
  import {
70
70
  codegenPrepareHook,
71
71
  cssgenDoneHook,
72
+ staticCssStripHook,
72
73
  } from '@iress-oss/ids-theme-preset/hooks';
73
74
 
74
75
  export default defineConfig({
@@ -77,11 +78,21 @@ export default defineConfig({
77
78
  outdir: './styled-system',
78
79
  hooks: {
79
80
  'codegen:prepare': ({ artifacts }) => codegenPrepareHook(artifacts),
80
- 'cssgen:done': ({ artifact, content }) => cssgenDoneHook(artifact, content),
81
+ 'cssgen:done': ({ artifact, content }) => {
82
+ // Chain both cleanup hooks: strip alias classes first, then IDS static CSS.
83
+ const afterAliasStrip = cssgenDoneHook(artifact, content) ?? content;
84
+ return staticCssStripHook(artifact, afterAliasStrip) ?? afterAliasStrip;
85
+ },
81
86
  },
82
87
  });
83
88
  ```
84
89
 
90
+ | Hook | Description |
91
+ |---|---|
92
+ | `codegenPrepareHook` | Injects spacing alias resolution into the Panda CSS runtime so that `gap="sm"` reuses the canonical token class instead of generating a duplicate alias class. |
93
+ | `cssgenDoneHook` | Strips leftover spacing alias utility classes and `:root` variable definitions from the final CSS. |
94
+ | `staticCssStripHook` | Strips IDS static-CSS utility classes (spacing tokens, textStyle, custom utilities, colour tokens, etc.) from the generated CSS. Used by `createMinimalConfig` to prevent duplicating CSS that is already shipped by `@iress-oss/ids-components` style.css. |
95
+
85
96
  ## Exports
86
97
 
87
98
  | Export path | Description |
@@ -68,8 +68,27 @@ function cssgenDoneHook(artifact, content) {
68
68
  return css;
69
69
  }
70
70
 
71
+ // src/hooks/staticCssStripHook.ts
72
+ function staticCssStripHook(artifact, content) {
73
+ if (artifact !== "styles.css") return;
74
+ let css = content;
75
+ css = css.replace(/\.(?:[a-z]+\\:)?[a-z]+_-?spacing\\\.\d+\{[^}]*\}/g, "");
76
+ css = css.replace(/\.textStyle_typography[^}]+\}/g, "");
77
+ css = css.replace(
78
+ /\.(?:[a-z]+\\:)?(focusable|span|offset|gutter|noGutter|scrollable|stretch|fha|fva)_[^\s{]+\{[^}]*\}/g,
79
+ ""
80
+ );
81
+ css = css.replace(/(?<!\()\.(?:[a-z]+\\:)?sr_[^\s{]+\{[^}]*\}/g, "");
82
+ css = css.replace(/\.hide_(xs|sm|md|lg|xl|xxl)\{[^}]*\}/g, "");
83
+ css = css.replace(/\.bg_colour\\\.[^\s{]+\{[^}]*\}/g, "");
84
+ css = css.replace(/\.c_colour\\\.[^\s{]+\{[^}]*\}/g, "");
85
+ css = css.replace(/\.rounded_radius\\\.[^\s{]+\{[^}]*\}/g, "");
86
+ return css;
87
+ }
88
+
71
89
  export {
72
90
  SPACING_ALIAS_MAP,
73
91
  codegenPrepareHook,
74
- cssgenDoneHook
92
+ cssgenDoneHook,
93
+ staticCssStripHook
75
94
  };
@@ -1839,6 +1839,7 @@ var selectChevron = defineUtility4({
1839
1839
  values: { type: "boolean" },
1840
1840
  transform: (value) => {
1841
1841
  return {
1842
+ paddingInlineEnd: `calc(${cssVars13.spacing[2]} + ${sizes["chevron.select"].value})`,
1842
1843
  "&:after": {
1843
1844
  content: `''`,
1844
1845
  width: sizes["chevron.select"].value,
package/dist/config.d.ts CHANGED
@@ -7,6 +7,14 @@ import { Config } from '@pandacss/dev';
7
7
  * Includes the IDS theme preset and disables preflight, globalCss, and
8
8
  * staticCss to avoid duplicating CSS already shipped by IDS components.
9
9
  * Panda will still generate CSS for utilities your code actually uses.
10
+ *
11
+ * The `cssgen:done` hook runs two passes over the generated styles.css:
12
+ * 1. `cssgenDoneHook` — strips spacing alias classes (e.g. `gap_sm`) that
13
+ * were generated before runtime alias resolution could redirect them to the
14
+ * canonical token class.
15
+ * 2. `staticCssStripHook` — strips IDS static-CSS utility classes that are
16
+ * already shipped in `@iress-oss/ids-components` style.css, preventing
17
+ * duplication in the consumer's own bundle.
10
18
  */
11
19
  declare function createMinimalConfig(): Pick<Config, 'presets' | 'preflight' | 'staticCss' | 'globalCss' | 'hooks'>;
12
20
 
package/dist/config.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  src_default
3
- } from "./chunk-6T7NHIQQ.js";
3
+ } from "./chunk-VMF4RPCS.js";
4
4
  import "./chunk-OGLE65KO.js";
5
5
  import {
6
6
  codegenPrepareHook,
7
- cssgenDoneHook
8
- } from "./chunk-V3SF6JCX.js";
7
+ cssgenDoneHook,
8
+ staticCssStripHook
9
+ } from "./chunk-MOGGW7LB.js";
9
10
 
10
11
  // src/createMinimalConfig.ts
11
12
  function createMinimalConfig() {
@@ -16,7 +17,10 @@ function createMinimalConfig() {
16
17
  globalCss: {},
17
18
  hooks: {
18
19
  "codegen:prepare": ({ artifacts }) => codegenPrepareHook(artifacts),
19
- "cssgen:done": ({ artifact, content }) => cssgenDoneHook(artifact, content)
20
+ "cssgen:done": ({ artifact, content }) => {
21
+ const afterAliasStrip = cssgenDoneHook(artifact, content) ?? content;
22
+ return staticCssStripHook(artifact, afterAliasStrip) ?? afterAliasStrip;
23
+ }
20
24
  }
21
25
  };
22
26
  }
@@ -14,10 +14,33 @@ declare function codegenPrepareHook(artifacts: Artifact[]): Artifact[] | void;
14
14
  */
15
15
  declare function cssgenDoneHook(artifact: string, content: string): string | void;
16
16
 
17
+ /**
18
+ * Strips CSS rules generated by the IDS preset's staticCss configuration from
19
+ * the consumer's bundle. These classes are already shipped by IDS via
20
+ * @iress-oss/ids-components style.css, so duplicating them in the consumer's
21
+ * bundle only adds unnecessary weight.
22
+ *
23
+ * Used in createMinimalConfig() alongside cssgenDoneHook to ensure the
24
+ * consumer's Panda output only contains CSS that is genuinely unique to their
25
+ * application.
26
+ *
27
+ * Pattern coverage:
28
+ * - Canonical spacing utility classes (gap, margin, padding, etc.) for IDS
29
+ * spacing tokens, including responsive breakpoint-prefixed variants and
30
+ * negative margin values.
31
+ * - IDS typography composition classes (textStyle_typography.*).
32
+ * - IDS-specific custom utility classes: focusable, span, offset, gutter,
33
+ * noGutter, scrollable, stretch, flexHorizontalAlign (fha),
34
+ * flexVerticalAlign (fva), srOnly (sr), and responsive visibility (hide_*).
35
+ * - IDS colour and radius token classes (bg_colour.*, c_colour.*,
36
+ * rounded_radius.*).
37
+ */
38
+ declare function staticCssStripHook(artifact: string, content: string): string | void;
39
+
17
40
  /**
18
41
  * Derives the alias-to-canonical spacing map from the ids-tokens schema.
19
42
  * e.g. { none: 'spacing.0', xs: 'spacing.1', sm: 'spacing.2', ... }
20
43
  */
21
44
  declare const SPACING_ALIAS_MAP: Record<string, string>;
22
45
 
23
- export { SPACING_ALIAS_MAP, codegenPrepareHook, cssgenDoneHook };
46
+ export { SPACING_ALIAS_MAP, codegenPrepareHook, cssgenDoneHook, staticCssStripHook };
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  SPACING_ALIAS_MAP,
3
3
  codegenPrepareHook,
4
- cssgenDoneHook
5
- } from "../chunk-V3SF6JCX.js";
4
+ cssgenDoneHook,
5
+ staticCssStripHook
6
+ } from "../chunk-MOGGW7LB.js";
6
7
  export {
7
8
  SPACING_ALIAS_MAP,
8
9
  codegenPrepareHook,
9
- cssgenDoneHook
10
+ cssgenDoneHook,
11
+ staticCssStripHook
10
12
  };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  idsThemePreset,
3
3
  src_default
4
- } from "./chunk-6T7NHIQQ.js";
4
+ } from "./chunk-VMF4RPCS.js";
5
5
  import "./chunk-OGLE65KO.js";
6
6
  export {
7
7
  src_default as default,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iress-oss/ids-theme-preset",
3
- "version": "6.0.0-alpha.1",
3
+ "version": "6.0.0-alpha.2",
4
4
  "description": "Panda CSS preset for the Iress Design System",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -34,6 +34,7 @@
34
34
  ],
35
35
  "scripts": {
36
36
  "build": "tsup",
37
+ "dev": "tsup --watch",
37
38
  "clean": "rimraf dist coverage",
38
39
  "lint": "eslint . --ext=.js,.jsx,.ts,.tsx,.mjs,.cjs --max-warnings=0",
39
40
  "test": "vitest --config vitest.config.ts --watch",
@@ -58,9 +59,9 @@
58
59
  "devDependencies": {
59
60
  "@pandacss/dev": "1.8.2",
60
61
  "@pandacss/types": "1.8.2",
61
- "@typescript-eslint/eslint-plugin": "^8.56.0",
62
- "@typescript-eslint/parser": "^8.56.0",
63
- "eslint": "^10.0.1",
62
+ "@typescript-eslint/eslint-plugin": "^8.56.1",
63
+ "@typescript-eslint/parser": "^8.56.1",
64
+ "eslint": "^10.0.2",
64
65
  "eslint-plugin-file-progress": "^3.0.2",
65
66
  "rimraf": "^6.1.3",
66
67
  "tsup": "^8.4.0",
@@ -70,5 +71,6 @@
70
71
  "repository": {
71
72
  "type": "git",
72
73
  "url": "https://github.com/iress/design-system"
73
- }
74
- }
74
+ },
75
+ "stableVersion": "6.0.0-alpha.1"
76
+ }
@@ -2,6 +2,7 @@ import type { Config } from '@pandacss/dev';
2
2
  import idsThemePreset from './index';
3
3
  import { codegenPrepareHook } from './hooks/codegenPrepareHook';
4
4
  import { cssgenDoneHook } from './hooks/cssgenDoneHook';
5
+ import { staticCssStripHook } from './hooks/staticCssStripHook';
5
6
 
6
7
  /**
7
8
  * Returns Panda CSS config overrides for packages that already include
@@ -10,6 +11,14 @@ import { cssgenDoneHook } from './hooks/cssgenDoneHook';
10
11
  * Includes the IDS theme preset and disables preflight, globalCss, and
11
12
  * staticCss to avoid duplicating CSS already shipped by IDS components.
12
13
  * Panda will still generate CSS for utilities your code actually uses.
14
+ *
15
+ * The `cssgen:done` hook runs two passes over the generated styles.css:
16
+ * 1. `cssgenDoneHook` — strips spacing alias classes (e.g. `gap_sm`) that
17
+ * were generated before runtime alias resolution could redirect them to the
18
+ * canonical token class.
19
+ * 2. `staticCssStripHook` — strips IDS static-CSS utility classes that are
20
+ * already shipped in `@iress-oss/ids-components` style.css, preventing
21
+ * duplication in the consumer's own bundle.
13
22
  */
14
23
  export function createMinimalConfig(): Pick<
15
24
  Config,
@@ -22,8 +31,13 @@ export function createMinimalConfig(): Pick<
22
31
  globalCss: {},
23
32
  hooks: {
24
33
  'codegen:prepare': ({ artifacts }) => codegenPrepareHook(artifacts),
25
- 'cssgen:done': ({ artifact, content }) =>
26
- cssgenDoneHook(artifact, content),
34
+ 'cssgen:done': ({ artifact, content }) => {
35
+ // Run alias stripping first, then strip IDS static-CSS classes.
36
+ // `??` (not `||`) ensures an empty-string return is treated as valid
37
+ // CSS content rather than falling back to the unmodified input.
38
+ const afterAliasStrip = cssgenDoneHook(artifact, content) ?? content;
39
+ return staticCssStripHook(artifact, afterAliasStrip) ?? afterAliasStrip;
40
+ },
27
41
  },
28
42
  };
29
43
  }
@@ -1,3 +1,4 @@
1
1
  export { codegenPrepareHook } from './codegenPrepareHook';
2
2
  export { cssgenDoneHook } from './cssgenDoneHook';
3
+ export { staticCssStripHook } from './staticCssStripHook';
3
4
  export { SPACING_ALIAS_MAP } from './spacingAliasMap';
@@ -0,0 +1,332 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { staticCssStripHook } from './staticCssStripHook';
3
+
4
+ describe('staticCssStripHook', () => {
5
+ it('ignores non-styles.css artifacts', () => {
6
+ const result = staticCssStripHook(
7
+ 'tokens',
8
+ '.gap_spacing\\.2{gap:var(--spacing-spacing\\.2)}',
9
+ );
10
+ expect(result).toBeUndefined();
11
+ });
12
+
13
+ describe('spacing utility classes', () => {
14
+ it('strips canonical spacing classes', () => {
15
+ const css =
16
+ '.gap_spacing\\.2{gap:var(--spacing-spacing\\.2)}' +
17
+ '.p_spacing\\.3{padding:var(--spacing-spacing\\.3)}' +
18
+ '.m_spacing\\.0{margin:var(--spacing-spacing\\.0)}' +
19
+ '.cursor_pointer{cursor:pointer}';
20
+
21
+ const result = staticCssStripHook('styles.css', css);
22
+ expect(result).not.toContain('.gap_spacing');
23
+ expect(result).not.toContain('.p_spacing');
24
+ expect(result).not.toContain('.m_spacing');
25
+ expect(result).toContain('.cursor_pointer{cursor:pointer}');
26
+ });
27
+
28
+ it('strips breakpoint-prefixed responsive spacing classes', () => {
29
+ const css =
30
+ '.xs\\:gap_spacing\\.0{gap:var(--spacing-spacing\\.0)}' +
31
+ '.md\\:mt_spacing\\.2{margin-top:var(--spacing-spacing\\.2)}' +
32
+ '.unrelated_class{color:red}';
33
+
34
+ const result = staticCssStripHook('styles.css', css);
35
+ expect(result).not.toContain('.xs\\:gap_spacing');
36
+ expect(result).not.toContain('.md\\:mt_spacing');
37
+ expect(result).toContain('.unrelated_class{color:red}');
38
+ });
39
+
40
+ it('strips negative margin spacing classes', () => {
41
+ const css =
42
+ '.my_-spacing\\.2{margin-block:calc(var(--spacing-spacing\\.2) * -1)}' +
43
+ '.mt_-spacing\\.1{margin-top:calc(var(--spacing-spacing\\.1) * -1)}';
44
+
45
+ const result = staticCssStripHook('styles.css', css);
46
+ expect(result).not.toContain('.my_-spacing');
47
+ expect(result).not.toContain('.mt_-spacing');
48
+ });
49
+
50
+ it('strips spacing classes for all common shorthand properties', () => {
51
+ const prefixes = [
52
+ 'gap',
53
+ 'cg',
54
+ 'rg',
55
+ 'm',
56
+ 'mt',
57
+ 'mb',
58
+ 'ml',
59
+ 'mr',
60
+ 'mx',
61
+ 'my',
62
+ 'p',
63
+ 'pt',
64
+ 'pb',
65
+ 'pl',
66
+ 'pr',
67
+ 'px',
68
+ 'py',
69
+ ];
70
+ const css = prefixes
71
+ .map((p) => `.${p}_spacing\\.2{${p}:var(--spacing-spacing\\.2)}`)
72
+ .join('');
73
+
74
+ const result = staticCssStripHook('styles.css', css);
75
+ for (const prefix of prefixes) {
76
+ expect(result).not.toContain(`.${prefix}_spacing`);
77
+ }
78
+ });
79
+ });
80
+
81
+ describe('textStyle utility classes', () => {
82
+ it('strips basic textStyle classes', () => {
83
+ const css =
84
+ '.textStyle_typography\\.body\\.md{font:var(--iress-typography-body-md)}' +
85
+ '.other_class{color:red}';
86
+
87
+ const result = staticCssStripHook('styles.css', css);
88
+ expect(result).not.toContain('.textStyle_typography');
89
+ expect(result).toContain('.other_class{color:red}');
90
+ });
91
+
92
+ it('strips multi-selector textStyle rules with descendant combinators', () => {
93
+ const css =
94
+ '.textStyle_typography\\.body\\.md strong:not([class]),.textStyle_typography\\.body\\.md:is(strong){font:var(--x)}' +
95
+ '.cursor_pointer{cursor:pointer}';
96
+
97
+ const result = staticCssStripHook('styles.css', css);
98
+ expect(result).not.toContain('.textStyle_typography');
99
+ expect(result).toContain('.cursor_pointer{cursor:pointer}');
100
+ });
101
+ });
102
+
103
+ describe('custom IDS utility classes', () => {
104
+ it('strips focusable utility classes including pseudo-selectors', () => {
105
+ const css =
106
+ '.focusable_true:focus-visible{outline:none;box-shadow:0 0 0 2px blue}' +
107
+ '.focusable_label-after:focus-visible+label{box-shadow:0 0 0 2px blue}' +
108
+ '.other_class{color:red}';
109
+
110
+ const result = staticCssStripHook('styles.css', css);
111
+ expect(result).not.toContain('.focusable_true');
112
+ expect(result).not.toContain('.focusable_label-after');
113
+ expect(result).toContain('.other_class{color:red}');
114
+ });
115
+
116
+ it('strips span utility classes', () => {
117
+ const css =
118
+ '.span_auto{flex-grow:1;flex-shrink:0;flex-basis:0}' +
119
+ '.span_6{flex-basis:50%}' +
120
+ '.not_a_span_class{color:red}';
121
+
122
+ const result = staticCssStripHook('styles.css', css);
123
+ expect(result).not.toContain('.span_auto');
124
+ expect(result).not.toContain('.span_6');
125
+ expect(result).toContain('.not_a_span_class{color:red}');
126
+ });
127
+
128
+ it('strips breakpoint-prefixed span utility classes', () => {
129
+ const css =
130
+ '.xs\\:span_6{flex-basis:50%}' +
131
+ '.md\\:span_auto{flex-grow:1;flex-shrink:0;flex-basis:0}' +
132
+ '.unrelated{color:red}';
133
+
134
+ const result = staticCssStripHook('styles.css', css);
135
+ expect(result).not.toContain('.xs\\:span_6');
136
+ expect(result).not.toContain('.md\\:span_auto');
137
+ expect(result).toContain('.unrelated{color:red}');
138
+ });
139
+
140
+ it('strips offset utility classes', () => {
141
+ const css =
142
+ '.offset_3{margin-left:calc(3 / 12 * 100%)}' +
143
+ '.offset_6{margin-left:50%}';
144
+
145
+ const result = staticCssStripHook('styles.css', css);
146
+ expect(result).not.toContain('.offset_3');
147
+ expect(result).not.toContain('.offset_6');
148
+ });
149
+
150
+ it('strips breakpoint-prefixed offset utility classes', () => {
151
+ const css =
152
+ '.md\\:offset_3{margin-left:calc(3 / 12 * 100%)}' +
153
+ '.lg\\:offset_6{margin-left:50%}' +
154
+ '.unrelated{color:red}';
155
+
156
+ const result = staticCssStripHook('styles.css', css);
157
+ expect(result).not.toContain('.md\\:offset_3');
158
+ expect(result).not.toContain('.lg\\:offset_6');
159
+ expect(result).toContain('.unrelated{color:red}');
160
+ });
161
+
162
+ it('strips gutter utility classes', () => {
163
+ const css =
164
+ '.gutter_spacing\\.4{--col-gap:var(--iress-spacing-4);margin-inline:calc(-1 * var(--col-gap) / 2)}';
165
+
166
+ const result = staticCssStripHook('styles.css', css);
167
+ expect(result).not.toContain('.gutter_spacing');
168
+ });
169
+
170
+ it('strips noGutter utility classes including child combinator selectors', () => {
171
+ const css =
172
+ '.noGutter_true>:last-child{margin-block-end:0px}' +
173
+ '.other{display:block}';
174
+
175
+ const result = staticCssStripHook('styles.css', css);
176
+ expect(result).not.toContain('.noGutter_true');
177
+ expect(result).toContain('.other{display:block}');
178
+ });
179
+
180
+ it('strips scrollable utility classes including webkit scrollbar pseudo-elements', () => {
181
+ const css =
182
+ '.scrollable_y{overflow-y:auto}' +
183
+ '.scrollable_y::-webkit-scrollbar{width:1rem}' +
184
+ '.scrollable_x{overflow-x:auto}';
185
+
186
+ const result = staticCssStripHook('styles.css', css);
187
+ expect(result).not.toContain('.scrollable_y');
188
+ expect(result).not.toContain('.scrollable_x');
189
+ });
190
+
191
+ it('strips stretch utility classes', () => {
192
+ const css = '.stretch_true{align-self:stretch;flex:1;height:100%}';
193
+
194
+ const result = staticCssStripHook('styles.css', css);
195
+ expect(result).not.toContain('.stretch_true');
196
+ });
197
+
198
+ it('strips flexHorizontalAlign (fha) utility classes', () => {
199
+ const css =
200
+ '.fha_around:where([data-flex-dir=row],:not([data-flex-dir])){justify-content:space-around}' +
201
+ '.fha_center:where([data-flex-dir=column]){align-items:center}';
202
+
203
+ const result = staticCssStripHook('styles.css', css);
204
+ expect(result).not.toContain('.fha_around');
205
+ expect(result).not.toContain('.fha_center');
206
+ });
207
+
208
+ it('strips flexVerticalAlign (fva) utility classes', () => {
209
+ const css =
210
+ '.fva_top:where([data-flex-dir=row],:not([data-flex-dir])){align-items:flex-start}' +
211
+ '.fva_middle:where([data-flex-dir=column]){justify-content:center}';
212
+
213
+ const result = staticCssStripHook('styles.css', css);
214
+ expect(result).not.toContain('.fva_top');
215
+ expect(result).not.toContain('.fva_middle');
216
+ });
217
+ });
218
+
219
+ describe('srOnly (sr) utility classes', () => {
220
+ it('strips sr utility classes', () => {
221
+ const css =
222
+ '.sr_true{position:absolute;width:1px;height:1px}' +
223
+ '.sr_false{position:static;width:auto}';
224
+
225
+ const result = staticCssStripHook('styles.css', css);
226
+ expect(result).not.toContain('.sr_true{');
227
+ expect(result).not.toContain('.sr_false{');
228
+ });
229
+
230
+ it('strips breakpoint-prefixed sr utility classes', () => {
231
+ const css =
232
+ '.xs\\:sr_true{position:absolute;width:1px;height:1px}' +
233
+ '.md\\:sr_false{position:static;width:auto}' +
234
+ '.unrelated{color:red}';
235
+
236
+ const result = staticCssStripHook('styles.css', css);
237
+ expect(result).not.toContain('.xs\\:sr_true');
238
+ expect(result).not.toContain('.md\\:sr_false');
239
+ expect(result).toContain('.unrelated{color:red}');
240
+ });
241
+
242
+ it('preserves rules that reference .sr_true inside :not() pseudo-class', () => {
243
+ // The nestedFormLabels condition in IDS uses :not(.sr_true) to target
244
+ // visible form labels. Stripping this rule would break form label styling.
245
+ const css =
246
+ '.nestedFormLabels\\:c_colour\\.neutral\\.70 .iress-form-label:not(.sr_true){color:red}' +
247
+ '.sr_true{position:absolute;width:1px}';
248
+
249
+ const result = staticCssStripHook('styles.css', css);
250
+ expect(result).toContain(':not(.sr_true)');
251
+ expect(result).not.toContain('.sr_true{');
252
+ });
253
+ });
254
+
255
+ describe('responsive visibility (hideBelow / hideFrom) utility classes', () => {
256
+ it('strips hide_* breakpoint classes', () => {
257
+ const css =
258
+ '.hide_xs{display:none}' +
259
+ '.hide_sm{display:none}' +
260
+ '.hide_md{display:none}' +
261
+ '.hide_lg{display:none}' +
262
+ '.hide_xl{display:none}' +
263
+ '.hide_xxl{display:none}' +
264
+ '.other{color:red}';
265
+
266
+ const result = staticCssStripHook('styles.css', css);
267
+ expect(result).not.toContain('.hide_xs');
268
+ expect(result).not.toContain('.hide_sm');
269
+ expect(result).not.toContain('.hide_md');
270
+ expect(result).not.toContain('.hide_lg');
271
+ expect(result).not.toContain('.hide_xl');
272
+ expect(result).not.toContain('.hide_xxl');
273
+ expect(result).toContain('.other{color:red}');
274
+ });
275
+
276
+ it('does not strip hide_ classes with non-breakpoint values', () => {
277
+ const css = '.hide_custom-value{display:none}';
278
+
279
+ const result = staticCssStripHook('styles.css', css);
280
+ expect(result).toContain('.hide_custom-value{display:none}');
281
+ });
282
+ });
283
+
284
+ describe('IDS colour token utility classes', () => {
285
+ it('strips bg_colour.* utility classes', () => {
286
+ const css =
287
+ '.bg_colour\\.system\\.danger\\.fill{background:var(--colors-colour\\.system\\.danger\\.fill)}' +
288
+ '.bg_colour\\.neutral\\.10{background:var(--colors-colour\\.neutral\\.10)}' +
289
+ '.bg_custom-color{background:hotpink}';
290
+
291
+ const result = staticCssStripHook('styles.css', css);
292
+ expect(result).not.toContain('.bg_colour');
293
+ expect(result).toContain('.bg_custom-color{background:hotpink}');
294
+ });
295
+
296
+ it('strips c_colour.* utility classes', () => {
297
+ const css =
298
+ '.c_colour\\.neutral\\.80{color:var(--colors-colour\\.neutral\\.80)}' +
299
+ '.c_red{color:red}';
300
+
301
+ const result = staticCssStripHook('styles.css', css);
302
+ expect(result).not.toContain('.c_colour');
303
+ expect(result).toContain('.c_red{color:red}');
304
+ });
305
+
306
+ it('strips rounded_radius.* utility classes', () => {
307
+ const css =
308
+ '.rounded_radius\\.system\\.form{border-radius:var(--iress-radius-system-form)}' +
309
+ '.rounded_lg{border-radius:1rem}';
310
+
311
+ const result = staticCssStripHook('styles.css', css);
312
+ expect(result).not.toContain('.rounded_radius');
313
+ expect(result).toContain('.rounded_lg{border-radius:1rem}');
314
+ });
315
+ });
316
+
317
+ it('handles an empty CSS string', () => {
318
+ const result = staticCssStripHook('styles.css', '');
319
+ expect(result).toBe('');
320
+ });
321
+
322
+ it('preserves unrelated utility classes', () => {
323
+ const css =
324
+ '.cursor_pointer{cursor:pointer}' +
325
+ '.d_flex{display:flex}' +
326
+ '.text_red{color:red}' +
327
+ '.some-component_active{background:blue}';
328
+
329
+ const result = staticCssStripHook('styles.css', css);
330
+ expect(result).toBe(css);
331
+ });
332
+ });
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Strips CSS rules generated by the IDS preset's staticCss configuration from
3
+ * the consumer's bundle. These classes are already shipped by IDS via
4
+ * @iress-oss/ids-components style.css, so duplicating them in the consumer's
5
+ * bundle only adds unnecessary weight.
6
+ *
7
+ * Used in createMinimalConfig() alongside cssgenDoneHook to ensure the
8
+ * consumer's Panda output only contains CSS that is genuinely unique to their
9
+ * application.
10
+ *
11
+ * Pattern coverage:
12
+ * - Canonical spacing utility classes (gap, margin, padding, etc.) for IDS
13
+ * spacing tokens, including responsive breakpoint-prefixed variants and
14
+ * negative margin values.
15
+ * - IDS typography composition classes (textStyle_typography.*).
16
+ * - IDS-specific custom utility classes: focusable, span, offset, gutter,
17
+ * noGutter, scrollable, stretch, flexHorizontalAlign (fha),
18
+ * flexVerticalAlign (fva), srOnly (sr), and responsive visibility (hide_*).
19
+ * - IDS colour and radius token classes (bg_colour.*, c_colour.*,
20
+ * rounded_radius.*).
21
+ */
22
+ export function staticCssStripHook(
23
+ artifact: string,
24
+ content: string,
25
+ ): string | void {
26
+ if (artifact !== 'styles.css') return;
27
+
28
+ let css = content;
29
+
30
+ // Strip spacing utility classes for canonical IDS spacing tokens.
31
+ //
32
+ // Covers all Panda CSS shorthand property names for spacing with values
33
+ // matching the IDS canonical token format `spacing.N`.
34
+ //
35
+ // The `\\.` in the regex matches the literal backslash+dot that Panda CSS
36
+ // uses to escape dots in class names (e.g. .gap_spacing\.2).
37
+ //
38
+ // `[a-z]+` is used rather than an exhaustive explicit alternation
39
+ // (gap|cg|rg|m|mt|...) because: (a) an exhaustive alternation triggers
40
+ // the sonarjs/regex-complexity lint rule at this scope, and (b) the
41
+ // `_-?spacing\\\.\d+` suffix is already sufficiently specific — only IDS
42
+ // canonical token paths produce this pattern. Mixed-case Panda condition
43
+ // prefixes (e.g. `progressBar\:m_spacing`) are excluded by `[a-z]+` because
44
+ // they contain uppercase letters.
45
+ //
46
+ // Matches:
47
+ // .gap_spacing\.2{...} canonical spacing
48
+ // .xs\:gap_spacing\.2{...} responsive breakpoint-prefixed
49
+ // .mt_-spacing\.2{...} negative margin
50
+ css = css.replace(/\.(?:[a-z]+\\:)?[a-z]+_-?spacing\\\.\d+\{[^}]*\}/g, '');
51
+
52
+ // Strip textStyle classes for IDS typography compositions.
53
+ //
54
+ // These may have descendant-combinator selectors (e.g. `.textStyle_X strong`)
55
+ // so we match everything from .textStyle_typography up to the closing }.
56
+ // This relies on Panda CSS generating flat (non-nested) rules — property
57
+ // values in Panda's output do not contain literal `}` characters, so
58
+ // `[^}]+` always terminates at the correct closing brace.
59
+ //
60
+ // Matches:
61
+ // .textStyle_typography\.body\.md{...}
62
+ // .textStyle_typography\.body\.md strong:not([class]),...{...}
63
+ css = css.replace(/\.textStyle_typography[^}]+\}/g, '');
64
+
65
+ // Strip IDS-specific custom utility classes.
66
+ //
67
+ // These use Panda's `className` option and are unique to IDS, so they are
68
+ // safe to strip without risk of removing consumer-authored utilities.
69
+ // The class names (focusable, fha, fva, etc.) are not standard CSS property
70
+ // shorthands and are unlikely to be used as utility names in consumer code.
71
+ //
72
+ // `[^\s{]+` is safe here because `{` is in the exclusion set — it terminates
73
+ // the match at the exact opening brace of the CSS block with no ambiguity.
74
+ //
75
+ // An optional breakpoint prefix (`[a-z]+\:`) handles responsive variants
76
+ // for utilities in `responsiveProps` (span, offset, gutter), e.g.
77
+ // `.xs\:span_6{...}` or `.md\:offset_3{...}`.
78
+ //
79
+ // Covers: focusable, span (IressCol), offset (IressCol), gutter (IressRow),
80
+ // noGutter (IressRow), scrollable, stretch, fha (flexHorizontalAlign),
81
+ // fva (flexVerticalAlign).
82
+ css = css.replace(
83
+ /\.(?:[a-z]+\\:)?(focusable|span|offset|gutter|noGutter|scrollable|stretch|fha|fva)_[^\s{]+\{[^}]*\}/g,
84
+ '',
85
+ );
86
+
87
+ // Strip srOnly (sr) utility classes.
88
+ //
89
+ // A negative lookbehind is required because the IDS preset's
90
+ // `nestedFormLabels` condition embeds `.sr_true` inside a :not() selector
91
+ // (e.g. `.iress-form-label:not(.sr_true)`), which would otherwise be
92
+ // incorrectly stripped.
93
+ //
94
+ // An optional breakpoint prefix handles responsive variants (srOnly is in
95
+ // `responsiveProps`), e.g. `.xs\:sr_true{...}`.
96
+ css = css.replace(/(?<!\()\.(?:[a-z]+\\:)?sr_[^\s{]+\{[^}]*\}/g, '');
97
+
98
+ // Strip responsive visibility utility classes (hideBelow / hideFrom).
99
+ //
100
+ // These utilities generate breakpoint-scoped display:none rules inside
101
+ // @media blocks. Only the exact IDS breakpoint values are targeted.
102
+ css = css.replace(/\.hide_(xs|sm|md|lg|xl|xxl)\{[^}]*\}/g, '');
103
+
104
+ // Strip IDS colour token utility classes.
105
+ //
106
+ // Only targets classes whose value uses the IDS colour token path format
107
+ // (`colour.*`), which is distinct from generic colour values. Safe to strip
108
+ // because any class matching this pattern is already in IDS's style.css.
109
+ css = css.replace(/\.bg_colour\\\.[^\s{]+\{[^}]*\}/g, '');
110
+ css = css.replace(/\.c_colour\\\.[^\s{]+\{[^}]*\}/g, '');
111
+
112
+ // Strip IDS radius token utility classes (borderRadius with IDS radii).
113
+ css = css.replace(/\.rounded_radius\\\.[^\s{]+\{[^}]*\}/g, '');
114
+
115
+ return css;
116
+ }
@@ -7,6 +7,7 @@ export const selectChevron = defineUtility({
7
7
  values: { type: 'boolean' },
8
8
  transform: (value) => {
9
9
  return {
10
+ paddingInlineEnd: `calc(${cssVars.spacing[2]} + ${sizes['chevron.select'].value})`,
10
11
  '&:after': {
11
12
  content: `''` as never,
12
13
  width: sizes['chevron.select'].value,