aliascss 1.3.7 → 1.3.9

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.
@@ -45,6 +45,7 @@ export let classPrinter = {
45
45
  let attrValue = '';
46
46
  const testRegExp = this.useColon ? /class[-_:]/ : /class[-_]/;
47
47
  const testRegExpKF = this.useColon ? /keyframes[-_:]/ : /keyframes[-_]/;
48
+ const rawCSS = /data-raw-css/;
48
49
  // if class
49
50
  if (el.getAttribute('class'))
50
51
  attrValue += ' ' + el.getAttribute('class');
@@ -53,6 +54,7 @@ export let classPrinter = {
53
54
  // new Update
54
55
  [...el.attributes].map((each) => {
55
56
  // ------------
57
+ // Raw-CSS Statement
56
58
  // class-group
57
59
  if (testRegExp.test(each.name)) {
58
60
  let value = each.value;
@@ -232,11 +234,17 @@ export let classPrinter = {
232
234
  Array.prototype.forEach.call(template.content.querySelectorAll('[class]'), (e) => {
233
235
  this.print(e);
234
236
  });
237
+ Array.prototype.forEach.call(template.content.querySelectorAll('[data-raw-css]'), (e) => {
238
+ this.appendToStyleTag(e.getAttribute('data-raw-css'));
239
+ });
235
240
  });
236
241
  // <html>
237
242
  // Array.prototype.forEach.call($root.querySelectorAll('[class],[acss-class]'), (e) => {
238
243
  Array.prototype.forEach.call($root.querySelectorAll('[class]'), (e) => {
239
244
  this.print(e);
240
245
  });
246
+ Array.prototype.forEach.call($root.querySelectorAll('[data-raw-css]'), (e) => {
247
+ this.appendToStyleTag(e.getAttribute('data-raw-css'));
248
+ });
241
249
  },
242
250
  };
@@ -1,5 +1,9 @@
1
1
  export default function clipPath(data, custom) {
2
2
  const valuePortion = data.replace(/^-/, '') || '';
3
+ // for raw-css function
4
+ if (valuePortion.match(/[(]/)) {
5
+ return valuePortion;
6
+ }
3
7
  // const match = /^(path|pa|circle|c|inset|i|polygon|p|ellipse|e|xywh|rect|r)[-]?[\d]/;
4
8
  const match = /^(path|pa|circle|c|inset|i|polygon|p|ellipse|e|xywh|rect|r)[-]?([\d]|-)/;
5
9
  let shape = null;
@@ -14,6 +14,10 @@ export default function color(color, custom) {
14
14
  }
15
15
  // remove - before the color
16
16
  color = color.replace(/^[-]/, '');
17
+ // check if is a raw function
18
+ if (color.match(/^(rgb|hsl|hsla|rgba|hwb|hwba|lab|oklab|lch|oklch)[(]/)) {
19
+ return color;
20
+ }
17
21
  // custom-color
18
22
  if (custom.hasOwnProperty('colors') && typeof custom.colors === 'object') {
19
23
  if (custom.colors.hasOwnProperty(color)) {
@@ -4,6 +4,11 @@ export default function filter(valuePortion, custom) {
4
4
  const matchRegEx = /^[-]?([a-zA-Z]+([-][\w]+)?)(?=[-])/;
5
5
  valuePortion.split(/__/).forEach((each) => {
6
6
  var _a;
7
+ // check for raw-css funcion
8
+ if (each.match(/[(]/)) {
9
+ compileValue += each.replace(/^-/, '') + " ";
10
+ return;
11
+ }
7
12
  let [fn, value] = ['', ''];
8
13
  // css-var
9
14
  if (each.match(/--[a-zA-Z]/)) {
@@ -3,7 +3,10 @@ export default function gradient(datas, custom) {
3
3
  datas = datas.replace(/^[-]/, '');
4
4
  let masterHolder = '';
5
5
  datas.split('__').forEach((data) => {
6
- const matched = data.match(/[-]?(((repeating-)?(conic|linear|radial)-gradient)|(rrg|rg|lg|rcg|cg|rcg|rlg))([\w_-]+)/);
6
+ if (data.match(/[-]?(((repeating-)?(conic|linear|radial)-gradient)|(rrg|rg|lg|rcg|cg|rcg|rlg))[\(]/)) {
7
+ masterHolder += data.replace(/[_]/g, ' ') + ', ';
8
+ }
9
+ const matched = data.match(/[-]?(((repeating-)?(conic|linear|radial)-gradient)|(rrg|rg|lg|rcg|cg|rcg|rlg))([-_][\w_-]+)/);
7
10
  // console.warn(matched, data);
8
11
  if (matched) {
9
12
  const grad = matched[1];
@@ -5,6 +5,11 @@ export default (value) => {
5
5
  let compileValue = '';
6
6
  // check for multiple value
7
7
  value.split(/__(?=[a-z])/).forEach((e) => {
8
+ //
9
+ if (e.match(/[(]/)) {
10
+ compileValue += e + " ";
11
+ return;
12
+ }
8
13
  // extract function
9
14
  const result = transformEach(e);
10
15
  if (result)
@@ -4,6 +4,12 @@ export default function url(data) {
4
4
  let holder = '';
5
5
  data.split(/__/).forEach((each) => {
6
6
  each = each.replace(/^[-]?url/, '');
7
+ // match raw-css function
8
+ if (each.match(/^[(]/)) {
9
+ holder += 'url' + each + ',';
10
+ return;
11
+ }
12
+ // css-var inside url
7
13
  if (each.match(/^--[a-zA-Z]/)) {
8
14
  holder += `url(var(${each})),`;
9
15
  return;
@@ -224,7 +224,7 @@ const cssProps = {
224
224
  if (value.match(/^[-]?url/)) {
225
225
  return url(value);
226
226
  }
227
- else if (value.match(/[-]?(((repeating-)?(conic|linear|radial)-gradient)|(rrg|rg|lg|rcg|cg|rcg|rlg))([\w_-]+)/)) {
227
+ else if (value.match(/[-]?(((repeating-)?(conic|linear|radial)-gradient)|(rrg|rg|lg|rcg|cg|rcg|rlg))([(-_][\w_-]+)/)) {
228
228
  return gradient(value, custom);
229
229
  }
230
230
  else {
@@ -649,7 +649,7 @@ const cssProps = {
649
649
  compiler: length,
650
650
  values: [''],
651
651
  },
652
- 'border-start-star-radius': {
652
+ 'border-start-start-radius': {
653
653
  alias: 'bssr',
654
654
  type: 'd',
655
655
  compiler: length,
@@ -1,6 +1,7 @@
1
1
  import prebuild from "./prebuild.js";
2
2
  import { cssVarWithDefault } from "./utils/helper.js";
3
3
  import color from './compilers/color.js';
4
+ import length from './compilers/length.js';
4
5
  const cssCustomCompilers = Object.assign(Object.assign({}, prebuild), {
5
6
  // 'Button':{
6
7
  // type:'group',
@@ -32,14 +33,229 @@ const cssCustomCompilers = Object.assign(Object.assign({}, prebuild), {
32
33
  // 'lg':'border-radius: 6px; padding: 0px 24px;font-size: 18px;height: 48px;line-height: 26px;gap: 14px;',
33
34
  // },
34
35
  // },
35
- 'Color': {
36
+ 'ButtonAR': {
37
+ type: 'group',
38
+ compiler: (value, custom) => {
39
+ const stm = `
40
+ --border-color: ${color('accentRA', custom)};
41
+ --button-background: ${color('accentRATheme100', custom)};
42
+ --button-gradient:${color('accentRATheme200', custom)};
43
+ --button-border: ${color('accentRATheme300', custom)};
44
+ --button-highlight: rgb(255 255 255 / 0.8);
45
+ --button-shadow: ${color('accentRATheme400', custom)};
46
+ --button-border-size: 1px;
47
+ --button-text: ${color('accentRATheme1400', custom)};
48
+ --button-gradient-size: 8px;
49
+ --text-color: var(--gray-1200,${color('grayRATheme1200', custom)});
50
+ --text-color-hover: var(--gray-1300,${color('grayRATheme1300', custom)});
51
+ --text-color-disabled: var(--gray-600,${color('grayRATheme600', custom)});
52
+
53
+ background:var(--button-background);
54
+ display:inline-flex;align-items:center;justify-content:center;
55
+ color: var(--button-text);
56
+ box-shadow:
57
+ inset 0 -1px 0 var(--button-shadow), /* bottom shadow */
58
+ inset 0 0 0 var(--button-border-size) var(--button-border), /* border */
59
+ inset 0px calc(var(--button-border-size) + 1px) 0px var(--button-highlight), /* top specular highlight */
60
+ inset 0px calc(-1 * var(--button-gradient-size)) var(--button-gradient-size) -2px var(--button-gradient); /* inner gradient */
61
+ outline: none;
62
+ transition-property: background, color, scale, box-shadow;
63
+ transition-duration: 200ms;
64
+ will-change: scale;
65
+ forced-color-adjust: none;
66
+ -webkit-tap-highlight-color: transparent;
67
+
68
+ @media (prefers-color-scheme: dark) {
69
+ --button-shadow: ${color('accentRATheme200', custom)};;
70
+ --button-highlight: rgb(255 255 255 / 0.15);
71
+ box-shadow:
72
+ inset 0 var(--button-border-size) 0 var(--button-highlight), /* top specular highlight */
73
+ inset 0 calc(-1 * var(--button-border-size)) 0 var(--button-shadow), /* bottom shadow */
74
+ inset 0 0 0 var(--button-border-size) var(--button-border), /* border */
75
+ inset 0 var(--button-gradient-size) var(--button-gradient-size) -2px var(--button-gradient); /* inner gradient */
76
+ }
77
+
78
+ &:where([data-pressed]) {
79
+ --button-background: ${color('accentRATheme200', custom)};
80
+ }
81
+
82
+ &:where([data-focus-visible]) {
83
+ outline: 2px solid var(--focus-ring-color,${color('accentRATheme1000', custom)});
84
+ outline-offset: 2px;
85
+ }
86
+
87
+ &:where([data-variant=secondary]) {
88
+ --button-color: ${color('grayRA', custom)};
89
+ }
90
+
91
+ &:where([data-variant=quiet]) {
92
+ --button-background: none;
93
+ --button-text: var(--text-color);
94
+ box-shadow: 0 0 0 1px transparent;
95
+
96
+ &:where([data-hovered], [data-pressed]) {
97
+ --button-background: ${color('accentRATheme200', custom)};
98
+ --button-text: var(--tint-1400);
99
+ box-shadow: 0 0 0 1px ${color('accentRATheme200', custom)};
100
+ }
101
+ }
102
+
103
+ &:where([data-selected]) {
104
+ --button-background: oklch(from var(--button-color) 55% c h);
105
+ --button-border: oklch(from var(--button-color) 50% c h);
106
+ --button-gradient: var(--button-border);
107
+ --button-highlight: rgb(255 255 255 / 0.2);
108
+ --button-shadow: oklch(from var(--button-color) 30% c h);
109
+ --button-text: var(--highlight-foreground);
110
+
111
+ box-shadow:
112
+ inset 0 -1px 0 var(--button-shadow), /* bottom shadow */
113
+ inset 0 0 0 1px var(--button-border), /* border */
114
+ inset 0 2px 0 var(--button-highlight), /* top specular highlight */
115
+ inset 0 calc(-1 * var(--button-gradient-size)) var(--button-gradient-size) var(--button-gradient); /* inner gradient */
116
+
117
+ @media (prefers-color-scheme: dark) {
118
+ --button-highlight: rgb(255 255 255 / 0.4);
119
+ --button-gradient: rgb(255 255 255 / 0.2);
120
+ --button-shadow: var(--button-border);
121
+ box-shadow:
122
+ inset 0 1px 0 var(--button-highlight), /* top specular highlight */
123
+ inset 0 var(--button-gradient-size) var(--button-gradient-size) var(--button-gradient), /* inner gradient */
124
+ inset 0 0 0 1px var(--button-border); /* border */
125
+ }
126
+
127
+ &:where([data-pressed]) {
128
+ --button-background: oklch(from var(--button-color) 50% c h);
129
+ }
130
+ }
131
+
132
+ &:where([data-disabled]) {
133
+ box-shadow: none;
134
+ --button-background: var(--border-color-disabled);
135
+ --button-text: var(--text-color-disabled);
136
+
137
+ &:where([data-variant=quiet]) {
138
+ --button-background: none;
139
+ }
140
+ }
141
+
142
+ @media (forced-colors: active) {
143
+ --button-background: ButtonFace;
144
+ --button-text: ButtonText;
145
+ --button-border: ButtonBorder;
146
+ box-shadow: inset 0 0 0 var(--button-border-size) var(--button-border);
147
+
148
+ &:where([data-variant=quiet]) {
149
+ --button-border: transparent;
150
+ &:where([data-hovered], [data-pressed]) {
151
+ --button-border: ButtonBorder;
152
+ }
153
+ }
154
+
155
+ &:where([data-selected]) {
156
+ --button-background: Highlight;
157
+ --button-text: HighlightText;
158
+ --button-border: Highlight;
159
+ }
160
+
161
+ &:where([data-disabled]) {
162
+ --button-background: ButtonFace;
163
+ --button-text: GrayText;
164
+ --button-border: GrayText;
165
+
166
+ &:where([data-variant=quiet]) {
167
+ --button-border: transparent;
168
+ }
169
+ }
170
+ }`;
171
+ // const order=['padding','margin','gap'];
172
+ // const values=value.replace(/^\(|\)$/g,'').split(',');
173
+ // values.forEach((e,i)=>{
174
+ // if(i<order.length && e){
175
+ // if(/--[a-zA-Z]/.test(e)){
176
+ // stm+=`${order[i]}:var(${e});`
177
+ // }else{
178
+ // stm+=`${order[i]}:${length(e)};`
179
+ // }
180
+ // }
181
+ // });
182
+ return stm;
183
+ }
184
+ },
185
+ // Button:{
186
+ // type:'group',
187
+ // compiler:(value,custom)=>{
188
+ // let stm=`
189
+ // `
190
+ // }
191
+ // },
192
+ 'Space': {
193
+ type: 'group',
194
+ compiler: (value, custom) => {
195
+ let stm = '';
196
+ const order = ['padding', 'margin', 'gap'];
197
+ const values = value.replace(/^\(|\)$/g, '').split(',');
198
+ values.forEach((e, i) => {
199
+ if (i < order.length && e) {
200
+ if (/--[a-zA-Z]/.test(e)) {
201
+ stm += `${order[i]}:var(${e});`;
202
+ }
203
+ else {
204
+ stm += `${order[i]}:${length(e)};`;
205
+ }
206
+ }
207
+ });
208
+ return stm;
209
+ }
210
+ },
211
+ // 'Grid':{
212
+ // type:'group',
213
+ // compiler:(value,custom)=>{
214
+ // let stm=`display:grid;grid-template-columns:repeat(var(--columns),1fr);--columns:12;`;
215
+ // const order=['xs','md','gap'];
216
+ // const values=value.replace(/^\(|\)$/g,'').split(',');
217
+ // values.forEach((e,i)=>{
218
+ // if(i<order.length && e){
219
+ // if(/--[a-zA-Z]/.test(e)){
220
+ // stm+=`${order[i]}:var(${e});`
221
+ // }else{
222
+ // stm+=`${order[i]}:${length(e)};`
223
+ // }
224
+ // }
225
+ // });
226
+ // return stm;
227
+ // }
228
+ // },
229
+ 'Size': {
230
+ type: 'group',
231
+ compiler: (value, custom) => {
232
+ let stm = '';
233
+ const order = ['width', 'height', 'border-radius'];
234
+ const values = value.replace(/^\(|\)$/g, '').split(',');
235
+ if (values.length === 1) {
236
+ const val = /--[a-zA-Z]/.test(values[0]) ? `var(${values[0]})` : length(values[0]);
237
+ return `width:${val};height:${val}`;
238
+ }
239
+ values.forEach((e, i) => {
240
+ if (i < order.length && e) {
241
+ if (/--[a-zA-Z]/.test(e)) {
242
+ stm += `${order[i]}:var(${e});`;
243
+ }
244
+ else {
245
+ stm += `${order[i]}:${length(e)};`;
246
+ }
247
+ }
248
+ });
249
+ return stm;
250
+ }
251
+ }, 'Color': {
36
252
  type: 'group',
37
253
  compiler: (value, custom) => {
38
254
  let stm = '';
39
255
  const order = ['color', 'background-color', 'border-color'];
40
256
  const values = value.replace(/^\(|\)$/g, '').split(',');
41
257
  values.forEach((e, i) => {
42
- if (i < order.length) {
258
+ if (i < order.length && e) {
43
259
  stm += `${order[i]}:${color(e, custom)};`;
44
260
  }
45
261
  });
@@ -75,7 +75,12 @@ export function compileFile(file, config, statementMaker, globalClassList) {
75
75
  compiledStatement += `/* From:aliacss.config.group */\n${statementMaker.customGroupStatement}\n/* -----End:aliacss.config.group----- */\n\n`;
76
76
  moduleStatement += `/* From:aliacss.config.group */\n${statementMaker.customGroupStatement}\n/* -----End:aliacss.config.group----- */\n\n`;
77
77
  }
78
- const [classList, groups, keyframe] = extractClassNamesFromFile(file, config);
78
+ const [classList, groups, keyframe, rawCSSStatement] = extractClassNamesFromFile(file, config);
79
+ // 1. raw-css
80
+ if (rawCSSStatement) {
81
+ globalStatement += rawCSSStatement + '\n';
82
+ compiledStatement += rawCSSStatement + '\n';
83
+ }
79
84
  // 2. group
80
85
  for (const key in groups) {
81
86
  if (groups.hasOwnProperty(key)) {
@@ -14,5 +14,5 @@ export default function extractClassNamesFromFile(file: string, config: config):
14
14
  [key: string]: string;
15
15
  }, {
16
16
  [key: string]: string;
17
- }];
17
+ }, string];
18
18
  export {};
@@ -4,10 +4,24 @@ export default function extractClassNamesFromFile(file, config) {
4
4
  const classList = [];
5
5
  const groups = {};
6
6
  const keyframes = {};
7
+ let rawCSSStatement = '';
7
8
  const matchExtractorFunction = config.useExtractorFunction ? config.matchExtractorFunction : null;
8
9
  const matchCSSModuleFunction = config.useCSSModule ? config.matchCSSModuleFunction : null;
9
10
  const matchRegExp = config.useColon ? config.matchRegExpWithColon : config.matchRegExp;
10
11
  const matchRegExpKeyFrame = config.useColon ? config.matchRegExpWithColonKeyFrame : config.matchRegExpKeyFrame;
12
+ const matchRegExpRawCSSStatement = /data-raw-css=(["'])(.*?)\1/;
13
+ // 0. data-raw-css=
14
+ if (data.match(matchRegExpRawCSSStatement)) {
15
+ const matchesRawCSS = data.match(new RegExp(matchRegExpRawCSSStatement, "g"));
16
+ if (matchesRawCSS) {
17
+ matchesRawCSS.forEach((each) => {
18
+ const extraction = each.match(matchRegExpRawCSSStatement);
19
+ if (extraction && extraction[2]) {
20
+ rawCSSStatement += extraction[2] + '\n';
21
+ }
22
+ });
23
+ }
24
+ }
11
25
  // 1 - i. Extract from Extractor function
12
26
  if (config.useExtractorFunction && matchExtractorFunction) {
13
27
  const matchesEF = data.match(new RegExp(matchExtractorFunction, "g"));
@@ -102,5 +116,5 @@ export default function extractClassNamesFromFile(file, config) {
102
116
  // .replace(/["']/g,'')
103
117
  // .split(/\s+/)
104
118
  // extract from keyframes
105
- return [classList, groups, keyframes];
119
+ return [classList, groups, keyframes, rawCSSStatement];
106
120
  }
@@ -123,6 +123,10 @@ const prefix = {
123
123
  '--rt': ':root', // -rt
124
124
  '--selection': '::selection', // -sl
125
125
  '--s': '::selection', // -sl
126
+ '--search-cancel-button': '::-webkit-search-cancel-button',
127
+ '--webkit-search-cancel-button': '::-webkit-search-cancel-button',
128
+ '--search-decoration': '::-webkit-search-decoration',
129
+ '--webkit-search-decoration': '::-webkit-search-decoration',
126
130
  '--spelling-error': '::spelling-error',
127
131
  '--se': '::spelling-error',
128
132
  '--scrollbar': '::-webkit-scrollbar',
@@ -29,13 +29,13 @@ bool = false) {
29
29
  const val = value.replace(/(--[\w-]+)/g, 'var($1)')
30
30
  .replace(/^[(]/, '').replace(/_$/, '').replace(/[)]$/, '')
31
31
  .replace(/,/g, ', ');
32
- value = val;
32
+ value = val.replace(/_/g, ' ');
33
33
  }
34
34
  else {
35
35
  const val = value.replace(/(--[\w-]+)/g, 'var($1)')
36
36
  .replace(/^[(]/, '').replace(/[)]$/, '')
37
37
  .replace(/,/g, ' ');
38
- value = val;
38
+ value = val.replace(/_/g, ' ');
39
39
  }
40
40
  return bool ? [property, value] : property + ":" + value;
41
41
  }
@@ -130,13 +130,15 @@ bool = false) {
130
130
  if (valuePortion.match(/_$/)) {
131
131
  const val = valuePortion.replace(/(--[\w-]+)/g, 'var($1)')
132
132
  .replace(/^[(]/, '').replace(/_$/, '').replace(/[)]$/, '')
133
- .replace(/,/g, ', ');
133
+ .replace(/,/g, ', ')
134
+ .replace(/[_]/g, ' ');
134
135
  return bool ? [prop, val] : prop + ":" + val;
135
136
  }
136
137
  else {
137
138
  const val = valuePortion.replace(/(--[\w-]+)/g, 'var($1)')
138
139
  .replace(/^[(]/, '').replace(/[)]$/, '')
139
- .replace(/,/g, ' ');
140
+ .replace(/,/g, ' ')
141
+ .replace(/[_]/g, ' ');
140
142
  return bool ? [prop, val] : prop + ":" + val;
141
143
  }
142
144
  }
@@ -1,5 +1,7 @@
1
1
  const colorBase = {
2
2
  'brandRA': 'var(--brandColor,oklch(1 .25049 284.23))',
3
+ 'accentRA': 'var(--accentColor,oklch(1 .25049 284.23))',
4
+ 'tintRA': 'var(--tintColor,oklch(1 .25049 284.23))',
3
5
  'grayRA': 'var(--grayColor,oklch(0.5 0 0))',
4
6
  'redRA': 'var(--redColor,oklch(0.6 .181447 27.0726))',
5
7
  'orangeRA': 'var(--orangeColor,oklch(0.7 .150492 54))',
@@ -79,4 +81,4 @@ const colors = () => {
79
81
  }
80
82
  return collection;
81
83
  };
82
- export const customColorsRa = colors();
84
+ export const customColorsRa = Object.assign(Object.assign({}, colors()), colorBase);
@@ -0,0 +1,3 @@
1
+ export declare const staticClassNamesAlias: {
2
+ [key: string]: string;
3
+ };