@mezzanine-ui/react 1.0.0-beta.2 → 1.0.0-beta.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.
Files changed (193) hide show
  1. package/Anchor/Anchor.d.ts +51 -18
  2. package/Anchor/Anchor.js +15 -15
  3. package/Anchor/AnchorGroup.d.ts +34 -0
  4. package/Anchor/AnchorGroup.js +37 -0
  5. package/Anchor/AnchorItem.d.ts +30 -0
  6. package/Anchor/AnchorItem.js +65 -0
  7. package/Anchor/index.d.ts +2 -0
  8. package/Anchor/index.js +1 -0
  9. package/Anchor/utils.d.ts +13 -0
  10. package/Anchor/utils.js +95 -0
  11. package/AutoComplete/AutoComplete.d.ts +217 -0
  12. package/AutoComplete/AutoComplete.js +433 -0
  13. package/AutoComplete/index.d.ts +2 -0
  14. package/AutoComplete/index.js +1 -0
  15. package/AutoComplete/useAutoCompleteCreation.d.ts +33 -0
  16. package/AutoComplete/useAutoCompleteCreation.js +201 -0
  17. package/AutoComplete/useAutoCompleteKeyboard.d.ts +31 -0
  18. package/AutoComplete/useAutoCompleteKeyboard.js +149 -0
  19. package/AutoComplete/useAutoCompleteSearch.d.ts +16 -0
  20. package/AutoComplete/useAutoCompleteSearch.js +69 -0
  21. package/AutoComplete/useCreationTracker.d.ts +17 -0
  22. package/AutoComplete/useCreationTracker.js +47 -0
  23. package/Breadcrumb/Breadcrumb.js +16 -21
  24. package/Breadcrumb/BreadcrumbDropdown.d.ts +11 -0
  25. package/Breadcrumb/BreadcrumbDropdown.js +22 -0
  26. package/Breadcrumb/BreadcrumbItem.d.ts +2 -3
  27. package/Breadcrumb/BreadcrumbItem.js +13 -31
  28. package/Breadcrumb/BreadcrumbOverflowMenu.d.ts +7 -0
  29. package/Breadcrumb/BreadcrumbOverflowMenu.js +77 -0
  30. package/Breadcrumb/BreadcrumbOverflowMenuDropdown.d.ts +11 -0
  31. package/Breadcrumb/BreadcrumbOverflowMenuDropdown.js +21 -0
  32. package/Breadcrumb/BreadcrumbOverflowMenuItem.d.ts +3 -0
  33. package/Breadcrumb/BreadcrumbOverflowMenuItem.js +27 -0
  34. package/Breadcrumb/typings.d.ts +21 -39
  35. package/Button/Button.js +13 -11
  36. package/Button/index.d.ts +1 -1
  37. package/Button/typings.d.ts +27 -4
  38. package/Checkbox/index.d.ts +4 -5
  39. package/Checkbox/index.js +1 -5
  40. package/ContentHeader/ContentHeader.d.ts +160 -0
  41. package/ContentHeader/ContentHeader.js +54 -0
  42. package/ContentHeader/index.d.ts +2 -0
  43. package/ContentHeader/index.js +1 -0
  44. package/ContentHeader/utils.d.ts +23 -0
  45. package/ContentHeader/utils.js +215 -0
  46. package/Description/Description.d.ts +12 -22
  47. package/Description/Description.js +4 -24
  48. package/Dropdown/Dropdown.d.ts +46 -1
  49. package/Dropdown/Dropdown.js +99 -14
  50. package/Dropdown/DropdownAction.d.ts +1 -1
  51. package/Dropdown/DropdownAction.js +1 -4
  52. package/Dropdown/DropdownItem.d.ts +28 -1
  53. package/Dropdown/DropdownItem.js +56 -14
  54. package/Dropdown/DropdownItemCard.d.ts +2 -2
  55. package/Dropdown/DropdownItemCard.js +20 -16
  56. package/Dropdown/DropdownStatus.js +29 -0
  57. package/Dropdown/dropdownKeydownHandler.d.ts +2 -1
  58. package/Dropdown/dropdownKeydownHandler.js +73 -0
  59. package/Dropdown/highlightText.js +5 -1
  60. package/Dropdown/shortcutTextHandler.d.ts +24 -0
  61. package/Dropdown/shortcutTextHandler.js +171 -0
  62. package/Empty/Empty.js +2 -1
  63. package/Empty/icons/EmptyMainNotificationIcon.d.ts +4 -0
  64. package/Empty/icons/EmptyMainNotificationIcon.js +9 -0
  65. package/Empty/typings.d.ts +2 -2
  66. package/FilterArea/Filter.d.ts +32 -0
  67. package/FilterArea/Filter.js +23 -0
  68. package/FilterArea/FilterArea.d.ts +58 -0
  69. package/FilterArea/FilterArea.js +31 -0
  70. package/FilterArea/FilterLine.d.ts +11 -0
  71. package/FilterArea/FilterLine.js +13 -0
  72. package/FilterArea/index.d.ts +6 -0
  73. package/FilterArea/index.js +3 -0
  74. package/Form/FormField.js +3 -1
  75. package/Input/Input.d.ts +35 -7
  76. package/Input/Input.js +48 -14
  77. package/Input/index.d.ts +1 -1
  78. package/Modal/MediaPreviewModal.d.ts +54 -0
  79. package/Modal/MediaPreviewModal.js +158 -0
  80. package/Modal/Modal.d.ts +103 -11
  81. package/Modal/Modal.js +14 -9
  82. package/Modal/ModalBodyForVerification.d.ts +59 -0
  83. package/Modal/ModalBodyForVerification.js +99 -0
  84. package/Modal/ModalControl.d.ts +2 -2
  85. package/Modal/ModalControl.js +1 -1
  86. package/Modal/ModalFooter.d.ts +119 -1
  87. package/Modal/ModalFooter.js +15 -3
  88. package/Modal/ModalHeader.d.ts +26 -7
  89. package/Modal/ModalHeader.js +33 -7
  90. package/Modal/index.d.ts +6 -5
  91. package/Modal/index.js +2 -2
  92. package/Modal/useModalContainer.d.ts +12 -3
  93. package/Modal/useModalContainer.js +28 -6
  94. package/Navigation/Navigation.d.ts +7 -2
  95. package/Navigation/Navigation.js +36 -35
  96. package/Navigation/NavigationHeader.d.ts +4 -0
  97. package/Navigation/NavigationHeader.js +3 -2
  98. package/Navigation/NavigationOption.d.ts +8 -3
  99. package/Navigation/NavigationOption.js +46 -11
  100. package/Navigation/NavigationOptionCategory.js +1 -0
  101. package/Navigation/NavigationOverflowMenu.d.ts +6 -0
  102. package/Navigation/NavigationOverflowMenu.js +90 -0
  103. package/Navigation/NavigationOverflowMenuOption.d.ts +7 -0
  104. package/Navigation/NavigationOverflowMenuOption.js +68 -0
  105. package/Navigation/NavigationUserMenu.d.ts +4 -2
  106. package/Navigation/NavigationUserMenu.js +13 -5
  107. package/Navigation/context.d.ts +3 -2
  108. package/Navigation/useVisibleItems.d.ts +5 -0
  109. package/Navigation/useVisibleItems.js +54 -0
  110. package/NotificationCenter/NotificationCenter.d.ts +124 -0
  111. package/NotificationCenter/NotificationCenter.js +279 -0
  112. package/NotificationCenter/NotificationCenterDrawer.d.ts +109 -0
  113. package/NotificationCenter/index.d.ts +3 -0
  114. package/NotificationCenter/index.js +1 -0
  115. package/PageFooter/PageFooter.d.ts +19 -9
  116. package/PageFooter/PageFooter.js +10 -10
  117. package/PageHeader/PageHeader.d.ts +32 -25
  118. package/PageHeader/PageHeader.js +49 -43
  119. package/ResultState/ResultState.d.ts +9 -0
  120. package/ResultState/ResultState.js +36 -4
  121. package/Scrollbar/Scrollbar.d.ts +9 -0
  122. package/Scrollbar/Scrollbar.js +78 -0
  123. package/Scrollbar/index.d.ts +2 -0
  124. package/Scrollbar/index.js +1 -0
  125. package/Scrollbar/typings.d.ts +47 -0
  126. package/Select/SelectTrigger.js +5 -4
  127. package/Select/index.d.ts +0 -2
  128. package/Select/index.js +0 -1
  129. package/Select/typings.d.ts +6 -1
  130. package/Selection/Selection.js +1 -1
  131. package/Selection/SelectionGroup.d.ts +28 -0
  132. package/Slider/useSlider.js +1 -1
  133. package/Table/Table.d.ts +2 -120
  134. package/Table/Table.js +148 -53
  135. package/Table/TableContext.d.ts +11 -12
  136. package/Table/components/TableActionsCell.js +12 -4
  137. package/Table/components/TableBody.js +2 -1
  138. package/Table/components/TableBulkActions.js +1 -19
  139. package/Table/components/TableColGroup.d.ts +1 -4
  140. package/Table/components/TableColGroup.js +15 -16
  141. package/Table/components/TableCollectableCell.d.ts +17 -0
  142. package/Table/components/TableCollectableCell.js +54 -0
  143. package/Table/components/TableDragOrPinHandleCell.d.ts +20 -0
  144. package/Table/components/TableDragOrPinHandleCell.js +58 -0
  145. package/Table/components/TableExpandedRow.js +11 -2
  146. package/Table/components/TableHeader.js +12 -10
  147. package/Table/components/TableRow.js +38 -13
  148. package/Table/components/TableSelectionCell.js +1 -1
  149. package/Table/components/TableToggleableCell.d.ts +16 -0
  150. package/Table/components/TableToggleableCell.js +51 -0
  151. package/Table/components/index.d.ts +4 -1
  152. package/Table/components/index.js +3 -0
  153. package/Table/hooks/typings.d.ts +18 -4
  154. package/Table/hooks/useTableExpansion.d.ts +2 -2
  155. package/Table/hooks/useTableExpansion.js +5 -5
  156. package/Table/hooks/useTableFixedOffsets.d.ts +6 -2
  157. package/Table/hooks/useTableFixedOffsets.js +60 -26
  158. package/Table/hooks/useTableScroll.d.ts +9 -3
  159. package/Table/hooks/useTableScroll.js +34 -7
  160. package/Table/hooks/useTableVirtualization.d.ts +2 -1
  161. package/Table/hooks/useTableVirtualization.js +2 -8
  162. package/Table/index.d.ts +4 -3
  163. package/Table/index.js +3 -0
  164. package/Table/typings.d.ts +172 -0
  165. package/Table/utils/useTableRowSelection.js +13 -5
  166. package/Tag/TagGroup.d.ts +3 -0
  167. package/Tag/index.d.ts +2 -0
  168. package/Tag/index.js +1 -0
  169. package/Transition/Slide.d.ts +9 -2
  170. package/Transition/Slide.js +7 -4
  171. package/Tree/TreeNode.js +1 -1
  172. package/Upload/UploadPictureCard.js +1 -1
  173. package/index.d.ts +37 -21
  174. package/index.js +25 -11
  175. package/package.json +6 -4
  176. package/Modal/ModalActions.d.ts +0 -9
  177. package/Modal/ModalActions.js +0 -20
  178. package/Modal/ModalBody.d.ts +0 -7
  179. package/Modal/ModalBody.js +0 -14
  180. package/Notification/Notification.d.ts +0 -54
  181. package/Notification/Notification.js +0 -76
  182. package/Notification/index.d.ts +0 -3
  183. package/Notification/index.js +0 -1
  184. package/PageToolbar/PageToolbar.d.ts +0 -114
  185. package/PageToolbar/PageToolbar.js +0 -23
  186. package/PageToolbar/index.d.ts +0 -2
  187. package/PageToolbar/index.js +0 -1
  188. package/PageToolbar/utils.d.ts +0 -23
  189. package/PageToolbar/utils.js +0 -165
  190. package/Select/AutoComplete.d.ts +0 -107
  191. package/Select/AutoComplete.js +0 -114
  192. package/Table/components/TableDragHandleCell.d.ts +0 -11
  193. package/Table/components/TableDragHandleCell.js +0 -44
