@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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SelectInputSize } from '@mezzanine-ui/core/select';
|
|
3
|
+
import { FormElementFocusHandlers } from '../Form';
|
|
4
|
+
import { MenuProps } from '../Menu';
|
|
5
|
+
import { PickRenameMulti } from '../utils/rename-types';
|
|
6
|
+
import { InputTriggerPopperProps } from '../_internal/InputTriggerPopper';
|
|
7
|
+
import { SelectTriggerProps, SelectTriggerInputProps } from './SelectTrigger';
|
|
8
|
+
import { SelectValue, TreeSelectOption } from './typings';
|
|
9
|
+
import { TreeProps } from '../Tree';
|
|
10
|
+
export interface TreeSelectProps extends Omit<SelectTriggerProps, 'active' | 'onBlur' | 'onChange' | 'onClear' | 'onClick' | 'onFocus' | 'onKeyDown' | 'readOnly' | 'searchInputProps'>, FormElementFocusHandlers, Pick<TreeProps, 'defaultExpandAll' | 'disabledValues' | 'expandControllerRef'>, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
|
|
11
|
+
maxHeight: 'menuMaxHeight';
|
|
12
|
+
role: 'menuRole';
|
|
13
|
+
size: 'menuSize';
|
|
14
|
+
}>, PickRenameMulti<Pick<InputTriggerPopperProps, 'options'>, {
|
|
15
|
+
options: 'popperOptions';
|
|
16
|
+
}> {
|
|
17
|
+
/**
|
|
18
|
+
* The width of options panel will be calculated based on the depth of your options.
|
|
19
|
+
* If you know how many layers in your object, pass it via this prop will have better performance.
|
|
20
|
+
*/
|
|
21
|
+
depth?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The other native props for input element.
|
|
24
|
+
*/
|
|
25
|
+
inputProps?: Omit<SelectTriggerInputProps, 'onBlur' | 'onChange' | 'onFocus' | 'placeholder' | 'role' | 'value' | `aria-${'expanded'}`>;
|
|
26
|
+
/**
|
|
27
|
+
* Other props you may provide to `Menu`.
|
|
28
|
+
*/
|
|
29
|
+
menuProps?: Omit<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>;
|
|
30
|
+
/**
|
|
31
|
+
* The change event handler of input element.
|
|
32
|
+
*/
|
|
33
|
+
onChange?(newOptions: SelectValue[]): any;
|
|
34
|
+
/**
|
|
35
|
+
* The nested options for `TreeSelect`
|
|
36
|
+
*/
|
|
37
|
+
options: TreeSelectOption[];
|
|
38
|
+
/**
|
|
39
|
+
* select input placeholder
|
|
40
|
+
*/
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the selection is required.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
required?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* If true, the panel will have its min-width be same as the trigger width.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
sameWidth?: InputTriggerPopperProps['sameWidth'];
|
|
52
|
+
/**
|
|
53
|
+
* The size of input.
|
|
54
|
+
* @default 'medium'
|
|
55
|
+
*/
|
|
56
|
+
size?: SelectInputSize;
|
|
57
|
+
/**
|
|
58
|
+
* Other props you may provide to `Tree`
|
|
59
|
+
*/
|
|
60
|
+
treeProps?: Omit<TreeProps, 'defaultExpandAll' | 'disabledValues' | 'expandControllerRef' | 'expandedValues' | 'nodes' | 'onExpand' | 'onSelect' | 'selectMethod' | 'selectable' | 'values'>;
|
|
61
|
+
/**
|
|
62
|
+
* The value of selection.
|
|
63
|
+
* @default undefined
|
|
64
|
+
*/
|
|
65
|
+
value?: SelectValue[];
|
|
66
|
+
}
|
|
67
|
+
declare const TreeSelect: import("react").ForwardRefExoticComponent<TreeSelectProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
68
|
+
export default TreeSelect;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useContext, useMemo, useRef, useLayoutEffect, useState } from 'react';
|
|
3
|
+
import { selectClasses } from '@mezzanine-ui/core/select';
|
|
4
|
+
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
5
|
+
import { useClickAway } from '../hooks/useClickAway.js';
|
|
6
|
+
import SelectTrigger from './SelectTrigger.js';
|
|
7
|
+
import { FormControlContext } from '../Form/FormControlContext.js';
|
|
8
|
+
import { traverseTree } from '../Tree/traverseTree.js';
|
|
9
|
+
import InputTriggerPopper from '../_internal/InputTriggerPopper/InputTriggerPopper.js';
|
|
10
|
+
import Menu from '../Menu/Menu.js';
|
|
11
|
+
import Tree from '../Tree/Tree.js';
|
|
12
|
+
import { toggleValue } from '../Tree/toggleValue.js';
|
|
13
|
+
import cx from 'clsx';
|
|
14
|
+
|
|
15
|
+
const TreeSelect = forwardRef((props, ref) => {
|
|
16
|
+
const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
|
|
17
|
+
const { className, clearable = false, defaultExpandAll, depth, disabled = disabledFromFormControl || false, disabledValues, error = severity === 'error' || false, expandControllerRef, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuProps, menuRole = 'listbox', menuSize = 'medium', mode = 'single', onBlur, onChange: onChangeProp, onFocus, options, placeholder = '', popperOptions, prefix, renderValue, required = requiredFromFormControl || false, sameWidth = false, size = 'medium', suffixActionIcon, treeProps, value: valueProp, } = props;
|
|
18
|
+
const { className: treeClassName, ...restTreeProps } = treeProps || {};
|
|
19
|
+
const { width, border, ...restStyle } = (menuProps === null || menuProps === void 0 ? void 0 : menuProps.style) || {};
|
|
20
|
+
const multiple = mode === 'multiple';
|
|
21
|
+
/** Compute panel width */
|
|
22
|
+
const panelWidth = useMemo(() => {
|
|
23
|
+
if (width) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const base = multiple ? 224 : 208;
|
|
27
|
+
const indent = 16;
|
|
28
|
+
function getWidth(resultDepth) {
|
|
29
|
+
return (resultDepth - 1) * indent + base;
|
|
30
|
+
}
|
|
31
|
+
if (depth) {
|
|
32
|
+
return getWidth(depth);
|
|
33
|
+
}
|
|
34
|
+
function maxDepth(object, counter = 1) {
|
|
35
|
+
if (object.siblings) {
|
|
36
|
+
return Math.max(...object.siblings.map((sibling) => maxDepth(sibling, counter + 1)));
|
|
37
|
+
}
|
|
38
|
+
return counter;
|
|
39
|
+
}
|
|
40
|
+
const computedMaxDepth = options.reduce((acc, current) => {
|
|
41
|
+
const currentDepth = maxDepth(current);
|
|
42
|
+
return currentDepth > acc ? currentDepth : acc;
|
|
43
|
+
}, 0);
|
|
44
|
+
return getWidth(computedMaxDepth);
|
|
45
|
+
}, [depth, multiple, options, width]);
|
|
46
|
+
/** Popper positioning */
|
|
47
|
+
const nodeRef = useRef(null);
|
|
48
|
+
const controlRef = useRef(null);
|
|
49
|
+
const popperRef = useRef(null);
|
|
50
|
+
const composedRef = useComposeRefs([ref, controlRef]);
|
|
51
|
+
/** Make popper positioning dynamically by computing styles every time value prop changes */
|
|
52
|
+
const controllerRef = useRef(null);
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
(_b = (_a = controllerRef.current) === null || _a === void 0 ? void 0 : _a.forceUpdate) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
56
|
+
}, [valueProp]);
|
|
57
|
+
/** Open control */
|
|
58
|
+
const [open, toggleOpen] = useState(false);
|
|
59
|
+
const onOpen = () => {
|
|
60
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
61
|
+
toggleOpen(true);
|
|
62
|
+
};
|
|
63
|
+
const onClose = () => {
|
|
64
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
65
|
+
toggleOpen(false);
|
|
66
|
+
};
|
|
67
|
+
const onToggleOpen = () => {
|
|
68
|
+
if (open) {
|
|
69
|
+
onClose();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
onOpen();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const onTextFieldClick = disabled
|
|
76
|
+
? undefined
|
|
77
|
+
: () => {
|
|
78
|
+
onToggleOpen();
|
|
79
|
+
};
|
|
80
|
+
const onTextFieldKeydown = disabled
|
|
81
|
+
? undefined
|
|
82
|
+
: (event) => {
|
|
83
|
+
switch (event.code) {
|
|
84
|
+
case 'Enter':
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
86
|
+
onTextFieldClick();
|
|
87
|
+
break;
|
|
88
|
+
case 'ArrowUp':
|
|
89
|
+
case 'ArrowRight':
|
|
90
|
+
case 'ArrowLeft':
|
|
91
|
+
case 'ArrowDown': {
|
|
92
|
+
if (!open) {
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
94
|
+
onTextFieldClick();
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 'Tab': {
|
|
99
|
+
if (open) {
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
101
|
+
onTextFieldClick();
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
useClickAway(() => {
|
|
108
|
+
if (!open)
|
|
109
|
+
return;
|
|
110
|
+
return (event) => {
|
|
111
|
+
var _a;
|
|
112
|
+
if (!((_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) {
|
|
113
|
+
onClose();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}, controlRef, [
|
|
117
|
+
open,
|
|
118
|
+
toggleOpen,
|
|
119
|
+
]);
|
|
120
|
+
/** Trigger input props */
|
|
121
|
+
const resolvedInputProps = {
|
|
122
|
+
...inputProps,
|
|
123
|
+
'aria-expanded': open,
|
|
124
|
+
placeholder,
|
|
125
|
+
role: 'combobox',
|
|
126
|
+
};
|
|
127
|
+
/** Tags close handler */
|
|
128
|
+
const onTagClose = onChangeProp && valueProp
|
|
129
|
+
? (target) => {
|
|
130
|
+
onChangeProp(valueProp.filter((v) => v.id !== target.id));
|
|
131
|
+
}
|
|
132
|
+
: undefined;
|
|
133
|
+
/** Clear method */
|
|
134
|
+
const onClear = clearable && onChangeProp
|
|
135
|
+
? () => {
|
|
136
|
+
onChangeProp([]);
|
|
137
|
+
}
|
|
138
|
+
: undefined;
|
|
139
|
+
/** Map options to tree nodes */
|
|
140
|
+
function mapOptionToNode(option) {
|
|
141
|
+
var _a;
|
|
142
|
+
return {
|
|
143
|
+
label: option.name,
|
|
144
|
+
value: option.id,
|
|
145
|
+
nodes: (_a = option.siblings) === null || _a === void 0 ? void 0 : _a.map((sibling) => mapOptionToNode(sibling)),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function flattenOptions(targets) {
|
|
149
|
+
const optionsMap = {};
|
|
150
|
+
function mapOptionsToSelectValue(optionsToMap) {
|
|
151
|
+
optionsToMap.forEach((optionToMap) => {
|
|
152
|
+
optionsMap[optionToMap.id] = {
|
|
153
|
+
id: optionToMap.id,
|
|
154
|
+
name: optionToMap.name,
|
|
155
|
+
};
|
|
156
|
+
if (optionToMap.siblings) {
|
|
157
|
+
mapOptionsToSelectValue(optionToMap.siblings);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
mapOptionsToSelectValue(targets);
|
|
162
|
+
return optionsMap;
|
|
163
|
+
}
|
|
164
|
+
const optionMap = flattenOptions(options);
|
|
165
|
+
const nodes = options.map((option) => mapOptionToNode(option));
|
|
166
|
+
/** Map selected values */
|
|
167
|
+
const selectedValues = valueProp === null || valueProp === void 0 ? void 0 : valueProp.map((v) => mapOptionToNode(v).value);
|
|
168
|
+
const onSelect = onChangeProp
|
|
169
|
+
? (values) => {
|
|
170
|
+
const selectValues = values.map((currentValue) => optionMap[currentValue]);
|
|
171
|
+
onChangeProp(selectValues);
|
|
172
|
+
}
|
|
173
|
+
: undefined;
|
|
174
|
+
/** Controlled expanded value to avoid expanded values cleanup after panel toggled */
|
|
175
|
+
const [expandedValues, setExpandedValues] = useState(() => {
|
|
176
|
+
const currentExpandedValues = [];
|
|
177
|
+
if (defaultExpandAll) {
|
|
178
|
+
traverseTree(nodes, (node) => {
|
|
179
|
+
if (node.nodes) {
|
|
180
|
+
currentExpandedValues.push(node.value);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return currentExpandedValues;
|
|
185
|
+
});
|
|
186
|
+
const onExpand = (value) => {
|
|
187
|
+
const newExpandedValues = toggleValue(value, expandedValues);
|
|
188
|
+
setExpandedValues(newExpandedValues);
|
|
189
|
+
};
|
|
190
|
+
return (jsxs("div", Object.assign({ ref: nodeRef, className: selectClasses.treeSelect }, { children: [jsx(SelectTrigger, { ref: composedRef, active: open, className: className, clearable: clearable, disabled: disabled, error: error, fullWidth: fullWidth, inputProps: resolvedInputProps, inputRef: inputRef, mode: mode, onClear: onClear, onClick: onTextFieldClick, onKeyDown: onTextFieldKeydown, onTagClose: onTagClose, prefix: prefix, readOnly: true, renderValue: renderValue, required: required, size: size, suffixActionIcon: suffixActionIcon, value: valueProp }, void 0),
|
|
191
|
+
jsx(InputTriggerPopper, Object.assign({ ref: popperRef, anchor: controlRef, className: selectClasses.popper, controllerRef: controllerRef, open: open, options: popperOptions, sameWidth: sameWidth }, { children: jsx(Menu, Object.assign({ itemsInView: itemsInView, maxHeight: menuMaxHeight, role: menuRole, size: menuSize, style: {
|
|
192
|
+
...restStyle,
|
|
193
|
+
border: border || 0,
|
|
194
|
+
width: width || `${panelWidth}px`,
|
|
195
|
+
} }, { children: jsx(Tree, Object.assign({}, restTreeProps, { ref: ref, className: cx(selectClasses.tree, treeClassName), disabledValues: disabledValues, expandControllerRef: expandControllerRef, expandedValues: expandedValues, multiple: multiple, nodes: nodes, onExpand: onExpand, onSelect: onSelect, selectMethod: "target", selectable: true, values: selectedValues }), void 0) }), void 0) }), void 0)] }), void 0));
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
export default TreeSelect;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './typings';
|
|
2
|
+
export { SelectControlContext, } from './SelectControlContext';
|
|
3
|
+
export { SelectTriggerProps, SelectTriggerInputProps, default as SelectTrigger, } from './SelectTrigger';
|
|
4
|
+
export { SelectProps, default, } from './Select';
|
|
5
|
+
export { OptionProps, default as Option, } from './Option';
|
|
6
|
+
export { MenuItemGroupProps as OptionGroupProps, default as OptionGroup, } from '../Menu/MenuItemGroup';
|
|
7
|
+
export { TreeSelectProps, default as TreeSelect, } from './TreeSelect';
|
|
8
|
+
export { AutoCompleteProps, default as AutoComplete, } from './AutoComplete';
|
package/Select/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { SelectControlContext } from './SelectControlContext.js';
|
|
2
|
+
export { default as SelectTrigger } from './SelectTrigger.js';
|
|
3
|
+
export { default } from './Select.js';
|
|
4
|
+
export { default as Option } from './Option.js';
|
|
5
|
+
export { default as OptionGroup } from '../Menu/MenuItemGroup.js';
|
|
6
|
+
export { default as TreeSelect } from './TreeSelect.js';
|
|
7
|
+
export { default as AutoComplete } from './AutoComplete.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SelectValue {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TreeSelectOption extends SelectValue {
|
|
6
|
+
siblings?: TreeSelectOption[];
|
|
7
|
+
}
|
|
8
|
+
export interface SelectControl {
|
|
9
|
+
value: SelectValue[];
|
|
10
|
+
onChange: (v: SelectValue | null) => SelectValue[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
export interface SkeletonProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
|
|
4
|
+
/**
|
|
5
|
+
* Height of the skeleton.
|
|
6
|
+
*/
|
|
7
|
+
height?: number | string;
|
|
8
|
+
/**
|
|
9
|
+
* Type of the skeleton.
|
|
10
|
+
* @default 'rectangle'
|
|
11
|
+
*/
|
|
12
|
+
type?: 'rectangle' | 'circle';
|
|
13
|
+
/**
|
|
14
|
+
* Width of the skeleton.
|
|
15
|
+
*/
|
|
16
|
+
width?: number | string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The react component for `mezzanine` Skeleton.
|
|
20
|
+
*/
|
|
21
|
+
declare const Skeleton: import("react").ForwardRefExoticComponent<SkeletonProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
|
+
export default Skeleton;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { skeletonClasses } from '@mezzanine-ui/core/skeleton';
|
|
4
|
+
import cx from 'clsx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The react component for `mezzanine` Skeleton.
|
|
8
|
+
*/
|
|
9
|
+
const Skeleton = forwardRef(function Skeleton(props, ref) {
|
|
10
|
+
const { className, height: skeletonHeight, style: skeletonStyle, type, width: skeletonWidth, ...rest } = props;
|
|
11
|
+
return (jsx("div", Object.assign({}, rest, { ref: ref, className: cx(skeletonClasses.host, type === 'circle' && skeletonClasses.circle, className), style: { width: skeletonWidth, height: skeletonHeight, ...skeletonStyle } }, rest), void 0));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export default Skeleton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SkeletonProps, default } from './Skeleton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Skeleton.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { RangeSliderValue, SingleSliderValue } from '@mezzanine-ui/core/slider';
|
|
3
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
4
|
+
import { UseRangeSliderProps, UseSingleSliderProps } from './useSlider';
|
|
5
|
+
export interface SliderBaseProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'defaultChecked' | 'defaultValue' | 'onChange'> {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the slider is disabled.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The maximum permitted value
|
|
13
|
+
* @default 100
|
|
14
|
+
*/
|
|
15
|
+
max?: number;
|
|
16
|
+
/**
|
|
17
|
+
* The minimum permitted value
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
min?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The stepping interval.
|
|
23
|
+
* @default 0
|
|
24
|
+
*/
|
|
25
|
+
step?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Will render input if `withInput` is `true`.
|
|
28
|
+
*/
|
|
29
|
+
withInput?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The ref for Slider root.
|
|
32
|
+
*/
|
|
33
|
+
innerRef?: Ref<HTMLDivElement>;
|
|
34
|
+
}
|
|
35
|
+
export declare type SingleSliderProps = SliderBaseProps & {
|
|
36
|
+
onChange?: (value: SingleSliderValue) => void;
|
|
37
|
+
value: UseSingleSliderProps['value'];
|
|
38
|
+
};
|
|
39
|
+
export declare type RangeSliderProps = SliderBaseProps & {
|
|
40
|
+
onChange?: (value: RangeSliderValue) => void;
|
|
41
|
+
value: UseRangeSliderProps['value'];
|
|
42
|
+
};
|
|
43
|
+
export declare type SliderComponentProps = SingleSliderProps | RangeSliderProps;
|
|
44
|
+
export declare type SliderProps = Omit<SliderComponentProps, 'innerRef'>;
|
|
45
|
+
/**
|
|
46
|
+
* The react component for `mezzanine` slider.
|
|
47
|
+
* The outcome will be base on the type of given value.
|
|
48
|
+
* Notice that slider is a fully controlled component. Property value is always needed.
|
|
49
|
+
*/
|
|
50
|
+
declare const Slider: import("react").ForwardRefExoticComponent<Pick<SliderComponentProps, "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "value" | "disabled" | "max" | "min" | "step" | "withInput"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
51
|
+
export default Slider;
|
package/Slider/Slider.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
3
|
+
import { isRangeSlider, sortSliderValue, sliderClasses, roundToStep } from '@mezzanine-ui/core/slider';
|
|
4
|
+
import { useSlider } from './useSlider.js';
|
|
5
|
+
import Input from '../Input/Input.js';
|
|
6
|
+
import Tooltip from '../Tooltip/Tooltip.js';
|
|
7
|
+
import cx from 'clsx';
|
|
8
|
+
|
|
9
|
+
function SliderComponent(props) {
|
|
10
|
+
const { className, disabled, innerRef, max = 100, min = 0, onChange, step = 1, style: styleProp, value, withInput, ...rest } = props;
|
|
11
|
+
const { activeHandleIndex, cssVars, handleClickTrackOrRail, handlePress, railRef, } = useSlider({
|
|
12
|
+
max,
|
|
13
|
+
min,
|
|
14
|
+
onChange,
|
|
15
|
+
step,
|
|
16
|
+
value,
|
|
17
|
+
});
|
|
18
|
+
const style = {
|
|
19
|
+
...cssVars,
|
|
20
|
+
...styleProp,
|
|
21
|
+
};
|
|
22
|
+
const shouldHaveInputHandlers = withInput && onChange && !disabled;
|
|
23
|
+
const getHandle = (handlerValue, index) => (jsx("div", Object.assign({ className: cx(sliderClasses.handlerPosition, index === 0 && sliderClasses.handlerStartPosition, index === 1 && sliderClasses.handlerEndPosition) }, { children: jsx(Tooltip, Object.assign({ disablePortal: true, options: {
|
|
24
|
+
placement: 'top',
|
|
25
|
+
}, title: handlerValue.toString() }, { children: ({ onMouseEnter, onMouseLeave }) => (jsx("div", { className: cx(sliderClasses.handler, index === activeHandleIndex && sliderClasses.handlerActive), "aria-disabled": disabled, "aria-label": `Slider Handler ${index}`, "aria-valuemax": max, "aria-valuemin": min, "aria-valuenow": handlerValue, onFocus: () => { }, onMouseDown: (e) => handlePress(e, index), onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onTouchStart: (e) => handlePress(e, index), role: "slider", tabIndex: index }, void 0)) }), void 0) }), void 0));
|
|
26
|
+
const inputSize = Math.max(min.toString().length, max.toString().length);
|
|
27
|
+
const [startInputValue, setStartInputValue] = useState(() => {
|
|
28
|
+
if (!isRangeSlider(value)) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
return `${value[0]}`;
|
|
32
|
+
});
|
|
33
|
+
const [endInputValue, setEndInputValue] = useState(() => {
|
|
34
|
+
if (!isRangeSlider(value)) {
|
|
35
|
+
return `${value}`;
|
|
36
|
+
}
|
|
37
|
+
return `${value[1]}`;
|
|
38
|
+
});
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (withInput) {
|
|
41
|
+
if (isRangeSlider(value)) {
|
|
42
|
+
setStartInputValue(`${value[0]}`);
|
|
43
|
+
setEndInputValue(`${value[1]}`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
setEndInputValue(value.toString());
|
|
47
|
+
}
|
|
48
|
+
}, [value, withInput]);
|
|
49
|
+
function preventValueOverflow(target) {
|
|
50
|
+
if (target > max) {
|
|
51
|
+
return max;
|
|
52
|
+
}
|
|
53
|
+
if (target < min) {
|
|
54
|
+
return min;
|
|
55
|
+
}
|
|
56
|
+
return roundToStep(target, step, min, max);
|
|
57
|
+
}
|
|
58
|
+
const onStartInputChange = shouldHaveInputHandlers ? (e) => {
|
|
59
|
+
setStartInputValue(e.target.value);
|
|
60
|
+
} : undefined;
|
|
61
|
+
const onEndInputChange = shouldHaveInputHandlers ? (e) => {
|
|
62
|
+
setEndInputValue(e.target.value);
|
|
63
|
+
} : undefined;
|
|
64
|
+
const onStartInputBlur = shouldHaveInputHandlers && isRangeSlider(value)
|
|
65
|
+
? () => {
|
|
66
|
+
const result = sortSliderValue([
|
|
67
|
+
value[1],
|
|
68
|
+
preventValueOverflow(Number(startInputValue)),
|
|
69
|
+
]);
|
|
70
|
+
onChange(result);
|
|
71
|
+
}
|
|
72
|
+
: undefined;
|
|
73
|
+
const onEndInputBlur = shouldHaveInputHandlers
|
|
74
|
+
? () => {
|
|
75
|
+
if (isRangeSlider(value)) {
|
|
76
|
+
const result = sortSliderValue([
|
|
77
|
+
value[0],
|
|
78
|
+
preventValueOverflow(Number(endInputValue)),
|
|
79
|
+
]);
|
|
80
|
+
onChange(result);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
onChange(preventValueOverflow(Number(endInputValue)));
|
|
84
|
+
}
|
|
85
|
+
: undefined;
|
|
86
|
+
const onStartInputKeydown = shouldHaveInputHandlers && isRangeSlider(value)
|
|
87
|
+
? (e) => {
|
|
88
|
+
switch (e.code) {
|
|
89
|
+
case 'Enter': {
|
|
90
|
+
const result = sortSliderValue([
|
|
91
|
+
value[1],
|
|
92
|
+
preventValueOverflow(Number(startInputValue)),
|
|
93
|
+
]);
|
|
94
|
+
setStartInputValue(result[0].toString());
|
|
95
|
+
setEndInputValue(result[1].toString());
|
|
96
|
+
onChange(result);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case 'Escape': {
|
|
100
|
+
setStartInputValue(value[0].toString());
|
|
101
|
+
setEndInputValue(value[1].toString());
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
: undefined;
|
|
107
|
+
const onEndInputKeydown = shouldHaveInputHandlers
|
|
108
|
+
? (e) => {
|
|
109
|
+
switch (e.code) {
|
|
110
|
+
case 'Enter': {
|
|
111
|
+
if (isRangeSlider(value)) {
|
|
112
|
+
const result = sortSliderValue([
|
|
113
|
+
value[0],
|
|
114
|
+
preventValueOverflow(Number(endInputValue)),
|
|
115
|
+
]);
|
|
116
|
+
setStartInputValue(result[0].toString());
|
|
117
|
+
setEndInputValue(result[1].toString());
|
|
118
|
+
onChange(result);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const result = preventValueOverflow(Number(endInputValue));
|
|
122
|
+
setEndInputValue(result.toString());
|
|
123
|
+
onChange(result);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case 'Escape': {
|
|
127
|
+
if (isRangeSlider(value)) {
|
|
128
|
+
setStartInputValue(value[0].toString());
|
|
129
|
+
setEndInputValue(value[1].toString());
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
setEndInputValue(value.toString());
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
: undefined;
|
|
138
|
+
const inputProps = {
|
|
139
|
+
max,
|
|
140
|
+
min,
|
|
141
|
+
style: {
|
|
142
|
+
width: `${inputSize}ch`,
|
|
143
|
+
},
|
|
144
|
+
type: 'number',
|
|
145
|
+
};
|
|
146
|
+
return (jsxs("div", Object.assign({}, rest, { ref: innerRef, className: cx(sliderClasses.host, disabled && sliderClasses.disabled, className), style: style }, { children: [withInput && isRangeSlider(value) ? (jsx(Input, { className: sliderClasses.input, disabled: disabled, onChange: onStartInputChange, value: startInputValue, inputProps: {
|
|
147
|
+
...inputProps,
|
|
148
|
+
onKeyDown: onStartInputKeydown,
|
|
149
|
+
onBlur: onStartInputBlur,
|
|
150
|
+
} }, void 0)) : null,
|
|
151
|
+
jsxs("div", Object.assign({ className: sliderClasses.controls }, { children: [jsx("div", { ref: railRef, className: sliderClasses.rail, role: "presentation", onMouseDown: handleClickTrackOrRail }, void 0),
|
|
152
|
+
jsx("div", { className: sliderClasses.track, role: "presentation", onMouseDown: handleClickTrackOrRail }, void 0),
|
|
153
|
+
isRangeSlider(value) ? (jsxs(Fragment, { children: [getHandle(value[0], 0), getHandle(value[1], 1)] }, void 0)) : getHandle(value, -1)] }), void 0),
|
|
154
|
+
withInput ? (jsx(Input, { className: sliderClasses.input, disabled: disabled, onChange: onEndInputChange, value: endInputValue, inputProps: {
|
|
155
|
+
...inputProps,
|
|
156
|
+
onKeyDown: onEndInputKeydown,
|
|
157
|
+
onBlur: onEndInputBlur,
|
|
158
|
+
} }, void 0)) : null] }), void 0));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The react component for `mezzanine` slider.
|
|
162
|
+
* The outcome will be base on the type of given value.
|
|
163
|
+
* Notice that slider is a fully controlled component. Property value is always needed.
|
|
164
|
+
*/
|
|
165
|
+
const Slider = forwardRef((props, ref) => {
|
|
166
|
+
if (isRangeSlider(props.value)) {
|
|
167
|
+
return (jsx(SliderComponent, Object.assign({}, props, { innerRef: ref }), void 0));
|
|
168
|
+
}
|
|
169
|
+
return (jsx(SliderComponent, Object.assign({}, props, { innerRef: ref }), void 0));
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
export default Slider;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { SingleSliderValue, RangeSliderValue, SliderValue, SliderRect, } from '@mezzanine-ui/core/slider';
|
|
2
|
+
export { UseSliderCommonProps, UseSingleSliderProps, UseRangeSliderProps, UseSliderProps, UseSliderResult, useSlider, } from './useSlider';
|
|
3
|
+
export { SliderBaseProps, SingleSliderProps, RangeSliderProps, SliderComponentProps, SliderProps, default, } from './Slider';
|
package/Slider/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RangeSliderValue, SingleSliderValue } from '@mezzanine-ui/core/slider';
|
|
2
|
+
import { CssVarInterpolation } from '@mezzanine-ui/system/css';
|
|
3
|
+
import { RefObject } from 'react';
|
|
4
|
+
export interface UseSliderCommonProps {
|
|
5
|
+
max: number;
|
|
6
|
+
min: number;
|
|
7
|
+
step: number;
|
|
8
|
+
}
|
|
9
|
+
export interface UseSingleSliderProps extends UseSliderCommonProps {
|
|
10
|
+
onChange(value: RangeSliderValue): never;
|
|
11
|
+
onChange(value: SingleSliderValue): void;
|
|
12
|
+
value: SingleSliderValue;
|
|
13
|
+
}
|
|
14
|
+
export interface UseRangeSliderProps extends UseSliderCommonProps {
|
|
15
|
+
onChange(value: RangeSliderValue): void;
|
|
16
|
+
onChange(value: SingleSliderValue): never;
|
|
17
|
+
value: RangeSliderValue;
|
|
18
|
+
}
|
|
19
|
+
export interface UseSliderProps extends UseSliderCommonProps {
|
|
20
|
+
onChange?: UseRangeSliderProps['onChange'] | UseSingleSliderProps['onChange'];
|
|
21
|
+
value: SingleSliderValue | RangeSliderValue;
|
|
22
|
+
}
|
|
23
|
+
export interface UseSliderResult {
|
|
24
|
+
activeHandleIndex: number | undefined;
|
|
25
|
+
cssVars: Record<string, CssVarInterpolation>;
|
|
26
|
+
handleClickTrackOrRail?: (e: any) => void;
|
|
27
|
+
handlePress: (e: any, index?: number | undefined) => void;
|
|
28
|
+
railRef: RefObject<HTMLDivElement>;
|
|
29
|
+
}
|
|
30
|
+
export declare function useSlider(props: UseRangeSliderProps): UseSliderResult;
|
|
31
|
+
export declare function useSlider(props: UseSingleSliderProps): UseSliderResult;
|