@janiscommerce/ui-web 0.12.0 → 0.13.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/CHANGELOG.md +10 -0
- package/dist/index.umd.js +44 -73
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.13.0] - 2024-03-09
|
|
11
|
+
|
|
12
|
+
### Removed
|
|
13
|
+
|
|
14
|
+
- util to get color in InitialAvatar
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- MainColor prop, now accept hex color
|
|
19
|
+
|
|
10
20
|
## [0.12.0] - 2024-03-08
|
|
11
21
|
|
|
12
22
|
### Added
|
package/dist/index.umd.js
CHANGED
|
@@ -672,7 +672,8 @@
|
|
|
672
672
|
|
|
673
673
|
Skeleton.defaultProps = {
|
|
674
674
|
circle: false,
|
|
675
|
-
count: 1
|
|
675
|
+
count: 1,
|
|
676
|
+
width: '100%'
|
|
676
677
|
};
|
|
677
678
|
|
|
678
679
|
var styled$d = {
|
|
@@ -694,76 +695,6 @@
|
|
|
694
695
|
})
|
|
695
696
|
};
|
|
696
697
|
|
|
697
|
-
/**
|
|
698
|
-
* Checks if the name provided is single or compound and returns either the first two letters,
|
|
699
|
-
* or the initials of the two first names.
|
|
700
|
-
* @param {string} nameString
|
|
701
|
-
*/
|
|
702
|
-
|
|
703
|
-
var parseName = function parseName(nameString) {
|
|
704
|
-
var names = nameString.split(' ');
|
|
705
|
-
return names.length > 1 ? names.reduce(function (accum, name, idx) {
|
|
706
|
-
if (idx <= 1) return [].concat(_toConsumableArray(accum), [name.substring(0, 1)]);
|
|
707
|
-
return accum;
|
|
708
|
-
}, []) : nameString.substring(0, 2).split('');
|
|
709
|
-
};
|
|
710
|
-
/**
|
|
711
|
-
* If both firstname and lastname are provided, returns an array with each of their initials.
|
|
712
|
-
* If only a firstname or a lastname is provided, parses them to return either
|
|
713
|
-
* their initials (if it's a compound name) or first two letters.
|
|
714
|
-
* @param {string} firstname
|
|
715
|
-
* @param {string} lastname
|
|
716
|
-
*/
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
var getNamesToParse = function getNamesToParse(firstname, lastname) {
|
|
720
|
-
return !!firstname || !!lastname ? parseName(firstname || lastname) : null;
|
|
721
|
-
};
|
|
722
|
-
/**
|
|
723
|
-
* Assigns a color to the names or initials array provided.
|
|
724
|
-
* @param {array} name - Array containing the firstname and lastname strings
|
|
725
|
-
*/
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
var getUserColor = function getUserColor(name) {
|
|
729
|
-
var excludedColors = ['lightGreyHover', 'lightGrey', 'white', 'transparentWhite'];
|
|
730
|
-
var availableColors = Object.keys(viewsPalette).filter(function (color) {
|
|
731
|
-
return !excludedColors.includes(color);
|
|
732
|
-
});
|
|
733
|
-
var availableIndexes = availableColors.length;
|
|
734
|
-
|
|
735
|
-
var charCodes = _toConsumableArray(name).map(function (letter) {
|
|
736
|
-
return letter.charCodeAt(0);
|
|
737
|
-
});
|
|
738
|
-
|
|
739
|
-
var charCodesLength = charCodes.length;
|
|
740
|
-
var rotationFactor = charCodesLength % (availableIndexes - 1) + 1;
|
|
741
|
-
var sumOfCharacterCodes = charCodes.reduce(function (current, next) {
|
|
742
|
-
return current + next;
|
|
743
|
-
}) % availableIndexes;
|
|
744
|
-
var random = charCodes[0] % availableIndexes;
|
|
745
|
-
|
|
746
|
-
for (var i = 0; i < charCodesLength; i++) {
|
|
747
|
-
random = (rotationFactor * random + sumOfCharacterCodes) % availableIndexes;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
var userColor = availableColors[random];
|
|
751
|
-
return viewsPalette[userColor];
|
|
752
|
-
};
|
|
753
|
-
/**
|
|
754
|
-
* If firstname or lastname (or both) are defined, will return an object with their initials and assigned color.
|
|
755
|
-
* If not, returns null.
|
|
756
|
-
* @param {string} firstname
|
|
757
|
-
* @param {string} lastname
|
|
758
|
-
*/
|
|
759
|
-
|
|
760
|
-
var getInitialsTheme = function getInitialsTheme() {
|
|
761
|
-
var firstname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
762
|
-
var lastname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
763
|
-
if (!!firstname && !!lastname) return [firstname.substring(0, 1), lastname.substring(0, 1)];
|
|
764
|
-
return getNamesToParse(firstname, lastname);
|
|
765
|
-
};
|
|
766
|
-
|
|
767
698
|
var timingFunctions = {
|
|
768
699
|
standard: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
769
700
|
decelerate: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
|
|
@@ -812,12 +743,51 @@
|
|
|
812
743
|
imageSize = _ref.imageSize,
|
|
813
744
|
rounded = _ref.rounded;
|
|
814
745
|
return /*#__PURE__*/React__default["default"].createElement(styled$c.Initials, {
|
|
815
|
-
color: mainColor
|
|
746
|
+
color: mainColor,
|
|
816
747
|
size: imageSize,
|
|
817
748
|
rounded: rounded
|
|
818
749
|
}, initials);
|
|
819
750
|
};
|
|
820
751
|
|
|
752
|
+
/**
|
|
753
|
+
* Checks if the name provided is single or compound and returns either the first two letters,
|
|
754
|
+
* or the initials of the two first names.
|
|
755
|
+
* @param {string} nameString
|
|
756
|
+
*/
|
|
757
|
+
var parseName = function parseName(nameString) {
|
|
758
|
+
var names = nameString.split(' ');
|
|
759
|
+
return names.length > 1 ? names.reduce(function (accum, name, idx) {
|
|
760
|
+
if (idx <= 1) return [].concat(_toConsumableArray(accum), [name.substring(0, 1)]);
|
|
761
|
+
return accum;
|
|
762
|
+
}, []) : nameString.substring(0, 2).split('');
|
|
763
|
+
};
|
|
764
|
+
/**
|
|
765
|
+
* If both firstname and lastname are provided, returns an array with each of their initials.
|
|
766
|
+
* If only a firstname or a lastname is provided, parses them to return either
|
|
767
|
+
* their initials (if it's a compound name) or first two letters.
|
|
768
|
+
* @param {string} firstname
|
|
769
|
+
* @param {string} lastname
|
|
770
|
+
*/
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
var getNamesToParse = function getNamesToParse(firstname, lastname) {
|
|
774
|
+
return !!firstname || !!lastname ? parseName(firstname || lastname) : null;
|
|
775
|
+
};
|
|
776
|
+
/**
|
|
777
|
+
* If firstname or lastname (or both) are defined, will return an object with their initials and assigned color.
|
|
778
|
+
* If not, returns null.
|
|
779
|
+
* @param {string} firstname
|
|
780
|
+
* @param {string} lastname
|
|
781
|
+
*/
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
var getInitialsTheme = function getInitialsTheme() {
|
|
785
|
+
var firstname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
786
|
+
var lastname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
787
|
+
if (!!firstname && !!lastname) return [firstname.substring(0, 1), lastname.substring(0, 1)];
|
|
788
|
+
return getNamesToParse(firstname, lastname);
|
|
789
|
+
};
|
|
790
|
+
|
|
821
791
|
var Avatar = function Avatar(_ref) {
|
|
822
792
|
var firstname = _ref.firstname,
|
|
823
793
|
lastname = _ref.lastname,
|
|
@@ -882,7 +852,8 @@
|
|
|
882
852
|
lastname: '',
|
|
883
853
|
size: 'small',
|
|
884
854
|
url: '',
|
|
885
|
-
rounded: true
|
|
855
|
+
rounded: true,
|
|
856
|
+
mainColor: viewsPalette.grey
|
|
886
857
|
};
|
|
887
858
|
|
|
888
859
|
var API_key = {
|