@symbo.ls/scratch 3.14.0 → 3.14.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.
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/utils/sprite.js +29 -12
- package/dist/cjs/defaultConfig/animation.js +0 -24
- package/dist/cjs/defaultConfig/cases.js +0 -24
- package/dist/cjs/defaultConfig/class.js +0 -24
- package/dist/cjs/defaultConfig/color.js +0 -31
- package/dist/cjs/defaultConfig/document.js +0 -24
- package/dist/cjs/defaultConfig/font-family.js +0 -38
- package/dist/cjs/defaultConfig/font.js +0 -33
- package/dist/cjs/defaultConfig/grid.js +0 -25
- package/dist/cjs/defaultConfig/icons.js +0 -26
- package/dist/cjs/defaultConfig/index.js +0 -46
- package/dist/cjs/defaultConfig/media.js +0 -29
- package/dist/cjs/defaultConfig/responsive.js +0 -50
- package/dist/cjs/defaultConfig/sequence.js +0 -49
- package/dist/cjs/defaultConfig/shadow.js +0 -24
- package/dist/cjs/defaultConfig/spacing.js +0 -38
- package/dist/cjs/defaultConfig/svg.js +0 -26
- package/dist/cjs/defaultConfig/templates.js +0 -24
- package/dist/cjs/defaultConfig/theme.js +0 -36
- package/dist/cjs/defaultConfig/timing.js +0 -37
- package/dist/cjs/defaultConfig/typography.js +0 -41
- package/dist/cjs/defaultConfig/unit.js +0 -26
- package/dist/cjs/factory.js +0 -145
- package/dist/cjs/index.js +0 -45
- package/dist/cjs/set.js +0 -286
- package/dist/cjs/system/color.js +0 -268
- package/dist/cjs/system/document.js +0 -36
- package/dist/cjs/system/font.js +0 -71
- package/dist/cjs/system/index.js +0 -27
- package/dist/cjs/system/reset.js +0 -114
- package/dist/cjs/system/shadow.js +0 -108
- package/dist/cjs/system/spacing.js +0 -134
- package/dist/cjs/system/svg.js +0 -133
- package/dist/cjs/system/theme.js +0 -496
- package/dist/cjs/system/timing.js +0 -48
- package/dist/cjs/system/typography.js +0 -108
- package/dist/cjs/tests/index.js +0 -28
- package/dist/cjs/transforms/index.js +0 -219
- package/dist/cjs/utils/color.js +0 -206
- package/dist/cjs/utils/font.js +0 -114
- package/dist/cjs/utils/index.js +0 -24
- package/dist/cjs/utils/sequence.js +0 -342
- package/dist/cjs/utils/sprite.js +0 -92
- package/dist/cjs/utils/theme.js +0 -29
- package/dist/cjs/utils/unit.js +0 -79
- package/dist/cjs/utils/var.js +0 -116
- package/dist/esm/defaultConfig/animation.js +0 -4
- package/dist/esm/defaultConfig/cases.js +0 -4
- package/dist/esm/defaultConfig/class.js +0 -4
- package/dist/esm/defaultConfig/color.js +0 -11
- package/dist/esm/defaultConfig/document.js +0 -4
- package/dist/esm/defaultConfig/font-family.js +0 -18
- package/dist/esm/defaultConfig/font.js +0 -13
- package/dist/esm/defaultConfig/grid.js +0 -5
- package/dist/esm/defaultConfig/icons.js +0 -6
- package/dist/esm/defaultConfig/index.js +0 -25
- package/dist/esm/defaultConfig/media.js +0 -9
- package/dist/esm/defaultConfig/responsive.js +0 -30
- package/dist/esm/defaultConfig/sequence.js +0 -29
- package/dist/esm/defaultConfig/shadow.js +0 -4
- package/dist/esm/defaultConfig/spacing.js +0 -18
- package/dist/esm/defaultConfig/svg.js +0 -6
- package/dist/esm/defaultConfig/templates.js +0 -4
- package/dist/esm/defaultConfig/theme.js +0 -16
- package/dist/esm/defaultConfig/timing.js +0 -17
- package/dist/esm/defaultConfig/typography.js +0 -21
- package/dist/esm/defaultConfig/unit.js +0 -6
- package/dist/esm/factory.js +0 -120
- package/dist/esm/index.js +0 -14
- package/dist/esm/set.js +0 -280
- package/dist/esm/system/color.js +0 -253
- package/dist/esm/system/document.js +0 -16
- package/dist/esm/system/font.js +0 -58
- package/dist/esm/system/index.js +0 -10
- package/dist/esm/system/reset.js +0 -94
- package/dist/esm/system/shadow.js +0 -92
- package/dist/esm/system/spacing.js +0 -121
- package/dist/esm/system/svg.js +0 -113
- package/dist/esm/system/theme.js +0 -481
- package/dist/esm/system/timing.js +0 -32
- package/dist/esm/system/typography.js +0 -94
- package/dist/esm/tests/index.js +0 -8
- package/dist/esm/transforms/index.js +0 -216
- package/dist/esm/utils/color.js +0 -192
- package/dist/esm/utils/font.js +0 -94
- package/dist/esm/utils/index.js +0 -7
- package/dist/esm/utils/sequence.js +0 -322
- package/dist/esm/utils/sprite.js +0 -72
- package/dist/esm/utils/theme.js +0 -9
- package/dist/esm/utils/unit.js +0 -59
- package/dist/esm/utils/var.js +0 -96
- package/dist/iife/index.js +0 -3630
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var theme_exports = {};
|
|
20
|
-
__export(theme_exports, {
|
|
21
|
-
theme: () => theme
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(theme_exports);
|
|
24
|
-
const themeA = {
|
|
25
|
-
// eslint-disable-line no-unused-vars
|
|
26
|
-
text: "blue",
|
|
27
|
-
background: "white",
|
|
28
|
-
border: "black",
|
|
29
|
-
// .opacity(0.2),
|
|
30
|
-
active: {},
|
|
31
|
-
helpers: [],
|
|
32
|
-
themes: {},
|
|
33
|
-
inverse: {}
|
|
34
|
-
// schemeAInverse
|
|
35
|
-
};
|
|
36
|
-
const theme = {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var timing_exports = {};
|
|
20
|
-
__export(timing_exports, {
|
|
21
|
-
timing: () => timing
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(timing_exports);
|
|
24
|
-
var import_sequence = require("./sequence.js");
|
|
25
|
-
const defaultProps = {
|
|
26
|
-
default: 150,
|
|
27
|
-
base: 150,
|
|
28
|
-
type: "timing",
|
|
29
|
-
ratio: import_sequence.sequence["perfect-fourth"],
|
|
30
|
-
range: [-3, 12],
|
|
31
|
-
mediaRegenerate: false,
|
|
32
|
-
unit: "ms",
|
|
33
|
-
sequence: {},
|
|
34
|
-
scales: {},
|
|
35
|
-
vars: {}
|
|
36
|
-
};
|
|
37
|
-
const timing = defaultProps;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var typography_exports = {};
|
|
20
|
-
__export(typography_exports, {
|
|
21
|
-
typography: () => typography
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(typography_exports);
|
|
24
|
-
var import_sequence = require("./sequence.js");
|
|
25
|
-
const defaultProps = {
|
|
26
|
-
browserDefault: 16,
|
|
27
|
-
base: 16,
|
|
28
|
-
type: "font-size",
|
|
29
|
-
ratio: import_sequence.sequence["minor-third"],
|
|
30
|
-
range: [-3, 12],
|
|
31
|
-
h1Matches: 6,
|
|
32
|
-
lineHeight: 1.5,
|
|
33
|
-
subSequence: true,
|
|
34
|
-
mediaRegenerate: false,
|
|
35
|
-
unit: "em",
|
|
36
|
-
templates: {},
|
|
37
|
-
sequence: {},
|
|
38
|
-
scales: {},
|
|
39
|
-
vars: {}
|
|
40
|
-
};
|
|
41
|
-
const typography = defaultProps;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var unit_exports = {};
|
|
20
|
-
__export(unit_exports, {
|
|
21
|
-
unit: () => unit
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(unit_exports);
|
|
24
|
-
const unit = {
|
|
25
|
-
default: "em"
|
|
26
|
-
};
|
package/dist/cjs/factory.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var factory_exports = {};
|
|
30
|
-
__export(factory_exports, {
|
|
31
|
-
CONFIG: () => CONFIG,
|
|
32
|
-
FACTORY: () => FACTORY,
|
|
33
|
-
activateConfig: () => activateConfig,
|
|
34
|
-
createConfig: () => createConfig,
|
|
35
|
-
cssMediaVars: () => cssMediaVars,
|
|
36
|
-
cssVars: () => cssVars,
|
|
37
|
-
getActiveConfig: () => getActiveConfig,
|
|
38
|
-
popConfig: () => popConfig,
|
|
39
|
-
pushConfig: () => pushConfig,
|
|
40
|
-
setActiveConfig: () => setActiveConfig,
|
|
41
|
-
toCamel: () => toCamel
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(factory_exports);
|
|
44
|
-
var import_utils = require("@symbo.ls/utils");
|
|
45
|
-
var CONF = __toESM(require("./defaultConfig/index.js"), 1);
|
|
46
|
-
const cssVars = {};
|
|
47
|
-
const cssMediaVars = {};
|
|
48
|
-
const _CONF = CONF;
|
|
49
|
-
const _confLower = {};
|
|
50
|
-
const toCamel = (s) => s.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
51
|
-
for (const key in _CONF) {
|
|
52
|
-
const lower = key.toLowerCase();
|
|
53
|
-
_confLower[lower] = _CONF[key];
|
|
54
|
-
const camel = toCamel(lower);
|
|
55
|
-
if (camel !== lower) _confLower[camel] = _CONF[key];
|
|
56
|
-
if (lower !== key) _confLower[key] = _CONF[key];
|
|
57
|
-
}
|
|
58
|
-
const CONFIG = {
|
|
59
|
-
verbose: false,
|
|
60
|
-
useVariable: true,
|
|
61
|
-
useReset: true,
|
|
62
|
-
globalTheme: "auto",
|
|
63
|
-
cssVars,
|
|
64
|
-
cssMediaVars,
|
|
65
|
-
CSS_VARS: cssVars,
|
|
66
|
-
CSS_MEDIA_VARS: cssMediaVars,
|
|
67
|
-
_scratchConfig: true,
|
|
68
|
-
..._confLower
|
|
69
|
-
};
|
|
70
|
-
const cachedConfig = (0, import_utils.deepClone)(CONFIG);
|
|
71
|
-
const FACTORY = {
|
|
72
|
-
active: "0",
|
|
73
|
-
0: CONFIG
|
|
74
|
-
};
|
|
75
|
-
const activateConfig = (def) => {
|
|
76
|
-
if ((0, import_utils.isDefined)(def)) {
|
|
77
|
-
FACTORY.active = def;
|
|
78
|
-
}
|
|
79
|
-
return FACTORY[def || FACTORY.active];
|
|
80
|
-
};
|
|
81
|
-
const configStack = [];
|
|
82
|
-
const pushConfig = (config) => {
|
|
83
|
-
if (config && config._scratchConfig) configStack.push(config);
|
|
84
|
-
};
|
|
85
|
-
const popConfig = () => {
|
|
86
|
-
configStack.pop();
|
|
87
|
-
};
|
|
88
|
-
const getActiveConfig = (def) => {
|
|
89
|
-
if (configStack.length) return configStack[configStack.length - 1];
|
|
90
|
-
return FACTORY[def || FACTORY.active] || CONFIG;
|
|
91
|
-
};
|
|
92
|
-
const setActiveConfig = (newConfig) => {
|
|
93
|
-
if (!(0, import_utils.isObject)(newConfig)) return;
|
|
94
|
-
FACTORY.active = "1";
|
|
95
|
-
FACTORY["1"] = (0, import_utils.deepMerge)(newConfig, (0, import_utils.deepClone)(cachedConfig));
|
|
96
|
-
return newConfig;
|
|
97
|
-
};
|
|
98
|
-
const APP_FLAGS = [
|
|
99
|
-
"useReset",
|
|
100
|
-
"useVariable",
|
|
101
|
-
"useFontImport",
|
|
102
|
-
"useIconSprite",
|
|
103
|
-
"useSvgSprite",
|
|
104
|
-
"useDocumentTheme",
|
|
105
|
-
"useDefaultIcons",
|
|
106
|
-
"useDefaultConfig",
|
|
107
|
-
"verbose",
|
|
108
|
-
"globalTheme"
|
|
109
|
-
];
|
|
110
|
-
const ALIAS_GROUPS = [
|
|
111
|
-
["fontfamily", "fontFamily", "font_family"],
|
|
112
|
-
["fontfamilytypes", "fontFamilyTypes"],
|
|
113
|
-
["semanticicons", "semanticIcons"],
|
|
114
|
-
["svgdata", "svgData"]
|
|
115
|
-
];
|
|
116
|
-
const aliasCaseVariants = (cfg) => {
|
|
117
|
-
for (const vs of ALIAS_GROUPS) {
|
|
118
|
-
let merged;
|
|
119
|
-
for (const v of vs) {
|
|
120
|
-
const val = cfg[v];
|
|
121
|
-
if (!(0, import_utils.isObject)(val)) continue;
|
|
122
|
-
merged = merged ? (0, import_utils.deepMerge)(val, merged) : val;
|
|
123
|
-
}
|
|
124
|
-
if (!merged) continue;
|
|
125
|
-
for (const v of vs) if ((0, import_utils.isObject)(cfg[v])) cfg[v] = merged;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const createConfig = (name, overrides, { cleanBase = false } = {}) => {
|
|
129
|
-
const activeBase = cleanBase ? null : getActiveConfig();
|
|
130
|
-
const base = (0, import_utils.deepClone)(
|
|
131
|
-
!cleanBase && activeBase && activeBase._scratchConfig ? activeBase : cachedConfig
|
|
132
|
-
);
|
|
133
|
-
for (const flag of APP_FLAGS) {
|
|
134
|
-
delete base[flag];
|
|
135
|
-
}
|
|
136
|
-
const cfg = (0, import_utils.deepMerge)(overrides || {}, base);
|
|
137
|
-
cfg.cssVars = {};
|
|
138
|
-
cfg.cssMediaVars = {};
|
|
139
|
-
cfg.CSS_VARS = cfg.cssVars;
|
|
140
|
-
cfg.CSS_MEDIA_VARS = cfg.cssMediaVars;
|
|
141
|
-
cfg._scratchConfig = true;
|
|
142
|
-
aliasCaseVariants(cfg);
|
|
143
|
-
if (name) FACTORY[name] = cfg;
|
|
144
|
-
return cfg;
|
|
145
|
-
};
|
package/dist/cjs/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var index_exports = {};
|
|
31
|
-
__export(index_exports, {
|
|
32
|
-
scratchDefaultConfig: () => scratchDefaultConfig,
|
|
33
|
-
scratchSystem: () => scratchSystem,
|
|
34
|
-
scratchUtils: () => scratchUtils
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
var scratchUtils = __toESM(require("./utils/index.js"), 1);
|
|
38
|
-
var scratchSystem = __toESM(require("./system/index.js"), 1);
|
|
39
|
-
var scratchDefaultConfig = __toESM(require("./defaultConfig/index.js"), 1);
|
|
40
|
-
__reExport(index_exports, require("./factory.js"), module.exports);
|
|
41
|
-
__reExport(index_exports, require("./defaultConfig/index.js"), module.exports);
|
|
42
|
-
__reExport(index_exports, require("./system/index.js"), module.exports);
|
|
43
|
-
__reExport(index_exports, require("./utils/index.js"), module.exports);
|
|
44
|
-
__reExport(index_exports, require("./transforms/index.js"), module.exports);
|
|
45
|
-
__reExport(index_exports, require("./set.js"), module.exports);
|
package/dist/cjs/set.js
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var set_exports = {};
|
|
20
|
-
__export(set_exports, {
|
|
21
|
-
VALUE_TRANSFORMERS: () => VALUE_TRANSFORMERS,
|
|
22
|
-
changeGlobalTheme: () => changeGlobalTheme,
|
|
23
|
-
set: () => set,
|
|
24
|
-
setEach: () => setEach,
|
|
25
|
-
setValue: () => setValue
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(set_exports);
|
|
28
|
-
var import_factory = require("./factory.js");
|
|
29
|
-
var import_system = require("./system/index.js");
|
|
30
|
-
var import_utils = require("@symbo.ls/utils");
|
|
31
|
-
const setVars = (val, key) => {
|
|
32
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
33
|
-
const { cssVars } = CONFIG;
|
|
34
|
-
const varName = key.startsWith("--") ? key : `--${key}`;
|
|
35
|
-
cssVars[varName] = val;
|
|
36
|
-
return val;
|
|
37
|
-
};
|
|
38
|
-
const asIs = (val) => val;
|
|
39
|
-
const VALUE_TRANSFORMERS = {
|
|
40
|
-
color: import_system.setColor,
|
|
41
|
-
gradient: import_system.setGradient,
|
|
42
|
-
font: import_system.setFont,
|
|
43
|
-
fontFamily: import_system.setFontFamily,
|
|
44
|
-
fontfamily: import_system.setFontFamily,
|
|
45
|
-
theme: import_system.setTheme,
|
|
46
|
-
icons: import_system.setSvgIcon,
|
|
47
|
-
semanticIcons: asIs,
|
|
48
|
-
semanticicons: asIs,
|
|
49
|
-
svg: import_system.setSVG,
|
|
50
|
-
svgData: asIs,
|
|
51
|
-
typography: asIs,
|
|
52
|
-
shadow: import_system.setShadow,
|
|
53
|
-
spacing: asIs,
|
|
54
|
-
media: asIs,
|
|
55
|
-
grid: asIs,
|
|
56
|
-
class: asIs,
|
|
57
|
-
timing: asIs,
|
|
58
|
-
reset: asIs,
|
|
59
|
-
unit: asIs,
|
|
60
|
-
animation: asIs,
|
|
61
|
-
vars: setVars
|
|
62
|
-
};
|
|
63
|
-
const setValue = (factoryName, value, key) => {
|
|
64
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
65
|
-
const camelName = (0, import_factory.toCamel)(factoryName);
|
|
66
|
-
const lowerName = camelName.toLowerCase();
|
|
67
|
-
const FACTORY2 = CONFIG[camelName] || CONFIG[lowerName] || CONFIG[factoryName];
|
|
68
|
-
const transformer = VALUE_TRANSFORMERS[camelName] || VALUE_TRANSFORMERS[lowerName];
|
|
69
|
-
if (transformer) {
|
|
70
|
-
try {
|
|
71
|
-
const result = transformer(value, key);
|
|
72
|
-
if (FACTORY2) FACTORY2[key] = result;
|
|
73
|
-
return FACTORY2;
|
|
74
|
-
} catch (error) {
|
|
75
|
-
if (CONFIG.verbose)
|
|
76
|
-
console.warn("Error setting", lowerName, "value", value, key, error);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (CONFIG.verbose)
|
|
80
|
-
console.warn("Can not find", lowerName, "method in scratch");
|
|
81
|
-
};
|
|
82
|
-
const setEach = (factoryName, props) => {
|
|
83
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
84
|
-
const lowerName = factoryName.toLowerCase();
|
|
85
|
-
const keys = Object.keys(props).sort((a, b) => {
|
|
86
|
-
const aComposite = (0, import_utils.isObject)(props[a]) || (0, import_utils.isArray)(props[a]) ? 1 : 0;
|
|
87
|
-
const bComposite = (0, import_utils.isObject)(props[b]) || (0, import_utils.isArray)(props[b]) ? 1 : 0;
|
|
88
|
-
return aComposite - bComposite;
|
|
89
|
-
});
|
|
90
|
-
keys.forEach((key) => {
|
|
91
|
-
try {
|
|
92
|
-
return setValue(lowerName, props[key], key);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
if (CONFIG.verbose)
|
|
95
|
-
console.warn(
|
|
96
|
-
"Error setting",
|
|
97
|
-
lowerName,
|
|
98
|
-
"value",
|
|
99
|
-
props[key],
|
|
100
|
-
key,
|
|
101
|
-
error
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
return CONFIG[lowerName] || CONFIG[factoryName];
|
|
106
|
-
};
|
|
107
|
-
const changeGlobalTheme = (newTheme, targetConfig) => {
|
|
108
|
-
const CONFIG = targetConfig || (0, import_factory.getActiveConfig)();
|
|
109
|
-
CONFIG.globalTheme = newTheme;
|
|
110
|
-
const configDoc = CONFIG.document && CONFIG.document.documentElement ? CONFIG.document : null;
|
|
111
|
-
const targetDoc = configDoc || (typeof document !== "undefined" ? document : null);
|
|
112
|
-
const targetWin = targetDoc && targetDoc.defaultView || (typeof window !== "undefined" ? window : null);
|
|
113
|
-
if (targetDoc) {
|
|
114
|
-
const root = CONFIG.themeRoot || targetDoc.documentElement;
|
|
115
|
-
const forced = newTheme && newTheme !== "auto";
|
|
116
|
-
if (forced) {
|
|
117
|
-
root.setAttribute("data-theme", newTheme);
|
|
118
|
-
if (newTheme === "dark" || newTheme === "light") {
|
|
119
|
-
root.style.colorScheme = newTheme;
|
|
120
|
-
} else {
|
|
121
|
-
root.style.colorScheme = "light dark";
|
|
122
|
-
}
|
|
123
|
-
} else if (targetWin && targetWin.matchMedia) {
|
|
124
|
-
const apply = (mq2) => {
|
|
125
|
-
root.setAttribute("data-theme", mq2.matches ? "dark" : "light");
|
|
126
|
-
};
|
|
127
|
-
const mq = targetWin.matchMedia("(prefers-color-scheme: dark)");
|
|
128
|
-
apply(mq);
|
|
129
|
-
root.style.colorScheme = "light dark";
|
|
130
|
-
if (!CONFIG.__prefersListener) {
|
|
131
|
-
CONFIG.__prefersListener = apply;
|
|
132
|
-
try {
|
|
133
|
-
mq.addEventListener("change", apply);
|
|
134
|
-
} catch (e) {
|
|
135
|
-
mq.addListener(apply);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
root.setAttribute("data-theme", "light");
|
|
140
|
-
root.style.colorScheme = "light";
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
const themeVarPrefix = CONFIG.varPrefix ? `--${CONFIG.varPrefix}-theme-` : "--theme-";
|
|
144
|
-
for (const key in CONFIG.cssVars) {
|
|
145
|
-
if (key.startsWith(themeVarPrefix)) delete CONFIG.cssVars[key];
|
|
146
|
-
}
|
|
147
|
-
for (const key in CONFIG.cssMediaVars) {
|
|
148
|
-
delete CONFIG.cssMediaVars[key];
|
|
149
|
-
}
|
|
150
|
-
if (targetDoc && CONFIG.cssVars) {
|
|
151
|
-
const targetSelector = CONFIG.scopeSelector || ":root";
|
|
152
|
-
const sheets = targetDoc.styleSheets;
|
|
153
|
-
for (let i = 0; i < sheets.length; i++) {
|
|
154
|
-
try {
|
|
155
|
-
const rules = sheets[i].cssRules;
|
|
156
|
-
for (let j = 0; j < rules.length; j++) {
|
|
157
|
-
if (rules[j].selectorText === targetSelector) {
|
|
158
|
-
for (const key in CONFIG.cssVars) {
|
|
159
|
-
rules[j].style.setProperty(key, CONFIG.cssVars[key]);
|
|
160
|
-
}
|
|
161
|
-
return CONFIG;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
} catch (e) {
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return CONFIG;
|
|
169
|
-
};
|
|
170
|
-
const SET_OPTIONS = {};
|
|
171
|
-
const set = (recivedConfig, options = SET_OPTIONS) => {
|
|
172
|
-
let CONFIG = options.config || (0, import_factory.getActiveConfig)();
|
|
173
|
-
const {
|
|
174
|
-
version,
|
|
175
|
-
verbose,
|
|
176
|
-
useVariable,
|
|
177
|
-
useReset,
|
|
178
|
-
useSvgSprite,
|
|
179
|
-
useFontImport,
|
|
180
|
-
useIconSprite,
|
|
181
|
-
globalTheme,
|
|
182
|
-
themeRoot,
|
|
183
|
-
useDocumentTheme,
|
|
184
|
-
useDefaultConfig,
|
|
185
|
-
semanticIcons,
|
|
186
|
-
files,
|
|
187
|
-
assets,
|
|
188
|
-
...config
|
|
189
|
-
} = recivedConfig;
|
|
190
|
-
if (options.newConfig) {
|
|
191
|
-
CONFIG = (0, import_factory.setActiveConfig)(options.newConfig);
|
|
192
|
-
}
|
|
193
|
-
if (files !== void 0) CONFIG.files = files;
|
|
194
|
-
if (assets !== void 0) CONFIG.assets = assets;
|
|
195
|
-
if (verbose !== void 0) CONFIG.verbose = verbose;
|
|
196
|
-
if (useVariable !== void 0) CONFIG.useVariable = useVariable;
|
|
197
|
-
if (useReset !== void 0) CONFIG.useReset = useReset;
|
|
198
|
-
if (useFontImport !== void 0) CONFIG.useFontImport = useFontImport;
|
|
199
|
-
if (useSvgSprite !== void 0) CONFIG.useSvgSprite = useSvgSprite;
|
|
200
|
-
if (useIconSprite !== void 0) CONFIG.useIconSprite = useIconSprite;
|
|
201
|
-
if (useDocumentTheme !== void 0) CONFIG.useDocumentTheme = useDocumentTheme;
|
|
202
|
-
if (globalTheme !== void 0) CONFIG.globalTheme = globalTheme;
|
|
203
|
-
if (themeRoot !== void 0) CONFIG.themeRoot = themeRoot;
|
|
204
|
-
if (recivedConfig.useThemeSuffixedVars !== void 0)
|
|
205
|
-
CONFIG.useThemeSuffixedVars = recivedConfig.useThemeSuffixedVars;
|
|
206
|
-
if (useDefaultConfig !== void 0) CONFIG.useDefaultConfig = useDefaultConfig;
|
|
207
|
-
if (semanticIcons !== void 0) CONFIG.semanticIcons = semanticIcons;
|
|
208
|
-
if (CONFIG.verbose) console.log(CONFIG);
|
|
209
|
-
const setConfigDoc = CONFIG.document && CONFIG.document.documentElement ? CONFIG.document : null;
|
|
210
|
-
const setTargetDoc = setConfigDoc || (typeof document !== "undefined" ? document : null);
|
|
211
|
-
const setTargetWin = setTargetDoc && setTargetDoc.defaultView || (typeof window !== "undefined" ? window : null);
|
|
212
|
-
const setRoot = setTargetDoc && (CONFIG.themeRoot || setTargetDoc.documentElement);
|
|
213
|
-
if (setRoot && typeof setRoot.setAttribute === "function") {
|
|
214
|
-
const forced = CONFIG.globalTheme && CONFIG.globalTheme !== "auto";
|
|
215
|
-
if (forced) {
|
|
216
|
-
setRoot.setAttribute("data-theme", CONFIG.globalTheme);
|
|
217
|
-
if (CONFIG.globalTheme === "dark" || CONFIG.globalTheme === "light") {
|
|
218
|
-
setRoot.style.colorScheme = CONFIG.globalTheme;
|
|
219
|
-
} else {
|
|
220
|
-
setRoot.style.colorScheme = "light dark";
|
|
221
|
-
}
|
|
222
|
-
} else if (setTargetWin && setTargetWin.matchMedia) {
|
|
223
|
-
const apply = (mq2) => {
|
|
224
|
-
setRoot.setAttribute("data-theme", mq2.matches ? "dark" : "light");
|
|
225
|
-
};
|
|
226
|
-
const mq = setTargetWin.matchMedia("(prefers-color-scheme: dark)");
|
|
227
|
-
apply(mq);
|
|
228
|
-
setRoot.style.colorScheme = "light dark";
|
|
229
|
-
if (!CONFIG.__prefersListener) {
|
|
230
|
-
CONFIG.__prefersListener = apply;
|
|
231
|
-
try {
|
|
232
|
-
mq.addEventListener("change", apply);
|
|
233
|
-
} catch (e) {
|
|
234
|
-
mq.addListener(apply);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
} else {
|
|
238
|
-
setRoot.setAttribute("data-theme", "light");
|
|
239
|
-
setRoot.style.colorScheme = "light";
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (!CONFIG.__svgCache) CONFIG.__svgCache = {};
|
|
243
|
-
const keys = Object.keys(config);
|
|
244
|
-
const keySet = new Set(keys);
|
|
245
|
-
keys.forEach((key) => {
|
|
246
|
-
const lower = key.toLowerCase();
|
|
247
|
-
if (lower !== key && keySet.has(lower)) {
|
|
248
|
-
(0, import_utils.deepMerge)(config[lower], config[key]);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
keys.map((key) => {
|
|
252
|
-
const lower = key.toLowerCase();
|
|
253
|
-
if (lower !== key && keySet.has(lower)) return;
|
|
254
|
-
return setEach(key, config[key]);
|
|
255
|
-
});
|
|
256
|
-
if (CONFIG.varPrefix) {
|
|
257
|
-
if (CONFIG.typography) CONFIG.typography.varPrefix = CONFIG.varPrefix;
|
|
258
|
-
if (CONFIG.spacing) CONFIG.spacing.varPrefix = CONFIG.varPrefix;
|
|
259
|
-
if (CONFIG.timing) CONFIG.timing.varPrefix = CONFIG.varPrefix;
|
|
260
|
-
}
|
|
261
|
-
if (config.typography) {
|
|
262
|
-
try {
|
|
263
|
-
(0, import_system.applyTypographySequence)();
|
|
264
|
-
} catch (e) {
|
|
265
|
-
if (CONFIG.verbose) console.warn("Error applying typography sequence", e);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (config.spacing) {
|
|
269
|
-
try {
|
|
270
|
-
(0, import_system.applySpacingSequence)();
|
|
271
|
-
} catch (e) {
|
|
272
|
-
if (CONFIG.verbose) console.warn("Error applying spacing sequence", e);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
if (config.timing) {
|
|
276
|
-
try {
|
|
277
|
-
(0, import_system.applyTimingSequence)();
|
|
278
|
-
} catch (e) {
|
|
279
|
-
if (CONFIG.verbose) console.warn("Error applying timing sequence", e);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
(0, import_system.applyDocument)();
|
|
283
|
-
const computedReset = (0, import_system.applyReset)();
|
|
284
|
-
if (computedReset) CONFIG.reset = computedReset;
|
|
285
|
-
return CONFIG;
|
|
286
|
-
};
|