@mezzanine-ui/react 1.0.0-alpha.0 → 1.0.0-beta.1

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 (180) hide show
  1. package/Breadcrumb/Breadcrumb.js +40 -12
  2. package/Breadcrumb/typings.d.ts +8 -3
  3. package/Drawer/Drawer.d.ts +47 -6
  4. package/Drawer/Drawer.js +36 -11
  5. package/Dropdown/Dropdown.d.ts +116 -15
  6. package/Dropdown/Dropdown.js +235 -32
  7. package/Dropdown/DropdownAction.d.ts +50 -0
  8. package/Dropdown/DropdownAction.js +26 -0
  9. package/Dropdown/DropdownItem.d.ts +60 -0
  10. package/Dropdown/DropdownItem.js +318 -0
  11. package/Dropdown/DropdownItemCard.d.ts +96 -0
  12. package/Dropdown/DropdownItemCard.js +115 -0
  13. package/Dropdown/DropdownStatus.d.ts +22 -0
  14. package/Dropdown/dropdownKeydownHandler.d.ts +15 -0
  15. package/Dropdown/highlightText.d.ts +9 -0
  16. package/Dropdown/highlightText.js +32 -0
  17. package/Dropdown/index.d.ts +1 -1
  18. package/Empty/Empty.js +26 -3
  19. package/Empty/typings.d.ts +16 -7
  20. package/Navigation/Navigation.d.ts +11 -17
  21. package/Navigation/Navigation.js +58 -41
  22. package/Navigation/NavigationFooter.d.ts +10 -0
  23. package/Navigation/NavigationFooter.js +26 -0
  24. package/Navigation/NavigationHeader.d.ts +8 -0
  25. package/Navigation/NavigationHeader.js +13 -0
  26. package/Navigation/NavigationIconButton.d.ts +15 -0
  27. package/Navigation/NavigationIconButton.js +12 -0
  28. package/Navigation/NavigationOption.d.ts +35 -0
  29. package/Navigation/NavigationOption.js +60 -0
  30. package/Navigation/NavigationOptionCategory.d.ts +6 -0
  31. package/Navigation/NavigationOptionCategory.js +12 -0
  32. package/Navigation/NavigationUserMenu.d.ts +8 -0
  33. package/Navigation/NavigationUserMenu.js +18 -0
  34. package/Navigation/context.d.ts +13 -0
  35. package/Navigation/context.js +7 -0
  36. package/Navigation/index.d.ts +12 -6
  37. package/Navigation/index.js +6 -3
  38. package/Navigation/useCurrentPathname.d.ts +1 -0
  39. package/Navigation/useCurrentPathname.js +14 -0
  40. package/PageHeader/PageHeader.d.ts +5 -1
  41. package/PageHeader/PageHeader.js +8 -3
  42. package/PageToolbar/PageToolbar.d.ts +73 -26
  43. package/PageToolbar/PageToolbar.js +10 -101
  44. package/PageToolbar/utils.d.ts +23 -0
  45. package/PageToolbar/utils.js +165 -0
  46. package/Pagination/PaginationItem.js +1 -3
  47. package/Pagination/usePagination.js +0 -18
  48. package/Radio/Radio.d.ts +36 -3
  49. package/Radio/Radio.js +21 -11
  50. package/Radio/RadioGroup.d.ts +36 -7
  51. package/Radio/RadioGroup.js +5 -4
  52. package/Radio/RadioGroupContext.d.ts +2 -1
  53. package/Radio/index.d.ts +3 -3
  54. package/Slider/useSlider.js +1 -1
  55. package/Tab/Tab.d.ts +32 -0
  56. package/Tab/Tab.js +57 -0
  57. package/Tab/TabItem.d.ts +27 -0
  58. package/Tab/TabItem.js +18 -0
  59. package/Tab/index.d.ts +4 -0
  60. package/Tab/index.js +2 -0
  61. package/Table/Table.d.ts +75 -94
  62. package/Table/Table.js +216 -161
  63. package/Table/TableContext.d.ts +114 -51
  64. package/Table/TableContext.js +21 -3
  65. package/Table/components/TableBody.d.ts +5 -0
  66. package/Table/components/TableBody.js +102 -0
  67. package/Table/components/TableCell.d.ts +17 -0
  68. package/Table/components/TableCell.js +74 -0
  69. package/Table/components/TableColGroup.d.ts +4 -0
  70. package/Table/components/TableColGroup.js +206 -0
  71. package/Table/components/TableDragHandleCell.d.ts +9 -0
  72. package/Table/components/TableDragHandleCell.js +37 -0
  73. package/Table/components/TableExpandCell.d.ts +11 -0
  74. package/Table/components/TableExpandCell.js +44 -0
  75. package/Table/components/TableExpandedRow.d.ts +9 -0
  76. package/Table/components/TableExpandedRow.js +46 -0
  77. package/Table/components/TableHeader.d.ts +4 -0
  78. package/Table/components/TableHeader.js +125 -0
  79. package/Table/components/TablePagination.d.ts +3 -0
  80. package/Table/components/TablePagination.js +11 -0
  81. package/Table/components/TableResizeHandle.d.ts +13 -0
  82. package/Table/components/TableResizeHandle.js +115 -0
  83. package/Table/components/TableRow.d.ts +12 -0
  84. package/Table/components/TableRow.js +126 -0
  85. package/Table/components/TableSelectionCell.d.ts +13 -0
  86. package/Table/components/TableSelectionCell.js +35 -0
  87. package/Table/components/index.d.ts +10 -0
  88. package/Table/components/index.js +10 -0
  89. package/Table/hooks/index.d.ts +9 -0
  90. package/Table/hooks/index.js +8 -0
  91. package/Table/hooks/typings.d.ts +14 -0
  92. package/Table/hooks/useTableColumns.d.ts +8 -0
  93. package/Table/hooks/useTableColumns.js +91 -0
  94. package/Table/hooks/useTableDataSource.d.ts +57 -0
  95. package/Table/hooks/useTableDataSource.js +183 -0
  96. package/Table/hooks/useTableExpansion.d.ts +7 -0
  97. package/Table/hooks/useTableExpansion.js +52 -0
  98. package/Table/hooks/useTableFixedOffsets.d.ts +29 -0
  99. package/Table/hooks/useTableFixedOffsets.js +241 -0
  100. package/Table/hooks/useTableScroll.d.ts +12 -0
  101. package/Table/hooks/useTableScroll.js +58 -0
  102. package/Table/hooks/useTableSelection.d.ts +7 -0
  103. package/Table/hooks/useTableSelection.js +94 -0
  104. package/Table/hooks/useTableSorting.d.ts +6 -0
  105. package/Table/hooks/useTableSorting.js +32 -0
  106. package/Table/hooks/useTableVirtualization.d.ts +22 -0
  107. package/Table/hooks/useTableVirtualization.js +115 -0
  108. package/Table/index.d.ts +7 -10
  109. package/Table/index.js +22 -6
  110. package/Table/utils/index.d.ts +2 -0
  111. package/Table/utils/index.js +1 -0
  112. package/Table/utils/useTableRowSelection.d.ts +18 -0
  113. package/Table/utils/useTableRowSelection.js +63 -0
  114. package/_internal/InputCheck/InputCheck.d.ts +15 -1
  115. package/_internal/InputCheck/InputCheck.js +6 -2
  116. package/_internal/InputCheck/InputCheckGroup.d.ts +11 -1
  117. package/_internal/InputCheck/InputCheckGroup.js +4 -2
  118. package/_internal/SlideFadeOverlay/SlideFadeOverlay.d.ts +1 -1
  119. package/_internal/SlideFadeOverlay/SlideFadeOverlay.js +1 -1
  120. package/hooks/useElementHeight.d.ts +8 -0
  121. package/hooks/useElementHeight.js +41 -0
  122. package/index.d.ts +9 -7
  123. package/index.js +6 -11
  124. package/package.json +6 -4
  125. package/utils/flatten-children.d.ts +12 -0
  126. package/utils/flatten-children.js +37 -0
  127. package/utils/get-css-variable-value.d.ts +1 -0
  128. package/utils/get-css-variable-value.js +4 -1
  129. package/Navigation/NavigationContext.d.ts +0 -5
  130. package/Navigation/NavigationContext.js +0 -8
  131. package/Navigation/NavigationItem.d.ts +0 -31
  132. package/Navigation/NavigationItem.js +0 -23
  133. package/Navigation/NavigationSubMenu.d.ts +0 -22
  134. package/Navigation/NavigationSubMenu.js +0 -50
  135. package/Table/TableBody.d.ts +0 -10
  136. package/Table/TableBody.js +0 -31
  137. package/Table/TableBodyRow.d.ts +0 -11
  138. package/Table/TableBodyRow.js +0 -65
  139. package/Table/TableCell.d.ts +0 -19
  140. package/Table/TableCell.js +0 -24
  141. package/Table/TableExpandedTable.d.ts +0 -11
  142. package/Table/TableExpandedTable.js +0 -29
  143. package/Table/TableHeader.d.ts +0 -3
  144. package/Table/TableHeader.js +0 -36
  145. package/Table/draggable/useTableDraggable.d.ts +0 -14
  146. package/Table/draggable/useTableDraggable.js +0 -64
  147. package/Table/editable/TableEditRenderWrapper.d.ts +0 -7
  148. package/Table/editable/TableEditRenderWrapper.js +0 -16
  149. package/Table/expandable/TableExpandable.d.ts +0 -27
  150. package/Table/expandable/TableExpandable.js +0 -24
  151. package/Table/pagination/TablePagination.d.ts +0 -10
  152. package/Table/pagination/TablePagination.js +0 -26
  153. package/Table/pagination/useTablePagination.d.ts +0 -8
  154. package/Table/pagination/useTablePagination.js +0 -30
  155. package/Table/refresh/TableRefresh.d.ts +0 -10
  156. package/Table/refresh/TableRefresh.js +0 -22
  157. package/Table/rowSelection/TableRowSelection.d.ts +0 -18
  158. package/Table/rowSelection/TableRowSelection.js +0 -93
  159. package/Table/rowSelection/useTableRowSelection.d.ts +0 -6
  160. package/Table/rowSelection/useTableRowSelection.js +0 -53
  161. package/Table/sorting/TableSortingIcon.d.ts +0 -10
  162. package/Table/sorting/TableSortingIcon.js +0 -33
  163. package/Table/sorting/useTableSorting.d.ts +0 -11
  164. package/Table/sorting/useTableSorting.js +0 -121
  165. package/Table/useTableFetchMore.d.ts +0 -10
  166. package/Table/useTableFetchMore.js +0 -50
  167. package/Table/useTableLoading.d.ts +0 -5
  168. package/Table/useTableLoading.js +0 -19
  169. package/Table/useTableScroll.d.ts +0 -592
  170. package/Table/useTableScroll.js +0 -296
  171. package/Tabs/Tab.d.ts +0 -18
  172. package/Tabs/Tab.js +0 -16
  173. package/Tabs/TabPane.d.ts +0 -14
  174. package/Tabs/TabPane.js +0 -19
  175. package/Tabs/Tabs.d.ts +0 -39
  176. package/Tabs/Tabs.js +0 -52
  177. package/Tabs/index.d.ts +0 -6
  178. package/Tabs/index.js +0 -3
  179. package/Tabs/useTabsOverflow.d.ts +0 -8
  180. package/Tabs/useTabsOverflow.js +0 -62
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { arrayMove } from './utils/array-move.js';
2
2
  export { composeRefs } from './utils/composeRefs.js';
