@coinbase/cds-web 8.62.1 → 8.66.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dts/alpha/combobox/DefaultComboboxControl.d.ts.map +1 -1
  3. package/dts/alpha/select/DefaultSelectControl.d.ts.map +1 -1
  4. package/dts/alpha/select/DefaultSelectDropdown.d.ts.map +1 -1
  5. package/dts/alpha/select/Select.d.ts.map +1 -1
  6. package/dts/core/componentConfig.d.ts +2 -2
  7. package/dts/core/componentConfig.d.ts.map +1 -1
  8. package/dts/dropdown/Dropdown.d.ts +4 -0
  9. package/dts/dropdown/Dropdown.d.ts.map +1 -1
  10. package/dts/dropdown/DropdownContent.d.ts +12 -5
  11. package/dts/dropdown/DropdownContent.d.ts.map +1 -1
  12. package/dts/dropdown/DropdownProps.d.ts +20 -0
  13. package/dts/dropdown/DropdownProps.d.ts.map +1 -1
  14. package/dts/dropdown/useResponsiveHeight.d.ts +4 -0
  15. package/dts/dropdown/useResponsiveHeight.d.ts.map +1 -1
  16. package/dts/overlays/Toast.d.ts.map +1 -1
  17. package/dts/overlays/index.d.ts +1 -0
  18. package/dts/overlays/index.d.ts.map +1 -1
  19. package/dts/overlays/modal/ModalHeader.d.ts +3 -3
  20. package/dts/overlays/modal/ModalHeader.d.ts.map +1 -1
  21. package/dts/overlays/modal/ModalWrapper.d.ts.map +1 -1
  22. package/dts/overlays/popover/Popover.d.ts +48 -31
  23. package/dts/overlays/popover/Popover.d.ts.map +1 -1
  24. package/dts/overlays/popover/PopoverPanel.d.ts +164 -0
  25. package/dts/overlays/popover/PopoverPanel.d.ts.map +1 -0
  26. package/dts/overlays/popover/PopoverPanelContent.d.ts +43 -0
  27. package/dts/overlays/popover/PopoverPanelContent.d.ts.map +1 -0
  28. package/dts/overlays/popover/PopoverProps.d.ts +13 -4
  29. package/dts/overlays/popover/PopoverProps.d.ts.map +1 -1
  30. package/dts/overlays/tooltip/TooltipContent.d.ts.map +1 -1
  31. package/dts/stepper/Stepper.d.ts.map +1 -1
  32. package/dts/tabs/DefaultTab.d.ts +42 -0
  33. package/dts/tabs/DefaultTab.d.ts.map +1 -0
  34. package/dts/tabs/DefaultTabsActiveIndicator.d.ts +16 -0
  35. package/dts/tabs/DefaultTabsActiveIndicator.d.ts.map +1 -0
  36. package/dts/tabs/TabIndicator.d.ts +2 -0
  37. package/dts/tabs/TabIndicator.d.ts.map +1 -1
  38. package/dts/tabs/TabLabel.d.ts +2 -0
  39. package/dts/tabs/TabLabel.d.ts.map +1 -1
  40. package/dts/tabs/TabNavigation.d.ts +16 -0
  41. package/dts/tabs/TabNavigation.d.ts.map +1 -1
  42. package/dts/tabs/Tabs.d.ts +25 -11
  43. package/dts/tabs/Tabs.d.ts.map +1 -1
  44. package/dts/tabs/index.d.ts +2 -0
  45. package/dts/tabs/index.d.ts.map +1 -1
  46. package/dts/tour/DefaultTourMask.d.ts +1 -2
  47. package/dts/tour/DefaultTourMask.d.ts.map +1 -1
  48. package/dts/tour/DefaultTourStepArrow.d.ts +1 -1
  49. package/dts/tour/DefaultTourStepArrow.d.ts.map +1 -1
  50. package/dts/tour/Tour.d.ts +35 -7
  51. package/dts/tour/Tour.d.ts.map +1 -1
  52. package/dts/tour/TourStep.d.ts +4 -1
  53. package/dts/tour/TourStep.d.ts.map +1 -1
  54. package/esm/alpha/combobox/DefaultComboboxControl.js +1 -2
  55. package/esm/alpha/select/DefaultSelectControl.js +4 -2
  56. package/esm/alpha/select/DefaultSelectDropdown.js +1 -0
  57. package/esm/alpha/select/Select.js +30 -1
  58. package/esm/dropdown/Dropdown.js +5 -0
  59. package/esm/dropdown/DropdownContent.js +12 -1
  60. package/esm/dropdown/useResponsiveHeight.js +5 -0
  61. package/esm/icons/__figma__/Icon.figma.js +1771 -869
  62. package/esm/overlays/Toast.js +20 -12
  63. package/esm/overlays/index.js +1 -0
  64. package/esm/overlays/modal/ModalHeader.js +6 -4
  65. package/esm/overlays/modal/ModalWrapper.js +7 -1
  66. package/esm/overlays/popover/Popover.js +71 -28
  67. package/esm/overlays/popover/PopoverPanel.css +2 -0
  68. package/esm/overlays/popover/PopoverPanel.js +220 -0
  69. package/esm/overlays/popover/PopoverPanelContent.js +57 -0
  70. package/esm/overlays/tooltip/TooltipContent.js +3 -5
  71. package/esm/stepper/Stepper.js +4 -3
  72. package/esm/tabs/DefaultTab.css +3 -0
  73. package/esm/tabs/DefaultTab.js +77 -0
  74. package/esm/tabs/DefaultTabsActiveIndicator.js +58 -0
  75. package/esm/tabs/TabIndicator.js +2 -0
  76. package/esm/tabs/TabLabel.js +3 -0
  77. package/esm/tabs/TabNavigation.js +21 -0
  78. package/esm/tabs/Tabs.js +32 -34
  79. package/esm/tabs/index.js +2 -0
  80. package/esm/tour/DefaultTourMask.js +1 -1
  81. package/esm/tour/DefaultTourStepArrow.js +3 -1
  82. package/esm/tour/Tour.js +38 -7
  83. package/esm/tour/TourStep.js +16 -6
  84. package/package.json +4 -4
