@hero-design/rn 8.27.2 → 8.27.3
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 +1 -1
- package/es/index.js +31 -7
- package/lib/index.js +31 -7
- package/package.json +5 -5
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +4 -0
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +6 -0
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +6 -6
- package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Collapse/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
- package/src/components/Collapse/index.tsx +25 -4
- package/src/components/DatePicker/DatePickerIOS.tsx +19 -1
- package/src/components/DatePicker/__tests__/DatePickerIOS.spec.tsx +25 -1
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +3 -3
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +1 -1
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +1 -1
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +1 -1
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +2 -2
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +3 -3
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +3 -3
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +1 -1
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +1 -1
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +3 -3
- package/src/components/Tag/StyledTag.tsx +1 -0
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +19 -10
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1 -1
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +14 -14
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +2 -2
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +2 -2
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +2 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +10 -7
- package/src/theme/components/tag.ts +5 -2
- package/src/theme/global/typography.ts +2 -2
- package/types/components/Collapse/index.d.ts +1 -1
- package/types/components/DatePicker/DatePickerIOS.d.ts +1 -0
- package/types/theme/components/tag.d.ts +3 -0
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 [
|
|
7
|
+
[32mcreated [1mlib/index.js, es/index.js[22m in [1m28.8s[22m[39m
|
|
8
8
|
$ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
|
package/es/index.js
CHANGED
|
@@ -1608,8 +1608,8 @@ var getLineHeights = function getLineHeights(fontSizes) {
|
|
|
1608
1608
|
xlarge: fontSizes.xlarge + additionalSpace,
|
|
1609
1609
|
large: fontSizes.large + additionalSpace,
|
|
1610
1610
|
medium: fontSizes.medium + additionalSpace,
|
|
1611
|
-
small: fontSizes.small + additionalSpace,
|
|
1612
|
-
xsmall: fontSizes.xsmall + additionalSpace
|
|
1611
|
+
small: fontSizes.small + additionalSpace / 2,
|
|
1612
|
+
xsmall: fontSizes.xsmall + additionalSpace / 2
|
|
1613
1613
|
};
|
|
1614
1614
|
};
|
|
1615
1615
|
|
|
@@ -2867,9 +2867,12 @@ var getTagTheme = function getTagTheme(theme) {
|
|
|
2867
2867
|
var fontSizes = {
|
|
2868
2868
|
"default": theme.fontSizes.small
|
|
2869
2869
|
};
|
|
2870
|
+
var lineHeights = {
|
|
2871
|
+
"default": theme.lineHeights.small
|
|
2872
|
+
};
|
|
2870
2873
|
var space = {
|
|
2871
2874
|
horizontalPadding: theme.space.small,
|
|
2872
|
-
verticalPadding: theme.space.
|
|
2875
|
+
verticalPadding: theme.space.xsmall
|
|
2873
2876
|
};
|
|
2874
2877
|
var radii = {
|
|
2875
2878
|
"default": theme.radii.base
|
|
@@ -2880,7 +2883,8 @@ var getTagTheme = function getTagTheme(theme) {
|
|
|
2880
2883
|
fonts: fonts,
|
|
2881
2884
|
fontSizes: fontSizes,
|
|
2882
2885
|
space: space,
|
|
2883
|
-
radii: radii
|
|
2886
|
+
radii: radii,
|
|
2887
|
+
lineHeights: lineHeights
|
|
2884
2888
|
};
|
|
2885
2889
|
};
|
|
2886
2890
|
|
|
@@ -6099,14 +6103,19 @@ var Collapse = function Collapse(_ref) {
|
|
|
6099
6103
|
open = _ref$open === void 0 ? false : _ref$open,
|
|
6100
6104
|
children = _ref.children,
|
|
6101
6105
|
testID = _ref.testID,
|
|
6102
|
-
style = _ref.style
|
|
6106
|
+
style = _ref.style,
|
|
6107
|
+
onLayout = _ref.onLayout;
|
|
6103
6108
|
var _React$useState = React.useState(0),
|
|
6104
6109
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6105
6110
|
contentHeight = _React$useState2[0],
|
|
6106
6111
|
setContentHeight = _React$useState2[1];
|
|
6112
|
+
var _React$useState3 = React.useState(false),
|
|
6113
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
6114
|
+
componentMounted = _React$useState4[0],
|
|
6115
|
+
setComponentMounted = _React$useState4[1];
|
|
6107
6116
|
var previousOpenState = usePrevious(open);
|
|
6108
6117
|
useEffect(function () {
|
|
6109
|
-
if (open !== previousOpenState && previousOpenState !== undefined || open) {
|
|
6118
|
+
if ((open !== previousOpenState && previousOpenState !== undefined || open) && componentMounted) {
|
|
6110
6119
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
6111
6120
|
}
|
|
6112
6121
|
}, [open, previousOpenState, contentHeight]);
|
|
@@ -6114,10 +6123,15 @@ var Collapse = function Collapse(_ref) {
|
|
|
6114
6123
|
var height = _ref2.height;
|
|
6115
6124
|
setContentHeight(height);
|
|
6116
6125
|
}, []);
|
|
6126
|
+
var onCollapseLayout = useCallback(function (e) {
|
|
6127
|
+
setComponentMounted(true);
|
|
6128
|
+
onLayout === null || onLayout === void 0 ? void 0 : onLayout(e);
|
|
6129
|
+
}, []);
|
|
6117
6130
|
return /*#__PURE__*/React.createElement(StyledWrapper$c, {
|
|
6118
6131
|
style: {
|
|
6119
6132
|
height: open ? contentHeight : 0
|
|
6120
6133
|
},
|
|
6134
|
+
onLayout: onCollapseLayout,
|
|
6121
6135
|
testID: testID
|
|
6122
6136
|
}, /*#__PURE__*/React.createElement(StyledHiddenWrapper, null, /*#__PURE__*/React.createElement(StyledChildWrapper, {
|
|
6123
6137
|
onLayout: function onLayout(event) {
|
|
@@ -12218,6 +12232,15 @@ var StyledPickerWrapper$1 = index$a(View)(function (_ref) {
|
|
|
12218
12232
|
};
|
|
12219
12233
|
});
|
|
12220
12234
|
|
|
12235
|
+
var getInitialDateValue = function getInitialDateValue(value, minDate, maxDate) {
|
|
12236
|
+
if (minDate && value < minDate) {
|
|
12237
|
+
return minDate;
|
|
12238
|
+
}
|
|
12239
|
+
if (maxDate && value > maxDate) {
|
|
12240
|
+
return maxDate;
|
|
12241
|
+
}
|
|
12242
|
+
return value;
|
|
12243
|
+
};
|
|
12221
12244
|
var DatePickerIOS = function DatePickerIOS(_ref) {
|
|
12222
12245
|
var value = _ref.value,
|
|
12223
12246
|
minDate = _ref.minDate,
|
|
@@ -12235,7 +12258,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
|
|
|
12235
12258
|
helpText = _ref.helpText,
|
|
12236
12259
|
style = _ref.style,
|
|
12237
12260
|
testID = _ref.testID;
|
|
12238
|
-
var _useState = useState(value || new Date()),
|
|
12261
|
+
var _useState = useState(getInitialDateValue(value || new Date(), minDate, maxDate)),
|
|
12239
12262
|
_useState2 = _slicedToArray(_useState, 2),
|
|
12240
12263
|
selectingDate = _useState2[0],
|
|
12241
12264
|
setSelectingDate = _useState2[1];
|
|
@@ -15920,6 +15943,7 @@ var StyledText = index$a(Typography.Text)(function (_ref3) {
|
|
|
15920
15943
|
return {
|
|
15921
15944
|
fontFamily: theme.__hd__.tag.fonts["default"],
|
|
15922
15945
|
fontSize: theme.__hd__.tag.fontSizes["default"],
|
|
15946
|
+
lineHeight: theme.__hd__.tag.lineHeights["default"],
|
|
15923
15947
|
color: textColor,
|
|
15924
15948
|
includeFontPadding: false,
|
|
15925
15949
|
textAlignVertical: 'center',
|
package/lib/index.js
CHANGED
|
@@ -1638,8 +1638,8 @@ var getLineHeights = function getLineHeights(fontSizes) {
|
|
|
1638
1638
|
xlarge: fontSizes.xlarge + additionalSpace,
|
|
1639
1639
|
large: fontSizes.large + additionalSpace,
|
|
1640
1640
|
medium: fontSizes.medium + additionalSpace,
|
|
1641
|
-
small: fontSizes.small + additionalSpace,
|
|
1642
|
-
xsmall: fontSizes.xsmall + additionalSpace
|
|
1641
|
+
small: fontSizes.small + additionalSpace / 2,
|
|
1642
|
+
xsmall: fontSizes.xsmall + additionalSpace / 2
|
|
1643
1643
|
};
|
|
1644
1644
|
};
|
|
1645
1645
|
|
|
@@ -2897,9 +2897,12 @@ var getTagTheme = function getTagTheme(theme) {
|
|
|
2897
2897
|
var fontSizes = {
|
|
2898
2898
|
"default": theme.fontSizes.small
|
|
2899
2899
|
};
|
|
2900
|
+
var lineHeights = {
|
|
2901
|
+
"default": theme.lineHeights.small
|
|
2902
|
+
};
|
|
2900
2903
|
var space = {
|
|
2901
2904
|
horizontalPadding: theme.space.small,
|
|
2902
|
-
verticalPadding: theme.space.
|
|
2905
|
+
verticalPadding: theme.space.xsmall
|
|
2903
2906
|
};
|
|
2904
2907
|
var radii = {
|
|
2905
2908
|
"default": theme.radii.base
|
|
@@ -2910,7 +2913,8 @@ var getTagTheme = function getTagTheme(theme) {
|
|
|
2910
2913
|
fonts: fonts,
|
|
2911
2914
|
fontSizes: fontSizes,
|
|
2912
2915
|
space: space,
|
|
2913
|
-
radii: radii
|
|
2916
|
+
radii: radii,
|
|
2917
|
+
lineHeights: lineHeights
|
|
2914
2918
|
};
|
|
2915
2919
|
};
|
|
2916
2920
|
|
|
@@ -6129,14 +6133,19 @@ var Collapse = function Collapse(_ref) {
|
|
|
6129
6133
|
open = _ref$open === void 0 ? false : _ref$open,
|
|
6130
6134
|
children = _ref.children,
|
|
6131
6135
|
testID = _ref.testID,
|
|
6132
|
-
style = _ref.style
|
|
6136
|
+
style = _ref.style,
|
|
6137
|
+
onLayout = _ref.onLayout;
|
|
6133
6138
|
var _React$useState = React__default["default"].useState(0),
|
|
6134
6139
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6135
6140
|
contentHeight = _React$useState2[0],
|
|
6136
6141
|
setContentHeight = _React$useState2[1];
|
|
6142
|
+
var _React$useState3 = React__default["default"].useState(false),
|
|
6143
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
6144
|
+
componentMounted = _React$useState4[0],
|
|
6145
|
+
setComponentMounted = _React$useState4[1];
|
|
6137
6146
|
var previousOpenState = usePrevious(open);
|
|
6138
6147
|
React.useEffect(function () {
|
|
6139
|
-
if (open !== previousOpenState && previousOpenState !== undefined || open) {
|
|
6148
|
+
if ((open !== previousOpenState && previousOpenState !== undefined || open) && componentMounted) {
|
|
6140
6149
|
reactNative.LayoutAnimation.configureNext(reactNative.LayoutAnimation.Presets.easeInEaseOut);
|
|
6141
6150
|
}
|
|
6142
6151
|
}, [open, previousOpenState, contentHeight]);
|
|
@@ -6144,10 +6153,15 @@ var Collapse = function Collapse(_ref) {
|
|
|
6144
6153
|
var height = _ref2.height;
|
|
6145
6154
|
setContentHeight(height);
|
|
6146
6155
|
}, []);
|
|
6156
|
+
var onCollapseLayout = React.useCallback(function (e) {
|
|
6157
|
+
setComponentMounted(true);
|
|
6158
|
+
onLayout === null || onLayout === void 0 ? void 0 : onLayout(e);
|
|
6159
|
+
}, []);
|
|
6147
6160
|
return /*#__PURE__*/React__default["default"].createElement(StyledWrapper$c, {
|
|
6148
6161
|
style: {
|
|
6149
6162
|
height: open ? contentHeight : 0
|
|
6150
6163
|
},
|
|
6164
|
+
onLayout: onCollapseLayout,
|
|
6151
6165
|
testID: testID
|
|
6152
6166
|
}, /*#__PURE__*/React__default["default"].createElement(StyledHiddenWrapper, null, /*#__PURE__*/React__default["default"].createElement(StyledChildWrapper, {
|
|
6153
6167
|
onLayout: function onLayout(event) {
|
|
@@ -12248,6 +12262,15 @@ var StyledPickerWrapper$1 = index$a(reactNative.View)(function (_ref) {
|
|
|
12248
12262
|
};
|
|
12249
12263
|
});
|
|
12250
12264
|
|
|
12265
|
+
var getInitialDateValue = function getInitialDateValue(value, minDate, maxDate) {
|
|
12266
|
+
if (minDate && value < minDate) {
|
|
12267
|
+
return minDate;
|
|
12268
|
+
}
|
|
12269
|
+
if (maxDate && value > maxDate) {
|
|
12270
|
+
return maxDate;
|
|
12271
|
+
}
|
|
12272
|
+
return value;
|
|
12273
|
+
};
|
|
12251
12274
|
var DatePickerIOS = function DatePickerIOS(_ref) {
|
|
12252
12275
|
var value = _ref.value,
|
|
12253
12276
|
minDate = _ref.minDate,
|
|
@@ -12265,7 +12288,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
|
|
|
12265
12288
|
helpText = _ref.helpText,
|
|
12266
12289
|
style = _ref.style,
|
|
12267
12290
|
testID = _ref.testID;
|
|
12268
|
-
var _useState = React.useState(value || new Date()),
|
|
12291
|
+
var _useState = React.useState(getInitialDateValue(value || new Date(), minDate, maxDate)),
|
|
12269
12292
|
_useState2 = _slicedToArray(_useState, 2),
|
|
12270
12293
|
selectingDate = _useState2[0],
|
|
12271
12294
|
setSelectingDate = _useState2[1];
|
|
@@ -15950,6 +15973,7 @@ var StyledText = index$a(Typography.Text)(function (_ref3) {
|
|
|
15950
15973
|
return {
|
|
15951
15974
|
fontFamily: theme.__hd__.tag.fonts["default"],
|
|
15952
15975
|
fontSize: theme.__hd__.tag.fontSizes["default"],
|
|
15976
|
+
lineHeight: theme.__hd__.tag.lineHeights["default"],
|
|
15953
15977
|
color: textColor,
|
|
15954
15978
|
includeFontPadding: false,
|
|
15955
15979
|
textAlignVertical: 'center',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.27.
|
|
3
|
+
"version": "8.27.3",
|
|
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.27.
|
|
24
|
+
"@hero-design/colors": "8.27.3",
|
|
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.27.
|
|
48
|
+
"@hero-design/eslint-plugin": "8.27.3",
|
|
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,10 +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.27.
|
|
64
|
+
"eslint-config-hd": "8.27.3",
|
|
65
65
|
"eslint-plugin-import": "^2.27.5",
|
|
66
66
|
"jest": "^27.3.1",
|
|
67
|
-
"prettier-config-hd": "8.27.
|
|
67
|
+
"prettier-config-hd": "8.27.3",
|
|
68
68
|
"react": "18.0.0",
|
|
69
69
|
"react-native": "0.69.7",
|
|
70
70
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -71,6 +71,7 @@ exports[`AccordionItem renders correctly when header is an element 1`] = `
|
|
|
71
71
|
</View>
|
|
72
72
|
<View
|
|
73
73
|
collapsable={false}
|
|
74
|
+
onLayout={[Function]}
|
|
74
75
|
style={
|
|
75
76
|
Object {
|
|
76
77
|
"height": 0,
|
|
@@ -205,6 +206,7 @@ exports[`AccordionItem renders correctly when header is string 1`] = `
|
|
|
205
206
|
</View>
|
|
206
207
|
<View
|
|
207
208
|
collapsable={false}
|
|
209
|
+
onLayout={[Function]}
|
|
208
210
|
style={
|
|
209
211
|
Object {
|
|
210
212
|
"height": 0,
|
|
@@ -339,6 +341,7 @@ exports[`AccordionItem renders correctly when open 1`] = `
|
|
|
339
341
|
</View>
|
|
340
342
|
<View
|
|
341
343
|
collapsable={false}
|
|
344
|
+
onLayout={[Function]}
|
|
342
345
|
style={
|
|
343
346
|
Object {
|
|
344
347
|
"height": 0,
|
|
@@ -473,6 +476,7 @@ exports[`AccordionItem renders correctly when variant is card 1`] = `
|
|
|
473
476
|
</View>
|
|
474
477
|
<View
|
|
475
478
|
collapsable={false}
|
|
479
|
+
onLayout={[Function]}
|
|
476
480
|
style={
|
|
477
481
|
Object {
|
|
478
482
|
"height": 0,
|
|
@@ -79,6 +79,7 @@ exports[`Accordion allows fully controlled 1`] = `
|
|
|
79
79
|
</View>
|
|
80
80
|
<View
|
|
81
81
|
collapsable={false}
|
|
82
|
+
onLayout={[Function]}
|
|
82
83
|
style={
|
|
83
84
|
Object {
|
|
84
85
|
"height": 0,
|
|
@@ -210,6 +211,7 @@ exports[`Accordion allows fully controlled 1`] = `
|
|
|
210
211
|
</View>
|
|
211
212
|
<View
|
|
212
213
|
collapsable={false}
|
|
214
|
+
onLayout={[Function]}
|
|
213
215
|
style={
|
|
214
216
|
Object {
|
|
215
217
|
"height": 0,
|
|
@@ -353,6 +355,7 @@ exports[`Accordion renders correctly 1`] = `
|
|
|
353
355
|
</View>
|
|
354
356
|
<View
|
|
355
357
|
collapsable={false}
|
|
358
|
+
onLayout={[Function]}
|
|
356
359
|
style={
|
|
357
360
|
Object {
|
|
358
361
|
"height": 0,
|
|
@@ -484,6 +487,7 @@ exports[`Accordion renders correctly 1`] = `
|
|
|
484
487
|
</View>
|
|
485
488
|
<View
|
|
486
489
|
collapsable={false}
|
|
490
|
+
onLayout={[Function]}
|
|
487
491
|
style={
|
|
488
492
|
Object {
|
|
489
493
|
"height": 0,
|
|
@@ -627,6 +631,7 @@ exports[`Accordion renders correctly when variant is card 1`] = `
|
|
|
627
631
|
</View>
|
|
628
632
|
<View
|
|
629
633
|
collapsable={false}
|
|
634
|
+
onLayout={[Function]}
|
|
630
635
|
style={
|
|
631
636
|
Object {
|
|
632
637
|
"height": 0,
|
|
@@ -769,6 +774,7 @@ exports[`Accordion renders correctly when variant is card 1`] = `
|
|
|
769
774
|
</View>
|
|
770
775
|
<View
|
|
771
776
|
collapsable={false}
|
|
777
|
+
onLayout={[Function]}
|
|
772
778
|
style={
|
|
773
779
|
Object {
|
|
774
780
|
"height": 0,
|
|
@@ -40,7 +40,7 @@ exports[`Badge has danger style when intent is danger 1`] = `
|
|
|
40
40
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
41
41
|
"fontSize": 12,
|
|
42
42
|
"includeFontPadding": false,
|
|
43
|
-
"lineHeight":
|
|
43
|
+
"lineHeight": 16,
|
|
44
44
|
"textAlign": "center",
|
|
45
45
|
"textAlignVertical": "center",
|
|
46
46
|
},
|
|
@@ -98,7 +98,7 @@ exports[`Badge has info style when intent is info 1`] = `
|
|
|
98
98
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
99
99
|
"fontSize": 12,
|
|
100
100
|
"includeFontPadding": false,
|
|
101
|
-
"lineHeight":
|
|
101
|
+
"lineHeight": 16,
|
|
102
102
|
"textAlign": "center",
|
|
103
103
|
"textAlignVertical": "center",
|
|
104
104
|
},
|
|
@@ -156,7 +156,7 @@ exports[`Badge has info style when intent is primary 1`] = `
|
|
|
156
156
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
157
157
|
"fontSize": 12,
|
|
158
158
|
"includeFontPadding": false,
|
|
159
|
-
"lineHeight":
|
|
159
|
+
"lineHeight": 16,
|
|
160
160
|
"textAlign": "center",
|
|
161
161
|
"textAlignVertical": "center",
|
|
162
162
|
},
|
|
@@ -214,7 +214,7 @@ exports[`Badge has success style when intent is success 1`] = `
|
|
|
214
214
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
215
215
|
"fontSize": 12,
|
|
216
216
|
"includeFontPadding": false,
|
|
217
|
-
"lineHeight":
|
|
217
|
+
"lineHeight": 16,
|
|
218
218
|
"textAlign": "center",
|
|
219
219
|
"textAlignVertical": "center",
|
|
220
220
|
},
|
|
@@ -272,7 +272,7 @@ exports[`Badge has warning style when intent is warning 1`] = `
|
|
|
272
272
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
273
273
|
"fontSize": 12,
|
|
274
274
|
"includeFontPadding": false,
|
|
275
|
-
"lineHeight":
|
|
275
|
+
"lineHeight": 16,
|
|
276
276
|
"textAlign": "center",
|
|
277
277
|
"textAlignVertical": "center",
|
|
278
278
|
},
|
|
@@ -331,7 +331,7 @@ exports[`Badge renders correctly with custom props 1`] = `
|
|
|
331
331
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
332
332
|
"fontSize": 12,
|
|
333
333
|
"includeFontPadding": false,
|
|
334
|
-
"lineHeight":
|
|
334
|
+
"lineHeight": 16,
|
|
335
335
|
"textAlign": "center",
|
|
336
336
|
"textAlignVertical": "center",
|
|
337
337
|
},
|
|
@@ -143,7 +143,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
143
143
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
144
144
|
"fontSize": 12,
|
|
145
145
|
"letterSpacing": 0.36,
|
|
146
|
-
"lineHeight":
|
|
146
|
+
"lineHeight": 16,
|
|
147
147
|
},
|
|
148
148
|
Array [
|
|
149
149
|
Object {
|
|
@@ -206,7 +206,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
206
206
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
207
207
|
"fontSize": 12,
|
|
208
208
|
"letterSpacing": 0.36,
|
|
209
|
-
"lineHeight":
|
|
209
|
+
"lineHeight": 16,
|
|
210
210
|
},
|
|
211
211
|
Array [
|
|
212
212
|
Object {
|
|
@@ -269,7 +269,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
269
269
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
270
270
|
"fontSize": 12,
|
|
271
271
|
"letterSpacing": 0.36,
|
|
272
|
-
"lineHeight":
|
|
272
|
+
"lineHeight": 16,
|
|
273
273
|
},
|
|
274
274
|
Array [
|
|
275
275
|
Object {
|
|
@@ -332,7 +332,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
332
332
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
333
333
|
"fontSize": 12,
|
|
334
334
|
"letterSpacing": 0.36,
|
|
335
|
-
"lineHeight":
|
|
335
|
+
"lineHeight": 16,
|
|
336
336
|
},
|
|
337
337
|
Array [
|
|
338
338
|
Object {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports[`Collapse renders correctly 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
collapsable={false}
|
|
6
|
+
onLayout={[Function]}
|
|
6
7
|
style={
|
|
7
8
|
Object {
|
|
8
9
|
"height": 0,
|
|
@@ -46,6 +47,7 @@ exports[`Collapse renders correctly 1`] = `
|
|
|
46
47
|
exports[`Collapse should render Sample Text but not visible 1`] = `
|
|
47
48
|
<View
|
|
48
49
|
collapsable={false}
|
|
50
|
+
onLayout={[Function]}
|
|
49
51
|
style={
|
|
50
52
|
Object {
|
|
51
53
|
"height": 0,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import React, { useCallback, useEffect } from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
LayoutChangeEvent,
|
|
5
|
+
StyleProp,
|
|
6
|
+
ViewProps,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
4
9
|
import { LayoutAnimation, Platform, UIManager } from 'react-native';
|
|
5
10
|
import { usePrevious } from '../../utils/hooks';
|
|
6
11
|
import {
|
|
@@ -34,15 +39,24 @@ if (Platform.OS === 'android') {
|
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
const Collapse = ({
|
|
42
|
+
const Collapse = ({
|
|
43
|
+
open = false,
|
|
44
|
+
children,
|
|
45
|
+
testID,
|
|
46
|
+
style,
|
|
47
|
+
onLayout,
|
|
48
|
+
}: CollapseProps) => {
|
|
38
49
|
const [contentHeight, setContentHeight] = React.useState<number>(0);
|
|
50
|
+
const [componentMounted, setComponentMounted] =
|
|
51
|
+
React.useState<boolean>(false);
|
|
39
52
|
|
|
40
53
|
const previousOpenState = usePrevious(open);
|
|
41
54
|
|
|
42
55
|
useEffect(() => {
|
|
43
56
|
if (
|
|
44
|
-
(open !== previousOpenState && previousOpenState !== undefined) ||
|
|
45
|
-
|
|
57
|
+
((open !== previousOpenState && previousOpenState !== undefined) ||
|
|
58
|
+
open) &&
|
|
59
|
+
componentMounted
|
|
46
60
|
) {
|
|
47
61
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
48
62
|
}
|
|
@@ -52,11 +66,18 @@ const Collapse = ({ open = false, children, testID, style }: CollapseProps) => {
|
|
|
52
66
|
setContentHeight(height);
|
|
53
67
|
}, []);
|
|
54
68
|
|
|
69
|
+
const onCollapseLayout = useCallback((e: LayoutChangeEvent) => {
|
|
70
|
+
setComponentMounted(true);
|
|
71
|
+
|
|
72
|
+
onLayout?.(e);
|
|
73
|
+
}, []);
|
|
74
|
+
|
|
55
75
|
return (
|
|
56
76
|
<StyledWrapper
|
|
57
77
|
style={{
|
|
58
78
|
height: open ? contentHeight : 0,
|
|
59
79
|
}}
|
|
80
|
+
onLayout={onCollapseLayout}
|
|
60
81
|
testID={testID}
|
|
61
82
|
>
|
|
62
83
|
<StyledHiddenWrapper>
|
|
@@ -10,6 +10,22 @@ import { StyledPickerWrapper } from './StyledDatePicker';
|
|
|
10
10
|
import type { DatePickerProps } from './types';
|
|
11
11
|
import { useTheme } from '../../theme';
|
|
12
12
|
|
|
13
|
+
export const getInitialDateValue = (
|
|
14
|
+
value: Date,
|
|
15
|
+
minDate?: Date | undefined,
|
|
16
|
+
maxDate?: Date | undefined
|
|
17
|
+
) => {
|
|
18
|
+
if (minDate && value < minDate) {
|
|
19
|
+
return minDate;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (maxDate && value > maxDate) {
|
|
23
|
+
return maxDate;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
|
|
13
29
|
const DatePickerIOS = ({
|
|
14
30
|
value,
|
|
15
31
|
minDate,
|
|
@@ -26,7 +42,9 @@ const DatePickerIOS = ({
|
|
|
26
42
|
style,
|
|
27
43
|
testID,
|
|
28
44
|
}: Omit<DatePickerProps, 'variant'>) => {
|
|
29
|
-
const [selectingDate, setSelectingDate] = useState<Date>(
|
|
45
|
+
const [selectingDate, setSelectingDate] = useState<Date>(
|
|
46
|
+
getInitialDateValue(value || new Date(), minDate, maxDate)
|
|
47
|
+
);
|
|
30
48
|
const [open, setOpen] = useState(false);
|
|
31
49
|
|
|
32
50
|
const displayValue = value ? formatDate(displayFormat, value) : '';
|
|
@@ -2,13 +2,37 @@ import { fireEvent } from '@testing-library/react-native';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ModalProps } from 'react-native';
|
|
4
4
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
5
|
-
import DatePickerIOS from '../DatePickerIOS';
|
|
5
|
+
import DatePickerIOS, { getInitialDateValue } from '../DatePickerIOS';
|
|
6
6
|
|
|
7
7
|
jest.mock('react-native/Libraries/Modal/Modal', () => {
|
|
8
8
|
const Modal = jest.requireActual('react-native/Libraries/Modal/Modal');
|
|
9
9
|
return (props: ModalProps) => <Modal {...props} />;
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
describe('getInitialDateValue', () => {
|
|
13
|
+
describe('when value is less than minDate', () => {
|
|
14
|
+
it('should return minDate', () => {
|
|
15
|
+
const value = new Date('2022-01-01T00:00:00.000Z');
|
|
16
|
+
const minDate = new Date('2025-01-01T00:00:00.000Z');
|
|
17
|
+
expect(getInitialDateValue(value, minDate)).toBe(minDate);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe('when value is greater than maxDate', () => {
|
|
21
|
+
it('should return maxDate', () => {
|
|
22
|
+
const value = new Date('2025-01-01T00:00:00.000Z');
|
|
23
|
+
const maxDate = new Date('2022-01-01T00:00:00.000Z');
|
|
24
|
+
expect(getInitialDateValue(value, undefined, maxDate)).toBe(maxDate);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('when minDate < value < maxDate', () => {
|
|
28
|
+
it('should return value', () => {
|
|
29
|
+
const minDate = new Date('2022-01-01T00:00:00.000Z');
|
|
30
|
+
const value = new Date('2023-01-01T00:00:00.000Z');
|
|
31
|
+
const maxDate = new Date('2025-01-01T00:00:00.000Z');
|
|
32
|
+
expect(getInitialDateValue(value, minDate, maxDate)).toBe(value);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
12
36
|
describe('DatePickerIOS', () => {
|
|
13
37
|
it('renders correctly', () => {
|
|
14
38
|
const onChange = jest.fn();
|
|
@@ -88,7 +88,7 @@ exports[`DatePicker renders DatePickerAndroid when OS is android 1`] = `
|
|
|
88
88
|
"left": 16,
|
|
89
89
|
"paddingHorizontal": 4,
|
|
90
90
|
"position": "absolute",
|
|
91
|
-
"top": -
|
|
91
|
+
"top": -4,
|
|
92
92
|
"zIndex": 1,
|
|
93
93
|
},
|
|
94
94
|
Object {
|
|
@@ -313,7 +313,7 @@ exports[`DatePicker renders DatePickerIOS when OS is iOS 1`] = `
|
|
|
313
313
|
"left": 16,
|
|
314
314
|
"paddingHorizontal": 4,
|
|
315
315
|
"position": "absolute",
|
|
316
|
-
"top": -
|
|
316
|
+
"top": -4,
|
|
317
317
|
"zIndex": 1,
|
|
318
318
|
},
|
|
319
319
|
Object {
|
|
@@ -544,7 +544,7 @@ exports[`DatePicker renders variant Calendar 1`] = `
|
|
|
544
544
|
"left": 16,
|
|
545
545
|
"paddingHorizontal": 4,
|
|
546
546
|
"position": "absolute",
|
|
547
|
-
"top": -
|
|
547
|
+
"top": -4,
|
|
548
548
|
"zIndex": 1,
|
|
549
549
|
},
|
|
550
550
|
Object {
|
|
@@ -96,7 +96,7 @@ exports[`BasicListItem when suffix and prefix are icon name renders correctly 1`
|
|
|
96
96
|
"fontFamily": "BeVietnamPro-Regular",
|
|
97
97
|
"fontSize": 12,
|
|
98
98
|
"letterSpacing": 0.36,
|
|
99
|
-
"lineHeight":
|
|
99
|
+
"lineHeight": 16,
|
|
100
100
|
},
|
|
101
101
|
undefined,
|
|
102
102
|
]
|
|
@@ -234,7 +234,7 @@ exports[`BasicListItem when suffix and prefix are react element renders correctl
|
|
|
234
234
|
"fontFamily": "BeVietnamPro-Regular",
|
|
235
235
|
"fontSize": 12,
|
|
236
236
|
"letterSpacing": 0.36,
|
|
237
|
-
"lineHeight":
|
|
237
|
+
"lineHeight": 16,
|
|
238
238
|
},
|
|
239
239
|
undefined,
|
|
240
240
|
]
|