@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,47 @@
|
|
|
1
|
+
import { RadioGroupOption, RadioSize } from '@mezzanine-ui/core/radio';
|
|
2
|
+
import { ChangeEventHandler, ReactNode } from 'react';
|
|
3
|
+
import { InputCheckGroupProps } from '../_internal/InputCheck';
|
|
4
|
+
export interface RadioGroupProps extends Omit<InputCheckGroupProps, 'onChange'> {
|
|
5
|
+
/**
|
|
6
|
+
* The radios in radio group.
|
|
7
|
+
*/
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* The default value of radio group.
|
|
11
|
+
*/
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the radio group is disabled.
|
|
15
|
+
* Control the disabled of radios in group if disabled not passed to radio.
|
|
16
|
+
*/
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The name of radio group.
|
|
20
|
+
* Control the name of radios in group if name not passed to radio.
|
|
21
|
+
*/
|
|
22
|
+
name?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The onChange of radio group.
|
|
25
|
+
* Will be passed to each radios but composing both instead of overriding.
|
|
26
|
+
*/
|
|
27
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
28
|
+
/**
|
|
29
|
+
* The options of radio group.
|
|
30
|
+
* Will be ignored if children passed.
|
|
31
|
+
*/
|
|
32
|
+
options?: RadioGroupOption[];
|
|
33
|
+
/**
|
|
34
|
+
* The size of radio group.
|
|
35
|
+
* Control the size of radios in group if size not passed to radio.
|
|
36
|
+
*/
|
|
37
|
+
size?: RadioSize;
|
|
38
|
+
/**
|
|
39
|
+
* The value of radio group.
|
|
40
|
+
*/
|
|
41
|
+
value?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The react component for `mezzanine` radio group.
|
|
45
|
+
*/
|
|
46
|
+
declare const RadioGroup: import("react").ForwardRefExoticComponent<RadioGroupProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
47
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useInputControlValue } from '../Form/useInputControlValue.js';
|
|
4
|
+
import { RadioGroupContext } from './RadioGroupContext.js';
|
|
5
|
+
import Radio from './Radio.js';
|
|
6
|
+
import InputCheckGroup from '../_internal/InputCheck/InputCheckGroup.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The react component for `mezzanine` radio group.
|
|
10
|
+
*/
|
|
11
|
+
const RadioGroup = forwardRef(function RadioGroup(props, ref) {
|
|
12
|
+
const { children: childrenProp, defaultValue, disabled, name, options = [], onChange: onChangeProp, size, value: valueProp, ...rest } = props;
|
|
13
|
+
const [value, onChange] = useInputControlValue({
|
|
14
|
+
defaultValue,
|
|
15
|
+
onChange: onChangeProp,
|
|
16
|
+
value: valueProp,
|
|
17
|
+
});
|
|
18
|
+
const context = {
|
|
19
|
+
disabled,
|
|
20
|
+
name,
|
|
21
|
+
onChange,
|
|
22
|
+
size,
|
|
23
|
+
value,
|
|
24
|
+
};
|
|
25
|
+
const children = childrenProp || options.map((option) => (jsx(Radio, Object.assign({ disabled: option.disabled, value: option.value }, { children: option.label }), option.value)));
|
|
26
|
+
return (jsx(RadioGroupContext.Provider, Object.assign({ value: context }, { children: jsx(InputCheckGroup, Object.assign({}, rest, { ref: ref, role: "radiogroup" }, { children: children }), void 0) }), void 0));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { RadioSize } from '@mezzanine-ui/core/radio';
|
|
3
|
+
import { RadioGroupControlContextValue } from '../Form/useRadioControlValue';
|
|
4
|
+
export interface RadioGroupContextValue extends RadioGroupControlContextValue {
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
name?: string;
|
|
7
|
+
size?: RadioSize;
|
|
8
|
+
}
|
|
9
|
+
export declare const RadioGroupContext: import("react").Context<RadioGroupContextValue | undefined>;
|
package/Radio/index.d.ts
ADDED
package/Radio/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SelectInputSize } from '@mezzanine-ui/core/select';
|
|
3
|
+
import { MenuProps } from '../Menu';
|
|
4
|
+
import { PopperProps } from '../Popper';
|
|
5
|
+
import { PickRenameMulti } from '../utils/rename-types';
|
|
6
|
+
import { SelectTriggerProps, SelectTriggerInputProps } from './SelectTrigger';
|
|
7
|
+
export interface AutoCompleteProps extends Omit<SelectTriggerProps, 'active' | 'clearable' | 'forceHideSuffixActionIcon' | 'mode' | 'onClick' | 'onKeyDown' | 'onChange' | 'renderValue' | 'inputProps' | 'suffixActionIcon' | 'value'>, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
|
|
8
|
+
maxHeight: 'menuMaxHeight';
|
|
9
|
+
role: 'menuRole';
|
|
10
|
+
size: 'menuSize';
|
|
11
|
+
}>, PickRenameMulti<Pick<PopperProps, 'options'>, {
|
|
12
|
+
options: 'popperOptions';
|
|
13
|
+
}> {
|
|
14
|
+
/**
|
|
15
|
+
* Set to true when options can be added dynamically
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
addable?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The default selection
|
|
21
|
+
*/
|
|
22
|
+
defaultValue?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Should the filter rules be disabled (If you need to control options filter by yourself)
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
disabledOptionsFilter?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The other native props for input element.
|
|
30
|
+
*/
|
|
31
|
+
inputProps?: Omit<SelectTriggerInputProps, 'onChange' | 'placeholder' | 'role' | 'value' | `aria-${'controls' | 'expanded' | 'owns'}`>;
|
|
32
|
+
/**
|
|
33
|
+
* The change event handler of input element.
|
|
34
|
+
*/
|
|
35
|
+
onChange?(text: string): any;
|
|
36
|
+
/**
|
|
37
|
+
* insert callback whenever insert icon is clicked
|
|
38
|
+
* return `true` when insert is successfully
|
|
39
|
+
*/
|
|
40
|
+
onInsert?(text: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The search event handler
|
|
43
|
+
*/
|
|
44
|
+
onSearch?(input: string): any;
|
|
45
|
+
/**
|
|
46
|
+
* The options that mapped autocomplete options
|
|
47
|
+
*/
|
|
48
|
+
options: string[];
|
|
49
|
+
/**
|
|
50
|
+
* select input placeholder
|
|
51
|
+
*/
|
|
52
|
+
placeholder?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the selection is required.
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
required?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The size of input.
|
|
60
|
+
* @default 'medium'
|
|
61
|
+
*/
|
|
62
|
+
size?: SelectInputSize;
|
|
63
|
+
/**
|
|
64
|
+
* The value of selection.
|
|
65
|
+
* @default undefined
|
|
66
|
+
*/
|
|
67
|
+
value?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The AutoComplete component for react. <br />
|
|
71
|
+
* Note that if you need search for ONLY given options, not included your typings,
|
|
72
|
+
* should considering using the `Select` component with `onSearch` prop.
|
|
73
|
+
*/
|
|
74
|
+
declare const AutoComplete: import("react").ForwardRefExoticComponent<AutoCompleteProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
75
|
+
export default AutoComplete;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useContext, useState, useRef } from 'react';
|
|
3
|
+
import { selectClasses } from '@mezzanine-ui/core/select';
|
|
4
|
+
import { PlusIcon } from '@mezzanine-ui/icons';
|
|
5
|
+
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
6
|
+
import Option from './Option.js';
|
|
7
|
+
import { SelectControlContext } from './SelectControlContext.js';
|
|
8
|
+
import { useAutoCompleteValueControl } from '../Form/useAutoCompleteValueControl.js';
|
|
9
|
+
import { useClickAway } from '../hooks/useClickAway.js';
|
|
10
|
+
import SelectTrigger from './SelectTrigger.js';
|
|
11
|
+
import { FormControlContext } from '../Form/FormControlContext.js';
|
|
12
|
+
import InputTriggerPopper from '../_internal/InputTriggerPopper/InputTriggerPopper.js';
|
|
13
|
+
import Menu from '../Menu/Menu.js';
|
|
14
|
+
import Empty from '../Empty/Empty.js';
|
|
15
|
+
import Icon from '../Icon/Icon.js';
|
|
16
|
+
import cx from 'clsx';
|
|
17
|
+
|
|
18
|
+
const MENU_ID = 'mzn-select-autocomplete-menu-id';
|
|
19
|
+
/**
|
|
20
|
+
* The AutoComplete component for react. <br />
|
|
21
|
+
* Note that if you need search for ONLY given options, not included your typings,
|
|
22
|
+
* should considering using the `Select` component with `onSearch` prop.
|
|
23
|
+
*/
|
|
24
|
+
const AutoComplete = forwardRef(function Select(props, ref) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
|
|
27
|
+
const { addable = false, className, disabled = disabledFromFormControl || false, disabledOptionsFilter = false, defaultValue, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputRef, inputProps, itemsInView = 4, menuMaxHeight, menuRole = 'listbox', menuSize = 'medium', onChange: onChangeProp, onClear: onClearProp, onInsert, onSearch, options: optionsProp, popperOptions = {}, placeholder = '', prefix, required = requiredFromFormControl || false, size = 'medium', value: valueProp, } = props;
|
|
28
|
+
const [open, toggleOpen] = useState(false);
|
|
29
|
+
const { focused, onFocus, onChange, onClear, options, searchText, setSearchText, setValue, value, } = useAutoCompleteValueControl({
|
|
30
|
+
defaultValue,
|
|
31
|
+
disabledOptionsFilter,
|
|
32
|
+
onChange: onChangeProp,
|
|
33
|
+
onClear: onClearProp,
|
|
34
|
+
onClose: () => toggleOpen(false),
|
|
35
|
+
options: optionsProp,
|
|
36
|
+
value: valueProp,
|
|
37
|
+
});
|
|
38
|
+
/** insert feature */
|
|
39
|
+
const [insertText, setInsertText] = useState('');
|
|
40
|
+
const nodeRef = useRef(null);
|
|
41
|
+
const controlRef = useRef(null);
|
|
42
|
+
const popperRef = useRef(null);
|
|
43
|
+
const composedRef = useComposeRefs([ref, controlRef]);
|
|
44
|
+
useClickAway(() => {
|
|
45
|
+
if (!open || focused)
|
|
46
|
+
return;
|
|
47
|
+
return () => {
|
|
48
|
+
toggleOpen((prev) => !prev);
|
|
49
|
+
};
|
|
50
|
+
}, nodeRef, [
|
|
51
|
+
focused,
|
|
52
|
+
nodeRef,
|
|
53
|
+
open,
|
|
54
|
+
toggleOpen,
|
|
55
|
+
]);
|
|
56
|
+
/** Trigger input props */
|
|
57
|
+
const onSearchInputChange = (e) => {
|
|
58
|
+
/** should sync both search input and value */
|
|
59
|
+
setSearchText(e.target.value);
|
|
60
|
+
setValue(e.target.value);
|
|
61
|
+
/** return current value to onSearch */
|
|
62
|
+
onSearch === null || onSearch === void 0 ? void 0 : onSearch(e.target.value);
|
|
63
|
+
};
|
|
64
|
+
const onSearchInputFocus = (e) => {
|
|
65
|
+
var _a;
|
|
66
|
+
e.stopPropagation();
|
|
67
|
+
toggleOpen(true);
|
|
68
|
+
onFocus(true);
|
|
69
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
70
|
+
};
|
|
71
|
+
const onSearchInputBlur = (e) => {
|
|
72
|
+
var _a;
|
|
73
|
+
onFocus(false);
|
|
74
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
75
|
+
};
|
|
76
|
+
const resolvedInputProps = {
|
|
77
|
+
...inputProps,
|
|
78
|
+
'aria-controls': MENU_ID,
|
|
79
|
+
'aria-expanded': open,
|
|
80
|
+
'aria-owns': MENU_ID,
|
|
81
|
+
onBlur: onSearchInputBlur,
|
|
82
|
+
onChange: onSearchInputChange,
|
|
83
|
+
onFocus: onSearchInputFocus,
|
|
84
|
+
placeholder,
|
|
85
|
+
role: 'combobox',
|
|
86
|
+
};
|
|
87
|
+
return (jsx(SelectControlContext.Provider, Object.assign({ value: {
|
|
88
|
+
onChange,
|
|
89
|
+
value,
|
|
90
|
+
} }, { children: jsxs("div", Object.assign({ ref: nodeRef, className: selectClasses.host }, { children: [jsx(SelectTrigger, { ref: composedRef, active: open, className: className, clearable: true, disabled: disabled, error: error, forceHideSuffixActionIcon: true, fullWidth: fullWidth, inputRef: inputRef, mode: "single", onTagClose: onChange, onClear: onClear, prefix: prefix, readOnly: false, required: required, inputProps: resolvedInputProps, size: size, suffixActionIcon: undefined, value: value }, void 0),
|
|
91
|
+
jsxs(InputTriggerPopper, Object.assign({ ref: popperRef, anchor: controlRef, className: selectClasses.popper, open: open, sameWidth: true, options: popperOptions }, { children: [jsxs(Menu, Object.assign({ id: MENU_ID, "aria-activedescendant": (_b = (_a = value[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '', itemsInView: itemsInView, maxHeight: menuMaxHeight, role: menuRole, size: menuSize, style: { border: 0 } }, { children: [jsx(Option, Object.assign({ value: searchText }, { children: searchText }), void 0),
|
|
92
|
+
options.length ? options.map((option) => (jsx(Option, Object.assign({ value: option }, { children: option }), option))) : (jsx(Empty, { children: "\u67E5\u7121\u8CC7\u6599" }, void 0))] }), void 0),
|
|
93
|
+
addable ? (jsxs("div", Object.assign({ className: selectClasses.autoComplete }, { children: [jsx("input", { type: "text", onChange: (e) => setInsertText(e.target.value), onClick: (e) => e.stopPropagation(), onFocus: (e) => e.stopPropagation(), placeholder: "\u65B0\u589E\u9078\u9805", value: insertText }, void 0),
|
|
94
|
+
jsx(Icon, { className: cx(selectClasses.autoCompleteIcon, {
|
|
95
|
+
[selectClasses.autoCompleteIconActive]: !!insertText,
|
|
96
|
+
}), icon: PlusIcon, onClick: (e) => {
|
|
97
|
+
var _a;
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
if (insertText) {
|
|
100
|
+
const insertSuccess = (_a = onInsert === null || onInsert === void 0 ? void 0 : onInsert(insertText)) !== null && _a !== void 0 ? _a : false;
|
|
101
|
+
if (insertSuccess) {
|
|
102
|
+
setInsertText('');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} }, void 0)] }), void 0)) : null] }), void 0)] }), void 0) }), void 0));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export default AutoComplete;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MenuItemProps } from '../Menu';
|
|
3
|
+
export interface OptionProps extends Omit<MenuItemProps, 'children' | 'role'> {
|
|
4
|
+
/**
|
|
5
|
+
* option children (often means the option name)
|
|
6
|
+
*/
|
|
7
|
+
children: string;
|
|
8
|
+
/**
|
|
9
|
+
* The role of menu item.
|
|
10
|
+
* @default 'option'
|
|
11
|
+
*/
|
|
12
|
+
role?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The value of option
|
|
15
|
+
*/
|
|
16
|
+
value: string;
|
|
17
|
+
}
|
|
18
|
+
declare const Option: import("react").ForwardRefExoticComponent<OptionProps & import("react").RefAttributes<HTMLLIElement>>;
|
|
19
|
+
export default Option;
|
package/Select/Option.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useContext } from 'react';
|
|
3
|
+
import { SelectControlContext } from './SelectControlContext.js';
|
|
4
|
+
import MenuItem from '../Menu/MenuItem.js';
|
|
5
|
+
|
|
6
|
+
const Option = forwardRef(function Option(props, ref) {
|
|
7
|
+
const { active: activeProp, children, role = 'option', value, ...rest } = props;
|
|
8
|
+
const selectControl = useContext(SelectControlContext);
|
|
9
|
+
const { onChange, value: selectedValue, } = selectControl || {};
|
|
10
|
+
const active = Boolean(activeProp || (selectedValue !== null && selectedValue !== void 0 ? selectedValue : []).find((sv) => sv.id === value));
|
|
11
|
+
const onSelect = () => {
|
|
12
|
+
if (typeof onChange === 'function' && value) {
|
|
13
|
+
onChange({
|
|
14
|
+
id: value,
|
|
15
|
+
name: children,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const onKeyDown = (evt) => {
|
|
20
|
+
switch (evt.code) {
|
|
21
|
+
case 'Enter':
|
|
22
|
+
onSelect();
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return (jsx(MenuItem, Object.assign({}, rest, { ref: ref, active: active, "aria-selected": active, id: value, onClick: (evt) => {
|
|
27
|
+
evt.stopPropagation();
|
|
28
|
+
onSelect();
|
|
29
|
+
}, onKeyDown: onKeyDown, role: role, tabIndex: 0 }, { children: children }), void 0));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default Option;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SelectInputSize } from '@mezzanine-ui/core/select';
|
|
3
|
+
import { FormElementFocusHandlers } from '../Form';
|
|
4
|
+
import { MenuProps } from '../Menu';
|
|
5
|
+
import { PopperProps } from '../Popper';
|
|
6
|
+
import { SelectValue } from './typings';
|
|
7
|
+
import { PickRenameMulti } from '../utils/rename-types';
|
|
8
|
+
import { SelectTriggerProps, SelectTriggerInputProps } from './SelectTrigger';
|
|
9
|
+
export interface SelectProps extends Omit<SelectTriggerProps, 'active' | 'inputProps' | 'onBlur' | 'onChange' | 'onClick' | 'onFocus' | 'onKeyDown'>, FormElementFocusHandlers, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
|
|
10
|
+
maxHeight: 'menuMaxHeight';
|
|
11
|
+
role: 'menuRole';
|
|
12
|
+
size: 'menuSize';
|
|
13
|
+
}>, PickRenameMulti<Pick<PopperProps, 'options'>, {
|
|
14
|
+
options: 'popperOptions';
|
|
15
|
+
}>, Pick<MenuProps, 'children'> {
|
|
16
|
+
/**
|
|
17
|
+
* The default selection
|
|
18
|
+
*/
|
|
19
|
+
defaultValue?: SelectValue[];
|
|
20
|
+
/**
|
|
21
|
+
* The other native props for input element.
|
|
22
|
+
*/
|
|
23
|
+
inputProps?: Omit<SelectTriggerInputProps, 'onBlur' | 'onChange' | 'onFocus' | 'placeholder' | 'role' | 'value' | `aria-${'controls' | 'expanded' | 'owns'}`>;
|
|
24
|
+
/**
|
|
25
|
+
* The change event handler of input element.
|
|
26
|
+
*/
|
|
27
|
+
onChange?(newOptions: SelectValue[]): any;
|
|
28
|
+
/**
|
|
29
|
+
* The search event handler, this prop won't work when mode is `multiple`
|
|
30
|
+
*/
|
|
31
|
+
onSearch?(input: string): any;
|
|
32
|
+
/**
|
|
33
|
+
* select input placeholder
|
|
34
|
+
*/
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
/**
|
|
37
|
+
* To customize rendering select input value
|
|
38
|
+
*/
|
|
39
|
+
renderValue?(values: SelectValue[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the selection is required.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
required?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The size of input.
|
|
47
|
+
* @default 'medium'
|
|
48
|
+
*/
|
|
49
|
+
size?: SelectInputSize;
|
|
50
|
+
/**
|
|
51
|
+
* The value of selection.
|
|
52
|
+
* @default undefined
|
|
53
|
+
*/
|
|
54
|
+
value?: SelectValue[];
|
|
55
|
+
}
|
|
56
|
+
declare const Select: import("react").ForwardRefExoticComponent<SelectProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
57
|
+
export default Select;
|
package/Select/Select.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useContext, useState, useRef, useLayoutEffect } from 'react';
|
|
3
|
+
import { selectClasses } from '@mezzanine-ui/core/select';
|
|
4
|
+
import { SearchIcon } from '@mezzanine-ui/icons';
|
|
5
|
+
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
6
|
+
import { SelectControlContext } from './SelectControlContext.js';
|
|
7
|
+
import { useSelectValueControl } from '../Form/useSelectValueControl.js';
|
|
8
|
+
import { useClickAway } from '../hooks/useClickAway.js';
|
|
9
|
+
import SelectTrigger from './SelectTrigger.js';
|
|
10
|
+
import { FormControlContext } from '../Form/FormControlContext.js';
|
|
11
|
+
import Icon from '../Icon/Icon.js';
|
|
12
|
+
import InputTriggerPopper from '../_internal/InputTriggerPopper/InputTriggerPopper.js';
|
|
13
|
+
import Menu from '../Menu/Menu.js';
|
|
14
|
+
import cx from 'clsx';
|
|
15
|
+
|
|
16
|
+
const MENU_ID = 'mzn-select-menu-id';
|
|
17
|
+
const Select = forwardRef(function Select(props, ref) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
|
|
20
|
+
const { children, className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuRole = 'listbox', menuSize = 'medium', mode = 'single', onBlur, onChange: onChangeProp, onClear: onClearProp, onFocus, onSearch, placeholder = '', popperOptions = {}, prefix, renderValue: renderValueProp, required = requiredFromFormControl || false, size = 'medium', suffixActionIcon: suffixActionIconProp, value: valueProp, } = props;
|
|
21
|
+
const [open, toggleOpen] = useState(false);
|
|
22
|
+
const onOpen = () => {
|
|
23
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
24
|
+
toggleOpen(true);
|
|
25
|
+
};
|
|
26
|
+
const onClose = () => {
|
|
27
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
28
|
+
toggleOpen(false);
|
|
29
|
+
};
|
|
30
|
+
const onToggleOpen = () => {
|
|
31
|
+
if (open) {
|
|
32
|
+
onClose();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
onOpen();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const { onChange, onClear, value, } = useSelectValueControl({
|
|
39
|
+
defaultValue,
|
|
40
|
+
mode,
|
|
41
|
+
onChange: onChangeProp,
|
|
42
|
+
onClear: onClearProp,
|
|
43
|
+
onClose,
|
|
44
|
+
value: valueProp,
|
|
45
|
+
});
|
|
46
|
+
const nodeRef = useRef(null);
|
|
47
|
+
const controlRef = useRef(null);
|
|
48
|
+
const popperRef = useRef(null);
|
|
49
|
+
const composedRef = useComposeRefs([ref, controlRef]);
|
|
50
|
+
const searchable = typeof onSearch === 'function';
|
|
51
|
+
const [searchText, changeSearchText] = useState('');
|
|
52
|
+
const [focused, setFocused] = useState(false);
|
|
53
|
+
const renderValue = focused && searchable ? () => searchText : renderValueProp;
|
|
54
|
+
function getPlaceholder() {
|
|
55
|
+
var _a;
|
|
56
|
+
if (focused && searchable) {
|
|
57
|
+
return (_a = renderValueProp === null || renderValueProp === void 0 ? void 0 : renderValueProp(value)) !== null && _a !== void 0 ? _a : value.map(({ name }) => name).join(', ');
|
|
58
|
+
}
|
|
59
|
+
return placeholder;
|
|
60
|
+
}
|
|
61
|
+
useLayoutEffect(() => {
|
|
62
|
+
if (!focused) {
|
|
63
|
+
changeSearchText('');
|
|
64
|
+
if (typeof onSearch === 'function') {
|
|
65
|
+
onSearch('');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, [focused, onSearch]);
|
|
69
|
+
useClickAway(() => {
|
|
70
|
+
if (!open || focused)
|
|
71
|
+
return;
|
|
72
|
+
return () => {
|
|
73
|
+
onClose();
|
|
74
|
+
};
|
|
75
|
+
}, nodeRef, [
|
|
76
|
+
focused,
|
|
77
|
+
nodeRef,
|
|
78
|
+
open,
|
|
79
|
+
toggleOpen,
|
|
80
|
+
]);
|
|
81
|
+
const suffixActionIcon = suffixActionIconProp || (searchable && open ? (jsx(Icon, { icon: SearchIcon }, void 0)) : undefined);
|
|
82
|
+
const onClickTextField = () => {
|
|
83
|
+
/** when searchable, should open menu when focus */
|
|
84
|
+
if (!searchable && !disabled) {
|
|
85
|
+
onToggleOpen();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* keyboard events for a11y
|
|
90
|
+
* (@todo keyboard event map into option selection when menu is opened)
|
|
91
|
+
*/
|
|
92
|
+
const onKeyDownTextField = (evt) => {
|
|
93
|
+
/** for a11y to open menu via keyboard */
|
|
94
|
+
switch (evt.code) {
|
|
95
|
+
case 'Enter':
|
|
96
|
+
onClose();
|
|
97
|
+
break;
|
|
98
|
+
case 'ArrowUp':
|
|
99
|
+
case 'ArrowRight':
|
|
100
|
+
case 'ArrowLeft':
|
|
101
|
+
case 'ArrowDown': {
|
|
102
|
+
if (!open) {
|
|
103
|
+
onOpen();
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case 'Tab': {
|
|
108
|
+
if (open) {
|
|
109
|
+
onClose();
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
/** Trigger input props */
|
|
116
|
+
const onSearchInputChange = searchable ? (e) => {
|
|
117
|
+
changeSearchText(e.target.value);
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
119
|
+
onSearch(e.target.value);
|
|
120
|
+
} : undefined;
|
|
121
|
+
const onSearchInputFocus = searchable ? (e) => {
|
|
122
|
+
e.stopPropagation();
|
|
123
|
+
onToggleOpen();
|
|
124
|
+
setFocused(true);
|
|
125
|
+
} : undefined;
|
|
126
|
+
const onSearchInputBlur = () => setFocused(false);
|
|
127
|
+
const resolvedInputProps = {
|
|
128
|
+
...inputProps,
|
|
129
|
+
'aria-controls': MENU_ID,
|
|
130
|
+
'aria-expanded': open,
|
|
131
|
+
'aria-owns': MENU_ID,
|
|
132
|
+
onBlur: onSearchInputBlur,
|
|
133
|
+
onChange: onSearchInputChange,
|
|
134
|
+
onFocus: onSearchInputFocus,
|
|
135
|
+
placeholder: getPlaceholder(),
|
|
136
|
+
role: 'combobox',
|
|
137
|
+
};
|
|
138
|
+
return (jsx(SelectControlContext.Provider, Object.assign({ value: {
|
|
139
|
+
onChange,
|
|
140
|
+
value,
|
|
141
|
+
} }, { children: jsxs("div", Object.assign({ ref: nodeRef, className: cx(selectClasses.host, fullWidth && selectClasses.hostFullWidth) }, { children: [jsx(SelectTrigger, { ref: composedRef, active: open, className: className, clearable: clearable, disabled: disabled, error: error, fullWidth: fullWidth, inputRef: inputRef, mode: mode, onTagClose: onChange, onClear: onClear, onClick: onClickTextField, onKeyDown: onKeyDownTextField, prefix: prefix, readOnly: !searchable, required: required, inputProps: resolvedInputProps, size: size, suffixActionIcon: suffixActionIcon, value: value, renderValue: renderValue }, void 0),
|
|
142
|
+
jsx(InputTriggerPopper, Object.assign({ ref: popperRef, anchor: controlRef, className: selectClasses.popper, open: open, sameWidth: true, options: popperOptions }, { children: jsx(Menu, Object.assign({ id: MENU_ID, "aria-activedescendant": (_b = (_a = value === null || value === void 0 ? void 0 : value[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '', itemsInView: itemsInView, maxHeight: menuMaxHeight, role: menuRole, size: menuSize, style: { border: 0 } }, { children: children }), void 0) }), void 0)] }), void 0) }), void 0));
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export default Select;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { SelectMode } from '@mezzanine-ui/core/select';
|
|
3
|
+
import { TextFieldProps } from '../TextField';
|
|
4
|
+
import { SelectValue } from './typings';
|
|
5
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
6
|
+
export declare type SelectTriggerInputProps = Omit<NativeElementPropsWithoutKeyAndRef<'input'>, 'autoComplete' | 'children' | 'defaultValue' | 'disabled' | 'readOnly' | 'required' | 'type' | 'value' | `aria-${'autocomplete' | 'disabled' | 'haspopup' | 'multiline' | 'readonly' | 'required'}`>;
|
|
7
|
+
export interface SelectTriggerProps extends Omit<TextFieldProps, 'active' | 'children' | 'defaultChecked' | 'suffix'> {
|
|
8
|
+
/**
|
|
9
|
+
* Controls the chevron icon layout.
|
|
10
|
+
*/
|
|
11
|
+
active?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* force hide suffixAction icons
|
|
14
|
+
*/
|
|
15
|
+
forceHideSuffixActionIcon?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Other props you may provide to input element.
|
|
18
|
+
*/
|
|
19
|
+
inputProps?: SelectTriggerInputProps;
|
|
20
|
+
/**
|
|
21
|
+
* The ref object for input element.
|
|
22
|
+
*/
|
|
23
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
24
|
+
/**
|
|
25
|
+
* Controls the layout of trigger.
|
|
26
|
+
*/
|
|
27
|
+
mode?: SelectMode;
|
|
28
|
+
/**
|
|
29
|
+
* The click handler for the cross icon on tags
|
|
30
|
+
*/
|
|
31
|
+
onTagClose?: (target: SelectValue) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the input is readonly.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
readOnly?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Provide if you have a customize value rendering logic.
|
|
39
|
+
* By default will have a comma between values.
|
|
40
|
+
*/
|
|
41
|
+
renderValue?: (value: SelectValue[]) => string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the input is required.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
required?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The value of selection.
|
|
49
|
+
* @default undefined
|
|
50
|
+
*/
|
|
51
|
+
value?: SelectValue[];
|
|
52
|
+
}
|
|
53
|
+
declare const SelectTrigger: import("react").ForwardRefExoticComponent<SelectTriggerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
54
|
+
export default SelectTrigger;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { selectClasses } from '@mezzanine-ui/core/select';
|
|
4
|
+
import { ChevronDownIcon } from '@mezzanine-ui/icons';
|
|
5
|
+
import Icon from '../Icon/Icon.js';
|
|
6
|
+
import TextField from '../TextField/TextField.js';
|
|
7
|
+
import Tag from '../Tag/Tag.js';
|
|
8
|
+
import cx from 'clsx';
|
|
9
|
+
|
|
10
|
+
const SelectTrigger = forwardRef(function SelectTrigger(props, ref) {
|
|
11
|
+
const { active, className, disabled, forceHideSuffixActionIcon, inputProps, inputRef, mode, onTagClose, readOnly, renderValue: renderValueProp, required, size, suffixActionIcon: suffixActionIconProp, value, ...restTextFieldProps } = props;
|
|
12
|
+
/** Render value to string for input */
|
|
13
|
+
const renderValue = () => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
return ((_b = (_a = renderValueProp === null || renderValueProp === void 0 ? void 0 : renderValueProp(value || [])) !== null && _a !== void 0 ? _a : value === null || value === void 0 ? void 0 : value.map((v) => v.name).join(', ')) !== null && _b !== void 0 ? _b : '');
|
|
16
|
+
};
|
|
17
|
+
/** Compute suffix action icon */
|
|
18
|
+
const suffixActionIcon = suffixActionIconProp || (jsx(Icon, { icon: ChevronDownIcon, className: cx(selectClasses.triggerSuffixActionIcon, {
|
|
19
|
+
[selectClasses.triggerSuffixActionIconActive]: active,
|
|
20
|
+
}) }, void 0));
|
|
21
|
+
return (jsx(TextField, Object.assign({ ref: ref }, restTextFieldProps, { active: !!(value === null || value === void 0 ? void 0 : value.length), className: cx(selectClasses.trigger, className), disabled: disabled, size: size, suffixActionIcon: forceHideSuffixActionIcon ? undefined : suffixActionIcon }, { children: mode === 'multiple' && (value === null || value === void 0 ? void 0 : value.length) ? (jsx("div", Object.assign({ className: selectClasses.triggerTags }, { children: value.map((selection) => (jsx(Tag, Object.assign({ closable: true, disabled: disabled, onClose: (e) => {
|
|
22
|
+
e.stopPropagation();
|
|
23
|
+
onTagClose === null || onTagClose === void 0 ? void 0 : onTagClose(selection);
|
|
24
|
+
}, size: size }, { children: selection.name }), selection.id))) }), void 0)) : (jsx("input", Object.assign({}, inputProps, { ref: inputRef, "aria-autocomplete": "list", "aria-disabled": disabled, "aria-haspopup": "listbox", "aria-readonly": readOnly, "aria-required": required, autoComplete: "false", disabled: disabled, readOnly: readOnly, required: required, type: "search", value: renderValue() }), void 0)) }), void 0));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default SelectTrigger;
|