@@ -6,10 +6,10 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
6
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
- import React, { forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle } from 'react';
9
+ import React, { forwardRef, memo, useCallback, useContext, useImperativeHandle, useRef, useState } from 'react';
10
10
  import { animateInBottomConfig, animateInOpacityConfig, animateOutBottomConfig, animateOutOpacityConfig } from '@coinbase/cds-common/animation/toast';
11
11
  import { ToastContext } from '@coinbase/cds-common/overlays/ToastProvider';
12
- import { m as motion, useAnimation } from 'framer-motion';
12
+ import { m as motion } from 'framer-motion';
13
13
  import { Button } from '../buttons/Button';
14
14
  import { IconButton } from '../buttons/IconButton';
15
15
  import { useComponentConfig } from '../hooks/useComponentConfig';
@@ -48,24 +48,31 @@ export const Toast = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) =>
48
48
  pauseTimer,
49
49
  resumeTimer
50
50
  } = useContext(ToastContext);
51
- const animationControls = useAnimation();
51
+ const [motionState, setMotionState] = useState('enter');
52
+ const exitResolverRef = useRef(null);
52
53
  const motionProps = useMotionProps({
53
54
  enterConfigs: [animateInOpacityConfig, animateInBottomConfig],
54
55
  exitConfigs: [animateOutOpacityConfig, animateOutBottomConfig],
55
- animate: animationControls,
56
+ animate: motionState,
56
57
  style: {
57
58
  bottom: bottomOffset
58
59
  }
59
60
  });
60
- useEffect(() => {
61
- void animationControls.start('enter');
62
- }, [animationControls]);
63
- const handleClose = useCallback(async () => {
61
+ const handleAnimationComplete = useCallback(definition => {
62
+ if (definition === 'exit') {
63
+ var _exitResolverRef$curr;
64
+ onDidHide === null || onDidHide === void 0 || onDidHide();
65
+ (_exitResolverRef$curr = exitResolverRef.current) === null || _exitResolverRef$curr === void 0 || _exitResolverRef$curr.call(exitResolverRef, true);
66
+ exitResolverRef.current = null;
67
+ }
68
+ }, [onDidHide]);
69
+ const handleClose = useCallback(() => {
64
70
  onWillHide === null || onWillHide === void 0 || onWillHide();
65
- await animationControls.start('exit');
66
- onDidHide === null || onDidHide === void 0 || onDidHide();
67
- return true;
68
- }, [onWillHide, onDidHide, animationControls]);
71
+ return new Promise(resolve => {
72
+ exitResolverRef.current = resolve;
73
+ setMotionState('exit');
74
+ });
75
+ }, [onWillHide]);
69
76
  useImperativeHandle(ref, () => ({
70
77
  hide: handleClose
71
78
  }), [handleClose]);
