@hero-design/rn 8.83.0 → 8.84.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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +6 -0
- package/es/index.js +107 -49
- package/lib/index.js +107 -49
- package/package.json +1 -1
- package/src/components/Button/Button.tsx +73 -26
- package/src/components/Button/StyledButton.tsx +137 -48
- package/src/components/Button/UtilityButton/StyledUtilityButton.tsx +1 -1
- package/src/components/Button/__tests__/Button.spec.tsx +39 -31
- package/src/components/Button/__tests__/StyledButton.spec.tsx +52 -0
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +774 -0
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +489 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +14 -4
- package/src/theme/components/button.ts +14 -4
- package/stats/8.84.0/rn-stats.html +4842 -0
- package/types/components/Button/Button.d.ts +2 -2
- package/types/components/Button/StyledButton.d.ts +11 -1
- package/types/theme/components/button.d.ts +14 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(node:
|
|
1
|
+
(node:2999) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
|
|
2
2
|
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
3
3
|
[36m
|
|
4
4
|
[1msrc/index.ts[22m → [1mlib/index.js, es/index.js[22m...[39m
|
|
5
5
|
[1m[33m(!) [plugin replace] @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.[39m[22m
|
|
6
6
|
[1m[33m(!) [plugin node-resolve] preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.[39m[22m
|
|
7
|
-
[32mcreated [1mlib/index.js, es/index.js[22m in [
|
|
7
|
+
[32mcreated [1mlib/index.js, es/index.js[22m in [1m52.3s[22m[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
+
## 8.84.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#3571](https://github.com/Thinkei/hero-design/pull/3571) [`8326368063b84b3279fdabd6af1de088abed1deb`](https://github.com/Thinkei/hero-design/commit/8326368063b84b3279fdabd6af1de088abed1deb) Thanks [@phucdph](https://github.com/phucdph)! - [Button] Support compact variant
|
|
8
|
+
|
|
3
9
|
## 8.83.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/es/index.js
CHANGED
|
@@ -2484,13 +2484,23 @@ var getButtonTheme = function getButtonTheme(theme) {
|
|
|
2484
2484
|
"default": theme.space.xxsmall
|
|
2485
2485
|
};
|
|
2486
2486
|
var space = {
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2487
|
+
"default": {
|
|
2488
|
+
buttonPadding: theme.space.medium,
|
|
2489
|
+
iconPadding: theme.space.smallMedium,
|
|
2490
|
+
textButtonPadding: theme.space.smallMedium
|
|
2491
|
+
},
|
|
2492
|
+
compact: {
|
|
2493
|
+
buttonPaddingVertical: theme.space.small,
|
|
2494
|
+
buttonPaddingHorizontal: theme.space.medium,
|
|
2495
|
+
iconPadding: theme.space.small
|
|
2496
|
+
},
|
|
2490
2497
|
utilityPadding: theme.space.small
|
|
2491
2498
|
};
|
|
2492
2499
|
var sizes = {
|
|
2493
|
-
iconSize:
|
|
2500
|
+
iconSize: {
|
|
2501
|
+
"default": theme.fontSizes.xxlarge,
|
|
2502
|
+
compact: theme.fontSizes.small
|
|
2503
|
+
}
|
|
2494
2504
|
};
|
|
2495
2505
|
var radii = {
|
|
2496
2506
|
"default": theme.radii['5xlarge'],
|
|
@@ -9634,7 +9644,15 @@ var LoadingIndicator = function LoadingIndicator(_ref2) {
|
|
|
9634
9644
|
}, nativeProps), Array.from(new Array(count), renderLoadingDot, themeVariant));
|
|
9635
9645
|
};
|
|
9636
9646
|
|
|
9637
|
-
var
|
|
9647
|
+
var getButtonHeight = function getButtonHeight(themeIsCompact) {
|
|
9648
|
+
switch (themeIsCompact) {
|
|
9649
|
+
case true:
|
|
9650
|
+
return scale(36);
|
|
9651
|
+
default:
|
|
9652
|
+
return scale(60);
|
|
9653
|
+
}
|
|
9654
|
+
};
|
|
9655
|
+
var genFilledContainerStyles = function genFilledContainerStyles(theme, intent, disabled, loading, compact) {
|
|
9638
9656
|
var backgroundColorStyling = function backgroundColorStyling() {
|
|
9639
9657
|
if (!loading && disabled) {
|
|
9640
9658
|
return {
|
|
@@ -9645,17 +9663,23 @@ var genFilledContainerStyles = function genFilledContainerStyles(theme, intent,
|
|
|
9645
9663
|
backgroundColor: theme.__hd__.button.colors[intent]
|
|
9646
9664
|
};
|
|
9647
9665
|
};
|
|
9648
|
-
return _objectSpread2({
|
|
9649
|
-
height:
|
|
9666
|
+
return _objectSpread2(_objectSpread2({
|
|
9667
|
+
height: getButtonHeight(compact),
|
|
9650
9668
|
flexDirection: 'row',
|
|
9651
9669
|
justifyContent: 'center',
|
|
9652
|
-
alignItems: 'center'
|
|
9670
|
+
alignItems: 'center'
|
|
9671
|
+
}, compact ? {
|
|
9672
|
+
alignSelf: 'flex-start',
|
|
9673
|
+
paddingVertical: theme.__hd__.button.space.compact.buttonPaddingVertical,
|
|
9674
|
+
paddingHorizontal: theme.__hd__.button.space["default"].buttonPadding
|
|
9675
|
+
} : {
|
|
9653
9676
|
alignSelf: 'stretch',
|
|
9654
|
-
padding: theme.__hd__.button.space.buttonPadding
|
|
9677
|
+
padding: theme.__hd__.button.space["default"].buttonPadding
|
|
9678
|
+
}), {}, {
|
|
9655
9679
|
borderRadius: theme.__hd__.button.radii["default"]
|
|
9656
9680
|
}, backgroundColorStyling());
|
|
9657
9681
|
};
|
|
9658
|
-
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled, loading) {
|
|
9682
|
+
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled, loading, compact) {
|
|
9659
9683
|
var borderColorStyling = function borderColorStyling() {
|
|
9660
9684
|
if (!loading && disabled) {
|
|
9661
9685
|
return {
|
|
@@ -9666,13 +9690,19 @@ var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent
|
|
|
9666
9690
|
borderColor: theme.__hd__.button.colors[intent]
|
|
9667
9691
|
};
|
|
9668
9692
|
};
|
|
9669
|
-
return _objectSpread2({
|
|
9670
|
-
height:
|
|
9693
|
+
return _objectSpread2(_objectSpread2({
|
|
9694
|
+
height: getButtonHeight(compact),
|
|
9671
9695
|
flexDirection: 'row',
|
|
9672
9696
|
justifyContent: 'center',
|
|
9673
|
-
alignItems: 'center'
|
|
9697
|
+
alignItems: 'center'
|
|
9698
|
+
}, compact ? {
|
|
9699
|
+
alignSelf: 'flex-start',
|
|
9700
|
+
paddingVertical: theme.__hd__.button.space.compact.buttonPaddingVertical - theme.__hd__.button.borderWidth["default"],
|
|
9701
|
+
paddingHorizontal: theme.__hd__.button.space["default"].buttonPadding - theme.__hd__.button.borderWidth["default"]
|
|
9702
|
+
} : {
|
|
9674
9703
|
alignSelf: 'stretch',
|
|
9675
|
-
padding: theme.__hd__.button.space.buttonPadding - theme.__hd__.button.borderWidth["default"]
|
|
9704
|
+
padding: theme.__hd__.button.space["default"].buttonPadding - theme.__hd__.button.borderWidth["default"]
|
|
9705
|
+
}), {}, {
|
|
9676
9706
|
borderWidth: theme.__hd__.button.borderWidth["default"],
|
|
9677
9707
|
borderRadius: theme.__hd__.button.radii["default"],
|
|
9678
9708
|
backgroundColor: 'transparent'
|
|
@@ -9699,31 +9729,34 @@ var StyledButtonContainer = index$a(TouchableHighlight)(function (_ref) {
|
|
|
9699
9729
|
_ref$loading = _ref.loading,
|
|
9700
9730
|
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
9701
9731
|
themeButtonVariant = _ref.themeButtonVariant,
|
|
9702
|
-
themeInlineText = _ref.themeInlineText,
|
|
9703
|
-
|
|
9732
|
+
_ref$themeInlineText = _ref.themeInlineText,
|
|
9733
|
+
themeInlineText = _ref$themeInlineText === void 0 ? false : _ref$themeInlineText,
|
|
9734
|
+
theme = _ref.theme,
|
|
9735
|
+
_ref$themeIsCompact = _ref.themeIsCompact,
|
|
9736
|
+
themeIsCompact = _ref$themeIsCompact === void 0 ? false : _ref$themeIsCompact;
|
|
9704
9737
|
switch (themeButtonVariant) {
|
|
9705
9738
|
case 'filled-primary':
|
|
9706
|
-
return genFilledContainerStyles(theme, 'primary', disabled, loading);
|
|
9739
|
+
return genFilledContainerStyles(theme, 'primary', disabled, loading, themeIsCompact);
|
|
9707
9740
|
case 'filled-secondary':
|
|
9708
|
-
return genFilledContainerStyles(theme, 'secondary', disabled, loading);
|
|
9741
|
+
return genFilledContainerStyles(theme, 'secondary', disabled, loading, themeIsCompact);
|
|
9709
9742
|
case 'filled-danger':
|
|
9710
|
-
return genFilledContainerStyles(theme, 'danger', disabled, loading);
|
|
9743
|
+
return genFilledContainerStyles(theme, 'danger', disabled, loading, themeIsCompact);
|
|
9711
9744
|
case 'outlined-primary':
|
|
9712
|
-
return genOutlineContainerStyles(theme, 'primary', disabled, loading);
|
|
9745
|
+
return genOutlineContainerStyles(theme, 'primary', disabled, loading, themeIsCompact);
|
|
9713
9746
|
case 'outlined-secondary':
|
|
9714
|
-
return genOutlineContainerStyles(theme, 'secondary', disabled, loading);
|
|
9747
|
+
return genOutlineContainerStyles(theme, 'secondary', disabled, loading, themeIsCompact);
|
|
9715
9748
|
case 'outlined-danger':
|
|
9716
|
-
return genOutlineContainerStyles(theme, 'danger', disabled, loading);
|
|
9749
|
+
return genOutlineContainerStyles(theme, 'danger', disabled, loading, themeIsCompact);
|
|
9717
9750
|
case 'text-primary':
|
|
9718
9751
|
case 'text-secondary':
|
|
9719
9752
|
case 'text-danger':
|
|
9720
9753
|
return {
|
|
9721
|
-
height: themeInlineText ? undefined :
|
|
9754
|
+
height: themeInlineText ? undefined : getButtonHeight(themeIsCompact),
|
|
9722
9755
|
borderRadius: theme.__hd__.button.radii.text,
|
|
9723
9756
|
flexDirection: 'row',
|
|
9724
9757
|
justifyContent: 'center',
|
|
9725
9758
|
alignItems: 'center',
|
|
9726
|
-
padding: themeInlineText ? 0 : theme.__hd__.button.space.textButtonPadding,
|
|
9759
|
+
padding: themeInlineText ? 0 : theme.__hd__.button.space["default"].textButtonPadding,
|
|
9727
9760
|
borderWidth: 0,
|
|
9728
9761
|
backgroundColor: loading && !themeInlineText ? theme.__hd__.button.colors.textLoadingBackground : 'transparent'
|
|
9729
9762
|
};
|
|
@@ -9760,6 +9793,7 @@ var StyledButtonText = index$a(Typography.Title)(function (_ref2) {
|
|
|
9760
9793
|
textAlign: 'center'
|
|
9761
9794
|
}, themeStyling());
|
|
9762
9795
|
});
|
|
9796
|
+
var StyledSmallButtonText = StyledButtonText.withComponent(Typography.Body);
|
|
9763
9797
|
var StyledButtonTitleOfVariantText = index$a(Typography.Body)(function (_ref3) {
|
|
9764
9798
|
var disabled = _ref3.disabled,
|
|
9765
9799
|
themeButtonVariant = _ref3.themeButtonVariant,
|
|
@@ -9784,15 +9818,16 @@ var StyledButtonTitleOfVariantText = index$a(Typography.Body)(function (_ref3) {
|
|
|
9784
9818
|
});
|
|
9785
9819
|
var StyledButtonIconWrapper = index$a(View)(function (_ref4) {
|
|
9786
9820
|
var themePosition = _ref4.themePosition,
|
|
9787
|
-
theme = _ref4.theme
|
|
9821
|
+
theme = _ref4.theme,
|
|
9822
|
+
themeIsCompact = _ref4.themeIsCompact;
|
|
9788
9823
|
switch (themePosition) {
|
|
9789
9824
|
case 'left':
|
|
9790
9825
|
return {
|
|
9791
|
-
paddingRight: theme.__hd__.button.space.iconPadding
|
|
9826
|
+
paddingRight: themeIsCompact ? theme.__hd__.button.space.compact.iconPadding : theme.__hd__.button.space["default"].iconPadding
|
|
9792
9827
|
};
|
|
9793
9828
|
case 'right':
|
|
9794
9829
|
return {
|
|
9795
|
-
paddingLeft: theme.__hd__.button.space.iconPadding
|
|
9830
|
+
paddingLeft: themeIsCompact ? theme.__hd__.button.space.compact.iconPadding : theme.__hd__.button.space["default"].iconPadding
|
|
9796
9831
|
};
|
|
9797
9832
|
}
|
|
9798
9833
|
});
|
|
@@ -9800,7 +9835,8 @@ var StyledButtonIcon = index$a(Icon)(function (_ref5) {
|
|
|
9800
9835
|
var disabled = _ref5.disabled,
|
|
9801
9836
|
themeButtonVariant = _ref5.themeButtonVariant,
|
|
9802
9837
|
themeIsPressed = _ref5.themeIsPressed,
|
|
9803
|
-
theme = _ref5.theme
|
|
9838
|
+
theme = _ref5.theme,
|
|
9839
|
+
themeIsCompact = _ref5.themeIsCompact;
|
|
9804
9840
|
var themeStyling = function themeStyling() {
|
|
9805
9841
|
switch (themeButtonVariant) {
|
|
9806
9842
|
case 'filled-primary':
|
|
@@ -9824,7 +9860,7 @@ var StyledButtonIcon = index$a(Icon)(function (_ref5) {
|
|
|
9824
9860
|
}
|
|
9825
9861
|
};
|
|
9826
9862
|
return _objectSpread2({
|
|
9827
|
-
fontSize: theme.__hd__.button.sizes.iconSize
|
|
9863
|
+
fontSize: themeIsCompact ? theme.__hd__.button.sizes.iconSize.compact : theme.__hd__.button.sizes.iconSize["default"]
|
|
9828
9864
|
}, themeStyling());
|
|
9829
9865
|
});
|
|
9830
9866
|
|
|
@@ -9849,8 +9885,10 @@ var TEXT_VARIANTS = {
|
|
|
9849
9885
|
var getThemeVariant = function getThemeVariant(variant, intent) {
|
|
9850
9886
|
switch (variant) {
|
|
9851
9887
|
case 'filled':
|
|
9888
|
+
case 'filled-compact':
|
|
9852
9889
|
return FILLED_VARIANTS[intent];
|
|
9853
9890
|
case 'outlined':
|
|
9891
|
+
case 'outlined-compact':
|
|
9854
9892
|
return OUTLINED_VARIANTS[intent];
|
|
9855
9893
|
case 'text':
|
|
9856
9894
|
return TEXT_VARIANTS[intent];
|
|
@@ -9910,6 +9948,34 @@ var Button = function Button(_ref) {
|
|
|
9910
9948
|
isPressed = _useState2[0],
|
|
9911
9949
|
setIsPressed = _useState2[1];
|
|
9912
9950
|
useDeprecation("Button variant ".concat(deprecatedVariants.join(', '), " are deprecated."), deprecatedVariants.includes(themeVariant));
|
|
9951
|
+
var isCompactVariant = ['filled-compact', 'outlined-compact'].includes(variant);
|
|
9952
|
+
var isRenderTextVariant = isTextVariant(themeVariant);
|
|
9953
|
+
var renderTextVariantTitle = function renderTextVariantTitle() {
|
|
9954
|
+
if (!isRenderTextVariant) return null;
|
|
9955
|
+
return /*#__PURE__*/React__default.createElement(StyledButtonTitleOfVariantText, {
|
|
9956
|
+
variant: isCompactVariant ? 'small-bold' : 'regular-bold',
|
|
9957
|
+
ellipsizeMode: "tail",
|
|
9958
|
+
numberOfLines: 1,
|
|
9959
|
+
disabled: disabled,
|
|
9960
|
+
themeButtonVariant: themeVariant,
|
|
9961
|
+
themeIsPressed: isPressed
|
|
9962
|
+
}, text);
|
|
9963
|
+
};
|
|
9964
|
+
var renderTitle = function renderTitle() {
|
|
9965
|
+
return isCompactVariant ? /*#__PURE__*/React__default.createElement(StyledSmallButtonText, {
|
|
9966
|
+
variant: "small",
|
|
9967
|
+
ellipsizeMode: "tail",
|
|
9968
|
+
numberOfLines: 1,
|
|
9969
|
+
disabled: disabled,
|
|
9970
|
+
themeButtonVariant: themeVariant
|
|
9971
|
+
}, text) : /*#__PURE__*/React__default.createElement(StyledButtonText, {
|
|
9972
|
+
level: "h5",
|
|
9973
|
+
ellipsizeMode: "tail",
|
|
9974
|
+
numberOfLines: 1,
|
|
9975
|
+
disabled: disabled,
|
|
9976
|
+
themeButtonVariant: themeVariant
|
|
9977
|
+
}, text);
|
|
9978
|
+
};
|
|
9913
9979
|
return /*#__PURE__*/React__default.createElement(StyledButtonContainer, {
|
|
9914
9980
|
accessibilityHint: accessibilityHint,
|
|
9915
9981
|
accessibilityLabel: accessibilityLabel,
|
|
@@ -9926,39 +9992,31 @@ var Button = function Button(_ref) {
|
|
|
9926
9992
|
},
|
|
9927
9993
|
onPressOut: function onPressOut() {
|
|
9928
9994
|
return isInlineText && setIsPressed(false);
|
|
9929
|
-
}
|
|
9995
|
+
},
|
|
9996
|
+
themeIsCompact: isCompactVariant
|
|
9930
9997
|
}, loading === true ? /*#__PURE__*/React__default.createElement(LoadingIndicator, {
|
|
9931
9998
|
testID: "".concat(testID, "-loading-indicator"),
|
|
9932
9999
|
themeVariant: themeVariant
|
|
9933
10000
|
}) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, icon !== undefined && /*#__PURE__*/React__default.createElement(StyledButtonIconWrapper, {
|
|
9934
|
-
themePosition: "left"
|
|
10001
|
+
themePosition: "left",
|
|
10002
|
+
themeIsCompact: isCompactVariant
|
|
9935
10003
|
}, isIconName(icon) ? /*#__PURE__*/React__default.createElement(StyledButtonIcon, {
|
|
9936
10004
|
disabled: disabled,
|
|
9937
10005
|
icon: icon,
|
|
9938
10006
|
testID: "".concat(testID, "-left-icon"),
|
|
9939
10007
|
themeButtonVariant: themeVariant,
|
|
9940
|
-
themeIsPressed: isPressed
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
disabled: disabled,
|
|
9946
|
-
themeButtonVariant: themeVariant,
|
|
9947
|
-
themeIsPressed: isPressed
|
|
9948
|
-
}, text) : /*#__PURE__*/React__default.createElement(StyledButtonText, {
|
|
9949
|
-
level: "h5",
|
|
9950
|
-
ellipsizeMode: "tail",
|
|
9951
|
-
numberOfLines: 1,
|
|
9952
|
-
disabled: disabled,
|
|
9953
|
-
themeButtonVariant: themeVariant
|
|
9954
|
-
}, text), rightIcon !== undefined && /*#__PURE__*/React__default.createElement(StyledButtonIconWrapper, {
|
|
9955
|
-
themePosition: "right"
|
|
10008
|
+
themeIsPressed: isPressed,
|
|
10009
|
+
themeIsCompact: isCompactVariant
|
|
10010
|
+
}) : icon), isRenderTextVariant ? renderTextVariantTitle() : renderTitle(), rightIcon !== undefined && /*#__PURE__*/React__default.createElement(StyledButtonIconWrapper, {
|
|
10011
|
+
themePosition: "right",
|
|
10012
|
+
themeIsCompact: isCompactVariant
|
|
9956
10013
|
}, isIconName(rightIcon) ? /*#__PURE__*/React__default.createElement(StyledButtonIcon, {
|
|
9957
10014
|
disabled: disabled,
|
|
9958
10015
|
icon: rightIcon,
|
|
9959
10016
|
testID: "".concat(testID, "-right-icon"),
|
|
9960
10017
|
themeButtonVariant: themeVariant,
|
|
9961
|
-
themeIsPressed: isPressed
|
|
10018
|
+
themeIsPressed: isPressed,
|
|
10019
|
+
themeIsCompact: isCompactVariant
|
|
9962
10020
|
}) : rightIcon)));
|
|
9963
10021
|
};
|
|
9964
10022
|
|
|
@@ -9999,7 +10057,7 @@ var ButtonContainer = index$a(TouchableOpacity)(function (_ref) {
|
|
|
9999
10057
|
var IconWrapper = index$a(View)(function (_ref2) {
|
|
10000
10058
|
var theme = _ref2.theme;
|
|
10001
10059
|
return {
|
|
10002
|
-
paddingRight: theme.__hd__.button.space.iconPadding
|
|
10060
|
+
paddingRight: theme.__hd__.button.space["default"].iconPadding
|
|
10003
10061
|
};
|
|
10004
10062
|
});
|
|
10005
10063
|
var ButtonText = index$a(Typography.Body)({
|
package/lib/index.js
CHANGED
|
@@ -2512,13 +2512,23 @@ var getButtonTheme = function getButtonTheme(theme) {
|
|
|
2512
2512
|
"default": theme.space.xxsmall
|
|
2513
2513
|
};
|
|
2514
2514
|
var space = {
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2515
|
+
"default": {
|
|
2516
|
+
buttonPadding: theme.space.medium,
|
|
2517
|
+
iconPadding: theme.space.smallMedium,
|
|
2518
|
+
textButtonPadding: theme.space.smallMedium
|
|
2519
|
+
},
|
|
2520
|
+
compact: {
|
|
2521
|
+
buttonPaddingVertical: theme.space.small,
|
|
2522
|
+
buttonPaddingHorizontal: theme.space.medium,
|
|
2523
|
+
iconPadding: theme.space.small
|
|
2524
|
+
},
|
|
2518
2525
|
utilityPadding: theme.space.small
|
|
2519
2526
|
};
|
|
2520
2527
|
var sizes = {
|
|
2521
|
-
iconSize:
|
|
2528
|
+
iconSize: {
|
|
2529
|
+
"default": theme.fontSizes.xxlarge,
|
|
2530
|
+
compact: theme.fontSizes.small
|
|
2531
|
+
}
|
|
2522
2532
|
};
|
|
2523
2533
|
var radii = {
|
|
2524
2534
|
"default": theme.radii['5xlarge'],
|
|
@@ -9662,7 +9672,15 @@ var LoadingIndicator = function LoadingIndicator(_ref2) {
|
|
|
9662
9672
|
}, nativeProps), Array.from(new Array(count), renderLoadingDot, themeVariant));
|
|
9663
9673
|
};
|
|
9664
9674
|
|
|
9665
|
-
var
|
|
9675
|
+
var getButtonHeight = function getButtonHeight(themeIsCompact) {
|
|
9676
|
+
switch (themeIsCompact) {
|
|
9677
|
+
case true:
|
|
9678
|
+
return scale(36);
|
|
9679
|
+
default:
|
|
9680
|
+
return scale(60);
|
|
9681
|
+
}
|
|
9682
|
+
};
|
|
9683
|
+
var genFilledContainerStyles = function genFilledContainerStyles(theme, intent, disabled, loading, compact) {
|
|
9666
9684
|
var backgroundColorStyling = function backgroundColorStyling() {
|
|
9667
9685
|
if (!loading && disabled) {
|
|
9668
9686
|
return {
|
|
@@ -9673,17 +9691,23 @@ var genFilledContainerStyles = function genFilledContainerStyles(theme, intent,
|
|
|
9673
9691
|
backgroundColor: theme.__hd__.button.colors[intent]
|
|
9674
9692
|
};
|
|
9675
9693
|
};
|
|
9676
|
-
return _objectSpread2({
|
|
9677
|
-
height:
|
|
9694
|
+
return _objectSpread2(_objectSpread2({
|
|
9695
|
+
height: getButtonHeight(compact),
|
|
9678
9696
|
flexDirection: 'row',
|
|
9679
9697
|
justifyContent: 'center',
|
|
9680
|
-
alignItems: 'center'
|
|
9698
|
+
alignItems: 'center'
|
|
9699
|
+
}, compact ? {
|
|
9700
|
+
alignSelf: 'flex-start',
|
|
9701
|
+
paddingVertical: theme.__hd__.button.space.compact.buttonPaddingVertical,
|
|
9702
|
+
paddingHorizontal: theme.__hd__.button.space["default"].buttonPadding
|
|
9703
|
+
} : {
|
|
9681
9704
|
alignSelf: 'stretch',
|
|
9682
|
-
padding: theme.__hd__.button.space.buttonPadding
|
|
9705
|
+
padding: theme.__hd__.button.space["default"].buttonPadding
|
|
9706
|
+
}), {}, {
|
|
9683
9707
|
borderRadius: theme.__hd__.button.radii["default"]
|
|
9684
9708
|
}, backgroundColorStyling());
|
|
9685
9709
|
};
|
|
9686
|
-
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled, loading) {
|
|
9710
|
+
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled, loading, compact) {
|
|
9687
9711
|
var borderColorStyling = function borderColorStyling() {
|
|
9688
9712
|
if (!loading && disabled) {
|
|
9689
9713
|
return {
|
|
@@ -9694,13 +9718,19 @@ var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent
|
|
|
9694
9718
|
borderColor: theme.__hd__.button.colors[intent]
|
|
9695
9719
|
};
|
|
9696
9720
|
};
|
|
9697
|
-
return _objectSpread2({
|
|
9698
|
-
height:
|
|
9721
|
+
return _objectSpread2(_objectSpread2({
|
|
9722
|
+
height: getButtonHeight(compact),
|
|
9699
9723
|
flexDirection: 'row',
|
|
9700
9724
|
justifyContent: 'center',
|
|
9701
|
-
alignItems: 'center'
|
|
9725
|
+
alignItems: 'center'
|
|
9726
|
+
}, compact ? {
|
|
9727
|
+
alignSelf: 'flex-start',
|
|
9728
|
+
paddingVertical: theme.__hd__.button.space.compact.buttonPaddingVertical - theme.__hd__.button.borderWidth["default"],
|
|
9729
|
+
paddingHorizontal: theme.__hd__.button.space["default"].buttonPadding - theme.__hd__.button.borderWidth["default"]
|
|
9730
|
+
} : {
|
|
9702
9731
|
alignSelf: 'stretch',
|
|
9703
|
-
padding: theme.__hd__.button.space.buttonPadding - theme.__hd__.button.borderWidth["default"]
|
|
9732
|
+
padding: theme.__hd__.button.space["default"].buttonPadding - theme.__hd__.button.borderWidth["default"]
|
|
9733
|
+
}), {}, {
|
|
9704
9734
|
borderWidth: theme.__hd__.button.borderWidth["default"],
|
|
9705
9735
|
borderRadius: theme.__hd__.button.radii["default"],
|
|
9706
9736
|
backgroundColor: 'transparent'
|
|
@@ -9727,31 +9757,34 @@ var StyledButtonContainer = index$a(reactNative.TouchableHighlight)(function (_r
|
|
|
9727
9757
|
_ref$loading = _ref.loading,
|
|
9728
9758
|
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
9729
9759
|
themeButtonVariant = _ref.themeButtonVariant,
|
|
9730
|
-
themeInlineText = _ref.themeInlineText,
|
|
9731
|
-
|
|
9760
|
+
_ref$themeInlineText = _ref.themeInlineText,
|
|
9761
|
+
themeInlineText = _ref$themeInlineText === void 0 ? false : _ref$themeInlineText,
|
|
9762
|
+
theme = _ref.theme,
|
|
9763
|
+
_ref$themeIsCompact = _ref.themeIsCompact,
|
|
9764
|
+
themeIsCompact = _ref$themeIsCompact === void 0 ? false : _ref$themeIsCompact;
|
|
9732
9765
|
switch (themeButtonVariant) {
|
|
9733
9766
|
case 'filled-primary':
|
|
9734
|
-
return genFilledContainerStyles(theme, 'primary', disabled, loading);
|
|
9767
|
+
return genFilledContainerStyles(theme, 'primary', disabled, loading, themeIsCompact);
|
|
9735
9768
|
case 'filled-secondary':
|
|
9736
|
-
return genFilledContainerStyles(theme, 'secondary', disabled, loading);
|
|
9769
|
+
return genFilledContainerStyles(theme, 'secondary', disabled, loading, themeIsCompact);
|
|
9737
9770
|
case 'filled-danger':
|
|
9738
|
-
return genFilledContainerStyles(theme, 'danger', disabled, loading);
|
|
9771
|
+
return genFilledContainerStyles(theme, 'danger', disabled, loading, themeIsCompact);
|
|
9739
9772
|
case 'outlined-primary':
|
|
9740
|
-
return genOutlineContainerStyles(theme, 'primary', disabled, loading);
|
|
9773
|
+
return genOutlineContainerStyles(theme, 'primary', disabled, loading, themeIsCompact);
|
|
9741
9774
|
case 'outlined-secondary':
|
|
9742
|
-
return genOutlineContainerStyles(theme, 'secondary', disabled, loading);
|
|
9775
|
+
return genOutlineContainerStyles(theme, 'secondary', disabled, loading, themeIsCompact);
|
|
9743
9776
|
case 'outlined-danger':
|
|
9744
|
-
return genOutlineContainerStyles(theme, 'danger', disabled, loading);
|
|
9777
|
+
return genOutlineContainerStyles(theme, 'danger', disabled, loading, themeIsCompact);
|
|
9745
9778
|
case 'text-primary':
|
|
9746
9779
|
case 'text-secondary':
|
|
9747
9780
|
case 'text-danger':
|
|
9748
9781
|
return {
|
|
9749
|
-
height: themeInlineText ? undefined :
|
|
9782
|
+
height: themeInlineText ? undefined : getButtonHeight(themeIsCompact),
|
|
9750
9783
|
borderRadius: theme.__hd__.button.radii.text,
|
|
9751
9784
|
flexDirection: 'row',
|
|
9752
9785
|
justifyContent: 'center',
|
|
9753
9786
|
alignItems: 'center',
|
|
9754
|
-
padding: themeInlineText ? 0 : theme.__hd__.button.space.textButtonPadding,
|
|
9787
|
+
padding: themeInlineText ? 0 : theme.__hd__.button.space["default"].textButtonPadding,
|
|
9755
9788
|
borderWidth: 0,
|
|
9756
9789
|
backgroundColor: loading && !themeInlineText ? theme.__hd__.button.colors.textLoadingBackground : 'transparent'
|
|
9757
9790
|
};
|
|
@@ -9788,6 +9821,7 @@ var StyledButtonText = index$a(Typography.Title)(function (_ref2) {
|
|
|
9788
9821
|
textAlign: 'center'
|
|
9789
9822
|
}, themeStyling());
|
|
9790
9823
|
});
|
|
9824
|
+
var StyledSmallButtonText = StyledButtonText.withComponent(Typography.Body);
|
|
9791
9825
|
var StyledButtonTitleOfVariantText = index$a(Typography.Body)(function (_ref3) {
|
|
9792
9826
|
var disabled = _ref3.disabled,
|
|
9793
9827
|
themeButtonVariant = _ref3.themeButtonVariant,
|
|
@@ -9812,15 +9846,16 @@ var StyledButtonTitleOfVariantText = index$a(Typography.Body)(function (_ref3) {
|
|
|
9812
9846
|
});
|
|
9813
9847
|
var StyledButtonIconWrapper = index$a(reactNative.View)(function (_ref4) {
|
|
9814
9848
|
var themePosition = _ref4.themePosition,
|
|
9815
|
-
theme = _ref4.theme
|
|
9849
|
+
theme = _ref4.theme,
|
|
9850
|
+
themeIsCompact = _ref4.themeIsCompact;
|
|
9816
9851
|
switch (themePosition) {
|
|
9817
9852
|
case 'left':
|
|
9818
9853
|
return {
|
|
9819
|
-
paddingRight: theme.__hd__.button.space.iconPadding
|
|
9854
|
+
paddingRight: themeIsCompact ? theme.__hd__.button.space.compact.iconPadding : theme.__hd__.button.space["default"].iconPadding
|
|
9820
9855
|
};
|
|
9821
9856
|
case 'right':
|
|
9822
9857
|
return {
|
|
9823
|
-
paddingLeft: theme.__hd__.button.space.iconPadding
|
|
9858
|
+
paddingLeft: themeIsCompact ? theme.__hd__.button.space.compact.iconPadding : theme.__hd__.button.space["default"].iconPadding
|
|
9824
9859
|
};
|
|
9825
9860
|
}
|
|
9826
9861
|
});
|
|
@@ -9828,7 +9863,8 @@ var StyledButtonIcon = index$a(Icon)(function (_ref5) {
|
|
|
9828
9863
|
var disabled = _ref5.disabled,
|
|
9829
9864
|
themeButtonVariant = _ref5.themeButtonVariant,
|
|
9830
9865
|
themeIsPressed = _ref5.themeIsPressed,
|
|
9831
|
-
theme = _ref5.theme
|
|
9866
|
+
theme = _ref5.theme,
|
|
9867
|
+
themeIsCompact = _ref5.themeIsCompact;
|
|
9832
9868
|
var themeStyling = function themeStyling() {
|
|
9833
9869
|
switch (themeButtonVariant) {
|
|
9834
9870
|
case 'filled-primary':
|
|
@@ -9852,7 +9888,7 @@ var StyledButtonIcon = index$a(Icon)(function (_ref5) {
|
|
|
9852
9888
|
}
|
|
9853
9889
|
};
|
|
9854
9890
|
return _objectSpread2({
|
|
9855
|
-
fontSize: theme.__hd__.button.sizes.iconSize
|
|
9891
|
+
fontSize: themeIsCompact ? theme.__hd__.button.sizes.iconSize.compact : theme.__hd__.button.sizes.iconSize["default"]
|
|
9856
9892
|
}, themeStyling());
|
|
9857
9893
|
});
|
|
9858
9894
|
|
|
@@ -9877,8 +9913,10 @@ var TEXT_VARIANTS = {
|
|
|
9877
9913
|
var getThemeVariant = function getThemeVariant(variant, intent) {
|
|
9878
9914
|
switch (variant) {
|
|
9879
9915
|
case 'filled':
|
|
9916
|
+
case 'filled-compact':
|
|
9880
9917
|
return FILLED_VARIANTS[intent];
|
|
9881
9918
|
case 'outlined':
|
|
9919
|
+
case 'outlined-compact':
|
|
9882
9920
|
return OUTLINED_VARIANTS[intent];
|
|
9883
9921
|
case 'text':
|
|
9884
9922
|
return TEXT_VARIANTS[intent];
|
|
@@ -9938,6 +9976,34 @@ var Button = function Button(_ref) {
|
|
|
9938
9976
|
isPressed = _useState2[0],
|
|
9939
9977
|
setIsPressed = _useState2[1];
|
|
9940
9978
|
useDeprecation("Button variant ".concat(deprecatedVariants.join(', '), " are deprecated."), deprecatedVariants.includes(themeVariant));
|
|
9979
|
+
var isCompactVariant = ['filled-compact', 'outlined-compact'].includes(variant);
|
|
9980
|
+
var isRenderTextVariant = isTextVariant(themeVariant);
|
|
9981
|
+
var renderTextVariantTitle = function renderTextVariantTitle() {
|
|
9982
|
+
if (!isRenderTextVariant) return null;
|
|
9983
|
+
return /*#__PURE__*/React__namespace.default.createElement(StyledButtonTitleOfVariantText, {
|
|
9984
|
+
variant: isCompactVariant ? 'small-bold' : 'regular-bold',
|
|
9985
|
+
ellipsizeMode: "tail",
|
|
9986
|
+
numberOfLines: 1,
|
|
9987
|
+
disabled: disabled,
|
|
9988
|
+
themeButtonVariant: themeVariant,
|
|
9989
|
+
themeIsPressed: isPressed
|
|
9990
|
+
}, text);
|
|
9991
|
+
};
|
|
9992
|
+
var renderTitle = function renderTitle() {
|
|
9993
|
+
return isCompactVariant ? /*#__PURE__*/React__namespace.default.createElement(StyledSmallButtonText, {
|
|
9994
|
+
variant: "small",
|
|
9995
|
+
ellipsizeMode: "tail",
|
|
9996
|
+
numberOfLines: 1,
|
|
9997
|
+
disabled: disabled,
|
|
9998
|
+
themeButtonVariant: themeVariant
|
|
9999
|
+
}, text) : /*#__PURE__*/React__namespace.default.createElement(StyledButtonText, {
|
|
10000
|
+
level: "h5",
|
|
10001
|
+
ellipsizeMode: "tail",
|
|
10002
|
+
numberOfLines: 1,
|
|
10003
|
+
disabled: disabled,
|
|
10004
|
+
themeButtonVariant: themeVariant
|
|
10005
|
+
}, text);
|
|
10006
|
+
};
|
|
9941
10007
|
return /*#__PURE__*/React__namespace.default.createElement(StyledButtonContainer, {
|
|
9942
10008
|
accessibilityHint: accessibilityHint,
|
|
9943
10009
|
accessibilityLabel: accessibilityLabel,
|
|
@@ -9954,39 +10020,31 @@ var Button = function Button(_ref) {
|
|
|
9954
10020
|
},
|
|
9955
10021
|
onPressOut: function onPressOut() {
|
|
9956
10022
|
return isInlineText && setIsPressed(false);
|
|
9957
|
-
}
|
|
10023
|
+
},
|
|
10024
|
+
themeIsCompact: isCompactVariant
|
|
9958
10025
|
}, loading === true ? /*#__PURE__*/React__namespace.default.createElement(LoadingIndicator, {
|
|
9959
10026
|
testID: "".concat(testID, "-loading-indicator"),
|
|
9960
10027
|
themeVariant: themeVariant
|
|
9961
10028
|
}) : /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, icon !== undefined && /*#__PURE__*/React__namespace.default.createElement(StyledButtonIconWrapper, {
|
|
9962
|
-
themePosition: "left"
|
|
10029
|
+
themePosition: "left",
|
|
10030
|
+
themeIsCompact: isCompactVariant
|
|
9963
10031
|
}, isIconName(icon) ? /*#__PURE__*/React__namespace.default.createElement(StyledButtonIcon, {
|
|
9964
10032
|
disabled: disabled,
|
|
9965
10033
|
icon: icon,
|
|
9966
10034
|
testID: "".concat(testID, "-left-icon"),
|
|
9967
10035
|
themeButtonVariant: themeVariant,
|
|
9968
|
-
themeIsPressed: isPressed
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
disabled: disabled,
|
|
9974
|
-
themeButtonVariant: themeVariant,
|
|
9975
|
-
themeIsPressed: isPressed
|
|
9976
|
-
}, text) : /*#__PURE__*/React__namespace.default.createElement(StyledButtonText, {
|
|
9977
|
-
level: "h5",
|
|
9978
|
-
ellipsizeMode: "tail",
|
|
9979
|
-
numberOfLines: 1,
|
|
9980
|
-
disabled: disabled,
|
|
9981
|
-
themeButtonVariant: themeVariant
|
|
9982
|
-
}, text), rightIcon !== undefined && /*#__PURE__*/React__namespace.default.createElement(StyledButtonIconWrapper, {
|
|
9983
|
-
themePosition: "right"
|
|
10036
|
+
themeIsPressed: isPressed,
|
|
10037
|
+
themeIsCompact: isCompactVariant
|
|
10038
|
+
}) : icon), isRenderTextVariant ? renderTextVariantTitle() : renderTitle(), rightIcon !== undefined && /*#__PURE__*/React__namespace.default.createElement(StyledButtonIconWrapper, {
|
|
10039
|
+
themePosition: "right",
|
|
10040
|
+
themeIsCompact: isCompactVariant
|
|
9984
10041
|
}, isIconName(rightIcon) ? /*#__PURE__*/React__namespace.default.createElement(StyledButtonIcon, {
|
|
9985
10042
|
disabled: disabled,
|
|
9986
10043
|
icon: rightIcon,
|
|
9987
10044
|
testID: "".concat(testID, "-right-icon"),
|
|
9988
10045
|
themeButtonVariant: themeVariant,
|
|
9989
|
-
themeIsPressed: isPressed
|
|
10046
|
+
themeIsPressed: isPressed,
|
|
10047
|
+
themeIsCompact: isCompactVariant
|
|
9990
10048
|
}) : rightIcon)));
|
|
9991
10049
|
};
|
|
9992
10050
|
|
|
@@ -10027,7 +10085,7 @@ var ButtonContainer = index$a(reactNative.TouchableOpacity)(function (_ref) {
|
|
|
10027
10085
|
var IconWrapper = index$a(reactNative.View)(function (_ref2) {
|
|
10028
10086
|
var theme = _ref2.theme;
|
|
10029
10087
|
return {
|
|
10030
|
-
paddingRight: theme.__hd__.button.space.iconPadding
|
|
10088
|
+
paddingRight: theme.__hd__.button.space["default"].iconPadding
|
|
10031
10089
|
};
|
|
10032
10090
|
});
|
|
10033
10091
|
var ButtonText = index$a(Typography.Body)({
|