@mezzanine-ui/react 0.6.4
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 -0
- package/Accordion/Accordion.js +32 -0
- package/Accordion/AccordionControlContext.d.ts +9 -0
- package/Accordion/AccordionControlContext.js +5 -0
- package/Accordion/AccordionDetails.d.ts +10 -0
- package/Accordion/AccordionDetails.js +25 -0
- package/Accordion/AccordionSummary.d.ts +19 -0
- package/Accordion/AccordionSummary.js +50 -0
- package/Accordion/index.d.ts +3 -0
- package/Accordion/index.js +3 -0
- package/Alert/Alert.d.ts +20 -0
- package/Alert/Alert.js +20 -0
- package/Alert/index.d.ts +2 -0
- package/Alert/index.js +1 -0
- package/AppBar/AppBar.d.ts +14 -0
- package/AppBar/AppBar.js +35 -0
- package/AppBar/AppBarBrand.d.ts +5 -0
- package/AppBar/AppBarBrand.js +11 -0
- package/AppBar/AppBarMain.d.ts +5 -0
- package/AppBar/AppBarMain.js +11 -0
- package/AppBar/AppBarSupport.d.ts +5 -0
- package/AppBar/AppBarSupport.js +11 -0
- package/AppBar/index.d.ts +4 -0
- package/AppBar/index.js +4 -0
- package/Badge/Badge.d.ts +19 -0
- package/Badge/Badge.js +27 -0
- package/Badge/BadgeContainer.d.ts +8 -0
- package/Badge/BadgeContainer.js +14 -0
- package/Badge/index.d.ts +2 -0
- package/Badge/index.js +2 -0
- package/Button/Button.d.ts +11 -0
- package/Button/Button.js +37 -0
- package/Button/ButtonGroup.d.ts +63 -0
- package/Button/ButtonGroup.js +35 -0
- package/Button/IconButton.d.ts +21 -0
- package/Button/IconButton.js +13 -0
- package/Button/index.d.ts +20 -0
- package/Button/index.js +8 -0
- package/Button/typings.d.ts +44 -0
- package/Calendar/Calendar.d.ts +69 -0
- package/Calendar/Calendar.js +53 -0
- package/Calendar/CalendarCell.d.ts +22 -0
- package/Calendar/CalendarCell.js +18 -0
- package/Calendar/CalendarContext.d.ts +22 -0
- package/Calendar/CalendarContext.js +27 -0
- package/Calendar/CalendarControls.d.ts +26 -0
- package/Calendar/CalendarControls.js +20 -0
- package/Calendar/CalendarDayOfWeek.d.ts +15 -0
- package/Calendar/CalendarDayOfWeek.js +18 -0
- package/Calendar/CalendarDays.d.ts +38 -0
- package/Calendar/CalendarDays.js +48 -0
- package/Calendar/CalendarMonths.d.ts +42 -0
- package/Calendar/CalendarMonths.js +30 -0
- package/Calendar/CalendarWeeks.d.ts +41 -0
- package/Calendar/CalendarWeeks.js +54 -0
- package/Calendar/CalendarYears.d.ts +40 -0
- package/Calendar/CalendarYears.js +34 -0
- package/Calendar/index.d.ts +12 -0
- package/Calendar/index.js +12 -0
- package/Calendar/useCalendarControlModifiers.d.ts +7 -0
- package/Calendar/useCalendarControlModifiers.js +26 -0
- package/Calendar/useCalendarControls.d.ts +13 -0
- package/Calendar/useCalendarControls.js +34 -0
- package/Calendar/useCalendarModeStack.d.ts +6 -0
- package/Calendar/useCalendarModeStack.js +15 -0
- package/Card/Card.d.ts +51 -0
- package/Card/Card.js +20 -0
- package/Card/CardActions.d.ts +34 -0
- package/Card/CardActions.js +16 -0
- package/Card/index.d.ts +2 -0
- package/Card/index.js +2 -0
- package/Checkbox/CheckAll.d.ts +13 -0
- package/Checkbox/CheckAll.js +36 -0
- package/Checkbox/Checkbox.d.ts +46 -0
- package/Checkbox/Checkbox.js +33 -0
- package/Checkbox/CheckboxGroup.d.ts +47 -0
- package/Checkbox/CheckboxGroup.js +36 -0
- package/Checkbox/CheckboxGroupContext.d.ts +9 -0
- package/Checkbox/CheckboxGroupContext.js +5 -0
- package/Checkbox/index.d.ts +4 -0
- package/Checkbox/index.js +3 -0
- package/ConfirmActions/ConfirmActions.d.ts +45 -0
- package/ConfirmActions/ConfirmActions.js +16 -0
- package/ConfirmActions/index.d.ts +1 -0
- package/ConfirmActions/index.js +1 -0
- package/DatePicker/DatePicker.d.ts +32 -0
- package/DatePicker/DatePicker.js +135 -0
- package/DatePicker/DatePickerCalendar.d.ts +32 -0
- package/DatePicker/DatePickerCalendar.js +61 -0
- package/DatePicker/index.d.ts +2 -0
- package/DatePicker/index.js +2 -0
- package/DateRangePicker/DateRangePicker.d.ts +38 -0
- package/DateRangePicker/DateRangePicker.js +187 -0
- package/DateRangePicker/DateRangePickerCalendar.d.ts +26 -0
- package/DateRangePicker/DateRangePickerCalendar.js +98 -0
- package/DateRangePicker/index.d.ts +4 -0
- package/DateRangePicker/index.js +4 -0
- package/DateRangePicker/useDateRangeCalendarControls.d.ts +15 -0
- package/DateRangePicker/useDateRangeCalendarControls.js +93 -0
- package/DateRangePicker/useDateRangePickerValue.d.ts +23 -0
- package/DateRangePicker/useDateRangePickerValue.js +87 -0
- package/DateTimePicker/DateTimePicker.d.ts +28 -0
- package/DateTimePicker/DateTimePicker.js +122 -0
- package/DateTimePicker/DateTimePickerPanel.d.ts +29 -0
- package/DateTimePicker/DateTimePickerPanel.js +51 -0
- package/DateTimePicker/index.d.ts +2 -0
- package/DateTimePicker/index.js +2 -0
- package/Drawer/Drawer.d.ts +18 -0
- package/Drawer/Drawer.js +34 -0
- package/Drawer/index.d.ts +2 -0
- package/Drawer/index.js +1 -0
- package/Dropdown/Dropdown.d.ts +25 -0
- package/Dropdown/Dropdown.js +60 -0
- package/Dropdown/index.d.ts +1 -0
- package/Dropdown/index.js +1 -0
- package/Empty/Empty.d.ts +18 -0
- package/Empty/Empty.js +16 -0
- package/Empty/index.d.ts +1 -0
- package/Empty/index.js +1 -0
- package/Form/FormControlContext.d.ts +9 -0
- package/Form/FormControlContext.js +5 -0
- package/Form/FormField.d.ts +27 -0
- package/Form/FormField.js +24 -0
- package/Form/FormLabel.d.ts +11 -0
- package/Form/FormLabel.js +17 -0
- package/Form/FormMessage.d.ts +8 -0
- package/Form/FormMessage.js +18 -0
- package/Form/index.d.ts +5 -0
- package/Form/index.js +4 -0
- package/Form/typings.d.ts +4 -0
- package/Form/useAutoCompleteValueControl.d.ts +23 -0
- package/Form/useAutoCompleteValueControl.js +58 -0
- package/Form/useCheckboxControlValue.d.ts +11 -0
- package/Form/useCheckboxControlValue.js +29 -0
- package/Form/useControlValueState.d.ts +7 -0
- package/Form/useControlValueState.js +15 -0
- package/Form/useCustomControlValue.d.ts +5 -0
- package/Form/useCustomControlValue.js +18 -0
- package/Form/useInputControlValue.d.ts +7 -0
- package/Form/useInputControlValue.js +24 -0
- package/Form/useInputWithClearControlValue.d.ts +6 -0
- package/Form/useInputWithClearControlValue.js +33 -0
- package/Form/useRadioControlValue.d.ts +11 -0
- package/Form/useRadioControlValue.js +24 -0
- package/Form/useSelectValueControl.d.ts +16 -0
- package/Form/useSelectValueControl.js +59 -0
- package/Form/useSwitchControlValue.d.ts +7 -0
- package/Form/useSwitchControlValue.js +24 -0
- package/Icon/Icon.d.ts +24 -0
- package/Icon/Icon.js +23 -0
- package/Icon/index.d.ts +3 -0
- package/Icon/index.js +1 -0
- package/Input/Input.d.ts +50 -0
- package/Input/Input.js +28 -0
- package/Input/index.d.ts +2 -0
- package/Input/index.js +1 -0
- package/LICENSE +21 -0
- package/Loading/Loading.d.ts +34 -0
- package/Loading/Loading.js +28 -0
- package/Loading/index.d.ts +1 -0
- package/Loading/index.js +1 -0
- package/Menu/Menu.d.ts +29 -0
- package/Menu/Menu.js +22 -0
- package/Menu/MenuDivider.d.ts +8 -0
- package/Menu/MenuDivider.js +14 -0
- package/Menu/MenuItem.d.ts +24 -0
- package/Menu/MenuItem.js +26 -0
- package/Menu/MenuItemGroup.d.ts +13 -0
- package/Menu/MenuItemGroup.js +15 -0
- package/Menu/index.d.ts +5 -0
- package/Menu/index.js +4 -0
- package/Message/Message.d.ts +33 -0
- package/Message/Message.js +59 -0
- package/Message/index.d.ts +2 -0
- package/Message/index.js +1 -0
- package/Modal/Modal.d.ts +42 -0
- package/Modal/Modal.js +75 -0
- package/Modal/ModalActions.d.ts +10 -0
- package/Modal/ModalActions.js +18 -0
- package/Modal/ModalBody.d.ts +8 -0
- package/Modal/ModalBody.js +14 -0
- package/Modal/ModalControl.d.ts +7 -0
- package/Modal/ModalControl.js +8 -0
- package/Modal/ModalFooter.d.ts +8 -0
- package/Modal/ModalFooter.js +14 -0
- package/Modal/ModalHeader.d.ts +20 -0
- package/Modal/ModalHeader.js +20 -0
- package/Modal/index.d.ts +6 -0
- package/Modal/index.js +5 -0
- package/Modal/useIsTopModal.d.ts +1 -0
- package/Modal/useIsTopModal.js +22 -0
- package/Navigation/Navigation.d.ts +29 -0
- package/Navigation/Navigation.js +48 -0
- package/Navigation/NavigationContext.d.ts +6 -0
- package/Navigation/NavigationContext.js +7 -0
- package/Navigation/NavigationItem.d.ts +31 -0
- package/Navigation/NavigationItem.js +22 -0
- package/Navigation/NavigationSubMenu.d.ts +17 -0
- package/Navigation/NavigationSubMenu.js +65 -0
- package/Navigation/index.d.ts +4 -0
- package/Navigation/index.js +4 -0
- package/Notification/Notification.d.ts +54 -0
- package/Notification/Notification.js +78 -0
- package/Notification/index.d.ts +2 -0
- package/Notification/index.js +1 -0
- package/Notifier/NotifierManager.d.ts +17 -0
- package/Notifier/NotifierManager.js +31 -0
- package/Notifier/createNotifier.d.ts +21 -0
- package/Notifier/createNotifier.js +67 -0
- package/Notifier/index.d.ts +2 -0
- package/Notifier/index.js +1 -0
- package/Notifier/typings.d.ts +28 -0
- package/Overlay/Overlay.d.ts +43 -0
- package/Overlay/Overlay.js +31 -0
- package/Overlay/index.d.ts +1 -0
- package/Overlay/index.js +1 -0
- package/PageFooter/PageFooter.d.ts +15 -0
- package/PageFooter/PageFooter.js +13 -0
- package/PageFooter/index.d.ts +1 -0
- package/PageFooter/index.js +1 -0
- package/Pagination/Pagination.d.ts +78 -0
- package/Pagination/Pagination.js +29 -0
- package/Pagination/PaginationItem.d.ts +27 -0
- package/Pagination/PaginationItem.js +25 -0
- package/Pagination/PaginationJumper.d.ts +38 -0
- package/Pagination/PaginationJumper.js +52 -0
- package/Pagination/index.d.ts +5 -0
- package/Pagination/index.js +4 -0
- package/Pagination/usePagination.d.ts +16 -0
- package/Pagination/usePagination.js +78 -0
- package/Picker/PickerTrigger.d.ts +40 -0
- package/Picker/PickerTrigger.js +15 -0
- package/Picker/RangePickerTrigger.d.ts +64 -0
- package/Picker/RangePickerTrigger.js +19 -0
- package/Picker/index.d.ts +7 -0
- package/Picker/index.js +7 -0
- package/Picker/usePickerDocumentEventClose.d.ts +10 -0
- package/Picker/usePickerDocumentEventClose.js +27 -0
- package/Picker/usePickerInputValue.d.ts +12 -0
- package/Picker/usePickerInputValue.js +24 -0
- package/Picker/usePickerValue.d.ts +21 -0
- package/Picker/usePickerValue.js +58 -0
- package/Picker/useRangePickerValue.d.ts +21 -0
- package/Picker/useRangePickerValue.js +94 -0
- package/Picker/useTabKeyClose.d.ts +2 -0
- package/Picker/useTabKeyClose.js +12 -0
- package/Popconfirm/Popconfirm.d.ts +16 -0
- package/Popconfirm/Popconfirm.js +15 -0
- package/Popconfirm/index.d.ts +1 -0
- package/Popconfirm/index.js +1 -0
- package/Popover/Popover.d.ts +23 -0
- package/Popover/Popover.js +45 -0
- package/Popover/index.d.ts +1 -0
- package/Popover/index.js +1 -0
- package/Popper/Popper.d.ts +32 -0
- package/Popper/Popper.js +30 -0
- package/Popper/index.d.ts +1 -0
- package/Popper/index.js +1 -0
- package/Portal/Portal.d.ts +20 -0
- package/Portal/Portal.js +22 -0
- package/Portal/index.d.ts +1 -0
- package/Portal/index.js +1 -0
- package/Progress/Progress.d.ts +59 -0
- package/Progress/Progress.js +32 -0
- package/Progress/index.d.ts +2 -0
- package/Progress/index.js +1 -0
- package/README.md +1 -0
- package/Radio/Radio.d.ts +41 -0
- package/Radio/Radio.js +31 -0
- package/Radio/RadioGroup.d.ts +47 -0
- package/Radio/RadioGroup.js +29 -0
- package/Radio/RadioGroupContext.d.ts +9 -0
- package/Radio/RadioGroupContext.js +5 -0
- package/Radio/index.d.ts +3 -0
- package/Radio/index.js +2 -0
- package/Select/AutoComplete.d.ts +75 -0
- package/Select/AutoComplete.js +108 -0
- package/Select/Option.d.ts +19 -0
- package/Select/Option.js +32 -0
- package/Select/Select.d.ts +57 -0
- package/Select/Select.js +145 -0
- package/Select/SelectControlContext.d.ts +3 -0
- package/Select/SelectControlContext.js +5 -0
- package/Select/SelectTrigger.d.ts +54 -0
- package/Select/SelectTrigger.js +27 -0
- package/Select/TreeSelect.d.ts +68 -0
- package/Select/TreeSelect.js +198 -0
- package/Select/index.d.ts +8 -0
- package/Select/index.js +7 -0
- package/Select/typings.d.ts +11 -0
- package/Skeleton/Skeleton.d.ts +22 -0
- package/Skeleton/Skeleton.js +14 -0
- package/Skeleton/index.d.ts +1 -0
- package/Skeleton/index.js +1 -0
- package/Slider/Slider.d.ts +51 -0
- package/Slider/Slider.js +172 -0
- package/Slider/index.d.ts +3 -0
- package/Slider/index.js +2 -0
- package/Slider/useSlider.d.ts +31 -0
- package/Slider/useSlider.js +104 -0
- package/Stepper/Step.d.ts +41 -0
- package/Stepper/Step.js +19 -0
- package/Stepper/Stepper.d.ts +19 -0
- package/Stepper/Stepper.js +33 -0
- package/Stepper/index.d.ts +2 -0
- package/Stepper/index.js +2 -0
- package/Switch/Switch.d.ts +43 -0
- package/Switch/Switch.js +29 -0
- package/Switch/index.d.ts +2 -0
- package/Switch/index.js +1 -0
- package/Table/Table.d.ts +79 -0
- package/Table/Table.js +111 -0
- package/Table/TableBody.d.ts +10 -0
- package/Table/TableBody.js +31 -0
- package/Table/TableBodyRow.d.ts +11 -0
- package/Table/TableBodyRow.js +63 -0
- package/Table/TableCell.d.ts +20 -0
- package/Table/TableCell.js +23 -0
- package/Table/TableContext.d.ts +46 -0
- package/Table/TableContext.js +7 -0
- package/Table/TableHeader.d.ts +3 -0
- package/Table/TableHeader.js +47 -0
- package/Table/editable/TableEditRenderWrapper.d.ts +8 -0
- package/Table/editable/TableEditRenderWrapper.js +15 -0
- package/Table/expandable/TableExpandable.d.ts +24 -0
- package/Table/expandable/TableExpandable.js +15 -0
- package/Table/index.d.ts +4 -0
- package/Table/index.js +3 -0
- package/Table/pagination/TablePagination.d.ts +10 -0
- package/Table/pagination/TablePagination.js +27 -0
- package/Table/pagination/useTablePagination.d.ts +16 -0
- package/Table/pagination/useTablePagination.js +49 -0
- package/Table/refresh/TableRefresh.d.ts +10 -0
- package/Table/refresh/TableRefresh.js +23 -0
- package/Table/rowSelection/TableRowSelection.d.ts +19 -0
- package/Table/rowSelection/TableRowSelection.js +86 -0
- package/Table/rowSelection/useTableRowSelection.d.ts +6 -0
- package/Table/rowSelection/useTableRowSelection.js +53 -0
- package/Table/sorting/TableSortingIcon.d.ts +11 -0
- package/Table/sorting/TableSortingIcon.js +28 -0
- package/Table/sorting/useTableSorting.d.ts +10 -0
- package/Table/sorting/useTableSorting.js +90 -0
- package/Table/useTableFetchMore.d.ts +10 -0
- package/Table/useTableFetchMore.js +50 -0
- package/Table/useTableLoading.d.ts +5 -0
- package/Table/useTableLoading.js +19 -0
- package/Table/useTableScroll.d.ts +272 -0
- package/Table/useTableScroll.js +170 -0
- package/Tabs/Tab.d.ts +19 -0
- package/Tabs/Tab.js +16 -0
- package/Tabs/TabPane.d.ts +14 -0
- package/Tabs/TabPane.js +18 -0
- package/Tabs/Tabs.d.ts +39 -0
- package/Tabs/Tabs.js +49 -0
- package/Tabs/index.d.ts +3 -0
- package/Tabs/index.js +3 -0
- package/Tabs/useTabsOverflow.d.ts +8 -0
- package/Tabs/useTabsOverflow.js +58 -0
- package/Tag/Tag.d.ts +29 -0
- package/Tag/Tag.js +23 -0
- package/Tag/index.d.ts +2 -0
- package/Tag/index.js +1 -0
- package/TextField/TextField.d.ts +54 -0
- package/TextField/TextField.js +39 -0
- package/TextField/index.d.ts +2 -0
- package/TextField/index.js +1 -0
- package/TextField/useTextFieldControl.d.ts +10 -0
- package/TextField/useTextFieldControl.js +15 -0
- package/Textarea/Textarea.d.ts +58 -0
- package/Textarea/Textarea.js +33 -0
- package/Textarea/index.d.ts +2 -0
- package/Textarea/index.js +1 -0
- package/TimePanel/TimePanel.d.ts +66 -0
- package/TimePanel/TimePanel.js +67 -0
- package/TimePanel/TimePanelAction.d.ts +18 -0
- package/TimePanel/TimePanelAction.js +15 -0
- package/TimePanel/TimePanelColumn.d.ts +37 -0
- package/TimePanel/TimePanelColumn.js +39 -0
- package/TimePanel/index.d.ts +3 -0
- package/TimePanel/index.js +3 -0
- package/TimePicker/TimePicker.d.ts +24 -0
- package/TimePicker/TimePicker.js +114 -0
- package/TimePicker/TimePickerPanel.d.ts +24 -0
- package/TimePicker/TimePickerPanel.js +14 -0
- package/TimePicker/index.d.ts +2 -0
- package/TimePicker/index.js +2 -0
- package/Tooltip/Tooltip.d.ts +25 -0
- package/Tooltip/Tooltip.js +37 -0
- package/Tooltip/index.d.ts +1 -0
- package/Tooltip/index.js +1 -0
- package/Tooltip/useDelayMouseEnterLeave.d.ts +12 -0
- package/Tooltip/useDelayMouseEnterLeave.js +41 -0
- package/Transition/Collapse.d.ts +15 -0
- package/Transition/Collapse.js +107 -0
- package/Transition/Fade.d.ts +8 -0
- package/Transition/Fade.js +84 -0
- package/Transition/Grow.d.ts +13 -0
- package/Transition/Grow.js +112 -0
- package/Transition/SlideFade.d.ts +15 -0
- package/Transition/SlideFade.js +93 -0
- package/Transition/Transition.d.ts +98 -0
- package/Transition/Transition.js +27 -0
- package/Transition/Zoom.d.ts +8 -0
- package/Transition/Zoom.js +84 -0
- package/Transition/getAutoSizeDuration.d.ts +1 -0
- package/Transition/getAutoSizeDuration.js +10 -0
- package/Transition/getTransitionStyleProps.d.ts +16 -0
- package/Transition/getTransitionStyleProps.js +25 -0
- package/Transition/index.d.ts +6 -0
- package/Transition/index.js +6 -0
- package/Transition/reflow.d.ts +4 -0
- package/Transition/reflow.js +9 -0
- package/Transition/useAutoTransitionDuration.d.ts +6 -0
- package/Transition/useAutoTransitionDuration.js +15 -0
- package/Transition/useSetNodeTransition.d.ts +7 -0
- package/Transition/useSetNodeTransition.js +35 -0
- package/Tree/Tree.d.ts +70 -0
- package/Tree/Tree.js +131 -0
- package/Tree/TreeNode.d.ts +41 -0
- package/Tree/TreeNode.js +41 -0
- package/Tree/TreeNodeList.d.ts +25 -0
- package/Tree/TreeNodeList.js +29 -0
- package/Tree/getTreeNodeEntities.d.ts +11 -0
- package/Tree/getTreeNodeEntities.js +86 -0
- package/Tree/index.d.ts +8 -0
- package/Tree/index.js +7 -0
- package/Tree/toggleValue.d.ts +4 -0
- package/Tree/toggleValue.js +19 -0
- package/Tree/traverseTree.d.ts +2 -0
- package/Tree/traverseTree.js +11 -0
- package/Tree/typings.d.ts +16 -0
- package/Tree/useTreeExpandedValue.d.ts +15 -0
- package/Tree/useTreeExpandedValue.js +32 -0
- package/Typography/Typography.d.ts +43 -0
- package/Typography/Typography.js +38 -0
- package/Typography/index.d.ts +11 -0
- package/Typography/index.js +2 -0
- package/Upload/UploadButton.d.ts +10 -0
- package/Upload/UploadButton.js +23 -0
- package/Upload/UploadInput.d.ts +21 -0
- package/Upload/UploadInput.js +22 -0
- package/Upload/UploadResult.d.ts +16 -0
- package/Upload/UploadResult.js +30 -0
- package/Upload/index.d.ts +3 -0
- package/Upload/index.js +2 -0
- package/_internal/InputCheck/InputCheck.d.ts +33 -0
- package/_internal/InputCheck/InputCheck.js +19 -0
- package/_internal/InputCheck/InputCheckGroup.d.ts +18 -0
- package/_internal/InputCheck/InputCheckGroup.js +14 -0
- package/_internal/InputCheck/index.d.ts +3 -0
- package/_internal/InputCheck/index.js +2 -0
- package/_internal/InputTriggerPopper/InputTriggerPopper.d.ts +18 -0
- package/_internal/InputTriggerPopper/InputTriggerPopper.js +44 -0
- package/_internal/InputTriggerPopper/index.d.ts +1 -0
- package/_internal/InputTriggerPopper/index.js +1 -0
- package/hooks/useClickAway.d.ts +5 -0
- package/hooks/useClickAway.js +23 -0
- package/hooks/useComposeRefs.d.ts +2 -0
- package/hooks/useComposeRefs.js +8 -0
- package/hooks/useDocumentEscapeKeyDown.d.ts +3 -0
- package/hooks/useDocumentEscapeKeyDown.js +20 -0
- package/hooks/useDocumentEvents.d.ts +5 -0
- package/hooks/useDocumentEvents.js +21 -0
- package/hooks/useDocumentTabKeyDown.d.ts +3 -0
- package/hooks/useDocumentTabKeyDown.js +19 -0
- package/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
- package/hooks/useIsomorphicLayoutEffect.js +7 -0
- package/hooks/useLastCallback.d.ts +1 -0
- package/hooks/useLastCallback.js +11 -0
- package/hooks/useLastValue.d.ts +3 -0
- package/hooks/useLastValue.js +9 -0
- package/hooks/usePreviousValue.d.ts +1 -0
- package/hooks/usePreviousValue.js +11 -0
- package/hooks/useWindowWidth.d.ts +1 -0
- package/hooks/useWindowWidth.js +15 -0
- package/index.d.ts +100 -0
- package/index.js +148 -0
- package/package.json +61 -0
- package/utils/composeRefs.d.ts +21 -0
- package/utils/composeRefs.js +32 -0
- package/utils/cx.d.ts +1 -0
- package/utils/getElement.d.ts +3 -0
- package/utils/getElement.js +14 -0
- package/utils/jsx-types.d.ts +11 -0
- package/utils/rename-types.d.ts +5 -0
- package/utils/scroll-lock.d.ts +2 -0
- package/utils/scroll-lock.js +18 -0
package/Tree/Tree.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { TreeNodeValue, TreeSelectMethod } from '@mezzanine-ui/core/tree';
|
|
2
|
+
import { Ref } from 'react';
|
|
3
|
+
import { GetTreeNodeEntitiesProps } from './getTreeNodeEntities';
|
|
4
|
+
import { TreeNodeListElementProps, TreeNodeListProps } from './TreeNodeList';
|
|
5
|
+
import { TreeExpandControl, TreeNodeProp } from './typings';
|
|
6
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
7
|
+
export interface TreeProps extends Pick<TreeNodeListProps, 'multiple' | 'selectable' | 'size' | 'treeNodeProps' | 'treeNodeRefs' | 'onExpand'>, Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children' | 'defaultChecked' | 'defaultValue' | 'onChange' | 'onSelect'> {
|
|
8
|
+
/**
|
|
9
|
+
* Controls whether to expand all at first render.
|
|
10
|
+
*/
|
|
11
|
+
defaultExpandAll?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Provide if certain nodes should be disabled.
|
|
14
|
+
* Notice that there are two conditions for auto disabling.
|
|
15
|
+
* First, if the siblings are all disabled, the parent will be disabled as well.
|
|
16
|
+
* Second, if the parent is disabled, all its siblings will be disabled as well.
|
|
17
|
+
*/
|
|
18
|
+
disabledValues?: GetTreeNodeEntitiesProps['disabledValues'];
|
|
19
|
+
/**
|
|
20
|
+
* Provide if access to expand control is needed.
|
|
21
|
+
*/
|
|
22
|
+
expandControllerRef?: Ref<TreeExpandControl | null>;
|
|
23
|
+
/**
|
|
24
|
+
* By default expanded values of `Tree` is uncontrolled.
|
|
25
|
+
* However, you may specify `expandedValues` to gain full control.
|
|
26
|
+
* If that's the case, you should provide `onExpand` as well.
|
|
27
|
+
* Notices that if `expandedValues` is provided, `expandControllerRef` will not get the control methods.
|
|
28
|
+
*/
|
|
29
|
+
expandedValues?: TreeNodeValue[];
|
|
30
|
+
/**
|
|
31
|
+
* By default Tree only passes the leaf values to the select handler.
|
|
32
|
+
* If you want to include all the node values, set `includeNodeValue` to `true`.
|
|
33
|
+
*/
|
|
34
|
+
includeNodeValue?: GetTreeNodeEntitiesProps['includeNodeValue'];
|
|
35
|
+
/**
|
|
36
|
+
* The nodes to be rendered in `Tree`
|
|
37
|
+
*/
|
|
38
|
+
nodes: TreeNodeProp[];
|
|
39
|
+
/**
|
|
40
|
+
* By default expanded values of `Tree` is uncontrolled, where `onExpand` is not needed.
|
|
41
|
+
* However, you may specify `expandedValues` to gain full control
|
|
42
|
+
* and that's where you should provide `onExpand` together.
|
|
43
|
+
*/
|
|
44
|
+
onExpand?: TreeNodeListProps['onExpand'];
|
|
45
|
+
/**
|
|
46
|
+
* Select handler for `Tree`. Receives all the current selected values as its argument.
|
|
47
|
+
*/
|
|
48
|
+
onSelect?: (selectedValues: TreeNodeValue[]) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Controls the singular select logic.
|
|
51
|
+
* `Toggle` means the value will be toggled.
|
|
52
|
+
* `Target` means the target value will always be the result value and will not deselect if click again.
|
|
53
|
+
* @default 'toggle''
|
|
54
|
+
*/
|
|
55
|
+
selectMethod?: TreeSelectMethod;
|
|
56
|
+
/**
|
|
57
|
+
* Other `ul` props you may provide to `TreeNodeList` component.
|
|
58
|
+
* A common use-case is to override classes and styles.
|
|
59
|
+
*/
|
|
60
|
+
treeNodeListProps?: TreeNodeListElementProps;
|
|
61
|
+
/**
|
|
62
|
+
* The selected values are controlled values. Should be use with `selectable`.
|
|
63
|
+
*/
|
|
64
|
+
values?: TreeNodeValue | TreeNodeValue[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The react component for `mezzanine` tree.
|
|
68
|
+
*/
|
|
69
|
+
declare const Tree: import("react").ForwardRefExoticComponent<TreeProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
70
|
+
export default Tree;
|
package/Tree/Tree.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { treeClasses } from '@mezzanine-ui/core/tree';
|
|
3
|
+
import { forwardRef, useMemo, useImperativeHandle } from 'react';
|
|
4
|
+
import castArray from 'lodash/castArray';
|
|
5
|
+
import without from 'lodash/without';
|
|
6
|
+
import uniq from 'lodash/uniq';
|
|
7
|
+
import { getTreeNodeEntities } from './getTreeNodeEntities.js';
|
|
8
|
+
import { toggleValueWithStatusControl } from './toggleValue.js';
|
|
9
|
+
import { traverseTree } from './traverseTree.js';
|
|
10
|
+
import TreeNodeList from './TreeNodeList.js';
|
|
11
|
+
import { useTreeExpandedValue } from './useTreeExpandedValue.js';
|
|
12
|
+
import cx from 'clsx';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The react component for `mezzanine` tree.
|
|
16
|
+
*/
|
|
17
|
+
const Tree = forwardRef(function Tree(props, ref) {
|
|
18
|
+
const { className, defaultExpandAll, disabledValues, expandControllerRef, expandedValues: expandedValuesProp, includeNodeValue, multiple, nodes, onExpand: onExpandProp, onSelect: onSelectProp, selectMethod = 'toggle', selectable, size, treeNodeListProps, treeNodeProps, treeNodeRefs, values, ...restRootProp } = props;
|
|
19
|
+
const selectedValues = values ? castArray(values) : undefined;
|
|
20
|
+
const { expandedValues, onExpand, setExpandedValues, } = useTreeExpandedValue({
|
|
21
|
+
nodes,
|
|
22
|
+
defaultExpandAll,
|
|
23
|
+
expandedValues: expandedValuesProp,
|
|
24
|
+
onExpand: onExpandProp,
|
|
25
|
+
});
|
|
26
|
+
const treeEntities = useMemo(() => getTreeNodeEntities({
|
|
27
|
+
disabledValues,
|
|
28
|
+
expandedValues,
|
|
29
|
+
includeNodeValue,
|
|
30
|
+
multiple,
|
|
31
|
+
nodes,
|
|
32
|
+
selectedValues,
|
|
33
|
+
}), [
|
|
34
|
+
disabledValues,
|
|
35
|
+
expandedValues,
|
|
36
|
+
includeNodeValue,
|
|
37
|
+
multiple,
|
|
38
|
+
nodes,
|
|
39
|
+
selectedValues,
|
|
40
|
+
]);
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
42
|
+
const displayNodes = nodes.map((node) => treeEntities.get(node.value).node);
|
|
43
|
+
const getAllExpandSiblingValues = (value) => {
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
|
+
const currentEntity = treeEntities.get(value);
|
|
46
|
+
const allSiblingEntities = currentEntity.siblings;
|
|
47
|
+
const allSiblingNodes = allSiblingEntities === null || allSiblingEntities === void 0 ? void 0 : allSiblingEntities.map(({ node }) => node);
|
|
48
|
+
const allNodeValues = [];
|
|
49
|
+
if (allSiblingNodes === null || allSiblingNodes === void 0 ? void 0 : allSiblingNodes.length) {
|
|
50
|
+
allNodeValues.push(currentEntity.node.value);
|
|
51
|
+
traverseTree(allSiblingNodes, (node) => {
|
|
52
|
+
var _a;
|
|
53
|
+
if ((_a = node.nodes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
54
|
+
allNodeValues.push(node.value);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return allNodeValues;
|
|
59
|
+
};
|
|
60
|
+
const collapse = (value) => {
|
|
61
|
+
setExpandedValues(expandedValues.filter((v) => v !== value));
|
|
62
|
+
};
|
|
63
|
+
const collapseAll = () => {
|
|
64
|
+
const allNodeValues = nodes.reduce((acc, currentNode) => [...acc, ...getAllExpandSiblingValues(currentNode.value)], []);
|
|
65
|
+
const uniqAllNodeValues = uniq(allNodeValues);
|
|
66
|
+
const newExpandedValues = without(expandedValues, ...uniqAllNodeValues);
|
|
67
|
+
setExpandedValues(newExpandedValues);
|
|
68
|
+
};
|
|
69
|
+
const collapseAllFrom = (value) => {
|
|
70
|
+
const allNodeValues = getAllExpandSiblingValues(value);
|
|
71
|
+
const newExpandedValues = without(expandedValues, ...allNodeValues);
|
|
72
|
+
setExpandedValues(newExpandedValues);
|
|
73
|
+
};
|
|
74
|
+
const expand = (value) => {
|
|
75
|
+
setExpandedValues(uniq([...expandedValues, value]));
|
|
76
|
+
};
|
|
77
|
+
const expandAll = () => {
|
|
78
|
+
const allNodeValues = nodes.reduce((acc, currentNode) => [...acc, ...getAllExpandSiblingValues(currentNode.value)], []);
|
|
79
|
+
const newExpandedValues = uniq([...expandedValues, ...allNodeValues]);
|
|
80
|
+
setExpandedValues(newExpandedValues);
|
|
81
|
+
};
|
|
82
|
+
const expandAllFrom = (value) => {
|
|
83
|
+
const allNodeValues = getAllExpandSiblingValues(value);
|
|
84
|
+
const newExpandedValues = uniq([...expandedValues, ...allNodeValues]);
|
|
85
|
+
setExpandedValues(newExpandedValues);
|
|
86
|
+
};
|
|
87
|
+
useImperativeHandle(expandControllerRef, () => {
|
|
88
|
+
if (expandedValuesProp) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
collapse,
|
|
93
|
+
collapseAll,
|
|
94
|
+
collapseAllFrom,
|
|
95
|
+
expand,
|
|
96
|
+
expandAll,
|
|
97
|
+
expandAllFrom,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
const onMultipleSelect = onSelectProp
|
|
101
|
+
? (value) => {
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
103
|
+
const targetEntity = treeEntities.get(value);
|
|
104
|
+
const { selected } = targetEntity.node;
|
|
105
|
+
const newCheckedValues = toggleValueWithStatusControl(!!selected, targetEntity.values, selectedValues || []);
|
|
106
|
+
onSelectProp(newCheckedValues);
|
|
107
|
+
}
|
|
108
|
+
: undefined;
|
|
109
|
+
const onSingleSelect = onSelectProp
|
|
110
|
+
? (value) => {
|
|
111
|
+
var _a;
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
113
|
+
const targetEntity = treeEntities.get(value);
|
|
114
|
+
const { selected } = targetEntity.node;
|
|
115
|
+
if (!((_a = targetEntity.siblings) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
116
|
+
if (selectMethod === 'target') {
|
|
117
|
+
onSelectProp([value]);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const newCheckedValues = toggleValueWithStatusControl(!!selected, targetEntity.values, []);
|
|
121
|
+
onSelectProp(newCheckedValues);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
: undefined;
|
|
126
|
+
const selectHandler = multiple ? onMultipleSelect : onSingleSelect;
|
|
127
|
+
const onSelect = selectable ? selectHandler : undefined;
|
|
128
|
+
return (jsx("div", Object.assign({ ref: ref, className: cx(treeClasses.host, className) }, restRootProp, { children: jsx(TreeNodeList, Object.assign({}, treeNodeListProps, { multiple: multiple, nodes: displayNodes, onExpand: onExpand, onSelect: onSelect, selectable: selectable, size: size, treeNodeProps: treeNodeProps, treeNodeRefs: treeNodeRefs }), void 0) }), void 0));
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
export default Tree;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TreeNodeValue, TreeSize } from '@mezzanine-ui/core/tree';
|
|
3
|
+
import { CollapseProps } from '../Transition';
|
|
4
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
5
|
+
import { TreeNodeData } from './typings';
|
|
6
|
+
export declare type TreeNodeElementProps = Omit<NativeElementPropsWithoutKeyAndRef<'li'>, 'children' | 'value' | 'onSelect'>;
|
|
7
|
+
export interface TreeNodeProps extends TreeNodeData, TreeNodeElementProps {
|
|
8
|
+
/**
|
|
9
|
+
* Provided children will be wrapped under `Collapse`.
|
|
10
|
+
*/
|
|
11
|
+
children?: CollapseProps['children'];
|
|
12
|
+
/**
|
|
13
|
+
* The list item will be rendered as `Checkbox` if multiple set to true.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
multiple?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Handler for caret icon click event. Receive current node value as its argument.
|
|
19
|
+
*/
|
|
20
|
+
onExpand?: (value: TreeNodeValue) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Handler for label element click event. Receive current node value as its argument.
|
|
23
|
+
* Must use with selectable setting to `true`.
|
|
24
|
+
*/
|
|
25
|
+
onSelect?: (value: TreeNodeValue) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Controls whether to be selectable.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
selectable?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Sizes for the layout.
|
|
33
|
+
* @default 'medium'
|
|
34
|
+
*/
|
|
35
|
+
size?: TreeSize;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The react component for `mezzanine` tree node.
|
|
39
|
+
*/
|
|
40
|
+
declare const TreeNode: import("react").ForwardRefExoticComponent<TreeNodeProps & import("react").RefAttributes<HTMLLIElement>>;
|
|
41
|
+
export default TreeNode;
|
package/Tree/TreeNode.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { treeClasses } from '@mezzanine-ui/core/tree';
|
|
3
|
+
import { CaretRightIcon } from '@mezzanine-ui/icons';
|
|
4
|
+
import { forwardRef, useMemo } from 'react';
|
|
5
|
+
import Typography from '../Typography/Typography.js';
|
|
6
|
+
import Icon from '../Icon/Icon.js';
|
|
7
|
+
import Checkbox from '../Checkbox/Checkbox.js';
|
|
8
|
+
import Collapse from '../Transition/Collapse.js';
|
|
9
|
+
import cx from 'clsx';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The react component for `mezzanine` tree node.
|
|
13
|
+
*/
|
|
14
|
+
const TreeNode = forwardRef(function TreeNode(props, ref) {
|
|
15
|
+
const { children, className, disabled, expanded, indeterminate, label, multiple = false, onExpand: onExpandProp, onSelect: onSelectProp, selectable = false, selected, size = 'medium', value, ...restRootProps } = props;
|
|
16
|
+
const variant = useMemo(() => {
|
|
17
|
+
if (size === 'small') {
|
|
18
|
+
return 'input3';
|
|
19
|
+
}
|
|
20
|
+
if (size === 'large') {
|
|
21
|
+
return 'input1';
|
|
22
|
+
}
|
|
23
|
+
return 'input2';
|
|
24
|
+
}, [size]);
|
|
25
|
+
const onExpand = onExpandProp ? () => { onExpandProp(value); } : undefined;
|
|
26
|
+
const onSelect = selectable && onSelectProp && !disabled ? () => { onSelectProp(value); } : undefined;
|
|
27
|
+
return (jsxs("li", Object.assign({ ref: ref }, restRootProps, { className: cx(treeClasses.node, treeClasses.nodeSize(size), className) }, { children: [jsxs("div", Object.assign({ className: treeClasses.nodeStem }, { children: [children ? (jsx(Icon, { icon: CaretRightIcon, className: cx(treeClasses.nodeCaret, {
|
|
28
|
+
[treeClasses.nodeCaretExpanded]: expanded,
|
|
29
|
+
}), role: "button", onClick: onExpand }, void 0)) : (jsx("div", {}, void 0)),
|
|
30
|
+
multiple
|
|
31
|
+
? (jsx(Checkbox, Object.assign({ checked: !!selected, disabled: disabled, indeterminate: indeterminate, onChange: onSelect, size: size, value: `${value}` }, { children: label }), void 0))
|
|
32
|
+
: (jsx(Typography, Object.assign({ component: "span", variant: variant, onClick: onSelect, className: cx(treeClasses.nodeLabel, {
|
|
33
|
+
[treeClasses.nodeLabelSelectable]: !children && selectable,
|
|
34
|
+
[treeClasses.nodeLabelIndeterminate]: indeterminate,
|
|
35
|
+
[treeClasses.nodeLabelActive]: selected,
|
|
36
|
+
[treeClasses.nodeLabelDisabled]: disabled,
|
|
37
|
+
}) }, { children: label }), void 0))] }), void 0),
|
|
38
|
+
children && (jsx(Collapse, Object.assign({ in: expanded, appear: false }, { children: children }), void 0))] }), void 0));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export default TreeNode;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
import { TreeNodeElementProps, TreeNodeProps } from './TreeNode';
|
|
4
|
+
import { TreeNodeData, TreeNodeRefs } from './typings';
|
|
5
|
+
export declare type TreeNodeListElementProps = Omit<NativeElementPropsWithoutKeyAndRef<'ul'>, 'children' | 'onSelect'>;
|
|
6
|
+
export interface TreeNodeListProps extends TreeNodeListElementProps, Pick<TreeNodeProps, 'multiple' | 'onExpand' | 'onSelect' | 'selectable' | 'size'> {
|
|
7
|
+
/**
|
|
8
|
+
* Given nodes will be passed to `TreeNode` component orderly.
|
|
9
|
+
*/
|
|
10
|
+
nodes?: TreeNodeData['nodes'];
|
|
11
|
+
/**
|
|
12
|
+
* Other props you may provide to `TreeNode` component. A common use-case is to override classes and styles.
|
|
13
|
+
*/
|
|
14
|
+
treeNodeProps?: TreeNodeElementProps;
|
|
15
|
+
/**
|
|
16
|
+
* Provide if you want to access every list element. Paired with node key and the element.
|
|
17
|
+
* Usage example: `const treeNodeRefs = useRef<TreeNodeRefsShape | undefined>(undefined)`
|
|
18
|
+
*/
|
|
19
|
+
treeNodeRefs?: TreeNodeRefs;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The react component for `mezzanine` tree node list.
|
|
23
|
+
*/
|
|
24
|
+
declare const TreeNodeList: import("react").ForwardRefExoticComponent<TreeNodeListProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
25
|
+
export default TreeNodeList;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { treeClasses } from '@mezzanine-ui/core/tree';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import TreeNode from './TreeNode.js';
|
|
5
|
+
import cx from 'clsx';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The react component for `mezzanine` tree node list.
|
|
9
|
+
*/
|
|
10
|
+
const TreeNodeList = forwardRef((props, ref) => {
|
|
11
|
+
const { className, multiple, nodes, onExpand, onSelect, selectable, size = 'medium', treeNodeProps, treeNodeRefs, ...restRootProp } = props;
|
|
12
|
+
const getNodeRefHandler = treeNodeRefs
|
|
13
|
+
? (value) => (node) => {
|
|
14
|
+
treeNodeRefs.current = {
|
|
15
|
+
...treeNodeRefs.current,
|
|
16
|
+
[value]: node,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
: undefined;
|
|
20
|
+
if (!(nodes === null || nodes === void 0 ? void 0 : nodes.length))
|
|
21
|
+
return null;
|
|
22
|
+
return (jsx("ul", Object.assign({}, restRootProp, { ref: ref, className: cx(treeClasses.nodeList, treeClasses.nodeListSize(size), className) }, { children: nodes.map((node) => {
|
|
23
|
+
const { value, nodes: siblingNodes, ...restNodeProps } = node;
|
|
24
|
+
return (jsx(TreeNode, Object.assign({ ref: getNodeRefHandler === null || getNodeRefHandler === void 0 ? void 0 : getNodeRefHandler(value) }, treeNodeProps, { multiple: multiple, onExpand: onExpand, onSelect: onSelect, selectable: selectable, size: size, value: value }, restNodeProps, { children: (siblingNodes === null || siblingNodes === void 0 ? void 0 : siblingNodes.length) ? (jsx(TreeNodeList, Object.assign({}, restRootProp, { className: className, multiple: multiple, nodes: siblingNodes, onExpand: onExpand, onSelect: onSelect, selectable: selectable, size: size, treeNodeRefs: treeNodeRefs }), void 0))
|
|
25
|
+
: undefined }), value));
|
|
26
|
+
}) }), void 0));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default TreeNodeList;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TreeNodeValue } from '@mezzanine-ui/core/tree';
|
|
2
|
+
import { TreeNodeData, TreeNodeEntities } from './typings';
|
|
3
|
+
export interface GetTreeNodeEntitiesProps {
|
|
4
|
+
disabledValues?: TreeNodeValue[];
|
|
5
|
+
expandedValues?: TreeNodeValue[];
|
|
6
|
+
includeNodeValue?: boolean;
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
nodes: TreeNodeData[];
|
|
9
|
+
selectedValues?: TreeNodeValue[];
|
|
10
|
+
}
|
|
11
|
+
export declare function getTreeNodeEntities({ disabledValues, expandedValues, includeNodeValue, multiple, nodes, selectedValues, }: GetTreeNodeEntitiesProps): TreeNodeEntities;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import xor from 'lodash/xor';
|
|
2
|
+
|
|
3
|
+
function getTreeNodeEntities({ disabledValues, expandedValues, includeNodeValue = false, multiple, nodes, selectedValues, }) {
|
|
4
|
+
const entities = new Map();
|
|
5
|
+
const selectedValueMap = (selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.length) ? new Map(selectedValues.map((val) => [val, true]))
|
|
6
|
+
: undefined;
|
|
7
|
+
const expandedValueMap = (expandedValues === null || expandedValues === void 0 ? void 0 : expandedValues.length) ? new Map(expandedValues.map((val) => [val, true]))
|
|
8
|
+
: undefined;
|
|
9
|
+
const disabledValueMap = (disabledValues === null || disabledValues === void 0 ? void 0 : disabledValues.length) ? new Map(disabledValues.map((val) => [val, true]))
|
|
10
|
+
: undefined;
|
|
11
|
+
function getTreeEntity(node, parentDisabled) {
|
|
12
|
+
const { nodes: currentSiblings, value, } = node;
|
|
13
|
+
const selected = selectedValueMap === null || selectedValueMap === void 0 ? void 0 : selectedValueMap.get(value);
|
|
14
|
+
const expanded = expandedValueMap === null || expandedValueMap === void 0 ? void 0 : expandedValueMap.get(value);
|
|
15
|
+
const disabled = disabledValueMap === null || disabledValueMap === void 0 ? void 0 : disabledValueMap.get(value);
|
|
16
|
+
const entity = {
|
|
17
|
+
node: {
|
|
18
|
+
...node,
|
|
19
|
+
disabled: parentDisabled || disabled,
|
|
20
|
+
expanded,
|
|
21
|
+
selected,
|
|
22
|
+
},
|
|
23
|
+
values: [],
|
|
24
|
+
};
|
|
25
|
+
if (!(currentSiblings === null || currentSiblings === void 0 ? void 0 : currentSiblings.length)) {
|
|
26
|
+
entities.set(entity.node.value, entity);
|
|
27
|
+
entity.values.push(value);
|
|
28
|
+
return entity;
|
|
29
|
+
}
|
|
30
|
+
const { anyIndeterminate, directSiblings, disabledValues: siblingDisabledValues, selectedValues: siblingSelectedValues, siblingNodes, siblings: siblingEntities, values: siblingValues, } = currentSiblings.reduce((acc, sibling) => {
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
|
+
const siblingEntity = getTreeEntity(sibling, parentDisabled || disabled);
|
|
33
|
+
const currentAnyIndeterminate = (siblingEntity.node.indeterminate ||
|
|
34
|
+
acc.anyIndeterminate);
|
|
35
|
+
return {
|
|
36
|
+
anyIndeterminate: currentAnyIndeterminate,
|
|
37
|
+
directSiblings: [...acc.directSiblings, siblingEntity.node.value],
|
|
38
|
+
disabledValues: siblingEntity.node.disabled
|
|
39
|
+
? [...acc.disabledValues, siblingEntity.node.value]
|
|
40
|
+
: acc.disabledValues,
|
|
41
|
+
selectedValues: siblingEntity.node.selected
|
|
42
|
+
? [...acc.selectedValues, siblingEntity.node.value]
|
|
43
|
+
: acc.selectedValues,
|
|
44
|
+
siblingNodes: [...acc.siblingNodes, siblingEntity.node],
|
|
45
|
+
siblings: [...acc.siblings, siblingEntity],
|
|
46
|
+
values: [...acc.values, ...siblingEntity.values],
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
anyIndeterminate: false,
|
|
50
|
+
directSiblings: [],
|
|
51
|
+
disabledValues: [],
|
|
52
|
+
selectedValues: [],
|
|
53
|
+
siblingNodes: [],
|
|
54
|
+
siblings: [],
|
|
55
|
+
values: [],
|
|
56
|
+
});
|
|
57
|
+
entity.node.nodes = siblingNodes;
|
|
58
|
+
entity.siblings = siblingEntities;
|
|
59
|
+
entity.values.push(...siblingValues);
|
|
60
|
+
if (includeNodeValue) {
|
|
61
|
+
entity.values.push(value);
|
|
62
|
+
}
|
|
63
|
+
const shouldDisabled = siblingDisabledValues.length && !xor(siblingDisabledValues, directSiblings).length;
|
|
64
|
+
if (!disabled && shouldDisabled) {
|
|
65
|
+
entity.node.disabled = true;
|
|
66
|
+
}
|
|
67
|
+
if ((anyIndeterminate && !disabled && !shouldDisabled) ||
|
|
68
|
+
(!multiple && siblingSelectedValues.length)) {
|
|
69
|
+
entity.node.selected = false;
|
|
70
|
+
entity.node.indeterminate = true;
|
|
71
|
+
entities.set(entity.node.value, entity);
|
|
72
|
+
return entity;
|
|
73
|
+
}
|
|
74
|
+
const allDirectSiblingChecked = !!(siblingSelectedValues.length && !xor(siblingSelectedValues, directSiblings).length);
|
|
75
|
+
entity.node.selected = allDirectSiblingChecked;
|
|
76
|
+
entity.node.indeterminate = allDirectSiblingChecked ? false : !!siblingSelectedValues.length;
|
|
77
|
+
entities.set(entity.node.value, entity);
|
|
78
|
+
return entity;
|
|
79
|
+
}
|
|
80
|
+
nodes.forEach((node) => {
|
|
81
|
+
getTreeEntity(node, disabledValueMap === null || disabledValueMap === void 0 ? void 0 : disabledValueMap.get(node.value));
|
|
82
|
+
});
|
|
83
|
+
return entities;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { getTreeNodeEntities };
|
package/Tree/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './typings';
|
|
2
|
+
export { uniqueArray, toggleValue, toggleValueWithStatusControl, } from './toggleValue';
|
|
3
|
+
export { traverseTree, } from './traverseTree';
|
|
4
|
+
export { UseTreeExpandedValueProps, useTreeExpandedValue, } from './useTreeExpandedValue';
|
|
5
|
+
export { GetTreeNodeEntitiesProps, getTreeNodeEntities, } from './getTreeNodeEntities';
|
|
6
|
+
export { TreeNodeElementProps, TreeNodeProps, default as TreeNode, } from './TreeNode';
|
|
7
|
+
export { TreeNodeListElementProps, TreeNodeListProps, default as TreeNodeList, } from './TreeNodeList';
|
|
8
|
+
export { TreeProps, default, } from './Tree';
|
package/Tree/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { toggleValue, toggleValueWithStatusControl, uniqueArray } from './toggleValue.js';
|
|
2
|
+
export { traverseTree } from './traverseTree.js';
|
|
3
|
+
export { useTreeExpandedValue } from './useTreeExpandedValue.js';
|
|
4
|
+
export { getTreeNodeEntities } from './getTreeNodeEntities.js';
|
|
5
|
+
export { default as TreeNode } from './TreeNode.js';
|
|
6
|
+
export { default as TreeNodeList } from './TreeNodeList.js';
|
|
7
|
+
export { default } from './Tree.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TreeNodeValue } from '@mezzanine-ui/core/tree';
|
|
2
|
+
export declare function uniqueArray<T>(items: T[]): T[];
|
|
3
|
+
export declare function toggleValue(value: TreeNodeValue | TreeNodeValue[], pool: TreeNodeValue[]): TreeNodeValue[];
|
|
4
|
+
export declare function toggleValueWithStatusControl(existed: boolean, value: TreeNodeValue | TreeNodeValue[], pool: TreeNodeValue[]): TreeNodeValue[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import castArray from 'lodash/castArray';
|
|
2
|
+
import xor from 'lodash/xor';
|
|
3
|
+
|
|
4
|
+
function uniqueArray(items) {
|
|
5
|
+
return Array.from(new Set(items));
|
|
6
|
+
}
|
|
7
|
+
function toggleValue(value, pool) {
|
|
8
|
+
const castedValue = castArray(value);
|
|
9
|
+
return xor(castedValue, pool);
|
|
10
|
+
}
|
|
11
|
+
function toggleValueWithStatusControl(existed, value, pool) {
|
|
12
|
+
const castedValue = castArray(value);
|
|
13
|
+
if (!existed) {
|
|
14
|
+
return uniqueArray([...pool, ...castedValue]);
|
|
15
|
+
}
|
|
16
|
+
return pool.filter((val) => !castedValue.includes(val));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { toggleValue, toggleValueWithStatusControl, uniqueArray };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MutableRefObject, ReactNode } from 'react';
|
|
2
|
+
import { TreeNodeDataShape, TreeNodeEntityShape, TreeNodePropShape, TreeNodeValue } from '@mezzanine-ui/core/tree';
|
|
3
|
+
export declare type TreeNodeProp = TreeNodePropShape<ReactNode>;
|
|
4
|
+
export declare type TreeNodeData = TreeNodeDataShape<ReactNode>;
|
|
5
|
+
export declare type TreeNodeEntity = TreeNodeEntityShape<ReactNode>;
|
|
6
|
+
export declare type TreeNodeEntities = Map<TreeNodeValue, TreeNodeEntity>;
|
|
7
|
+
export declare type TreeNodeRefsShape = Record<TreeNodeValue, HTMLLIElement>;
|
|
8
|
+
export declare type TreeNodeRefs = MutableRefObject<TreeNodeRefsShape | undefined>;
|
|
9
|
+
export declare type TreeExpandControl = {
|
|
10
|
+
collapse: (value: TreeNodeValue) => void;
|
|
11
|
+
collapseAll: () => void;
|
|
12
|
+
collapseAllFrom: (value: TreeNodeValue) => void;
|
|
13
|
+
expand: (value: TreeNodeValue) => void;
|
|
14
|
+
expandAll: () => void;
|
|
15
|
+
expandAllFrom: (value: TreeNodeValue) => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TreeNodeValue } from '@mezzanine-ui/core/tree';
|
|
3
|
+
import { TreeNodeListProps } from './TreeNodeList';
|
|
4
|
+
import { TreeNodeProp } from './typings';
|
|
5
|
+
export interface UseTreeExpandedValueProps {
|
|
6
|
+
defaultExpandAll?: boolean;
|
|
7
|
+
expandedValues?: TreeNodeValue[];
|
|
8
|
+
nodes: TreeNodeProp[];
|
|
9
|
+
onExpand?: TreeNodeListProps['onExpand'];
|
|
10
|
+
}
|
|
11
|
+
export declare function useTreeExpandedValue(props: UseTreeExpandedValueProps): {
|
|
12
|
+
expandedValues: TreeNodeValue[];
|
|
13
|
+
onExpand: (value: TreeNodeValue) => void;
|
|
14
|
+
setExpandedValues: import("react").Dispatch<import("react").SetStateAction<TreeNodeValue[]>>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { toggleValue } from './toggleValue.js';
|
|
3
|
+
import { traverseTree } from './traverseTree.js';
|
|
4
|
+
|
|
5
|
+
function useTreeExpandedValue(props) {
|
|
6
|
+
const { defaultExpandAll, expandedValues: expandedValuesProp, nodes, onExpand: onExpandProp, } = props;
|
|
7
|
+
const [expandedValues, setExpandedValues] = useState(() => {
|
|
8
|
+
if (expandedValuesProp) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const currentExpandedValues = [];
|
|
12
|
+
if (defaultExpandAll) {
|
|
13
|
+
traverseTree(nodes, (node) => {
|
|
14
|
+
if (node.nodes) {
|
|
15
|
+
currentExpandedValues.push(node.value);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return currentExpandedValues;
|
|
20
|
+
});
|
|
21
|
+
const onExpand = (value) => {
|
|
22
|
+
const newExpandedValues = toggleValue(value, expandedValues);
|
|
23
|
+
setExpandedValues(newExpandedValues);
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
expandedValues: expandedValuesProp || expandedValues,
|
|
27
|
+
onExpand: (expandedValuesProp && onExpandProp) ? onExpandProp : onExpand,
|
|
28
|
+
setExpandedValues,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { useTreeExpandedValue };
|