@openedx/paragon 22.6.0 → 23.0.0-alpha.2
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/README.md +61 -21
- package/bin/paragon-scripts.js +128 -9
- package/dist/ActionRow/_index.scss +2 -4
- package/dist/Alert/index.scss +41 -32
- package/dist/Annotation/_mixins.scss +104 -0
- package/dist/Annotation/index.scss +130 -103
- package/dist/Avatar/index.scss +18 -20
- package/dist/AvatarButton/index.scss +3 -5
- package/dist/Badge/index.scss +112 -2
- package/dist/Breadcrumb/index.scss +14 -16
- package/dist/Bubble/index.scss +25 -12
- package/dist/Button/_mixins.scss +14 -0
- package/dist/Button/button-group.scss +126 -0
- package/dist/Button/index.js +15 -40
- package/dist/Button/index.js.map +1 -1
- package/dist/Button/index.scss +855 -372
- package/dist/Card/card-bootstrap.scss +168 -0
- package/dist/Card/index.scss +78 -79
- package/dist/Carousel/index.scss +168 -2
- package/dist/Chip/ChipIcon.d.ts +2 -2
- package/dist/Chip/ChipIcon.js.map +1 -1
- package/dist/Chip/index.d.ts +2 -2
- package/dist/Chip/index.js +2 -2
- package/dist/Chip/index.js.map +1 -1
- package/dist/Chip/index.scss +48 -38
- package/dist/Chip/mixins.scss +8 -3
- package/dist/ChipCarousel/index.scss +4 -4
- package/dist/CloseButton/index.scss +31 -2
- package/dist/Code/index.scss +47 -2
- package/dist/Collapsible/index.scss +15 -15
- package/dist/ColorPicker/index.scss +9 -11
- package/dist/DataTable/CollapsibleButtonGroup.js +2 -2
- package/dist/DataTable/CollapsibleButtonGroup.js.map +1 -1
- package/dist/DataTable/index.scss +48 -50
- package/dist/Dropdown/dropdown-bootstrap.scss +181 -0
- package/dist/Dropdown/index.js +0 -2
- package/dist/Dropdown/index.js.map +1 -1
- package/dist/Dropdown/index.scss +11 -12
- package/dist/Dropzone/index.scss +12 -14
- package/dist/Form/_FormText.scss +8 -8
- package/dist/Form/_bootstrap-custom-forms.scss +551 -0
- package/dist/Form/_bootstrap-forms.scss +381 -0
- package/dist/Form/_index.scss +168 -146
- package/dist/Form/_input-group.scss +188 -0
- package/dist/Form/_mixins.scss +216 -3
- package/dist/Hyperlink/index.js +32 -20
- package/dist/Hyperlink/index.js.map +1 -1
- package/dist/Hyperlink/index.scss +1 -1
- package/dist/Icon/index.d.ts +2 -4
- package/dist/Icon/index.js +1 -1
- package/dist/Icon/index.js.map +1 -1
- package/dist/Icon/index.scss +10 -12
- package/dist/IconButton/_mixins.scss +4 -0
- package/dist/IconButton/index.js +5 -11
- package/dist/IconButton/index.js.map +1 -1
- package/dist/IconButton/index.scss +387 -74
- package/dist/IconButtonToggle/index.scss +1 -1
- package/dist/Image/index.scss +53 -2
- package/dist/Menu/index.scss +25 -27
- package/dist/Modal/_ModalDialog.scss +52 -54
- package/dist/Modal/index.scss +6 -73
- package/dist/Nav/_mixins.scss +4 -4
- package/dist/Nav/index.scss +70 -66
- package/dist/Navbar/index.scss +276 -2
- package/dist/OverflowScroll/data/useOverflowScrollElementAttributes.js +3 -3
- package/dist/Overlay/index.js +2 -3
- package/dist/Overlay/index.js.map +1 -1
- package/dist/PageBanner/index.scss +17 -21
- package/dist/Pagination/index.scss +32 -34
- package/dist/Pagination/pagination-bootstrap.scss +83 -0
- package/dist/Popover/index.scss +9 -10
- package/dist/Popover/popover-bootstrap.scss +198 -0
- package/dist/ProductTour/Checkpoint.scss +71 -43
- package/dist/ProgressBar/_mixins.scss +22 -0
- package/dist/ProgressBar/bootstrap-progress.scss +49 -0
- package/dist/ProgressBar/index.scss +28 -36
- package/dist/Scrollable/index.scss +2 -2
- package/dist/SearchField/SearchFieldInput.js +2 -2
- package/dist/SearchField/SearchFieldInput.js.map +1 -1
- package/dist/SearchField/index.scss +15 -17
- package/dist/SelectableBox/index.scss +11 -13
- package/dist/Sheet/index.scss +10 -10
- package/dist/Spinner/index.scss +57 -2
- package/dist/Stack/index.scss +1 -3
- package/dist/Stepper/index.scss +20 -20
- package/dist/Sticky/index.scss +4 -6
- package/dist/Tabs/index.js +0 -2
- package/dist/Tabs/index.js.map +1 -1
- package/dist/Tabs/index.scss +29 -25
- package/dist/Toast/ToastContainer.scss +9 -11
- package/dist/Toast/bootstrap-toast.scss +46 -0
- package/dist/Toast/index.scss +9 -10
- package/dist/Tooltip/index.scss +136 -10
- package/dist/ValidationMessage/index.scss +1 -1
- package/dist/core.css +16777 -0
- package/dist/core.css.map +1 -0
- package/dist/core.min.css +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -18
- package/dist/index.scss +0 -4
- package/dist/light.css +4098 -0
- package/dist/light.css.map +1 -0
- package/dist/light.min.css +2 -0
- package/dist/theme-urls.json +21 -0
- package/dist/utils/breakpoints.js +1 -1
- package/lib/build-scss.js +188 -0
- package/lib/build-tokens.js +133 -0
- package/lib/help.js +36 -23
- package/lib/replace-variables.js +38 -0
- package/lib/utils.js +30 -0
- package/package.json +30 -14
- package/src/ActionRow/_index.scss +2 -4
- package/src/Alert/index.scss +41 -32
- package/src/Annotation/_mixins.scss +104 -0
- package/src/Annotation/index.scss +130 -103
- package/src/Avatar/index.scss +18 -20
- package/src/AvatarButton/index.scss +3 -5
- package/src/Badge/index.scss +112 -2
- package/src/Breadcrumb/index.scss +14 -16
- package/src/Bubble/index.scss +25 -12
- package/src/Button/{Button.test.tsx → Button.test.jsx} +2 -14
- package/src/Button/README.md +0 -84
- package/src/Button/__snapshots__/{Button.test.tsx.snap → Button.test.jsx.snap} +2 -19
- package/src/Button/_mixins.scss +14 -0
- package/src/Button/button-group.scss +126 -0
- package/src/Button/index.jsx +113 -0
- package/src/Button/index.scss +855 -372
- package/src/Card/card-bootstrap.scss +168 -0
- package/src/Card/index.scss +78 -79
- package/src/Carousel/index.scss +168 -2
- package/src/Chip/ChipIcon.tsx +1 -1
- package/src/Chip/index.scss +48 -38
- package/src/Chip/index.tsx +5 -5
- package/src/Chip/mixins.scss +8 -3
- package/src/ChipCarousel/index.scss +4 -4
- package/src/CloseButton/index.scss +31 -2
- package/src/Code/index.scss +47 -2
- package/src/Collapsible/index.scss +15 -15
- package/src/ColorPicker/index.scss +9 -11
- package/src/DataTable/CollapsibleButtonGroup.jsx +2 -2
- package/src/DataTable/index.scss +48 -50
- package/src/Dropdown/README.md +0 -93
- package/src/Dropdown/dropdown-bootstrap.scss +181 -0
- package/src/Dropdown/index.jsx +0 -2
- package/src/Dropdown/index.scss +11 -12
- package/src/Dropzone/index.scss +12 -14
- package/src/Form/_FormText.scss +8 -8
- package/src/Form/_bootstrap-custom-forms.scss +551 -0
- package/src/Form/_bootstrap-forms.scss +381 -0
- package/src/Form/_index.scss +168 -146
- package/src/Form/_input-group.scss +188 -0
- package/src/Form/_mixins.scss +216 -3
- package/src/Hyperlink/{Hyperlink.test.tsx → Hyperlink.test.jsx} +10 -21
- package/src/Hyperlink/{index.tsx → index.jsx} +37 -41
- package/src/Hyperlink/index.scss +1 -1
- package/src/Icon/index.d.ts +2 -4
- package/src/Icon/index.jsx +1 -1
- package/src/Icon/index.scss +10 -12
- package/src/IconButton/README.md +1 -15
- package/src/IconButton/__snapshots__/IconButton.test.jsx.snap +5 -28
- package/src/IconButton/_mixins.scss +4 -0
- package/src/IconButton/index.jsx +6 -13
- package/src/IconButton/index.scss +387 -74
- package/src/IconButtonToggle/index.scss +1 -1
- package/src/Image/index.scss +53 -2
- package/src/Menu/index.scss +25 -27
- package/src/Modal/_ModalDialog.scss +52 -54
- package/src/Modal/index.scss +6 -73
- package/src/Nav/_mixins.scss +4 -4
- package/src/Nav/index.scss +70 -66
- package/src/Navbar/index.scss +276 -2
- package/src/OverflowScroll/data/useOverflowScrollElementAttributes.js +3 -3
- package/src/Overlay/index.jsx +2 -3
- package/src/PageBanner/index.scss +17 -21
- package/src/Pagination/index.scss +32 -34
- package/src/Pagination/pagination-bootstrap.scss +83 -0
- package/src/Popover/index.scss +9 -10
- package/src/Popover/popover-bootstrap.scss +198 -0
- package/src/ProductTour/Checkpoint.scss +71 -43
- package/src/ProgressBar/_mixins.scss +22 -0
- package/src/ProgressBar/bootstrap-progress.scss +49 -0
- package/src/ProgressBar/index.scss +28 -36
- package/src/Scrollable/index.scss +2 -2
- package/src/SearchField/SearchFieldInput.jsx +2 -2
- package/src/SearchField/__snapshots__/SearchField.test.jsx.snap +12 -8
- package/src/SearchField/index.scss +15 -17
- package/src/SelectableBox/index.scss +11 -13
- package/src/Sheet/index.scss +10 -10
- package/src/Spinner/index.scss +57 -2
- package/src/Stack/index.scss +1 -3
- package/src/Stepper/index.scss +20 -20
- package/src/Sticky/index.scss +4 -6
- package/src/Tabs/README.md +1 -23
- package/src/Tabs/index.jsx +0 -3
- package/src/Tabs/index.scss +29 -25
- package/src/Toast/ToastContainer.scss +9 -11
- package/src/Toast/bootstrap-toast.scss +46 -0
- package/src/Toast/index.scss +9 -10
- package/src/Tooltip/index.scss +136 -10
- package/src/TransitionReplace/README.md +4 -4
- package/src/ValidationMessage/index.scss +1 -1
- package/src/index.d.ts +2 -2
- package/src/index.js +4 -18
- package/src/index.scss +0 -4
- package/src/{setupTest.ts → setupTest.js} +0 -7
- package/src/utils/breakpoints.js +1 -1
- package/styles/css/core/custom-media-breakpoints.css +17 -0
- package/styles/css/core/index.css +2 -0
- package/styles/css/core/variables.css +603 -0
- package/styles/css/themes/light/index.css +2 -0
- package/styles/css/themes/light/utility-classes.css +2454 -0
- package/styles/css/themes/light/variables.css +1644 -0
- package/{scss → styles/scss}/core/_functions.scss +1 -1
- package/styles/scss/core/_grid.scss +21 -0
- package/{scss → styles/scss}/core/_utilities.scss +17 -11
- package/styles/scss/core/_variables.scss +868 -0
- package/styles/scss/core/bootstrap-override/_functions.scss +104 -0
- package/styles/scss/core/bootstrap-override/_mixins.scss +4 -0
- package/styles/scss/core/bootstrap-override/_utilities.scss +4 -0
- package/styles/scss/core/bootstrap-override/bootstrap.scss +2 -0
- package/styles/scss/core/bootstrap-override/mixins/_grid-framework.scss +80 -0
- package/styles/scss/core/bootstrap-override/mixins/_grid.scss +69 -0
- package/styles/scss/core/bootstrap-override/mixins/_list-group.scss +22 -0
- package/styles/scss/core/bootstrap-override/utilities/_background.scss +7 -0
- package/styles/scss/core/bootstrap-override/utilities/_borders.scss +67 -0
- package/styles/scss/core/bootstrap-override/utilities/_spacing.scss +70 -0
- package/styles/scss/core/bootstrap-override/utilities/_text.scss +68 -0
- package/styles/scss/core/core.scss +21 -0
- package/{scss → styles/scss}/core/utilities-only.scss +1 -0
- package/tokens/README.md +157 -0
- package/tokens/css-utilities.js +56 -0
- package/tokens/map-scss-to-css.js +24 -0
- package/tokens/replace-variables.js +32 -0
- package/tokens/sass-helpers.js +98 -0
- package/tokens/src/core/alias/size.json +15 -0
- package/tokens/src/core/components/ActionRow.json +10 -0
- package/tokens/src/core/components/Alert.json +30 -0
- package/tokens/src/core/components/Annotation.json +25 -0
- package/tokens/src/core/components/Avatar.json +17 -0
- package/tokens/src/core/components/AvatarButton.json +11 -0
- package/tokens/src/core/components/Badge.json +33 -0
- package/tokens/src/core/components/Breadcrumb.json +23 -0
- package/tokens/src/core/components/Bubble.json +10 -0
- package/tokens/src/core/components/Button/core.json +105 -0
- package/tokens/src/core/components/Card.json +96 -0
- package/tokens/src/core/components/Carousel.json +37 -0
- package/tokens/src/core/components/Chip.json +41 -0
- package/tokens/src/core/components/ChipCarousel.json +15 -0
- package/tokens/src/core/components/CloseButton.json +14 -0
- package/tokens/src/core/components/Code.json +34 -0
- package/tokens/src/core/components/Collapsible.json +29 -0
- package/tokens/src/core/components/ColorPicker.json +8 -0
- package/tokens/src/core/components/Container.json +13 -0
- package/tokens/src/core/components/DataTable.json +27 -0
- package/tokens/src/core/components/Dropdown.json +67 -0
- package/tokens/src/core/components/Dropzone.json +21 -0
- package/tokens/src/core/components/Form/other.json +14 -0
- package/tokens/src/core/components/Form/size.json +229 -0
- package/tokens/src/core/components/Form/spacing.json +155 -0
- package/tokens/src/core/components/Form/transition.json +16 -0
- package/tokens/src/core/components/Form/typography.json +122 -0
- package/tokens/src/core/components/Icon.json +11 -0
- package/tokens/src/core/components/IconButton.json +15 -0
- package/tokens/src/core/components/Image.json +28 -0
- package/tokens/src/core/components/Menu.json +48 -0
- package/tokens/src/core/components/Modal.json +47 -0
- package/tokens/src/core/components/Nav.json +52 -0
- package/tokens/src/core/components/Navbar.json +70 -0
- package/tokens/src/core/components/Pagination.json +66 -0
- package/tokens/src/core/components/Popover.json +48 -0
- package/tokens/src/core/components/ProductTour.json +32 -0
- package/tokens/src/core/components/ProgressBar.json +39 -0
- package/tokens/src/core/components/SearchField.json +23 -0
- package/tokens/src/core/components/SelectableBox.json +9 -0
- package/tokens/src/core/components/Sheet.json +10 -0
- package/tokens/src/core/components/Spinner.json +19 -0
- package/tokens/src/core/components/Stack.json +7 -0
- package/tokens/src/core/components/Stepper.json +42 -0
- package/tokens/src/core/components/Sticky.json +7 -0
- package/tokens/src/core/components/Tab.json +19 -0
- package/tokens/src/core/components/Tabs.json +19 -0
- package/tokens/src/core/components/Toast.json +30 -0
- package/tokens/src/core/components/Tooltip.json +33 -0
- package/tokens/src/core/components/general/caret.json +13 -0
- package/tokens/src/core/components/general/headings.json +16 -0
- package/tokens/src/core/components/general/hr.json +10 -0
- package/tokens/src/core/components/general/input.json +51 -0
- package/tokens/src/core/components/general/link.json +30 -0
- package/tokens/src/core/components/general/list.json +26 -0
- package/tokens/src/core/components/general/text.json +24 -0
- package/tokens/src/core/global/breakpoints.json +12 -0
- package/tokens/src/core/global/display.json +22 -0
- package/tokens/src/core/global/elevation.json +19 -0
- package/tokens/src/core/global/other.json +4 -0
- package/tokens/src/core/global/spacing.json +37 -0
- package/tokens/src/core/global/transition.json +14 -0
- package/tokens/src/core/global/typography.json +91 -0
- package/tokens/src/core/utilities/color.json +12 -0
- package/tokens/src/themes/light/alias/color.json +114 -0
- package/tokens/src/themes/light/components/Alert.json +38 -0
- package/tokens/src/themes/light/components/Annotation.json +29 -0
- package/tokens/src/themes/light/components/Avatar.json +7 -0
- package/tokens/src/themes/light/components/Badge.json +186 -0
- package/tokens/src/themes/light/components/Breadcrumb.json +13 -0
- package/tokens/src/themes/light/components/Bubble.json +18 -0
- package/tokens/src/themes/light/components/Button/brand.json +260 -0
- package/tokens/src/themes/light/components/Button/core.json +24 -0
- package/tokens/src/themes/light/components/Button/danger.json +247 -0
- package/tokens/src/themes/light/components/Button/dark.json +230 -0
- package/tokens/src/themes/light/components/Button/info.json +238 -0
- package/tokens/src/themes/light/components/Button/light.json +236 -0
- package/tokens/src/themes/light/components/Button/primary.json +250 -0
- package/tokens/src/themes/light/components/Button/secondary.json +278 -0
- package/tokens/src/themes/light/components/Button/success.json +253 -0
- package/tokens/src/themes/light/components/Button/tertiary.json +109 -0
- package/tokens/src/themes/light/components/Button/warning.json +276 -0
- package/tokens/src/themes/light/components/Card.json +36 -0
- package/tokens/src/themes/light/components/Carousel.json +45 -0
- package/tokens/src/themes/light/components/Chip.json +50 -0
- package/tokens/src/themes/light/components/CloseButton.json +10 -0
- package/tokens/src/themes/light/components/Code.json +23 -0
- package/tokens/src/themes/light/components/DataTable.json +26 -0
- package/tokens/src/themes/light/components/Dropdown.json +41 -0
- package/tokens/src/themes/light/components/Dropzone.json +23 -0
- package/tokens/src/themes/light/components/Form/color.json +270 -0
- package/tokens/src/themes/light/components/Form/elevation.json +76 -0
- package/tokens/src/themes/light/components/Form/other.json +131 -0
- package/tokens/src/themes/light/components/IconButton.json +451 -0
- package/tokens/src/themes/light/components/Image.json +18 -0
- package/tokens/src/themes/light/components/Menu.json +30 -0
- package/tokens/src/themes/light/components/Modal.json +37 -0
- package/tokens/src/themes/light/components/Nav.json +166 -0
- package/tokens/src/themes/light/components/Navbar.json +136 -0
- package/tokens/src/themes/light/components/OverflowScroll.json +9 -0
- package/tokens/src/themes/light/components/PageBanner.json +24 -0
- package/tokens/src/themes/light/components/Pagination.json +45 -0
- package/tokens/src/themes/light/components/Popover.json +55 -0
- package/tokens/src/themes/light/components/ProductTour.json +35 -0
- package/tokens/src/themes/light/components/ProgressBar.json +20 -0
- package/tokens/src/themes/light/components/Scrollable.json +14 -0
- package/tokens/src/themes/light/components/SearchField.json +25 -0
- package/tokens/src/themes/light/components/Sheet.json +22 -0
- package/tokens/src/themes/light/components/Stepper.json +34 -0
- package/tokens/src/themes/light/components/Sticky.json +18 -0
- package/tokens/src/themes/light/components/Tab.json +62 -0
- package/tokens/src/themes/light/components/Toast.json +33 -0
- package/tokens/src/themes/light/components/Tooltip.json +30 -0
- package/tokens/src/themes/light/components/general/body.json +8 -0
- package/tokens/src/themes/light/components/general/headings.json +7 -0
- package/tokens/src/themes/light/components/general/hr.json +15 -0
- package/tokens/src/themes/light/components/general/input.json +18 -0
- package/tokens/src/themes/light/components/general/link.json +109 -0
- package/tokens/src/themes/light/components/general/list.json +38 -0
- package/tokens/src/themes/light/components/general/text.json +12 -0
- package/tokens/src/themes/light/global/color.json +1661 -0
- package/tokens/src/themes/light/global/elevation.json +201 -0
- package/tokens/src/themes/light/global/other.json +4 -0
- package/tokens/style-dictionary.js +229 -0
- package/tokens/utils.js +210 -0
- package/dist/ActionRow/_variables.scss +0 -2
- package/dist/Alert/_variables.scss +0 -24
- package/dist/Annotation/_variables.scss +0 -18
- package/dist/Avatar/_variables.scss +0 -10
- package/dist/AvatarButton/_variables.scss +0 -3
- package/dist/Badge/_variables.scss +0 -16
- package/dist/Breadcrumb/_variables.scss +0 -27
- package/dist/Bubble/_variables.scss +0 -8
- package/dist/Button/_variables.scss +0 -52
- package/dist/Button/deprecated/index.js +0 -149
- package/dist/Button/deprecated/index.js.map +0 -1
- package/dist/Button/index.d.ts +0 -35
- package/dist/Card/_variables.scss +0 -55
- package/dist/Carousel/_variables.scss +0 -27
- package/dist/CheckBox/index.js +0 -102
- package/dist/CheckBox/index.js.map +0 -1
- package/dist/CheckBoxGroup/index.js +0 -15
- package/dist/CheckBoxGroup/index.js.map +0 -1
- package/dist/Chip/_variables.scss +0 -28
- package/dist/ChipCarousel/_variables.scss +0 -3
- package/dist/CloseButton/_variables.scss +0 -6
- package/dist/Code/_variables.scss +0 -17
- package/dist/Collapsible/_variables.scss +0 -12
- package/dist/ColorPicker/_variables.scss +0 -2
- package/dist/Container/_variables.scss +0 -5
- package/dist/DataTable/_variables.scss +0 -11
- package/dist/Dropdown/_variables.scss +0 -33
- package/dist/Dropdown/deprecated/DropdownButton.js +0 -44
- package/dist/Dropdown/deprecated/DropdownButton.js.map +0 -1
- package/dist/Dropdown/deprecated/DropdownItem.js +0 -33
- package/dist/Dropdown/deprecated/DropdownItem.js.map +0 -1
- package/dist/Dropdown/deprecated/DropdownMenu.js +0 -46
- package/dist/Dropdown/deprecated/DropdownMenu.js.map +0 -1
- package/dist/Dropdown/deprecated/index.js +0 -241
- package/dist/Dropdown/deprecated/index.js.map +0 -1
- package/dist/Dropzone/_variables.scss +0 -9
- package/dist/Fieldset/index.js +0 -117
- package/dist/Fieldset/index.js.map +0 -1
- package/dist/Fieldset/index.scss +0 -12
- package/dist/Form/_variables.scss +0 -267
- package/dist/Hyperlink/index.d.ts +0 -24
- package/dist/Icon/_variables.scss +0 -7
- package/dist/Image/_variables.scss +0 -13
- package/dist/Input/index.js +0 -166
- package/dist/Input/index.js.map +0 -1
- package/dist/InputSelect/index.js +0 -105
- package/dist/InputSelect/index.js.map +0 -1
- package/dist/InputText/index.js +0 -45
- package/dist/InputText/index.js.map +0 -1
- package/dist/ListBox/index.js +0 -148
- package/dist/ListBox/index.js.map +0 -1
- package/dist/ListBoxOption/index.js +0 -94
- package/dist/ListBoxOption/index.js.map +0 -1
- package/dist/Menu/_variables.scss +0 -24
- package/dist/Modal/_variables.scss +0 -50
- package/dist/Modal/index.js +0 -292
- package/dist/Modal/index.js.map +0 -1
- package/dist/Nav/_variables.scss +0 -58
- package/dist/Navbar/_variables.scss +0 -40
- package/dist/OverflowScroll/_variables.scss +0 -5
- package/dist/OverflowScroll/index.scss +0 -1
- package/dist/Pagination/_variables.scss +0 -19
- package/dist/Popover/_variables.scss +0 -36
- package/dist/ProductTour/_variables.scss +0 -15
- package/dist/ProgressBar/_variables.scss +0 -23
- package/dist/RadioButtonGroup/index.js +0 -188
- package/dist/RadioButtonGroup/index.js.map +0 -1
- package/dist/SearchField/_variables.scss +0 -14
- package/dist/SelectableBox/_variables.scss +0 -5
- package/dist/Spinner/_variables.scss +0 -9
- package/dist/Stack/_variables.scss +0 -1
- package/dist/StatusAlert/index.js +0 -168
- package/dist/StatusAlert/index.js.map +0 -1
- package/dist/Stepper/_variables.scss +0 -18
- package/dist/Sticky/_variables.scss +0 -3
- package/dist/Table/_variables.scss +0 -34
- package/dist/Table/index.js +0 -267
- package/dist/Table/index.js.map +0 -1
- package/dist/Table/index.scss +0 -12
- package/dist/Tabs/_variables.scss +0 -24
- package/dist/Tabs/deprecated/Tabs.scss +0 -3
- package/dist/Tabs/deprecated/index.js +0 -123
- package/dist/Tabs/deprecated/index.js.map +0 -1
- package/dist/TextArea/index.js +0 -44
- package/dist/TextArea/index.js.map +0 -1
- package/dist/Toast/_variables.scss +0 -19
- package/dist/Tooltip/_variables.scss +0 -21
- package/dist/ValidationFormGroup/index.js +0 -106
- package/dist/ValidationFormGroup/index.js.map +0 -1
- package/dist/paragon.css +0 -45
- package/dist/setupTest.d.ts +0 -2
- package/dist/setupTest.js.map +0 -1
- package/dist/utils/types/bootstrap.d.ts +0 -39
- package/dist/utils/types/bootstrap.js +0 -2
- package/dist/utils/types/bootstrap.js.map +0 -1
- package/scss/core/_grid.scss +0 -21
- package/scss/core/_variables.scss +0 -875
- package/scss/core/core.scss +0 -21
- package/src/ActionRow/_variables.scss +0 -2
- package/src/Alert/_variables.scss +0 -24
- package/src/Annotation/_variables.scss +0 -18
- package/src/Avatar/_variables.scss +0 -10
- package/src/AvatarButton/_variables.scss +0 -3
- package/src/Badge/_variables.scss +0 -16
- package/src/Breadcrumb/_variables.scss +0 -27
- package/src/Bubble/_variables.scss +0 -8
- package/src/Button/_variables.scss +0 -52
- package/src/Button/deprecated/Button.test.jsx +0 -34
- package/src/Button/deprecated/index.jsx +0 -145
- package/src/Button/index.tsx +0 -159
- package/src/Card/_variables.scss +0 -55
- package/src/Carousel/_variables.scss +0 -27
- package/src/CheckBox/CheckBox.test.jsx +0 -65
- package/src/CheckBox/README.md +0 -93
- package/src/CheckBox/index.jsx +0 -80
- package/src/CheckBoxGroup/CheckBoxGroup.test.jsx +0 -33
- package/src/CheckBoxGroup/README.md +0 -35
- package/src/CheckBoxGroup/index.jsx +0 -19
- package/src/Chip/_variables.scss +0 -28
- package/src/ChipCarousel/_variables.scss +0 -3
- package/src/CloseButton/_variables.scss +0 -6
- package/src/Code/_variables.scss +0 -17
- package/src/Collapsible/_variables.scss +0 -12
- package/src/ColorPicker/_variables.scss +0 -2
- package/src/Container/_variables.scss +0 -5
- package/src/DataTable/_variables.scss +0 -11
- package/src/Dropdown/_variables.scss +0 -33
- package/src/Dropdown/deprecated/Dropdown.test.jsx +0 -238
- package/src/Dropdown/deprecated/DropdownButton.jsx +0 -52
- package/src/Dropdown/deprecated/DropdownItem.jsx +0 -34
- package/src/Dropdown/deprecated/DropdownMenu.jsx +0 -50
- package/src/Dropdown/deprecated/__snapshots__/Dropdown.test.jsx.snap +0 -229
- package/src/Dropdown/deprecated/index.jsx +0 -222
- package/src/Dropzone/_variables.scss +0 -9
- package/src/Fieldset/Fieldset.test.jsx +0 -101
- package/src/Fieldset/README.md +0 -146
- package/src/Fieldset/index.jsx +0 -107
- package/src/Fieldset/index.scss +0 -12
- package/src/Form/_variables.scss +0 -267
- package/src/Icon/_variables.scss +0 -7
- package/src/Image/_variables.scss +0 -13
- package/src/Input/README.md +0 -74
- package/src/Input/__snapshots__/input.test.jsx.snap +0 -53
- package/src/Input/index.jsx +0 -151
- package/src/Input/input.test.jsx +0 -85
- package/src/InputSelect/README.md +0 -136
- package/src/InputSelect/index.jsx +0 -92
- package/src/InputText/InputText.test.jsx +0 -74
- package/src/InputText/README.md +0 -293
- package/src/InputText/index.jsx +0 -49
- package/src/ListBox/ListBox.test.jsx +0 -161
- package/src/ListBox/README.md +0 -185
- package/src/ListBox/index.jsx +0 -115
- package/src/ListBoxOption/ListBoxOption.test.jsx +0 -154
- package/src/ListBoxOption/index.jsx +0 -78
- package/src/Menu/_variables.scss +0 -24
- package/src/Modal/README.md +0 -148
- package/src/Modal/_variables.scss +0 -50
- package/src/Modal/index.jsx +0 -319
- package/src/Modal/tests/Modal.test.jsx +0 -261
- package/src/Nav/_variables.scss +0 -58
- package/src/Navbar/_variables.scss +0 -40
- package/src/OverflowScroll/_variables.scss +0 -5
- package/src/OverflowScroll/index.scss +0 -1
- package/src/Pagination/_variables.scss +0 -19
- package/src/Popover/_variables.scss +0 -36
- package/src/ProductTour/_variables.scss +0 -15
- package/src/ProgressBar/_variables.scss +0 -23
- package/src/RadioButtonGroup/README.md +0 -50
- package/src/RadioButtonGroup/RadioButtonGroup.test.jsx +0 -127
- package/src/RadioButtonGroup/index.jsx +0 -185
- package/src/SearchField/_variables.scss +0 -14
- package/src/SelectableBox/_variables.scss +0 -5
- package/src/Spinner/_variables.scss +0 -9
- package/src/Stack/_variables.scss +0 -1
- package/src/StatusAlert/README.md +0 -149
- package/src/StatusAlert/StatusAlert.test.jsx +0 -150
- package/src/StatusAlert/index.jsx +0 -144
- package/src/Stepper/_variables.scss +0 -18
- package/src/Sticky/_variables.scss +0 -3
- package/src/Table/README.md +0 -506
- package/src/Table/Table.test.jsx +0 -367
- package/src/Table/_variables.scss +0 -34
- package/src/Table/index.jsx +0 -264
- package/src/Table/index.scss +0 -12
- package/src/Tabs/_variables.scss +0 -24
- package/src/Tabs/deprecated/Tabs.scss +0 -3
- package/src/Tabs/deprecated/Tabs.test.jsx +0 -50
- package/src/Tabs/deprecated/index.jsx +0 -117
- package/src/TextArea/README.md +0 -63
- package/src/TextArea/index.jsx +0 -48
- package/src/Toast/_variables.scss +0 -19
- package/src/Tooltip/_variables.scss +0 -21
- package/src/ValidationFormGroup/README.md +0 -116
- package/src/ValidationFormGroup/ValidationFormGroup.test.jsx +0 -146
- package/src/ValidationFormGroup/__snapshots__/ValidationFormGroup.test.jsx.snap +0 -161
- package/src/ValidationFormGroup/index.jsx +0 -114
- package/src/utils/types/bootstrap.test.tsx +0 -86
- package/src/utils/types/bootstrap.ts +0 -43
- /package/src/Button/{ButtonGroup.test.tsx → ButtonGroup.test.jsx} +0 -0
- /package/src/Button/{ButtonToolbar.test.tsx → ButtonToolbar.test.jsx} +0 -0
- /package/src/Button/__snapshots__/{ButtonGroup.test.tsx.snap → ButtonGroup.test.jsx.snap} +0 -0
- /package/src/Button/__snapshots__/{ButtonToolbar.test.tsx.snap → ButtonToolbar.test.jsx.snap} +0 -0
- /package/{scss → styles/scss}/core/_exports.module.scss +0 -0
- /package/{scss → styles/scss}/core/_typography.scss +0 -0
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
4
|
-
|
|
5
|
-
import ListBox from '.';
|
|
6
|
-
import ListBoxOption from '../ListBoxOption';
|
|
7
|
-
|
|
8
|
-
describe('ListBox', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
render(
|
|
11
|
-
<ListBox>
|
|
12
|
-
<ListBoxOption>test1</ListBoxOption>
|
|
13
|
-
<ListBoxOption>test2</ListBoxOption>
|
|
14
|
-
<ListBoxOption>test3</ListBoxOption>
|
|
15
|
-
</ListBox>,
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should have null aria-activedescendant attribute by default', () => {
|
|
20
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
21
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toBeNull();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it(
|
|
25
|
-
'should have correct aria-activedescendant attribute when selectedOptionIndex state is non-null',
|
|
26
|
-
async () => {
|
|
27
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
28
|
-
const selectedOptionIndex = 1;
|
|
29
|
-
|
|
30
|
-
listBoxElement.focus();
|
|
31
|
-
|
|
32
|
-
await userEvent.keyboard('{arrowdown}');
|
|
33
|
-
|
|
34
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual(`list-box-option-${selectedOptionIndex}`);
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
it('selectedOptionIndex prop should override selectedOptionIndex state', async () => {
|
|
39
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
40
|
-
const selectedOptionIndex = 2;
|
|
41
|
-
|
|
42
|
-
listBoxElement.focus();
|
|
43
|
-
|
|
44
|
-
await userEvent.keyboard('{arrowdown}');
|
|
45
|
-
await userEvent.keyboard('{arrowdown}');
|
|
46
|
-
|
|
47
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual(`list-box-option-${selectedOptionIndex}`);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should render a div by default', () => {
|
|
51
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
52
|
-
expect(listBoxElement.tagName.toLowerCase()).toBe('div');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should render an HTML element when passed tag prop is an HTML element', () => {
|
|
56
|
-
const { container } = render(
|
|
57
|
-
<ListBox tag="li">
|
|
58
|
-
<ListBoxOption>test1</ListBoxOption>
|
|
59
|
-
</ListBox>,
|
|
60
|
-
);
|
|
61
|
-
const listBoxElement = container.querySelector('li');
|
|
62
|
-
expect(listBoxElement).toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should have correct default classNames', () => {
|
|
66
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
67
|
-
expect(listBoxElement).toHaveClass('list-group');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should have listbox role', () => {
|
|
71
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
72
|
-
expect(listBoxElement).toHaveAttribute('role', 'listbox');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should have 0 tabIndex', () => {
|
|
76
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
77
|
-
expect(listBoxElement).toHaveAttribute('tabIndex', '0');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should select first ListBoxOption on focus if not ListBoxOption selected', async () => {
|
|
81
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
82
|
-
|
|
83
|
-
listBoxElement.focus();
|
|
84
|
-
|
|
85
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual('list-box-option-0');
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('should not select first ListBoxOption on focus if ListBoxOption selected', async () => {
|
|
89
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
90
|
-
|
|
91
|
-
listBoxElement.focus();
|
|
92
|
-
|
|
93
|
-
await userEvent.keyboard('{arrowdown}');
|
|
94
|
-
|
|
95
|
-
listBoxElement.focus();
|
|
96
|
-
|
|
97
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual('list-box-option-1');
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should select next ListBoxOption on down arrow key', async () => {
|
|
101
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
102
|
-
|
|
103
|
-
listBoxElement.focus();
|
|
104
|
-
|
|
105
|
-
await userEvent.keyboard('{arrowdown}');
|
|
106
|
-
|
|
107
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual('list-box-option-1');
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('should not select next ListBoxOption on down arrow key if at end of list', async () => {
|
|
111
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
112
|
-
|
|
113
|
-
listBoxElement.focus();
|
|
114
|
-
|
|
115
|
-
await userEvent.keyboard('{arrowdown}');
|
|
116
|
-
await userEvent.keyboard('{arrowdown}');
|
|
117
|
-
await userEvent.keyboard('{arrowdown}');
|
|
118
|
-
|
|
119
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual('list-box-option-2');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should select previous ListBoxOption on up arrow key', async () => {
|
|
123
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
124
|
-
|
|
125
|
-
listBoxElement.focus();
|
|
126
|
-
|
|
127
|
-
await userEvent.keyboard('{arrowdown}');
|
|
128
|
-
await userEvent.keyboard('{arrowup}');
|
|
129
|
-
|
|
130
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual('list-box-option-0');
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should not select previous ListBoxOption on up arrow key if at start of list', async () => {
|
|
134
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
135
|
-
|
|
136
|
-
listBoxElement.focus();
|
|
137
|
-
|
|
138
|
-
await userEvent.keyboard('{arrowup}');
|
|
139
|
-
|
|
140
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual('list-box-option-0');
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('should not change ListBoxOption selection on non-supported key', async () => {
|
|
144
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
145
|
-
|
|
146
|
-
listBoxElement.focus();
|
|
147
|
-
|
|
148
|
-
await userEvent.keyboard('{leftarrow}');
|
|
149
|
-
|
|
150
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual('list-box-option-0');
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('should update state when child\'s onSelect is called', async () => {
|
|
154
|
-
const listBoxElement = screen.getByRole('listbox');
|
|
155
|
-
const listBoxOption2 = screen.getAllByRole('option')[1];
|
|
156
|
-
|
|
157
|
-
await userEvent.click(listBoxOption2);
|
|
158
|
-
|
|
159
|
-
expect(listBoxElement.getAttribute('aria-activedescendant')).toEqual('list-box-option-1');
|
|
160
|
-
});
|
|
161
|
-
});
|
package/src/ListBox/README.md
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'ListBox'
|
|
3
|
-
type: 'component'
|
|
4
|
-
components:
|
|
5
|
-
- ListBox
|
|
6
|
-
- ListBoxOption
|
|
7
|
-
categories:
|
|
8
|
-
- Forms (deprecated)
|
|
9
|
-
status: 'Deprecate Soon'
|
|
10
|
-
designStatus: 'TBD'
|
|
11
|
-
devStatus: 'To Do'
|
|
12
|
-
notes: 'Not used anywhere in code on Github. Consult design.'
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## basic usage
|
|
16
|
-
|
|
17
|
-
```jsx live
|
|
18
|
-
<ListBox>
|
|
19
|
-
<ListBoxOption>
|
|
20
|
-
Apple
|
|
21
|
-
</ListBoxOption>
|
|
22
|
-
<ListBoxOption>
|
|
23
|
-
Orange
|
|
24
|
-
</ListBoxOption>
|
|
25
|
-
<ListBoxOption>
|
|
26
|
-
Strawberry
|
|
27
|
-
</ListBoxOption>
|
|
28
|
-
<ListBoxOption>
|
|
29
|
-
Banana
|
|
30
|
-
</ListBoxOption>
|
|
31
|
-
</ListBox>
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## using tag prop
|
|
35
|
-
|
|
36
|
-
```jsx live
|
|
37
|
-
<React.Fragment>
|
|
38
|
-
<div>This is an ordered list!</div>
|
|
39
|
-
<ListBox tag="ol">
|
|
40
|
-
<ListBoxOption tag="li">
|
|
41
|
-
Apple
|
|
42
|
-
</ListBoxOption>
|
|
43
|
-
<ListBoxOption tag="li">
|
|
44
|
-
<div>Orange</div>
|
|
45
|
-
</ListBoxOption>
|
|
46
|
-
<ListBoxOption tag="li">
|
|
47
|
-
Strawberry
|
|
48
|
-
</ListBoxOption>
|
|
49
|
-
<ListBoxOption tag="li">
|
|
50
|
-
Banana
|
|
51
|
-
</ListBoxOption>
|
|
52
|
-
</ListBox>
|
|
53
|
-
</React.Fragment>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## using onSelect prop
|
|
57
|
-
|
|
58
|
-
```jsx live
|
|
59
|
-
class ListBoxWrapperForOnSelect extends React.Component {
|
|
60
|
-
constructor(props) {
|
|
61
|
-
super(props);
|
|
62
|
-
|
|
63
|
-
this.onSelect = this.onSelect.bind(this);
|
|
64
|
-
|
|
65
|
-
this.state = {
|
|
66
|
-
selectedOption: null,
|
|
67
|
-
selectedOptionIndex: null,
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
this.fruits = {
|
|
71
|
-
Apple: '🍎',
|
|
72
|
-
Orange: '🍊',
|
|
73
|
-
Strawberry: '🍓',
|
|
74
|
-
Banana: '🍌',
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
onSelect(option, index) {
|
|
79
|
-
this.setState({
|
|
80
|
-
selectedOption: option,
|
|
81
|
-
selectedOptionIndex: index,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
getSelectedFruitEmoji(fruit) {
|
|
86
|
-
return fruit ? this.fruits[fruit] : '';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
render() {
|
|
90
|
-
const children = Object.keys(this.fruits).map((fruit, index) => (
|
|
91
|
-
<ListBoxOption
|
|
92
|
-
key={fruit}
|
|
93
|
-
onSelect={() => this.onSelect(fruit, index)}
|
|
94
|
-
style={{ textAlign: 'center' }}
|
|
95
|
-
>
|
|
96
|
-
{fruit}
|
|
97
|
-
</ListBoxOption>
|
|
98
|
-
));
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<React.Fragment>
|
|
102
|
-
<span aria-live="polite">
|
|
103
|
-
Selected Fruit:
|
|
104
|
-
{this.state.selectedOptionIndex === undefined ? (
|
|
105
|
-
<span className="sr-only">none</span>
|
|
106
|
-
) : (
|
|
107
|
-
<span
|
|
108
|
-
arialabelledby={`list-box-option-${
|
|
109
|
-
this.state.selectedOptionIndex
|
|
110
|
-
}`}
|
|
111
|
-
>
|
|
112
|
-
{this.getSelectedFruitEmoji(this.state.selectedOption)}
|
|
113
|
-
</span>
|
|
114
|
-
)}
|
|
115
|
-
</span>
|
|
116
|
-
<ListBox style={{ width: '200px' }}>
|
|
117
|
-
{children}
|
|
118
|
-
</ListBox>
|
|
119
|
-
</React.Fragment>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## using selectedOptionIndex prop
|
|
126
|
-
|
|
127
|
-
```jsx live
|
|
128
|
-
class ListBoxWrapperForSelectedOptionIndex extends React.Component {
|
|
129
|
-
constructor(props) {
|
|
130
|
-
super(props);
|
|
131
|
-
|
|
132
|
-
this.onSelect = this.onSelect.bind(this);
|
|
133
|
-
this.onButtonClick = this.onButtonClick.bind(this);
|
|
134
|
-
|
|
135
|
-
this.state = {
|
|
136
|
-
reset: true,
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
this.fruits = Object.keys({
|
|
140
|
-
Apple: '🍎',
|
|
141
|
-
Orange: '🍊',
|
|
142
|
-
Strawberry: '🍓',
|
|
143
|
-
Banana: '🍌',
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
onButtonClick() {
|
|
148
|
-
this.setState({
|
|
149
|
-
reset: true,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
onSelect() {
|
|
154
|
-
this.setState({
|
|
155
|
-
reset: false,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
render() {
|
|
160
|
-
const children = this.fruits.map(fruit => (
|
|
161
|
-
<ListBoxOption
|
|
162
|
-
key={fruit}
|
|
163
|
-
onSelect={this.onSelect}
|
|
164
|
-
style={{ textAlign: 'center' }}
|
|
165
|
-
>
|
|
166
|
-
{fruit}
|
|
167
|
-
</ListBoxOption>
|
|
168
|
-
));
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<React.Fragment>
|
|
172
|
-
<Button variant="primary" onClick={this.onButtonClick}>
|
|
173
|
-
Click me to reset your selected fruit!
|
|
174
|
-
</Button>
|
|
175
|
-
<ListBox
|
|
176
|
-
selectedOptionIndex={this.state.reset ? null : undefined}
|
|
177
|
-
style={{ margin: '10px' }}
|
|
178
|
-
>
|
|
179
|
-
{children}
|
|
180
|
-
</ListBox>
|
|
181
|
-
</React.Fragment>
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
```
|
package/src/ListBox/index.jsx
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { nonNegativeInteger } from '../utils/propTypes';
|
|
6
|
-
|
|
7
|
-
export default class ListBox extends React.Component {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
super(props);
|
|
10
|
-
|
|
11
|
-
this.onFocus = this.onFocus.bind(this);
|
|
12
|
-
this.onKeyDown = this.onKeyDown.bind(this);
|
|
13
|
-
|
|
14
|
-
this.state = {
|
|
15
|
-
selectedOptionIndex: null,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static getDerivedStateFromProps(nextProps, prevState) {
|
|
20
|
-
const { selectedOptionIndex } = nextProps;
|
|
21
|
-
|
|
22
|
-
if (selectedOptionIndex !== prevState.selectedOptionIndex
|
|
23
|
-
&& selectedOptionIndex !== undefined) {
|
|
24
|
-
return { selectedOptionIndex };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
onFocus() {
|
|
31
|
-
// if no ListBoxOption is selected, select first ListBoxOption on ListBox focus
|
|
32
|
-
if (!this.state.selectedOptionIndex) {
|
|
33
|
-
this.setState({
|
|
34
|
-
selectedOptionIndex: 0,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
onKeyDown(e) {
|
|
40
|
-
switch (e.key) {
|
|
41
|
-
case 'ArrowDown': {
|
|
42
|
-
// prevent scrolling entire modal body with arrow keys
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
if (this.state.selectedOptionIndex < React.Children.count(this.props.children) - 1) {
|
|
45
|
-
this.setState(state => ({
|
|
46
|
-
selectedOptionIndex: state.selectedOptionIndex + 1,
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
case 'ArrowUp': {
|
|
52
|
-
// prevent scrolling entire modal body with arrow keys
|
|
53
|
-
e.preventDefault();
|
|
54
|
-
|
|
55
|
-
if (this.state.selectedOptionIndex > 0) {
|
|
56
|
-
this.setState(state => ({
|
|
57
|
-
selectedOptionIndex: state.selectedOptionIndex - 1,
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
default:
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
renderChildren() {
|
|
67
|
-
return React.Children.map(this.props.children, (child, index) => React.cloneElement(child, {
|
|
68
|
-
index,
|
|
69
|
-
isSelected: index === this.state.selectedOptionIndex,
|
|
70
|
-
onSelect: () => { this.setState({ selectedOptionIndex: index }); child.props.onSelect(); },
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
render() {
|
|
75
|
-
const {
|
|
76
|
-
children,
|
|
77
|
-
className,
|
|
78
|
-
selectedOptionIndex,
|
|
79
|
-
tag,
|
|
80
|
-
...other
|
|
81
|
-
} = this.props;
|
|
82
|
-
|
|
83
|
-
return React.createElement(
|
|
84
|
-
this.props.tag,
|
|
85
|
-
{
|
|
86
|
-
'aria-activedescendant': this.state.selectedOptionIndex === null ? null : `list-box-option-${this.state.selectedOptionIndex}`,
|
|
87
|
-
className: classNames(['list-group', this.props.className]),
|
|
88
|
-
onFocus: this.onFocus,
|
|
89
|
-
onKeyDown: this.onKeyDown,
|
|
90
|
-
role: 'listbox',
|
|
91
|
-
tabIndex: 0,
|
|
92
|
-
...other,
|
|
93
|
-
},
|
|
94
|
-
this.renderChildren(),
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
ListBox.propTypes = {
|
|
100
|
-
/** specifies the ListBoxOption component(s) that will be displayed within the ListBox element. You can pass in one or more ListBoxOption components.
|
|
101
|
-
*/
|
|
102
|
-
children: PropTypes.node.isRequired,
|
|
103
|
-
/** specifies Bootstrap class names to apply to the ListBox component. The default is an empty string. */
|
|
104
|
-
className: PropTypes.string,
|
|
105
|
-
/** Although the ListBox component keeps track of which ListBoxOption is selected, `selectedOptionIndex` provides a mechanism for an override, if necessary. An example would be to clear the selectedOption when moving between views. Note that override is not permanent and that clicking on a ListBoxOption or interacting with the ListBox with the keyboard will change the selected ListBoxOption relative to the original override. The default is undefined. */
|
|
106
|
-
selectedOptionIndex: nonNegativeInteger,
|
|
107
|
-
/** used to specify the element type of the rendered ListBox component. The default is div. Example alternatives include ol, ul, span, etc. */
|
|
108
|
-
tag: PropTypes.string,
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
ListBox.defaultProps = {
|
|
112
|
-
className: undefined,
|
|
113
|
-
selectedOptionIndex: undefined,
|
|
114
|
-
tag: 'div',
|
|
115
|
-
};
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
4
|
-
|
|
5
|
-
import ListBoxOption from '.';
|
|
6
|
-
|
|
7
|
-
describe('ListBoxOption', () => {
|
|
8
|
-
const listBoxOptionChild = 'test';
|
|
9
|
-
|
|
10
|
-
describe('rendering', () => {
|
|
11
|
-
it('should have false aria-selected attribute by default', () => {
|
|
12
|
-
render(
|
|
13
|
-
<ListBoxOption data-testid="listbox-option">{listBoxOptionChild}</ListBoxOption>,
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
17
|
-
expect(listBoxOptionElement.getAttribute('aria-selected')).toEqual('false');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should have false aria-selected attribute when isSelected prop is false', () => {
|
|
21
|
-
const { rerender } = render(
|
|
22
|
-
<ListBoxOption data-testid="listbox-option" isSelected={false}>{listBoxOptionChild}</ListBoxOption>,
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
26
|
-
expect(listBoxOptionElement.getAttribute('aria-selected')).toEqual('false');
|
|
27
|
-
|
|
28
|
-
rerender(
|
|
29
|
-
<ListBoxOption isSelected>{listBoxOptionChild}</ListBoxOption>,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
expect(listBoxOptionElement.getAttribute('aria-selected')).toEqual('true');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should render a div by default', () => {
|
|
36
|
-
const { container } = render(
|
|
37
|
-
<ListBoxOption>{listBoxOptionChild}</ListBoxOption>,
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const listBoxOptionElement = container.querySelector('div');
|
|
41
|
-
expect(listBoxOptionElement).toBeInTheDocument();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should render an HTML element when tag prop is an HTML element', () => {
|
|
45
|
-
const { container } = render(
|
|
46
|
-
<ListBoxOption tag="li">{listBoxOptionChild}</ListBoxOption>,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const listBoxOptionElement = container.querySelector('li');
|
|
50
|
-
expect(listBoxOptionElement).toBeInTheDocument();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should have correct default classNames', () => {
|
|
54
|
-
render(
|
|
55
|
-
<ListBoxOption data-testid="listbox-option">{listBoxOptionChild}</ListBoxOption>,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
59
|
-
expect(listBoxOptionElement).toHaveClass('list-group-item');
|
|
60
|
-
expect(listBoxOptionElement).toHaveClass('list-group-item-action');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should not have active className by default', () => {
|
|
64
|
-
render(
|
|
65
|
-
<ListBoxOption data-testid="listbox-option">{listBoxOptionChild}</ListBoxOption>,
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
69
|
-
expect(listBoxOptionElement).not.toHaveClass('active');
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should have correct default id', () => {
|
|
73
|
-
render(
|
|
74
|
-
<ListBoxOption data-testid="listbox-option">{listBoxOptionChild}</ListBoxOption>,
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
78
|
-
expect(listBoxOptionElement.getAttribute('id')).toBeNull();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should have correct id when index prop is a number', () => {
|
|
82
|
-
const { rerender } = render(
|
|
83
|
-
<ListBoxOption data-testid="listbox-option" index={1}>{listBoxOptionChild}</ListBoxOption>,
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
87
|
-
expect(listBoxOptionElement.getAttribute('id')).toEqual('list-box-option-1');
|
|
88
|
-
|
|
89
|
-
rerender(
|
|
90
|
-
<ListBoxOption index={2}>{listBoxOptionChild}</ListBoxOption>,
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
expect(listBoxOptionElement.getAttribute('id')).toEqual('list-box-option-2');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('should have option role', () => {
|
|
97
|
-
render(
|
|
98
|
-
<ListBoxOption data-testid="listbox-option">{listBoxOptionChild}</ListBoxOption>,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
102
|
-
expect(listBoxOptionElement.getAttribute('role')).toEqual('option');
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should have active className when isSelected prop is true', () => {
|
|
106
|
-
const { rerender } = render(
|
|
107
|
-
<ListBoxOption data-testid="listbox-option" isSelected={false}>{listBoxOptionChild}</ListBoxOption>,
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
111
|
-
expect(listBoxOptionElement).not.toHaveClass('active');
|
|
112
|
-
|
|
113
|
-
rerender(
|
|
114
|
-
<ListBoxOption isSelected>{listBoxOptionChild}</ListBoxOption>,
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
expect(listBoxOptionElement).toHaveClass('active');
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe('behavior', () => {
|
|
122
|
-
it('should call onSelect on mouse down', async () => {
|
|
123
|
-
const onSelectSpy = jest.fn();
|
|
124
|
-
render(
|
|
125
|
-
<ListBoxOption data-testid="listbox-option" onSelect={onSelectSpy}>{listBoxOptionChild}</ListBoxOption>,
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
129
|
-
|
|
130
|
-
await userEvent.click(listBoxOptionElement);
|
|
131
|
-
|
|
132
|
-
expect(onSelectSpy).toHaveBeenCalledTimes(1);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('should call onSelect when receiving new isSelected prop', async () => {
|
|
136
|
-
const onSelectSpy = jest.fn();
|
|
137
|
-
const { rerender } = render(
|
|
138
|
-
<ListBoxOption data-testid="listbox-option" onSelect={onSelectSpy}>{listBoxOptionChild}</ListBoxOption>,
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const listBoxOptionElement = screen.getByTestId('listbox-option');
|
|
142
|
-
|
|
143
|
-
await userEvent.click(listBoxOptionElement);
|
|
144
|
-
|
|
145
|
-
rerender(
|
|
146
|
-
<ListBoxOption onSelect={onSelectSpy} isSelected>
|
|
147
|
-
{listBoxOptionChild}
|
|
148
|
-
</ListBoxOption>,
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
expect(onSelectSpy).toHaveBeenCalledTimes(2);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
export default class ListBoxOption extends React.Component {
|
|
6
|
-
constructor(props) {
|
|
7
|
-
super(props);
|
|
8
|
-
|
|
9
|
-
this.onMouseDown = this.onMouseDown.bind(this);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
componentDidUpdate(prevProps) {
|
|
13
|
-
if (this.props.isSelected && !prevProps.isSelected) {
|
|
14
|
-
this.props.onSelect();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* onMouseDown is used instead of onClick because onClick triggers the focus
|
|
20
|
-
* event before click event. This focus event bubbles up to the parent
|
|
21
|
-
* (since onFocus bubbles in React), which triggers the ListBox's onFocus function.
|
|
22
|
-
* This function will select the first ListBoxOption if one is not selected, and this
|
|
23
|
-
* causes the user to see the first option selected before their desired option is selected
|
|
24
|
-
* when the click event is fired shortly thereafter. The mouseDown event occurs before the
|
|
25
|
-
* focus event, which prevents this behavior.
|
|
26
|
-
*/
|
|
27
|
-
onMouseDown() {
|
|
28
|
-
this.props.onSelect();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
render() {
|
|
32
|
-
const {
|
|
33
|
-
children,
|
|
34
|
-
className,
|
|
35
|
-
index,
|
|
36
|
-
isSelected,
|
|
37
|
-
tag,
|
|
38
|
-
...other
|
|
39
|
-
} = this.props;
|
|
40
|
-
|
|
41
|
-
return React.createElement(
|
|
42
|
-
this.props.tag,
|
|
43
|
-
{
|
|
44
|
-
'aria-selected': isSelected,
|
|
45
|
-
className: classNames(
|
|
46
|
-
'list-group-item',
|
|
47
|
-
'list-group-item-action',
|
|
48
|
-
{
|
|
49
|
-
active: this.props.isSelected,
|
|
50
|
-
},
|
|
51
|
-
className,
|
|
52
|
-
),
|
|
53
|
-
id: index === undefined ? null : `list-box-option-${index}`,
|
|
54
|
-
onMouseDown: this.onMouseDown,
|
|
55
|
-
role: 'option',
|
|
56
|
-
...other,
|
|
57
|
-
},
|
|
58
|
-
children,
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
ListBoxOption.propTypes = {
|
|
64
|
-
children: PropTypes.node.isRequired,
|
|
65
|
-
className: PropTypes.string,
|
|
66
|
-
index: PropTypes.number,
|
|
67
|
-
isSelected: PropTypes.bool,
|
|
68
|
-
tag: PropTypes.string,
|
|
69
|
-
onSelect: PropTypes.func,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
ListBoxOption.defaultProps = {
|
|
73
|
-
className: undefined,
|
|
74
|
-
index: undefined,
|
|
75
|
-
isSelected: false,
|
|
76
|
-
tag: 'div',
|
|
77
|
-
onSelect: () => { },
|
|
78
|
-
};
|