@coinbase/cds-web 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.
Files changed (287) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dts/accordion/Accordion.d.ts +1 -9
  3. package/dts/accordion/Accordion.d.ts.map +1 -1
  4. package/dts/alpha/combobox/Combobox.d.ts.map +1 -1
  5. package/dts/alpha/select/Select.d.ts.map +1 -1
  6. package/dts/alpha/select-chip/SelectChip.d.ts.map +1 -1
  7. package/dts/alpha/tabbed-chips/TabbedChips.d.ts.map +1 -1
  8. package/dts/banner/Banner.d.ts.map +1 -1
  9. package/dts/buttons/AvatarButton.d.ts.map +1 -1
  10. package/dts/buttons/Button.d.ts +2 -4
  11. package/dts/buttons/Button.d.ts.map +1 -1
  12. package/dts/buttons/ButtonGroup.d.ts.map +1 -1
  13. package/dts/buttons/IconButton.d.ts.map +1 -1
  14. package/dts/buttons/IconCounterButton.d.ts.map +1 -1
  15. package/dts/buttons/Tile.d.ts +1 -1
  16. package/dts/buttons/Tile.d.ts.map +1 -1
  17. package/dts/buttons/TileButton.d.ts.map +1 -1
  18. package/dts/cards/Card.d.ts +4 -0
  19. package/dts/cards/Card.d.ts.map +1 -1
  20. package/dts/cards/CardBody.d.ts +3 -0
  21. package/dts/cards/CardBody.d.ts.map +1 -1
  22. package/dts/cards/CardFooter.d.ts +4 -0
  23. package/dts/cards/CardFooter.d.ts.map +1 -1
  24. package/dts/cards/CardGroup.d.ts +12 -0
  25. package/dts/cards/CardGroup.d.ts.map +1 -1
  26. package/dts/cards/CardHeader.d.ts +4 -0
  27. package/dts/cards/CardHeader.d.ts.map +1 -1
  28. package/dts/cards/CardMedia.d.ts +4 -0
  29. package/dts/cards/CardMedia.d.ts.map +1 -1
  30. package/dts/cards/LikeButton.d.ts.map +1 -1
  31. package/dts/carousel/Carousel.d.ts.map +1 -1
  32. package/dts/cells/Cell.d.ts.map +1 -1
  33. package/dts/cells/CellAccessory.d.ts.map +1 -1
  34. package/dts/cells/ListCell.d.ts.map +1 -1
  35. package/dts/cells/ListCellFallback.d.ts.map +1 -1
  36. package/dts/chips/Chip.d.ts.map +1 -1
  37. package/dts/chips/ChipProps.d.ts +10 -8
  38. package/dts/chips/ChipProps.d.ts.map +1 -1
  39. package/dts/chips/InputChip.d.ts.map +1 -1
  40. package/dts/chips/MediaChip.d.ts +4 -4
  41. package/dts/chips/MediaChip.d.ts.map +1 -1
  42. package/dts/chips/TabbedChips.d.ts.map +1 -1
  43. package/dts/coachmark/Coachmark.d.ts.map +1 -1
  44. package/dts/collapsible/Collapsible.d.ts.map +1 -1
  45. package/dts/collapsible/useCollapsibleMotionProps.d.ts +221 -221
  46. package/dts/controls/Checkbox.d.ts.map +1 -1
  47. package/dts/controls/CheckboxCell.d.ts.map +1 -1
  48. package/dts/controls/Control.d.ts.map +1 -1
  49. package/dts/controls/ControlGroup.d.ts +13 -4
  50. package/dts/controls/ControlGroup.d.ts.map +1 -1
  51. package/dts/controls/InputStack.d.ts.map +1 -1
  52. package/dts/controls/Radio.d.ts.map +1 -1
  53. package/dts/controls/RadioCell.d.ts.map +1 -1
  54. package/dts/controls/SearchInput.d.ts.map +1 -1
  55. package/dts/controls/SelectOption.d.ts +1 -14
  56. package/dts/controls/SelectOption.d.ts.map +1 -1
  57. package/dts/controls/Switch.d.ts +2 -1
  58. package/dts/controls/Switch.d.ts.map +1 -1
  59. package/dts/controls/TextInput.d.ts.map +1 -1
  60. package/dts/core/componentConfig.d.ts +192 -0
  61. package/dts/core/componentConfig.d.ts.map +1 -0
  62. package/dts/dates/Calendar.d.ts.map +1 -1
  63. package/dts/dates/DateInput.d.ts.map +1 -1
  64. package/dts/dates/DatePicker.d.ts.map +1 -1
  65. package/dts/dots/DotCount.d.ts +1 -15
  66. package/dts/dots/DotCount.d.ts.map +1 -1
  67. package/dts/dots/DotStatusColor.d.ts +1 -10
  68. package/dts/dots/DotStatusColor.d.ts.map +1 -1
  69. package/dts/dots/DotSymbol.d.ts +1 -22
  70. package/dts/dots/DotSymbol.d.ts.map +1 -1
  71. package/dts/dropdown/Dropdown.d.ts +30 -29
  72. package/dts/dropdown/Dropdown.d.ts.map +1 -1
  73. package/dts/dropdown/DropdownProps.d.ts +53 -51
  74. package/dts/dropdown/DropdownProps.d.ts.map +1 -1
  75. package/dts/hooks/useComponentConfig.d.ts +22 -0
  76. package/dts/hooks/useComponentConfig.d.ts.map +1 -0
  77. package/dts/hooks/useIsoEffect.d.ts +2 -2
  78. package/dts/hooks/useIsoEffect.d.ts.map +1 -1
  79. package/dts/icons/Icon.d.ts.map +1 -1
  80. package/dts/index.d.ts +2 -0
  81. package/dts/index.d.ts.map +1 -1
  82. package/dts/layout/Divider.d.ts +1 -6
  83. package/dts/layout/Divider.d.ts.map +1 -1
  84. package/dts/layout/Fallback.d.ts.map +1 -1
  85. package/dts/media/Avatar.d.ts +1 -15
  86. package/dts/media/Avatar.d.ts.map +1 -1
  87. package/dts/media/RemoteImage.d.ts +1 -15
  88. package/dts/media/RemoteImage.d.ts.map +1 -1
  89. package/dts/media/RemoteImageGroup.d.ts +3 -10
  90. package/dts/media/RemoteImageGroup.d.ts.map +1 -1
  91. package/dts/motion/useMotionProps.d.ts +457 -457
  92. package/dts/motion/utils.d.ts +211 -211
  93. package/dts/navigation/NavigationBar.d.ts +1 -25
  94. package/dts/navigation/NavigationBar.d.ts.map +1 -1
  95. package/dts/navigation/NavigationTitle.d.ts +4 -3
  96. package/dts/navigation/NavigationTitle.d.ts.map +1 -1
  97. package/dts/navigation/NavigationTitleSelect.d.ts +5 -12
  98. package/dts/navigation/NavigationTitleSelect.d.ts.map +1 -1
  99. package/dts/navigation/Sidebar.d.ts.map +1 -1
  100. package/dts/navigation/SidebarItem.d.ts +40 -34
  101. package/dts/navigation/SidebarItem.d.ts.map +1 -1
  102. package/dts/navigation/SidebarMoreMenu.d.ts +13 -12
  103. package/dts/navigation/SidebarMoreMenu.d.ts.map +1 -1
  104. package/dts/numbers/RollingNumber/RollingNumber.d.ts.map +1 -1
  105. package/dts/overlays/Alert.d.ts.map +1 -1
  106. package/dts/overlays/FocusTrap.d.ts +9 -12
  107. package/dts/overlays/FocusTrap.d.ts.map +1 -1
  108. package/dts/overlays/FullscreenAlert.d.ts +10 -7
  109. package/dts/overlays/FullscreenAlert.d.ts.map +1 -1
  110. package/dts/overlays/Toast.d.ts.map +1 -1
  111. package/dts/overlays/modal/FullscreenModal.d.ts +47 -45
  112. package/dts/overlays/modal/FullscreenModal.d.ts.map +1 -1
  113. package/dts/overlays/modal/FullscreenModalHeader.d.ts.map +1 -1
  114. package/dts/overlays/modal/FullscreenModalLayout.d.ts +2 -2
  115. package/dts/overlays/modal/Modal.d.ts.map +1 -1
  116. package/dts/overlays/modal/ModalBody.d.ts +6 -3
  117. package/dts/overlays/modal/ModalBody.d.ts.map +1 -1
  118. package/dts/overlays/modal/ModalFooter.d.ts +3 -10
  119. package/dts/overlays/modal/ModalFooter.d.ts.map +1 -1
  120. package/dts/overlays/modal/ModalHeader.d.ts +3 -12
  121. package/dts/overlays/modal/ModalHeader.d.ts.map +1 -1
  122. package/dts/overlays/modal/ModalWrapper.d.ts.map +1 -1
  123. package/dts/overlays/overlay/Overlay.d.ts +2 -1
  124. package/dts/overlays/overlay/Overlay.d.ts.map +1 -1
  125. package/dts/overlays/overlay/OverlayContent.d.ts +7 -5
  126. package/dts/overlays/overlay/OverlayContent.d.ts.map +1 -1
  127. package/dts/overlays/popover/PopoverProps.d.ts +46 -46
  128. package/dts/overlays/popover/PopoverProps.d.ts.map +1 -1
  129. package/dts/overlays/tooltip/Tooltip.d.ts +4 -22
  130. package/dts/overlays/tooltip/Tooltip.d.ts.map +1 -1
  131. package/dts/overlays/tooltip/TooltipContent.d.ts +7 -1
  132. package/dts/overlays/tooltip/TooltipContent.d.ts.map +1 -1
  133. package/dts/overlays/tray/Tray.d.ts.map +1 -1
  134. package/dts/page/PageFooter.d.ts.map +1 -1
  135. package/dts/page/PageHeader.d.ts.map +1 -1
  136. package/dts/pagination/Pagination.d.ts +3 -19
  137. package/dts/pagination/Pagination.d.ts.map +1 -1
  138. package/dts/perf/component-config/Button.component-config.perf-test.d.ts +2 -0
  139. package/dts/perf/component-config/Button.component-config.perf-test.d.ts.map +1 -0
  140. package/dts/perf/component-config/ComponentConfigProvider.perf-test.d.ts +2 -0
  141. package/dts/perf/component-config/ComponentConfigProvider.perf-test.d.ts.map +1 -0
  142. package/dts/perf/component-config/ComponentConfigStickerSheet.perf-test.d.ts +2 -0
  143. package/dts/perf/component-config/ComponentConfigStickerSheet.perf-test.d.ts.map +1 -0
  144. package/dts/section-header/SectionHeader.d.ts.map +1 -1
  145. package/dts/stepper/Stepper.d.ts.map +1 -1
  146. package/dts/system/ComponentConfigProvider.d.ts +26 -0
  147. package/dts/system/ComponentConfigProvider.d.ts.map +1 -0
  148. package/dts/system/index.d.ts +1 -0
  149. package/dts/system/index.d.ts.map +1 -1
  150. package/dts/tables/Table.d.ts +7 -5
  151. package/dts/tables/Table.d.ts.map +1 -1
  152. package/dts/tables/TableCaption.d.ts +32 -41
  153. package/dts/tables/TableCaption.d.ts.map +1 -1
  154. package/dts/tables/TableCell.d.ts +26 -48
  155. package/dts/tables/TableCell.d.ts.map +1 -1
  156. package/dts/tables/TableCellFallback.d.ts +10 -17
  157. package/dts/tables/TableCellFallback.d.ts.map +1 -1
  158. package/dts/tables/TableRow.d.ts +44 -53
  159. package/dts/tables/TableRow.d.ts.map +1 -1
  160. package/dts/tabs/SegmentedTab.d.ts +6 -3
  161. package/dts/tabs/SegmentedTab.d.ts.map +1 -1
  162. package/dts/tabs/SegmentedTabs.d.ts +9 -3
  163. package/dts/tabs/SegmentedTabs.d.ts.map +1 -1
  164. package/dts/tabs/Tabs.d.ts +16 -15
  165. package/dts/tabs/Tabs.d.ts.map +1 -1
  166. package/dts/tabs/hooks/useAnimateTabIndicator.d.ts +457 -457
  167. package/dts/tag/Tag.d.ts.map +1 -1
  168. package/dts/tour/Tour.d.ts +54 -53
  169. package/dts/tour/Tour.d.ts.map +1 -1
  170. package/dts/typography/Link.d.ts.map +1 -1
  171. package/dts/utils/mergeComponentProps.d.ts +34 -0
  172. package/dts/utils/mergeComponentProps.d.ts.map +1 -0
  173. package/dts/visualizations/ProgressBar.d.ts.map +1 -1
  174. package/dts/visualizations/ProgressBarWithFixedLabels.d.ts +5 -3
  175. package/dts/visualizations/ProgressBarWithFixedLabels.d.ts.map +1 -1
  176. package/dts/visualizations/ProgressBarWithFloatLabel.d.ts +3 -1
  177. package/dts/visualizations/ProgressBarWithFloatLabel.d.ts.map +1 -1
  178. package/dts/visualizations/ProgressCircle.d.ts.map +1 -1
  179. package/esm/accordion/Accordion.js +5 -3
  180. package/esm/alpha/combobox/Combobox.js +6 -4
  181. package/esm/alpha/select/Select.js +5 -3
  182. package/esm/alpha/select-chip/SelectChip.js +6 -4
  183. package/esm/alpha/tabbed-chips/TabbedChips.js +6 -4
  184. package/esm/banner/Banner.js +6 -4
  185. package/esm/buttons/AvatarButton.js +6 -4
  186. package/esm/buttons/Button.js +6 -4
  187. package/esm/buttons/ButtonGroup.js +5 -3
  188. package/esm/buttons/IconButton.js +6 -4
  189. package/esm/buttons/IconCounterButton.js +6 -4
  190. package/esm/buttons/Tile.js +5 -3
  191. package/esm/buttons/TileButton.js +6 -4
  192. package/esm/cards/Card.js +4 -0
  193. package/esm/cards/CardBody.js +3 -0
  194. package/esm/cards/CardFooter.js +4 -0
  195. package/esm/cards/CardGroup.js +14 -0
  196. package/esm/cards/CardHeader.js +5 -0
  197. package/esm/cards/CardMedia.js +5 -0
  198. package/esm/cards/LikeButton.js +6 -4
  199. package/esm/carousel/Carousel.js +8 -6
  200. package/esm/cells/Cell.js +8 -6
  201. package/esm/cells/CellAccessory.js +6 -4
  202. package/esm/cells/ListCell.js +6 -4
  203. package/esm/cells/ListCellFallback.js +6 -4
  204. package/esm/chips/Chip.js +6 -4
  205. package/esm/chips/InputChip.js +6 -4
  206. package/esm/chips/MediaChip.js +6 -4
  207. package/esm/chips/TabbedChips.js +6 -4
  208. package/esm/coachmark/Coachmark.js +6 -4
  209. package/esm/collapsible/Collapsible.js +5 -3
  210. package/esm/controls/Checkbox.js +6 -4
  211. package/esm/controls/CheckboxCell.js +6 -4
  212. package/esm/controls/Control.js +6 -4
  213. package/esm/controls/ControlGroup.js +6 -4
  214. package/esm/controls/InputStack.js +6 -4
  215. package/esm/controls/Radio.js +6 -4
  216. package/esm/controls/RadioCell.js +6 -4
  217. package/esm/controls/SearchInput.js +11 -12
  218. package/esm/controls/SelectOption.js +6 -4
  219. package/esm/controls/Switch.js +6 -4
  220. package/esm/controls/TextInput.js +6 -4
  221. package/esm/core/componentConfig.js +1 -0
  222. package/esm/dates/Calendar.js +6 -4
  223. package/esm/dates/DateInput.js +6 -4
  224. package/esm/dates/DatePicker.js +6 -4
  225. package/esm/dots/DotCount.js +6 -4
  226. package/esm/dots/DotStatusColor.js +6 -4
  227. package/esm/dots/DotSymbol.js +6 -4
  228. package/esm/dropdown/Dropdown.js +6 -4
  229. package/esm/hooks/useComponentConfig.js +27 -0
  230. package/esm/icons/Icon.js +6 -4
  231. package/esm/index.js +2 -0
  232. package/esm/layout/Divider.js +6 -4
  233. package/esm/layout/Fallback.js +6 -4
  234. package/esm/media/Avatar.js +8 -6
  235. package/esm/media/RemoteImage.js +6 -4
  236. package/esm/media/RemoteImageGroup.js +6 -4
  237. package/esm/navigation/NavigationBar.js +6 -4
  238. package/esm/navigation/NavigationTitle.js +6 -4
  239. package/esm/navigation/NavigationTitleSelect.js +6 -4
  240. package/esm/navigation/Sidebar.js +6 -4
  241. package/esm/navigation/SidebarItem.js +6 -4
  242. package/esm/navigation/SidebarMoreMenu.js +6 -4
  243. package/esm/numbers/RollingNumber/RollingNumber.js +6 -4
  244. package/esm/overlays/Alert.js +6 -4
  245. package/esm/overlays/FocusTrap.js +5 -3
  246. package/esm/overlays/FullscreenAlert.js +5 -3
  247. package/esm/overlays/Toast.js +6 -4
  248. package/esm/overlays/modal/FullscreenModal.js +5 -3
  249. package/esm/overlays/modal/FullscreenModalHeader.js +6 -4
  250. package/esm/overlays/modal/Modal.js +6 -4
  251. package/esm/overlays/modal/ModalBody.js +9 -6
  252. package/esm/overlays/modal/ModalFooter.js +8 -6
  253. package/esm/overlays/modal/ModalHeader.js +6 -4
  254. package/esm/overlays/modal/ModalWrapper.js +6 -4
  255. package/esm/overlays/overlay/Overlay.js +4 -2
  256. package/esm/overlays/tooltip/Tooltip.js +9 -7
  257. package/esm/overlays/tooltip/TooltipContent.js +16 -9
  258. package/esm/overlays/tray/Tray.js +5 -3
  259. package/esm/page/PageFooter.js +6 -4
  260. package/esm/page/PageHeader.js +6 -4
  261. package/esm/pagination/Pagination.js +6 -4
  262. package/esm/perf/component-config/Button.component-config.perf-test.js +43 -0
  263. package/esm/perf/component-config/ComponentConfigProvider.perf-test.js +134 -0
  264. package/esm/perf/component-config/ComponentConfigStickerSheet.perf-test.js +332 -0
  265. package/esm/perf/component-config/README.md +8 -0
  266. package/esm/section-header/SectionHeader.js +6 -4
  267. package/esm/stepper/Stepper.js +12 -10
  268. package/esm/system/ComponentConfigProvider.js +41 -0
  269. package/esm/system/index.js +1 -0
  270. package/esm/tables/Table.js +6 -4
  271. package/esm/tables/TableCaption.js +6 -4
  272. package/esm/tables/TableCell.js +9 -7
  273. package/esm/tables/TableCellFallback.js +6 -4
  274. package/esm/tables/TableRow.js +6 -4
  275. package/esm/tabs/SegmentedTab.js +6 -4
  276. package/esm/tabs/SegmentedTabs.js +6 -4
  277. package/esm/tabs/Tabs.js +12 -10
  278. package/esm/tag/Tag.js +6 -4
  279. package/esm/tour/Tour.js +5 -3
  280. package/esm/typography/Link.js +6 -4
  281. package/esm/utils/mergeComponentProps.js +39 -0
  282. package/esm/visualizations/ProgressBar.js +5 -3
  283. package/esm/visualizations/ProgressBarWithFixedLabels.js +5 -3
  284. package/esm/visualizations/ProgressBarWithFloatLabel.js +5 -3
  285. package/esm/visualizations/ProgressCircle.js +7 -5
  286. package/package.json +4 -3
  287. package/esm/controls/SearchInput.css +0 -2
