@wallarm-org/design-system 4.9.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/Badge/generateBadgeVariants.js +9 -28
- package/dist/components/CodeSnippet/internal/FoldToggle.js +1 -1
- package/dist/components/SimpleCharts/Chart/classes.js +1 -1
- package/dist/components/SimpleCharts/HorizontalBarStack/classes.js +1 -1
- package/dist/components/SimpleCharts/Metric/classes.d.ts +2 -2
- package/dist/components/SimpleCharts/Metric/classes.js +2 -2
- package/dist/components/Table/TableBody/TableBodyCell.js +4 -1
- package/dist/guidelines/patterns/complex-drawer.md +1084 -0
- package/dist/guidelines/patterns/confirmation-dialogs.md +3 -11
- package/dist/guidelines/patterns/detail-drawer.md +31 -13
- package/dist/guidelines/patterns/empty-states.md +6 -5
- package/dist/guidelines/patterns/entity-table.md +25 -29
- package/dist/guidelines/patterns/feedback-toasts.md +3 -11
- package/dist/guidelines/patterns/resource-list-page.md +14 -16
- package/dist/guidelines/rules.md +6 -5
- package/dist/guidelines/templates/ai-assistant.md +1133 -0
- package/dist/guidelines/templates/api-inventory.md +905 -0
- package/dist/guidelines/templates/attack-events.md +2722 -0
- package/dist/guidelines/templates/incident-detail.md +2085 -0
- package/dist/guidelines/templates/integrations-settings.md +836 -0
- package/dist/guidelines/templates/page-states.md +798 -0
- package/dist/guidelines/templates/rule-editor.md +886 -0
- package/dist/guidelines/templates/security-dashboard.md +681 -0
- package/dist/metadata/components.json +10 -10
- package/dist/metadata/guidelines.json +1204 -37
- package/dist/theme/tokens.test.ts +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { describe, expect, it } from '@rstest/core';
|
|
2
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
// Tailwind v4 emits no CSS for a utility whose `--color-*` token does not exist, so a
|
|
6
|
+
// typo or a removed token renders nothing and fails nowhere. This test is that check.
|
|
7
|
+
const src = path.resolve(__dirname, '..');
|
|
8
|
+
const files = (dir: string, ext: RegExp): string[] =>
|
|
9
|
+
readdirSync(dir, { recursive: true, encoding: 'utf8' })
|
|
10
|
+
.filter(f => ext.test(f))
|
|
11
|
+
.map(f => path.join(dir, f));
|
|
12
|
+
|
|
13
|
+
const tokens = new Set(
|
|
14
|
+
files(__dirname, /\.css$/).flatMap(f =>
|
|
15
|
+
[...readFileSync(f, 'utf8').matchAll(/--color-([a-z0-9-]+)\s*:/g)].map(m => m[1] as string),
|
|
16
|
+
),
|
|
17
|
+
);
|
|
18
|
+
// Only names in a semantic namespace (`bg-…`, `text-…`, `badge-…`) are checked, so
|
|
19
|
+
// unrelated utilities like `text-sm` or `border-2` never match.
|
|
20
|
+
const semantic = readFileSync(path.join(__dirname, 'semantic.css'), 'utf8');
|
|
21
|
+
const namespaces = new Set([...semantic.matchAll(/--color-([a-z]+)-/g)].map(m => m[1] as string));
|
|
22
|
+
|
|
23
|
+
const UTILITY =
|
|
24
|
+
/(?<![\w-])(?:bg|text|border(?:-[trblxyse])?|fill|stroke|ring(?:-offset)?|outline|divide|from|via|to|decoration|accent|caret|placeholder)-([a-z][a-z0-9-]*[a-z0-9])(?![\w-]|\$\{)/g;
|
|
25
|
+
const VAR = /var\(--color-([a-z0-9-]+)[,)]/g;
|
|
26
|
+
|
|
27
|
+
const unknownTokens = () =>
|
|
28
|
+
files(src, /\.(tsx?|css|mdx)$/).flatMap(file => {
|
|
29
|
+
const rel = path.relative(src, file);
|
|
30
|
+
return readFileSync(file, 'utf8')
|
|
31
|
+
.split('\n')
|
|
32
|
+
.flatMap((line, i) =>
|
|
33
|
+
/^\s*(\/\/|\*)/.test(line)
|
|
34
|
+
? []
|
|
35
|
+
: [...line.matchAll(UTILITY), ...line.matchAll(VAR)]
|
|
36
|
+
.map(m => m[1] as string)
|
|
37
|
+
// A one-segment name (`text-badge`) is a plain string value, not a token
|
|
38
|
+
.filter(
|
|
39
|
+
name =>
|
|
40
|
+
name.includes('-') &&
|
|
41
|
+
namespaces.has(name.split('-')[0] as string) &&
|
|
42
|
+
!tokens.has(name),
|
|
43
|
+
)
|
|
44
|
+
.map(name => `${rel}:${i + 1} ${name}`),
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('theme tokens', () => {
|
|
49
|
+
it('every semantic color utility and var() resolves to a defined --color-* token', () => {
|
|
50
|
+
expect(unknownTokens()).toEqual([]);
|
|
51
|
+
});
|
|
52
|
+
});
|