@mezzanine-ui/react 0.13.9 → 0.13.11
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/Accordion/Accordion.d.ts +24 -24
- package/Accordion/Accordion.js +25 -25
- package/Accordion/AccordionControlContext.d.ts +9 -9
- package/Accordion/AccordionDetails.d.ts +10 -10
- package/Accordion/AccordionDetails.js +16 -16
- package/Accordion/AccordionSummary.d.ts +18 -18
- package/Accordion/AccordionSummary.js +39 -39
- package/Accordion/index.d.ts +3 -3
- package/Alert/Alert.d.ts +20 -20
- package/Alert/Alert.js +9 -9
- package/Alert/index.d.ts +2 -2
- package/AppBar/AppBar.d.ts +14 -14
- package/AppBar/AppBar.js +25 -25
- package/AppBar/AppBarBrand.d.ts +5 -5
- package/AppBar/AppBarBrand.js +4 -4
- package/AppBar/AppBarMain.d.ts +5 -5
- package/AppBar/AppBarMain.js +4 -4
- package/AppBar/AppBarSupport.d.ts +5 -5
- package/AppBar/AppBarSupport.js +4 -4
- package/AppBar/index.d.ts +4 -4
- package/Badge/Badge.d.ts +19 -19
- package/Badge/Badge.js +20 -20
- package/Badge/BadgeContainer.d.ts +8 -8
- package/Badge/BadgeContainer.js +7 -7
- package/Badge/index.d.ts +2 -2
- package/Button/Button.d.ts +11 -11
- package/Button/Button.js +29 -29
- package/Button/ButtonGroup.d.ts +63 -63
- package/Button/ButtonGroup.js +29 -29
- package/Button/IconButton.d.ts +21 -21
- package/Button/IconButton.js +7 -7
- package/Button/index.d.ts +20 -20
- package/Button/typings.d.ts +44 -44
- package/Calendar/Calendar.d.ts +69 -69
- package/Calendar/Calendar.js +38 -38
- package/Calendar/CalendarCell.d.ts +22 -21
- package/Calendar/CalendarCell.js +11 -11
- package/Calendar/CalendarContext.d.ts +22 -22
- package/Calendar/CalendarContext.js +28 -28
- package/Calendar/CalendarControls.d.ts +26 -25
- package/Calendar/CalendarControls.js +11 -11
- package/Calendar/CalendarDayOfWeek.d.ts +15 -14
- package/Calendar/CalendarDayOfWeek.js +9 -9
- package/Calendar/CalendarDays.d.ts +38 -37
- package/Calendar/CalendarDays.js +36 -36
- package/Calendar/CalendarMonths.d.ts +42 -41
- package/Calendar/CalendarMonths.js +22 -22
- package/Calendar/CalendarWeeks.d.ts +41 -40
- package/Calendar/CalendarWeeks.js +42 -42
- package/Calendar/CalendarYears.d.ts +40 -39
- package/Calendar/CalendarYears.js +25 -25
- package/Calendar/index.d.ts +12 -12
- package/Calendar/useCalendarControlModifiers.d.ts +7 -7
- package/Calendar/useCalendarControlModifiers.js +20 -20
- package/Calendar/useCalendarControls.d.ts +12 -12
- package/Calendar/useCalendarControls.js +27 -27
- package/Calendar/useCalendarModeStack.d.ts +6 -6
- package/Calendar/useCalendarModeStack.js +10 -10
- package/Card/Card.d.ts +51 -51
- package/Card/Card.js +12 -12
- package/Card/CardActions.d.ts +34 -34
- package/Card/CardActions.js +7 -7
- package/Card/index.d.ts +2 -2
- package/Checkbox/CheckAll.d.ts +13 -13
- package/Checkbox/CheckAll.js +28 -28
- package/Checkbox/Checkbox.d.ts +46 -46
- package/Checkbox/Checkbox.js +23 -23
- package/Checkbox/CheckboxGroup.d.ts +47 -47
- package/Checkbox/CheckboxGroup.js +27 -27
- package/Checkbox/CheckboxGroupContext.d.ts +9 -9
- package/Checkbox/index.d.ts +4 -4
- package/ConfirmActions/ConfirmActions.d.ts +45 -45
- package/ConfirmActions/ConfirmActions.js +8 -8
- package/ConfirmActions/index.d.ts +1 -1
- package/DatePicker/DatePicker.d.ts +32 -32
- package/DatePicker/DatePicker.js +119 -119
- package/DatePicker/DatePickerCalendar.d.ts +32 -32
- package/DatePicker/DatePickerCalendar.js +52 -52
- package/DatePicker/index.d.ts +2 -2
- package/DateRangePicker/DateRangePicker.d.ts +38 -38
- package/DateRangePicker/DateRangePicker.js +173 -173
- package/DateRangePicker/DateRangePickerCalendar.d.ts +26 -26
- package/DateRangePicker/DateRangePickerCalendar.js +86 -86
- package/DateRangePicker/index.d.ts +4 -4
- package/DateRangePicker/useDateRangeCalendarControls.d.ts +14 -14
- package/DateRangePicker/useDateRangeCalendarControls.js +84 -84
- package/DateRangePicker/useDateRangePickerValue.d.ts +23 -23
- package/DateRangePicker/useDateRangePickerValue.js +81 -81
- package/DateTimePicker/DateTimePicker.d.ts +28 -28
- package/DateTimePicker/DateTimePicker.js +107 -107
- package/DateTimePicker/DateTimePickerPanel.d.ts +29 -29
- package/DateTimePicker/DateTimePickerPanel.js +36 -36
- package/DateTimePicker/index.d.ts +2 -2
- package/Drawer/Drawer.d.ts +13 -13
- package/Drawer/Drawer.js +10 -10
- package/Drawer/index.d.ts +2 -2
- package/Dropdown/Dropdown.d.ts +25 -25
- package/Dropdown/Dropdown.js +52 -52
- package/Dropdown/index.d.ts +1 -1
- package/Empty/Empty.d.ts +18 -18
- package/Empty/Empty.js +6 -6
- package/Empty/index.d.ts +1 -1
- package/Form/FormControlContext.d.ts +9 -9
- package/Form/FormField.d.ts +27 -27
- package/Form/FormField.js +16 -16
- package/Form/FormLabel.d.ts +11 -11
- package/Form/FormLabel.js +8 -8
- package/Form/FormMessage.d.ts +8 -8
- package/Form/FormMessage.js +9 -9
- package/Form/index.d.ts +5 -5
- package/Form/typings.d.ts +4 -4
- package/Form/useAutoCompleteValueControl.d.ts +42 -42
- package/Form/useAutoCompleteValueControl.js +94 -94
- package/Form/useCheckboxControlValue.d.ts +11 -11
- package/Form/useCheckboxControlValue.js +24 -24
- package/Form/useControlValueState.d.ts +7 -7
- package/Form/useControlValueState.js +10 -10
- package/Form/useCustomControlValue.d.ts +5 -5
- package/Form/useCustomControlValue.js +12 -12
- package/Form/useInputControlValue.d.ts +7 -7
- package/Form/useInputControlValue.js +18 -18
- package/Form/useInputWithClearControlValue.d.ts +6 -6
- package/Form/useInputWithClearControlValue.js +28 -28
- package/Form/useInputWithTagsModeValue.d.ts +37 -37
- package/Form/useInputWithTagsModeValue.js +83 -83
- package/Form/useRadioControlValue.d.ts +11 -11
- package/Form/useRadioControlValue.js +19 -19
- package/Form/useSelectValueControl.d.ts +33 -33
- package/Form/useSelectValueControl.js +71 -71
- package/Form/useSwitchControlValue.d.ts +7 -7
- package/Form/useSwitchControlValue.js +18 -18
- package/Icon/Icon.d.ts +32 -32
- package/Icon/Icon.js +18 -18
- package/Icon/index.d.ts +3 -3
- package/Input/Input.d.ts +78 -78
- package/Input/Input.js +34 -34
- package/Input/index.d.ts +2 -2
- package/Loading/Loading.d.ts +34 -34
- package/Loading/Loading.js +19 -19
- package/Loading/index.d.ts +1 -1
- package/Menu/Menu.d.ts +29 -29
- package/Menu/Menu.js +16 -16
- package/Menu/MenuDivider.d.ts +8 -8
- package/Menu/MenuDivider.js +7 -7
- package/Menu/MenuItem.d.ts +24 -24
- package/Menu/MenuItem.js +16 -16
- package/Menu/MenuItemGroup.d.ts +13 -13
- package/Menu/MenuItemGroup.js +7 -7
- package/Menu/index.d.ts +5 -5
- package/Message/Message.d.ts +36 -36
- package/Message/Message.js +63 -63
- package/Message/index.d.ts +2 -2
- package/Modal/Modal.d.ts +37 -37
- package/Modal/Modal.js +15 -15
- package/Modal/ModalActions.d.ts +10 -10
- package/Modal/ModalActions.js +10 -10
- package/Modal/ModalBody.d.ts +8 -8
- package/Modal/ModalBody.js +7 -7
- package/Modal/ModalControl.d.ts +7 -7
- package/Modal/ModalControl.js +3 -3
- package/Modal/ModalFooter.d.ts +8 -8
- package/Modal/ModalFooter.js +7 -7
- package/Modal/ModalHeader.d.ts +20 -20
- package/Modal/ModalHeader.js +10 -10
- package/Modal/index.d.ts +7 -7
- package/Modal/useModalContainer.d.ts +6 -6
- package/Modal/useModalContainer.js +19 -19
- package/Navigation/Navigation.d.ts +29 -29
- package/Navigation/Navigation.js +45 -45
- package/Navigation/NavigationContext.d.ts +6 -6
- package/Navigation/NavigationContext.js +2 -2
- package/Navigation/NavigationItem.d.ts +31 -31
- package/Navigation/NavigationItem.js +13 -13
- package/Navigation/NavigationSubMenu.d.ts +22 -22
- package/Navigation/NavigationSubMenu.js +48 -48
- package/Navigation/index.d.ts +4 -4
- package/Notification/Notification.d.ts +54 -54
- package/Notification/Notification.js +60 -60
- package/Notification/index.d.ts +2 -2
- package/Notifier/NotifierManager.d.ts +17 -17
- package/Notifier/NotifierManager.js +25 -25
- package/Notifier/createNotifier.d.ts +21 -21
- package/Notifier/createNotifier.js +65 -65
- package/Notifier/index.d.ts +2 -2
- package/Notifier/typings.d.ts +28 -28
- package/Overlay/Overlay.d.ts +43 -43
- package/Overlay/Overlay.js +22 -22
- package/Overlay/index.d.ts +1 -1
- package/PageFooter/PageFooter.d.ts +15 -15
- package/PageFooter/PageFooter.js +4 -4
- package/PageFooter/index.d.ts +1 -1
- package/Pagination/Pagination.d.ts +105 -105
- package/Pagination/Pagination.js +18 -18
- package/Pagination/PaginationItem.d.ts +27 -27
- package/Pagination/PaginationItem.js +16 -16
- package/Pagination/PaginationJumper.d.ts +38 -38
- package/Pagination/PaginationJumper.js +40 -40
- package/Pagination/PaginationPageSize.d.ts +38 -38
- package/Pagination/PaginationPageSize.js +8 -8
- package/Pagination/index.d.ts +6 -6
- package/Pagination/usePagination.d.ts +16 -16
- package/Pagination/usePagination.js +73 -73
- package/Picker/PickerTrigger.d.ts +40 -40
- package/Picker/PickerTrigger.js +7 -7
- package/Picker/RangePickerTrigger.d.ts +64 -64
- package/Picker/RangePickerTrigger.js +7 -7
- package/Picker/index.d.ts +7 -7
- package/Picker/usePickerDocumentEventClose.d.ts +10 -10
- package/Picker/usePickerDocumentEventClose.js +20 -20
- package/Picker/usePickerInputValue.d.ts +12 -12
- package/Picker/usePickerInputValue.js +18 -18
- package/Picker/usePickerValue.d.ts +20 -20
- package/Picker/usePickerValue.js +51 -51
- package/Picker/useRangePickerValue.d.ts +20 -20
- package/Picker/useRangePickerValue.js +88 -88
- package/Picker/useTabKeyClose.d.ts +2 -2
- package/Picker/useTabKeyClose.js +7 -7
- package/Popconfirm/Popconfirm.d.ts +16 -16
- package/Popconfirm/Popconfirm.js +4 -4
- package/Popconfirm/index.d.ts +1 -1
- package/Popover/Popover.d.ts +23 -23
- package/Popover/Popover.js +34 -34
- package/Popover/index.d.ts +1 -1
- package/Popper/Popper.d.ts +32 -32
- package/Popper/Popper.js +21 -21
- package/Popper/index.d.ts +1 -1
- package/Portal/Portal.d.ts +20 -20
- package/Portal/Portal.js +15 -15
- package/Portal/index.d.ts +1 -1
- package/Progress/Progress.d.ts +59 -59
- package/Progress/Progress.js +21 -21
- package/Progress/index.d.ts +2 -2
- package/Provider/ConfigProvider.d.ts +8 -8
- package/Provider/ConfigProvider.js +6 -6
- package/Provider/context.d.ts +6 -6
- package/Provider/context.js +2 -2
- package/Provider/index.d.ts +4 -4
- package/Radio/Radio.d.ts +41 -41
- package/Radio/Radio.js +21 -21
- package/Radio/RadioGroup.d.ts +47 -47
- package/Radio/RadioGroup.js +20 -20
- package/Radio/RadioGroupContext.d.ts +9 -9
- package/Radio/index.d.ts +3 -3
- package/Select/AutoComplete.d.ts +101 -101
- package/Select/AutoComplete.js +101 -101
- package/Select/Option.d.ts +19 -19
- package/Select/Option.js +37 -37
- package/Select/Select.d.ts +94 -94
- package/Select/Select.js +111 -111
- package/Select/SelectControlContext.d.ts +3 -3
- package/Select/SelectTrigger.d.ts +89 -89
- package/Select/SelectTrigger.js +44 -39
- package/Select/SelectTriggerTags.d.ts +19 -19
- package/Select/SelectTriggerTags.js +21 -21
- package/Select/TreeSelect.d.ts +68 -68
- package/Select/TreeSelect.js +183 -183
- package/Select/index.d.ts +9 -9
- package/Select/typings.d.ts +12 -12
- package/Select/useSelectTriggerTags.d.ts +19 -19
- package/Select/useSelectTriggerTags.js +53 -53
- package/Skeleton/Skeleton.d.ts +22 -22
- package/Skeleton/Skeleton.js +7 -7
- package/Skeleton/index.d.ts +1 -1
- package/Slider/Slider.d.ts +51 -51
- package/Slider/Slider.js +174 -174
- package/Slider/index.d.ts +3 -3
- package/Slider/useSlider.d.ts +31 -31
- package/Slider/useSlider.js +99 -99
- package/Stepper/Step.d.ts +41 -41
- package/Stepper/Step.js +9 -9
- package/Stepper/Stepper.d.ts +19 -19
- package/Stepper/Stepper.js +26 -26
- package/Stepper/index.d.ts +2 -2
- package/Switch/Switch.d.ts +43 -43
- package/Switch/Switch.js +18 -18
- package/Switch/index.d.ts +2 -2
- package/Table/Table.d.ts +110 -110
- package/Table/Table.js +146 -146
- package/Table/TableBody.d.ts +10 -10
- package/Table/TableBody.js +13 -13
- package/Table/TableBodyRow.d.ts +12 -12
- package/Table/TableBodyRow.js +45 -45
- package/Table/TableCell.d.ts +20 -20
- package/Table/TableCell.js +15 -15
- package/Table/TableContext.d.ts +52 -52
- package/Table/TableContext.js +2 -2
- package/Table/TableExpandedTable.d.ts +12 -12
- package/Table/TableExpandedTable.js +14 -14
- package/Table/TableHeader.d.ts +4 -4
- package/Table/TableHeader.js +20 -20
- package/Table/draggable/useTableDraggable.d.ts +14 -14
- package/Table/draggable/useTableDraggable.js +54 -54
- package/Table/editable/TableEditRenderWrapper.d.ts +8 -7
- package/Table/editable/TableEditRenderWrapper.js +8 -8
- package/Table/expandable/TableExpandable.d.ts +28 -28
- package/Table/expandable/TableExpandable.js +15 -15
- package/Table/index.d.ts +6 -6
- package/Table/pagination/TablePagination.d.ts +10 -10
- package/Table/pagination/TablePagination.js +15 -15
- package/Table/pagination/useTablePagination.d.ts +8 -8
- package/Table/pagination/useTablePagination.js +21 -21
- package/Table/refresh/TableRefresh.d.ts +10 -10
- package/Table/refresh/TableRefresh.js +13 -13
- package/Table/rowSelection/TableRowSelection.d.ts +19 -19
- package/Table/rowSelection/TableRowSelection.js +70 -70
- package/Table/rowSelection/useTableRowSelection.d.ts +6 -6
- package/Table/rowSelection/useTableRowSelection.js +47 -47
- package/Table/sorting/TableSortingIcon.d.ts +11 -11
- package/Table/sorting/TableSortingIcon.js +18 -18
- package/Table/sorting/useTableSorting.d.ts +12 -12
- package/Table/sorting/useTableSorting.js +103 -103
- package/Table/useTableFetchMore.d.ts +10 -10
- package/Table/useTableFetchMore.js +42 -42
- package/Table/useTableLoading.d.ts +5 -5
- package/Table/useTableLoading.js +13 -13
- package/Table/useTableScroll.d.ts +550 -568
- package/Table/useTableScroll.js +275 -275
- package/Tabs/Tab.d.ts +19 -19
- package/Tabs/Tab.js +9 -9
- package/Tabs/TabPane.d.ts +14 -14
- package/Tabs/TabPane.js +11 -11
- package/Tabs/Tabs.d.ts +39 -39
- package/Tabs/Tabs.js +36 -36
- package/Tabs/index.d.ts +3 -3
- package/Tabs/useTabsOverflow.d.ts +8 -8
- package/Tabs/useTabsOverflow.js +56 -56
- package/Tag/Tag.d.ts +29 -29
- package/Tag/Tag.js +14 -14
- package/Tag/index.d.ts +2 -2
- package/TextField/TextField.d.ts +54 -54
- package/TextField/TextField.js +33 -33
- package/TextField/index.d.ts +2 -2
- package/TextField/useTextFieldControl.d.ts +10 -10
- package/TextField/useTextFieldControl.js +12 -12
- package/Textarea/Textarea.d.ts +58 -58
- package/Textarea/Textarea.js +22 -22
- package/Textarea/index.d.ts +2 -2
- package/TimePanel/TimePanel.d.ts +66 -66
- package/TimePanel/TimePanel.js +54 -54
- package/TimePanel/TimePanelAction.d.ts +18 -18
- package/TimePanel/TimePanelAction.js +7 -7
- package/TimePanel/TimePanelColumn.d.ts +37 -37
- package/TimePanel/TimePanelColumn.js +28 -28
- package/TimePanel/index.d.ts +3 -3
- package/TimePicker/TimePicker.d.ts +24 -24
- package/TimePicker/TimePicker.js +99 -99
- package/TimePicker/TimePickerPanel.d.ts +24 -24
- package/TimePicker/TimePickerPanel.js +7 -7
- package/TimePicker/index.d.ts +2 -2
- package/Tooltip/Tooltip.d.ts +25 -25
- package/Tooltip/Tooltip.js +27 -27
- package/Tooltip/index.d.ts +1 -1
- package/Tooltip/useDelayMouseEnterLeave.d.ts +12 -12
- package/Tooltip/useDelayMouseEnterLeave.js +36 -36
- package/Transition/Collapse.d.ts +15 -15
- package/Transition/Collapse.js +96 -96
- package/Transition/Fade.d.ts +8 -8
- package/Transition/Fade.js +74 -74
- package/Transition/Grow.d.ts +13 -13
- package/Transition/Grow.js +101 -101
- package/Transition/SlideFade.d.ts +15 -15
- package/Transition/SlideFade.js +83 -83
- package/Transition/Transition.d.ts +98 -98
- package/Transition/Transition.js +21 -21
- package/Transition/Zoom.d.ts +8 -8
- package/Transition/Zoom.js +74 -74
- package/Transition/getAutoSizeDuration.d.ts +1 -1
- package/Transition/getAutoSizeDuration.js +7 -7
- package/Transition/getTransitionStyleProps.d.ts +16 -16
- package/Transition/getTransitionStyleProps.js +22 -22
- package/Transition/index.d.ts +6 -6
- package/Transition/reflow.d.ts +4 -4
- package/Transition/reflow.js +6 -6
- package/Transition/useAutoTransitionDuration.d.ts +6 -6
- package/Transition/useAutoTransitionDuration.js +10 -10
- package/Transition/useSetNodeTransition.d.ts +7 -7
- package/Transition/useSetNodeTransition.js +30 -30
- package/Tree/Tree.d.ts +70 -70
- package/Tree/Tree.js +116 -116
- package/Tree/TreeNode.d.ts +41 -41
- package/Tree/TreeNode.js +29 -29
- package/Tree/TreeNodeList.d.ts +25 -25
- package/Tree/TreeNodeList.js +22 -22
- package/Tree/getTreeNodeEntities.d.ts +11 -11
- package/Tree/getTreeNodeEntities.js +84 -84
- package/Tree/index.d.ts +8 -8
- package/Tree/toggleValue.d.ts +4 -4
- package/Tree/toggleValue.js +13 -13
- package/Tree/traverseTree.d.ts +2 -2
- package/Tree/traverseTree.js +8 -8
- package/Tree/typings.d.ts +16 -16
- package/Tree/useTreeExpandedValue.d.ts +15 -15
- package/Tree/useTreeExpandedValue.js +26 -26
- package/Typography/Typography.d.ts +43 -43
- package/Typography/Typography.js +31 -31
- package/Typography/index.d.ts +11 -11
- package/Upload/UploadButton.d.ts +10 -10
- package/Upload/UploadButton.js +14 -14
- package/Upload/UploadInput.d.ts +21 -21
- package/Upload/UploadInput.js +18 -18
- package/Upload/UploadPicture.d.ts +49 -49
- package/Upload/UploadPicture.js +43 -43
- package/Upload/UploadPictureBlock.d.ts +20 -20
- package/Upload/UploadPictureBlock.js +70 -70
- package/Upload/UploadPictureWall.d.ts +81 -81
- package/Upload/UploadPictureWall.js +144 -144
- package/Upload/UploadPictureWallItem.d.ts +15 -15
- package/Upload/UploadPictureWallItem.js +10 -10
- package/Upload/UploadResult.d.ts +35 -35
- package/Upload/UploadResult.js +19 -19
- package/Upload/index.d.ts +6 -6
- package/_internal/InputCheck/InputCheck.d.ts +33 -33
- package/_internal/InputCheck/InputCheck.js +11 -11
- package/_internal/InputCheck/InputCheckGroup.d.ts +18 -18
- package/_internal/InputCheck/InputCheckGroup.js +7 -7
- package/_internal/InputCheck/index.d.ts +3 -3
- package/_internal/InputTriggerPopper/InputTriggerPopper.d.ts +18 -18
- package/_internal/InputTriggerPopper/InputTriggerPopper.js +35 -35
- package/_internal/InputTriggerPopper/index.d.ts +1 -1
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.d.ts +21 -21
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.js +53 -53
- package/_internal/SlideFadeOverlay/index.d.ts +1 -1
- package/_internal/SlideFadeOverlay/useTopStack.d.ts +1 -1
- package/_internal/SlideFadeOverlay/useTopStack.js +17 -17
- package/hooks/useClickAway.d.ts +5 -5
- package/hooks/useClickAway.js +18 -18
- package/hooks/useComposeRefs.d.ts +2 -2
- package/hooks/useComposeRefs.js +2 -2
- package/hooks/useDocumentEscapeKeyDown.d.ts +3 -3
- package/hooks/useDocumentEscapeKeyDown.js +15 -15
- package/hooks/useDocumentEvents.d.ts +5 -5
- package/hooks/useDocumentEvents.js +16 -16
- package/hooks/useDocumentTabKeyDown.d.ts +3 -3
- package/hooks/useDocumentTabKeyDown.js +14 -14
- package/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/hooks/useIsomorphicLayoutEffect.js +2 -2
- package/hooks/useLastCallback.d.ts +1 -1
- package/hooks/useLastCallback.js +5 -5
- package/hooks/useLastValue.d.ts +3 -3
- package/hooks/useLastValue.js +4 -4
- package/hooks/usePreviousValue.d.ts +1 -1
- package/hooks/usePreviousValue.js +6 -6
- package/hooks/useWindowWidth.d.ts +1 -1
- package/hooks/useWindowWidth.js +10 -10
- package/index.d.ts +102 -102
- package/package.json +14 -30
- package/utils/array-move.d.ts +1 -1
- package/utils/array-move.js +10 -10
- package/utils/composeRefs.d.ts +21 -21
- package/utils/composeRefs.js +29 -29
- package/utils/cx.d.ts +1 -1
- package/utils/general.d.ts +8 -8
- package/utils/getElement.d.ts +3 -3
- package/utils/getElement.js +11 -11
- package/utils/jsx-types.d.ts +11 -11
- package/utils/scroll-lock.d.ts +2 -2
- package/utils/scroll-lock.js +17 -17
package/Table/useTableScroll.js
CHANGED
|
@@ -1,280 +1,280 @@
|
|
|
1
1
|
import { useRef, useState, useCallback, useEffect, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
const HEADER_DEFAULT_HEIGHT = 40; // px
|
|
4
|
-
const SCROLL_BAR_MIN_START_AT = 4; // px
|
|
5
|
-
const SCROLL_BAR_MAX_END_SPACING = 16; // px
|
|
6
|
-
const FETCH_MORE_TRIGGER_AT_BOTTOM = 46; // px
|
|
7
|
-
const SCROLL_BAR_DISPLAY_TIMES = 1500; // ms
|
|
8
|
-
const defaultScrollBarTrackStyle = {
|
|
9
|
-
position: 'absolute',
|
|
10
|
-
right: 0,
|
|
11
|
-
top: `${HEADER_DEFAULT_HEIGHT}px`,
|
|
12
|
-
width: 12,
|
|
13
|
-
height: 0,
|
|
14
|
-
opacity: '0',
|
|
15
|
-
transition: '0.1s opacity ease-in',
|
|
16
|
-
backgroundColor: '#F2F2F2',
|
|
17
|
-
};
|
|
18
|
-
const defaultScrollBarStyle = {
|
|
19
|
-
display: 'flex',
|
|
20
|
-
justifyContent: 'center',
|
|
21
|
-
alignItems: 'flex-start',
|
|
22
|
-
position: 'absolute',
|
|
23
|
-
right: 0,
|
|
24
|
-
top: `${SCROLL_BAR_MIN_START_AT}px`,
|
|
25
|
-
width: 10,
|
|
26
|
-
height: 0,
|
|
27
|
-
borderRadius: 10,
|
|
28
|
-
transform: 'translate3d(0, 0, 0)',
|
|
29
|
-
outline: 'none',
|
|
30
|
-
opacity: '0',
|
|
31
|
-
transition: '0.1s opacity ease-in',
|
|
32
|
-
backgroundColor: 'transparent',
|
|
33
|
-
};
|
|
34
|
-
function useTableScroll(props) {
|
|
35
|
-
const { onFetchMore, loading, scrollBarSize = 4, } = props;
|
|
36
|
-
const scrollRef = useRef(null);
|
|
37
|
-
const tableRef = useRef(null);
|
|
38
|
-
const scrollBarTrackRef = useRef(null);
|
|
39
|
-
const scrollBarRef = useRef(null);
|
|
40
|
-
const scrollBarDisplayTimer = useRef();
|
|
41
|
-
const [scrollBarHeight, setScrollBarHeight] = useState(0);
|
|
42
|
-
const [pointerOffset, setPointerOffset] = useState(0);
|
|
43
|
-
const [isHorizontalScrolling, toggleIsHorizontalScrolling] = useState(false);
|
|
44
|
-
/** set scroll bar callback */
|
|
45
|
-
const onSetScrollBarHeight = useCallback(() => {
|
|
46
|
-
/** @NOTE Scroll bar 高度為可視區域的百分比 */
|
|
47
|
-
if (!scrollRef.current)
|
|
48
|
-
return;
|
|
49
|
-
const { scrollHeight, clientHeight: tableHeight, } = scrollRef.current;
|
|
50
|
-
const bodyHeight = scrollHeight - HEADER_DEFAULT_HEIGHT;
|
|
51
|
-
const viewAreaHeight = tableHeight - HEADER_DEFAULT_HEIGHT;
|
|
52
|
-
const nextHeight = Math.max((viewAreaHeight - (SCROLL_BAR_MAX_END_SPACING * 2)) * (viewAreaHeight / bodyHeight), tableHeight / 10);
|
|
53
|
-
setScrollBarHeight(nextHeight);
|
|
54
|
-
}, []);
|
|
55
|
-
/** display/hide scroll bar */
|
|
56
|
-
const onHideScrollBar = useCallback(() => {
|
|
57
|
-
if (!scrollBarRef.current)
|
|
58
|
-
return;
|
|
59
|
-
if (scrollBarDisplayTimer.current) {
|
|
60
|
-
window.clearTimeout(scrollBarDisplayTimer.current);
|
|
61
|
-
}
|
|
62
|
-
scrollBarDisplayTimer.current = window.setTimeout(() => {
|
|
63
|
-
if (scrollBarRef.current) {
|
|
64
|
-
scrollBarRef.current.style.opacity = '0';
|
|
65
|
-
scrollBarRef.current.style.pointerEvents = 'none';
|
|
66
|
-
}
|
|
67
|
-
if (scrollBarTrackRef.current) {
|
|
68
|
-
scrollBarTrackRef.current.style.opacity = '0';
|
|
69
|
-
scrollBarTrackRef.current.style.pointerEvents = 'none';
|
|
70
|
-
}
|
|
71
|
-
}, SCROLL_BAR_DISPLAY_TIMES);
|
|
72
|
-
}, []);
|
|
73
|
-
const onDisplayScrollBar = useCallback(() => {
|
|
74
|
-
if (!scrollBarRef.current || !scrollRef.current || !scrollBarTrackRef.current)
|
|
75
|
-
return;
|
|
76
|
-
/** 觸控螢幕不需要 scroll bar */
|
|
77
|
-
const isTouchEnabled = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0);
|
|
78
|
-
/** firefox 的滾軸只能同時顯示 or 取消,所以乾脆就用原生的(除非能單獨關掉直向的滾軸,只顯示橫向的才行) */
|
|
79
|
-
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
80
|
-
if (isTouchEnabled || isFirefox)
|
|
81
|
-
return;
|
|
82
|
-
scrollBarRef.current.style.opacity = '1';
|
|
83
|
-
scrollBarRef.current.style.pointerEvents = 'auto';
|
|
84
|
-
scrollBarTrackRef.current.style.opacity = '1';
|
|
85
|
-
scrollBarTrackRef.current.style.pointerEvents = 'auto';
|
|
86
|
-
if (scrollBarDisplayTimer.current) {
|
|
87
|
-
window.clearTimeout(scrollBarDisplayTimer.current);
|
|
88
|
-
}
|
|
89
|
-
}, []);
|
|
90
|
-
const resetPointerOffset = useCallback(() => setPointerOffset(0), []);
|
|
91
|
-
/** scroll bar style reset when mouse leave */
|
|
92
|
-
const onScrollBarLeave = useCallback(() => {
|
|
93
|
-
if (scrollBarRef.current) {
|
|
94
|
-
scrollBarRef.current.childNodes[0].style.width = `${scrollBarSize}px`;
|
|
95
|
-
}
|
|
96
|
-
resetPointerOffset();
|
|
97
|
-
}, []);
|
|
98
|
-
/** when use mouse to drag scroll bar, get cursor position */
|
|
99
|
-
const onScrollBarMouseDown = useCallback(({ clientY }) => {
|
|
100
|
-
const { current: scrollBar } = scrollBarRef;
|
|
101
|
-
if (!scrollBar)
|
|
102
|
-
return;
|
|
103
|
-
const { top: initScrollBarTop } = scrollBar.getBoundingClientRect();
|
|
104
|
-
setPointerOffset(clientY - initScrollBarTop);
|
|
105
|
-
}, []);
|
|
106
|
-
const onScrollBarMouseUp = useCallback(() => resetPointerOffset(), []);
|
|
107
|
-
/** 偵測 table 高度是否發生變化,有的話就要重新計算 scroll bar 長度 */
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
const { current: table } = tableRef;
|
|
110
|
-
function resizing() {
|
|
111
|
-
window.requestAnimationFrame(onSetScrollBarHeight);
|
|
112
|
-
}
|
|
113
|
-
if (table) {
|
|
114
|
-
const observer = new ResizeObserver(resizing);
|
|
115
|
-
observer.observe(table);
|
|
116
|
-
return () => {
|
|
117
|
-
observer.disconnect();
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
return () => { };
|
|
121
|
-
}, []);
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
const { current: body } = scrollRef;
|
|
124
|
-
const { current: scrollBar } = scrollBarRef;
|
|
125
|
-
const { current: scrollBarTrack } = scrollBarTrackRef;
|
|
126
|
-
if (!body || !scrollBar || !scrollBarTrack)
|
|
127
|
-
return;
|
|
128
|
-
/** 游標在滾軸上長按並移動 */
|
|
129
|
-
function onMouseMove({ clientY }) {
|
|
130
|
-
const { scrollHeight, clientHeight: tableHeight, } = body;
|
|
131
|
-
if (!pointerOffset)
|
|
132
|
-
return;
|
|
133
|
-
// keep scroll bar display when moving
|
|
134
|
-
window.requestAnimationFrame(onDisplayScrollBar);
|
|
135
|
-
const { top: tableTop, } = body.getBoundingClientRect();
|
|
136
|
-
/** Table 最大滾動距離 */
|
|
137
|
-
const maxScrollDistance = scrollHeight - tableHeight;
|
|
138
|
-
/** 游標在 scroll bar 上的位置 */
|
|
139
|
-
const scrollBarCurrentPosition = clientY - (tableTop + HEADER_DEFAULT_HEIGHT) - pointerOffset;
|
|
140
|
-
/** 可視區域高度 */
|
|
141
|
-
const viewAreaHeight = tableHeight - HEADER_DEFAULT_HEIGHT;
|
|
142
|
-
/** 最大滑動距離 */
|
|
143
|
-
const maxScrollBarDistance = viewAreaHeight - scrollBarHeight - SCROLL_BAR_MAX_END_SPACING;
|
|
144
|
-
/** 計算出來的距離 */
|
|
145
|
-
const clampScrollBarTop = Math.min(Math.max(scrollBarCurrentPosition, 0), // min boundary
|
|
146
|
-
maxScrollBarDistance);
|
|
147
|
-
scrollBar.style.setProperty('transform', `translate3d(0, ${clampScrollBarTop}px, 0)`);
|
|
148
|
-
body.scrollTop = ((clampScrollBarTop * maxScrollDistance) / maxScrollBarDistance);
|
|
149
|
-
}
|
|
150
|
-
/** 在滾軸滑軌上點擊,直接滾動到指定位置上 */
|
|
151
|
-
function onMouseClick({ clientY }) {
|
|
152
|
-
if (!scrollBar)
|
|
153
|
-
return;
|
|
154
|
-
const { scrollHeight, clientHeight: tableHeight, } = body;
|
|
155
|
-
// keep scroll bar display when moving
|
|
156
|
-
window.requestAnimationFrame(onDisplayScrollBar);
|
|
157
|
-
const { top: tableTop, } = body.getBoundingClientRect();
|
|
158
|
-
/** Table 最大滾動距離 */
|
|
159
|
-
const maxScrollDistance = scrollHeight - tableHeight;
|
|
160
|
-
/** 游標在 Track 上的位置 */
|
|
161
|
-
const scrollBarCurrentPosition = clientY - (tableTop + HEADER_DEFAULT_HEIGHT) - (scrollBarHeight / 2);
|
|
162
|
-
/** 可視區域高度 */
|
|
163
|
-
const viewAreaHeight = tableHeight - HEADER_DEFAULT_HEIGHT;
|
|
164
|
-
/** 最大滑動距離 */
|
|
165
|
-
const maxScrollBarDistance = viewAreaHeight - scrollBarHeight - SCROLL_BAR_MAX_END_SPACING;
|
|
166
|
-
/** 計算出來的距離 */
|
|
167
|
-
const clampScrollBarTop = Math.min(Math.max(scrollBarCurrentPosition, 0), // min boundary
|
|
168
|
-
maxScrollBarDistance);
|
|
169
|
-
scrollBar.style.setProperty('transform', `translate3d(0, ${clampScrollBarTop}px, 0)`);
|
|
170
|
-
body.scrollTop = ((clampScrollBarTop * maxScrollDistance) / maxScrollBarDistance);
|
|
171
|
-
}
|
|
172
|
-
/** 游標移動到滾軸/滑軌上方時 */
|
|
173
|
-
function onMouseOver() {
|
|
174
|
-
scrollBar.style.setProperty('transition', '0s');
|
|
175
|
-
onDisplayScrollBar();
|
|
176
|
-
}
|
|
177
|
-
/** 游標移開滾軸/滑軌上方時 */
|
|
178
|
-
function onMouseLeave() {
|
|
179
|
-
scrollBar.style.setProperty('transition', '0.1s');
|
|
180
|
-
onHideScrollBar();
|
|
181
|
-
}
|
|
182
|
-
scrollBar.addEventListener('mousemove', onMouseMove, false);
|
|
183
|
-
scrollBar.addEventListener('mouseover', onMouseOver, false);
|
|
184
|
-
scrollBar.addEventListener('mouseleave', onMouseLeave, false);
|
|
185
|
-
scrollBarTrack.addEventListener('mousemove', onMouseMove, false);
|
|
186
|
-
scrollBarTrack.addEventListener('mouseover', onMouseOver, false);
|
|
187
|
-
scrollBarTrack.addEventListener('mouseleave', onMouseLeave, false);
|
|
188
|
-
scrollBarTrack.addEventListener('click', onMouseClick, false);
|
|
189
|
-
return () => {
|
|
190
|
-
scrollBar.removeEventListener('mousemove', onMouseMove, false);
|
|
191
|
-
scrollBar.removeEventListener('mouseover', onMouseOver, false);
|
|
192
|
-
scrollBar.removeEventListener('mouseleave', onMouseLeave, false);
|
|
193
|
-
scrollBarTrack.removeEventListener('mousemove', onMouseMove, false);
|
|
194
|
-
scrollBarTrack.removeEventListener('mouseover', onMouseOver, false);
|
|
195
|
-
scrollBarTrack.removeEventListener('mouseleave', onMouseLeave, false);
|
|
196
|
-
scrollBarTrack.removeEventListener('click', onMouseClick, false);
|
|
197
|
-
};
|
|
198
|
-
}, [scrollBarHeight, pointerOffset, onDisplayScrollBar, onHideScrollBar]);
|
|
199
|
-
/** scroll bar fatter when mouse enter */
|
|
200
|
-
const onScrollBarEnter = useCallback(() => {
|
|
201
|
-
if (scrollBarRef.current) {
|
|
202
|
-
scrollBarRef.current.childNodes[0].style.width = `${scrollBarSize + 6}px`;
|
|
203
|
-
}
|
|
204
|
-
}, []);
|
|
205
|
-
/** scroll table directly */
|
|
206
|
-
const setScrollBarTop = useCallback(() => {
|
|
207
|
-
if (scrollRef.current) {
|
|
208
|
-
const { clientHeight: tableHeight, scrollTop, scrollHeight, } = scrollRef.current;
|
|
209
|
-
/** @NOTE don't apply scroll change when use pointer dragging */
|
|
210
|
-
if (scrollBarRef.current && !pointerOffset) {
|
|
211
|
-
const bodyHeight = scrollHeight - HEADER_DEFAULT_HEIGHT;
|
|
212
|
-
const viewAreaHeight = tableHeight - HEADER_DEFAULT_HEIGHT;
|
|
213
|
-
const distance = Math.max((viewAreaHeight * Math.max((scrollTop / bodyHeight), 0)), 0);
|
|
214
|
-
scrollBarRef.current.style.transform = `translate3d(0, ${distance}px, 0)`;
|
|
215
|
-
}
|
|
216
|
-
if (scrollBarTrackRef.current) {
|
|
217
|
-
scrollBarTrackRef.current.style.height = `${tableHeight - HEADER_DEFAULT_HEIGHT}px`;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}, [scrollBarHeight, pointerOffset]);
|
|
221
|
-
const onScroll = useCallback((scrollTarget) => {
|
|
222
|
-
/** 使用者開始橫向滾動 */
|
|
223
|
-
if (scrollTarget.target.scrollLeft) {
|
|
224
|
-
toggleIsHorizontalScrolling(true);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
toggleIsHorizontalScrolling(false);
|
|
228
|
-
}
|
|
229
|
-
if (loading)
|
|
230
|
-
return;
|
|
231
|
-
if (scrollRef.current) {
|
|
232
|
-
const { clientHeight, scrollTop, scrollHeight, } = scrollRef.current;
|
|
233
|
-
/** 如果不需要滾動,則不需要觸發 */
|
|
234
|
-
if (clientHeight >= scrollHeight)
|
|
235
|
-
return;
|
|
236
|
-
window.requestAnimationFrame(onDisplayScrollBar);
|
|
237
|
-
/** @Note safari specific bug fix for scroll bouncing */
|
|
238
|
-
const belowBottom = scrollTop > (scrollHeight - clientHeight);
|
|
239
|
-
if (belowBottom)
|
|
240
|
-
return;
|
|
241
|
-
window.requestAnimationFrame(setScrollBarTop);
|
|
242
|
-
/** trigger fetchMore when scrolling */
|
|
243
|
-
if ((scrollHeight - (scrollTop + clientHeight)) < FETCH_MORE_TRIGGER_AT_BOTTOM) {
|
|
244
|
-
onFetchMore === null || onFetchMore === void 0 ? void 0 : onFetchMore();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
window.requestAnimationFrame(onHideScrollBar);
|
|
248
|
-
}, [loading, setScrollBarTop, onDisplayScrollBar, onFetchMore, onHideScrollBar]);
|
|
249
|
-
const scrollBarStyle = useMemo(() => ({
|
|
250
|
-
...defaultScrollBarStyle,
|
|
251
|
-
height: `${scrollBarHeight}px`,
|
|
252
|
-
}), [scrollBarHeight]);
|
|
253
|
-
const scrollBarTrackStyle = useMemo(() => {
|
|
254
|
-
var _a, _b;
|
|
255
|
-
return ({
|
|
256
|
-
...defaultScrollBarTrackStyle,
|
|
257
|
-
height: `${(_b = (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight) !== null && _b !== void 0 ? _b : 0}px`,
|
|
258
|
-
});
|
|
259
|
-
}, [scrollBarHeight]);
|
|
260
|
-
/** composing result */
|
|
261
|
-
const tableScrollContainer = {
|
|
262
|
-
ref: scrollRef,
|
|
263
|
-
target: tableRef,
|
|
264
|
-
onScroll,
|
|
265
|
-
};
|
|
266
|
-
const scrollElement = {
|
|
267
|
-
ref: scrollBarRef,
|
|
268
|
-
trackRef: scrollBarTrackRef,
|
|
269
|
-
scrollBarSize,
|
|
270
|
-
onMouseDown: onScrollBarMouseDown,
|
|
271
|
-
onMouseUp: onScrollBarMouseUp,
|
|
272
|
-
onMouseEnter: onScrollBarEnter,
|
|
273
|
-
onMouseLeave: onScrollBarLeave,
|
|
274
|
-
style: scrollBarStyle,
|
|
275
|
-
trackStyle: scrollBarTrackStyle,
|
|
276
|
-
};
|
|
277
|
-
return [tableScrollContainer, scrollElement, isHorizontalScrolling];
|
|
3
|
+
const HEADER_DEFAULT_HEIGHT = 40; // px
|
|
4
|
+
const SCROLL_BAR_MIN_START_AT = 4; // px
|
|
5
|
+
const SCROLL_BAR_MAX_END_SPACING = 16; // px
|
|
6
|
+
const FETCH_MORE_TRIGGER_AT_BOTTOM = 46; // px
|
|
7
|
+
const SCROLL_BAR_DISPLAY_TIMES = 1500; // ms
|
|
8
|
+
const defaultScrollBarTrackStyle = {
|
|
9
|
+
position: 'absolute',
|
|
10
|
+
right: 0,
|
|
11
|
+
top: `${HEADER_DEFAULT_HEIGHT}px`,
|
|
12
|
+
width: 12,
|
|
13
|
+
height: 0,
|
|
14
|
+
opacity: '0',
|
|
15
|
+
transition: '0.1s opacity ease-in',
|
|
16
|
+
backgroundColor: '#F2F2F2',
|
|
17
|
+
};
|
|
18
|
+
const defaultScrollBarStyle = {
|
|
19
|
+
display: 'flex',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
alignItems: 'flex-start',
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
right: 0,
|
|
24
|
+
top: `${SCROLL_BAR_MIN_START_AT}px`,
|
|
25
|
+
width: 10,
|
|
26
|
+
height: 0,
|
|
27
|
+
borderRadius: 10,
|
|
28
|
+
transform: 'translate3d(0, 0, 0)',
|
|
29
|
+
outline: 'none',
|
|
30
|
+
opacity: '0',
|
|
31
|
+
transition: '0.1s opacity ease-in',
|
|
32
|
+
backgroundColor: 'transparent',
|
|
33
|
+
};
|
|
34
|
+
function useTableScroll(props) {
|
|
35
|
+
const { onFetchMore, loading, scrollBarSize = 4, } = props;
|
|
36
|
+
const scrollRef = useRef(null);
|
|
37
|
+
const tableRef = useRef(null);
|
|
38
|
+
const scrollBarTrackRef = useRef(null);
|
|
39
|
+
const scrollBarRef = useRef(null);
|
|
40
|
+
const scrollBarDisplayTimer = useRef();
|
|
41
|
+
const [scrollBarHeight, setScrollBarHeight] = useState(0);
|
|
42
|
+
const [pointerOffset, setPointerOffset] = useState(0);
|
|
43
|
+
const [isHorizontalScrolling, toggleIsHorizontalScrolling] = useState(false);
|
|
44
|
+
/** set scroll bar callback */
|
|
45
|
+
const onSetScrollBarHeight = useCallback(() => {
|
|
46
|
+
/** @NOTE Scroll bar 高度為可視區域的百分比 */
|
|
47
|
+
if (!scrollRef.current)
|
|
48
|
+
return;
|
|
49
|
+
const { scrollHeight, clientHeight: tableHeight, } = scrollRef.current;
|
|
50
|
+
const bodyHeight = scrollHeight - HEADER_DEFAULT_HEIGHT;
|
|
51
|
+
const viewAreaHeight = tableHeight - HEADER_DEFAULT_HEIGHT;
|
|
52
|
+
const nextHeight = Math.max((viewAreaHeight - (SCROLL_BAR_MAX_END_SPACING * 2)) * (viewAreaHeight / bodyHeight), tableHeight / 10);
|
|
53
|
+
setScrollBarHeight(nextHeight);
|
|
54
|
+
}, []);
|
|
55
|
+
/** display/hide scroll bar */
|
|
56
|
+
const onHideScrollBar = useCallback(() => {
|
|
57
|
+
if (!scrollBarRef.current)
|
|
58
|
+
return;
|
|
59
|
+
if (scrollBarDisplayTimer.current) {
|
|
60
|
+
window.clearTimeout(scrollBarDisplayTimer.current);
|
|
61
|
+
}
|
|
62
|
+
scrollBarDisplayTimer.current = window.setTimeout(() => {
|
|
63
|
+
if (scrollBarRef.current) {
|
|
64
|
+
scrollBarRef.current.style.opacity = '0';
|
|
65
|
+
scrollBarRef.current.style.pointerEvents = 'none';
|
|
66
|
+
}
|
|
67
|
+
if (scrollBarTrackRef.current) {
|
|
68
|
+
scrollBarTrackRef.current.style.opacity = '0';
|
|
69
|
+
scrollBarTrackRef.current.style.pointerEvents = 'none';
|
|
70
|
+
}
|
|
71
|
+
}, SCROLL_BAR_DISPLAY_TIMES);
|
|
72
|
+
}, []);
|
|
73
|
+
const onDisplayScrollBar = useCallback(() => {
|
|
74
|
+
if (!scrollBarRef.current || !scrollRef.current || !scrollBarTrackRef.current)
|
|
75
|
+
return;
|
|
76
|
+
/** 觸控螢幕不需要 scroll bar */
|
|
77
|
+
const isTouchEnabled = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0);
|
|
78
|
+
/** firefox 的滾軸只能同時顯示 or 取消,所以乾脆就用原生的(除非能單獨關掉直向的滾軸,只顯示橫向的才行) */
|
|
79
|
+
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
80
|
+
if (isTouchEnabled || isFirefox)
|
|
81
|
+
return;
|
|
82
|
+
scrollBarRef.current.style.opacity = '1';
|
|
83
|
+
scrollBarRef.current.style.pointerEvents = 'auto';
|
|
84
|
+
scrollBarTrackRef.current.style.opacity = '1';
|
|
85
|
+
scrollBarTrackRef.current.style.pointerEvents = 'auto';
|
|
86
|
+
if (scrollBarDisplayTimer.current) {
|
|
87
|
+
window.clearTimeout(scrollBarDisplayTimer.current);
|
|
88
|
+
}
|
|
89
|
+
}, []);
|
|
90
|
+
const resetPointerOffset = useCallback(() => setPointerOffset(0), []);
|
|
91
|
+
/** scroll bar style reset when mouse leave */
|
|
92
|
+
const onScrollBarLeave = useCallback(() => {
|
|
93
|
+
if (scrollBarRef.current) {
|
|
94
|
+
scrollBarRef.current.childNodes[0].style.width = `${scrollBarSize}px`;
|
|
95
|
+
}
|
|
96
|
+
resetPointerOffset();
|
|
97
|
+
}, []);
|
|
98
|
+
/** when use mouse to drag scroll bar, get cursor position */
|
|
99
|
+
const onScrollBarMouseDown = useCallback(({ clientY }) => {
|
|
100
|
+
const { current: scrollBar } = scrollBarRef;
|
|
101
|
+
if (!scrollBar)
|
|
102
|
+
return;
|
|
103
|
+
const { top: initScrollBarTop } = scrollBar.getBoundingClientRect();
|
|
104
|
+
setPointerOffset(clientY - initScrollBarTop);
|
|
105
|
+
}, []);
|
|
106
|
+
const onScrollBarMouseUp = useCallback(() => resetPointerOffset(), []);
|
|
107
|
+
/** 偵測 table 高度是否發生變化,有的話就要重新計算 scroll bar 長度 */
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
const { current: table } = tableRef;
|
|
110
|
+
function resizing() {
|
|
111
|
+
window.requestAnimationFrame(onSetScrollBarHeight);
|
|
112
|
+
}
|
|
113
|
+
if (table) {
|
|
114
|
+
const observer = new ResizeObserver(resizing);
|
|
115
|
+
observer.observe(table);
|
|
116
|
+
return () => {
|
|
117
|
+
observer.disconnect();
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return () => { };
|
|
121
|
+
}, []);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const { current: body } = scrollRef;
|
|
124
|
+
const { current: scrollBar } = scrollBarRef;
|
|
125
|
+
const { current: scrollBarTrack } = scrollBarTrackRef;
|
|
126
|
+
if (!body || !scrollBar || !scrollBarTrack)
|
|
127
|
+
return;
|
|
128
|
+
/** 游標在滾軸上長按並移動 */
|
|
129
|
+
function onMouseMove({ clientY }) {
|
|
130
|
+
const { scrollHeight, clientHeight: tableHeight, } = body;
|
|
131
|
+
if (!pointerOffset)
|
|
132
|
+
return;
|
|
133
|
+
// keep scroll bar display when moving
|
|
134
|
+
window.requestAnimationFrame(onDisplayScrollBar);
|
|
135
|
+
const { top: tableTop, } = body.getBoundingClientRect();
|
|
136
|
+
/** Table 最大滾動距離 */
|
|
137
|
+
const maxScrollDistance = scrollHeight - tableHeight;
|
|
138
|
+
/** 游標在 scroll bar 上的位置 */
|
|
139
|
+
const scrollBarCurrentPosition = clientY - (tableTop + HEADER_DEFAULT_HEIGHT) - pointerOffset;
|
|
140
|
+
/** 可視區域高度 */
|
|
141
|
+
const viewAreaHeight = tableHeight - HEADER_DEFAULT_HEIGHT;
|
|
142
|
+
/** 最大滑動距離 */
|
|
143
|
+
const maxScrollBarDistance = viewAreaHeight - scrollBarHeight - SCROLL_BAR_MAX_END_SPACING;
|
|
144
|
+
/** 計算出來的距離 */
|
|
145
|
+
const clampScrollBarTop = Math.min(Math.max(scrollBarCurrentPosition, 0), // min boundary
|
|
146
|
+
maxScrollBarDistance);
|
|
147
|
+
scrollBar.style.setProperty('transform', `translate3d(0, ${clampScrollBarTop}px, 0)`);
|
|
148
|
+
body.scrollTop = ((clampScrollBarTop * maxScrollDistance) / maxScrollBarDistance);
|
|
149
|
+
}
|
|
150
|
+
/** 在滾軸滑軌上點擊,直接滾動到指定位置上 */
|
|
151
|
+
function onMouseClick({ clientY }) {
|
|
152
|
+
if (!scrollBar)
|
|
153
|
+
return;
|
|
154
|
+
const { scrollHeight, clientHeight: tableHeight, } = body;
|
|
155
|
+
// keep scroll bar display when moving
|
|
156
|
+
window.requestAnimationFrame(onDisplayScrollBar);
|
|
157
|
+
const { top: tableTop, } = body.getBoundingClientRect();
|
|
158
|
+
/** Table 最大滾動距離 */
|
|
159
|
+
const maxScrollDistance = scrollHeight - tableHeight;
|
|
160
|
+
/** 游標在 Track 上的位置 */
|
|
161
|
+
const scrollBarCurrentPosition = clientY - (tableTop + HEADER_DEFAULT_HEIGHT) - (scrollBarHeight / 2);
|
|
162
|
+
/** 可視區域高度 */
|
|
163
|
+
const viewAreaHeight = tableHeight - HEADER_DEFAULT_HEIGHT;
|
|
164
|
+
/** 最大滑動距離 */
|
|
165
|
+
const maxScrollBarDistance = viewAreaHeight - scrollBarHeight - SCROLL_BAR_MAX_END_SPACING;
|
|
166
|
+
/** 計算出來的距離 */
|
|
167
|
+
const clampScrollBarTop = Math.min(Math.max(scrollBarCurrentPosition, 0), // min boundary
|
|
168
|
+
maxScrollBarDistance);
|
|
169
|
+
scrollBar.style.setProperty('transform', `translate3d(0, ${clampScrollBarTop}px, 0)`);
|
|
170
|
+
body.scrollTop = ((clampScrollBarTop * maxScrollDistance) / maxScrollBarDistance);
|
|
171
|
+
}
|
|
172
|
+
/** 游標移動到滾軸/滑軌上方時 */
|
|
173
|
+
function onMouseOver() {
|
|
174
|
+
scrollBar.style.setProperty('transition', '0s');
|
|
175
|
+
onDisplayScrollBar();
|
|
176
|
+
}
|
|
177
|
+
/** 游標移開滾軸/滑軌上方時 */
|
|
178
|
+
function onMouseLeave() {
|
|
179
|
+
scrollBar.style.setProperty('transition', '0.1s');
|
|
180
|
+
onHideScrollBar();
|
|
181
|
+
}
|
|
182
|
+
scrollBar.addEventListener('mousemove', onMouseMove, false);
|
|
183
|
+
scrollBar.addEventListener('mouseover', onMouseOver, false);
|
|
184
|
+
scrollBar.addEventListener('mouseleave', onMouseLeave, false);
|
|
185
|
+
scrollBarTrack.addEventListener('mousemove', onMouseMove, false);
|
|
186
|
+
scrollBarTrack.addEventListener('mouseover', onMouseOver, false);
|
|
187
|
+
scrollBarTrack.addEventListener('mouseleave', onMouseLeave, false);
|
|
188
|
+
scrollBarTrack.addEventListener('click', onMouseClick, false);
|
|
189
|
+
return () => {
|
|
190
|
+
scrollBar.removeEventListener('mousemove', onMouseMove, false);
|
|
191
|
+
scrollBar.removeEventListener('mouseover', onMouseOver, false);
|
|
192
|
+
scrollBar.removeEventListener('mouseleave', onMouseLeave, false);
|
|
193
|
+
scrollBarTrack.removeEventListener('mousemove', onMouseMove, false);
|
|
194
|
+
scrollBarTrack.removeEventListener('mouseover', onMouseOver, false);
|
|
195
|
+
scrollBarTrack.removeEventListener('mouseleave', onMouseLeave, false);
|
|
196
|
+
scrollBarTrack.removeEventListener('click', onMouseClick, false);
|
|
197
|
+
};
|
|
198
|
+
}, [scrollBarHeight, pointerOffset, onDisplayScrollBar, onHideScrollBar]);
|
|
199
|
+
/** scroll bar fatter when mouse enter */
|
|
200
|
+
const onScrollBarEnter = useCallback(() => {
|
|
201
|
+
if (scrollBarRef.current) {
|
|
202
|
+
scrollBarRef.current.childNodes[0].style.width = `${scrollBarSize + 6}px`;
|
|
203
|
+
}
|
|
204
|
+
}, []);
|
|
205
|
+
/** scroll table directly */
|
|
206
|
+
const setScrollBarTop = useCallback(() => {
|
|
207
|
+
if (scrollRef.current) {
|
|
208
|
+
const { clientHeight: tableHeight, scrollTop, scrollHeight, } = scrollRef.current;
|
|
209
|
+
/** @NOTE don't apply scroll change when use pointer dragging */
|
|
210
|
+
if (scrollBarRef.current && !pointerOffset) {
|
|
211
|
+
const bodyHeight = scrollHeight - HEADER_DEFAULT_HEIGHT;
|
|
212
|
+
const viewAreaHeight = tableHeight - HEADER_DEFAULT_HEIGHT;
|
|
213
|
+
const distance = Math.max((viewAreaHeight * Math.max((scrollTop / bodyHeight), 0)), 0);
|
|
214
|
+
scrollBarRef.current.style.transform = `translate3d(0, ${distance}px, 0)`;
|
|
215
|
+
}
|
|
216
|
+
if (scrollBarTrackRef.current) {
|
|
217
|
+
scrollBarTrackRef.current.style.height = `${tableHeight - HEADER_DEFAULT_HEIGHT}px`;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}, [scrollBarHeight, pointerOffset]);
|
|
221
|
+
const onScroll = useCallback((scrollTarget) => {
|
|
222
|
+
/** 使用者開始橫向滾動 */
|
|
223
|
+
if (scrollTarget.target.scrollLeft) {
|
|
224
|
+
toggleIsHorizontalScrolling(true);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
toggleIsHorizontalScrolling(false);
|
|
228
|
+
}
|
|
229
|
+
if (loading)
|
|
230
|
+
return;
|
|
231
|
+
if (scrollRef.current) {
|
|
232
|
+
const { clientHeight, scrollTop, scrollHeight, } = scrollRef.current;
|
|
233
|
+
/** 如果不需要滾動,則不需要觸發 */
|
|
234
|
+
if (clientHeight >= scrollHeight)
|
|
235
|
+
return;
|
|
236
|
+
window.requestAnimationFrame(onDisplayScrollBar);
|
|
237
|
+
/** @Note safari specific bug fix for scroll bouncing */
|
|
238
|
+
const belowBottom = scrollTop > (scrollHeight - clientHeight);
|
|
239
|
+
if (belowBottom)
|
|
240
|
+
return;
|
|
241
|
+
window.requestAnimationFrame(setScrollBarTop);
|
|
242
|
+
/** trigger fetchMore when scrolling */
|
|
243
|
+
if ((scrollHeight - (scrollTop + clientHeight)) < FETCH_MORE_TRIGGER_AT_BOTTOM) {
|
|
244
|
+
onFetchMore === null || onFetchMore === void 0 ? void 0 : onFetchMore();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
window.requestAnimationFrame(onHideScrollBar);
|
|
248
|
+
}, [loading, setScrollBarTop, onDisplayScrollBar, onFetchMore, onHideScrollBar]);
|
|
249
|
+
const scrollBarStyle = useMemo(() => ({
|
|
250
|
+
...defaultScrollBarStyle,
|
|
251
|
+
height: `${scrollBarHeight}px`,
|
|
252
|
+
}), [scrollBarHeight]);
|
|
253
|
+
const scrollBarTrackStyle = useMemo(() => {
|
|
254
|
+
var _a, _b;
|
|
255
|
+
return ({
|
|
256
|
+
...defaultScrollBarTrackStyle,
|
|
257
|
+
height: `${(_b = (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight) !== null && _b !== void 0 ? _b : 0}px`,
|
|
258
|
+
});
|
|
259
|
+
}, [scrollBarHeight]);
|
|
260
|
+
/** composing result */
|
|
261
|
+
const tableScrollContainer = {
|
|
262
|
+
ref: scrollRef,
|
|
263
|
+
target: tableRef,
|
|
264
|
+
onScroll,
|
|
265
|
+
};
|
|
266
|
+
const scrollElement = {
|
|
267
|
+
ref: scrollBarRef,
|
|
268
|
+
trackRef: scrollBarTrackRef,
|
|
269
|
+
scrollBarSize,
|
|
270
|
+
onMouseDown: onScrollBarMouseDown,
|
|
271
|
+
onMouseUp: onScrollBarMouseUp,
|
|
272
|
+
onMouseEnter: onScrollBarEnter,
|
|
273
|
+
onMouseLeave: onScrollBarLeave,
|
|
274
|
+
style: scrollBarStyle,
|
|
275
|
+
trackStyle: scrollBarTrackStyle,
|
|
276
|
+
};
|
|
277
|
+
return [tableScrollContainer, scrollElement, isHorizontalScrolling];
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
export { useTableScroll as default };
|
package/Tabs/Tab.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
-
export interface TabProps extends NativeElementPropsWithoutKeyAndRef<'button'> {
|
|
4
|
-
/**
|
|
5
|
-
* Whether the tab is active.
|
|
6
|
-
* Controlled by tabs.
|
|
7
|
-
*/
|
|
8
|
-
active?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Whether the tab is disabled
|
|
11
|
-
* @default false
|
|
12
|
-
*/
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The react component for `mezzanine` tab.
|
|
17
|
-
*/
|
|
18
|
-
declare const Tab: import("react").ForwardRefExoticComponent<TabProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
19
|
-
export default Tab;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
export interface TabProps extends NativeElementPropsWithoutKeyAndRef<'button'> {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the tab is active.
|
|
6
|
+
* Controlled by tabs.
|
|
7
|
+
*/
|
|
8
|
+
active?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the tab is disabled
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The react component for `mezzanine` tab.
|
|
17
|
+
*/
|
|
18
|
+
declare const Tab: import("react").ForwardRefExoticComponent<TabProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
19
|
+
export default Tab;
|
package/Tabs/Tab.js
CHANGED
|
@@ -3,15 +3,15 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
import { tabsClasses } from '@mezzanine-ui/core/tabs';
|
|
4
4
|
import cx from 'clsx';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* The react component for `mezzanine` tab.
|
|
8
|
-
*/
|
|
9
|
-
const Tab = forwardRef(function Tab(props, ref) {
|
|
10
|
-
const { active, children, className, disabled, ...rest } = props;
|
|
11
|
-
return (jsx("button", { ...rest, ref: ref, type: "button", "aria-disabled": disabled, className: cx(tabsClasses.tab, {
|
|
12
|
-
[tabsClasses.tabActive]: active,
|
|
13
|
-
}, className), disabled: disabled, children: children }));
|
|
14
|
-
});
|
|
6
|
+
/**
|
|
7
|
+
* The react component for `mezzanine` tab.
|
|
8
|
+
*/
|
|
9
|
+
const Tab = forwardRef(function Tab(props, ref) {
|
|
10
|
+
const { active, children, className, disabled, ...rest } = props;
|
|
11
|
+
return (jsx("button", { ...rest, ref: ref, type: "button", "aria-disabled": disabled, className: cx(tabsClasses.tab, {
|
|
12
|
+
[tabsClasses.tabActive]: active,
|
|
13
|
+
}, className), disabled: disabled, children: children }));
|
|
14
|
+
});
|
|
15
15
|
var Tab$1 = Tab;
|
|
16
16
|
|
|
17
17
|
export { Tab$1 as default };
|
package/Tabs/TabPane.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
-
import { TabProps } from './Tab';
|
|
4
|
-
export interface TabPaneProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
|
|
5
|
-
/**
|
|
6
|
-
* Only for tabs to control the tab pane.
|
|
7
|
-
*/
|
|
8
|
-
tab: ReactElement<TabProps>;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* The react component for `mezzanine` tab pane.
|
|
12
|
-
*/
|
|
13
|
-
declare const TabPane: import("react").ForwardRefExoticComponent<TabPaneProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
-
export default TabPane;
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
import { TabProps } from './Tab';
|
|
4
|
+
export interface TabPaneProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* Only for tabs to control the tab pane.
|
|
7
|
+
*/
|
|
8
|
+
tab: ReactElement<TabProps>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The react component for `mezzanine` tab pane.
|
|
12
|
+
*/
|
|
13
|
+
declare const TabPane: import("react").ForwardRefExoticComponent<TabPaneProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export default TabPane;
|