@coinbase/cds-mobile 9.15.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 +6 -0
- 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 +49 -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 +3 -0
- package/dts/chips/Chip.d.ts.map +1 -1
- package/dts/chips/ChipProps.d.ts +35 -2
- package/dts/chips/ChipProps.d.ts.map +1 -1
- package/dts/chips/InputChip.d.ts.map +1 -1
- package/dts/chips/MediaChip.d.ts +3 -0
- package/dts/chips/MediaChip.d.ts.map +1 -1
- package/esm/alpha/select-chip/SelectChip.js +73 -21
- package/esm/alpha/select-chip/SelectChipControl.js +39 -10
- package/esm/alpha/select-chip/__stories__/AlphaSelectChip.stories.js +4 -4
- package/esm/alpha/select-chip/index.js +1 -1
- package/esm/alpha/tabbed-chips/TabbedChips.js +2 -2
- package/esm/chips/Chip.js +16 -7
- package/esm/chips/InputChip.js +24 -6
- package/esm/chips/__stories__/Chip.stories.js +2 -2
- package/esm/chips/__stories__/MediaChip.stories.js +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
|
|
9
9
|
<!-- template-start -->
|
|
10
10
|
|
|
11
|
+
## 9.16.0 (8/13/2026 PST)
|
|
12
|
+
|
|
13
|
+
#### 🚀 Updates
|
|
14
|
+
|
|
15
|
+
- Deprecate invertColorScheme in favor of new, canoncical active prop for the Chip family of props. [[#843](https://github.com/coinbase/cds/pull/843)]
|
|
16
|
+
|
|
11
17
|
## 9.15.0 (8/11/2026 PST)
|
|
12
18
|
|
|
13
19
|
#### 🚀 Updates
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ChipBaseProps } from '../../chips/ChipProps';
|
|
3
2
|
import { type SelectRef } from '../select/Select';
|
|
4
3
|
import type { SelectProps, SelectType } from '../select/types';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
'invertColorScheme' | 'numberOfLines' | 'maxWidth' | 'size' | 'compact'
|
|
8
|
-
> & {
|
|
9
|
-
/**
|
|
10
|
-
* Override the displayed value in the chip control.
|
|
11
|
-
* Useful for avoiding truncation, especially in multi-select scenarios where multiple option labels might be too long to display.
|
|
12
|
-
* When provided, this value takes precedence over the default label generation.
|
|
13
|
-
*/
|
|
14
|
-
displayValue?: React.ReactNode;
|
|
15
|
-
};
|
|
4
|
+
import { type SelectChipControlChipProps, type SelectChipControlProps } from './SelectChipControl';
|
|
5
|
+
export type SelectChipBaseProps = Pick<SelectChipControlProps, keyof SelectChipControlChipProps>;
|
|
16
6
|
export type SelectChipProps<
|
|
17
7
|
Type extends SelectType = 'single',
|
|
18
8
|
SelectOptionValue extends string = string,
|
|
@@ -26,6 +16,10 @@ export type SelectChipProps<
|
|
|
26
16
|
| 'maxWidth'
|
|
27
17
|
| 'size'
|
|
28
18
|
| 'compact'
|
|
19
|
+
| 'bordered'
|
|
20
|
+
| 'borderWidth'
|
|
21
|
+
| 'borderColor'
|
|
22
|
+
| 'borderRadius'
|
|
29
23
|
>;
|
|
30
24
|
export declare const SelectChip: <
|
|
31
25
|
Type extends SelectType = 'single',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectChip.d.ts","sourceRoot":"","sources":["../../../src/alpha/select-chip/SelectChip.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectChip.d.ts","sourceRoot":"","sources":["../../../src/alpha/select-chip/SelectChip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAI7C,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAsB,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC5B,MAAM,qBAAqB,CAAC;AAI7B,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,EAAE,MAAM,0BAA0B,CAAC,CAAC;AAEjG,MAAM,MAAM,eAAe,CACzB,IAAI,SAAS,UAAU,GAAG,QAAQ,EAClC,iBAAiB,SAAS,MAAM,GAAG,MAAM,IACvC,mBAAmB,GACrB,IAAI,CACF,WAAW,CAAC,IAAI,EAAE,iBAAiB,CAAC,EAClC,wBAAwB,GACxB,YAAY,GACZ,cAAc,GACd,SAAS,GACT,UAAU,GACV,MAAM,GACN,SAAS,GACT,UAAU,GACV,aAAa,GACb,aAAa,GACb,cAAc,CACjB,CAAC;AAuHJ,eAAO,MAAM,UAAU,EAA0B,CAC/C,IAAI,SAAS,UAAU,GAAG,QAAQ,EAClC,iBAAiB,SAAS,MAAM,GAAG,MAAM,EAEzC,KAAK,EAAE,eAAe,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;CAAE,KAC7E,KAAK,CAAC,YAAY,CAAC"}
|
|
@@ -1,14 +1,58 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { View } from 'react-native';
|
|
3
|
+
import type { ChipBaseProps } from '../../chips/ChipProps';
|
|
3
4
|
import { type SelectControlProps, type SelectType } from '../select/types';
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Chip props accepted by {@link SelectChipControl} and forwarded to {@link MediaChip}.
|
|
7
|
+
* Includes selection state, layout, borders, and `displayValue` for the control label.
|
|
8
|
+
*/
|
|
9
|
+
export type SelectChipControlChipProps = Pick<
|
|
10
|
+
ChipBaseProps,
|
|
11
|
+
| 'active'
|
|
12
|
+
| 'activeBackground'
|
|
13
|
+
| 'activeColor'
|
|
14
|
+
| 'background'
|
|
15
|
+
| 'color'
|
|
16
|
+
| 'invertColorScheme'
|
|
17
|
+
| 'inverted'
|
|
18
|
+
| 'numberOfLines'
|
|
19
|
+
| 'maxWidth'
|
|
20
|
+
| 'size'
|
|
21
|
+
| 'compact'
|
|
22
|
+
| 'borderWidth'
|
|
23
|
+
| 'borderColor'
|
|
24
|
+
| 'bordered'
|
|
25
|
+
| 'borderRadius'
|
|
26
|
+
> & {
|
|
27
|
+
/**
|
|
28
|
+
* Override the displayed value in the chip control.
|
|
29
|
+
* Useful for avoiding truncation, especially in multi-select scenarios where multiple option labels might be too long to display.
|
|
30
|
+
* When provided, this value takes precedence over the default label generation.
|
|
31
|
+
*/
|
|
32
|
+
displayValue?: React.ReactNode;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* SelectControlProps fields superseded by {@link SelectChipControlChipProps}.
|
|
36
|
+
* Omit is required: intersection would merge overlapping keys (e.g. `size` as SelectSize &
|
|
37
|
+
* ChipSize, `background` as Box vs chip tokens) instead of replacing select-scale definitions.
|
|
38
|
+
*/
|
|
39
|
+
type SelectControlPropsReplacedByChipProps = keyof Pick<
|
|
40
|
+
SelectControlProps,
|
|
41
|
+
'size' | 'compact' | 'borderWidth' | 'borderColor' | 'bordered' | 'borderRadius'
|
|
42
|
+
>;
|
|
43
|
+
export type SelectChipControlProps<
|
|
44
|
+
Type extends SelectType = 'single',
|
|
45
|
+
SelectOptionValue extends string = string,
|
|
46
|
+
> = Omit<SelectControlProps<Type, SelectOptionValue>, SelectControlPropsReplacedByChipProps> &
|
|
47
|
+
SelectChipControlChipProps;
|
|
48
|
+
/** Generic memo components need an explicit cast for the public polymorphic signature. */
|
|
5
49
|
export declare const SelectChipControl: <
|
|
6
50
|
Type extends SelectType,
|
|
7
51
|
SelectOptionValue extends string = string,
|
|
8
52
|
>(
|
|
9
|
-
props:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
53
|
+
props: SelectChipControlProps<Type, SelectOptionValue> & {
|
|
54
|
+
ref?: React.Ref<View>;
|
|
55
|
+
},
|
|
13
56
|
) => React.ReactElement;
|
|
57
|
+
export {};
|
|
14
58
|
//# sourceMappingURL=SelectChipControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectChipControl.d.ts","sourceRoot":"","sources":["../../../src/alpha/select-chip/SelectChipControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectChipControl.d.ts","sourceRoot":"","sources":["../../../src/alpha/select-chip/SelectChipControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,aAAa,EACX,QAAQ,GACR,kBAAkB,GAClB,aAAa,GACb,YAAY,GACZ,OAAO,GACP,mBAAmB,GACnB,UAAU,GACV,eAAe,GACf,UAAU,GACV,MAAM,GACN,SAAS,GACT,aAAa,GACb,aAAa,GACb,UAAU,GACV,cAAc,CACjB,GAAG;IACF;;;;OAIG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAChC,CAAC;AAEF;;;;GAIG;AACH,KAAK,qCAAqC,GAAG,MAAM,IAAI,CACrD,kBAAkB,EAClB,MAAM,GAAG,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,UAAU,GAAG,cAAc,CACjF,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAChC,IAAI,SAAS,UAAU,GAAG,QAAQ,EAClC,iBAAiB,SAAS,MAAM,GAAG,MAAM,IACvC,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,CAAC,EAAE,qCAAqC,CAAC,GAC1F,0BAA0B,CAAC;AAmK7B,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,EAAiC,CAC7D,IAAI,SAAS,UAAU,EACvB,iBAAiB,SAAS,MAAM,GAAG,MAAM,EAEzC,KAAK,EAAE,sBAAsB,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAAG;IACvD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;CACvB,KACE,KAAK,CAAC,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/alpha/select-chip/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/alpha/select-chip/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -16,11 +16,14 @@ export type TabbedChipProps<TabId extends string = string> = Omit<
|
|
|
16
16
|
Component?: React.FC<Omit<ChipProps, 'children'> & TabValue<TabId>>;
|
|
17
17
|
/**
|
|
18
18
|
* Custom background color applied to the chip when it is the active tab.
|
|
19
|
-
*
|
|
19
|
+
* Skips color-scheme inversion and paints this token directly. Any `start`,
|
|
20
|
+
* `end`, or custom tab content must set explicit colors to match.
|
|
20
21
|
*/
|
|
21
22
|
activeBackground?: MediaChipBaseProps['background'];
|
|
22
23
|
/**
|
|
23
24
|
* Custom foreground color applied to the chip label when it is the active tab.
|
|
25
|
+
* Skips color-scheme inversion when set. Any `start`, `end`, or custom tab
|
|
26
|
+
* content must set explicit colors to match.
|
|
24
27
|
*/
|
|
25
28
|
activeColor?: MediaChipBaseProps['color'];
|
|
26
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabbedChips.d.ts","sourceRoot":"","sources":["../../../src/alpha/tabbed-chips/TabbedChips.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AACpE,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qDAAqD,CAAC;AACpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3E,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAQ,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"TabbedChips.d.ts","sourceRoot":"","sources":["../../../src/alpha/tabbed-chips/TabbedChips.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AACpE,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qDAAqD,CAAC;AACpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3E,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAQ,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgC3E,MAAM,MAAM,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI,IAAI,CAC/D,SAAS,EACT,UAAU,GAAG,SAAS,CACvB,GACC,QAAQ,CAAC,KAAK,CAAC,GAAG;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;IACpD;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAC3C,CAAC;AAEJ,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI,IAAI,CACpE,aAAa,CAAC,KAAK,CAAC,EAClB,cAAc,GACd,8BAA8B,GAC9B,MAAM,GACN,0BAA0B,GAC1B,kBAAkB,GAClB,aAAa,CAChB,GAAG;IACF,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,4BAA4B,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,8BAA8B,CAAC,CAAC;IAChF;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI,oBAAoB,CAAC,KAAK,CAAC,GACvF,WAAW,GACX,wBAAwB,GAAG;IACzB;;;OAGG;IACH,GAAG,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC;IACtB;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC1B,MAAM,CAAC,EAAE;QACP,6BAA6B;QAC7B,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAC5B,wBAAwB;QACxB,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;KAC7B,CAAC;CACH,CAAC;AAEJ,KAAK,aAAa,GAAG,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACjD,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,YAAY,CAAC;AAoFxB,eAAO,MAAM,WAAW,EAA2B,aAAa,CAAC"}
|
package/dts/chips/Chip.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export declare const Chip: React.NamedExoticComponent<
|
|
|
13
13
|
start?: React.ReactNode;
|
|
14
14
|
end?: React.ReactNode;
|
|
15
15
|
maxWidth?: import('react-native').DimensionValue;
|
|
16
|
+
active?: boolean;
|
|
17
|
+
activeBackground?: import('../styles/styleProps').StyleProps['background'];
|
|
18
|
+
activeColor?: import('../styles/styleProps').StyleProps['color'];
|
|
16
19
|
inverted?: boolean;
|
|
17
20
|
invertColorScheme?: boolean;
|
|
18
21
|
compact?: boolean;
|
package/dts/chips/Chip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../src/chips/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../src/chips/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAUzC,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAiBpC;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;YAuGP,CAAP;eAGmB,CAAC;;;UAtGf,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;EAwGrB,CAAC"}
|
package/dts/chips/ChipProps.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type DimensionValue, type StyleProp, type ViewStyle } from 'react-native';
|
|
2
2
|
import { type SharedAccessibilityProps } from '@coinbase/cds-common/types/SharedAccessibilityProps';
|
|
3
3
|
import { type SharedProps } from '@coinbase/cds-common/types/SharedProps';
|
|
4
|
+
import type { StyleProps } from '../styles/styleProps';
|
|
4
5
|
import type { PressableProps } from '../system/Pressable';
|
|
5
6
|
export type ChipSize = 'xs' | 's';
|
|
6
7
|
export type ChipBaseProps = SharedProps &
|
|
@@ -17,18 +18,50 @@ export type ChipBaseProps = SharedProps &
|
|
|
17
18
|
* @default 200
|
|
18
19
|
*/
|
|
19
20
|
maxWidth?: DimensionValue;
|
|
21
|
+
/**
|
|
22
|
+
* When true, emphasizes the Chip with higher contrast by inverting the color
|
|
23
|
+
* scheme for everything rendered inside the Chip — including `background`,
|
|
24
|
+
* `color`, icons, and other token-based colors. Those props are resolved
|
|
25
|
+
* against the opposite color scheme, matching the legacy `invertColorScheme`
|
|
26
|
+
* behavior.
|
|
27
|
+
*
|
|
28
|
+
* Set `activeBackground` and/or `activeColor` to opt out of inversion and
|
|
29
|
+
* paint explicit active colors instead.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
active?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Background color applied when `active` is true. When set, the Chip skips
|
|
35
|
+
* color-scheme inversion and uses this token directly.
|
|
36
|
+
*
|
|
37
|
+
* **Warning:** `start`, `end`, and `children` ReactNodes are not updated
|
|
38
|
+
* automatically — pass explicit `color` props on nested icons and other
|
|
39
|
+
* content so they match the active palette.
|
|
40
|
+
*/
|
|
41
|
+
activeBackground?: StyleProps['background'];
|
|
42
|
+
/**
|
|
43
|
+
* Foreground color applied when `active` is true. When set, the Chip skips
|
|
44
|
+
* color-scheme inversion and uses this token for string labels.
|
|
45
|
+
*
|
|
46
|
+
* **Warning:** `start`, `end`, and `children` ReactNodes are not updated
|
|
47
|
+
* automatically — pass explicit `color` props on nested icons and other
|
|
48
|
+
* content so they match the active palette.
|
|
49
|
+
*/
|
|
50
|
+
activeColor?: StyleProps['color'];
|
|
20
51
|
/**
|
|
21
52
|
* Invert the foreground and background colors to emphasize the Chip.
|
|
22
53
|
* Depending on your theme, it may be dangerous to use this prop in conjunction with `transparentWhileInactive`.
|
|
23
54
|
* @default false
|
|
24
|
-
* @deprecated Use the
|
|
25
|
-
* @deprecationExpectedRemoval
|
|
55
|
+
* @deprecated Use the `active` prop instead. This will be removed in a future major release.
|
|
56
|
+
* @deprecationExpectedRemoval v11
|
|
26
57
|
*/
|
|
27
58
|
inverted?: boolean;
|
|
28
59
|
/**
|
|
29
60
|
* Invert the foreground and background colors to emphasize the Chip.
|
|
30
61
|
* Depending on your theme, it may be dangerous to use this prop in conjunction with `transparentWhileInactive`.
|
|
31
62
|
* @default false
|
|
63
|
+
* @deprecated Use the `active` prop instead. This will be removed in a future major release.
|
|
64
|
+
* @deprecationExpectedRemoval v11
|
|
32
65
|
*/
|
|
33
66
|
invertColorScheme?: boolean;
|
|
34
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipProps.d.ts","sourceRoot":"","sources":["../../src/chips/ChipProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,qDAAqD,CAAC;AACpG,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,GAAG,CAAC;AAElC,MAAM,MAAM,aAAa,GAAG,WAAW,GACrC,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC,GACjF,IAAI,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,GAAG;IACrD,iDAAiD;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,wCAAwC;IACxC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,uCAAuC;IACvC,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB
|
|
1
|
+
{"version":3,"file":"ChipProps.d.ts","sourceRoot":"","sources":["../../src/chips/ChipProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,qDAAqD,CAAC;AACpG,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,GAAG,CAAC;AAElC,MAAM,MAAM,aAAa,GAAG,WAAW,GACrC,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC,GACjF,IAAI,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,GAAG;IACrD,iDAAiD;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,wCAAwC;IACxC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,uCAAuC;IACvC,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IAC5C;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,kEAAkE;IAClE,MAAM,CAAC,EAAE;QACP,mBAAmB;QACnB,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAC5B,sBAAsB;QACtB,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;KAChC,CAAC;CACH,CAAC;AAEJ,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC;AAEtC,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAE/C,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAC7C,SAAS,GAAG;IACV;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputChip.d.ts","sourceRoot":"","sources":["../../src/chips/InputChip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAKzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,eAAO,MAAM,SAAS,iDAIjB,cAAc,GAAG;IAClB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;CACvB,
|
|
1
|
+
{"version":3,"file":"InputChip.d.ts","sourceRoot":"","sources":["../../src/chips/InputChip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAKzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,eAAO,MAAM,SAAS,iDAIjB,cAAc,GAAG;IAClB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;CACvB,6CA6CF,CAAC"}
|
package/dts/chips/MediaChip.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export declare const MediaChip: import('react').NamedExoticComponent<
|
|
|
10
10
|
start?: React.ReactNode;
|
|
11
11
|
end?: React.ReactNode;
|
|
12
12
|
maxWidth?: import('react-native').DimensionValue;
|
|
13
|
+
active?: boolean;
|
|
14
|
+
activeBackground?: import('../styles/styleProps').StyleProps['background'];
|
|
15
|
+
activeColor?: import('../styles/styleProps').StyleProps['color'];
|
|
13
16
|
inverted?: boolean;
|
|
14
17
|
invertColorScheme?: boolean;
|
|
15
18
|
compact?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaChip.d.ts","sourceRoot":"","sources":["../../src/chips/MediaChip.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAC/C,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,SAAS,CAAC;AAE5D,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"MediaChip.d.ts","sourceRoot":"","sources":["../../src/chips/MediaChip.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAC/C,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,SAAS,CAAC;AAE5D,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;YAmEo7D,CAAC;eAAkE,CAAC;;;UA/DtgE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;EA8DrB,CAAC"}
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
const _excluded = ["ref"],
|
|
2
|
-
_excluded2 = ["
|
|
3
|
-
|
|
2
|
+
_excluded2 = ["active", "invertColorScheme", "inverted", "value"],
|
|
3
|
+
_excluded3 = ["active", "activeBackground", "activeColor", "background", "color", "numberOfLines", "maxWidth", "displayValue", "size", "compact", "borderWidth", "borderColor", "bordered", "borderRadius", "invertColorScheme", "inverted"];
|
|
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
|
+
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); }
|
|
6
|
+
import React, { memo, useMemo } from 'react';
|
|
7
|
+
import { getSelectChipActive } from '@coinbase/cds-common/chips/getSelectChipActive';
|
|
6
8
|
import { useComponentConfig } from '../../hooks/useComponentConfig';
|
|
7
9
|
import { Select } from '../select/Select';
|
|
8
10
|
import { SelectChipControl } from './SelectChipControl';
|
|
11
|
+
|
|
12
|
+
// TODO(CDS-2544): SelectChipBaseProps should also compose SelectBaseProps.
|
|
13
|
+
// https://linear.app/coinbase/issue/CDS-2544/selectchipbaseprops-should-compose-selectbaseprops
|
|
9
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
/**
|
|
16
|
+
* Creates a wrapper component that injects chip-specific props into SelectChipControl.
|
|
17
|
+
* Select only forwards generic control props to `SelectControlComponent`; chip styling
|
|
18
|
+
* and `active` are owned by SelectChip and must be closed over here.
|
|
19
|
+
*/
|
|
20
|
+
function createSelectChipControlWrapper(chipProps) {
|
|
21
|
+
return /*#__PURE__*/memo(controlProps => {
|
|
22
|
+
// Chip props are spread last so they win at runtime; the cast bridges overlapping keys
|
|
23
|
+
// (`size`, borders) where SelectControlProps and SelectChipBaseProps use different types.
|
|
24
|
+
return /*#__PURE__*/_jsx(SelectChipControl, _extends({}, _extends({}, controlProps, chipProps)));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
10
28
|
/**
|
|
11
29
|
* Chip-styled Select control built on top of the Alpha Select.
|
|
12
30
|
* Supports both single and multi selection via Select's `type` prop.
|
|
@@ -16,33 +34,67 @@ const SelectChipComponent = /*#__PURE__*/memo(_ref => {
|
|
|
16
34
|
ref
|
|
17
35
|
} = _ref,
|
|
18
36
|
_props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
19
|
-
|
|
37
|
+
// Resolve `active` from instance props before config merge so state-aware resolvers
|
|
38
|
+
// (active vs inactive border styling) see the final selection state. `value` and
|
|
39
|
+
// legacy invert props are pulled out with `active` and passed back explicitly because
|
|
40
|
+
// they feed that resolution and must remain available to the config resolver input.
|
|
20
41
|
const {
|
|
42
|
+
active: activeProp,
|
|
21
43
|
invertColorScheme,
|
|
44
|
+
inverted,
|
|
45
|
+
value
|
|
46
|
+
} = _props,
|
|
47
|
+
restProps = _objectWithoutPropertiesLoose(_props, _excluded2);
|
|
48
|
+
const resolvedActive = getSelectChipActive(activeProp, value, invertColorScheme, inverted);
|
|
49
|
+
const mergedProps = useComponentConfig('SelectChip', _extends({}, restProps, {
|
|
50
|
+
value,
|
|
51
|
+
active: resolvedActive,
|
|
52
|
+
invertColorScheme,
|
|
53
|
+
inverted
|
|
54
|
+
}));
|
|
55
|
+
// SelectChip composes Select + MediaChip; peel chip props off merged props so the rest
|
|
56
|
+
// can flow to `<Select>` without chip-only fields leaking into the select interface.
|
|
57
|
+
const {
|
|
58
|
+
active,
|
|
59
|
+
activeBackground,
|
|
60
|
+
activeColor,
|
|
61
|
+
background,
|
|
62
|
+
color,
|
|
22
63
|
numberOfLines,
|
|
23
64
|
maxWidth,
|
|
24
65
|
displayValue,
|
|
25
66
|
size,
|
|
26
|
-
compact
|
|
67
|
+
compact,
|
|
68
|
+
borderWidth,
|
|
69
|
+
borderColor,
|
|
70
|
+
bordered,
|
|
71
|
+
borderRadius,
|
|
72
|
+
invertColorScheme: mergedInvertColorScheme,
|
|
73
|
+
inverted: mergedInverted
|
|
27
74
|
} = mergedProps,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
75
|
+
selectProps = _objectWithoutPropertiesLoose(mergedProps, _excluded3);
|
|
76
|
+
const WrappedSelectChipControl = useMemo(() => createSelectChipControlWrapper({
|
|
77
|
+
active,
|
|
78
|
+
activeBackground,
|
|
79
|
+
activeColor,
|
|
80
|
+
background,
|
|
81
|
+
color,
|
|
82
|
+
numberOfLines,
|
|
83
|
+
maxWidth,
|
|
84
|
+
displayValue,
|
|
85
|
+
size,
|
|
86
|
+
compact,
|
|
87
|
+
borderWidth,
|
|
88
|
+
borderColor,
|
|
89
|
+
bordered,
|
|
90
|
+
borderRadius,
|
|
91
|
+
invertColorScheme: mergedInvertColorScheme,
|
|
92
|
+
inverted: mergedInverted
|
|
93
|
+
}), [active, activeBackground, activeColor, background, color, displayValue, numberOfLines, maxWidth, size, compact, borderWidth, borderColor, bordered, borderRadius, mergedInvertColorScheme, mergedInverted]);
|
|
42
94
|
return /*#__PURE__*/_jsx(Select, _extends({
|
|
43
95
|
ref: ref,
|
|
44
|
-
SelectControlComponent:
|
|
45
|
-
},
|
|
96
|
+
SelectControlComponent: WrappedSelectChipControl
|
|
97
|
+
}, selectProps));
|
|
46
98
|
});
|
|
47
99
|
SelectChipComponent.displayName = 'SelectChip';
|
|
48
100
|
export const SelectChip = SelectChipComponent;
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import React, { 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 Box vs chip tokens) instead of replacing select-scale definitions.
|
|
16
|
+
*/
|
|
5
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
18
|
const SelectChipControlComponent = /*#__PURE__*/memo(_ref => {
|
|
7
19
|
let {
|
|
@@ -22,13 +34,23 @@ const SelectChipControlComponent = /*#__PURE__*/memo(_ref => {
|
|
|
22
34
|
label,
|
|
23
35
|
compact,
|
|
24
36
|
size,
|
|
37
|
+
active,
|
|
38
|
+
activeBackground,
|
|
39
|
+
activeColor,
|
|
40
|
+
background,
|
|
41
|
+
color,
|
|
25
42
|
invertColorScheme,
|
|
43
|
+
inverted,
|
|
26
44
|
numberOfLines,
|
|
27
45
|
maxWidth,
|
|
28
|
-
displayValue
|
|
46
|
+
displayValue,
|
|
47
|
+
borderWidth,
|
|
48
|
+
borderColor,
|
|
49
|
+
bordered,
|
|
50
|
+
borderRadius
|
|
29
51
|
} = _ref;
|
|
30
52
|
const isMultiSelect = type === 'multi';
|
|
31
|
-
const hasValue =
|
|
53
|
+
const hasValue = getSelectChipHasValue(value);
|
|
32
54
|
|
|
33
55
|
// Map of options to their values
|
|
34
56
|
// If multiple options share the same value, the first occurrence wins (matches native HTML select behavior)
|
|
@@ -83,30 +105,34 @@ const SelectChipControlComponent = /*#__PURE__*/memo(_ref => {
|
|
|
83
105
|
const opt = optionsMap.get(value);
|
|
84
106
|
return (_ref6 = (_ref7 = (_ref8 = (_opt$label2 = opt == null ? void 0 : opt.label) != null ? _opt$label2 : opt == null ? void 0 : opt.description) != null ? _ref8 : opt == null ? void 0 : opt.value) != null ? _ref7 : placeholder) != null ? _ref6 : null;
|
|
85
107
|
}, [hasValue, label, placeholder, displayValue, isMultiSelect, optionsMap, value, maxSelectedOptionsToShow, hiddenSelectedOptionsLabel]);
|
|
108
|
+
const resolvedColor = active && activeColor !== undefined ? activeColor : color;
|
|
86
109
|
const endNode = useMemo(() => {
|
|
110
|
+
// Match Chip's label color. `fg` still inverts with the chip when active uses theme inversion.
|
|
87
111
|
return customEndNode != null ? customEndNode : /*#__PURE__*/_jsx(AnimatedCaret, {
|
|
88
112
|
active: true,
|
|
89
|
-
color:
|
|
113
|
+
color: resolvedColor != null ? resolvedColor : 'fg',
|
|
90
114
|
rotate: open ? 0 : 180,
|
|
91
115
|
size: "xs"
|
|
92
116
|
});
|
|
93
|
-
}, [customEndNode, open,
|
|
94
|
-
const color = useMemo(() => {
|
|
95
|
-
return hasValue ? 'fgInverse' : 'fg';
|
|
96
|
-
}, [hasValue]);
|
|
97
|
-
const background = useMemo(() => {
|
|
98
|
-
return hasValue ? 'bgInverse' : 'bgSecondary';
|
|
99
|
-
}, [hasValue]);
|
|
117
|
+
}, [customEndNode, open, resolvedColor]);
|
|
100
118
|
return /*#__PURE__*/_jsx(MediaChip, {
|
|
101
119
|
ref: ref,
|
|
102
120
|
accessibilityHint: accessibilityHint,
|
|
103
121
|
accessibilityLabel: accessibilityLabel,
|
|
122
|
+
active: active,
|
|
123
|
+
activeBackground: activeBackground,
|
|
124
|
+
activeColor: activeColor,
|
|
104
125
|
background: background,
|
|
126
|
+
bordered: bordered,
|
|
127
|
+
borderColor: borderColor,
|
|
128
|
+
borderRadius: borderRadius,
|
|
129
|
+
borderWidth: borderWidth,
|
|
105
130
|
color: color,
|
|
106
131
|
compact: compact,
|
|
107
132
|
disabled: disabled,
|
|
108
133
|
end: endNode,
|
|
109
134
|
invertColorScheme: invertColorScheme,
|
|
135
|
+
inverted: inverted,
|
|
110
136
|
maxWidth: maxWidth,
|
|
111
137
|
numberOfLines: numberOfLines,
|
|
112
138
|
onPress: () => setOpen(s => !s),
|
|
@@ -115,4 +141,7 @@ const SelectChipControlComponent = /*#__PURE__*/memo(_ref => {
|
|
|
115
141
|
children: labelContent
|
|
116
142
|
});
|
|
117
143
|
});
|
|
144
|
+
SelectChipControlComponent.displayName = 'SelectChipControl';
|
|
145
|
+
|
|
146
|
+
/** Generic memo components need an explicit cast for the public polymorphic signature. */
|
|
118
147
|
export const SelectChipControl = SelectChipControlComponent;
|
|
@@ -217,7 +217,7 @@ export const MultiSelectWithAssets = () => {
|
|
|
217
217
|
value: value
|
|
218
218
|
});
|
|
219
219
|
};
|
|
220
|
-
export const
|
|
220
|
+
export const Active = () => {
|
|
221
221
|
const exampleOptions = [{
|
|
222
222
|
value: '1',
|
|
223
223
|
label: 'Option 1'
|
|
@@ -231,7 +231,7 @@ export const InvertColorScheme = () => {
|
|
|
231
231
|
borderRadius: 200,
|
|
232
232
|
padding: 2,
|
|
233
233
|
children: /*#__PURE__*/_jsx(SelectChip, {
|
|
234
|
-
|
|
234
|
+
active: true,
|
|
235
235
|
onChange: setValue,
|
|
236
236
|
options: exampleOptions,
|
|
237
237
|
placeholder: "Choose an option",
|
|
@@ -587,8 +587,8 @@ const SelectChipScreen = () => {
|
|
|
587
587
|
title: "Multi-Select with Assets",
|
|
588
588
|
children: /*#__PURE__*/_jsx(MultiSelectWithAssets, {})
|
|
589
589
|
}), /*#__PURE__*/_jsx(Example, {
|
|
590
|
-
title: "
|
|
591
|
-
children: /*#__PURE__*/_jsx(
|
|
590
|
+
title: "Active",
|
|
591
|
+
children: /*#__PURE__*/_jsx(Active, {})
|
|
592
592
|
}), /*#__PURE__*/_jsx(Example, {
|
|
593
593
|
title: "Empty Options",
|
|
594
594
|
children: /*#__PURE__*/_jsx(EmptyOptions, {})
|
|
@@ -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 = ["ref"],
|
|
3
3
|
_excluded3 = ["tabs", "activeTab", "testID", "TabComponent", "onChange", "width", "gap", "compact", "size", "styles", "autoScrollOffset"];
|
|
4
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); }
|
|
@@ -32,9 +32,9 @@ const DefaultTabComponent = _ref => {
|
|
|
32
32
|
accessibilityState: {
|
|
33
33
|
selected: isActive
|
|
34
34
|
},
|
|
35
|
+
active: isActive && !activeBackground,
|
|
35
36
|
background: isActive && activeBackground ? activeBackground : undefined,
|
|
36
37
|
color: isActive && activeColor ? activeColor : color,
|
|
37
|
-
invertColorScheme: isActive && !activeBackground,
|
|
38
38
|
onPress: handlePress
|
|
39
39
|
}, tabProps, {
|
|
40
40
|
children: label
|
package/esm/chips/Chip.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const _excluded = ["ref"],
|
|
2
|
-
_excluded2 = ["alignSelf", "children", "start", "end", "invertColorScheme", "inverted", "maxWidth", "compact", "size", "gap", "paddingX", "paddingY", "alignItems", "justifyContent", "padding", "paddingTop", "paddingBottom", "paddingStart", "paddingEnd", "numberOfLines", "testID", "contentStyle", "borderRadius", "background", "style", "styles", "onPress", "color", "font"];
|
|
2
|
+
_excluded2 = ["alignSelf", "children", "start", "end", "active", "activeBackground", "activeColor", "invertColorScheme", "inverted", "maxWidth", "compact", "size", "gap", "paddingX", "paddingY", "alignItems", "justifyContent", "padding", "paddingTop", "paddingBottom", "paddingStart", "paddingEnd", "numberOfLines", "testID", "contentStyle", "borderRadius", "background", "style", "styles", "onPress", "color", "font"];
|
|
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, { Fragment, memo } from 'react';
|
|
5
|
+
import React, { Fragment, memo, useMemo } from 'react';
|
|
6
6
|
import { chipMaxWidth } from '@coinbase/cds-common/tokens/chip';
|
|
7
7
|
import { useComponentConfig } from '../hooks/useComponentConfig';
|
|
8
8
|
import { Box } from '../layout/Box';
|
|
@@ -44,6 +44,9 @@ export const Chip = /*#__PURE__*/memo(function Chip(_ref) {
|
|
|
44
44
|
children,
|
|
45
45
|
start,
|
|
46
46
|
end,
|
|
47
|
+
active = false,
|
|
48
|
+
activeBackground,
|
|
49
|
+
activeColor,
|
|
47
50
|
invertColorScheme,
|
|
48
51
|
inverted,
|
|
49
52
|
maxWidth = chipMaxWidth,
|
|
@@ -69,14 +72,20 @@ export const Chip = /*#__PURE__*/memo(function Chip(_ref) {
|
|
|
69
72
|
font = sizeConfig.font
|
|
70
73
|
} = mergedProps,
|
|
71
74
|
props = _objectWithoutPropertiesLoose(mergedProps, _excluded2);
|
|
72
|
-
const
|
|
75
|
+
const hasActiveColorOverrides = activeBackground !== undefined || activeColor !== undefined;
|
|
76
|
+
const activeUsesThemeInversion = active && !hasActiveColorOverrides;
|
|
77
|
+
const shouldInvert = Boolean(invertColorScheme != null ? invertColorScheme : inverted) || activeUsesThemeInversion;
|
|
78
|
+
const WrapperComponent = shouldInvert ? InvertedThemeProvider : Fragment;
|
|
79
|
+
const resolvedBackground = active && activeBackground !== undefined ? activeBackground : background;
|
|
80
|
+
const resolvedColor = active && activeColor !== undefined ? activeColor : color;
|
|
81
|
+
const containerStyle = useMemo(() => [style, styles == null ? void 0 : styles.root], [style, styles == null ? void 0 : styles.root]);
|
|
73
82
|
const containerProps = {
|
|
74
83
|
testID,
|
|
75
|
-
background,
|
|
84
|
+
background: resolvedBackground,
|
|
76
85
|
borderRadius,
|
|
77
86
|
ref,
|
|
78
87
|
alignSelf,
|
|
79
|
-
style:
|
|
88
|
+
style: containerStyle
|
|
80
89
|
};
|
|
81
90
|
const content = /*#__PURE__*/_jsxs(HStack, {
|
|
82
91
|
alignItems: alignItems,
|
|
@@ -93,13 +102,13 @@ export const Chip = /*#__PURE__*/memo(function Chip(_ref) {
|
|
|
93
102
|
style: [contentStyle, styles == null ? void 0 : styles.content],
|
|
94
103
|
testID: testID ? testID + "-content" : undefined,
|
|
95
104
|
children: [start, typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
96
|
-
color:
|
|
105
|
+
color: resolvedColor,
|
|
97
106
|
flexShrink: 1,
|
|
98
107
|
font: font,
|
|
99
108
|
numberOfLines: numberOfLines,
|
|
100
109
|
children: children
|
|
101
110
|
}) : children ? /*#__PURE__*/_jsx(Box, {
|
|
102
|
-
color:
|
|
111
|
+
color: resolvedColor,
|
|
103
112
|
flexShrink: 1,
|
|
104
113
|
children: children
|
|
105
114
|
}) : null, end]
|
package/esm/chips/InputChip.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const _excluded = ["ref"],
|
|
2
|
-
_excluded2 = ["
|
|
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
|
|
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
|
-
|
|
21
|
-
|
|
34
|
+
testID = 'input-chip',
|
|
35
|
+
invertColorScheme: mergedInvertColorScheme,
|
|
36
|
+
inverted: mergedInverted
|
|
22
37
|
} = mergedProps,
|
|
23
|
-
props = _objectWithoutPropertiesLoose(mergedProps,
|
|
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:
|
|
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: "
|
|
110
|
+
title: "Active",
|
|
111
111
|
children: /*#__PURE__*/_jsx(ChipExamples, {
|
|
112
|
-
|
|
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: "
|
|
84
|
+
title: "Active",
|
|
85
85
|
children: /*#__PURE__*/_jsx(MediaChipExamples, {
|
|
86
|
-
|
|
86
|
+
active: true
|
|
87
87
|
})
|
|
88
88
|
}), /*#__PURE__*/_jsx(Example, {
|
|
89
89
|
title: "Compact",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-mobile",
|
|
3
|
-
"version": "9.
|
|
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.
|
|
221
|
+
"@coinbase/cds-common": "^9.16.0",
|
|
222
222
|
"@coinbase/cds-icons": "^5.21.0",
|
|
223
|
-
"@coinbase/cds-illustrations": "^4.
|
|
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",
|