3
- export { getCSSVariableValue } from './utils/get-css-variable-value.js';
3
+ export { getCSSVariableValue, getNumericCSSVariablePixelValue } from './utils/get-css-variable-value.js';
4
4
  export { getScrollbarWidth } from './utils/get-scrollbar-width.js';
5
5
  export { getElement } from './utils/getElement.js';
6
6
  export { useClickAway } from './hooks/useClickAway.js';
@@ -44,15 +44,12 @@ export { default as MenuDivider } from './Menu/MenuDivider.js';
44
44
  export { default as MenuItem } from './Menu/MenuItem.js';
45
45
  export { default as MenuItemGroup, default as OptionGroup } from './Menu/MenuItemGroup.js';
46
46
  export { default as Navigation } from './Navigation/Navigation.js';
47
- export { default as NavigationItem } from './Navigation/NavigationItem.js';
48
- export { default as NavigationSubMenu } from './Navigation/NavigationSubMenu.js';
49
47
  export { default as PageFooter } from './PageFooter/PageFooter.js';
50
48
  export { default as PageHeader } from './PageHeader/PageHeader.js';
51
49
  export { default as Step } from './Stepper/Step.js';
52
50
  export { default as Stepper } from './Stepper/Stepper.js';
53
- export { default as Tab } from './Tabs/Tab.js';
54
- export { default as TabPane } from './Tabs/TabPane.js';
55
- export { default as Tabs } from './Tabs/Tabs.js';
51
+ export { default as TabItem } from './Tab/TabItem.js';
52
+ export { default as Tab } from './Tab/Tab.js';
56
53
  export { default as Accordion } from './Accordion/Accordion.js';
