@coinbase/cds-mobile 8.60.0 → 8.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dts/accordion/Accordion.d.ts +1 -9
- package/dts/accordion/Accordion.d.ts.map +1 -1
- package/dts/alpha/combobox/Combobox.d.ts.map +1 -1
- package/dts/alpha/select/Select.d.ts.map +1 -1
- package/dts/alpha/select-chip/SelectChip.d.ts.map +1 -1
- package/dts/alpha/tabbed-chips/TabbedChips.d.ts.map +1 -1
- package/dts/banner/Banner.d.ts.map +1 -1
- package/dts/buttons/AvatarButton.d.ts +6 -3
- package/dts/buttons/AvatarButton.d.ts.map +1 -1
- package/dts/buttons/Button.d.ts.map +1 -1
- package/dts/buttons/ButtonGroup.d.ts +3 -1
- package/dts/buttons/ButtonGroup.d.ts.map +1 -1
- package/dts/buttons/IconButton.d.ts.map +1 -1
- package/dts/buttons/IconCounterButton.d.ts.map +1 -1
- package/dts/buttons/SlideButton.d.ts.map +1 -1
- package/dts/cards/Card.d.ts +4 -0
- package/dts/cards/Card.d.ts.map +1 -1
- package/dts/cards/CardBody.d.ts +4 -0
- package/dts/cards/CardBody.d.ts.map +1 -1
- package/dts/cards/CardFooter.d.ts +4 -0
- package/dts/cards/CardFooter.d.ts.map +1 -1
- package/dts/cards/CardGroup.d.ts +12 -0
- package/dts/cards/CardGroup.d.ts.map +1 -1
- package/dts/cards/CardHeader.d.ts +8 -0
- package/dts/cards/CardHeader.d.ts.map +1 -1
- package/dts/cards/CardMedia.d.ts +8 -0
- package/dts/cards/CardMedia.d.ts.map +1 -1
- package/dts/cards/LikeButton.d.ts.map +1 -1
- package/dts/carousel/Carousel.d.ts.map +1 -1
- package/dts/cells/Cell.d.ts.map +1 -1
- package/dts/cells/ListCell.d.ts.map +1 -1
- package/dts/cells/ListCellFallback.d.ts.map +1 -1
- package/dts/chips/Chip.d.ts.map +1 -1
- package/dts/chips/ChipProps.d.ts +10 -8
- package/dts/chips/ChipProps.d.ts.map +1 -1
- package/dts/chips/InputChip.d.ts.map +1 -1
- package/dts/chips/MediaChip.d.ts +3 -2
- package/dts/chips/MediaChip.d.ts.map +1 -1
- package/dts/chips/TabbedChips.d.ts.map +1 -1
- package/dts/coachmark/Coachmark.d.ts.map +1 -1
- package/dts/collapsible/Collapsible.d.ts.map +1 -1
- package/dts/controls/Checkbox.d.ts.map +1 -1
- package/dts/controls/CheckboxCell.d.ts.map +1 -1
- package/dts/controls/Control.d.ts.map +1 -1
- package/dts/controls/ControlGroup.d.ts +13 -4
- package/dts/controls/ControlGroup.d.ts.map +1 -1
- package/dts/controls/InputStack.d.ts.map +1 -1
- package/dts/controls/Radio.d.ts.map +1 -1
- package/dts/controls/RadioCell.d.ts.map +1 -1
- package/dts/controls/SearchInput.d.ts.map +1 -1
- package/dts/controls/SelectOption.d.ts +3 -1
- package/dts/controls/SelectOption.d.ts.map +1 -1
- package/dts/controls/Switch.d.ts.map +1 -1
- package/dts/controls/TextInput.d.ts.map +1 -1
- package/dts/core/componentConfig.d.ts +166 -0
- package/dts/core/componentConfig.d.ts.map +1 -0
- package/dts/dates/Calendar.d.ts.map +1 -1
- package/dts/dates/DateInput.d.ts.map +1 -1
- package/dts/dates/DatePicker.d.ts.map +1 -1
- package/dts/dots/DotCount.d.ts +1 -11
- package/dts/dots/DotCount.d.ts.map +1 -1
- package/dts/dots/DotStatusColor.d.ts +1 -8
- package/dts/dots/DotStatusColor.d.ts.map +1 -1
- package/dts/dots/DotSymbol.d.ts +1 -17
- package/dts/dots/DotSymbol.d.ts.map +1 -1
- package/dts/hooks/useComponentConfig.d.ts +22 -0
- package/dts/hooks/useComponentConfig.d.ts.map +1 -0
- package/dts/icons/Icon.d.ts +11 -1
- package/dts/icons/Icon.d.ts.map +1 -1
- package/dts/index.d.ts +2 -0
- package/dts/index.d.ts.map +1 -1
- package/dts/layout/Divider.d.ts +3 -1
- package/dts/layout/Divider.d.ts.map +1 -1
- package/dts/layout/Fallback.d.ts +3 -1
- package/dts/layout/Fallback.d.ts.map +1 -1
- package/dts/media/Avatar.d.ts +1 -14
- package/dts/media/Avatar.d.ts.map +1 -1
- package/dts/media/RemoteImage.d.ts.map +1 -1
- package/dts/media/RemoteImageGroup.d.ts +3 -10
- package/dts/media/RemoteImageGroup.d.ts.map +1 -1
- package/dts/navigation/BrowserBar.d.ts +5 -14
- package/dts/navigation/BrowserBar.d.ts.map +1 -1
- package/dts/navigation/NavigationTitle.d.ts +4 -7
- package/dts/navigation/NavigationTitle.d.ts.map +1 -1
- package/dts/navigation/NavigationTitleSelect.d.ts +5 -11
- package/dts/navigation/NavigationTitleSelect.d.ts.map +1 -1
- package/dts/navigation/TopNavBar.d.ts +3 -13
- package/dts/navigation/TopNavBar.d.ts.map +1 -1
- package/dts/numbers/RollingNumber/RollingNumber.d.ts.map +1 -1
- package/dts/numpad/Numpad.d.ts +41 -38
- package/dts/numpad/Numpad.d.ts.map +1 -1
- package/dts/overlays/Alert.d.ts.map +1 -1
- package/dts/overlays/Toast.d.ts.map +1 -1
- package/dts/overlays/drawer/Drawer.d.ts.map +1 -1
- package/dts/overlays/modal/Modal.d.ts.map +1 -1
- package/dts/overlays/modal/ModalBody.d.ts.map +1 -1
- package/dts/overlays/modal/ModalFooter.d.ts +3 -8
- package/dts/overlays/modal/ModalFooter.d.ts.map +1 -1
- package/dts/overlays/modal/ModalHeader.d.ts.map +1 -1
- package/dts/overlays/overlay/Overlay.d.ts +7 -3
- package/dts/overlays/overlay/Overlay.d.ts.map +1 -1
- package/dts/overlays/tooltip/Tooltip.d.ts +2 -20
- package/dts/overlays/tooltip/Tooltip.d.ts.map +1 -1
- package/dts/overlays/tray/Tray.d.ts.map +1 -1
- package/dts/page/PageFooter.d.ts.map +1 -1
- package/dts/page/PageHeader.d.ts.map +1 -1
- package/dts/perf/component-config/Button.component-config.perf-test.d.ts +2 -0
- package/dts/perf/component-config/Button.component-config.perf-test.d.ts.map +1 -0
- package/dts/perf/component-config/ComponentConfigProvider.perf-test.d.ts +2 -0
- package/dts/perf/component-config/ComponentConfigProvider.perf-test.d.ts.map +1 -0
- package/dts/perf/component-config/ComponentConfigStickerSheet.perf-test.d.ts +2 -0
- package/dts/perf/component-config/ComponentConfigStickerSheet.perf-test.d.ts.map +1 -0
- package/dts/stepper/Stepper.d.ts.map +1 -1
- package/dts/system/ComponentConfigProvider.d.ts +26 -0
- package/dts/system/ComponentConfigProvider.d.ts.map +1 -0
- package/dts/system/index.d.ts +1 -0
- package/dts/system/index.d.ts.map +1 -1
- package/dts/tabs/SegmentedTab.d.ts +6 -3
- package/dts/tabs/SegmentedTab.d.ts.map +1 -1
- package/dts/tabs/SegmentedTabs.d.ts +6 -3
- package/dts/tabs/SegmentedTabs.d.ts.map +1 -1
- package/dts/tabs/Tabs.d.ts +25 -24
- package/dts/tabs/Tabs.d.ts.map +1 -1
- package/dts/tag/Tag.d.ts.map +1 -1
- package/dts/tour/Tour.d.ts +42 -41
- package/dts/tour/Tour.d.ts.map +1 -1
- package/dts/typography/Link.d.ts +1 -14
- package/dts/typography/Link.d.ts.map +1 -1
- package/dts/utils/mergeComponentProps.d.ts +34 -0
- package/dts/utils/mergeComponentProps.d.ts.map +1 -0
- package/dts/visualizations/ProgressBar.d.ts.map +1 -1
- package/dts/visualizations/ProgressBarWithFixedLabels.d.ts +5 -3
- package/dts/visualizations/ProgressBarWithFixedLabels.d.ts.map +1 -1
- package/dts/visualizations/ProgressBarWithFloatLabel.d.ts +3 -1
- package/dts/visualizations/ProgressBarWithFloatLabel.d.ts.map +1 -1
- package/dts/visualizations/ProgressCircle.d.ts.map +1 -1
- package/esm/accordion/Accordion.js +5 -3
- package/esm/alpha/combobox/Combobox.js +8 -6
- package/esm/alpha/select/Select.js +6 -4
- package/esm/alpha/select-chip/SelectChip.js +6 -4
- package/esm/alpha/tabbed-chips/TabbedChips.js +6 -4
- package/esm/banner/Banner.js +6 -4
- package/esm/buttons/AvatarButton.js +6 -4
- package/esm/buttons/Button.js +25 -10
- package/esm/buttons/ButtonGroup.js +5 -3
- package/esm/buttons/IconButton.js +14 -11
- package/esm/buttons/IconCounterButton.js +6 -4
- package/esm/buttons/SlideButton.js +10 -8
- package/esm/buttons/__stories__/Button.stories.js +32 -0
- package/esm/buttons/__stories__/IconButton.stories.js +32 -0
- package/esm/cards/Card.js +5 -0
- package/esm/cards/CardBody.js +5 -0
- package/esm/cards/CardFooter.js +4 -0
- package/esm/cards/CardGroup.js +14 -0
- package/esm/cards/CardHeader.js +9 -0
- package/esm/cards/CardMedia.js +10 -0
- package/esm/cards/LikeButton.js +6 -4
- package/esm/carousel/Carousel.js +10 -8
- package/esm/cells/Cell.js +6 -4
- package/esm/cells/ListCell.js +6 -4
- package/esm/cells/ListCellFallback.js +6 -4
- package/esm/chips/Chip.js +6 -4
- package/esm/chips/InputChip.js +6 -4
- package/esm/chips/MediaChip.js +6 -4
- package/esm/chips/TabbedChips.js +6 -4
- package/esm/coachmark/Coachmark.js +6 -4
- package/esm/collapsible/Collapsible.js +10 -8
- package/esm/controls/Checkbox.js +6 -4
- package/esm/controls/CheckboxCell.js +6 -4
- package/esm/controls/Control.js +8 -6
- package/esm/controls/ControlGroup.js +6 -4
- package/esm/controls/InputStack.js +6 -4
- package/esm/controls/Radio.js +6 -4
- package/esm/controls/RadioCell.js +6 -4
- package/esm/controls/SearchInput.js +6 -4
- package/esm/controls/SelectOption.js +6 -4
- package/esm/controls/Switch.js +6 -4
- package/esm/controls/TextInput.js +6 -4
- package/esm/core/componentConfig.js +1 -0
- package/esm/dates/Calendar.js +8 -6
- package/esm/dates/DateInput.js +6 -4
- package/esm/dates/DatePicker.js +9 -6
- package/esm/dots/DotCount.js +6 -4
- package/esm/dots/DotStatusColor.js +6 -4
- package/esm/dots/DotSymbol.js +6 -4
- package/esm/hooks/useComponentConfig.js +27 -0
- package/esm/icons/Icon.js +10 -8
- package/esm/index.js +2 -0
- package/esm/layout/Divider.js +6 -4
- package/esm/layout/Fallback.js +6 -4
- package/esm/media/Avatar.js +6 -4
- package/esm/media/RemoteImage.js +6 -4
- package/esm/media/RemoteImageGroup.js +6 -4
- package/esm/navigation/BrowserBar.js +6 -4
- package/esm/navigation/NavigationTitle.js +6 -4
- package/esm/navigation/NavigationTitleSelect.js +8 -6
- package/esm/navigation/TopNavBar.js +5 -3
- package/esm/numbers/RollingNumber/RollingNumber.js +6 -4
- package/esm/numpad/Numpad.js +8 -6
- package/esm/overlays/Alert.js +7 -5
- package/esm/overlays/Toast.js +10 -8
- package/esm/overlays/drawer/Drawer.js +12 -10
- package/esm/overlays/modal/Modal.js +4 -1
- package/esm/overlays/modal/ModalBody.js +8 -6
- package/esm/overlays/modal/ModalFooter.js +8 -6
- package/esm/overlays/modal/ModalHeader.js +6 -4
- package/esm/overlays/overlay/Overlay.js +6 -4
- package/esm/overlays/tooltip/Tooltip.js +5 -3
- package/esm/overlays/tray/Tray.js +13 -11
- package/esm/page/PageFooter.js +6 -4
- package/esm/page/PageHeader.js +6 -4
- package/esm/perf/component-config/Button.component-config.perf-test.js +35 -0
- package/esm/perf/component-config/ComponentConfigProvider.perf-test.js +147 -0
- package/esm/perf/component-config/ComponentConfigStickerSheet.perf-test.js +326 -0
- package/esm/perf/component-config/README.md +8 -0
- package/esm/stepper/Stepper.js +11 -9
- package/esm/system/ComponentConfigProvider.js +39 -0
- package/esm/system/__stories__/ComponentConfigProvider.stories.js +12 -0
- package/esm/system/__stories__/ComponentConfigProviderCustom.stories.js +22 -0
- package/esm/system/__stories__/componentConfigStickerSheet/Container.js +27 -0
- package/esm/system/__stories__/componentConfigStickerSheet/StickerSheet.js +94 -0
- package/esm/system/__stories__/componentConfigStickerSheet/customComponentConfig.js +116 -0
- package/esm/system/__stories__/componentConfigStickerSheet/customTheme.js +520 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Accordion.js +67 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Avatar.js +48 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Banner.js +43 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Button.js +77 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Coachmark.js +15 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Controls.js +29 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/DatePicker.js +15 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/DotCount.js +28 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Icon.js +57 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/InputChip.js +17 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/ListCell.js +48 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Search.js +20 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/SegmentedTabs.js +12 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Select.js +24 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/SelectChip.js +22 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/Tag.js +35 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/TextInput.js +46 -0
- package/esm/system/__stories__/componentConfigStickerSheet/examples/constants.js +33 -0
- package/esm/system/__stories__/componentConfigStickerSheet/themeVars.js +2 -0
- package/esm/system/index.js +1 -0
- package/esm/tabs/SegmentedTab.js +7 -5
- package/esm/tabs/SegmentedTabs.js +9 -4
- package/esm/tabs/Tabs.js +12 -10
- package/esm/tag/Tag.js +6 -4
- package/esm/tour/Tour.js +5 -3
- package/esm/typography/Link.js +6 -4
- package/esm/utils/mergeComponentProps.js +35 -0
- package/esm/visualizations/ProgressBar.js +7 -5
- package/esm/visualizations/ProgressBarWithFixedLabels.js +5 -3
- package/esm/visualizations/ProgressBarWithFloatLabel.js +5 -3
- package/esm/visualizations/ProgressCircle.js +7 -5
- package/package.json +4 -3
package/esm/overlays/Toast.js
CHANGED
|
@@ -5,6 +5,7 @@ import React, { forwardRef, memo, useCallback, useEffect, useImperativeHandle }
|
|
|
5
5
|
import { zIndex } from '@coinbase/cds-common/tokens/zIndex';
|
|
6
6
|
import { Button } from '../buttons';
|
|
7
7
|
import { useA11y } from '../hooks/useA11y';
|
|
8
|
+
import { useComponentConfig } from '../hooks/useComponentConfig';
|
|
8
9
|
import { useTheme } from '../hooks/useTheme';
|
|
9
10
|
import { Box, HStack } from '../layout';
|
|
10
11
|
import { ColorSurge } from '../motion/ColorSurge';
|
|
@@ -12,9 +13,10 @@ import { Text } from '../typography/Text';
|
|
|
12
13
|
import { useToastAnimation } from './useToastAnimation';
|
|
13
14
|
import { useToastPanResponder } from './useToastPanResponder';
|
|
14
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
export const Toast = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((
|
|
16
|
+
export const Toast = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
|
|
16
17
|
var _action$testID;
|
|
17
|
-
|
|
18
|
+
const mergedProps = useComponentConfig('Toast', _props);
|
|
19
|
+
const {
|
|
18
20
|
text,
|
|
19
21
|
action,
|
|
20
22
|
onWillHide,
|
|
@@ -22,8 +24,8 @@ export const Toast = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
22
24
|
bottomOffset,
|
|
23
25
|
variant,
|
|
24
26
|
accessibilityLabel
|
|
25
|
-
} =
|
|
26
|
-
props = _objectWithoutPropertiesLoose(
|
|
27
|
+
} = mergedProps,
|
|
28
|
+
props = _objectWithoutPropertiesLoose(mergedProps, _excluded);
|
|
27
29
|
const theme = useTheme();
|
|
28
30
|
const [{
|
|
29
31
|
opacity,
|
|
@@ -34,10 +36,10 @@ export const Toast = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
34
36
|
} = useA11y();
|
|
35
37
|
const defaultA11yLabel = text + (action ? action.label : '');
|
|
36
38
|
useEffect(() => {
|
|
37
|
-
animateIn.start(
|
|
39
|
+
animateIn.start(_ref => {
|
|
38
40
|
let {
|
|
39
41
|
finished
|
|
40
|
-
} =
|
|
42
|
+
} = _ref;
|
|
41
43
|
if (finished) {
|
|
42
44
|
// announce toast copy and action label to screen reader
|
|
43
45
|
announceForA11y(accessibilityLabel != null ? accessibilityLabel : defaultA11yLabel);
|
|
@@ -47,10 +49,10 @@ export const Toast = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
47
49
|
const handleClose = useCallback(async () => {
|
|
48
50
|
onWillHide == null || onWillHide();
|
|
49
51
|
return new Promise(resolve => {
|
|
50
|
-
animateOut.start(
|
|
52
|
+
animateOut.start(_ref2 => {
|
|
51
53
|
let {
|
|
52
54
|
finished
|
|
53
|
-
} =
|
|
55
|
+
} = _ref2;
|
|
54
56
|
if (finished) {
|
|
55
57
|
onDidHide == null || onDidHide();
|
|
56
58
|
resolve(finished);
|
|
@@ -6,6 +6,7 @@ import { Animated, Keyboard, Modal, Platform, useWindowDimensions } from 'react-
|
|
|
6
6
|
import { drawerAnimationDefaultDuration, MAX_OVER_DRAG } from '@coinbase/cds-common/animation/drawer';
|
|
7
7
|
import { OverlayContentContext } from '@coinbase/cds-common/overlays/OverlayContentContext';
|
|
8
8
|
import { horizontalDrawerPercentageOfView, verticalDrawerPercentageOfView as defaultVerticalDrawerPercentageOfView } from '@coinbase/cds-common/tokens/drawer';
|
|
9
|
+
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
9
10
|
import { useTheme } from '../../hooks/useTheme';
|
|
10
11
|
import { Box } from '../../layout/Box';
|
|
11
12
|
import { HandleBar } from '../handlebar/HandleBar';
|
|
@@ -19,8 +20,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
19
20
|
const overlayContentContextValue = {
|
|
20
21
|
isDrawer: true
|
|
21
22
|
};
|
|
22
|
-
export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(
|
|
23
|
-
|
|
23
|
+
export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
|
|
24
|
+
const mergedProps = useComponentConfig('Drawer', _props);
|
|
25
|
+
const {
|
|
24
26
|
children,
|
|
25
27
|
pin = 'bottom',
|
|
26
28
|
onCloseComplete,
|
|
@@ -41,8 +43,8 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
41
43
|
accessibilityRole = 'alert',
|
|
42
44
|
animationType = 'none',
|
|
43
45
|
disableSafeAreaPaddingBottom
|
|
44
|
-
} =
|
|
45
|
-
props = _objectWithoutPropertiesLoose(
|
|
46
|
+
} = mergedProps,
|
|
47
|
+
props = _objectWithoutPropertiesLoose(mergedProps, _excluded);
|
|
46
48
|
const theme = useTheme();
|
|
47
49
|
const {
|
|
48
50
|
width,
|
|
@@ -61,10 +63,10 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
61
63
|
const paddingStyles = useDrawerSpacing(pin, disableSafeAreaPaddingBottom);
|
|
62
64
|
const isMounted = useRef(false);
|
|
63
65
|
const handleClose = useCallback(() => {
|
|
64
|
-
Animated.parallel([animateDrawerOut, animateOverlayOut]).start(
|
|
66
|
+
Animated.parallel([animateDrawerOut, animateOverlayOut]).start(_ref => {
|
|
65
67
|
let {
|
|
66
68
|
finished
|
|
67
|
-
} =
|
|
69
|
+
} = _ref;
|
|
68
70
|
if (finished) {
|
|
69
71
|
isMounted.current = false;
|
|
70
72
|
onCloseComplete == null || onCloseComplete();
|
|
@@ -74,10 +76,10 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
74
76
|
const handleRequestClose = useCallback(() => preventHardwareBackBehaviorAndroid && isAndroid ? undefined : handleClose(), [preventHardwareBackBehaviorAndroid, handleClose, isAndroid]);
|
|
75
77
|
const handleSwipeToClose = useCallback(() => {
|
|
76
78
|
if (!preventDismissGestures) {
|
|
77
|
-
Animated.parallel([animateSwipeToClose, animateOverlayOut]).start(
|
|
79
|
+
Animated.parallel([animateSwipeToClose, animateOverlayOut]).start(_ref2 => {
|
|
78
80
|
let {
|
|
79
81
|
finished
|
|
80
|
-
} =
|
|
82
|
+
} = _ref2;
|
|
81
83
|
if (finished) {
|
|
82
84
|
isMounted.current = false;
|
|
83
85
|
onCloseComplete == null || onCloseComplete();
|
|
@@ -87,10 +89,10 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
87
89
|
}, [preventDismissGestures, animateSwipeToClose, animateOverlayOut, onCloseComplete]);
|
|
88
90
|
useEffect(() => {
|
|
89
91
|
if (!isMounted.current) {
|
|
90
|
-
Animated.parallel([animateOverlayIn, animateDrawerIn]).start(
|
|
92
|
+
Animated.parallel([animateOverlayIn, animateDrawerIn]).start(_ref3 => {
|
|
91
93
|
let {
|
|
92
94
|
finished
|
|
93
|
-
} =
|
|
95
|
+
} = _ref3;
|
|
94
96
|
if (finished) {
|
|
95
97
|
isMounted.current = true;
|
|
96
98
|
onOpenComplete == null || onOpenComplete();
|
|
@@ -6,13 +6,16 @@ import { Modal as RNModal, Platform, SafeAreaView, StatusBar, StyleSheet } from
|
|
|
6
6
|
import { usePreviousValue } from '@coinbase/cds-common/hooks/usePreviousValue';
|
|
7
7
|
import { ModalContext } from '@coinbase/cds-common/overlays/ModalContext';
|
|
8
8
|
import { OverlayContentContext } from '@coinbase/cds-common/overlays/OverlayContentContext';
|
|
9
|
+
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
9
10
|
import { VStack } from '../../layout';
|
|
10
11
|
import { useModalAnimation } from './useModalAnimation';
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
const overlayContentContextValue = {
|
|
13
14
|
isModal: true
|
|
14
15
|
};
|
|
15
|
-
export const Modal = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((
|
|
16
|
+
export const Modal = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
|
|
17
|
+
const mergedProps = useComponentConfig('Modal', _props);
|
|
18
|
+
const props = mergedProps;
|
|
16
19
|
const {
|
|
17
20
|
children,
|
|
18
21
|
visible,
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
const _excluded = ["children", "padding", "paddingX", "paddingY", "paddingTop", "paddingBottom", "paddingStart", "paddingEnd"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
-
import React, { useMemo } from 'react';
|
|
4
|
+
import React, { memo, useMemo } from 'react';
|
|
5
5
|
import { KeyboardAvoidingView, ScrollView } from 'react-native';
|
|
6
6
|
import { useModalContext } from '@coinbase/cds-common/overlays/ModalContext';
|
|
7
|
+
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
7
8
|
import { useContentSize } from '../../hooks/useContentSize';
|
|
8
9
|
import { useLayout } from '../../hooks/useLayout';
|
|
9
10
|
import { Box } from '../../layout/Box';
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
export const ModalBody =
|
|
12
|
-
|
|
12
|
+
export const ModalBody = /*#__PURE__*/memo(_props => {
|
|
13
|
+
const mergedProps = useComponentConfig('ModalBody', _props);
|
|
14
|
+
const {
|
|
13
15
|
children,
|
|
14
16
|
padding,
|
|
15
17
|
paddingX = 3,
|
|
@@ -18,8 +20,8 @@ export const ModalBody = _ref => {
|
|
|
18
20
|
paddingBottom,
|
|
19
21
|
paddingStart,
|
|
20
22
|
paddingEnd
|
|
21
|
-
} =
|
|
22
|
-
props = _objectWithoutPropertiesLoose(
|
|
23
|
+
} = mergedProps,
|
|
24
|
+
props = _objectWithoutPropertiesLoose(mergedProps, _excluded);
|
|
23
25
|
const [{
|
|
24
26
|
height: contentHeight
|
|
25
27
|
}, onContentSizeChange] = useContentSize();
|
|
@@ -61,4 +63,4 @@ export const ModalBody = _ref => {
|
|
|
61
63
|
})
|
|
62
64
|
}))
|
|
63
65
|
});
|
|
64
|
-
};
|
|
66
|
+
});
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
const _excluded = ["primaryAction", "secondaryAction", "direction", "paddingX", "paddingY"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
-
import React, { Fragment } from 'react';
|
|
4
|
+
import React, { Fragment, memo } from 'react';
|
|
5
5
|
import { useModalContext } from '@coinbase/cds-common/overlays/ModalContext';
|
|
6
6
|
import { ButtonGroup } from '../../buttons/ButtonGroup';
|
|
7
|
+
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
7
8
|
import { Box } from '../../layout/Box';
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
export const ModalFooter =
|
|
10
|
-
|
|
10
|
+
export const ModalFooter = /*#__PURE__*/memo(_props => {
|
|
11
|
+
const mergedProps = useComponentConfig('ModalFooter', _props);
|
|
12
|
+
const {
|
|
11
13
|
primaryAction,
|
|
12
14
|
secondaryAction,
|
|
13
15
|
direction = 'horizontal',
|
|
14
16
|
paddingX = 3,
|
|
15
17
|
paddingY = 2
|
|
16
|
-
} =
|
|
17
|
-
props = _objectWithoutPropertiesLoose(
|
|
18
|
+
} = mergedProps,
|
|
19
|
+
props = _objectWithoutPropertiesLoose(mergedProps, _excluded);
|
|
18
20
|
const {
|
|
19
21
|
hideDividers = false
|
|
20
22
|
} = useModalContext();
|
|
@@ -41,4 +43,4 @@ export const ModalFooter = _ref => {
|
|
|
41
43
|
}, i))
|
|
42
44
|
})
|
|
43
45
|
}));
|
|
44
|
-
};
|
|
46
|
+
});
|
|
@@ -4,12 +4,14 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { useModalContext } from '@coinbase/cds-common/overlays/ModalContext';
|
|
6
6
|
import { IconButton } from '../../buttons';
|
|
7
|
+
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
7
8
|
import { Box } from '../../layout/Box';
|
|
8
9
|
import { HStack } from '../../layout/HStack';
|
|
9
10
|
import { Text } from '../../typography/Text';
|
|
10
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
export const ModalHeader =
|
|
12
|
-
|
|
12
|
+
export const ModalHeader = _props => {
|
|
13
|
+
const mergedProps = useComponentConfig('ModalHeader', _props);
|
|
14
|
+
const {
|
|
13
15
|
alignItems = 'center',
|
|
14
16
|
paddingX = 3,
|
|
15
17
|
paddingY = 2,
|
|
@@ -19,8 +21,8 @@ export const ModalHeader = _ref => {
|
|
|
19
21
|
backAccessibilityHint,
|
|
20
22
|
closeAccessibilityLabel,
|
|
21
23
|
closeAccessibilityHint
|
|
22
|
-
} =
|
|
23
|
-
props = _objectWithoutPropertiesLoose(
|
|
24
|
+
} = mergedProps,
|
|
25
|
+
props = _objectWithoutPropertiesLoose(mergedProps, _excluded);
|
|
24
26
|
const {
|
|
25
27
|
onRequestClose,
|
|
26
28
|
hideCloseButton,
|
|
@@ -3,18 +3,20 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import React, { memo } from 'react';
|
|
5
5
|
import { OverlayContentContext } from '@coinbase/cds-common/overlays/OverlayContentContext';
|
|
6
|
+
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
6
7
|
import { useTheme } from '../../hooks/useTheme';
|
|
7
8
|
import { VStack } from '../../layout/VStack';
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
const overlayContentContextValue = {
|
|
10
11
|
isOverlay: true
|
|
11
12
|
};
|
|
12
|
-
export const Overlay = /*#__PURE__*/memo(
|
|
13
|
+
export const Overlay = /*#__PURE__*/memo(_props => {
|
|
13
14
|
var _theme$darkSpectrum;
|
|
14
|
-
|
|
15
|
+
const mergedProps = useComponentConfig('Overlay', _props);
|
|
16
|
+
const {
|
|
15
17
|
opacity
|
|
16
|
-
} =
|
|
17
|
-
props = _objectWithoutPropertiesLoose(
|
|
18
|
+
} = mergedProps,
|
|
19
|
+
props = _objectWithoutPropertiesLoose(mergedProps, _excluded);
|
|
18
20
|
const theme = useTheme();
|
|
19
21
|
return /*#__PURE__*/_jsx(OverlayContentContext.Provider, {
|
|
20
22
|
value: overlayContentContextValue,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { Modal as RNModal, TouchableOpacity, View } from 'react-native';
|
|
4
|
+
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
4
5
|
import { InvertedThemeProvider } from '../../system/ThemeProvider';
|
|
5
6
|
import { InternalTooltip } from './InternalTooltip';
|
|
6
7
|
import { useTooltipAnimation } from './useTooltipAnimation';
|
|
7
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
-
export const Tooltip = /*#__PURE__*/memo(
|
|
9
|
-
|
|
9
|
+
export const Tooltip = /*#__PURE__*/memo(_props => {
|
|
10
|
+
const mergedProps = useComponentConfig('Tooltip', _props);
|
|
11
|
+
const {
|
|
10
12
|
children,
|
|
11
13
|
content,
|
|
12
14
|
placement = 'top',
|
|
@@ -25,7 +27,7 @@ export const Tooltip = /*#__PURE__*/memo(_ref => {
|
|
|
25
27
|
elevation,
|
|
26
28
|
openDelay,
|
|
27
29
|
closeDelay
|
|
28
|
-
} =
|
|
30
|
+
} = mergedProps;
|
|
29
31
|
const subjectRef = useRef(null);
|
|
30
32
|
const [isOpen, setIsOpen] = useState(false);
|
|
31
33
|
const isVisible = visible !== false && isOpen;
|
|
@@ -6,6 +6,7 @@ import React, { createContext, forwardRef, memo, useCallback, useContext, useEff
|
|
|
6
6
|
import { useWindowDimensions } from 'react-native';
|
|
7
7
|
import { MAX_OVER_DRAG } from '@coinbase/cds-common/animation/drawer';
|
|
8
8
|
import { verticalDrawerPercentageOfView as defaultVerticalDrawerPercentageOfView } from '@coinbase/cds-common/tokens/drawer';
|
|
9
|
+
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
9
10
|
import { Box, VStack } from '../../layout';
|
|
10
11
|
import { Text } from '../../typography/Text';
|
|
11
12
|
import { Drawer } from '../drawer/Drawer';
|
|
@@ -14,8 +15,9 @@ export const TrayContext = /*#__PURE__*/createContext({
|
|
|
14
15
|
verticalDrawerPercentageOfView: defaultVerticalDrawerPercentageOfView,
|
|
15
16
|
titleHeight: 0
|
|
16
17
|
});
|
|
17
|
-
export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(
|
|
18
|
-
|
|
18
|
+
export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_props, ref) {
|
|
19
|
+
const mergedProps = useComponentConfig('Tray', _props);
|
|
20
|
+
const {
|
|
19
21
|
children,
|
|
20
22
|
title,
|
|
21
23
|
header,
|
|
@@ -25,8 +27,8 @@ export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref
|
|
|
25
27
|
handleBarVariant = 'outside',
|
|
26
28
|
verticalDrawerPercentageOfView = defaultVerticalDrawerPercentageOfView,
|
|
27
29
|
styles
|
|
28
|
-
} =
|
|
29
|
-
props = _objectWithoutPropertiesLoose(
|
|
30
|
+
} = mergedProps,
|
|
31
|
+
props = _objectWithoutPropertiesLoose(mergedProps, _excluded);
|
|
30
32
|
const [titleHeight, setTitleHeight] = useState(0);
|
|
31
33
|
const isInsideHandleBar = handleBarVariant === 'inside';
|
|
32
34
|
const isTitleString = typeof title === 'string';
|
|
@@ -36,13 +38,13 @@ export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref
|
|
|
36
38
|
titleStyle,
|
|
37
39
|
drawerStyles
|
|
38
40
|
} = useMemo(() => {
|
|
39
|
-
const
|
|
41
|
+
const _ref = styles != null ? styles : {},
|
|
40
42
|
{
|
|
41
43
|
content: contentStyle,
|
|
42
44
|
header: headerStyle,
|
|
43
45
|
title: titleStyle
|
|
44
|
-
} =
|
|
45
|
-
drawerStyles = _objectWithoutPropertiesLoose(
|
|
46
|
+
} = _ref,
|
|
47
|
+
drawerStyles = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
46
48
|
return {
|
|
47
49
|
contentStyle,
|
|
48
50
|
headerStyle,
|
|
@@ -54,10 +56,10 @@ export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref
|
|
|
54
56
|
if (!title) return;
|
|
55
57
|
setTitleHeight(event.nativeEvent.layout.height);
|
|
56
58
|
}, [title]);
|
|
57
|
-
const renderChildren = useCallback(
|
|
59
|
+
const renderChildren = useCallback(_ref2 => {
|
|
58
60
|
let {
|
|
59
61
|
handleClose
|
|
60
|
-
} =
|
|
62
|
+
} = _ref2;
|
|
61
63
|
const content = typeof children === 'function' ? children({
|
|
62
64
|
handleClose
|
|
63
65
|
}) : children;
|
|
@@ -125,10 +127,10 @@ export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref
|
|
|
125
127
|
* @deprecated Redundant component. This will be removed in a future major release.
|
|
126
128
|
* @deprecationExpectedRemoval v9
|
|
127
129
|
*/
|
|
128
|
-
export const TrayStickyFooter =
|
|
130
|
+
export const TrayStickyFooter = _ref3 => {
|
|
129
131
|
let {
|
|
130
132
|
children
|
|
131
|
-
} =
|
|
133
|
+
} = _ref3;
|
|
132
134
|
const {
|
|
133
135
|
verticalDrawerPercentageOfView,
|
|
134
136
|
titleHeight
|
package/esm/page/PageFooter.js
CHANGED
|
@@ -3,13 +3,15 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import React, { forwardRef, memo } from 'react';
|
|
5
5
|
import { pageFooterHeight } from '@coinbase/cds-common/tokens/page';
|
|
6
|
+
import { useComponentConfig } from '../hooks/useComponentConfig';
|
|
6
7
|
import { Box } from '../layout/Box';
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
export const PageFooter = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(
|
|
9
|
-
|
|
9
|
+
export const PageFooter = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
|
|
10
|
+
const mergedProps = useComponentConfig('PageFooter', _props);
|
|
11
|
+
const {
|
|
10
12
|
action
|
|
11
|
-
} =
|
|
12
|
-
props = _objectWithoutPropertiesLoose(
|
|
13
|
+
} = mergedProps,
|
|
14
|
+
props = _objectWithoutPropertiesLoose(mergedProps, _excluded);
|
|
13
15
|
return /*#__PURE__*/_jsx(Box, _extends({
|
|
14
16
|
ref: ref,
|
|
15
17
|
accessibilityRole: "toolbar",
|
package/esm/page/PageHeader.js
CHANGED
|
@@ -3,20 +3,22 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import React, { forwardRef, memo, useMemo } from 'react';
|
|
5
5
|
import { pageHeaderHeight } from '@coinbase/cds-common/tokens/page';
|
|
6
|
+
import { useComponentConfig } from '../hooks/useComponentConfig';
|
|
6
7
|
import { Box } from '../layout/Box';
|
|
7
8
|
import { HStack } from '../layout/HStack';
|
|
8
9
|
import { VStack } from '../layout/VStack';
|
|
9
10
|
import { Text } from '../typography/Text';
|
|
10
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
export const PageHeader = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(
|
|
12
|
-
|
|
12
|
+
export const PageHeader = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
|
|
13
|
+
const mergedProps = useComponentConfig('PageHeader', _props);
|
|
14
|
+
const {
|
|
13
15
|
start,
|
|
14
16
|
title,
|
|
15
17
|
end,
|
|
16
18
|
styles,
|
|
17
19
|
style
|
|
18
|
-
} =
|
|
19
|
-
props = _objectWithoutPropertiesLoose(
|
|
20
|
+
} = mergedProps,
|
|
21
|
+
props = _objectWithoutPropertiesLoose(mergedProps, _excluded);
|
|
20
22
|
const isMultiRow = useMemo(() => Boolean(start && title && end), [start, end, title]);
|
|
21
23
|
return /*#__PURE__*/_jsxs(VStack, _extends({
|
|
22
24
|
ref: ref,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { measurePerformance } from 'reassure';
|
|
2
|
+
import { Button } from '../../buttons/Button';
|
|
3
|
+
import { ComponentConfigProvider } from '../../system/ComponentConfigProvider';
|
|
4
|
+
import { DefaultThemeProvider } from '../../utils/testHelpers';
|
|
5
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
|
+
const buttonCount = 1000;
|
|
7
|
+
const ButtonList = () => {
|
|
8
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
9
|
+
children: Array.from({
|
|
10
|
+
length: buttonCount
|
|
11
|
+
}, (_, index) => /*#__PURE__*/_jsx(Button, {
|
|
12
|
+
children: "Child"
|
|
13
|
+
}, index))
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
describe('Button component-config performance (mobile)', () => {
|
|
17
|
+
jest.setTimeout(20000);
|
|
18
|
+
it('no provider', async () => {
|
|
19
|
+
await measurePerformance(/*#__PURE__*/_jsx(DefaultThemeProvider, {
|
|
20
|
+
children: /*#__PURE__*/_jsx(ButtonList, {})
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
it('provider customization', async () => {
|
|
24
|
+
await measurePerformance(/*#__PURE__*/_jsx(DefaultThemeProvider, {
|
|
25
|
+
children: /*#__PURE__*/_jsx(ComponentConfigProvider, {
|
|
26
|
+
value: {
|
|
27
|
+
Button: {
|
|
28
|
+
compact: true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
children: /*#__PURE__*/_jsx(ButtonList, {})
|
|
32
|
+
})
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import { Pressable, Text } from 'react-native';
|
|
3
|
+
import { fireEvent, screen } from '@testing-library/react-native';
|
|
4
|
+
import { measurePerformance } from 'reassure';
|
|
5
|
+
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
6
|
+
import { ComponentConfigProvider } from '../../system/ComponentConfigProvider';
|
|
7
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const consumerCount = 1000;
|
|
9
|
+
const updateIterations = 50;
|
|
10
|
+
const testTimeoutMs = 20000;
|
|
11
|
+
const stableButtonConfig = () => ({
|
|
12
|
+
compact: true
|
|
13
|
+
});
|
|
14
|
+
const stableAvatarConfig = () => ({});
|
|
15
|
+
const ButtonConfigConsumer = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
index
|
|
18
|
+
} = _ref;
|
|
19
|
+
const mergedProps = useComponentConfig('Button', {
|
|
20
|
+
compact: false,
|
|
21
|
+
variant: 'primary'
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
24
|
+
testID: "consumer-" + index,
|
|
25
|
+
children: mergedProps.compact ? 'compact' : 'default'
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const ButtonConfigConsumerList = _ref2 => {
|
|
29
|
+
let {
|
|
30
|
+
count
|
|
31
|
+
} = _ref2;
|
|
32
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
33
|
+
children: Array.from({
|
|
34
|
+
length: count
|
|
35
|
+
}, (_, index) => /*#__PURE__*/_jsx(ButtonConfigConsumer, {
|
|
36
|
+
index: index
|
|
37
|
+
}, index))
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const UnrelatedKeyUpdateHarness = _ref3 => {
|
|
41
|
+
let {
|
|
42
|
+
count
|
|
43
|
+
} = _ref3;
|
|
44
|
+
const [unrelatedUpdates, setUnrelatedUpdates] = useState(0);
|
|
45
|
+
const value = useMemo(() => ({
|
|
46
|
+
Avatar: () => unrelatedUpdates % 2 === 0 ? {} : {},
|
|
47
|
+
Button: stableButtonConfig
|
|
48
|
+
}), [unrelatedUpdates]);
|
|
49
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
50
|
+
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
51
|
+
onPress: () => setUnrelatedUpdates(v => v + 1),
|
|
52
|
+
testID: "update-unrelated-key",
|
|
53
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
54
|
+
children: "Update unrelated key"
|
|
55
|
+
})
|
|
56
|
+
}), /*#__PURE__*/_jsx(ComponentConfigProvider, {
|
|
57
|
+
value: value,
|
|
58
|
+
children: /*#__PURE__*/_jsx(ButtonConfigConsumerList, {
|
|
59
|
+
count: count
|
|
60
|
+
})
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const TargetKeyUpdateHarness = _ref4 => {
|
|
65
|
+
let {
|
|
66
|
+
count
|
|
67
|
+
} = _ref4;
|
|
68
|
+
const [targetUpdates, setTargetUpdates] = useState(0);
|
|
69
|
+
const value = useMemo(() => ({
|
|
70
|
+
Avatar: stableAvatarConfig,
|
|
71
|
+
Button: () => ({
|
|
72
|
+
compact: targetUpdates % 2 === 0
|
|
73
|
+
})
|
|
74
|
+
}), [targetUpdates]);
|
|
75
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
76
|
+
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
77
|
+
onPress: () => setTargetUpdates(v => v + 1),
|
|
78
|
+
testID: "update-target-key",
|
|
79
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
80
|
+
children: "Update target key"
|
|
81
|
+
})
|
|
82
|
+
}), /*#__PURE__*/_jsx(ComponentConfigProvider, {
|
|
83
|
+
value: value,
|
|
84
|
+
children: /*#__PURE__*/_jsx(ButtonConfigConsumerList, {
|
|
85
|
+
count: count
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
describe('ComponentConfigProvider performance tests (mobile)', () => {
|
|
91
|
+
jest.setTimeout(testTimeoutMs);
|
|
92
|
+
beforeAll(() => {
|
|
93
|
+
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
94
|
+
});
|
|
95
|
+
afterAll(() => {
|
|
96
|
+
jest.restoreAllMocks();
|
|
97
|
+
});
|
|
98
|
+
it('Scenario A: renders 1000 consumers under one provider', async () => {
|
|
99
|
+
await measurePerformance(/*#__PURE__*/_jsx(ComponentConfigProvider, {
|
|
100
|
+
value: {
|
|
101
|
+
Button: stableButtonConfig
|
|
102
|
+
},
|
|
103
|
+
children: /*#__PURE__*/_jsx(ButtonConfigConsumerList, {
|
|
104
|
+
count: consumerCount
|
|
105
|
+
})
|
|
106
|
+
}));
|
|
107
|
+
});
|
|
108
|
+
it('Scenario B: updates unrelated component key 50 times', async () => {
|
|
109
|
+
const scenario = async () => {
|
|
110
|
+
for (let i = 0; i < updateIterations; i += 1) {
|
|
111
|
+
fireEvent.press(screen.getByTestId('update-unrelated-key'));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
await measurePerformance(/*#__PURE__*/_jsx(UnrelatedKeyUpdateHarness, {
|
|
115
|
+
count: consumerCount
|
|
116
|
+
}), {
|
|
117
|
+
scenario
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
it('Scenario C: updates target component key 50 times', async () => {
|
|
121
|
+
const scenario = async () => {
|
|
122
|
+
for (let i = 0; i < updateIterations; i += 1) {
|
|
123
|
+
fireEvent.press(screen.getByTestId('update-target-key'));
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
await measurePerformance(/*#__PURE__*/_jsx(TargetKeyUpdateHarness, {
|
|
127
|
+
count: consumerCount
|
|
128
|
+
}), {
|
|
129
|
+
scenario
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
it('Scenario D (baseline): no provider with 1000 consumers', async () => {
|
|
133
|
+
await measurePerformance(/*#__PURE__*/_jsx(ButtonConfigConsumerList, {
|
|
134
|
+
count: consumerCount
|
|
135
|
+
}));
|
|
136
|
+
});
|
|
137
|
+
it('Scenario D (provider): provider enabled with 1000 consumers', async () => {
|
|
138
|
+
await measurePerformance(/*#__PURE__*/_jsx(ComponentConfigProvider, {
|
|
139
|
+
value: {
|
|
140
|
+
Button: stableButtonConfig
|
|
141
|
+
},
|
|
142
|
+
children: /*#__PURE__*/_jsx(ButtonConfigConsumerList, {
|
|
143
|
+
count: consumerCount
|
|
144
|
+
})
|
|
145
|
+
}));
|
|
146
|
+
});
|
|
147
|
+
});
|