bootstrap-rn 0.2.11 → 0.2.12

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.
@@ -678,23 +678,10 @@ var UnitValue = /*#__PURE__*/function () {
678
678
  }
679
679
 
680
680
  _createClass(UnitValue, [{
681
- key: "toPercentage",
682
- value: function toPercentage() {
683
- if (!['number', 'percent'].includes(this.unit)) {
684
- throw new Error("Unexpected unit \"".concat(this.unit, "\"."));
685
- }
686
-
687
- if (this.unit === 'percent') {
688
- return this.value / 100;
689
- }
690
-
691
- return this.value;
692
- }
693
- }, {
694
681
  key: "toNumber",
695
682
  value: function toNumber() {
696
- if (!['number', 'px', 'rem'].includes(this.unit)) {
697
- throw new Error("Unexpected unit \"".concat(this.unit, "\"."));
683
+ if (this.unit === 'percent') {
684
+ return this.value / 100;
698
685
  }
699
686
 
700
687
  if (this.unit === 'rem') {
@@ -706,7 +693,15 @@ var UnitValue = /*#__PURE__*/function () {
706
693
  }, {
707
694
  key: "toString",
708
695
  value: function toString() {
709
- return "".concat(this.value).concat(this.unit === 'number' ? '' : this.unit);
696
+ if (this.unit === 'number') {
697
+ return this.value;
698
+ }
699
+
700
+ if (this.unit === 'percent') {
701
+ return "".concat(this.value, "%");
702
+ }
703
+
704
+ return "".concat(this.value).concat(this.unit);
710
705
  }
711
706
  }], [{
712
707
  key: "parse",
@@ -733,12 +728,28 @@ var UnitValue = /*#__PURE__*/function () {
733
728
  }();
734
729
 
735
730
  var POWER = Math.pow(10, 8);
731
+ var UNIT_ORDER = ['percent', 'number', 'px', 'rem'];
736
732
 
737
733
  var fixRounding = function fixRounding(value) {
738
734
  return Math.round(value * POWER) / POWER;
739
735
  };
740
736
 
741
- var calculateValue = function calculateValue(value1, operator, value2) {
737
+ var normalizeValue$1 = function normalizeValue(number1, number2) {
738
+ if (number1.unit === 'px' && number2.unit === 'rem') {
739
+ return number1.value / (reactNative.PixelRatio.getFontScale() * 16);
740
+ }
741
+
742
+ if (number1.unit === 'percent' && number2.unit !== 'percent') {
743
+ return number1.value / 100;
744
+ }
745
+
746
+ return number1.value;
747
+ };
748
+
749
+ var calculateValue = function calculateValue(number1, operator, number2) {
750
+ var value1 = normalizeValue$1(number1, number2);
751
+ var value2 = normalizeValue$1(number2, number1);
752
+
742
753
  switch (operator) {
743
754
  case '+':
744
755
  return value1 + value2;
@@ -760,24 +771,18 @@ var calculateValue = function calculateValue(value1, operator, value2) {
760
771
  }
761
772
  };
762
773
 
763
- var pxToRem = function pxToRem(value) {
764
- return value / (reactNative.PixelRatio.getFontScale() * 16);
774
+ var determineUnit = function determineUnit(number1, number2) {
775
+ var index1 = UNIT_ORDER.indexOf(number1.unit);
776
+ var index2 = UNIT_ORDER.indexOf(number2.unit);
777
+ return index1 > index2 ? number1.unit : number2.unit;
765
778
  };
766
779
 
767
780
  function calculate(value1, operator, value2) {
768
781
  var number1 = UnitValue.parse(value1);
769
782
  var number2 = UnitValue.parse(value2);
770
-
771
- if (number1.unit === 'px' && number2.unit === 'rem') {
772
- return "".concat(calculateValue(pxToRem(number1.value), operator, number2.value), "rem");
773
- }
774
-
775
- if (number1.unit === 'rem' && number2.unit === 'px') {
776
- return "".concat(calculateValue(number1.value, operator, pxToRem(number2.value)), "rem");
777
- }
778
-
779
- var unit = number1.unit === 'number' ? number2.unit : number1.unit;
780
- return "".concat(calculateValue(number1.value, operator, number2.value)).concat(unit === 'number' ? '' : unit);
783
+ var value = calculateValue(number1, operator, number2);
784
+ var unit = determineUnit(number1, number2);
785
+ return new UnitValue(value, unit).toString();
781
786
  }
782
787
  function normalizeNumber(value) {
783
788
  return UnitValue.parse(value).toNumber();
@@ -1083,7 +1088,7 @@ function mix(color1, color2) {
1083
1088
  var weight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
1084
1089
  var rgb1 = RgbaValue.parse(color1).toRgb();
1085
1090
  var rgb2 = RgbaValue.parse(color2).toRgb();
1086
- var percentage = UnitValue.parse(weight).toPercentage();
1091
+ var percentage = UnitValue.parse(weight).toNumber();
1087
1092
 
1088
1093
  var _rgb1$map = rgb1.map(function (value, key) {
1089
1094
  return Math.round(rgb2[key] + (value - rgb2[key]) * percentage);
@@ -2542,7 +2547,7 @@ var shiftColor = fn(function (_ref9, t) {
2542
2547
  color = _ref10[0],
2543
2548
  weight = _ref10[1];
2544
2549
 
2545
- var percentage = UnitValue.parse(weight).toPercentage();
2550
+ var percentage = UnitValue.parse(weight).toNumber();
2546
2551
  var handle = percentage > 0 ? shadeColor(color, percentage) : tintColor(color, -percentage);
2547
2552
  return handle(t);
2548
2553
  });
@@ -3662,7 +3667,7 @@ function useModifier(name, props, ref) {
3662
3667
  }
3663
3668
 
3664
3669
  var _excluded$1p = ["toggle", "dismiss"],
3665
- _excluded2$2 = ["ref"];
3670
+ _excluded2$3 = ["ref"];
3666
3671
 
3667
3672
  var getActionHook = function getActionHook(toggle, dismiss) {
3668
3673
  if (toggle) {
@@ -3693,7 +3698,7 @@ function useAction(props, ref) {
3693
3698
 
3694
3699
  var _useActionHook = useActionHook(restProps),
3695
3700
  actionRef = _useActionHook.ref,
3696
- actionProps = _objectWithoutProperties(_useActionHook, _excluded2$2);
3701
+ actionProps = _objectWithoutProperties(_useActionHook, _excluded2$3);
3697
3702
 
3698
3703
  return [actionProps, concatRefs(actionRef, ref)];
3699
3704
  }
@@ -6524,7 +6529,7 @@ Popover.Header = PopoverHeader;
6524
6529
  Popover.Body = PopoverBody;
6525
6530
 
6526
6531
  var _excluded$M = ["title", "content", "autoClose", "trigger", "placement"],
6527
- _excluded2$1 = ["popover"];
6532
+ _excluded2$2 = ["popover"];
6528
6533
  var propTypes$O = {
6529
6534
  popover: PropTypes__default["default"].shape(_objectSpread2({
6530
6535
  title: PropTypes__default["default"].node,
@@ -6545,7 +6550,7 @@ function injectPopover(Target) {
6545
6550
  _props$popover$placem = _props$popover.placement,
6546
6551
  placement = _props$popover$placem === void 0 ? 'right' : _props$popover$placem,
6547
6552
  tooltipProps = _objectWithoutProperties(_props$popover, _excluded$M),
6548
- elementProps = _objectWithoutProperties(props, _excluded2$1);
6553
+ elementProps = _objectWithoutProperties(props, _excluded2$2);
6549
6554
  /* eslint-enable */
6550
6555
 
6551
6556
 
@@ -6721,7 +6726,7 @@ Tooltip.Arrow = TooltipArrow;
6721
6726
  Tooltip.Inner = TooltipInner;
6722
6727
 
6723
6728
  var _excluded$I = ["title", "autoClose", "trigger", "placement"],
6724
- _excluded2 = ["tooltip"];
6729
+ _excluded2$1 = ["tooltip"];
6725
6730
  var propTypes$K = {
6726
6731
  tooltip: PropTypes__default["default"].shape(_objectSpread2({
6727
6732
  title: PropTypes__default["default"].node.isRequired,
@@ -6740,7 +6745,7 @@ function injectTooltip(Target) {
6740
6745
  _props$tooltip$placem = _props$tooltip.placement,
6741
6746
  placement = _props$tooltip$placem === void 0 ? 'top' : _props$tooltip$placem,
6742
6747
  tooltipProps = _objectWithoutProperties(_props$tooltip, _excluded$I),
6743
- elementProps = _objectWithoutProperties(props, _excluded2);
6748
+ elementProps = _objectWithoutProperties(props, _excluded2$1);
6744
6749
  /* eslint-enable */
6745
6750
 
6746
6751
 
@@ -7033,11 +7038,14 @@ ListGroup.propTypes = propTypes$F;
7033
7038
  ListGroup.Item = ListGroupItem;
7034
7039
  ListGroup.ItemAction = ListGroupItemAction;
7035
7040
 
7036
- var _excluded$C = ["children", "style"];
7041
+ var _excluded$C = ["children", "onHoverIn", "onHoverOut", "onMouseEnter", "onMouseLeave", "style"],
7042
+ _excluded2 = ["onHoverIn", "onHoverOut"];
7037
7043
 
7038
7044
  var _templateObject$w;
7039
7045
  var propTypes$E = {
7040
7046
  children: PropTypes__default["default"].node.isRequired,
7047
+ onMouseEnter: PropTypes__default["default"].func,
7048
+ onMouseLeave: PropTypes__default["default"].func,
7041
7049
  // eslint-disable-next-line react/forbid-prop-types
7042
7050
  style: PropTypes__default["default"].any
7043
7051
  };
@@ -7055,7 +7063,13 @@ var Link = /*#__PURE__*/React__default["default"].forwardRef(function (props, re
7055
7063
  actionProps = _useAction2[0],
7056
7064
  actionRef = _useAction2[1];
7057
7065
 
7058
- var children = actionProps.children,
7066
+ var children = actionProps.children;
7067
+ actionProps.onHoverIn;
7068
+ actionProps.onHoverOut;
7069
+ var _actionProps$onMouseE = actionProps.onMouseEnter,
7070
+ handleMouseEnter = _actionProps$onMouseE === void 0 ? function () {} : _actionProps$onMouseE,
7071
+ _actionProps$onMouseL = actionProps.onMouseLeave,
7072
+ handleMouseLeave = _actionProps$onMouseL === void 0 ? function () {} : _actionProps$onMouseL,
7059
7073
  style = actionProps.style,
7060
7074
  elementProps = _objectWithoutProperties(actionProps, _excluded$C);
7061
7075
 
@@ -7065,9 +7079,20 @@ var Link = /*#__PURE__*/React__default["default"].forwardRef(function (props, re
7065
7079
 
7066
7080
  var _useInteractionState = useInteractionState(elementProps),
7067
7081
  interaction = _useInteractionState.interaction,
7068
- interactionProps = _useInteractionState.interactionProps;
7082
+ _useInteractionState$ = _useInteractionState.interactionProps,
7083
+ handleMouseEnterInteraction = _useInteractionState$.onHoverIn,
7084
+ handleMouseLeaveInteraction = _useInteractionState$.onHoverOut,
7085
+ interactionProps = _objectWithoutProperties(_useInteractionState$, _excluded2);
7069
7086
 
7070
7087
  return /*#__PURE__*/React__default["default"].createElement(Text, _extends({}, elementProps, interactionProps, {
7088
+ onMouseEnter: function onMouseEnter(event) {
7089
+ handleMouseEnter(event);
7090
+ handleMouseEnterInteraction(event);
7091
+ },
7092
+ onMouseLeave: function onMouseLeave(event) {
7093
+ handleMouseLeave(event);
7094
+ handleMouseLeaveInteraction(event);
7095
+ },
7071
7096
  ref: actionRef,
7072
7097
  accessibilityRole: getRole$2(actionProps),
7073
7098
  accessible: true,
@@ -669,23 +669,10 @@ var UnitValue = /*#__PURE__*/function () {
669
669
  }
670
670
 
671
671
  _createClass(UnitValue, [{
672
- key: "toPercentage",
673
- value: function toPercentage() {
674
- if (!['number', 'percent'].includes(this.unit)) {
675
- throw new Error("Unexpected unit \"".concat(this.unit, "\"."));
676
- }
677
-
678
- if (this.unit === 'percent') {
679
- return this.value / 100;
680
- }
681
-
682
- return this.value;
683
- }
684
- }, {
685
672
  key: "toNumber",
686
673
  value: function toNumber() {
687
- if (!['number', 'px', 'rem'].includes(this.unit)) {
688
- throw new Error("Unexpected unit \"".concat(this.unit, "\"."));
674
+ if (this.unit === 'percent') {
675
+ return this.value / 100;
689
676
  }
690
677
 
691
678
  if (this.unit === 'rem') {
@@ -697,7 +684,15 @@ var UnitValue = /*#__PURE__*/function () {
697
684
  }, {
698
685
  key: "toString",
699
686
  value: function toString() {
700
- return "".concat(this.value).concat(this.unit === 'number' ? '' : this.unit);
687
+ if (this.unit === 'number') {
688
+ return this.value;
689
+ }
690
+
691
+ if (this.unit === 'percent') {
692
+ return "".concat(this.value, "%");
693
+ }
694
+
695
+ return "".concat(this.value).concat(this.unit);
701
696
  }
702
697
  }], [{
703
698
  key: "parse",
@@ -724,12 +719,28 @@ var UnitValue = /*#__PURE__*/function () {
724
719
  }();
725
720
 
726
721
  var POWER = Math.pow(10, 8);
722
+ var UNIT_ORDER = ['percent', 'number', 'px', 'rem'];
727
723
 
728
724
  var fixRounding = function fixRounding(value) {
729
725
  return Math.round(value * POWER) / POWER;
730
726
  };
731
727
 
732
- var calculateValue = function calculateValue(value1, operator, value2) {
728
+ var normalizeValue$1 = function normalizeValue(number1, number2) {
729
+ if (number1.unit === 'px' && number2.unit === 'rem') {
730
+ return number1.value / (PixelRatio.getFontScale() * 16);
731
+ }
732
+
733
+ if (number1.unit === 'percent' && number2.unit !== 'percent') {
734
+ return number1.value / 100;
735
+ }
736
+
737
+ return number1.value;
738
+ };
739
+
740
+ var calculateValue = function calculateValue(number1, operator, number2) {
741
+ var value1 = normalizeValue$1(number1, number2);
742
+ var value2 = normalizeValue$1(number2, number1);
743
+
733
744
  switch (operator) {
734
745
  case '+':
735
746
  return value1 + value2;
@@ -751,24 +762,18 @@ var calculateValue = function calculateValue(value1, operator, value2) {
751
762
  }
752
763
  };
753
764
 
754
- var pxToRem = function pxToRem(value) {
755
- return value / (PixelRatio.getFontScale() * 16);
765
+ var determineUnit = function determineUnit(number1, number2) {
766
+ var index1 = UNIT_ORDER.indexOf(number1.unit);
767
+ var index2 = UNIT_ORDER.indexOf(number2.unit);
768
+ return index1 > index2 ? number1.unit : number2.unit;
756
769
  };
757
770
 
758
771
  function calculate(value1, operator, value2) {
759
772
  var number1 = UnitValue.parse(value1);
760
773
  var number2 = UnitValue.parse(value2);
761
-
762
- if (number1.unit === 'px' && number2.unit === 'rem') {
763
- return "".concat(calculateValue(pxToRem(number1.value), operator, number2.value), "rem");
764
- }
765
-
766
- if (number1.unit === 'rem' && number2.unit === 'px') {
767
- return "".concat(calculateValue(number1.value, operator, pxToRem(number2.value)), "rem");
768
- }
769
-
770
- var unit = number1.unit === 'number' ? number2.unit : number1.unit;
771
- return "".concat(calculateValue(number1.value, operator, number2.value)).concat(unit === 'number' ? '' : unit);
774
+ var value = calculateValue(number1, operator, number2);
775
+ var unit = determineUnit(number1, number2);
776
+ return new UnitValue(value, unit).toString();
772
777
  }
773
778
  function normalizeNumber(value) {
774
779
  return UnitValue.parse(value).toNumber();
@@ -1074,7 +1079,7 @@ function mix(color1, color2) {
1074
1079
  var weight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
1075
1080
  var rgb1 = RgbaValue.parse(color1).toRgb();
1076
1081
  var rgb2 = RgbaValue.parse(color2).toRgb();
1077
- var percentage = UnitValue.parse(weight).toPercentage();
1082
+ var percentage = UnitValue.parse(weight).toNumber();
1078
1083
 
1079
1084
  var _rgb1$map = rgb1.map(function (value, key) {
1080
1085
  return Math.round(rgb2[key] + (value - rgb2[key]) * percentage);
@@ -2533,7 +2538,7 @@ var shiftColor = fn(function (_ref9, t) {
2533
2538
  color = _ref10[0],
2534
2539
  weight = _ref10[1];
2535
2540
 
2536
- var percentage = UnitValue.parse(weight).toPercentage();
2541
+ var percentage = UnitValue.parse(weight).toNumber();
2537
2542
  var handle = percentage > 0 ? shadeColor(color, percentage) : tintColor(color, -percentage);
2538
2543
  return handle(t);
2539
2544
  });
@@ -3653,7 +3658,7 @@ function useModifier(name, props, ref) {
3653
3658
  }
3654
3659
 
3655
3660
  var _excluded$1p = ["toggle", "dismiss"],
3656
- _excluded2$2 = ["ref"];
3661
+ _excluded2$3 = ["ref"];
3657
3662
 
3658
3663
  var getActionHook = function getActionHook(toggle, dismiss) {
3659
3664
  if (toggle) {
@@ -3684,7 +3689,7 @@ function useAction(props, ref) {
3684
3689
 
3685
3690
  var _useActionHook = useActionHook(restProps),
3686
3691
  actionRef = _useActionHook.ref,
3687
- actionProps = _objectWithoutProperties(_useActionHook, _excluded2$2);
3692
+ actionProps = _objectWithoutProperties(_useActionHook, _excluded2$3);
3688
3693
 
3689
3694
  return [actionProps, concatRefs(actionRef, ref)];
3690
3695
  }
@@ -6515,7 +6520,7 @@ Popover.Header = PopoverHeader;
6515
6520
  Popover.Body = PopoverBody;
6516
6521
 
6517
6522
  var _excluded$M = ["title", "content", "autoClose", "trigger", "placement"],
6518
- _excluded2$1 = ["popover"];
6523
+ _excluded2$2 = ["popover"];
6519
6524
  var propTypes$O = {
6520
6525
  popover: PropTypes.shape(_objectSpread2({
6521
6526
  title: PropTypes.node,
@@ -6536,7 +6541,7 @@ function injectPopover(Target) {
6536
6541
  _props$popover$placem = _props$popover.placement,
6537
6542
  placement = _props$popover$placem === void 0 ? 'right' : _props$popover$placem,
6538
6543
  tooltipProps = _objectWithoutProperties(_props$popover, _excluded$M),
6539
- elementProps = _objectWithoutProperties(props, _excluded2$1);
6544
+ elementProps = _objectWithoutProperties(props, _excluded2$2);
6540
6545
  /* eslint-enable */
6541
6546
 
6542
6547
 
@@ -6712,7 +6717,7 @@ Tooltip.Arrow = TooltipArrow;
6712
6717
  Tooltip.Inner = TooltipInner;
6713
6718
 
6714
6719
  var _excluded$I = ["title", "autoClose", "trigger", "placement"],
6715
- _excluded2 = ["tooltip"];
6720
+ _excluded2$1 = ["tooltip"];
6716
6721
  var propTypes$K = {
6717
6722
  tooltip: PropTypes.shape(_objectSpread2({
6718
6723
  title: PropTypes.node.isRequired,
@@ -6731,7 +6736,7 @@ function injectTooltip(Target) {
6731
6736
  _props$tooltip$placem = _props$tooltip.placement,
6732
6737
  placement = _props$tooltip$placem === void 0 ? 'top' : _props$tooltip$placem,
6733
6738
  tooltipProps = _objectWithoutProperties(_props$tooltip, _excluded$I),
6734
- elementProps = _objectWithoutProperties(props, _excluded2);
6739
+ elementProps = _objectWithoutProperties(props, _excluded2$1);
6735
6740
  /* eslint-enable */
6736
6741
 
6737
6742
 
@@ -7024,11 +7029,14 @@ ListGroup.propTypes = propTypes$F;
7024
7029
  ListGroup.Item = ListGroupItem;
7025
7030
  ListGroup.ItemAction = ListGroupItemAction;
7026
7031
 
7027
- var _excluded$C = ["children", "style"];
7032
+ var _excluded$C = ["children", "onHoverIn", "onHoverOut", "onMouseEnter", "onMouseLeave", "style"],
7033
+ _excluded2 = ["onHoverIn", "onHoverOut"];
7028
7034
 
7029
7035
  var _templateObject$w;
7030
7036
  var propTypes$E = {
7031
7037
  children: PropTypes.node.isRequired,
7038
+ onMouseEnter: PropTypes.func,
7039
+ onMouseLeave: PropTypes.func,
7032
7040
  // eslint-disable-next-line react/forbid-prop-types
7033
7041
  style: PropTypes.any
7034
7042
  };
@@ -7046,7 +7054,13 @@ var Link = /*#__PURE__*/React.forwardRef(function (props, ref) {
7046
7054
  actionProps = _useAction2[0],
7047
7055
  actionRef = _useAction2[1];
7048
7056
 
7049
- var children = actionProps.children,
7057
+ var children = actionProps.children;
7058
+ actionProps.onHoverIn;
7059
+ actionProps.onHoverOut;
7060
+ var _actionProps$onMouseE = actionProps.onMouseEnter,
7061
+ handleMouseEnter = _actionProps$onMouseE === void 0 ? function () {} : _actionProps$onMouseE,
7062
+ _actionProps$onMouseL = actionProps.onMouseLeave,
7063
+ handleMouseLeave = _actionProps$onMouseL === void 0 ? function () {} : _actionProps$onMouseL,
7050
7064
  style = actionProps.style,
7051
7065
  elementProps = _objectWithoutProperties(actionProps, _excluded$C);
7052
7066
 
@@ -7056,9 +7070,20 @@ var Link = /*#__PURE__*/React.forwardRef(function (props, ref) {
7056
7070
 
7057
7071
  var _useInteractionState = useInteractionState(elementProps),
7058
7072
  interaction = _useInteractionState.interaction,
7059
- interactionProps = _useInteractionState.interactionProps;
7073
+ _useInteractionState$ = _useInteractionState.interactionProps,
7074
+ handleMouseEnterInteraction = _useInteractionState$.onHoverIn,
7075
+ handleMouseLeaveInteraction = _useInteractionState$.onHoverOut,
7076
+ interactionProps = _objectWithoutProperties(_useInteractionState$, _excluded2);
7060
7077
 
7061
7078
  return /*#__PURE__*/React.createElement(Text, _extends({}, elementProps, interactionProps, {
7079
+ onMouseEnter: function onMouseEnter(event) {
7080
+ handleMouseEnter(event);
7081
+ handleMouseEnterInteraction(event);
7082
+ },
7083
+ onMouseLeave: function onMouseLeave(event) {
7084
+ handleMouseLeave(event);
7085
+ handleMouseLeaveInteraction(event);
7086
+ },
7062
7087
  ref: actionRef,
7063
7088
  accessibilityRole: getRole$2(actionProps),
7064
7089
  accessible: true,