@coinbase/cds-web 8.43.0 → 8.44.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.
@@ -0,0 +1,68 @@
1
+ const _excluded = ["type", "value"];
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 { figma } from '@figma/code-connect';
10
+ import { Select } from '../select/Select';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const selectOptions = [{
13
+ value: 'apple',
14
+ label: 'Apple'
15
+ }, {
16
+ value: 'banana',
17
+ label: 'Banana'
18
+ }, {
19
+ value: 'orange',
20
+ label: 'Orange',
21
+ description: 'Citrus'
22
+ }];
23
+ figma.connect(Select, 'https://www.figma.com/design/k5CtyJccNQUGMI5bI4lJ2g/✨-CDS-Components?node-id=71762-14938', {
24
+ imports: ["import { Select } from '@coinbase/cds-web/alpha/select/Select'"],
25
+ props: {
26
+ type: figma.enum('type', {
27
+ 'single select': 'single',
28
+ 'multi-select': 'multi'
29
+ }),
30
+ disabled: figma.boolean('disabled'),
31
+ compact: figma.boolean('compact'),
32
+ label: figma.boolean('show label', {
33
+ true: figma.boolean('show info icon') ? "<HStack alignItems=\"center\">\n <InputLabel>".concat(figma.string('label string'), "</InputLabel>\n <Tooltip content=\"This will be visible to other users.\">\n <Icon active color=\"fg\" name=\"info\" padding={0.75} size=\"xs\" tabIndex={0} />\n </Tooltip>\n </HStack>") : figma.string('label string'),
34
+ false: undefined
35
+ }),
36
+ start: figma.boolean('show start', {
37
+ true: figma.instance('start'),
38
+ false: undefined
39
+ }),
40
+ helperText: figma.boolean('show helper text', {
41
+ true: figma.string('helper text'),
42
+ false: undefined
43
+ }),
44
+ placeholder: figma.string('placeholderText'),
45
+ variant: figma.enum('state', {
46
+ default: undefined,
47
+ positive: 'positive',
48
+ negative: 'negative'
49
+ }),
50
+ value: figma.enum('type', {
51
+ 'single select': 'Item 1',
52
+ 'multi-select': ['Item 1', 'Item 2']
53
+ })
54
+ },
55
+ example: _ref => {
56
+ let {
57
+ type,
58
+ value
59
+ } = _ref,
60
+ props = _objectWithoutProperties(_ref, _excluded);
61
+ return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({}, props), {}, {
62
+ onChange: () => {},
63
+ options: selectOptions,
64
+ type: type,
65
+ value: value
66
+ }));
67
+ }
68
+ });
@@ -1,75 +1,108 @@
1
+ const _excluded = ["start", "children", "end", "bottom", "accessibilityLabel", "background", "paddingX", "paddingTop", "paddingBottom", "position", "top", "left", "right", "width", "dangerouslyDisableOverflowHidden", "columnGap", "rowGap", "className", "classNames", "style", "styles", "testID"];
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; }
1
9
  import React, { memo, useMemo } from 'react';
2
10
  import { usePreviousValue } from '@coinbase/cds-common/hooks/usePreviousValue';
3
11
  import { zIndex } from '@coinbase/cds-common/tokens/zIndex';
4
12
  import { Collapsible } from '../collapsible/Collapsible';
13
+ import { cx } from '../cx';
5
14
  import { HStack, VStack } from '../layout';
