@mezzanine-ui/react 1.0.0-beta.5 → 1.0.0-beta.7

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.
Files changed (199) hide show
  1. package/Accordion/Accordion.d.ts +23 -1
  2. package/Accordion/Accordion.js +59 -11
  3. package/Accordion/AccordionActions.d.ts +13 -0
  4. package/Accordion/AccordionActions.js +24 -0
  5. package/Accordion/AccordionContent.d.ts +9 -0
  6. package/Accordion/{AccordionDetails.js → AccordionContent.js} +4 -6
  7. package/Accordion/AccordionControlContext.d.ts +2 -2
  8. package/Accordion/AccordionGroup.d.ts +10 -0
  9. package/Accordion/AccordionGroup.js +26 -0
  10. package/Accordion/AccordionTitle.d.ts +14 -0
  11. package/Accordion/AccordionTitle.js +56 -0
  12. package/Accordion/index.d.ts +8 -4
  13. package/Accordion/index.js +4 -2
  14. package/AutoComplete/AutoComplete.d.ts +25 -6
  15. package/AutoComplete/AutoComplete.js +119 -30
  16. package/Backdrop/Backdrop.js +15 -19
  17. package/Breadcrumb/BreadcrumbDropdown.js +1 -1
  18. package/Breadcrumb/BreadcrumbItem.js +1 -1
  19. package/Breadcrumb/BreadcrumbOverflowMenuItem.js +1 -1
  20. package/Calendar/CalendarDays.js +1 -1
  21. package/Card/BaseCard.d.ts +11 -0
  22. package/Card/BaseCard.js +48 -0
  23. package/Card/BaseCardSkeleton.d.ts +14 -0
  24. package/Card/BaseCardSkeleton.js +18 -0
  25. package/Card/CardGroup.d.ts +47 -0
  26. package/Card/CardGroup.js +147 -0
  27. package/Card/FourThumbnailCard.d.ts +14 -0
  28. package/Card/FourThumbnailCard.js +73 -0
  29. package/Card/FourThumbnailCardSkeleton.d.ts +14 -0
  30. package/Card/FourThumbnailCardSkeleton.js +20 -0
  31. package/Card/QuickActionCard.d.ts +12 -0
  32. package/Card/QuickActionCard.js +23 -0
  33. package/Card/QuickActionCardSkeleton.d.ts +14 -0
  34. package/Card/QuickActionCardSkeleton.js +18 -0
  35. package/Card/SingleThumbnailCard.d.ts +13 -0
  36. package/Card/SingleThumbnailCard.js +44 -0
  37. package/Card/SingleThumbnailCardSkeleton.d.ts +19 -0
  38. package/Card/SingleThumbnailCardSkeleton.js +18 -0
  39. package/Card/Thumbnail.d.ts +12 -0
  40. package/Card/Thumbnail.js +18 -0
  41. package/Card/ThumbnailCardInfo.d.ts +34 -0
  42. package/Card/ThumbnailCardInfo.js +43 -0
  43. package/Card/index.d.ts +43 -4
  44. package/Card/index.js +19 -2
  45. package/Card/typings.d.ts +442 -0
  46. package/Checkbox/Checkbox.d.ts +8 -0
  47. package/Checkbox/Checkbox.js +3 -2
  48. package/Checkbox/CheckboxGroup.js +1 -1
  49. package/ContentHeader/ContentHeader.d.ts +22 -70
  50. package/ContentHeader/ContentHeader.js +1 -1
  51. package/ContentHeader/ContentHeaderResponsive.d.ts +9 -0
  52. package/ContentHeader/ContentHeaderResponsive.js +7 -0
  53. package/ContentHeader/utils.d.ts +3 -3
  54. package/ContentHeader/utils.js +66 -20
  55. package/Cropper/Cropper.d.ts +66 -0
  56. package/Cropper/Cropper.js +115 -0
  57. package/Cropper/CropperElement.d.ts +10 -0
  58. package/Cropper/CropperElement.js +892 -0
  59. package/Cropper/index.d.ts +18 -0
  60. package/Cropper/index.js +8 -0
  61. package/Cropper/tools.d.ts +90 -0
  62. package/Cropper/tools.js +143 -0
  63. package/Cropper/typings.d.ts +69 -0
  64. package/Cropper/utils/cropper-calculations.d.ts +39 -0
  65. package/Cropper/utils/cropper-calculations.js +95 -0
  66. package/DateTimePicker/DateTimePicker.d.ts +1 -1
  67. package/DateTimePicker/DateTimePicker.js +22 -5
  68. package/DateTimeRangePicker/DateTimeRangePicker.d.ts +34 -0
  69. package/DateTimeRangePicker/DateTimeRangePicker.js +118 -0
  70. package/DateTimeRangePicker/index.d.ts +2 -0
  71. package/DateTimeRangePicker/index.js +1 -0
  72. package/Drawer/Drawer.d.ts +132 -1
  73. package/Drawer/Drawer.js +47 -3
  74. package/Dropdown/Dropdown.d.ts +10 -4
  75. package/Dropdown/Dropdown.js +37 -42
  76. package/Dropdown/DropdownItem.d.ts +7 -1
  77. package/Dropdown/DropdownItem.js +36 -6
  78. package/Dropdown/DropdownItemCard.js +2 -1
  79. package/FloatingButton/FloatingButton.d.ts +21 -0
  80. package/FloatingButton/FloatingButton.js +18 -0
  81. package/FloatingButton/index.d.ts +2 -0
  82. package/FloatingButton/index.js +1 -0
  83. package/Form/FormField.d.ts +30 -7
  84. package/Form/FormField.js +12 -4
  85. package/Input/Input.js +12 -21
  86. package/Input/SelectButton/SelectButton.d.ts +25 -4
  87. package/Input/SelectButton/SelectButton.js +21 -9
  88. package/Message/Message.js +1 -1
  89. package/Modal/MediaPreviewModal.d.ts +11 -0
  90. package/Modal/MediaPreviewModal.js +24 -7
  91. package/Modal/Modal.d.ts +1 -1
  92. package/Modal/Modal.js +1 -1
  93. package/Modal/useModalContainer.js +6 -2
  94. package/MultipleDatePicker/MultipleDatePicker.d.ts +62 -0
  95. package/MultipleDatePicker/MultipleDatePicker.js +176 -0
  96. package/MultipleDatePicker/MultipleDatePickerTrigger.d.ts +56 -0
  97. package/MultipleDatePicker/MultipleDatePickerTrigger.js +92 -0
  98. package/MultipleDatePicker/index.d.ts +6 -0
  99. package/MultipleDatePicker/index.js +3 -0
  100. package/MultipleDatePicker/useMultipleDatePickerValue.d.ts +55 -0
  101. package/MultipleDatePicker/useMultipleDatePickerValue.js +68 -0
  102. package/Navigation/NavigationHeader.js +1 -1
  103. package/NotificationCenter/NotificationCenterDrawer.d.ts +10 -52
  104. package/NotificationCenter/NotificationCenterDrawer.js +128 -0
  105. package/NotificationCenter/index.d.ts +2 -0
  106. package/NotificationCenter/index.js +1 -0
  107. package/OverflowTooltip/index.d.ts +2 -2
  108. package/Picker/FormattedInput.d.ts +1 -1
  109. package/Picker/FormattedInput.js +2 -1
  110. package/Picker/PickerTriggerWithSeparator.d.ts +10 -0
  111. package/Picker/PickerTriggerWithSeparator.js +2 -2
  112. package/Picker/RangePickerTrigger.js +1 -1
  113. package/Picker/useDateInputFormatter.d.ts +6 -0
  114. package/Picker/useDateInputFormatter.js +4 -1
  115. package/Section/Section.d.ts +32 -0
  116. package/Section/Section.js +62 -0
  117. package/Section/index.d.ts +2 -0
  118. package/Select/Select.d.ts +11 -12
  119. package/Select/Select.js +13 -34
  120. package/Select/SelectTrigger.js +21 -7
  121. package/Select/index.d.ts +0 -4
  122. package/Select/index.js +0 -2
  123. package/Select/typings.d.ts +0 -4
  124. package/Select/useSelectTriggerTags.d.ts +1 -1
  125. package/Select/useSelectTriggerTags.js +9 -6
  126. package/Separator/Separator.d.ts +14 -0
  127. package/Separator/Separator.js +17 -0
  128. package/Separator/index.d.ts +2 -0
  129. package/Separator/index.js +1 -0
  130. package/Table/utils/useTableRowSelection.js +6 -0
  131. package/Tag/TagGroup.d.ts +4 -2
  132. package/Tag/TagGroup.js +7 -4
  133. package/TextField/TextField.d.ts +1 -1
  134. package/TextField/TextField.js +63 -9
  135. package/TimePanel/TimePanelColumn.js +30 -21
  136. package/TimeRangePicker/TimeRangePicker.d.ts +29 -0
  137. package/TimeRangePicker/TimeRangePicker.js +96 -0
  138. package/TimeRangePicker/index.d.ts +3 -0
  139. package/TimeRangePicker/index.js +2 -0
  140. package/TimeRangePicker/useTimeRangePickerValue.d.ts +30 -0
  141. package/TimeRangePicker/useTimeRangePickerValue.js +92 -0
  142. package/Transition/Rotate.js +2 -5
  143. package/index.d.ts +30 -28
  144. package/index.js +26 -27
  145. package/package.json +4 -4
  146. package/Accordion/AccordionDetails.d.ts +0 -9
  147. package/Accordion/AccordionSummary.d.ts +0 -18
  148. package/Accordion/AccordionSummary.js +0 -51
  149. package/Alert/Alert.d.ts +0 -20
  150. package/Alert/Alert.js +0 -18
  151. package/Alert/index.d.ts +0 -3
  152. package/Alert/index.js +0 -1
  153. package/AppBar/AppBar.d.ts +0 -14
  154. package/AppBar/AppBar.js +0 -33
  155. package/AppBar/AppBarBrand.d.ts +0 -4
  156. package/AppBar/AppBarBrand.js +0 -11
  157. package/AppBar/AppBarMain.d.ts +0 -4
  158. package/AppBar/AppBarMain.js +0 -11
  159. package/AppBar/AppBarSupport.d.ts +0 -4
  160. package/AppBar/AppBarSupport.js +0 -11
  161. package/AppBar/index.d.ts +0 -8
  162. package/AppBar/index.js +0 -4
  163. package/Card/Card.d.ts +0 -51
  164. package/Card/Card.js +0 -20
  165. package/Card/CardActions.d.ts +0 -34
  166. package/Card/CardActions.js +0 -15
  167. package/ConfirmActions/ConfirmActions.d.ts +0 -46
  168. package/ConfirmActions/ConfirmActions.js +0 -15
  169. package/ConfirmActions/index.d.ts +0 -2
  170. package/ConfirmActions/index.js +0 -1
  171. package/Popconfirm/Popconfirm.d.ts +0 -16
  172. package/Popconfirm/Popconfirm.js +0 -15
  173. package/Popconfirm/index.d.ts +0 -2
  174. package/Popconfirm/index.js +0 -1
  175. package/Popover/Popover.d.ts +0 -23
  176. package/Popover/Popover.js +0 -35
  177. package/Popover/index.d.ts +0 -2
  178. package/Popover/index.js +0 -1
  179. package/Select/Option.d.ts +0 -18
  180. package/Select/Option.js +0 -45
  181. package/Select/TreeSelect.d.ts +0 -67
  182. package/Select/TreeSelect.js +0 -198
  183. package/Tree/Tree.d.ts +0 -70
  184. package/Tree/Tree.js +0 -139
  185. package/Tree/TreeNode.d.ts +0 -40
  186. package/Tree/TreeNode.js +0 -50
  187. package/Tree/TreeNodeList.d.ts +0 -24
  188. package/Tree/TreeNodeList.js +0 -28
  189. package/Tree/getTreeNodeEntities.d.ts +0 -11
  190. package/Tree/getTreeNodeEntities.js +0 -92
  191. package/Tree/index.d.ts +0 -13
  192. package/Tree/index.js +0 -7
  193. package/Tree/toggleValue.d.ts +0 -4
  194. package/Tree/toggleValue.js +0 -19
  195. package/Tree/traverseTree.d.ts +0 -2
  196. package/Tree/traverseTree.js +0 -11
  197. package/Tree/typings.d.ts +0 -16
  198. package/Tree/useTreeExpandedValue.d.ts +0 -14
  199. package/Tree/useTreeExpandedValue.js +0 -33
