@coinbase/cds-mobile 9.14.0 → 9.16.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 (50) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dts/accordion/Accordion.d.ts +11 -1
  3. package/dts/accordion/Accordion.d.ts.map +1 -1
  4. package/dts/accordion/AccordionHeader.d.ts +33 -5
  5. package/dts/accordion/AccordionHeader.d.ts.map +1 -1
  6. package/dts/accordion/AccordionItem.d.ts +25 -17
  7. package/dts/accordion/AccordionItem.d.ts.map +1 -1
  8. package/dts/accordion/AccordionPanel.d.ts +6 -2
  9. package/dts/accordion/AccordionPanel.d.ts.map +1 -1
  10. package/dts/alpha/select-chip/SelectChip.d.ts +6 -12
  11. package/dts/alpha/select-chip/SelectChip.d.ts.map +1 -1
  12. package/dts/alpha/select-chip/SelectChipControl.d.ts +49 -5
  13. package/dts/alpha/select-chip/SelectChipControl.d.ts.map +1 -1
  14. package/dts/alpha/select-chip/index.d.ts +1 -1
  15. package/dts/alpha/select-chip/index.d.ts.map +1 -1
  16. package/dts/alpha/tabbed-chips/TabbedChips.d.ts +4 -1
  17. package/dts/alpha/tabbed-chips/TabbedChips.d.ts.map +1 -1
  18. package/dts/chips/Chip.d.ts +3 -0
  19. package/dts/chips/Chip.d.ts.map +1 -1
  20. package/dts/chips/ChipProps.d.ts +35 -2
  21. package/dts/chips/ChipProps.d.ts.map +1 -1
  22. package/dts/chips/InputChip.d.ts.map +1 -1
  23. package/dts/chips/MediaChip.d.ts +3 -0
  24. package/dts/chips/MediaChip.d.ts.map +1 -1
  25. package/dts/collapsible/Collapsible.d.ts +5 -2
  26. package/dts/collapsible/Collapsible.d.ts.map +1 -1
  27. package/dts/controls/Switch.d.ts +10 -1
  28. package/dts/controls/Switch.d.ts.map +1 -1
  29. package/dts/core/componentConfig.d.ts +2 -0
  30. package/dts/core/componentConfig.d.ts.map +1 -1
  31. package/dts/tabs/SegmentedTabs.d.ts +10 -2
  32. package/dts/tabs/SegmentedTabs.d.ts.map +1 -1
  33. package/esm/accordion/Accordion.js +6 -2
  34. package/esm/accordion/AccordionHeader.js +49 -15
  35. package/esm/accordion/AccordionItem.js +40 -6
  36. package/esm/accordion/AccordionPanel.js +3 -1
  37. package/esm/alpha/select-chip/SelectChip.js +73 -21
  38. package/esm/alpha/select-chip/SelectChipControl.js +39 -10
  39. package/esm/alpha/select-chip/__stories__/AlphaSelectChip.stories.js +4 -4
  40. package/esm/alpha/select-chip/index.js +1 -1
  41. package/esm/alpha/tabbed-chips/TabbedChips.js +2 -2
  42. package/esm/chips/Chip.js +16 -7
  43. package/esm/chips/InputChip.js +24 -6
  44. package/esm/chips/__stories__/Chip.stories.js +2 -2
  45. package/esm/chips/__stories__/MediaChip.stories.js +2 -2
  46. package/esm/collapsible/Collapsible.js +4 -2
  47. package/esm/controls/Switch.js +25 -4
  48. package/esm/controls/__stories__/Switch.stories.js +26 -1
  49. package/esm/tabs/SegmentedTabs.js +24 -5
  50. package/package.json +3 -3
@@ -1,5 +1,6 @@
1
1
  const _excluded = ["ref"],
2
- _excluded2 = ["value", "children", "accessibilityLabel", "invertColorScheme", "testID"];
2
+ _excluded2 = ["active", "invertColorScheme", "inverted"],
3
+ _excluded3 = ["value", "children", "accessibilityLabel", "testID", "active", "invertColorScheme", "inverted"];
3
4
  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); }
4
5
  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
6
  import React, { memo } from 'react';
