@medyll/cssfabric 0.2.0 → 0.2.1-beta.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.
Files changed (173) hide show
  1. package/README.md +58 -38
  2. package/dist/NewMenu.svelte +41 -0
  3. package/dist/NewMenu.svelte.d.ts +19 -0
  4. package/dist/css/animation/animation.css +2 -0
  5. package/dist/css/base/base.css +47 -0
  6. package/dist/css/base/base.min.css +1 -0
  7. package/{styles → dist/css}/box/box.css +118 -0
  8. package/dist/css/box/box.min.css +1 -0
  9. package/{styles → dist/css}/box/box.responsive.css +3063 -1550
  10. package/dist/css/box/box.responsive.min.css +1 -0
  11. package/{styles → dist/css}/color/color.css +11 -9
  12. package/{styles → dist/css}/color/color.responsive.css +3446 -1932
  13. package/dist/css/color/color.responsive.min.css +1 -0
  14. package/dist/css/cssfabric.css +5167 -0
  15. package/dist/css/cssfabric.min.css +4877 -0
  16. package/dist/css/cssfabric.responsive.css +20419 -0
  17. package/dist/css/cssfabric.responsive.min.css +1 -0
  18. package/{styles → dist/css}/flex/flex.css +2 -0
  19. package/{styles → dist/css}/flex/flex.responsive.css +192 -114
  20. package/dist/css/flex/flex.responsive.min.css +1 -0
  21. package/{styles → dist/css}/grid/grid.css +2 -0
  22. package/{styles → dist/css}/grid/grid.responsive.css +230 -212
  23. package/dist/css/grid/grid.responsive.min.css +1 -0
  24. package/{styles → dist/css}/menu/menu.css +2 -0
  25. package/{styles → dist/css}/menu/menu.responsive.css +165 -78
  26. package/dist/css/menu/menu.responsive.min.css +1 -0
  27. package/{styles → dist/css}/overflow/overflow.css +2 -0
  28. package/{styles → dist/css}/overflow/overflow.responsive.css +98 -105
  29. package/dist/css/overflow/overflow.responsive.min.css +1 -0
  30. package/{styles → dist/css}/scale/scale.css +2 -0
  31. package/{styles → dist/css}/scale/scale.responsive.css +1520 -1152
  32. package/dist/css/scale/scale.responsive.min.css +1 -0
  33. package/{styles → dist/css}/table/table.css +2 -0
  34. package/{styles → dist/css}/table/table.responsive.css +162 -86
  35. package/dist/css/table/table.responsive.min.css +1 -0
  36. package/{styles → dist/css}/text/text.css +2 -0
  37. package/{styles → dist/css}/text/text.responsive.css +76 -55
  38. package/dist/css/text/text.responsive.min.css +1 -0
  39. package/{styles → dist/css}/theme/theme.css +51 -0
  40. package/{styles → dist/css}/theme/theme.min.css +1 -1
  41. package/{styles → dist/css}/vars.css +66 -67
  42. package/dist/css/vars.min.css +1 -0
  43. package/{styles → dist/css}/zindex/zindex.css +2 -0
  44. package/dist/cssFabric/config.d.ts +29 -0
  45. package/dist/cssFabric/config.js +29 -0
  46. package/dist/cssFabric/cssFabricSheet.d.ts +1226 -0
  47. package/dist/cssFabric/cssFabricSheet.js +1270 -0
  48. package/dist/cssFabric/cssProperties.d.ts +27 -0
  49. package/dist/cssFabric/cssProperties.js +343 -0
  50. package/dist/cssFabric/cssVariationsAi.d.ts +12 -0
  51. package/dist/cssFabric/cssVariationsAi.js +111 -0
  52. package/dist/cssFabric/index.d.ts +113 -0
  53. package/dist/cssFabric/index.js +341 -0
  54. package/dist/cssf/README.md +197 -0
  55. package/{init/importCssVars.d.ts → dist/cssf/cssf.d.ts} +1 -1
  56. package/dist/cssf/cssf.js +12 -0
  57. package/dist/cssf/cssfGuide.d.ts +14 -0
  58. package/dist/cssf/cssfGuide.js +50 -0
  59. package/dist/cssf/cssfLib.d.ts +134 -0
  60. package/dist/cssf/cssfLib.js +116 -0
  61. package/dist/cssf/cssfModel.d.ts +8 -0
  62. package/dist/cssf/cssfModel.js +59 -0
  63. package/dist/cssf/cssfPlugin.d.ts +3 -0
  64. package/dist/cssf/cssfPlugin.js +37 -0
  65. package/dist/cssf/cssfTransformer.d.ts +2 -0
  66. package/dist/cssf/cssfTransformer.js +100 -0
  67. package/dist/cssf/index.d.ts +6 -0
  68. package/dist/cssf/index.js +7 -0
  69. package/dist/cssfVsCode/.vscode/launch.json +17 -0
  70. package/dist/cssfVsCode/.vscodeignore +4 -0
  71. package/dist/cssfVsCode/CHANGELOG.md +9 -0
  72. package/dist/cssfVsCode/README.md +65 -0
  73. package/dist/cssfVsCode/language-configuration.json +36 -0
  74. package/dist/cssfVsCode/package.json +40 -0
  75. package/dist/cssfVsCode/syntaxes/cssf.tmLanguage.json +1868 -0
  76. package/dist/cssfVsCode/test.cssf +6 -0
  77. package/dist/cssfVsCode/vsc-extension-quickstart.md +29 -0
  78. package/{_generated → dist/generated}/cssFabric.vars.json +4 -4
  79. package/{_generated/export.variables.md → dist/generated/cssFabric.vars.md} +268 -240
  80. package/dist/index.d.ts +119 -0
  81. package/dist/index.js +120 -0
  82. package/dist/scripts/cssfabric.d.ts +24 -0
  83. package/{scripts → dist/scripts}/cssfabric.js +43 -43
  84. package/{scripts → dist/scripts}/cssfabricClassNames.d.ts +14 -14
  85. package/{scripts → dist/scripts}/cssfabricClassNames.js +146 -146
  86. package/dist/scripts/index.d.ts +2 -0
  87. package/{scripts → dist/scripts}/index.js +4 -4
  88. package/{scripts → dist/scripts}/utils.d.ts +5 -5
  89. package/{scripts → dist/scripts}/utils.js +38 -38
  90. package/dist/scss/_utils.scss +203 -0
  91. package/dist/scss/modules/_cssfabric-config.scss +178 -0
  92. package/dist/scss/modules/_mixins.scss +1 -0
  93. package/dist/scss/modules/animation/_animation-vars.scss +17 -0
  94. package/dist/scss/modules/animation/animation.scss +3 -0
  95. package/dist/scss/modules/base/_base-vars.scss +19 -0
  96. package/dist/scss/modules/base/base.scss +58 -0
  97. package/dist/scss/modules/box/_box-build.scss +305 -0
  98. package/dist/scss/modules/box/_box-vars.scss +121 -0
  99. package/dist/scss/modules/box/box-responsive.scss +18 -0
  100. package/dist/scss/modules/box/box.scss +3 -0
  101. package/dist/scss/modules/color/_color-build.scss +196 -0
  102. package/dist/scss/modules/color/_color-vars.scss +80 -0
  103. package/dist/scss/modules/color/color-responsive.scss +23 -0
  104. package/dist/scss/modules/color/color.scss +9 -0
  105. package/dist/scss/modules/css-fabric.scss +1 -0
  106. package/dist/scss/modules/flex/_flex-build.scss +150 -0
  107. package/dist/scss/modules/flex/_flex-vars.scss +84 -0
  108. package/dist/scss/modules/flex/flex-responsive.scss +25 -0
  109. package/dist/scss/modules/flex/flex.scss +3 -0
  110. package/dist/scss/modules/grid/_grid-build.scss +87 -0
  111. package/dist/scss/modules/grid/_grid-vars.scss +88 -0
  112. package/dist/scss/modules/grid/grid-responsive.scss +25 -0
  113. package/dist/scss/modules/grid/grid.scss +6 -0
  114. package/dist/scss/modules/menu/_menu-build.scss +120 -0
  115. package/dist/scss/modules/menu/_menu-vars.scss +29 -0
  116. package/dist/scss/modules/menu/menu-responsive.scss +19 -0
  117. package/dist/scss/modules/menu/menu.scss +6 -0
  118. package/dist/scss/modules/overflow/_overflow-build.scss +22 -0
  119. package/dist/scss/modules/overflow/_overflow-vars.scss +31 -0
  120. package/dist/scss/modules/overflow/overflow-responsive.scss +25 -0
  121. package/dist/scss/modules/overflow/overflow.scss +7 -0
  122. package/dist/scss/modules/scale/_scale-build.scss +142 -0
  123. package/dist/scss/modules/scale/_scale-vars.scss +84 -0
  124. package/dist/scss/modules/scale/scale-responsive.scss +23 -0
  125. package/dist/scss/modules/scale/scale.scss +8 -0
  126. package/dist/scss/modules/table/_table-build.scss +134 -0
  127. package/dist/scss/modules/table/_table-vars.scss +30 -0
  128. package/dist/scss/modules/table/table-responsive.scss +24 -0
  129. package/dist/scss/modules/table/table.scss +8 -0
  130. package/dist/scss/modules/text/_text-build.scss +166 -0
  131. package/dist/scss/modules/text/_text-vars.scss +87 -0
  132. package/dist/scss/modules/text/text-responsive.scss +26 -0
  133. package/dist/scss/modules/text/text.scss +6 -0
  134. package/dist/scss/modules/theme/_theme-build.scss +128 -0
  135. package/dist/scss/modules/theme/_theme-vars.scss +46 -0
  136. package/dist/scss/modules/theme/theme.scss +6 -0
  137. package/dist/scss/modules/vars.scss +46 -0
  138. package/dist/scss/modules/zindex/_zindex-vars.scss +14 -0
  139. package/dist/scss/modules/zindex/zindex.scss +15 -0
  140. package/package.json +70 -113
  141. package/_generated/readme.md +0 -0
  142. package/init/importCssVars.js +0 -2
  143. package/scripts/cssfabric.d.ts +0 -24
  144. package/scripts/index.d.ts +0 -2
  145. package/styles/animation/animation.css +0 -0
  146. package/styles/base/base.css +0 -215
  147. package/styles/base/base.min.css +0 -1
  148. package/styles/box/box.min.css +0 -1
  149. package/styles/box/box.responsive.min.css +0 -1
  150. package/styles/color/color.responsive.min.css +0 -1
  151. package/styles/cssfabric.css +0 -61792
  152. package/styles/cssfabric.min.css +0 -168
  153. package/styles/cssfabric.responsive.css +0 -200596
  154. package/styles/cssfabric.responsive.min.css +0 -108
  155. package/styles/flex/flex.responsive.min.css +0 -1
  156. package/styles/grid/grid.responsive.min.css +0 -1
  157. package/styles/menu/menu.responsive.min.css +0 -1
  158. package/styles/overflow/overflow.responsive.min.css +0 -1
  159. package/styles/scale/scale.responsive.min.css +0 -1
  160. package/styles/table/table.responsive.min.css +0 -1
  161. package/styles/text/text.responsive.min.css +0 -1
  162. package/styles/vars.min.css +0 -1
  163. /package/{styles → dist/css}/animation/animation.min.css +0 -0
  164. /package/{styles → dist/css}/color/color.min.css +0 -0
  165. /package/{styles → dist/css}/flex/flex.min.css +0 -0
  166. /package/{styles → dist/css}/grid/grid.min.css +0 -0
  167. /package/{styles → dist/css}/menu/menu.min.css +0 -0
  168. /package/{styles → dist/css}/overflow/overflow.min.css +0 -0
  169. /package/{styles → dist/css}/scale/scale.min.css +0 -0
  170. /package/{styles → dist/css}/table/table.min.css +0 -0
  171. /package/{styles → dist/css}/text/text.min.css +0 -0
  172. /package/{styles → dist/css}/zindex/zindex.min.css +0 -0
  173. /package/{_generated → dist/scss}/index.d.ts +0 -0
