@thecb/components 9.1.7-beta.4 → 9.1.7-beta.5

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/index.cjs.js CHANGED
@@ -18686,22 +18686,12 @@ var fallbackValues$4 = {
18686
18686
  link: link
18687
18687
  };
18688
18688
 
18689
- /*
18690
-
18691
- A utility function that can generate box-shadow values for components
18692
- Takes a string representing an rgb color value and returns an object
18693
- with values for standard, inset, and overlay shadows.
18694
-
18695
- The objects for standard and inset shadows contain versions approiate
18696
- for base, hover, and active interaction states.
18697
-
18698
- */
18699
-
18700
18689
  /*
18701
18690
  Function to convert string representing rgb color to rgba value with provided opacity
18702
18691
  ("rgb(41, 42, 51)", "0.1") => "rgba(41, 42, 51, 0.1)"
18703
18692
 
18704
18693
  */
18694
+
18705
18695
  var rgbToRgba = function rgbToRgba() {
18706
18696
  var rgbValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
18707
18697
  var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
@@ -18712,6 +18702,17 @@ var rgbToRgba = function rgbToRgba() {
18712
18702
 
18713
18703
  return "".concat(rgbValue.slice(0, 3), "a").concat(rgbValue.slice(3, -1), ", ").concat(opacity).concat(rgbValue.slice(-1));
18714
18704
  };
18705
+ /*
18706
+
18707
+ A utility function that can generate box-shadow values for components
18708
+ Takes a string representing an rgb color value and returns an object
18709
+ with values for standard, inset, and overlay shadows.
18710
+
18711
+ The objects for standard and inset shadows contain versions approiate
18712
+ for base, hover, and active interaction states.
18713
+
18714
+ */
18715
+
18715
18716
 
18716
18717
  var generateShadows = function generateShadows() {
18717
18718
  var baseColorRGB = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "rgb(41, 42, 51)";
@@ -18739,9 +18740,43 @@ var generateShadows = function generateShadows() {
18739
18740
  overlay: overlay
18740
18741
  };
18741
18742
  };
18742
- var addOpacity = function addOpacity(color, opacity, r, g, b) {
18743
- var rgba = "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
18744
- return "linear-gradient(0deg, ".concat(rgba, ", ").concat(rgba, "), linear-gradient(0deg, ").concat(color, ", ").concat(color, ");");
18743
+ /*
18744
+ Function to convert a string representing hex color to rgb color
18745
+ hexToRbg("#00ff00") => [0, 255, 0]
18746
+ */
18747
+
18748
+ var hexToRbg = function hexToRbg(hexColor) {
18749
+ var hexArr = hexColor.replace("#", "");
18750
+ var red = parseInt(hexArr.slice(0, 2), 16);
18751
+ var green = parseInt(hexArr.slice(2, 4), 16);
18752
+ var blue = parseInt(hexArr.slice(4, 6), 16);
18753
+ return [red, green, blue];
18754
+ };
18755
+ /*
18756
+ Function to calculate a new hex color given an original
18757
+ hex color, a hex background color, and an opacity number
18758
+ between 0 and 1 to apply to the background.
18759
+
18760
+ For example, to add a 20% black opacity (20% darker) to a green color
18761
+ ("#00ff00"):
18762
+ addOpacityToHex("00ff00", "#000000", .2) => "rgb(0, 204, 0)"
18763
+ */
18764
+
18765
+
18766
+ var addOpacityToHex = function addOpacityToHex(hexColor, background, opacity) {
18767
+ if (hexColor == TRANSPARENT) {
18768
+ return hexColor;
18769
+ }
18770
+
18771
+ var color = hexToRbg(hexColor);
18772
+ var backgroundRbg = hexToRbg(background);
18773
+ var newColor = color.map(function (colorElem, index) {
18774
+ return Math.floor(opacity * backgroundRbg[index] + (1 - opacity) * colorElem);
18775
+ });
18776
+ return "rgb(".concat(newColor[0], ", ").concat(newColor[1], ", ").concat(newColor[2], ")");
18777
+ };
18778
+ var darken = function darken(hexColor, opacity) {
18779
+ return addOpacityToHex(hexColor, "#000000", opacity);
18745
18780
  };
18746
18781
 
18747
18782
  var Alert = function Alert(_ref) {
@@ -23770,7 +23805,7 @@ var DropdownContentWrapper = styled__default.div.withConfig({
23770
23805
  var DropdownItemWrapper = styled__default.li.withConfig({
23771
23806
  displayName: "Dropdown__DropdownItemWrapper",
23772
23807
  componentId: "sc-pn6m0h-2"
23773
- })(["text-align:start;border-width:2px;border-style:solid;border-color:", ";box-shadow:none;box-sizing:border-box;width:100%;list-style:none;cursor:", ";&:hover{background:", ";border-color:", ";> *{background:", ";border-color:transparent;}}&:focus{outline:none;background:", ";border-color:", ";> *{background:", ";border-color:white;outline:none;}}"], function (_ref4) {
23808
+ })(["text-align:start;border-width:2px;border-style:solid;border-color:", ";box-shadow:none;box-sizing:border-box;width:100%;list-style:none;cursor:", ";&:hover{border-color:", ";> *{background:", ";border-color:", ";}}&:focus{outline:none;border-color:", ";> *{background:", ";border-color:white;outline:none;}}"], function (_ref4) {
23774
23809
  var selected = _ref4.selected,
23775
23810
  themeValues = _ref4.themeValues;
23776
23811
  return selected ? themeValues.selectedColor : WHITE;
@@ -23779,71 +23814,68 @@ var DropdownItemWrapper = styled__default.li.withConfig({
23779
23814
  return disabled ? "default" : "pointer";
23780
23815
  }, function (_ref6) {
23781
23816
  var disabled = _ref6.disabled,
23817
+ selected = _ref6.selected,
23782
23818
  themeValues = _ref6.themeValues;
23783
- return disabled ? WHITE : addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0);
23819
+ return selected ? darken(themeValues.selectedColor, 0.2) : disabled ? WHITE : themeValues.hoverColor;
23784
23820
  }, function (_ref7) {
23785
23821
  var selected = _ref7.selected,
23822
+ disabled = _ref7.disabled,
23786
23823
  themeValues = _ref7.themeValues;
23787
- return selected ? TRANSPARENT : themeValues.hoverColor;
23824
+ return selected ? darken(themeValues.selectedColor, 0.2) : disabled ? WHITE : themeValues.hoverColor;
23788
23825
  }, function (_ref8) {
23789
23826
  var selected = _ref8.selected,
23790
23827
  disabled = _ref8.disabled,
23791
23828
  themeValues = _ref8.themeValues;
23792
- return selected ? addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0) : disabled ? WHITE : themeValues.hoverColor;
23829
+ return selected ? darken(themeValues.selectedColor, 0.2) : disabled ? WHITE : themeValues.hoverColor;
23793
23830
  }, function (_ref9) {
23794
- var selected = _ref9.selected,
23795
- themeValues = _ref9.themeValues;
23796
- return selected ? addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0) : "";
23831
+ var themeValues = _ref9.themeValues;
23832
+ return themeValues.selectedColor;
23797
23833
  }, function (_ref10) {
23798
23834
  var selected = _ref10.selected,
23835
+ disabled = _ref10.disabled,
23799
23836
  themeValues = _ref10.themeValues;
23800
- return selected ? TRANSPARENT : themeValues.selectedColor;
23801
- }, function (_ref11) {
23802
- var selected = _ref11.selected,
23803
- disabled = _ref11.disabled,
23804
- themeValues = _ref11.themeValues;
23805
- return selected ? addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0) : disabled ? WHITE : themeValues.hoverColor;
23837
+ return selected ? darken(themeValues.selectedColor, 0.2) : disabled ? WHITE : themeValues.hoverColor;
23806
23838
  });
23807
23839
  var DropdownItemBorder = styled__default.div.withConfig({
23808
23840
  displayName: "Dropdown__DropdownItemBorder",
23809
23841
  componentId: "sc-pn6m0h-3"
23810
- })(["background:", ";border-color:", ";border-width:2px;border-style:solid;padding:12px;"], function (_ref12) {
23842
+ })(["background:", ";border-color:", ";border-width:2px;border-style:solid;padding:12px;"], function (_ref11) {
23843
+ var selected = _ref11.selected,
23844
+ themeValues = _ref11.themeValues;
23845
+ return selected ? themeValues.selectedColor : WHITE;
23846
+ }, function (_ref12) {
23811
23847
  var selected = _ref12.selected,
23812
23848
  themeValues = _ref12.themeValues;
23813
23849
  return selected ? themeValues.selectedColor : WHITE;
23814
- }, function (_ref13) {
23815
- var selected = _ref13.selected,
23816
- themeValues = _ref13.themeValues;
23817
- return selected ? themeValues.selectedColor : WHITE;
23818
23850
  });
23819
23851
 
23820
- var Dropdown = function Dropdown(_ref14) {
23821
- var placeholder = _ref14.placeholder,
23822
- options = _ref14.options,
23823
- value = _ref14.value,
23824
- isOpen = _ref14.isOpen,
23825
- isError = _ref14.isError,
23826
- onSelect = _ref14.onSelect,
23827
- _ref14$disabledValues = _ref14.disabledValues,
23828
- disabledValues = _ref14$disabledValues === void 0 ? [] : _ref14$disabledValues,
23829
- _ref14$onClick = _ref14.onClick,
23830
- _onClick = _ref14$onClick === void 0 ? noop : _ref14$onClick,
23831
- themeValues = _ref14.themeValues,
23832
- maxHeight = _ref14.maxHeight,
23833
- _ref14$widthFitOption = _ref14.widthFitOptions,
23834
- widthFitOptions = _ref14$widthFitOption === void 0 ? false : _ref14$widthFitOption,
23835
- disabled = _ref14.disabled,
23836
- _ref14$hasTitles = _ref14.hasTitles,
23837
- hasTitles = _ref14$hasTitles === void 0 ? false : _ref14$hasTitles,
23838
- _ref14$autoEraseTypeA = _ref14.autoEraseTypeAhead,
23839
- autoEraseTypeAhead = _ref14$autoEraseTypeA === void 0 ? true : _ref14$autoEraseTypeA,
23840
- ariaLabelledby = _ref14.ariaLabelledby,
23841
- ariaDescribedby = _ref14.ariaDescribedby,
23842
- autocompleteValue = _ref14.autocompleteValue,
23843
- _ref14$smoothScroll = _ref14.smoothScroll,
23844
- smoothScroll = _ref14$smoothScroll === void 0 ? true : _ref14$smoothScroll,
23845
- _ref14$ariaInvalid = _ref14.ariaInvalid,
23846
- ariaInvalid = _ref14$ariaInvalid === void 0 ? false : _ref14$ariaInvalid;
23852
+ var Dropdown = function Dropdown(_ref13) {
23853
+ var placeholder = _ref13.placeholder,
23854
+ options = _ref13.options,
23855
+ value = _ref13.value,
23856
+ isOpen = _ref13.isOpen,
23857
+ isError = _ref13.isError,
23858
+ onSelect = _ref13.onSelect,
23859
+ _ref13$disabledValues = _ref13.disabledValues,
23860
+ disabledValues = _ref13$disabledValues === void 0 ? [] : _ref13$disabledValues,
23861
+ _ref13$onClick = _ref13.onClick,
23862
+ _onClick = _ref13$onClick === void 0 ? noop : _ref13$onClick,
23863
+ themeValues = _ref13.themeValues,
23864
+ maxHeight = _ref13.maxHeight,
23865
+ _ref13$widthFitOption = _ref13.widthFitOptions,
23866
+ widthFitOptions = _ref13$widthFitOption === void 0 ? false : _ref13$widthFitOption,
23867
+ disabled = _ref13.disabled,
23868
+ _ref13$hasTitles = _ref13.hasTitles,
23869
+ hasTitles = _ref13$hasTitles === void 0 ? false : _ref13$hasTitles,
23870
+ _ref13$autoEraseTypeA = _ref13.autoEraseTypeAhead,
23871
+ autoEraseTypeAhead = _ref13$autoEraseTypeA === void 0 ? true : _ref13$autoEraseTypeA,
23872
+ ariaLabelledby = _ref13.ariaLabelledby,
23873
+ ariaDescribedby = _ref13.ariaDescribedby,
23874
+ autocompleteValue = _ref13.autocompleteValue,
23875
+ _ref13$smoothScroll = _ref13.smoothScroll,
23876
+ smoothScroll = _ref13$smoothScroll === void 0 ? true : _ref13$smoothScroll,
23877
+ _ref13$ariaInvalid = _ref13.ariaInvalid,
23878
+ ariaInvalid = _ref13$ariaInvalid === void 0 ? false : _ref13$ariaInvalid;
23847
23879
 
23848
23880
  var _useState = React.useState(""),
23849
23881
  _useState2 = _slicedToArray(_useState, 2),