@bigbinary/neeto-commons-frontend 2.0.12 → 2.0.14
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/initializers.cjs.js +54 -0
- package/initializers.js +55 -1
- package/package.json +1 -1
- package/pure.cjs.js +117 -46
- package/pure.d.ts +157 -1
- package/pure.js +92 -48
- package/react-utils.cjs.js +318 -250
- package/react-utils.d.ts +11 -2
- package/react-utils.js +320 -252
- package/utils.cjs.js +64 -0
- package/utils.js +65 -1
package/utils.cjs.js
CHANGED
|
@@ -534,6 +534,22 @@ try {
|
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
|
|
537
|
+
/**
|
|
538
|
+
* @template {Function} T
|
|
539
|
+
* @param {T} func
|
|
540
|
+
* @returns {T}
|
|
541
|
+
*/
|
|
542
|
+
|
|
543
|
+
var nullSafe = function nullSafe(func) {
|
|
544
|
+
return (// @ts-ignore
|
|
545
|
+
ramda.curryN(func.length, function () {
|
|
546
|
+
var _ref;
|
|
547
|
+
|
|
548
|
+
var dataArg = (_ref = func.length - 1, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref]);
|
|
549
|
+
return ramda.isNil(dataArg) ? dataArg : func.apply(void 0, arguments);
|
|
550
|
+
})
|
|
551
|
+
);
|
|
552
|
+
};
|
|
537
553
|
var getRandomInt = function getRandomInt() {
|
|
538
554
|
var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Number.MAX_SAFE_INTEGER;
|
|
539
555
|
var b = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -559,6 +575,39 @@ function _typeof(obj) {
|
|
|
559
575
|
}, _typeof(obj);
|
|
560
576
|
}
|
|
561
577
|
|
|
578
|
+
var slugify = function slugify(string) {
|
|
579
|
+
return string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
|
|
580
|
+
.replace(/&/g, "-and-") // Replace & with 'and'
|
|
581
|
+
.replace(/[^\w-]+/g, "") // Remove all non-word characters
|
|
582
|
+
.replace(/--+/g, "-") // Replace multiple - with single -
|
|
583
|
+
.replace(/^-+/, "") // Trim - from start of text
|
|
584
|
+
.replace(/-+$/, "");
|
|
585
|
+
}; // Trim - from end of text
|
|
586
|
+
|
|
587
|
+
var humanize = function humanize(string) {
|
|
588
|
+
string = string.replace(/[_-]+/g, " ").replace(/\s{2,}/g, " ").replace(/([a-z\d])([A-Z])/g, "$1" + " " + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + " " + "$2").toLowerCase().trim();
|
|
589
|
+
string = string.charAt(0).toUpperCase() + string.slice(1);
|
|
590
|
+
return string;
|
|
591
|
+
};
|
|
592
|
+
var snakeToCamelCase = function snakeToCamelCase(string) {
|
|
593
|
+
return string.replace(/(_\w)/g, function (letter) {
|
|
594
|
+
return letter[1].toUpperCase();
|
|
595
|
+
});
|
|
596
|
+
};
|
|
597
|
+
var camelToSnakeCase = function camelToSnakeCase(string) {
|
|
598
|
+
return string.replace(/[A-Z]/g, function (letter) {
|
|
599
|
+
return "_".concat(letter.toLowerCase());
|
|
600
|
+
});
|
|
601
|
+
};
|
|
602
|
+
var capitalize = function capitalize(string) {
|
|
603
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
604
|
+
};
|
|
605
|
+
nullSafe(slugify);
|
|
606
|
+
nullSafe(humanize);
|
|
607
|
+
nullSafe(snakeToCamelCase);
|
|
608
|
+
nullSafe(camelToSnakeCase);
|
|
609
|
+
nullSafe(capitalize);
|
|
610
|
+
|
|
562
611
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
563
612
|
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
564
613
|
|
|
@@ -589,6 +638,21 @@ var preprocessForSerialization = function preprocessForSerialization(object) {
|
|
|
589
638
|
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
590
639
|
});
|
|
591
640
|
};
|
|
641
|
+
var filterNonNull = function filterNonNull(object) {
|
|
642
|
+
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
643
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
644
|
+
v = _ref6[1];
|
|
645
|
+
|
|
646
|
+
return !ramda.isNil(v);
|
|
647
|
+
}).map(function (_ref7) {
|
|
648
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
649
|
+
k = _ref8[0],
|
|
650
|
+
v = _ref8[1];
|
|
651
|
+
|
|
652
|
+
return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
|
|
653
|
+
}));
|
|
654
|
+
};
|
|
655
|
+
nullSafe(filterNonNull);
|
|
592
656
|
|
|
593
657
|
/* eslint complexity: [2, 18], max-statements: [2, 33] */
|
|
594
658
|
var shams = function hasSymbols() {
|
package/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { values, curry, toPairs, pipe, omit, isEmpty } from 'ramda';
|
|
2
|
+
import { values, curryN, isNil, curry, toPairs, pipe, omit, isEmpty } from 'ramda';
|
|
3
3
|
import { Toastr } from '@bigbinary/neetoui';
|
|
4
4
|
import i18next from 'i18next';
|
|
5
5
|
import require$$0 from 'util';
|
|
@@ -521,6 +521,22 @@ try {
|
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
+
/**
|
|
525
|
+
* @template {Function} T
|
|
526
|
+
* @param {T} func
|
|
527
|
+
* @returns {T}
|
|
528
|
+
*/
|
|
529
|
+
|
|
530
|
+
var nullSafe = function nullSafe(func) {
|
|
531
|
+
return (// @ts-ignore
|
|
532
|
+
curryN(func.length, function () {
|
|
533
|
+
var _ref;
|
|
534
|
+
|
|
535
|
+
var dataArg = (_ref = func.length - 1, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref]);
|
|
536
|
+
return isNil(dataArg) ? dataArg : func.apply(void 0, arguments);
|
|
537
|
+
})
|
|
538
|
+
);
|
|
539
|
+
};
|
|
524
540
|
var getRandomInt = function getRandomInt() {
|
|
525
541
|
var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Number.MAX_SAFE_INTEGER;
|
|
526
542
|
var b = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -546,6 +562,39 @@ function _typeof(obj) {
|
|
|
546
562
|
}, _typeof(obj);
|
|
547
563
|
}
|
|
548
564
|
|
|
565
|
+
var slugify = function slugify(string) {
|
|
566
|
+
return string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
|
|
567
|
+
.replace(/&/g, "-and-") // Replace & with 'and'
|
|
568
|
+
.replace(/[^\w-]+/g, "") // Remove all non-word characters
|
|
569
|
+
.replace(/--+/g, "-") // Replace multiple - with single -
|
|
570
|
+
.replace(/^-+/, "") // Trim - from start of text
|
|
571
|
+
.replace(/-+$/, "");
|
|
572
|
+
}; // Trim - from end of text
|
|
573
|
+
|
|
574
|
+
var humanize = function humanize(string) {
|
|
575
|
+
string = string.replace(/[_-]+/g, " ").replace(/\s{2,}/g, " ").replace(/([a-z\d])([A-Z])/g, "$1" + " " + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + " " + "$2").toLowerCase().trim();
|
|
576
|
+
string = string.charAt(0).toUpperCase() + string.slice(1);
|
|
577
|
+
return string;
|
|
578
|
+
};
|
|
579
|
+
var snakeToCamelCase = function snakeToCamelCase(string) {
|
|
580
|
+
return string.replace(/(_\w)/g, function (letter) {
|
|
581
|
+
return letter[1].toUpperCase();
|
|
582
|
+
});
|
|
583
|
+
};
|
|
584
|
+
var camelToSnakeCase = function camelToSnakeCase(string) {
|
|
585
|
+
return string.replace(/[A-Z]/g, function (letter) {
|
|
586
|
+
return "_".concat(letter.toLowerCase());
|
|
587
|
+
});
|
|
588
|
+
};
|
|
589
|
+
var capitalize = function capitalize(string) {
|
|
590
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
591
|
+
};
|
|
592
|
+
nullSafe(slugify);
|
|
593
|
+
nullSafe(humanize);
|
|
594
|
+
nullSafe(snakeToCamelCase);
|
|
595
|
+
nullSafe(camelToSnakeCase);
|
|
596
|
+
nullSafe(capitalize);
|
|
597
|
+
|
|
549
598
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
550
599
|
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
551
600
|
|
|
@@ -576,6 +625,21 @@ var preprocessForSerialization = function preprocessForSerialization(object) {
|
|
|
576
625
|
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
577
626
|
});
|
|
578
627
|
};
|
|
628
|
+
var filterNonNull = function filterNonNull(object) {
|
|
629
|
+
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
630
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
631
|
+
v = _ref6[1];
|
|
632
|
+
|
|
633
|
+
return !isNil(v);
|
|
634
|
+
}).map(function (_ref7) {
|
|
635
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
636
|
+
k = _ref8[0],
|
|
637
|
+
v = _ref8[1];
|
|
638
|
+
|
|
639
|
+
return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
|
|
640
|
+
}));
|
|
641
|
+
};
|
|
642
|
+
nullSafe(filterNonNull);
|
|
579
643
|
|
|
580
644
|
/* eslint complexity: [2, 18], max-statements: [2, 33] */
|
|
581
645
|
var shams = function hasSymbols() {
|