From 4fa21d7c07d138e03daf228f4a6a17fcbf379a3f Mon Sep 17 00:00:00 2001 From: Nicholas Boll Date: Mon, 14 Oct 2024 16:44:11 -0600 Subject: [PATCH] feat: Add a MultiSelect component (#2911) Add a MutliSelect component. [category:Components] --- cypress/component/FormField.spec.tsx | 2 +- cypress/support/commands.ts | 1 - .../codemod/lib/v7/recategorizeIconButtons.ts | 1 - modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx | 21 +- modules/labs-css/.gitignore | 1 + modules/labs-css/expandable.css | 5 - .../expandable/stories/testing.stories.tsx | 2 - modules/preview-react/multi-select/LICENSE | 52 ++++ modules/preview-react/multi-select/README.md | 5 + modules/preview-react/multi-select/index.ts | 4 + .../multi-select/lib/MultiSelect.tsx | 28 ++ .../multi-select/lib/MultiSelectCard.tsx | 34 +++ .../multi-select/lib/MultiSelectInput.tsx | 262 ++++++++++++++++++ .../multi-select/lib/MultiSelectItem.tsx | 37 +++ .../multi-select/lib/useMultiSelectModel.ts | 79 ++++++ .../multi-select/spec/tsconfig.json | 3 + .../multi-select/stories/MultiSelect.mdx | 101 +++++++ .../stories/MultiSelect.stories.ts | 43 +++ .../multi-select/stories/examples/Basic.tsx | 30 ++ .../multi-select/stories/examples/Complex.tsx | 75 +++++ .../stories/examples/Controlled.tsx | 92 ++++++ .../multi-select/stories/examples/Icons.tsx | 43 +++ .../stories/examples/Searching.tsx | 123 ++++++++ .../multi-select/stories/tsconfig.json | 3 + .../stories/examples/OverflowActionBar.tsx | 1 + .../react/button/stories/button/Button.mdx | 5 +- modules/react/collection/lib/ListBox.tsx | 23 +- .../collection/lib/useListItemRemoveable.ts | 99 +++++++ modules/react/collection/lib/useListLoader.ts | 1 + .../collection/lib/useSelectionListModel.tsx | 3 +- .../combobox/lib/hooks/useComboboxInput.ts | 3 +- .../lib/hooks/useComboboxInputArbitrary.ts | 4 + .../lib/hooks/useComboboxInputConstrained.ts | 11 +- .../combobox/lib/hooks/useComboboxLoader.ts | 2 +- .../combobox/lib/hooks/useComboboxModel.tsx | 4 + modules/react/combobox/stories/Combobox.mdx | 5 +- modules/react/common/README.md | 177 +----------- .../react/common/lib/utils/mergeCallback.ts | 12 +- modules/react/common/lib/utils/mergeProps.ts | 8 +- modules/react/icon/lib/SystemIcon.tsx | 1 - .../react/layout/lib/utils/buildStyleFns.ts | 22 +- .../react/select/lib/hooks/useSelectInput.ts | 7 +- .../testing/lib/ComponentStatesTable.tsx | 4 + modules/react/text-input/lib/InputGroup.tsx | 6 +- modules/react/text-input/lib/TextInput.tsx | 3 +- modules/styling/lib/cs.ts | 53 ++-- modules/styling/spec/cs.spec.tsx | 8 +- 47 files changed, 1254 insertions(+), 255 deletions(-) create mode 100644 modules/labs-css/.gitignore delete mode 100644 modules/labs-css/expandable.css create mode 100644 modules/preview-react/multi-select/LICENSE create mode 100644 modules/preview-react/multi-select/README.md create mode 100644 modules/preview-react/multi-select/index.ts create mode 100644 modules/preview-react/multi-select/lib/MultiSelect.tsx create mode 100644 modules/preview-react/multi-select/lib/MultiSelectCard.tsx create mode 100644 modules/preview-react/multi-select/lib/MultiSelectInput.tsx create mode 100644 modules/preview-react/multi-select/lib/MultiSelectItem.tsx create mode 100644 modules/preview-react/multi-select/lib/useMultiSelectModel.ts create mode 100644 modules/preview-react/multi-select/spec/tsconfig.json create mode 100644 modules/preview-react/multi-select/stories/MultiSelect.mdx create mode 100644 modules/preview-react/multi-select/stories/MultiSelect.stories.ts create mode 100644 modules/preview-react/multi-select/stories/examples/Basic.tsx create mode 100644 modules/preview-react/multi-select/stories/examples/Complex.tsx create mode 100644 modules/preview-react/multi-select/stories/examples/Controlled.tsx create mode 100644 modules/preview-react/multi-select/stories/examples/Icons.tsx create mode 100644 modules/preview-react/multi-select/stories/examples/Searching.tsx create mode 100644 modules/preview-react/multi-select/stories/tsconfig.json create mode 100644 modules/react/collection/lib/useListItemRemoveable.ts diff --git a/cypress/component/FormField.spec.tsx b/cypress/component/FormField.spec.tsx index 0a73c27780..e5f059419e 100644 --- a/cypress/component/FormField.spec.tsx +++ b/cypress/component/FormField.spec.tsx @@ -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'); }); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 5f9d3490e7..9fac2d002b 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -137,7 +137,6 @@ export const haveAriaLabel = (text: string) => ($target: JQuery) => { expect($labelledEl).to.have.text(text); } else if ($target.attr('id')) { const id = $target.attr('id'); - console.log('id', id); const $labelledEl = Cypress.$(`label[for="${id}"]`); if (!$labelledEl.length) { throw Error( diff --git a/modules/codemod/lib/v7/recategorizeIconButtons.ts b/modules/codemod/lib/v7/recategorizeIconButtons.ts index c94e04f3c3..d0035aa163 100644 --- a/modules/codemod/lib/v7/recategorizeIconButtons.ts +++ b/modules/codemod/lib/v7/recategorizeIconButtons.ts @@ -185,7 +185,6 @@ export default function transformer(file: FileInfo, api: API, options: Options) } } }); - console.log(node.specifiers?.length); // if we removed all specifiers, remove the import if (!node.specifiers?.length) { diff --git a/modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx b/modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx index 41a929cd5c..0df0ec4ecf 100644 --- a/modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx +++ b/modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx @@ -45,16 +45,17 @@ A note to the reader: - [Component Updates](#component-updates) - [Styling API and CSS Tokens](#styling-api-and-css-tokens) - [Avatar](#avatar) + - [Collections](#collections) - [Combobox](#combmbox) - [Form Field](#form-field) - [Form Field Group](#form-field-group) - [Form Field Field](#form-field-field) - [Menu Item](#menu-item) + - [MultiSelect](#multiselect) - [Search Form](#search-form) - [Select](#select) - [Text Area](#text-area) - [Text Input](#text-input) - - [Collections](#collections) - [Utility Updates](#utility-updates) - [Troubleshooting](#troubleshooting) - [Glossary](#glossary) @@ -489,9 +490,9 @@ this sub-component when using `FormField`. This component also exists on `FormFi ### Menu Item -**PR: ** [2969](https://github.com/Workday/canvas-kit/pull/2969) +**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 +`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 `Menu.Option` component for menus that have a selected visual state. `Menu.Option` will need more accessibility affordances that depend on the nature of your use of the `Menu` component. For example, `` and `