57
54
  export { default as AccordionDetails } from './Accordion/AccordionDetails.js';
58
55
  export { default as AccordionSummary } from './Accordion/AccordionSummary.js';
@@ -66,9 +63,7 @@ export { default as Pagination } from './Pagination/Pagination.js';
66
63
  export { default as PaginationItem } from './Pagination/PaginationItem.js';
67
64
  export { default as PaginationJumper } from './Pagination/PaginationJumper.js';
68
65
  export { default as PaginationPageSize } from './Pagination/PaginationPageSize.js';
69
- export { default as Table } from './Table/Table.js';
70
- export { default as TableRefresh } from './Table/refresh/TableRefresh.js';
71
- export { default as useTableScroll } from './Table/useTableScroll.js';
66
+ export { Table } from './Table/Table.js';
72
67
  export { default as Tag } from './Tag/Tag.js';
73
68
  export { default as Tooltip } from './Tooltip/Tooltip.js';
74
69
  export { default as Tree } from './Tree/Tree.js';
@@ -152,8 +147,8 @@ export { default as Translate } from './Transition/Translate.js';
152
147
  export { default as ConfigProvider } from './Provider/ConfigProvider.js';
153
148
  export { useStepper } from './Stepper/useStepper.js';
154
149
  export { usePagination } from './Pagination/usePagination.js';
155
- export { SELECTED_ALL_KEY, useTableRowSelection } from './Table/rowSelection/useTableRowSelection.js';
156
- export { useTableDraggable } from './Table/draggable/useTableDraggable.js';
150
+ export { TableContext, TableDataContext, useTableContext, useTableDataContext } from './Table/TableContext.js';
151
+ export { useTableRowSelection } from './Table/utils/useTableRowSelection.js';
157
152
  export { getTreeNodeEntities } from './Tree/getTreeNodeEntities.js';
158
153
  export { toggleValue, toggleValueWithStatusControl, uniqueArray } from './Tree/toggleValue.js';
159
154
  export { traverseTree } from './Tree/traverseTree.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mezzanine-ui/react",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "React components for mezzanine-ui",
5
5
  "author": "Mezzanine",