@@ -1,4 +1,5 @@
1
- import React, { cloneElement, useCallback, useMemo, useRef } from 'react';
1
+ import React, { cloneElement, memo, useCallback, useMemo, useRef } from 'react';
2
+ import { useComponentConfig } from '../../hooks/useComponentConfig';
2
3
  import { Popover } from '../popover/Popover';
3
4
  import { TooltipContent } from './TooltipContent';
4
5
  import { useTooltipState } from './useTooltipState';
@@ -7,8 +8,9 @@ const preventMouseDown = event => {
7
8
  event.preventDefault();
8
9
  event.stopPropagation();
9
10
  };
10
- export const Tooltip = _ref => {
11
- let {
11
+ export const Tooltip = /*#__PURE__*/memo(_props => {
12
+ const mergedProps = useComponentConfig('Tooltip', _props);
13
+ const {
12
14
  children,
13
15
  content,
14
16
  elevation,
@@ -29,7 +31,7 @@ export const Tooltip = _ref => {
29
31
  autoFocusDelay = 20,
30
32
  openDelay,
31
33
  closeDelay
32
- } = _ref;
34
+ } = mergedProps;
33
35
  const {
34
36
  isOpen,
35
37
  handleOnMouseEnter,
@@ -39,10 +41,10 @@ export const Tooltip = _ref => {
39
41
  tooltipId
40
42
  } = useTooltipState(tooltipIdDefault, openDelay, closeDelay);
41
43
  const tooltipContentRef = useRef(null);
42
- const handleMouseEnter = useCallback(_ref2 => {
44
+ const handleMouseEnter = useCallback(_ref => {
43
45
  let {
44
46
  target
45
- } = _ref2;
47
+ } = _ref;
46
48
  const node = tooltipContentRef.current;
47
49
 
48
50
  // to prevent flicker, don't open tooltip if enter event originates from tooltip content
@@ -98,4 +100,4 @@ export const Tooltip = _ref => {
98
100
  visible: isVisible,
99
101
  children: clonedChild
100
102
  });
101
- };
103
+ });
@@ -8,21 +8,28 @@ import { animateInOpacityConfig, animateOutOpacityConfig, getTranslateConfigByPl
8
8
  import { tooltipMaxWidth, tooltipPaddingX, tooltipPaddingY } from '@coinbase/cds-common/tokens/tooltip';
9
9
  import { zIndex as zIndexTokens } from '@coinbase/cds-common/tokens/zIndex';
10
10
  import { m as motion } from 'framer-motion';
11
+ import { useComponentConfig } from '../../hooks/useComponentConfig';
11
12
  import { Box } from '../../layout/Box';
12
13
  import { useMotionProps } from '../../motion/useMotionProps';
13
14
  import { Text } from '../../typography/Text';
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
  const textCss = "textCss-t15dzixe";
16
- export const TooltipContent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
17
- let {
17
+ export const TooltipContent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
18
+ const mergedProps = useComponentConfig('TooltipContent', _props);
19
+ const {
18
20
  content,
19
21
  elevation,
20
22
  gap,
21
23
  testID,
22
24
  zIndex,
23
25
  tooltipId,
24
- placement = 'top'
25
- } = _ref;
26
+ placement = 'top',
27
+ background = 'bg',
28
+ borderRadius = 200,
29
+ maxWidth = tooltipMaxWidth,
30
+ paddingX = tooltipPaddingX,
31
+ paddingY = tooltipPaddingY
32
+ } = mergedProps;
26
33
  const outerStyle = useMemo(() => ({
27
34
  padding: "var(--space-".concat(gap, ")"),
28
35
  zIndex: zIndex !== null && zIndex !== void 0 ? zIndex : zIndexTokens.tooltip
@@ -42,14 +49,14 @@ export const TooltipContent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
42
49
  "data-testid": "".concat(testID, "-motion"),
43
50
  children: /*#__PURE__*/_jsx(Box, {
44
51
  ref: ref,
45
- background: "bg",
46
- borderRadius: 200,
52
+ background: background,
53
+ borderRadius: borderRadius,
47
54
  "data-testid": testID,
48
55
  elevation: elevation,
49
56
  id: tooltipId,
50
- maxWidth: tooltipMaxWidth,
51
- paddingX: tooltipPaddingX,
52
- paddingY: tooltipPaddingY,
57
+ maxWidth: maxWidth,
58
+ paddingX: paddingX,
59
+ paddingY: paddingY,
53
60
  role: "tooltip",
54
61
  children: typeof content === 'string' ? /*#__PURE__*/_jsx(Text, {
55
62
  className: textCss,
@@ -9,6 +9,7 @@ import { OverlayContentContext } from '@coinbase/cds-common/overlays/OverlayCont
9
9
  import { domMax, LazyMotion, m as motion, MotionConfig, useAnimate, useDragControls } from 'framer-motion';
10
10
  import { IconButton } from '../../buttons';
11
11
  import { cx } from '../../cx';
12
+ import { useComponentConfig } from '../../hooks/useComponentConfig';
12
13
  import { useDimensions } from '../../hooks/useDimensions';
13
14
  import { useScrollBlocker } from '../../hooks/useScrollBlocker';
14
15
  import { useTheme } from '../../hooks/useTheme';
@@ -90,8 +91,9 @@ const animationConfig = {
90
91
  const overlayContentContextValue = {
91
92
  isDrawer: true
92
93
  };
93
- export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref2, ref) {
94
- let {
94
+ export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_props, ref) {
95
+ const mergedProps = useComponentConfig('Tray', _props);
96
+ const {
95
97
  children,
96
98
  header,
97
99
  footer,
@@ -119,7 +121,7 @@ export const Tray = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Tray(_ref
119
121
  pin = 'bottom',
120
122
  showHandleBar,
121
123
  hideCloseButton
122
- } = _ref2;
124
+ } = mergedProps;
123
125
  const theme = useTheme();
124
126
  const [isOpen, setIsOpen] = useState(true);
125
127
  const [hasScrolledDown, setHasScrolledDown] = useState(false);
@@ -8,6 +8,7 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i
8
8
  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; }
9
9
  import React, { forwardRef, memo } from 'react';
10
10
  import { pageFooterHeight } from '@coinbase/cds-common/tokens/page';
11
+ import { useComponentConfig } from '../hooks/useComponentConfig';
11
12
  import { Box } from '../layout/Box';
12
13
  import { jsx as _jsx } from "react/jsx-runtime";
13
14
  export const pageFooterPaddingX = {
@@ -20,16 +21,17 @@ export const pageFooterJustifyContent = {
20
21
  tablet: 'flex-end',
21
22
  desktop: 'flex-end'
22
23
  };
23
- export const PageFooter = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function PageFooter(_ref, ref) {
24
- let {
24
+ export const PageFooter = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
25
+ const mergedProps = useComponentConfig('PageFooter', _props);
26
+ const {
25
27
  action,
26
28
  height = pageFooterHeight,
27
29
  justifyContent = pageFooterJustifyContent,
28
30
  paddingX = pageFooterPaddingX,
29
31
  paddingY = 1.5,
30
32
  role = 'contentinfo'
31
- } = _ref,
32
- props = _objectWithoutProperties(_ref, _excluded);
33
+ } = mergedProps,
34
+ props = _objectWithoutProperties(mergedProps, _excluded);
33
35
  return /*#__PURE__*/_jsx(Box, _objectSpread(_objectSpread({
34
36
  ref: ref,
35
37
  height: height,
@@ -9,6 +9,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
9
9
  import React, { forwardRef, memo, useMemo } from 'react';
10
10
  import { pageHeaderHeight } from '@coinbase/cds-common/tokens/page';
11
11
  import { cx } from '../cx';
12
+ import { useComponentConfig } from '../hooks/useComponentConfig';
12
13
  import { Box } from '../layout/Box';
13
14
  import { Grid } from '../layout/Grid';
14
15
  import { media } from '../styles/media';
@@ -26,8 +27,9 @@ export const pageHeaderEndPaddingX = {
26
27
  tablet: 4,
27
28
  desktop: 4
28
29
  };
29
- export const PageHeader = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function PageHeader(_ref, ref) {
30
- let {
30
+ export const PageHeader = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
31
+ const mergedProps = useComponentConfig('PageHeader', _props);
32
+ const {
31
33
  start,
32
34
  end,
33
35
  title,
@@ -38,8 +40,8 @@ export const PageHeader = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Pag
38
40
  style,
39
41
  classNames,
40
42
  className
41
- } = _ref,
42
- props = _objectWithoutProperties(_ref, _excluded);
43
+ } = mergedProps,
44
+ props = _objectWithoutProperties(mergedProps, _excluded);
43
45
  const titleResponsivePaddingLeft = useMemo(() => ({
44
46
  phone: start && !end ? 0 : 3,
45
47
  tablet: start ? 0 : 4,
@@ -7,6 +7,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
7
7
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
8
8
  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; }
9
9
  import React, { useCallback, useRef } from 'react';
10
+ import { useComponentConfig } from '../hooks/useComponentConfig';
10
11
  import { HStack } from '../layout/HStack';
11
12
  import { DefaultPaginationEllipsis } from './DefaultPaginationEllipsis';
12
13
  import { DefaultPaginationNavigationButton } from './DefaultPaginationNavigationButton';
@@ -14,9 +15,10 @@ import { DefaultPaginationNavigationTextButton } from './DefaultPaginationNaviga
14
15
  import { DefaultPaginationPageButton } from './DefaultPaginationPageButton';
15
16
  import { usePagination } from './usePagination';
16
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
- export const Pagination = _ref => {
18
+ export const Pagination = _props => {
18
19
  var _accessibilityLabels$, _accessibilityLabels$2, _accessibilityLabels$3, _accessibilityLabels$4, _accessibilityLabels$5, _accessibilityLabels$6;
19
- let {
20
+ const mergedProps = useComponentConfig('Pagination', _props);
21
+ const {
20
22
  totalPages,
21
23
  activePage,
22
24
  onChange,
@@ -33,8 +35,8 @@ export const Pagination = _ref => {
33
35
  PaginationEllipsisComponent = DefaultPaginationEllipsis,
34
36
  firstPageButtonLabel = 'First',
35
37
  lastPageButtonLabel = 'Last'
36
- } = _ref,
37
- props = _objectWithoutProperties(_ref, _excluded);
38
+ } = mergedProps,
39
+ props = _objectWithoutProperties(mergedProps, _excluded);
38
40
  const {
39
41
  items,
40
42
  updateActivePage,
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { measurePerformance } from 'reassure';
3
+ import { Button } from '../../buttons/Button';
4
+ import { ComponentConfigProvider } from '../../system/ComponentConfigProvider';
5
+ import { DefaultThemeProvider } from '../../utils/test';
6
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
7
+ const buttonCount = 1000;
8
+ const ButtonList = () => {
9
+ return /*#__PURE__*/_jsx(_Fragment, {
10
+ children: Array.from({
11
+ length: buttonCount
12
+ }, (_, index) => /*#__PURE__*/_jsx(Button, {
13
+ children: "Child"
14
+ }, index))
15
+ });
16
+ };
17
+ const Wrapper = _ref => {
18
+ let {
19
+ children
20
+ } = _ref;
21
+ return /*#__PURE__*/_jsx(DefaultThemeProvider, {
22
+ children: children
23
+ });
24
+ };
25
+ describe('Button component-config performance (web)', () => {
26
+ it('no provider', async () => {
27
+ await measurePerformance(/*#__PURE__*/_jsx(Wrapper, {
28
+ children: /*#__PURE__*/_jsx(ButtonList, {})
29
+ }));
30
+ });
31
+ it('provider customization', async () => {
32
+ await measurePerformance(/*#__PURE__*/_jsx(Wrapper, {
33
+ children: /*#__PURE__*/_jsx(ComponentConfigProvider, {
34
+ value: {
35
+ Button: {
36
+ compact: true
37
+ }
38
+ },
39
+ children: /*#__PURE__*/_jsx(ButtonList, {})
40
+ })
41
+ }));
42
+ });
43
+ });
@@ -0,0 +1,134 @@
1
+ import React from 'react';
2
+ import { fireEvent, screen } from '@testing-library/react';
3
+ import { measurePerformance } from 'reassure';
4
+ import { useComponentConfig } from '../../hooks/useComponentConfig';
5
+ import { ComponentConfigProvider } from '../../system/ComponentConfigProvider';
6
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const consumerCount = 1000;
8
+ const updateIterations = 50;
9
+ const stableButtonConfig = () => ({
10
+ compact: true
11
+ });
12
+ const stableAvatarConfig = () => ({});
13
+ const ButtonConfigConsumer = _ref => {
14
+ let {
15
+ index
16
+ } = _ref;
17
+ const mergedProps = useComponentConfig('Button', {
18
+ compact: false,
19
+ variant: 'primary'
20
+ });
21
+ return /*#__PURE__*/_jsx("div", {
22
+ "data-compact": String(mergedProps.compact),
23
+ "data-index": index
24
+ });
25
+ };
26
+ const ButtonConfigConsumerList = _ref2 => {
27
+ let {
28
+ count
29
+ } = _ref2;
30
+ return /*#__PURE__*/_jsx(_Fragment, {
31
+ children: Array.from({
32
+ length: count
33
+ }, (_, index) => /*#__PURE__*/_jsx(ButtonConfigConsumer, {
34
+ index: index
35
+ }, index))
36
+ });
37
+ };
38
+ const UnrelatedKeyUpdateHarness = _ref3 => {
39
+ let {
40
+ count
41
+ } = _ref3;
42
+ const [unrelatedUpdates, setUnrelatedUpdates] = React.useState(0);
43
+ const value = React.useMemo(() => ({
44
+ Avatar: () => unrelatedUpdates % 2 === 0 ? {} : {},
45
+ Button: stableButtonConfig
46
+ }), [unrelatedUpdates]);
47
+ return /*#__PURE__*/_jsxs(_Fragment, {
48
+ children: [/*#__PURE__*/_jsx("button", {
49
+ "data-testid": "update-unrelated-key",
50
+ onClick: () => setUnrelatedUpdates(v => v + 1),
51
+ children: "Update unrelated key"
52
+ }), /*#__PURE__*/_jsx(ComponentConfigProvider, {
53
+ value: value,
54
+ children: /*#__PURE__*/_jsx(ButtonConfigConsumerList, {
55
+ count: count
56
+ })
57
+ })]
58
+ });
59
+ };
60
+ const TargetKeyUpdateHarness = _ref4 => {
61
+ let {
62
+ count
63
+ } = _ref4;
64
+ const [targetUpdates, setTargetUpdates] = React.useState(0);
65
+ const value = React.useMemo(() => ({
66
+ Avatar: stableAvatarConfig,
67
+ Button: () => ({
68
+ compact: targetUpdates % 2 === 0
69
+ })
70
+ }), [targetUpdates]);
71
+ return /*#__PURE__*/_jsxs(_Fragment, {
72
+ children: [/*#__PURE__*/_jsx("button", {
73
+ "data-testid": "update-target-key",
74
+ onClick: () => setTargetUpdates(v => v + 1),
75
+ children: "Update target key"
76
+ }), /*#__PURE__*/_jsx(ComponentConfigProvider, {
77
+ value: value,
78
+ children: /*#__PURE__*/_jsx(ButtonConfigConsumerList, {
79
+ count: count
80
+ })
81
+ })]
82
+ });
83
+ };
84
+ describe('ComponentConfigProvider performance tests', () => {
85
+ it('Scenario A: renders 1000 consumers under one provider', async () => {
86
+ await measurePerformance(/*#__PURE__*/_jsx(ComponentConfigProvider, {
87
+ value: {
88
+ Button: stableButtonConfig
89
+ },
90
+ children: /*#__PURE__*/_jsx(ButtonConfigConsumerList, {
91
+ count: consumerCount
92
+ })
93
+ }));
94
+ });
95
+ it('Scenario B: updates unrelated component key 50 times', async () => {
96
+ const scenario = async () => {
97
+ for (let i = 0; i < updateIterations; i += 1) {
98
+ fireEvent.click(screen.getByTestId('update-unrelated-key'));
99
+ }
100
+ };
101
+ await measurePerformance(/*#__PURE__*/_jsx(UnrelatedKeyUpdateHarness, {
102
+ count: consumerCount
103
+ }), {
104
+ scenario
105
+ });
106
+ });
107
+ it('Scenario C: updates target component key 50 times', async () => {
108
+ const scenario = async () => {
109
+ for (let i = 0; i < updateIterations; i += 1) {
110
+ fireEvent.click(screen.getByTestId('update-target-key'));
111
+ }
112
+ };
113
+ await measurePerformance(/*#__PURE__*/_jsx(TargetKeyUpdateHarness, {
114
+ count: consumerCount
115
+ }), {
116
+ scenario
117
+ });
118
+ });
119
+ it('Scenario D (baseline): no provider with 1000 consumers', async () => {
120
+ await measurePerformance(/*#__PURE__*/_jsx(ButtonConfigConsumerList, {
121
+ count: consumerCount
122
+ }));
123
+ });
124
+ it('Scenario D (provider): provider enabled with 1000 consumers', async () => {
125
+ await measurePerformance(/*#__PURE__*/_jsx(ComponentConfigProvider, {
126
+ value: {
127
+ Button: stableButtonConfig
128
+ },
129
+ children: /*#__PURE__*/_jsx(ButtonConfigConsumerList, {
130
+ count: consumerCount
131
+ })
132
+ }));
133
+ });
134
+ });