6
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- const COMPONENT_STATIC_CLASSNAME = 'cds-NavigationBar';
16
+ export const navigationBarDefaultElement = 'nav';
17
+ /**
18
+ * Static class names for NavigationBar component parts.
19
+ * Use these selectors to target specific elements with CSS.
20
+ */
21
+ export const navigationBarClassNames = {
22
+ /** Root nav element containing the entire navigation bar */
23
+ root: 'cds-NavigationBar',
24
+ /** Container for the start slot (e.g., back button) */
25
+ start: 'cds-NavigationBar-start',
26
+ /** Container for the main children content (e.g., title) */
27
+ content: 'cds-NavigationBar-content'
28
+ };
8
29
  export const NavigationBar = /*#__PURE__*/memo(_ref => {
9
30
  let {
10
- start,
11
- children,
12
- end,
13
- bottom,
14
- accessibilityLabel = 'main navigation',
15
- paddingX = 2,
16
- paddingTop = 2,
17
- paddingBottom = bottom ? undefined : 2,
18
- dangerouslyDisableOverflowHidden,
19
- columnGap,
20
- rowGap = 1
21
- } = _ref;
31
+ start,
32
+ children,
33
+ end,
34
+ bottom,
35
+ accessibilityLabel = 'main navigation',
36
+ background = 'bg',
37
+ paddingX = 2,
38
+ paddingTop = 2,
39
+ paddingBottom = bottom ? undefined : 2,
40
+ position = 'sticky',
41
+ top = 0,
42
+ left = 0,
43
+ right = 0,
44
+ width = '100%',
45
+ dangerouslyDisableOverflowHidden,
46
+ columnGap,
47
+ rowGap = 1,
48
+ className,
49
+ classNames,
50
+ style,
51
+ styles,
52
+ testID
53
+ } = _ref,
54
+ props = _objectWithoutProperties(_ref, _excluded);
22
55
  const prevStart = usePreviousValue(start);
23
56
  const startNode = useMemo(() => start || prevStart, [start, prevStart]);
24
- return /*#__PURE__*/_jsxs(VStack, {
57
+ return /*#__PURE__*/_jsxs(VStack, _objectSpread(_objectSpread({
25
58
  borderedBottom: true,
26
59
  accessibilityLabel: accessibilityLabel,
27
60
  as: "nav",
28
- background: "bg",
29
- className: COMPONENT_STATIC_CLASSNAME,
61
+ background: background,
62
+ className: cx(navigationBarClassNames.root, className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
30
63
  gap: rowGap,
31
- left: 0,
64
+ left: left,
32
65
  paddingBottom: paddingBottom,
33
66
  paddingTop: paddingTop,
34
67
  paddingX: paddingX,
35
- position: "sticky",
36
- right: 0,
37
- top: 0,
38
- width: "100%",
39
- zIndex: zIndex.navigation,
68
+ position: position,
69
+ right: right,
70
+ style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root),
71
+ testID: testID,
72
+ top: top,
73
+ width: width,
74
+ zIndex: zIndex.navigation
75
+ }, props), {}, {
40
76
  children: [/*#__PURE__*/_jsxs(HStack, {
41
77
  alignItems: "center",
42
78
  gap: columnGap !== null && columnGap !== void 0 ? columnGap : {
43
79
  base: 2,
44
80
  phone: 1
45
81
  },
46
- justifyContent: "space-between",
47
82
  overflow: "auto",
48
- children: [/*#__PURE__*/_jsxs(HStack, {
83
+ children: [/*#__PURE__*/_jsx(Collapsible, {
84
+ collapsed: !start,
85
+ dangerouslyDisableOverflowHidden: dangerouslyDisableOverflowHidden,
86
+ direction: "horizontal",
87
+ children: /*#__PURE__*/_jsx(HStack, {
88
+ alignItems: "center",
89
+ className: cx(navigationBarClassNames.start, classNames === null || classNames === void 0 ? void 0 : classNames.start),
90
+ paddingEnd: columnGap !== null && columnGap !== void 0 ? columnGap : {
91
+ base: 2,
92
+ phone: 1
93
+ },
94
+ style: styles === null || styles === void 0 ? void 0 : styles.start,
95
+ children: startNode
96
+ })
97
+ }), /*#__PURE__*/_jsx(HStack, {
49
98
  alignItems: "center",
99
+ className: cx(navigationBarClassNames.content, classNames === null || classNames === void 0 ? void 0 : classNames.content),
50
100
  flexGrow: 1,
51
- flexShrink: 0,
52
- justifyContent: "flex-start",
53
- children: [/*#__PURE__*/_jsx(Collapsible, {
54
- collapsed: !start,
55
- dangerouslyDisableOverflowHidden: dangerouslyDisableOverflowHidden,
56
- direction: "horizontal",
57
- children: /*#__PURE__*/_jsx(HStack, {
58
- alignItems: "center",
59
- paddingEnd: columnGap !== null && columnGap !== void 0 ? columnGap : {
60
- base: 2,
61
- phone: 1
62
- },
63
- children: startNode
64
- })
65
- }), /*#__PURE__*/_jsx(HStack, {
66
- alignItems: "center",
67
- flexGrow: 1,
68
- gap: 1,
69
- children: children
70
- })]
101
+ gap: 1,
102
+ style: styles === null || styles === void 0 ? void 0 : styles.content,
103
+ children: children
71
104
  }), end]
72
105
  }), bottom]
73
- });
106
+ }));
74
107
  });
75
108
  NavigationBar.displayName = 'NavigationBar';
@@ -1,4 +1,5 @@
1
1
  import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
2
+ import { useMergeRefs } from '@coinbase/cds-common/hooks/useMergeRefs';
2
3
  import { FOCUSABLE_ELEMENTS } from '@coinbase/cds-common/tokens/overlays';
3
4
  import { debounce } from '@coinbase/cds-common/utils/debounce';
4
5
  import { getBrowserGlobals } from '../utils/browser';
@@ -203,12 +204,13 @@ export const FocusTrap = /*#__PURE__*/memo(function FocusTrap(_ref) {
203
204
 
204
205
  // only works for single child
205
206
  const onlyChild = React.Children.only(children);
207
+ const mergedRef = useMergeRefs(childrenRef, children === null || children === void 0 ? void 0 : children.ref);
206
208
  if (!onlyChild) {
207
209
  return /*#__PURE__*/_jsx(_Fragment, {
208
210
  children: children
209
211
  });
210
212
  }
211
213
  return /*#__PURE__*/React.cloneElement(children, {
212
- ref: childrenRef
214
+ ref: mergedRef
213
215
  });
214
216
  });
@@ -0,0 +1,3 @@
1
+ @layer cds{.containerBaseCss-c1oq904k{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;padding-top:var(--space-2);padding-bottom:var(--space-2);}
2
+ .containerPressableCss-cya0rqx{width:100%;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab;touch-action:none;}.containerPressableCss-cya0rqx:active{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing;}
3
+ .handleCss-h1mpswnh{width:32px;height:4px;border-radius:var(--borderRadius-1000);opacity:0.4;}}
@@ -0,0 +1,66 @@
1
+ const _excluded = ["testID", "onClose", "accessibilityLabel", "accessibilityHint", "classNames", "styles", "className", "style"];
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, { memo, useMemo } from 'react';
10
+ import { handleBarHeight } from '@coinbase/cds-common/tokens/drawer';
11
+ import { cx } from '../../cx';
12
+ import { Box } from '../../layout';
13
+ import { Pressable } from '../../system/Pressable';
14
+
15
+ // Fixed pixel values used intentionally — handle size should not scale with theme density.
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ const HANDLE_WIDTH = 32;
18
+ const HANDLE_OPACITY = 0.4;
19
+ const containerBaseCss = "containerBaseCss-c1oq904k";
20
+ const containerPressableCss = "containerPressableCss-cya0rqx";
21
+ const handleCss = "handleCss-h1mpswnh";
22
+
23
+ /**
24
+ * A draggable handle indicator for overlay components like Tray.
25
+ * @note Web only supports inside handlebar.
26
+ */
27
+
28
+ export const HandleBar = /*#__PURE__*/memo(_ref => {
29
+ var _classNames$root;
30
+ let {
31
+ testID = 'handleBar',
32
+ onClose,
33
+ accessibilityLabel,
34
+ accessibilityHint,
35
+ classNames,
36
+ styles,
37
+ className,
38
+ style
39
+ } = _ref,
40
+ props = _objectWithoutProperties(_ref, _excluded);
41
+ const rootStyle = useMemo(() => style || styles !== null && styles !== void 0 && styles.root ? _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root) : undefined, [style, styles === null || styles === void 0 ? void 0 : styles.root]);
42
+ const handleClassName = cx(handleCss, classNames === null || classNames === void 0 ? void 0 : classNames.handle);
43
+ return /*#__PURE__*/_jsx(Box, _objectSpread(_objectSpread({
44
+ className: cx(containerBaseCss, onClose && containerPressableCss, (_classNames$root = classNames === null || classNames === void 0 ? void 0 : classNames.root) !== null && _classNames$root !== void 0 ? _classNames$root : className),
45
+ "data-testid": testID,
46
+ style: rootStyle
47
+ }, props), {}, {
48
+ children: onClose ? /*#__PURE__*/_jsx(Pressable, {
49
+ noScaleOnPress: true,
50
+ accessibilityHint: accessibilityHint,
51
+ accessibilityLabel: accessibilityLabel,
52
+ background: "bgInverse",
53
+ borderColor: "transparent",
54
+ className: handleClassName,
55
+ onClick: onClose,
56
+ style: styles === null || styles === void 0 ? void 0 : styles.handle
57
+ }) : /*#__PURE__*/_jsx(Box, {
58
+ accessibilityHint: accessibilityHint,
59
+ accessibilityLabel: accessibilityLabel,
60
+ background: "bgInverse",
61
+ className: handleClassName,
62
+ style: styles === null || styles === void 0 ? void 0 : styles.handle
63
+ })
64
+ }));
65
+ });
66
+ import "./HandleBar.css";
@@ -0,0 +1 @@
1
+ export * from './HandleBar';
@@ -0,0 +1,7 @@
1
+ @layer cds{.trayHeaderBorderBaseCss-t552jyb{border-bottom-width:var(--borderWidth-100);border-bottom-style:solid;border-bottom-color:transparent;}
2
+ .trayHeaderBorderVisibleCss-tx59ve0{border-bottom-color:var(--color-bgLine);}
3
+ .trayContainerBaseCss-t1gubbn2{z-index:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;overflow:hidden;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;min-height:0;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
4
+ .trayContainerPinBottomCss-ttp17ir{border-top-left-radius:var(--borderRadius-600);border-top-right-radius:var(--borderRadius-600);}
5
+ .trayContainerPinTopCss-t1ql0a7m{border-bottom-left-radius:var(--borderRadius-600);border-bottom-right-radius:var(--borderRadius-600);}
6
+ .trayContainerPinLeftCss-tddpnpb{border-top-right-radius:var(--borderRadius-600);border-bottom-right-radius:var(--borderRadius-600);}
7
+ .trayContainerPinRightCss-t17d10kx{border-top-left-radius:var(--borderRadius-600);border-bottom-left-radius:var(--borderRadius-600);}}