@iress-oss/ids-theme-preset 6.0.0-alpha.1 → 6.0.0-alpha.3
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 +12 -1
- package/dist/{chunk-6T7NHIQQ.js → chunk-IVI5DGPP.js} +11 -9
- package/dist/{chunk-V3SF6JCX.js → chunk-MOGGW7LB.js} +20 -1
- package/dist/{chunk-OGLE65KO.js → chunk-NEAYSXME.js} +2 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.js +9 -5
- package/dist/constants.d.ts +13 -1
- package/dist/constants.js +5 -3
- package/dist/hooks/index.d.ts +24 -1
- package/dist/hooks/index.js +5 -3
- package/dist/index.js +2 -2
- package/package.json +11 -9
- package/src/constants.ts +13 -0
- package/src/createMinimalConfig.ts +16 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/staticCssStripHook.test.ts +332 -0
- package/src/hooks/staticCssStripHook.ts +116 -0
- package/src/tokens/animationStyles.ts +66 -65
- package/src/tokens/zIndex.ts +8 -8
- package/src/utilities/chevron.ts +1 -0
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 }) =>
|
|
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 |
|
|
@@ -6,8 +6,9 @@ import {
|
|
|
6
6
|
MATERIAL_SYMBOLS,
|
|
7
7
|
TEXT_ALIGNS,
|
|
8
8
|
VERTICAL_ALIGNS,
|
|
9
|
-
Z_INDEX
|
|
10
|
-
|
|
9
|
+
Z_INDEX,
|
|
10
|
+
Z_INDEX_OFFSET_VAR
|
|
11
|
+
} from "./chunk-NEAYSXME.js";
|
|
11
12
|
|
|
12
13
|
// src/index.ts
|
|
13
14
|
import { definePreset } from "@pandacss/dev";
|
|
@@ -1544,25 +1545,25 @@ var borders = {
|
|
|
1544
1545
|
// src/tokens/zIndex.ts
|
|
1545
1546
|
var zIndex = {
|
|
1546
1547
|
"000": {
|
|
1547
|
-
value: Z_INDEX.DEFAULT
|
|
1548
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.DEFAULT})`
|
|
1548
1549
|
},
|
|
1549
1550
|
"100": {
|
|
1550
|
-
value: Z_INDEX.NAVBAR
|
|
1551
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.NAVBAR})`
|
|
1551
1552
|
},
|
|
1552
1553
|
"200": {
|
|
1553
|
-
value: Z_INDEX.POPOVER
|
|
1554
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.POPOVER})`
|
|
1554
1555
|
},
|
|
1555
1556
|
"300": {
|
|
1556
|
-
value: Z_INDEX.SLIDEOUT
|
|
1557
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.SLIDEOUT})`
|
|
1557
1558
|
},
|
|
1558
1559
|
"400": {
|
|
1559
|
-
value: Z_INDEX.MODAL
|
|
1560
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.MODAL})`
|
|
1560
1561
|
},
|
|
1561
1562
|
"500": {
|
|
1562
|
-
value: Z_INDEX.TOAST
|
|
1563
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.TOAST})`
|
|
1563
1564
|
},
|
|
1564
1565
|
"600": {
|
|
1565
|
-
value: Z_INDEX.TOOLTIP
|
|
1566
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.TOOLTIP})`
|
|
1566
1567
|
}
|
|
1567
1568
|
};
|
|
1568
1569
|
|
|
@@ -1839,6 +1840,7 @@ var selectChevron = defineUtility4({
|
|
|
1839
1840
|
values: { type: "boolean" },
|
|
1840
1841
|
transform: (value) => {
|
|
1841
1842
|
return {
|
|
1843
|
+
paddingInlineEnd: `calc(${cssVars13.spacing[2]} + ${sizes["chevron.select"].value})`,
|
|
1842
1844
|
"&:after": {
|
|
1843
1845
|
content: `''`,
|
|
1844
1846
|
width: sizes["chevron.select"].value,
|
|
@@ -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
|
};
|
|
@@ -101,6 +101,7 @@ var Z_INDEX = {
|
|
|
101
101
|
TOAST: 500,
|
|
102
102
|
TOOLTIP: 600
|
|
103
103
|
};
|
|
104
|
+
var Z_INDEX_OFFSET_VAR = "--iress-zindex-offset";
|
|
104
105
|
var MATERIAL_SYMBOLS = {
|
|
105
106
|
family: "Material Symbols Rounded",
|
|
106
107
|
className: "material-symbols-rounded",
|
|
@@ -142,6 +143,7 @@ export {
|
|
|
142
143
|
FORM_ELEMENT_WIDTHS,
|
|
143
144
|
GRID_SIZE,
|
|
144
145
|
Z_INDEX,
|
|
146
|
+
Z_INDEX_OFFSET_VAR,
|
|
145
147
|
MATERIAL_SYMBOLS,
|
|
146
148
|
HORIZONTAL_ALIGNS,
|
|
147
149
|
TEXT_ALIGNS,
|
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-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-IVI5DGPP.js";
|
|
4
|
+
import "./chunk-NEAYSXME.js";
|
|
5
5
|
import {
|
|
6
6
|
codegenPrepareHook,
|
|
7
|
-
cssgenDoneHook
|
|
8
|
-
|
|
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 }) =>
|
|
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
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -122,6 +122,18 @@ declare const Z_INDEX: {
|
|
|
122
122
|
TOAST: number;
|
|
123
123
|
TOOLTIP: number;
|
|
124
124
|
};
|
|
125
|
+
/**
|
|
126
|
+
* The CSS custom property name for the z-index offset.
|
|
127
|
+
* Set this in your application CSS to shift all IDS z-index values:
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```css
|
|
131
|
+
* :root {
|
|
132
|
+
* --iress-zindex-offset: 1000;
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare const Z_INDEX_OFFSET_VAR = "--iress-zindex-offset";
|
|
125
137
|
/**
|
|
126
138
|
* Material Symbols icon configuration.
|
|
127
139
|
*/
|
|
@@ -147,4 +159,4 @@ declare const TEXT_ALIGNS: readonly ["inherit", "left", "center", "right", "just
|
|
|
147
159
|
*/
|
|
148
160
|
declare const VERTICAL_ALIGNS: readonly ["top", "middle", "bottom", "between", "around", "evenly", "stretch"];
|
|
149
161
|
|
|
150
|
-
export { BREAKPOINTS, BREAKPOINT_DETAILS, type BreakpointDetail, FORM_ELEMENT_WIDTHS, GRID_SIZE, HORIZONTAL_ALIGNS, MATERIAL_SYMBOLS, TEXT_ALIGNS, VERTICAL_ALIGNS, Z_INDEX };
|
|
162
|
+
export { BREAKPOINTS, BREAKPOINT_DETAILS, type BreakpointDetail, FORM_ELEMENT_WIDTHS, GRID_SIZE, HORIZONTAL_ALIGNS, MATERIAL_SYMBOLS, TEXT_ALIGNS, VERTICAL_ALIGNS, Z_INDEX, Z_INDEX_OFFSET_VAR };
|
package/dist/constants.js
CHANGED
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
MATERIAL_SYMBOLS,
|
|
8
8
|
TEXT_ALIGNS,
|
|
9
9
|
VERTICAL_ALIGNS,
|
|
10
|
-
Z_INDEX
|
|
11
|
-
|
|
10
|
+
Z_INDEX,
|
|
11
|
+
Z_INDEX_OFFSET_VAR
|
|
12
|
+
} from "./chunk-NEAYSXME.js";
|
|
12
13
|
export {
|
|
13
14
|
BREAKPOINTS,
|
|
14
15
|
BREAKPOINT_DETAILS,
|
|
@@ -18,5 +19,6 @@ export {
|
|
|
18
19
|
MATERIAL_SYMBOLS,
|
|
19
20
|
TEXT_ALIGNS,
|
|
20
21
|
VERTICAL_ALIGNS,
|
|
21
|
-
Z_INDEX
|
|
22
|
+
Z_INDEX,
|
|
23
|
+
Z_INDEX_OFFSET_VAR
|
|
22
24
|
};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -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 };
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SPACING_ALIAS_MAP,
|
|
3
3
|
codegenPrepareHook,
|
|
4
|
-
cssgenDoneHook
|
|
5
|
-
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iress-oss/ids-theme-preset",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.3",
|
|
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",
|
|
@@ -56,19 +57,20 @@
|
|
|
56
57
|
}
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@pandacss/dev": "1.
|
|
60
|
-
"@pandacss/types": "1.
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
62
|
-
"@typescript-eslint/parser": "^8.
|
|
63
|
-
"eslint": "^10.0.
|
|
60
|
+
"@pandacss/dev": "1.9.0",
|
|
61
|
+
"@pandacss/types": "1.9.0",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
|
63
|
+
"@typescript-eslint/parser": "^8.57.0",
|
|
64
|
+
"eslint": "^10.0.3",
|
|
64
65
|
"eslint-plugin-file-progress": "^3.0.2",
|
|
65
66
|
"rimraf": "^6.1.3",
|
|
66
67
|
"tsup": "^8.4.0",
|
|
67
68
|
"typescript": "5.9.3",
|
|
68
|
-
"vitest": "4.0
|
|
69
|
+
"vitest": "4.1.0"
|
|
69
70
|
},
|
|
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
|
+
}
|
package/src/constants.ts
CHANGED
|
@@ -142,6 +142,19 @@ export const Z_INDEX = {
|
|
|
142
142
|
TOOLTIP: 600,
|
|
143
143
|
};
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* The CSS custom property name for the z-index offset.
|
|
147
|
+
* Set this in your application CSS to shift all IDS z-index values:
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```css
|
|
151
|
+
* :root {
|
|
152
|
+
* --iress-zindex-offset: 1000;
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export const Z_INDEX_OFFSET_VAR = '--iress-zindex-offset';
|
|
157
|
+
|
|
145
158
|
/**
|
|
146
159
|
* Material Symbols icon configuration.
|
|
147
160
|
*/
|
|
@@ -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
|
-
|
|
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
|
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -3,77 +3,78 @@ import { type keyframes } from './keyframes';
|
|
|
3
3
|
|
|
4
4
|
type AnimationName = keyof typeof keyframes;
|
|
5
5
|
|
|
6
|
-
export const animationStyles
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
export const animationStyles: ReturnType<typeof defineAnimationStyles> =
|
|
7
|
+
defineAnimationStyles({
|
|
8
|
+
'field-footer': {
|
|
9
|
+
value: {
|
|
10
|
+
animationName: 'fieldFooter' as AnimationName,
|
|
11
|
+
animationDuration: '0.5s',
|
|
12
|
+
animationTimingFunction: 'ease-in-out',
|
|
13
|
+
animationFillMode: 'forwards',
|
|
14
|
+
},
|
|
13
15
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
'icon-spin-half': {
|
|
17
|
+
value: {
|
|
18
|
+
animationName: 'iconRotation' as AnimationName,
|
|
19
|
+
animationDuration: '0.5s',
|
|
20
|
+
animationTimingFunction: 'linear',
|
|
21
|
+
animationIterationCount: 'infinite',
|
|
22
|
+
},
|
|
21
23
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
'icon-spin-1': {
|
|
25
|
+
value: {
|
|
26
|
+
animationName: 'iconRotation' as AnimationName,
|
|
27
|
+
animationDuration: '1s',
|
|
28
|
+
animationTimingFunction: 'linear',
|
|
29
|
+
animationIterationCount: 'infinite',
|
|
30
|
+
},
|
|
29
31
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
'icon-spin-2': {
|
|
33
|
+
value: {
|
|
34
|
+
animationName: 'iconRotation' as AnimationName,
|
|
35
|
+
animationDuration: '2s',
|
|
36
|
+
animationTimingFunction: 'linear',
|
|
37
|
+
animationIterationCount: 'infinite',
|
|
38
|
+
},
|
|
37
39
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
'icon-spin-3': {
|
|
41
|
+
value: {
|
|
42
|
+
animationName: 'iconRotation' as AnimationName,
|
|
43
|
+
animationDuration: '3s',
|
|
44
|
+
animationTimingFunction: 'linear',
|
|
45
|
+
animationIterationCount: 'infinite',
|
|
46
|
+
},
|
|
45
47
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
'loading-fade-next': {
|
|
49
|
+
value: {
|
|
50
|
+
animationName: 'loadingFadeNext' as AnimationName,
|
|
51
|
+
animationDuration: '0.6s',
|
|
52
|
+
animationTimingFunction: 'linear',
|
|
53
|
+
animationFillMode: 'forwards',
|
|
54
|
+
},
|
|
53
55
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
'loading-slide-next': {
|
|
57
|
+
value: {
|
|
58
|
+
animationName: 'loadingSlideNext' as AnimationName,
|
|
59
|
+
animationDuration: '0.5s',
|
|
60
|
+
animationTimingFunction: 'ease-in-out',
|
|
61
|
+
animationFillMode: 'forwards',
|
|
62
|
+
},
|
|
61
63
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
'skeleton-loading': {
|
|
65
|
+
value: {
|
|
66
|
+
animationName: 'skeletonLoading' as AnimationName,
|
|
67
|
+
animationDuration: '2s',
|
|
68
|
+
animationTimingFunction: 'ease-in-out',
|
|
69
|
+
animationIterationCount: 'infinite',
|
|
70
|
+
},
|
|
69
71
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
'toggle-active': {
|
|
73
|
+
value: {
|
|
74
|
+
animationName: 'toggleActive' as AnimationName,
|
|
75
|
+
animationDuration: '0.3s',
|
|
76
|
+
animationTimingFunction: 'ease-in-out',
|
|
77
|
+
animationFillMode: 'forwards',
|
|
78
|
+
},
|
|
77
79
|
},
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
+
});
|
package/src/tokens/zIndex.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Z_INDEX } from '../constants';
|
|
1
|
+
import { Z_INDEX, Z_INDEX_OFFSET_VAR } from '../constants';
|
|
2
2
|
|
|
3
3
|
export const zIndex = {
|
|
4
4
|
'000': {
|
|
5
|
-
value: Z_INDEX.DEFAULT
|
|
5
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.DEFAULT})`,
|
|
6
6
|
},
|
|
7
7
|
'100': {
|
|
8
|
-
value: Z_INDEX.NAVBAR
|
|
8
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.NAVBAR})`,
|
|
9
9
|
},
|
|
10
10
|
'200': {
|
|
11
|
-
value: Z_INDEX.POPOVER
|
|
11
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.POPOVER})`,
|
|
12
12
|
},
|
|
13
13
|
'300': {
|
|
14
|
-
value: Z_INDEX.SLIDEOUT
|
|
14
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.SLIDEOUT})`,
|
|
15
15
|
},
|
|
16
16
|
'400': {
|
|
17
|
-
value: Z_INDEX.MODAL
|
|
17
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.MODAL})`,
|
|
18
18
|
},
|
|
19
19
|
'500': {
|
|
20
|
-
value: Z_INDEX.TOAST
|
|
20
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.TOAST})`,
|
|
21
21
|
},
|
|
22
22
|
'600': {
|
|
23
|
-
value: Z_INDEX.TOOLTIP
|
|
23
|
+
value: `calc(var(${Z_INDEX_OFFSET_VAR}, 0) + ${Z_INDEX.TOOLTIP})`,
|
|
24
24
|
},
|
|
25
25
|
};
|
package/src/utilities/chevron.ts
CHANGED
|
@@ -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,
|