@mlut/core 1.0.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 (84) hide show
  1. package/README.md +24 -0
  2. package/_index.scss +1 -0
  3. package/_tools.scss +1 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.js +2 -0
  6. package/dist/jit/JitEngine.d.ts +19 -0
  7. package/dist/jit/JitEngine.js +124 -0
  8. package/dist/jit/index.d.ts +1 -0
  9. package/dist/jit/index.js +1 -0
  10. package/dist/sass/addons/demo-theme.scss +112 -0
  11. package/dist/sass/css/_base-setup.scss +3 -0
  12. package/dist/sass/css/_index.scss +2 -0
  13. package/dist/sass/css/helpers/_index.scss +3 -0
  14. package/dist/sass/css/helpers/btn.scss +28 -0
  15. package/dist/sass/css/helpers/gs-debug.scss +28 -0
  16. package/dist/sass/css/helpers/ratio-box.scss +47 -0
  17. package/dist/sass/css/helpers/row.scss +98 -0
  18. package/dist/sass/css/helpers/wrapper.scss +21 -0
  19. package/dist/sass/css/styles/_index.scss +2 -0
  20. package/dist/sass/css/styles/generic.scss +296 -0
  21. package/dist/sass/css/styles/variables.scss +32 -0
  22. package/dist/sass/css/utils/_bg-bd.scss +27 -0
  23. package/dist/sass/css/utils/_grid.scss +37 -0
  24. package/dist/sass/css/utils/_index.scss +2 -0
  25. package/dist/sass/css/utils/_load.scss +9 -0
  26. package/dist/sass/css/utils/_transition.scss +16 -0
  27. package/dist/sass/css/utils/box-alignment.scss +29 -0
  28. package/dist/sass/css/utils/box-model.scss +48 -0
  29. package/dist/sass/css/utils/grid-system.scss +17 -0
  30. package/dist/sass/css/utils/init.scss +107 -0
  31. package/dist/sass/css/utils/other.scss +35 -0
  32. package/dist/sass/css/utils/text.scss +33 -0
  33. package/dist/sass/css/utils/visual.scss +32 -0
  34. package/dist/sass/index.scss +4 -0
  35. package/dist/sass/tools/_index.scss +4 -0
  36. package/dist/sass/tools/functions/_index.import.scss +3 -0
  37. package/dist/sass/tools/functions/_index.scss +9 -0
  38. package/dist/sass/tools/functions/base/_error.scss +9 -0
  39. package/dist/sass/tools/functions/base/_getters.scss +124 -0
  40. package/dist/sass/tools/functions/base/_index.scss +11 -0
  41. package/dist/sass/tools/functions/base/_list.scss +56 -0
  42. package/dist/sass/tools/functions/base/_math.scss +149 -0
  43. package/dist/sass/tools/functions/base/_string.scss +300 -0
  44. package/dist/sass/tools/functions/common/_custom-units.scss +231 -0
  45. package/dist/sass/tools/functions/common/_forward-tools.scss +2 -0
  46. package/dist/sass/tools/functions/common/_helpers.scss +57 -0
  47. package/dist/sass/tools/functions/common/_index.scss +9 -0
  48. package/dist/sass/tools/functions/common/_utils.scss +211 -0
  49. package/dist/sass/tools/functions/high/_at-rules.scss +296 -0
  50. package/dist/sass/tools/functions/high/_forward-tools.scss +3 -0
  51. package/dist/sass/tools/functions/high/_index.scss +8 -0
  52. package/dist/sass/tools/functions/high/utils/_index.scss +288 -0
  53. package/dist/sass/tools/functions/high/utils/_parse-util.scss +107 -0
  54. package/dist/sass/tools/functions/high/utils/_range-generators.scss +355 -0
  55. package/dist/sass/tools/functions/high/utils/_util-apply-selector.scss +134 -0
  56. package/dist/sass/tools/functions/high/utils/_value-converters.scss +294 -0
  57. package/dist/sass/tools/functions/high/utils/_value-transformers.scss +65 -0
  58. package/dist/sass/tools/mixins/_index.import.scss +2 -0
  59. package/dist/sass/tools/mixins/_index.scss +8 -0
  60. package/dist/sass/tools/mixins/base/_forward-tools.scss +2 -0
  61. package/dist/sass/tools/mixins/base/_index.scss +93 -0
  62. package/dist/sass/tools/mixins/base/_mk-ar.scss +96 -0
  63. package/dist/sass/tools/mixins/base/_mk-state.scss +175 -0
  64. package/dist/sass/tools/mixins/high/_forward-tools.scss +3 -0
  65. package/dist/sass/tools/mixins/high/_index.scss +1 -0
  66. package/dist/sass/tools/mixins/high/utils/_index.scss +188 -0
  67. package/dist/sass/tools/mixins/high/utils/_mk-util.scss +366 -0
  68. package/dist/sass/tools/settings/_index.import.scss +3 -0
  69. package/dist/sass/tools/settings/_index.scss +3 -0
  70. package/dist/sass/tools/settings/base/_general.scss +175 -0
  71. package/dist/sass/tools/settings/base/_index.scss +2 -0
  72. package/dist/sass/tools/settings/base/_utils.scss +578 -0
  73. package/dist/sass/tools/settings/common/_at-rules.scss +213 -0
  74. package/dist/sass/tools/settings/common/_index.scss +2 -0
  75. package/dist/sass/tools/settings/common/_utils.scss +1926 -0
  76. package/dist/sass/tools/settings/high/_forward-tools.scss +2 -0
  77. package/dist/sass/tools/settings/high/_grid.scss +55 -0
  78. package/dist/sass/tools/settings/high/_index.scss +2 -0
  79. package/dist/sass/tools/settings/high/_utils.scss +104 -0
  80. package/dist/utils/index.d.ts +1 -0
  81. package/dist/utils/index.js +1 -0
  82. package/dist/utils/logger.d.ts +7 -0
  83. package/dist/utils/logger.js +13 -0
  84. package/package.json +48 -0
