Skip to content

Commit 7fdc44b

Browse files
authored
feat(ListBox): select all (#735)
1 parent 46931cc commit 7fdc44b

23 files changed

+1674
-321
lines changed

.changeset/curly-pans-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Fix flipping of popover in FilterPicker if it's already open.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Improved Button layout.

.changeset/nice-comics-fix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Improved FilterPicker layout with additional wrapper for consistency.

.changeset/slow-fans-develop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Fix initial state inconsistency in FilterPicker.

.changeset/sour-donkeys-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Overflow text ellipsis in Buttons with icons by default.

.changeset/thirty-bikes-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Add `showSelectAll` and `selectAllLabel` options for ListBox, FilterListBox, and FilterPicker to add "Select All" option. The label can be customized.

.size-limit.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = [
2020
}),
2121
);
2222
},
23-
limit: '280kB',
23+
limit: '281kB',
2424
},
2525
{
2626
name: 'Tree shaking (just a Button)',

src/components/actions/Button/Button.docs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The `mods` prop accepts the following modifiers you can override:
5555
| loading | `boolean` | Displays loading spinner. |
5656
| selected | `boolean` | Displays selected state. |
5757
| with-icons | `boolean` | Indicates that the button contains at least one icon. |
58-
| single-icon-only | `boolean` | Icon-only button without text. |
58+
| single-icon | `boolean` | Icon-only button without text. |
5959

6060
## Variants
6161

src/components/actions/Button/Button.tsx

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
TEXT_STYLES,
1111
} from '../../../tasty';
1212
import { accessibilityWarning } from '../../../utils/warnings';
13+
import { Text } from '../../content/Text';
1314
import { CubeActionProps } from '../Action/Action';
1415
import { useAction } from '../use-action';
1516

@@ -60,8 +61,16 @@ const STYLE_PROPS = [...CONTAINER_STYLES, ...TEXT_STYLES];
6061

6162
export const DEFAULT_BUTTON_STYLES = {
6263
display: 'inline-grid',
63-
placeItems: 'center stretch',
64-
placeContent: 'center',
64+
flow: 'column',
65+
placeItems: 'center start',
66+
placeContent: {
67+
'': 'center',
68+
'right-icon | suffix': 'center stretch',
69+
},
70+
gridColumns: {
71+
'': 'initial',
72+
'left-icon | loading | prefix': 'max-content',
73+
},
6574
position: 'relative',
6675
margin: 0,
6776
boxSizing: 'border-box',
@@ -73,7 +82,6 @@ export const DEFAULT_BUTTON_STYLES = {
7382
'': '.75x',
7483
'[data-size="small"]': '.5x',
7584
},
76-
flow: 'column',
7785
preset: {
7886
'': 't3m',
7987
'[data-size="xsmall"]': 't4',
@@ -85,19 +93,19 @@ export const DEFAULT_BUTTON_STYLES = {
8593
outlineOffset: 1,
8694
padding: {
8795
'': '.5x (1.5x - 1bw)',
88-
'[data-size="small"] | [data-size="xsmall"]': '.5x (1x - 1bw)',
96+
'[data-size="small"] | [data-size="xsmall"]': '.5x (1.25x - 1bw)',
8997
'[data-size="medium"]': '.5x (1.5x - 1bw)',
90-
'[data-size="large"]': '.5x (2x - 1bw)',
91-
'[data-size="xlarge"]': '.5x (2.25x - 1bw)',
92-
'single-icon-only | [data-type="link"]': 0,
98+
'[data-size="large"]': '.5x (1.75x - 1bw)',
99+
'[data-size="xlarge"]': '.5x (2x - 1bw)',
100+
'single-icon | [data-type="link"]': 0,
93101
},
94102
width: {
95103
'': 'initial',
96-
'[data-size="xsmall"] & single-icon-only': '@size-xs @size-xs',
97-
'[data-size="small"] & single-icon-only': '@size-sm @size-sm',
98-
'[data-size="medium"] & single-icon-only': '@size-md @size-md',
99-
'[data-size="large"] & single-icon-only': '@size-lg @size-lg',
100-
'[data-size="xlarge"] & single-icon-only': '@size-xl @size-xl',
104+
'[data-size="xsmall"] & single-icon': '@size-xs @size-xs',
105+
'[data-size="small"] & single-icon': '@size-sm @size-sm',
106+
'[data-size="medium"] & single-icon': '@size-md @size-md',
107+
'[data-size="large"] & single-icon': '@size-lg @size-lg',
108+
'[data-size="xlarge"] & single-icon': '@size-xl @size-xl',
101109
'[data-type="link"]': 'initial',
102110
},
103111
height: {
@@ -114,6 +122,20 @@ export const DEFAULT_BUTTON_STYLES = {
114122
'': true,
115123
'[data-type="link"] & !focused': 0,
116124
},
125+
126+
ButtonIcon: {
127+
width: 'max-content',
128+
},
129+
130+
'& [data-element="ButtonIcon"]:first-child:not(:last-child)': {
131+
marginLeft: '-.5x',
132+
placeSelf: 'center start',
133+
},
134+
135+
'& [data-element="ButtonIcon"]:last-child:not(:first-child)': {
136+
marginRight: '-.5x',
137+
placeSelf: 'center end',
138+
},
117139
} as const;
118140

119141
// ---------- DEFAULT THEME ----------
@@ -657,12 +679,16 @@ export const Button = forwardRef(function Button(
657679
!children
658680
);
659681

682+
const hasIcons = !!icon || !!rightIcon;
683+
660684
const modifiers = useMemo(
661685
() => ({
662686
loading: isLoading,
663687
selected: isSelected,
664-
'with-icons': !!icon || !!rightIcon,
665-
'single-icon-only': singleIcon,
688+
'with-icons': hasIcons,
689+
'left-icon': !!icon,
690+
'right-icon': !!rightIcon,
691+
'single-icon': singleIcon,
666692
...mods,
667693
}),
668694
[mods, isDisabled, isLoading, isSelected, singleIcon],
@@ -696,7 +722,12 @@ export const Button = forwardRef(function Button(
696722
<LoadingIcon data-element="ButtonIcon" />
697723
)
698724
) : null}
699-
{children}
725+
{((hasIcons && children) || (!!icon && !!rightIcon)) &&
726+
typeof children === 'string' ? (
727+
<Text ellipsis>{children}</Text>
728+
) : (
729+
children
730+
)}
700731
{rightIcon}
701732
</ButtonElement>
702733
);

src/components/actions/Menu/styled.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ export const StyledItem = tasty({
172172
placeItems: 'center',
173173
},
174174

175+
'& [data-element="ButtonIcon"]:first-child:not(:last-child)': {
176+
marginLeft: 0,
177+
},
178+
179+
'& [data-element="ButtonIcon"]:last-child:not(:first-child)': {
180+
marginRight: 0,
181+
},
182+
175183
Postfix: {
176184
color: {
177185
'': '#dark-03',

0 commit comments

Comments
 (0)