@pure-ds/core 0.3.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/CSS-INTELLISENSE-LIMITATION.md +98 -0
- package/CSS-INTELLISENSE-QUICK-REF.md +238 -0
- package/INTELLISENSE.md +384 -0
- package/LICENSE +15 -0
- package/custom-elements-manifest.config.js +30 -0
- package/custom-elements.json +2003 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/packages/pds-configurator/src/figma-export.d.ts +13 -0
- package/dist/types/packages/pds-configurator/src/figma-export.d.ts.map +1 -0
- package/dist/types/packages/pds-configurator/src/pds-config-form.d.ts +2 -0
- package/dist/types/packages/pds-configurator/src/pds-config-form.d.ts.map +1 -0
- package/dist/types/packages/pds-configurator/src/pds-configurator.d.ts +2 -0
- package/dist/types/packages/pds-configurator/src/pds-configurator.d.ts.map +1 -0
- package/dist/types/packages/pds-configurator/src/pds-demo.d.ts +2 -0
- package/dist/types/packages/pds-configurator/src/pds-demo.d.ts.map +1 -0
- package/dist/types/pds.config.d.ts +13 -0
- package/dist/types/pds.config.d.ts.map +1 -0
- package/dist/types/pds.d.ts +408 -0
- package/dist/types/public/assets/js/app.d.ts +2 -0
- package/dist/types/public/assets/js/app.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds.d.ts +23 -0
- package/dist/types/public/assets/js/pds.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-calendar.d.ts +23 -0
- package/dist/types/public/assets/pds/components/pds-calendar.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-drawer.d.ts +2 -0
- package/dist/types/public/assets/pds/components/pds-drawer.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-icon.d.ts +53 -0
- package/dist/types/public/assets/pds/components/pds-icon.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-jsonform.d.ts +104 -0
- package/dist/types/public/assets/pds/components/pds-jsonform.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-richtext.d.ts +121 -0
- package/dist/types/public/assets/pds/components/pds-richtext.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts +61 -0
- package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-splitpanel.d.ts +1 -0
- package/dist/types/public/assets/pds/components/pds-splitpanel.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-tabstrip.d.ts +39 -0
- package/dist/types/public/assets/pds/components/pds-tabstrip.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-toaster.d.ts +111 -0
- package/dist/types/public/assets/pds/components/pds-toaster.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-upload.d.ts +83 -0
- package/dist/types/public/assets/pds/components/pds-upload.d.ts.map +1 -0
- package/dist/types/src/js/app.d.ts +2 -0
- package/dist/types/src/js/app.d.ts.map +1 -0
- package/dist/types/src/js/common/ask.d.ts +22 -0
- package/dist/types/src/js/common/ask.d.ts.map +1 -0
- package/dist/types/src/js/common/common.d.ts +3 -0
- package/dist/types/src/js/common/common.d.ts.map +1 -0
- package/dist/types/src/js/common/font-loader.d.ts +24 -0
- package/dist/types/src/js/common/font-loader.d.ts.map +1 -0
- package/dist/types/src/js/common/msg.d.ts +3 -0
- package/dist/types/src/js/common/msg.d.ts.map +1 -0
- package/dist/types/src/js/lit.d.ts +25 -0
- package/dist/types/src/js/lit.d.ts.map +1 -0
- package/dist/types/src/js/pds-configurator/figma-export.d.ts +13 -0
- package/dist/types/src/js/pds-configurator/figma-export.d.ts.map +1 -0
- package/dist/types/src/js/pds-configurator/pds-config-form.d.ts +2 -0
- package/dist/types/src/js/pds-configurator/pds-config-form.d.ts.map +1 -0
- package/dist/types/src/js/pds-configurator/pds-configurator.d.ts +2 -0
- package/dist/types/src/js/pds-configurator/pds-configurator.d.ts.map +1 -0
- package/dist/types/src/js/pds-configurator/pds-demo.d.ts +2 -0
- package/dist/types/src/js/pds-configurator/pds-demo.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-config.d.ts +758 -0
- package/dist/types/src/js/pds-core/pds-config.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-enhancer-metadata.d.ts +6 -0
- package/dist/types/src/js/pds-core/pds-enhancer-metadata.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-enhancers.d.ts +14 -0
- package/dist/types/src/js/pds-core/pds-enhancers.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-enums.d.ts +87 -0
- package/dist/types/src/js/pds-core/pds-enums.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-generator.d.ts +741 -0
- package/dist/types/src/js/pds-core/pds-generator.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-ontology.d.ts +48 -0
- package/dist/types/src/js/pds-core/pds-ontology.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-paths.d.ts +37 -0
- package/dist/types/src/js/pds-core/pds-paths.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-query.d.ts +102 -0
- package/dist/types/src/js/pds-core/pds-query.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-registry.d.ts +40 -0
- package/dist/types/src/js/pds-core/pds-registry.d.ts.map +1 -0
- package/dist/types/src/js/pds.d.ts +109 -0
- package/dist/types/src/js/pds.d.ts.map +1 -0
- package/dist/types/src/pds-core/pds-api.d.ts +31 -0
- package/dist/types/src/pds-core/pds-api.d.ts.map +1 -0
- package/package.json +104 -0
- package/packages/pds-cli/README.md +15 -0
- package/packages/pds-cli/bin/generate-css-data.js +565 -0
- package/packages/pds-cli/bin/generate-manifest.js +352 -0
- package/packages/pds-cli/bin/pds-build-icons.js +152 -0
- package/packages/pds-cli/bin/pds-dx.js +114 -0
- package/packages/pds-cli/bin/pds-static.js +556 -0
- package/packages/pds-cli/bin/pds.js +127 -0
- package/packages/pds-cli/bin/postinstall.js +380 -0
- package/packages/pds-cli/bin/sync-assets.js +252 -0
- package/packages/pds-cli/lib/asset-roots.js +47 -0
- package/packages/pds-cli/lib/fs-writer.js +75 -0
- package/pds.css-data.json +5 -0
- package/pds.html-data.json +5 -0
- package/public/assets/js/app.js +5719 -0
- package/public/assets/js/lit.js +131 -0
- package/public/assets/js/pds.js +3423 -0
- package/public/assets/pds/components/pds-calendar.js +837 -0
- package/public/assets/pds/components/pds-drawer.js +857 -0
- package/public/assets/pds/components/pds-icon.js +338 -0
- package/public/assets/pds/components/pds-jsonform.js +1775 -0
- package/public/assets/pds/components/pds-richtext.js +1035 -0
- package/public/assets/pds/components/pds-scrollrow.js +331 -0
- package/public/assets/pds/components/pds-splitpanel.js +401 -0
- package/public/assets/pds/components/pds-tabstrip.js +251 -0
- package/public/assets/pds/components/pds-toaster.js +446 -0
- package/public/assets/pds/components/pds-upload.js +657 -0
- package/public/assets/pds/custom-elements.json +2003 -0
- package/public/assets/pds/icons/pds-icons.svg +498 -0
- package/public/assets/pds/pds-css-complete.json +1861 -0
- package/public/assets/pds/pds.css-data.json +2152 -0
- package/public/assets/pds/vscode-custom-data.json +824 -0
- package/readme.md +1870 -0
- package/src/js/pds-core/pds-config.js +1162 -0
- package/src/js/pds-core/pds-enhancer-metadata.js +75 -0
- package/src/js/pds-core/pds-enhancers.js +357 -0
- package/src/js/pds-core/pds-enums.js +86 -0
- package/src/js/pds-core/pds-generator.js +5317 -0
- package/src/js/pds-core/pds-ontology.js +256 -0
- package/src/js/pds-core/pds-paths.js +109 -0
- package/src/js/pds-core/pds-query.js +571 -0
- package/src/js/pds-core/pds-registry.js +129 -0
- package/src/js/pds-core/pds.d.ts +129 -0
- package/src/js/pds.d.ts +408 -0
- package/src/js/pds.js +1579 -0
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate CSS Custom Data for IntelliSense
|
|
5
|
+
* Creates VS Code CSS custom data and standard CSS data formats
|
|
6
|
+
* Provides autocomplete for CSS tokens, classes, and custom properties
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { writeFile, mkdir, readFile } from 'fs/promises';
|
|
10
|
+
import { existsSync } from 'fs';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
13
|
+
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = path.dirname(__filename);
|
|
16
|
+
const repoRoot = path.resolve(__dirname, '../../../');
|
|
17
|
+
|
|
18
|
+
// Colors for terminal output
|
|
19
|
+
const COLORS = {
|
|
20
|
+
reset: '\x1b[0m',
|
|
21
|
+
bold: '\x1b[1m',
|
|
22
|
+
green: '\x1b[32m',
|
|
23
|
+
yellow: '\x1b[33m',
|
|
24
|
+
blue: '\x1b[34m',
|
|
25
|
+
red: '\x1b[31m',
|
|
26
|
+
cyan: '\x1b[36m',
|
|
27
|
+
};
|
|
28
|
+
const shouldLogToStderr = () => process.env.PDS_LOG_STREAM === 'stderr' || process.env.PDS_POSTINSTALL === '1';
|
|
29
|
+
const log = (msg, color = 'reset') => {
|
|
30
|
+
const colorCode = COLORS[color] || '';
|
|
31
|
+
const text = `${colorCode}${msg}${COLORS.reset}`;
|
|
32
|
+
if (shouldLogToStderr()) {
|
|
33
|
+
process.stderr.write(`${text}\n`);
|
|
34
|
+
} else {
|
|
35
|
+
console.log(text);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Extract CSS custom properties from generated tokens
|
|
41
|
+
*/
|
|
42
|
+
function extractCSSProperties(generator) {
|
|
43
|
+
const properties = [];
|
|
44
|
+
const compiled = generator.compiled;
|
|
45
|
+
|
|
46
|
+
if (!compiled?.tokens) {
|
|
47
|
+
log('ā ļø No tokens found in generator', 'yellow');
|
|
48
|
+
return properties;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Extract color tokens
|
|
52
|
+
if (compiled.tokens.colors) {
|
|
53
|
+
for (const [colorName, colorScale] of Object.entries(compiled.tokens.colors)) {
|
|
54
|
+
if (typeof colorScale === 'object' && colorScale !== null) {
|
|
55
|
+
// Color scales (50-900)
|
|
56
|
+
for (const [shade, value] of Object.entries(colorScale)) {
|
|
57
|
+
properties.push({
|
|
58
|
+
name: `--color-${colorName}-${shade}`,
|
|
59
|
+
description: `${colorName} color scale - shade ${shade}`,
|
|
60
|
+
syntax: '<color>',
|
|
61
|
+
value: value,
|
|
62
|
+
category: 'Color Tokens'
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
} else if (typeof colorScale === 'string') {
|
|
66
|
+
// Single color value
|
|
67
|
+
properties.push({
|
|
68
|
+
name: `--color-${colorName}`,
|
|
69
|
+
description: `${colorName} color`,
|
|
70
|
+
syntax: '<color>',
|
|
71
|
+
value: colorScale,
|
|
72
|
+
category: 'Color Tokens'
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Extract spacing tokens
|
|
79
|
+
if (compiled.tokens.spacing) {
|
|
80
|
+
for (const [key, value] of Object.entries(compiled.tokens.spacing)) {
|
|
81
|
+
properties.push({
|
|
82
|
+
name: `--spacing-${key}`,
|
|
83
|
+
description: `Spacing scale value ${key}`,
|
|
84
|
+
syntax: '<length>',
|
|
85
|
+
value: value,
|
|
86
|
+
category: 'Spacing Tokens'
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Extract typography tokens
|
|
92
|
+
if (compiled.tokens.typography) {
|
|
93
|
+
const typo = compiled.tokens.typography;
|
|
94
|
+
|
|
95
|
+
// Font families
|
|
96
|
+
if (typo.families) {
|
|
97
|
+
for (const [key, value] of Object.entries(typo.families)) {
|
|
98
|
+
properties.push({
|
|
99
|
+
name: `--font-family-${key}`,
|
|
100
|
+
description: `Font family for ${key}`,
|
|
101
|
+
syntax: '<custom-ident>',
|
|
102
|
+
value: value,
|
|
103
|
+
category: 'Typography Tokens'
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Font sizes
|
|
109
|
+
if (typo.sizes) {
|
|
110
|
+
for (const [key, value] of Object.entries(typo.sizes)) {
|
|
111
|
+
properties.push({
|
|
112
|
+
name: `--font-size-${key}`,
|
|
113
|
+
description: `Font size ${key}`,
|
|
114
|
+
syntax: '<length>',
|
|
115
|
+
value: value,
|
|
116
|
+
category: 'Typography Tokens'
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Font weights
|
|
122
|
+
if (typo.weights) {
|
|
123
|
+
for (const [key, value] of Object.entries(typo.weights)) {
|
|
124
|
+
properties.push({
|
|
125
|
+
name: `--font-weight-${key}`,
|
|
126
|
+
description: `Font weight ${key}`,
|
|
127
|
+
syntax: '<number>',
|
|
128
|
+
value: value,
|
|
129
|
+
category: 'Typography Tokens'
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Line heights
|
|
135
|
+
if (typo.lineHeights) {
|
|
136
|
+
for (const [key, value] of Object.entries(typo.lineHeights)) {
|
|
137
|
+
properties.push({
|
|
138
|
+
name: `--line-height-${key}`,
|
|
139
|
+
description: `Line height ${key}`,
|
|
140
|
+
syntax: '<number> | <length>',
|
|
141
|
+
value: value,
|
|
142
|
+
category: 'Typography Tokens'
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Extract border radius tokens
|
|
149
|
+
if (compiled.tokens.radius) {
|
|
150
|
+
for (const [key, value] of Object.entries(compiled.tokens.radius)) {
|
|
151
|
+
properties.push({
|
|
152
|
+
name: `--radius-${key}`,
|
|
153
|
+
description: `Border radius ${key}`,
|
|
154
|
+
syntax: '<length>',
|
|
155
|
+
value: value,
|
|
156
|
+
category: 'Border Tokens'
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Extract border width tokens
|
|
162
|
+
if (compiled.tokens.borderWidths) {
|
|
163
|
+
for (const [key, value] of Object.entries(compiled.tokens.borderWidths)) {
|
|
164
|
+
properties.push({
|
|
165
|
+
name: `--border-width-${key}`,
|
|
166
|
+
description: `Border width ${key}`,
|
|
167
|
+
syntax: '<length>',
|
|
168
|
+
value: value,
|
|
169
|
+
category: 'Border Tokens'
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Extract shadow tokens
|
|
175
|
+
if (compiled.tokens.shadows) {
|
|
176
|
+
for (const [key, value] of Object.entries(compiled.tokens.shadows)) {
|
|
177
|
+
properties.push({
|
|
178
|
+
name: `--shadow-${key}`,
|
|
179
|
+
description: `Shadow ${key}`,
|
|
180
|
+
syntax: '<shadow>',
|
|
181
|
+
value: value,
|
|
182
|
+
category: 'Shadow Tokens'
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Extract transition tokens
|
|
188
|
+
if (compiled.tokens.transitions) {
|
|
189
|
+
for (const [key, value] of Object.entries(compiled.tokens.transitions)) {
|
|
190
|
+
properties.push({
|
|
191
|
+
name: `--transition-${key}`,
|
|
192
|
+
description: `Transition ${key}`,
|
|
193
|
+
syntax: '<time>',
|
|
194
|
+
value: value,
|
|
195
|
+
category: 'Transition Tokens'
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Extract z-index tokens
|
|
201
|
+
if (compiled.tokens.zIndex) {
|
|
202
|
+
for (const [key, value] of Object.entries(compiled.tokens.zIndex)) {
|
|
203
|
+
properties.push({
|
|
204
|
+
name: `--z-${key}`,
|
|
205
|
+
description: `Z-index ${key}`,
|
|
206
|
+
syntax: '<integer>',
|
|
207
|
+
value: value,
|
|
208
|
+
category: 'Layout Tokens'
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Extract layout tokens
|
|
214
|
+
if (compiled.tokens.layout) {
|
|
215
|
+
for (const [key, value] of Object.entries(compiled.tokens.layout)) {
|
|
216
|
+
if (key === 'breakpoints') {
|
|
217
|
+
for (const [bp, bpValue] of Object.entries(value)) {
|
|
218
|
+
properties.push({
|
|
219
|
+
name: `--breakpoint-${bp}`,
|
|
220
|
+
description: `Breakpoint ${bp}`,
|
|
221
|
+
syntax: '<length>',
|
|
222
|
+
value: bpValue,
|
|
223
|
+
category: 'Layout Tokens'
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
properties.push({
|
|
228
|
+
name: `--layout-${key}`,
|
|
229
|
+
description: `Layout ${key}`,
|
|
230
|
+
syntax: '<length>',
|
|
231
|
+
value: value,
|
|
232
|
+
category: 'Layout Tokens'
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Surface tokens (semantic)
|
|
239
|
+
const surfaceTokens = [
|
|
240
|
+
{ name: '--surface-bg', description: 'Surface background color', category: 'Surface Tokens' },
|
|
241
|
+
{ name: '--surface-text', description: 'Surface text color', category: 'Surface Tokens' },
|
|
242
|
+
{ name: '--surface-text-secondary', description: 'Surface secondary text color', category: 'Surface Tokens' },
|
|
243
|
+
{ name: '--surface-border', description: 'Surface border color', category: 'Surface Tokens' },
|
|
244
|
+
{ name: '--surface-shadow', description: 'Surface shadow', category: 'Surface Tokens' },
|
|
245
|
+
{ name: '--surface-hover', description: 'Surface hover state', category: 'Surface Tokens' },
|
|
246
|
+
];
|
|
247
|
+
|
|
248
|
+
for (const token of surfaceTokens) {
|
|
249
|
+
properties.push({
|
|
250
|
+
name: token.name,
|
|
251
|
+
description: token.description,
|
|
252
|
+
syntax: '<color>',
|
|
253
|
+
category: token.category
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return properties;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Extract CSS classes from ontology and utilities
|
|
262
|
+
*/
|
|
263
|
+
async function extractCSSClasses(ontology) {
|
|
264
|
+
const classes = [];
|
|
265
|
+
|
|
266
|
+
// Primitives
|
|
267
|
+
if (ontology.primitives) {
|
|
268
|
+
for (const primitive of ontology.primitives) {
|
|
269
|
+
for (const selector of primitive.selectors) {
|
|
270
|
+
// Only add class selectors
|
|
271
|
+
if (selector.startsWith('.')) {
|
|
272
|
+
const className = selector.slice(1);
|
|
273
|
+
classes.push({
|
|
274
|
+
name: className,
|
|
275
|
+
description: `${primitive.name} primitive component`,
|
|
276
|
+
category: 'Primitives'
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Components
|
|
284
|
+
if (ontology.components) {
|
|
285
|
+
for (const component of ontology.components) {
|
|
286
|
+
for (const selector of component.selectors) {
|
|
287
|
+
if (selector.startsWith('.')) {
|
|
288
|
+
const className = selector.slice(1);
|
|
289
|
+
classes.push({
|
|
290
|
+
name: className,
|
|
291
|
+
description: `${component.name} component`,
|
|
292
|
+
category: 'Components'
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Layout patterns
|
|
300
|
+
if (ontology.layoutPatterns) {
|
|
301
|
+
for (const pattern of ontology.layoutPatterns) {
|
|
302
|
+
for (const selector of pattern.selectors) {
|
|
303
|
+
if (selector.startsWith('.')) {
|
|
304
|
+
const className = selector.slice(1);
|
|
305
|
+
classes.push({
|
|
306
|
+
name: className,
|
|
307
|
+
description: pattern.description || `${pattern.name} layout pattern`,
|
|
308
|
+
category: 'Layout Utilities'
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Utilities
|
|
316
|
+
if (ontology.utilities) {
|
|
317
|
+
for (const utility of ontology.utilities) {
|
|
318
|
+
if (utility.startsWith('.')) {
|
|
319
|
+
const className = utility.slice(1);
|
|
320
|
+
|
|
321
|
+
// Handle wildcard utilities
|
|
322
|
+
if (className.includes('*')) {
|
|
323
|
+
const baseClass = className.replace('*', '');
|
|
324
|
+
const variants = generateUtilityVariants(baseClass);
|
|
325
|
+
for (const variant of variants) {
|
|
326
|
+
classes.push({
|
|
327
|
+
name: variant.name,
|
|
328
|
+
description: variant.description,
|
|
329
|
+
category: 'Utilities'
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
classes.push({
|
|
334
|
+
name: className,
|
|
335
|
+
description: `${className} utility class`,
|
|
336
|
+
category: 'Utilities'
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return classes;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Generate common variants for wildcard utilities
|
|
348
|
+
*/
|
|
349
|
+
function generateUtilityVariants(baseClass) {
|
|
350
|
+
const variants = [];
|
|
351
|
+
|
|
352
|
+
if (baseClass.includes('gap-')) {
|
|
353
|
+
// Gap utilities (0-12)
|
|
354
|
+
for (let i = 0; i <= 12; i++) {
|
|
355
|
+
variants.push({
|
|
356
|
+
name: `gap-${i}`,
|
|
357
|
+
description: `Gap spacing of ${i} units`
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
} else if (baseClass.includes('items-')) {
|
|
361
|
+
// Flexbox align-items
|
|
362
|
+
const alignments = ['start', 'end', 'center', 'baseline', 'stretch'];
|
|
363
|
+
for (const align of alignments) {
|
|
364
|
+
variants.push({
|
|
365
|
+
name: `items-${align}`,
|
|
366
|
+
description: `Align items: ${align}`
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
} else if (baseClass.includes('justify-')) {
|
|
370
|
+
// Flexbox justify-content
|
|
371
|
+
const justifications = ['start', 'end', 'center', 'between', 'around', 'evenly'];
|
|
372
|
+
for (const justify of justifications) {
|
|
373
|
+
variants.push({
|
|
374
|
+
name: `justify-${justify}`,
|
|
375
|
+
description: `Justify content: ${justify}`
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
} else if (baseClass.includes('border-glow-')) {
|
|
379
|
+
// Border glow variants
|
|
380
|
+
const colors = ['primary', 'secondary', 'accent', 'success', 'warning', 'danger', 'info'];
|
|
381
|
+
for (const color of colors) {
|
|
382
|
+
variants.push({
|
|
383
|
+
name: `border-glow-${color}`,
|
|
384
|
+
description: `Border glow effect with ${color} color`
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return variants;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Extract data attributes from enhancements
|
|
394
|
+
*/
|
|
395
|
+
function extractDataAttributes(ontology) {
|
|
396
|
+
const attributes = [];
|
|
397
|
+
|
|
398
|
+
if (ontology.enhancements) {
|
|
399
|
+
for (const enhancement of ontology.enhancements) {
|
|
400
|
+
// Extract data attributes from selectors like "[data-dropdown]"
|
|
401
|
+
const matches = enhancement.match(/\[data-([^\]]+)\]/g);
|
|
402
|
+
if (matches) {
|
|
403
|
+
for (const match of matches) {
|
|
404
|
+
const attrName = match.slice(1, -1); // Remove [ and ]
|
|
405
|
+
attributes.push({
|
|
406
|
+
name: attrName,
|
|
407
|
+
description: `Enhancement: ${enhancement}`,
|
|
408
|
+
category: 'Data Enhancements'
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return attributes;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Convert to VS Code CSS custom data format
|
|
420
|
+
*/
|
|
421
|
+
function toVSCodeFormat(properties, classes) {
|
|
422
|
+
return {
|
|
423
|
+
version: 1.1,
|
|
424
|
+
properties: properties.map(prop => ({
|
|
425
|
+
name: prop.name,
|
|
426
|
+
description: prop.description,
|
|
427
|
+
syntax: prop.syntax || '<custom-ident>',
|
|
428
|
+
...(prop.value && { references: [{ name: 'Value', url: `data:text/plain,${encodeURIComponent(prop.value)}` }] })
|
|
429
|
+
})),
|
|
430
|
+
atDirectives: [],
|
|
431
|
+
pseudoClasses: classes.map(cls => ({
|
|
432
|
+
name: cls.name,
|
|
433
|
+
description: cls.description
|
|
434
|
+
})).slice(0, 100), // Limit for performance
|
|
435
|
+
pseudoElements: []
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Convert to standard CSS data format (for other editors)
|
|
441
|
+
*/
|
|
442
|
+
function toStandardFormat(properties, classes, attributes) {
|
|
443
|
+
return {
|
|
444
|
+
version: '1.1',
|
|
445
|
+
cssProperties: properties.map(prop => ({
|
|
446
|
+
name: prop.name,
|
|
447
|
+
description: prop.description,
|
|
448
|
+
syntax: prop.syntax || '<custom-ident>',
|
|
449
|
+
value: prop.value || undefined,
|
|
450
|
+
category: prop.category
|
|
451
|
+
})),
|
|
452
|
+
cssClasses: classes.map(cls => ({
|
|
453
|
+
name: cls.name,
|
|
454
|
+
description: cls.description,
|
|
455
|
+
category: cls.category
|
|
456
|
+
})),
|
|
457
|
+
dataAttributes: attributes.map(attr => ({
|
|
458
|
+
name: attr.name,
|
|
459
|
+
description: attr.description,
|
|
460
|
+
category: attr.category
|
|
461
|
+
})),
|
|
462
|
+
metadata: {
|
|
463
|
+
generator: 'PDS CSS Data Generator',
|
|
464
|
+
generatedAt: new Date().toISOString(),
|
|
465
|
+
totalProperties: properties.length,
|
|
466
|
+
totalClasses: classes.length,
|
|
467
|
+
totalAttributes: attributes.length
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Generate CSS IntelliSense data files
|
|
474
|
+
*/
|
|
475
|
+
async function generateCSSData(targetDir) {
|
|
476
|
+
try {
|
|
477
|
+
log('šØ Generating CSS IntelliSense data...', 'bold');
|
|
478
|
+
|
|
479
|
+
// Import Generator and ontology
|
|
480
|
+
const generatorPath = path.join(repoRoot, 'src/js/pds-core/pds-generator.js');
|
|
481
|
+
const ontologyPath = path.join(repoRoot, 'src/js/pds-core/pds-ontology.js');
|
|
482
|
+
const configPath = path.join(repoRoot, 'src/js/pds-core/pds-config.js');
|
|
483
|
+
|
|
484
|
+
log('š¦ Loading PDS modules...', 'blue');
|
|
485
|
+
const { Generator } = await import(pathToFileURL(generatorPath).href);
|
|
486
|
+
const { ontology } = await import(pathToFileURL(ontologyPath).href);
|
|
487
|
+
const { presets } = await import(pathToFileURL(configPath).href);
|
|
488
|
+
|
|
489
|
+
// Generate design system with default preset
|
|
490
|
+
log('āļø Generating design system...', 'blue');
|
|
491
|
+
const generator = new Generator({ preset: 'default', design: presets.default });
|
|
492
|
+
|
|
493
|
+
// Extract data
|
|
494
|
+
log('š Extracting CSS properties...', 'blue');
|
|
495
|
+
const properties = extractCSSProperties(generator);
|
|
496
|
+
log(` Found ${properties.length} CSS custom properties`, 'cyan');
|
|
497
|
+
|
|
498
|
+
log('š Extracting CSS classes...', 'blue');
|
|
499
|
+
const classes = await extractCSSClasses(ontology);
|
|
500
|
+
log(` Found ${classes.length} CSS classes`, 'cyan');
|
|
501
|
+
|
|
502
|
+
log('š Extracting data attributes...', 'blue');
|
|
503
|
+
const attributes = extractDataAttributes(ontology);
|
|
504
|
+
log(` Found ${attributes.length} data attributes`, 'cyan');
|
|
505
|
+
|
|
506
|
+
// Generate VS Code format
|
|
507
|
+
log('š Generating VS Code CSS custom data...', 'blue');
|
|
508
|
+
const vscodeData = toVSCodeFormat(properties, classes);
|
|
509
|
+
|
|
510
|
+
// Generate standard format
|
|
511
|
+
log('š Generating standard CSS data...', 'blue');
|
|
512
|
+
const standardData = toStandardFormat(properties, classes, attributes);
|
|
513
|
+
|
|
514
|
+
// Write files to repository
|
|
515
|
+
const vscodeOutputPath = path.join(repoRoot, 'public/assets/pds/pds.css-data.json');
|
|
516
|
+
const standardOutputPath = path.join(repoRoot, 'public/assets/pds/pds-css-complete.json');
|
|
517
|
+
|
|
518
|
+
await mkdir(path.dirname(vscodeOutputPath), { recursive: true });
|
|
519
|
+
await writeFile(vscodeOutputPath, JSON.stringify(vscodeData, null, 2), 'utf-8');
|
|
520
|
+
log(`ā
VS Code CSS data: ${path.relative(repoRoot, vscodeOutputPath)}`, 'green');
|
|
521
|
+
|
|
522
|
+
await writeFile(standardOutputPath, JSON.stringify(standardData, null, 2), 'utf-8');
|
|
523
|
+
log(`ā
Standard CSS data: ${path.relative(repoRoot, standardOutputPath)}`, 'green');
|
|
524
|
+
|
|
525
|
+
// Copy to target directory if specified
|
|
526
|
+
if (targetDir) {
|
|
527
|
+
const targetVSCodePath = path.join(targetDir, 'pds.css-data.json');
|
|
528
|
+
const targetStandardPath = path.join(targetDir, 'pds-css-complete.json');
|
|
529
|
+
|
|
530
|
+
await mkdir(targetDir, { recursive: true });
|
|
531
|
+
await writeFile(targetVSCodePath, JSON.stringify(vscodeData, null, 2), 'utf-8');
|
|
532
|
+
await writeFile(targetStandardPath, JSON.stringify(standardData, null, 2), 'utf-8');
|
|
533
|
+
|
|
534
|
+
log(`ā
Copied to ${path.relative(process.cwd(), targetDir)}`, 'green');
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Create workspace settings reference
|
|
538
|
+
const settingsRef = {
|
|
539
|
+
"css.customData": ["public/assets/pds/pds.css-data.json"]
|
|
540
|
+
};
|
|
541
|
+
const settingsPath = path.join(repoRoot, 'pds.css-data.json');
|
|
542
|
+
await writeFile(settingsPath, JSON.stringify(settingsRef, null, 2), 'utf-8');
|
|
543
|
+
log(`ā
Created settings reference: pds.css-data.json`, 'green');
|
|
544
|
+
|
|
545
|
+
log('\n⨠CSS IntelliSense data generation complete!', 'bold');
|
|
546
|
+
log('š To enable in VS Code, add to .vscode/settings.json:', 'cyan');
|
|
547
|
+
log(' "css.customData": ["node_modules/pure-ds/public/assets/pds/pds.css-data.json"]', 'blue');
|
|
548
|
+
|
|
549
|
+
return true;
|
|
550
|
+
} catch (error) {
|
|
551
|
+
log(`ā Error generating CSS data: ${error.message}`, 'red');
|
|
552
|
+
console.error(error);
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
export { generateCSSData };
|
|
558
|
+
|
|
559
|
+
// Run if called directly
|
|
560
|
+
if (process.argv[1] && process.argv[1].endsWith('generate-css-data.js')) {
|
|
561
|
+
const targetDir = process.argv[2] || null;
|
|
562
|
+
generateCSSData(targetDir).then(success => {
|
|
563
|
+
process.exit(success ? 0 : 1);
|
|
564
|
+
});
|
|
565
|
+
}
|