spoko-design-system 0.9.2 → 0.9.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/uno-config/index.ts +111 -109
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spoko-design-system",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "private": false,
5
5
  "main": "./index.ts",
6
6
  "module": "./index.ts",
@@ -19,6 +19,32 @@ import presetWebFonts from '@unocss/preset-web-fonts'; // Web fonts preset
19
19
  import { shortcuts } from './theme/shortcuts';
20
20
  import { theme } from './theme';
21
21
 
22
+ // Static imports for all icon collections (prevents Vite module runner issues)
23
+ import antDesignIcons from '@iconify-json/ant-design/icons.json';
24
+ import biIcons from '@iconify-json/bi/icons.json';
25
+ import bxIcons from '@iconify-json/bx/icons.json';
26
+ import carbonIcons from '@iconify-json/carbon/icons.json';
27
+ import circleFlagsIcons from '@iconify-json/circle-flags/icons.json';
28
+ import eiIcons from '@iconify-json/ei/icons.json';
29
+ import elIcons from '@iconify-json/el/icons.json';
30
+ import eosIcons from '@iconify-json/eos-icons/icons.json';
31
+ import etIcons from '@iconify-json/et/icons.json';
32
+ import flowbiteIcons from '@iconify-json/flowbite/icons.json';
33
+ import fluentIcons from '@iconify-json/fluent/icons.json';
34
+ import fluentEmojiIcons from '@iconify-json/fluent-emoji/icons.json';
35
+ import icIcons from '@iconify-json/ic/icons.json';
36
+ import iconParkOutlineIcons from '@iconify-json/icon-park-outline/icons.json';
37
+ import laIcons from '@iconify-json/la/icons.json';
38
+ import lucideIcons from '@iconify-json/lucide/icons.json';
39
+ import materialSymbolsLightIcons from '@iconify-json/material-symbols-light/icons.json';
40
+ import mdiIcons from '@iconify-json/mdi/icons.json';
41
+ import notoV1Icons from '@iconify-json/noto-v1/icons.json';
42
+ import octiconIcons from '@iconify-json/octicon/icons.json';
43
+ import phIcons from '@iconify-json/ph/icons.json';
44
+ import simpleIcons from '@iconify-json/simple-icons/icons.json';
45
+ import systemUiconsIcons from '@iconify-json/system-uicons/icons.json';
46
+ import uilIcons from '@iconify-json/uil/icons.json';
47
+
22
48
  // List of peer selectors we want to preserve during build