@@ -79,6 +86,7 @@ export const Toast = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) =>
79
86
  children: /*#__PURE__*/_jsx(motion.div, _objectSpread(_objectSpread({}, motionProps), {}, {
80
87
  className: baseCss,
81
88
  "data-testid": "".concat(testID, "-motion"),
89
+ onAnimationComplete: handleAnimationComplete,
82
90
  children: /*#__PURE__*/_jsx(Box, _objectSpread(_objectSpread({
83
91
  justifyContent: "center",
84
92
  onMouseEnter: pauseTimer // persist toast when hovering
@@ -10,6 +10,7 @@ export * from './modal/ModalFooter';
10
10
  export * from './modal/ModalHeader';
11
11
  export * from './overlay/Overlay';
12
12
  export * from './popover/Popover';
13
+ export * from './popover/PopoverPanel';
13
14
  export * from './popover/PopoverProps';
14
15
  export * from './popover/usePopper';
15
16
  export * from './PortalProvider';
@@ -1,4 +1,4 @@
1
- const _excluded = ["alignItems", "paddingX", "paddingY", "title", "onBackButtonClick", "backAccessibilityLabel", "backAccessibilityHint", "closeAccessibilityLabel", "closeAccessibilityHint"];
1
+ const _excluded = ["alignItems", "paddingX", "paddingY", "font", "title", "onBackButtonClick", "backAccessibilityLabel", "backAccessibilityHint", "closeAccessibilityLabel", "closeAccessibilityHint"];
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -21,6 +21,7 @@ export const ModalHeader = _props => {
21
21
  alignItems = 'center',
22
22
  paddingX = 3,
23
23
  paddingY = 2,
24
+ font = 'headline',
24
25
  title,
25
26
  onBackButtonClick,
26
27
  backAccessibilityLabel,
@@ -45,6 +46,7 @@ export const ModalHeader = _props => {
45
46
  return /*#__PURE__*/_jsxs(HStack, _objectSpread(_objectSpread({
46
47
  alignItems: alignItems,
47
48
  borderedBottom: !hideDividers,
49
+ font: font,
48
50
  paddingX: paddingX,
49
51
  paddingY: paddingY
50
52
  }, props), {}, {
@@ -62,14 +64,14 @@ export const ModalHeader = _props => {
62
64
  flexGrow: 1,
63
65
  justifyContent: "center",
64
66
  paddingX: 2,
65
- children: title && /*#__PURE__*/_jsx(Text, {
67
+ children: title && (typeof title === 'string' ? /*#__PURE__*/_jsx(Text, {
66
68
  as: "h2",
67
69
  display: "block",
68
- font: "headline",
70
+ font: "inherit",
69
71
  id: accessibilityLabelledBy,
70
72
  textAlign: "center",
71
73
  children: title
72
- })
74
+ }) : title)
73
75
  }), !hideCloseButton && /*#__PURE__*/_jsx(Box, {
74
76
  justifyContent: "flex-end",
75
77
  children: /*#__PURE__*/_jsx(IconButton, {
@@ -11,6 +11,7 @@ import { NewAnimatePresence } from '../../animation/NewAnimatePresence';
11
11
  import { cx } from '../../cx';
12
12
  import { useComponentConfig } from '../../hooks/useComponentConfig';
13
13
  import { useScrollBlocker } from '../../hooks/useScrollBlocker';
14
+ import { VStack } from '../../layout';
14
15
  import { Box } from '../../layout/Box';
15
16
  import { media } from '../../styles/media';
16
17
  import { Overlay } from '../overlay/Overlay';
@@ -65,11 +66,16 @@ export const ModalWrapper = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, r
65
66
  width: width
66
67
  }, props), {}, {
67
68
  children: /*#__PURE__*/_jsxs(_Fragment, {
68
- children: [!hideOverlay && /*#__PURE__*/_jsx(Overlay, {
69
+ children: [!hideOverlay ? /*#__PURE__*/_jsx(Overlay, {
69
70
  animated: true,
70
71
  className: cx(!dangerouslyDisableResponsiveness && modalOverlayResponsiveCss),
71
72
  onClick: !disableOverlayPress ? onOverlayPress : undefined,
72
73
  testID: "modal-overlay"
74
+ }) : /*#__PURE__*/_jsx(VStack, {
75
+ background: "transparent",
76
+ onClick: !disableOverlayPress ? onOverlayPress : undefined,
77
+ pin: "all",
78
+ position: "fixed"
73
79
  }), children]
74
80
  })
75
81
  }))
@@ -4,17 +4,19 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
4
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
5
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
6
  /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
7
- import React, { memo, useCallback, useMemo } from 'react';
7
+ import React, { forwardRef, memo, useCallback, useMemo } from 'react';
8
+ import { useMergeRefs } from '@coinbase/cds-common/hooks/useMergeRefs';
8
9
  import { zIndex } from '@coinbase/cds-common/tokens/zIndex';
10
+ import { autoPlacement, autoUpdate, flip, limitShift, offset, shift, useFloating } from '@floating-ui/react-dom';
9
11
  import { NewAnimatePresence } from '../../animation/NewAnimatePresence';
10
12
  import { cx } from '../../cx';
13
+ import { useTheme } from '../../hooks/useTheme';
11
14
  import { Box } from '../../layout/Box';
12
15
  import { InvertedThemeProvider } from '../../system/ThemeProvider';
13
16
  import { FocusTrap } from '../FocusTrap';
14
17
  import { Overlay } from '../overlay/Overlay';
15
18
  import { Portal } from '../Portal';
16
19
  import { tooltipContainerId } from '../PortalProvider';
17
- import { usePopper } from './usePopper';
18
20
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
21
  const subjectCss = "subjectCss-s1cgr9z4";
20
22
  const defaultContentPosition = {
@@ -27,10 +29,15 @@ const defaultContentPosition = {
27
29
  const blockCss = "blockCss-b13rnbro";
28
30
 
29
31
  /**
30
- * Popover is the internal recommended base component used for any overlay that is laid out with respect to a subject.
31
- * It is purposely a flexible component and is reserved for CDS internal usage.
32
+ * Low-level primitive that positions an arbitrary `content` node relative to a subject (trigger) element.
33
+ * It handles placement, portal rendering, and open/close wiring, but intentionally renders `content` as-is —
34
+ * it does not provide a styled surface, animation, or focus management.
35
+ *
36
+ * For a fully composed overlay with an animated elevated panel and focus trap, use {@link PopoverPanel} instead.
37
+ *
38
+ * @internal Reserved for CDS internal use only.
32
39
  */
33
- export const Popover = /*#__PURE__*/memo(_ref => {
40
+ export const Popover = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
34
41
  let {
35
42
  content,
36
43
  children,
@@ -57,14 +64,51 @@ export const Popover = /*#__PURE__*/memo(_ref => {
57
64
  respectNegativeTabIndex,
58
65
  autoFocusDelay,
59
66
  restoreFocusOnUnmount,
60
- controlledElementAccessibilityProps
67
+ controlledElementAccessibilityProps,
68
+ style,
69
+ className
61
70
  } = _ref;
71
+ const theme = useTheme();
62
72
  const {
63
- setSubject,
64
- setPopper,
65
- popperStyles,
66
- popperAttributes
67
- } = usePopper(contentPosition);
73
+ placement: rawPlacement = 'bottom',
74
+ skid = 0,
75
+ gap = 0,
76
+ offsetGap,
77
+ strategy
78
+ } = contentPosition;
79
+ const computedSkid = theme.space[skid];
80
+ const computedGap = theme.space[gap];
81
+ const getOffsetGap = offsetGap && gap - offsetGap;
82
+ const isAutoPlacement = typeof rawPlacement === 'string' && rawPlacement.startsWith('auto');
83
+ const middleware = useMemo(() => {
84
+ const middlewareList = [offset({
85
+ crossAxis: computedSkid,
86
+ mainAxis: getOffsetGap !== null && getOffsetGap !== void 0 ? getOffsetGap : computedGap
87
+ })];
88
+ if (isAutoPlacement) {
89
+ const alignment = rawPlacement === 'auto-start' ? 'start' : rawPlacement === 'auto-end' ? 'end' : undefined;
90
+ middlewareList.push(autoPlacement(alignment ? {
91
+ alignment
92
+ } : undefined));
93
+ } else {
94
+ middlewareList.push(flip());
95
+ middlewareList.push(shift({
96
+ crossAxis: true,
97
+ limiter: limitShift()
98
+ }));
99
+ }
100
+ return middlewareList;
101
+ }, [computedSkid, getOffsetGap, computedGap, isAutoPlacement, rawPlacement]);
102
+ const {
103
+ refs,
104
+ floatingStyles
105
+ } = useFloating({
106
+ placement: isAutoPlacement ? undefined : rawPlacement,
107
+ strategy,
108
+ middleware,
109
+ whileElementsMounted: autoUpdate
110
+ });
111
+ const mergedRef = useMergeRefs(ref, refs.setReference);
68
112
 
69
113
  // We use this to infer that hover events are triggering the mounting/dismounting of the content
70
114
  const hasHoverInteractions = !!onMouseEnter && !!onMouseLeave && !onPressSubject;
@@ -78,13 +122,13 @@ export const Popover = /*#__PURE__*/memo(_ref => {
78
122
  const handleCaptureEvents = useCallback(event => {
79
123
  event.stopPropagation();
80
124
  }, []);
81
- const memoizedContent = useMemo(() => /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
82
- ref: setPopper,
83
- style: _objectSpread(_objectSpread({}, popperStyles.popper), {}, {
84
- zIndex: zIndex.dropdown
85
- })
86
- }, popperAttributes.popper), {}, {
125
+ const memoizedContent = useMemo(() => /*#__PURE__*/_jsx("div", {
126
+ ref: refs.setFloating,
87
127
  onClick: handleCaptureEvents,
128
+ onMouseDown: handleCaptureEvents,
129
+ style: _objectSpread(_objectSpread({}, floatingStyles), {}, {
130
+ zIndex: zIndex.dropdown
131
+ }),
88
132
  children: /*#__PURE__*/_jsx(FocusTrap, {
89
133
  autoFocusDelay: autoFocusDelay,
90
134
  disableAutoFocus: disableAutoFocus,
@@ -101,7 +145,7 @@ export const Popover = /*#__PURE__*/memo(_ref => {
101
145
  children: content
102
146
  }))
103
147
  })
104
- })), [setPopper, popperStyles.popper, popperAttributes.popper, handleCaptureEvents, autoFocusDelay, disableAutoFocus, disableFocusTrap, disableTypeFocus, focusTabIndexElements, handleClose, respectNegativeTabIndex, restoreFocusOnUnmount, testID, controlledElementAccessibilityProps, content]);
148
+ }), [refs.setFloating, floatingStyles, handleCaptureEvents, autoFocusDelay, disableAutoFocus, disableFocusTrap, disableTypeFocus, focusTabIndexElements, handleClose, respectNegativeTabIndex, restoreFocusOnUnmount, testID, controlledElementAccessibilityProps, content]);
105
149
  const renderContent = hasHoverInteractions ? memoizedContent : /*#__PURE__*/_jsx(Box, {
106
150
  "aria-label": accessibilityLabel,
107
151
  "aria-modal": "true",
@@ -114,18 +158,16 @@ export const Popover = /*#__PURE__*/memo(_ref => {
114
158
  });
115
159
  const Wrapper = invertColorScheme ? InvertedThemeProvider : React.Fragment;
116
160
  return /*#__PURE__*/_jsxs("div", {
117
- className: block ? blockCss : undefined,
161
+ ref: mergedRef,
162
+ className: cx(subjectCss, block && blockCss, className),
118
163
  onBlur: onBlur,
164
+ onClick: disabled ? undefined : onPressSubject,
165
+ onFocus: disabled ? undefined : onFocus,
166
+ onMouseDown: disabled ? undefined : onMouseDown,
119
167
  onMouseEnter: disabled ? undefined : onMouseEnter,
120
168
  onMouseLeave: disabled ? undefined : onMouseLeave,
121
- children: [/*#__PURE__*/_jsx("div", {
122
- ref: setSubject,
123
- className: cx(subjectCss, block && blockCss),
124
- onClick: disabled ? undefined : onPressSubject,
125
- onFocus: disabled ? undefined : onFocus,
126
- onMouseDown: disabled ? undefined : onMouseDown,
127
- children: children
128
- }), /*#__PURE__*/_jsx(NewAnimatePresence, {
169
+ style: style,
170
+ children: [children, /*#__PURE__*/_jsx(NewAnimatePresence, {
129
171
  children: shouldShowContent ? /*#__PURE__*/_jsx(Portal, {
130
172
  containerId: tooltipContainerId,
131
173
  disablePortal: disablePortal,
@@ -143,5 +185,6 @@ export const Popover = /*#__PURE__*/memo(_ref => {
143
185
  }) : undefined
144
186
  })]
145
187
  });
146
- });
188
+ }));
189
+ Popover.displayName = 'Popover';
147
190
  import "./Popover.css";
@@ -0,0 +1,2 @@
1
+ @layer cds{.triggerContainerCss-tkun82{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;}
2
+ .blockCss-bqzogy1{width:100%;}}
@@ -0,0 +1,220 @@
1
+ const _excluded = ["content", "showOverlay", "children", "visible", "onClose", "onOpen", "panelWidth", "minPanelWidth", "maxPanelWidth", "maxPanelHeight", "panelHeight", "testID", "disablePortal", "onBlur", "contentPosition", "block", "disabled", "restoreFocusOnUnmount", "style", "styles", "className", "classNames"],
2
+ _excluded2 = ["children", "content", "maxPanelHeight", "enableMobileModal", "onOpen", "onClose", "restoreFocusOnUnmount"];
3
+ 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; }
4
+ 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; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ import React, { forwardRef, memo, useCallback, useImperativeHandle, useMemo, useState } from 'react';
11
+ import useMeasure from 'react-use-measure';
12
+ import { cx } from '../../cx';
13
+ import { useBreakpoints } from '../../hooks/useBreakpoints';
14
+ import { useComponentConfig } from '../../hooks/useComponentConfig';
15
+ import { FocusTrap } from '../FocusTrap';
16
+ import { ModalWrapper } from '../modal/ModalWrapper';
17
+ import { Popover } from './Popover';
18
+ import { PopoverPanelContent } from './PopoverPanelContent';
19
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
+ const POPOVER_PANEL_MAX_HEIGHT = 300;
21
+ export const popoverPanelClassNames = {
22
+ /** Elevated panel surface (`PopoverPanelContent`). */
23
+ content: 'cds-PopoverPanel-content',
24
+ /** Wrapper around `children` (the `Popover` root in floating layout, or the trigger `div` in the mobile modal). */
25
+ triggerContainer: 'cds-PopoverPanel-triggerContainer'
26
+ };
27
+ const NOOP = () => {};
28
+ const defaultPopoverContentPositionConfig = {
29
+ gap: 0.5,
30
+ placement: 'bottom-start'
31
+ };
32
+ function usePopoverPanelImperativeHandle(ref, onOpen, onClose) {
33
+ useImperativeHandle(ref, () => ({
34
+ openPopover: onOpen,
35
+ closePopover: onClose
36
+ }), [onOpen, onClose]);
37
+ }
38
+ const triggerContainerCss = "triggerContainerCss-tkun82";
39
+ const blockCss = "blockCss-bqzogy1";
40
+ const MobilePopoverPanel = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
41
+ let {
42
+ children,
43
+ onOpen = NOOP,
44
+ onClose = NOOP,
45
+ block,
46
+ content,
47
+ disablePortal,
48
+ visible,
49
+ panelWidth,
50
+ showOverlay,
51
+ minPanelWidth,
52
+ maxPanelWidth,
53
+ maxPanelHeight,
54
+ disabled,
55
+ controlledElementAccessibilityProps,
56
+ respectNegativeTabIndex,
57
+ restoreFocusOnUnmount,
58
+ style,
59
+ styles,
60
+ className,
61
+ classNames,
62
+ onBlur,
63
+ testID,
64
+ disableAutoFocus,
65
+ focusTabIndexElements,
66
+ autoFocusDelay
67
+ } = _ref;
68
+ usePopoverPanelImperativeHandle(ref, onOpen, onClose);
69
+ const handleCaptureEvents = useCallback(event => {
70
+ event.stopPropagation();
71
+ }, []);
72
+ return (
73
+ /*#__PURE__*/
74
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events
75
+ _jsxs("div", {
76
+ className: cx(block ? blockCss : triggerContainerCss, popoverPanelClassNames.triggerContainer, className, classNames === null || classNames === void 0 ? void 0 : classNames.triggerContainer),
77
+ onBlur: onBlur,
78
+ onClick: disabled ? undefined : onOpen,
79
+ style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.triggerContainer),
80
+ children: [children, /*#__PURE__*/_jsx(ModalWrapper, _objectSpread(_objectSpread({
81
+ dangerouslyDisableResponsiveness: true,
82
+ disablePortal: disablePortal,
83
+ hideOverlay: !showOverlay,
84
+ onClick: handleCaptureEvents,
85
+ onOverlayPress: onClose,
86
+ testID: testID,
87
+ visible: visible
88
+ }, controlledElementAccessibilityProps), {}, {
89
+ children: /*#__PURE__*/_jsx(FocusTrap, {
90
+ autoFocusDelay: autoFocusDelay,
91
+ disableAutoFocus: disableAutoFocus,
92
+ focusTabIndexElements: focusTabIndexElements,
93
+ onEscPress: onClose,
94
+ respectNegativeTabIndex: respectNegativeTabIndex,
95
+ restoreFocusOnUnmount: restoreFocusOnUnmount,
96
+ children: /*#__PURE__*/_jsx(PopoverPanelContent, {
97
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.content,
98
+ maxHeight: maxPanelHeight,
99
+ maxWidth: maxPanelWidth,
100
+ minWidth: minPanelWidth,
101
+ style: styles === null || styles === void 0 ? void 0 : styles.content,
102
+ width: panelWidth,
103
+ children: content
104
+ })
105
+ })
106
+ }))]
107
+ })
108
+ );
109
+ }));
110
+ const FloatingPopoverPanel = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) => {
111
+ let {
112
+ content,
113
+ showOverlay,
114
+ children,
115
+ visible,
116
+ onClose = NOOP,
117
+ onOpen = NOOP,
118
+ panelWidth: width,
119
+ minPanelWidth: minWidth,
120
+ maxPanelWidth: maxWidth,
121
+ maxPanelHeight: maxHeight = POPOVER_PANEL_MAX_HEIGHT,
122
+ panelHeight: height,
123
+ testID,
124
+ disablePortal,
125
+ onBlur,
126
+ contentPosition = defaultPopoverContentPositionConfig,
127
+ block,
128
+ disabled,
129
+ restoreFocusOnUnmount,
130
+ style,
131
+ styles,
132
+ className,
133
+ classNames
134
+ } = _ref2,
135
+ props = _objectWithoutProperties(_ref2, _excluded);
136
+ const [triggerRef, triggerBounds] = useMeasure();
137
+ const combinedContentPosition = useMemo(() => _objectSpread(_objectSpread({}, defaultPopoverContentPositionConfig), contentPosition), [contentPosition]);
138
+ const memoizedContent = useMemo(() => /*#__PURE__*/_jsx(PopoverPanelContent, {
139
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.content,
140
+ height: height,
141
+ maxHeight: maxHeight,
142
+ maxWidth: maxWidth,
143
+ minWidth: minWidth,
144
+ placement: combinedContentPosition.placement,
145
+ style: styles === null || styles === void 0 ? void 0 : styles.content,
146
+ width: width !== null && width !== void 0 ? width : triggerBounds.width,
147
+ children: content
148
+ }), [classNames === null || classNames === void 0 ? void 0 : classNames.content, height, maxHeight, maxWidth, minWidth, combinedContentPosition.placement, styles === null || styles === void 0 ? void 0 : styles.content, width, triggerBounds.width, content]);
149
+ usePopoverPanelImperativeHandle(ref, onOpen, onClose);
150
+ return /*#__PURE__*/_jsx(Popover, _objectSpread(_objectSpread({
151
+ ref: triggerRef,
152
+ block: block,
153
+ className: cx(!block && triggerContainerCss, popoverPanelClassNames.triggerContainer, className, classNames === null || classNames === void 0 ? void 0 : classNames.triggerContainer),
154
+ content: disabled ? undefined : memoizedContent,
155
+ contentPosition: combinedContentPosition,
156
+ disablePortal: disablePortal,
157
+ disabled: disabled,
158
+ onBlur: onBlur,
159
+ onClose: onClose,
160
+ onPressSubject: !visible ? onOpen : undefined,
161
+ restoreFocusOnUnmount: restoreFocusOnUnmount,
162
+ showOverlay: showOverlay,
163
+ style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.triggerContainer),
164
+ testID: testID,
165
+ visible: disabled ? false : visible
166
+ }, props), {}, {
167
+ children: children
168
+ }));
169
+ }));
170
+
171
+ /**
172
+ * Anchored floating panel built on {@link Popover} and {@link PopoverPanelContent} without select context. Use for custom panel content.
173
+ * Imperative `openPopover` / `closePopover` are implemented in the floating and modal subcomponents (Dropdown continues to use `openMenu` / `closeMenu` on its ref).
174
+ */
175
+ export const PopoverPanel = /*#__PURE__*/forwardRef((_props, ref) => {
176
+ const mergedProps = useComponentConfig('PopoverPanel', _props);
177
+ const {
178
+ children,
179
+ content,
180
+ maxPanelHeight = POPOVER_PANEL_MAX_HEIGHT,
181
+ enableMobileModal,
182
+ onOpen,
183
+ onClose,
184
+ restoreFocusOnUnmount = true
185
+ } = mergedProps,
186
+ props = _objectWithoutProperties(mergedProps, _excluded2);
187
+ const {
188
+ isPhone
189
+ } = useBreakpoints();
190
+ const [visible, setVisible] = useState(false);
191
+ const handleOpenPopover = useCallback(() => {
192
+ setVisible(true);
193
+ onOpen === null || onOpen === void 0 || onOpen();
194
+ }, [onOpen]);
195
+ const handleClosePopover = useCallback(() => {
196
+ setVisible(false);
197
+ onClose === null || onClose === void 0 || onClose();
198
+ }, [onClose]);
199
+ const resolvedContent = useMemo(() => typeof content === 'function' ? content({
200
+ closePopover: handleClosePopover
201
+ }) : content, [content, handleClosePopover]);
202
+ const sharedProps = _objectSpread({
203
+ maxPanelHeight,
204
+ onClose: handleClosePopover,
205
+ onOpen: handleOpenPopover,
206
+ restoreFocusOnUnmount,
207
+ visible,
208
+ content: resolvedContent
209
+ }, props);
210
+ return isPhone && enableMobileModal ? /*#__PURE__*/_jsx(MobilePopoverPanel, _objectSpread(_objectSpread({
211
+ ref: ref
212
+ }, sharedProps), {}, {
213
+ children: children
214
+ })) : /*#__PURE__*/_jsx(FloatingPopoverPanel, _objectSpread(_objectSpread({
215
+ ref: ref
216
+ }, sharedProps), {}, {
217
+ children: children
218
+ }));
219
+ });
220
+ import "./PopoverPanel.css";
@@ -0,0 +1,57 @@
1
+ const _excluded = ["children", "placement", "minWidth", "borderRadius", "background", "overflow", "style", "className"];
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
+ 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
+ import React, { forwardRef, memo } from 'react';
10
+ import { animateDropdownOpacityInConfig, animateDropdownOpacityOutConfig, animateDropdownTransformInConfig, animateDropdownTransformOutConfig } from '@coinbase/cds-common/animation/dropdown';
11
+ import { zIndex } from '@coinbase/cds-common/tokens/zIndex';
12
+ import { m as motion } from 'framer-motion';
13
+ import { cx } from '../../cx';
14
+ import { VStack } from '../../layout/VStack';
15
+ import { useMotionProps } from '../../motion/useMotionProps';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ const popoverPanelContentClassName = 'cds-popover-panel-content';
18
+ const MotionVStack = motion(VStack);
19
+ export const PopoverPanelContent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
20
+ let {
21
+ children,
22
+ placement,
23
+ minWidth = 'min-content',
24
+ borderRadius = 400,
25
+ background = 'bg',
26
+ overflow = 'auto',
27
+ style,
28
+ className
29
+ } = _ref,
30
+ props = _objectWithoutProperties(_ref, _excluded);
31
+ const isHorizontal = (placement === null || placement === void 0 ? void 0 : placement.includes('left')) || (placement === null || placement === void 0 ? void 0 : placement.includes('right'));
32
+ const translate = isHorizontal ? 'x' : 'y';
33
+ const motionProps = useMotionProps({
34
+ enterConfigs: [animateDropdownOpacityInConfig, _objectSpread(_objectSpread({}, animateDropdownTransformInConfig), {}, {
35
+ property: translate
36
+ })],
37
+ exitConfigs: [animateDropdownOpacityOutConfig, _objectSpread(_objectSpread({}, animateDropdownTransformOutConfig), {}, {
38
+ property: translate
39
+ })],
40
+ exit: 'exit'
41
+ });
42
+ return /*#__PURE__*/_jsx(MotionVStack, _objectSpread(_objectSpread(_objectSpread({
43
+ ref: ref,
44
+ bordered: true,
45
+ background: background,
46
+ borderRadius: borderRadius,
47
+ className: cx(popoverPanelContentClassName, className),
48
+ elevation: 2,
49
+ minWidth: minWidth,
50
+ overflow: overflow,
51
+ role: "dialog",
52
+ style: style,
53
+ zIndex: zIndex.dropdown
54
+ }, props), motionProps), {}, {
55
+ children: children
56
+ }));
57
+ }));
@@ -8,15 +8,13 @@ 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';
12
11
  import { Box } from '../../layout/Box';
13
12
  import { useMotionProps } from '../../motion/useMotionProps';
14
13
  import { Text } from '../../typography/Text';
15
14
  import { jsx as _jsx } from "react/jsx-runtime";
16
15
  const textCss = "textCss-t15dzixe";
17
- export const TooltipContent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
18
- const mergedProps = useComponentConfig('TooltipContent', _props);
19
- const {
16
+ export const TooltipContent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
17
+ let {
20
18
  content,
21
19
  elevation,
22
20
  gap,
@@ -29,7 +27,7 @@ export const TooltipContent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props,
29
27
  maxWidth = tooltipMaxWidth,
30
28
  paddingX = tooltipPaddingX,
31
29
  paddingY = tooltipPaddingY
32
- } = mergedProps;
30
+ } = _ref;
33
31
  const outerStyle = useMemo(() => ({
34
32
  padding: "var(--space-".concat(gap, ")"),
35
33
  zIndex: zIndex !== null && zIndex !== void 0 ? zIndex : zIndexTokens.tooltip
@@ -123,9 +123,10 @@ const StepperBase = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
123
123
  const previousComplete = (_usePreviousValue = usePreviousValue(complete)) !== null && _usePreviousValue !== void 0 ? _usePreviousValue : false;
124
124
  const previousActiveStepIndex = (_usePreviousValue2 = usePreviousValue(activeStepIndex)) !== null && _usePreviousValue2 !== void 0 ? _usePreviousValue2 : -1;
125
125
  const [progressSprings, progressSpringsApi] = useSprings(steps.length, index => ({
126
- progress: complete ? 1 : 0,
127
- config: progressSpringConfig,
128
- immediate: !animate || disableAnimateOnMount && !hasMounted
126
+ from: {
127
+ progress: complete ? 1 : 0
128
+ },
129
+ config: progressSpringConfig
129
130
  }));
130
131
  useEffect(() => {
131
132
  // update the previous values for next render
@@ -0,0 +1,3 @@
1
+ @layer cds{.pressableCss-p1gyavxu{margin:0;padding:0;white-space:nowrap;}
2
+ .insetFocusRingCss-i14sq9yf{position:relative;}.insetFocusRingCss-i14sq9yf:focus{outline:none;}.insetFocusRingCss-i14sq9yf:focus-visible{outline-style:solid;outline-width:2px;outline-color:var(--color-bgPrimary);outline-offset:-3px;border-radius:4px;}
3
+ .labelPaddingCss-lu2xm1d{padding-top:var(--space-2);padding-bottom:calc(var(--space-2) - 2px);}}