6
6
  "repository": {
@@ -31,11 +31,13 @@
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-alpha.0",
35
- "@mezzanine-ui/icons": "^1.0.0-alpha.0",
36
- "@mezzanine-ui/system": "^1.0.0-alpha.0",
34
+ "@mezzanine-ui/core": "^1.0.0-beta.1",
35
+ "@mezzanine-ui/icons": "^1.0.0-beta.1",
36
+ "@mezzanine-ui/system": "^1.0.0-beta.1",
37
+ "@tanstack/react-virtual": "^3.13.13",
37
38
  "@types/react-transition-group": "^4.4.12",
38
39
  "clsx": "^2.1.1",
40
+ "keycode": "^2.2.1",
39
41
  "lodash": "^4.17.21",
40
42
  "react-transition-group": "^4.4.5",
41
43
  "tslib": "^2.8.1"
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Flattens nested React children into a single-level array. <br />
4
+ * Preserves keys by concatenating parent keys with child keys. <br />
5
+ * Handles fragments and nested fragments recursively. <br />
6
+ *
7
+ * @param children - The React children to flatten.
8
+ * @param recursionDepth - The maximum depth to recurse into fragments. Default is -1 (infinite).
9
+ * @param keys - The accumulated keys from parent elements.
10
+ * @returns An array of flattened React nodes.
11
+ */
12
+ export declare function flattenChildren(children: ReactNode, recursionDepth?: number, keys?: (string | number)[]): ReactNode[];
@@ -0,0 +1,37 @@
1
+ import { Children, isValidElement, Fragment, cloneElement } from 'react';
2
+
3
+ /**
4
+ * Flattens nested React children into a single-level array. <br />
5
+ * Preserves keys by concatenating parent keys with child keys. <br />
6
+ * Handles fragments and nested fragments recursively. <br />
7
+ *
8
+ * @param children - The React children to flatten.
9
+ * @param recursionDepth - The maximum depth to recurse into fragments. Default is -1 (infinite).
10
+ * @param keys - The accumulated keys from parent elements.
11
+ * @returns An array of flattened React nodes.
12
+ */
13
+ function flattenChildren(children, recursionDepth = -1, keys = []) {
14
+ if (recursionDepth === 0) {
15
+ return Children.toArray(children);
16
+ }
17
+ return Children.toArray(children).reduce((acc, node, nodeIndex) => {
18
+ if (isValidElement(node) && node.type === Fragment) {
19
+ acc.push(...flattenChildren(node.props.children, recursionDepth - 1, keys.concat(node.key || nodeIndex)));
20
+ }
21
+ else {
22
+ if (isValidElement(node)) {
23
+ acc.push(cloneElement(node, {
24
+ key: keys.concat(String(node.key)).join('.'),
25
+ }));
26
+ }
27
+ else if (typeof node === 'string' ||
28
+ typeof node === 'number' ||
29
+ typeof node === 'bigint') {
30
+ acc.push(node);
31
+ }
32
+ }
33
+ return acc;
34
+ }, []);
35
+ }
36
+
37
+ export { flattenChildren };
@@ -1 +1,2 @@
1
1
  export declare function getCSSVariableValue(variableName: string): string;
2
+ export declare function getNumericCSSVariablePixelValue(variableName: string): number;
@@ -5,5 +5,8 @@ function getCSSVariableValue(variableName) {
5
5
  .trim()
6
6
  : '';
7
7
  }
8
+ function getNumericCSSVariablePixelValue(variableName) {
9
+ return Number(getCSSVariableValue(variableName).replace('rem', '')) * 16;
10
+ }
8
11
 
9
- export { getCSSVariableValue };
12
+ export { getCSSVariableValue, getNumericCSSVariablePixelValue };
@@ -1,5 +0,0 @@
1
- import { NavigationOrientation } from '@mezzanine-ui/core/navigation';
2
- export interface NavigationContextValue {
3
- orientation: NavigationOrientation;
4
- }
5
- export declare const NavigationContext: import("react").Context<NavigationContextValue>;
@@ -1,8 +0,0 @@
1
- 'use client';
2
- import { createContext } from 'react';
3
-
4
- const NavigationContext = createContext({
5
- orientation: 'horizontal',
6
- });
7
-
8
- export { NavigationContext };
@@ -1,31 +0,0 @@
1
- import { Key, ReactNode } from 'react';
2
- import { IconDefinition } from '@mezzanine-ui/icons';
3
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
- export interface NavigationItemProps extends Omit<NativeElementPropsWithoutKeyAndRef<'li'>, 'onClick'> {
5
- /**
6
- * Whether the item is active.
7
- */
8
- active?: boolean;
9
- /**
10
- * Item display content.
11
- */
12
- children?: ReactNode;
13
- /**
14
- * Unique ID of the item.
15
- */
16
- key?: Key | null;
17
- /**
18
- * @ignore
19
- */
20
- eventKey?: Key | null;
21
- /**
22
- * Icon of the item.
23
- */
24
- icon?: IconDefinition;
25
- /**
26
- * Called when item is clicked.
27
- */
28
- onClick?: (key?: Key | string | null) => void;
29
- }
30
- declare const NavigationItem: import("react").ForwardRefExoticComponent<NavigationItemProps & import("react").RefAttributes<HTMLLIElement>>;
31
- export default NavigationItem;
@@ -1,23 +0,0 @@
1
- 'use client';
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { forwardRef, useContext, useCallback } from 'react';
4
- import { navigationItemClasses } from '@mezzanine-ui/core/navigation';
5
- import { NavigationContext } from './NavigationContext.js';
6
- import Icon from '../Icon/Icon.js';
7
- import cx from 'clsx';
8
-
9
- const NavigationItem = forwardRef((props, ref) => {
10
- const { active, children, className, eventKey, icon, onClick, ...rest } = props;
11
- const { orientation } = useContext(NavigationContext);
12
- const handleClick = useCallback((event) => {
13
- if (orientation === 'vertical') {
14
- event.stopPropagation();
15
- }
16
- if (onClick) {
17
- onClick(eventKey);
18
- }
19
- }, [eventKey, onClick, orientation]);
20
- return (jsxs("li", { ...rest, ref: ref, className: cx(navigationItemClasses.host, active && navigationItemClasses.active, className), role: "menuitem", onClick: handleClick, onKeyDown: () => { }, children: [icon && jsx(Icon, { className: navigationItemClasses.icon, icon: icon }), children] }));
21
- });
22
-
23
- export { NavigationItem as default };
@@ -1,22 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { NavigationItemProps } from './NavigationItem';
3
- export type NavigationSubMenuChild = ReactElement<NavigationItemProps>;
4
- export type NavigationSubMenuChildren = NavigationSubMenuChild | NavigationSubMenuChild[];
5
- export interface NavigationSubMenuProps extends Omit<NavigationItemProps, 'onClick' | 'eventKey' | 'key'> {
6
- /**
7
- * Strict children with `NavigationItem`.
8
- * @default []
9
- */
10
- children?: NavigationSubMenuChildren;
11
- /**
12
- * Set display title for sub-menu item.
13
- */
14
- title?: string;
15
- /**
16
- * Open menu as default
17
- * @default false
18
- */
19
- defaultOpen?: boolean;
20
- }
21
- declare const NavigationSubMenu: import("react").ForwardRefExoticComponent<NavigationSubMenuProps & import("react").RefAttributes<HTMLLIElement>>;
22
- export default NavigationSubMenu;
@@ -1,50 +0,0 @@
1
- 'use client';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { forwardRef, useState, useRef, useContext } from 'react';
4
- import { navigationSubMenuClasses } from '@mezzanine-ui/core/navigation';
5
- import { ChevronUpIcon, ChevronDownIcon } from '@mezzanine-ui/icons';
6
- import { offset, size } from '@floating-ui/react-dom';
7
- import { useClickAway } from '../hooks/useClickAway.js';
8
- import { useComposeRefs } from '../hooks/useComposeRefs.js';
9
- import NavigationItem from './NavigationItem.js';
10
- import { NavigationContext } from './NavigationContext.js';
11
- import Icon from '../Icon/Icon.js';
12
- import Popper from '../Popper/Popper.js';
13
- import Collapse from '../Transition/Collapse.js';
14
- import cx from 'clsx';
15
-
16
- // Middleware to make the submenu have the same width as the reference element
17
- const sameWidthMiddleware = size({
18
- apply({ rects, elements }) {
19
- Object.assign(elements.floating.style, {
20
- width: `${rects.reference.width}px`,
21
- });
22
- },
23
- });
24
- const NavigationSubMenu = forwardRef((props, ref) => {
25
- const { active, className, children = [], defaultOpen = false, icon, title, ...rest } = props;
26
- const [open, setOpen] = useState(defaultOpen);
27
- const nodeRef = useRef(null);
28
- const composedNodeRef = useComposeRefs([ref, nodeRef]);
29
- const { orientation } = useContext(NavigationContext);
30
- const GroupToggleIcon = open ? ChevronUpIcon : ChevronDownIcon;
31
- useClickAway(() => {
32
- if (!open || orientation === 'vertical') {
33
- return;
34
- }
35
- return () => {
36
- setOpen(!open);
37
- };
38
- }, nodeRef, [open, orientation]);
39
- const WrapChildren = jsx("ul", { className: navigationSubMenuClasses.group, children: children });
40
- return (jsxs(NavigationItem, { ...rest, ref: composedNodeRef, className: cx(navigationSubMenuClasses.host, active && navigationSubMenuClasses.active, open && navigationSubMenuClasses.open, icon && orientation === 'vertical' && navigationSubMenuClasses.indent, className), onClick: () => setOpen(!open), children: [jsxs("div", { className: navigationSubMenuClasses.title, children: [icon && jsx(Icon, { className: navigationSubMenuClasses.icon, icon: icon }), title, jsx(Icon, { className: navigationSubMenuClasses.toggleIcon, icon: GroupToggleIcon })] }), orientation === 'horizontal' && (jsx(Popper, { anchor: nodeRef, disablePortal: true, open: !!open, options: {
41
- middleware: [
42
- offset({ mainAxis: 0, crossAxis: 0 }),
43
- sameWidthMiddleware,
44
- ],
45
- }, children: WrapChildren })), orientation === 'vertical' && (jsx(Collapse, { style: {
46
- width: '100%',
47
- }, in: !!open, children: WrapChildren }))] }));
48
- });
49
-
50
- export { NavigationSubMenu as default };
@@ -1,10 +0,0 @@
1
- import { TableDataSource } from '@mezzanine-ui/core/table';
2
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
- export interface TableBodyProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
4
- /**
5
- * customize row className
6
- */
7
- rowClassName?: (source: TableDataSource) => string;
8
- }
9
- declare const TableBody: import("react").ForwardRefExoticComponent<TableBodyProps & import("react").RefAttributes<HTMLTableSectionElement>>;
10
- export default TableBody;
@@ -1,31 +0,0 @@
1
- 'use client';
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { forwardRef, useContext } from 'react';
4
- import { tableClasses } from '@mezzanine-ui/core/table';
5
- import { TableDataContext, TableContext } from './TableContext.js';
6
- import TableBodyRow from './TableBodyRow.js';
7
- import Spin from '../Spin/Spin.js';
8
- import Empty from '../Empty/Empty.js';
9
- import cx from 'clsx';
10
-
11
- const TableBody = forwardRef(function TableBody(props, ref) {
12
- const { className, rowClassName, ...rest } = props;
13
- const { dataSource = [] } = useContext(TableDataContext) || {};
14
- const { emptyProps, fetchMore, pagination } = useContext(TableContext) || {};
15
- /** customizing empty */
16
- const { className: emptyComponentClassName = '', children: emptyComponentChildren = '查無資料', fullHeight: emptyComponentFullHeight = true, ...restEmptyProps } = emptyProps || {};
17
- /** pagination feature */
18
- const { current: currentPage, disableAutoSlicing, total, options: paginationOptions, } = pagination || {};
19
- const currentStartCount = (paginationOptions === null || paginationOptions === void 0 ? void 0 : paginationOptions.pageSize) && currentPage
20
- ? paginationOptions.pageSize * (currentPage - 1)
21
- : 0;
22
- const currentEndCount = (paginationOptions === null || paginationOptions === void 0 ? void 0 : paginationOptions.pageSize) && currentPage && total
23
- ? Math.min(paginationOptions.pageSize * currentPage, total)
24
- : 0;
25
- const currentDataSource = pagination && !disableAutoSlicing
26
- ? dataSource.slice(currentStartCount, currentEndCount)
27
- : dataSource;
28
- return (jsxs("tbody", { ...rest, ref: ref, className: cx(tableClasses.body, className), children: [currentDataSource.length ? (currentDataSource.map((rowData, index) => (jsx(TableBodyRow, { className: rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(rowData), rowData: rowData, rowIndex: index }, (rowData.key || rowData.id))))) : (jsx("tr", { children: jsx("td", { children: jsx(Empty, { ...restEmptyProps, className: cx(tableClasses.bodyEmpty, emptyComponentClassName), fullHeight: emptyComponentFullHeight, children: emptyComponentChildren }) }) })), (fetchMore === null || fetchMore === void 0 ? void 0 : fetchMore.isFetching) ? (jsx("tr", { className: tableClasses.bodyFetchMore, children: jsx("td", { "aria-label": "Loading", children: jsx(Spin, { loading: true }) }) })) : null] }));
29
- });
30
-
31
- export { TableBody as default };
@@ -1,11 +0,0 @@
1
- import { TableDataSource } from '@mezzanine-ui/core/table';
2
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
- export interface TableBodyRowProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
4
- /**
5
- * table body row dataSource
6
- */
7
- rowData: TableDataSource;
8
- rowIndex: number;
9
- }
10
- declare const TableBodyRow: import("react").ForwardRefExoticComponent<TableBodyRowProps & import("react").RefAttributes<HTMLTableRowElement>>;
11
- export default TableBodyRow;
@@ -1,65 +0,0 @@
1
- 'use client';
2
- import { forwardRef, useContext, useState, useMemo, Fragment, createElement } from 'react';
3
- import { jsxs, jsx } from 'react/jsx-runtime';
4
- import { tableClasses, getColumnStyle, getCellStyle } from '@mezzanine-ui/core/table';
5
- import { Draggable } from '@hello-pangea/dnd';
6
- import get from 'lodash/get';
7
- import { TableContext, TableDataContext } from './TableContext.js';
8
- import TableCell from './TableCell.js';
9
- import TableExpandedTable from './TableExpandedTable.js';
10
- import TableRowSelection from './rowSelection/TableRowSelection.js';
11
- import TableExpandable from './expandable/TableExpandable.js';
12
- import TableEditRenderWrapper from './editable/TableEditRenderWrapper.js';
13
- import AccordionDetails from '../Accordion/AccordionDetails.js';
14
- import { composeRefs } from '../utils/composeRefs.js';
15
- import cx from 'clsx';
16
-
17
- const TableBodyRow = forwardRef(function TableBodyRow(props, ref) {
18
- const { className, rowData, rowIndex, ...rest } = props;
19
- const { rowSelection, expanding, isHorizontalScrolling, scroll, draggable, } = useContext(TableContext) || {};
20
- const { columns } = useContext(TableDataContext) || {};
21
- /** Feature rowSelection */
22
- const [selected, setSelected] = useState(false);
23
- /** Feature expandable */
24
- const [expanded, setExpanded] = useState(false);
25
- const isExpandable = useMemo(() => { var _a, _b; return (_b = (_a = expanding === null || expanding === void 0 ? void 0 : expanding.rowExpandable) === null || _a === void 0 ? void 0 : _a.call(expanding, rowData)) !== null && _b !== void 0 ? _b : false; }, [expanding, rowData]);
26
- const renderedExpandedContent = useMemo(() => { var _a, _b; return (_b = (_a = expanding === null || expanding === void 0 ? void 0 : expanding.expandedRowRender) === null || _a === void 0 ? void 0 : _a.call(expanding, rowData)) !== null && _b !== void 0 ? _b : null; }, [expanding, rowData]);
27
- /** Feature scrolling */
28
- const isFirstColumnShouldSticky = useMemo(() => {
29
- var _a;
30
- /** 前面有 action 時不可 sticky */
31
- if (rowSelection || expanding)
32
- return false;
33
- return (_a = scroll === null || scroll === void 0 ? void 0 : scroll.fixedFirstColumn) !== null && _a !== void 0 ? _a : false;
34
- }, [rowSelection, expanding, scroll === null || scroll === void 0 ? void 0 : scroll.fixedFirstColumn]);
35
- return (jsxs(Fragment, { children: [jsx(Draggable, { index: rowIndex, draggableId: rowData.key || rowData.id, isDragDisabled: !(draggable === null || draggable === void 0 ? void 0 : draggable.enabled), children: (draggableProvided) => (jsxs("tr", { ...rest, ...draggableProvided.draggableProps, ...draggableProvided.dragHandleProps, ref: composeRefs([ref, draggableProvided.innerRef]), className: cx(tableClasses.bodyRow, {
36
- [tableClasses.bodyRowHighlight]: selected || expanded,
37
- [tableClasses.bodyRowDragging]: (draggable === null || draggable === void 0 ? void 0 : draggable.draggingId) &&
38
- draggable.draggingId ===
39
- (rowData.key || rowData.id),
40
- }, className), children: [rowSelection ? (jsx("td", { "aria-label": "Selection", className: tableClasses.bodyRowCellWrapper, style: {
41
- flex: 'unset',
42
- minWidth: 'unset',
43
- }, children: jsx(TableRowSelection, { rowKey: (rowData.key || rowData.id), setChecked: (status) => setSelected(status), showDropdownIcon: false }) })) : null, expanding ? (jsx("td", { "aria-label": "Expand", className: tableClasses.bodyRowCellWrapper, style: {
44
- flex: 'unset',
45
- minWidth: 'unset',
46
- }, children: jsx(TableExpandable, { expandable: isExpandable, expanded: expanded, setExpanded: setExpanded, onExpand: (status) => { var _a; return (_a = expanding.onExpand) === null || _a === void 0 ? void 0 : _a.call(expanding, rowData, status); } }) })) : null, (columns !== null && columns !== void 0 ? columns : []).map((column, idx) => {
47
- var _a, _b, _c, _d;
48
- const autoGrabData = column.dataIndex
49
- ? get(rowData, column.dataIndex)
50
- : '';
51
- const ellipsis = (_a = column.ellipsis) !== null && _a !== void 0 ? _a : true;
52
- const tooltipTitle = ((_c = (_b = column.renderTooltipTitle) === null || _b === void 0 ? void 0 : _b.call(column, rowData)) !== null && _c !== void 0 ? _c : autoGrabData);
53
- return (jsx("td", { className: cx(tableClasses.bodyRowCellWrapper, isFirstColumnShouldSticky &&
54
- idx === 0 &&
55
- tableClasses.bodyRowCellWrapperFixed, isFirstColumnShouldSticky &&
56
- idx === 0 &&
57
- isHorizontalScrolling &&
58
- tableClasses.bodyRowCellWrapperFixedStuck, column.bodyClassName), style: getColumnStyle(column), children: createElement(TableEditRenderWrapper, { ...column, key: (rowData.key || rowData.id), rowData: rowData },
59
- jsx(TableCell, { ellipsis: ellipsis, forceShownTooltipWhenHovered: column.forceShownTooltipWhenHovered, style: getCellStyle(column), tooltipTitle: tooltipTitle, children: ((_d = column.render) === null || _d === void 0 ? void 0 : _d.call(column, rowData, rowIndex, column)) ||
60
- autoGrabData })) }, `${idx + 1}-${rowData.key || rowData.id}`));
61
- })] })) }, rowData.key || rowData.id), renderedExpandedContent ? (jsx("tr", { children: jsx("td", { style: { padding: 0 }, children: jsx(AccordionDetails, { className: cx(expanding
62
- .className, tableClasses.bodyRowExpandedTableWrapper), expanded: expanded, children: (renderedExpandedContent === null || renderedExpandedContent === void 0 ? void 0 : renderedExpandedContent.dataSource) ? (jsx(TableExpandedTable, { renderedExpandedContent: renderedExpandedContent })) : renderedExpandedContent }) }) })) : null] }));
63
- });
64
-
65
- export { TableBodyRow as default };
@@ -1,19 +0,0 @@
1
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
2
- export interface TableCellProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
3
- /**
4
- * whether cell content should be ellipsis
5
- * @default true
6
- */
7
- ellipsis?: boolean;
8
- /**
9
- * whether tooltip is force to shown when hovered
10
- * @default false
11
- */
12
- forceShownTooltipWhenHovered?: boolean;
13
- /**
14
- * tooltip title that you want to display
15
- */
16
- tooltipTitle?: string | number;
17
- }
18
- declare const TableCell: import("react").ForwardRefExoticComponent<TableCellProps & import("react").RefAttributes<HTMLDivElement>>;
19
- export default TableCell;
@@ -1,24 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useRef } from 'react';
3
- import { tableClasses } from '@mezzanine-ui/core/table';
4
- import Tooltip from '../Tooltip/Tooltip.js';
5
- import cx from 'clsx';
6
-
7
- const TableCell = forwardRef(function TableCell(props, ref) {
8
- const { children, className, ellipsis = true, forceShownTooltipWhenHovered = false, tooltipTitle, ...rest } = props;
9
- const ellipsisRef = useRef(null);
10
- return (jsx("div", { ref: ref, ...rest, className: cx(tableClasses.cell, className), children: ellipsis || forceShownTooltipWhenHovered ? (jsx(Tooltip, { title: `${tooltipTitle}`, options: {
11
- placement: 'top-start',
12
- }, children: ({ onMouseEnter, onMouseLeave }) => (jsx("div", { ref: ellipsisRef, className: ellipsis ? tableClasses.cellEllipsis : '', onMouseEnter: (e) => {
13
- if (ellipsisRef.current) {
14
- const { current: el } = ellipsisRef;
15
- const isOverflow = forceShownTooltipWhenHovered ||
16
- el.scrollWidth > el.offsetWidth;
17
- /** display tooltip only when content is overflow */
18
- if (isOverflow)
19
- onMouseEnter(e);
20
- }
21
- }, onMouseLeave: onMouseLeave, children: children })) })) : (children) }));
22
- });
23
-
24
- export { TableCell as default };
@@ -1,11 +0,0 @@
1
- import { TableDataSource, ExpandedTableColumn } from '@mezzanine-ui/core/table';
2
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
- export interface TableExpandedTableProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
4
- renderedExpandedContent: {
5
- dataSource: TableDataSource[];
6
- columns?: ExpandedTableColumn[];
7
- className?: string;
8
- };
9
- }
10
- declare const TableExpandedTable: import("react").ForwardRefExoticComponent<TableExpandedTableProps & import("react").RefAttributes<HTMLDivElement>>;
11
- export default TableExpandedTable;
@@ -1,29 +0,0 @@
1
- 'use client';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { forwardRef, useContext } from 'react';
4
- import { tableClasses, getColumnStyle, getCellStyle } from '@mezzanine-ui/core/table';
5
- import get from 'lodash/get';
6
- import { TableDataContext } from './TableContext.js';
7
- import TableCell from './TableCell.js';
8
- import TableExpandable from './expandable/TableExpandable.js';
9
- import cx from 'clsx';
10
-
11
- const TableExpandedTable = forwardRef(function TableExpandedTable(props, ref) {
12
- const { renderedExpandedContent } = props;
13
- const { columns } = useContext(TableDataContext) || {};
14
- return (jsx("div", { className: tableClasses.bodyRowExpandedTable, children: renderedExpandedContent.dataSource.map((source, sourceIndex) => {
15
- var _a;
16
- return (jsxs("div", { ref: ref, className: cx(tableClasses.bodyRow, tableClasses.bodyRowExpandedTableRow, renderedExpandedContent.className), role: "row", children: [jsx(TableExpandable, { showIcon: false }), ((_a = (renderedExpandedContent.columns || columns)) !== null && _a !== void 0 ? _a : []).map((column, index) => {
17
- var _a, _b, _c, _d;
18
- const autoGrabData = column.dataIndex
19
- ? get(source, column.dataIndex)
20
- : '';
21
- const ellipsis = !!autoGrabData && ((_a = column.ellipsis) !== null && _a !== void 0 ? _a : true);
22
- const tooltipTitle = ((_c = (_b = column.renderTooltipTitle) === null || _b === void 0 ? void 0 : _b.call(column, source)) !== null && _c !== void 0 ? _c : autoGrabData);
23
- return (jsx("div", { className: cx(tableClasses.bodyRowCellWrapper, column.bodyClassName), style: getColumnStyle((columns !== null && columns !== void 0 ? columns : [])[index]), children: jsx(TableCell, { ellipsis: ellipsis, forceShownTooltipWhenHovered: column.forceShownTooltipWhenHovered, style: getCellStyle((columns !== null && columns !== void 0 ? columns : [])[index]), tooltipTitle: tooltipTitle || '', children: ((_d = column.render) === null || _d === void 0 ? void 0 : _d.call(column, source, sourceIndex, column)) ||
24
- autoGrabData }) }, `${index + 1}`));
25
- })] }, (source.key || source.id)));
26
- }) }));
27
- });
28
-
29
- export { TableExpandedTable as default };
@@ -1,3 +0,0 @@
1
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
2
- declare const TableHeader: import("react").ForwardRefExoticComponent<NativeElementPropsWithoutKeyAndRef<"div"> & import("react").RefAttributes<HTMLTableRowElement>>;
3
- export default TableHeader;
@@ -1,36 +0,0 @@
1
- 'use client';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { forwardRef, useContext, useMemo } from 'react';
4
- import { tableClasses, getColumnStyle, getCellStyle } from '@mezzanine-ui/core/table';
5
- import { TableContext, TableDataContext } from './TableContext.js';
6
- import { SELECTED_ALL_KEY } from './rowSelection/useTableRowSelection.js';
7
- import TableCell from './TableCell.js';
8
- import TableRowSelection from './rowSelection/TableRowSelection.js';
9
- import TableSortingIcon from './sorting/TableSortingIcon.js';
10
- import TableExpandable from './expandable/TableExpandable.js';
11
- import cx from 'clsx';
12
-
13
- const TableHeader = forwardRef(function TableHeader(props, ref) {
14
- const { className, ...rest } = props;
15
- const { rowSelection, isHorizontalScrolling, scroll, expanding } = useContext(TableContext) || {};
16
- const { columns } = useContext(TableDataContext) || {};
17
- const isFirstColumnShouldSticky = useMemo(() => {
18
- var _a;
19
- /** 前面有 action 時不可 sticky */
20
- if (rowSelection || expanding)
21
- return false;
22
- return (_a = scroll === null || scroll === void 0 ? void 0 : scroll.fixedFirstColumn) !== null && _a !== void 0 ? _a : false;
23
- }, [rowSelection, expanding, scroll === null || scroll === void 0 ? void 0 : scroll.fixedFirstColumn]);
24
- return (jsx("thead", { className: tableClasses.headerFixed, children: jsxs("tr", { ref: ref, ...rest, className: cx(tableClasses.header, className), children: [rowSelection ? (jsx("th", { "aria-label": "Row Selection", style: { display: 'flex' }, children: jsx(TableRowSelection, { rowKey: SELECTED_ALL_KEY, showDropdownIcon: true }) })) : null, expanding && !rowSelection ? (jsx("th", { "aria-label": "Row Expansion", style: { display: 'flex' }, children: jsx(TableExpandable, { showIcon: false }) })) : null, (columns !== null && columns !== void 0 ? columns : []).map((column, idx) => {
25
- var _a;
26
- return (jsx("th", { className: cx(tableClasses.headerCellWrapper, isFirstColumnShouldSticky &&
27
- idx === 0 &&
28
- tableClasses.headerCellWrapperFixed, isFirstColumnShouldSticky &&
29
- idx === 0 &&
30
- isHorizontalScrolling &&
31
- tableClasses.headerCellWrapperFixedStuck, column.headerClassName), style: getColumnStyle(column), children: jsxs(TableCell, { ellipsis: false, style: getCellStyle(column), children: [((_a = column.renderTitle) === null || _a === void 0 ? void 0 : _a.call(column, tableClasses)) || column.title, typeof column.sorter === 'function' ||
32
- typeof column.onSorted === 'function' ? (jsx(TableSortingIcon, { column: column })) : null] }) }, `${idx + 1}`));
33
- })] }) }));
34
- });
35
-
36
- export { TableHeader as default };
@@ -1,14 +0,0 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
- import { TableDataSource, TableDraggable } from '@mezzanine-ui/core/table';
3
- export interface UseTableDraggable {
4
- dataSource: TableDataSource[];
5
- setDataSource: Dispatch<SetStateAction<TableDataSource[]>>;
6
- draggable?: TableDraggable;
7
- }
8
- export declare function useTableDraggable(props: UseTableDraggable): {
9
- draggingId: string;
10
- onBeforeDragStart: (e: {
11
- draggableId: SetStateAction<string>;
12
- }) => void;
13
- onDragEnd: import("@hello-pangea/dnd").OnDragEndResponder<string>;
14
- };
@@ -1,64 +0,0 @@
1
- import { useRef, useState, useEffect, useCallback } from 'react';
2
- import isEqual from 'lodash/isEqual';
3
- import debounce from 'lodash/debounce';
4
- import { arrayMove } from '../../utils/array-move.js';
5
- import { usePreviousValue } from '../../hooks/usePreviousValue.js';
6
-
7
- function useTableDraggable(props) {
8
- const { dataSource, setDataSource, draggable } = props;
9
- const resultSnapshot = useRef(null);
10
- const dataSnapShot = useRef(dataSource);
11
- const isDragging = useRef(false);
12
- const [draggingId, setDraggingId] = useState('');
13
- const prevDataSource = usePreviousValue(dataSource);
14
- useEffect(() => {
15
- if (!isEqual(prevDataSource, dataSource)) {
16
- dataSnapShot.current = dataSource;
17
- }
18
- }, [prevDataSource, dataSource]);
19
- const onBeforeDragStart = useCallback((e) => {
20
- isDragging.current = true;
21
- setDraggingId(e.draggableId);
22
- }, []);
23
- const onDragEnd = useCallback(async (result, id) => {
24
- var _a, _b;
25
- resultSnapshot.current = [result, id];
26
- isDragging.current = false;
27
- setDraggingId('');
28
- const temp = [...dataSnapShot.current];
29
- const from = result.source.index;
30
- const to = (_b = (_a = result.destination) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : from;
31
- const newData = arrayMove(temp, from, to);
32
- dataSnapShot.current = newData;
33
- setDataSource(newData);
34
- }, [setDataSource]);
35
- useEffect(() => {
36
- if (!(draggable === null || draggable === void 0 ? void 0 : draggable.enabled))
37
- return () => { };
38
- async function onMouseUp() {
39
- var _a, _b, _c;
40
- if (isDragging.current)
41
- return;
42
- const args = resultSnapshot.current;
43
- resultSnapshot.current = null;
44
- if (!(args === null || args === void 0 ? void 0 : args[0]) ||
45
- ((_a = args === null || args === void 0 ? void 0 : args[0]) === null || _a === void 0 ? void 0 : _a.source.index) === ((_c = (_b = args === null || args === void 0 ? void 0 : args[0]) === null || _b === void 0 ? void 0 : _b.destination) === null || _c === void 0 ? void 0 : _c.index))
46
- return;
47
- if ((draggable === null || draggable === void 0 ? void 0 : draggable.onDragEnd) && args) {
48
- draggable.onDragEnd(Array.from(dataSnapShot.current));
49
- }
50
- }
51
- const debouncedOnMouseUp = debounce(onMouseUp, 500);
52
- window.addEventListener('mouseup', debouncedOnMouseUp, false);
53
- return () => {
54
- window.removeEventListener('mouseup', debouncedOnMouseUp, false);
55
- };
56
- }, [draggable]);
57
- return {
58
- draggingId,
59
- onBeforeDragStart,
60
- onDragEnd,
61
- };
62
- }
63
-
64
- export { useTableDraggable };