package/Card/Card.d.ts DELETED
@@ -1,51 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
- import { TypographyProps } from '../Typography';
4
- export interface CardProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'title' | 'children'> {
5
- /**
6
- * Card footer actions.
7
- */
8
- actions?: ReactNode;
9
- /**
10
- * Card cover.
11
- */
12
- cover?: ReactNode;
13
- /**
14
- * The container of the text content(title, subtitle and description).
15
- */
16
- contentProps?: Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'>;
17
- /**
18
- * Description under the subtitle. visible if value is not empty.
19
- */
20
- description?: string;
21
- /**
22
- * Description props
23
- */
24
- descriptionProps?: Omit<TypographyProps, 'children'>;
25
- /**
26
- * The container of the content and actions.
27
- */
28
- metaProps?: Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'>;
29
- /**
30
- * Subtitle under the title. visible if value is not empty.
31
- */
32
- subtitle?: ReactNode;
33
- /**
34
- * Subtitle props
35
- */
36
- subtitleProps?: Omit<TypographyProps, 'children'>;
37
- /**
38
- * Card title, visible if value is not empty.
39
- */
40
- title?: ReactNode;
41
- /**
42
- * Card title props
43
- * @default 'variant: h3'
44
- */
45
- titleProps?: Omit<TypographyProps, 'children'>;
46
- }
47
- /**
48
- * The react component for `mezzanine` card.
49
- */
50
- declare const Card: import("react").ForwardRefExoticComponent<CardProps & import("react").RefAttributes<HTMLDivElement>>;
51
- export default Card;
package/Card/Card.js DELETED
@@ -1,20 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { cardClasses } from '@mezzanine-ui/core/card';
4
- import Typography from '../Typography/Typography.js';
5
- import cx from 'clsx';
6
-
7
- /**
8
- * The react component for `mezzanine` card.
9
- */
10
- const Card = forwardRef(function Card(props, ref) {
11
- const { actions, className, contentProps, cover, description, descriptionProps, metaProps, subtitle, subtitleProps, title, titleProps, ...rest } = props;
12
- const { variant = 'h3' } = titleProps || {};
13
- const titleTypography = title ? (jsx(Typography, { variant: variant, ...titleProps, children: title })) : null;
14
- const subtitleTypography = subtitle ? (jsx(Typography, { ...subtitleProps, children: subtitle })) : null;
15
- const contentHeader = titleTypography || subtitleTypography ? (jsxs("div", { className: cardClasses.metaContentsHeader, children: [titleTypography, subtitleTypography] })) : null;
16
- const descriptionTypography = description ? (jsx(Typography, { ...descriptionProps, children: description })) : null;
17
- return (jsxs("div", { ref: ref, className: cx(cardClasses.host, className), ...rest, children: [cover, jsxs("div", { className: cardClasses.meta, ...metaProps, children: [jsxs("div", { className: cardClasses.metaContents, ...contentProps, children: [contentHeader, descriptionTypography] }), actions] })] }));
18
- });
19
-
20
- export { Card as default };
@@ -1,34 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { ButtonProps } from '../Button';
3
- import { ConfirmActionsProps } from '../ConfirmActions';
4
- export interface CardActionsProps extends ConfirmActionsProps {
5
- /**
6
- * Content of cancel button. not render if value is empty.
7
- */
8
- cancelText?: string;
9
- /**
10
- * Content of confirm button. not render if value is empty.
11
- */
12
- confirmText?: string;
13
- /**
14
- * Click handler for cancel button.
15
- */
16
- onCancel?: ButtonProps['onClick'];
17
- /**
18
- * Click handler for confirm button.
19
- */
20
- onConfirm?: ButtonProps['onClick'];
21
- /**
22
- * Indicate whether confirm button loading and cancel button disabled.
23
- */
24
- loading?: boolean;
25
- /**
26
- * The action bottom on the left. not render if value is empty.
27
- */
28
- otherActions?: ReactNode;
29
- }
30
- /**
31
- * The react component for `mezzanine` cardActions.
32
- */
33
- declare const CardActions: import("react").ForwardRefExoticComponent<CardActionsProps & import("react").RefAttributes<HTMLDivElement>>;
34
- export default CardActions;
@@ -1,15 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { cardActionsClasses } from '@mezzanine-ui/core/card';
4
- import ConfirmActions from '../ConfirmActions/ConfirmActions.js';
5
- import cx from 'clsx';
6
-
7
- /**
8
- * The react component for `mezzanine` cardActions.
9
- */
10
- const CardActions = forwardRef(function CardActions(props, ref) {
11
- const { cancelText, cancelButtonProps, className, confirmText, confirmButtonProps, hideCancelButton, hideConfirmButton, loading, onCancel, onConfirm, otherActions, ...rest } = props;
12
- return (jsxs("div", { ref: ref, className: cx(cardActionsClasses.host, className), ...rest, children: [otherActions || jsx("div", {}), jsx(ConfirmActions, { cancelText: cancelText, confirmText: confirmText, cancelButtonProps: cancelButtonProps, confirmButtonProps: confirmButtonProps, hideCancelButton: hideCancelButton || !cancelText, hideConfirmButton: hideConfirmButton || !confirmText, loading: loading, onCancel: onCancel, onConfirm: onConfirm })] }));
13
- });
14
-
15
- export { CardActions as default };
@@ -1,46 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { ButtonProps } from '../Button/Button';
3
- import { ButtonGroupProps } from '../Button/ButtonGroup';
4
- export interface ConfirmActionsProps extends Omit<ButtonGroupProps, 'children'> {
5
- /**
6
- * Other props of cancel button.
7
- */
8
- cancelButtonProps?: ButtonProps;
9
- /**
10
- * Content of cancel button.
11
- */
12
- cancelText?: ReactNode;
13
- /**
14
- * Other props of confirm button.
15
- */
16
- confirmButtonProps?: ButtonProps;
17
- /**
18
- * Content of confirm button.
19
- */
20
- confirmText?: ReactNode;
21
- /**
22
- * Whether to hide cancel button.
23
- */
24
- hideCancelButton?: boolean;
25
- /**
26
- * Whether to hide confirm button.
27
- */
28
- hideConfirmButton?: boolean;
29
- /**
30
- * Indicate whether confirm button loading and cancel button disabled.
31
- */
32
- loading?: boolean;
33
- /**
34
- * Click handler for cancel button.
35
- */
36
- onCancel?: ButtonProps['onClick'];
37
- /**
38
- * Click handler for confirm button.
39
- */
40
- onConfirm?: ButtonProps['onClick'];
41
- }
42
- /**
43
- * The react component for `mezzanine` confirm actions.
44
- */
45
- declare const ConfirmActions: import("react").ForwardRefExoticComponent<ConfirmActionsProps & import("react").RefAttributes<HTMLDivElement>>;
46
- export default ConfirmActions;
@@ -1,15 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import Button from '../Button/Button.js';
4
- import ButtonGroup from '../Button/ButtonGroup.js';
5
-
6
- /**
7
- * The react component for `mezzanine` confirm actions.
8
- */
9
- const ConfirmActions = forwardRef(function ConfirmActions(props, ref) {
10
- const { cancelButtonProps, cancelText, confirmButtonProps, confirmText, hideCancelButton, hideConfirmButton, loading, onCancel, onConfirm, ...rest } = props;
11
- const { disabled: cancelButtonDisabled = loading } = cancelButtonProps || {};
12
- return (jsxs(ButtonGroup, { ...rest, ref: ref, children: [!hideCancelButton && (jsx(Button, { variant: "outlined", ...cancelButtonProps, disabled: cancelButtonDisabled, onClick: onCancel, children: cancelText })), !hideConfirmButton && (jsx(Button, { variant: "contained", ...confirmButtonProps, loading: loading, onClick: onConfirm, children: confirmText }))] }));
13
- });
14
-
15
- export { ConfirmActions as default };
@@ -1,2 +0,0 @@
1
- export { default } from './ConfirmActions';
2
- export type { ConfirmActionsProps } from './ConfirmActions';
@@ -1 +0,0 @@
1
- export { default } from './ConfirmActions.js';
@@ -1,16 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { IconDefinition } from '@mezzanine-ui/icons';
3
- import { PopoverProps } from '../Popover';
4
- import { ConfirmActionsProps } from '../ConfirmActions';
5
- export interface PopconfirmProps extends PopoverProps, Pick<ConfirmActionsProps, 'cancelButtonProps' | 'cancelText' | 'confirmButtonProps' | 'confirmText' | 'onCancel' | 'onConfirm'> {
6
- /**
7
- * Customize the icon on the popconfirm
8
- */
9
- icon?: IconDefinition;
10
- /**
11
- * the title of the confirmation box
12
- */
13
- title?: ReactNode;
14
- }
15
- declare const Popconfirm: import("react").ForwardRefExoticComponent<PopconfirmProps & import("react").RefAttributes<HTMLDivElement>>;
16
- export default Popconfirm;
@@ -1,15 +0,0 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { ExclamationCircleFilledIcon } from '@mezzanine-ui/icons';
4
- import { popConfirmClasses } from '@mezzanine-ui/core/popconfirm';
5
- import Popover from '../Popover/Popover.js';
6
- import ConfirmActions from '../ConfirmActions/ConfirmActions.js';
7
- import Icon from '../Icon/Icon.js';
8
- import cx from 'clsx';
9
-
10
- const Popconfirm = forwardRef(function Popconfirm(props, ref) {
11
- const { className, cancelButtonProps, cancelText, confirmButtonProps, confirmText, icon = ExclamationCircleFilledIcon, onCancel, onConfirm, title, ...rest } = props;
12
- return (jsx(Popover, { ...rest, ref: ref, className: cx(popConfirmClasses.host, className), title: jsxs(Fragment, { children: [jsx(Icon, { className: popConfirmClasses.icon, icon: icon }), title] }), children: jsx(ConfirmActions, { cancelButtonProps: cancelButtonProps, cancelText: cancelText, confirmButtonProps: confirmButtonProps, confirmText: confirmText, onCancel: onCancel, onConfirm: onConfirm, size: "small" }) }));
13
- });
14
-
15
- export { Popconfirm as default };
@@ -1,2 +0,0 @@
1
- export type { PopconfirmProps } from './Popconfirm';
2
- export { default } from './Popconfirm';
@@ -1 +0,0 @@
1
- export { default } from './Popconfirm.js';
@@ -1,23 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { PopperProps } from '../Popper';
3
- import { ClickAwayEvent } from '../hooks/useClickAway';
4
- export interface PopoverProps extends Omit<PopperProps, 'title'> {
5
- /**
6
- * Whether to disable triggering onClose while clicked away.
7
- * @default false
8
- */
9
- disableClickAway?: boolean;
10
- /**
11
- * The handler fired while clicked away.
12
- */
13
- onClose?: (event: ClickAwayEvent) => void;
14
- /**
15
- * the title of popover
16
- */
17
- title?: ReactNode;
18
- }
19
- /**
20
- * The react component for `mezzanine` popover.
21
- */
22
- declare const Popover: import("react").ForwardRefExoticComponent<PopoverProps & import("react").RefAttributes<HTMLDivElement>>;
23
- export default Popover;
@@ -1,35 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useRef } from 'react';
3
- import { popoverClasses } from '@mezzanine-ui/core/popover';
4
- import { offset } from '@floating-ui/react-dom';
5
- import { useClickAway } from '../hooks/useClickAway.js';
6
- import { useComposeRefs } from '../hooks/useComposeRefs.js';
7
- import Popper from '../Popper/Popper.js';
8
- import cx from 'clsx';
9
-
10
- const offsetMiddleware = offset({ mainAxis: 8 });
11
- /**
12
- * The react component for `mezzanine` popover.
13
- */
14
- const Popover = forwardRef(function Popover(props, ref) {
15
- const { children, className, disableClickAway = false, onClose, open, options = {}, title, ...rest } = props;
16
- const { middleware = [] } = options;
17
- const popoverRef = useRef(null);
18
- const composedRef = useComposeRefs([ref, popoverRef]);
19
- useClickAway(() => {
20
- if (!open || disableClickAway || !onClose) {
21
- return;
22
- }
23
- return (event) => {
24
- if (onClose) {
25
- onClose(event);
26
- }
27
- };
28
- }, popoverRef, [open, disableClickAway, onClose, popoverRef]);
29
- return (jsxs(Popper, { ...rest, ref: composedRef, className: cx(popoverClasses.host, className), open: open, options: {
30
- ...options,
31
- middleware: [offsetMiddleware, ...middleware],
32
- }, children: [title && jsx("div", { className: popoverClasses.title, children: title }), children && jsx("div", { className: popoverClasses.content, children: children })] }));
33
- });
34
-
35
- export { Popover as default };
@@ -1,2 +0,0 @@
1
- export type { PopoverProps } from './Popover';
2
- export { default } from './Popover';
package/Popover/index.js DELETED
@@ -1 +0,0 @@
1
- export { default } from './Popover.js';
@@ -1,18 +0,0 @@
1
- import { MenuItemProps } from '../Menu';
2
- export interface OptionProps extends Omit<MenuItemProps, 'children' | 'role'> {
3
- /**
4
- * option children (often means the option name)
5
- */
6
- children: string;
7
- /**
8
- * The role of menu item.
9
- * @default 'option'
10
- */
11
- role?: string;
12
- /**
13
- * The value of option
14
- */
15
- value: string;
16
- }
17
- declare const Option: import("react").ForwardRefExoticComponent<OptionProps & import("react").RefAttributes<HTMLLIElement>>;
18
- export default Option;
package/Select/Option.js DELETED
@@ -1,45 +0,0 @@
1
- 'use client';
2
- import { jsx } from 'react/jsx-runtime';
3
- import { forwardRef, useContext } from 'react';
4
- import { SelectControlContext } from './SelectControlContext.js';
5
- import MenuItem from '../Menu/MenuItem.js';
6
-
7
- const Option = forwardRef(function Option(props, ref) {
8
- const { active: activeProp, children, role = 'option', value, ...rest } = props;
9
- const selectControl = useContext(SelectControlContext);
10
- const { onChange, value: selectedValue } = selectControl || {};
11
- const getActive = () => {
12
- if (activeProp) {
13
- return activeProp;
14
- }
15
- if (selectedValue) {
16
- if (Array.isArray(selectedValue)) {
17
- return selectedValue.find((sv) => sv.id === value);
18
- }
19
- return selectedValue.id === value;
20
- }
21
- return false;
22
- };
23
- const active = Boolean(getActive());
24
- const onSelect = () => {
25
- if (typeof onChange === 'function' && value) {
26
- onChange({
27
- id: value,
28
- name: children,
29
- });
30
- }
31
- };
32
- const onKeyDown = (evt) => {
33
- switch (evt.code) {
34
- case 'Enter':
35
- onSelect();
36
- break;
37
- }
38
- };
39
- return (jsx(MenuItem, { ...rest, ref: ref, active: active, "aria-selected": active, id: value, onClick: (evt) => {
40
- evt.stopPropagation();
41
- onSelect();
42
- }, onKeyDown: onKeyDown, role: role, tabIndex: 0, children: children }));
43
- });
44
-
45
- export { Option as default };
@@ -1,67 +0,0 @@
1
- import { SelectInputSize } from '@mezzanine-ui/core/select';
2
- import { FormElementFocusHandlers } from '../Form';
3
- import { MenuProps } from '../Menu';
4
- import { PickRenameMulti } from '../utils/general';
5
- import { InputTriggerPopperProps } from '../_internal/InputTriggerPopper';
6
- import { SelectTriggerProps, SelectTriggerInputProps } from './SelectTrigger';
7
- import { SelectValue, TreeSelectOption } from './typings';
8
- import { TreeProps } from '../Tree';
9
- export interface TreeSelectProps extends Omit<SelectTriggerProps, 'active' | 'onBlur' | 'onChange' | 'onClear' | 'onClick' | 'onFocus' | 'onKeyDown' | 'readOnly' | 'searchInputProps'>, FormElementFocusHandlers, Pick<TreeProps, 'defaultExpandAll' | 'disabledValues' | 'expandControllerRef' | 'onExpand'>, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
10
- maxHeight: 'menuMaxHeight';
11
- role: 'menuRole';
12
- size: 'menuSize';
13
- }>, PickRenameMulti<Pick<InputTriggerPopperProps, 'options'>, {
14
- options: 'popperOptions';
15
- }> {
16
- /**
17
- * The width of options panel will be calculated based on the depth of your options.
18
- * If you know how many layers in your object, pass it via this prop will have better performance.
19
- */
20
- depth?: number;
21
- /**
22
- * The other native props for input element.
23
- */
24
- inputProps?: Omit<SelectTriggerInputProps, 'onBlur' | 'onChange' | 'onFocus' | 'placeholder' | 'role' | 'value' | `aria-${'expanded'}`>;
25
- /**
26
- * Other props you may provide to `Menu`.
27
- */
28
- menuProps?: Omit<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>;
29
- /**
30
- * The change event handler of input element.
31
- */
32
- onChange?(newOptions: SelectValue[]): any;
33
- /**
34
- * The nested options for `TreeSelect`
35
- */
36
- options: TreeSelectOption[];
37
- /**
38
- * select input placeholder
39
- */
40
- placeholder?: string;
41
- /**
42
- * Whether the selection is required.
43
- * @default false
44
- */
45
- required?: boolean;
46
- /**
47
- * If true, the panel will have its min-width be same as the trigger width.
48
- * @default false
49
- */
50
- sameWidth?: InputTriggerPopperProps['sameWidth'];
51
- /**
52
- * The size of input.
53
- * @default 'medium'
54
- */
55
- size?: SelectInputSize;
56
- /**
57
- * Other props you may provide to `Tree`
58
- */
59
- treeProps?: Omit<TreeProps, 'defaultExpandAll' | 'disabledValues' | 'expandControllerRef' | 'expandedValues' | 'nodes' | 'onExpand' | 'onSelect' | 'selectMethod' | 'selectable' | 'values'>;
60
- /**
61
- * The value of selection.
62
- * @default undefined
63
- */
64
- value?: SelectValue[];
65
- }
66
- declare const TreeSelect: import("react").ForwardRefExoticComponent<Omit<TreeSelectProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
67
- export default TreeSelect;
@@ -1,198 +0,0 @@
1
- 'use client';
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { forwardRef, useContext, useMemo, useRef, useState } from 'react';
4
- import { selectClasses } from '@mezzanine-ui/core/select';
5
- import { useComposeRefs } from '../hooks/useComposeRefs.js';
6
- import { useClickAway } from '../hooks/useClickAway.js';
7
- import SelectTrigger from './SelectTrigger.js';
8
- import { useIsomorphicLayoutEffect } from '../hooks/useIsomorphicLayoutEffect.js';
9
- import { FormControlContext } from '../Form/FormControlContext.js';
10
- import { traverseTree } from '../Tree/traverseTree.js';
11
- import InputTriggerPopper from '../_internal/InputTriggerPopper/InputTriggerPopper.js';
12
- import Menu from '../Menu/Menu.js';
13
- import Tree from '../Tree/Tree.js';
14
- import { toggleValue } from '../Tree/toggleValue.js';
15
- import cx from 'clsx';
16
-
17
- const TreeSelect = forwardRef((props, ref) => {
18
- const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
19
- 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, mode = 'single', onBlur, onChange: onChangeProp, onExpand: onExpandProp, onFocus, options, placeholder = '', popperOptions, prefix, renderValue, required = requiredFromFormControl || false, sameWidth = false, size, suffixActionIcon, treeProps, value: valueProp, } = props;
20
- const { className: treeClassName, ...restTreeProps } = treeProps || {};
21
- const { width, border, ...restStyle } = (menuProps === null || menuProps === void 0 ? void 0 : menuProps.style) || {};
22
- const multiple = mode === 'multiple';
23
- /** Compute panel width */
24
- const panelWidth = useMemo(() => {
25
- if (width) {
26
- return;
27
- }
28
- const base = multiple ? 224 : 208;
29
- const indent = 16;
30
- function getWidth(resultDepth) {
31
- return (resultDepth - 1) * indent + base;
32
- }
33
- if (depth) {
34
- return getWidth(depth);
35
- }
36
- function maxDepth(object, counter = 1) {
37
- if (object.siblings) {
38
- return Math.max(...object.siblings.map((sibling) => maxDepth(sibling, counter + 1)));
39
- }
40
- return counter;
41
- }
42
- const computedMaxDepth = options.reduce((acc, current) => {
43
- const currentDepth = maxDepth(current);
44
- return currentDepth > acc ? currentDepth : acc;
45
- }, 0);
46
- return getWidth(computedMaxDepth);
47
- }, [depth, multiple, options, width]);
48
- /** Popper positioning */
49
- const nodeRef = useRef(null);
50
- const controlRef = useRef(null);
51
- const popperRef = useRef(null);
52
- const composedRef = useComposeRefs([ref, controlRef]);
53
- /** Make popper positioning dynamically by computing styles every time value prop changes */
54
- const controllerRef = useRef(null);
55
- useIsomorphicLayoutEffect(() => {
56
- var _a, _b;
57
- (_b = (_a = controllerRef.current) === null || _a === void 0 ? void 0 : _a.forceUpdate) === null || _b === void 0 ? void 0 : _b.call(_a);
58
- }, [valueProp]);
59
- /** Open control */
60
- const [open, toggleOpen] = useState(false);
61
- const onOpen = () => {
62
- onFocus === null || onFocus === void 0 ? void 0 : onFocus();
63
- toggleOpen(true);
64
- };
65
- const onClose = () => {
66
- onBlur === null || onBlur === void 0 ? void 0 : onBlur();
67
- toggleOpen(false);
68
- };
69
- const onToggleOpen = () => {
70
- if (open) {
71
- onClose();
72
- }
73
- else {
74
- onOpen();
75
- }
76
- };
77
- const onTextFieldClick = disabled
78
- ? undefined
79
- : () => {
80
- onToggleOpen();
81
- };
82
- const onTextFieldKeydown = disabled
83
- ? undefined
84
- : (event) => {
85
- switch (event.code) {
86
- case 'Enter':
87
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
88
- onTextFieldClick();
89
- break;
90
- case 'ArrowUp':
91
- case 'ArrowRight':
92
- case 'ArrowLeft':
93
- case 'ArrowDown': {
94
- if (!open) {
95
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
96
- onTextFieldClick();
97
- }
98
- break;
99
- }
100
- case 'Tab': {
101
- if (open) {
102
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
103
- onTextFieldClick();
104
- }
105
- break;
106
- }
107
- }
108
- };
109
- useClickAway(() => {
110
- if (!open)
111
- return;
112
- return (event) => {
113
- var _a;
114
- if (!((_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) {
115
- onClose();
116
- }
117
- };
118
- }, controlRef, [open, toggleOpen]);
119
- /** Trigger input props */
120
- const resolvedInputProps = {
121
- ...inputProps,
122
- 'aria-expanded': open,
123
- placeholder,
124
- role: 'combobox',
125
- };
126
- /** Tags close handler */
127
- const onTagClose = onChangeProp && valueProp
128
- ? (target) => {
129
- onChangeProp(valueProp.filter((v) => v.id !== target.id));
130
- }
131
- : undefined;
132
- /** Clear method */
133
- const onClear = clearable && onChangeProp
134
- ? () => {
135
- onChangeProp([]);
136
- }
137
- : undefined;
138
- /** Map options to tree nodes */
139
- function mapOptionToNode(option) {
140
- var _a;
141
- return {
142
- label: option.name,
143
- value: option.id,
144
- dynamicNodesFetching: option.dynamicChildrenFetching,
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
- onExpandProp === null || onExpandProp === void 0 ? void 0 : onExpandProp(value);
190
- };
191
- return (jsxs("div", { 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 }), jsx(InputTriggerPopper, { ref: popperRef, anchor: controlRef, className: selectClasses.popper, controllerRef: controllerRef, open: open, options: popperOptions, sameWidth: sameWidth, children: jsx(Menu, { itemsInView: itemsInView, maxHeight: menuMaxHeight, role: menuRole, size: menuSize, style: {
192
- ...restStyle,
193
- border: border || 0,
194
- width: width || `${panelWidth}px`,
195
- }, children: jsx(Tree, { ...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 }) }) })] }));
196
- });
197
-
198
- export { TreeSelect as default };