@@ -1,114 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { ButtonProps } from '../Button';
3
- import { SearchInputProps } from '../Input';
4
- import { SelectProps } from '../Select';
5
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
6
- import { IconDefinition } from '@mezzanine-ui/icons';
7
- type SegmentedControlProps = {
8
- mock: 'SegmentedControlProps';
9
- };
10
- type PageToolbarChild = ReactElement<SearchInputProps | SelectProps | SegmentedControlProps | ButtonProps> | null | false | undefined;
11
- /**
12
- * Props for the PageToolbar component.
13
- *
14
- * PageToolbar provides a flexible toolbar layout for page-level actions,
15
- * including filter components, action buttons, and utility buttons.
16
- *
17
- * @example
18
- * ```tsx
19
- * <PageToolbar
20
- * size="main"
21
- * filter={{ variant: 'search', placeholder: 'Search...' }}
22
- * actions={{
23
- * primaryButton: { children: 'Save' },
24
- * secondaryButton: { children: 'Cancel' },
25
- * }}
26
- * utilities={[{ icon: { src: settingsIcon }, title: 'Settings' }]}
27
- * />
28
- * ```
29
- */
30
- export type PageToolbarProps = Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> & {
31
- /**
32
- * Button configuration for primary, secondary, and destructive actions. <br />
33
- * Automatically applies proper styling and order. <br />
34
- */
35
- actions?: {
36
- destructiveButton?: ButtonProps;
37
- primaryButton?: ButtonProps;
38
- secondaryButton?: ButtonProps;
39
- };
40
- /**
41
- * Children elements: <br />
42
- * - Filter component (SearchInput, Select, or SegmentedControl) <br />
43
- * - Action buttons `<Button />` <br />
44
- * - Icon-only utility buttons `<Button icon="..." />` <br />
45
- * <br />
46
- * Can mix and match the above children. <br />
47
- * The order of children does not matter as they will be arranged properly. <br />
48
- * When conflicting with other props, props take priority over children. <br />
49
- */
50
- children?: PageToolbarChild[] | PageToolbarChild;
51
- /** Filter component (SearchInput, Select, or SegmentedControl) */
52
- filter?: {
53
- variant: 'search' | 'select' | 'segmentedControl';
54
- } & (SearchInputProps | SelectProps | SegmentedControlProps);
55
- /**
56
- * Size variant of the toolbar. <br />
57
- * Affects the size of buttons and filter component. <br />
58
- */
59
- size?: 'main' | 'sub';
60
- /**
61
- * Icon-only utility buttons `<Button icon="..." />`. <br />
62
- * They usually appear as smaller buttons with only an icon and no text.
63
- */
64
- utilities?: (ButtonProps & {
65
- icon: {
66
- src: IconDefinition;
67
- };
68
- })[];
69
- };
70
- /**
71
- * PageToolbar component provides a flexible toolbar with filter, action buttons, and utility icons.
72
- * Commonly used in page headers for primary user actions.
73
- */
74
- declare const PageToolbar: import("react").ForwardRefExoticComponent<Omit<NativeElementPropsWithoutKeyAndRef<"div">, "children"> & {
75
- /**
76
- * Button configuration for primary, secondary, and destructive actions. <br />
77
- * Automatically applies proper styling and order. <br />
78
- */
79
- actions?: {
80
- destructiveButton?: ButtonProps;
81
- primaryButton?: ButtonProps;
82
- secondaryButton?: ButtonProps;
83
- };
84
- /**
85
- * Children elements: <br />
86
- * - Filter component (SearchInput, Select, or SegmentedControl) <br />
87
- * - Action buttons `<Button />` <br />
88
- * - Icon-only utility buttons `<Button icon="..." />` <br />
89
- * <br />
90
- * Can mix and match the above children. <br />
91
- * The order of children does not matter as they will be arranged properly. <br />
92
- * When conflicting with other props, props take priority over children. <br />
93
- */
94
- children?: PageToolbarChild[] | PageToolbarChild;
95
- /** Filter component (SearchInput, Select, or SegmentedControl) */
96
- filter?: {
97
- variant: "search" | "select" | "segmentedControl";
98
- } & (SearchInputProps | SelectProps | SegmentedControlProps);
99
- /**
100
- * Size variant of the toolbar. <br />
101
- * Affects the size of buttons and filter component. <br />
102
- */
103
- size?: "main" | "sub";
104
- /**
105
- * Icon-only utility buttons `<Button icon="..." />`. <br />
106
- * They usually appear as smaller buttons with only an icon and no text.
107
- */
108
- utilities?: (ButtonProps & {
109
- icon: {
110
- src: IconDefinition;
111
- };
112
- })[];
113
- } & import("react").RefAttributes<HTMLDivElement>>;
114
- export default PageToolbar;
@@ -1,23 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { pageToolbarClasses } from '@mezzanine-ui/core/page-toolbar';
4
- import { renderFilterProp, renderActionsProp, renderIconButtonsProp, resolvePageToolbarChild } from './utils.js';
5
- import ButtonGroup from '../Button/ButtonGroup.js';
6
- import cx from 'clsx';
7
-
8
- /**
9
- * PageToolbar component provides a flexible toolbar with filter, action buttons, and utility icons.
10
- * Commonly used in page headers for primary user actions.
11
- */
12
- const PageToolbar = forwardRef(function PageToolbar(props, ref) {
13
- const { actions, children, className, filter, size = 'main', utilities, ...rest } = props;
14
- const renderFilter = renderFilterProp(filter, size);
15
- const renderActions = actions ? renderActionsProp(actions, size) : null;
16
- const renderUtilities = utilities
17
- ? renderIconButtonsProp(utilities, size)
18
- : null;
19
- const { filter: filterFromChildren, actions: actionsFromChildren, utilities: utilitiesFromChildren, } = resolvePageToolbarChild(children, size);
20
- return (jsxs("div", { ...rest, className: cx(pageToolbarClasses.host, pageToolbarClasses.size(size), className), ref: ref, children: [renderFilter || filterFromChildren, jsx(ButtonGroup, { children: renderActions || actionsFromChildren }), jsx(ButtonGroup, { children: renderUtilities || utilitiesFromChildren })] }));
21
- });
22
-
23
- export { PageToolbar as default };
@@ -1,2 +0,0 @@
1
- export type { PageToolbarProps } from './PageToolbar';
2
- export { default } from './PageToolbar';
@@ -1 +0,0 @@
1
- export { default } from './PageToolbar.js';
@@ -1,23 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { ButtonProps, ButtonGroupChild } from '../Button';
3
- import { PageToolbarProps } from './PageToolbar';
4
- type ToolbarButtonVariant = 'base-primary' | 'base-secondary' | 'destructive-secondary';
5
- /**
6
- * Renders a button from either ButtonProps or a React element.
7
- * Applies the specified size and variant to the button.
8
- */
9
- export declare const renderButton: (button: ButtonProps | ButtonGroupChild | undefined, size: ButtonProps["size"], variant: ToolbarButtonVariant) => ReactElement<ButtonProps> | null;
10
- export declare const renderFilterProp: (prop: PageToolbarProps["filter"], size: "main" | "sub") => import("react/jsx-runtime").JSX.Element | null;
11
- export declare const renderIconButtonWithProps: (child: ReactElement<ButtonProps>, size: ButtonProps["size"]) => ReactElement<ButtonProps>;
12
- export declare const renderIconButtonsProp: (utilities: PageToolbarProps["utilities"], size: ButtonProps["size"]) => ButtonGroupChild | ButtonGroupChild[];
13
- /**
14
- * Renders action buttons based on the actions configuration.
15
- * Supports both structured actions object and single button element/props.
16
- */
17
- export declare const renderActionsProp: (actions: PageToolbarProps["actions"], size: ButtonProps["size"]) => ButtonGroupChild | ButtonGroupChild[];
18
- export declare const resolvePageToolbarChild: (children: PageToolbarProps["children"], size: "main" | "sub") => {
19
- filter: null;
20
- actions: [ButtonGroupChild, ButtonGroupChild, ButtonGroupChild];
21
- utilities: ButtonGroupChild[];
22
- };
23
- export {};
@@ -1,165 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { Children, isValidElement, cloneElement } from 'react';
3
- import Button from '../Button/Button.js';
4
- import { flattenChildren } from '../utils/flatten-children.js';
5
- import Input from '../Input/Input.js';
6
- import Select from '../Select/Select.js';
7
-
8
- /**
9
- * Renders a button from either ButtonProps or a React element.
10
- * Applies the specified size and variant to the button.
11
- */
12
- const renderButton = (button, size, variant) => {
13
- if (!button) {
14
- return null;
15
- }
16
- if (isValidElement(button)) {
17
- return cloneElement(button, {
18
- size,
19
- variant,
20
- key: variant,
21
- });
22
- }
23
- return jsx(Button, { ...button, size: size, variant: variant }, variant);
24
- };
25
- const withSize = (target, size) => {
26
- return cloneElement(target, { size });
27
- };
28
- const renderFilterProp = (prop, size) => {
29
- if (!prop) {
30
- return null;
31
- }
32
- const { variant } = prop;
33
- if (variant === 'search') {
34
- return (jsx(Input, { ...prop, size: size, variant: "search" }));
35
- }
36
- if (variant === 'select') {
37
- return jsx(Select, { ...prop, size: size });
38
- }
39
- if (variant === 'segmentedControl') {
40
- console.warn('SegmentedControl component is not implemented yet.');
41
- return null;
42
- }
43
- return null;
44
- };
45
- const renderIconButtonWithProps = (child, size) => {
46
- const { icon } = child.props;
47
- return cloneElement(child, {
48
- icon: icon
49
- ? {
50
- ...icon,
51
- position: 'icon-only',
52
- }
53
- : undefined,
54
- size,
55
- variant: 'base-secondary',
56
- });
57
- };
58
- const renderIconButtonsProp = (utilities, size) => {
59
- const result = [];
60
- utilities === null || utilities === void 0 ? void 0 : utilities.forEach((buttonProps) => {
61
- result.push(jsx(Button, { ...buttonProps, size: size, icon: {
62
- ...buttonProps.icon,
63
- position: 'icon-only',
64
- }, variant: "base-secondary" }));
65
- });
66
- return result;
67
- };
68
- /**
69
- * Renders action buttons based on the actions configuration.
70
- * Supports both structured actions object and single button element/props.
71
- */
72
- const renderActionsProp = (actions, size) => {
73
- if (actions &&
74
- ('primaryButton' in actions ||
75
- 'secondaryButton' in actions ||
76
- 'destructiveButton' in actions)) {
77
- return [
78
- renderButton(actions.destructiveButton, size, 'destructive-secondary'),
79
- renderButton(actions.secondaryButton, size, 'base-secondary'),
80
- renderButton(actions.primaryButton, size, 'base-primary'),
81
- ].filter(Boolean);
82
- }
83
- return jsx(Button, { ...actions, size: size, variant: "base-primary" });
84
- };
85
- const resolvePageToolbarChild = (children, size) => {
86
- let filter = null;
87
- const actions = [
88
- null,
89
- null,
90
- null,
91
- ];
92
- const buttonsWithoutVariant = [];
93
- const utilities = [];
94
- if (children) {
95
- const flatChildren = flattenChildren(children);
96
- Children.forEach(flatChildren, (child) => {
97
- var _a;
98
- if (!isValidElement(child)) {
99
- return;
100
- }
101
- const { type, props } = child;
102
- // is filter
103
- if (type === Input && props.variant === 'search') {
104
- filter = withSize(child, size);
105
- }
106
- else if (type === Select) {
107
- // TODO: waiting size prop Select
108
- filter = withSize(child, size);
109
- }
110
- else if (type.toString() === 'SegmentedControl') {
111
- console.warn('SegmentedControl component is not implemented yet.');
112
- }
113
- // is utilities (icon button)
114
- else if (type === Button &&
115
- ((_a = props.icon) === null || _a === void 0 ? void 0 : _a.position) === 'icon-only') {
116
- utilities.push(renderIconButtonWithProps(child, size));
117
- }
118
- // is actions (normal button)
119
- else if (type === Button && props.variant) {
120
- // with variant prop
121
- const variant = props.variant;
122
- if (variant !== 'base-primary' &&
123
- variant !== 'base-secondary' &&
124
- variant !== 'destructive-secondary') {
125
- return;
126
- }
127
- const buttonElement = renderButton(child, size, variant);
128
- if (variant === 'destructive-secondary') {
129
- actions[0] = buttonElement;
130
- }
131
- else if (variant === 'base-secondary') {
132
- actions[1] = buttonElement;
133
- }
134
- else if (variant === 'base-primary') {
135
- actions[2] = buttonElement;
136
- }
137
- }
138
- else if (type === Button) {
139
- // without variant prop
140
- buttonsWithoutVariant.push(child);
141
- }
142
- });
143
- // Fill the buttons from left to right according to the number of buttons passed in,
144
- // and ensure that the button on the right has a higher priority
145
- const fillIndexStartWith = 3 -
146
- buttonsWithoutVariant.length -
147
- (actions[0] ? 1 : 0) -
148
- (actions[1] ? 1 : 0) -
149
- (actions[2] ? 1 : 0);
150
- buttonsWithoutVariant.forEach((button) => {
151
- if (fillIndexStartWith <= 0 && !actions[0]) {
152
- actions[0] = renderButton(button, size, 'destructive-secondary');
153
- }
154
- else if (fillIndexStartWith <= 1 && !actions[1]) {
155
- actions[1] = renderButton(button, size, 'base-secondary');
156
- }
157
- else if (fillIndexStartWith <= 2 && !actions[2]) {
158
- actions[2] = renderButton(button, size, 'base-primary');
159
- }
160
- });
161
- }
162
- return { filter, actions, utilities };
163
- };
164
-
165
- export { renderActionsProp, renderButton, renderFilterProp, renderIconButtonWithProps, renderIconButtonsProp, resolvePageToolbarChild };
@@ -1,107 +0,0 @@
1
- import { Dispatch, SetStateAction, RefObject } from 'react';
2
- import { SelectInputSize } from '@mezzanine-ui/core/select';
3
- import { SelectValue } from './typings';
4
- import { MenuProps } from '../Menu';
5
- import { PopperProps } from '../Popper';
6
- import { PickRenameMulti } from '../utils/general';
7
- import { SelectTriggerProps, SelectTriggerInputProps } from './SelectTrigger';
8
- export interface AutoCompleteBaseProps extends Omit<SelectTriggerProps, 'active' | 'clearable' | 'forceHideSuffixActionIcon' | 'mode' | 'onClick' | 'onKeyDown' | 'onChange' | 'renderValue' | 'inputProps' | 'suffixActionIcon' | 'value'>, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
9
- maxHeight: 'menuMaxHeight';
10
- role: 'menuRole';
11
- size: 'menuSize';
12
- }>, PickRenameMulti<Pick<PopperProps, 'options'>, {
13
- options: 'popperOptions';
14
- }> {
15
- /**
16
- * Set to true when options can be added dynamically
17
- * @default false
18
- */
19
- addable?: boolean;
20
- /**
21
- * Should the filter rules be disabled (If you need to control options filter by yourself)
22
- * @default false
23
- */
24
- disabledOptionsFilter?: boolean;
25
- /**
26
- * The other native props for input element.
27
- */
28
- inputProps?: Omit<SelectTriggerInputProps, 'onChange' | 'placeholder' | 'role' | 'value' | `aria-${'controls' | 'expanded' | 'owns'}`>;
29
- /**
30
- * insert callback whenever insert icon is clicked
31
- * return `true` when insert is successfully
32
- */
33
- onInsert?(text: string): SelectValue;
34
- /**
35
- * The search event handler
36
- */
37
- onSearch?(input: string): any;
38
- /**
39
- * The options that mapped autocomplete options
40
- */
41
- options: SelectValue[];
42
- /**
43
- * select input placeholder
44
- */
45
- placeholder?: string;
46
- /**
47
- * Whether the selection is required.
48
- * @default false
49
- */
50
- required?: boolean;
51
- /**
52
- *
53
- */
54
- searchTextControlRef?: RefObject<{
55
- setSearchText: Dispatch<SetStateAction<string>>;
56
- } | undefined>;
57
- /**
58
- * The size of input.
59
- */
60
- size?: SelectInputSize;
61
- }
62
- export type AutoCompleteMultipleProps = AutoCompleteBaseProps & {
63
- /**
64
- * The default selection
65
- */
66
- defaultValue?: SelectValue[];
67
- /**
68
- * Controls the layout of trigger.
69
- */
70
- mode: 'multiple';
71
- /**
72
- * The change event handler of input element.
73
- */
74
- onChange?(newOptions: SelectValue[]): any;
75
- /**
76
- * The value of selection.
77
- * @default undefined
78
- */
79
- value?: SelectValue[];
80
- };
81
- export type AutoCompleteSingleProps = AutoCompleteBaseProps & {
82
- /**
83
- * The default selection
84
- */
85
- defaultValue?: SelectValue;
86
- /**
87
- * Controls the layout of trigger.
88
- */
89
- mode?: 'single';
90
- /**
91
- * The change event handler of input element.
92
- */
93
- onChange?(newOptions: SelectValue): any;
94
- /**
95
- * The value of selection.
96
- * @default undefined
97
- */
98
- value?: SelectValue | null;
99
- };
100
- export type AutoCompleteProps = AutoCompleteMultipleProps | AutoCompleteSingleProps;
101
- /**
102
- * The AutoComplete component for react. <br />
103
- * Note that if you need search for ONLY given options, not included your typings,
104
- * should considering using the `Select` component with `onSearch` prop.
105
- */
106
- declare const AutoComplete: import("react").ForwardRefExoticComponent<(Omit<AutoCompleteMultipleProps, "ref"> | Omit<AutoCompleteSingleProps, "ref">) & import("react").RefAttributes<HTMLDivElement>>;
107
- export default AutoComplete;
@@ -1,114 +0,0 @@
1
- 'use client';
2
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { forwardRef, useContext, useState, useImperativeHandle, useRef, useMemo } from 'react';
4
- import { selectClasses } from '@mezzanine-ui/core/select';
5
- import { PlusIcon } from '@mezzanine-ui/icons';
6
- import isArray from 'lodash/isArray';
7
- import { useComposeRefs } from '../hooks/useComposeRefs.js';
8
- import Option from './Option.js';
9
- import { SelectControlContext } from './SelectControlContext.js';
10
- import { useAutoCompleteValueControl } from '../Form/useAutoCompleteValueControl.js';
11
- import { useClickAway } from '../hooks/useClickAway.js';
12
- import SelectTrigger from './SelectTrigger.js';
13
- import { FormControlContext } from '../Form/FormControlContext.js';
14
- import InputTriggerPopper from '../_internal/InputTriggerPopper/InputTriggerPopper.js';
15
- import Menu from '../Menu/Menu.js';
16
- import Icon from '../Icon/Icon.js';
17
- import cx from 'clsx';
18
-
19
- const MENU_ID = 'mzn-select-autocomplete-menu-id';
20
- /**
21
- * The AutoComplete component for react. <br />
22
- * Note that if you need search for ONLY given options, not included your typings,
23
- * should considering using the `Select` component with `onSearch` prop.
24
- */
25
- const AutoComplete = forwardRef(function Select(props, ref) {
26
- var _a, _b;
27
- const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
28
- 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, mode = 'single', onChange: onChangeProp, onClear: onClearProp, onInsert, onSearch, options: optionsProp, popperOptions = {}, placeholder = '', prefix, required = requiredFromFormControl || false, searchTextControlRef, size, value: valueProp, } = props;
29
- const [open, toggleOpen] = useState(false);
30
- const { focused, onFocus, onChange, onClear, options, searchText, selectedOptions, setSearchText, unselectedOptions, value, } = useAutoCompleteValueControl({
31
- defaultValue,
32
- disabledOptionsFilter,
33
- mode,
34
- onChange: onChangeProp,
35
- onClear: onClearProp,
36
- onClose: () => toggleOpen(false),
37
- onSearch,
38
- options: optionsProp,
39
- value: valueProp,
40
- });
41
- /** export set search text action to props (allow user to customize search text) */
42
- useImperativeHandle(searchTextControlRef, () => ({ setSearchText }));
43
- /** insert feature */
44
- const [insertText, setInsertText] = useState('');
45
- const nodeRef = useRef(null);
46
- const controlRef = useRef(null);
47
- const popperRef = useRef(null);
48
- const composedRef = useComposeRefs([ref, controlRef]);
49
- const renderValue = focused ? () => searchText : undefined;
50
- useClickAway(() => {
51
- if (!open || focused)
52
- return;
53
- return () => {
54
- toggleOpen((prev) => !prev);
55
- };
56
- }, nodeRef, [focused, nodeRef, open, toggleOpen]);
57
- function getPlaceholder() {
58
- if (focused && value && !isArray(value)) {
59
- return value.name;
60
- }
61
- return placeholder;
62
- }
63
- /** Trigger input props */
64
- const onSearchInputChange = (e) => {
65
- /** should sync both search input and value */
66
- setSearchText(e.target.value);
67
- setInsertText(e.target.value);
68
- /** return current value to onSearch */
69
- onSearch === null || onSearch === void 0 ? void 0 : onSearch(e.target.value);
70
- };
71
- const onSearchInputFocus = (e) => {
72
- var _a;
73
- e.stopPropagation();
74
- toggleOpen(true);
75
- onFocus(true);
76
- (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
77
- };
78
- const onSearchInputBlur = (e) => {
79
- var _a;
80
- onFocus(false);
81
- (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
82
- };
83
- const onClickSuffixActionIcon = () => {
84
- toggleOpen((prev) => !prev);
85
- };
86
- const resolvedInputProps = {
87
- ...inputProps,
88
- 'aria-controls': MENU_ID,
89
- 'aria-expanded': open,
90
- 'aria-owns': MENU_ID,
91
- onBlur: onSearchInputBlur,
92
- onChange: onSearchInputChange,
93
- onFocus: onSearchInputFocus,
94
- placeholder: getPlaceholder(),
95
- role: 'combobox',
96
- };
97
- const searchTextExistWithoutOption = !!searchText &&
98
- options.find((option) => option.name === searchText) === undefined;
99
- const context = useMemo(() => ({ onChange, value }), [onChange, value]);
100
- return (jsx(SelectControlContext.Provider, { value: context, children: jsxs("div", { ref: nodeRef, className: cx(selectClasses.host, { [selectClasses.hostFullWidth]: fullWidth }), children: [jsx(SelectTrigger, { ref: composedRef, active: open, className: className, clearable: true, disabled: disabled, ellipsis: true, error: error, fullWidth: fullWidth, inputRef: inputRef, mode: mode, onTagClose: onChange, onClear: onClear, prefix: prefix, readOnly: false, required: required, inputProps: resolvedInputProps, searchText: searchText, size: size, showTextInputAfterTags: true, suffixAction: onClickSuffixActionIcon, value: value, renderValue: renderValue }), jsxs(InputTriggerPopper, { ref: popperRef, anchor: controlRef, className: selectClasses.popper, open: open, sameWidth: true, options: popperOptions, children: [options.length ? (jsx(Menu, { id: MENU_ID, "aria-activedescendant": Array.isArray(value) ? ((_b = (_a = value === null || value === void 0 ? void 0 : value[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '') : value === null || value === void 0 ? void 0 : value.id, itemsInView: itemsInView, maxHeight: menuMaxHeight, role: menuRole, size: menuSize, style: { border: 0 }, children: mode === 'single' ? (jsx(Fragment, { children: options.map((option) => (jsx(Option, { value: option.id, children: option.name }, option.id))) })) : (jsxs(Fragment, { children: [selectedOptions.map((option) => (jsx(Option, { value: option.id, children: option.name }, option.id))), unselectedOptions.map((option) => (jsx(Option, { value: option.id, children: option.name }, option.id)))] })) })) : null, searchTextExistWithoutOption && addable ? (jsxs("button", { type: "button", className: selectClasses.autoComplete, onClick: (e) => {
101
- var _a;
102
- e.stopPropagation();
103
- if (insertText) {
104
- const newOption = (_a = onInsert === null || onInsert === void 0 ? void 0 : onInsert(insertText)) !== null && _a !== void 0 ? _a : null;
105
- if (newOption) {
106
- setInsertText('');
107
- setSearchText('');
108
- onChange(newOption);
109
- }
110
- }
111
- }, children: [jsx("p", { children: insertText }), jsx(Icon, { className: selectClasses.autoCompleteIcon, icon: PlusIcon })] })) : null] })] }) }));
112
- });
113
-
114
- export { AutoComplete as default };
@@ -1,11 +0,0 @@
1
- export interface TableDragHandleCellProps {
2
- className?: string;
3
- dragHandleProps?: Record<string, unknown>;
4
- fixed?: boolean;
5
- fixedOffset?: number;
6
- isHeader?: boolean;
7
- showShadow?: boolean;
8
- /** Explicit width for dragging state */
9
- width?: number;
10
- }
11
- export declare const TableDragHandleCell: import("react").NamedExoticComponent<TableDragHandleCellProps & import("react").RefAttributes<HTMLTableCellElement>>;
@@ -1,44 +0,0 @@
1
- 'use client';
2
- import { jsx } from 'react/jsx-runtime';
3
- import { memo, forwardRef } from 'react';
4
- import { tableClasses } from '@mezzanine-ui/core/table';
5
- import { DotDragVerticalIcon } from '@mezzanine-ui/icons';
6
- import { useTableContext } from '../TableContext.js';
7
- import Skeleton from '../../Skeleton/Skeleton.js';
8
- import Icon from '../../Icon/Icon.js';
9
- import cx from 'clsx';
10
-
11
- const TableDragHandleCellInner = forwardRef(function TableDragHandleCell(props, ref) {
12
- const { loading } = useTableContext();
13
- const { className, dragHandleProps, fixed = false, fixedOffset = 0, isHeader = false, showShadow = false, width, } = props;
14
- const CellComponent = isHeader ? 'th' : 'td';
15
- const cellStyle = {};
16
- // Apply explicit width for dragging state
17
- if (width !== undefined) {
18
- cellStyle.width = width;
19
- cellStyle.minWidth = width;
20
- cellStyle.maxWidth = width;
21
- cellStyle.flexShrink = 0;
22
- }
23
- if (fixed) {
24
- cellStyle['--fixed-start-offset'] =
25
- `${fixedOffset}px`;
26
- }
27
- const renderChild = () => {
28
- if (!isHeader) {
29
- if (loading) {
30
- return jsx(Skeleton, { width: "100%", variant: "body-highlight" });
31
- }
32
- return (jsx("span", { className: tableClasses.dragHandle, ...dragHandleProps, children: jsx(Icon, { color: "neutral", icon: DotDragVerticalIcon }) }));
33
- }
34
- return null;
35
- };
36
- return (jsx(CellComponent, { className: cx(isHeader ? tableClasses.headerCell : tableClasses.cell, tableClasses.dragHandleCell, {
37
- [tableClasses.cellFixed]: fixed,
38
- [tableClasses.cellFixedStart]: fixed,
39
- [tableClasses.cellFixedShadow]: showShadow,
40
- }, className), ref: ref, scope: isHeader ? 'col' : undefined, style: cellStyle, children: renderChild() }));
41
- });
42
- const TableDragHandleCell = memo(TableDragHandleCellInner);
43
-
44
- export { TableDragHandleCell };