@master/css 2.0.0-rc.27 → 2.0.0-rc.29

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.
package/dist/common.cjs CHANGED
@@ -104,10 +104,31 @@ const IMAGE_VALUE_REGEX = /(?:url|linear-gradient|radial-gradient|repeating-line
104
104
  const COLOR_VALUE_REGEX = /(?:#|(?:color|color-contrast|color-mix|hwb|lab|lch|oklab|oklch|rgb|rgba|hsl|hsla)\\(.*\\)|(?:\$colors)(?![a-zA-Z0-9-]))/;
105
105
  const NUMBER_VALUE_REGEX = /(?:[\d.]|(?:max|min|calc|clamp)\(.*\))/;
106
106
  const OFFICIAL_URL = new URL('https://rc.css.master.co');
107
+ const CLASS_ATTRIBUTES = [
108
+ 'class',
109
+ 'className'
110
+ ];
111
+ const CLASS_DECLARATIONS = [
112
+ 'styles'
113
+ ];
114
+ const CLASS_FUNCTIONS = [
115
+ 'clsx',
116
+ 'cva',
117
+ 'ctl',
118
+ 'cv',
119
+ 'class',
120
+ 'classnames',
121
+ 'classVariant',
122
+ 'styled(?:\\s+)?(?:\\.\\w+)?',
123
+ 'classList(?:\\s+)?\\.(?:add|remove|toggle|replace)'
124
+ ];
107
125
 
108
126
  exports.ANIMATION_SIGN = ANIMATION_SIGN;
109
127
  exports.AT_SIGN = AT_SIGN;
110
128
  exports.BASE_UNIT_REGEX = BASE_UNIT_REGEX;
129
+ exports.CLASS_ATTRIBUTES = CLASS_ATTRIBUTES;
130
+ exports.CLASS_DECLARATIONS = CLASS_DECLARATIONS;
131
+ exports.CLASS_FUNCTIONS = CLASS_FUNCTIONS;
111
132
  exports.COLOR_VALUE_REGEX = COLOR_VALUE_REGEX;
112
133
  exports.DELIMITER_SIGN = DELIMITER_SIGN;
113
134
  exports.IMAGE_VALUE_REGEX = IMAGE_VALUE_REGEX;
package/dist/common.d.ts CHANGED
@@ -20,3 +20,6 @@ export declare const IMAGE_VALUE_REGEX: RegExp;
20
20
  export declare const COLOR_VALUE_REGEX: RegExp;
21
21
  export declare const NUMBER_VALUE_REGEX: RegExp;
22
22
  export declare const OFFICIAL_URL: URL;
23
+ export declare const CLASS_ATTRIBUTES: string[];
24
+ export declare const CLASS_DECLARATIONS: string[];
25
+ export declare const CLASS_FUNCTIONS: string[];
package/dist/common.mjs CHANGED
@@ -102,5 +102,23 @@ const IMAGE_VALUE_REGEX = /(?:url|linear-gradient|radial-gradient|repeating-line
102
102
  const COLOR_VALUE_REGEX = /(?:#|(?:color|color-contrast|color-mix|hwb|lab|lch|oklab|oklch|rgb|rgba|hsl|hsla)\\(.*\\)|(?:\$colors)(?![a-zA-Z0-9-]))/;
103
103
  const NUMBER_VALUE_REGEX = /(?:[\d.]|(?:max|min|calc|clamp)\(.*\))/;
104
104
  const OFFICIAL_URL = new URL('https://rc.css.master.co');
105
+ const CLASS_ATTRIBUTES = [
106
+ 'class',
107
+ 'className'
108
+ ];
109
+ const CLASS_DECLARATIONS = [
110
+ 'styles'
111
+ ];
112
+ const CLASS_FUNCTIONS = [
113
+ 'clsx',
114
+ 'cva',
115
+ 'ctl',
116
+ 'cv',
117
+ 'class',
118
+ 'classnames',
119
+ 'classVariant',
120
+ 'styled(?:\\s+)?(?:\\.\\w+)?',
121
+ 'classList(?:\\s+)?\\.(?:add|remove|toggle|replace)'
122
+ ];
105
123
 
106
- export { ANIMATION_SIGN, AT_SIGN, BASE_UNIT_REGEX, COLOR_VALUE_REGEX, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS };
124
+ export { ANIMATION_SIGN, AT_SIGN, BASE_UNIT_REGEX, CLASS_ATTRIBUTES, CLASS_DECLARATIONS, CLASS_FUNCTIONS, COLOR_VALUE_REGEX, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS };
@@ -6,6 +6,7 @@ var utilities = require('./utilities.cjs');
6
6
  var animations = require('./animations.cjs');
7
7
  var variables = require('./variables.cjs');
8
8
  var rules = require('./rules.cjs');
9
+ var modes = require('./modes.cjs');
9
10
  var functions = require('./functions.cjs');
10
11
 
11
12
  const config = {
@@ -16,12 +17,12 @@ const config = {
16
17
  functions,
17
18
  animations,
18
19
  variables,
20
+ modes,
19
21
  scope: '',
20
22
  rootSize: 16,
21
23
  baseUnit: 4,
22
24
  override: false,
23
- important: false,
24
- modeDriver: 'class'
25
+ important: false
25
26
  };
26
27
 
27
28
  exports.queries = queries;
@@ -30,5 +31,6 @@ exports.utilities = utilities;
30
31
  exports.animations = animations;
31
32
  exports.variables = variables;
32
33
  exports.rules = rules.default;
34
+ exports.modes = modes;
33
35
  exports.functions = functions;
34
36
  exports.config = config;
@@ -4,11 +4,12 @@ import utilities from './utilities';
4
4
  import animations from './animations';
5
5
  import variables from './variables';
6
6
  import rules from './rules';
7
+ import modes from './modes';
7
8
  import functions from './functions';
8
9
  import type { PropertiesHyphen } from 'csstype';
9
10
  import type { Rule, RuleDefinition, ValueComponent } from '../rule';
10
11
  declare const config: Config;
11
- export { config, queries, selectors, utilities, rules, functions, animations, variables };
12
+ export { config, queries, selectors, utilities, rules, functions, animations, variables, modes };
12
13
  export type VariableValue = number | string | Array<number | string>;
13
14
  export type VariableDefinition = {
14
15
  [key in '' | `@${string}` | string]?: VariableValue | VariableDefinition;
@@ -41,6 +42,9 @@ export type UtilityDefinitions = {
41
42
  } & {
42
43
  [key: string]: PropertiesHyphen;
43
44
  };
45
+ export type ModeDefinitions = {
46
+ [key: string]: 'class' | 'media' | 'host';
47
+ };
44
48
  export interface FunctionDefinition {
45
49
  unit?: string;
46
50
  transform?(this: Rule, value: string, bypassVariableNames: string[]): string | ValueComponent[];
@@ -63,5 +67,5 @@ export interface Config {
63
67
  override?: boolean;
64
68
  functions?: FunctionDefinitions;
65
69
  animations?: AnimationDefinitions;
66
- modeDriver?: 'class' | 'media' | 'host';
70
+ modes?: Record<string, 'class' | 'media' | 'host' | false>;
67
71
  }
@@ -4,6 +4,7 @@ import utilities from './utilities.mjs';
4
4
  import animations from './animations.mjs';
5
5
  import variables from './variables.mjs';
6
6
  import rules from './rules.mjs';
7
+ import modes from './modes.mjs';
7
8
  import functions from './functions.mjs';
8
9
 
9
10
  const config = {
@@ -14,12 +15,12 @@ const config = {
14
15
  functions,
15
16
  animations,
16
17
  variables,
18
+ modes,
17
19
  scope: '',
18
20
  rootSize: 16,
19
21
  baseUnit: 4,
20
22
  override: false,
21
- important: false,
22
- modeDriver: 'class'
23
+ important: false
23
24
  };
24
25
 
25
- export { animations, config, functions, queries, rules, selectors, utilities, variables };
26
+ export { animations, config, functions, modes, queries, rules, selectors, utilities, variables };
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const modes = {
4
+ dark: 'class',
5
+ light: 'class'
6
+ };
7
+
8
+ module.exports = modes;
@@ -0,0 +1,3 @@
1
+ import type { ModeDefinitions } from './';
2
+ declare const modes: ModeDefinitions;
3
+ export default modes;
@@ -0,0 +1,6 @@
1
+ const modes = {
2
+ dark: 'class',
3
+ light: 'class'
4
+ };
5
+
6
+ export { modes as default };
package/dist/core.cjs CHANGED
@@ -922,7 +922,7 @@ class MasterCSS {
922
922
  let mediaConditionText;
923
923
  let selectorText;
924
924
  if (mode) {
925
- switch(this.config.modeDriver){
925
+ switch(this.config.modes?.[mode]){
926
926
  case 'media':
927
927
  mediaConditionText = `@media(prefers-color-scheme:${mode})`;
928
928
  selectorText = ':root';
@@ -930,9 +930,11 @@ class MasterCSS {
930
930
  case 'host':
931
931
  selectorText = `:host(.${mode})`;
932
932
  break;
933
- default:
933
+ case 'class':
934
934
  selectorText = `.${mode}`;
935
935
  break;
936
+ default:
937
+ return;
936
938
  }
937
939
  } else {
938
940
  selectorText = ':root';
package/dist/core.mjs CHANGED
@@ -918,7 +918,7 @@ class MasterCSS {
918
918
  let mediaConditionText;
919
919
  let selectorText;
920
920
  if (mode) {
921
- switch(this.config.modeDriver){
921
+ switch(this.config.modes?.[mode]){
922
922
  case 'media':
923
923
  mediaConditionText = `@media(prefers-color-scheme:${mode})`;
924
924
  selectorText = ':root';
@@ -926,9 +926,11 @@ class MasterCSS {
926
926
  case 'host':
927
927
  selectorText = `:host(.${mode})`;
928
928
  break;
929
- default:
929
+ case 'class':
930
930
  selectorText = `.${mode}`;
931
931
  break;
932
+ default:
933
+ return;
932
934
  }
933
935
  } else {
934
936
  selectorText = ':root';
package/dist/index.cjs CHANGED
@@ -22,6 +22,7 @@ var utilities = require('./config/utilities.cjs');
22
22
  var functions = require('./config/functions.cjs');
23
23
  var animations = require('./config/animations.cjs');
24
24
  var variables = require('./config/variables.cjs');
25
+ var modes = require('./config/modes.cjs');
25
26
  var rules = require('./config/rules.cjs');
26
27
 
27
28
 
@@ -31,6 +32,9 @@ exports.Rule = rule.Rule;
31
32
  exports.ANIMATION_SIGN = common.ANIMATION_SIGN;
32
33
  exports.AT_SIGN = common.AT_SIGN;
33
34
  exports.BASE_UNIT_REGEX = common.BASE_UNIT_REGEX;
35
+ exports.CLASS_ATTRIBUTES = common.CLASS_ATTRIBUTES;
36
+ exports.CLASS_DECLARATIONS = common.CLASS_DECLARATIONS;
37
+ exports.CLASS_FUNCTIONS = common.CLASS_FUNCTIONS;
34
38
  exports.COLOR_VALUE_REGEX = common.COLOR_VALUE_REGEX;
35
39
  exports.DELIMITER_SIGN = common.DELIMITER_SIGN;
36
40
  exports.IMAGE_VALUE_REGEX = common.IMAGE_VALUE_REGEX;
@@ -64,4 +68,5 @@ exports.utilities = utilities;
64
68
  exports.functions = functions;
65
69
  exports.animations = animations;
66
70
  exports.variables = variables;
71
+ exports.modes = modes;
67
72
  exports.rules = rules.default;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { config } from './config/index.mjs';
2
2
  export { Rule } from './rule.mjs';
3
- export { ANIMATION_SIGN, AT_SIGN, BASE_UNIT_REGEX, COLOR_VALUE_REGEX, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS } from './common.mjs';
3
+ export { ANIMATION_SIGN, AT_SIGN, BASE_UNIT_REGEX, CLASS_ATTRIBUTES, CLASS_DECLARATIONS, CLASS_FUNCTIONS, COLOR_VALUE_REGEX, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS } from './common.mjs';
4
4
  export { default as MasterCSS, default, masterCSSs } from './core.mjs';
5
5
  export { default as Layer } from './layer.mjs';
6
6
  export { default as extendConfig } from './utils/extend-config.mjs';
@@ -18,4 +18,5 @@ export { default as utilities } from './config/utilities.mjs';
18
18
  export { default as functions } from './config/functions.mjs';
19
19
  export { default as animations } from './config/animations.mjs';
20
20
  export { default as variables } from './config/variables.mjs';
21
+ export { default as modes } from './config/modes.mjs';
21
22
  export { default as rules } from './config/rules.mjs';
package/dist/rule.cjs CHANGED
@@ -266,7 +266,7 @@ class Rule {
266
266
  if (!definition.separators) definition.separators = [
267
267
  ','
268
268
  ];
269
- const { scope, important, modeDriver } = css.config;
269
+ const { scope, important, modes } = css.config;
270
270
  const { selectors, queries, stylesBy, animations } = css;
271
271
  const classNames = stylesBy[className];
272
272
  if (create) create.call(this, className);
@@ -558,7 +558,7 @@ class Rule {
558
558
  analyzeToken(atToken);
559
559
  }
560
560
  if (!atComponents.length) {
561
- if (!isAmpersandIncluded) {
561
+ if (!isAmpersandIncluded && modes?.[atToken]) {
562
562
  this.mode = atToken;
563
563
  continue;
564
564
  }
@@ -624,7 +624,7 @@ class Rule {
624
624
  const prefixSelectors = this.vendorPrefixSelectors[prefixSelectorVendor];
625
625
  const suffixSelectors = this.vendorSuffixSelectors[eachSuffixSelectorVendor];
626
626
  const prefixTexts = prefixSelectors.map((eachPrefixSelector)=>eachPrefixSelector + prefixText);
627
- const getCssText = (name)=>prefixTexts.map((eachPrefixText)=>(this.mode && modeDriver !== 'media' ? modeDriver === 'host' ? `:host(.${this.mode}) ` : `.${this.mode} ` : '') + (scope ? scope + ' ' : '') + eachPrefixText).reduce((arr, eachPrefixText)=>{
627
+ const getCssText = (name)=>prefixTexts.map((eachPrefixText)=>(this.mode && modes?.[this.mode] !== 'media' ? modes?.[this.mode] === 'host' ? `:host(.${this.mode}) ` : `.${this.mode} ` : '') + (scope ? scope + ' ' : '') + eachPrefixText).reduce((arr, eachPrefixText)=>{
628
628
  arr.push(suffixSelectors.reduce((_arr, eachSuffixSelector)=>{
629
629
  _arr.push(eachPrefixText + '.' + cssEscape(name) + eachSuffixSelector);
630
630
  return _arr;
@@ -635,7 +635,7 @@ class Rule {
635
635
  for (const key of Object.keys(this.at).sort((_a, b)=>b === 'supports' ? -1 : 1)){
636
636
  cssText = '@' + key + (key.includes(' ') ? '' : ' ') + this.at[key].map((eachAtComponent)=>this.resolveAtComponent(eachAtComponent)).join(' ') + '{' + cssText + '}';
637
637
  }
638
- if (this.mode && modeDriver === 'media') {
638
+ if (this.mode && modes?.[this.mode] === 'media') {
639
639
  cssText = `@media(prefers-color-scheme:${this.mode}){` + cssText + '}';
640
640
  }
641
641
  this.natives.push({
package/dist/rule.mjs CHANGED
@@ -264,7 +264,7 @@ class Rule {
264
264
  if (!definition.separators) definition.separators = [
265
265
  ','
266
266
  ];
267
- const { scope, important, modeDriver } = css.config;
267
+ const { scope, important, modes } = css.config;
268
268
  const { selectors, queries, stylesBy, animations } = css;
269
269
  const classNames = stylesBy[className];
270
270
  if (create) create.call(this, className);
@@ -556,7 +556,7 @@ class Rule {
556
556
  analyzeToken(atToken);
557
557
  }
558
558
  if (!atComponents.length) {
559
- if (!isAmpersandIncluded) {
559
+ if (!isAmpersandIncluded && modes?.[atToken]) {
560
560
  this.mode = atToken;
561
561
  continue;
562
562
  }
@@ -622,7 +622,7 @@ class Rule {
622
622
  const prefixSelectors = this.vendorPrefixSelectors[prefixSelectorVendor];
623
623
  const suffixSelectors = this.vendorSuffixSelectors[eachSuffixSelectorVendor];
624
624
  const prefixTexts = prefixSelectors.map((eachPrefixSelector)=>eachPrefixSelector + prefixText);
625
- const getCssText = (name)=>prefixTexts.map((eachPrefixText)=>(this.mode && modeDriver !== 'media' ? modeDriver === 'host' ? `:host(.${this.mode}) ` : `.${this.mode} ` : '') + (scope ? scope + ' ' : '') + eachPrefixText).reduce((arr, eachPrefixText)=>{
625
+ const getCssText = (name)=>prefixTexts.map((eachPrefixText)=>(this.mode && modes?.[this.mode] !== 'media' ? modes?.[this.mode] === 'host' ? `:host(.${this.mode}) ` : `.${this.mode} ` : '') + (scope ? scope + ' ' : '') + eachPrefixText).reduce((arr, eachPrefixText)=>{
626
626
  arr.push(suffixSelectors.reduce((_arr, eachSuffixSelector)=>{
627
627
  _arr.push(eachPrefixText + '.' + cssEscape(name) + eachSuffixSelector);
628
628
  return _arr;
@@ -633,7 +633,7 @@ class Rule {
633
633
  for (const key of Object.keys(this.at).sort((_a, b)=>b === 'supports' ? -1 : 1)){
634
634
  cssText = '@' + key + (key.includes(' ') ? '' : ' ') + this.at[key].map((eachAtComponent)=>this.resolveAtComponent(eachAtComponent)).join(' ') + '{' + cssText + '}';
635
635
  }
636
- if (this.mode && modeDriver === 'media') {
636
+ if (this.mode && modes?.[this.mode] === 'media') {
637
637
  cssText = `@media(prefers-color-scheme:${this.mode}){` + cssText + '}';
638
638
  }
639
639
  this.natives.push({
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@master/css","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","test":"jest","type-check":"tsc --noEmit","lint":"eslint src"},"license":"MIT","description":"The CSS language and framework for rapidly building modern and high-performance websites","author":"Aoyue Design LLC.","funding":"https://css.master.co/docs/donate","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/css"},"keywords":["style","styles","html","variants","virtual","virtual-css","utility","css","ui","lightweight","class","webpack","plugin","integration","vite","parcel","build-tools","mastercss"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.cjs","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"bin":"./dist/bin/index.mjs","files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/colors":"^2.0.0","@master/normal.css":"^2.1.0","@techor/extend":"^3.0.18"},"devDependencies":{"@master/css-shared":"^2.0.0-rc.27","csstype":"^3.1.3"},"version":"2.0.0-rc.27"}
1
+ {"name":"@master/css","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","test":"jest","type-check":"tsc --noEmit","lint":"eslint src"},"license":"MIT","description":"The CSS language and framework for rapidly building modern and high-performance websites","author":"Aoyue Design LLC.","funding":"https://css.master.co/docs/donate","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/core"},"keywords":["style","styles","html","variants","virtual","virtual-css","utility","css","ui","lightweight","class","webpack","plugin","integration","vite","parcel","build-tools","mastercss"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.cjs","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"bin":"./dist/bin/index.mjs","files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/colors":"^2.0.0","@master/normal.css":"^2.1.0","@techor/extend":"^3.0.18"},"devDependencies":{"@master/css-shared":"^2.0.0-rc.29","csstype":"^3.1.3"},"version":"2.0.0-rc.29"}