@udixio/theme 1.1.0 → 1.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/bin/main.ts +85 -0
  3. package/dist/API.d.ts +1 -0
  4. package/dist/API.d.ts.map +1 -1
  5. package/dist/bin.cjs +64 -0
  6. package/dist/bin.js +63 -0
  7. package/dist/browser.cjs +39 -0
  8. package/dist/browser.js +39 -0
  9. package/dist/color/color.manager.d.ts.map +1 -1
  10. package/dist/color/default-color.d.ts.map +1 -1
  11. package/dist/config/config.interface.d.ts.map +1 -0
  12. package/dist/config/define-config.d.ts.map +1 -0
  13. package/dist/config/index.d.ts +3 -0
  14. package/dist/config/index.d.ts.map +1 -0
  15. package/dist/config/index.node.d.ts +2 -0
  16. package/dist/config/index.node.d.ts.map +1 -0
  17. package/dist/config/resolver-config.d.ts +11 -0
  18. package/dist/config/resolver-config.d.ts.map +1 -0
  19. package/dist/define-config-B1QPKKY_.js +430 -0
  20. package/dist/define-config-BGgVazsr.cjs +429 -0
  21. package/dist/index.browser.d.ts +2 -0
  22. package/dist/index.browser.d.ts.map +1 -0
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.node.d.ts +4 -0
  26. package/dist/index.node.d.ts.map +1 -0
  27. package/dist/load-from-path-BSrT4DOj.js +39 -0
  28. package/dist/load-from-path-BuN8RpOs.cjs +78 -0
  29. package/dist/loader/index.d.ts +2 -0
  30. package/dist/loader/index.d.ts.map +1 -0
  31. package/dist/loader/index.node.d.ts +3 -0
  32. package/dist/loader/index.node.d.ts.map +1 -0
  33. package/dist/loader/load-from-path.d.ts +5 -0
  34. package/dist/loader/load-from-path.d.ts.map +1 -0
  35. package/dist/loader/loader.d.ts +3 -0
  36. package/dist/loader/loader.d.ts.map +1 -0
  37. package/dist/loader/unplugin.d.ts +16 -0
  38. package/dist/loader/unplugin.d.ts.map +1 -0
  39. package/dist/{index.js → loader-Bc0bstAD.js} +172 -661
  40. package/dist/{index.cjs → loader-YNN5hAF3.cjs} +148 -678
  41. package/dist/material-color-utilities/dynamic_color.d.ts +9 -15
  42. package/dist/material-color-utilities/dynamic_color.d.ts.map +1 -1
  43. package/dist/material-color-utilities/toneDeltaPair.d.ts +9 -2
  44. package/dist/material-color-utilities/toneDeltaPair.d.ts.map +1 -1
  45. package/dist/node.cjs +191 -0
  46. package/dist/node.js +170 -0
  47. package/dist/plugin/plugin.api.d.ts +1 -1
  48. package/dist/plugin/plugin.api.d.ts.map +1 -1
  49. package/dist/theme/scheme.d.ts +1 -1
  50. package/dist/theme/scheme.d.ts.map +1 -1
  51. package/dist/theme/variants/fidelity.variant.d.ts +3 -0
  52. package/dist/theme/variants/fidelity.variant.d.ts.map +1 -0
  53. package/dist/theme/variants/index.d.ts +1 -0
  54. package/dist/theme/variants/index.d.ts.map +1 -1
  55. package/package.json +27 -10
  56. package/src/API.ts +4 -0
  57. package/src/color/color.manager.ts +10 -8
  58. package/src/color/default-color.ts +82 -34
  59. package/src/config/index.node.ts +1 -0
  60. package/src/{adapter → config}/index.ts +0 -1
  61. package/src/config/resolver-config.ts +49 -0
  62. package/src/index.browser.ts +1 -0
  63. package/src/index.node.ts +3 -0
  64. package/src/index.ts +2 -2
  65. package/src/loader/index.node.ts +2 -0
  66. package/src/loader/index.ts +1 -0
  67. package/src/loader/load-from-path.ts +9 -0
  68. package/src/{adapter/adapter.abstract.ts → loader/loader.ts} +23 -28
  69. package/src/loader/unplugin.ts +158 -0
  70. package/src/material-color-utilities/dynamic_color.ts +18 -120
  71. package/src/material-color-utilities/toneDeltaPair.ts +91 -2
  72. package/src/plugin/plugin.api.ts +4 -4
  73. package/src/theme/scheme.ts +7 -1
  74. package/src/theme/variants/fidelity.variant.ts +38 -0
  75. package/src/theme/variants/index.ts +2 -0
  76. package/vite.config.ts +18 -4
  77. package/dist/adapter/adapter.abstract.d.ts +0 -10
  78. package/dist/adapter/adapter.abstract.d.ts.map +0 -1
  79. package/dist/adapter/config.interface.d.ts.map +0 -1
  80. package/dist/adapter/define-config.d.ts.map +0 -1
  81. package/dist/adapter/file-adapter.mixin.d.ts +0 -18
  82. package/dist/adapter/file-adapter.mixin.d.ts.map +0 -1
  83. package/dist/adapter/index.d.ts +0 -4
  84. package/dist/adapter/index.d.ts.map +0 -1
  85. package/dist/adapters/index.d.ts +0 -3
  86. package/dist/adapters/index.d.ts.map +0 -1
  87. package/dist/adapters/node.adapter.d.ts +0 -7
  88. package/dist/adapters/node.adapter.d.ts.map +0 -1
  89. package/dist/adapters/vite.adapter.d.ts +0 -3
  90. package/dist/adapters/vite.adapter.d.ts.map +0 -1
  91. package/src/adapter/file-adapter.mixin.ts +0 -72
  92. package/src/adapters/index.ts +0 -2
  93. package/src/adapters/node.adapter.ts +0 -57
  94. package/src/adapters/vite.adapter.ts +0 -79
  95. /package/dist/{adapter → config}/config.interface.d.ts +0 -0
  96. /package/dist/{adapter → config}/define-config.d.ts +0 -0
  97. /package/src/{adapter → config}/config.interface.ts +0 -0
  98. /package/src/{adapter → config}/define-config.ts +0 -0
