@ids-group-ltd/ids-design-system 1.1.1 → 1.1.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/CHANGELOG.md +114 -0
- package/agent/feedback/ds-empty-state.md +2 -1
- package/agent/feedback/ds-tree.md +3 -1
- package/agent/forms/ds-chat-input.md +3 -3
- package/agent/navigation/ds-splitter.md +1 -1
- package/components.md +9 -6
- package/fesm2022/ids-group-ltd-ids-design-system-components-autocomplete.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-autocomplete.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-banner.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-banner.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-legend.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-legend.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-chat.mjs +48 -6
- package/fesm2022/ids-group-ltd-ids-design-system-components-chat.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-checkbox.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-checkbox.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-empty-state.mjs +14 -7
- package/fesm2022/ids-group-ltd-ids-design-system-components-empty-state.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-multi-select.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-multi-select.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-number-stepper.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-number-stepper.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-popover.mjs +9 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-popover.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-radio-group.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-radio-group.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-segmented.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-segmented.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-switch.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-switch.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-table-columns.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-table-columns.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-textarea.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-textarea.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-toggle-button.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-toggle-button.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-tree.mjs +47 -8
- package/fesm2022/ids-group-ltd-ids-design-system-components-tree.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-core.mjs +14 -1
- package/fesm2022/ids-group-ltd-ids-design-system-core.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system.mjs.map +1 -1
- package/migrations/1.1.2.json +135 -0
- package/migrations/README.md +3 -1
- package/package.json +4 -1
- package/schematics/check-overrides/surface.json +10 -1
- package/stylelint/index.mjs +17 -3
- package/stylelint/known-tokens.mjs +139 -0
- package/stylelint/report.mjs +185 -0
- package/stylelint/tokens.mjs +160 -0
- package/stylelint/use-tokens.mjs +397 -0
- package/styles/_check-box.scss +2 -2
- package/styles/_tokens.scss +8 -0
- package/themes/_semantic.scss +9 -1
- package/themes/dark/_theme.scss +5 -1
- package/types/ids-group-ltd-ids-design-system-components-chat.d.ts +18 -2
- package/types/ids-group-ltd-ids-design-system-components-empty-state.d.ts +7 -2
- package/types/ids-group-ltd-ids-design-system-components-tree.d.ts +20 -2
- package/types/ids-group-ltd-ids-design-system-core.d.ts +19 -1
- package/types/ids-group-ltd-ids-design-system.d.ts +3 -3
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Read-only audit of how far a project's styles are on design-system tokens:
|
|
3
|
+
//
|
|
4
|
+
// npx ids-design-system-token-report "src/**/*.{scss,css,ts}" [--ignore <glob>]... [--json <file>]
|
|
5
|
+
//
|
|
6
|
+
// Lints every matched .scss and .css file, and every inline `styles` template of a matched .ts
|
|
7
|
+
// file, with `use-tokens` and `known-tokens` only, then prints the findings with their suggestions
|
|
8
|
+
// and the counts per category, property, file and value. Names the project declares in the matched
|
|
9
|
+
// files, ignored ones included, or in the template beside a matched component count as known.
|
|
10
|
+
// Nothing is written except the `--json` file.
|
|
11
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import { createRequire } from 'node:module';
|
|
13
|
+
import { join, relative } from 'node:path';
|
|
14
|
+
import stylelint from 'stylelint';
|
|
15
|
+
import knownTokens, { ruleName as knownName } from './known-tokens.mjs';
|
|
16
|
+
import useTokens, { ruleName as useName } from './use-tokens.mjs';
|
|
17
|
+
|
|
18
|
+
const fastGlob = createRequire(import.meta.resolve('stylelint'))('fast-glob');
|
|
19
|
+
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
const flag = (name) =>
|
|
22
|
+
args.flatMap((arg, index) => (args[index - 1] === name ? [arg] : []));
|
|
23
|
+
const globs = args.filter(
|
|
24
|
+
(arg, index) =>
|
|
25
|
+
!arg.startsWith('--') && !['--ignore', '--json'].includes(args[index - 1]),
|
|
26
|
+
);
|
|
27
|
+
if (!globs.length) {
|
|
28
|
+
console.error(
|
|
29
|
+
'usage: ids-design-system-token-report <glob>... [--ignore <glob>]... [--json <file>]',
|
|
30
|
+
);
|
|
31
|
+
process.exit(2);
|
|
32
|
+
}
|
|
33
|
+
const built = ['**/node_modules/**', '**/dist/**', '**/.angular/**'];
|
|
34
|
+
const ignore = [...built, ...flag('--ignore')];
|
|
35
|
+
const jsonOut = flag('--json')[0];
|
|
36
|
+
const asGlob = (pattern) => pattern.replaceAll('\\', '/');
|
|
37
|
+
|
|
38
|
+
const scssSyntax = () => {
|
|
39
|
+
for (const base of [join(process.cwd(), 'noop.js'), import.meta.url]) {
|
|
40
|
+
try {
|
|
41
|
+
return createRequire(base)('postcss-scss');
|
|
42
|
+
} catch {}
|
|
43
|
+
}
|
|
44
|
+
console.error(
|
|
45
|
+
'Reading .scss needs postcss-scss: npm install -D postcss-scss',
|
|
46
|
+
);
|
|
47
|
+
process.exit(2);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const files = fastGlob
|
|
51
|
+
.sync(globs.map(asGlob), { ignore, absolute: true })
|
|
52
|
+
.filter((file) => /\.(scss|css|ts)$/.test(file))
|
|
53
|
+
.sort();
|
|
54
|
+
const display = (file) => relative(process.cwd(), file).replaceAll('\\', '/');
|
|
55
|
+
|
|
56
|
+
const sources = [];
|
|
57
|
+
for (const file of files) {
|
|
58
|
+
const text = readFileSync(file, 'utf8');
|
|
59
|
+
if (!file.endsWith('.ts')) {
|
|
60
|
+
sources.push({
|
|
61
|
+
file,
|
|
62
|
+
code: text,
|
|
63
|
+
lineOffset: 0,
|
|
64
|
+
scss: file.endsWith('.scss'),
|
|
65
|
+
});
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
for (const match of text.matchAll(/styles\s*:\s*\[?\s*`([\s\S]*?)`/g)) {
|
|
69
|
+
const start = match.index + match[0].indexOf('`');
|
|
70
|
+
sources.push({
|
|
71
|
+
file,
|
|
72
|
+
code: match[1].replace(/\$\{[^}]*\}/g, '0'),
|
|
73
|
+
lineOffset: text.slice(0, start).split('\n').length - 1,
|
|
74
|
+
scss: true,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// An ignored file still declares names (a brand layer), and a component sets custom properties
|
|
80
|
+
// from its template too (`[style.--x]`).
|
|
81
|
+
const declaring = fastGlob
|
|
82
|
+
.sync(globs.map(asGlob), { ignore: built, absolute: true })
|
|
83
|
+
.filter((file) => /.(scss|css|ts)$/.test(file));
|
|
84
|
+
const templates = declaring
|
|
85
|
+
.map((file) => file.replace(/\.ts$/, '.html'))
|
|
86
|
+
.filter((file) => file.endsWith('.html') && existsSync(file));
|
|
87
|
+
|
|
88
|
+
const config = {
|
|
89
|
+
plugins: [useTokens, knownTokens],
|
|
90
|
+
rules: {
|
|
91
|
+
[useName]: true,
|
|
92
|
+
[knownName]: [true, { declarationsFrom: [...declaring, ...templates] }],
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
const syntax = sources.some((source) => source.scss) ? scssSyntax() : undefined;
|
|
96
|
+
|
|
97
|
+
const KIND = [
|
|
98
|
+
[/ has no exact token, nearest /, 'nearest'],
|
|
99
|
+
[/ matches no design-system colour$/, 'none'],
|
|
100
|
+
[/, use /, 'exact'],
|
|
101
|
+
];
|
|
102
|
+
const findings = [];
|
|
103
|
+
for (const source of sources) {
|
|
104
|
+
const { results } = await stylelint.lint({
|
|
105
|
+
code: source.code,
|
|
106
|
+
codeFilename: source.file,
|
|
107
|
+
config: { ...config, customSyntax: source.scss ? syntax : undefined },
|
|
108
|
+
});
|
|
109
|
+
for (const warning of results[0].warnings) {
|
|
110
|
+
const text = warning.text.replace(/ \(ids-design-system\/[\w-]+\)$/, '');
|
|
111
|
+
const base = {
|
|
112
|
+
file: display(source.file),
|
|
113
|
+
line: warning.line + source.lineOffset,
|
|
114
|
+
text,
|
|
115
|
+
};
|
|
116
|
+
if (warning.rule === knownName) {
|
|
117
|
+
findings.push({
|
|
118
|
+
...base,
|
|
119
|
+
category: 'unknown-token',
|
|
120
|
+
prop: '',
|
|
121
|
+
raw: text.match(/"(--[\w-]+)"/)[1],
|
|
122
|
+
kind: 'unknown',
|
|
123
|
+
});
|
|
124
|
+
} else if (warning.rule === useName) {
|
|
125
|
+
const [, category, raw, prop] = text.match(
|
|
126
|
+
/^([\w-]+): raw "([\s\S]*?)" in ([\w-]+)/,
|
|
127
|
+
);
|
|
128
|
+
const kind = KIND.find(([pattern]) => pattern.test(text))[1];
|
|
129
|
+
findings.push({ ...base, category, prop, raw, kind });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const countBy = (key) =>
|
|
135
|
+
Object.entries(
|
|
136
|
+
findings.reduce((counts, finding) => {
|
|
137
|
+
counts[key(finding)] = (counts[key(finding)] ?? 0) + 1;
|
|
138
|
+
return counts;
|
|
139
|
+
}, {}),
|
|
140
|
+
).sort((a, b) => b[1] - a[1]);
|
|
141
|
+
const table = (title, rows) => {
|
|
142
|
+
console.log(`\n${title}`);
|
|
143
|
+
for (const [label, count] of rows)
|
|
144
|
+
console.log(` ${String(count).padStart(5)} ${label}`);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
console.log('findings');
|
|
148
|
+
for (const finding of findings)
|
|
149
|
+
console.log(` ${finding.file}:${finding.line} ${finding.text}`);
|
|
150
|
+
console.log(
|
|
151
|
+
`\nfiles ${files.length}, style sources ${sources.length} (inline .ts templates ${sources.filter((source) => source.file.endsWith('.ts')).length})`,
|
|
152
|
+
);
|
|
153
|
+
const tokenFindings = findings.filter((finding) => finding.kind !== 'unknown');
|
|
154
|
+
console.log(
|
|
155
|
+
`use-tokens ${tokenFindings.length} in ${new Set(tokenFindings.map((finding) => finding.file)).size} files, known-tokens ${findings.length - tokenFindings.length}`,
|
|
156
|
+
);
|
|
157
|
+
table(
|
|
158
|
+
'by category',
|
|
159
|
+
countBy((finding) => finding.category),
|
|
160
|
+
);
|
|
161
|
+
table(
|
|
162
|
+
'by category and kind',
|
|
163
|
+
countBy((finding) => `${finding.category} ${finding.kind}`),
|
|
164
|
+
);
|
|
165
|
+
table(
|
|
166
|
+
'by property',
|
|
167
|
+
countBy((finding) => finding.prop).filter(([prop]) => prop),
|
|
168
|
+
);
|
|
169
|
+
table(
|
|
170
|
+
'by file',
|
|
171
|
+
countBy((finding) => finding.file),
|
|
172
|
+
);
|
|
173
|
+
table(
|
|
174
|
+
'by value',
|
|
175
|
+
countBy((finding) => `${finding.category} ${finding.raw}`),
|
|
176
|
+
);
|
|
177
|
+
if (jsonOut)
|
|
178
|
+
writeFileSync(
|
|
179
|
+
jsonOut,
|
|
180
|
+
JSON.stringify(
|
|
181
|
+
{ files: files.length, sources: sources.length, findings },
|
|
182
|
+
null,
|
|
183
|
+
1,
|
|
184
|
+
),
|
|
185
|
+
);
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// The token tables `use-tokens` matches raw values against and the names `known-tokens` accepts,
|
|
2
|
+
// read at load time from the stylesheets and the bundle that sit beside this folder (`styles/`,
|
|
3
|
+
// `themes/`, `fesm2022/`).
|
|
4
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const packageRoot = fileURLToPath(new URL('..', import.meta.url));
|
|
9
|
+
const lib = existsSync(join(packageRoot, 'styles/_tokens.scss'))
|
|
10
|
+
? packageRoot
|
|
11
|
+
: join(packageRoot, 'src/lib');
|
|
12
|
+
|
|
13
|
+
const stripComments = (text) =>
|
|
14
|
+
text.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:])\/\/.*$/gm, '$1');
|
|
15
|
+
|
|
16
|
+
const declarations = (file) =>
|
|
17
|
+
[
|
|
18
|
+
...stripComments(readFileSync(join(lib, file), 'utf8')).matchAll(
|
|
19
|
+
/(--[\w-]+)\s*:\s*([^;{}]+);/g,
|
|
20
|
+
),
|
|
21
|
+
].map((match) => [match[1], match[2].replace(/\s+/g, ' ').trim()]);
|
|
22
|
+
|
|
23
|
+
const hex2 = (number) =>
|
|
24
|
+
Math.round(number).toString(16).padStart(2, '0').toUpperCase();
|
|
25
|
+
|
|
26
|
+
const hslToHex = (hue, saturation, lightness) => {
|
|
27
|
+
const s = saturation / 100;
|
|
28
|
+
const l = lightness / 100;
|
|
29
|
+
const k = (n) => (n + hue / 30) % 12;
|
|
30
|
+
const a = s * Math.min(l, 1 - l);
|
|
31
|
+
const channel = (n) =>
|
|
32
|
+
l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
33
|
+
return `#${hex2(channel(0) * 255)}${hex2(channel(8) * 255)}${hex2(channel(4) * 255)}`;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// An opaque colour as `#RRGGBB`, or null for anything translucent or not a literal colour.
|
|
37
|
+
export const normalizeColor = (raw) => {
|
|
38
|
+
const value = raw.trim().toLowerCase();
|
|
39
|
+
let match = value.match(/^#([0-9a-f]{3,8})$/);
|
|
40
|
+
if (match) {
|
|
41
|
+
let hex = match[1];
|
|
42
|
+
if (hex.length === 3 || hex.length === 4)
|
|
43
|
+
hex = [...hex].map((digit) => digit + digit).join('');
|
|
44
|
+
if (hex.length === 8 && hex.endsWith('ff')) hex = hex.slice(0, 6);
|
|
45
|
+
return hex.length === 6 ? `#${hex.toUpperCase()}` : null;
|
|
46
|
+
}
|
|
47
|
+
match = value.match(
|
|
48
|
+
/^hsla?\(\s*(-?[\d.]+)(?:deg)?[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*(?:[,/]\s*(1|100%))?\s*\)$/,
|
|
49
|
+
);
|
|
50
|
+
if (match) return hslToHex(+match[1], +match[2], +match[3]);
|
|
51
|
+
match = value.match(
|
|
52
|
+
/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)\s*(?:[,/]\s*(1|100%))?\s*\)$/,
|
|
53
|
+
);
|
|
54
|
+
if (match) return `#${hex2(+match[1])}${hex2(+match[2])}${hex2(+match[3])}`;
|
|
55
|
+
if (value === 'white') return '#FFFFFF';
|
|
56
|
+
if (value === 'black') return '#000000';
|
|
57
|
+
return null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const scale = new Map(declarations('styles/_tokens.scss').reverse());
|
|
61
|
+
const colorDeclarations = new Map();
|
|
62
|
+
const semantic = new Set();
|
|
63
|
+
for (const file of [
|
|
64
|
+
'themes/_base-palette.scss',
|
|
65
|
+
'themes/light/_palette.scss',
|
|
66
|
+
'themes/_semantic.scss',
|
|
67
|
+
])
|
|
68
|
+
for (const [name, value] of declarations(file)) {
|
|
69
|
+
if (!colorDeclarations.has(name)) colorDeclarations.set(name, value);
|
|
70
|
+
if (file.includes('_semantic')) semantic.add(name);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const all = new Map([...scale, ...colorDeclarations]);
|
|
74
|
+
const resolve = (value, depth = 0) => {
|
|
75
|
+
if (depth > 20) return value;
|
|
76
|
+
const next = value.replace(/var\((--[\w-]+)(?:,[^()]*)?\)/g, (whole, name) =>
|
|
77
|
+
all.has(name) ? resolve(all.get(name), depth + 1) : whole,
|
|
78
|
+
);
|
|
79
|
+
return next.replace(/calc\(\s*(-?[\d.]+)\s*-\s*([\d.]+)\s*\)/g, (_, a, b) =>
|
|
80
|
+
String(a - b),
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const colorsByHex = new Map();
|
|
85
|
+
for (const [name, value] of colorDeclarations) {
|
|
86
|
+
const hex = normalizeColor(resolve(value));
|
|
87
|
+
if (!hex) continue;
|
|
88
|
+
if (!colorsByHex.has(hex))
|
|
89
|
+
colorsByHex.set(hex, { semantic: [], palette: [] });
|
|
90
|
+
colorsByHex.get(hex)[semantic.has(name) ? 'semantic' : 'palette'].push(name);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const group = (prefix, exclude = []) =>
|
|
94
|
+
[...scale.keys()]
|
|
95
|
+
.filter(
|
|
96
|
+
(name) =>
|
|
97
|
+
name.startsWith(prefix) && !exclude.some((part) => name.includes(part)),
|
|
98
|
+
)
|
|
99
|
+
.map((name) => ({ name, value: resolve(scale.get(name)) }));
|
|
100
|
+
|
|
101
|
+
const inPx = (list) =>
|
|
102
|
+
list
|
|
103
|
+
.filter((token) => /^(0|[\d.]+px)$/.test(token.value))
|
|
104
|
+
.map((token) => ({ ...token, number: parseFloat(token.value) }));
|
|
105
|
+
|
|
106
|
+
const numeric = (list) =>
|
|
107
|
+
list.map((token) => ({ ...token, number: +token.value }));
|
|
108
|
+
|
|
109
|
+
export const tokens = {
|
|
110
|
+
colorsByHex,
|
|
111
|
+
space: inPx(group('--space-', ['stack', 'inline'])),
|
|
112
|
+
radius: inPx(group('--radius-', ['pill-value', 'flat'])),
|
|
113
|
+
fontSize: inPx(group('--font-size-', ['h5-strong', 'mono'])),
|
|
114
|
+
fontWeight: numeric(group('--font-weight-')),
|
|
115
|
+
lineHeight: numeric(group('--line-height-')),
|
|
116
|
+
layer: numeric(group('--layer-')),
|
|
117
|
+
duration: group('--duration-', ['loop']).map((token) => ({
|
|
118
|
+
...token,
|
|
119
|
+
number: parseFloat(token.value),
|
|
120
|
+
})),
|
|
121
|
+
ease: group('--ease-').map((token) => ({
|
|
122
|
+
...token,
|
|
123
|
+
normalized: normalizeEase(token.value),
|
|
124
|
+
})),
|
|
125
|
+
shadow: group('--shadow-')
|
|
126
|
+
.filter((token) => /^--shadow-\d$/.test(token.name))
|
|
127
|
+
.map((token) => {
|
|
128
|
+
const [, y, blur] = token.value.match(/^0 (\d+)px (\d+)px/) ?? [];
|
|
129
|
+
return { ...token, y: +y, blur: +blur };
|
|
130
|
+
}),
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export function normalizeEase(value) {
|
|
134
|
+
return value.replace(/\s+/g, '').replace(/(^|[(,])0\./g, '$1.');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Every custom property name the library declares or reads: tokens, theme roles and the `--ds-*`
|
|
138
|
+
// hooks its components read, which live in the compiled bundle rather than in `styles/`.
|
|
139
|
+
const filesUnder = (directory, pattern) =>
|
|
140
|
+
existsSync(directory)
|
|
141
|
+
? readdirSync(directory, { recursive: true })
|
|
142
|
+
.filter((file) => pattern.test(file))
|
|
143
|
+
.map((file) => join(directory, file))
|
|
144
|
+
: [];
|
|
145
|
+
|
|
146
|
+
export const libraryNames = new Set(
|
|
147
|
+
[
|
|
148
|
+
...(lib === packageRoot
|
|
149
|
+
? [
|
|
150
|
+
...filesUnder(join(lib, 'styles'), /\.s?css$/),
|
|
151
|
+
...filesUnder(join(lib, 'themes'), /\.s?css$/),
|
|
152
|
+
...filesUnder(join(lib, 'fesm2022'), /\.mjs$/),
|
|
153
|
+
]
|
|
154
|
+
: filesUnder(lib, /\.(scss|ts)$/)),
|
|
155
|
+
].flatMap((file) =>
|
|
156
|
+
[...readFileSync(file, 'utf8').matchAll(/(?<![\w-])--[a-zA-Z][\w-]*/g)].map(
|
|
157
|
+
(match) => match[0],
|
|
158
|
+
),
|
|
159
|
+
),
|
|
160
|
+
);
|