buefy 1.0.0 → 1.0.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/LICENSE.md +21 -0
- package/README.md +242 -0
- package/dist/buefy.css +15895 -0
- package/dist/buefy.d.ts +11706 -0
- package/dist/buefy.esm.js +21082 -0
- package/dist/buefy.esm.min.js +2 -0
- package/dist/buefy.js +21227 -0
- package/dist/buefy.min.css +1 -0
- package/dist/buefy.min.js +2 -0
- package/dist/cjs/Autocomplete-BMmOsPiK.js +864 -0
- package/dist/cjs/Button-Cq7yqI8p.js +118 -0
- package/dist/cjs/CheckRadioMixin-CDu0SN3g.js +58 -0
- package/dist/cjs/Checkbox-GPzAMQqM.js +85 -0
- package/dist/cjs/CompatFallthroughMixin-hhK0Gkhr.js +48 -0
- package/dist/cjs/Datepicker-B-9ReBe6.js +2120 -0
- package/dist/cjs/Dropdown-DtpKU9qf.js +470 -0
- package/dist/cjs/DropdownItem-IMOKyRGV.js +110 -0
- package/dist/cjs/Field-19ZCJFF8.js +405 -0
- package/dist/cjs/FormElementMixin-DavX4iOv.js +170 -0
- package/dist/cjs/Icon-lsDKE2wQ.js +184 -0
- package/dist/cjs/Image-CocPwU3n.js +356 -0
- package/dist/cjs/InjectedChildMixin-CUKn09dB.js +150 -0
- package/dist/cjs/Input-BcloGeZ3.js +350 -0
- package/dist/cjs/Loading-GqqqjipO.js +145 -0
- package/dist/cjs/MessageMixin-bGuuzfev.js +136 -0
- package/dist/cjs/Modal-CYpSQe2Q.js +315 -0
- package/dist/cjs/NoticeMixin--3RjH43z.js +163 -0
- package/dist/cjs/Pagination-D1MVdiLp.js +547 -0
- package/dist/cjs/Progress-DT9Qc8Id.js +177 -0
- package/dist/cjs/Select-DayPKwCY.js +147 -0
- package/dist/cjs/SlotComponent-BruGdRW3.js +41 -0
- package/dist/cjs/TabbedChildMixin-B3JUUwcf.js +211 -0
- package/dist/cjs/Tag-BprnwJJ1.js +167 -0
- package/dist/cjs/Timepicker-CDZ3V-2J.js +283 -0
- package/dist/cjs/TimepickerMixin-C9WVvcUL.js +666 -0
- package/dist/cjs/Tooltip-Cgighv0j.js +393 -0
- package/dist/cjs/_plugin-vue_export-helper-Die8u8yB.js +11 -0
- package/dist/cjs/autocomplete.js +23 -0
- package/dist/cjs/breadcrumb.js +107 -0
- package/dist/cjs/button.js +20 -0
- package/dist/cjs/carousel.js +825 -0
- package/dist/cjs/checkbox.js +88 -0
- package/dist/cjs/clockpicker.js +668 -0
- package/dist/cjs/collapse.js +99 -0
- package/dist/cjs/colorpicker.js +25 -0
- package/dist/cjs/config-DR826Ki2.js +103 -0
- package/dist/cjs/config.js +18 -0
- package/dist/cjs/datepicker.js +28 -0
- package/dist/cjs/datetimepicker.js +483 -0
- package/dist/cjs/dialog.js +506 -0
- package/dist/cjs/dropdown.js +23 -0
- package/dist/cjs/field.js +19 -0
- package/dist/cjs/helpers.js +276 -0
- package/dist/cjs/icon.js +19 -0
- package/dist/cjs/image.js +19 -0
- package/dist/cjs/index-DiQy3SCb.js +1942 -0
- package/dist/cjs/index.js +274 -0
- package/dist/cjs/input.js +22 -0
- package/dist/cjs/loading.js +87 -0
- package/dist/cjs/menu.js +340 -0
- package/dist/cjs/message.js +119 -0
- package/dist/cjs/modal.js +103 -0
- package/dist/cjs/navbar.js +572 -0
- package/dist/cjs/notification.js +281 -0
- package/dist/cjs/numberinput.js +386 -0
- package/dist/cjs/pagination.js +22 -0
- package/dist/cjs/plugins-DbyYGVpp.js +16 -0
- package/dist/cjs/progress.js +91 -0
- package/dist/cjs/radio.js +137 -0
- package/dist/cjs/rate.js +197 -0
- package/dist/cjs/select.js +22 -0
- package/dist/cjs/sidebar.js +309 -0
- package/dist/cjs/skeleton.js +78 -0
- package/dist/cjs/slider.js +699 -0
- package/dist/cjs/snackbar.js +224 -0
- package/dist/cjs/ssr-DVRFTu_P.js +8 -0
- package/dist/cjs/steps.js +347 -0
- package/dist/cjs/switch.js +161 -0
- package/dist/cjs/table.js +2391 -0
- package/dist/cjs/tabs.js +258 -0
- package/dist/cjs/tag.js +44 -0
- package/dist/cjs/taginput.js +425 -0
- package/dist/cjs/timepicker.js +29 -0
- package/dist/cjs/toast.js +162 -0
- package/dist/cjs/tooltip.js +19 -0
- package/dist/cjs/trapFocus-BlX6xykt.js +53 -0
- package/dist/cjs/upload.js +195 -0
- package/dist/components/autocomplete/index.js +1647 -0
- package/dist/components/autocomplete/index.min.js +2 -0
- package/dist/components/breadcrumb/index.js +173 -0
- package/dist/components/breadcrumb/index.min.js +2 -0
- package/dist/components/button/index.js +334 -0
- package/dist/components/button/index.min.js +2 -0
- package/dist/components/carousel/index.js +1534 -0
- package/dist/components/carousel/index.min.js +2 -0
- package/dist/components/checkbox/index.js +236 -0
- package/dist/components/checkbox/index.min.js +2 -0
- package/dist/components/clockpicker/index.js +2636 -0
- package/dist/components/clockpicker/index.min.js +2 -0
- package/dist/components/collapse/index.js +111 -0
- package/dist/components/collapse/index.min.js +2 -0
- package/dist/components/colorpicker/index.js +4251 -0
- package/dist/components/colorpicker/index.min.js +2 -0
- package/dist/components/datepicker/index.js +4110 -0
- package/dist/components/datepicker/index.min.js +2 -0
- package/dist/components/datetimepicker/index.js +5479 -0
- package/dist/components/datetimepicker/index.min.js +2 -0
- package/dist/components/dialog/index.js +1202 -0
- package/dist/components/dialog/index.min.js +2 -0
- package/dist/components/dropdown/index.js +680 -0
- package/dist/components/dropdown/index.min.js +2 -0
- package/dist/components/field/index.js +439 -0
- package/dist/components/field/index.min.js +2 -0
- package/dist/components/icon/index.js +212 -0
- package/dist/components/icon/index.min.js +2 -0
- package/dist/components/image/index.js +396 -0
- package/dist/components/image/index.min.js +2 -0
- package/dist/components/input/index.js +764 -0
- package/dist/components/input/index.min.js +2 -0
- package/dist/components/loading/index.js +280 -0
- package/dist/components/loading/index.min.js +2 -0
- package/dist/components/menu/index.js +586 -0
- package/dist/components/menu/index.min.js +2 -0
- package/dist/components/message/index.js +611 -0
- package/dist/components/message/index.min.js +2 -0
- package/dist/components/modal/index.js +516 -0
- package/dist/components/modal/index.min.js +2 -0
- package/dist/components/navbar/index.js +634 -0
- package/dist/components/navbar/index.min.js +2 -0
- package/dist/components/notification/index.js +976 -0
- package/dist/components/notification/index.min.js +2 -0
- package/dist/components/numberinput/index.js +1128 -0
- package/dist/components/numberinput/index.min.js +2 -0
- package/dist/components/pagination/index.js +764 -0
- package/dist/components/pagination/index.min.js +2 -0
- package/dist/components/progress/index.js +280 -0
- package/dist/components/progress/index.min.js +2 -0
- package/dist/components/radio/index.js +208 -0
- package/dist/components/radio/index.min.js +2 -0
- package/dist/components/rate/index.js +391 -0
- package/dist/components/rate/index.min.js +2 -0
- package/dist/components/select/index.js +560 -0
- package/dist/components/select/index.min.js +2 -0
- package/dist/components/sidebar/index.js +337 -0
- package/dist/components/sidebar/index.min.js +2 -0
- package/dist/components/skeleton/index.js +87 -0
- package/dist/components/skeleton/index.min.js +2 -0
- package/dist/components/slider/index.js +1171 -0
- package/dist/components/slider/index.min.js +2 -0
- package/dist/components/snackbar/index.js +439 -0
- package/dist/components/snackbar/index.min.js +2 -0
- package/dist/components/steps/index.js +925 -0
- package/dist/components/steps/index.min.js +2 -0
- package/dist/components/switch/index.js +182 -0
- package/dist/components/switch/index.min.js +2 -0
- package/dist/components/table/index.js +4208 -0
- package/dist/components/table/index.min.js +2 -0
- package/dist/components/tabs/index.js +837 -0
- package/dist/components/tabs/index.min.js +2 -0
- package/dist/components/tag/index.js +396 -0
- package/dist/components/tag/index.min.js +2 -0
- package/dist/components/taginput/index.js +2209 -0
- package/dist/components/taginput/index.min.js +2 -0
- package/dist/components/timepicker/index.js +2906 -0
- package/dist/components/timepicker/index.min.js +2 -0
- package/dist/components/toast/index.js +377 -0
- package/dist/components/toast/index.min.js +2 -0
- package/dist/components/tooltip/index.js +445 -0
- package/dist/components/tooltip/index.min.js +2 -0
- package/dist/components/upload/index.js +426 -0
- package/dist/components/upload/index.min.js +2 -0
- package/dist/esm/Autocomplete-CjbTh9D8.js +862 -0
- package/dist/esm/Button-DyUYShTZ.js +116 -0
- package/dist/esm/CheckRadioMixin-DSD_rjC8.js +56 -0
- package/dist/esm/Checkbox-KUMz0sfA.js +83 -0
- package/dist/esm/CompatFallthroughMixin-C8LPuwDr.js +46 -0
- package/dist/esm/Datepicker-Bl8Wfdkn.js +2118 -0
- package/dist/esm/Dropdown-CGTYVyoL.js +467 -0
- package/dist/esm/DropdownItem-Cn3nM0A3.js +108 -0
- package/dist/esm/Field-B7bX_uUg.js +403 -0
- package/dist/esm/FormElementMixin-Dd_wkBN5.js +168 -0
- package/dist/esm/Icon-DPyGDeRK.js +182 -0
- package/dist/esm/Image-DhX-4hlV.js +354 -0
- package/dist/esm/InjectedChildMixin-D2K-FwuO.js +145 -0
- package/dist/esm/Input-C4L520az.js +348 -0
- package/dist/esm/Loading-tuQoo6TU.js +143 -0
- package/dist/esm/MessageMixin-CQ7LIdvq.js +134 -0
- package/dist/esm/Modal-tfvyhxw_.js +313 -0
- package/dist/esm/NoticeMixin-ByNlva3T.js +161 -0
- package/dist/esm/Pagination-B-LAJQay.js +543 -0
- package/dist/esm/Progress-BPGTVZgr.js +174 -0
- package/dist/esm/Select-bl4qUzij.js +145 -0
- package/dist/esm/SlotComponent-BwNpVnfH.js +39 -0
- package/dist/esm/TabbedChildMixin-C4i6WP9j.js +208 -0
- package/dist/esm/Tag-jS5Bcj6N.js +165 -0
- package/dist/esm/Timepicker-DnkqnOBT.js +281 -0
- package/dist/esm/TimepickerMixin-Bikh6_Fg.js +664 -0
- package/dist/esm/Tooltip-CtDSXAqa.js +391 -0
- package/dist/esm/_plugin-vue_export-helper-OJRSZE6i.js +9 -0
- package/dist/esm/autocomplete.js +18 -0
- package/dist/esm/breadcrumb.js +101 -0
- package/dist/esm/button.js +15 -0
- package/dist/esm/carousel.js +818 -0
- package/dist/esm/checkbox.js +82 -0
- package/dist/esm/clockpicker.js +663 -0
- package/dist/esm/collapse.js +94 -0
- package/dist/esm/colorpicker.js +16 -0
- package/dist/esm/config-CKuo-p6e.js +100 -0
- package/dist/esm/config.js +14 -0
- package/dist/esm/datepicker.js +23 -0
- package/dist/esm/datetimepicker.js +478 -0
- package/dist/esm/dialog.js +500 -0
- package/dist/esm/dropdown.js +17 -0
- package/dist/esm/field.js +14 -0
- package/dist/esm/helpers.js +247 -0
- package/dist/esm/icon.js +14 -0
- package/dist/esm/image.js +14 -0
- package/dist/esm/index-CQegEsxK.js +1938 -0
- package/dist/esm/index.js +164 -0
- package/dist/esm/input.js +17 -0
- package/dist/esm/loading.js +81 -0
- package/dist/esm/menu.js +333 -0
- package/dist/esm/message.js +114 -0
- package/dist/esm/modal.js +97 -0
- package/dist/esm/navbar.js +565 -0
- package/dist/esm/notification.js +275 -0
- package/dist/esm/numberinput.js +381 -0
- package/dist/esm/pagination.js +16 -0
- package/dist/esm/plugins-B172kuKE.js +13 -0
- package/dist/esm/progress.js +85 -0
- package/dist/esm/radio.js +131 -0
- package/dist/esm/rate.js +192 -0
- package/dist/esm/select.js +17 -0
- package/dist/esm/sidebar.js +304 -0
- package/dist/esm/skeleton.js +73 -0
- package/dist/esm/slider.js +693 -0
- package/dist/esm/snackbar.js +218 -0
- package/dist/esm/ssr-C7yEpGLm.js +5 -0
- package/dist/esm/steps.js +341 -0
- package/dist/esm/switch.js +156 -0
- package/dist/esm/table.js +2385 -0
- package/dist/esm/tabs.js +252 -0
- package/dist/esm/tag.js +38 -0
- package/dist/esm/taginput.js +420 -0
- package/dist/esm/timepicker.js +24 -0
- package/dist/esm/toast.js +156 -0
- package/dist/esm/tooltip.js +14 -0
- package/dist/esm/trapFocus-KHP_kCNE.js +51 -0
- package/dist/esm/upload.js +190 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/package.json +73 -6
- package/src/components/autocomplete/Autocomplete.spec.ts +783 -0
- package/src/components/autocomplete/Autocomplete.vue +966 -0
- package/src/components/autocomplete/__snapshots__/Autocomplete.spec.ts.snap +21 -0
- package/src/components/autocomplete/index.ts +16 -0
- package/src/components/breadcrumb/Breadcrumb.spec.ts +65 -0
- package/src/components/breadcrumb/Breadcrumb.vue +42 -0
- package/src/components/breadcrumb/BreadcrumbItem.spec.ts +74 -0
- package/src/components/breadcrumb/BreadcrumbItem.vue +34 -0
- package/src/components/breadcrumb/__snapshots__/Breadcrumb.spec.ts.snap +7 -0
- package/src/components/breadcrumb/__snapshots__/BreadcrumbItem.spec.ts.snap +3 -0
- package/src/components/breadcrumb/index.ts +19 -0
- package/src/components/button/Button.spec.ts +117 -0
- package/src/components/button/Button.vue +112 -0
- package/src/components/button/__snapshots__/Button.spec.ts.snap +9 -0
- package/src/components/button/index.ts +16 -0
- package/src/components/carousel/Carousel.spec.ts +304 -0
- package/src/components/carousel/Carousel.vue +389 -0
- package/src/components/carousel/CarouselItem.spec.ts +105 -0
- package/src/components/carousel/CarouselItem.vue +38 -0
- package/src/components/carousel/CarouselList.spec.ts +172 -0
- package/src/components/carousel/CarouselList.vue +364 -0
- package/src/components/carousel/__snapshots__/Carousel.spec.ts.snap +19 -0
- package/src/components/carousel/__snapshots__/CarouselItem.spec.ts.snap +7 -0
- package/src/components/carousel/__snapshots__/CarouselList.spec.ts.snap +36 -0
- package/src/components/carousel/index.ts +23 -0
- package/src/components/carousel/types.ts +17 -0
- package/src/components/checkbox/Checkbox.spec.ts +40 -0
- package/src/components/checkbox/Checkbox.vue +63 -0
- package/src/components/checkbox/CheckboxButton.spec.ts +46 -0
- package/src/components/checkbox/CheckboxButton.vue +59 -0
- package/src/components/checkbox/__snapshots__/Checkbox.spec.ts.snap +9 -0
- package/src/components/checkbox/__snapshots__/CheckboxButton.spec.ts.snap +3 -0
- package/src/components/checkbox/index.ts +20 -0
- package/src/components/clockpicker/Clockpicker.spec.ts +161 -0
- package/src/components/clockpicker/Clockpicker.vue +311 -0
- package/src/components/clockpicker/ClockpickerFace.spec.ts +99 -0
- package/src/components/clockpicker/ClockpickerFace.vue +272 -0
- package/src/components/clockpicker/__snapshots__/Clockpicker.spec.ts.snap +36 -0
- package/src/components/clockpicker/__snapshots__/ClockpickerFace.spec.ts.snap +9 -0
- package/src/components/clockpicker/index.ts +16 -0
- package/src/components/collapse/Collapse.spec.ts +106 -0
- package/src/components/collapse/Collapse.vue +98 -0
- package/src/components/collapse/__snapshots__/Collapse.spec.ts.snap +10 -0
- package/src/components/collapse/index.ts +16 -0
- package/src/components/colorpicker/Colorpicker.spec.ts +22 -0
- package/src/components/colorpicker/Colorpicker.vue +416 -0
- package/src/components/colorpicker/ColorpickerAlphaSlider.spec.ts +17 -0
- package/src/components/colorpicker/ColorpickerAlphaSlider.vue +205 -0
- package/src/components/colorpicker/ColorpickerHSLRepresentationSquare.spec.ts +23 -0
- package/src/components/colorpicker/ColorpickerHSLRepresentationSquare.vue +380 -0
- package/src/components/colorpicker/ColorpickerHSLRepresentationTriangle.spec.ts +23 -0
- package/src/components/colorpicker/ColorpickerHSLRepresentationTriangle.vue +456 -0
- package/src/components/colorpicker/__snapshots__/Colorpicker.spec.ts.snap +77 -0
- package/src/components/colorpicker/__snapshots__/ColorpickerAlphaSlider.spec.ts.snap +9 -0
- package/src/components/colorpicker/__snapshots__/ColorpickerHSLRepresentationSquare.spec.ts.snap +12 -0
- package/src/components/colorpicker/__snapshots__/ColorpickerHSLRepresentationTriangle.spec.ts.snap +36 -0
- package/src/components/colorpicker/index.ts +16 -0
- package/src/components/datepicker/Datepicker.spec.ts +482 -0
- package/src/components/datepicker/Datepicker.vue +908 -0
- package/src/components/datepicker/DatepickerMonth.spec.ts +346 -0
- package/src/components/datepicker/DatepickerMonth.vue +444 -0
- package/src/components/datepicker/DatepickerTable.spec.ts +290 -0
- package/src/components/datepicker/DatepickerTable.vue +398 -0
- package/src/components/datepicker/DatepickerTableRow.spec.ts +300 -0
- package/src/components/datepicker/DatepickerTableRow.vue +416 -0
- package/src/components/datepicker/__snapshots__/Datepicker.spec.ts.snap +54 -0
- package/src/components/datepicker/__snapshots__/DatepickerMonth.spec.ts.snap +33 -0
- package/src/components/datepicker/__snapshots__/DatepickerTable.spec.ts.snap +16 -0
- package/src/components/datepicker/__snapshots__/DatepickerTableRow.spec.ts.snap +23 -0
- package/src/components/datepicker/index.ts +17 -0
- package/src/components/datepicker/types.ts +41 -0
- package/src/components/datetimepicker/Datetimepicker.spec.ts +132 -0
- package/src/components/datetimepicker/Datetimepicker.vue +491 -0
- package/src/components/datetimepicker/index.ts +16 -0
- package/src/components/dialog/Dialog.spec.ts +108 -0
- package/src/components/dialog/Dialog.vue +300 -0
- package/src/components/dialog/index.ts +169 -0
- package/src/components/dropdown/Dropdown.spec.ts +229 -0
- package/src/components/dropdown/Dropdown.vue +491 -0
- package/src/components/dropdown/DropdownItem.spec.ts +78 -0
- package/src/components/dropdown/DropdownItem.vue +112 -0
- package/src/components/dropdown/__snapshots__/Dropdown.spec.ts.snap +15 -0
- package/src/components/dropdown/__snapshots__/DropdownItem.spec.ts.snap +3 -0
- package/src/components/dropdown/index.ts +20 -0
- package/src/components/field/Field.spec.ts +324 -0
- package/src/components/field/Field.vue +316 -0
- package/src/components/field/FieldBody.spec.ts +96 -0
- package/src/components/field/FieldBody.vue +74 -0
- package/src/components/field/__snapshots__/Field.spec.ts.snap +8 -0
- package/src/components/field/__snapshots__/FieldBody.spec.ts.snap +3 -0
- package/src/components/field/index.ts +16 -0
- package/src/components/icon/Icon.spec.ts +142 -0
- package/src/components/icon/Icon.vue +120 -0
- package/src/components/icon/__snapshots__/Icon.spec.ts.snap +3 -0
- package/src/components/icon/index.ts +17 -0
- package/src/components/image/Image.spec.ts +218 -0
- package/src/components/image/Image.vue +358 -0
- package/src/components/image/__snapshots__/Image.spec.ts.snap +37 -0
- package/src/components/image/index.ts +16 -0
- package/src/components/index.ts +179 -0
- package/src/components/input/Input.spec.ts +396 -0
- package/src/components/input/Input.vue +335 -0
- package/src/components/input/__snapshots__/Input.spec.ts.snap +9 -0
- package/src/components/input/index.ts +17 -0
- package/src/components/loading/Loading.spec.ts +151 -0
- package/src/components/loading/Loading.vue +135 -0
- package/src/components/loading/__snapshots__/Loading.spec.ts.snap +10 -0
- package/src/components/loading/index.ts +91 -0
- package/src/components/menu/Menu.spec.ts +21 -0
- package/src/components/menu/Menu.vue +31 -0
- package/src/components/menu/MenuItem.spec.ts +92 -0
- package/src/components/menu/MenuItem.vue +168 -0
- package/src/components/menu/MenuItemContainerMixin.ts +72 -0
- package/src/components/menu/MenuList.spec.ts +35 -0
- package/src/components/menu/MenuList.vue +47 -0
- package/src/components/menu/__snapshots__/Menu.spec.ts.snap +3 -0
- package/src/components/menu/__snapshots__/MenuItem.spec.ts.snap +9 -0
- package/src/components/menu/__snapshots__/MenuList.spec.ts.snap +8 -0
- package/src/components/menu/index.ts +25 -0
- package/src/components/message/Message.spec.ts +30 -0
- package/src/components/message/Message.vue +73 -0
- package/src/components/message/__snapshots__/Message.spec.ts.snap +11 -0
- package/src/components/message/index.ts +15 -0
- package/src/components/modal/Modal.spec.ts +167 -0
- package/src/components/modal/Modal.vue +335 -0
- package/src/components/modal/__snapshots__/Modal.spec.ts.snap +10 -0
- package/src/components/modal/index.ts +107 -0
- package/src/components/navbar/NavBar.spec.ts +78 -0
- package/src/components/navbar/NavBarBurger.spec.ts +30 -0
- package/src/components/navbar/NavBarItem.spec.ts +92 -0
- package/src/components/navbar/Navbar.vue +274 -0
- package/src/components/navbar/NavbarBurger.vue +29 -0
- package/src/components/navbar/NavbarDropdown.spec.ts +84 -0
- package/src/components/navbar/NavbarDropdown.vue +115 -0
- package/src/components/navbar/NavbarItem.vue +97 -0
- package/src/components/navbar/__snapshots__/NavBar.spec.ts.snap +11 -0
- package/src/components/navbar/__snapshots__/NavBarBurger.spec.ts.snap +3 -0
- package/src/components/navbar/__snapshots__/NavBarItem.spec.ts.snap +3 -0
- package/src/components/navbar/__snapshots__/NavbarDropdown.spec.ts.snap +7 -0
- package/src/components/navbar/index.ts +22 -0
- package/src/components/notification/Notification.spec.ts +21 -0
- package/src/components/notification/Notification.vue +77 -0
- package/src/components/notification/NotificationNotice.vue +76 -0
- package/src/components/notification/__snapshots__/Notification.spec.ts.snap +10 -0
- package/src/components/notification/index.ts +121 -0
- package/src/components/numberinput/Numberinput.spec.ts +445 -0
- package/src/components/numberinput/Numberinput.vue +372 -0
- package/src/components/numberinput/index.ts +16 -0
- package/src/components/pagination/Pagination.spec.ts +94 -0
- package/src/components/pagination/Pagination.vue +434 -0
- package/src/components/pagination/PaginationButton.spec.ts +42 -0
- package/src/components/pagination/PaginationButton.vue +59 -0
- package/src/components/pagination/__snapshots__/Pagination.spec.ts.snap +22 -0
- package/src/components/pagination/__snapshots__/PaginationButton.spec.ts.snap +3 -0
- package/src/components/pagination/index.ts +19 -0
- package/src/components/pagination/types.ts +11 -0
- package/src/components/progress/Progress.spec.ts +81 -0
- package/src/components/progress/Progress.vue +168 -0
- package/src/components/progress/ProgressBar.spec.ts +45 -0
- package/src/components/progress/ProgressBar.vue +74 -0
- package/src/components/progress/__snapshots__/Progress.spec.ts.snap +7 -0
- package/src/components/progress/__snapshots__/ProgressBar.spec.ts.snap +7 -0
- package/src/components/progress/index.ts +18 -0
- package/src/components/radio/Radio.spec.ts +40 -0
- package/src/components/radio/Radio.vue +35 -0
- package/src/components/radio/RadioButton.spec.ts +40 -0
- package/src/components/radio/RadioButton.vue +69 -0
- package/src/components/radio/__snapshots__/Radio.spec.ts.snap +3 -0
- package/src/components/radio/__snapshots__/RadioButton.spec.ts.snap +3 -0
- package/src/components/radio/index.ts +18 -0
- package/src/components/rate/Rate.spec.ts +90 -0
- package/src/components/rate/Rate.vue +158 -0
- package/src/components/rate/index.ts +15 -0
- package/src/components/select/Select.spec.ts +74 -0
- package/src/components/select/Select.vue +118 -0
- package/src/components/select/__snapshots__/Select.spec.ts.snap +7 -0
- package/src/components/select/index.ts +16 -0
- package/src/components/sidebar/Sidebar.spec.ts +107 -0
- package/src/components/sidebar/Sidebar.vue +316 -0
- package/src/components/sidebar/__snapshots__/Sidebar.spec.ts.snap +25 -0
- package/src/components/sidebar/index.ts +16 -0
- package/src/components/skeleton/Skeleton.spec.ts +16 -0
- package/src/components/skeleton/Skeleton.vue +98 -0
- package/src/components/skeleton/__snapshots__/Skeleton.spec.ts.snap +7 -0
- package/src/components/skeleton/index.ts +18 -0
- package/src/components/slider/Slider.spec.ts +115 -0
- package/src/components/slider/Slider.vue +374 -0
- package/src/components/slider/SliderThumb.spec.ts +176 -0
- package/src/components/slider/SliderThumb.vue +251 -0
- package/src/components/slider/SliderTick.spec.ts +33 -0
- package/src/components/slider/SliderTick.vue +50 -0
- package/src/components/slider/__snapshots__/Slider.spec.ts.snap +12 -0
- package/src/components/slider/__snapshots__/SliderThumb.spec.ts.snap +16 -0
- package/src/components/slider/__snapshots__/SliderTick.spec.ts.snap +7 -0
- package/src/components/slider/index.ts +19 -0
- package/src/components/slider/types.ts +34 -0
- package/src/components/snackbar/Snackbar.spec.ts +35 -0
- package/src/components/snackbar/Snackbar.vue +88 -0
- package/src/components/snackbar/__snapshots__/Snackbar.spec.ts.snap +12 -0
- package/src/components/snackbar/index.ts +118 -0
- package/src/components/steps/StepItem.spec.ts +114 -0
- package/src/components/steps/StepItem.vue +26 -0
- package/src/components/steps/Steps.spec.ts +125 -0
- package/src/components/steps/Steps.vue +273 -0
- package/src/components/steps/__snapshots__/StepItem.spec.ts.snap +7 -0
- package/src/components/steps/__snapshots__/Steps.spec.ts.snap +40 -0
- package/src/components/steps/index.ts +19 -0
- package/src/components/switch/Switch.spec.ts +74 -0
- package/src/components/switch/Switch.vue +146 -0
- package/src/components/switch/__snapshots__/Switch.spec.ts.snap +3 -0
- package/src/components/switch/index.ts +16 -0
- package/src/components/table/Table.spec.ts +622 -0
- package/src/components/table/Table.vue +1770 -0
- package/src/components/table/TableColumn.spec.ts +85 -0
- package/src/components/table/TableColumn.vue +140 -0
- package/src/components/table/TableMobileSort.spec.ts +47 -0
- package/src/components/table/TableMobileSort.vue +236 -0
- package/src/components/table/TablePagination.vue +86 -0
- package/src/components/table/__snapshots__/Table.spec.ts.snap +24 -0
- package/src/components/table/__snapshots__/TableMobileSort.spec.ts.snap +12 -0
- package/src/components/table/index.ts +32 -0
- package/src/components/table/mockTableColumn.ts +110 -0
- package/src/components/table/types.ts +110 -0
- package/src/components/tabs/TabItem.spec.ts +203 -0
- package/src/components/tabs/TabItem.vue +19 -0
- package/src/components/tabs/Tabs.spec.ts +122 -0
- package/src/components/tabs/Tabs.vue +204 -0
- package/src/components/tabs/__snapshots__/TabItem.spec.ts.snap +7 -0
- package/src/components/tabs/__snapshots__/Tabs.spec.ts.snap +33 -0
- package/src/components/tabs/index.ts +19 -0
- package/src/components/tag/Tag.spec.ts +32 -0
- package/src/components/tag/Tag.vue +132 -0
- package/src/components/tag/Taglist.spec.ts +21 -0
- package/src/components/tag/Taglist.vue +16 -0
- package/src/components/tag/__snapshots__/Tag.spec.ts.snap +6 -0
- package/src/components/tag/__snapshots__/Taglist.spec.ts.snap +3 -0
- package/src/components/tag/index.ts +19 -0
- package/src/components/taginput/Taginput.spec.ts +132 -0
- package/src/components/taginput/Taginput.vue +415 -0
- package/src/components/taginput/__snapshots__/Taginput.spec.ts.snap +10 -0
- package/src/components/taginput/index.ts +16 -0
- package/src/components/timepicker/Timepicker.spec.ts +108 -0
- package/src/components/timepicker/Timepicker.vue +183 -0
- package/src/components/timepicker/__snapshots__/Timepicker.spec.ts.snap +41 -0
- package/src/components/timepicker/index.ts +17 -0
- package/src/components/toast/Toast.spec.ts +74 -0
- package/src/components/toast/Toast.vue +46 -0
- package/src/components/toast/__snapshots__/Toast.spec.ts.snap +10 -0
- package/src/components/toast/index.ts +120 -0
- package/src/components/tooltip/Tooltip.spec.ts +64 -0
- package/src/components/tooltip/Tooltip.vue +393 -0
- package/src/components/tooltip/__snapshots__/Tooltip.spec.ts.snap +12 -0
- package/src/components/tooltip/index.ts +16 -0
- package/src/components/upload/Upload.spec.ts +62 -0
- package/src/components/upload/Upload.vue +188 -0
- package/src/components/upload/__snapshots__/Upload.spec.ts.snap +3 -0
- package/src/components/upload/index.ts +15 -0
- package/src/directives/clickOutside.ts +113 -0
- package/src/directives/trapFocus.ts +61 -0
- package/src/index.ts +43 -0
- package/src/scss/buefy-build.scss +6 -0
- package/src/scss/buefy.scss +39 -0
- package/src/scss/components/_autocomplete.scss +39 -0
- package/src/scss/components/_carousel.scss +204 -0
- package/src/scss/components/_checkbox.scss +106 -0
- package/src/scss/components/_clockpicker.scss +283 -0
- package/src/scss/components/_collapse.scss +9 -0
- package/src/scss/components/_colorpicker.scss +283 -0
- package/src/scss/components/_datepicker.scss +220 -0
- package/src/scss/components/_dialog.scss +54 -0
- package/src/scss/components/_dropdown.scss +143 -0
- package/src/scss/components/_form.scss +309 -0
- package/src/scss/components/_icon.scss +16 -0
- package/src/scss/components/_image.scss +20 -0
- package/src/scss/components/_loading.scss +45 -0
- package/src/scss/components/_menu.scss +11 -0
- package/src/scss/components/_message.scss +16 -0
- package/src/scss/components/_modal.scss +37 -0
- package/src/scss/components/_navbar.scss +22 -0
- package/src/scss/components/_notices.scss +144 -0
- package/src/scss/components/_notification.scss +8 -0
- package/src/scss/components/_numberinput.scss +33 -0
- package/src/scss/components/_pagination.scss +63 -0
- package/src/scss/components/_progress.scss +105 -0
- package/src/scss/components/_radio.scss +123 -0
- package/src/scss/components/_rate.scss +72 -0
- package/src/scss/components/_select.scss +38 -0
- package/src/scss/components/_sidebar.scss +107 -0
- package/src/scss/components/_skeleton.scss +66 -0
- package/src/scss/components/_slider.scss +162 -0
- package/src/scss/components/_steps.scss +491 -0
- package/src/scss/components/_switch.scss +214 -0
- package/src/scss/components/_table.scss +322 -0
- package/src/scss/components/_tabs.scss +197 -0
- package/src/scss/components/_tag.scss +36 -0
- package/src/scss/components/_taginput.scss +73 -0
- package/src/scss/components/_timepicker.scss +73 -0
- package/src/scss/components/_tooltip.scss +192 -0
- package/src/scss/components/_upload.scss +62 -0
- package/src/scss/utils/_all.scss +4 -0
- package/src/scss/utils/_animations.scss +183 -0
- package/src/scss/utils/_functions.scss +49 -0
- package/src/scss/utils/_helpers.scss +6 -0
- package/src/scss/utils/_variables-ext.scss +2 -0
- package/src/scss/utils/_variables.scss +16 -0
- package/src/utils/CheckRadioMixin.spec.ts +28 -0
- package/src/utils/CheckRadioMixin.ts +61 -0
- package/src/utils/CompatFallthroughMixin.ts +34 -0
- package/src/utils/ConfigComponent.ts +12 -0
- package/src/utils/FormElementMixin.spec.ts +41 -0
- package/src/utils/FormElementMixin.ts +206 -0
- package/src/utils/InjectedChildMixin.ts +139 -0
- package/src/utils/MessageMixin.spec.ts +51 -0
- package/src/utils/MessageMixin.ts +138 -0
- package/src/utils/NoticeMixin.spec.ts +55 -0
- package/src/utils/NoticeMixin.ts +181 -0
- package/src/utils/ProvideInjectTypes.ts +20 -0
- package/src/utils/ProviderParentMixin.ts +105 -0
- package/src/utils/SlotComponent.spec.ts +55 -0
- package/src/utils/SlotComponent.ts +38 -0
- package/src/utils/TabbedChildMixin.ts +96 -0
- package/src/utils/TabbedMixin.ts +166 -0
- package/src/utils/TabbedTypes.ts +33 -0
- package/src/utils/TimepickerMixin.spec.ts +75 -0
- package/src/utils/TimepickerMixin.ts +767 -0
- package/src/utils/color.spec.ts +55 -0
- package/src/utils/color.ts +507 -0
- package/src/utils/config.spec.ts +11 -0
- package/src/utils/config.ts +619 -0
- package/src/utils/debounce.spec.ts +52 -0
- package/src/utils/debounce.ts +20 -0
- package/src/utils/helpers.spec.ts +257 -0
- package/src/utils/helpers.ts +527 -0
- package/src/utils/icons.ts +73 -0
- package/src/utils/plugins.ts +20 -0
- package/src/utils/ssr.ts +6 -0
- package/src/utils/vue-augmentation.ts +35 -0
|
@@ -0,0 +1,1770 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="b-table" v-bind="rootAttrs">
|
|
3
|
+
<slot />
|
|
4
|
+
|
|
5
|
+
<b-table-mobile-sort
|
|
6
|
+
v-if="mobileCards && hasSortablenewColumns"
|
|
7
|
+
:current-sort-column="currentSortColumn"
|
|
8
|
+
:sort-multiple="sortMultiple"
|
|
9
|
+
:sort-multiple-data="sortMultipleDataComputed"
|
|
10
|
+
:is-asc="isAsc"
|
|
11
|
+
:columns="newColumns"
|
|
12
|
+
:placeholder="mobileSortPlaceholder"
|
|
13
|
+
:icon-pack="iconPack"
|
|
14
|
+
:sort-icon="sortIcon"
|
|
15
|
+
:sort-icon-size="sortIconSize"
|
|
16
|
+
@sort="(column, event) => sort(column, null, event)"
|
|
17
|
+
@remove-priority="(column) => removeSortingPriority(column)"
|
|
18
|
+
/>
|
|
19
|
+
|
|
20
|
+
<template
|
|
21
|
+
v-if="paginated && (paginationPosition === 'top' || paginationPosition === 'both')"
|
|
22
|
+
>
|
|
23
|
+
<slot name="pagination">
|
|
24
|
+
<b-table-pagination
|
|
25
|
+
v-bind="fallthroughAttrs"
|
|
26
|
+
:per-page="perPage"
|
|
27
|
+
:paginated="paginated"
|
|
28
|
+
:rounded="paginationRounded"
|
|
29
|
+
:icon-pack="iconPack"
|
|
30
|
+
:total="newDataTotal"
|
|
31
|
+
v-model:current-page="newCurrentPage"
|
|
32
|
+
:aria-next-label="ariaNextLabel"
|
|
33
|
+
:aria-previous-label="ariaPreviousLabel"
|
|
34
|
+
:aria-page-label="ariaPageLabel"
|
|
35
|
+
:aria-current-label="ariaCurrentLabel"
|
|
36
|
+
@page-change="(event) => $emit('page-change', event)"
|
|
37
|
+
:page-input="pageInput"
|
|
38
|
+
:pagination-order="paginationOrder"
|
|
39
|
+
:page-input-position="pageInputPosition"
|
|
40
|
+
:debounce-page-input="debouncePageInput"
|
|
41
|
+
>
|
|
42
|
+
<slot name="top-left" />
|
|
43
|
+
</b-table-pagination>
|
|
44
|
+
</slot>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<div
|
|
48
|
+
class="table-wrapper"
|
|
49
|
+
:class="tableWrapperClasses"
|
|
50
|
+
:style="tableStyle"
|
|
51
|
+
>
|
|
52
|
+
<table
|
|
53
|
+
class="table"
|
|
54
|
+
:class="tableClasses"
|
|
55
|
+
:tabindex="!focusable ? undefined : 0"
|
|
56
|
+
@keydown.self.prevent.up="pressedArrow(-1)"
|
|
57
|
+
@keydown.self.prevent.down="pressedArrow(1)"
|
|
58
|
+
>
|
|
59
|
+
<caption v-show="showCaption" v-if="caption">
|
|
60
|
+
{{ caption }}
|
|
61
|
+
</caption>
|
|
62
|
+
<thead v-if="newColumns.length && showHeader">
|
|
63
|
+
<tr>
|
|
64
|
+
<th v-if="showDetailRowIcon" width="40px" />
|
|
65
|
+
<th
|
|
66
|
+
:class="['checkbox-cell', { 'is-sticky': stickyCheckbox } ]"
|
|
67
|
+
v-if="checkable && checkboxPosition === 'left'"
|
|
68
|
+
>
|
|
69
|
+
<template v-if="headerCheckable">
|
|
70
|
+
<slot
|
|
71
|
+
name="check-all"
|
|
72
|
+
:is-all-checked="isAllChecked"
|
|
73
|
+
:is-all-uncheckable="isAllUncheckable"
|
|
74
|
+
:check-all="checkAll"
|
|
75
|
+
>
|
|
76
|
+
<b-checkbox
|
|
77
|
+
autocomplete="off"
|
|
78
|
+
:model-value="isAllChecked"
|
|
79
|
+
:type="checkboxType"
|
|
80
|
+
:disabled="isAllUncheckable"
|
|
81
|
+
@change="checkAll"
|
|
82
|
+
/>
|
|
83
|
+
</slot>
|
|
84
|
+
</template>
|
|
85
|
+
</th>
|
|
86
|
+
<th
|
|
87
|
+
v-for="(column, index) in visibleColumns"
|
|
88
|
+
:key="column.newKey + ':' + index + 'header'"
|
|
89
|
+
v-bind="column.thAttrs(column)"
|
|
90
|
+
:class="[column.thClasses, {
|
|
91
|
+
'is-current-sort': !sortMultiple && currentSortColumn === column,
|
|
92
|
+
}]"
|
|
93
|
+
:style="column.thStyle"
|
|
94
|
+
@click.stop="sort(column, null, $event)"
|
|
95
|
+
:draggable="canDragColumn"
|
|
96
|
+
@dragstart="handleColumnDragStart($event, column, index)"
|
|
97
|
+
@dragend="handleColumnDragEnd($event, column, index)"
|
|
98
|
+
@drop="handleColumnDrop($event, column, index)"
|
|
99
|
+
@dragover="handleColumnDragOver($event, column, index)"
|
|
100
|
+
@dragleave="handleColumnDragLeave($event, column, index)"
|
|
101
|
+
@touchstart="handleColumnTouchStart($event)"
|
|
102
|
+
@touchmove="handleColumnTouchMove($event)"
|
|
103
|
+
@touchend="handleColumnTouchEnd($event)"
|
|
104
|
+
>
|
|
105
|
+
<div
|
|
106
|
+
class="th-wrap is-relative"
|
|
107
|
+
:class="{
|
|
108
|
+
'is-numeric': column.numeric,
|
|
109
|
+
'is-centered': column.centered
|
|
110
|
+
}"
|
|
111
|
+
:style="column.thWrapStyle"
|
|
112
|
+
>
|
|
113
|
+
<template v-if="column.$slots.header">
|
|
114
|
+
<b-slot-component
|
|
115
|
+
:component="column"
|
|
116
|
+
scoped
|
|
117
|
+
name="header"
|
|
118
|
+
tag="span"
|
|
119
|
+
:props="{ column, index }"
|
|
120
|
+
/>
|
|
121
|
+
</template>
|
|
122
|
+
<template v-else>
|
|
123
|
+
{{ column.label }}
|
|
124
|
+
<template
|
|
125
|
+
v-if="sortMultiple &&
|
|
126
|
+
sortMultipleDataComputed &&
|
|
127
|
+
sortMultipleDataComputed.length > 0 &&
|
|
128
|
+
sortMultipleDataComputed.filter(i =>
|
|
129
|
+
i.field === column.field).length > 0"
|
|
130
|
+
>
|
|
131
|
+
<span class="multi-sort-icons">
|
|
132
|
+
<b-icon
|
|
133
|
+
:icon="sortIcon"
|
|
134
|
+
:pack="iconPack"
|
|
135
|
+
both
|
|
136
|
+
:size="sortIconSize"
|
|
137
|
+
:class="{
|
|
138
|
+
'is-desc': sortMultipleDataComputed
|
|
139
|
+
.filter(i => i.field === column.field)[0]
|
|
140
|
+
.order === 'desc'}"
|
|
141
|
+
/>
|
|
142
|
+
{{ findIndexOfSortData(column) }}
|
|
143
|
+
<button
|
|
144
|
+
class="delete is-small multi-sort-cancel-icon"
|
|
145
|
+
type="button"
|
|
146
|
+
@click.stop="removeSortingPriority(column)"
|
|
147
|
+
/>
|
|
148
|
+
</span>
|
|
149
|
+
</template>
|
|
150
|
+
|
|
151
|
+
<b-icon
|
|
152
|
+
v-else
|
|
153
|
+
:icon="sortIcon"
|
|
154
|
+
:pack="iconPack"
|
|
155
|
+
both
|
|
156
|
+
:size="sortIconSize"
|
|
157
|
+
class="sort-icon"
|
|
158
|
+
:class="{
|
|
159
|
+
'is-desc': !isAsc,
|
|
160
|
+
'is-invisible': currentSortColumn !== column
|
|
161
|
+
}"
|
|
162
|
+
/>
|
|
163
|
+
</template>
|
|
164
|
+
</div>
|
|
165
|
+
</th>
|
|
166
|
+
<th
|
|
167
|
+
:class="['checkbox-cell', { 'is-sticky': stickyCheckbox } ]"
|
|
168
|
+
v-if="checkable && checkboxPosition === 'right'"
|
|
169
|
+
>
|
|
170
|
+
<template v-if="headerCheckable">
|
|
171
|
+
<slot
|
|
172
|
+
name="check-all"
|
|
173
|
+
:is-all-checked="isAllChecked"
|
|
174
|
+
:is-all-uncheckable="isAllUncheckable"
|
|
175
|
+
:check-all="checkAll"
|
|
176
|
+
>
|
|
177
|
+
<b-checkbox
|
|
178
|
+
autocomplete="off"
|
|
179
|
+
:model-value="isAllChecked"
|
|
180
|
+
:type="checkboxType"
|
|
181
|
+
:disabled="isAllUncheckable"
|
|
182
|
+
@change="checkAll"
|
|
183
|
+
/>
|
|
184
|
+
</slot>
|
|
185
|
+
</template>
|
|
186
|
+
</th>
|
|
187
|
+
</tr>
|
|
188
|
+
<tr v-if="hasCustomSubheadings" class="is-subheading">
|
|
189
|
+
<th v-if="showDetailRowIcon" width="40px" />
|
|
190
|
+
<th v-if="checkable && checkboxPosition === 'left'" />
|
|
191
|
+
<th
|
|
192
|
+
v-for="(column, index) in visibleColumns"
|
|
193
|
+
:key="column.newKey + ':' + index + 'subheading'"
|
|
194
|
+
:style="column.style"
|
|
195
|
+
>
|
|
196
|
+
<div
|
|
197
|
+
class="th-wrap"
|
|
198
|
+
:class="{
|
|
199
|
+
'is-numeric': column.numeric,
|
|
200
|
+
'is-centered': column.centered
|
|
201
|
+
}"
|
|
202
|
+
:style="column.thWrapStyle"
|
|
203
|
+
>
|
|
204
|
+
<template
|
|
205
|
+
v-if="column.$slots.subheading"
|
|
206
|
+
>
|
|
207
|
+
<b-slot-component
|
|
208
|
+
:component="column"
|
|
209
|
+
scoped
|
|
210
|
+
name="subheading"
|
|
211
|
+
tag="span"
|
|
212
|
+
:props="{ column, index }"
|
|
213
|
+
/>
|
|
214
|
+
</template>
|
|
215
|
+
<template v-else>
|
|
216
|
+
{{ column.subheading }}
|
|
217
|
+
</template>
|
|
218
|
+
</div>
|
|
219
|
+
</th>
|
|
220
|
+
<th v-if="checkable && checkboxPosition === 'right'" />
|
|
221
|
+
</tr>
|
|
222
|
+
<tr v-if="hasSearchablenewColumns">
|
|
223
|
+
<th v-if="showDetailRowIcon" width="40px" />
|
|
224
|
+
<th v-if="checkable && checkboxPosition === 'left'" />
|
|
225
|
+
<th
|
|
226
|
+
v-for="(column, index) in visibleColumns"
|
|
227
|
+
:key="column.newKey + ':' + index + 'searchable'"
|
|
228
|
+
v-bind="column.thAttrs(column)"
|
|
229
|
+
:style="column.thStyle"
|
|
230
|
+
:class="{'is-sticky': column.sticky}"
|
|
231
|
+
>
|
|
232
|
+
<div class="th-wrap" :style="column.thWrapStyle">
|
|
233
|
+
<template v-if="column.searchable">
|
|
234
|
+
<template
|
|
235
|
+
v-if="column.$slots.searchable"
|
|
236
|
+
>
|
|
237
|
+
<b-slot-component
|
|
238
|
+
:component="column"
|
|
239
|
+
:scoped="true"
|
|
240
|
+
name="searchable"
|
|
241
|
+
tag="span"
|
|
242
|
+
:props="{ column, filters }"
|
|
243
|
+
/>
|
|
244
|
+
</template>
|
|
245
|
+
<b-input
|
|
246
|
+
v-else
|
|
247
|
+
@[filtersEvent]="onFiltersEvent"
|
|
248
|
+
v-model="filters[column.field!]"
|
|
249
|
+
:type="column.numeric ? 'number' : 'text'"
|
|
250
|
+
/>
|
|
251
|
+
</template>
|
|
252
|
+
</div>
|
|
253
|
+
</th>
|
|
254
|
+
<th v-if="checkable && checkboxPosition === 'right'" />
|
|
255
|
+
</tr>
|
|
256
|
+
</thead>
|
|
257
|
+
<tbody>
|
|
258
|
+
<template
|
|
259
|
+
v-for="(row, index) in visibleData"
|
|
260
|
+
:key="customRowKey ? row[customRowKey] : index"
|
|
261
|
+
>
|
|
262
|
+
<tr
|
|
263
|
+
:class="[rowClass(row, index), {
|
|
264
|
+
'is-selected': isRowSelected(row, selected),
|
|
265
|
+
'is-checked': isRowChecked(row),
|
|
266
|
+
}]"
|
|
267
|
+
@click="selectRow(row)"
|
|
268
|
+
@dblclick="$emit('dblclick', row)"
|
|
269
|
+
@mouseenter="emitEventForRow('mouseenter', $event, row)"
|
|
270
|
+
@mouseleave="emitEventForRow('mouseleave', $event, row)"
|
|
271
|
+
@contextmenu="$emit('contextmenu', row, $event)"
|
|
272
|
+
:draggable="canDragRow"
|
|
273
|
+
@dragstart="handleDragStart($event, row, index)"
|
|
274
|
+
@dragend="handleDragEnd($event, row, index)"
|
|
275
|
+
@drop="handleDrop($event, row, index)"
|
|
276
|
+
@dragover="handleDragOver($event, row, index)"
|
|
277
|
+
@dragleave="handleDragLeave($event, row, index)"
|
|
278
|
+
@touchstart="handleTouchStart($event, row)"
|
|
279
|
+
@touchmove="handleTouchMove($event)"
|
|
280
|
+
@touchend="handleTouchEnd($event)"
|
|
281
|
+
>
|
|
282
|
+
<td
|
|
283
|
+
v-if="showDetailRowIcon"
|
|
284
|
+
class="chevron-cell"
|
|
285
|
+
>
|
|
286
|
+
<a
|
|
287
|
+
v-if="hasDetailedVisible(row)"
|
|
288
|
+
role="button"
|
|
289
|
+
@click.stop="toggleDetails(row)"
|
|
290
|
+
>
|
|
291
|
+
<b-icon
|
|
292
|
+
:icon="detailIcon"
|
|
293
|
+
:pack="iconPack"
|
|
294
|
+
both
|
|
295
|
+
:class="{'is-expanded': isVisibleDetailRow(row)}"
|
|
296
|
+
/>
|
|
297
|
+
</a>
|
|
298
|
+
</td>
|
|
299
|
+
|
|
300
|
+
<td
|
|
301
|
+
:class="['checkbox-cell', { 'is-sticky': stickyCheckbox } ]"
|
|
302
|
+
v-if="checkable && checkboxPosition === 'left'"
|
|
303
|
+
>
|
|
304
|
+
<b-checkbox
|
|
305
|
+
autocomplete="off"
|
|
306
|
+
:model-value="isRowChecked(row)"
|
|
307
|
+
:type="checkboxType"
|
|
308
|
+
:disabled="!isRowCheckable(row)"
|
|
309
|
+
@click.prevent.stop="checkRow(row, index, $event)"
|
|
310
|
+
/>
|
|
311
|
+
</td>
|
|
312
|
+
|
|
313
|
+
<template
|
|
314
|
+
v-for="(column, colindex) in visibleColumns"
|
|
315
|
+
:key="column.newKey + ':' + index + ':' + colindex"
|
|
316
|
+
>
|
|
317
|
+
<template v-if="column.$slots.default">
|
|
318
|
+
<b-slot-component
|
|
319
|
+
:component="column"
|
|
320
|
+
v-bind="column.tdAttrs(row, column)"
|
|
321
|
+
scoped
|
|
322
|
+
name="default"
|
|
323
|
+
tag="td"
|
|
324
|
+
:class="column.getRootClasses(row)"
|
|
325
|
+
:style="column.getRootStyle(row)"
|
|
326
|
+
:data-label="column.label"
|
|
327
|
+
:props="{
|
|
328
|
+
row, column, index, colindex,
|
|
329
|
+
toggleDetails, isActiveDetailRow
|
|
330
|
+
}"
|
|
331
|
+
@click="$emit('cellclick',row,column,index,colindex)"
|
|
332
|
+
/>
|
|
333
|
+
</template>
|
|
334
|
+
</template>
|
|
335
|
+
|
|
336
|
+
<td
|
|
337
|
+
:class="['checkbox-cell', { 'is-sticky': stickyCheckbox } ]"
|
|
338
|
+
v-if="checkable && checkboxPosition === 'right'"
|
|
339
|
+
>
|
|
340
|
+
<b-checkbox
|
|
341
|
+
autocomplete="off"
|
|
342
|
+
:model-value="isRowChecked(row)"
|
|
343
|
+
:type="checkboxType"
|
|
344
|
+
:disabled="!isRowCheckable(row)"
|
|
345
|
+
@click.prevent.stop="checkRow(row, index, $event)"
|
|
346
|
+
/>
|
|
347
|
+
</td>
|
|
348
|
+
</tr>
|
|
349
|
+
|
|
350
|
+
<transition
|
|
351
|
+
:name="detailTransition"
|
|
352
|
+
>
|
|
353
|
+
<tr
|
|
354
|
+
v-if="isActiveDetailRow(row)"
|
|
355
|
+
class="detail"
|
|
356
|
+
>
|
|
357
|
+
<td :colspan="columnCount">
|
|
358
|
+
<div class="detail-container">
|
|
359
|
+
<slot
|
|
360
|
+
name="detail"
|
|
361
|
+
:row="row"
|
|
362
|
+
:index="index"
|
|
363
|
+
/>
|
|
364
|
+
</div>
|
|
365
|
+
</td>
|
|
366
|
+
</tr>
|
|
367
|
+
</transition>
|
|
368
|
+
<slot
|
|
369
|
+
v-if="isActiveCustomDetailRow(row)"
|
|
370
|
+
name="detail"
|
|
371
|
+
:row="row"
|
|
372
|
+
:index="index"
|
|
373
|
+
/>
|
|
374
|
+
</template>
|
|
375
|
+
|
|
376
|
+
<tr
|
|
377
|
+
v-if="!visibleData.length"
|
|
378
|
+
class="is-empty"
|
|
379
|
+
>
|
|
380
|
+
<td :colspan="columnCount">
|
|
381
|
+
<slot name="empty" />
|
|
382
|
+
</td>
|
|
383
|
+
</tr>
|
|
384
|
+
</tbody>
|
|
385
|
+
|
|
386
|
+
<tfoot v-if="$slots.footer !== undefined">
|
|
387
|
+
<tr class="table-footer">
|
|
388
|
+
<slot name="footer" v-if="hasCustomFooterSlot()" />
|
|
389
|
+
<th :colspan="columnCount" v-else>
|
|
390
|
+
<slot name="footer" />
|
|
391
|
+
</th>
|
|
392
|
+
</tr>
|
|
393
|
+
</tfoot>
|
|
394
|
+
</table>
|
|
395
|
+
|
|
396
|
+
<template v-if="loading">
|
|
397
|
+
<slot name="loading">
|
|
398
|
+
<b-loading :is-full-page="false" :model-value="loading" />
|
|
399
|
+
</slot>
|
|
400
|
+
</template>
|
|
401
|
+
</div>
|
|
402
|
+
|
|
403
|
+
<template
|
|
404
|
+
v-if="(checkable && hasBottomLeftSlot()) ||
|
|
405
|
+
(paginated && (paginationPosition === 'bottom' || paginationPosition === 'both'))"
|
|
406
|
+
>
|
|
407
|
+
<slot name="pagination">
|
|
408
|
+
<b-table-pagination
|
|
409
|
+
v-bind="fallthroughAttrs"
|
|
410
|
+
:per-page="perPage"
|
|
411
|
+
:paginated="paginated"
|
|
412
|
+
:rounded="paginationRounded"
|
|
413
|
+
:icon-pack="iconPack"
|
|
414
|
+
:total="newDataTotal"
|
|
415
|
+
v-model:current-page="newCurrentPage"
|
|
416
|
+
:aria-next-label="ariaNextLabel"
|
|
417
|
+
:aria-previous-label="ariaPreviousLabel"
|
|
418
|
+
:aria-page-label="ariaPageLabel"
|
|
419
|
+
:aria-current-label="ariaCurrentLabel"
|
|
420
|
+
@page-change="(event) => $emit('page-change', event)"
|
|
421
|
+
:page-input="pageInput"
|
|
422
|
+
:pagination-order="paginationOrder"
|
|
423
|
+
:page-input-position="pageInputPosition"
|
|
424
|
+
:debounce-page-input="debouncePageInput"
|
|
425
|
+
>
|
|
426
|
+
<slot name="bottom-left" />
|
|
427
|
+
</b-table-pagination>
|
|
428
|
+
</slot>
|
|
429
|
+
</template>
|
|
430
|
+
|
|
431
|
+
<!-- eslint-disable vue/no-v-html -->
|
|
432
|
+
<div
|
|
433
|
+
v-show="mayBeTouchDragging && (isDraggingRow || isDraggingColumn)"
|
|
434
|
+
ref="draggedCell"
|
|
435
|
+
class="touch-dragged-cell"
|
|
436
|
+
:class="touchDraggedCellClasses"
|
|
437
|
+
v-html="draggedCellContent"
|
|
438
|
+
/>
|
|
439
|
+
<!-- eslint-enable vue/no-v-html -->
|
|
440
|
+
</div>
|
|
441
|
+
</template>
|
|
442
|
+
|
|
443
|
+
<script lang="ts">
|
|
444
|
+
import { defineComponent, toRaw } from 'vue'
|
|
445
|
+
import type { PropType } from 'vue'
|
|
446
|
+
|
|
447
|
+
import type { VueClassAttribute } from '../../utils/config'
|
|
448
|
+
import { getValueByPath, indexOf, multiColumnSort, escapeRegExpChars, toCssWidth, removeDiacriticsFromString, isFragment, isNil, translateTouchAsDragEvent, createAbsoluteElement, removeElement } from '../../utils/helpers'
|
|
449
|
+
import debounce from '../../utils/debounce'
|
|
450
|
+
import CompatFallthroughMixin from '../../utils/CompatFallthroughMixin'
|
|
451
|
+
import BCheckbox from '../checkbox/Checkbox.vue'
|
|
452
|
+
import BIcon from '../icon/Icon.vue'
|
|
453
|
+
import BInput from '../input/Input.vue'
|
|
454
|
+
import BLoading from '../loading/Loading.vue'
|
|
455
|
+
import BSlotComponent from '../../utils/SlotComponent'
|
|
456
|
+
import BTableMobileSort from './TableMobileSort.vue'
|
|
457
|
+
import BTablePagination from './TablePagination.vue'
|
|
458
|
+
import mockTableColumn from './mockTableColumn'
|
|
459
|
+
import type {
|
|
460
|
+
CustomSortFunction,
|
|
461
|
+
ITableColumn,
|
|
462
|
+
ModifierKeys,
|
|
463
|
+
TableColumnDragEvent,
|
|
464
|
+
TableColumnOrder,
|
|
465
|
+
TableColumnProps,
|
|
466
|
+
TableRow,
|
|
467
|
+
TableRowDragEvent
|
|
468
|
+
} from './types'
|
|
469
|
+
|
|
470
|
+
// Dummy column object that indicates there is no column present.
|
|
471
|
+
const BLANK_COLUMN = {
|
|
472
|
+
thAttrs: () => ({}),
|
|
473
|
+
tdAttrs: () => ({}),
|
|
474
|
+
getRootClasses: () => [],
|
|
475
|
+
getRootStyle: () => undefined,
|
|
476
|
+
$slots: {}
|
|
477
|
+
} as const
|
|
478
|
+
|
|
479
|
+
// Handler for filters' changes.
|
|
480
|
+
type FiltersChangeHandler = (filters: Record<string, string | number>) => void
|
|
481
|
+
|
|
482
|
+
export default defineComponent({
|
|
483
|
+
name: 'BTable',
|
|
484
|
+
components: {
|
|
485
|
+
BCheckbox,
|
|
486
|
+
BIcon,
|
|
487
|
+
BInput,
|
|
488
|
+
BLoading,
|
|
489
|
+
BSlotComponent,
|
|
490
|
+
BTableMobileSort,
|
|
491
|
+
BTablePagination
|
|
492
|
+
},
|
|
493
|
+
mixins: [CompatFallthroughMixin],
|
|
494
|
+
provide() {
|
|
495
|
+
return {
|
|
496
|
+
$table: this
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
props: {
|
|
500
|
+
data: {
|
|
501
|
+
type: Array as PropType<TableRow[]>,
|
|
502
|
+
default: () => []
|
|
503
|
+
},
|
|
504
|
+
columns: {
|
|
505
|
+
type: Array as PropType<TableColumnProps[]>,
|
|
506
|
+
default: () => []
|
|
507
|
+
},
|
|
508
|
+
bordered: Boolean,
|
|
509
|
+
striped: Boolean,
|
|
510
|
+
narrowed: Boolean,
|
|
511
|
+
hoverable: Boolean,
|
|
512
|
+
loading: Boolean,
|
|
513
|
+
detailed: Boolean,
|
|
514
|
+
checkable: Boolean,
|
|
515
|
+
headerCheckable: {
|
|
516
|
+
type: Boolean,
|
|
517
|
+
default: true
|
|
518
|
+
},
|
|
519
|
+
checkboxType: {
|
|
520
|
+
type: String,
|
|
521
|
+
default: 'is-primary'
|
|
522
|
+
},
|
|
523
|
+
checkboxPosition: {
|
|
524
|
+
type: String,
|
|
525
|
+
default: 'left',
|
|
526
|
+
validator: (value) => {
|
|
527
|
+
return [
|
|
528
|
+
'left',
|
|
529
|
+
'right'
|
|
530
|
+
].indexOf(value as string) >= 0
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
stickyCheckbox: {
|
|
534
|
+
type: Boolean,
|
|
535
|
+
default: false
|
|
536
|
+
},
|
|
537
|
+
selected: Object as PropType<TableRow>,
|
|
538
|
+
isRowSelectable: {
|
|
539
|
+
type: Function,
|
|
540
|
+
default: () => true
|
|
541
|
+
},
|
|
542
|
+
focusable: Boolean,
|
|
543
|
+
customIsChecked: Function as PropType<(a: TableRow, b: TableRow) => boolean>,
|
|
544
|
+
isRowCheckable: {
|
|
545
|
+
type: Function as PropType<(row: TableRow) => boolean>,
|
|
546
|
+
default: () => true
|
|
547
|
+
},
|
|
548
|
+
checkedRows: {
|
|
549
|
+
type: Array<TableRow>,
|
|
550
|
+
default: () => []
|
|
551
|
+
},
|
|
552
|
+
mobileCards: {
|
|
553
|
+
type: Boolean,
|
|
554
|
+
default: true
|
|
555
|
+
},
|
|
556
|
+
defaultSort: [String, Array<string>],
|
|
557
|
+
defaultSortDirection: {
|
|
558
|
+
type: String,
|
|
559
|
+
default: 'asc'
|
|
560
|
+
},
|
|
561
|
+
sortIcon: {
|
|
562
|
+
type: String,
|
|
563
|
+
default: 'arrow-up'
|
|
564
|
+
},
|
|
565
|
+
sortIconSize: {
|
|
566
|
+
type: String,
|
|
567
|
+
default: 'is-small'
|
|
568
|
+
},
|
|
569
|
+
sortMultiple: {
|
|
570
|
+
type: Boolean,
|
|
571
|
+
default: false
|
|
572
|
+
},
|
|
573
|
+
sortMultipleData: {
|
|
574
|
+
type: Array as PropType<TableColumnOrder[]>,
|
|
575
|
+
default: () => []
|
|
576
|
+
},
|
|
577
|
+
sortMultipleKey: {
|
|
578
|
+
type: String as PropType<keyof ModifierKeys | null>,
|
|
579
|
+
default: null
|
|
580
|
+
},
|
|
581
|
+
paginated: Boolean,
|
|
582
|
+
currentPage: {
|
|
583
|
+
type: Number,
|
|
584
|
+
default: 1
|
|
585
|
+
},
|
|
586
|
+
perPage: {
|
|
587
|
+
type: [Number, String],
|
|
588
|
+
default: 20
|
|
589
|
+
},
|
|
590
|
+
showDetailIcon: {
|
|
591
|
+
type: Boolean,
|
|
592
|
+
default: true
|
|
593
|
+
},
|
|
594
|
+
detailIcon: {
|
|
595
|
+
type: String,
|
|
596
|
+
default: 'chevron-right'
|
|
597
|
+
},
|
|
598
|
+
paginationPosition: {
|
|
599
|
+
type: String,
|
|
600
|
+
default: 'bottom',
|
|
601
|
+
validator: (value) => {
|
|
602
|
+
return [
|
|
603
|
+
'bottom',
|
|
604
|
+
'top',
|
|
605
|
+
'both'
|
|
606
|
+
].indexOf(value as string) >= 0
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
paginationRounded: Boolean,
|
|
610
|
+
backendSorting: Boolean,
|
|
611
|
+
backendFiltering: Boolean,
|
|
612
|
+
rowClass: {
|
|
613
|
+
type: Function as PropType<(row: TableRow, index: number) => VueClassAttribute>,
|
|
614
|
+
default: () => ''
|
|
615
|
+
},
|
|
616
|
+
openedDetailed: {
|
|
617
|
+
type: Array<TableRow>,
|
|
618
|
+
default: () => []
|
|
619
|
+
},
|
|
620
|
+
hasDetailedVisible: {
|
|
621
|
+
type: Function as PropType<(row: TableRow) => boolean>,
|
|
622
|
+
default: () => true
|
|
623
|
+
},
|
|
624
|
+
detailKey: {
|
|
625
|
+
type: String,
|
|
626
|
+
default: ''
|
|
627
|
+
},
|
|
628
|
+
detailTransition: {
|
|
629
|
+
type: String,
|
|
630
|
+
default: ''
|
|
631
|
+
},
|
|
632
|
+
customDetailRow: {
|
|
633
|
+
type: Boolean,
|
|
634
|
+
default: false
|
|
635
|
+
},
|
|
636
|
+
backendPagination: Boolean,
|
|
637
|
+
total: {
|
|
638
|
+
type: [Number, String],
|
|
639
|
+
default: 0
|
|
640
|
+
},
|
|
641
|
+
iconPack: String,
|
|
642
|
+
mobileSortPlaceholder: String,
|
|
643
|
+
customRowKey: String,
|
|
644
|
+
draggable: {
|
|
645
|
+
type: Boolean,
|
|
646
|
+
default: false
|
|
647
|
+
},
|
|
648
|
+
draggableColumn: {
|
|
649
|
+
type: Boolean,
|
|
650
|
+
default: false
|
|
651
|
+
},
|
|
652
|
+
scrollable: Boolean,
|
|
653
|
+
ariaNextLabel: String,
|
|
654
|
+
ariaPreviousLabel: String,
|
|
655
|
+
ariaPageLabel: String,
|
|
656
|
+
ariaCurrentLabel: String,
|
|
657
|
+
stickyHeader: Boolean,
|
|
658
|
+
height: [Number, String],
|
|
659
|
+
filtersEvent: {
|
|
660
|
+
type: String,
|
|
661
|
+
default: ''
|
|
662
|
+
},
|
|
663
|
+
cardLayout: Boolean,
|
|
664
|
+
showHeader: {
|
|
665
|
+
type: Boolean,
|
|
666
|
+
default: true
|
|
667
|
+
},
|
|
668
|
+
debounceSearch: Number,
|
|
669
|
+
caption: String,
|
|
670
|
+
showCaption: {
|
|
671
|
+
type: Boolean,
|
|
672
|
+
default: true
|
|
673
|
+
},
|
|
674
|
+
pageInput: {
|
|
675
|
+
type: Boolean,
|
|
676
|
+
default: false
|
|
677
|
+
},
|
|
678
|
+
paginationOrder: String,
|
|
679
|
+
pageInputPosition: String,
|
|
680
|
+
debouncePageInput: [Number, String]
|
|
681
|
+
},
|
|
682
|
+
emits: {
|
|
683
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
684
|
+
cellclick: (
|
|
685
|
+
_row: TableRow,
|
|
686
|
+
_column: ITableColumn,
|
|
687
|
+
_rowIndex: number,
|
|
688
|
+
_colIndex: number
|
|
689
|
+
) => true,
|
|
690
|
+
check: (_checkedRows: TableRow[], _row?: TableRow) => true,
|
|
691
|
+
'check-all': (_rows: TableRow[]) => true,
|
|
692
|
+
click: (_row: TableRow) => true,
|
|
693
|
+
columndragend: (_event: TableColumnDragEvent) => true,
|
|
694
|
+
columndragleave: (_event: TableColumnDragEvent) => true,
|
|
695
|
+
columndragover: (_event: TableColumnDragEvent) => true,
|
|
696
|
+
columndragstart: (_event: TableColumnDragEvent) => true,
|
|
697
|
+
columndrop: (_event: TableColumnDragEvent) => true,
|
|
698
|
+
contextmenu: (_row: TableRow, _event: MouseEvent) => true,
|
|
699
|
+
dblclick: (_row: TableRow) => true,
|
|
700
|
+
'details-close': (_row: TableRow) => true,
|
|
701
|
+
'details-open': (_row: TableRow) => true,
|
|
702
|
+
dragend: (_event: TableRowDragEvent) => true,
|
|
703
|
+
dragleave: (_event: TableRowDragEvent) => true,
|
|
704
|
+
dragover: (_event: TableRowDragEvent) => true,
|
|
705
|
+
dragstart: (_event: TableRowDragEvent) => true,
|
|
706
|
+
drop: (_event: TableRowDragEvent) => true,
|
|
707
|
+
'filters-change': (_value: Record<string, string | number>) => true,
|
|
708
|
+
'page-change': (_page: string | number) => true,
|
|
709
|
+
select: (_new: TableRow, _old: TableRow) => true,
|
|
710
|
+
sort: (
|
|
711
|
+
_field: string | undefined,
|
|
712
|
+
_order: 'asc' | 'desc',
|
|
713
|
+
_event: ModifierKeys | null
|
|
714
|
+
) => true,
|
|
715
|
+
'sorting-priority-removed': (_field: string | undefined) => true,
|
|
716
|
+
'update:checkedRows': (_rows: TableRow[]) => true,
|
|
717
|
+
'update:currentPage': (_page: string | number) => true,
|
|
718
|
+
'update:openedDetailed': (_rows: TableRow[]) => true,
|
|
719
|
+
'update:selected': (_row: TableRow) => true
|
|
720
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
721
|
+
},
|
|
722
|
+
data() {
|
|
723
|
+
return {
|
|
724
|
+
sortMultipleDataLocal: [] as TableColumnOrder[],
|
|
725
|
+
getValueByPath,
|
|
726
|
+
visibleDetailRows: this.openedDetailed,
|
|
727
|
+
newData: this.data,
|
|
728
|
+
newDataTotal: this.backendPagination ? this.total : this.data.length,
|
|
729
|
+
newCheckedRows: [...this.checkedRows],
|
|
730
|
+
lastCheckedRowIndex: null as number | null,
|
|
731
|
+
newCurrentPage: this.currentPage,
|
|
732
|
+
currentSortColumn: {} as ITableColumn,
|
|
733
|
+
isAsc: true,
|
|
734
|
+
filters: {} as Record<string, string | number>,
|
|
735
|
+
defaultSlots: [] as ITableColumn[],
|
|
736
|
+
firstTimeSort: true, // Used by first time initSort
|
|
737
|
+
isDraggingRow: false,
|
|
738
|
+
isDraggingColumn: false,
|
|
739
|
+
debouncedHandleFiltersChange: undefined as FiltersChangeHandler | undefined,
|
|
740
|
+
// for touch-enabled devices
|
|
741
|
+
_selectedRow: null,
|
|
742
|
+
mayBeTouchDragging: false,
|
|
743
|
+
touchDragoverTarget: null as Element | null,
|
|
744
|
+
_draggedCellEl: undefined as Element | undefined,
|
|
745
|
+
draggedCellContent: ''
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
computed: {
|
|
749
|
+
sortMultipleDataComputed() {
|
|
750
|
+
return this.backendSorting ? this.sortMultipleData : this.sortMultipleDataLocal
|
|
751
|
+
},
|
|
752
|
+
tableClasses() {
|
|
753
|
+
return {
|
|
754
|
+
'is-bordered': this.bordered,
|
|
755
|
+
'is-striped': this.striped,
|
|
756
|
+
'is-narrow': this.narrowed,
|
|
757
|
+
'is-hoverable': (
|
|
758
|
+
(this.hoverable || this.focusable) &&
|
|
759
|
+
this.visibleData.length
|
|
760
|
+
)
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
tableWrapperClasses() {
|
|
764
|
+
return {
|
|
765
|
+
'has-mobile-cards': this.mobileCards,
|
|
766
|
+
'has-sticky-header': this.stickyHeader,
|
|
767
|
+
'is-card-list': this.cardLayout,
|
|
768
|
+
'table-container': this.isScrollable
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
tableStyle() {
|
|
772
|
+
return {
|
|
773
|
+
height: toCssWidth(this.height)!
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
touchDraggedCellClasses() {
|
|
777
|
+
return {
|
|
778
|
+
'has-mobile-cards': this.mobileCards
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
|
|
782
|
+
/*
|
|
783
|
+
* Splitted data based on the pagination.
|
|
784
|
+
*/
|
|
785
|
+
visibleData() {
|
|
786
|
+
if (!this.paginated) return this.newData
|
|
787
|
+
|
|
788
|
+
const currentPage = this.newCurrentPage
|
|
789
|
+
const perPage = +this.perPage
|
|
790
|
+
|
|
791
|
+
if (this.newData.length <= perPage) {
|
|
792
|
+
return this.newData
|
|
793
|
+
} else {
|
|
794
|
+
const start = (currentPage - 1) * perPage
|
|
795
|
+
const end = parseInt(start + '', 10) + parseInt(perPage + '', 10)
|
|
796
|
+
return this.newData.slice(start, end)
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
|
|
800
|
+
visibleColumns() {
|
|
801
|
+
if (!this.newColumns) return this.newColumns
|
|
802
|
+
return this.newColumns.filter((column) => {
|
|
803
|
+
return column.visible || column.visible === undefined
|
|
804
|
+
})
|
|
805
|
+
},
|
|
806
|
+
|
|
807
|
+
/*
|
|
808
|
+
* Check if all rows in the page are checked.
|
|
809
|
+
*/
|
|
810
|
+
isAllChecked() {
|
|
811
|
+
const validVisibleData = this.visibleData.filter(
|
|
812
|
+
(row) => this.isRowCheckable(row))
|
|
813
|
+
if (validVisibleData.length === 0) return false
|
|
814
|
+
const isAllChecked = validVisibleData.some((currentVisibleRow) => {
|
|
815
|
+
return indexOf(this.newCheckedRows, currentVisibleRow, this.customIsChecked) < 0
|
|
816
|
+
})
|
|
817
|
+
return !isAllChecked
|
|
818
|
+
},
|
|
819
|
+
|
|
820
|
+
/*
|
|
821
|
+
* Check if all rows in the page are checkable.
|
|
822
|
+
*/
|
|
823
|
+
isAllUncheckable() {
|
|
824
|
+
const validVisibleData = this.visibleData.filter(
|
|
825
|
+
(row) => this.isRowCheckable(row))
|
|
826
|
+
return validVisibleData.length === 0
|
|
827
|
+
},
|
|
828
|
+
|
|
829
|
+
/*
|
|
830
|
+
* Check if has any sortable column.
|
|
831
|
+
*/
|
|
832
|
+
hasSortablenewColumns() {
|
|
833
|
+
return this.newColumns.some((column) => {
|
|
834
|
+
return column.sortable
|
|
835
|
+
})
|
|
836
|
+
},
|
|
837
|
+
|
|
838
|
+
/*
|
|
839
|
+
* Check if has any searchable column.
|
|
840
|
+
*/
|
|
841
|
+
hasSearchablenewColumns() {
|
|
842
|
+
return this.newColumns.some((column) => {
|
|
843
|
+
return column.searchable
|
|
844
|
+
})
|
|
845
|
+
},
|
|
846
|
+
|
|
847
|
+
/*
|
|
848
|
+
* Check if has any column using subheading.
|
|
849
|
+
*/
|
|
850
|
+
hasCustomSubheadings() {
|
|
851
|
+
if (this.$slots && this.$slots.subheading) return true
|
|
852
|
+
return this.newColumns.some((column) => {
|
|
853
|
+
return column.subheading || column.$slots.subheading
|
|
854
|
+
})
|
|
855
|
+
},
|
|
856
|
+
|
|
857
|
+
/*
|
|
858
|
+
* Return total column count based if it's checkable or expanded
|
|
859
|
+
*/
|
|
860
|
+
columnCount() {
|
|
861
|
+
let count = this.visibleColumns.length
|
|
862
|
+
count += this.checkable ? 1 : 0
|
|
863
|
+
count += (this.detailed && this.showDetailIcon) ? 1 : 0
|
|
864
|
+
|
|
865
|
+
return count
|
|
866
|
+
},
|
|
867
|
+
|
|
868
|
+
/*
|
|
869
|
+
* return if detailed row tabled
|
|
870
|
+
* will be with chevron column & icon or not
|
|
871
|
+
*/
|
|
872
|
+
showDetailRowIcon() {
|
|
873
|
+
return this.detailed && this.showDetailIcon
|
|
874
|
+
},
|
|
875
|
+
|
|
876
|
+
/*
|
|
877
|
+
* return if scrollable table
|
|
878
|
+
*/
|
|
879
|
+
isScrollable() {
|
|
880
|
+
if (this.scrollable) return true
|
|
881
|
+
if (!this.newColumns) return false
|
|
882
|
+
return this.newColumns.some((column) => {
|
|
883
|
+
return column.sticky
|
|
884
|
+
})
|
|
885
|
+
},
|
|
886
|
+
|
|
887
|
+
newColumns() {
|
|
888
|
+
if (this.columns && this.columns.length) {
|
|
889
|
+
return this.columns.map((column) => {
|
|
890
|
+
return mockTableColumn(this, column)
|
|
891
|
+
})
|
|
892
|
+
}
|
|
893
|
+
return this.defaultSlots
|
|
894
|
+
},
|
|
895
|
+
canDragRow() {
|
|
896
|
+
return this.draggable && !this.isDraggingColumn
|
|
897
|
+
},
|
|
898
|
+
canDragColumn() {
|
|
899
|
+
return this.draggableColumn && !this.isDraggingRow
|
|
900
|
+
}
|
|
901
|
+
},
|
|
902
|
+
watch: {
|
|
903
|
+
/*
|
|
904
|
+
* When data prop change:
|
|
905
|
+
* 1. Update internal value.
|
|
906
|
+
* 2. Filter data if it's not backend-filtered.
|
|
907
|
+
* 3. Sort again if it's not backend-sorted.
|
|
908
|
+
* 4. Set new total if it's not backend-paginated.
|
|
909
|
+
*/
|
|
910
|
+
data(value) {
|
|
911
|
+
this.newData = value
|
|
912
|
+
if (!this.backendFiltering) {
|
|
913
|
+
this.newData = value.filter(
|
|
914
|
+
(row: TableRow) => this.isRowFiltered(row))
|
|
915
|
+
}
|
|
916
|
+
if (!this.backendSorting) {
|
|
917
|
+
this.sort(this.currentSortColumn, true)
|
|
918
|
+
}
|
|
919
|
+
if (!this.backendPagination) {
|
|
920
|
+
this.newDataTotal = this.newData.length
|
|
921
|
+
}
|
|
922
|
+
},
|
|
923
|
+
|
|
924
|
+
/*
|
|
925
|
+
* When Pagination total change, update internal total
|
|
926
|
+
* only if it's backend-paginated.
|
|
927
|
+
*/
|
|
928
|
+
total(newTotal) {
|
|
929
|
+
if (!this.backendPagination) return
|
|
930
|
+
|
|
931
|
+
this.newDataTotal = newTotal
|
|
932
|
+
},
|
|
933
|
+
|
|
934
|
+
currentPage(newVal) {
|
|
935
|
+
this.newCurrentPage = newVal
|
|
936
|
+
},
|
|
937
|
+
|
|
938
|
+
newCurrentPage(newVal) {
|
|
939
|
+
this.$emit('update:currentPage', newVal)
|
|
940
|
+
},
|
|
941
|
+
|
|
942
|
+
/*
|
|
943
|
+
* When checkedRows prop change, update internal value without
|
|
944
|
+
* mutating original data.
|
|
945
|
+
*/
|
|
946
|
+
checkedRows(rows) {
|
|
947
|
+
this.newCheckedRows = [...rows]
|
|
948
|
+
},
|
|
949
|
+
|
|
950
|
+
debounceSearch: {
|
|
951
|
+
handler(value) {
|
|
952
|
+
this.debouncedHandleFiltersChange = debounce(this.handleFiltersChange, value)
|
|
953
|
+
},
|
|
954
|
+
immediate: true
|
|
955
|
+
},
|
|
956
|
+
|
|
957
|
+
filters: {
|
|
958
|
+
handler(value) {
|
|
959
|
+
if (this.debounceSearch) {
|
|
960
|
+
this.debouncedHandleFiltersChange!(value)
|
|
961
|
+
} else {
|
|
962
|
+
this.handleFiltersChange(value)
|
|
963
|
+
}
|
|
964
|
+
},
|
|
965
|
+
deep: true
|
|
966
|
+
},
|
|
967
|
+
|
|
968
|
+
/*
|
|
969
|
+
* When the user wants to control the detailed rows via props.
|
|
970
|
+
* Or wants to open the details of certain row with the router for example.
|
|
971
|
+
*/
|
|
972
|
+
openedDetailed(expandedRows) {
|
|
973
|
+
this.visibleDetailRows = expandedRows
|
|
974
|
+
}
|
|
975
|
+
},
|
|
976
|
+
methods: {
|
|
977
|
+
onFiltersEvent(event: Event) {
|
|
978
|
+
// @ts-expect-error `filtersEvent` may be any native event, so we cannot exhaustively list possible values in `emits`. btw, the motivation for `filtersEvent`: https://github.com/buefy/buefy/issues/2297
|
|
979
|
+
this.$emit(`filters-event-${this.filtersEvent}`, { event, filters: this.filters })
|
|
980
|
+
},
|
|
981
|
+
handleFiltersChange(value: Record<string, string | number>) {
|
|
982
|
+
if (this.backendFiltering) {
|
|
983
|
+
this.$emit('filters-change', value)
|
|
984
|
+
} else {
|
|
985
|
+
this.newData = this.data.filter(
|
|
986
|
+
(row) => this.isRowFiltered(row))
|
|
987
|
+
if (!this.backendPagination) {
|
|
988
|
+
this.newDataTotal = this.newData.length
|
|
989
|
+
}
|
|
990
|
+
if (!this.backendSorting) {
|
|
991
|
+
if (this.sortMultiple &&
|
|
992
|
+
this.sortMultipleDataLocal && this.sortMultipleDataLocal.length > 0) {
|
|
993
|
+
this.doSortMultiColumn()
|
|
994
|
+
} else if (Object.keys(this.currentSortColumn).length > 0) {
|
|
995
|
+
this.doSortSingleColumn(this.currentSortColumn)
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
findIndexOfSortData(column: ITableColumn) {
|
|
1001
|
+
const sortObj = this.sortMultipleDataComputed.filter((i) =>
|
|
1002
|
+
i.field === column.field)[0]
|
|
1003
|
+
return this.sortMultipleDataComputed.indexOf(sortObj) + 1
|
|
1004
|
+
},
|
|
1005
|
+
removeSortingPriority(column: ITableColumn) {
|
|
1006
|
+
if (this.backendSorting) {
|
|
1007
|
+
this.$emit('sorting-priority-removed', column.field)
|
|
1008
|
+
} else {
|
|
1009
|
+
this.sortMultipleDataLocal = this.sortMultipleDataLocal.filter(
|
|
1010
|
+
(priority) => priority.field !== column.field)
|
|
1011
|
+
|
|
1012
|
+
if (this.sortMultipleDataLocal.length === 0) {
|
|
1013
|
+
this.resetMultiSorting()
|
|
1014
|
+
} else {
|
|
1015
|
+
this.newData = multiColumnSort(this.newData, this.sortMultipleDataLocal)
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
},
|
|
1019
|
+
resetMultiSorting() {
|
|
1020
|
+
this.sortMultipleDataLocal = []
|
|
1021
|
+
this.currentSortColumn = BLANK_COLUMN
|
|
1022
|
+
this.newData = this.data
|
|
1023
|
+
},
|
|
1024
|
+
/*
|
|
1025
|
+
* Sort an array by key without mutating original data.
|
|
1026
|
+
* Call the user sort function if it was passed.
|
|
1027
|
+
*/
|
|
1028
|
+
sortBy(
|
|
1029
|
+
array: TableRow[],
|
|
1030
|
+
key: string | undefined,
|
|
1031
|
+
fn: CustomSortFunction | undefined,
|
|
1032
|
+
isAsc: boolean
|
|
1033
|
+
) {
|
|
1034
|
+
let sorted = []
|
|
1035
|
+
// Sorting without mutating original data
|
|
1036
|
+
if (fn && typeof fn === 'function') {
|
|
1037
|
+
sorted = [...array].sort((a, b) => fn(a, b, isAsc))
|
|
1038
|
+
} else {
|
|
1039
|
+
sorted = [...array].sort((a, b) => {
|
|
1040
|
+
// Get nested values from objects
|
|
1041
|
+
let newA = getValueByPath(a, key!)
|
|
1042
|
+
let newB = getValueByPath(b, key!)
|
|
1043
|
+
|
|
1044
|
+
// sort boolean type
|
|
1045
|
+
if (typeof newA === 'boolean' && typeof newB === 'boolean') {
|
|
1046
|
+
return isAsc ? +newA - +newB : +newB - +newA
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
// sort null values to the bottom when in asc order
|
|
1050
|
+
// and to the top when in desc order
|
|
1051
|
+
if (!isNil(newB) && isNil(newA)) return isAsc ? 1 : -1
|
|
1052
|
+
if (!isNil(newA) && isNil(newB)) return isAsc ? -1 : 1
|
|
1053
|
+
if (newA === newB) return 0
|
|
1054
|
+
|
|
1055
|
+
newA = (typeof newA === 'string')
|
|
1056
|
+
? newA.toUpperCase()
|
|
1057
|
+
: newA
|
|
1058
|
+
newB = (typeof newB === 'string')
|
|
1059
|
+
? newB.toUpperCase()
|
|
1060
|
+
: newB
|
|
1061
|
+
|
|
1062
|
+
return isAsc
|
|
1063
|
+
? newA > newB ? 1 : -1
|
|
1064
|
+
: newA > newB ? -1 : 1
|
|
1065
|
+
})
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
return sorted
|
|
1069
|
+
},
|
|
1070
|
+
|
|
1071
|
+
sortMultiColumn(column: ITableColumn | TableColumnOrder) {
|
|
1072
|
+
this.currentSortColumn = BLANK_COLUMN
|
|
1073
|
+
if (!this.backendSorting) {
|
|
1074
|
+
const existingPriority = this.sortMultipleDataLocal.filter((i) =>
|
|
1075
|
+
i.field === column.field)[0]
|
|
1076
|
+
if (existingPriority) {
|
|
1077
|
+
existingPriority.order = existingPriority.order === 'desc' ? 'asc' : 'desc'
|
|
1078
|
+
} else {
|
|
1079
|
+
this.sortMultipleDataLocal.push({
|
|
1080
|
+
field: column.field,
|
|
1081
|
+
order: this.isAsc ? 'asc' : 'desc',
|
|
1082
|
+
customSort: column.customSort
|
|
1083
|
+
})
|
|
1084
|
+
}
|
|
1085
|
+
this.doSortMultiColumn()
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
|
|
1089
|
+
doSortMultiColumn() {
|
|
1090
|
+
this.newData = multiColumnSort(this.newData, this.sortMultipleDataLocal)
|
|
1091
|
+
},
|
|
1092
|
+
|
|
1093
|
+
/*
|
|
1094
|
+
* Sort the column.
|
|
1095
|
+
* Toggle current direction on column if it's sortable
|
|
1096
|
+
* and not just updating the prop.
|
|
1097
|
+
*/
|
|
1098
|
+
sort(
|
|
1099
|
+
column: ITableColumn | null | undefined,
|
|
1100
|
+
updatingData: boolean | null = false,
|
|
1101
|
+
event: ModifierKeys | null = null
|
|
1102
|
+
) {
|
|
1103
|
+
if (!column || !column.sortable) return
|
|
1104
|
+
if (
|
|
1105
|
+
// if backend sorting is enabled, just emit the sort press like usual
|
|
1106
|
+
// if the correct key combination isnt pressed, sort like usual
|
|
1107
|
+
!this.backendSorting &&
|
|
1108
|
+
this.sortMultiple &&
|
|
1109
|
+
((this.sortMultipleKey && event![this.sortMultipleKey]) || !this.sortMultipleKey)
|
|
1110
|
+
) {
|
|
1111
|
+
if (updatingData) {
|
|
1112
|
+
this.doSortMultiColumn()
|
|
1113
|
+
} else {
|
|
1114
|
+
this.sortMultiColumn(column)
|
|
1115
|
+
}
|
|
1116
|
+
} else {
|
|
1117
|
+
// sort multiple is enabled but the correct key combination isnt pressed so reset
|
|
1118
|
+
if (this.sortMultiple) {
|
|
1119
|
+
this.sortMultipleDataLocal = []
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
if (!updatingData) {
|
|
1123
|
+
this.isAsc = toRaw(column) === toRaw(this.currentSortColumn)
|
|
1124
|
+
? !this.isAsc
|
|
1125
|
+
: (this.defaultSortDirection.toLowerCase() !== 'desc')
|
|
1126
|
+
}
|
|
1127
|
+
if (!this.firstTimeSort) {
|
|
1128
|
+
this.$emit('sort', column.field, this.isAsc ? 'asc' : 'desc', event)
|
|
1129
|
+
}
|
|
1130
|
+
if (!this.backendSorting) {
|
|
1131
|
+
this.doSortSingleColumn(column)
|
|
1132
|
+
}
|
|
1133
|
+
this.currentSortColumn = column
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1136
|
+
|
|
1137
|
+
doSortSingleColumn(column: ITableColumn) {
|
|
1138
|
+
this.newData = this.sortBy(
|
|
1139
|
+
this.newData,
|
|
1140
|
+
column.field,
|
|
1141
|
+
column.customSort,
|
|
1142
|
+
this.isAsc
|
|
1143
|
+
)
|
|
1144
|
+
},
|
|
1145
|
+
|
|
1146
|
+
isRowSelected(row: TableRow, selected: TableRow | undefined) {
|
|
1147
|
+
if (!selected) {
|
|
1148
|
+
return false
|
|
1149
|
+
}
|
|
1150
|
+
if (this.customRowKey) {
|
|
1151
|
+
return row[this.customRowKey] === selected[this.customRowKey]
|
|
1152
|
+
}
|
|
1153
|
+
return row === selected
|
|
1154
|
+
},
|
|
1155
|
+
|
|
1156
|
+
/*
|
|
1157
|
+
* Check if the row is checked (is added to the array).
|
|
1158
|
+
*/
|
|
1159
|
+
isRowChecked(row: TableRow) {
|
|
1160
|
+
return indexOf(this.newCheckedRows, row, this.customIsChecked) >= 0
|
|
1161
|
+
},
|
|
1162
|
+
|
|
1163
|
+
/*
|
|
1164
|
+
* Remove a checked row from the array.
|
|
1165
|
+
*/
|
|
1166
|
+
removeCheckedRow(row: TableRow) {
|
|
1167
|
+
const index = indexOf(this.newCheckedRows, row, this.customIsChecked)
|
|
1168
|
+
if (index >= 0) {
|
|
1169
|
+
this.newCheckedRows.splice(index, 1)
|
|
1170
|
+
}
|
|
1171
|
+
},
|
|
1172
|
+
|
|
1173
|
+
/*
|
|
1174
|
+
* Header checkbox click listener.
|
|
1175
|
+
* Add or remove all rows in current page.
|
|
1176
|
+
*/
|
|
1177
|
+
checkAll() {
|
|
1178
|
+
const isAllChecked = this.isAllChecked
|
|
1179
|
+
this.visibleData.forEach((currentRow) => {
|
|
1180
|
+
if (this.isRowCheckable(currentRow)) {
|
|
1181
|
+
this.removeCheckedRow(currentRow)
|
|
1182
|
+
}
|
|
1183
|
+
if (!isAllChecked) {
|
|
1184
|
+
if (this.isRowCheckable(currentRow)) {
|
|
1185
|
+
this.newCheckedRows.push(currentRow)
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
})
|
|
1189
|
+
|
|
1190
|
+
this.$emit('check', this.newCheckedRows)
|
|
1191
|
+
this.$emit('check-all', this.newCheckedRows)
|
|
1192
|
+
|
|
1193
|
+
// Emit checked rows to update user variable
|
|
1194
|
+
this.$emit('update:checkedRows', this.newCheckedRows)
|
|
1195
|
+
},
|
|
1196
|
+
|
|
1197
|
+
/*
|
|
1198
|
+
* Row checkbox click listener.
|
|
1199
|
+
*/
|
|
1200
|
+
checkRow(row: TableRow, index: number, event: ModifierKeys) {
|
|
1201
|
+
if (!this.isRowCheckable(row)) return
|
|
1202
|
+
const lastIndex = this.lastCheckedRowIndex
|
|
1203
|
+
this.lastCheckedRowIndex = index
|
|
1204
|
+
|
|
1205
|
+
if (event.shiftKey && lastIndex !== null && index !== lastIndex) {
|
|
1206
|
+
this.shiftCheckRow(row, index, lastIndex)
|
|
1207
|
+
} else if (!this.isRowChecked(row)) {
|
|
1208
|
+
this.newCheckedRows.push(row)
|
|
1209
|
+
} else {
|
|
1210
|
+
this.removeCheckedRow(row)
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
this.$emit('check', this.newCheckedRows, row)
|
|
1214
|
+
|
|
1215
|
+
// Emit checked rows to update user variable
|
|
1216
|
+
this.$emit('update:checkedRows', this.newCheckedRows)
|
|
1217
|
+
},
|
|
1218
|
+
|
|
1219
|
+
/*
|
|
1220
|
+
* Check row when shift is pressed.
|
|
1221
|
+
*/
|
|
1222
|
+
shiftCheckRow(row: TableRow, index: number, lastCheckedRowIndex: number) {
|
|
1223
|
+
// Get the subset of the list between the two indicies
|
|
1224
|
+
const subset = this.visibleData.slice(
|
|
1225
|
+
Math.min(index, lastCheckedRowIndex),
|
|
1226
|
+
Math.max(index, lastCheckedRowIndex) + 1
|
|
1227
|
+
)
|
|
1228
|
+
|
|
1229
|
+
// Determine the operation based on the state of the clicked checkbox
|
|
1230
|
+
const shouldCheck = !this.isRowChecked(row)
|
|
1231
|
+
|
|
1232
|
+
subset.forEach((item) => {
|
|
1233
|
+
this.removeCheckedRow(item)
|
|
1234
|
+
if (shouldCheck && this.isRowCheckable(item)) {
|
|
1235
|
+
this.newCheckedRows.push(item)
|
|
1236
|
+
}
|
|
1237
|
+
})
|
|
1238
|
+
},
|
|
1239
|
+
|
|
1240
|
+
/*
|
|
1241
|
+
* Row click listener.
|
|
1242
|
+
* Emit all necessary events.
|
|
1243
|
+
*/
|
|
1244
|
+
selectRow(row: TableRow) {
|
|
1245
|
+
this.$emit('click', row)
|
|
1246
|
+
|
|
1247
|
+
this._selectedRow = row // row must be clicked before dragging by touch
|
|
1248
|
+
if (this.selected === row) return
|
|
1249
|
+
if (!this.isRowSelectable(row)) return
|
|
1250
|
+
|
|
1251
|
+
// Emit new and old row
|
|
1252
|
+
this.$emit('select', row, this.selected)
|
|
1253
|
+
|
|
1254
|
+
// Emit new row to update user variable
|
|
1255
|
+
this.$emit('update:selected', row)
|
|
1256
|
+
},
|
|
1257
|
+
|
|
1258
|
+
/*
|
|
1259
|
+
* Toggle to show/hide details slot
|
|
1260
|
+
*/
|
|
1261
|
+
toggleDetails(obj: TableRow) {
|
|
1262
|
+
const found = this.isVisibleDetailRow(obj)
|
|
1263
|
+
|
|
1264
|
+
if (found) {
|
|
1265
|
+
this.closeDetailRow(obj)
|
|
1266
|
+
this.$emit('details-close', obj)
|
|
1267
|
+
} else {
|
|
1268
|
+
this.openDetailRow(obj)
|
|
1269
|
+
this.$emit('details-open', obj)
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
// Syncs the detailed rows with the parent component
|
|
1273
|
+
this.$emit('update:openedDetailed', this.visibleDetailRows)
|
|
1274
|
+
},
|
|
1275
|
+
|
|
1276
|
+
openDetailRow(obj: TableRow) {
|
|
1277
|
+
const index = this.handleDetailKey(obj)
|
|
1278
|
+
this.visibleDetailRows.push(index)
|
|
1279
|
+
},
|
|
1280
|
+
|
|
1281
|
+
closeDetailRow(obj: TableRow) {
|
|
1282
|
+
const index = this.handleDetailKey(obj)
|
|
1283
|
+
const i = this.visibleDetailRows.indexOf(index)
|
|
1284
|
+
if (i >= 0) {
|
|
1285
|
+
this.visibleDetailRows.splice(i, 1)
|
|
1286
|
+
}
|
|
1287
|
+
},
|
|
1288
|
+
|
|
1289
|
+
isVisibleDetailRow(obj: TableRow) {
|
|
1290
|
+
const index = this.handleDetailKey(obj)
|
|
1291
|
+
return this.visibleDetailRows.indexOf(index) >= 0
|
|
1292
|
+
},
|
|
1293
|
+
|
|
1294
|
+
isActiveDetailRow(row: TableRow) {
|
|
1295
|
+
return this.detailed && !this.customDetailRow && this.isVisibleDetailRow(row)
|
|
1296
|
+
},
|
|
1297
|
+
|
|
1298
|
+
isActiveCustomDetailRow(row: TableRow) {
|
|
1299
|
+
return this.detailed && this.customDetailRow && this.isVisibleDetailRow(row)
|
|
1300
|
+
},
|
|
1301
|
+
|
|
1302
|
+
isRowFiltered(row: TableRow) {
|
|
1303
|
+
for (const key in this.filters) {
|
|
1304
|
+
if (!this.filters[key]) continue
|
|
1305
|
+
const input = this.filters[key]
|
|
1306
|
+
const column = this.newColumns.filter((c) => c.field === key)[0]
|
|
1307
|
+
if (column && column.customSearch && typeof column.customSearch === 'function') {
|
|
1308
|
+
if (!column.customSearch(row, input)) return false
|
|
1309
|
+
} else {
|
|
1310
|
+
const value = this.getValueByPath(row, key)
|
|
1311
|
+
if (value == null) return false
|
|
1312
|
+
if (Number.isInteger(value)) {
|
|
1313
|
+
if (value !== Number(input)) return false
|
|
1314
|
+
} else {
|
|
1315
|
+
const re = new RegExp(escapeRegExpChars(input + '')!, 'i')
|
|
1316
|
+
if (Array.isArray(value)) {
|
|
1317
|
+
const valid = value.some((val) =>
|
|
1318
|
+
re.test(removeDiacriticsFromString(val)) || re.test(val)
|
|
1319
|
+
)
|
|
1320
|
+
if (!valid) return false
|
|
1321
|
+
} else {
|
|
1322
|
+
if (!re.test(removeDiacriticsFromString(value)) && !re.test(value)) {
|
|
1323
|
+
return false
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
return true
|
|
1330
|
+
},
|
|
1331
|
+
|
|
1332
|
+
/*
|
|
1333
|
+
* When the detailKey is defined we use the object[detailKey] as index.
|
|
1334
|
+
* If not, use the object reference by default.
|
|
1335
|
+
*/
|
|
1336
|
+
handleDetailKey(index: TableRow) {
|
|
1337
|
+
const key = this.detailKey
|
|
1338
|
+
return !key.length || !index
|
|
1339
|
+
? index
|
|
1340
|
+
: index[key]
|
|
1341
|
+
},
|
|
1342
|
+
|
|
1343
|
+
checkPredefinedDetailedRows() {
|
|
1344
|
+
const defaultExpandedRowsDefined = this.openedDetailed.length > 0
|
|
1345
|
+
if (defaultExpandedRowsDefined && !this.detailKey.length) {
|
|
1346
|
+
throw new Error('If you set a predefined opened-detailed, you must provide a unique key using the prop "detail-key"')
|
|
1347
|
+
}
|
|
1348
|
+
},
|
|
1349
|
+
|
|
1350
|
+
/*
|
|
1351
|
+
* Call initSort only first time (For example async data).
|
|
1352
|
+
*/
|
|
1353
|
+
checkSort() {
|
|
1354
|
+
if (this.newColumns.length && this.firstTimeSort) {
|
|
1355
|
+
this.initSort()
|
|
1356
|
+
this.firstTimeSort = false
|
|
1357
|
+
} else if (this.newColumns.length) {
|
|
1358
|
+
if (toRaw(this.currentSortColumn) !== BLANK_COLUMN) {
|
|
1359
|
+
for (let i = 0; i < this.newColumns.length; i++) {
|
|
1360
|
+
if (this.newColumns[i].field === this.currentSortColumn.field) {
|
|
1361
|
+
this.currentSortColumn = this.newColumns[i]
|
|
1362
|
+
break
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
},
|
|
1368
|
+
|
|
1369
|
+
/*
|
|
1370
|
+
* Check if footer slot has custom content.
|
|
1371
|
+
*
|
|
1372
|
+
* Assumes that `$slots.footer` is specified.
|
|
1373
|
+
*/
|
|
1374
|
+
hasCustomFooterSlot() {
|
|
1375
|
+
const footer = this.$slots.footer!()
|
|
1376
|
+
if (footer.length > 1) return true
|
|
1377
|
+
|
|
1378
|
+
// if a template is specified to `footer`, `footer.length` is 1
|
|
1379
|
+
// but should contain multiple elements.
|
|
1380
|
+
if (isFragment(footer[0])) return true
|
|
1381
|
+
|
|
1382
|
+
const tag = footer[0].el?.tag
|
|
1383
|
+
if (tag !== 'th' && tag !== 'td') return false
|
|
1384
|
+
|
|
1385
|
+
return true
|
|
1386
|
+
},
|
|
1387
|
+
|
|
1388
|
+
/*
|
|
1389
|
+
* Check if bottom-left slot exists.
|
|
1390
|
+
*/
|
|
1391
|
+
hasBottomLeftSlot() {
|
|
1392
|
+
return typeof this.$slots['bottom-left'] !== 'undefined'
|
|
1393
|
+
},
|
|
1394
|
+
|
|
1395
|
+
/*
|
|
1396
|
+
* Table arrow keys listener, change selection.
|
|
1397
|
+
*/
|
|
1398
|
+
pressedArrow(pos: number) {
|
|
1399
|
+
if (!this.visibleData.length) return
|
|
1400
|
+
|
|
1401
|
+
let index = this.visibleData.indexOf(this.selected) + pos
|
|
1402
|
+
|
|
1403
|
+
// Prevent from going up from first and down from last
|
|
1404
|
+
index = index < 0
|
|
1405
|
+
? 0
|
|
1406
|
+
: index > this.visibleData.length - 1
|
|
1407
|
+
? this.visibleData.length - 1
|
|
1408
|
+
: index
|
|
1409
|
+
|
|
1410
|
+
const row = this.visibleData[index]
|
|
1411
|
+
|
|
1412
|
+
if (!this.isRowSelectable(row)) {
|
|
1413
|
+
let newIndex = null
|
|
1414
|
+
if (pos > 0) {
|
|
1415
|
+
for (let i = index; i < this.visibleData.length && newIndex === null; i++) {
|
|
1416
|
+
if (this.isRowSelectable(this.visibleData[i])) newIndex = i
|
|
1417
|
+
}
|
|
1418
|
+
} else {
|
|
1419
|
+
for (let i = index; i >= 0 && newIndex === null; i--) {
|
|
1420
|
+
if (this.isRowSelectable(this.visibleData[i])) newIndex = i
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
if (newIndex! >= 0) {
|
|
1424
|
+
this.selectRow(this.visibleData[newIndex!])
|
|
1425
|
+
}
|
|
1426
|
+
} else {
|
|
1427
|
+
this.selectRow(row)
|
|
1428
|
+
}
|
|
1429
|
+
},
|
|
1430
|
+
|
|
1431
|
+
/*
|
|
1432
|
+
* Focus table element if has selected prop.
|
|
1433
|
+
*/
|
|
1434
|
+
focus() {
|
|
1435
|
+
if (!this.focusable) return
|
|
1436
|
+
|
|
1437
|
+
this.$el.querySelector('table').focus()
|
|
1438
|
+
},
|
|
1439
|
+
|
|
1440
|
+
/*
|
|
1441
|
+
* Initial sorted column based on the default-sort prop.
|
|
1442
|
+
*/
|
|
1443
|
+
initSort() {
|
|
1444
|
+
if (this.sortMultiple && this.sortMultipleData) {
|
|
1445
|
+
this.sortMultipleData.forEach((column) => {
|
|
1446
|
+
this.sortMultiColumn(column)
|
|
1447
|
+
})
|
|
1448
|
+
} else {
|
|
1449
|
+
if (!this.defaultSort) return
|
|
1450
|
+
|
|
1451
|
+
let sortField = ''
|
|
1452
|
+
let sortDirection = this.defaultSortDirection
|
|
1453
|
+
|
|
1454
|
+
if (Array.isArray(this.defaultSort)) {
|
|
1455
|
+
sortField = this.defaultSort[0]
|
|
1456
|
+
if (this.defaultSort[1]) {
|
|
1457
|
+
sortDirection = this.defaultSort[1]
|
|
1458
|
+
}
|
|
1459
|
+
} else {
|
|
1460
|
+
sortField = this.defaultSort
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
const sortColumn = this.newColumns.filter(
|
|
1464
|
+
(column) => (column.field === sortField))[0]
|
|
1465
|
+
if (sortColumn) {
|
|
1466
|
+
this.isAsc = sortDirection.toLowerCase() !== 'desc'
|
|
1467
|
+
this.sort(sortColumn, true)
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
},
|
|
1471
|
+
/*
|
|
1472
|
+
* Emits drag start event (row)
|
|
1473
|
+
*/
|
|
1474
|
+
handleDragStart(event: DragEvent, row: TableRow, index: number) {
|
|
1475
|
+
if (!this.canDragRow) return
|
|
1476
|
+
this.isDraggingRow = true
|
|
1477
|
+
this.$emit('dragstart', { event, row, index })
|
|
1478
|
+
},
|
|
1479
|
+
/*
|
|
1480
|
+
* Emits drag leave event (row)
|
|
1481
|
+
*/
|
|
1482
|
+
handleDragEnd(event: DragEvent, row: TableRow, index: number) {
|
|
1483
|
+
if (!this.canDragRow) return
|
|
1484
|
+
this.isDraggingRow = false
|
|
1485
|
+
this.$emit('dragend', { event, row, index })
|
|
1486
|
+
},
|
|
1487
|
+
/*
|
|
1488
|
+
* Emits drop event (row)
|
|
1489
|
+
*/
|
|
1490
|
+
handleDrop(event: DragEvent, row: TableRow, index: number) {
|
|
1491
|
+
if (!this.canDragRow) return
|
|
1492
|
+
this.$emit('drop', { event, row, index })
|
|
1493
|
+
},
|
|
1494
|
+
/*
|
|
1495
|
+
* Emits drag over event (row)
|
|
1496
|
+
*/
|
|
1497
|
+
handleDragOver(event: DragEvent, row: TableRow, index: number) {
|
|
1498
|
+
if (!this.canDragRow) return
|
|
1499
|
+
this.$emit('dragover', { event, row, index })
|
|
1500
|
+
},
|
|
1501
|
+
/*
|
|
1502
|
+
* Emits drag leave event (row)
|
|
1503
|
+
*/
|
|
1504
|
+
handleDragLeave(event: DragEvent, row: TableRow, index: number) {
|
|
1505
|
+
if (!this.canDragRow) return
|
|
1506
|
+
this.$emit('dragleave', { event, row, index })
|
|
1507
|
+
},
|
|
1508
|
+
|
|
1509
|
+
// FIXME: this method may emit events not listed in `emits`.
|
|
1510
|
+
// I decided not to list them to check if event listeners are actually
|
|
1511
|
+
// set in `$attrs`. The original idea of this method was to address
|
|
1512
|
+
// some performance issues and introduced at the commit:
|
|
1513
|
+
// https://github.com/ntohq/buefy-next/commit/e38726497785145195e9605840e33980fd4ae9e0
|
|
1514
|
+
// I am not sure whether the justification at https://github.com/buefy/buefy/pull/2150
|
|
1515
|
+
// is still relevant with Vue 3.
|
|
1516
|
+
emitEventForRow(eventName: string, event: Event, row: TableRow) {
|
|
1517
|
+
// eventName should not be in `emits` because it is never included
|
|
1518
|
+
// in `$attrs` if it is listed in `emits`.
|
|
1519
|
+
// @ts-expect-error `on${eventName}` unlikely matches the actual prop.
|
|
1520
|
+
// we should use `toHandlerKey` with/without `camelize` instead.
|
|
1521
|
+
return this.$attrs[`on${eventName}`] ? this.$emit(eventName, row, event) : null
|
|
1522
|
+
},
|
|
1523
|
+
|
|
1524
|
+
/*
|
|
1525
|
+
* Emits drag start event (column)
|
|
1526
|
+
*/
|
|
1527
|
+
handleColumnDragStart(event: DragEvent, column: ITableColumn, index: number) {
|
|
1528
|
+
if (!this.canDragColumn) return
|
|
1529
|
+
this.isDraggingColumn = true
|
|
1530
|
+
this.$emit('columndragstart', { event, column, index })
|
|
1531
|
+
},
|
|
1532
|
+
|
|
1533
|
+
/*
|
|
1534
|
+
* Emits drag leave event (column)
|
|
1535
|
+
*/
|
|
1536
|
+
handleColumnDragEnd(event: DragEvent, column: ITableColumn, index: number) {
|
|
1537
|
+
if (!this.canDragColumn) return
|
|
1538
|
+
this.isDraggingColumn = false
|
|
1539
|
+
this.$emit('columndragend', { event, column, index })
|
|
1540
|
+
},
|
|
1541
|
+
|
|
1542
|
+
/*
|
|
1543
|
+
* Emits drop event (column)
|
|
1544
|
+
*/
|
|
1545
|
+
handleColumnDrop(event: DragEvent, column: ITableColumn, index: number) {
|
|
1546
|
+
if (!this.canDragColumn) return
|
|
1547
|
+
this.$emit('columndrop', { event, column, index })
|
|
1548
|
+
},
|
|
1549
|
+
|
|
1550
|
+
/*
|
|
1551
|
+
* Emits drag over event (column)
|
|
1552
|
+
*/
|
|
1553
|
+
handleColumnDragOver(event: DragEvent, column: ITableColumn, index: number) {
|
|
1554
|
+
if (!this.canDragColumn) return
|
|
1555
|
+
this.$emit('columndragover', { event, column, index })
|
|
1556
|
+
},
|
|
1557
|
+
|
|
1558
|
+
/*
|
|
1559
|
+
* Emits drag leave event (column)
|
|
1560
|
+
*/
|
|
1561
|
+
handleColumnDragLeave(event: DragEvent, column: ITableColumn, index: number) {
|
|
1562
|
+
if (!this.canDragColumn) return
|
|
1563
|
+
this.$emit('columndragleave', { event, column, index })
|
|
1564
|
+
},
|
|
1565
|
+
|
|
1566
|
+
/*
|
|
1567
|
+
* Starts monitoring drag-by-touch events (row on touch-enabled devices)
|
|
1568
|
+
*/
|
|
1569
|
+
handleTouchStart(event: TouchEvent, row: TableRow) {
|
|
1570
|
+
if (!this.canDragRow) return
|
|
1571
|
+
if (this.isDraggingColumn) return
|
|
1572
|
+
// drag won't start unless the row has been clicked (tapped)
|
|
1573
|
+
// I think trapping touch-scrolling is annoying
|
|
1574
|
+
if (this._selectedRow !== row) return
|
|
1575
|
+
event.preventDefault()
|
|
1576
|
+
this.mayBeTouchDragging = true
|
|
1577
|
+
},
|
|
1578
|
+
/*
|
|
1579
|
+
* Emits dragover and dragleave events (row on touch-enabled devices)
|
|
1580
|
+
*
|
|
1581
|
+
* Emits also dragstart if this is the first touchmove after touchstart.
|
|
1582
|
+
*/
|
|
1583
|
+
handleTouchMove(event: TouchEvent) {
|
|
1584
|
+
if (!this.canDragRow) return
|
|
1585
|
+
if (!this.mayBeTouchDragging) return
|
|
1586
|
+
if (!this.isDraggingRow) {
|
|
1587
|
+
const eventTarget = event.target! as HTMLElement
|
|
1588
|
+
const tr = eventTarget.closest('tr')
|
|
1589
|
+
this.draggedCellContent = tr
|
|
1590
|
+
? `<table class="table"><tr>${tr.innerHTML}</tr></table>`
|
|
1591
|
+
: eventTarget.innerHTML;
|
|
1592
|
+
(this.$refs.draggedCell as HTMLElement).style.width = tr
|
|
1593
|
+
? `${tr.offsetWidth}px`
|
|
1594
|
+
: `${eventTarget.offsetWidth}px`
|
|
1595
|
+
eventTarget.dispatchEvent(translateTouchAsDragEvent(event, {
|
|
1596
|
+
type: 'dragstart'
|
|
1597
|
+
}))
|
|
1598
|
+
}
|
|
1599
|
+
const touch = event.touches[0]
|
|
1600
|
+
const target = document.elementFromPoint(touch.clientX, touch.clientY)
|
|
1601
|
+
if (target != null) {
|
|
1602
|
+
if (target !== this.touchDragoverTarget) {
|
|
1603
|
+
if (this.touchDragoverTarget != null) {
|
|
1604
|
+
this.touchDragoverTarget.dispatchEvent(
|
|
1605
|
+
translateTouchAsDragEvent(event, {
|
|
1606
|
+
type: 'dragleave',
|
|
1607
|
+
target: this.touchDragoverTarget
|
|
1608
|
+
})
|
|
1609
|
+
)
|
|
1610
|
+
}
|
|
1611
|
+
this.touchDragoverTarget = target
|
|
1612
|
+
target.dispatchEvent(
|
|
1613
|
+
translateTouchAsDragEvent(event, {
|
|
1614
|
+
type: 'dragover',
|
|
1615
|
+
target
|
|
1616
|
+
})
|
|
1617
|
+
)
|
|
1618
|
+
}
|
|
1619
|
+
} else if (this.touchDragoverTarget != null) {
|
|
1620
|
+
this.touchDragoverTarget.dispatchEvent(
|
|
1621
|
+
translateTouchAsDragEvent(event, {
|
|
1622
|
+
type: 'dragleave',
|
|
1623
|
+
target: this.touchDragoverTarget
|
|
1624
|
+
})
|
|
1625
|
+
)
|
|
1626
|
+
this.touchDragoverTarget = null
|
|
1627
|
+
}
|
|
1628
|
+
this.updateDraggedCell(touch)
|
|
1629
|
+
},
|
|
1630
|
+
/*
|
|
1631
|
+
* Emits drop and dragend events (row on touch-enabled devices)
|
|
1632
|
+
*/
|
|
1633
|
+
handleTouchEnd(event: TouchEvent) {
|
|
1634
|
+
if (!this.canDragRow) return
|
|
1635
|
+
if (this.isDraggingRow) {
|
|
1636
|
+
const touch = event.changedTouches[0]
|
|
1637
|
+
const target = document.elementFromPoint(touch.clientX, touch.clientY)
|
|
1638
|
+
if (target != null) {
|
|
1639
|
+
target.dispatchEvent(translateTouchAsDragEvent(event, {
|
|
1640
|
+
type: 'drop',
|
|
1641
|
+
target
|
|
1642
|
+
}))
|
|
1643
|
+
}
|
|
1644
|
+
event.target!.dispatchEvent(translateTouchAsDragEvent(event, {
|
|
1645
|
+
type: 'dragend'
|
|
1646
|
+
}))
|
|
1647
|
+
this._selectedRow = null
|
|
1648
|
+
}
|
|
1649
|
+
this.mayBeTouchDragging = false
|
|
1650
|
+
},
|
|
1651
|
+
|
|
1652
|
+
/*
|
|
1653
|
+
* Starts monitoring drag-by-touch events (column on touch-enabled devices)
|
|
1654
|
+
*/
|
|
1655
|
+
handleColumnTouchStart(event: TouchEvent) {
|
|
1656
|
+
if (!this.canDragColumn) return
|
|
1657
|
+
if (this.isDraggingRow) return
|
|
1658
|
+
event.preventDefault() // otherwise triggers touch-scrolling
|
|
1659
|
+
this.mayBeTouchDragging = true
|
|
1660
|
+
},
|
|
1661
|
+
/*
|
|
1662
|
+
* Emits dragover and dragleave events (column on touch-enabled devices)
|
|
1663
|
+
*
|
|
1664
|
+
* Also emits dragstart if this is the first touchmove after touchstart.
|
|
1665
|
+
*/
|
|
1666
|
+
handleColumnTouchMove(event: TouchEvent) {
|
|
1667
|
+
if (!this.canDragColumn) return
|
|
1668
|
+
if (!this.mayBeTouchDragging) return
|
|
1669
|
+
if (!this.isDraggingColumn) {
|
|
1670
|
+
const eventTarget = event.target! as HTMLElement
|
|
1671
|
+
this.draggedCellContent = eventTarget.innerHTML;
|
|
1672
|
+
(this.$refs.draggedCell as HTMLElement).style.width = `${eventTarget.offsetWidth}px`
|
|
1673
|
+
eventTarget.dispatchEvent(translateTouchAsDragEvent(event, {
|
|
1674
|
+
type: 'dragstart'
|
|
1675
|
+
}))
|
|
1676
|
+
}
|
|
1677
|
+
const touch = event.touches[0]
|
|
1678
|
+
const target = document.elementFromPoint(touch.clientX, touch.clientY)
|
|
1679
|
+
if (target != null) {
|
|
1680
|
+
if (target !== this.touchDragoverTarget) {
|
|
1681
|
+
if (this.touchDragoverTarget != null) {
|
|
1682
|
+
this.touchDragoverTarget.dispatchEvent(
|
|
1683
|
+
translateTouchAsDragEvent(event, {
|
|
1684
|
+
type: 'dragleave',
|
|
1685
|
+
target: this.touchDragoverTarget
|
|
1686
|
+
})
|
|
1687
|
+
)
|
|
1688
|
+
}
|
|
1689
|
+
this.touchDragoverTarget = target
|
|
1690
|
+
target.dispatchEvent(
|
|
1691
|
+
translateTouchAsDragEvent(event, {
|
|
1692
|
+
type: 'dragover',
|
|
1693
|
+
target
|
|
1694
|
+
})
|
|
1695
|
+
)
|
|
1696
|
+
}
|
|
1697
|
+
} else if (this.touchDragoverTarget != null) {
|
|
1698
|
+
this.touchDragoverTarget.dispatchEvent(
|
|
1699
|
+
translateTouchAsDragEvent(event, {
|
|
1700
|
+
type: 'dragleave',
|
|
1701
|
+
target: this.touchDragoverTarget
|
|
1702
|
+
})
|
|
1703
|
+
)
|
|
1704
|
+
this.touchDragoverTarget = null
|
|
1705
|
+
}
|
|
1706
|
+
this.updateDraggedCell(touch)
|
|
1707
|
+
},
|
|
1708
|
+
/*
|
|
1709
|
+
* Emits drop and dragend events (column on touch-enabled devices)
|
|
1710
|
+
*/
|
|
1711
|
+
handleColumnTouchEnd(event: TouchEvent) {
|
|
1712
|
+
if (!this.canDragColumn) return
|
|
1713
|
+
if (this.isDraggingColumn) {
|
|
1714
|
+
const touch = event.changedTouches[0]
|
|
1715
|
+
const target = document.elementFromPoint(touch.clientX, touch.clientY)
|
|
1716
|
+
if (target != null) {
|
|
1717
|
+
target.dispatchEvent(translateTouchAsDragEvent(event, {
|
|
1718
|
+
type: 'drop',
|
|
1719
|
+
target
|
|
1720
|
+
}))
|
|
1721
|
+
}
|
|
1722
|
+
event.target!.dispatchEvent(translateTouchAsDragEvent(event, {
|
|
1723
|
+
type: 'dragend'
|
|
1724
|
+
}))
|
|
1725
|
+
}
|
|
1726
|
+
this.mayBeTouchDragging = false
|
|
1727
|
+
},
|
|
1728
|
+
|
|
1729
|
+
updateDraggedCell({ clientX, clientY }: { clientX: number, clientY: number }) {
|
|
1730
|
+
const cellRect = (this.$refs.draggedCell as HTMLElement).getBoundingClientRect()
|
|
1731
|
+
const top = clientY + window.scrollY - cellRect.height / 2
|
|
1732
|
+
const left = clientX + window.scrollX - cellRect.width / 2;
|
|
1733
|
+
(this.$refs.draggedCell as HTMLElement).style.top = `calc(${top}px)`;
|
|
1734
|
+
(this.$refs.draggedCell as HTMLElement).style.left = `calc(${left}px)`
|
|
1735
|
+
},
|
|
1736
|
+
|
|
1737
|
+
_registerTableColumn(column: ITableColumn) {
|
|
1738
|
+
if (column._isTableColumn) {
|
|
1739
|
+
this.defaultSlots.push(column)
|
|
1740
|
+
}
|
|
1741
|
+
},
|
|
1742
|
+
_unregisterTableColumn(column: ITableColumn) {
|
|
1743
|
+
const index = this.defaultSlots.indexOf(column)
|
|
1744
|
+
if (index !== -1) {
|
|
1745
|
+
this.defaultSlots.splice(index, 1)
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
},
|
|
1749
|
+
mounted() {
|
|
1750
|
+
this.checkPredefinedDetailedRows()
|
|
1751
|
+
this.checkSort()
|
|
1752
|
+
// appends `draggedCell` to the body whenever `draggable` or
|
|
1753
|
+
// `draggableColumn` becomes true
|
|
1754
|
+
// starts watching here to make sure the DOM is ready
|
|
1755
|
+
const prepareDraggedCell = (isDraggable: boolean) => {
|
|
1756
|
+
if (isDraggable && this.$data._draggedCellEl == null) {
|
|
1757
|
+
this.$data._draggedCellEl =
|
|
1758
|
+
createAbsoluteElement(this.$refs.draggedCell as HTMLElement)
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
this.$watch('draggable', prepareDraggedCell, { immediate: true })
|
|
1762
|
+
this.$watch('draggableColumn', prepareDraggedCell, { immediate: true })
|
|
1763
|
+
},
|
|
1764
|
+
beforeUnmount() {
|
|
1765
|
+
if (this.$data._draggedCellEl) {
|
|
1766
|
+
removeElement(this.$data._draggedCellEl)
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
})
|
|
1770
|
+
</script>
|