@@ -0,0 +1,430 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { p as getRotatedHue, o as getPiecewiseHue, H as Hct, k as tonalSpotVariant } from "./loader-Bc0bstAD.js";
5
+ import { TonalPalette } from "@material/material-color-utilities";
6
+ const getExpressiveNeutralHue = (sourceColorHct) => {
7
+ const hue = getRotatedHue(
8
+ sourceColorHct,
9
+ [0, 71, 124, 253, 278, 300, 360],
10
+ [10, 0, 10, 0, 10, 0]
11
+ );
12
+ return hue;
13
+ };
14
+ const getExpressiveNeutralChroma = (sourceColorHct, isDark) => {
15
+ const neutralHue = getExpressiveNeutralHue(sourceColorHct);
16
+ return isDark ? Hct.isYellow(neutralHue) ? 6 : 14 : 18;
17
+ };
18
+ const expressiveVariant = {
19
+ name: "expressive",
20
+ palettes: {
21
+ primary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 36 : 48),
22
+ secondary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(
23
+ getRotatedHue(
24
+ sourceColorHct,
25
+ [0, 105, 140, 204, 253, 278, 300, 333, 360],
26
+ [-160, 155, -100, 96, -96, -156, -165, -160]
27
+ ),
28
+ isDark ? 16 : 24
29
+ ),
30
+ tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
31
+ getRotatedHue(
32
+ sourceColorHct,
33
+ [0, 105, 140, 204, 253, 278, 300, 333, 360],
34
+ [-165, 160, -105, 101, -101, -160, -170, -165]
35
+ ),
36
+ 48
37
+ ),
38
+ neutral: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(
39
+ getExpressiveNeutralHue(sourceColorHct),
40
+ getExpressiveNeutralChroma(sourceColorHct, isDark)
41
+ ),
42
+ neutralVariant: ({ sourceColorHct, isDark }) => {
43
+ const expressiveNeutralHue = getExpressiveNeutralHue(sourceColorHct);
44
+ const expressiveNeutralChroma = getExpressiveNeutralChroma(
45
+ sourceColorHct,
46
+ isDark
47
+ );
48
+ return TonalPalette.fromHueAndChroma(
49
+ expressiveNeutralHue,
50
+ expressiveNeutralChroma * (expressiveNeutralHue >= 105 && expressiveNeutralHue < 125 ? 1.6 : 2.3)
51
+ );
52
+ },
53
+ error: ({ sourceColorHct }) => {
54
+ const errorHue = getPiecewiseHue(
55
+ sourceColorHct,
56
+ [0, 3, 13, 23, 33, 43, 153, 273, 360],
57
+ [12, 22, 32, 12, 22, 32, 22, 12]
58
+ );
59
+ return TonalPalette.fromHueAndChroma(errorHue, 64);
60
+ }
61
+ },
62
+ customPalettes: ({ colorHct, isDark }) => TonalPalette.fromHueAndChroma(
63
+ getRotatedHue(
64
+ colorHct,
65
+ [0, 105, 140, 204, 253, 278, 300, 333, 360],
66
+ [-160, 155, -100, 96, -96, -156, -165, -160]
67
+ ),
68
+ isDark ? 16 : 24
69
+ )
70
+ };
71
+ const neutralVariant = {
72
+ name: "neutral",
73
+ palettes: {
74
+ primary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
75
+ sourceColorHct.hue,
76
+ Hct.isBlue(sourceColorHct.hue) ? 12 : 8
77
+ ),
78
+ secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
79
+ sourceColorHct.hue,
80
+ Hct.isBlue(sourceColorHct.hue) ? 6 : 4
81
+ ),
82
+ tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
83
+ getRotatedHue(
84
+ sourceColorHct,
85
+ [0, 38, 105, 161, 204, 278, 333, 360],
86
+ [-32, 26, 10, -39, 24, -15, -32]
87
+ ),
88
+ 20
89
+ ),
90
+ neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4),
91
+ neutralVariant: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4 * 2.2),
92
+ error: ({ sourceColorHct }) => {
93
+ const errorHue = getPiecewiseHue(
94
+ sourceColorHct,
95
+ [0, 3, 13, 23, 33, 43, 153, 273, 360],
96
+ [12, 22, 32, 12, 22, 32, 22, 12]
97
+ );
98
+ return TonalPalette.fromHueAndChroma(errorHue, 50);
99
+ }
100
+ },
101
+ customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(
102
+ colorHct.hue,
103
+ Hct.isBlue(colorHct.hue) ? 6 : 4
104
+ )
105
+ };
106
+ const getVibrantNeutralHue = (sourceColorHct) => {
107
+ return getRotatedHue(
108
+ sourceColorHct,
109
+ [0, 38, 105, 140, 333, 360],
110
+ [-14, 10, -14, 10, -14]
111
+ );
112
+ };
113
+ const getVibrantNeutralChroma = (sourceColorHct) => {
114
+ getVibrantNeutralHue(sourceColorHct);
115
+ return 28;
116
+ };
117
+ const vibrantVariant = {
118
+ name: "vibrant",
119
+ palettes: {
120
+ primary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 74),
121
+ secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
122
+ getRotatedHue(
123
+ sourceColorHct,
124
+ [0, 38, 105, 140, 333, 360],
125
+ [-14, 10, -14, 10, -14]
126
+ ),
127
+ 56
128
+ ),
129
+ tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
130
+ getRotatedHue(
131
+ sourceColorHct,
132
+ [0, 38, 71, 105, 140, 161, 253, 333, 360],
133
+ [-72, 35, 24, -24, 62, 50, 62, -72]
134
+ ),
135
+ 56
136
+ ),
137
+ neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
138
+ getVibrantNeutralHue(sourceColorHct),
139
+ getVibrantNeutralChroma(sourceColorHct)
140
+ ),
141
+ neutralVariant: ({ sourceColorHct }) => {
142
+ const vibrantNeutralHue = getVibrantNeutralHue(sourceColorHct);
143
+ const vibrantNeutralChroma = getVibrantNeutralChroma(sourceColorHct);
144
+ return TonalPalette.fromHueAndChroma(
145
+ vibrantNeutralHue,
146
+ vibrantNeutralChroma * 1.29
147
+ );
148
+ },
149
+ error: ({ sourceColorHct }) => {
150
+ const errorHue = getPiecewiseHue(
151
+ sourceColorHct,
152
+ [0, 3, 13, 23, 33, 43, 153, 273, 360],
153
+ [12, 22, 32, 12, 22, 32, 22, 12]
154
+ );
155
+ return TonalPalette.fromHueAndChroma(errorHue, 80);
156
+ }
157
+ },
158
+ customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(
159
+ getRotatedHue(
160
+ colorHct,
161
+ [0, 38, 105, 140, 333, 360],
162
+ [-14, 10, -14, 10, -14]
163
+ ),
164
+ 56
165
+ )
166
+ };
167
+ const fidelityVariant = {
168
+ name: "fidelity",
169
+ palettes: {
170
+ primary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, sourceColorHct.chroma),
171
+ secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
172
+ sourceColorHct.hue,
173
+ sourceColorHct.chroma * 0.5
174
+ ),
175
+ tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(
176
+ getRotatedHue(
177
+ sourceColorHct,
178
+ [0, 20, 71, 161, 333, 360],
179
+ [-40, 48, -32, 40, -32]
180
+ ),
181
+ sourceColorHct.chroma
182
+ ),
183
+ neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5),
184
+ neutralVariant: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5 * 1.7),
185
+ error: ({ sourceColorHct }) => {
186
+ const errorHue = getPiecewiseHue(
187
+ sourceColorHct,
188
+ [0, 3, 13, 23, 33, 43, 153, 273, 360],
189
+ [12, 22, 32, 12, 22, 32, 22, 12]
190
+ );
191
+ return TonalPalette.fromHueAndChroma(errorHue, 60);
192
+ }
193
+ },
194
+ customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(colorHct.hue, colorHct.chroma)
195
+ };
196
+ const Variants = {
197
+ Expressive: expressiveVariant,
198
+ Neutral: neutralVariant,
199
+ TonalSpot: tonalSpotVariant,
200
+ Vibrant: vibrantVariant,
201
+ Fidelity: fidelityVariant
202
+ };
203
+ class PluginAbstract {
204
+ constructor(options) {
205
+ __publicField(this, "options");
206
+ __publicField(this, "pluginInstance");
207
+ this.options = options;
208
+ }
209
+ init(api) {
210
+ var _a, _b;
211
+ this.pluginInstance = new this.pluginClass(api, this.options);
212
+ (_b = (_a = this.pluginInstance).onInit) == null ? void 0 : _b.call(_a);
213
+ return this;
214
+ }
215
+ getInstance() {
216
+ if (!this.pluginInstance) {
217
+ throw new Error(`Plugin ${this.name} is not initialized`);
218
+ }
219
+ return this.pluginInstance;
220
+ }
221
+ }
222
+ class PluginImplAbstract {
223
+ constructor(api, options) {
224
+ var _a;
225
+ this.api = api;
226
+ this.options = options;
227
+ (_a = this.onInit) == null ? void 0 : _a.call(this);
228
+ }
229
+ }
230
+ var FontFamily = /* @__PURE__ */ ((FontFamily2) => {
231
+ FontFamily2["Expressive"] = "expressive";
232
+ FontFamily2["Neutral"] = "neutral";
233
+ return FontFamily2;
234
+ })(FontFamily || {});
235
+ class FontPlugin extends PluginAbstract {
236
+ constructor() {
237
+ super(...arguments);
238
+ __publicField(this, "dependencies", []);
239
+ __publicField(this, "name", "font");
240
+ __publicField(this, "pluginClass", FontPluginImpl);
241
+ }
242
+ }
243
+ class FontPluginImpl extends PluginImplAbstract {
244
+ constructor() {
245
+ super(...arguments);
246
+ __publicField(this, "_fontFamily");
247
+ __publicField(this, "_fontStyles");
248
+ }
249
+ get fontFamily() {
250
+ if (!this._fontFamily) throw new Error("Font family not initialized");
251
+ return this._fontFamily;
252
+ }
253
+ set fontFamily(value) {
254
+ this._fontFamily = value;
255
+ }
256
+ get fontStyles() {
257
+ if (!this._fontStyles) throw new Error("Font styles not initialized");
258
+ return this._fontStyles;
259
+ }
260
+ set fontStyles(value) {
261
+ this._fontStyles = value;
262
+ }
263
+ getFonts() {
264
+ return {
265
+ fontStyles: this.fontStyles,
266
+ fontFamily: this.fontFamily
267
+ };
268
+ }
269
+ onInit() {
270
+ var _a, _b, _c, _d;
271
+ this.fontFamily = {
272
+ expressive: ((_b = (_a = this.options) == null ? void 0 : _a.fontFamily) == null ? void 0 : _b.expressive) ?? [
273
+ "Roboto",
274
+ "sans-serif"
275
+ ],
276
+ neutral: ((_d = (_c = this.options) == null ? void 0 : _c.fontFamily) == null ? void 0 : _d.neutral) ?? ["Roboto", "sans-serif"]
277
+ };
278
+ this.fontStyles = {
279
+ display: {
280
+ large: {
281
+ fontWeight: 400,
282
+ fontSize: 3.5625,
283
+ lineHeight: 4,
284
+ letterSpacing: -0.015625,
285
+ fontFamily: "expressive"
286
+ /* Expressive */
287
+ },
288
+ medium: {
289
+ fontWeight: 400,
290
+ fontSize: 2.8125,
291
+ lineHeight: 3.25,
292
+ fontFamily: "expressive"
293
+ /* Expressive */
294
+ },
295
+ small: {
296
+ fontWeight: 400,
297
+ fontSize: 2.25,
298
+ lineHeight: 2.75,
299
+ fontFamily: "expressive"
300
+ /* Expressive */
301
+ }
302
+ },
303
+ headline: {
304
+ large: {
305
+ fontWeight: 400,
306
+ fontSize: 2,
307
+ lineHeight: 2.5,
308
+ fontFamily: "expressive"
309
+ /* Expressive */
310
+ },
311
+ medium: {
312
+ fontWeight: 400,
313
+ fontSize: 1.75,
314
+ lineHeight: 2.25,
315
+ fontFamily: "expressive"
316
+ /* Expressive */
317
+ },
318
+ small: {
319
+ fontWeight: 400,
320
+ fontSize: 1.5,
321
+ lineHeight: 2,
322
+ fontFamily: "expressive"
323
+ /* Expressive */
324
+ }
325
+ },
326
+ title: {
327
+ large: {
328
+ fontWeight: 400,
329
+ fontSize: 1.375,
330
+ lineHeight: 1.75,
331
+ fontFamily: "neutral"
332
+ /* Neutral */
333
+ },
334
+ medium: {
335
+ fontWeight: 500,
336
+ fontSize: 1,
337
+ lineHeight: 1.5,
338
+ fontFamily: "neutral",
339
+ letterSpacing: 9375e-6
340
+ },
341
+ small: {
342
+ fontWeight: 500,
343
+ fontSize: 0.875,
344
+ lineHeight: 1.25,
345
+ fontFamily: "neutral",
346
+ letterSpacing: 625e-5
347
+ }
348
+ },
349
+ label: {
350
+ large: {
351
+ fontWeight: 500,
352
+ fontSize: 0.875,
353
+ lineHeight: 1.25,
354
+ fontFamily: "neutral",
355
+ letterSpacing: 625e-5
356
+ },
357
+ medium: {
358
+ fontWeight: 500,
359
+ fontSize: 0.75,
360
+ lineHeight: 1,
361
+ fontFamily: "neutral",
362
+ letterSpacing: 0.03125
363
+ },
364
+ small: {
365
+ fontWeight: 500,
366
+ fontSize: 0.6875,
367
+ lineHeight: 1,
368
+ fontFamily: "neutral",
369
+ letterSpacing: 0.03125
370
+ }
371
+ },
372
+ body: {
373
+ large: {
374
+ fontWeight: 400,
375
+ fontSize: 1,
376
+ lineHeight: 1.5625,
377
+ fontFamily: "neutral",
378
+ letterSpacing: 0.03125
379
+ },
380
+ medium: {
381
+ fontWeight: 400,
382
+ fontSize: 0.875,
383
+ lineHeight: 1.25,
384
+ fontFamily: "neutral",
385
+ letterSpacing: 0.015625
386
+ },
387
+ small: {
388
+ fontWeight: 400,
389
+ fontSize: 0.75,
390
+ lineHeight: 1,
391
+ fontFamily: "neutral",
392
+ letterSpacing: 0.025
393
+ }
394
+ }
395
+ };
396
+ if (this.options && this.options.fontStyles)
397
+ Object.entries(this.options.fontStyles).forEach(([key, fontParam]) => {
398
+ const fontRole = key;
399
+ Object.entries(fontParam).forEach(([size, fontStyle]) => {
400
+ const fontSize = size;
401
+ if (fontStyle) {
402
+ this.fontStyles[fontRole][fontSize] = {
403
+ ...this.fontStyles[fontRole][fontSize],
404
+ ...fontStyle
405
+ };
406
+ }
407
+ });
408
+ });
409
+ }
410
+ }
411
+ function defineConfig(configObject) {
412
+ if (!configObject || typeof configObject !== "object") {
413
+ throw new Error("The configuration is missing or not an object");
414
+ }
415
+ if (!("sourceColor" in configObject)) {
416
+ throw new Error("Invalid configuration");
417
+ }
418
+ return configObject;
419
+ }
420
+ export {
421
+ FontFamily as F,
422
+ PluginAbstract as P,
423
+ Variants as V,
424
+ PluginImplAbstract as a,
425
+ FontPlugin as b,
426
+ defineConfig as d,
427
+ expressiveVariant as e,
428
+ neutralVariant as n,
429
+ vibrantVariant as v
430
+ };