@@ -12,18 +13,33 @@ export const InputChip = /*#__PURE__*/memo(_ref => {
12
13
  ref
13
14
  } = _ref,
14
15
  _props = _objectWithoutPropertiesLoose(_ref, _excluded);
15
- const mergedProps = useComponentConfig('InputChip', _props);
16
+ const {
17
+ active: activeProp,
18
+ invertColorScheme,
19
+ inverted
20
+ } = _props,
21
+ restProps = _objectWithoutPropertiesLoose(_props, _excluded2);
22
+ // Default before component config so state-aware resolvers (active borders) see the
23
+ // same active semantics as the rendered chip.
24
+ const active = activeProp != null ? activeProp : invertColorScheme === undefined && inverted === undefined ? true : false;
25
+ const mergedProps = useComponentConfig('InputChip', _extends({}, restProps, {
26
+ active,
27
+ invertColorScheme,
28
+ inverted
29
+ }));
16
30
  const {
17
31
  value,
18
32
  children = value,
19
33
  accessibilityLabel = typeof children === 'string' ? "Remove " + children : 'Remove option',
20
- invertColorScheme = true,
21
- testID = 'input-chip'
34
+ testID = 'input-chip',
35
+ invertColorScheme: mergedInvertColorScheme,
36
+ inverted: mergedInverted
22
37
  } = mergedProps,
23
- props = _objectWithoutPropertiesLoose(mergedProps, _excluded2);
38
+ props = _objectWithoutPropertiesLoose(mergedProps, _excluded3);
24
39
  return /*#__PURE__*/_jsx(MediaChip, _extends({
25
40
  ref: ref,
26
41
  accessibilityLabel: accessibilityLabel,
42
+ active: active,
27
43
  end: /*#__PURE__*/_jsx(Icon, {
28
44
  active: true,
29
45
  color: "fg",
@@ -31,7 +47,9 @@ export const InputChip = /*#__PURE__*/memo(_ref => {
31
47
  size: "xs",
32
48
  testID: testID ? testID + "-close-icon" : 'input-chip-close-icon'
33
49
  }),
34
- invertColorScheme: invertColorScheme
50
+ invertColorScheme: mergedInvertColorScheme,
51
+ inverted: mergedInverted,
52
+ testID: testID
35
53
  }, props, {
36
54
  children: children
37
55
  }));
@@ -107,9 +107,9 @@ const ChipScreen = () => /*#__PURE__*/_jsxs(ExampleScreen, {
107
107
  title: "Default",
108
108
  children: /*#__PURE__*/_jsx(ChipExamples, {})
109
109
  }), /*#__PURE__*/_jsx(Example, {
110
- title: "Inverted",
110
+ title: "Active",
111
111
  children: /*#__PURE__*/_jsx(ChipExamples, {
112
- inverted: true
112
+ active: true
113
113
  })
114
114
  }), /*#__PURE__*/_jsx(Example, {
115
115
  title: "Size xs",
@@ -81,9 +81,9 @@ const MediaChipScreen = () => /*#__PURE__*/_jsxs(ExampleScreen, {
81
81
  title: "Default (Automatic Spacing)",
82
82
  children: /*#__PURE__*/_jsx(MediaChipExamples, {})
83
83
  }), /*#__PURE__*/_jsx(Example, {
84
- title: "Inverted",
84
+ title: "Active",
85
85
  children: /*#__PURE__*/_jsx(MediaChipExamples, {
86
- inverted: true
86
+ active: true
87
87
  })
88
88
  }), /*#__PURE__*/_jsx(Example, {
89
89
  title: "Compact",
@@ -34,7 +34,8 @@ export const Collapsible = /*#__PURE__*/memo(_ref => {
34
34
  paddingEnd,
35
35
  paddingBottom,
36
36
  paddingStart,
37
- scrollViewProps
37
+ scrollViewProps,
38
+ style
38
39
  } = mergedProps;
39
40
  const theme = useTheme();
40
41
  // TO DO: Remove this after refactoring useContentSize to default values to null on initial render
@@ -112,10 +113,11 @@ export const Collapsible = /*#__PURE__*/memo(_ref => {
112
113
  }));
113
114
  const animatedContainerStyles = useMemo(() => [styles.container, animatedStyles, animatedInMaxSize], [animatedStyles, animatedInMaxSize]);
114
115
  const containerStyles = isUnmountedExpanded ? styles.container : animatedContainerStyles;
116
+ const mergedContainerStyles = useMemo(() => style ? [containerStyles, style] : containerStyles, [containerStyles, style]);
115
117
  return /*#__PURE__*/_jsx(ReanimatedView, {
116
118
  ref: forwardedRef,
117
119
  "aria-expanded": !collapsed,
118
- style: containerStyles,
120
+ style: mergedContainerStyles,
119
121
  testID: testID,
120
122
  children: /*#__PURE__*/_jsx(ScrollView, _extends({
121
123
  nestedScrollEnabled: true // for Android
@@ -1,5 +1,5 @@
1
1
  const _excluded = ["ref"],
2
- _excluded2 = ["children", "style", "styles"];
2
+ _excluded2 = ["children", "style", "styles", "variant", "background", "checked"];
3
3
  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); }
4
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
5
  import React, { memo, useMemo } from 'react';
@@ -9,14 +9,26 @@ import { useTheme } from '../hooks/useTheme';
9
9
  import { Box } from '../layout/Box';
10
10
  import { Interactable } from '../system/Interactable';
11
11
  import { Control } from './Control';
12
+
13
+ /** Border width of the switch head/handle, kept as a hairline regardless of theme. */
12
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
+ const switchThumbBorderWidth = 0.5;
16
+
17
+ /** Semantic color variants for Switch, matching the semantics used by other control components. */
18
+
19
+ /** Track background color applied when Switch is checked, keyed by `variant`. */
20
+ const switchVariantBackground = {
21
+ primary: 'bgPrimary',
22
+ positive: 'bgPositive',
23
+ negative: 'bgNegative'
24
+ };
13
25
  const SwitchIcon = _ref => {
14
26
  let {
15
27
  pressed,
16
28
  checked,
17
29
  disabled,
18
30
  controlColor,
19
- background = checked ? 'bgPrimary' : 'bgTertiary',
31
+ background = 'bgTertiary',
20
32
  borderColor,
21
33
  borderRadius = 1000,
22
34
  borderWidth = 0,
@@ -45,7 +57,8 @@ const SwitchIcon = _ref => {
45
57
  height: switchThumbSize,
46
58
  position: 'absolute',
47
59
  top: thumbInset - borderSize,
48
- left: thumbInset - borderSize
60
+ left: thumbInset - borderSize,
61
+ borderWidth: switchThumbBorderWidth
49
62
  }, {
50
63
  transform: [{
51
64
  translateX: animatedScaleValue.interpolate({
@@ -85,7 +98,10 @@ const SwitchWithRef = function SwitchWithRef(_ref2) {
85
98
  const {
86
99
  children,
87
100
  style,
88
- styles
101
+ styles,
102
+ variant = 'primary',
103
+ background,
104
+ checked
89
105
  } = mergedProps,
90
106
  props = _objectWithoutPropertiesLoose(mergedProps, _excluded2);
91
107
  const theme = useTheme();
@@ -93,11 +109,16 @@ const SwitchWithRef = function SwitchWithRef(_ref2) {
93
109
  switchHeight
94
110
  } = theme.controlSize;
95
111
  const controlStyles = useMemo(() => StyleSheet.flatten([style, styles == null ? void 0 : styles.control]), [style, styles == null ? void 0 : styles.control]);
112
+ // The variant only informs the track color while checked; the background prop is more
113
+ // specific and always wins when provided.
114
+ const resolvedBackground = useMemo(() => background != null ? background : checked ? switchVariantBackground[variant] : undefined, [background, checked, variant]);
96
115
  const switchNode = /*#__PURE__*/_jsx(Control, _extends({
97
116
  ref: ref,
98
117
  accessible: true,
99
118
  shouldUseSwitchTransition: true,
100
119
  accessibilityRole: "switch",
120
+ background: resolvedBackground,
121
+ checked: checked,
101
122
  label: children,
102
123
  style: controlStyles
103
124
  }, props, {
@@ -1,7 +1,7 @@
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, { useState } from 'react';
3
3
  import { Example, ExampleScreen } from '../../examples/ExampleScreen';
4
- import { VStack } from '../../layout';
4
+ import { HStack, VStack } from '../../layout';
5
5
  import { ThemeProvider } from '../../system/ThemeProvider';
6
6
  import { defaultTheme } from '../../themes/defaultTheme';
7
7
  import { Switch } from '../Switch';
@@ -68,6 +68,31 @@ const SwitchScreen = () => {
68
68
  })]
69
69
  });
70
70
  }
71
+ }), /*#__PURE__*/_jsx(Example, {
72
+ inline: true,
73
+ title: "Variants",
74
+ children: /*#__PURE__*/_jsxs(HStack, {
75
+ flexWrap: "wrap",
76
+ gap: 2,
77
+ children: [/*#__PURE__*/_jsx(Switch, {
78
+ checked: true,
79
+ variant: "primary",
80
+ children: "Primary"
81
+ }), /*#__PURE__*/_jsx(Switch, {
82
+ checked: true,
83
+ variant: "positive",
84
+ children: "Positive"
85
+ }), /*#__PURE__*/_jsx(Switch, {
86
+ checked: true,
87
+ variant: "negative",
88
+ children: "Negative"
89
+ }), /*#__PURE__*/_jsx(Switch, {
90
+ checked: true,
91
+ background: "accentBoldPurple",
92
+ variant: "negative",
93
+ children: "Background override"
94
+ })]
95
+ })
71
96
  }), /*#__PURE__*/_jsx(Example, {
72
97
  inline: true,
73
98
  title: "Custom Theme",
@@ -1,16 +1,23 @@
1
1
  const _excluded = ["ref"],
2
- _excluded2 = ["TabComponent", "TabsActiveIndicatorComponent", "activeBackground", "background", "borderRadius"];
2
+ _excluded2 = ["TabComponent", "TabsActiveIndicatorComponent", "activeBackground", "background", "borderRadius", "equalWidth", "alignSelf", "styles"];
3
3
  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); }
4
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
- import React, { memo } from 'react';
5
+ import React, { memo, useMemo } from 'react';
6
6
  import { useComponentConfig } from '../hooks/useComponentConfig';
7
7
  import { SegmentedTab } from './SegmentedTab';
8
8
  import { SegmentedTabsActiveIndicator } from './SegmentedTabsActiveIndicator';
9
9
  import { Tabs } from './Tabs';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const equalWidthTabContainerStyle = {
12
+ flex: 1
13
+ };
14
+ const equalWidthTabStyle = {
15
+ alignSelf: 'stretch'
16
+ };
10
17
 
11
18
  // We do Partial/Pick to allow TabComponent and TabsActiveIndicatorComponent to be optional
12
19
  // We grab 'tabs' from the Omit allowing it to stay required
13
- import { jsx as _jsx } from "react/jsx-runtime";
20
+
14
21
  const SegmentedTabsComponent = /*#__PURE__*/memo(_ref => {
15
22
  let {
16
23
  ref
@@ -22,16 +29,28 @@ const SegmentedTabsComponent = /*#__PURE__*/memo(_ref => {
22
29
  TabsActiveIndicatorComponent = SegmentedTabsActiveIndicator,
23
30
  activeBackground = 'bgInverse',
24
31
  background = 'bgSecondary',
25
- borderRadius = 700
32
+ borderRadius = 700,
33
+ equalWidth,
34
+ alignSelf = equalWidth ? 'stretch' : undefined,
35
+ styles
26
36
  } = mergedProps,
27
37
  props = _objectWithoutPropertiesLoose(mergedProps, _excluded2);
38
+ const resolvedStyles = useMemo(() => {
39
+ if (!equalWidth) return styles;
40
+ return _extends({}, styles, {
41
+ tabContainer: [equalWidthTabContainerStyle, styles == null ? void 0 : styles.tabContainer],
42
+ tab: [equalWidthTabStyle, styles == null ? void 0 : styles.tab]
43
+ });
44
+ }, [equalWidth, styles]);
28
45
  return /*#__PURE__*/_jsx(Tabs, _extends({
29
46
  ref: ref,
30
47
  TabComponent: TabComponent,
31
48
  TabsActiveIndicatorComponent: TabsActiveIndicatorComponent,
32
49
  activeBackground: activeBackground,
50
+ alignSelf: alignSelf,
33
51
  background: background,
34
- borderRadius: borderRadius
52
+ borderRadius: borderRadius,
53
+ styles: resolvedStyles
35
54
  }, props));
36
55
  });
37
56
  SegmentedTabsComponent.displayName = 'SegmentedTabs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cds-mobile",
3
- "version": "9.14.0",
3
+ "version": "9.16.0",
4
4
  "description": "Coinbase Design System - Mobile",
5
5
  "repository": {
6
6
  "type": "git",
@@ -218,9 +218,9 @@
218
218
  "react-native-worklets": "0.5.2"
219
219
  },
220
220
  "dependencies": {
221
- "@coinbase/cds-common": "^9.14.0",
221
+ "@coinbase/cds-common": "^9.16.0",
222
222
  "@coinbase/cds-icons": "^5.21.0",
223
- "@coinbase/cds-illustrations": "^4.47.0",
223
+ "@coinbase/cds-illustrations": "^4.48.0",
224
224
  "@coinbase/cds-lottie-files": "^3.3.4",
225
225
  "@coinbase/cds-utils": "^2.3.5",
226
226
  "@floating-ui/react-native": "^0.10.5",