@master/css 2.0.0-rc.68 → 2.0.0-rc.69
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 +0 -2
- package/dist/common.d.ts +0 -1
- package/dist/common.mjs +1 -2
- package/dist/config/functions.cjs +9 -243
- package/dist/config/functions.d.ts +137 -2
- package/dist/config/functions.mjs +9 -243
- package/dist/config/index.cjs +2 -2
- package/dist/config/index.mjs +2 -2
- package/dist/config/modes.cjs +307 -3
- package/dist/config/modes.d.ts +306 -2
- package/dist/config/modes.mjs +307 -3
- package/dist/config/rules.cjs +740 -782
- package/dist/config/rules.d.ts +692 -683
- package/dist/config/rules.mjs +741 -783
- package/dist/config/utilities.cjs +328 -97
- package/dist/config/utilities.d.ts +247 -16
- package/dist/config/utilities.mjs +328 -97
- package/dist/config/variables.cjs +88 -460
- package/dist/config/variables.d.ts +358 -369
- package/dist/config/variables.mjs +88 -460
- package/dist/core.cjs +234 -234
- package/dist/core.d.ts +5 -3
- package/dist/core.mjs +234 -234
- package/dist/create.cjs +10 -0
- package/dist/create.d.ts +3 -0
- package/dist/create.mjs +8 -0
- package/dist/declarers/core.group.cjs +99 -0
- package/dist/declarers/core.group.d.ts +2 -0
- package/dist/declarers/core.group.mjs +97 -0
- package/dist/declarers/core.variable.cjs +9 -0
- package/dist/declarers/core.variable.d.ts +4 -0
- package/dist/declarers/core.variable.mjs +7 -0
- package/dist/declarers/index.cjs +13 -0
- package/dist/declarers/index.d.ts +10 -0
- package/dist/declarers/index.mjs +11 -0
- package/dist/declarers/pair.cjs +12 -0
- package/dist/declarers/pair.d.ts +4 -0
- package/dist/declarers/pair.mjs +10 -0
- package/dist/factories/with-syntax-layer.cjs +0 -2
- package/dist/factories/with-syntax-layer.mjs +0 -2
- package/dist/function-transformers/core.calc.cjs +225 -0
- package/dist/function-transformers/core.calc.d.ts +2 -0
- package/dist/function-transformers/core.calc.mjs +223 -0
- package/dist/function-transformers/core.variable.cjs +23 -0
- package/dist/function-transformers/core.variable.d.ts +7 -0
- package/dist/function-transformers/core.variable.mjs +21 -0
- package/dist/function-transformers/index.cjs +11 -0
- package/dist/function-transformers/index.d.ts +8 -0
- package/dist/function-transformers/index.mjs +9 -0
- package/dist/index.cjs +10 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.mjs +6 -1
- package/dist/layer.cjs +2 -4
- package/dist/layer.mjs +2 -4
- package/dist/non-layer.cjs +2 -4
- package/dist/non-layer.mjs +2 -4
- package/dist/syntax-rule-type.cjs +8 -7
- package/dist/syntax-rule-type.d.ts +7 -7
- package/dist/syntax-rule-type.mjs +8 -7
- package/dist/syntax-rule.cjs +305 -258
- package/dist/syntax-rule.d.ts +2 -2
- package/dist/syntax-rule.mjs +306 -259
- package/dist/{utils/autofill-solid-style.cjs → transformers/auto-fill-solid.cjs} +3 -3
- package/dist/transformers/auto-fill-solid.d.ts +2 -0
- package/dist/{utils/autofill-solid-style.mjs → transformers/auto-fill-solid.mjs} +3 -3
- package/dist/transformers/index.cjs +9 -0
- package/dist/transformers/index.d.ts +6 -0
- package/dist/transformers/index.mjs +7 -0
- package/dist/types/common.d.ts +0 -2
- package/dist/types/config.d.ts +24 -20
- package/dist/types/syntax.d.ts +10 -8
- package/dist/utils/equal-selectors.cjs +1 -2
- package/dist/utils/equal-selectors.mjs +1 -2
- package/dist/utils/extend-config.cjs +83 -44
- package/dist/utils/extend-config.d.ts +10 -1
- package/dist/utils/extend-config.mjs +83 -44
- package/dist/utils/flatten-meta-object.cjs +38 -0
- package/dist/utils/flatten-meta-object.d.ts +13 -0
- package/dist/utils/flatten-meta-object.mjs +36 -0
- package/dist/utils/flatten-object.cjs +13 -9
- package/dist/utils/flatten-object.d.ts +1 -1
- package/dist/utils/flatten-object.mjs +13 -9
- package/dist/utils/generate-css.cjs +2 -2
- package/dist/utils/generate-css.d.ts +1 -2
- package/dist/utils/generate-css.mjs +2 -2
- package/dist/utils/minify-extended-config.cjs +64 -0
- package/dist/utils/minify-extended-config.d.ts +9 -0
- package/dist/utils/minify-extended-config.mjs +62 -0
- package/dist/utils/nest-meta-object.cjs +25 -0
- package/dist/utils/nest-meta-object.d.ts +7 -0
- package/dist/utils/nest-meta-object.mjs +23 -0
- package/dist/utils/parse-at.cjs +1 -2
- package/dist/utils/parse-at.d.ts +2 -2
- package/dist/utils/parse-at.mjs +1 -2
- package/dist/utils/parse-pair.cjs +3 -6
- package/dist/utils/parse-pair.mjs +3 -6
- package/dist/utils/parse-selector.cjs +2 -4
- package/dist/utils/parse-selector.d.ts +2 -2
- package/dist/utils/parse-selector.mjs +2 -4
- package/dist/utils/sort-readable-classes.cjs +2 -2
- package/dist/utils/sort-readable-classes.d.ts +1 -2
- package/dist/utils/sort-readable-classes.mjs +2 -2
- package/dist/variable-rule.cjs +35 -29
- package/dist/variable-rule.d.ts +16 -6
- package/dist/variable-rule.mjs +35 -29
- package/package.json +1 -1
- package/dist/utils/autofill-solid-style.d.ts +0 -3
package/dist/types/common.d.ts
CHANGED
package/dist/types/config.d.ts
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
import type { PropertiesHyphen } from 'csstype';
|
|
2
|
-
import type { SyntaxRule } from '../syntax-rule';
|
|
3
|
-
import type { ValueComponent } from './syntax';
|
|
4
2
|
import type { rules, utilities } from '../config';
|
|
5
3
|
import { AT_IDENTIFIERS } from '../common';
|
|
6
|
-
import {
|
|
4
|
+
import { DeclarerNames } from '../declarers';
|
|
5
|
+
import { TransformerNames } from '../transformers';
|
|
6
|
+
import { FunctionTransformerNames } from '../function-transformers';
|
|
7
|
+
import SyntaxRuleType from '../syntax-rule-type';
|
|
7
8
|
export interface SyntaxRuleDefinition {
|
|
8
|
-
type?:
|
|
9
|
-
matcher?: RegExp;
|
|
9
|
+
type?: SyntaxRuleType;
|
|
10
|
+
matcher?: RegExp | string;
|
|
10
11
|
sign?: string;
|
|
11
12
|
key?: string;
|
|
12
13
|
subkey?: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
aliasGroups?: string[];
|
|
15
|
+
values?: string[];
|
|
16
|
+
kind?: 'number' | 'color' | 'image';
|
|
17
|
+
namespaces?: string[];
|
|
16
18
|
separators?: string[];
|
|
17
19
|
unit?: any;
|
|
18
|
-
declarations?: PropertiesHyphen;
|
|
20
|
+
declarations?: PropertiesHyphen | Record<string, string | undefined | (string | undefined)[]> | (keyof PropertiesHyphen)[];
|
|
19
21
|
includeAnimations?: boolean;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
transformValueComponents?(this: SyntaxRule, valueComponents: ValueComponent[]): ValueComponent[];
|
|
23
|
-
declare?(this: SyntaxRule, value: string, valueComponents: ValueComponent[]): PropertiesHyphen;
|
|
24
|
-
delete?(this: SyntaxRule, className: string): void;
|
|
25
|
-
create?(this: SyntaxRule, className: string): void;
|
|
26
|
-
insert?(this: SyntaxRule): void;
|
|
22
|
+
declarer?: DeclarerNames | [DeclarerNames, any];
|
|
23
|
+
transformer?: TransformerNames | [TransformerNames, any];
|
|
27
24
|
}
|
|
28
25
|
export type VariableValue = number | string | false | (number | string)[];
|
|
29
26
|
export type VariableDefinition = {
|
|
30
|
-
[key in '' |
|
|
27
|
+
[key in '' | string]?: VariableValue | VariableDefinition;
|
|
31
28
|
} | VariableValue;
|
|
32
29
|
export type CSSKeyframes = Record<'from' | 'to' | string, PropertiesHyphen>;
|
|
33
30
|
export type AnimationDefinitions = Record<string, CSSKeyframes>;
|
|
@@ -48,10 +45,10 @@ export type VariableDefinitions = {
|
|
|
48
45
|
export type UtilityDefinitions = {
|
|
49
46
|
[key in keyof typeof utilities]?: PropertiesHyphen;
|
|
50
47
|
} & Record<string, PropertiesHyphen>;
|
|
51
|
-
export type ModeDefinitions = Record<string,
|
|
48
|
+
export type ModeDefinitions = Record<string, VariableDefinitions>;
|
|
52
49
|
export interface FunctionDefinition {
|
|
53
50
|
unit?: string;
|
|
54
|
-
|
|
51
|
+
transformer?: FunctionTransformerNames | [FunctionTransformerNames, any];
|
|
55
52
|
}
|
|
56
53
|
export type FunctionDefinitions = Record<string, FunctionDefinition>;
|
|
57
54
|
export interface Config {
|
|
@@ -68,8 +65,15 @@ export interface Config {
|
|
|
68
65
|
defaultMode?: 'light' | 'dark' | string | false;
|
|
69
66
|
scope?: string;
|
|
70
67
|
important?: boolean;
|
|
71
|
-
override?: boolean;
|
|
72
68
|
functions?: FunctionDefinitions;
|
|
73
69
|
animations?: AnimationDefinitions;
|
|
74
70
|
modes?: ModeDefinitions;
|
|
71
|
+
modeTrigger?: 'class' | 'media' | 'host';
|
|
72
|
+
}
|
|
73
|
+
declare module 'csstype' {
|
|
74
|
+
interface PropertiesHyphen {
|
|
75
|
+
'-webkit-user-drag'?: 'auto' | 'element' | 'none' | 'inherit';
|
|
76
|
+
'user-drag'?: 'auto' | 'element' | 'none' | 'inherit';
|
|
77
|
+
'-webkit-text-decoration'?: string;
|
|
78
|
+
}
|
|
75
79
|
}
|
package/dist/types/syntax.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface VariableValueComponent {
|
|
|
27
27
|
token: string;
|
|
28
28
|
type: 'variable';
|
|
29
29
|
name: string;
|
|
30
|
-
alpha?:
|
|
30
|
+
alpha?: number;
|
|
31
31
|
fallback?: string;
|
|
32
32
|
variable?: Variable;
|
|
33
33
|
}
|
|
@@ -47,7 +47,7 @@ export interface DefinedRule {
|
|
|
47
47
|
value?: RegExp;
|
|
48
48
|
arbitrary?: RegExp;
|
|
49
49
|
};
|
|
50
|
-
variables
|
|
50
|
+
variables?: Map<string, Variable>;
|
|
51
51
|
order: number;
|
|
52
52
|
definition: SyntaxRuleDefinition;
|
|
53
53
|
}
|
|
@@ -64,24 +64,26 @@ export interface MediaQuery {
|
|
|
64
64
|
type?: string;
|
|
65
65
|
}
|
|
66
66
|
type VariableCommon = {
|
|
67
|
+
namespace?: string;
|
|
67
68
|
group?: string;
|
|
68
69
|
name: string;
|
|
69
70
|
key: string;
|
|
70
71
|
modes?: Record<string, LiteralVariable>;
|
|
71
72
|
};
|
|
72
|
-
export
|
|
73
|
+
export type StringVariable = {
|
|
73
74
|
type: 'string';
|
|
74
75
|
value: string;
|
|
75
|
-
}
|
|
76
|
-
export
|
|
76
|
+
};
|
|
77
|
+
export type NumberVariable = {
|
|
77
78
|
type: 'number';
|
|
78
79
|
value: number;
|
|
79
|
-
}
|
|
80
|
-
export
|
|
80
|
+
};
|
|
81
|
+
export type ColorVariable = {
|
|
81
82
|
type: 'color';
|
|
82
83
|
value: string;
|
|
83
84
|
space: 'rgb' | 'hsl';
|
|
84
|
-
|
|
85
|
+
alpha?: number;
|
|
86
|
+
};
|
|
85
87
|
export type LiteralVariable = StringVariable | NumberVariable | ColorVariable;
|
|
86
88
|
export type Variable = LiteralVariable & VariableCommon;
|
|
87
89
|
export {};
|
|
@@ -1,58 +1,97 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var extend = require('
|
|
3
|
+
var extend = require('json-safe-extend');
|
|
4
|
+
var flattenObject = require('./flatten-object.cjs');
|
|
5
|
+
var flattenMetaObject = require('./flatten-meta-object.cjs');
|
|
4
6
|
|
|
5
|
-
// todo: split resolveConfig into a function
|
|
6
7
|
function extendConfig(...configs) {
|
|
7
|
-
const formatConfig = (config)=>{
|
|
8
|
-
const clonedConfig = extend({}, config);
|
|
9
|
-
const formatDeeply = (obj)=>{
|
|
10
|
-
Object.entries(obj).forEach(([key, value])=>{
|
|
11
|
-
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
12
|
-
formatDeeply(value);
|
|
13
|
-
} else if (key && !key.startsWith('@')) {
|
|
14
|
-
obj[key] = {
|
|
15
|
-
'': value
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
[
|
|
21
|
-
'components',
|
|
22
|
-
'variables'
|
|
23
|
-
].forEach((key)=>{
|
|
24
|
-
if (clonedConfig[key]) {
|
|
25
|
-
formatDeeply(clonedConfig[key]);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return clonedConfig;
|
|
29
|
-
};
|
|
30
8
|
const collectConfigs = (config, result = [])=>{
|
|
31
9
|
if (!config) return result;
|
|
32
10
|
if (config.extends?.length) {
|
|
33
|
-
|
|
11
|
+
for (const ext of config.extends){
|
|
12
|
+
collectConfigs('config' in ext ? ext.config : ext, result);
|
|
13
|
+
}
|
|
34
14
|
}
|
|
35
|
-
|
|
15
|
+
const cleanConfig = {
|
|
16
|
+
...config
|
|
17
|
+
};
|
|
18
|
+
delete cleanConfig.extends;
|
|
19
|
+
result.push(cleanConfig);
|
|
36
20
|
return result;
|
|
37
21
|
};
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
const allConfigs = configs.reduce((acc, config)=>collectConfigs(config, acc), []);
|
|
23
|
+
let extendedConfig = {
|
|
24
|
+
__extended: true
|
|
25
|
+
};
|
|
26
|
+
for (const { variables, modes, components, animations, at, rules, utilities, selectors, functions, ...rest } of allConfigs){
|
|
27
|
+
const isExtended = '__extended' in rest;
|
|
28
|
+
if (isExtended) delete rest.__extended;
|
|
29
|
+
// variables
|
|
30
|
+
if (variables) {
|
|
31
|
+
extendedConfig.variables ??= {};
|
|
32
|
+
const flattened = isExtended ? {
|
|
33
|
+
...variables
|
|
34
|
+
} : flattenMetaObject(variables, [], {});
|
|
35
|
+
Object.assign(extendedConfig.variables, flattened);
|
|
36
|
+
}
|
|
37
|
+
// modes
|
|
38
|
+
if (modes) {
|
|
39
|
+
extendedConfig.modes ??= {};
|
|
40
|
+
for (const [modeName, modeVars] of Object.entries(modes)){
|
|
41
|
+
const flattenedMode = isExtended ? {
|
|
42
|
+
...modeVars
|
|
43
|
+
} : flattenMetaObject(modeVars, [], {});
|
|
44
|
+
extendedConfig.modes[modeName] = {
|
|
45
|
+
...extendedConfig.modes[modeName],
|
|
46
|
+
...flattenedMode
|
|
47
|
+
};
|
|
47
48
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
}
|
|
50
|
+
// components
|
|
51
|
+
if (components) {
|
|
52
|
+
extendedConfig.components ??= {};
|
|
53
|
+
const flattened = isExtended ? {
|
|
54
|
+
...components
|
|
55
|
+
} : flattenObject(components);
|
|
56
|
+
Object.assign(extendedConfig.components, flattened);
|
|
57
|
+
}
|
|
58
|
+
// at
|
|
59
|
+
if (at) {
|
|
60
|
+
extendedConfig.at ??= {};
|
|
61
|
+
const flattened = isExtended ? {
|
|
62
|
+
...at
|
|
63
|
+
} : flattenObject(at);
|
|
64
|
+
Object.assign(extendedConfig.at, flattened);
|
|
65
|
+
}
|
|
66
|
+
// animations
|
|
67
|
+
if (animations) {
|
|
68
|
+
extendedConfig.animations ??= {};
|
|
69
|
+
Object.assign(extendedConfig.animations, animations);
|
|
70
|
+
}
|
|
71
|
+
// rules
|
|
72
|
+
if (rules) {
|
|
73
|
+
extendedConfig.rules ??= {};
|
|
74
|
+
Object.assign(extendedConfig.rules, rules);
|
|
75
|
+
}
|
|
76
|
+
// utilities
|
|
77
|
+
if (utilities) {
|
|
78
|
+
extendedConfig.utilities ??= {};
|
|
79
|
+
Object.assign(extendedConfig.utilities, utilities);
|
|
80
|
+
}
|
|
81
|
+
// selectors
|
|
82
|
+
if (selectors) {
|
|
83
|
+
extendedConfig.selectors ??= {};
|
|
84
|
+
Object.assign(extendedConfig.selectors, selectors);
|
|
85
|
+
}
|
|
86
|
+
// functions
|
|
87
|
+
if (functions) {
|
|
88
|
+
extendedConfig.functions ??= {};
|
|
89
|
+
Object.assign(extendedConfig.functions, functions);
|
|
90
|
+
}
|
|
91
|
+
// merge the rest (non-structured fields)
|
|
92
|
+
extendedConfig = extend({}, extendedConfig, rest);
|
|
93
|
+
}
|
|
94
|
+
return extendedConfig;
|
|
56
95
|
}
|
|
57
96
|
|
|
58
97
|
module.exports = extendConfig;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import type { Config } from '../types/config';
|
|
2
|
-
|
|
2
|
+
import { Variable } from '../types/syntax';
|
|
3
|
+
export declare type ExtendedConfig = {
|
|
4
|
+
__extended?: boolean;
|
|
5
|
+
variables?: Record<string, Variable>;
|
|
6
|
+
modes?: Record<string, Record<string, Variable>>;
|
|
7
|
+
at?: Record<string, string>;
|
|
8
|
+
selectors?: Record<string, string>;
|
|
9
|
+
components?: Record<string, string>;
|
|
10
|
+
} & Omit<Config, 'variables' | 'modes'>;
|
|
11
|
+
export default function extendConfig(...configs: (Config | undefined)[]): ExtendedConfig;
|
|
@@ -1,56 +1,95 @@
|
|
|
1
|
-
import extend from '
|
|
1
|
+
import extend from 'json-safe-extend';
|
|
2
|
+
import flattenObject from './flatten-object.mjs';
|
|
3
|
+
import flattenMetaObject from './flatten-meta-object.mjs';
|
|
2
4
|
|
|
3
|
-
// todo: split resolveConfig into a function
|
|
4
5
|
function extendConfig(...configs) {
|
|
5
|
-
const formatConfig = (config)=>{
|
|
6
|
-
const clonedConfig = extend({}, config);
|
|
7
|
-
const formatDeeply = (obj)=>{
|
|
8
|
-
Object.entries(obj).forEach(([key, value])=>{
|
|
9
|
-
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
10
|
-
formatDeeply(value);
|
|
11
|
-
} else if (key && !key.startsWith('@')) {
|
|
12
|
-
obj[key] = {
|
|
13
|
-
'': value
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
[
|
|
19
|
-
'components',
|
|
20
|
-
'variables'
|
|
21
|
-
].forEach((key)=>{
|
|
22
|
-
if (clonedConfig[key]) {
|
|
23
|
-
formatDeeply(clonedConfig[key]);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return clonedConfig;
|
|
27
|
-
};
|
|
28
6
|
const collectConfigs = (config, result = [])=>{
|
|
29
7
|
if (!config) return result;
|
|
30
8
|
if (config.extends?.length) {
|
|
31
|
-
|
|
9
|
+
for (const ext of config.extends){
|
|
10
|
+
collectConfigs('config' in ext ? ext.config : ext, result);
|
|
11
|
+
}
|
|
32
12
|
}
|
|
33
|
-
|
|
13
|
+
const cleanConfig = {
|
|
14
|
+
...config
|
|
15
|
+
};
|
|
16
|
+
delete cleanConfig.extends;
|
|
17
|
+
result.push(cleanConfig);
|
|
34
18
|
return result;
|
|
35
19
|
};
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
const allConfigs = configs.reduce((acc, config)=>collectConfigs(config, acc), []);
|
|
21
|
+
let extendedConfig = {
|
|
22
|
+
__extended: true
|
|
23
|
+
};
|
|
24
|
+
for (const { variables, modes, components, animations, at, rules, utilities, selectors, functions, ...rest } of allConfigs){
|
|
25
|
+
const isExtended = '__extended' in rest;
|
|
26
|
+
if (isExtended) delete rest.__extended;
|
|
27
|
+
// variables
|
|
28
|
+
if (variables) {
|
|
29
|
+
extendedConfig.variables ??= {};
|
|
30
|
+
const flattened = isExtended ? {
|
|
31
|
+
...variables
|
|
32
|
+
} : flattenMetaObject(variables, [], {});
|
|
33
|
+
Object.assign(extendedConfig.variables, flattened);
|
|
34
|
+
}
|
|
35
|
+
// modes
|
|
36
|
+
if (modes) {
|
|
37
|
+
extendedConfig.modes ??= {};
|
|
38
|
+
for (const [modeName, modeVars] of Object.entries(modes)){
|
|
39
|
+
const flattenedMode = isExtended ? {
|
|
40
|
+
...modeVars
|
|
41
|
+
} : flattenMetaObject(modeVars, [], {});
|
|
42
|
+
extendedConfig.modes[modeName] = {
|
|
43
|
+
...extendedConfig.modes[modeName],
|
|
44
|
+
...flattenedMode
|
|
45
|
+
};
|
|
45
46
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
}
|
|
48
|
+
// components
|
|
49
|
+
if (components) {
|
|
50
|
+
extendedConfig.components ??= {};
|
|
51
|
+
const flattened = isExtended ? {
|
|
52
|
+
...components
|
|
53
|
+
} : flattenObject(components);
|
|
54
|
+
Object.assign(extendedConfig.components, flattened);
|
|
55
|
+
}
|
|
56
|
+
// at
|
|
57
|
+
if (at) {
|
|
58
|
+
extendedConfig.at ??= {};
|
|
59
|
+
const flattened = isExtended ? {
|
|
60
|
+
...at
|
|
61
|
+
} : flattenObject(at);
|
|
62
|
+
Object.assign(extendedConfig.at, flattened);
|
|
63
|
+
}
|
|
64
|
+
// animations
|
|
65
|
+
if (animations) {
|
|
66
|
+
extendedConfig.animations ??= {};
|
|
67
|
+
Object.assign(extendedConfig.animations, animations);
|
|
68
|
+
}
|
|
69
|
+
// rules
|
|
70
|
+
if (rules) {
|
|
71
|
+
extendedConfig.rules ??= {};
|
|
72
|
+
Object.assign(extendedConfig.rules, rules);
|
|
73
|
+
}
|
|
74
|
+
// utilities
|
|
75
|
+
if (utilities) {
|
|
76
|
+
extendedConfig.utilities ??= {};
|
|
77
|
+
Object.assign(extendedConfig.utilities, utilities);
|
|
78
|
+
}
|
|
79
|
+
// selectors
|
|
80
|
+
if (selectors) {
|
|
81
|
+
extendedConfig.selectors ??= {};
|
|
82
|
+
Object.assign(extendedConfig.selectors, selectors);
|
|
83
|
+
}
|
|
84
|
+
// functions
|
|
85
|
+
if (functions) {
|
|
86
|
+
extendedConfig.functions ??= {};
|
|
87
|
+
Object.assign(extendedConfig.functions, functions);
|
|
88
|
+
}
|
|
89
|
+
// merge the rest (non-structured fields)
|
|
90
|
+
extendedConfig = extend({}, extendedConfig, rest);
|
|
91
|
+
}
|
|
92
|
+
return extendedConfig;
|
|
54
93
|
}
|
|
55
94
|
|
|
56
95
|
export { extendConfig as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function flattenMetaObject(obj, name = [], result = {}) {
|
|
4
|
+
for (const [rawKey, rawValue] of Object.entries(obj)){
|
|
5
|
+
const key = rawKey || name[0] || '';
|
|
6
|
+
const path = [
|
|
7
|
+
...name,
|
|
8
|
+
rawKey
|
|
9
|
+
].filter(Boolean);
|
|
10
|
+
const flatKey = path.join('-');
|
|
11
|
+
const groupPath = path.slice(0, -1).join('.');
|
|
12
|
+
const namespace = path[0];
|
|
13
|
+
const isObject = rawValue && typeof rawValue === 'object' && !Array.isArray(rawValue);
|
|
14
|
+
const isSelfObject = isObject && Object.keys(rawValue).length === 1 && '' in rawValue;
|
|
15
|
+
if (isSelfObject) {
|
|
16
|
+
result[flatKey] = {
|
|
17
|
+
name: flatKey,
|
|
18
|
+
key,
|
|
19
|
+
value: rawValue[''],
|
|
20
|
+
group: path.length > 1 ? groupPath : undefined,
|
|
21
|
+
namespace: path.length > 1 ? namespace : undefined
|
|
22
|
+
};
|
|
23
|
+
} else if (!isObject) {
|
|
24
|
+
result[flatKey] = {
|
|
25
|
+
name: flatKey,
|
|
26
|
+
key,
|
|
27
|
+
value: Array.isArray(rawValue) ? rawValue.join(',') : rawValue,
|
|
28
|
+
group: path.length > 1 ? groupPath : undefined,
|
|
29
|
+
namespace: path.length > 1 ? namespace : undefined
|
|
30
|
+
};
|
|
31
|
+
} else {
|
|
32
|
+
flattenMetaObject(rawValue, path, result);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = flattenMetaObject;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default function flattenMetaObject(obj: Record<string, any>, name?: string[], result?: Record<string, {
|
|
2
|
+
name: string;
|
|
3
|
+
value: any;
|
|
4
|
+
key: string;
|
|
5
|
+
group?: string;
|
|
6
|
+
namespace?: string;
|
|
7
|
+
}>): Record<string, {
|
|
8
|
+
name: string;
|
|
9
|
+
value: any;
|
|
10
|
+
key: string;
|
|
11
|
+
group?: string;
|
|
12
|
+
namespace?: string;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function flattenMetaObject(obj, name = [], result = {}) {
|
|
2
|
+
for (const [rawKey, rawValue] of Object.entries(obj)){
|
|
3
|
+
const key = rawKey || name[0] || '';
|
|
4
|
+
const path = [
|
|
5
|
+
...name,
|
|
6
|
+
rawKey
|
|
7
|
+
].filter(Boolean);
|
|
8
|
+
const flatKey = path.join('-');
|
|
9
|
+
const groupPath = path.slice(0, -1).join('.');
|
|
10
|
+
const namespace = path[0];
|
|
11
|
+
const isObject = rawValue && typeof rawValue === 'object' && !Array.isArray(rawValue);
|
|
12
|
+
const isSelfObject = isObject && Object.keys(rawValue).length === 1 && '' in rawValue;
|
|
13
|
+
if (isSelfObject) {
|
|
14
|
+
result[flatKey] = {
|
|
15
|
+
name: flatKey,
|
|
16
|
+
key,
|
|
17
|
+
value: rawValue[''],
|
|
18
|
+
group: path.length > 1 ? groupPath : undefined,
|
|
19
|
+
namespace: path.length > 1 ? namespace : undefined
|
|
20
|
+
};
|
|
21
|
+
} else if (!isObject) {
|
|
22
|
+
result[flatKey] = {
|
|
23
|
+
name: flatKey,
|
|
24
|
+
key,
|
|
25
|
+
value: Array.isArray(rawValue) ? rawValue.join(',') : rawValue,
|
|
26
|
+
group: path.length > 1 ? groupPath : undefined,
|
|
27
|
+
namespace: path.length > 1 ? namespace : undefined
|
|
28
|
+
};
|
|
29
|
+
} else {
|
|
30
|
+
flattenMetaObject(rawValue, path, result);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { flattenMetaObject as default };
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function flattenObject(obj,
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
function flattenObject(obj, name = [], result = {}) {
|
|
4
|
+
for (const [key, value] of Object.entries(obj)){
|
|
5
|
+
const nextName = [
|
|
6
|
+
...name,
|
|
7
|
+
key
|
|
8
|
+
].filter(Boolean);
|
|
9
|
+
const flatKey = nextName.join('-');
|
|
10
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
11
|
+
flattenObject(value, nextName, result);
|
|
8
12
|
} else {
|
|
9
|
-
|
|
13
|
+
result[flatKey] = Array.isArray(value) ? value.join(',') : value;
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
exports
|
|
19
|
+
module.exports = flattenObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function flattenObject(obj: Record<string, any>, name?: string[], result?: Record<string, any>): Record<string, any>;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
function flattenObject(obj,
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function flattenObject(obj, name = [], result = {}) {
|
|
2
|
+
for (const [key, value] of Object.entries(obj)){
|
|
3
|
+
const nextName = [
|
|
4
|
+
...name,
|
|
5
|
+
key
|
|
6
|
+
].filter(Boolean);
|
|
7
|
+
const flatKey = nextName.join('-');
|
|
8
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
9
|
+
flattenObject(value, nextName, result);
|
|
6
10
|
} else {
|
|
7
|
-
|
|
11
|
+
result[flatKey] = Array.isArray(value) ? value.join(',') : value;
|
|
8
12
|
}
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
export { flattenObject };
|
|
17
|
+
export { flattenObject as default };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default function generateCSS(classes: string[], css?: MasterCSS): string;
|
|
1
|
+
export default function generateCSS(classes: string[], css?: import("..").MasterCSS): string;
|