@zelgadis87/utils-core 4.7.0 → 4.8.0
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/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/css.d.ts +7 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/strings/StringParts.d.ts +6 -0
- package/esbuild/index.cjs +36 -0
- package/esbuild/index.cjs.map +3 -3
- package/esbuild/index.mjs +35 -0
- package/esbuild/index.mjs.map +3 -3
- package/package.json +1 -1
- package/src/utils/css.ts +33 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/strings/StringParts.ts +11 -0
package/esbuild/index.mjs
CHANGED
|
@@ -626,6 +626,32 @@ function isFalse(x) {
|
|
|
626
626
|
return x === false;
|
|
627
627
|
}
|
|
628
628
|
|
|
629
|
+
// src/utils/css.ts
|
|
630
|
+
var newLine = "\n";
|
|
631
|
+
var tabulation = " ";
|
|
632
|
+
var colon = ":";
|
|
633
|
+
var semiColon = ";";
|
|
634
|
+
var space = " ";
|
|
635
|
+
var openBracket = "{";
|
|
636
|
+
var closeBracket = "}";
|
|
637
|
+
function cssDeclarationRulesDictionaryToCss(syleDeclarationRulesForSelectors) {
|
|
638
|
+
return Object.entries(syleDeclarationRulesForSelectors).map(([selector, styleDeclarationRules]) => {
|
|
639
|
+
const cssRules = cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRules);
|
|
640
|
+
if (!cssRules.length) return null;
|
|
641
|
+
return selector + space + openBracket + newLine + cssRules.map((rule) => tabulation + rule + semiColon).join(newLine) + newLine + closeBracket;
|
|
642
|
+
}).filter(Boolean).join(newLine + newLine);
|
|
643
|
+
}
|
|
644
|
+
function cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRulesProduceable) {
|
|
645
|
+
const styleDeclarationRules = produceableToValue(styleDeclarationRulesProduceable);
|
|
646
|
+
return Object.entries(styleDeclarationRules).map(([key, value]) => pascalCaseToKebabCase(key) + colon + space + produceableToValue(value));
|
|
647
|
+
}
|
|
648
|
+
function pascalCaseToKebabCase(s) {
|
|
649
|
+
return s.split(/([A-Z][a-z]*)/).filter(Boolean).map((n) => n.toLowerCase()).join("-");
|
|
650
|
+
}
|
|
651
|
+
function produceableToValue(t) {
|
|
652
|
+
return isFunction(t) ? t() : t;
|
|
653
|
+
}
|
|
654
|
+
|
|
629
655
|
// src/utils/errors/withTryCatch.ts
|
|
630
656
|
function withTryCatch(fn, errMapFn) {
|
|
631
657
|
try {
|
|
@@ -905,6 +931,14 @@ var StringParts = class _StringParts {
|
|
|
905
931
|
static fromParts = (...parts) => {
|
|
906
932
|
return new _StringParts(...parts);
|
|
907
933
|
};
|
|
934
|
+
/**
|
|
935
|
+
* Tries to convert a word in PascalCase to an array of words. Will not work if there are spaces or special characters. Does not cope well on uppercase abbreviations (eg, "CSS").
|
|
936
|
+
* @param s a string in PascalCase.
|
|
937
|
+
* @returns a StringParts where each sub-word in PascalCase is now a part.
|
|
938
|
+
*/
|
|
939
|
+
static tryToParsePascalCaseWord(s) {
|
|
940
|
+
return new _StringParts(...s.split(/([A-Z][a-z]*)/).filter(Boolean).map((n) => n.toLowerCase()));
|
|
941
|
+
}
|
|
908
942
|
};
|
|
909
943
|
|
|
910
944
|
// src/utils/strings.ts
|
|
@@ -2676,6 +2710,7 @@ export {
|
|
|
2676
2710
|
constantTrue,
|
|
2677
2711
|
constantZero,
|
|
2678
2712
|
createSorterFor,
|
|
2713
|
+
cssDeclarationRulesDictionaryToCss,
|
|
2679
2714
|
decrement,
|
|
2680
2715
|
decrementBy,
|
|
2681
2716
|
delayPromise,
|