diff --git a/cypress/integration/Avatar.spec.ts b/cypress/integration/Avatar.spec.ts index fd15abe0b6..787a353e15 100644 --- a/cypress/integration/Avatar.spec.ts +++ b/cypress/integration/Avatar.spec.ts @@ -5,9 +5,9 @@ describe('Avatar', () => { h.stories.visit(); }); - context('given default avatar light is rendered', () => { + context('given default avatar is rendered', () => { beforeEach(() => { - h.stories.load('Components/Indicators/Avatar/Default', 'Light'); + h.stories.load('Components/Indicators/Avatar', 'Basic'); }); it('should not have any axe errors', () => { @@ -17,7 +17,7 @@ describe('Avatar', () => { context('given avatar button light is rendered', () => { beforeEach(() => { - h.stories.load('Components/Indicators/Avatar Button/Default', 'Light'); + h.stories.load('Components/Indicators/Avatar', 'Button'); }); it('should not have any axe errors', () => { @@ -27,7 +27,7 @@ describe('Avatar', () => { context('given avatar button image is rendered', () => { beforeEach(() => { - h.stories.load('Components/Indicators/Avatar/Avatar Button', 'Image'); + h.stories.load('Components/Indicators/Avatar/Avatar', 'Image'); }); it('should not have any axe errors', () => { diff --git a/cypress/integration/SelectPreview.spec.ts b/cypress/integration/SelectPreview.spec.ts deleted file mode 100644 index 353733ceee..0000000000 --- a/cypress/integration/SelectPreview.spec.ts +++ /dev/null @@ -1,964 +0,0 @@ -import * as h from '../helpers'; - -function getAssistiveFocus($menu: JQuery): JQuery { - const activeId = $menu.attr('aria-activedescendant'); - return $menu.find(`[id="${activeId}"]`); -} - -function assertOptionInView($option: JQuery) { - const option = $option[0]; - const $menu = $option.parent(); - const menu = $menu[0]; - - const menuBorderTopWidth = parseInt($menu.css('borderTopWidth'), 10); - - const menuViewTop = menu.scrollTop + menuBorderTopWidth; - const menuViewBottom = menuViewTop + menu.clientHeight; - const optionTop = option.offsetTop; - const optionBottom = optionTop + option.offsetHeight; - - const optionInView = optionTop >= menuViewTop && optionBottom <= menuViewBottom; - - expect(optionInView).to.equal(true); -} - -function assertOptionCenteredInView($option: JQuery) { - const option = $option[0]; - const $menu = $option.parent(); - const menu = $menu[0]; - - const menuBorderTopWidth = parseInt($menu.css('borderTopWidth'), 10); - - const expectedMenuScrollTop = Math.floor( - option.offsetTop - menu.clientHeight / 2 - menuBorderTopWidth + option.clientHeight / 2 - ); - - expect(menu.scrollTop).to.equal(expectedMenuScrollTop); -} - -describe('Select', () => { - before(() => { - h.stories.visit(); - }); - ['Default', 'Alert', 'Error'].forEach(story => { - context(`given the "${story}" story is rendered`, () => { - beforeEach(() => { - h.stories.load('Preview/Select/Top Label', story); - }); - - it('should not have any axe errors', () => { - cy.checkA11y(); - }); - - context('when the select button is clicked', () => { - beforeEach(() => { - cy.findByLabelText('Label').click(); - }); - - it('should not have any axe errors', () => { - cy.checkA11y(); - }); - - context('the select button', () => { - it('should have an aria-expanded attribute set to "true"', () => { - cy.findByLabelText('Label').should('have.attr', 'aria-expanded', 'true'); - }); - }); - - context('the menu', () => { - it('should be visible', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .should('be.visible'); - }); - - it('should have focus', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .should('be.focused'); - }); - - it('should have an aria-activedescendant attribute with the same value as the id of the first option ("E-mail")', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .should($menu => { - const menuAD = $menu.attr('aria-activedescendant'); - const optionId = $menu.find(`[role=option]:eq(0)`).attr('id'); - - expect(menuAD).to.equal(optionId); - }); - }); - - it('should set assistive focus to the first option ("E-mail")', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'E-mail'); - }); - }); - - context('the first option ("Mail")', () => { - it('should have an aria-selected attribute set to "true"', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getOption(0)) - .should('have.attr', 'aria-selected', 'true'); - }); - }); - - context(`when the "Phone" option (with the value "phone") is clicked`, () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getOption('Phone')) - .click(); - }); - - context('the select button', () => { - it(`should read "Phone"`, () => { - cy.findByLabelText('Label').should('have.text', 'Phone'); - }); - - it(`should have a value of "phone"`, () => { - cy.findByLabelText('Label').should('have.value', 'phone'); - }); - - it(`should re-acquire focus`, () => { - cy.findByLabelText('Label').should('be.focused'); - }); - }); - - context('the menu', () => { - it('should not be visible', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .should('not.exist'); - }); - }); - - context('when the menu is opened again', () => { - beforeEach(() => { - cy.findByLabelText('Label').click(); - }); - - context('the menu', () => { - it('should set assistive focus to the "Phone" option', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Phone'); - }); - }); - - context('the "Phone" option', () => { - it('should have an aria-selected attribute set to "true"', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getOption('Phone')) - .should('have.attr', 'aria-selected', 'true'); - }); - }); - }); - }); - }); - - context('when the select button is focused', () => { - beforeEach(() => { - cy.findByLabelText('Label').focus(); - }); - - context('when the down arrow key is pressed', () => { - beforeEach(() => { - cy.focused().realType('{downarrow}'); - }); - - context('the select button', () => { - it('should have an aria-expanded attribute set to "true"', () => { - cy.findByLabelText('Label').should('have.attr', 'aria-expanded', 'true'); - }); - }); - - context('the menu', () => { - it('should be visible', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .should('be.visible'); - }); - - it('should have focus', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .should('be.focused'); - }); - }); - - context('when the down arrow key is pressed for a second time', () => { - beforeEach(() => { - cy.focused().realType('{downarrow}'); - }); - - context('the menu', () => { - it('should set assistive focus to the "Phone" option', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Phone'); - }); - }); - - context('when the down arrow key is pressed for a third time', () => { - beforeEach(() => { - cy.focused().realType('{downarrow}'); - }); - - context('the menu', () => { - it('should set assistive focus to the "Mail" option', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Mail'); - }); - }); - - context('when the enter key is pressed', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .realType('{enter}'); - }); - - context('the select button', () => { - it(`should read "Mail"`, () => { - cy.findByLabelText('Label').should('have.text', 'Mail'); - }); - - it(`should have a value of "mail"`, () => { - cy.findByLabelText('Label').should('have.value', 'mail'); - }); - - it(`should re-acquire focus`, () => { - cy.findByLabelText('Label').should('be.focused'); - }); - }); - - context('the menu', () => { - it('should not be visible', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .should('not.exist'); - }); - }); - - context('when the menu is expanded again', () => { - beforeEach(() => { - cy.focused().realType('{downarrow}'); - }); - - context('the menu', () => { - it('should set assistive focus to the "Mail" option', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Mail'); - }); - }); - - context('the "Mail" option', () => { - it('should have an aria-selected attribute set to "true"', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getOption('Mail')) - .should('have.attr', 'aria-selected', 'true'); - }); - }); - }); - }); - }); - - context('when the up arrow key is pressed', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .realType('{uparrow}'); - }); - - context('the menu', () => { - it('should set assistive focus to the "E-mail" option', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'E-mail'); - }); - }); - }); - }); - }); - - context('when the enter key is pressed', () => { - beforeEach(() => { - cy.findByLabelText('Label').realType('{enter}'); - }); - - context('the select button', () => { - it('should have an aria-expanded attribute set to "true"', () => { - cy.findByLabelText('Label').should('have.attr', 'aria-expanded', 'true'); - }); - }); - }); - - context('when the space key is pressed', () => { - beforeEach(() => { - cy.findByLabelText('Label').type(' ', {force: true}); // disable event.preventDefault checks - }); - - context('the select button', () => { - it('should have an aria-expanded attribute set to "true"', () => { - cy.findByLabelText('Label').should('have.attr', 'aria-expanded', 'true'); - }); - }); - }); - }); - - context('when the "select" helper is used to select "Mail"', () => { - beforeEach(() => { - cy.findByLabelText('Label').pipe(h.selectPreview.select('Mail')); - }); - - it('should have a value of "mail"', () => { - cy.findByLabelText('Label').should('have.value', 'mail'); - }); - }); - - context('when the "select" helper is used to select /^Mail$/', () => { - beforeEach(() => { - cy.findByLabelText('Label').pipe(h.selectPreview.select(/^Mail$/)); - }); - - it('should have a value of "mail"', () => { - cy.findByLabelText('Label').should('have.value', 'mail'); - }); - }); - }); - }); - - context(`given the "Default" story is rendered`, () => { - beforeEach(() => { - h.stories.load('Preview/Select/Top Label', 'Default'); - }); - - context('when the menu is opened', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .focus() - .realType('{downarrow}'); - }); - - context('the menu', () => { - it('should set assistive focus to the first option ("E-mail")', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'E-mail'); - }); - }); - - context('when focus is advanced to the second option ("Phone")', () => { - beforeEach(() => { - cy.focused().realType('{downarrow}'); - }); - - context('the menu', () => { - it('should set assistive focus to the second option ("Phone")', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Phone'); - }); - }); - - context( - 'when the menu is closed WITHOUT selecting the newly focused option ("Phone")', - () => { - beforeEach(() => { - cy.focused().realType('{esc}'); - }); - - context('when the menu is re-opened AFTER it has fully closed', () => { - beforeEach(() => { - // Wait for menu to fully close before we open it again (so we - // don't interrupt the menu's closing animation and cause it to - // re-open while it's in the middle of closing) - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .should('not.exist'); - cy.findByLabelText('Label') - .focus() - .realType('{downarrow}'); - }); - - context('the menu', () => { - it('should have reset assistive focus to the first option ("E-mail")', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'E-mail'); - }); - }); - }); - - context('when the menu is re-opened BEFORE it has fully closed', () => { - beforeEach(() => { - cy.focused().realType('{downarrow}'); - }); - - context('the menu', () => { - it('should still have assistive focus set to the second option ("Phone")', () => { - // Focus is shifting between the button and menu as we close - // and open the menu. It's important that we use getMenu rather - // than cy.focused() to ensure we obtain a reference to the menu. - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Phone'); - }); - }); - }); - } - ); - }); - }); - }); - - context(`given the "Disabled" story is rendered`, () => { - beforeEach(() => { - h.stories.load('Preview/Select/Top Label', 'Disabled'); - }); - - it('should not have any axe errors', () => { - cy.checkA11y(); - }); - - context('the select button', () => { - it('should be disabled', () => { - cy.findByLabelText('Label').should('be.disabled'); - }); - }); - }); - - context('given the "Disabled Options Test" story is rendered', () => { - beforeEach(() => { - h.stories.load('Testing/Preview/Select/Cypress', 'Disabled Options Test'); - }); - - context('when the menu is opened', () => { - beforeEach(() => { - cy.findByLabelText('Label (Disabled Options)') - .focus() - .realType('{downarrow}'); - }); - - context('the "Carrier Pigeon" option', () => { - it('should have an aria-disabled attribute set to "true"', () => { - cy.findByLabelText('Label (Disabled Options)') - .pipe(h.selectPreview.getOption('Carrier Pigeon')) - .should('have.attr', 'aria-disabled', 'true'); - }); - }); - - context('when the down arrow key is pressed', () => { - beforeEach(() => { - cy.focused().realType('{downarrow}'); - }); - - context('the menu', () => { - it('should set assistive focus to first enabled option ("E-mail")', () => { - cy.findByLabelText('Label (Disabled Options)') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'E-mail'); - }); - }); - - context('when the up arrow key is pressed', () => { - beforeEach(() => { - cy.focused().realType('{uparrow}'); - }); - - context('the menu', () => { - it('should retain assistive focus on the "E-mail" option since the previous option ("Carrier Pigeon", which also happens to be the first option) is disabled', () => { - cy.findByLabelText('Label (Disabled Options)') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'E-mail'); - }); - }); - }); - - context('when the down arrow key is pressed 2 more times', () => { - beforeEach(() => { - cy.focused().realType('{downarrow}{downarrow}'); - }); - - context('the menu', () => { - it('should set assistive focus to the third option down ("Mail") since focus will have skipped one disabled option ("Fax")', () => { - cy.findByLabelText('Label (Disabled Options)') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Mail'); - }); - }); - - context('when the down arrow key is pressed 2 more times', () => { - beforeEach(() => { - cy.focused().realType('{downarrow}{downarrow}'); - }); - - context('the menu', () => { - it('should set assistive focus to the first option down ("Mobile Phone") since the second option down ("Telegram", which also happens to be the last option) is disabled', () => { - cy.findByLabelText('Label (Disabled Options)') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Mobile Phone'); - }); - }); - }); - }); - }); - - context('when the Home key is pressed', () => { - beforeEach(() => { - cy.focused().realType('{home}'); - }); - - context('the menu', () => { - it('should set assistive focus to the first enabled option ("E-mail")', () => { - cy.findByLabelText('Label (Disabled Options)') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'E-mail'); - }); - }); - }); - - context('when the End key is pressed', () => { - beforeEach(() => { - cy.focused().realType('{end}'); - }); - - context('the menu', () => { - it('should set assistive focus to the last enabled option ("Mobile Phone")', () => { - cy.findByLabelText('Label (Disabled Options)') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Mobile Phone'); - }); - }); - }); - }); - }); - - context(`given the "Scrollable" story is rendered`, () => { - beforeEach(() => { - h.stories.load('Preview/Select/Top Label', 'Scrollable'); - }); - - context('when the select button is focused', () => { - beforeEach(() => { - cy.findByLabelText('Label').focus(); - }); - - context( - 'when a character is typed (provided no other characters have been typed in the last 500ms), the select should select the first matching option beyond the currently selected option (cycling back to the beginning of the options if necessary)', - () => { - context('when "s" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label').realType('s'); - }); - - context('the select button', () => { - it('should read the first option beginning with "s" ("San Francisco (United States)")', () => { - cy.findByLabelText('Label').should('have.text', 'San Francisco (United States)'); - }); - - it(`should have a value of "san-francisco"`, () => { - cy.findByLabelText('Label').should('have.value', 'san-francisco'); - }); - }); - }); - - context('when "s{500ms delay}s" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label').realType('ss', {delay: 500}); - }); - - context('the select button', () => { - it('should read the second option beginning with "s" ("San Mateo (United States)")', () => { - cy.findByLabelText('Label').should('have.text', 'San Mateo (United States)'); - }); - }); - }); - - context('when "s{500ms delay}d" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label').realType('sd', {delay: 500}); - }); - - context('the select button', () => { - it('should read the first option beginning with "d" ("Dallas (United States)")', () => { - cy.findByLabelText('Label').should('have.text', 'Dallas (United States)'); - }); - }); - }); - } - ); - - context( - 'when multiple characters are typed in rapid succession (<500ms between keystrokes), thus forming a string, and multiple options begin with that string, the select should retain the currently selected option for as long as possible (instead of cycling selection between matching options with each keystroke)', - () => { - context('when "sa" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label').realType('sa'); - }); - - context('the select button', () => { - it('should read "San Francisco (United States)"', () => { - cy.findByLabelText('Label').should('have.text', 'San Francisco (United States)'); - }); - }); - }); - - context('when "san " is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label').realType('san '); - }); - - context('the select button', () => { - it('should read "San Francisco (United States)"', () => { - cy.findByLabelText('Label').should('have.text', 'San Francisco (United States)'); - }); - }); - }); - - context('when "san m" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label').realType('san m'); - }); - - context('the select button', () => { - it('should read "San Mateo (United States)"', () => { - cy.findByLabelText('Label').should('have.text', 'San Mateo (United States)'); - }); - }); - }); - } - ); - - // TODO: Figure out why this test doesn't open the menu when the - // space key is pressed when using Firefox with Cypress (pressing - // the space key in the middle of a typeahead string in normal - // usage of Firefox opens the menu, see SelectBase) - // Ensure Firefox doesn't display the menu if there's a space in the - // typeahead string - // context('when "san " is typed', () => { - // beforeEach(() => { - // cy.findByLabelText('Label').realType('san '); - // }); - - // context('the menu', () => { - // it('should not be visible', () => { - // cy.findByLabelText('Label') - // .pipe(h.selectPreview.getMenu) - // .should('not.exist'); - // }); - // }); - // }); - }); - - context('when the menu is opened', () => { - beforeEach(() => { - cy.findByLabelText('Label').click(); - }); - - context( - 'when a character is typed (provided no other characters have been typed in the last 500ms), the select should advance assistive focus to the first matching option beyond the currently selected option (cycling back to the beginning of the options if necessary) and scroll that option into view', - () => { - context('when "s" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .realType('s'); - }); - - context('the menu', () => { - it('should set assistive focus to the first option beginning with "s" ("San Francisco (United States)")', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'San Francisco (United States)'); - }); - - it('should scroll so that the "San Francisco (United States)" option is fully visible', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should(assertOptionInView); - }); - }); - }); - - context('when "s{500ms delay}s" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .realType('ss', {delay: 500}); - }); - - context('the menu', () => { - it('should set assistive focus to the second option beginning with "s" ("San Mateo (United States)")', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'San Mateo (United States)'); - }); - - it('should scroll so that the "San Mateo (United States)" option is fully visible', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should(assertOptionInView); - }); - }); - }); - - context('when "s{500ms delay}d" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .realType('sd', {delay: 500}); - }); - - context('the menu', () => { - it('should set assistive focus to the first option beginning with "d" ("Dallas (United States)")', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'Dallas (United States)'); - }); - - it('should scroll so that the "Dallas (United States)" option is fully visible', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should(assertOptionInView); - }); - }); - }); - - context('when "the onto" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .realType('the onto'); - }); - - context('the menu', () => { - it('should set assistive focus to "The Ontologically..."', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should( - 'have.text', - 'The Ontologically Anthropocentric Sensory Immersive Simulation (Virtual Reality)' - ); - }); - - it('should scroll so that the "The Ontologically..." (text wrapped) option is fully visible', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should(assertOptionInView); - }); - }); - }); - } - ); - - context( - 'when multiple characters are typed in rapid succession (<500ms between keystrokes), thus forming a string, and multiple options begin with that string, the select should retain assistive focus on the currently focused option for as long as possible (instead of cycling focus between matching options with each keystroke)', - () => { - context('when "sa" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .realType('sa'); - }); - - context('the menu', () => { - it('should set assistive focus to the "San Francisco (United States)" option', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'San Francisco (United States)'); - }); - }); - }); - - context('when "san " is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .realType('san '); - }); - - context('the menu', () => { - it('should set assistive focus to the "San Francisco (United States)" option', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'San Francisco (United States)'); - }); - }); - }); - - context('when "san m" is typed', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .realType('san m'); - }); - - context('the menu', () => { - it('should set assistive focus to the "San Mateo (United States)" option', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should('have.text', 'San Mateo (United States)'); - }); - }); - }); - } - ); - }); - - context( - 'when the menu is opened and the selected option is initially out of view, the menu should scroll the selected option into view and center it if possible', - () => { - context('when "Dallas (United States)" is selected and the menu is opened', () => { - beforeEach(() => { - cy.findByLabelText('Label') - .focus() - .type('d') - .click(); - }); - - context('the menu', () => { - it('should scroll so that the "Dallas (United States)" option is centered in view', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should(assertOptionCenteredInView); - }); - }); - }); - - context( - 'when "The Ontologically..." (text wrapped) is selected and the menu is opened', - () => { - beforeEach(() => { - cy.findByLabelText('Label') - .focus() - .type('the onto') - .click(); - }); - - context('the menu', () => { - it('should scroll so that the "The Ontologically..." option is centered in view', () => { - cy.findByLabelText('Label') - .pipe(h.selectPreview.getMenu) - .pipe(getAssistiveFocus) - .should(assertOptionCenteredInView); - }); - }); - } - ); - } - ); - }); - - context(`given the "Portal Test" story is rendered`, () => { - beforeEach(() => { - h.stories.load('Testing/Preview/Select/Cypress', 'Portal Test'); - }); - - context('when the page is scrolled to the bottom', () => { - beforeEach(() => { - cy.scrollTo('bottom'); - cy.window() - .its('scrollY') - .as('originalWindowScrollY'); - }); - - context('when the bottommost select button is clicked', () => { - beforeEach(() => { - cy.findByLabelText('Label (Bottom)').click(); - }); - - context('the page', () => { - it('should not scroll', () => { - cy.window().then($window => { - cy.get('@originalWindowScrollY').should('equal', Math.floor($window.scrollY)); - }); - }); - }); - }); - - context( - `when the blur test button is clicked and then the bottommost select button (which is re-rendered by the test button's blur handler) is clicked`, - () => { - beforeEach(() => { - cy.findByTestId('blur-test-button').click(); - cy.findByLabelText('Label (Bottom)').click(); - }); - - context('the page', () => { - it('should not scroll', () => { - cy.window().then($window => { - cy.get('@originalWindowScrollY').should('equal', Math.floor($window.scrollY)); - }); - }); - }); - } - ); - }); - }); - - context(`given the "Accessibility Test" story is rendered`, () => { - beforeEach(() => { - h.stories.load('Testing/Preview/Select/Cypress', 'Accessibility Test'); - }); - - context('when the select button with aria-required set to true is clicked', () => { - beforeEach(() => { - cy.findByLabelText(/Label \(aria-required\)/).click(); - }); - - context('the menu', () => { - it('should have an aria-required attribute set to "true"', () => { - cy.findByLabelText(/Label \(aria-required\)/) - .pipe(h.selectPreview.getMenu) - .should('have.attr', 'aria-required', 'true'); - }); - }); - }); - - context('when the select button with required set to true is clicked', () => { - beforeEach(() => { - cy.findByLabelText(/Label \(required\)/).click(); - }); - - context('the menu', () => { - it('should have an aria-required attribute set to "true"', () => { - cy.findByLabelText(/Label \(required\)/) - .pipe(h.selectPreview.getMenu) - .should('have.attr', 'aria-required', 'true'); - }); - }); - }); - }); -}); diff --git a/modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx b/modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx new file mode 100644 index 0000000000..37ebc92973 --- /dev/null +++ b/modules/docs/mdx/12.0-UPGRADE-GUIDE.mdx @@ -0,0 +1,207 @@ +import {Meta} from '@storybook/addon-docs'; +import {Table} from '@workday/canvas-kit-react/table'; +import {base, brand, system} from '@workday/canvas-tokens-web'; +import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator'; +import {cssVar} from '@workday/canvas-kit-styling'; +import {Box} from '@workday/canvas-kit-react/layout'; + + + +# Canvas Kit 12.0 Upgrade Guide + +This guide contains an overview of the changes in Canvas Kit v12. Please +[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have +any questions. + +## Why You Should Upgrade + +Canvas Kit v12 is transitioning into a +[new way of styling](https://github.com/Workday/canvas-kit/discussions/2265). Theming and building +an in sync Canvas Kit CSS has been at the top of our minds. We've started using our new +[Canvas Tokens Web](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs) +package to take advantage of +[CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) and +provide semantic tokens that can translate to theming components. + +A note to the reader: + +- While we still support our old tokens from `@workday/canvas-kit-react/tokens` in v12, you must + install our new tokens from `@workday/canvas-tokens-web`. You can find more info in our + [docs](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs). +- In this release, we've introduced a + [new styling API](https://workday.github.io/canvas-kit/?path=/docs/styling-basics--create-stencil). + This shouldn't effect the way you currently style your components. Because we're moving away from + Emotion, support for style props will eventually be removed, however, this API provide backwards + compatability. If you want to slowly move off of Emotion as well, you can start styling components + via the `cs` prop or our new styling utilities. + +## Table of contents + +- [Canvas Tokens](#canvas-tokens) +- [Codemod](#codemod) +- [Deprecations](#deprecations) +- [Removals](#removals) + - [InputIconContainer](#inputiconcontainer) + - [Select (Preview)](#select-preview) +- [Component Updates](#component-updates) + - [Styling API and CSS Tokens](#styling-api-and-css-tokens) + - [Avatar](#avatar) + - [Text Area](#text-area) +- [Troubleshooting](#troubleshooting) +- [Glossary](#glossary) + - [Main](#main) + - [Preview](#preview) + - [Labs](#labs) + +## Canvas Tokens + +In v12, all the components listed in this guide have started using our new +[Canvas Tokens Web](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs). + +In v12 you must add `@workday/canvas-tokens-web` to ensure our components are properly styled and +the variables are defined. For more information on installing and using, please reference our tokens +[docs](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs). + +## Deprecations + +We add the [@deprecated](https://jsdoc.app/tags-deprecated.html) JSDoc tag to code we plan to remove +in a future major release. This signals consumers to migrate to a more stable alternative before the +deprecated code is removed. + +## Removals + +Removals are deletions from our codebase and you can no longer consume this component. We've either +promoted or replaced a component or utility. + +### Select (Preview) + +**PR:** [#2796](https://github.com/Workday/canvas-kit/pull/2796) + +We've removed the `Select` component that was in Preview. Please use the compound +[Select component from Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--basic). + +### InputIconContainer + +**PR:** [#2838](https://github.com/Workday/canvas-kit/pull/2838) + +We've removed `InputIconContainer` from Main. Please use +[InputGroup](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--icons) +from Main instead. + +--- + +## Component Updates + +### Styling API and CSS Tokens + +**PRs:** [#2825](https://github.com/Workday/canvas-kit/pull/2825), +[#2795](https://github.com/Workday/canvas-kit/pull/2795), +[#2793](https://github.com/Workday/canvas-kit/pull/2793) + +Several components have been refactored to use our new +[Canvas Tokens](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs) and +[styling API](https://workday.github.io/canvas-kit/?path=/docs/styling-basics--create-modifiers#createstyles-api). +The React interface **has not changed**, but CSS variables are now used for dynamic properties. + +The following components are affected: + +- `Avatar` +- `Dialog` +- `Modal` +- `Popup` +- `TextArea` +- `TextInput` +- `Toast` + +> **Note:** These components also support our new `cs` prop for styling. Learn more about styling +> with `cs` in our +> [documentation](https://workday.github.io/canvas-kit/?path=/docs/styling-basics--cs-prop). + +### Avatar + +- Avatar no longer uses `SystemIconCircle` for sizing. +- `Avatar.Size` is no longer supported. The `size` prop type has change to accept the following: + `"extraExtraLarge" | "extraLarge" | "large" | "medium" | "small" | "extraSmall" | (string{})` +- `Avatar.Variant` is no longer supported. Enum `AvatarVariant` has been removed. The `variant` type + prop now accepts `"dark" | "light"` +- The `as` prop now accepts any element, not just `div`. + +### Text Area + +**PR:** [#2825](https://github.com/Workday/canvas-kit/pull/2825) + +`TextAreaResizeDirection` is no longer a TypeScript enum, but a JavaScript object. This change does +not effect runtime at all, but may cause TypeScript errors if you use `TextAreaResizeDirection` as a +type. + +```tsx +// v11 +interface MyProps { resize?: TextAreaResizeDirection } + +// 12 type ValueOf = T[keyof T]; interface MyProps { resize?: +ValueOf } +``` + +## Troubleshooting + +### My Styles Seem Broken? + +Our components are reliant on our new Canvas Tokens Web package. Be sure you install +`@workday/canvas-tokens-web`. For more information, reference our +[Getting Started docs](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs) +for this package. + +### Did You Upgrade All Canvas Kit Related Packages? + +In order for all the packages to work in harmony, you must upgrade all Canvas Kit packages to the +same version that you're using, including: + +- `@workday/canvas-kit-react` +- `@workday/canvas-kit-preview-react` +- `@workday/canvas-kit-labs-react` +- `@workday/canvas-kit-styling` +- `@workday/canvas-kit-react-fonts` +- `@workday/canvas-kit-docs` + +## Glossary + +### Main + +Our Main package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-react` has +undergone a full design and a11y review and is approved for use in product. + +Breaking changes to code in Main will only occur during major version updates and will always be +communicated in advance and accompanied by migration strategies. + +--- + +### Preview + +Our Preview package of Canvas Kit tokens, components, and utilities at +`@workday/canvas-kit-preview-react` has undergone a full design and a11y review and is approved for +use in product, but may not be up to the high code standards upheld in the [Main](#main) package. +Preview is analagous to code in beta. + +Breaking changes are unlikely, but possible, and can be deployed to Preview at any time without +triggering a major version update, though such changes will be communicated in advance and +accompanied by migration strategies. + +Generally speaking, our goal is to eventually promote code from Preview to [Main](#main). +Occasionally, a component with the same name will exist in both [Main](#main) and Preview (for +example, see Segmented Control in [Preview](/components/buttons/segmented-control/) and +[Main](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/components-buttons-segmented-control--basic)). +In these cases, Preview serves as a staging ground for an improved version of the component with a +different API. The component in [Main](#main) will eventually be replaced with the one in Preview. + +--- + +### Labs + +Our Labs package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-labs-react` +has **not** undergone a full design and a11y review. Labs serves as an incubator space for new and +experimental code and is analagous to code in alpha. + +Breaking changes can be deployed to Labs at any time without triggering a major version update and +may not be subject to the same rigor in communcation and migration strategies reserved for breaking +changes in [Preview](#preview) and [Main](#main). import { opacity } from +"@workday/canvas-tokens-web/dist/es6/system" diff --git a/modules/labs-react/expandable/lib/ExpandableAvatar.tsx b/modules/labs-react/expandable/lib/ExpandableAvatar.tsx index d1c867aa4f..7ef10c871f 100644 --- a/modules/labs-react/expandable/lib/ExpandableAvatar.tsx +++ b/modules/labs-react/expandable/lib/ExpandableAvatar.tsx @@ -21,6 +21,6 @@ const StyledAvatar = styled(Avatar)({ export const ExpandableAvatar = createComponent('button')({ displayName: 'Expandable.Avatar', Component: ({altText, ...elemProps}: ExpandableAvatarProps, ref) => { - return ; + return ; }, }); diff --git a/modules/preview-react/index.ts b/modules/preview-react/index.ts index d0a5f54083..3388de841d 100644 --- a/modules/preview-react/index.ts +++ b/modules/preview-react/index.ts @@ -6,7 +6,6 @@ export * from './menu'; export * from './pill'; export * from './radio'; export * from './segmented-control'; -export * from './select'; export * from './side-panel'; export * from './status-indicator'; export * from './text-area'; diff --git a/modules/preview-react/pill/lib/PillAvatar.tsx b/modules/preview-react/pill/lib/PillAvatar.tsx index ebd9e05866..d309c60ead 100644 --- a/modules/preview-react/pill/lib/PillAvatar.tsx +++ b/modules/preview-react/pill/lib/PillAvatar.tsx @@ -3,25 +3,23 @@ import React from 'react'; import {createSubcomponent} from '@workday/canvas-kit-react/common'; import {Avatar, AvatarProps} from '@workday/canvas-kit-react/avatar'; import {usePillModel} from './usePillModel'; +import {px2rem} from '@workday/canvas-kit-styling'; export interface PillAvatarProps extends AvatarProps {} // When the component is created, it needs to be a button element to match AvatarProps. // Once Avatar becomes a `createComponent` we can default the element type to a `div` // and the types should be properly extracted -export const PillAvatar = createSubcomponent('button')({ +export const PillAvatar = createSubcomponent('div')({ modelHook: usePillModel, -})((elemProps, Element, model) => { +})(({...elemProps}: PillAvatarProps, Element, model) => { return ( - {elemProps.children} - + > ); }); diff --git a/modules/preview-react/select/LICENSE b/modules/preview-react/select/LICENSE deleted file mode 100644 index 5bcbbab3b9..0000000000 --- a/modules/preview-react/select/LICENSE +++ /dev/null @@ -1,51 +0,0 @@ -Apache License, Version 2.0 Apache License Version 2.0, January 2004 - -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. -Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. -Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. -You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: -You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. -Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. -This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. -Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. -In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. -While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -©2020. Workday, Inc. All rights reserved. Workday and the Workday logo are registered trademarks of Workday, Inc. All other brand and product names are trademarks or registered trademarks of their respective holders. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/modules/preview-react/select/README.md b/modules/preview-react/select/README.md deleted file mode 100644 index dc196ee7e1..0000000000 --- a/modules/preview-react/select/README.md +++ /dev/null @@ -1,236 +0,0 @@ -# Canvas Kit Select (with Canvas-styled Menu) - - - PREVIEW: Beta - This component is in Preview because it has not been converted to a [Compound Component](../../docs/mdx/COMPOUND_COMPONENTS.mdx) yet. - -A Canvas-styled Select with a Canvas-styled menu. This is a -[_controlled_](https://reactjs.org/docs/forms.html#controlled-components) component. - -Undocumented props (`disabled`, `name`, etc.) should behave similarly to how you would expect from a -standard `; -} -``` - -#### Accessible Example - -```tsx -import * as React from 'react'; -import {Select} from '@workday/canvas-kit-preview-react/select'; -import {FormField} from '@workday/canvas-kit-react/form-field'; - -function Example() { - const options = [ - {label: 'E-mail', value: 'email'}, - {label: 'Phone', value: 'phone'}, - {label: 'Fax (disabled)', value: 'fax', disabled: true}, - {label: 'Mail', value: 'mail'}, - ]; - - const [value, setValue] = React.useState('email'); - - const handleChange = event => { - setValue(event.currentTarget.value); - }; - - return ( - - - - ); -} -``` - -#### Example with Custom Options Data - -Each option in `options` may contain a `data` object with any number of key/value pairs. This `data` -object is carried over to the `option` passed into the `renderOption` function where it may then be -used to customize how each option is rendered. - -```tsx -import * as React from 'react'; -import {Select} from '@workday/canvas-kit-preview-react/select'; -import {FormField} from '@workday/canvas-kit-react/form-field'; -import {colors, typeColors} from '@workday/canvas-kit-react/tokens'; -import { - activityStreamIcon, - avatarIcon, - uploadCloudIcon, - userIcon, -} from '@workday/canvas-system-icons-web'; -import {SystemIcon} from '@workday/canvas-kit-react/icon'; - -function Example() { - const options = [ - {value: 'Activity Stream', data: {icon: activityStreamIcon}}, - {value: 'Avatar', data: {icon: avatarIcon}}, - {value: 'Upload Cloud', data: {icon: uploadCloudIcon}}, - {value: 'User', data: {icon: userIcon}}, - ]; - - const renderOption = option => { - const iconColor = option.focused ? typeColors.inverse : colors.blackPepper100; - return ( -
- -
{option.value}
-
- ); - }; - - const [value, setValue] = React.useState('Activity Stream'); - - const handleChange = event => { - setValue(event.currentTarget.value); - }; - - return ( - - -``` - -## Component Props - -### Required - -#### `options: (Option | string)[]` - -> The options of the Select. `options` may be an array of objects or an array of strings. -> -> If `options` is an array of objects, each object must adhere to the `Option` interface: -> -> - `data: object` (optional) -> - `disabled: boolean` (optional) -> - `id: string` (optional, a random `id` will be assigned to the object if one isn't provided) -> - `label: string` (optional, analagous to the text content of an `