@hero-design/rn 8.12.0 → 8.12.2
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 +9 -9
- package/es/index.js +121 -34
- package/lib/index.js +120 -33
- package/package.json +5 -5
- package/src/components/Button/Button.tsx +42 -2
- package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +1 -1
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +1 -1
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +3 -3
- package/src/components/Button/StyledButton.tsx +21 -14
- package/src/components/Button/__tests__/Button.spec.tsx +46 -1
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +1564 -0
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +126 -110
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +24 -22
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +17 -3
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +29 -12
- package/src/components/FAB/ActionGroup/ActionItem.tsx +17 -6
- package/src/components/FAB/ActionGroup/StyledActionItem.tsx +15 -17
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +170 -160
- package/src/components/FAB/FAB.tsx +3 -1
- package/src/components/List/BasicListItem.tsx +6 -0
- package/src/components/List/ListItem.tsx +6 -0
- package/src/components/List/StyledBasicListItem.tsx +2 -2
- package/src/components/List/StyledListItem.tsx +2 -2
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +22 -18
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +32 -28
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +44 -36
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +50 -46
- package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +22 -18
- package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +33 -27
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +4 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +11 -9
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +132 -108
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +268 -166
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +11 -9
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +132 -108
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +232 -139
- package/src/components/TextInput/StyledTextInput.tsx +3 -0
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +466 -28
- package/src/components/TextInput/__tests__/index.spec.tsx +32 -0
- package/src/components/TextInput/index.tsx +32 -4
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +34 -6
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +46 -15
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +18 -0
- package/src/theme/components/button.ts +16 -2
- package/src/theme/components/fab.ts +2 -0
- package/src/theme/components/textInput.ts +1 -0
- package/src/theme/global/borders.ts +2 -0
- package/types/components/Button/Button.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +4 -3
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +3 -3
- package/types/components/List/StyledBasicListItem.d.ts +3 -3
- package/types/components/List/StyledListItem.d.ts +3 -3
- package/types/theme/components/button.d.ts +14 -0
- package/types/theme/components/fab.d.ts +2 -0
- package/types/theme/components/textInput.d.ts +1 -0
- package/types/theme/global/borders.d.ts +1 -0
package/lib/index.js
CHANGED
|
@@ -1619,7 +1619,8 @@ var getRadii = function getRadii(baseRadius) {
|
|
|
1619
1619
|
large: baseRadius * 3,
|
|
1620
1620
|
xlarge: baseRadius * 4,
|
|
1621
1621
|
xxlarge: baseRadius * 5,
|
|
1622
|
-
xxxlarge: baseRadius * 6
|
|
1622
|
+
xxxlarge: baseRadius * 6,
|
|
1623
|
+
'5xlarge': baseRadius * 8 // 32
|
|
1623
1624
|
};
|
|
1624
1625
|
};
|
|
1625
1626
|
|
|
@@ -1882,6 +1883,7 @@ var getButtonTheme = function getButtonTheme(theme) {
|
|
|
1882
1883
|
};
|
|
1883
1884
|
var space = {
|
|
1884
1885
|
buttonPadding: theme.space.medium,
|
|
1886
|
+
textButtonPadding: theme.space.smallMedium,
|
|
1885
1887
|
iconPadding: theme.space.smallMedium,
|
|
1886
1888
|
utilityPadding: theme.space.small
|
|
1887
1889
|
};
|
|
@@ -1889,8 +1891,9 @@ var getButtonTheme = function getButtonTheme(theme) {
|
|
|
1889
1891
|
iconSize: theme.fontSizes.xxlarge
|
|
1890
1892
|
};
|
|
1891
1893
|
var radii = {
|
|
1892
|
-
"default": theme.
|
|
1893
|
-
utilityRadii: theme.
|
|
1894
|
+
"default": theme.radii['5xlarge'],
|
|
1895
|
+
utilityRadii: theme.radii.medium,
|
|
1896
|
+
text: theme.radii.base
|
|
1894
1897
|
};
|
|
1895
1898
|
var colors = {
|
|
1896
1899
|
primary: theme.colors.primary,
|
|
@@ -1901,7 +1904,19 @@ var getButtonTheme = function getButtonTheme(theme) {
|
|
|
1901
1904
|
disabledBorder: theme.colors.disabledOnDefaultGlobalSurface,
|
|
1902
1905
|
disabledBackground: theme.colors.disabledOnDefaultGlobalSurface,
|
|
1903
1906
|
invertedText: theme.colors.onDarkGlobalSurface,
|
|
1904
|
-
utilityBackground: theme.colors.neutralGlobalSurface
|
|
1907
|
+
utilityBackground: theme.colors.neutralGlobalSurface,
|
|
1908
|
+
textLoadingBackground: theme.colors.highlightedSurface,
|
|
1909
|
+
pressedBackground: {
|
|
1910
|
+
filledPrimary: theme.colors.pressedSurface,
|
|
1911
|
+
filledSecondary: theme.colors.pressedSurface,
|
|
1912
|
+
filledDanger: theme.colors.errorSurface,
|
|
1913
|
+
outlinedPrimary: theme.colors.highlightedSurface,
|
|
1914
|
+
outlinedSecondary: theme.colors.highlightedSurface,
|
|
1915
|
+
outlineDanger: theme.colors.errorSurface,
|
|
1916
|
+
textPrimary: theme.colors.highlightedSurface,
|
|
1917
|
+
textSecondary: theme.colors.highlightedSurface,
|
|
1918
|
+
textDanger: theme.colors.errorSurface
|
|
1919
|
+
}
|
|
1905
1920
|
};
|
|
1906
1921
|
return {
|
|
1907
1922
|
borderWidth: borderWidth,
|
|
@@ -2166,9 +2181,11 @@ var getEmptyTheme = function getEmptyTheme(theme) {
|
|
|
2166
2181
|
var getFABTheme = function getFABTheme(theme) {
|
|
2167
2182
|
var colors = {
|
|
2168
2183
|
buttonBackground: theme.colors.primary,
|
|
2184
|
+
buttonPressedBackground: theme.colors.pressedSurface,
|
|
2169
2185
|
icon: theme.colors.onPrimary,
|
|
2170
2186
|
headerText: theme.colors.onDefaultGlobalSurface,
|
|
2171
2187
|
actionItemBackground: theme.colors.primary,
|
|
2188
|
+
actionItemPressedBackground: theme.colors.pressedSurface,
|
|
2172
2189
|
backdropBackground: theme.colors.overlayGlobalSurface,
|
|
2173
2190
|
titleText: theme.colors.onPrimary,
|
|
2174
2191
|
actionItemText: theme.colors.onPrimary
|
|
@@ -2703,6 +2720,7 @@ var getTagTheme = function getTagTheme(theme) {
|
|
|
2703
2720
|
var getTextInputTheme = function getTextInputTheme(theme) {
|
|
2704
2721
|
var colors = {
|
|
2705
2722
|
labelBackground: theme.colors.defaultGlobalSurface,
|
|
2723
|
+
containerBackground: theme.colors.defaultGlobalSurface,
|
|
2706
2724
|
asterisks: {
|
|
2707
2725
|
"default": theme.colors.onErrorSurface,
|
|
2708
2726
|
error: theme.colors.onErrorSurface,
|
|
@@ -7371,8 +7389,8 @@ var StyledLoadingDot = index$a(reactNative.View)(function (_ref2) {
|
|
|
7371
7389
|
backgroundColor: theme.__hd__.button.colors.invertedText
|
|
7372
7390
|
};
|
|
7373
7391
|
case 'outlined-primary':
|
|
7374
|
-
case 'text-primary':
|
|
7375
7392
|
return genLoadingIndicatorStyles(theme, 'primary');
|
|
7393
|
+
case 'text-primary':
|
|
7376
7394
|
case 'outlined-secondary':
|
|
7377
7395
|
case 'text-secondary':
|
|
7378
7396
|
return genLoadingIndicatorStyles(theme, 'secondary');
|
|
@@ -7454,9 +7472,9 @@ var LoadingIndicator = function LoadingIndicator(_ref2) {
|
|
|
7454
7472
|
}, nativeProps), Array.from(new Array(count), renderLoadingDot, themeVariant));
|
|
7455
7473
|
};
|
|
7456
7474
|
|
|
7457
|
-
var genFilledContainerStyles = function genFilledContainerStyles(theme, intent, disabled) {
|
|
7475
|
+
var genFilledContainerStyles = function genFilledContainerStyles(theme, intent, disabled, loading) {
|
|
7458
7476
|
var backgroundColorStyling = function backgroundColorStyling() {
|
|
7459
|
-
if (disabled) {
|
|
7477
|
+
if (!loading && disabled) {
|
|
7460
7478
|
return {
|
|
7461
7479
|
backgroundColor: theme.__hd__.button.colors.disabledBorder
|
|
7462
7480
|
};
|
|
@@ -7474,9 +7492,9 @@ var genFilledContainerStyles = function genFilledContainerStyles(theme, intent,
|
|
|
7474
7492
|
borderRadius: theme.__hd__.button.radii["default"]
|
|
7475
7493
|
}, backgroundColorStyling());
|
|
7476
7494
|
};
|
|
7477
|
-
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled) {
|
|
7495
|
+
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled, loading) {
|
|
7478
7496
|
var borderColorStyling = function borderColorStyling() {
|
|
7479
|
-
if (disabled) {
|
|
7497
|
+
if (!loading && disabled) {
|
|
7480
7498
|
return {
|
|
7481
7499
|
borderColor: theme.__hd__.button.colors.disabledBorder
|
|
7482
7500
|
};
|
|
@@ -7528,33 +7546,37 @@ var genTextVariantTextStyles = function genTextVariantTextStyles(theme, intent,
|
|
|
7528
7546
|
lineHeight: theme.__hd__.button.lineHeight["default"]
|
|
7529
7547
|
}, textColorStyling());
|
|
7530
7548
|
};
|
|
7531
|
-
var StyledButtonContainer = index$a(reactNative.
|
|
7549
|
+
var StyledButtonContainer = index$a(reactNative.TouchableHighlight)(function (_ref) {
|
|
7532
7550
|
var _ref$disabled = _ref.disabled,
|
|
7533
7551
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
7552
|
+
_ref$loading = _ref.loading,
|
|
7553
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
7534
7554
|
themeVariant = _ref.themeVariant,
|
|
7535
7555
|
theme = _ref.theme;
|
|
7536
7556
|
switch (themeVariant) {
|
|
7537
7557
|
case 'filled-primary':
|
|
7538
|
-
return genFilledContainerStyles(theme, 'primary', disabled);
|
|
7558
|
+
return genFilledContainerStyles(theme, 'primary', disabled, loading);
|
|
7539
7559
|
case 'filled-secondary':
|
|
7540
|
-
return genFilledContainerStyles(theme, 'secondary', disabled);
|
|
7560
|
+
return genFilledContainerStyles(theme, 'secondary', disabled, loading);
|
|
7541
7561
|
case 'filled-danger':
|
|
7542
|
-
return genFilledContainerStyles(theme, 'danger', disabled);
|
|
7562
|
+
return genFilledContainerStyles(theme, 'danger', disabled, loading);
|
|
7543
7563
|
case 'outlined-primary':
|
|
7544
|
-
return genOutlineContainerStyles(theme, 'primary', disabled);
|
|
7564
|
+
return genOutlineContainerStyles(theme, 'primary', disabled, loading);
|
|
7545
7565
|
case 'outlined-secondary':
|
|
7546
|
-
return genOutlineContainerStyles(theme, 'secondary', disabled);
|
|
7566
|
+
return genOutlineContainerStyles(theme, 'secondary', disabled, loading);
|
|
7547
7567
|
case 'outlined-danger':
|
|
7548
|
-
return genOutlineContainerStyles(theme, 'danger', disabled);
|
|
7568
|
+
return genOutlineContainerStyles(theme, 'danger', disabled, loading);
|
|
7549
7569
|
case 'text-primary':
|
|
7550
7570
|
case 'text-secondary':
|
|
7551
7571
|
case 'text-danger':
|
|
7552
7572
|
return {
|
|
7573
|
+
borderRadius: theme.__hd__.button.radii.text,
|
|
7553
7574
|
flexDirection: 'row',
|
|
7554
7575
|
justifyContent: 'center',
|
|
7555
7576
|
alignItems: 'center',
|
|
7556
|
-
padding: theme.__hd__.button.space.
|
|
7557
|
-
borderWidth: 0
|
|
7577
|
+
padding: theme.__hd__.button.space.textButtonPadding,
|
|
7578
|
+
borderWidth: 0,
|
|
7579
|
+
backgroundColor: loading ? theme.__hd__.button.colors.textLoadingBackground : 'transparent'
|
|
7558
7580
|
};
|
|
7559
7581
|
}
|
|
7560
7582
|
});
|
|
@@ -7662,6 +7684,29 @@ var getThemeVariant = function getThemeVariant(variant, intent) {
|
|
|
7662
7684
|
return TEXT_VARIANTS[intent];
|
|
7663
7685
|
}
|
|
7664
7686
|
};
|
|
7687
|
+
var getUnderlayColor = function getUnderlayColor(theme, themeVariant) {
|
|
7688
|
+
switch (themeVariant) {
|
|
7689
|
+
case 'filled-primary':
|
|
7690
|
+
return theme.__hd__.button.colors.pressedBackground.filledPrimary;
|
|
7691
|
+
case 'filled-secondary':
|
|
7692
|
+
return theme.__hd__.button.colors.pressedBackground.filledSecondary;
|
|
7693
|
+
case 'filled-danger':
|
|
7694
|
+
return theme.__hd__.button.colors.pressedBackground.filledDanger;
|
|
7695
|
+
case 'outlined-primary':
|
|
7696
|
+
return theme.__hd__.button.colors.pressedBackground.outlinedPrimary;
|
|
7697
|
+
case 'outlined-secondary':
|
|
7698
|
+
return theme.__hd__.button.colors.pressedBackground.outlinedSecondary;
|
|
7699
|
+
case 'outlined-danger':
|
|
7700
|
+
return theme.__hd__.button.colors.pressedBackground.outlineDanger;
|
|
7701
|
+
case 'text-primary':
|
|
7702
|
+
return theme.__hd__.button.colors.pressedBackground.textPrimary;
|
|
7703
|
+
case 'text-secondary':
|
|
7704
|
+
return theme.__hd__.button.colors.pressedBackground.textSecondary;
|
|
7705
|
+
case 'text-danger':
|
|
7706
|
+
return theme.__hd__.button.colors.pressedBackground.textDanger;
|
|
7707
|
+
}
|
|
7708
|
+
};
|
|
7709
|
+
var deprecatedVariants = ['filled-secondary', 'filled-danger', 'outlined-secondary', 'outlined-danger'];
|
|
7665
7710
|
var Button = function Button(_ref) {
|
|
7666
7711
|
var accessibilityHint = _ref.accessibilityHint,
|
|
7667
7712
|
accessibilityLabel = _ref.accessibilityLabel,
|
|
@@ -7680,14 +7725,21 @@ var Button = function Button(_ref) {
|
|
|
7680
7725
|
_ref$variant = _ref.variant,
|
|
7681
7726
|
variant = _ref$variant === void 0 ? 'filled' : _ref$variant;
|
|
7682
7727
|
var themeVariant = getThemeVariant(variant, intent);
|
|
7728
|
+
var theme = useTheme();
|
|
7729
|
+
var underlayColor = React.useMemo(function () {
|
|
7730
|
+
return getUnderlayColor(theme, themeVariant);
|
|
7731
|
+
}, [theme, themeVariant]);
|
|
7732
|
+
useDeprecation("Button variant ".concat(deprecatedVariants.join(', '), " are deprecated."), deprecatedVariants.includes(themeVariant));
|
|
7683
7733
|
return /*#__PURE__*/React__default["default"].createElement(StyledButtonContainer, {
|
|
7684
7734
|
accessibilityHint: accessibilityHint,
|
|
7685
7735
|
accessibilityLabel: accessibilityLabel,
|
|
7686
7736
|
disabled: disabled || loading,
|
|
7737
|
+
loading: loading,
|
|
7687
7738
|
onPress: onPress,
|
|
7688
7739
|
testID: testID,
|
|
7689
7740
|
themeVariant: themeVariant,
|
|
7690
|
-
style: style
|
|
7741
|
+
style: style,
|
|
7742
|
+
underlayColor: underlayColor
|
|
7691
7743
|
}, loading === true ? /*#__PURE__*/React__default["default"].createElement(LoadingIndicator, {
|
|
7692
7744
|
testID: "".concat(testID, "-loading-indicator"),
|
|
7693
7745
|
themeVariant: themeVariant
|
|
@@ -11463,7 +11515,9 @@ var StyledTextInputContainer = index$a(reactNative.View)(function (_ref13) {
|
|
|
11463
11515
|
return {
|
|
11464
11516
|
flexDirection: 'row',
|
|
11465
11517
|
alignItems: 'center',
|
|
11466
|
-
padding: theme.__hd__.textInput.space.containerPadding
|
|
11518
|
+
padding: theme.__hd__.textInput.space.containerPadding,
|
|
11519
|
+
backgroundColor: theme.__hd__.textInput.colors.containerBackground,
|
|
11520
|
+
borderRadius: theme.__hd__.textInput.radii.container
|
|
11467
11521
|
};
|
|
11468
11522
|
});
|
|
11469
11523
|
var StyledTextInputAndLabelContainer = index$a(reactNative.View)(function () {
|
|
@@ -11597,8 +11651,24 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
11597
11651
|
}, [textStyle]),
|
|
11598
11652
|
borderStyle = _useMemo.borderStyle,
|
|
11599
11653
|
textStyleWithoutBorderStyle = _useMemo.textStyleWithoutBorderStyle;
|
|
11654
|
+
var _useMemo2 = React.useMemo(function () {
|
|
11655
|
+
var _flattenTextStyle$bac;
|
|
11656
|
+
if (!style) {
|
|
11657
|
+
return {
|
|
11658
|
+
backgroundColor: theme.__hd__.textInput.colors.containerBackground
|
|
11659
|
+
};
|
|
11660
|
+
}
|
|
11661
|
+
var flattenTextStyle = reactNative.StyleSheet.flatten(style);
|
|
11662
|
+
return {
|
|
11663
|
+
backgroundColor: (_flattenTextStyle$bac = flattenTextStyle.backgroundColor) !== null && _flattenTextStyle$bac !== void 0 ? _flattenTextStyle$bac : theme.__hd__.textInput.colors.containerBackground,
|
|
11664
|
+
styleWithoutBackgroundColor: omit(['backgroundColor'], flattenTextStyle)
|
|
11665
|
+
};
|
|
11666
|
+
}, [style, theme]),
|
|
11667
|
+
backgroundColor = _useMemo2.backgroundColor,
|
|
11668
|
+
styleWithoutBackgroundColor = _useMemo2.styleWithoutBackgroundColor;
|
|
11600
11669
|
var nativeInputProps = _objectSpread2(_objectSpread2({
|
|
11601
11670
|
style: reactNative.StyleSheet.flatten([{
|
|
11671
|
+
backgroundColor: backgroundColor,
|
|
11602
11672
|
color: theme.__hd__.textInput.colors.text
|
|
11603
11673
|
}, textStyleWithoutBorderStyle]),
|
|
11604
11674
|
testID: 'text-input',
|
|
@@ -11630,15 +11700,22 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
11630
11700
|
placeholder: isFocused || label === undefined ? nativeProps.placeholder : EMPTY_PLACEHOLDER_VALUE
|
|
11631
11701
|
});
|
|
11632
11702
|
return /*#__PURE__*/React__default["default"].createElement(StyledContainer$3, {
|
|
11633
|
-
style:
|
|
11703
|
+
style: styleWithoutBackgroundColor,
|
|
11634
11704
|
pointerEvents: variant === 'disabled' || variant === 'readonly' ? 'none' : 'auto',
|
|
11635
11705
|
testID: testID
|
|
11636
11706
|
}, /*#__PURE__*/React__default["default"].createElement(StyledTextInputContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledBorderBackDrop, {
|
|
11637
11707
|
themeFocused: isFocused,
|
|
11638
11708
|
themeVariant: variant,
|
|
11639
|
-
|
|
11709
|
+
testID: "text-input-border",
|
|
11710
|
+
style: [{
|
|
11711
|
+
backgroundColor: backgroundColor
|
|
11712
|
+
}, borderStyle]
|
|
11640
11713
|
}), (isFocused || label && !isEmptyValue) && /*#__PURE__*/React__default["default"].createElement(StyledLabelContainer, {
|
|
11641
|
-
pointerEvents: "none"
|
|
11714
|
+
pointerEvents: "none",
|
|
11715
|
+
testID: "label-container",
|
|
11716
|
+
style: {
|
|
11717
|
+
backgroundColor: backgroundColor
|
|
11718
|
+
}
|
|
11642
11719
|
}, required && /*#__PURE__*/React__default["default"].createElement(StyledAsteriskLabel, {
|
|
11643
11720
|
themeVariant: variant,
|
|
11644
11721
|
fontSize: "small"
|
|
@@ -11646,7 +11723,10 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
11646
11723
|
nativeID: accessibilityLabelledBy,
|
|
11647
11724
|
testID: "input-label",
|
|
11648
11725
|
fontSize: "small",
|
|
11649
|
-
themeVariant: variant
|
|
11726
|
+
themeVariant: variant,
|
|
11727
|
+
style: {
|
|
11728
|
+
backgroundColor: backgroundColor
|
|
11729
|
+
}
|
|
11650
11730
|
}, label)), typeof prefix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
11651
11731
|
intent: variant === 'disabled' ? 'disabled-text' : 'text',
|
|
11652
11732
|
testID: "input-prefix",
|
|
@@ -12278,11 +12358,12 @@ var FAB = function FAB(_ref3) {
|
|
|
12278
12358
|
active = _ref3.active,
|
|
12279
12359
|
style = _ref3.style;
|
|
12280
12360
|
var isIconOnly = !title;
|
|
12361
|
+
var theme = useTheme();
|
|
12281
12362
|
return /*#__PURE__*/React__default["default"].createElement(StyledFABContainer, {
|
|
12363
|
+
underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
|
|
12282
12364
|
testID: testID,
|
|
12283
12365
|
style: style,
|
|
12284
|
-
onPress: onPress
|
|
12285
|
-
activeOpacity: 0.6
|
|
12366
|
+
onPress: onPress
|
|
12286
12367
|
}, isIconOnly ? /*#__PURE__*/React__default["default"].createElement(IconOnlyContent, {
|
|
12287
12368
|
animated: animated,
|
|
12288
12369
|
active: active,
|
|
@@ -12293,7 +12374,7 @@ var FAB = function FAB(_ref3) {
|
|
|
12293
12374
|
}));
|
|
12294
12375
|
};
|
|
12295
12376
|
|
|
12296
|
-
var StyledActionItem = index$a(reactNative.
|
|
12377
|
+
var StyledActionItem = index$a(reactNative.TouchableHighlight)(function (_ref) {
|
|
12297
12378
|
var theme = _ref.theme;
|
|
12298
12379
|
return {
|
|
12299
12380
|
paddingLeft: theme.__hd__.fab.space.actionItemPaddingLeft,
|
|
@@ -12333,13 +12414,15 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
12333
12414
|
onPress = _ref.onPress,
|
|
12334
12415
|
style = _ref.style,
|
|
12335
12416
|
testID = _ref.testID;
|
|
12417
|
+
var theme = useTheme();
|
|
12336
12418
|
return /*#__PURE__*/React__default["default"].createElement(StyledActionItem, {
|
|
12419
|
+
underlayColor: theme.__hd__.fab.colors.actionItemPressedBackground,
|
|
12337
12420
|
style: style,
|
|
12338
12421
|
onPress: onPress,
|
|
12339
12422
|
testID: testID
|
|
12340
|
-
}, /*#__PURE__*/React__default["default"].createElement(StyledIcon, {
|
|
12423
|
+
}, /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(StyledIcon, {
|
|
12341
12424
|
icon: icon
|
|
12342
|
-
}), /*#__PURE__*/React__default["default"].createElement(StyledActionItemText, null, title));
|
|
12425
|
+
}), /*#__PURE__*/React__default["default"].createElement(StyledActionItemText, null, title)));
|
|
12343
12426
|
};
|
|
12344
12427
|
|
|
12345
12428
|
var StyledContainer$1 = index$a(reactNative.View)({
|
|
@@ -12466,7 +12549,7 @@ var index$6 = Object.assign(FAB, {
|
|
|
12466
12549
|
ActionGroup: ActionGroup
|
|
12467
12550
|
});
|
|
12468
12551
|
|
|
12469
|
-
var StyledListItemContainer$1 = index$a(reactNative.
|
|
12552
|
+
var StyledListItemContainer$1 = index$a(reactNative.TouchableHighlight)(function (_ref) {
|
|
12470
12553
|
var theme = _ref.theme,
|
|
12471
12554
|
_ref$themeSelected = _ref.themeSelected,
|
|
12472
12555
|
themeSelected = _ref$themeSelected === void 0 ? false : _ref$themeSelected,
|
|
@@ -12552,13 +12635,15 @@ var ListItem = function ListItem(_ref) {
|
|
|
12552
12635
|
onPress = _ref.onPress,
|
|
12553
12636
|
_ref$disabled = _ref.disabled,
|
|
12554
12637
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
12638
|
+
var theme = useTheme();
|
|
12555
12639
|
return /*#__PURE__*/React__default["default"].createElement(StyledListItemContainer$1, {
|
|
12556
12640
|
style: style,
|
|
12557
12641
|
testID: testID,
|
|
12558
12642
|
themeSelected: selected,
|
|
12559
12643
|
themeVariant: variant,
|
|
12560
12644
|
onPress: onPress,
|
|
12561
|
-
disabled: disabled
|
|
12645
|
+
disabled: disabled,
|
|
12646
|
+
underlayColor: theme.__hd__.list.colors.checkedListItemContainerBackground
|
|
12562
12647
|
}, /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, leadingStatus && /*#__PURE__*/React__default["default"].createElement(StyledLeadingStatus, {
|
|
12563
12648
|
themeLeadingStatusIntent: leadingStatus,
|
|
12564
12649
|
testID: "leadingStatus"
|
|
@@ -12600,7 +12685,7 @@ var StyledTitleContainer = index$a(reactNative.View)(function () {
|
|
|
12600
12685
|
flex: 1
|
|
12601
12686
|
};
|
|
12602
12687
|
});
|
|
12603
|
-
var StyledListItemContainer = index$a(reactNative.
|
|
12688
|
+
var StyledListItemContainer = index$a(reactNative.TouchableHighlight)(function (_ref3) {
|
|
12604
12689
|
var theme = _ref3.theme,
|
|
12605
12690
|
themeSelected = _ref3.themeSelected,
|
|
12606
12691
|
themeDisabled = _ref3.themeDisabled;
|
|
@@ -12626,13 +12711,15 @@ var BasicListItem = function BasicListItem(_ref) {
|
|
|
12626
12711
|
_ref$disabled = _ref.disabled,
|
|
12627
12712
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
12628
12713
|
onPress = _ref.onPress;
|
|
12714
|
+
var theme = useTheme();
|
|
12629
12715
|
return /*#__PURE__*/React__default["default"].createElement(StyledListItemContainer, {
|
|
12630
12716
|
style: style,
|
|
12631
12717
|
testID: testID,
|
|
12632
12718
|
themeSelected: selected,
|
|
12633
12719
|
themeDisabled: disabled,
|
|
12634
12720
|
onPress: onPress,
|
|
12635
|
-
disabled: disabled
|
|
12721
|
+
disabled: disabled,
|
|
12722
|
+
underlayColor: theme.__hd__.list.colors.checkedListItemContainerBackground
|
|
12636
12723
|
}, /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, prefix && /*#__PURE__*/React__default["default"].createElement(StyledPrefixContainer, null, typeof prefix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
12637
12724
|
icon: prefix,
|
|
12638
12725
|
intent: disabled ? 'disabled-text' : 'primary'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.12.
|
|
3
|
+
"version": "8.12.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.12.
|
|
24
|
+
"@hero-design/colors": "8.12.2",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@babel/preset-typescript": "^7.17.12",
|
|
45
45
|
"@babel/runtime": "^7.18.9",
|
|
46
46
|
"@emotion/jest": "^11.9.3",
|
|
47
|
-
"@hero-design/eslint-plugin": "8.12.
|
|
47
|
+
"@hero-design/eslint-plugin": "8.12.2",
|
|
48
48
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
49
49
|
"@react-native-community/slider": "4.1.12",
|
|
50
50
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"@types/react-native": "^0.67.7",
|
|
61
61
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
62
62
|
"babel-plugin-inline-import": "^3.0.0",
|
|
63
|
-
"eslint-config-hd": "8.12.
|
|
63
|
+
"eslint-config-hd": "8.12.2",
|
|
64
64
|
"jest": "^27.3.1",
|
|
65
|
-
"prettier-config-hd": "8.12.
|
|
65
|
+
"prettier-config-hd": "8.12.2",
|
|
66
66
|
"react": "18.0.0",
|
|
67
67
|
"react-native": "0.69.7",
|
|
68
68
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactChild, useMemo } from 'react';
|
|
3
2
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { Theme, useTheme } from '../../theme';
|
|
4
4
|
import type { IconName } from '../Icon';
|
|
5
5
|
import LoadingIndicator from './LoadingIndicator';
|
|
6
6
|
import type { Intent, ThemeVariant } from './StyledButton';
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
StyledButtonIconWrapper,
|
|
11
11
|
StyledButtonText,
|
|
12
12
|
} from './StyledButton';
|
|
13
|
+
import { useDeprecation } from '../../utils/hooks';
|
|
13
14
|
|
|
14
15
|
export interface ButtonProps {
|
|
15
16
|
/**
|
|
@@ -93,7 +94,35 @@ export const getThemeVariant = (
|
|
|
93
94
|
return TEXT_VARIANTS[intent];
|
|
94
95
|
}
|
|
95
96
|
};
|
|
97
|
+
const getUnderlayColor = (theme: Theme, themeVariant: ThemeVariant) => {
|
|
98
|
+
switch (themeVariant) {
|
|
99
|
+
case 'filled-primary':
|
|
100
|
+
return theme.__hd__.button.colors.pressedBackground.filledPrimary;
|
|
101
|
+
case 'filled-secondary':
|
|
102
|
+
return theme.__hd__.button.colors.pressedBackground.filledSecondary;
|
|
103
|
+
case 'filled-danger':
|
|
104
|
+
return theme.__hd__.button.colors.pressedBackground.filledDanger;
|
|
105
|
+
case 'outlined-primary':
|
|
106
|
+
return theme.__hd__.button.colors.pressedBackground.outlinedPrimary;
|
|
107
|
+
case 'outlined-secondary':
|
|
108
|
+
return theme.__hd__.button.colors.pressedBackground.outlinedSecondary;
|
|
109
|
+
case 'outlined-danger':
|
|
110
|
+
return theme.__hd__.button.colors.pressedBackground.outlineDanger;
|
|
111
|
+
case 'text-primary':
|
|
112
|
+
return theme.__hd__.button.colors.pressedBackground.textPrimary;
|
|
113
|
+
case 'text-secondary':
|
|
114
|
+
return theme.__hd__.button.colors.pressedBackground.textSecondary;
|
|
115
|
+
case 'text-danger':
|
|
116
|
+
return theme.__hd__.button.colors.pressedBackground.textDanger;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
96
119
|
|
|
120
|
+
const deprecatedVariants: ThemeVariant[] = [
|
|
121
|
+
'filled-secondary',
|
|
122
|
+
'filled-danger',
|
|
123
|
+
'outlined-secondary',
|
|
124
|
+
'outlined-danger',
|
|
125
|
+
];
|
|
97
126
|
const Button = ({
|
|
98
127
|
accessibilityHint,
|
|
99
128
|
accessibilityLabel,
|
|
@@ -109,16 +138,27 @@ const Button = ({
|
|
|
109
138
|
variant = 'filled',
|
|
110
139
|
}: ButtonProps): JSX.Element => {
|
|
111
140
|
const themeVariant = getThemeVariant(variant, intent);
|
|
141
|
+
const theme = useTheme();
|
|
142
|
+
const underlayColor = useMemo(() => {
|
|
143
|
+
return getUnderlayColor(theme, themeVariant);
|
|
144
|
+
}, [theme, themeVariant]);
|
|
145
|
+
|
|
146
|
+
useDeprecation(
|
|
147
|
+
`Button variant ${deprecatedVariants.join(', ')} are deprecated.`,
|
|
148
|
+
deprecatedVariants.includes(themeVariant)
|
|
149
|
+
);
|
|
112
150
|
|
|
113
151
|
return (
|
|
114
152
|
<StyledButtonContainer
|
|
115
153
|
accessibilityHint={accessibilityHint}
|
|
116
154
|
accessibilityLabel={accessibilityLabel}
|
|
117
155
|
disabled={disabled || loading}
|
|
156
|
+
loading={loading}
|
|
118
157
|
onPress={onPress}
|
|
119
158
|
testID={testID}
|
|
120
159
|
themeVariant={themeVariant}
|
|
121
160
|
style={style}
|
|
161
|
+
underlayColor={underlayColor}
|
|
122
162
|
>
|
|
123
163
|
{loading === true ? (
|
|
124
164
|
<LoadingIndicator
|
|
@@ -46,8 +46,8 @@ const StyledLoadingDot = styled(View)<{
|
|
|
46
46
|
backgroundColor: theme.__hd__.button.colors.invertedText,
|
|
47
47
|
};
|
|
48
48
|
case 'outlined-primary':
|
|
49
|
-
case 'text-primary':
|
|
50
49
|
return genLoadingIndicatorStyles(theme, 'primary');
|
|
50
|
+
case 'text-primary':
|
|
51
51
|
case 'outlined-secondary':
|
|
52
52
|
case 'text-secondary':
|
|
53
53
|
return genLoadingIndicatorStyles(theme, 'secondary');
|
|
@@ -945,7 +945,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-primary 1`
|
|
|
945
945
|
style={
|
|
946
946
|
Array [
|
|
947
947
|
Object {
|
|
948
|
-
"backgroundColor": "#
|
|
948
|
+
"backgroundColor": "#795e90",
|
|
949
949
|
"borderRadius": 8,
|
|
950
950
|
"height": 12,
|
|
951
951
|
"marginBottom": 4,
|
|
@@ -977,7 +977,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-primary 1`
|
|
|
977
977
|
style={
|
|
978
978
|
Array [
|
|
979
979
|
Object {
|
|
980
|
-
"backgroundColor": "#
|
|
980
|
+
"backgroundColor": "#795e90",
|
|
981
981
|
"borderRadius": 8,
|
|
982
982
|
"height": 12,
|
|
983
983
|
"marginBottom": 4,
|
|
@@ -1009,7 +1009,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-primary 1`
|
|
|
1009
1009
|
style={
|
|
1010
1010
|
Array [
|
|
1011
1011
|
Object {
|
|
1012
|
-
"backgroundColor": "#
|
|
1012
|
+
"backgroundColor": "#795e90",
|
|
1013
1013
|
"borderRadius": 8,
|
|
1014
1014
|
"height": 12,
|
|
1015
1015
|
"marginBottom": 4,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TouchableHighlight, View } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
3
|
import type { ReactNativeStyle } from '@emotion/native';
|
|
4
4
|
import type { Theme } from '@emotion/react';
|
|
@@ -21,10 +21,11 @@ type ThemeVariant =
|
|
|
21
21
|
const genFilledContainerStyles = (
|
|
22
22
|
theme: Theme,
|
|
23
23
|
intent: Intent,
|
|
24
|
-
disabled: boolean
|
|
24
|
+
disabled: boolean,
|
|
25
|
+
loading: boolean
|
|
25
26
|
): ReactNativeStyle => {
|
|
26
27
|
const backgroundColorStyling = () => {
|
|
27
|
-
if (disabled) {
|
|
28
|
+
if (!loading && disabled) {
|
|
28
29
|
return {
|
|
29
30
|
backgroundColor: theme.__hd__.button.colors.disabledBorder,
|
|
30
31
|
};
|
|
@@ -47,10 +48,11 @@ const genFilledContainerStyles = (
|
|
|
47
48
|
const genOutlineContainerStyles = (
|
|
48
49
|
theme: Theme,
|
|
49
50
|
intent: Intent,
|
|
50
|
-
disabled: boolean
|
|
51
|
+
disabled: boolean,
|
|
52
|
+
loading: boolean
|
|
51
53
|
): ReactNativeStyle => {
|
|
52
54
|
const borderColorStyling = () => {
|
|
53
|
-
if (disabled) {
|
|
55
|
+
if (!loading && disabled) {
|
|
54
56
|
return {
|
|
55
57
|
borderColor: theme.__hd__.button.colors.disabledBorder,
|
|
56
58
|
};
|
|
@@ -118,32 +120,37 @@ const genTextVariantTextStyles = (
|
|
|
118
120
|
};
|
|
119
121
|
};
|
|
120
122
|
|
|
121
|
-
const StyledButtonContainer = styled(
|
|
123
|
+
const StyledButtonContainer = styled(TouchableHighlight)<{
|
|
122
124
|
disabled?: boolean;
|
|
123
125
|
themeVariant: ThemeVariant;
|
|
124
|
-
|
|
126
|
+
loading?: boolean;
|
|
127
|
+
}>(({ disabled = false, loading = false, themeVariant, theme }) => {
|
|
125
128
|
switch (themeVariant) {
|
|
126
129
|
case 'filled-primary':
|
|
127
|
-
return genFilledContainerStyles(theme, 'primary', disabled);
|
|
130
|
+
return genFilledContainerStyles(theme, 'primary', disabled, loading);
|
|
128
131
|
case 'filled-secondary':
|
|
129
|
-
return genFilledContainerStyles(theme, 'secondary', disabled);
|
|
132
|
+
return genFilledContainerStyles(theme, 'secondary', disabled, loading);
|
|
130
133
|
case 'filled-danger':
|
|
131
|
-
return genFilledContainerStyles(theme, 'danger', disabled);
|
|
134
|
+
return genFilledContainerStyles(theme, 'danger', disabled, loading);
|
|
132
135
|
case 'outlined-primary':
|
|
133
|
-
return genOutlineContainerStyles(theme, 'primary', disabled);
|
|
136
|
+
return genOutlineContainerStyles(theme, 'primary', disabled, loading);
|
|
134
137
|
case 'outlined-secondary':
|
|
135
|
-
return genOutlineContainerStyles(theme, 'secondary', disabled);
|
|
138
|
+
return genOutlineContainerStyles(theme, 'secondary', disabled, loading);
|
|
136
139
|
case 'outlined-danger':
|
|
137
|
-
return genOutlineContainerStyles(theme, 'danger', disabled);
|
|
140
|
+
return genOutlineContainerStyles(theme, 'danger', disabled, loading);
|
|
138
141
|
case 'text-primary':
|
|
139
142
|
case 'text-secondary':
|
|
140
143
|
case 'text-danger':
|
|
141
144
|
return {
|
|
145
|
+
borderRadius: theme.__hd__.button.radii.text,
|
|
142
146
|
flexDirection: 'row',
|
|
143
147
|
justifyContent: 'center',
|
|
144
148
|
alignItems: 'center',
|
|
145
|
-
padding: theme.__hd__.button.space.
|
|
149
|
+
padding: theme.__hd__.button.space.textButtonPadding,
|
|
146
150
|
borderWidth: 0,
|
|
151
|
+
backgroundColor: loading
|
|
152
|
+
? theme.__hd__.button.colors.textLoadingBackground
|
|
153
|
+
: 'transparent',
|
|
147
154
|
};
|
|
148
155
|
}
|
|
149
156
|
});
|