@mezzanine-ui/react 1.0.0-beta.3 → 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.
- package/AutoComplete/AutoComplete.d.ts +23 -0
- package/AutoComplete/AutoComplete.js +23 -9
- package/Breadcrumb/Breadcrumb.js +16 -21
- package/Breadcrumb/BreadcrumbDropdown.d.ts +11 -0
- package/Breadcrumb/BreadcrumbDropdown.js +22 -0
- package/Breadcrumb/BreadcrumbItem.d.ts +2 -3
- package/Breadcrumb/BreadcrumbItem.js +13 -31
- package/Breadcrumb/BreadcrumbOverflowMenu.d.ts +7 -0
- package/Breadcrumb/BreadcrumbOverflowMenu.js +77 -0
- package/Breadcrumb/BreadcrumbOverflowMenuDropdown.d.ts +11 -0
- package/Breadcrumb/BreadcrumbOverflowMenuDropdown.js +21 -0
- package/Breadcrumb/BreadcrumbOverflowMenuItem.d.ts +3 -0
- package/Breadcrumb/BreadcrumbOverflowMenuItem.js +27 -0
- package/Breadcrumb/typings.d.ts +21 -39
- package/Checkbox/index.d.ts +4 -5
- package/Checkbox/index.js +1 -5
- package/ContentHeader/ContentHeader.d.ts +160 -0
- package/ContentHeader/ContentHeader.js +54 -0
- package/ContentHeader/index.d.ts +2 -0
- package/ContentHeader/index.js +1 -0
- package/ContentHeader/utils.d.ts +23 -0
- package/ContentHeader/utils.js +215 -0
- package/Dropdown/Dropdown.d.ts +17 -0
- package/Dropdown/Dropdown.js +6 -2
- package/Dropdown/DropdownItem.d.ts +10 -0
- package/Dropdown/DropdownItem.js +37 -8
- package/Dropdown/DropdownItemCard.d.ts +2 -2
- package/Dropdown/DropdownItemCard.js +11 -8
- package/Empty/Empty.js +2 -1
- package/Empty/icons/EmptyMainNotificationIcon.d.ts +4 -0
- package/Empty/icons/EmptyMainNotificationIcon.js +9 -0
- package/Empty/typings.d.ts +2 -2
- package/FilterArea/Filter.d.ts +32 -0
- package/FilterArea/Filter.js +23 -0
- package/FilterArea/FilterArea.d.ts +58 -0
- package/FilterArea/FilterArea.js +31 -0
- package/FilterArea/FilterLine.d.ts +11 -0
- package/FilterArea/FilterLine.js +13 -0
- package/FilterArea/index.d.ts +6 -0
- package/FilterArea/index.js +3 -0
- package/Input/Input.d.ts +6 -4
- package/Input/Input.js +28 -10
- package/Input/index.d.ts +1 -1
- package/Modal/MediaPreviewModal.d.ts +54 -0
- package/Modal/MediaPreviewModal.js +158 -0
- package/Modal/Modal.js +1 -1
- package/Modal/index.d.ts +2 -0
- package/Modal/index.js +1 -0
- package/Navigation/Navigation.js +6 -5
- package/Navigation/NavigationOption.d.ts +6 -2
- package/Navigation/NavigationOption.js +19 -9
- package/Navigation/NavigationOverflowMenu.d.ts +6 -0
- package/Navigation/NavigationOverflowMenu.js +90 -0
- package/Navigation/NavigationOverflowMenuOption.d.ts +7 -0
- package/Navigation/NavigationOverflowMenuOption.js +68 -0
- package/Navigation/NavigationUserMenu.d.ts +4 -2
- package/Navigation/NavigationUserMenu.js +13 -5
- package/Navigation/context.d.ts +3 -2
- package/NotificationCenter/NotificationCenter.d.ts +1 -1
- package/NotificationCenter/NotificationCenter.js +34 -14
- package/NotificationCenter/NotificationCenterDrawer.d.ts +20 -0
- package/PageHeader/PageHeader.d.ts +32 -25
- package/PageHeader/PageHeader.js +49 -35
- package/ResultState/ResultState.d.ts +9 -0
- package/ResultState/ResultState.js +36 -4
- package/Scrollbar/Scrollbar.d.ts +9 -0
- package/Scrollbar/Scrollbar.js +78 -0
- package/Scrollbar/index.d.ts +2 -0
- package/Scrollbar/index.js +1 -0
- package/Scrollbar/typings.d.ts +47 -0
- package/Select/SelectTrigger.js +5 -4
- package/Select/typings.d.ts +6 -1
- package/Selection/Selection.js +1 -1
- package/Selection/SelectionGroup.d.ts +28 -0
- package/Table/Table.d.ts +2 -120
- package/Table/Table.js +148 -53
- package/Table/TableContext.d.ts +11 -12
- package/Table/components/TableActionsCell.js +12 -4
- package/Table/components/TableBody.js +2 -1
- package/Table/components/TableColGroup.d.ts +1 -4
- package/Table/components/TableColGroup.js +15 -16
- package/Table/components/TableCollectableCell.d.ts +17 -0
- package/Table/components/TableCollectableCell.js +54 -0
- package/Table/components/TableDragOrPinHandleCell.d.ts +20 -0
- package/Table/components/TableDragOrPinHandleCell.js +58 -0
- package/Table/components/TableExpandedRow.js +11 -2
- package/Table/components/TableHeader.js +12 -10
- package/Table/components/TableRow.js +38 -13
- package/Table/components/TableSelectionCell.js +1 -1
- package/Table/components/TableToggleableCell.d.ts +16 -0
- package/Table/components/TableToggleableCell.js +51 -0
- package/Table/components/index.d.ts +4 -1
- package/Table/components/index.js +3 -0
- package/Table/hooks/typings.d.ts +18 -4
- package/Table/hooks/useTableExpansion.d.ts +2 -2
- package/Table/hooks/useTableExpansion.js +5 -5
- package/Table/hooks/useTableFixedOffsets.d.ts +6 -2
- package/Table/hooks/useTableFixedOffsets.js +58 -24
- package/Table/hooks/useTableScroll.d.ts +9 -3
- package/Table/hooks/useTableScroll.js +34 -7
- package/Table/hooks/useTableVirtualization.d.ts +2 -1
- package/Table/hooks/useTableVirtualization.js +2 -8
- package/Table/index.d.ts +4 -3
- package/Table/index.js +3 -0
- package/Table/typings.d.ts +172 -0
- package/Transition/Slide.d.ts +9 -2
- package/Transition/Slide.js +7 -4
- package/Tree/TreeNode.js +1 -1
- package/index.d.ts +4 -2
- package/index.js +6 -3
- package/package.json +6 -4
- package/Navigation/CollapsedMenu.d.ts +0 -6
- package/Navigation/CollapsedMenu.js +0 -16
- package/PageToolbar/PageToolbar.d.ts +0 -110
- package/PageToolbar/PageToolbar.js +0 -23
- package/PageToolbar/index.d.ts +0 -2
- package/PageToolbar/index.js +0 -1
- package/PageToolbar/utils.d.ts +0 -23
- package/PageToolbar/utils.js +0 -157
- package/Table/components/TableDragHandleCell.d.ts +0 -11
- package/Table/components/TableDragHandleCell.js +0 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mezzanine-ui/react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"description": "React components for mezzanine-ui",
|
|
5
5
|
"author": "Mezzanine",
|
|
6
6
|
"repository": {
|
|
@@ -31,14 +31,16 @@
|
|
|
31
31
|
"@floating-ui/dom": "^1.7.4",
|
|
32
32
|
"@floating-ui/react-dom": "^2.1.6",
|
|
33
33
|
"@hello-pangea/dnd": "^18.0.1",
|
|
34
|
-
"@mezzanine-ui/core": "1.0.0-beta.
|
|
35
|
-
"@mezzanine-ui/icons": "1.0.0-beta.
|
|
36
|
-
"@mezzanine-ui/system": "1.0.0-beta.
|
|
34
|
+
"@mezzanine-ui/core": "1.0.0-beta.4",
|
|
35
|
+
"@mezzanine-ui/icons": "1.0.0-beta.4",
|
|
36
|
+
"@mezzanine-ui/system": "1.0.0-beta.4",
|
|
37
37
|
"@tanstack/react-virtual": "^3.13.13",
|
|
38
38
|
"@types/react-transition-group": "^4.4.12",
|
|
39
39
|
"clsx": "^2.1.1",
|
|
40
40
|
"keycode": "^2.2.1",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
|
+
"overlayscrollbars": "^2.13.0",
|
|
43
|
+
"overlayscrollbars-react": "^0.5.6",
|
|
42
44
|
"react-transition-group": "^4.4.5",
|
|
43
45
|
"tslib": "^2.8.1"
|
|
44
46
|
},
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useRef } from 'react';
|
|
3
|
-
import { navigationClasses } from '@mezzanine-ui/core/navigation';
|
|
4
|
-
import NavigationIconButton from './NavigationIconButton.js';
|
|
5
|
-
import { DotHorizontalIcon } from '@mezzanine-ui/icons';
|
|
6
|
-
import Popper from '../Popper/Popper.js';
|
|
7
|
-
|
|
8
|
-
const CollapsedMenu = ({ items }) => {
|
|
9
|
-
const [menuOpen, setMenuOpen] = useState(false);
|
|
10
|
-
const targetRef = useRef(null);
|
|
11
|
-
return (jsxs(Fragment, { children: [jsx(NavigationIconButton, { ref: targetRef, icon: DotHorizontalIcon, onClick: () => setMenuOpen(!menuOpen) }), jsx(Popper, { anchor: targetRef.current, open: menuOpen, options: {
|
|
12
|
-
placement: 'right-end',
|
|
13
|
-
}, children: jsx("div", { className: navigationClasses.collapsedMenu, children: jsx("ul", { children: items }) }) })] }));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { CollapsedMenu };
|
|
@@ -1,110 +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: IconDefinition;
|
|
66
|
-
})[];
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* PageToolbar component provides a flexible toolbar with filter, action buttons, and utility icons.
|
|
70
|
-
* Commonly used in page headers for primary user actions.
|
|
71
|
-
*/
|
|
72
|
-
declare const PageToolbar: import("react").ForwardRefExoticComponent<Omit<NativeElementPropsWithoutKeyAndRef<"div">, "children"> & {
|
|
73
|
-
/**
|
|
74
|
-
* Button configuration for primary, secondary, and destructive actions. <br />
|
|
75
|
-
* Automatically applies proper styling and order. <br />
|
|
76
|
-
*/
|
|
77
|
-
actions?: {
|
|
78
|
-
destructiveButton?: ButtonProps;
|
|
79
|
-
primaryButton?: ButtonProps;
|
|
80
|
-
secondaryButton?: ButtonProps;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Children elements: <br />
|
|
84
|
-
* - Filter component (SearchInput, Select, or SegmentedControl) <br />
|
|
85
|
-
* - Action buttons `<Button />` <br />
|
|
86
|
-
* - Icon-only utility buttons `<Button icon="..." />` <br />
|
|
87
|
-
* <br />
|
|
88
|
-
* Can mix and match the above children. <br />
|
|
89
|
-
* The order of children does not matter as they will be arranged properly. <br />
|
|
90
|
-
* When conflicting with other props, props take priority over children. <br />
|
|
91
|
-
*/
|
|
92
|
-
children?: PageToolbarChild[] | PageToolbarChild;
|
|
93
|
-
/** Filter component (SearchInput, Select, or SegmentedControl) */
|
|
94
|
-
filter?: {
|
|
95
|
-
variant: "search" | "select" | "segmentedControl";
|
|
96
|
-
} & (SearchInputProps | SelectProps | SegmentedControlProps);
|
|
97
|
-
/**
|
|
98
|
-
* Size variant of the toolbar. <br />
|
|
99
|
-
* Affects the size of buttons and filter component. <br />
|
|
100
|
-
*/
|
|
101
|
-
size?: "main" | "sub";
|
|
102
|
-
/**
|
|
103
|
-
* Icon-only utility buttons `<Button icon="..." />`. <br />
|
|
104
|
-
* They usually appear as smaller buttons with only an icon and no text.
|
|
105
|
-
*/
|
|
106
|
-
utilities?: (ButtonProps & {
|
|
107
|
-
icon: IconDefinition;
|
|
108
|
-
})[];
|
|
109
|
-
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
110
|
-
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 };
|
package/PageToolbar/index.d.ts
DELETED
package/PageToolbar/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './PageToolbar.js';
|
package/PageToolbar/utils.d.ts
DELETED
|
@@ -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 {};
|
package/PageToolbar/utils.js
DELETED
|
@@ -1,157 +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
|
-
iconType: icon ? 'icon-only' : undefined,
|
|
50
|
-
size,
|
|
51
|
-
variant: 'base-secondary',
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const renderIconButtonsProp = (utilities, size) => {
|
|
55
|
-
const result = [];
|
|
56
|
-
utilities === null || utilities === void 0 ? void 0 : utilities.forEach((buttonProps) => {
|
|
57
|
-
result.push(jsx(Button, { ...buttonProps, size: size, icon: buttonProps.icon, iconType: buttonProps.icon ? 'icon-only' : undefined, variant: "base-secondary" }));
|
|
58
|
-
});
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Renders action buttons based on the actions configuration.
|
|
63
|
-
* Supports both structured actions object and single button element/props.
|
|
64
|
-
*/
|
|
65
|
-
const renderActionsProp = (actions, size) => {
|
|
66
|
-
if (actions &&
|
|
67
|
-
('primaryButton' in actions ||
|
|
68
|
-
'secondaryButton' in actions ||
|
|
69
|
-
'destructiveButton' in actions)) {
|
|
70
|
-
return [
|
|
71
|
-
renderButton(actions.destructiveButton, size, 'destructive-secondary'),
|
|
72
|
-
renderButton(actions.secondaryButton, size, 'base-secondary'),
|
|
73
|
-
renderButton(actions.primaryButton, size, 'base-primary'),
|
|
74
|
-
].filter(Boolean);
|
|
75
|
-
}
|
|
76
|
-
return jsx(Button, { ...actions, size: size, variant: "base-primary" });
|
|
77
|
-
};
|
|
78
|
-
const resolvePageToolbarChild = (children, size) => {
|
|
79
|
-
let filter = null;
|
|
80
|
-
const actions = [
|
|
81
|
-
null,
|
|
82
|
-
null,
|
|
83
|
-
null,
|
|
84
|
-
];
|
|
85
|
-
const buttonsWithoutVariant = [];
|
|
86
|
-
const utilities = [];
|
|
87
|
-
if (children) {
|
|
88
|
-
const flatChildren = flattenChildren(children);
|
|
89
|
-
Children.forEach(flatChildren, (child) => {
|
|
90
|
-
if (!isValidElement(child)) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const { type, props } = child;
|
|
94
|
-
// is filter
|
|
95
|
-
if (type === Input && props.variant === 'search') {
|
|
96
|
-
filter = withSize(child, size);
|
|
97
|
-
}
|
|
98
|
-
else if (type === Select) {
|
|
99
|
-
// TODO: waiting size prop Select
|
|
100
|
-
filter = withSize(child, size);
|
|
101
|
-
}
|
|
102
|
-
else if (type.toString() === 'SegmentedControl') {
|
|
103
|
-
console.warn('SegmentedControl component is not implemented yet.');
|
|
104
|
-
}
|
|
105
|
-
// is utilities (icon button)
|
|
106
|
-
else if (type === Button &&
|
|
107
|
-
props.iconType === 'icon-only') {
|
|
108
|
-
utilities.push(renderIconButtonWithProps(child, size));
|
|
109
|
-
}
|
|
110
|
-
// is actions (normal button)
|
|
111
|
-
else if (type === Button && props.variant) {
|
|
112
|
-
// with variant prop
|
|
113
|
-
const variant = props.variant;
|
|
114
|
-
if (variant !== 'base-primary' &&
|
|
115
|
-
variant !== 'base-secondary' &&
|
|
116
|
-
variant !== 'destructive-secondary') {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
const buttonElement = renderButton(child, size, variant);
|
|
120
|
-
if (variant === 'destructive-secondary') {
|
|
121
|
-
actions[0] = buttonElement;
|
|
122
|
-
}
|
|
123
|
-
else if (variant === 'base-secondary') {
|
|
124
|
-
actions[1] = buttonElement;
|
|
125
|
-
}
|
|
126
|
-
else if (variant === 'base-primary') {
|
|
127
|
-
actions[2] = buttonElement;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else if (type === Button) {
|
|
131
|
-
// without variant prop
|
|
132
|
-
buttonsWithoutVariant.push(child);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
// Fill the buttons from left to right according to the number of buttons passed in,
|
|
136
|
-
// and ensure that the button on the right has a higher priority
|
|
137
|
-
const fillIndexStartWith = 3 -
|
|
138
|
-
buttonsWithoutVariant.length -
|
|
139
|
-
(actions[0] ? 1 : 0) -
|
|
140
|
-
(actions[1] ? 1 : 0) -
|
|
141
|
-
(actions[2] ? 1 : 0);
|
|
142
|
-
buttonsWithoutVariant.forEach((button) => {
|
|
143
|
-
if (fillIndexStartWith <= 0 && !actions[0]) {
|
|
144
|
-
actions[0] = renderButton(button, size, 'destructive-secondary');
|
|
145
|
-
}
|
|
146
|
-
else if (fillIndexStartWith <= 1 && !actions[1]) {
|
|
147
|
-
actions[1] = renderButton(button, size, 'base-secondary');
|
|
148
|
-
}
|
|
149
|
-
else if (fillIndexStartWith <= 2 && !actions[2]) {
|
|
150
|
-
actions[2] = renderButton(button, size, 'base-primary');
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return { filter, actions, utilities };
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
export { renderActionsProp, renderButton, renderFilterProp, renderIconButtonWithProps, renderIconButtonsProp, resolvePageToolbarChild };
|
|
@@ -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 };
|