Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a MultiSelect component #2911

Merged
merged 33 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f43c4e0
wip
NicholasBoll Aug 13, 2024
dd603a1
wip
NicholasBoll Sep 9, 2024
2352a45
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Sep 9, 2024
f134171
Update stories for SB upgrade
NicholasBoll Sep 9, 2024
b39916e
Add non-searchable multiselect
NicholasBoll Sep 25, 2024
d9bf591
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Oct 7, 2024
d4e1d3e
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Oct 8, 2024
59c5fbd
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Oct 8, 2024
27a3076
wip
NicholasBoll Oct 9, 2024
71bb793
wip
NicholasBoll Oct 9, 2024
5b80f75
Add constrained combobox input hook and update Select to fix all teh …
NicholasBoll Oct 10, 2024
e6cdc6e
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Oct 11, 2024
d5c9890
chore: Remove useResizeObserver hack
NicholasBoll Oct 11, 2024
7ed9d10
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Oct 12, 2024
d7e41e9
chore: Collection navigation getItem can return undefined
NicholasBoll Oct 12, 2024
0846784
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Oct 12, 2024
5e2c4fd
chore: Refactor Select to use useComboboxInputConstrained
NicholasBoll Oct 12, 2024
a20dff7
wip
NicholasBoll Oct 12, 2024
e9fdf38
Moved to preview folder
NicholasBoll Oct 13, 2024
a52cbe2
Add Basic example
NicholasBoll Oct 13, 2024
58db5e5
Add Searchable example
NicholasBoll Oct 14, 2024
30ae13c
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Oct 14, 2024
34f772a
Update exports
NicholasBoll Oct 14, 2024
8f53069
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Oct 14, 2024
8c59419
Remove duplicated upgrade entry
NicholasBoll Oct 14, 2024
707d9c3
Clean up types
NicholasBoll Oct 14, 2024
04d1dd4
PR feedback
NicholasBoll Oct 14, 2024
41b6c32
PR feedback
NicholasBoll Oct 14, 2024
bf744b7
remove console logs, fix Select specs
NicholasBoll Oct 14, 2024
086b92e
Add css gitignore to labs-css
NicholasBoll Oct 14, 2024
1ae1f54
Remove duplicate Upgrade guide ToC entry
NicholasBoll Oct 14, 2024
932fa7a
Fix controlled example
NicholasBoll Oct 14, 2024
69e5f62
Merge branch 'prerelease/major' of github.com:Workday/canvas-kit into…
NicholasBoll Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/component/FormField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Form Field', () => {
});
});

it.only('should link the input to the label name', () => {
it('should link the input to the label name', () => {
cy.get('input').should('have.ariaLabel', 'First Name');
});

Expand Down
15 changes: 15 additions & 0 deletions modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ A note to the reader:
- [Search Form](#search-form)
- [Select](#select)
- [Text Area](#text-area)
- [Menu Item](#menu-item)
- [Troubleshooting](#troubleshooting)
- [Glossary](#glossary)
- [Main](#main)
Expand Down Expand Up @@ -474,6 +475,20 @@ interface MyProps {
}
```

### Menu Item

**PR: ** [2969](https://github.com/Workday/canvas-kit/pull/2969)

`Menu.Item` was converted to use Stencils for styling and uses SystemIcon stencil variables to
change icon color instead of deeply nested selectors. We also added a `type` prop that can be either
`selectable` or `actionable`. The default for `Menu.Item` is `actionable`, while components with the
primary function of selection (like `Select`) default to `selectable`.

- `actionable` - used for menu items where the user performs an action rather than selecting. A
selected checkmark does not show for `actionable` menu items.
- `selectable` - used for menu items where the user selects an option. A selected checkmark will
show. Note this may cause visual regression tests to trigger, but this is intended.

## Troubleshooting

### My Styles Seem Broken?
Expand Down
5 changes: 0 additions & 5 deletions modules/labs-css/expandable.css

This file was deleted.

30 changes: 30 additions & 0 deletions modules/preview-react/mutliselect/MultiSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';

import {createContainer, createSubcomponent} from '@workday/canvas-kit-react/common';
import {handleCsProp} from '@workday/canvas-kit-styling';
import {Combobox} from '@workday/canvas-kit-react/combobox';
import {Menu} from '@workday/canvas-kit-react/menu';

import {useMultiSelectModel} from './useMultiSelectModel';
import {MultiSelectInput, MultiSelectSearchInput} from './MultiSelectInput';
import {MultiSelectCard} from './MultiSelectCard';

export interface MultiSelectProps extends React.PropsWithChildren {}

export const MultiSelect = createContainer()({
modelHook: useMultiSelectModel,
subComponents: {
Input: MultiSelectInput,
SearchInput: MultiSelectSearchInput,
Popper: Combobox.Menu.Popper,
Card: MultiSelectCard,
List: Combobox.Menu.List,
Item: Combobox.Menu.Item,
},
})<MultiSelectProps>(({children, ...elemProps}, _, model) => {
return (
<Combobox.Menu model={model} {...elemProps}>
{children}
</Combobox.Menu>
);
});
34 changes: 34 additions & 0 deletions modules/preview-react/mutliselect/MultiSelectCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';

import {
createElemPropsHook,
createSubcomponent,
ExtractProps,
} from '@workday/canvas-kit-react/common';
import {Menu} from '@workday/canvas-kit-react/menu';

import {useMultiSelectModel} from './useMultiSelectModel';
import {calc, px2rem} from '@workday/canvas-kit-styling';

export interface MultiSelectCardProps extends ExtractProps<typeof Menu.Card> {}

/**
* This hook sets the `minWidth` style attribute to match the width of the
* {@link MultiSelectInput MultiSelect.Input} component.
*/
export const useMultiSelectCard = createElemPropsHook(useMultiSelectModel)(model => {
return {
minWidth: calc.add(px2rem(model.state.width), px2rem(2)),
} as const;
});

export const MultiSelectCard = createSubcomponent('div')({
modelHook: useMultiSelectModel,
elemPropsHook: useMultiSelectCard,
})<MultiSelectCardProps>(({children, ...elemProps}, Element) => {
return (
<Menu.Card as={Element} {...elemProps}>
{children}
</Menu.Card>
);
});
Loading
Loading