@hero-design/rn 8.26.0 → 8.26.1
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/.eslintrc.js +2 -1
- package/.turbo/turbo-build.log +1 -1
- package/es/index.js +68 -12
- package/lib/index.js +68 -12
- package/package.json +6 -5
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +17 -3
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +558 -1066
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +9 -15
- package/src/components/FAB/ActionGroup/index.tsx +97 -35
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +1 -0
- package/src/theme/components/fab.ts +1 -0
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +7 -1
- package/types/theme/components/fab.d.ts +1 -0
package/.eslintrc.js
CHANGED
|
@@ -5,8 +5,9 @@ module.exports = {
|
|
|
5
5
|
project: ['./tsconfig.json'],
|
|
6
6
|
},
|
|
7
7
|
extends: ['hd', 'plugin:@hero-design/recommendedRn'],
|
|
8
|
-
plugins: ['@hero-design'],
|
|
8
|
+
plugins: ['@hero-design', 'import'],
|
|
9
9
|
rules: {
|
|
10
10
|
'no-underscore-dangle': [2, { allow: ['__hd__'] }],
|
|
11
|
+
'import/no-cycle': 2,
|
|
11
12
|
},
|
|
12
13
|
};
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -4,5 +4,5 @@ $ rollup -c
|
|
|
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 '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning[39m[22m
|
|
7
|
-
[32mcreated [1mlib/index.js, es/index.js[22m in [1m25.
|
|
7
|
+
[32mcreated [1mlib/index.js, es/index.js[22m in [1m25.7s[22m[39m
|
|
8
8
|
$ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
|
package/es/index.js
CHANGED
|
@@ -2327,7 +2327,8 @@ var getFABTheme = function getFABTheme(theme) {
|
|
|
2327
2327
|
headerTextMarginRight: theme.space.large,
|
|
2328
2328
|
headerTextMarginBottom: theme.space.large,
|
|
2329
2329
|
containerPadding: theme.space.large - theme.space.xsmall,
|
|
2330
|
-
titleMarginHorizontal: theme.space.small
|
|
2330
|
+
titleMarginHorizontal: theme.space.small,
|
|
2331
|
+
internalFABMarginBottom: theme.space.large
|
|
2331
2332
|
};
|
|
2332
2333
|
var radii = {
|
|
2333
2334
|
actionItem: theme.radii.rounded
|
|
@@ -13070,10 +13071,11 @@ var StyledBackdrop = index$a(Animated.View)(function (_ref2) {
|
|
|
13070
13071
|
var theme = _ref2.theme;
|
|
13071
13072
|
return {
|
|
13072
13073
|
position: 'absolute',
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
|
|
13074
|
+
flex: 1,
|
|
13075
|
+
height: '100%',
|
|
13076
|
+
width: '100%',
|
|
13076
13077
|
bottom: 0,
|
|
13078
|
+
right: 0,
|
|
13077
13079
|
backgroundColor: theme.__hd__.fab.colors.backdropBackground
|
|
13078
13080
|
};
|
|
13079
13081
|
});
|
|
@@ -13089,6 +13091,17 @@ var StyledHeaderText = index$a(Typography.Text)(function (_ref3) {
|
|
|
13089
13091
|
textAlign: 'right'
|
|
13090
13092
|
};
|
|
13091
13093
|
});
|
|
13094
|
+
var StyledModalView = index$a(View)({
|
|
13095
|
+
position: 'absolute',
|
|
13096
|
+
flex: 1,
|
|
13097
|
+
height: '100%',
|
|
13098
|
+
width: '100%',
|
|
13099
|
+
bottom: 0,
|
|
13100
|
+
right: 0,
|
|
13101
|
+
justifyContent: 'flex-end',
|
|
13102
|
+
alignItems: 'flex-end',
|
|
13103
|
+
backgroundColor: 'transparent'
|
|
13104
|
+
});
|
|
13092
13105
|
|
|
13093
13106
|
var ActionItemsListComponent = function ActionItemsListComponent(_ref) {
|
|
13094
13107
|
var style = _ref.style,
|
|
@@ -13111,15 +13124,43 @@ var ActionGroup = function ActionGroup(_ref2) {
|
|
|
13111
13124
|
fabTitle = _ref2.fabTitle,
|
|
13112
13125
|
_ref2$fabIcon = _ref2.fabIcon,
|
|
13113
13126
|
fabIcon = _ref2$fabIcon === void 0 ? 'add' : _ref2$fabIcon;
|
|
13127
|
+
var theme = useTheme();
|
|
13128
|
+
// Internal state to control the animation of the action group
|
|
13129
|
+
var _useState = useState(active),
|
|
13130
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13131
|
+
visible = _useState2[0],
|
|
13132
|
+
setVisibility = _useState2[1];
|
|
13114
13133
|
var tranlateXAnimation = useRef(new Animated.Value(active ? 1 : 0));
|
|
13115
13134
|
useEffect(function () {
|
|
13135
|
+
if (active && !visible) {
|
|
13136
|
+
setVisibility(true);
|
|
13137
|
+
}
|
|
13138
|
+
}, [active]);
|
|
13139
|
+
useEffect(function () {
|
|
13140
|
+
if (active) {
|
|
13141
|
+
var animation = Animated.timing(tranlateXAnimation.current, {
|
|
13142
|
+
toValue: 1,
|
|
13143
|
+
useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
|
|
13144
|
+
easing: Easing.inOut(Easing.cubic)
|
|
13145
|
+
});
|
|
13146
|
+
animation.start();
|
|
13147
|
+
}
|
|
13148
|
+
}, [active]);
|
|
13149
|
+
// Make sure the animation finishes running before closing the modal
|
|
13150
|
+
var onInternalFABPress = useCallback(function () {
|
|
13151
|
+
if (!onPress) {
|
|
13152
|
+
return;
|
|
13153
|
+
}
|
|
13116
13154
|
var animation = Animated.timing(tranlateXAnimation.current, {
|
|
13117
|
-
toValue:
|
|
13155
|
+
toValue: 0,
|
|
13118
13156
|
useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
|
|
13119
13157
|
easing: Easing.inOut(Easing.cubic)
|
|
13120
13158
|
});
|
|
13121
|
-
animation.start()
|
|
13122
|
-
|
|
13159
|
+
animation.start(function () {
|
|
13160
|
+
setVisibility(false);
|
|
13161
|
+
onPress();
|
|
13162
|
+
});
|
|
13163
|
+
}, [visible]);
|
|
13123
13164
|
var interpolatedTranlateXAnimation = tranlateXAnimation.current.interpolate({
|
|
13124
13165
|
inputRange: [0, 1],
|
|
13125
13166
|
outputRange: [400, 0]
|
|
@@ -13136,13 +13177,18 @@ var ActionGroup = function ActionGroup(_ref2) {
|
|
|
13136
13177
|
testID: testID,
|
|
13137
13178
|
pointerEvents: "box-none",
|
|
13138
13179
|
style: style
|
|
13180
|
+
}, /*#__PURE__*/React.createElement(Modal, {
|
|
13181
|
+
visible: visible,
|
|
13182
|
+
transparent: true,
|
|
13183
|
+
statusBarTranslucent: true,
|
|
13184
|
+
animationType: "none"
|
|
13139
13185
|
}, /*#__PURE__*/React.createElement(StyledBackdrop, {
|
|
13140
|
-
pointerEvents: active ? 'auto' : 'box-none',
|
|
13141
|
-
testID: "back-drop",
|
|
13142
13186
|
style: {
|
|
13143
13187
|
opacity: interpolatedBackdropOpacityAnimation
|
|
13144
|
-
}
|
|
13145
|
-
|
|
13188
|
+
},
|
|
13189
|
+
testID: "back-drop",
|
|
13190
|
+
pointerEvents: active ? 'auto' : 'box-none'
|
|
13191
|
+
}), /*#__PURE__*/React.createElement(StyledModalView, null, /*#__PURE__*/React.createElement(StyledActionGroupContainer, {
|
|
13146
13192
|
pointerEvents: active ? 'auto' : 'none',
|
|
13147
13193
|
testID: "action-group",
|
|
13148
13194
|
style: {
|
|
@@ -13155,7 +13201,17 @@ var ActionGroup = function ActionGroup(_ref2) {
|
|
|
13155
13201
|
testID: "header-text"
|
|
13156
13202
|
}, headerTitle), /*#__PURE__*/React.createElement(ActionItemsListComponent, {
|
|
13157
13203
|
items: items
|
|
13158
|
-
})), /*#__PURE__*/React.createElement(StyledFAB, {
|
|
13204
|
+
})), active && /*#__PURE__*/React.createElement(StyledFAB, {
|
|
13205
|
+
testID: "fab",
|
|
13206
|
+
icon: fabIcon,
|
|
13207
|
+
onPress: onInternalFABPress,
|
|
13208
|
+
animated: true,
|
|
13209
|
+
active: active,
|
|
13210
|
+
title: fabTitle,
|
|
13211
|
+
style: {
|
|
13212
|
+
marginBottom: theme.__hd__.fab.space.internalFABMarginBottom
|
|
13213
|
+
}
|
|
13214
|
+
}))), !active && /*#__PURE__*/React.createElement(StyledFAB, {
|
|
13159
13215
|
testID: "fab",
|
|
13160
13216
|
icon: fabIcon,
|
|
13161
13217
|
onPress: onPress,
|
package/lib/index.js
CHANGED
|
@@ -2357,7 +2357,8 @@ var getFABTheme = function getFABTheme(theme) {
|
|
|
2357
2357
|
headerTextMarginRight: theme.space.large,
|
|
2358
2358
|
headerTextMarginBottom: theme.space.large,
|
|
2359
2359
|
containerPadding: theme.space.large - theme.space.xsmall,
|
|
2360
|
-
titleMarginHorizontal: theme.space.small
|
|
2360
|
+
titleMarginHorizontal: theme.space.small,
|
|
2361
|
+
internalFABMarginBottom: theme.space.large
|
|
2361
2362
|
};
|
|
2362
2363
|
var radii = {
|
|
2363
2364
|
actionItem: theme.radii.rounded
|
|
@@ -13100,10 +13101,11 @@ var StyledBackdrop = index$a(reactNative.Animated.View)(function (_ref2) {
|
|
|
13100
13101
|
var theme = _ref2.theme;
|
|
13101
13102
|
return {
|
|
13102
13103
|
position: 'absolute',
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13104
|
+
flex: 1,
|
|
13105
|
+
height: '100%',
|
|
13106
|
+
width: '100%',
|
|
13106
13107
|
bottom: 0,
|
|
13108
|
+
right: 0,
|
|
13107
13109
|
backgroundColor: theme.__hd__.fab.colors.backdropBackground
|
|
13108
13110
|
};
|
|
13109
13111
|
});
|
|
@@ -13119,6 +13121,17 @@ var StyledHeaderText = index$a(Typography.Text)(function (_ref3) {
|
|
|
13119
13121
|
textAlign: 'right'
|
|
13120
13122
|
};
|
|
13121
13123
|
});
|
|
13124
|
+
var StyledModalView = index$a(reactNative.View)({
|
|
13125
|
+
position: 'absolute',
|
|
13126
|
+
flex: 1,
|
|
13127
|
+
height: '100%',
|
|
13128
|
+
width: '100%',
|
|
13129
|
+
bottom: 0,
|
|
13130
|
+
right: 0,
|
|
13131
|
+
justifyContent: 'flex-end',
|
|
13132
|
+
alignItems: 'flex-end',
|
|
13133
|
+
backgroundColor: 'transparent'
|
|
13134
|
+
});
|
|
13122
13135
|
|
|
13123
13136
|
var ActionItemsListComponent = function ActionItemsListComponent(_ref) {
|
|
13124
13137
|
var style = _ref.style,
|
|
@@ -13141,15 +13154,43 @@ var ActionGroup = function ActionGroup(_ref2) {
|
|
|
13141
13154
|
fabTitle = _ref2.fabTitle,
|
|
13142
13155
|
_ref2$fabIcon = _ref2.fabIcon,
|
|
13143
13156
|
fabIcon = _ref2$fabIcon === void 0 ? 'add' : _ref2$fabIcon;
|
|
13157
|
+
var theme = useTheme();
|
|
13158
|
+
// Internal state to control the animation of the action group
|
|
13159
|
+
var _useState = React.useState(active),
|
|
13160
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13161
|
+
visible = _useState2[0],
|
|
13162
|
+
setVisibility = _useState2[1];
|
|
13144
13163
|
var tranlateXAnimation = React.useRef(new reactNative.Animated.Value(active ? 1 : 0));
|
|
13145
13164
|
React.useEffect(function () {
|
|
13165
|
+
if (active && !visible) {
|
|
13166
|
+
setVisibility(true);
|
|
13167
|
+
}
|
|
13168
|
+
}, [active]);
|
|
13169
|
+
React.useEffect(function () {
|
|
13170
|
+
if (active) {
|
|
13171
|
+
var animation = reactNative.Animated.timing(tranlateXAnimation.current, {
|
|
13172
|
+
toValue: 1,
|
|
13173
|
+
useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android',
|
|
13174
|
+
easing: reactNative.Easing.inOut(reactNative.Easing.cubic)
|
|
13175
|
+
});
|
|
13176
|
+
animation.start();
|
|
13177
|
+
}
|
|
13178
|
+
}, [active]);
|
|
13179
|
+
// Make sure the animation finishes running before closing the modal
|
|
13180
|
+
var onInternalFABPress = React.useCallback(function () {
|
|
13181
|
+
if (!onPress) {
|
|
13182
|
+
return;
|
|
13183
|
+
}
|
|
13146
13184
|
var animation = reactNative.Animated.timing(tranlateXAnimation.current, {
|
|
13147
|
-
toValue:
|
|
13185
|
+
toValue: 0,
|
|
13148
13186
|
useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android',
|
|
13149
13187
|
easing: reactNative.Easing.inOut(reactNative.Easing.cubic)
|
|
13150
13188
|
});
|
|
13151
|
-
animation.start()
|
|
13152
|
-
|
|
13189
|
+
animation.start(function () {
|
|
13190
|
+
setVisibility(false);
|
|
13191
|
+
onPress();
|
|
13192
|
+
});
|
|
13193
|
+
}, [visible]);
|
|
13153
13194
|
var interpolatedTranlateXAnimation = tranlateXAnimation.current.interpolate({
|
|
13154
13195
|
inputRange: [0, 1],
|
|
13155
13196
|
outputRange: [400, 0]
|
|
@@ -13166,13 +13207,18 @@ var ActionGroup = function ActionGroup(_ref2) {
|
|
|
13166
13207
|
testID: testID,
|
|
13167
13208
|
pointerEvents: "box-none",
|
|
13168
13209
|
style: style
|
|
13210
|
+
}, /*#__PURE__*/React__default["default"].createElement(reactNative.Modal, {
|
|
13211
|
+
visible: visible,
|
|
13212
|
+
transparent: true,
|
|
13213
|
+
statusBarTranslucent: true,
|
|
13214
|
+
animationType: "none"
|
|
13169
13215
|
}, /*#__PURE__*/React__default["default"].createElement(StyledBackdrop, {
|
|
13170
|
-
pointerEvents: active ? 'auto' : 'box-none',
|
|
13171
|
-
testID: "back-drop",
|
|
13172
13216
|
style: {
|
|
13173
13217
|
opacity: interpolatedBackdropOpacityAnimation
|
|
13174
|
-
}
|
|
13175
|
-
|
|
13218
|
+
},
|
|
13219
|
+
testID: "back-drop",
|
|
13220
|
+
pointerEvents: active ? 'auto' : 'box-none'
|
|
13221
|
+
}), /*#__PURE__*/React__default["default"].createElement(StyledModalView, null, /*#__PURE__*/React__default["default"].createElement(StyledActionGroupContainer, {
|
|
13176
13222
|
pointerEvents: active ? 'auto' : 'none',
|
|
13177
13223
|
testID: "action-group",
|
|
13178
13224
|
style: {
|
|
@@ -13185,7 +13231,17 @@ var ActionGroup = function ActionGroup(_ref2) {
|
|
|
13185
13231
|
testID: "header-text"
|
|
13186
13232
|
}, headerTitle), /*#__PURE__*/React__default["default"].createElement(ActionItemsListComponent, {
|
|
13187
13233
|
items: items
|
|
13188
|
-
})), /*#__PURE__*/React__default["default"].createElement(StyledFAB, {
|
|
13234
|
+
})), active && /*#__PURE__*/React__default["default"].createElement(StyledFAB, {
|
|
13235
|
+
testID: "fab",
|
|
13236
|
+
icon: fabIcon,
|
|
13237
|
+
onPress: onInternalFABPress,
|
|
13238
|
+
animated: true,
|
|
13239
|
+
active: active,
|
|
13240
|
+
title: fabTitle,
|
|
13241
|
+
style: {
|
|
13242
|
+
marginBottom: theme.__hd__.fab.space.internalFABMarginBottom
|
|
13243
|
+
}
|
|
13244
|
+
}))), !active && /*#__PURE__*/React__default["default"].createElement(StyledFAB, {
|
|
13189
13245
|
testID: "fab",
|
|
13190
13246
|
icon: fabIcon,
|
|
13191
13247
|
onPress: onPress,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.26.
|
|
3
|
+
"version": "8.26.1",
|
|
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.26.
|
|
24
|
+
"@hero-design/colors": "8.26.1",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/preset-typescript": "^7.17.12",
|
|
46
46
|
"@babel/runtime": "^7.18.9",
|
|
47
47
|
"@emotion/jest": "^11.9.3",
|
|
48
|
-
"@hero-design/eslint-plugin": "8.26.
|
|
48
|
+
"@hero-design/eslint-plugin": "8.26.1",
|
|
49
49
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
50
50
|
"@react-native-community/slider": "4.1.12",
|
|
51
51
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -61,9 +61,10 @@
|
|
|
61
61
|
"@types/react-native": "^0.67.7",
|
|
62
62
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
63
63
|
"babel-plugin-inline-import": "^3.0.0",
|
|
64
|
-
"eslint-config-hd": "8.26.
|
|
64
|
+
"eslint-config-hd": "8.26.1",
|
|
65
|
+
"eslint-plugin-import": "^2.27.5",
|
|
65
66
|
"jest": "^27.3.1",
|
|
66
|
-
"prettier-config-hd": "8.26.
|
|
67
|
+
"prettier-config-hd": "8.26.1",
|
|
67
68
|
"react": "18.0.0",
|
|
68
69
|
"react-native": "0.69.7",
|
|
69
70
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -34,10 +34,11 @@ const StyledBackdrop = styled(Animated.View)<
|
|
|
34
34
|
ComponentProps<typeof Animated.View>
|
|
35
35
|
>(({ theme }) => ({
|
|
36
36
|
position: 'absolute',
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
flex: 1,
|
|
38
|
+
height: '100%',
|
|
39
|
+
width: '100%',
|
|
40
40
|
bottom: 0,
|
|
41
|
+
right: 0,
|
|
41
42
|
backgroundColor: theme.__hd__.fab.colors.backdropBackground,
|
|
42
43
|
}));
|
|
43
44
|
|
|
@@ -51,10 +52,23 @@ const StyledHeaderText = styled(Typography.Text)<TextProps>(({ theme }) => ({
|
|
|
51
52
|
textAlign: 'right',
|
|
52
53
|
}));
|
|
53
54
|
|
|
55
|
+
const StyledModalView = styled(View)({
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
flex: 1,
|
|
58
|
+
height: '100%',
|
|
59
|
+
width: '100%',
|
|
60
|
+
bottom: 0,
|
|
61
|
+
right: 0,
|
|
62
|
+
justifyContent: 'flex-end',
|
|
63
|
+
alignItems: 'flex-end',
|
|
64
|
+
backgroundColor: 'transparent',
|
|
65
|
+
});
|
|
66
|
+
|
|
54
67
|
export {
|
|
55
68
|
StyledHeaderText,
|
|
56
69
|
StyledBackdrop,
|
|
57
70
|
StyledContainer,
|
|
58
71
|
StyledActionGroupContainer,
|
|
59
72
|
StyledFAB,
|
|
73
|
+
StyledModalView,
|
|
60
74
|
};
|