@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
package/src/Table/Table.test.jsx
DELETED
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
4
|
-
|
|
5
|
-
import Table from '.';
|
|
6
|
-
|
|
7
|
-
const props = {
|
|
8
|
-
columns: [
|
|
9
|
-
{ key: 'num', label: 'Number' },
|
|
10
|
-
{ key: 'x2', label: 'Number * 2' },
|
|
11
|
-
{ key: 'sq', label: 'Number Squared' },
|
|
12
|
-
{ key: 'i', label: 'Imaginary Number' },
|
|
13
|
-
],
|
|
14
|
-
data: [
|
|
15
|
-
{
|
|
16
|
-
sq: 1, num: 1, x2: 2, i: 'i',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
sq: 4, num: 2, x2: 4, i: '2i',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
sq: 9, num: 3, x2: 6, i: '3i',
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const sortableColumnProps = {
|
|
28
|
-
num: {
|
|
29
|
-
columnSortable: true,
|
|
30
|
-
onSort: () => {},
|
|
31
|
-
},
|
|
32
|
-
x2: {
|
|
33
|
-
columnSortable: true,
|
|
34
|
-
onSort: () => {},
|
|
35
|
-
},
|
|
36
|
-
sq: {
|
|
37
|
-
columnSortable: false,
|
|
38
|
-
},
|
|
39
|
-
i: {
|
|
40
|
-
columnSortable: false,
|
|
41
|
-
hideHeader: true,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const sortableColumns = props.columns.map(column => ({
|
|
46
|
-
...column,
|
|
47
|
-
...sortableColumnProps[column.key],
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
const sortableProps = {
|
|
51
|
-
columns: sortableColumns,
|
|
52
|
-
data: props.data,
|
|
53
|
-
tableSortable: true,
|
|
54
|
-
defaultSortedColumn: sortableColumns[0].key,
|
|
55
|
-
defaultSortDirection: 'desc',
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const fixedColumnProps = {
|
|
59
|
-
num: { width: 'col-4' },
|
|
60
|
-
x2: { width: 'col-2' },
|
|
61
|
-
sq: { width: 'col-3' },
|
|
62
|
-
i: { width: 'col-3' },
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const fixedColumns = props.columns.map(column => ({
|
|
66
|
-
...column,
|
|
67
|
-
...fixedColumnProps[column.key],
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
const fixedProps = {
|
|
71
|
-
...props,
|
|
72
|
-
columns: fixedColumns,
|
|
73
|
-
hasFixedColumnWidths: true,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const propsWithColWidths = {
|
|
77
|
-
...props,
|
|
78
|
-
columns: fixedColumns,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
describe('<Table />', () => {
|
|
82
|
-
describe('renders', () => {
|
|
83
|
-
it('with display columns in the right order', () => {
|
|
84
|
-
render(<Table {...props} />);
|
|
85
|
-
props.columns.forEach((column) => {
|
|
86
|
-
const columnHeader = screen.getByText(column.label);
|
|
87
|
-
expect(columnHeader).toBeInTheDocument();
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('with data in the same order as the columns', () => {
|
|
92
|
-
render(<Table {...props} />);
|
|
93
|
-
|
|
94
|
-
const rows = screen.getAllByRole('row');
|
|
95
|
-
rows.forEach((row, rowIndex) => {
|
|
96
|
-
const cells = within(row).queryAllByRole('cell');
|
|
97
|
-
cells.forEach((cell, columnIndex) => {
|
|
98
|
-
const cellContent = cell.textContent.trim();
|
|
99
|
-
let parsed = Number(cellContent);
|
|
100
|
-
if (Number.isNaN(parsed)) {
|
|
101
|
-
parsed = cellContent;
|
|
102
|
-
}
|
|
103
|
-
// rowIndex - 1 due to the absence of td elements at the first circle
|
|
104
|
-
expect(parsed).toEqual(props.data[rowIndex - 1][props.columns[columnIndex].key]);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('that is non-sortable renders', () => {
|
|
111
|
-
it('it sets column headers correctly even with hidden prop', () => {
|
|
112
|
-
render(<Table {...sortableProps} tableSortable={false} />);
|
|
113
|
-
const tableHeadings = screen.getAllByRole('columnheader');
|
|
114
|
-
|
|
115
|
-
let hiddenHeader;
|
|
116
|
-
|
|
117
|
-
tableHeadings.forEach((th, i) => {
|
|
118
|
-
expect(th.textContent).toEqual(sortableProps.columns[i].label);
|
|
119
|
-
if (sortableProps.columns[i].hideHeader) {
|
|
120
|
-
hiddenHeader = sortableProps.columns[i].label;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
const spanElement = screen.getByText(hiddenHeader);
|
|
125
|
-
expect(spanElement).toBeInTheDocument();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('without sortable columns', () => {
|
|
129
|
-
render(<Table {...sortableProps} tableSortable={false} />);
|
|
130
|
-
const tableHeadings = screen.getAllByRole('columnheader');
|
|
131
|
-
|
|
132
|
-
tableHeadings.forEach((heading) => {
|
|
133
|
-
expect(heading).not.toHaveClass('sortable');
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('without column buttons', () => {
|
|
138
|
-
render(<Table {...sortableProps} tableSortable={false} />);
|
|
139
|
-
const buttons = screen.queryAllByRole('button');
|
|
140
|
-
expect(buttons).toHaveLength(0);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe('that is sortable and has mixed columns renders', () => {
|
|
145
|
-
beforeEach(() => {
|
|
146
|
-
render(<Table {...sortableProps} />);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('with sortable classname on correct headings', () => {
|
|
150
|
-
const tableHeadings = screen.queryAllByRole('columnheader');
|
|
151
|
-
|
|
152
|
-
expect(tableHeadings).toHaveLength(sortableProps.columns.length);
|
|
153
|
-
expect(tableHeadings[0]).toHaveClass('sortable');
|
|
154
|
-
expect(tableHeadings[1]).toHaveClass('sortable');
|
|
155
|
-
expect(tableHeadings[2]).not.toHaveClass('sortable');
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('with sr-only classname on correct headings', () => {
|
|
159
|
-
const srOnly = screen.queryAllByTestId('table-heading-sr');
|
|
160
|
-
|
|
161
|
-
expect(srOnly).toHaveLength(sortableProps.columns.length - 1);
|
|
162
|
-
expect(srOnly[0]).toHaveClass('sr-only');
|
|
163
|
-
expect(srOnly[1]).toHaveClass('sr-only');
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('with correct initial sr-only text on correct headings', () => {
|
|
167
|
-
const headings = screen.queryAllByTestId('table-heading-sr');
|
|
168
|
-
|
|
169
|
-
expect(headings[0]).toHaveTextContent('sort descending');
|
|
170
|
-
expect(headings[1]).toHaveTextContent('click to sort');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('with correct column buttons', () => {
|
|
174
|
-
const buttons = screen.queryAllByRole('button');
|
|
175
|
-
expect(buttons).toHaveLength(2);
|
|
176
|
-
expect(buttons[0].classList).toContain('btn-header');
|
|
177
|
-
expect(buttons[1].classList).toContain('btn-header');
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('with correct initial sort icons', () => {
|
|
181
|
-
const buttons = screen.queryAllByRole('button');
|
|
182
|
-
|
|
183
|
-
expect(buttons).toHaveLength(sortableProps.columns.length - 2);
|
|
184
|
-
expect(buttons[0].querySelector('.fa')).toHaveClass('fa-sort-desc');
|
|
185
|
-
expect(buttons[1].querySelector('.fa')).toHaveClass('fa-sort');
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
describe('that is sortable and has mixed columns has behavior that', () => {
|
|
190
|
-
let buttons;
|
|
191
|
-
let numSpy;
|
|
192
|
-
let x2Spy;
|
|
193
|
-
|
|
194
|
-
beforeEach(() => {
|
|
195
|
-
render(<Table data-testid="sorted" {...sortableProps} />);
|
|
196
|
-
|
|
197
|
-
buttons = screen.queryAllByRole('button');
|
|
198
|
-
numSpy = jest.fn();
|
|
199
|
-
x2Spy = jest.fn();
|
|
200
|
-
|
|
201
|
-
sortableProps.columns.find(column => (column.key === 'num')).onSort = numSpy;
|
|
202
|
-
sortableProps.columns.find(column => (column.key === 'x2')).onSort = x2Spy;
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it('changes sort icons appropriately on click', async () => {
|
|
206
|
-
await userEvent.click(buttons[0]);
|
|
207
|
-
buttons = screen.queryAllByRole('button');
|
|
208
|
-
|
|
209
|
-
expect(buttons[0].querySelector('.fa')).toHaveClass('fa-sort-asc');
|
|
210
|
-
expect(buttons[0].querySelector('.fa')).not.toHaveClass('fa-sort-desc');
|
|
211
|
-
expect(buttons[0].querySelector('.fa')).not.toHaveClass('fa-sort');
|
|
212
|
-
|
|
213
|
-
expect(buttons[1].querySelector('.fa')).toHaveClass('fa-sort');
|
|
214
|
-
expect(buttons[1].querySelector('.fa')).not.toHaveClass('fa-sort-asc');
|
|
215
|
-
expect(buttons[1].querySelector('.fa')).not.toHaveClass('fa-sort-desc');
|
|
216
|
-
|
|
217
|
-
await userEvent.click(buttons[1]);
|
|
218
|
-
buttons = screen.queryAllByRole('button');
|
|
219
|
-
|
|
220
|
-
expect(buttons[0].querySelector('.fa')).toHaveClass('fa-sort');
|
|
221
|
-
expect(buttons[0].querySelector('.fa')).not.toHaveClass('fa-sort-asc');
|
|
222
|
-
expect(buttons[0].querySelector('.fa')).not.toHaveClass('fa-sort-desc');
|
|
223
|
-
|
|
224
|
-
expect(buttons[1].querySelector('.fa')).toHaveClass('fa-sort-desc');
|
|
225
|
-
expect(buttons[1].querySelector('.fa')).not.toHaveClass('fa-sort');
|
|
226
|
-
expect(buttons[1].querySelector('.fa')).not.toHaveClass('fa-sort-asc');
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('changes sr-only text appropriately on click', async () => {
|
|
230
|
-
const headings = screen.queryAllByTestId('table-heading-sr');
|
|
231
|
-
|
|
232
|
-
await userEvent.click(buttons[0]);
|
|
233
|
-
buttons = screen.queryAllByRole('button');
|
|
234
|
-
|
|
235
|
-
expect(headings[0]).toHaveTextContent('sort ascending');
|
|
236
|
-
expect(headings[1]).toHaveTextContent('click to sort');
|
|
237
|
-
|
|
238
|
-
await userEvent.click(buttons[1]);
|
|
239
|
-
|
|
240
|
-
expect(headings[0]).toHaveTextContent('click to sort');
|
|
241
|
-
expect(headings[1]).toHaveTextContent('sort descending');
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('calls onSort function correctly on click', async () => {
|
|
245
|
-
expect(numSpy).toHaveBeenCalledTimes(0);
|
|
246
|
-
expect(x2Spy).toHaveBeenCalledTimes(0);
|
|
247
|
-
|
|
248
|
-
await userEvent.click(buttons[0]);
|
|
249
|
-
buttons = screen.queryAllByRole('button');
|
|
250
|
-
|
|
251
|
-
expect(numSpy).toHaveBeenCalledTimes(1);
|
|
252
|
-
expect(x2Spy).toHaveBeenCalledTimes(0);
|
|
253
|
-
|
|
254
|
-
expect(numSpy).toBeCalledWith('asc');
|
|
255
|
-
|
|
256
|
-
await userEvent.click(buttons[0]);
|
|
257
|
-
buttons = screen.queryAllByRole('button');
|
|
258
|
-
|
|
259
|
-
expect(numSpy).toHaveBeenCalledTimes(2);
|
|
260
|
-
expect(x2Spy).toHaveBeenCalledTimes(0);
|
|
261
|
-
|
|
262
|
-
expect(numSpy).toBeCalledWith('desc');
|
|
263
|
-
|
|
264
|
-
await userEvent.click(buttons[1]);
|
|
265
|
-
buttons = screen.queryAllByRole('button');
|
|
266
|
-
|
|
267
|
-
expect(numSpy).toHaveBeenCalledTimes(2);
|
|
268
|
-
expect(x2Spy).toHaveBeenCalledTimes(1);
|
|
269
|
-
|
|
270
|
-
expect(x2Spy).toBeCalledWith('desc');
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
describe('that is fixed', () => {
|
|
275
|
-
beforeEach(() => {
|
|
276
|
-
render(<Table {...fixedProps} />);
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it('with col width classnames on headings', () => {
|
|
280
|
-
const tableHeadings = screen.queryAllByRole('columnheader');
|
|
281
|
-
|
|
282
|
-
expect(tableHeadings).toHaveLength(fixedProps.columns.length);
|
|
283
|
-
expect(tableHeadings[0]).toHaveClass('col-4');
|
|
284
|
-
expect(tableHeadings[1]).toHaveClass('col-2');
|
|
285
|
-
expect(tableHeadings[2]).toHaveClass('col-3');
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('with col width classnames on cells', () => {
|
|
289
|
-
const tableCells = screen.queryAllByRole('cell');
|
|
290
|
-
|
|
291
|
-
expect(tableCells).toHaveLength(fixedProps.columns.length * fixedProps.data.length);
|
|
292
|
-
expect(tableCells[0]).toHaveClass('col-4');
|
|
293
|
-
expect(tableCells[1]).toHaveClass('col-2');
|
|
294
|
-
expect(tableCells[2]).toHaveClass('col-3');
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it('with fixed-related classnames on head, body, and rows', () => {
|
|
298
|
-
const thead = screen.queryAllByRole('rowgroup')[0];
|
|
299
|
-
const tbody = screen.queryAllByRole('rowgroup')[1];
|
|
300
|
-
const tr = screen.queryAllByRole('row')[0];
|
|
301
|
-
|
|
302
|
-
expect(thead).toHaveClass('d-inline');
|
|
303
|
-
expect(tbody).toHaveClass('d-inline');
|
|
304
|
-
expect(tr).toHaveClass('d-flex');
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
describe('that is not fixed with col widths', () => {
|
|
309
|
-
beforeEach(() => {
|
|
310
|
-
render(<Table {...propsWithColWidths} />);
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it('with no col width classnames on headings', () => {
|
|
314
|
-
const tableHeadings = screen.queryAllByRole('columnheader');
|
|
315
|
-
|
|
316
|
-
expect(tableHeadings).toHaveLength(fixedProps.columns.length);
|
|
317
|
-
expect(tableHeadings[0]).not.toHaveClass('col-4');
|
|
318
|
-
expect(tableHeadings[1]).not.toHaveClass('col-2');
|
|
319
|
-
expect(tableHeadings[2]).not.toHaveClass('col-3');
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it('with no col width classnames on cells', () => {
|
|
323
|
-
const tableCells = screen.queryAllByRole('cell');
|
|
324
|
-
|
|
325
|
-
expect(tableCells).toHaveLength(fixedProps.columns.length * fixedProps.data.length);
|
|
326
|
-
expect(tableCells[0]).not.toHaveClass('col-4');
|
|
327
|
-
expect(tableCells[1]).not.toHaveClass('col-2');
|
|
328
|
-
expect(tableCells[2]).not.toHaveClass('col-3');
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it('with no fixed-related classnames on head, body, and rows', () => {
|
|
332
|
-
const thead = screen.queryAllByRole('rowgroup')[0];
|
|
333
|
-
const tbody = screen.queryAllByRole('rowgroup')[1];
|
|
334
|
-
const tr = screen.queryAllByRole('row')[0];
|
|
335
|
-
|
|
336
|
-
expect(thead).not.toHaveClass('d-inline');
|
|
337
|
-
expect(tbody).not.toHaveClass('d-inline');
|
|
338
|
-
expect(tr).not.toHaveClass('d-flex');
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
describe('renders row headers', () => {
|
|
343
|
-
beforeEach(() => {
|
|
344
|
-
render(<Table {...props} rowHeaderColumnKey="num" />);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it('with the row header as th with row scope', () => {
|
|
348
|
-
const tableHeadings = screen.queryAllByRole('rowheader');
|
|
349
|
-
|
|
350
|
-
tableHeadings.forEach((th) => {
|
|
351
|
-
if (th.getAttribute('data-colkey') === 'num') {
|
|
352
|
-
expect(th.getAttribute('scope')).toEqual('row');
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it('with all other columns unchanged', () => {
|
|
358
|
-
const tableCells = screen.queryAllByRole('cell');
|
|
359
|
-
|
|
360
|
-
tableCells.forEach((td) => {
|
|
361
|
-
if (td.getAttribute('data-colkey') !== 'num') {
|
|
362
|
-
expect(td.getAttribute('scope')).not.toEqual('row');
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Tables
|
|
2
|
-
//
|
|
3
|
-
// Customizes the `.table` component with basic values, each used across all table variations.
|
|
4
|
-
|
|
5
|
-
$table-cell-padding: .75rem !default;
|
|
6
|
-
$table-cell-padding-sm: .3rem !default;
|
|
7
|
-
|
|
8
|
-
$table-color: $body-color !default;
|
|
9
|
-
$table-bg: null !default;
|
|
10
|
-
$table-accent-bg: rgba($black, .05) !default;
|
|
11
|
-
$table-hover-color: $table-color !default;
|
|
12
|
-
$table-hover-bg: rgba($black, .075) !default;
|
|
13
|
-
$table-active-bg: $table-hover-bg !default;
|
|
14
|
-
|
|
15
|
-
$table-border-width: $border-width !default;
|
|
16
|
-
$table-border-color: $border-color !default;
|
|
17
|
-
|
|
18
|
-
$table-head-bg: theme-color("gray", "background") !default;
|
|
19
|
-
$table-head-color: theme-color("gray", "text") !default;
|
|
20
|
-
|
|
21
|
-
$table-dark-color: $white !default;
|
|
22
|
-
$table-dark-bg: theme-color("gray", "hover") !default;
|
|
23
|
-
$table-dark-accent-bg: rgba($white, .05) !default;
|
|
24
|
-
$table-dark-hover-color: $table-dark-color !default;
|
|
25
|
-
$table-dark-hover-bg: rgba($white, .075) !default;
|
|
26
|
-
$table-dark-border-color: lighten($table-dark-bg, 7.5%) !default;
|
|
27
|
-
$table-dark-color: $white !default;
|
|
28
|
-
|
|
29
|
-
$table-striped-order: odd !default;
|
|
30
|
-
|
|
31
|
-
$table-caption-color: $text-muted !default;
|
|
32
|
-
|
|
33
|
-
$table-bg-level: -9 !default;
|
|
34
|
-
$table-border-level: -6 !default;
|
package/src/Table/index.jsx
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import isRequiredIf from 'react-proptype-conditional-require';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
|
|
7
|
-
import Button from '../Button';
|
|
8
|
-
import withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';
|
|
9
|
-
|
|
10
|
-
class Table extends React.Component {
|
|
11
|
-
constructor(props) {
|
|
12
|
-
super(props);
|
|
13
|
-
|
|
14
|
-
this.state = {
|
|
15
|
-
sortedColumn: props.tableSortable ? this.props.defaultSortedColumn : '',
|
|
16
|
-
sortDirection: props.tableSortable ? this.props.defaultSortDirection : '',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
this.onSortClick = this.onSortClick.bind(this);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
onSortClick(columnKey) {
|
|
23
|
-
let newDirection = 'desc';
|
|
24
|
-
|
|
25
|
-
if (this.state.sortedColumn === columnKey) {
|
|
26
|
-
newDirection = (this.state.sortDirection === 'desc' ? 'asc' : 'desc');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
this.setState({
|
|
30
|
-
sortedColumn: columnKey,
|
|
31
|
-
sortDirection: newDirection,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const currentlySortedColumn = this.props.columns.find(column => (columnKey === column.key));
|
|
35
|
-
currentlySortedColumn.onSort(newDirection);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
getCaption() {
|
|
39
|
-
return this.props.caption && (
|
|
40
|
-
<caption>{this.props.caption}</caption>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getSortButtonScreenReaderText(columnKey) {
|
|
45
|
-
let text;
|
|
46
|
-
|
|
47
|
-
if (this.state.sortedColumn === columnKey) {
|
|
48
|
-
text = this.props.sortButtonsScreenReaderText[this.state.sortDirection];
|
|
49
|
-
} else {
|
|
50
|
-
text = this.props.sortButtonsScreenReaderText.defaultText;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return text;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
getSortIcon(sortDirection) {
|
|
57
|
-
const sortIconClassName = ['fa-sort', sortDirection].filter(n => n).join('-');
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<span
|
|
61
|
-
className={classNames('fa', sortIconClassName)}
|
|
62
|
-
aria-hidden
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
getTableHeading(column) {
|
|
68
|
-
let heading;
|
|
69
|
-
if (this.props.tableSortable && column.columnSortable) {
|
|
70
|
-
heading = (
|
|
71
|
-
<Button
|
|
72
|
-
variant="header"
|
|
73
|
-
onClick={() => this.onSortClick(column.key)}
|
|
74
|
-
>
|
|
75
|
-
<span>
|
|
76
|
-
{column.label}
|
|
77
|
-
<span className={classNames('sr-only')} data-testid="table-heading-sr">
|
|
78
|
-
{' '}
|
|
79
|
-
{this.getSortButtonScreenReaderText(column.key)}
|
|
80
|
-
</span>
|
|
81
|
-
{' '}
|
|
82
|
-
{this.getSortIcon(column.key === this.state.sortedColumn ? this.state.sortDirection : '')}
|
|
83
|
-
</span>
|
|
84
|
-
</Button>
|
|
85
|
-
);
|
|
86
|
-
} else if (column.hideHeader) {
|
|
87
|
-
heading = (<span className={classNames('sr-only')} data-testid="table-heading-sr">{column.label}</span>);
|
|
88
|
-
} else {
|
|
89
|
-
heading = column.label;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return heading;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
getHeadings() {
|
|
96
|
-
return (
|
|
97
|
-
<thead
|
|
98
|
-
className={classNames(
|
|
99
|
-
...this.props.headingClassName,
|
|
100
|
-
{ 'd-inline': this.props.hasFixedColumnWidths },
|
|
101
|
-
)}
|
|
102
|
-
>
|
|
103
|
-
<tr className={classNames({ 'd-flex': this.props.hasFixedColumnWidths })}>
|
|
104
|
-
{this.props.columns.map(col => (
|
|
105
|
-
<th
|
|
106
|
-
className={classNames(
|
|
107
|
-
{ sortable: this.props.tableSortable && col.columnSortable },
|
|
108
|
-
this.props.hasFixedColumnWidths ? col.width : null,
|
|
109
|
-
)}
|
|
110
|
-
key={col.key}
|
|
111
|
-
scope="col"
|
|
112
|
-
>
|
|
113
|
-
{this.getTableHeading(col)}
|
|
114
|
-
</th>
|
|
115
|
-
))}
|
|
116
|
-
</tr>
|
|
117
|
-
</thead>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
getBody() {
|
|
122
|
-
return (
|
|
123
|
-
<tbody className={classNames({ 'd-inline': this.props.hasFixedColumnWidths })}>
|
|
124
|
-
{this.props.data.map((row, i) => (
|
|
125
|
-
<tr
|
|
126
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
127
|
-
key={i}
|
|
128
|
-
className={classNames({ 'd-flex': this.props.hasFixedColumnWidths })}
|
|
129
|
-
>
|
|
130
|
-
{this.props.columns.map(({ key, width }) => (
|
|
131
|
-
React.createElement(
|
|
132
|
-
(key === this.props.rowHeaderColumnKey) ? 'th' : 'td',
|
|
133
|
-
{
|
|
134
|
-
key,
|
|
135
|
-
className: classNames(this.props.hasFixedColumnWidths ? width : null),
|
|
136
|
-
scope: (key === this.props.rowHeaderColumnKey) ? 'row' : null,
|
|
137
|
-
},
|
|
138
|
-
row[key],
|
|
139
|
-
)
|
|
140
|
-
))}
|
|
141
|
-
</tr>
|
|
142
|
-
))}
|
|
143
|
-
</tbody>
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
render() {
|
|
148
|
-
return (
|
|
149
|
-
<table className={classNames(
|
|
150
|
-
'table',
|
|
151
|
-
this.props.className,
|
|
152
|
-
)}
|
|
153
|
-
>
|
|
154
|
-
{this.getCaption()}
|
|
155
|
-
{this.getHeadings()}
|
|
156
|
-
{this.getBody()}
|
|
157
|
-
</table>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
Table.propTypes = {
|
|
163
|
-
caption: PropTypes.oneOfType([
|
|
164
|
-
PropTypes.string,
|
|
165
|
-
PropTypes.element,
|
|
166
|
-
]),
|
|
167
|
-
className: PropTypes.string,
|
|
168
|
-
/** specifies the order and contents of the table's columns and provides display strings for each column's heading. It is composed of an ordered array of objects. Each object contains the following keys:
|
|
169
|
-
|
|
170
|
-
1. `label` (string or element; required) contains the display string for each column's heading.
|
|
171
|
-
2. `key` (string; required) maps that label to its corresponding datum for each row in `data`, to ensure table data are displayed in their appropriate columns.
|
|
172
|
-
3. `columnSortable` (boolean; optional) specifies at the column-level whether the column is sortable. If `columnSortable` is `true`, a sort button will be rendered in the column table heading. It is only required if `tableSortable` is set to `true`.
|
|
173
|
-
4. `onSort` (function; conditionally required) specifies what function is called when a sortable column is clicked. It is only required if the column's `columnSortable` is set to `true`.
|
|
174
|
-
5. `hideHeader` (boolean; optional) specifies at the column-level whether the column label is visible. A column that is sortable cannot have its label be hidden.
|
|
175
|
-
6. `width` (string; conditionally required) only if `hasFixedColumnWidths` is set to `true`, the `<td>` elements' `class` attributes will be set to this value. This allows restricting columns to specific widths. See [Bootstrap's grid documentation](https://getbootstrap.com/docs/4.0/layout/grid/) for `col` class names that can be used.
|
|
176
|
-
|
|
177
|
-
The order of objects in `columns` specifies the order of the columns in the table. */
|
|
178
|
-
data: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
|
179
|
-
/** specifies the order and contents of the table's columns and provides display strings for each column's heading. It is composed of an ordered array of objects. Each object contains the following keys:
|
|
180
|
-
|
|
181
|
-
1. `label` (string or element; required) contains the display string for each column's heading.
|
|
182
|
-
2. `key` (string; required) maps that label to its corresponding datum for each row in `data`, to ensure table data are displayed in their appropriate columns.
|
|
183
|
-
3. `columnSortable` (boolean; optional) specifies at the column-level whether the column is sortable. If `columnSortable` is `true`, a sort button will be rendered in the column table heading. It is only required if `tableSortable` is set to `true`.
|
|
184
|
-
4. `onSort` (function; conditionally required) specifies what function is called when a sortable column is clicked. It is only required if the column's `columnSortable` is set to `true`.
|
|
185
|
-
5. `hideHeader` (boolean; optional) specifies at the column-level whether the column label is visible. A column that is sortable cannot have its label be hidden.
|
|
186
|
-
6. `width` (string; conditionally required) only if `hasFixedColumnWidths` is set to `true`, the `<td>` elements' `class` attributes will be set to this value. This allows restricting columns to specific widths. See [Bootstrap's grid documentation](https://getbootstrap.com/docs/4.0/layout/grid/) for `col` class names that can be used.
|
|
187
|
-
|
|
188
|
-
The order of objects in `columns` specifies the order of the columns in the table. */
|
|
189
|
-
columns: PropTypes.arrayOf(PropTypes.shape({
|
|
190
|
-
key: PropTypes.string.isRequired,
|
|
191
|
-
label: PropTypes.oneOfType([
|
|
192
|
-
PropTypes.string,
|
|
193
|
-
PropTypes.element,
|
|
194
|
-
]).isRequired,
|
|
195
|
-
columnSortable: isRequiredIf(PropTypes.bool, props => props.tableSortable),
|
|
196
|
-
onSort: isRequiredIf(PropTypes.func, props => props.columnSortable),
|
|
197
|
-
hideHeader: PropTypes.bool,
|
|
198
|
-
width: isRequiredIf(PropTypes.string, props => props.hasFixedColumnWidths),
|
|
199
|
-
})).isRequired,
|
|
200
|
-
/** Specifies Bootstrap class names to apply to the table heading. Options are detailed in [Bootstrap's docs](https://getbootstrap.com/docs/4.0/content/tables/#table-head-options).
|
|
201
|
-
*/
|
|
202
|
-
headingClassName: PropTypes.arrayOf(PropTypes.string),
|
|
203
|
-
/** Specifies whether the table is sortable. This setting supercedes column-level sortability, so if it is `false`, no sortable components will be rendered. */
|
|
204
|
-
tableSortable: PropTypes.bool,
|
|
205
|
-
/** Specifies whether the table's columns have fixed widths. Every element in `columns` must define a `width` if this is `true`.
|
|
206
|
-
*/
|
|
207
|
-
hasFixedColumnWidths: PropTypes.bool,
|
|
208
|
-
/* eslint-disable react/require-default-props */
|
|
209
|
-
/** Specifies the key of the column that is sorted by default. It is only required if `tableSortable` is set to `true`. */
|
|
210
|
-
defaultSortedColumn: isRequiredIf(PropTypes.string, props => props.tableSortable),
|
|
211
|
-
/* eslint-disable react/require-default-props */
|
|
212
|
-
/** Specifies the direction the `defaultSortedColumn` is sorted in by default; it will typically be either 'asc' or 'desc'. It is only required if `tableSortable` is set to `true`. */
|
|
213
|
-
defaultSortDirection: isRequiredIf(PropTypes.string, props => props.tableSortable),
|
|
214
|
-
/** Specifies the screen reader only text that accompanies the sort buttons for sortable columns. It takes the form of an object containing the following keys:
|
|
215
|
-
|
|
216
|
-
1. `asc`: (string) specifies the screen reader only text for sort buttons in the ascending state.
|
|
217
|
-
2. `desc`: (string) specifies the screen reader only text for sort buttons in the descending state.
|
|
218
|
-
3. `defaultText`: (string) specifies the screen reader only text for sort buttons that are not engaged.
|
|
219
|
-
|
|
220
|
-
It is only required if `tableSortable` is set to `true`.
|
|
221
|
-
|
|
222
|
-
Default:
|
|
223
|
-
|
|
224
|
-
```javascript
|
|
225
|
-
{
|
|
226
|
-
asc: 'sort ascending',
|
|
227
|
-
desc: 'sort descending',
|
|
228
|
-
defaultText: 'click to sort',
|
|
229
|
-
}
|
|
230
|
-
``` */
|
|
231
|
-
sortButtonsScreenReaderText: isRequiredIf(
|
|
232
|
-
PropTypes.shape({
|
|
233
|
-
asc: PropTypes.string,
|
|
234
|
-
desc: PropTypes.string,
|
|
235
|
-
defaultText: PropTypes.string,
|
|
236
|
-
}),
|
|
237
|
-
props => props.tableSortable,
|
|
238
|
-
),
|
|
239
|
-
/** Specifies the key for the column that should act as a row header. Rather than rendering as `<td>` elements,
|
|
240
|
-
cells in this column will render as `<th scope="row">` */
|
|
241
|
-
rowHeaderColumnKey: PropTypes.string,
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
Table.defaultProps = {
|
|
245
|
-
caption: null,
|
|
246
|
-
className: undefined,
|
|
247
|
-
headingClassName: [],
|
|
248
|
-
tableSortable: false,
|
|
249
|
-
hasFixedColumnWidths: false,
|
|
250
|
-
sortButtonsScreenReaderText: {
|
|
251
|
-
asc: 'sort ascending',
|
|
252
|
-
desc: 'sort descending',
|
|
253
|
-
defaultText: 'click to sort',
|
|
254
|
-
},
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
export default withDeprecatedProps(Table, 'TableDeprecated', {
|
|
258
|
-
className: {
|
|
259
|
-
deprType: DeprTypes.FORMAT,
|
|
260
|
-
expect: value => typeof value === 'string',
|
|
261
|
-
transform: value => (Array.isArray(value) ? value.join(' ') : value),
|
|
262
|
-
message: 'It should be a string.',
|
|
263
|
-
},
|
|
264
|
-
});
|