@hero-design/rn 8.12.1 → 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 +79 -25
- package/lib/index.js +78 -24
- 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__/DatePickerIOS.spec.tsx.snap +12 -9
- 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/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +36 -27
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +12 -9
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +17 -0
- package/src/theme/components/button.ts +16 -2
- package/src/theme/components/fab.ts +2 -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/theme/components/button.d.ts +14 -0
- package/types/theme/components/fab.d.ts +2 -0
- package/types/theme/global/borders.d.ts +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
1
|
+
[34m@hero-design/rn:build[0m: cache hit, replaying output [2m11fbf9e3773167e6[0m
|
|
2
|
+
[34m@hero-design/rn:build: [0m$ yarn build:js && yarn build:types
|
|
3
|
+
[34m@hero-design/rn:build: [0m$ rollup -c
|
|
4
|
+
[34m@hero-design/rn:build: [0m[36m
|
|
5
|
+
[34m@hero-design/rn:build: [0m[1msrc/index.ts[22m → [1mlib/index.js, es/index.js[22m...[39m
|
|
6
|
+
[34m@hero-design/rn:build: [0m[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
|
|
7
|
+
[34m@hero-design/rn:build: [0m[1m[33m(!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning[39m[22m
|
|
8
|
+
[34m@hero-design/rn:build: [0m[32mcreated [1mlib/index.js, es/index.js[22m in [1m24.8s[22m[39m
|
|
9
|
+
[34m@hero-design/rn:build: [0m$ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as reactNative from 'react-native';
|
|
2
|
-
import { Platform, Dimensions, StyleSheet as StyleSheet$1, Animated, View, Easing, TouchableOpacity, Text as Text$1, Image as Image$1, TouchableWithoutFeedback, Pressable, SafeAreaView, KeyboardAvoidingView, ScrollView, Modal, FlatList, useWindowDimensions, TextInput as TextInput$1, PanResponder,
|
|
2
|
+
import { Platform, Dimensions, StyleSheet as StyleSheet$1, Animated, View, Easing, TouchableOpacity, Text as Text$1, Image as Image$1, TouchableWithoutFeedback, Pressable, SafeAreaView, KeyboardAvoidingView, TouchableHighlight, ScrollView, Modal, FlatList, useWindowDimensions, TextInput as TextInput$1, PanResponder, InteractionManager, Keyboard, SectionList, LayoutAnimation, RefreshControl as RefreshControl$1 } from 'react-native';
|
|
3
3
|
import React, { useContext, createContext, createElement, useMemo, forwardRef, useEffect, useCallback, useRef, useState, useLayoutEffect, useImperativeHandle } from 'react';
|
|
4
4
|
import { createIconSet } from 'react-native-vector-icons';
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
@@ -1590,7 +1590,8 @@ var getRadii = function getRadii(baseRadius) {
|
|
|
1590
1590
|
large: baseRadius * 3,
|
|
1591
1591
|
xlarge: baseRadius * 4,
|
|
1592
1592
|
xxlarge: baseRadius * 5,
|
|
1593
|
-
xxxlarge: baseRadius * 6
|
|
1593
|
+
xxxlarge: baseRadius * 6,
|
|
1594
|
+
'5xlarge': baseRadius * 8 // 32
|
|
1594
1595
|
};
|
|
1595
1596
|
};
|
|
1596
1597
|
|
|
@@ -1853,6 +1854,7 @@ var getButtonTheme = function getButtonTheme(theme) {
|
|
|
1853
1854
|
};
|
|
1854
1855
|
var space = {
|
|
1855
1856
|
buttonPadding: theme.space.medium,
|
|
1857
|
+
textButtonPadding: theme.space.smallMedium,
|
|
1856
1858
|
iconPadding: theme.space.smallMedium,
|
|
1857
1859
|
utilityPadding: theme.space.small
|
|
1858
1860
|
};
|
|
@@ -1860,8 +1862,9 @@ var getButtonTheme = function getButtonTheme(theme) {
|
|
|
1860
1862
|
iconSize: theme.fontSizes.xxlarge
|
|
1861
1863
|
};
|
|
1862
1864
|
var radii = {
|
|
1863
|
-
"default": theme.
|
|
1864
|
-
utilityRadii: theme.
|
|
1865
|
+
"default": theme.radii['5xlarge'],
|
|
1866
|
+
utilityRadii: theme.radii.medium,
|
|
1867
|
+
text: theme.radii.base
|
|
1865
1868
|
};
|
|
1866
1869
|
var colors = {
|
|
1867
1870
|
primary: theme.colors.primary,
|
|
@@ -1872,7 +1875,19 @@ var getButtonTheme = function getButtonTheme(theme) {
|
|
|
1872
1875
|
disabledBorder: theme.colors.disabledOnDefaultGlobalSurface,
|
|
1873
1876
|
disabledBackground: theme.colors.disabledOnDefaultGlobalSurface,
|
|
1874
1877
|
invertedText: theme.colors.onDarkGlobalSurface,
|
|
1875
|
-
utilityBackground: theme.colors.neutralGlobalSurface
|
|
1878
|
+
utilityBackground: theme.colors.neutralGlobalSurface,
|
|
1879
|
+
textLoadingBackground: theme.colors.highlightedSurface,
|
|
1880
|
+
pressedBackground: {
|
|
1881
|
+
filledPrimary: theme.colors.pressedSurface,
|
|
1882
|
+
filledSecondary: theme.colors.pressedSurface,
|
|
1883
|
+
filledDanger: theme.colors.errorSurface,
|
|
1884
|
+
outlinedPrimary: theme.colors.highlightedSurface,
|
|
1885
|
+
outlinedSecondary: theme.colors.highlightedSurface,
|
|
1886
|
+
outlineDanger: theme.colors.errorSurface,
|
|
1887
|
+
textPrimary: theme.colors.highlightedSurface,
|
|
1888
|
+
textSecondary: theme.colors.highlightedSurface,
|
|
1889
|
+
textDanger: theme.colors.errorSurface
|
|
1890
|
+
}
|
|
1876
1891
|
};
|
|
1877
1892
|
return {
|
|
1878
1893
|
borderWidth: borderWidth,
|
|
@@ -2137,9 +2152,11 @@ var getEmptyTheme = function getEmptyTheme(theme) {
|
|
|
2137
2152
|
var getFABTheme = function getFABTheme(theme) {
|
|
2138
2153
|
var colors = {
|
|
2139
2154
|
buttonBackground: theme.colors.primary,
|
|
2155
|
+
buttonPressedBackground: theme.colors.pressedSurface,
|
|
2140
2156
|
icon: theme.colors.onPrimary,
|
|
2141
2157
|
headerText: theme.colors.onDefaultGlobalSurface,
|
|
2142
2158
|
actionItemBackground: theme.colors.primary,
|
|
2159
|
+
actionItemPressedBackground: theme.colors.pressedSurface,
|
|
2143
2160
|
backdropBackground: theme.colors.overlayGlobalSurface,
|
|
2144
2161
|
titleText: theme.colors.onPrimary,
|
|
2145
2162
|
actionItemText: theme.colors.onPrimary
|
|
@@ -7343,8 +7360,8 @@ var StyledLoadingDot = index$a(View)(function (_ref2) {
|
|
|
7343
7360
|
backgroundColor: theme.__hd__.button.colors.invertedText
|
|
7344
7361
|
};
|
|
7345
7362
|
case 'outlined-primary':
|
|
7346
|
-
case 'text-primary':
|
|
7347
7363
|
return genLoadingIndicatorStyles(theme, 'primary');
|
|
7364
|
+
case 'text-primary':
|
|
7348
7365
|
case 'outlined-secondary':
|
|
7349
7366
|
case 'text-secondary':
|
|
7350
7367
|
return genLoadingIndicatorStyles(theme, 'secondary');
|
|
@@ -7426,9 +7443,9 @@ var LoadingIndicator = function LoadingIndicator(_ref2) {
|
|
|
7426
7443
|
}, nativeProps), Array.from(new Array(count), renderLoadingDot, themeVariant));
|
|
7427
7444
|
};
|
|
7428
7445
|
|
|
7429
|
-
var genFilledContainerStyles = function genFilledContainerStyles(theme, intent, disabled) {
|
|
7446
|
+
var genFilledContainerStyles = function genFilledContainerStyles(theme, intent, disabled, loading) {
|
|
7430
7447
|
var backgroundColorStyling = function backgroundColorStyling() {
|
|
7431
|
-
if (disabled) {
|
|
7448
|
+
if (!loading && disabled) {
|
|
7432
7449
|
return {
|
|
7433
7450
|
backgroundColor: theme.__hd__.button.colors.disabledBorder
|
|
7434
7451
|
};
|
|
@@ -7446,9 +7463,9 @@ var genFilledContainerStyles = function genFilledContainerStyles(theme, intent,
|
|
|
7446
7463
|
borderRadius: theme.__hd__.button.radii["default"]
|
|
7447
7464
|
}, backgroundColorStyling());
|
|
7448
7465
|
};
|
|
7449
|
-
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled) {
|
|
7466
|
+
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled, loading) {
|
|
7450
7467
|
var borderColorStyling = function borderColorStyling() {
|
|
7451
|
-
if (disabled) {
|
|
7468
|
+
if (!loading && disabled) {
|
|
7452
7469
|
return {
|
|
7453
7470
|
borderColor: theme.__hd__.button.colors.disabledBorder
|
|
7454
7471
|
};
|
|
@@ -7500,33 +7517,37 @@ var genTextVariantTextStyles = function genTextVariantTextStyles(theme, intent,
|
|
|
7500
7517
|
lineHeight: theme.__hd__.button.lineHeight["default"]
|
|
7501
7518
|
}, textColorStyling());
|
|
7502
7519
|
};
|
|
7503
|
-
var StyledButtonContainer = index$a(
|
|
7520
|
+
var StyledButtonContainer = index$a(TouchableHighlight)(function (_ref) {
|
|
7504
7521
|
var _ref$disabled = _ref.disabled,
|
|
7505
7522
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
7523
|
+
_ref$loading = _ref.loading,
|
|
7524
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
7506
7525
|
themeVariant = _ref.themeVariant,
|
|
7507
7526
|
theme = _ref.theme;
|
|
7508
7527
|
switch (themeVariant) {
|
|
7509
7528
|
case 'filled-primary':
|
|
7510
|
-
return genFilledContainerStyles(theme, 'primary', disabled);
|
|
7529
|
+
return genFilledContainerStyles(theme, 'primary', disabled, loading);
|
|
7511
7530
|
case 'filled-secondary':
|
|
7512
|
-
return genFilledContainerStyles(theme, 'secondary', disabled);
|
|
7531
|
+
return genFilledContainerStyles(theme, 'secondary', disabled, loading);
|
|
7513
7532
|
case 'filled-danger':
|
|
7514
|
-
return genFilledContainerStyles(theme, 'danger', disabled);
|
|
7533
|
+
return genFilledContainerStyles(theme, 'danger', disabled, loading);
|
|
7515
7534
|
case 'outlined-primary':
|
|
7516
|
-
return genOutlineContainerStyles(theme, 'primary', disabled);
|
|
7535
|
+
return genOutlineContainerStyles(theme, 'primary', disabled, loading);
|
|
7517
7536
|
case 'outlined-secondary':
|
|
7518
|
-
return genOutlineContainerStyles(theme, 'secondary', disabled);
|
|
7537
|
+
return genOutlineContainerStyles(theme, 'secondary', disabled, loading);
|
|
7519
7538
|
case 'outlined-danger':
|
|
7520
|
-
return genOutlineContainerStyles(theme, 'danger', disabled);
|
|
7539
|
+
return genOutlineContainerStyles(theme, 'danger', disabled, loading);
|
|
7521
7540
|
case 'text-primary':
|
|
7522
7541
|
case 'text-secondary':
|
|
7523
7542
|
case 'text-danger':
|
|
7524
7543
|
return {
|
|
7544
|
+
borderRadius: theme.__hd__.button.radii.text,
|
|
7525
7545
|
flexDirection: 'row',
|
|
7526
7546
|
justifyContent: 'center',
|
|
7527
7547
|
alignItems: 'center',
|
|
7528
|
-
padding: theme.__hd__.button.space.
|
|
7529
|
-
borderWidth: 0
|
|
7548
|
+
padding: theme.__hd__.button.space.textButtonPadding,
|
|
7549
|
+
borderWidth: 0,
|
|
7550
|
+
backgroundColor: loading ? theme.__hd__.button.colors.textLoadingBackground : 'transparent'
|
|
7530
7551
|
};
|
|
7531
7552
|
}
|
|
7532
7553
|
});
|
|
@@ -7634,6 +7655,29 @@ var getThemeVariant = function getThemeVariant(variant, intent) {
|
|
|
7634
7655
|
return TEXT_VARIANTS[intent];
|
|
7635
7656
|
}
|
|
7636
7657
|
};
|
|
7658
|
+
var getUnderlayColor = function getUnderlayColor(theme, themeVariant) {
|
|
7659
|
+
switch (themeVariant) {
|
|
7660
|
+
case 'filled-primary':
|
|
7661
|
+
return theme.__hd__.button.colors.pressedBackground.filledPrimary;
|
|
7662
|
+
case 'filled-secondary':
|
|
7663
|
+
return theme.__hd__.button.colors.pressedBackground.filledSecondary;
|
|
7664
|
+
case 'filled-danger':
|
|
7665
|
+
return theme.__hd__.button.colors.pressedBackground.filledDanger;
|
|
7666
|
+
case 'outlined-primary':
|
|
7667
|
+
return theme.__hd__.button.colors.pressedBackground.outlinedPrimary;
|
|
7668
|
+
case 'outlined-secondary':
|
|
7669
|
+
return theme.__hd__.button.colors.pressedBackground.outlinedSecondary;
|
|
7670
|
+
case 'outlined-danger':
|
|
7671
|
+
return theme.__hd__.button.colors.pressedBackground.outlineDanger;
|
|
7672
|
+
case 'text-primary':
|
|
7673
|
+
return theme.__hd__.button.colors.pressedBackground.textPrimary;
|
|
7674
|
+
case 'text-secondary':
|
|
7675
|
+
return theme.__hd__.button.colors.pressedBackground.textSecondary;
|
|
7676
|
+
case 'text-danger':
|
|
7677
|
+
return theme.__hd__.button.colors.pressedBackground.textDanger;
|
|
7678
|
+
}
|
|
7679
|
+
};
|
|
7680
|
+
var deprecatedVariants = ['filled-secondary', 'filled-danger', 'outlined-secondary', 'outlined-danger'];
|
|
7637
7681
|
var Button = function Button(_ref) {
|
|
7638
7682
|
var accessibilityHint = _ref.accessibilityHint,
|
|
7639
7683
|
accessibilityLabel = _ref.accessibilityLabel,
|
|
@@ -7652,14 +7696,21 @@ var Button = function Button(_ref) {
|
|
|
7652
7696
|
_ref$variant = _ref.variant,
|
|
7653
7697
|
variant = _ref$variant === void 0 ? 'filled' : _ref$variant;
|
|
7654
7698
|
var themeVariant = getThemeVariant(variant, intent);
|
|
7699
|
+
var theme = useTheme();
|
|
7700
|
+
var underlayColor = useMemo(function () {
|
|
7701
|
+
return getUnderlayColor(theme, themeVariant);
|
|
7702
|
+
}, [theme, themeVariant]);
|
|
7703
|
+
useDeprecation("Button variant ".concat(deprecatedVariants.join(', '), " are deprecated."), deprecatedVariants.includes(themeVariant));
|
|
7655
7704
|
return /*#__PURE__*/React.createElement(StyledButtonContainer, {
|
|
7656
7705
|
accessibilityHint: accessibilityHint,
|
|
7657
7706
|
accessibilityLabel: accessibilityLabel,
|
|
7658
7707
|
disabled: disabled || loading,
|
|
7708
|
+
loading: loading,
|
|
7659
7709
|
onPress: onPress,
|
|
7660
7710
|
testID: testID,
|
|
7661
7711
|
themeVariant: themeVariant,
|
|
7662
|
-
style: style
|
|
7712
|
+
style: style,
|
|
7713
|
+
underlayColor: underlayColor
|
|
7663
7714
|
}, loading === true ? /*#__PURE__*/React.createElement(LoadingIndicator, {
|
|
7664
7715
|
testID: "".concat(testID, "-loading-indicator"),
|
|
7665
7716
|
themeVariant: themeVariant
|
|
@@ -12278,11 +12329,12 @@ var FAB = function FAB(_ref3) {
|
|
|
12278
12329
|
active = _ref3.active,
|
|
12279
12330
|
style = _ref3.style;
|
|
12280
12331
|
var isIconOnly = !title;
|
|
12332
|
+
var theme = useTheme();
|
|
12281
12333
|
return /*#__PURE__*/React.createElement(StyledFABContainer, {
|
|
12334
|
+
underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
|
|
12282
12335
|
testID: testID,
|
|
12283
12336
|
style: style,
|
|
12284
|
-
onPress: onPress
|
|
12285
|
-
activeOpacity: 0.6
|
|
12337
|
+
onPress: onPress
|
|
12286
12338
|
}, isIconOnly ? /*#__PURE__*/React.createElement(IconOnlyContent, {
|
|
12287
12339
|
animated: animated,
|
|
12288
12340
|
active: active,
|
|
@@ -12293,7 +12345,7 @@ var FAB = function FAB(_ref3) {
|
|
|
12293
12345
|
}));
|
|
12294
12346
|
};
|
|
12295
12347
|
|
|
12296
|
-
var StyledActionItem = index$a(
|
|
12348
|
+
var StyledActionItem = index$a(TouchableHighlight)(function (_ref) {
|
|
12297
12349
|
var theme = _ref.theme;
|
|
12298
12350
|
return {
|
|
12299
12351
|
paddingLeft: theme.__hd__.fab.space.actionItemPaddingLeft,
|
|
@@ -12333,13 +12385,15 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
12333
12385
|
onPress = _ref.onPress,
|
|
12334
12386
|
style = _ref.style,
|
|
12335
12387
|
testID = _ref.testID;
|
|
12388
|
+
var theme = useTheme();
|
|
12336
12389
|
return /*#__PURE__*/React.createElement(StyledActionItem, {
|
|
12390
|
+
underlayColor: theme.__hd__.fab.colors.actionItemPressedBackground,
|
|
12337
12391
|
style: style,
|
|
12338
12392
|
onPress: onPress,
|
|
12339
12393
|
testID: testID
|
|
12340
|
-
}, /*#__PURE__*/React.createElement(StyledIcon, {
|
|
12394
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledIcon, {
|
|
12341
12395
|
icon: icon
|
|
12342
|
-
}), /*#__PURE__*/React.createElement(StyledActionItemText, null, title));
|
|
12396
|
+
}), /*#__PURE__*/React.createElement(StyledActionItemText, null, title)));
|
|
12343
12397
|
};
|
|
12344
12398
|
|
|
12345
12399
|
var StyledContainer$1 = index$a(View)({
|
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
|
|
@@ -7372,8 +7389,8 @@ var StyledLoadingDot = index$a(reactNative.View)(function (_ref2) {
|
|
|
7372
7389
|
backgroundColor: theme.__hd__.button.colors.invertedText
|
|
7373
7390
|
};
|
|
7374
7391
|
case 'outlined-primary':
|
|
7375
|
-
case 'text-primary':
|
|
7376
7392
|
return genLoadingIndicatorStyles(theme, 'primary');
|
|
7393
|
+
case 'text-primary':
|
|
7377
7394
|
case 'outlined-secondary':
|
|
7378
7395
|
case 'text-secondary':
|
|
7379
7396
|
return genLoadingIndicatorStyles(theme, 'secondary');
|
|
@@ -7455,9 +7472,9 @@ var LoadingIndicator = function LoadingIndicator(_ref2) {
|
|
|
7455
7472
|
}, nativeProps), Array.from(new Array(count), renderLoadingDot, themeVariant));
|
|
7456
7473
|
};
|
|
7457
7474
|
|
|
7458
|
-
var genFilledContainerStyles = function genFilledContainerStyles(theme, intent, disabled) {
|
|
7475
|
+
var genFilledContainerStyles = function genFilledContainerStyles(theme, intent, disabled, loading) {
|
|
7459
7476
|
var backgroundColorStyling = function backgroundColorStyling() {
|
|
7460
|
-
if (disabled) {
|
|
7477
|
+
if (!loading && disabled) {
|
|
7461
7478
|
return {
|
|
7462
7479
|
backgroundColor: theme.__hd__.button.colors.disabledBorder
|
|
7463
7480
|
};
|
|
@@ -7475,9 +7492,9 @@ var genFilledContainerStyles = function genFilledContainerStyles(theme, intent,
|
|
|
7475
7492
|
borderRadius: theme.__hd__.button.radii["default"]
|
|
7476
7493
|
}, backgroundColorStyling());
|
|
7477
7494
|
};
|
|
7478
|
-
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled) {
|
|
7495
|
+
var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent, disabled, loading) {
|
|
7479
7496
|
var borderColorStyling = function borderColorStyling() {
|
|
7480
|
-
if (disabled) {
|
|
7497
|
+
if (!loading && disabled) {
|
|
7481
7498
|
return {
|
|
7482
7499
|
borderColor: theme.__hd__.button.colors.disabledBorder
|
|
7483
7500
|
};
|
|
@@ -7529,33 +7546,37 @@ var genTextVariantTextStyles = function genTextVariantTextStyles(theme, intent,
|
|
|
7529
7546
|
lineHeight: theme.__hd__.button.lineHeight["default"]
|
|
7530
7547
|
}, textColorStyling());
|
|
7531
7548
|
};
|
|
7532
|
-
var StyledButtonContainer = index$a(reactNative.
|
|
7549
|
+
var StyledButtonContainer = index$a(reactNative.TouchableHighlight)(function (_ref) {
|
|
7533
7550
|
var _ref$disabled = _ref.disabled,
|
|
7534
7551
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
7552
|
+
_ref$loading = _ref.loading,
|
|
7553
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
7535
7554
|
themeVariant = _ref.themeVariant,
|
|
7536
7555
|
theme = _ref.theme;
|
|
7537
7556
|
switch (themeVariant) {
|
|
7538
7557
|
case 'filled-primary':
|
|
7539
|
-
return genFilledContainerStyles(theme, 'primary', disabled);
|
|
7558
|
+
return genFilledContainerStyles(theme, 'primary', disabled, loading);
|
|
7540
7559
|
case 'filled-secondary':
|
|
7541
|
-
return genFilledContainerStyles(theme, 'secondary', disabled);
|
|
7560
|
+
return genFilledContainerStyles(theme, 'secondary', disabled, loading);
|
|
7542
7561
|
case 'filled-danger':
|
|
7543
|
-
return genFilledContainerStyles(theme, 'danger', disabled);
|
|
7562
|
+
return genFilledContainerStyles(theme, 'danger', disabled, loading);
|
|
7544
7563
|
case 'outlined-primary':
|
|
7545
|
-
return genOutlineContainerStyles(theme, 'primary', disabled);
|
|
7564
|
+
return genOutlineContainerStyles(theme, 'primary', disabled, loading);
|
|
7546
7565
|
case 'outlined-secondary':
|
|
7547
|
-
return genOutlineContainerStyles(theme, 'secondary', disabled);
|
|
7566
|
+
return genOutlineContainerStyles(theme, 'secondary', disabled, loading);
|
|
7548
7567
|
case 'outlined-danger':
|
|
7549
|
-
return genOutlineContainerStyles(theme, 'danger', disabled);
|
|
7568
|
+
return genOutlineContainerStyles(theme, 'danger', disabled, loading);
|
|
7550
7569
|
case 'text-primary':
|
|
7551
7570
|
case 'text-secondary':
|
|
7552
7571
|
case 'text-danger':
|
|
7553
7572
|
return {
|
|
7573
|
+
borderRadius: theme.__hd__.button.radii.text,
|
|
7554
7574
|
flexDirection: 'row',
|
|
7555
7575
|
justifyContent: 'center',
|
|
7556
7576
|
alignItems: 'center',
|
|
7557
|
-
padding: theme.__hd__.button.space.
|
|
7558
|
-
borderWidth: 0
|
|
7577
|
+
padding: theme.__hd__.button.space.textButtonPadding,
|
|
7578
|
+
borderWidth: 0,
|
|
7579
|
+
backgroundColor: loading ? theme.__hd__.button.colors.textLoadingBackground : 'transparent'
|
|
7559
7580
|
};
|
|
7560
7581
|
}
|
|
7561
7582
|
});
|
|
@@ -7663,6 +7684,29 @@ var getThemeVariant = function getThemeVariant(variant, intent) {
|
|
|
7663
7684
|
return TEXT_VARIANTS[intent];
|
|
7664
7685
|
}
|
|
7665
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'];
|
|
7666
7710
|
var Button = function Button(_ref) {
|
|
7667
7711
|
var accessibilityHint = _ref.accessibilityHint,
|
|
7668
7712
|
accessibilityLabel = _ref.accessibilityLabel,
|
|
@@ -7681,14 +7725,21 @@ var Button = function Button(_ref) {
|
|
|
7681
7725
|
_ref$variant = _ref.variant,
|
|
7682
7726
|
variant = _ref$variant === void 0 ? 'filled' : _ref$variant;
|
|
7683
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));
|
|
7684
7733
|
return /*#__PURE__*/React__default["default"].createElement(StyledButtonContainer, {
|
|
7685
7734
|
accessibilityHint: accessibilityHint,
|
|
7686
7735
|
accessibilityLabel: accessibilityLabel,
|
|
7687
7736
|
disabled: disabled || loading,
|
|
7737
|
+
loading: loading,
|
|
7688
7738
|
onPress: onPress,
|
|
7689
7739
|
testID: testID,
|
|
7690
7740
|
themeVariant: themeVariant,
|
|
7691
|
-
style: style
|
|
7741
|
+
style: style,
|
|
7742
|
+
underlayColor: underlayColor
|
|
7692
7743
|
}, loading === true ? /*#__PURE__*/React__default["default"].createElement(LoadingIndicator, {
|
|
7693
7744
|
testID: "".concat(testID, "-loading-indicator"),
|
|
7694
7745
|
themeVariant: themeVariant
|
|
@@ -12307,11 +12358,12 @@ var FAB = function FAB(_ref3) {
|
|
|
12307
12358
|
active = _ref3.active,
|
|
12308
12359
|
style = _ref3.style;
|
|
12309
12360
|
var isIconOnly = !title;
|
|
12361
|
+
var theme = useTheme();
|
|
12310
12362
|
return /*#__PURE__*/React__default["default"].createElement(StyledFABContainer, {
|
|
12363
|
+
underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
|
|
12311
12364
|
testID: testID,
|
|
12312
12365
|
style: style,
|
|
12313
|
-
onPress: onPress
|
|
12314
|
-
activeOpacity: 0.6
|
|
12366
|
+
onPress: onPress
|
|
12315
12367
|
}, isIconOnly ? /*#__PURE__*/React__default["default"].createElement(IconOnlyContent, {
|
|
12316
12368
|
animated: animated,
|
|
12317
12369
|
active: active,
|
|
@@ -12322,7 +12374,7 @@ var FAB = function FAB(_ref3) {
|
|
|
12322
12374
|
}));
|
|
12323
12375
|
};
|
|
12324
12376
|
|
|
12325
|
-
var StyledActionItem = index$a(reactNative.
|
|
12377
|
+
var StyledActionItem = index$a(reactNative.TouchableHighlight)(function (_ref) {
|
|
12326
12378
|
var theme = _ref.theme;
|
|
12327
12379
|
return {
|
|
12328
12380
|
paddingLeft: theme.__hd__.fab.space.actionItemPaddingLeft,
|
|
@@ -12362,13 +12414,15 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
12362
12414
|
onPress = _ref.onPress,
|
|
12363
12415
|
style = _ref.style,
|
|
12364
12416
|
testID = _ref.testID;
|
|
12417
|
+
var theme = useTheme();
|
|
12365
12418
|
return /*#__PURE__*/React__default["default"].createElement(StyledActionItem, {
|
|
12419
|
+
underlayColor: theme.__hd__.fab.colors.actionItemPressedBackground,
|
|
12366
12420
|
style: style,
|
|
12367
12421
|
onPress: onPress,
|
|
12368
12422
|
testID: testID
|
|
12369
|
-
}, /*#__PURE__*/React__default["default"].createElement(StyledIcon, {
|
|
12423
|
+
}, /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(StyledIcon, {
|
|
12370
12424
|
icon: icon
|
|
12371
|
-
}), /*#__PURE__*/React__default["default"].createElement(StyledActionItemText, null, title));
|
|
12425
|
+
}), /*#__PURE__*/React__default["default"].createElement(StyledActionItemText, null, title)));
|
|
12372
12426
|
};
|
|
12373
12427
|
|
|
12374
12428
|
var StyledContainer$1 = index$a(reactNative.View)({
|
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,
|