@symbo.ls/scratch 2.10.257 → 2.10.259
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/cjs/factory.js +4 -1
- package/dist/cjs/index.js +48 -16
- package/dist/cjs/set.js +12 -280
- package/dist/cjs/system/index.js +14 -14
- package/dist/cjs/system/reset.js +1 -1
- package/dist/cjs/system/svg.js +10 -10
- package/dist/cjs/system/theme.js +3 -3
- package/dist/cjs/transforms/index.js +52 -0
- package/dist/cjs/utils/index.js +7 -7
- package/dist/cjs/utils/sprite.js +7 -7
- package/package.json +2 -2
- package/src/factory.js +4 -1
- package/src/set.js +4 -5
- package/src/system/color.js +0 -1
- package/src/system/reset.js +1 -1
- package/src/system/svg.js +9 -9
- package/src/system/theme.js +3 -3
- package/src/transforms/index.js +37 -4
- package/src/utils/index.js +1 -1
- package/src/utils/sprite.js +16 -16
package/dist/cjs/factory.js
CHANGED
|
@@ -860,6 +860,7 @@ __export(factory_exports, {
|
|
|
860
860
|
CSS_VARS: () => CSS_VARS,
|
|
861
861
|
FACTORY: () => FACTORY,
|
|
862
862
|
activateConfig: () => activateConfig,
|
|
863
|
+
default: () => factory_default,
|
|
863
864
|
getActiveConfig: () => getActiveConfig,
|
|
864
865
|
setActiveConfig: () => setActiveConfig
|
|
865
866
|
});
|
|
@@ -1091,5 +1092,7 @@ var getActiveConfig = (def) => {
|
|
|
1091
1092
|
return FACTORY[def || FACTORY.active];
|
|
1092
1093
|
};
|
|
1093
1094
|
var setActiveConfig = (def) => {
|
|
1094
|
-
|
|
1095
|
+
FACTORY.active = FACTORY[def];
|
|
1096
|
+
return FACTORY.active;
|
|
1095
1097
|
};
|
|
1098
|
+
var factory_default = CONFIG;
|
package/dist/cjs/index.js
CHANGED
|
@@ -952,10 +952,13 @@ __export(src_exports, {
|
|
|
952
952
|
setTheme: () => setTheme,
|
|
953
953
|
setValue: () => setValue,
|
|
954
954
|
setVariables: () => setVariables,
|
|
955
|
+
splitTransition: () => splitTransition,
|
|
955
956
|
transformBackgroundImage: () => transformBackgroundImage,
|
|
956
957
|
transformBorder: () => transformBorder,
|
|
958
|
+
transformDuration: () => transformDuration,
|
|
957
959
|
transformShadow: () => transformShadow,
|
|
958
960
|
transformTextStroke: () => transformTextStroke,
|
|
961
|
+
transformTransition: () => transformTransition,
|
|
959
962
|
transfromGap: () => transfromGap
|
|
960
963
|
});
|
|
961
964
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -1434,7 +1437,8 @@ var getActiveConfig = (def) => {
|
|
|
1434
1437
|
return FACTORY[def || FACTORY.active];
|
|
1435
1438
|
};
|
|
1436
1439
|
var setActiveConfig = (def) => {
|
|
1437
|
-
|
|
1440
|
+
FACTORY.active = FACTORY[def];
|
|
1441
|
+
return FACTORY.active;
|
|
1438
1442
|
};
|
|
1439
1443
|
|
|
1440
1444
|
// src/utils/sequence.js
|
|
@@ -1650,7 +1654,7 @@ var applySequenceVars = (props, mediaName, options = {}) => {
|
|
|
1650
1654
|
var import_utils7 = __toESM(require_cjs3(), 1);
|
|
1651
1655
|
var generateSprite = (icons) => {
|
|
1652
1656
|
let sprite = '<svg aria-hidden="true" width="0" height="0" style="position:absolute">';
|
|
1653
|
-
for (
|
|
1657
|
+
for (const key in icons) {
|
|
1654
1658
|
sprite += icons[key];
|
|
1655
1659
|
}
|
|
1656
1660
|
sprite += "</svg>";
|
|
@@ -1660,14 +1664,14 @@ var parseRootAttributes = (htmlString) => {
|
|
|
1660
1664
|
if (!(0, import_utils7.isString)(htmlString)) {
|
|
1661
1665
|
return console.warn(`parseRootAttributes: ${htmlString} is not a string`);
|
|
1662
1666
|
}
|
|
1663
|
-
|
|
1667
|
+
const match = htmlString.match(/<svg\s+(.*?)>/);
|
|
1664
1668
|
if (!match || !match[1]) {
|
|
1665
1669
|
return {};
|
|
1666
1670
|
}
|
|
1667
|
-
|
|
1668
|
-
|
|
1671
|
+
const attrString = match[1];
|
|
1672
|
+
const attrs = attrString.match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm);
|
|
1669
1673
|
return attrs.reduce((acc, attr) => {
|
|
1670
|
-
|
|
1674
|
+
const [key, value] = attr.split("=");
|
|
1671
1675
|
acc[key] = value.replace(/['"]/g, "");
|
|
1672
1676
|
return acc;
|
|
1673
1677
|
}, {});
|
|
@@ -1681,8 +1685,8 @@ var convertSvgToSymbol = (key, code) => {
|
|
|
1681
1685
|
"<svg",
|
|
1682
1686
|
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
1683
1687
|
);
|
|
1684
|
-
symbol = symbol.replace(/width="[
|
|
1685
|
-
symbol = symbol.replace(/height="[
|
|
1688
|
+
symbol = symbol.replace(/width="[^"]*/, "");
|
|
1689
|
+
symbol = symbol.replace(/height="[^"]*/, "");
|
|
1686
1690
|
symbol = symbol.replace("</svg", "</symbol");
|
|
1687
1691
|
return symbol;
|
|
1688
1692
|
};
|
|
@@ -2016,10 +2020,10 @@ var setMediaTheme = (val, key, suffix, prefers) => {
|
|
|
2016
2020
|
theme[`.${param}`] = { [param]: theme[param] };
|
|
2017
2021
|
}
|
|
2018
2022
|
}
|
|
2019
|
-
if (theme
|
|
2023
|
+
if (theme.background || theme.color || theme.backgroundColor) {
|
|
2020
2024
|
theme[".inversed"] = {
|
|
2021
|
-
color: theme
|
|
2022
|
-
background: theme
|
|
2025
|
+
color: theme.background || theme.backgroundColor,
|
|
2026
|
+
background: theme.color
|
|
2023
2027
|
};
|
|
2024
2028
|
}
|
|
2025
2029
|
}
|
|
@@ -2320,12 +2324,12 @@ var DEF_OPTIONS = {
|
|
|
2320
2324
|
document: import_globals2.document
|
|
2321
2325
|
};
|
|
2322
2326
|
var setSVG = (val, key) => {
|
|
2327
|
+
const CONFIG2 = getActiveConfig();
|
|
2323
2328
|
if (!val) {
|
|
2324
2329
|
if (CONFIG2.verbose)
|
|
2325
2330
|
console.warn("setSVG: val is not defined", key);
|
|
2326
2331
|
return;
|
|
2327
2332
|
}
|
|
2328
|
-
const CONFIG2 = getActiveConfig();
|
|
2329
2333
|
if (CONFIG2.useSvgSprite) {
|
|
2330
2334
|
return convertSvgToSymbol(key, val);
|
|
2331
2335
|
}
|
|
@@ -2335,7 +2339,7 @@ var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
2335
2339
|
const CONFIG2 = getActiveConfig();
|
|
2336
2340
|
const doc = options.document || import_globals2.document;
|
|
2337
2341
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.SVG;
|
|
2338
|
-
for (
|
|
2342
|
+
for (const key in LIBRARY)
|
|
2339
2343
|
lib[key] = CONFIG2.SVG[key];
|
|
2340
2344
|
const SVGsprite = generateSprite(lib);
|
|
2341
2345
|
if (!doc) {
|
|
@@ -2357,7 +2361,7 @@ var appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
2357
2361
|
const CONFIG2 = getActiveConfig();
|
|
2358
2362
|
const doc = options.document || import_globals2.document;
|
|
2359
2363
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.ICONS;
|
|
2360
|
-
for (
|
|
2364
|
+
for (const key in LIBRARY)
|
|
2361
2365
|
lib[key] = CONFIG2.ICONS[key];
|
|
2362
2366
|
const SVGsprite = generateSprite(lib);
|
|
2363
2367
|
if (!doc) {
|
|
@@ -2373,7 +2377,7 @@ var appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
2373
2377
|
var import_utils24 = __toESM(require_cjs3(), 1);
|
|
2374
2378
|
var applyReset = (reset = {}) => {
|
|
2375
2379
|
const CONFIG2 = getActiveConfig();
|
|
2376
|
-
const {
|
|
2380
|
+
const { RESET: RESET2, TYPOGRAPHY: TYPOGRAPHY2, DOCUMENT: DOCUMENT2 } = CONFIG2;
|
|
2377
2381
|
if (RESET2) {
|
|
2378
2382
|
if (RESET2[":root"]) {
|
|
2379
2383
|
const configReset = RESET2;
|
|
@@ -2466,6 +2470,7 @@ var transformTextStroke = (stroke) => {
|
|
|
2466
2470
|
return v;
|
|
2467
2471
|
else if (getColor(v))
|
|
2468
2472
|
return getColor(v);
|
|
2473
|
+
return v;
|
|
2469
2474
|
}).join(" ");
|
|
2470
2475
|
};
|
|
2471
2476
|
var transformShadow = (shadows) => shadows.split("|").map((shadow) => {
|
|
@@ -2500,6 +2505,33 @@ var transformBackgroundImage = (backgroundImage, globalTheme) => {
|
|
|
2500
2505
|
}).join(" ");
|
|
2501
2506
|
};
|
|
2502
2507
|
var transfromGap = (gap) => (0, import_utils25.isString)(gap) && gap.split(" ").map((v) => getSpacingByKey(v, "gap").gap).join(" ");
|
|
2508
|
+
var transformTransition = (transition) => {
|
|
2509
|
+
const arr = transition.split(" ");
|
|
2510
|
+
if (!arr.length)
|
|
2511
|
+
return transition;
|
|
2512
|
+
return arr.map((v) => {
|
|
2513
|
+
if (v.slice(0, 2) === "--")
|
|
2514
|
+
return `var(${v})`;
|
|
2515
|
+
if (v.length < 3 || v.includes("ms")) {
|
|
2516
|
+
const mapWithSequence = getTimingByKey(v);
|
|
2517
|
+
return mapWithSequence.timing || v;
|
|
2518
|
+
}
|
|
2519
|
+
if (getTimingFunction(v))
|
|
2520
|
+
return getTimingFunction(v);
|
|
2521
|
+
return v;
|
|
2522
|
+
}).join(" ");
|
|
2523
|
+
};
|
|
2524
|
+
var transformDuration = (duration, props, propertyName) => {
|
|
2525
|
+
if (!(0, import_utils25.isString)(duration))
|
|
2526
|
+
return;
|
|
2527
|
+
return duration.split(",").map((v) => getTimingByKey(v).timing || v).join(",");
|
|
2528
|
+
};
|
|
2529
|
+
var splitTransition = (transition) => {
|
|
2530
|
+
const arr = transition.split(",");
|
|
2531
|
+
if (!arr.length)
|
|
2532
|
+
return;
|
|
2533
|
+
return arr.map(transformTransition).join(",");
|
|
2534
|
+
};
|
|
2503
2535
|
|
|
2504
2536
|
// src/set.js
|
|
2505
2537
|
var import_utils26 = __toESM(require_cjs3(), 1);
|
|
@@ -2562,7 +2594,7 @@ var set = (recivedConfig, options = SET_OPTIONS) => {
|
|
|
2562
2594
|
...config
|
|
2563
2595
|
} = recivedConfig;
|
|
2564
2596
|
if (options.newConfig) {
|
|
2565
|
-
FACTORY
|
|
2597
|
+
FACTORY.active = options.newConfig;
|
|
2566
2598
|
CONFIG2 = getActiveConfig(options.newConfig);
|
|
2567
2599
|
}
|
|
2568
2600
|
if (verbose !== void 0)
|
package/dist/cjs/set.js
CHANGED
|
@@ -857,35 +857,8 @@ var require_cjs3 = __commonJS({
|
|
|
857
857
|
var set_exports = {};
|
|
858
858
|
__export(set_exports, {
|
|
859
859
|
VALUE_TRANSFORMERS: () => VALUE_TRANSFORMERS,
|
|
860
|
-
appendIconsSprite: () => appendIconsSprite,
|
|
861
|
-
appendSVGSprite: () => appendSVGSprite,
|
|
862
|
-
applyDocument: () => applyDocument,
|
|
863
|
-
applyHeadings: () => applyHeadings,
|
|
864
|
-
applyReset: () => applyReset,
|
|
865
|
-
applySpacingSequence: () => applySpacingSequence,
|
|
866
|
-
applyTimingSequence: () => applyTimingSequence,
|
|
867
|
-
applyTypographySequence: () => applyTypographySequence,
|
|
868
|
-
getColor: () => getColor,
|
|
869
|
-
getFontFamily: () => getFontFamily,
|
|
870
|
-
getFontSizeByKey: () => getFontSizeByKey,
|
|
871
|
-
getMediaColor: () => getMediaColor,
|
|
872
|
-
getMediaTheme: () => getMediaTheme,
|
|
873
|
-
getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
|
|
874
|
-
getSpacingByKey: () => getSpacingByKey,
|
|
875
|
-
getTheme: () => getTheme,
|
|
876
|
-
getTimingByKey: () => getTimingByKey,
|
|
877
|
-
getTimingFunction: () => getTimingFunction,
|
|
878
|
-
runThroughMedia: () => runThroughMedia,
|
|
879
860
|
set: () => set,
|
|
880
|
-
setColor: () => setColor,
|
|
881
861
|
setEach: () => setEach,
|
|
882
|
-
setFont: () => setFont,
|
|
883
|
-
setFontFamily: () => setFontFamily,
|
|
884
|
-
setGradient: () => setGradient,
|
|
885
|
-
setIcon: () => setIcon,
|
|
886
|
-
setMediaTheme: () => setMediaTheme,
|
|
887
|
-
setSVG: () => setSVG,
|
|
888
|
-
setTheme: () => setTheme,
|
|
889
862
|
setValue: () => setValue
|
|
890
863
|
});
|
|
891
864
|
module.exports = __toCommonJS(set_exports);
|
|
@@ -1228,12 +1201,6 @@ var import_utils3 = __toESM(require_cjs3());
|
|
|
1228
1201
|
var import_utils2 = __toESM(require_cjs3());
|
|
1229
1202
|
|
|
1230
1203
|
// ../utils/src/index.js
|
|
1231
|
-
var toCamelCase = (str) => {
|
|
1232
|
-
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
|
|
1233
|
-
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
1234
|
-
}).replaceAll(/\s+/g, "");
|
|
1235
|
-
};
|
|
1236
|
-
var toDashCase = (val) => val.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase()).replace(".", "-");
|
|
1237
1204
|
var arrayzeValue = (val) => {
|
|
1238
1205
|
if ((0, import_utils3.isString)(val))
|
|
1239
1206
|
return val.split(" ");
|
|
@@ -1342,67 +1309,6 @@ var generateSequence = (sequenceProps) => {
|
|
|
1342
1309
|
}
|
|
1343
1310
|
return sequenceProps;
|
|
1344
1311
|
};
|
|
1345
|
-
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
1346
|
-
const CONFIG2 = getActiveConfig();
|
|
1347
|
-
const { UNIT: UNIT2 } = CONFIG2;
|
|
1348
|
-
const {
|
|
1349
|
-
sequence,
|
|
1350
|
-
unit = UNIT2.default,
|
|
1351
|
-
useVariable
|
|
1352
|
-
} = sequenceProps;
|
|
1353
|
-
if ((0, import_utils4.isString)(value) && value.slice(0, 2) === "--")
|
|
1354
|
-
return `var(${value})`;
|
|
1355
|
-
const prefix = `--${toDashCase(sequenceProps.type.replace(".", "-"))}-`;
|
|
1356
|
-
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
1357
|
-
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
1358
|
-
if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || !startsWithDashOrLetter)
|
|
1359
|
-
return value;
|
|
1360
|
-
const letterVal = value.toUpperCase();
|
|
1361
|
-
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
1362
|
-
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
1363
|
-
let mediaName = "";
|
|
1364
|
-
if (absValue.includes("-")) {
|
|
1365
|
-
mediaName = "-" + absValue.split("-")[1].toLowerCase();
|
|
1366
|
-
absValue = absValue.split("-")[0];
|
|
1367
|
-
}
|
|
1368
|
-
const varValue = (v) => `var(${prefix}${v}${mediaName})`;
|
|
1369
|
-
if (absValue.includes("+")) {
|
|
1370
|
-
const args = absValue.split("+");
|
|
1371
|
-
const [first, second] = args;
|
|
1372
|
-
const joint = `${varValue(first)} + ${varValue(second)}`;
|
|
1373
|
-
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
1374
|
-
} else if (absValue.includes("-")) {
|
|
1375
|
-
const args = absValue.split("-");
|
|
1376
|
-
const [first, second] = args;
|
|
1377
|
-
const joint = `${varValue(first)} - ${varValue(second)}`;
|
|
1378
|
-
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
1379
|
-
}
|
|
1380
|
-
if (!sequence[absValue] && absValue.length === 2) {
|
|
1381
|
-
if (CONFIG2.verbose)
|
|
1382
|
-
console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
1383
|
-
absValue = absValue.slice(0, 1);
|
|
1384
|
-
}
|
|
1385
|
-
if (useVariable || CONFIG2.useVariable) {
|
|
1386
|
-
const varValue2 = `var(${prefix}${absValue}${mediaName})`;
|
|
1387
|
-
return isNegative ? `calc(${varValue2} * -1)` : varValue2;
|
|
1388
|
-
}
|
|
1389
|
-
const sequenceItem = sequence ? sequence[absValue] : null;
|
|
1390
|
-
if (!sequenceItem)
|
|
1391
|
-
return console.warn("can't find", sequence, absValue);
|
|
1392
|
-
if (unit === "ms" || unit === "s") {
|
|
1393
|
-
return isNegative + sequenceItem.val + unit;
|
|
1394
|
-
}
|
|
1395
|
-
return isNegative + sequenceItem.scaling + unit;
|
|
1396
|
-
};
|
|
1397
|
-
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
|
|
1398
|
-
if (typeof value !== "string") {
|
|
1399
|
-
console.warn(propertyName, value, "is not a string");
|
|
1400
|
-
return {};
|
|
1401
|
-
}
|
|
1402
|
-
if (value === "-" || value === "")
|
|
1403
|
-
return {};
|
|
1404
|
-
return { [propertyName]: getSequenceValue(value, sequenceProps) };
|
|
1405
|
-
};
|
|
1406
1312
|
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
1407
1313
|
var findHeadings = (propertyNames) => {
|
|
1408
1314
|
const { h1Matches, sequence } = propertyNames;
|
|
@@ -1446,26 +1352,18 @@ var applySequenceVars = (props, mediaName, options = {}) => {
|
|
|
1446
1352
|
|
|
1447
1353
|
// src/utils/sprite.js
|
|
1448
1354
|
var import_utils7 = __toESM(require_cjs3(), 1);
|
|
1449
|
-
var generateSprite = (icons) => {
|
|
1450
|
-
let sprite = '<svg aria-hidden="true" width="0" height="0" style="position:absolute">';
|
|
1451
|
-
for (let key in icons) {
|
|
1452
|
-
sprite += icons[key];
|
|
1453
|
-
}
|
|
1454
|
-
sprite += "</svg>";
|
|
1455
|
-
return sprite;
|
|
1456
|
-
};
|
|
1457
1355
|
var parseRootAttributes = (htmlString) => {
|
|
1458
1356
|
if (!(0, import_utils7.isString)(htmlString)) {
|
|
1459
1357
|
return console.warn(`parseRootAttributes: ${htmlString} is not a string`);
|
|
1460
1358
|
}
|
|
1461
|
-
|
|
1359
|
+
const match = htmlString.match(/<svg\s+(.*?)>/);
|
|
1462
1360
|
if (!match || !match[1]) {
|
|
1463
1361
|
return {};
|
|
1464
1362
|
}
|
|
1465
|
-
|
|
1466
|
-
|
|
1363
|
+
const attrString = match[1];
|
|
1364
|
+
const attrs = attrString.match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm);
|
|
1467
1365
|
return attrs.reduce((acc, attr) => {
|
|
1468
|
-
|
|
1366
|
+
const [key, value] = attr.split("=");
|
|
1469
1367
|
acc[key] = value.replace(/['"]/g, "");
|
|
1470
1368
|
return acc;
|
|
1471
1369
|
}, {});
|
|
@@ -1479,8 +1377,8 @@ var convertSvgToSymbol = (key, code) => {
|
|
|
1479
1377
|
"<svg",
|
|
1480
1378
|
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
1481
1379
|
);
|
|
1482
|
-
symbol = symbol.replace(/width="[
|
|
1483
|
-
symbol = symbol.replace(/height="[
|
|
1380
|
+
symbol = symbol.replace(/width="[^"]*/, "");
|
|
1381
|
+
symbol = symbol.replace(/height="[^"]*/, "");
|
|
1484
1382
|
symbol = symbol.replace("</svg", "</symbol");
|
|
1485
1383
|
return symbol;
|
|
1486
1384
|
};
|
|
@@ -1538,41 +1436,6 @@ var getColor = (value, key) => {
|
|
|
1538
1436
|
} else
|
|
1539
1437
|
return CONFIG2.useVariable ? `var(${val.var})` : val.value;
|
|
1540
1438
|
};
|
|
1541
|
-
var getMediaColor = (value, globalTheme) => {
|
|
1542
|
-
const CONFIG2 = getActiveConfig();
|
|
1543
|
-
if (!globalTheme)
|
|
1544
|
-
globalTheme = CONFIG2.globalTheme;
|
|
1545
|
-
if (!(0, import_utils8.isString)(value)) {
|
|
1546
|
-
if (CONFIG2.verbose)
|
|
1547
|
-
console.warn(value, "- type for color is not valid");
|
|
1548
|
-
return;
|
|
1549
|
-
}
|
|
1550
|
-
if (value.slice(0, 2) === "--")
|
|
1551
|
-
return `var(${value})`;
|
|
1552
|
-
const [name] = (0, import_utils8.isArray)(value) ? value : value.split(" ");
|
|
1553
|
-
const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
|
|
1554
|
-
const val = COLOR2[name] || GRADIENT2[name];
|
|
1555
|
-
const isObj = (0, import_utils8.isObject)(val);
|
|
1556
|
-
if (isObj && val.value)
|
|
1557
|
-
return getColor(value, `@${globalTheme}`);
|
|
1558
|
-
else if (isObj) {
|
|
1559
|
-
if (globalTheme)
|
|
1560
|
-
return getColor(value, `@${globalTheme}`);
|
|
1561
|
-
else {
|
|
1562
|
-
const obj = {};
|
|
1563
|
-
for (const mediaName in val) {
|
|
1564
|
-
const query = CONFIG2.MEDIA[mediaName.slice(1)];
|
|
1565
|
-
const media = `@media screen and ${query}`;
|
|
1566
|
-
obj[media] = getColor(value, mediaName);
|
|
1567
|
-
}
|
|
1568
|
-
return obj;
|
|
1569
|
-
}
|
|
1570
|
-
} else {
|
|
1571
|
-
if (CONFIG2.verbose)
|
|
1572
|
-
console.warn("Can't find color", value);
|
|
1573
|
-
return value;
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
1439
|
var setColor = (val, key, suffix) => {
|
|
1577
1440
|
const CONFIG2 = getActiveConfig();
|
|
1578
1441
|
if ((0, import_utils8.isString)(val) && val.slice(0, 2) === "--")
|
|
@@ -1781,10 +1644,10 @@ var setMediaTheme = (val, key, suffix, prefers) => {
|
|
|
1781
1644
|
theme[`.${param}`] = { [param]: theme[param] };
|
|
1782
1645
|
}
|
|
1783
1646
|
}
|
|
1784
|
-
if (theme
|
|
1647
|
+
if (theme.background || theme.color || theme.backgroundColor) {
|
|
1785
1648
|
theme[".inversed"] = {
|
|
1786
|
-
color: theme
|
|
1787
|
-
background: theme
|
|
1649
|
+
color: theme.background || theme.backgroundColor,
|
|
1650
|
+
background: theme.color
|
|
1788
1651
|
};
|
|
1789
1652
|
}
|
|
1790
1653
|
}
|
|
@@ -1853,11 +1716,6 @@ var setFont = (val, key) => {
|
|
|
1853
1716
|
const fontFace = val[0] ? getFontFaceEach(key, val) : setCustomFontMedia(key, val.url);
|
|
1854
1717
|
return { var: CSSvar, value: val, fontFace };
|
|
1855
1718
|
};
|
|
1856
|
-
var getFontFamily = (key, factory) => {
|
|
1857
|
-
const CONFIG2 = getActiveConfig();
|
|
1858
|
-
const { FONT_FAMILY: FONT_FAMILY2 } = CONFIG2;
|
|
1859
|
-
return getDefaultOrFirstKey(factory || FONT_FAMILY2, key);
|
|
1860
|
-
};
|
|
1861
1719
|
var setFontFamily = (val, key) => {
|
|
1862
1720
|
const CONFIG2 = getActiveConfig();
|
|
1863
1721
|
const { FONT_FAMILY: FONT_FAMILY2, FONT_FAMILY_TYPES: FONT_FAMILY_TYPES2 } = CONFIG2;
|
|
@@ -1930,15 +1788,6 @@ var applyTypographySequence = () => {
|
|
|
1930
1788
|
applySequenceVars(TYPOGRAPHY2);
|
|
1931
1789
|
runThroughMedia(TYPOGRAPHY2);
|
|
1932
1790
|
};
|
|
1933
|
-
var getFontSizeByKey = (value) => {
|
|
1934
|
-
const CONFIG2 = getActiveConfig();
|
|
1935
|
-
const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
|
|
1936
|
-
return getSequenceValuePropertyPair(
|
|
1937
|
-
value,
|
|
1938
|
-
"fontSize",
|
|
1939
|
-
TYPOGRAPHY2
|
|
1940
|
-
);
|
|
1941
|
-
};
|
|
1942
1791
|
|
|
1943
1792
|
// src/system/spacing.js
|
|
1944
1793
|
var import_utils17 = __toESM(require_cjs3(), 1);
|
|
@@ -1973,76 +1822,6 @@ var applySpacingSequence = () => {
|
|
|
1973
1822
|
applySequenceVars(SPACING2);
|
|
1974
1823
|
runThroughMedia2(SPACING2);
|
|
1975
1824
|
};
|
|
1976
|
-
var getSequence = (sequenceProps) => {
|
|
1977
|
-
const CONFIG2 = getActiveConfig();
|
|
1978
|
-
const { SPACING: SPACING2 } = CONFIG2;
|
|
1979
|
-
if (!sequenceProps)
|
|
1980
|
-
return SPACING2;
|
|
1981
|
-
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
1982
|
-
return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
|
|
1983
|
-
};
|
|
1984
|
-
var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
1985
|
-
const sequence = getSequence(sequenceProps);
|
|
1986
|
-
const stack = arrayzeValue(value);
|
|
1987
|
-
if (!stack)
|
|
1988
|
-
return;
|
|
1989
|
-
if ((0, import_utils17.isString)(value) && value.includes("calc")) {
|
|
1990
|
-
return { [propertyName]: value };
|
|
1991
|
-
}
|
|
1992
|
-
if (stack.length > 1) {
|
|
1993
|
-
let suffix = "";
|
|
1994
|
-
if (propertyName === "borderWidth") {
|
|
1995
|
-
propertyName = "border";
|
|
1996
|
-
suffix = "Width";
|
|
1997
|
-
}
|
|
1998
|
-
const directions = {
|
|
1999
|
-
2: ["Block", "Inline"],
|
|
2000
|
-
3: ["BlockStart", "Inline", "BlockEnd"],
|
|
2001
|
-
4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
|
|
2002
|
-
};
|
|
2003
|
-
const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
|
|
2004
|
-
stack[i],
|
|
2005
|
-
propertyName + direction + suffix,
|
|
2006
|
-
sequence
|
|
2007
|
-
);
|
|
2008
|
-
return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
|
|
2009
|
-
}
|
|
2010
|
-
return getSequenceValuePropertyPair(
|
|
2011
|
-
value,
|
|
2012
|
-
propertyName,
|
|
2013
|
-
sequence
|
|
2014
|
-
);
|
|
2015
|
-
};
|
|
2016
|
-
var getSpacingBasedOnRatio = (props, propertyName, val) => {
|
|
2017
|
-
const CONFIG2 = getActiveConfig();
|
|
2018
|
-
const { SPACING: SPACING2 } = CONFIG2;
|
|
2019
|
-
const { spacingRatio, unit } = props;
|
|
2020
|
-
const value = val || props[propertyName];
|
|
2021
|
-
if (spacingRatio) {
|
|
2022
|
-
let sequenceProps = SPACING2[spacingRatio];
|
|
2023
|
-
if (!sequenceProps) {
|
|
2024
|
-
const { type, base, range, subSequence } = SPACING2;
|
|
2025
|
-
sequenceProps = SPACING2[spacingRatio] = (0, import_utils17.merge)({
|
|
2026
|
-
ratio: spacingRatio,
|
|
2027
|
-
type: type + "-" + spacingRatio,
|
|
2028
|
-
unit,
|
|
2029
|
-
sequence: {},
|
|
2030
|
-
scales: {},
|
|
2031
|
-
templates: {},
|
|
2032
|
-
vars: {}
|
|
2033
|
-
}, {
|
|
2034
|
-
base,
|
|
2035
|
-
range,
|
|
2036
|
-
subSequence,
|
|
2037
|
-
ratio: SPACING2.ratio,
|
|
2038
|
-
unit: SPACING2.unit
|
|
2039
|
-
});
|
|
2040
|
-
}
|
|
2041
|
-
applySequenceVars(sequenceProps, null, { useDefault: false });
|
|
2042
|
-
return getSpacingByKey(value, propertyName, sequenceProps);
|
|
2043
|
-
}
|
|
2044
|
-
return getSpacingByKey(value, propertyName);
|
|
2045
|
-
};
|
|
2046
1825
|
|
|
2047
1826
|
// src/system/timing.js
|
|
2048
1827
|
var applyTimingSequence = () => {
|
|
@@ -2051,20 +1830,6 @@ var applyTimingSequence = () => {
|
|
|
2051
1830
|
generateSequence(TIMING2);
|
|
2052
1831
|
applySequenceVars(TIMING2);
|
|
2053
1832
|
};
|
|
2054
|
-
var getTimingFunction = (value) => {
|
|
2055
|
-
const CONFIG2 = getActiveConfig();
|
|
2056
|
-
const { TIMING: TIMING2 } = CONFIG2;
|
|
2057
|
-
return TIMING2[value] || TIMING2[toCamelCase(value)] || value;
|
|
2058
|
-
};
|
|
2059
|
-
var getTimingByKey = (value, property = "timing") => {
|
|
2060
|
-
const CONFIG2 = getActiveConfig();
|
|
2061
|
-
const { TIMING: TIMING2 } = CONFIG2;
|
|
2062
|
-
return getSequenceValuePropertyPair(
|
|
2063
|
-
value,
|
|
2064
|
-
property,
|
|
2065
|
-
TIMING2
|
|
2066
|
-
);
|
|
2067
|
-
};
|
|
2068
1833
|
|
|
2069
1834
|
// src/system/document.js
|
|
2070
1835
|
var import_utils21 = __toESM(require_cjs3(), 1);
|
|
@@ -2081,36 +1846,18 @@ var applyDocument = () => {
|
|
|
2081
1846
|
|
|
2082
1847
|
// src/system/svg.js
|
|
2083
1848
|
var import_globals2 = __toESM(require_cjs(), 1);
|
|
2084
|
-
var DEF_OPTIONS = {
|
|
2085
|
-
document: import_globals2.document
|
|
2086
|
-
};
|
|
2087
1849
|
var setSVG = (val, key) => {
|
|
1850
|
+
const CONFIG2 = getActiveConfig();
|
|
2088
1851
|
if (!val) {
|
|
2089
1852
|
if (CONFIG2.verbose)
|
|
2090
1853
|
console.warn("setSVG: val is not defined", key);
|
|
2091
1854
|
return;
|
|
2092
1855
|
}
|
|
2093
|
-
const CONFIG2 = getActiveConfig();
|
|
2094
1856
|
if (CONFIG2.useSvgSprite) {
|
|
2095
1857
|
return convertSvgToSymbol(key, val);
|
|
2096
1858
|
}
|
|
2097
1859
|
return val;
|
|
2098
1860
|
};
|
|
2099
|
-
var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
2100
|
-
const CONFIG2 = getActiveConfig();
|
|
2101
|
-
const doc = options.document || import_globals2.document;
|
|
2102
|
-
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.SVG;
|
|
2103
|
-
for (let key in LIBRARY)
|
|
2104
|
-
lib[key] = CONFIG2.SVG[key];
|
|
2105
|
-
const SVGsprite = generateSprite(lib);
|
|
2106
|
-
if (!doc) {
|
|
2107
|
-
console.warn("To append SVG sprites it should be run in browser environment");
|
|
2108
|
-
return SVGsprite;
|
|
2109
|
-
}
|
|
2110
|
-
const svgSpriteDOM = doc.createElement("template");
|
|
2111
|
-
svgSpriteDOM.innerHTML = SVGsprite;
|
|
2112
|
-
doc.body.appendChild(svgSpriteDOM.content);
|
|
2113
|
-
};
|
|
2114
1861
|
var setIcon = (val, key) => {
|
|
2115
1862
|
const CONFIG2 = getActiveConfig();
|
|
2116
1863
|
if (CONFIG2.useIconSprite) {
|
|
@@ -2118,27 +1865,12 @@ var setIcon = (val, key) => {
|
|
|
2118
1865
|
}
|
|
2119
1866
|
return val;
|
|
2120
1867
|
};
|
|
2121
|
-
var appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
2122
|
-
const CONFIG2 = getActiveConfig();
|
|
2123
|
-
const doc = options.document || import_globals2.document;
|
|
2124
|
-
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.ICONS;
|
|
2125
|
-
for (let key in LIBRARY)
|
|
2126
|
-
lib[key] = CONFIG2.ICONS[key];
|
|
2127
|
-
const SVGsprite = generateSprite(lib);
|
|
2128
|
-
if (!doc) {
|
|
2129
|
-
console.warn("To append SVG Icon sprites it should be run in browser environment");
|
|
2130
|
-
return SVGsprite;
|
|
2131
|
-
}
|
|
2132
|
-
const iconsSpriteDOM = doc.createElement("template");
|
|
2133
|
-
iconsSpriteDOM.innerHTML = SVGsprite;
|
|
2134
|
-
doc.body.appendChild(iconsSpriteDOM.content);
|
|
2135
|
-
};
|
|
2136
1868
|
|
|
2137
1869
|
// src/system/reset.js
|
|
2138
1870
|
var import_utils24 = __toESM(require_cjs3(), 1);
|
|
2139
1871
|
var applyReset = (reset = {}) => {
|
|
2140
1872
|
const CONFIG2 = getActiveConfig();
|
|
2141
|
-
const {
|
|
1873
|
+
const { RESET: RESET2, TYPOGRAPHY: TYPOGRAPHY2, DOCUMENT: DOCUMENT2 } = CONFIG2;
|
|
2142
1874
|
if (RESET2) {
|
|
2143
1875
|
if (RESET2[":root"]) {
|
|
2144
1876
|
const configReset = RESET2;
|
|
@@ -2254,7 +1986,7 @@ var set = (recivedConfig, options = SET_OPTIONS) => {
|
|
|
2254
1986
|
...config
|
|
2255
1987
|
} = recivedConfig;
|
|
2256
1988
|
if (options.newConfig) {
|
|
2257
|
-
FACTORY
|
|
1989
|
+
FACTORY.active = options.newConfig;
|
|
2258
1990
|
CONFIG2 = getActiveConfig(options.newConfig);
|
|
2259
1991
|
}
|
|
2260
1992
|
if (verbose !== void 0)
|
package/dist/cjs/system/index.js
CHANGED
|
@@ -1444,7 +1444,7 @@ var applySequenceVars = (props, mediaName, options = {}) => {
|
|
|
1444
1444
|
var import_utils7 = __toESM(require_cjs3(), 1);
|
|
1445
1445
|
var generateSprite = (icons) => {
|
|
1446
1446
|
let sprite = '<svg aria-hidden="true" width="0" height="0" style="position:absolute">';
|
|
1447
|
-
for (
|
|
1447
|
+
for (const key in icons) {
|
|
1448
1448
|
sprite += icons[key];
|
|
1449
1449
|
}
|
|
1450
1450
|
sprite += "</svg>";
|
|
@@ -1454,14 +1454,14 @@ var parseRootAttributes = (htmlString) => {
|
|
|
1454
1454
|
if (!(0, import_utils7.isString)(htmlString)) {
|
|
1455
1455
|
return console.warn(`parseRootAttributes: ${htmlString} is not a string`);
|
|
1456
1456
|
}
|
|
1457
|
-
|
|
1457
|
+
const match = htmlString.match(/<svg\s+(.*?)>/);
|
|
1458
1458
|
if (!match || !match[1]) {
|
|
1459
1459
|
return {};
|
|
1460
1460
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1461
|
+
const attrString = match[1];
|
|
1462
|
+
const attrs = attrString.match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm);
|
|
1463
1463
|
return attrs.reduce((acc, attr) => {
|
|
1464
|
-
|
|
1464
|
+
const [key, value] = attr.split("=");
|
|
1465
1465
|
acc[key] = value.replace(/['"]/g, "");
|
|
1466
1466
|
return acc;
|
|
1467
1467
|
}, {});
|
|
@@ -1475,8 +1475,8 @@ var convertSvgToSymbol = (key, code) => {
|
|
|
1475
1475
|
"<svg",
|
|
1476
1476
|
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
1477
1477
|
);
|
|
1478
|
-
symbol = symbol.replace(/width="[
|
|
1479
|
-
symbol = symbol.replace(/height="[
|
|
1478
|
+
symbol = symbol.replace(/width="[^"]*/, "");
|
|
1479
|
+
symbol = symbol.replace(/height="[^"]*/, "");
|
|
1480
1480
|
symbol = symbol.replace("</svg", "</symbol");
|
|
1481
1481
|
return symbol;
|
|
1482
1482
|
};
|
|
@@ -1777,10 +1777,10 @@ var setMediaTheme = (val, key, suffix, prefers) => {
|
|
|
1777
1777
|
theme[`.${param}`] = { [param]: theme[param] };
|
|
1778
1778
|
}
|
|
1779
1779
|
}
|
|
1780
|
-
if (theme
|
|
1780
|
+
if (theme.background || theme.color || theme.backgroundColor) {
|
|
1781
1781
|
theme[".inversed"] = {
|
|
1782
|
-
color: theme
|
|
1783
|
-
background: theme
|
|
1782
|
+
color: theme.background || theme.backgroundColor,
|
|
1783
|
+
background: theme.color
|
|
1784
1784
|
};
|
|
1785
1785
|
}
|
|
1786
1786
|
}
|
|
@@ -2081,12 +2081,12 @@ var DEF_OPTIONS = {
|
|
|
2081
2081
|
document: import_globals2.document
|
|
2082
2082
|
};
|
|
2083
2083
|
var setSVG = (val, key) => {
|
|
2084
|
+
const CONFIG2 = getActiveConfig();
|
|
2084
2085
|
if (!val) {
|
|
2085
2086
|
if (CONFIG2.verbose)
|
|
2086
2087
|
console.warn("setSVG: val is not defined", key);
|
|
2087
2088
|
return;
|
|
2088
2089
|
}
|
|
2089
|
-
const CONFIG2 = getActiveConfig();
|
|
2090
2090
|
if (CONFIG2.useSvgSprite) {
|
|
2091
2091
|
return convertSvgToSymbol(key, val);
|
|
2092
2092
|
}
|
|
@@ -2096,7 +2096,7 @@ var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
2096
2096
|
const CONFIG2 = getActiveConfig();
|
|
2097
2097
|
const doc = options.document || import_globals2.document;
|
|
2098
2098
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.SVG;
|
|
2099
|
-
for (
|
|
2099
|
+
for (const key in LIBRARY)
|
|
2100
2100
|
lib[key] = CONFIG2.SVG[key];
|
|
2101
2101
|
const SVGsprite = generateSprite(lib);
|
|
2102
2102
|
if (!doc) {
|
|
@@ -2118,7 +2118,7 @@ var appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
2118
2118
|
const CONFIG2 = getActiveConfig();
|
|
2119
2119
|
const doc = options.document || import_globals2.document;
|
|
2120
2120
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.ICONS;
|
|
2121
|
-
for (
|
|
2121
|
+
for (const key in LIBRARY)
|
|
2122
2122
|
lib[key] = CONFIG2.ICONS[key];
|
|
2123
2123
|
const SVGsprite = generateSprite(lib);
|
|
2124
2124
|
if (!doc) {
|
|
@@ -2134,7 +2134,7 @@ var appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
2134
2134
|
var import_utils24 = __toESM(require_cjs3(), 1);
|
|
2135
2135
|
var applyReset = (reset = {}) => {
|
|
2136
2136
|
const CONFIG2 = getActiveConfig();
|
|
2137
|
-
const {
|
|
2137
|
+
const { RESET: RESET2, TYPOGRAPHY: TYPOGRAPHY2, DOCUMENT: DOCUMENT2 } = CONFIG2;
|
|
2138
2138
|
if (RESET2) {
|
|
2139
2139
|
if (RESET2[":root"]) {
|
|
2140
2140
|
const configReset = RESET2;
|
package/dist/cjs/system/reset.js
CHANGED
|
@@ -1174,7 +1174,7 @@ var import_globals2 = __toESM(require_cjs(), 1);
|
|
|
1174
1174
|
// src/system/reset.js
|
|
1175
1175
|
var applyReset = (reset = {}) => {
|
|
1176
1176
|
const CONFIG2 = getActiveConfig();
|
|
1177
|
-
const {
|
|
1177
|
+
const { RESET: RESET2, TYPOGRAPHY: TYPOGRAPHY2, DOCUMENT: DOCUMENT2 } = CONFIG2;
|
|
1178
1178
|
if (RESET2) {
|
|
1179
1179
|
if (RESET2[":root"]) {
|
|
1180
1180
|
const configReset = RESET2;
|
package/dist/cjs/system/svg.js
CHANGED
|
@@ -1105,7 +1105,7 @@ var import_utils6 = __toESM(require_cjs3(), 1);
|
|
|
1105
1105
|
var import_utils7 = __toESM(require_cjs3(), 1);
|
|
1106
1106
|
var generateSprite = (icons) => {
|
|
1107
1107
|
let sprite = '<svg aria-hidden="true" width="0" height="0" style="position:absolute">';
|
|
1108
|
-
for (
|
|
1108
|
+
for (const key in icons) {
|
|
1109
1109
|
sprite += icons[key];
|
|
1110
1110
|
}
|
|
1111
1111
|
sprite += "</svg>";
|
|
@@ -1115,14 +1115,14 @@ var parseRootAttributes = (htmlString) => {
|
|
|
1115
1115
|
if (!(0, import_utils7.isString)(htmlString)) {
|
|
1116
1116
|
return console.warn(`parseRootAttributes: ${htmlString} is not a string`);
|
|
1117
1117
|
}
|
|
1118
|
-
|
|
1118
|
+
const match = htmlString.match(/<svg\s+(.*?)>/);
|
|
1119
1119
|
if (!match || !match[1]) {
|
|
1120
1120
|
return {};
|
|
1121
1121
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1122
|
+
const attrString = match[1];
|
|
1123
|
+
const attrs = attrString.match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm);
|
|
1124
1124
|
return attrs.reduce((acc, attr) => {
|
|
1125
|
-
|
|
1125
|
+
const [key, value] = attr.split("=");
|
|
1126
1126
|
acc[key] = value.replace(/['"]/g, "");
|
|
1127
1127
|
return acc;
|
|
1128
1128
|
}, {});
|
|
@@ -1136,8 +1136,8 @@ var convertSvgToSymbol = (key, code) => {
|
|
|
1136
1136
|
"<svg",
|
|
1137
1137
|
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
1138
1138
|
);
|
|
1139
|
-
symbol = symbol.replace(/width="[
|
|
1140
|
-
symbol = symbol.replace(/height="[
|
|
1139
|
+
symbol = symbol.replace(/width="[^"]*/, "");
|
|
1140
|
+
symbol = symbol.replace(/height="[^"]*/, "");
|
|
1141
1141
|
symbol = symbol.replace("</svg", "</symbol");
|
|
1142
1142
|
return symbol;
|
|
1143
1143
|
};
|
|
@@ -1147,12 +1147,12 @@ var DEF_OPTIONS = {
|
|
|
1147
1147
|
document: import_globals2.document
|
|
1148
1148
|
};
|
|
1149
1149
|
var setSVG = (val, key) => {
|
|
1150
|
+
const CONFIG2 = getActiveConfig();
|
|
1150
1151
|
if (!val) {
|
|
1151
1152
|
if (CONFIG2.verbose)
|
|
1152
1153
|
console.warn("setSVG: val is not defined", key);
|
|
1153
1154
|
return;
|
|
1154
1155
|
}
|
|
1155
|
-
const CONFIG2 = getActiveConfig();
|
|
1156
1156
|
if (CONFIG2.useSvgSprite) {
|
|
1157
1157
|
return convertSvgToSymbol(key, val);
|
|
1158
1158
|
}
|
|
@@ -1162,7 +1162,7 @@ var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
1162
1162
|
const CONFIG2 = getActiveConfig();
|
|
1163
1163
|
const doc = options.document || import_globals2.document;
|
|
1164
1164
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.SVG;
|
|
1165
|
-
for (
|
|
1165
|
+
for (const key in LIBRARY)
|
|
1166
1166
|
lib[key] = CONFIG2.SVG[key];
|
|
1167
1167
|
const SVGsprite = generateSprite(lib);
|
|
1168
1168
|
if (!doc) {
|
|
@@ -1184,7 +1184,7 @@ var appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
1184
1184
|
const CONFIG2 = getActiveConfig();
|
|
1185
1185
|
const doc = options.document || import_globals2.document;
|
|
1186
1186
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.ICONS;
|
|
1187
|
-
for (
|
|
1187
|
+
for (const key in LIBRARY)
|
|
1188
1188
|
lib[key] = CONFIG2.ICONS[key];
|
|
1189
1189
|
const SVGsprite = generateSprite(lib);
|
|
1190
1190
|
if (!doc) {
|
package/dist/cjs/system/theme.js
CHANGED
|
@@ -1348,10 +1348,10 @@ var setMediaTheme = (val, key, suffix, prefers) => {
|
|
|
1348
1348
|
theme[`.${param}`] = { [param]: theme[param] };
|
|
1349
1349
|
}
|
|
1350
1350
|
}
|
|
1351
|
-
if (theme
|
|
1351
|
+
if (theme.background || theme.color || theme.backgroundColor) {
|
|
1352
1352
|
theme[".inversed"] = {
|
|
1353
|
-
color: theme
|
|
1354
|
-
background: theme
|
|
1353
|
+
color: theme.background || theme.backgroundColor,
|
|
1354
|
+
background: theme.color
|
|
1355
1355
|
};
|
|
1356
1356
|
}
|
|
1357
1357
|
}
|
|
@@ -856,10 +856,13 @@ var require_cjs3 = __commonJS({
|
|
|
856
856
|
// src/transforms/index.js
|
|
857
857
|
var transforms_exports = {};
|
|
858
858
|
__export(transforms_exports, {
|
|
859
|
+
splitTransition: () => splitTransition,
|
|
859
860
|
transformBackgroundImage: () => transformBackgroundImage,
|
|
860
861
|
transformBorder: () => transformBorder,
|
|
862
|
+
transformDuration: () => transformDuration,
|
|
861
863
|
transformShadow: () => transformShadow,
|
|
862
864
|
transformTextStroke: () => transformTextStroke,
|
|
865
|
+
transformTransition: () => transformTransition,
|
|
863
866
|
transfromGap: () => transfromGap
|
|
864
867
|
});
|
|
865
868
|
module.exports = __toCommonJS(transforms_exports);
|
|
@@ -1140,6 +1143,11 @@ var import_utils3 = __toESM(require_cjs3());
|
|
|
1140
1143
|
var import_utils2 = __toESM(require_cjs3());
|
|
1141
1144
|
|
|
1142
1145
|
// ../utils/src/index.js
|
|
1146
|
+
var toCamelCase = (str) => {
|
|
1147
|
+
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
|
|
1148
|
+
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
1149
|
+
}).replaceAll(/\s+/g, "");
|
|
1150
|
+
};
|
|
1143
1151
|
var toDashCase = (val) => val.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase()).replace(".", "-");
|
|
1144
1152
|
var arrayzeValue = (val) => {
|
|
1145
1153
|
if ((0, import_utils3.isString)(val))
|
|
@@ -1458,6 +1466,22 @@ var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
|
1458
1466
|
);
|
|
1459
1467
|
};
|
|
1460
1468
|
|
|
1469
|
+
// src/system/timing.js
|
|
1470
|
+
var getTimingFunction = (value) => {
|
|
1471
|
+
const CONFIG2 = getActiveConfig();
|
|
1472
|
+
const { TIMING: TIMING2 } = CONFIG2;
|
|
1473
|
+
return TIMING2[value] || TIMING2[toCamelCase(value)] || value;
|
|
1474
|
+
};
|
|
1475
|
+
var getTimingByKey = (value, property = "timing") => {
|
|
1476
|
+
const CONFIG2 = getActiveConfig();
|
|
1477
|
+
const { TIMING: TIMING2 } = CONFIG2;
|
|
1478
|
+
return getSequenceValuePropertyPair(
|
|
1479
|
+
value,
|
|
1480
|
+
property,
|
|
1481
|
+
TIMING2
|
|
1482
|
+
);
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1461
1485
|
// src/system/document.js
|
|
1462
1486
|
var import_utils21 = __toESM(require_cjs3(), 1);
|
|
1463
1487
|
|
|
@@ -1504,6 +1528,7 @@ var transformTextStroke = (stroke) => {
|
|
|
1504
1528
|
return v;
|
|
1505
1529
|
else if (getColor(v))
|
|
1506
1530
|
return getColor(v);
|
|
1531
|
+
return v;
|
|
1507
1532
|
}).join(" ");
|
|
1508
1533
|
};
|
|
1509
1534
|
var transformShadow = (shadows) => shadows.split("|").map((shadow) => {
|
|
@@ -1538,3 +1563,30 @@ var transformBackgroundImage = (backgroundImage, globalTheme) => {
|
|
|
1538
1563
|
}).join(" ");
|
|
1539
1564
|
};
|
|
1540
1565
|
var transfromGap = (gap) => (0, import_utils25.isString)(gap) && gap.split(" ").map((v) => getSpacingByKey(v, "gap").gap).join(" ");
|
|
1566
|
+
var transformTransition = (transition) => {
|
|
1567
|
+
const arr = transition.split(" ");
|
|
1568
|
+
if (!arr.length)
|
|
1569
|
+
return transition;
|
|
1570
|
+
return arr.map((v) => {
|
|
1571
|
+
if (v.slice(0, 2) === "--")
|
|
1572
|
+
return `var(${v})`;
|
|
1573
|
+
if (v.length < 3 || v.includes("ms")) {
|
|
1574
|
+
const mapWithSequence = getTimingByKey(v);
|
|
1575
|
+
return mapWithSequence.timing || v;
|
|
1576
|
+
}
|
|
1577
|
+
if (getTimingFunction(v))
|
|
1578
|
+
return getTimingFunction(v);
|
|
1579
|
+
return v;
|
|
1580
|
+
}).join(" ");
|
|
1581
|
+
};
|
|
1582
|
+
var transformDuration = (duration, props, propertyName) => {
|
|
1583
|
+
if (!(0, import_utils25.isString)(duration))
|
|
1584
|
+
return;
|
|
1585
|
+
return duration.split(",").map((v) => getTimingByKey(v).timing || v).join(",");
|
|
1586
|
+
};
|
|
1587
|
+
var splitTransition = (transition) => {
|
|
1588
|
+
const arr = transition.split(",");
|
|
1589
|
+
if (!arr.length)
|
|
1590
|
+
return;
|
|
1591
|
+
return arr.map(transformTransition).join(",");
|
|
1592
|
+
};
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1522,7 +1522,7 @@ var applySequenceVars = (props, mediaName, options = {}) => {
|
|
|
1522
1522
|
var import_utils7 = __toESM(require_cjs3(), 1);
|
|
1523
1523
|
var generateSprite = (icons) => {
|
|
1524
1524
|
let sprite = '<svg aria-hidden="true" width="0" height="0" style="position:absolute">';
|
|
1525
|
-
for (
|
|
1525
|
+
for (const key in icons) {
|
|
1526
1526
|
sprite += icons[key];
|
|
1527
1527
|
}
|
|
1528
1528
|
sprite += "</svg>";
|
|
@@ -1532,14 +1532,14 @@ var parseRootAttributes = (htmlString) => {
|
|
|
1532
1532
|
if (!(0, import_utils7.isString)(htmlString)) {
|
|
1533
1533
|
return console.warn(`parseRootAttributes: ${htmlString} is not a string`);
|
|
1534
1534
|
}
|
|
1535
|
-
|
|
1535
|
+
const match = htmlString.match(/<svg\s+(.*?)>/);
|
|
1536
1536
|
if (!match || !match[1]) {
|
|
1537
1537
|
return {};
|
|
1538
1538
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1539
|
+
const attrString = match[1];
|
|
1540
|
+
const attrs = attrString.match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm);
|
|
1541
1541
|
return attrs.reduce((acc, attr) => {
|
|
1542
|
-
|
|
1542
|
+
const [key, value] = attr.split("=");
|
|
1543
1543
|
acc[key] = value.replace(/['"]/g, "");
|
|
1544
1544
|
return acc;
|
|
1545
1545
|
}, {});
|
|
@@ -1553,8 +1553,8 @@ var convertSvgToSymbol = (key, code) => {
|
|
|
1553
1553
|
"<svg",
|
|
1554
1554
|
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
1555
1555
|
);
|
|
1556
|
-
symbol = symbol.replace(/width="[
|
|
1557
|
-
symbol = symbol.replace(/height="[
|
|
1556
|
+
symbol = symbol.replace(/width="[^"]*/, "");
|
|
1557
|
+
symbol = symbol.replace(/height="[^"]*/, "");
|
|
1558
1558
|
symbol = symbol.replace("</svg", "</symbol");
|
|
1559
1559
|
return symbol;
|
|
1560
1560
|
};
|
package/dist/cjs/utils/sprite.js
CHANGED
|
@@ -863,7 +863,7 @@ module.exports = __toCommonJS(sprite_exports);
|
|
|
863
863
|
var import_utils = __toESM(require_cjs3(), 1);
|
|
864
864
|
var generateSprite = (icons) => {
|
|
865
865
|
let sprite = '<svg aria-hidden="true" width="0" height="0" style="position:absolute">';
|
|
866
|
-
for (
|
|
866
|
+
for (const key in icons) {
|
|
867
867
|
sprite += icons[key];
|
|
868
868
|
}
|
|
869
869
|
sprite += "</svg>";
|
|
@@ -873,14 +873,14 @@ var parseRootAttributes = (htmlString) => {
|
|
|
873
873
|
if (!(0, import_utils.isString)(htmlString)) {
|
|
874
874
|
return console.warn(`parseRootAttributes: ${htmlString} is not a string`);
|
|
875
875
|
}
|
|
876
|
-
|
|
876
|
+
const match = htmlString.match(/<svg\s+(.*?)>/);
|
|
877
877
|
if (!match || !match[1]) {
|
|
878
878
|
return {};
|
|
879
879
|
}
|
|
880
|
-
|
|
881
|
-
|
|
880
|
+
const attrString = match[1];
|
|
881
|
+
const attrs = attrString.match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm);
|
|
882
882
|
return attrs.reduce((acc, attr) => {
|
|
883
|
-
|
|
883
|
+
const [key, value] = attr.split("=");
|
|
884
884
|
acc[key] = value.replace(/['"]/g, "");
|
|
885
885
|
return acc;
|
|
886
886
|
}, {});
|
|
@@ -894,8 +894,8 @@ var convertSvgToSymbol = (key, code) => {
|
|
|
894
894
|
"<svg",
|
|
895
895
|
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
896
896
|
);
|
|
897
|
-
symbol = symbol.replace(/width="[
|
|
898
|
-
symbol = symbol.replace(/height="[
|
|
897
|
+
symbol = symbol.replace(/width="[^"]*/, "");
|
|
898
|
+
symbol = symbol.replace(/height="[^"]*/, "");
|
|
899
899
|
symbol = symbol.replace("</svg", "</symbol");
|
|
900
900
|
return symbol;
|
|
901
901
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
|
-
"version": "2.10.
|
|
5
|
+
"version": "2.10.259",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
8
8
|
"dist"
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@emotion/css": "^11.5.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "c454826279438617c85a5f8d8e7b3a6938d94dea"
|
|
36
36
|
}
|
package/src/factory.js
CHANGED
package/src/set.js
CHANGED
|
@@ -90,10 +90,11 @@ export const set = (recivedConfig, options = SET_OPTIONS) => {
|
|
|
90
90
|
useIconSprite,
|
|
91
91
|
globalTheme,
|
|
92
92
|
useDocumentTheme,
|
|
93
|
-
...config
|
|
94
|
-
|
|
93
|
+
...config
|
|
94
|
+
} = recivedConfig
|
|
95
|
+
|
|
95
96
|
if (options.newConfig) {
|
|
96
|
-
FACTORY
|
|
97
|
+
FACTORY.active = options.newConfig
|
|
97
98
|
CONFIG = getActiveConfig(options.newConfig)
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -119,5 +120,3 @@ export const set = (recivedConfig, options = SET_OPTIONS) => {
|
|
|
119
120
|
|
|
120
121
|
return CONFIG
|
|
121
122
|
}
|
|
122
|
-
|
|
123
|
-
export * from './system'
|
package/src/system/color.js
CHANGED
package/src/system/reset.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getMediaTheme } from '.'
|
|
|
6
6
|
|
|
7
7
|
export const applyReset = (reset = {}) => {
|
|
8
8
|
const CONFIG = getActiveConfig()
|
|
9
|
-
const {
|
|
9
|
+
const { RESET, TYPOGRAPHY, DOCUMENT } = CONFIG
|
|
10
10
|
if (RESET) {
|
|
11
11
|
if (RESET[':root']) {
|
|
12
12
|
const configReset = RESET
|
package/src/system/svg.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { document } from '@domql/globals'
|
|
4
|
-
import { generateSprite, convertSvgToSymbol } from
|
|
4
|
+
import { generateSprite, convertSvgToSymbol } from '../utils'
|
|
5
5
|
import { getActiveConfig } from '../factory.js'
|
|
6
6
|
|
|
7
7
|
const DEF_OPTIONS = {
|
|
8
|
-
document
|
|
8
|
+
document
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const setSVG = (val, key) => {
|
|
12
|
+
const CONFIG = getActiveConfig()
|
|
12
13
|
if (!val) {
|
|
13
14
|
if (CONFIG.verbose) console.warn('setSVG: val is not defined', key)
|
|
14
15
|
return
|
|
15
16
|
}
|
|
16
|
-
const CONFIG = getActiveConfig()
|
|
17
17
|
if (CONFIG.useSvgSprite) {
|
|
18
18
|
return convertSvgToSymbol(key, val)
|
|
19
19
|
} return val
|
|
@@ -24,14 +24,14 @@ export const appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
24
24
|
const doc = options.document || document
|
|
25
25
|
|
|
26
26
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG.SVG
|
|
27
|
-
for (
|
|
28
|
-
|
|
27
|
+
for (const key in LIBRARY) lib[key] = CONFIG.SVG[key]
|
|
28
|
+
|
|
29
29
|
const SVGsprite = generateSprite(lib)
|
|
30
30
|
if (!doc) {
|
|
31
31
|
console.warn('To append SVG sprites it should be run in browser environment')
|
|
32
32
|
return SVGsprite
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
const svgSpriteDOM = doc.createElement('template')
|
|
36
36
|
svgSpriteDOM.innerHTML = SVGsprite
|
|
37
37
|
doc.body.appendChild(svgSpriteDOM.content)
|
|
@@ -47,10 +47,10 @@ export const setIcon = (val, key) => {
|
|
|
47
47
|
export const appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
48
48
|
const CONFIG = getActiveConfig()
|
|
49
49
|
const doc = options.document || document
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG.ICONS
|
|
52
|
-
for (
|
|
53
|
-
|
|
52
|
+
for (const key in LIBRARY) lib[key] = CONFIG.ICONS[key]
|
|
53
|
+
|
|
54
54
|
const SVGsprite = generateSprite(lib)
|
|
55
55
|
if (!doc) {
|
|
56
56
|
console.warn('To append SVG Icon sprites it should be run in browser environment')
|
package/src/system/theme.js
CHANGED
|
@@ -168,10 +168,10 @@ export const setMediaTheme = (val, key, suffix, prefers) => {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
if (theme
|
|
171
|
+
if (theme.background || theme.color || theme.backgroundColor) {
|
|
172
172
|
theme['.inversed'] = {
|
|
173
|
-
color: theme
|
|
174
|
-
background: theme
|
|
173
|
+
color: theme.background || theme.backgroundColor,
|
|
174
|
+
background: theme.color
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
package/src/transforms/index.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { isString } from '@domql/utils'
|
|
4
|
-
import { getActiveConfig } from
|
|
5
|
-
import {
|
|
4
|
+
import { getActiveConfig } from '../factory'
|
|
5
|
+
import {
|
|
6
|
+
getSpacingByKey,
|
|
7
|
+
getColor,
|
|
8
|
+
getMediaColor,
|
|
9
|
+
getTimingByKey,
|
|
10
|
+
getTimingFunction
|
|
11
|
+
} from '../system'
|
|
6
12
|
|
|
7
13
|
const isBorderStyle = str => [
|
|
8
14
|
'none',
|
|
@@ -35,6 +41,7 @@ export const transformTextStroke = stroke => {
|
|
|
35
41
|
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
36
42
|
if (v.includes('px')) return v
|
|
37
43
|
else if (getColor(v)) return getColor(v)
|
|
44
|
+
return v
|
|
38
45
|
}).join(' ')
|
|
39
46
|
}
|
|
40
47
|
|
|
@@ -59,8 +66,7 @@ export const transformBackgroundImage = (backgroundImage, globalTheme) => {
|
|
|
59
66
|
return {
|
|
60
67
|
backgroundImage: getMediaColor(backgroundImage, globalTheme || CONFIG.globalTheme)
|
|
61
68
|
}
|
|
62
|
-
}
|
|
63
|
-
else if (v.includes('/') || v.includes('http')) return `url(${v})`
|
|
69
|
+
} else if (v.includes('/') || v.includes('http')) return `url(${v})`
|
|
64
70
|
return v
|
|
65
71
|
}).join(' ')
|
|
66
72
|
}
|
|
@@ -68,3 +74,30 @@ export const transformBackgroundImage = (backgroundImage, globalTheme) => {
|
|
|
68
74
|
export const transfromGap = gap => isString(gap) && (
|
|
69
75
|
gap.split(' ').map(v => getSpacingByKey(v, 'gap').gap).join(' ')
|
|
70
76
|
)
|
|
77
|
+
|
|
78
|
+
export const transformTransition = transition => {
|
|
79
|
+
const arr = transition.split(' ')
|
|
80
|
+
|
|
81
|
+
if (!arr.length) return transition
|
|
82
|
+
|
|
83
|
+
return arr.map(v => {
|
|
84
|
+
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
85
|
+
if (v.length < 3 || v.includes('ms')) {
|
|
86
|
+
const mapWithSequence = getTimingByKey(v)
|
|
87
|
+
return mapWithSequence.timing || v
|
|
88
|
+
}
|
|
89
|
+
if (getTimingFunction(v)) return getTimingFunction(v)
|
|
90
|
+
return v
|
|
91
|
+
}).join(' ')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const transformDuration = (duration, props, propertyName) => {
|
|
95
|
+
if (!isString(duration)) return
|
|
96
|
+
return duration.split(',').map(v => getTimingByKey(v).timing || v).join(',')
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const splitTransition = transition => {
|
|
100
|
+
const arr = transition.split(',')
|
|
101
|
+
if (!arr.length) return
|
|
102
|
+
return arr.map(transformTransition).join(',')
|
|
103
|
+
}
|
package/src/utils/index.js
CHANGED
package/src/utils/sprite.js
CHANGED
|
@@ -6,11 +6,11 @@ export const generateSprite = (icons) => {
|
|
|
6
6
|
let sprite =
|
|
7
7
|
'<svg aria-hidden="true" width="0" height="0" style="position:absolute">'
|
|
8
8
|
|
|
9
|
-
for (
|
|
9
|
+
for (const key in icons) {
|
|
10
10
|
sprite += icons[key]
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
sprite +=
|
|
13
|
+
sprite += '</svg>'
|
|
14
14
|
|
|
15
15
|
return sprite
|
|
16
16
|
}
|
|
@@ -19,33 +19,33 @@ const parseRootAttributes = (htmlString) => {
|
|
|
19
19
|
if (!isString(htmlString)) {
|
|
20
20
|
return console.warn(`parseRootAttributes: ${htmlString} is not a string`)
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
|
|
23
|
+
const match = htmlString.match(/<svg\s+(.*?)>/)
|
|
24
24
|
if (!match || !match[1]) {
|
|
25
|
-
return {}
|
|
25
|
+
return {}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const attrString = match[1]
|
|
29
|
+
const attrs = attrString.match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm)
|
|
30
30
|
return attrs.reduce((acc, attr) => {
|
|
31
|
-
|
|
32
|
-
acc[key] = value.replace(/['"]/g,
|
|
33
|
-
return acc
|
|
34
|
-
}, {})
|
|
31
|
+
const [key, value] = attr.split('=')
|
|
32
|
+
acc[key] = value.replace(/['"]/g, '')
|
|
33
|
+
return acc
|
|
34
|
+
}, {})
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export const convertSvgToSymbol = (key, code) => {
|
|
38
38
|
const extractAttrs = parseRootAttributes(code)
|
|
39
39
|
const { width, height } = extractAttrs
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
const viewBox = extractAttrs.viewBox || `0 0 ${width || 24} ${height || 24}`
|
|
42
42
|
const xmlns = 'http://www.w3.org/2000/svg'
|
|
43
43
|
|
|
44
|
-
let symbol = code.replace(
|
|
44
|
+
let symbol = code.replace('<svg',
|
|
45
45
|
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
46
46
|
)
|
|
47
|
-
symbol = symbol.replace(/width="[
|
|
48
|
-
symbol = symbol.replace(/height="[
|
|
49
|
-
symbol = symbol.replace(
|
|
47
|
+
symbol = symbol.replace(/width="[^"]*/, '')
|
|
48
|
+
symbol = symbol.replace(/height="[^"]*/, '')
|
|
49
|
+
symbol = symbol.replace('</svg', '</symbol')
|
|
50
50
|
return symbol
|
|
51
51
|
}
|