@coinbase/cds-web 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.
- package/CHANGELOG.md +18 -0
- package/dts/accordion/Accordion.d.ts +27 -4
- package/dts/accordion/Accordion.d.ts.map +1 -1
- package/dts/accordion/AccordionHeader.d.ts +36 -4
- package/dts/accordion/AccordionHeader.d.ts.map +1 -1
- package/dts/accordion/AccordionItem.d.ts +26 -15
- package/dts/accordion/AccordionItem.d.ts.map +1 -1
- package/dts/accordion/AccordionPanel.d.ts +7 -1
- package/dts/accordion/AccordionPanel.d.ts.map +1 -1
- package/dts/alpha/select-chip/SelectChip.d.ts +6 -12
- package/dts/alpha/select-chip/SelectChip.d.ts.map +1 -1
- package/dts/alpha/select-chip/SelectChipControl.d.ts +50 -5
- package/dts/alpha/select-chip/SelectChipControl.d.ts.map +1 -1
- package/dts/alpha/select-chip/index.d.ts +1 -1
- package/dts/alpha/select-chip/index.d.ts.map +1 -1
- package/dts/alpha/tabbed-chips/TabbedChips.d.ts +4 -1
- package/dts/alpha/tabbed-chips/TabbedChips.d.ts.map +1 -1
- package/dts/chips/Chip.d.ts.map +1 -1
- package/dts/chips/ChipProps.d.ts +36 -2
- package/dts/chips/ChipProps.d.ts.map +1 -1
- package/dts/chips/InputChip.d.ts.map +1 -1
- package/dts/collapsible/Collapsible.d.ts +7 -1
- package/dts/collapsible/Collapsible.d.ts.map +1 -1
- package/dts/controls/Switch.d.ts +14 -0
- package/dts/controls/Switch.d.ts.map +1 -1
- package/dts/core/componentConfig.d.ts +2 -0
- package/dts/core/componentConfig.d.ts.map +1 -1
- package/dts/tabs/SegmentedTabs.d.ts +11 -1
- package/dts/tabs/SegmentedTabs.d.ts.map +1 -1
- package/dts/visualizations/chart/PeriodSelector.d.ts +3 -2
- package/dts/visualizations/chart/PeriodSelector.d.ts.map +1 -1
- package/esm/accordion/Accordion.js +28 -6
- package/esm/accordion/AccordionHeader.js +51 -14
- package/esm/accordion/AccordionItem.js +64 -6
- package/esm/accordion/AccordionPanel.js +5 -1
- package/esm/alpha/select-chip/SelectChip.js +58 -29
- package/esm/alpha/select-chip/SelectChipControl.js +41 -11
- package/esm/alpha/select-chip/index.js +1 -1
- package/esm/alpha/tabbed-chips/TabbedChips.js +3 -2
- package/esm/chips/Chip.js +15 -7
- package/esm/chips/InputChip.js +25 -6
- package/esm/collapsible/Collapsible.js +7 -3
- package/esm/controls/Switch.js +14 -2
- package/esm/tabs/SegmentedTabs.css +2 -0
- package/esm/tabs/SegmentedTabs.js +21 -6
- package/package.json +3 -3
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import React, { forwardRef, memo, useMemo } from 'react';
|
|
2
|
+
import { getSelectChipHasValue } from '@coinbase/cds-common/chips/getSelectChipActive';
|
|
2
3
|
import { MediaChip } from '../../chips/MediaChip';
|
|
3
4
|
import { AnimatedCaret } from '../../motion/AnimatedCaret';
|
|
4
5
|
import { isSelectOptionGroup } from '../select/types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Chip props accepted by {@link SelectChipControl} and forwarded to {@link MediaChip}.
|
|
9
|
+
* Includes selection state, layout, borders, and `displayValue` for the control label.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* SelectControlProps fields superseded by {@link SelectChipControlChipProps}.
|
|
14
|
+
* Omit is required: intersection would merge overlapping keys (e.g. `size` as SelectSize &
|
|
15
|
+
* ChipSize, `background` as responsive Box vs chip tokens) instead of replacing select-scale
|
|
16
|
+
* definitions.
|
|
17
|
+
*/
|
|
5
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
19
|
const SelectChipControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
7
20
|
let {
|
|
@@ -20,16 +33,26 @@ const SelectChipControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_r
|
|
|
20
33
|
maxSelectedOptionsToShow = 2,
|
|
21
34
|
hiddenSelectedOptionsLabel = 'more',
|
|
22
35
|
label,
|
|
36
|
+
disabled,
|
|
23
37
|
compact,
|
|
24
38
|
size,
|
|
39
|
+
active,
|
|
40
|
+
activeBackground,
|
|
41
|
+
activeColor,
|
|
42
|
+
background,
|
|
43
|
+
color,
|
|
25
44
|
invertColorScheme,
|
|
45
|
+
inverted,
|
|
26
46
|
numberOfLines,
|
|
27
|
-
disabled,
|
|
28
47
|
maxWidth,
|
|
29
|
-
displayValue
|
|
48
|
+
displayValue,
|
|
49
|
+
borderWidth,
|
|
50
|
+
borderColor,
|
|
51
|
+
bordered,
|
|
52
|
+
borderRadius
|
|
30
53
|
} = _ref;
|
|
31
54
|
const isMultiSelect = type === 'multi';
|
|
32
|
-
const hasValue =
|
|
55
|
+
const hasValue = getSelectChipHasValue(value);
|
|
33
56
|
|
|
34
57
|
// Map of options to their values
|
|
35
58
|
// If multiple options share the same value, the first occurrence wins (matches native HTML select behavior)
|
|
@@ -84,32 +107,36 @@ const SelectChipControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_r
|
|
|
84
107
|
const opt = optionsMap.get(value);
|
|
85
108
|
return (_ref6 = (_ref7 = (_ref8 = (_opt$label2 = opt === null || opt === void 0 ? void 0 : opt.label) !== null && _opt$label2 !== void 0 ? _opt$label2 : opt === null || opt === void 0 ? void 0 : opt.description) !== null && _ref8 !== void 0 ? _ref8 : opt === null || opt === void 0 ? void 0 : opt.value) !== null && _ref7 !== void 0 ? _ref7 : placeholder) !== null && _ref6 !== void 0 ? _ref6 : null;
|
|
86
109
|
}, [hasValue, label, placeholder, displayValue, isMultiSelect, optionsMap, value, maxSelectedOptionsToShow, hiddenSelectedOptionsLabel]);
|
|
110
|
+
const resolvedColor = active && activeColor !== undefined ? activeColor : color;
|
|
87
111
|
const endNode = useMemo(() => {
|
|
112
|
+
// Match Chip's label color. `fg` still inverts with the chip when active uses theme inversion.
|
|
88
113
|
return customEndNode !== null && customEndNode !== void 0 ? customEndNode : /*#__PURE__*/_jsx(AnimatedCaret, {
|
|
89
114
|
active: true,
|
|
90
|
-
color:
|
|
115
|
+
color: resolvedColor !== null && resolvedColor !== void 0 ? resolvedColor : 'fg',
|
|
91
116
|
rotate: open ? 0 : 180,
|
|
92
117
|
size: "xs"
|
|
93
118
|
});
|
|
94
|
-
}, [customEndNode,
|
|
95
|
-
const color = useMemo(() => {
|
|
96
|
-
return hasValue ? 'fgInverse' : 'fg';
|
|
97
|
-
}, [hasValue]);
|
|
98
|
-
const background = useMemo(() => {
|
|
99
|
-
return hasValue ? 'bgInverse' : 'bgSecondary';
|
|
100
|
-
}, [hasValue]);
|
|
119
|
+
}, [customEndNode, open, resolvedColor]);
|
|
101
120
|
return /*#__PURE__*/_jsx(MediaChip, {
|
|
102
121
|
ref: ref,
|
|
103
122
|
noScaleOnPress: true,
|
|
104
123
|
accessibilityLabel: accessibilityLabel,
|
|
124
|
+
active: active,
|
|
125
|
+
activeBackground: activeBackground,
|
|
126
|
+
activeColor: activeColor,
|
|
105
127
|
"aria-haspopup": ariaHaspopup,
|
|
106
128
|
background: background,
|
|
129
|
+
bordered: bordered,
|
|
130
|
+
borderColor: borderColor,
|
|
131
|
+
borderRadius: borderRadius,
|
|
132
|
+
borderWidth: borderWidth,
|
|
107
133
|
className: className,
|
|
108
134
|
color: color,
|
|
109
135
|
compact: compact,
|
|
110
136
|
disabled: disabled,
|
|
111
137
|
end: endNode,
|
|
112
138
|
invertColorScheme: invertColorScheme,
|
|
139
|
+
inverted: inverted,
|
|
113
140
|
maxWidth: maxWidth,
|
|
114
141
|
numberOfLines: numberOfLines,
|
|
115
142
|
onClick: () => setOpen(s => !s),
|
|
@@ -119,4 +146,7 @@ const SelectChipControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_r
|
|
|
119
146
|
children: labelContent
|
|
120
147
|
});
|
|
121
148
|
}));
|
|
149
|
+
SelectChipControlComponent.displayName = 'SelectChipControl';
|
|
150
|
+
|
|
151
|
+
/** Generic memo components need an explicit cast for the public polymorphic signature. */
|
|
122
152
|
export const SelectChipControl = SelectChipControlComponent;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './SelectChip';
|
|
2
|
-
export
|
|
2
|
+
export { SelectChipControl } from './SelectChipControl';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["label", "id", "activeBackground", "activeColor", "color"],
|
|
1
|
+
const _excluded = ["label", "id", "Component", "activeBackground", "activeColor", "color"],
|
|
2
2
|
_excluded2 = ["tabs", "activeTab", "onChange", "TabComponent", "testID", "background", "gap", "previousArrowAccessibilityLabel", "nextArrowAccessibilityLabel", "width", "TabsActiveIndicatorComponent", "disabled", "compact", "size", "styles", "classNames", "autoScrollOffset"];
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
@@ -23,6 +23,7 @@ const DefaultTabComponent = _ref => {
|
|
|
23
23
|
let {
|
|
24
24
|
label = '',
|
|
25
25
|
id,
|
|
26
|
+
Component: _Component,
|
|
26
27
|
activeBackground,
|
|
27
28
|
activeColor,
|
|
28
29
|
color
|
|
@@ -47,10 +48,10 @@ const DefaultTabComponent = _ref => {
|
|
|
47
48
|
}, [isActive]);
|
|
48
49
|
return /*#__PURE__*/_jsx(MediaChip, _objectSpread(_objectSpread({
|
|
49
50
|
ref: chipRef,
|
|
51
|
+
active: isActive && !activeBackground,
|
|
50
52
|
"aria-selected": isActive,
|
|
51
53
|
background: isActive && activeBackground ? activeBackground : undefined,
|
|
52
54
|
color: isActive && activeColor ? activeColor : color,
|
|
53
|
-
invertColorScheme: isActive && !activeBackground,
|
|
54
55
|
onClick: handleClick,
|
|
55
56
|
role: "tab",
|
|
56
57
|
width: "max-content"
|
package/esm/chips/Chip.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["as", "alignItems", "width", "height", "compact", "size", "gap", "start", "end", "paddingX", "paddingY", "padding", "paddingTop", "paddingBottom", "paddingStart", "paddingEnd", "justifyContent", "children", "maxWidth", "invertColorScheme", "inverted", "numberOfLines", "testID", "contentStyle", "borderRadius", "background", "style", "className", "styles", "classNames", "font", "color", "onClick"];
|
|
1
|
+
const _excluded = ["as", "alignItems", "width", "height", "compact", "size", "gap", "start", "end", "paddingX", "paddingY", "padding", "paddingTop", "paddingBottom", "paddingStart", "paddingEnd", "justifyContent", "children", "maxWidth", "active", "activeBackground", "activeColor", "invertColorScheme", "inverted", "numberOfLines", "testID", "contentStyle", "borderRadius", "background", "style", "className", "styles", "classNames", "font", "color", "onClick"];
|
|
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; }
|
|
@@ -64,6 +64,9 @@ export const Chip = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Chip(_pro
|
|
|
64
64
|
justifyContent,
|
|
65
65
|
children,
|
|
66
66
|
maxWidth = chipMaxWidth,
|
|
67
|
+
active = false,
|
|
68
|
+
activeBackground,
|
|
69
|
+
activeColor,
|
|
67
70
|
invertColorScheme,
|
|
68
71
|
inverted,
|
|
69
72
|
numberOfLines = 1,
|
|
@@ -80,9 +83,14 @@ export const Chip = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Chip(_pro
|
|
|
80
83
|
onClick
|
|
81
84
|
} = mergedProps,
|
|
82
85
|
props = _objectWithoutProperties(mergedProps, _excluded);
|
|
83
|
-
const
|
|
86
|
+
const hasActiveColorOverrides = activeBackground !== undefined || activeColor !== undefined;
|
|
87
|
+
const activeUsesThemeInversion = active && !hasActiveColorOverrides;
|
|
88
|
+
const shouldInvert = Boolean(invertColorScheme !== null && invertColorScheme !== void 0 ? invertColorScheme : inverted) || activeUsesThemeInversion;
|
|
89
|
+
const WrapperComponent = shouldInvert ? InvertedThemeProvider : Fragment;
|
|
90
|
+
const resolvedBackground = active && activeBackground !== undefined ? activeBackground : background;
|
|
91
|
+
const resolvedColor = active && activeColor !== undefined ? activeColor : color;
|
|
84
92
|
const containerProps = {
|
|
85
|
-
background,
|
|
93
|
+
background: resolvedBackground,
|
|
86
94
|
borderRadius,
|
|
87
95
|
className: cx(transitionCss, className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
|
|
88
96
|
style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root),
|
|
@@ -107,19 +115,19 @@ export const Chip = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Chip(_pro
|
|
|
107
115
|
paddingY: paddingY,
|
|
108
116
|
style: _objectSpread(_objectSpread({}, contentStyle), styles === null || styles === void 0 ? void 0 : styles.content),
|
|
109
117
|
children: [start, typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
110
|
-
color:
|
|
118
|
+
color: resolvedColor,
|
|
111
119
|
flexShrink: 1,
|
|
112
120
|
font: font,
|
|
113
121
|
numberOfLines: numberOfLines,
|
|
114
122
|
children: children
|
|
115
123
|
}) : children ? /*#__PURE__*/_jsx(Box, {
|
|
116
|
-
color:
|
|
124
|
+
color: resolvedColor,
|
|
117
125
|
flexShrink: 1,
|
|
118
126
|
children: children
|
|
119
127
|
}) : null, end]
|
|
120
128
|
});
|
|
121
|
-
}, [alignItems, classNames === null || classNames === void 0 ? void 0 : classNames.content, gap, justifyContent, maxWidth, padding, paddingBottom, paddingEnd, paddingStart, paddingTop, paddingX, paddingY, contentStyle, styles === null || styles === void 0 ? void 0 : styles.content, start, children,
|
|
122
|
-
return /*#__PURE__*/_jsx(WrapperComponent, _objectSpread(_objectSpread({}, inverted ? {
|
|
129
|
+
}, [alignItems, classNames === null || classNames === void 0 ? void 0 : classNames.content, gap, justifyContent, maxWidth, padding, paddingBottom, paddingEnd, paddingStart, paddingTop, paddingX, paddingY, contentStyle, styles === null || styles === void 0 ? void 0 : styles.content, start, children, resolvedColor, font, numberOfLines, end]);
|
|
130
|
+
return /*#__PURE__*/_jsx(WrapperComponent, _objectSpread(_objectSpread({}, shouldInvert && inverted ? {
|
|
123
131
|
display: 'content'
|
|
124
132
|
} : {}), {}, {
|
|
125
133
|
children: onClick ? /*#__PURE__*/_jsx(Pressable, _objectSpread(_objectSpread(_objectSpread({
|
package/esm/chips/InputChip.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const _excluded = ["
|
|
1
|
+
const _excluded = ["active", "invertColorScheme", "inverted"],
|
|
2
|
+
_excluded2 = ["value", "children", "accessibilityLabel", "testID", "active", "invertColorScheme", "inverted"];
|
|
2
3
|
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
4
|
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
5
|
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; }
|
|
@@ -12,18 +13,34 @@ import { Icon } from '../icons/Icon';
|
|
|
12
13
|
import { MediaChip } from './MediaChip';
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
export const InputChip = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
|
|
15
|
-
const
|
|
16
|
+
const {
|
|
17
|
+
active: activeProp,
|
|
18
|
+
invertColorScheme,
|
|
19
|
+
inverted
|
|
20
|
+
} = _props,
|
|
21
|
+
restProps = _objectWithoutProperties(_props, _excluded);
|
|
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 !== void 0 ? activeProp : invertColorScheme === undefined && inverted === undefined ? true : false;
|
|
25
|
+
const mergedProps = useComponentConfig('InputChip', _objectSpread(_objectSpread({}, 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 ".concat(children) : 'Remove option',
|
|
20
|
-
|
|
21
|
-
|
|
34
|
+
testID = 'input-chip',
|
|
35
|
+
active: _active,
|
|
36
|
+
invertColorScheme: mergedInvertColorScheme,
|
|
37
|
+
inverted: mergedInverted
|
|
22
38
|
} = mergedProps,
|
|
23
|
-
props = _objectWithoutProperties(mergedProps,
|
|
39
|
+
props = _objectWithoutProperties(mergedProps, _excluded2);
|
|
24
40
|
return /*#__PURE__*/_jsx(MediaChip, _objectSpread(_objectSpread({
|
|
25
41
|
ref: ref,
|
|
26
42
|
accessibilityLabel: accessibilityLabel,
|
|
43
|
+
active: active,
|
|
27
44
|
end: /*#__PURE__*/_jsx(Icon, {
|
|
28
45
|
active: true,
|
|
29
46
|
color: "fg",
|
|
@@ -31,7 +48,9 @@ export const InputChip = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref)
|
|
|
31
48
|
size: "xs",
|
|
32
49
|
testID: testID ? "".concat(testID, "-close-icon") : 'input-chip-close-icon'
|
|
33
50
|
}),
|
|
34
|
-
invertColorScheme:
|
|
51
|
+
invertColorScheme: mergedInvertColorScheme,
|
|
52
|
+
inverted: mergedInverted,
|
|
53
|
+
testID: testID
|
|
35
54
|
}, props), {}, {
|
|
36
55
|
children: children
|
|
37
56
|
}));
|
|
@@ -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, useCallback, useMemo, useState } from 'react';
|
|
10
10
|
import { m as motion } from 'framer-motion';
|
|
11
|
+
import { cx } from '../cx';
|
|
11
12
|
import { useComponentConfig } from '../hooks/useComponentConfig';
|
|
12
13
|
import { Box } from '../layout/Box';
|
|
13
14
|
import { useCollapsibleMotionProps } from './useCollapsibleMotionProps';
|
|
@@ -26,6 +27,8 @@ export const Collapsible = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, fo
|
|
|
26
27
|
id,
|
|
27
28
|
role = 'region',
|
|
28
29
|
dangerouslyDisableOverflowHidden = false,
|
|
30
|
+
className,
|
|
31
|
+
style: styleProp,
|
|
29
32
|
// Spacing
|
|
30
33
|
padding,
|
|
31
34
|
paddingBottom,
|
|
@@ -67,17 +70,18 @@ export const Collapsible = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, fo
|
|
|
67
70
|
}
|
|
68
71
|
}, [collapsed]);
|
|
69
72
|
const style = useMemo(() => {
|
|
70
|
-
|
|
73
|
+
const nextStyle = isDisplayNone ? _objectSpread(_objectSpread({}, motionStyle), {}, {
|
|
71
74
|
display: 'none'
|
|
72
75
|
}) : motionStyle;
|
|
73
|
-
|
|
76
|
+
return styleProp ? _objectSpread(_objectSpread({}, nextStyle), styleProp) : nextStyle;
|
|
77
|
+
}, [motionStyle, isDisplayNone, styleProp]);
|
|
74
78
|
return (
|
|
75
79
|
/*#__PURE__*/
|
|
76
80
|
// TODO: Remove type assertion after upgrading framer-motion to v11+ for React 19 compatibility
|
|
77
81
|
_jsx(motion.div, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, motionProps), {}, {
|
|
78
82
|
ref: forwardedRef,
|
|
79
83
|
'aria-labelledby': accessibilityLabelledBy,
|
|
80
|
-
className: COMPONENT_STATIC_CLASSNAME,
|
|
84
|
+
className: cx(COMPONENT_STATIC_CLASSNAME, className),
|
|
81
85
|
'data-testid': testID,
|
|
82
86
|
id: id,
|
|
83
87
|
onAnimationComplete: handleAnimationComplete,
|
package/esm/controls/Switch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["children", "checked", "disabled", "elevation", "controlColor", "background", "borderColor", "borderRadius", "borderWidth", "value", "className", "style", "classNames", "styles"];
|
|
1
|
+
const _excluded = ["children", "checked", "disabled", "elevation", "controlColor", "variant", "background", "borderColor", "borderRadius", "borderWidth", "value", "className", "style", "classNames", "styles"];
|
|
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; }
|
|
@@ -33,6 +33,15 @@ export const switchClassNames = {
|
|
|
33
33
|
};
|
|
34
34
|
const trackCss = "trackCss-t1fng8qd";
|
|
35
35
|
const thumbCss = "thumbCss-t1l9xlcf";
|
|
36
|
+
|
|
37
|
+
/** Semantic color variants for Switch, matching the semantics used by other control components. */
|
|
38
|
+
|
|
39
|
+
/** Track background color applied when Switch is checked, keyed by `variant`. */
|
|
40
|
+
const switchVariantBackground = {
|
|
41
|
+
primary: 'bgPrimary',
|
|
42
|
+
positive: 'bgPositive',
|
|
43
|
+
negative: 'bgNegative'
|
|
44
|
+
};
|
|
36
45
|
const MotionBox = motion(Box);
|
|
37
46
|
const thumbMotionVariants = {
|
|
38
47
|
checked: {
|
|
@@ -52,7 +61,10 @@ const SwitchWithRef = /*#__PURE__*/forwardRef(function SwitchWithRef(_props, ref
|
|
|
52
61
|
disabled,
|
|
53
62
|
elevation,
|
|
54
63
|
controlColor,
|
|
55
|
-
|
|
64
|
+
variant = 'primary',
|
|
65
|
+
// The variant only informs the track color while checked; the background prop is more
|
|
66
|
+
// specific and always wins when provided.
|
|
67
|
+
background = checked ? switchVariantBackground[variant] : 'bgTertiary',
|
|
56
68
|
borderColor,
|
|
57
69
|
borderRadius = 1000,
|
|
58
70
|
borderWidth,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["TabComponent", "TabsActiveIndicatorComponent", "activeBackground", "background", "borderRadius", "className", "classNames", "style", "styles"];
|
|
1
|
+
const _excluded = ["TabComponent", "TabsActiveIndicatorComponent", "activeBackground", "background", "borderRadius", "equalWidth", "alignSelf", "width", "className", "classNames", "style", "styles"];
|
|
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; }
|
|
@@ -6,13 +6,15 @@ 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 } from 'react';
|
|
9
|
+
import React, { forwardRef, memo, useMemo } from 'react';
|
|
10
10
|
import { cx } from '../cx';
|
|
11
11
|
import { useComponentConfig } from '../hooks/useComponentConfig';
|
|
12
12
|
import { SegmentedTab } from './SegmentedTab';
|
|
13
13
|
import { SegmentedTabsActiveIndicator } from './SegmentedTabsActiveIndicator';
|
|
14
14
|
import { Tabs } from './Tabs';
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
const equalWidthTabContainerCss = "equalWidthTabContainerCss-eg1j8x0";
|
|
17
|
+
const equalWidthTabCss = "equalWidthTabCss-e1aaasyn";
|
|
16
18
|
const SegmentedTabsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
|
|
17
19
|
const mergedProps = useComponentConfig('SegmentedTabs', _props);
|
|
18
20
|
const {
|
|
@@ -21,23 +23,34 @@ const SegmentedTabsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props
|
|
|
21
23
|
activeBackground = 'bgInverse',
|
|
22
24
|
background = 'bgSecondary',
|
|
23
25
|
borderRadius = 700,
|
|
26
|
+
equalWidth,
|
|
27
|
+
alignSelf = equalWidth ? 'stretch' : undefined,
|
|
28
|
+
width = equalWidth ? '100%' : undefined,
|
|
24
29
|
className,
|
|
25
30
|
classNames,
|
|
26
31
|
style,
|
|
27
32
|
styles
|
|
28
33
|
} = mergedProps,
|
|
29
34
|
props = _objectWithoutProperties(mergedProps, _excluded);
|
|
35
|
+
const resolvedClassNames = useMemo(() => {
|
|
36
|
+
if (!equalWidth) return classNames;
|
|
37
|
+
return _objectSpread(_objectSpread({}, classNames), {}, {
|
|
38
|
+
tabContainer: cx(equalWidthTabContainerCss, classNames === null || classNames === void 0 ? void 0 : classNames.tabContainer),
|
|
39
|
+
tab: cx(equalWidthTabCss, classNames === null || classNames === void 0 ? void 0 : classNames.tab)
|
|
40
|
+
});
|
|
41
|
+
}, [equalWidth, classNames]);
|
|
30
42
|
return /*#__PURE__*/_jsx(Tabs, _objectSpread({
|
|
31
43
|
ref: ref,
|
|
32
44
|
TabComponent: TabComponent,
|
|
33
45
|
TabsActiveIndicatorComponent: TabsActiveIndicatorComponent,
|
|
34
46
|
activeBackground: activeBackground,
|
|
47
|
+
alignSelf: alignSelf,
|
|
35
48
|
background: background,
|
|
36
49
|
borderRadius: borderRadius,
|
|
37
50
|
className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
|
|
38
51
|
classNames: {
|
|
39
|
-
tabContainer:
|
|
40
|
-
tab:
|
|
52
|
+
tabContainer: resolvedClassNames === null || resolvedClassNames === void 0 ? void 0 : resolvedClassNames.tabContainer,
|
|
53
|
+
tab: resolvedClassNames === null || resolvedClassNames === void 0 ? void 0 : resolvedClassNames.tab,
|
|
41
54
|
activeIndicator: classNames === null || classNames === void 0 ? void 0 : classNames.activeIndicator
|
|
42
55
|
},
|
|
43
56
|
role: "tablist",
|
|
@@ -46,8 +59,10 @@ const SegmentedTabsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props
|
|
|
46
59
|
tabContainer: styles === null || styles === void 0 ? void 0 : styles.tabContainer,
|
|
47
60
|
tab: styles === null || styles === void 0 ? void 0 : styles.tab,
|
|
48
61
|
activeIndicator: styles === null || styles === void 0 ? void 0 : styles.activeIndicator
|
|
49
|
-
}
|
|
62
|
+
},
|
|
63
|
+
width: width
|
|
50
64
|
}, props));
|
|
51
65
|
}));
|
|
52
66
|
SegmentedTabsComponent.displayName = 'SegmentedTabs';
|
|
53
|
-
export const SegmentedTabs = SegmentedTabsComponent;
|
|
67
|
+
export const SegmentedTabs = SegmentedTabsComponent;
|
|
68
|
+
import "./SegmentedTabs.css";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-web",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.16.0",
|
|
4
4
|
"description": "Coinbase Design System - Web",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -227,9 +227,9 @@
|
|
|
227
227
|
"react-dom": "^18.0.0 || ~19.1.2"
|
|
228
228
|
},
|
|
229
229
|
"dependencies": {
|
|
230
|
-
"@coinbase/cds-common": "^9.
|
|
230
|
+
"@coinbase/cds-common": "^9.16.0",
|
|
231
231
|
"@coinbase/cds-icons": "^5.21.0",
|
|
232
|
-
"@coinbase/cds-illustrations": "^4.
|
|
232
|
+
"@coinbase/cds-illustrations": "^4.48.0",
|
|
233
233
|
"@coinbase/cds-lottie-files": "^3.3.4",
|
|
234
234
|
"@coinbase/cds-utils": "^2.3.5",
|
|
235
235
|
"@floating-ui/react-dom": "^2.1.1",
|