23
49
  const peerSelectorClasses = [
24
50
  // Focus state classes
@@ -56,6 +82,12 @@ interface CustomConfig extends Partial<UserConfig> {
56
82
  */
57
83
  export function createSdsConfig(customConfig: CustomConfig = {}) {
58
84
  return defineConfig({
85
+ // Optimizations for static builds
86
+ ...(process.env.NODE_ENV === 'production' && {
87
+ inspector: false,
88
+ hmr: false,
89
+ }),
90
+
59
91
  // Transform directives and variant groups
60
92
  transformers: [
61
93
  transformerDirectives(),
@@ -101,134 +133,71 @@ export function createSdsConfig(customConfig: CustomConfig = {}) {
101
133
  };
102
134
  },
103
135
  ],
104
- // Comprehensive safelist with all needed classes
136
+ // Optimized safelist for static Astro builds
105
137
  safelist: [
106
- // Existing safelist items
138
+ // Layout and grid classes that might be used dynamically
107
139
  'md:grid-cols-product',
108
140
 
141
+ // Component-specific classes for static generation
109
142
  'breadcrumb-link-disabled',
110
143
  'breadcrumb-link',
111
144
  'breadcrumb-item',
112
145
  'features-list-caption',
113
146
  'features-list-ul',
114
147
  'features-list-item',
115
-
116
148
  'category-link-base',
117
149
  'category-link-active',
118
-
119
- // Base peer class
150
+
151
+ // Essential peer and input classes
120
152
  'peer',
121
-
122
- // All input component classes from shortcuts
123
- 'input-base',
124
- 'input-label-base',
125
- 'input-placeholder',
126
- 'input-standard',
127
- 'input-filled',
128
- 'input-wrapper-standard',
129
- 'input-wrapper-filled',
130
- 'input-label-standard',
131
- 'input-label-filled',
132
-
133
- // Label state shortcuts
134
- 'input-label-focus-color',
135
- 'input-label-focus-scale',
136
- 'input-label-focus-translate-standard',
137
- 'input-label-focus-translate-filled',
138
- 'input-label-placeholder',
139
- 'input-label-filled-standard',
140
- 'input-label-filled-filled',
141
- 'input-label-standard-state',
142
- 'input-label-filled-state',
143
-
144
- // Input types
145
- 'input-textarea',
146
153
  'resize-none',
147
-
148
- // Size variants
149
- 'input-sm',
150
- 'input-md',
151
- 'input-lg',
152
- 'input-label-sm',
153
- 'input-label-md',
154
- 'input-label-lg',
155
-
156
- // Status classes
157
- 'input-error',
158
- 'input-label-error',
159
- 'input-error-message',
160
- 'input-success',
161
- 'input-label-success',
162
- 'input-success-message',
163
-
164
- // Transform related classes
165
154
  'origin-top-left',
166
155
  'transform-gpu',
167
- 'translate-y-0',
168
- '-translate-y-4',
169
- '-translate-y-6',
170
- 'scale-75',
171
- 'scale-100',
172
-
173
- // Every possible arbitrary selector used
174
- '[&:focus~label]:scale-75',
175
- '[&:focus~label]:-translate-y-4',
176
- '[&:focus~label]:-translate-y-6',
177
- '[&:focus~label]:text-blue-light',
178
- '[&:focus~label]:dark:text-blue-lightest',
179
- '[&:focus~label]:start-0',
180
- '[&:placeholder-shown~label]:scale-100',
181
- '[&:placeholder-shown~label]:translate-y-0',
182
- '[&:not(:placeholder-shown)~label]:scale-75',
183
- '[&:not(:placeholder-shown)~label]:-translate-y-4',
184
- '[&:not(:placeholder-shown)~label]:-translate-y-6',
185
-
186
- // Combinations of selectors
187
- 'peer:focus:text-blue-light',
188
- 'peer:focus:dark:text-blue-lightest',
189
- 'peer:focus:scale-75',
190
- 'peer:focus:-translate-y-4',
191
- 'peer:focus:-translate-y-6',
192
- 'peer:focus:start-0',
193
- 'peer-placeholder-shown:scale-100',
194
- 'peer-placeholder-shown:translate-y-0',
195
- 'peer-not-placeholder-shown:scale-75',
196
- 'peer-not-placeholder-shown:-translate-y-4',
197
- 'peer-not-placeholder-shown:-translate-y-6',
198
-
199
- // With !important for good measure
200
- '[&:focus~label]:!scale-75',
201
- '[&:focus~label]:!-translate-y-4',
202
- '[&:focus~label]:!-translate-y-6',
203
- '[&:not(:placeholder-shown)~label]:!scale-75',
204
- '[&:not(:placeholder-shown)~label]:!-translate-y-4',
205
- '[&:not(:placeholder-shown)~label]:!-translate-y-6',
206
-
207
- // Direct css vars that might be used
208
- '--un-scale-x',
209
- '--un-scale-y',
210
- '--un-translate-y',
211
-
212
- // All peer selectors from the list
156
+
157
+ // All peer selectors from the list (needed for floating labels)
213
158
  ...peerSelectorClasses,
214
159
  ],
215
- // Custom extractors to ensure peer classes are preserved
160
+ // Optimized extractors for static Astro builds
216
161
  extractors: [
217
162
  {
218
- name: 'vue-astro',
219
- extract({ code }) {
163
+ name: 'astro-static',
164
+ extract({ code, id }) {
220
165
  const result = new Set();
221
-
222
- // Extract all peer selectors in the code
223
- const peerRegex = /peer-([a-zA-Z0-9-]+:[a-zA-Z0-9-]+)/g;
166
+
167
+ // Enhanced class extraction for Astro components
168
+ const classRegex = /class(?:Name)?=["'`]([^"'`]+)["'`]/g;
169
+ let match;
170
+ while ((match = classRegex.exec(code)) !== null) {
171
+ match[1].split(/\s+/).forEach(cls => {
172
+ if (cls) result.add(cls);
173
+ });
174
+ }
175
+
176
+ // Extract peer selectors
177
+ const peerRegex = /peer-[a-zA-Z0-9-]+(?::[a-zA-Z0-9-]+)*/g;
224
178
  const peerMatches = code.match(peerRegex);
225
179
  if (peerMatches) {
226
180
  peerMatches.forEach(match => result.add(match));
227
181
  }
228
-
229
- // Add all known peer selectors
230
- peerSelectorClasses.forEach(cls => result.add(cls));
231
-
182
+
183
+ // Extract shortcut references
184
+ const shortcutRegex = /\b(?:input|button|layout|component|product|jumbotron)-[a-zA-Z0-9-]+/g;
185
+ const shortcutMatches = code.match(shortcutRegex);
186
+ if (shortcutMatches) {
187
+ shortcutMatches.forEach(match => result.add(match));
188
+ }
189
+
190
+ // For .astro files, extract from both template and script sections
191
+ if (id && id.endsWith('.astro')) {
192
+ // Extract from dynamic class bindings
193
+ const dynamicClassRegex = /class:\w+\s*=\s*["'`]([^"'`]+)["'`]/g;
194
+ while ((match = dynamicClassRegex.exec(code)) !== null) {
195
+ match[1].split(/\s+/).forEach(cls => {
196
+ if (cls) result.add(cls);
197
+ });
198
+ }
199
+ }
200
+
232
201
  return result;
233
202
  },
234
203
  },
@@ -246,11 +215,31 @@ export function createSdsConfig(customConfig: CustomConfig = {}) {
246
215
  'vertical-align': 'middle',
247
216
  },
248
217
  collections: {
249
- // Only load specific icon collections to prevent auto-detection issues
250
- 'lucide': () => import('@iconify-json/lucide/icons.json').then(i => i.default),
251
- 'simple-icons': () => import('@iconify-json/simple-icons/icons.json').then(i => i.default),
252
- 'mdi': () => import('@iconify-json/mdi/icons.json').then(i => i.default),
253
- 'carbon': () => import('@iconify-json/carbon/icons.json').then(i => i.default),
218
+ // All icon collections with static imports to prevent Vite module runner issues
219
+ 'ant-design': antDesignIcons,
220
+ 'bi': biIcons,
221
+ 'bx': bxIcons,
222
+ 'carbon': carbonIcons,
223
+ 'circle-flags': circleFlagsIcons,
224
+ 'ei': eiIcons,
225
+ 'el': elIcons,
226
+ 'eos-icons': eosIcons,
227
+ 'et': etIcons,
228
+ 'flowbite': flowbiteIcons,
229
+ 'fluent': fluentIcons,
230
+ 'fluent-emoji': fluentEmojiIcons,
231
+ 'ic': icIcons,
232
+ 'icon-park-outline': iconParkOutlineIcons,
233
+ 'la': laIcons,
234
+ 'lucide': lucideIcons,
235
+ 'material-symbols-light': materialSymbolsLightIcons,
236
+ 'mdi': mdiIcons,
237
+ 'noto-v1': notoV1Icons,
238
+ 'octicon': octiconIcons,
239
+ 'ph': phIcons,
240
+ 'simple-icons': simpleIcons,
241
+ 'system-uicons': systemUiconsIcons,
242
+ 'uil': uilIcons,
254
243
  }
255
244
  }),
256
245
  presetTypography(),
@@ -259,6 +248,19 @@ export function createSdsConfig(customConfig: CustomConfig = {}) {
259
248
  fonts: theme.fontFamily
260
249
  })
261
250
  ],
251
+
252
+ // Additional optimizations for static Astro builds
253
+ preflights: [
254
+ {
255
+ getCSS: () => `
256
+ /* Optimized base styles for static builds */
257
+ *,*::before,*::after{box-sizing:border-box}
258
+ html{line-height:1.15;-webkit-text-size-adjust:100%}
259
+ body{margin:0;font-family:system-ui,sans-serif}
260
+ `
261
+ }
262
+ ],
263
+
262
264
  ...customConfig
263
265
  });
264
266
  }