@@ -0,0 +1,27 @@
1
+ export type CssFabricBlock = {
2
+ [key: string]: {
3
+ initial: string;
4
+ syntax: string;
5
+ fabric: Record<'classNames' | 'declinations' | 'variations', Record<string, string>>;
6
+ variations: Record<string, string[] | string[][]>;
7
+ };
8
+ };
9
+ export type CssFabricFragment = {
10
+ description: string;
11
+ syntax: string;
12
+ template: string;
13
+ initial: string;
14
+ appliesTo: string;
15
+ fabric: Record<'classNames' | 'declinations' | 'variations', Record<string, string>>;
16
+ variations: Record<string, string>;
17
+ };
18
+ export type CssFabricPropertyFragment = Record<string, CssFabricFragment>;
19
+ export type CssFabricPropertyCatalog = Record<string, CssFabricPropertyFragment | CssFabricFragment>;
20
+ export declare class CSSProperties {
21
+ private cssProperties;
22
+ private onlyKeys;
23
+ constructor(cssProperties: any, onlyKeys?: string[]);
24
+ private chkValidity;
25
+ private recursiveFabricSearch;
26
+ generateCSS(): Record<string, any>;
27
+ }
@@ -0,0 +1,343 @@
1
+ import { cssFabricSheet } from './cssFabricSheet.js';
2
+ import fsExtra from 'fs-extra';
3
+ import { CssFabricVariations } from './cssVariationsAi.js';
4
+ function camelToUnderscore(str) {
5
+ return str.replace(/([A-Z])/g, '-$1').toLowerCase();
6
+ }
7
+ const syntaxDecodeTypeConfig = {
8
+ length: [0, 52, 16, 'rem'],
9
+ width: [0, 256, 32, 'rem', [2, 16]],
10
+ 'border-width': [0, 2, 0.5, 'px', [2, 16]],
11
+ height: [0, 256, 32, 'rem', [2, 16]],
12
+ percentage: [0, 100, 10, '%', [2, 16]],
13
+ number: [0, 10, 1, 'px', [2, 16]],
14
+ opacity: [0.1, 1.0, 0.2, [2, 16]],
15
+ color: ['blue', 'red', 'yellow', 'orange', 'green', 'violet']
16
+ };
17
+ function cleanSyntaxKey(toClean) {
18
+ let cleaned = toClean.replace(/(em|px|%|rem)$/, '');
19
+ cleaned = cleaned.endsWith('-') ? cleaned.slice(0, -1) : cleaned;
20
+ return cleaned;
21
+ }
22
+ class SyntaxDecode {
23
+ static hasProgression(...rest) {
24
+ return rest.some((value) => Boolean(syntaxDecodeTypeConfig[value]));
25
+ }
26
+ static generateValues(...title) {
27
+ let result = {};
28
+ let progression = syntaxDecodeTypeConfig[title[1]] ?? syntaxDecodeTypeConfig[title[0]];
29
+ if (progression?.every((value) => typeof value === 'string')) {
30
+ // presets iteration
31
+ progression.forEach((value) => {
32
+ let newKey = `${fabricTitle}-${value}`;
33
+ result[cleanSyntaxKey(newKey)] = value;
34
+ });
35
+ }
36
+ else {
37
+ const unity = SyntaxDecode.getUnity(progression);
38
+ let [from, to, increment, unit, [ease = 0, trigger] = []] = progression;
39
+ for (let i = from; i <= to; i += i < trigger || i >= to - trigger ? increment / ease : increment) {
40
+ let newKey = `${title[0]}-${i}`;
41
+ result[cleanSyntaxKey(newKey)] = [i, unit];
42
+ }
43
+ }
44
+ // return value,unity
45
+ return result;
46
+ }
47
+ static getUnity(arr) {
48
+ for (let i = arr?.length - 1; i >= 0; i--) {
49
+ if (typeof arr[i] === 'string') {
50
+ return arr[i];
51
+ }
52
+ }
53
+ return null;
54
+ }
55
+ }
56
+ class DistributionType {
57
+ static detectDistributionType(fragment, fabricKey) {
58
+ let fabricKeys = Object.keys(fragment.fabric[fabricKey]);
59
+ let syntaxKeys = fragment.syntax.split('|').map((s) => s.trim());
60
+ if (!fabricKeys.some((key) => syntaxKeys.includes(key))) {
61
+ return 'detectionProgressive';
62
+ }
63
+ if (fabricKeys.every((key, index) => syntaxKeys[index] === key)) {
64
+ return 'detectionFollowLine';
65
+ }
66
+ return 'unknown';
67
+ }
68
+ }
69
+ class CSSFormalSyntaxDecoder {
70
+ syntax;
71
+ decodedSyntax;
72
+ constructor() {
73
+ this.syntax = '';
74
+ this.decodedSyntax = {};
75
+ }
76
+ decodeQuantifier(group) {
77
+ const quantifierMatch = group.match(/\{(\d+),(\d+)\}/);
78
+ if (quantifierMatch) {
79
+ return { min: parseInt(quantifierMatch[1]), max: parseInt(quantifierMatch[2]) };
80
+ }
81
+ return null;
82
+ }
83
+ getRenderMode(syntax) {
84
+ if (syntax.includes('length')) {
85
+ return 'length';
86
+ }
87
+ else if (syntax.includes('percentage')) {
88
+ return 'percentage';
89
+ }
90
+ else if (syntax.includes('range')) {
91
+ return 'range';
92
+ }
93
+ else if (syntax.includes('number')) {
94
+ return 'number';
95
+ }
96
+ else {
97
+ return 'raw';
98
+ }
99
+ }
100
+ decodeFormalSyntax(syntax) {
101
+ let decodedSyntax = {};
102
+ // Split the syntax into groups
103
+ let groups = syntax.split('|').map((g) => g.trim());
104
+ groups.forEach((group) => {
105
+ let optional = false;
106
+ let repeatable = false;
107
+ let quantifier = null;
108
+ let optionalPart = null;
109
+ // Check if the group is optional or repeatable
110
+ if (group.endsWith('?')) {
111
+ optional = true;
112
+ group = group.slice(0, -1); // Remove the question mark
113
+ }
114
+ if (group.endsWith('+')) {
115
+ repeatable = true;
116
+ group = group.slice(0, -1); // Remove the plus sign
117
+ }
118
+ // Check for quantifiers like {1,4}
119
+ quantifier = this.decodeQuantifier(group);
120
+ if (quantifier) {
121
+ group = group.replace(/\{\d+,\d+\}/, '').trim(); // Remove the quantifier part
122
+ }
123
+ // Check for optional parts
124
+ const optionalPartMatch = group.match(/\[(.*?)\]/);
125
+ if (optionalPartMatch) {
126
+ optionalPart = optionalPartMatch[1];
127
+ group = group.replace(optionalPartMatch[0], '').trim(); // Remove the optional part
128
+ }
129
+ // Remove brackets from the group
130
+ group = group.replace(/\[|\]/g, '');
131
+ decodedSyntax[group] = { optional, repeatable, quantifier, optionalPart };
132
+ });
133
+ return decodedSyntax;
134
+ }
135
+ decodeAndGenerateValue(fragmentPiece, key = '', followUp = '') {
136
+ let result = {};
137
+ const fragmentTitle = Object.keys(fragmentPiece)[0];
138
+ const fragment = fragmentPiece[fragmentTitle];
139
+ let out = {};
140
+ //
141
+ // console.log('----------------------------------', key, fragmentTitle);
142
+ Object.keys(fragment?.fabric).forEach((fabricMode) => {
143
+ switch (fabricMode) {
144
+ case 'classNames':
145
+ let classNames = this.applyClassNames(fragment, fabricMode);
146
+ //console.log('followUp', followUp);
147
+ if (Object.keys(classNames.classNames).length > 0) {
148
+ // result = { ...result, [fragmentTitle]: { classNames: classNames.classNames } };
149
+ result = { ...result, ...{ classNames: classNames.classNames } };
150
+ }
151
+ break;
152
+ case 'vertical':
153
+ /* console.log(fabricMode);
154
+ console.log(fragment.fabric); */
155
+ break;
156
+ case 'variations':
157
+ const ouh = { [fragmentTitle]: fragment.fabric };
158
+ const tr = CSSFormalSyntaxDecoder.translateVariations(ouh);
159
+ const gf = { [fragmentTitle]: { classNames: CssFabricVariations.loopVariations(tr) } };
160
+ result = { ...result, ...gf };
161
+ break;
162
+ case 'colors':
163
+ Object.assign(result, {});
164
+ break;
165
+ }
166
+ });
167
+ // console.log(result);
168
+ return result;
169
+ }
170
+ static translateVariations(cssBlock) {
171
+ let out = { ...cssBlock };
172
+ const mdl = Object.keys(cssBlock)[0];
173
+ Object.entries(cssBlock[mdl].variations).forEach(([key, value]) => {
174
+ // console.log(value);
175
+ out[mdl].variations[key] = value.split('|').map((v) => v.trim());
176
+ });
177
+ return out;
178
+ }
179
+ applyClassNames(fragment, fabricMode) {
180
+ let result = {};
181
+ const fragmentTitle = Object.keys(fragment.fabric[fabricMode])[0];
182
+ const fragmentPiece = fragment.fabric[fabricMode];
183
+ // console.log(fragmentTitle);
184
+ const distributionType = DistributionType.detectDistributionType(fragment, fabricMode);
185
+ //console.log(fragmentPiece);
186
+ Object.keys(fragmentPiece).forEach((fabricType) => {
187
+ //const distributionType = DistributionType.detectDistributionType(fragment, fabricType);
188
+ let syntax = fragment.syntax;
189
+ let fabricTitle = fragmentTitle == fabricType ? fragmentTitle : `${fragmentTitle}-${fabricType}`;
190
+ let decodedSyntax = this.decodeFormalSyntax(syntax);
191
+ Object.keys(decodedSyntax).forEach((syntaxKey) => {
192
+ let syntaxValue = decodedSyntax[syntaxKey];
193
+ if (syntaxValue.optional ||
194
+ syntaxValue.repeatable ||
195
+ syntaxValue.quantifier ||
196
+ syntaxValue.optionalPart) {
197
+ // This is a complex syntax, we need to decode it further
198
+ // ...
199
+ }
200
+ else {
201
+ switch (distributionType) {
202
+ case 'detectionProgressive':
203
+ // Handle progressive distribution
204
+ let progression = syntaxDecodeTypeConfig[syntaxKey] ?? syntaxDecodeTypeConfig[fabricTitle];
205
+ let generatedValues = {};
206
+ if (!progression) {
207
+ let className = `.${fabricTitle}-${syntaxKey}`;
208
+ generatedValues = {
209
+ [className]: {
210
+ [`--${fabricTitle}`]: `var(--${fabricTitle}-${syntaxKey});`,
211
+ [`${fabricTitle}`]: `var(--${fabricTitle},${syntaxKey});`
212
+ }
213
+ };
214
+ }
215
+ if (SyntaxDecode.hasProgression(fabricTitle, syntaxKey)) {
216
+ //console.log(SyntaxDecode.generateValues(fabricTitle, syntaxKey));
217
+ generatedValues = {};
218
+ for (const [key, value] of Object.entries(SyntaxDecode.generateValues(fabricTitle, syntaxKey))) {
219
+ generatedValues[`.${key}`] = {
220
+ [`--${fabricTitle}-${value[0]}`]: `${value[0]}${value[1]};`,
221
+ [`${fabricTitle}`]: `var(--${fabricTitle}-${value[0]});`
222
+ };
223
+ }
224
+ }
225
+ Object.assign(result, generatedValues);
226
+ break;
227
+ case 'detectionFollowLine':
228
+ // Handle follow line distribution
229
+ // ...
230
+ break;
231
+ default:
232
+ // Handle unknown distribution
233
+ // ...
234
+ break;
235
+ }
236
+ }
237
+ });
238
+ });
239
+ return { [fabricMode]: result };
240
+ }
241
+ }
242
+ export class CSSProperties {
243
+ cssProperties;
244
+ onlyKeys;
245
+ constructor(cssProperties, onlyKeys = []) {
246
+ this.cssProperties = cssProperties;
247
+ this.onlyKeys = onlyKeys;
248
+ }
249
+ chkValidity(cssProperties) {
250
+ if (cssProperties.fabric)
251
+ return true;
252
+ for (const key in cssProperties) {
253
+ if (cssProperties.hasOwnProperty(key)) {
254
+ const element = cssProperties[key];
255
+ if (typeof element === 'object') {
256
+ if (element.fabric) {
257
+ return true;
258
+ }
259
+ else {
260
+ return this.chkValidity(element);
261
+ }
262
+ }
263
+ return false;
264
+ }
265
+ }
266
+ return false;
267
+ }
268
+ recursiveFabricSearch(cssProperties, parent = '', followUp = []) {
269
+ let out = {};
270
+ for (let key in cssProperties) {
271
+ // if (key == 'box') console.log(key);
272
+ if (this.chkValidity(cssProperties[key]) && cssProperties.hasOwnProperty(key)) {
273
+ key = camelToUnderscore(key);
274
+ if (key == 'box')
275
+ console.log(key, parent);
276
+ const element = cssProperties[key];
277
+ const elementTitle = Object.keys(cssProperties)[0];
278
+ if (typeof element === 'object') {
279
+ // migration to new syntax
280
+ if (element.fabric && (!this.onlyKeys.length || this.onlyKeys.includes(key))) {
281
+ console.log('done followUp', key);
282
+ followUp.push(key);
283
+ try {
284
+ let decoder = new CSSFormalSyntaxDecoder();
285
+ let result = decoder.decodeAndGenerateValue({ [key]: element }, key, followUp);
286
+ parent += key;
287
+ if (!out[parent])
288
+ out[parent] = {};
289
+ out[parent] = { ...out[parent], ...result };
290
+ //followUp = '';
291
+ }
292
+ catch (err) {
293
+ out[parent] = { cssError: key };
294
+ // followUp = '';
295
+ }
296
+ // followUp = [];
297
+ }
298
+ else {
299
+ out = { ...out, ...this.recursiveFabricSearch(element, key, followUp) };
300
+ followUp = [];
301
+ parent = '';
302
+ //followUp = '';
303
+ }
304
+ }
305
+ }
306
+ else {
307
+ // console.log(key);
308
+ //console.log('done', followUp);
309
+ // followUp += key;
310
+ }
311
+ //console.log('done', followUp);
312
+ parent = '';
313
+ // followUp = '';
314
+ }
315
+ return out;
316
+ }
317
+ generateCSS() {
318
+ // console.log('-----------------------------------------------------------------------');
319
+ // console.log(this.cssProperties);
320
+ console.log('-----------------------------------------------------------------------');
321
+ return this.recursiveFabricSearch(this.cssProperties);
322
+ }
323
+ }
324
+ /* const cssF = cssP.generateCSS();
325
+ console.log(cssF); */
326
+ // console.log(JSON.stringify(cssF, null, 4));
327
+ function modifyObject(obj, filepath) {
328
+ for (let key in obj) {
329
+ if (typeof obj[key] === 'object') {
330
+ if (obj[key].fabric && !obj[key].fabric.classNames) {
331
+ let tmp;
332
+ tmp = obj[key].fabric;
333
+ obj[key].fabric = {};
334
+ obj[key].fabric.classNames = tmp;
335
+ }
336
+ else {
337
+ modifyObject(obj[key], filepath);
338
+ }
339
+ }
340
+ else {
341
+ }
342
+ }
343
+ }
@@ -0,0 +1,12 @@
1
+ import type { CssFabricBlock } from './cssProperties.js';
2
+ export declare class CssFabricVariations {
3
+ verticalModel: Record<string, any>;
4
+ className: string;
5
+ insert: string;
6
+ constructor(model: Record<string, any>, options?: any);
7
+ generateCss(prefix?: string): Record<string, any>;
8
+ static loopVertical(): void;
9
+ static loopVariations(fragmentObj: CssFabricBlock): Record<string, any>;
10
+ private generateRoot;
11
+ private generateCombinations;
12
+ }
@@ -0,0 +1,111 @@
1
+ import { colorConfig } from './config.js';
2
+ export class CssFabricVariations {
3
+ verticalModel;
4
+ className;
5
+ insert;
6
+ constructor(model, options = {}) {
7
+ [this.className, this.verticalModel] = Object.entries(model)[0];
8
+ // this.insert = insert;
9
+ }
10
+ generateCss(prefix = '') {
11
+ this.generateRoot(this.verticalModel, prefix);
12
+ return this.generateCombinations(this.verticalModel, prefix);
13
+ }
14
+ static loopVertical() { }
15
+ static loopVariations(fragmentObj) {
16
+ const fragmentKey = Object.keys(fragmentObj)[0];
17
+ const fragment = Object.values(fragmentObj)[0];
18
+ let variations = fragment.variations;
19
+ let variationValues = Object.values(variations);
20
+ let firstVarKey = variationValues?.[0];
21
+ let firstKey = Object.keys(variations)?.[0];
22
+ let strap = firstVarKey?.[0];
23
+ let remainingVariations = Object.fromEntries(Object.entries(variations).slice(1));
24
+ // if (strap.includes('cssFab')) {
25
+ let output = {};
26
+ // loop on each array
27
+ for (const value of [firstVarKey]) {
28
+ // create CssModel
29
+ value.forEach((element) => {
30
+ // if enclosed by ()
31
+ const enclosedValue = element.match(/\((.*?)\)/)?.[1];
32
+ if (enclosedValue) {
33
+ console.log('will be root:', enclosedValue);
34
+ }
35
+ // if contains cssFab.
36
+ let modelData = {
37
+ [fragmentKey]: { [firstKey]: [], ...remainingVariations }
38
+ };
39
+ const options = {};
40
+ let theme;
41
+ if (element.includes('cssFab.')) {
42
+ // replace with cssFab.theme
43
+ const fabTheme = element.split('cssFab.')[1].replace(')', '');
44
+ // modelData[fabTheme] = {};
45
+ modelData[fragmentKey][firstKey] = Object.keys(colorConfig[fabTheme] ?? {});
46
+ if (enclosedValue)
47
+ options[firstKey] = fabTheme;
48
+ console.log(options);
49
+ theme = fabTheme;
50
+ }
51
+ else {
52
+ modelData[fragmentKey][firstKey] = value;
53
+ }
54
+ // create CssModel
55
+ const cssModel = new CssFabricVariations(modelData, options);
56
+ let results = cssModel.generateCss();
57
+ // console.log('results');
58
+ if (theme) {
59
+ output[theme] = results;
60
+ }
61
+ else {
62
+ output = results;
63
+ }
64
+ });
65
+ }
66
+ return output;
67
+ // }
68
+ /* else {
69
+ let modelData: Record<string, any> = {
70
+ [fragmentKey]: { [firstKey]: [], ...remainingVariations }
71
+ };
72
+ //
73
+ let objg = {};
74
+ for (const value of firstVarKey) {
75
+ objg[value] = firstVarKey;
76
+ }
77
+ return modelData;
78
+ } */
79
+ }
80
+ generateRoot(obj, prefix = '') {
81
+ let result = {};
82
+ result[`.${this.className}`] = 'thin solid blue';
83
+ const ref = Object.entries(obj).reduce((acc, [style, propertyValues]) => {
84
+ acc[style] = propertyValues;
85
+ return acc;
86
+ }, {});
87
+ }
88
+ generateCombinations(obj, prefix = '', remainingCombinations = {}) {
89
+ let result = {};
90
+ // if no more keys, return the remaining combinations
91
+ if (Object.keys(remainingCombinations).length > 0) {
92
+ result[prefix] = remainingCombinations;
93
+ }
94
+ for (const key in obj) {
95
+ for (const value of obj[key]) {
96
+ const newPrefix = prefix + (prefix ? '-' : '.' + this.className + '-') + value;
97
+ let cssVar = `--var(${this.className}-${key},${value})`;
98
+ const newCombination = {
99
+ ...remainingCombinations,
100
+ [`${this.className}-${key}`]: cssVar,
101
+ [`--${this.className}-${key}`]: value
102
+ };
103
+ const { [key]: _, ...remainingObj } = obj;
104
+ const subCombinations = this.generateCombinations(remainingObj, newPrefix, newCombination);
105
+ result = { ...result, ...subCombinations };
106
+ }
107
+ break; // S'arrêter après avoir traité la première clé
108
+ }
109
+ return result;
110
+ }
111
+ }
@@ -0,0 +1,113 @@
1
+ import { colorConfig } from './config.js';
2
+ type Steps = [number, number, number];
3
+ type Mask = string;
4
+ type ToMask = string;
5
+ type EaseTrigger = number;
6
+ type Ease = number;
7
+ declare class CssFabricExport {
8
+ private cssFabricModel;
9
+ exportPaths: Record<'css' | 'json', string>;
10
+ constructor(cssFabricModel: cssFabricModelType, exportPaths?: CssFabricExport['exportPaths']);
11
+ export(options: CssFabricExport['exportPaths']): void;
12
+ private createCssFile;
13
+ private createJsonModel;
14
+ }
15
+ declare class CssFabricBuilder {
16
+ cssFabricBuilderParams: CssFabricBuilderParams;
17
+ constructor();
18
+ parseModel(json: Record<string, any>, parentKey?: string): string;
19
+ createProgression(options: {
20
+ property: string;
21
+ steps: {
22
+ steps: Steps;
23
+ presets?: string[];
24
+ ease: [Ease, EaseTrigger];
25
+ reverseValue?: boolean;
26
+ };
27
+ iteratorMask: string;
28
+ propertyValue?: {
29
+ content: [Mask, ToMask];
30
+ apply: string;
31
+ };
32
+ }, format?: 'css' | 'json'): {};
33
+ /**
34
+ * Dispatches elements based on the input mask.
35
+ *
36
+ * @template M - The type of the mask key.
37
+ * @template E - The type of the element.
38
+ * @template A - The type of the value.
39
+ *
40
+ * @param inputMask - The input mask.
41
+ * @param creatorFunction - The function to create the element based on the mask key.
42
+ * @param apply - The function to apply the value to the element.
43
+ */
44
+ dispatchHandleElements<M extends string = string, E = Element, A = any>(inputMask: any[], creatorFunction: (maskKey: M, index: number) => E, apply: (element: E, value: A) => void): void;
45
+ enqueue(callback: (callbackKey: string) => void, ...rest: string[][]): any;
46
+ flattenIt(arr1: string[], arr2: string[], scope?: string): Record<string, any>;
47
+ makeVariation(themeColor: string, variation: string): any;
48
+ makeDefaultVariations(arr1: string[], arr2: string[], prefix: string, vendor?: string): Record<string, any>;
49
+ mainRule(vars: Record<string, any>, prefix: string): Record<string, any>;
50
+ }
51
+ declare class CssFabricBuilderParams {
52
+ vendorName: string;
53
+ variations: {
54
+ readonly none: "var({#vendor}-color-##);";
55
+ readonly light: "color-mix(in srgb, var({#vendor}-color-##) white ##%);";
56
+ readonly lighter: "color-mix(in srgb, var({#vendor}-color-##) white ##%);";
57
+ readonly dark: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
58
+ readonly darker: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
59
+ readonly complement: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
60
+ readonly invert: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
61
+ readonly 'alpha-low': "color-mix(in srgb, var({#vendor}-color-##) transparent ##%);";
62
+ readonly alpha: "color-mix(in srgb, var({#vendor}-color-##) transparent ##%);";
63
+ readonly 'alpha-high': "color-mix(in srgb, var({#vendor}-color-##) transparent ##%);";
64
+ };
65
+ defaultVariationSteps: {
66
+ readonly steps: readonly [0, 100, 10];
67
+ readonly ease: readonly [2, 20];
68
+ };
69
+ correspondances: Record<string, any>;
70
+ baseColors: {
71
+ primary: string;
72
+ secondary: string;
73
+ accent: string;
74
+ neutral: string;
75
+ error: string;
76
+ };
77
+ presets: string[];
78
+ config: typeof colorConfig;
79
+ constructor();
80
+ setVariations(variations: typeof CssFabricBuilderParams.prototype.variations): void;
81
+ setDefaultVariationSteps(variationSteps: typeof CssFabricBuilderParams.prototype.defaultVariationSteps): void;
82
+ private deepMerge;
83
+ }
84
+ declare enum ModelConfigKeys {
85
+ base = 0,
86
+ palette = 1,
87
+ presets = 2,
88
+ status = 3,
89
+ out = 4,
90
+ gray = 5,
91
+ out2 = 6
92
+ }
93
+ type cssFabricModelKey = keyof typeof ModelConfigKeys;
94
+ type cssFabricModelType = Record<cssFabricModelKey, any>;
95
+ declare class CssFabric {
96
+ vendor: (fragment?: string) => string;
97
+ cssFabricModel: cssFabricModelType;
98
+ cssFabricBuilderParams: CssFabricBuilderParams;
99
+ cssFabricBuilder: CssFabricBuilder;
100
+ constructor();
101
+ private cleanModelKey;
102
+ setParams(params: Partial<CssFabricBuilderParams>): void;
103
+ createCssFabricVarsColors(...args: cssFabricModelKey[]): {
104
+ export: CssFabricExport['export'];
105
+ css: string;
106
+ };
107
+ cssFabricSheet(): {
108
+ export: (options: any) => void;
109
+ css: Record<string, any>;
110
+ };
111
+ }
112
+ export declare const cssFabric: CssFabric;
113
+ export {};