@@ -0,0 +1,288 @@
1
+ @use 'sass:list';
2
+ @use 'sass:map';
3
+ @use 'sass:meta';
4
+ @use 'sass:math';
5
+ @use 'sass:string';
6
+ @use 'sass:selector';
7
+ @use 'sass:color';
8
+
9
+ @forward 'value-converters';
10
+ @forward 'parse-util';
11
+ @forward 'util-apply-selector';
12
+ @forward 'range-generators' as generate-uv-*;
13
+ @forward 'value-transformers' as transform-uv-*;
14
+
15
+ @use '../forward-tools' as ml;
16
+ @use 'value-converters' as converters;
17
+ @use 'value-transformers' as transformers;
18
+ @use 'range-generators';
19
+ @use 'parse-util' as pu;
20
+
21
+ // Utilities
22
+ //
23
+ // Functions for working with utilities.
24
+ //
25
+ // Styleguide: sass-tools.functions.utils
26
+
27
+ /// Styleguide: sass-tools.functions.high.utils
28
+
29
+ @function convert-util-states($states, $this-util: null, $pre: false) {
30
+ $prefix: '&';
31
+ $suffix: '';
32
+
33
+ @if $pre {
34
+ $prefix: '';
35
+
36
+ @if string.slice($states, -1) == '.' {
37
+ $states: string.slice($states, 1, -2);
38
+ } @else {
39
+ $suffix: ' ';
40
+ }
41
+ }
42
+
43
+ $result: $prefix;
44
+ $or: ', ';
45
+
46
+ @each $state in ml.str-split($states, ml.$tSOr) {
47
+ @each $item in ml.str-split($state, ml.$tSAnd) {
48
+ $converted: '';
49
+ $not: string.slice($item, 1, 1) == ml.$tSNot;
50
+
51
+ @if $not {
52
+ $item: string.slice($item, 2);
53
+ }
54
+
55
+ @if map.has-key(ml.$utils-states, $item) {
56
+ $converted: map.get(ml.$utils-states, $item);
57
+ } @else if ml.str-starts($item, ml.$tSCs) {
58
+ $item-name: string.slice($item, string.length(ml.$tSCs) + 1);
59
+
60
+ @if map.has-key(ml.$utils-cfg, 'states', 'custom', $item-name) {
61
+ $converted: map.get(ml.$utils-cfg, 'states', 'custom', $item-name);
62
+ } @else {
63
+ @return ml.error('Undefined custom state: `#{$item}`');
64
+ }
65
+ } @else if ml.str-starts($item, ml.$tSCn) {
66
+ $ctx-value: string.slice($item, 2);
67
+ $converted: '.' + ml.str-escape(
68
+ ml.$cCtx + util-separated-value($ctx-value)
69
+ );
70
+ } @else if ml.str-starts($item, ml.$tSRaw) {
71
+ $converted: string.slice($item, 2);
72
+ } @else if ml.str-starts($item, ml.$tSTu) {
73
+ @if not $this-util {
74
+ @return ml.error('`#{ml.$tSTu}` cannot be used because $this-util is not passed');
75
+ }
76
+
77
+ @if $item == ml.$tSTu {
78
+ $converted: ml.str-escape(ml.$tSTu);
79
+ } @else if $item == ml.$tSTudv {
80
+ $converted: ml.css-class($this-util);
81
+ } @else {
82
+ $converted: ml.css-class($this-util + ml.str-escape(string.slice($item, 2)));
83
+ }
84
+ } @else if $item == '' {
85
+ $converted: ' ';
86
+ } @else {
87
+ $converted: $item;
88
+ }
89
+
90
+ @if $not {
91
+ $converted: ':not(#{$converted})';
92
+ }
93
+
94
+ $result: $result + $converted;
95
+ }
96
+
97
+ $result: $result + $suffix + $or + $prefix;
98
+ }
99
+
100
+ @return string.slice($result, 1, -(1 + string.length($or) + string.length($prefix)));
101
+ }
102
+
103
+ @function util-separated-value($value) {
104
+ @if $value == '' {
105
+ @return '';
106
+ }
107
+
108
+ @if ml.str2n($value) {
109
+ @return ml.$tUNv + $value;
110
+ }
111
+
112
+ $str-value: if(
113
+ meta.type-of($value) == 'string',
114
+ $value,
115
+ $value + ''
116
+ );
117
+
118
+ $first-char: string.slice($str-value, 1, 1);
119
+
120
+ @if $first-char == '#' {
121
+ @return ml.$tUHv + $str-value;
122
+ }
123
+
124
+ @return if(
125
+ $first-char == ml.$tURv,
126
+ $str-value,
127
+ ml.$tUSv + $str-value
128
+ );
129
+ }
130
+
131
+ @function expand-util-kw-alias($raw-alias, $util) {
132
+ $alias-data: pu.parse-util($raw-alias);
133
+ $alias-list: ml.str-split(map.get($alias-data, 'value'), ml.$tUKwc);
134
+ $length: list.length($alias-list);
135
+ $values: ();
136
+
137
+ $result: if(
138
+ list.length($alias-data) > 1,
139
+ ('components': map.remove($alias-data, 'value')),
140
+ ()
141
+ );
142
+
143
+ @if $length == 1 {
144
+ $keywords: map.get(ml.$utils-db, 'utils', 'registry', $util, 'keywords');
145
+
146
+ @if meta.type-of($keywords) == 'map' {
147
+ $values: $keywords;
148
+ } @else {
149
+ @each $link in $keywords {
150
+ @if map.has-key(ml.$utils-db, 'utils', 'keywords', $link) {
151
+ $values: map.merge($values, map.get(ml.$utils-db, 'utils', 'keywords', $link));
152
+ }
153
+ }
154
+
155
+ @if $values == () {
156
+ $values: map.get(ml.$utils-db, 'common', 'keywords', 'css');
157
+ }
158
+ }
159
+ } @else if $length == 2 {
160
+ $group: list.nth($alias-list, 2);
161
+
162
+ @if map.has-key(ml.$utils-db, 'common', 'keywords', $group) {
163
+ $values: map.get(ml.$utils-db, 'common', 'keywords', $group);
164
+ } @else if $group == 'General' {
165
+ $values: map.merge(
166
+ map.get(ml.$utils-db, 'common', 'keywords', 'css'),
167
+ map.get(ml.$utils-db, 'common', 'keywords', 'global'),
168
+ );
169
+ } @else if $group == 'All' {
170
+ $values: map.merge(
171
+ map.merge(
172
+ map.get(ml.$utils-db, 'common', 'keywords', 'css'),
173
+ map.get(ml.$utils-db, 'common', 'keywords', 'global'),
174
+ ),
175
+ map.get(ml.$utils-db, 'utils', 'registry', $util, 'keywords') or ()
176
+ );
177
+ } @else {
178
+ @return ml.error('Invalid keyword group alias: `#{$group}`');
179
+ }
180
+ } @else {
181
+ $section: list.nth($alias-list, 2);
182
+ $group: list.nth($alias-list, 3);
183
+
184
+ @if not map.has-key(ml.$utils-db, $section, 'keywords', $group) {
185
+ @return ml.error('Not found keywords on this path: `#{$section}.#{$group}`');
186
+ }
187
+
188
+ $values: map.get(ml.$utils-db, $section, 'keywords', $group);
189
+ }
190
+
191
+ @if map.has-key($values, '') {
192
+ @if ml.$uv-kw-alias-behavior == 1 {
193
+ $def-value: map.get($values, '');
194
+ $kw-def-value-index: list.index(
195
+ map.values(map.set($values, '', null)), $def-value
196
+ );
197
+
198
+ @if $kw-def-value-index {
199
+ $values: map.remove(
200
+ $values, list.nth(list.nth($values, $kw-def-value-index), 1)
201
+ );
202
+ }
203
+ } @else if ml.$uv-kw-alias-behavior == 2 {
204
+ $values: map.remove($values, '');
205
+ }
206
+ }
207
+
208
+ @return map.set($result, 'values', $values);
209
+ }
210
+
211
+ // uv
212
+ //
213
+ // Get CSS value of utility.
214
+ // ```scss
215
+ //@debug ml.uv('D'); // 'block'
216
+ //@debug ml.uv('C#c06*80'); // rgba(204, 0, 102, 0.8)
217
+ //@debug ml.uv('M3gg;a;gSm'); // calc(var(--ml-gg) * 3) auto 520px
218
+ //```
219
+ //
220
+ // $util - `string` <div> Any utility </div>
221
+ //
222
+ // Styleguide: sass-tools.functions.utils.uv
223
+
224
+ /// Styleguide: sass-tools.functions.high.utils.uv
225
+
226
+ @function uv($util) {
227
+ @if $util == '' {
228
+ @return ml.error('Empty string passed');
229
+ }
230
+
231
+ $util-data: ml.parse-abbr($util);
232
+
233
+ @return ml.convert-util-value(
234
+ map.get($util-data, 'value'),
235
+ map.get($util-data, 'name'),
236
+ );
237
+ }
238
+
239
+ // TODO: replace several `map.set()` to one `map.merge`
240
+ $-util-value-converters: ();
241
+
242
+ $-fn-prefix-length: string.length('convert-uv-');
243
+
244
+ @each $key, $value in meta.module-functions(converters) {
245
+ $-util-value-converters: map.set(
246
+ $-util-value-converters, string.slice($key, $-fn-prefix-length + 1), $value
247
+ );
248
+ }
249
+
250
+ ml.$utils-cfg: map.set(
251
+ ml.$utils-cfg,
252
+ 'converters',
253
+ map.merge(
254
+ $-util-value-converters, map.get(ml.$utils-cfg, 'converters')
255
+ )
256
+ );
257
+
258
+ $-util-range-generators: ();
259
+
260
+ @each $key, $value in meta.module-functions(range-generators) {
261
+ $-util-range-generators: map.set(
262
+ $-util-range-generators, ml.str-replace($key, '-range'), $value
263
+ );
264
+ }
265
+
266
+ ml.$utils-cfg: map.set(
267
+ ml.$utils-cfg,
268
+ 'range-generators',
269
+ map.merge(
270
+ $-util-range-generators, map.get(ml.$utils-cfg, 'range-generators')
271
+ )
272
+ );
273
+
274
+ $-util-value-transformers: ();
275
+
276
+ @each $key, $value in meta.module-functions(transformers) {
277
+ $-util-value-transformers: map.set(
278
+ $-util-value-transformers, $key, $value
279
+ );
280
+ }
281
+
282
+ ml.$utils-cfg: map.set(
283
+ ml.$utils-cfg,
284
+ 'transformers',
285
+ map.merge(
286
+ $-util-value-transformers, map.get(ml.$utils-cfg, 'transformers')
287
+ )
288
+ );
@@ -0,0 +1,107 @@
1
+ @use 'sass:list';
2
+ @use 'sass:map';
3
+ @use 'sass:meta';
4
+ @use 'sass:string';
5
+
6
+ @use '../forward-tools' as ml;
7
+
8
+ $-ar-keywords: list.join(
9
+ map.keys(ml.$bp-map),
10
+ map.keys(map.get(ml.$at-rules-cfg, 'keywords')),
11
+ );
12
+ $-states-tokens: (ml.$tSCn, ml.$tSAnd, ml.$tSTu);
13
+
14
+ // parse-util
15
+ //
16
+ // Parse utility value or name. Return map with passed value components:
17
+ // - `value` - pure value or name
18
+ // - `mq` - breakpoint or any mediaquery
19
+ // ```scss
20
+ //parse-util('1u_md') => ('value': '1u', 'mq': 'md')
21
+ // ```
22
+ //
23
+ // $raw-value - utility value or name. Type string.
24
+ //
25
+ /// Styleguide: sass-tools.functions.high.utils.parse_util
26
+
27
+ @function parse-util($raw-value) {
28
+ $raw-value-parts: ml.str-split($raw-value + '', ml.$tUCm);
29
+ $result: ();
30
+ $at-rules: null;
31
+ $value: null;
32
+ $states: ();
33
+ $comp-indexes: ();
34
+ $i: 1;
35
+
36
+ @if list.length($raw-value-parts) > 1 {
37
+ @each $component in $raw-value-parts {
38
+ $component-trimmed: ml.str-trim($component);
39
+ $component-item: list.nth(ml.str-split($component-trimmed, ' '), 1);
40
+
41
+ @if string.slice($component-item, 1, 1) == ml.$tSNot {
42
+ $component-item: string.slice($component-item, 2);
43
+ }
44
+
45
+ $part: list.nth(ml.str-split(
46
+ list.nth(ml.str-split($component-item, ml.$tSOr), 1),
47
+ ml.$tSAnd
48
+ ), 1);
49
+
50
+ @if not $at-rules and (
51
+ string.index($part, ml.$tAAr) or
52
+ list.index($-ar-keywords, $part) or
53
+ ml.str-starts($part, ml.$tALs)
54
+ ) {
55
+ $at-rules: $component-trimmed;
56
+ $comp-indexes: map.set($comp-indexes, 'ar', $i);
57
+ } @else if (
58
+ not $value and not string.index($component, ' ') and
59
+ not list.index($-states-tokens, string.slice($component-item, 1, 1))
60
+ ) {
61
+ $value: $component-trimmed;
62
+ $comp-indexes: map.set($comp-indexes, 'value', $i);
63
+ } @else {
64
+ $states: list.append($states, $component-trimmed);
65
+ $comp-indexes: map.set(
66
+ $comp-indexes, 'state' + list.length($states), $i
67
+ );
68
+ }
69
+
70
+ $i: $i + 1;
71
+ }
72
+ } @else {
73
+ $value: $raw-value;
74
+ }
75
+
76
+ @if not $value {
77
+ $value: $at-rules;
78
+ $comp-indexes: map.set($comp-indexes, 'value', map.get($comp-indexes, 'ar'));
79
+ } @else if $at-rules {
80
+ $result: map.set($result, 'at-rules', $at-rules);
81
+ }
82
+
83
+ @if not $value {
84
+ @return ml.error('Not specified value or name in string `#{$raw-value}`');
85
+ }
86
+
87
+ $i: 1;
88
+
89
+ @each $item in $states {
90
+ @if map.get($comp-indexes, 'state' + $i) < map.get($comp-indexes, 'value') {
91
+ $result: map.set($result, 'pre-states', $item);
92
+ } @else {
93
+ $result: map.set($result, 'post-states', $item);
94
+ }
95
+
96
+ $i: $i + 1;
97
+ }
98
+
99
+ @if meta.type-of($value) == 'string' and (
100
+ string.slice($value, -(string.length(ml.$tUIm))) == ml.$tUIm
101
+ ) {
102
+ $value: string.slice($value, 1, -(1 + string.length(ml.$tUIm)));
103
+ $result: map.set($result, 'important', true);
104
+ }
105
+
106
+ @return map.set($result, 'value', $value);
107
+ }