@pdg/react-table 1.0.19 → 1.0.21
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/dist/TableContext/TableContext.d.ts +4 -0
- package/dist/TableContext/TableContext.types.d.ts +6 -0
- package/dist/TableContext/index.d.ts +5 -0
- package/dist/TableContext/useTableState.d.ts +2 -0
- package/dist/TableContextProvider/TableContextProvider.d.ts +4 -0
- package/dist/TableContextProvider/TableContextProvider.types.d.ts +6 -0
- package/dist/TableContextProvider/index.d.ts +4 -0
- package/dist/TableMenuButton/TableMenuButton.d.ts +4 -0
- package/dist/TableMenuButton/TableMenuButton.types.d.ts +11 -0
- package/dist/TableMenuButton/index.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +180 -44
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +179 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TableMenuButtonProps as Props } from './TableMenuButton.types';
|
|
3
|
+
declare const TableMenuButton: React.ForwardRefExoticComponent<Pick<Props, "children" | "className" | "style" | "classes" | "form" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "href" | "startIcon" | "variant" | "key" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "icon" | "placement" | "menuList"> & React.RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export default TableMenuButton;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonProps } from '@mui/material';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { PopperPlacementType } from '@mui/base/Popper/Popper.types';
|
|
4
|
+
export interface TableMenuButtonProps extends Omit<ButtonProps, 'size' | 'startIcon' | 'endIcon' | 'onClick'> {
|
|
5
|
+
icon?: string;
|
|
6
|
+
startIcon?: string;
|
|
7
|
+
endIcon?: string;
|
|
8
|
+
placement?: PopperPlacementType;
|
|
9
|
+
menuList: ReactElement;
|
|
10
|
+
}
|
|
11
|
+
export declare const TableMenuButtonDefaultProps: Pick<TableMenuButtonProps, 'variant' | 'color' | 'placement'>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as React from'react';import React__default,{useRef,useEffect,cloneElement,useState,isValidElement,createRef,PureComponent,useLayoutEffect,useMemo,useCallback}from'react';import {styled,TableRow,lighten,TableCell,Box,Tooltip,Stack,Pagination,Paper,Table as Table$1,TableHead,TableBody,Icon,TableFooter,Grid,Button}from'@mui/material';import {findDOMNode}from'react-dom';import {useSortable,sortableKeyboardCoordinates,arrayMove,SortableContext,verticalListSortingStrategy}from'@dnd-kit/sortable';import dayjs from'dayjs';import {useSensors,useSensor,MouseSensor,TouchSensor,KeyboardSensor,DndContext,closestCenter}from'@dnd-kit/core';import {Search,SearchGroup,FormHidden}from'@pdg/react-form';/******************************************************************************
|
|
1
|
+
import*as React from'react';import React__default,{useRef,useEffect,cloneElement,useState,isValidElement,createRef,PureComponent,useLayoutEffect,createContext,useContext,useMemo,useCallback,useId}from'react';import {styled,TableRow,lighten,TableCell,Box,Tooltip,Stack,Pagination,Paper,Table as Table$1,TableHead,TableBody,Icon,TableFooter,Grid,Button,Popper,Grow,ClickAwayListener}from'@mui/material';import {findDOMNode}from'react-dom';import {useSortable,sortableKeyboardCoordinates,arrayMove,SortableContext,verticalListSortingStrategy}from'@dnd-kit/sortable';import dayjs from'dayjs';import {useSensors,useSensor,MouseSensor,TouchSensor,KeyboardSensor,DndContext,closestCenter}from'@dnd-kit/core';import {Search,SearchGroup,FormHidden}from'@pdg/react-form';/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -8336,11 +8336,31 @@ var equal = function (v1, v2) {
|
|
|
8336
8336
|
default:
|
|
8337
8337
|
return column.align || defaultAlign;
|
|
8338
8338
|
}
|
|
8339
|
+
}var TableContextDefaultValue = {
|
|
8340
|
+
menuOpen: false,
|
|
8341
|
+
openMenuId: undefined,
|
|
8342
|
+
// eslint-disable-next-line
|
|
8343
|
+
setMenuOpen: function () { },
|
|
8344
|
+
};var TableContext = createContext(TableContextDefaultValue);function useTableState() {
|
|
8345
|
+
var value = useContext(TableContext);
|
|
8346
|
+
if (value === undefined) {
|
|
8347
|
+
throw new Error('useFormState should be used within TableContext.Provider');
|
|
8348
|
+
}
|
|
8349
|
+
return value;
|
|
8339
8350
|
}var StyledTableCell = styled(TableCell)(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n &.ellipsis {\n position: relative;\n max-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n"], ["\n &.ellipsis {\n position: relative;\n max-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n"])));
|
|
8340
8351
|
var TableCommonCell = function (_a) {
|
|
8352
|
+
// Use ---------------------------------------------------------------------------------------------------------------
|
|
8341
8353
|
var children = _a.children, initClassName = _a.className, initStyle = _a.style, initSx = _a.sx, type = _a.type, column = _a.column, defaultAlign = _a.defaultAlign, initDefaultEllipsis = _a.defaultEllipsis, index = _a.index, item = _a.item, onClick = _a.onClick;
|
|
8354
|
+
var menuOpen = useTableState().menuOpen;
|
|
8355
|
+
// Memo --------------------------------------------------------------------------------------------------------------
|
|
8342
8356
|
var align = useMemo(function () { return getTableColumnAlign(column, defaultAlign); }, [column, defaultAlign]);
|
|
8343
|
-
var ellipsis = useMemo(function () {
|
|
8357
|
+
var ellipsis = useMemo(function () {
|
|
8358
|
+
return type !== 'head' &&
|
|
8359
|
+
column.type !== 'img' &&
|
|
8360
|
+
column.type !== 'button' &&
|
|
8361
|
+
column.type !== 'buttons' &&
|
|
8362
|
+
(column.ellipsis != null ? column.ellipsis : !!initDefaultEllipsis);
|
|
8363
|
+
}, [type, column, initDefaultEllipsis]);
|
|
8344
8364
|
var className = useMemo(function () {
|
|
8345
8365
|
var _a, _b, _c, _d, _e, _f;
|
|
8346
8366
|
var className;
|
|
@@ -8433,26 +8453,30 @@ var TableCommonCell = function (_a) {
|
|
|
8433
8453
|
}, [column, index, initSx, item, type]);
|
|
8434
8454
|
// Event Handler ---------------------------------------------------------------------------------------------------
|
|
8435
8455
|
var handleClick = useCallback(function (e) {
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
if (
|
|
8439
|
-
if (
|
|
8440
|
-
column.onClick
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
onClick
|
|
8456
|
+
if (!menuOpen) {
|
|
8457
|
+
e.stopPropagation();
|
|
8458
|
+
if (type === 'body') {
|
|
8459
|
+
if (item != null && index != null) {
|
|
8460
|
+
if (column.onClick) {
|
|
8461
|
+
column.onClick(item, index);
|
|
8462
|
+
}
|
|
8463
|
+
else {
|
|
8464
|
+
if (onClick)
|
|
8465
|
+
onClick(item, index);
|
|
8466
|
+
}
|
|
8445
8467
|
}
|
|
8446
8468
|
}
|
|
8447
8469
|
}
|
|
8448
|
-
}, [type,
|
|
8470
|
+
}, [menuOpen, type, item, index, column, onClick]);
|
|
8449
8471
|
// Render ----------------------------------------------------------------------------------------------------------
|
|
8450
8472
|
return (React__default.createElement(StyledTableCell, { align: align, className: classNames(className, 'TableCommonCell', ellipsis && 'ellipsis', column.type ? "column-type-".concat(column.type) : false), style: style, sx: sx, onClick: type === 'body' ? handleClick : undefined }, children));
|
|
8451
8473
|
};
|
|
8452
8474
|
var templateObject_1$1;var StyledButtonsBox = styled(Box)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"], ["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"])));
|
|
8453
8475
|
var TableBodyCell = function (_a) {
|
|
8454
|
-
//
|
|
8476
|
+
// Use ---------------------------------------------------------------------------------------------------------------
|
|
8455
8477
|
var item = _a.item, index = _a.index, column = _a.column, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, onClick = _a.onClick;
|
|
8478
|
+
var menuOpen = useTableState().menuOpen;
|
|
8479
|
+
// Memo --------------------------------------------------------------------------------------------------------------
|
|
8456
8480
|
var buttonsBoxJustifyContent = useMemo(function () {
|
|
8457
8481
|
switch (getTableColumnAlign(column, defaultAlign)) {
|
|
8458
8482
|
case 'center':
|
|
@@ -8485,10 +8509,10 @@ var TableBodyCell = function (_a) {
|
|
|
8485
8509
|
}
|
|
8486
8510
|
break;
|
|
8487
8511
|
case 'button':
|
|
8488
|
-
data = (React__default.createElement(Box, { className: 'TableBoxyCell-button-box', onClick: function (e) { return e.stopPropagation(); } }, data));
|
|
8512
|
+
data = (React__default.createElement(Box, { className: 'TableBoxyCell-button-box', onClick: menuOpen ? undefined : function (e) { return e.stopPropagation(); } }, data));
|
|
8489
8513
|
break;
|
|
8490
8514
|
case 'buttons':
|
|
8491
|
-
data = (React__default.createElement(StyledButtonsBox, { className: 'TableBodyCell-buttons-box', justifyContent: buttonsBoxJustifyContent, onClick: function (e) { return e.stopPropagation(); } }, data));
|
|
8515
|
+
data = (React__default.createElement(StyledButtonsBox, { className: 'TableBodyCell-buttons-box', justifyContent: buttonsBoxJustifyContent, onClick: menuOpen ? undefined : function (e) { return e.stopPropagation(); } }, data));
|
|
8492
8516
|
break;
|
|
8493
8517
|
}
|
|
8494
8518
|
switch (column.type) {
|
|
@@ -8496,9 +8520,11 @@ var TableBodyCell = function (_a) {
|
|
|
8496
8520
|
{
|
|
8497
8521
|
var img = React__default.createElement("img", { src: data, style: { maxWidth: '100%', verticalAlign: 'middle' }, alt: '' });
|
|
8498
8522
|
var placement = ((_a = column.tooltipProps) === null || _a === void 0 ? void 0 : _a.placement) ? (_b = column.tooltipProps) === null || _b === void 0 ? void 0 : _b.placement : 'left';
|
|
8499
|
-
data = (React__default.createElement("a", { href: data, target: '_blank', onClick:
|
|
8500
|
-
|
|
8501
|
-
|
|
8523
|
+
data = (React__default.createElement("a", { href: data, target: '_blank', onClick: menuOpen
|
|
8524
|
+
? undefined
|
|
8525
|
+
: function (e) {
|
|
8526
|
+
e.stopPropagation();
|
|
8527
|
+
} },
|
|
8502
8528
|
React__default.createElement(Tooltip, __assign$1({ className: 'TableBodyCell-tooltip', title: React__default.createElement("div", { style: { paddingTop: 3, paddingBottom: 3 } }, img) }, column.tooltipProps, { placement: placement }), img)));
|
|
8503
8529
|
}
|
|
8504
8530
|
break;
|
|
@@ -8525,8 +8551,7 @@ var TableBodyCell = function (_a) {
|
|
|
8525
8551
|
break;
|
|
8526
8552
|
}
|
|
8527
8553
|
setData(data);
|
|
8528
|
-
|
|
8529
|
-
}, [item, column]);
|
|
8554
|
+
}, [item, column, index, buttonsBoxJustifyContent, menuOpen]);
|
|
8530
8555
|
// Event Handler ---------------------------------------------------------------------------------------------------
|
|
8531
8556
|
var handleClick = useCallback(function (item, index) {
|
|
8532
8557
|
if (column.onClick) {
|
|
@@ -8688,7 +8713,10 @@ TableBodyRow.defaultProps = TableBodyRowDefaultProps;var TableHeadCell = functio
|
|
|
8688
8713
|
style.appendChild(document.createTextNode(css));
|
|
8689
8714
|
}
|
|
8690
8715
|
}var css_248z = "[data-simplebar]{position:relative;flex-direction:column;flex-wrap:wrap;justify-content:flex-start;align-content:flex-start;align-items:flex-start}.simplebar-wrapper{overflow:hidden;width:inherit;height:inherit;max-width:inherit;max-height:inherit}.simplebar-mask{direction:inherit;position:absolute;overflow:hidden;padding:0;margin:0;left:0;top:0;bottom:0;right:0;width:auto!important;height:auto!important;z-index:0}.simplebar-offset{direction:inherit!important;box-sizing:inherit!important;resize:none!important;position:absolute;top:0;left:0;bottom:0;right:0;padding:0;margin:0;-webkit-overflow-scrolling:touch}.simplebar-content-wrapper{direction:inherit;box-sizing:border-box!important;position:relative;display:block;height:100%;width:auto;max-width:100%;max-height:100%;scrollbar-width:none;-ms-overflow-style:none}.simplebar-content-wrapper::-webkit-scrollbar,.simplebar-hide-scrollbar::-webkit-scrollbar{width:0;height:0}.simplebar-content:after,.simplebar-content:before{content:' ';display:table}.simplebar-placeholder{max-height:100%;max-width:100%;width:100%;pointer-events:none}.simplebar-height-auto-observer-wrapper{box-sizing:inherit!important;height:100%;width:100%;max-width:1px;position:relative;float:left;max-height:1px;overflow:hidden;z-index:-1;padding:0;margin:0;pointer-events:none;flex-grow:inherit;flex-shrink:0;flex-basis:0}.simplebar-height-auto-observer{box-sizing:inherit;display:block;opacity:0;position:absolute;top:0;left:0;height:1000%;width:1000%;min-height:1px;min-width:1px;overflow:hidden;pointer-events:none;z-index:-1}.simplebar-track{z-index:1;position:absolute;right:0;bottom:0;pointer-events:none;overflow:hidden}[data-simplebar].simplebar-dragging .simplebar-content{pointer-events:none;user-select:none;-webkit-user-select:none}[data-simplebar].simplebar-dragging .simplebar-track{pointer-events:all}.simplebar-scrollbar{position:absolute;left:0;right:0;min-height:10px}.simplebar-scrollbar:before{position:absolute;content:'';background:#000;border-radius:7px;left:2px;right:2px;opacity:0;transition:opacity .2s .5s linear}.simplebar-scrollbar.simplebar-visible:before{opacity:.5;transition-delay:0s;transition-duration:0s}.simplebar-track.simplebar-vertical{top:0;width:11px}.simplebar-scrollbar:before{top:2px;bottom:2px;left:2px;right:2px}.simplebar-track.simplebar-horizontal{left:0;height:11px}.simplebar-track.simplebar-horizontal .simplebar-scrollbar{right:auto;left:0;top:0;bottom:0;min-height:0;min-width:10px;width:auto}[data-simplebar-direction=rtl] .simplebar-track.simplebar-vertical{right:auto;left:0}.simplebar-dummy-scrollbar-size{direction:rtl;position:fixed;opacity:0;visibility:hidden;height:500px;width:500px;overflow-y:hidden;overflow-x:scroll;-ms-overflow-style:scrollbar!important}.simplebar-dummy-scrollbar-size>div{width:200%;height:200%;margin:10px 0}.simplebar-hide-scrollbar{position:fixed;left:0;visibility:hidden;overflow-y:scroll;scrollbar-width:none;-ms-overflow-style:none}\n";
|
|
8691
|
-
styleInject(css_248z);function
|
|
8716
|
+
styleInject(css_248z);var TableContextProvider = function (_a) {
|
|
8717
|
+
var children = _a.children, value = _a.value;
|
|
8718
|
+
return React__default.createElement(TableContext.Provider, { value: value }, children);
|
|
8719
|
+
};function columnFilter(v) {
|
|
8692
8720
|
return v !== undefined && v !== null && v !== false;
|
|
8693
8721
|
}
|
|
8694
8722
|
var Table = React__default.forwardRef(function (_a, ref) {
|
|
@@ -8710,8 +8738,11 @@ var Table = React__default.forwardRef(function (_a, ref) {
|
|
|
8710
8738
|
}), useSensor(KeyboardSensor, {
|
|
8711
8739
|
coordinateGetter: sortableKeyboardCoordinates,
|
|
8712
8740
|
}));
|
|
8741
|
+
// State -------------------------------------------------------------------------------------------------------------
|
|
8742
|
+
var _b = useState(false), menuOpen = _b[0], setMenuOpen = _b[1];
|
|
8743
|
+
var _c = useState(undefined), openMenuId = _c[0], setOpenMenuId = _c[1];
|
|
8713
8744
|
// State - containerHeight -------------------------------------------------------------------------------------------
|
|
8714
|
-
var
|
|
8745
|
+
var _d = useState(), containerHeight = _d[0], setContainerHeight = _d[1];
|
|
8715
8746
|
var containerHeightDetector = useResizeDetector({
|
|
8716
8747
|
handleHeight: true,
|
|
8717
8748
|
handleWidth: false,
|
|
@@ -8725,7 +8756,7 @@ var Table = React__default.forwardRef(function (_a, ref) {
|
|
|
8725
8756
|
},
|
|
8726
8757
|
}).ref;
|
|
8727
8758
|
// State - footerHeight --------------------------------------------------------------------------------------------
|
|
8728
|
-
var
|
|
8759
|
+
var _e = useState(), pagingHeight = _e[0], setPagingHeight = _e[1];
|
|
8729
8760
|
var pagingHeightResizeDetector = useResizeDetector({
|
|
8730
8761
|
handleHeight: true,
|
|
8731
8762
|
handleWidth: false,
|
|
@@ -8739,11 +8770,11 @@ var Table = React__default.forwardRef(function (_a, ref) {
|
|
|
8739
8770
|
},
|
|
8740
8771
|
}).ref;
|
|
8741
8772
|
// State -----------------------------------------------------------------------------------------------------------
|
|
8742
|
-
var
|
|
8743
|
-
var
|
|
8744
|
-
var
|
|
8745
|
-
var
|
|
8746
|
-
var
|
|
8773
|
+
var _f = useAutoUpdateLayoutState(initColumns), columns = _f[0], setColumns = _f[1];
|
|
8774
|
+
var _g = useState(), finalColumns = _g[0], setFinalColumns = _g[1];
|
|
8775
|
+
var _h = useAutoUpdateLayoutState(initItems), items = _h[0], setItems = _h[1];
|
|
8776
|
+
var _j = useState(), sortableItems = _j[0], setSortableItems = _j[1];
|
|
8777
|
+
var _k = useAutoUpdateLayoutState(initPaging), paging = _k[0], setPaging = _k[1];
|
|
8747
8778
|
// Memo --------------------------------------------------------------------------------------------------------------
|
|
8748
8779
|
var tableSx = useMemo(function () {
|
|
8749
8780
|
var sx = {
|
|
@@ -8874,21 +8905,37 @@ var Table = React__default.forwardRef(function (_a, ref) {
|
|
|
8874
8905
|
return style;
|
|
8875
8906
|
}, [fullHeight]);
|
|
8876
8907
|
// Render ----------------------------------------------------------------------------------------------------------
|
|
8877
|
-
return finalColumns ? (React__default.createElement(
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8908
|
+
return finalColumns ? (React__default.createElement(TableContextProvider, { value: {
|
|
8909
|
+
menuOpen: menuOpen,
|
|
8910
|
+
openMenuId: openMenuId,
|
|
8911
|
+
setMenuOpen: function (newMenuOpen, newOpenMenuId) {
|
|
8912
|
+
if (newMenuOpen) {
|
|
8913
|
+
setMenuOpen(newMenuOpen);
|
|
8914
|
+
setOpenMenuId(newOpenMenuId);
|
|
8915
|
+
}
|
|
8916
|
+
else {
|
|
8917
|
+
if (openMenuId === newOpenMenuId) {
|
|
8918
|
+
setMenuOpen(false);
|
|
8919
|
+
setOpenMenuId(undefined);
|
|
8920
|
+
}
|
|
8921
|
+
}
|
|
8922
|
+
},
|
|
8923
|
+
} },
|
|
8924
|
+
React__default.createElement(Paper, { ref: fullHeight ? containerHeightDetector : undefined, className: classNames('Table', className), variant: 'outlined', style: style, sx: sx },
|
|
8925
|
+
React__default.createElement(SimpleBar, { style: simpleBarStyle },
|
|
8926
|
+
React__default.createElement(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd },
|
|
8927
|
+
React__default.createElement(Table$1, { stickyHeader: !isNoData && stickyHeader, sx: tableSx, style: tableStyle },
|
|
8928
|
+
React__default.createElement(TableHead, null,
|
|
8929
|
+
React__default.createElement(TableRow, null, finalColumns.map(function (column, idx) { return (React__default.createElement(TableHeadCell, { key: idx, column: column, defaultAlign: defaultAlign })); }))),
|
|
8930
|
+
React__default.createElement(TableBody, null, sortableItems ? (sortableItems.length > 0 ? (React__default.createElement(SortableContext, { items: sortableItems, strategy: verticalListSortingStrategy }, sortableItems.map(function (item, idx) { return (React__default.createElement(TableBodyRow, { key: item.id, className: classNames(!!showOddColor && 'odd-color', !!showEvenColor && 'even-color'), hover: true, sx: onGetBodyRowSx ? onGetBodyRowSx(item, idx) : undefined, id: item.id, index: idx, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, sortable: sortable, columns: finalColumns, item: item, onClick: onClick })); }))) : (React__default.createElement(StyledBodyRow$1, null,
|
|
8931
|
+
React__default.createElement(TableCell, { colSpan: finalColumns.length, style: { flex: 1 } }, noData ? (noData) : (React__default.createElement(StyledNoDataDiv, null,
|
|
8932
|
+
React__default.createElement("div", null,
|
|
8933
|
+
React__default.createElement(Icon, null, "error")),
|
|
8934
|
+
React__default.createElement("div", null, "\uAC80\uC0C9\uB41C \uC815\uBCF4\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."))))))) : undefined),
|
|
8935
|
+
!isNoData && footer && (React__default.createElement(TableFooter, null,
|
|
8936
|
+
React__default.createElement(TableRow, null, finalColumns.map(function (column, idx) { return (React__default.createElement(TableFooterCell, { key: idx, column: column, defaultAlign: defaultAlign })); }))))))),
|
|
8937
|
+
paging && paging.total > 0 && (React__default.createElement(Stack, { ref: fullHeight ? pagingHeightResizeDetector : undefined, alignItems: pagingAlign, style: pagingStyle },
|
|
8938
|
+
React__default.createElement(TablePagination, { className: pagination === null || pagination === void 0 ? void 0 : pagination.className, style: pagination === null || pagination === void 0 ? void 0 : pagination.style, sx: pagination === null || pagination === void 0 ? void 0 : pagination.sx, paging: paging, align: pagingAlign, onChange: onPageChange })))))) : null;
|
|
8892
8939
|
});
|
|
8893
8940
|
Table.displayName = 'Table';
|
|
8894
8941
|
Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var SearchTable = React__default.forwardRef(function (_a, ref) {
|
|
@@ -9242,4 +9289,93 @@ TableIcon.defaultProps = TableIconDefaultProps;var TableButton = React__default.
|
|
|
9242
9289
|
children));
|
|
9243
9290
|
});
|
|
9244
9291
|
TableButton.displayName = 'TableButton';
|
|
9245
|
-
TableButton.defaultProps = TableButtonDefaultProps;
|
|
9292
|
+
TableButton.defaultProps = TableButtonDefaultProps;var TableMenuButtonDefaultProps = {
|
|
9293
|
+
variant: 'outlined',
|
|
9294
|
+
color: 'primary',
|
|
9295
|
+
placement: 'bottom',
|
|
9296
|
+
};var TableMenuButton = React__default.forwardRef(function (_a, ref) {
|
|
9297
|
+
// ID ----------------------------------------------------------------------------------------------------------------
|
|
9298
|
+
var children = _a.children, className = _a.className, initSx = _a.sx, color = _a.color, icon = _a.icon, startIcon = _a.startIcon, endIcon = _a.endIcon, placement = _a.placement, menuList = _a.menuList, props = __rest$1(_a, ["children", "className", "sx", "color", "icon", "startIcon", "endIcon", "placement", "menuList"]);
|
|
9299
|
+
var buttonId = useId();
|
|
9300
|
+
var menuId = useId();
|
|
9301
|
+
// Use ---------------------------------------------------------------------------------------------------------------
|
|
9302
|
+
var _b = useTableState(), menuOpen = _b.menuOpen, openMenuId = _b.openMenuId, setMenuOpen = _b.setMenuOpen;
|
|
9303
|
+
// Ref ---------------------------------------------------------------------------------------------------------------
|
|
9304
|
+
var anchorRef = useRef();
|
|
9305
|
+
// State -------------------------------------------------------------------------------------------------------------
|
|
9306
|
+
var _c = useState(false), open = _c[0], setOpen = _c[1];
|
|
9307
|
+
// Effect ------------------------------------------------------------------------------------------------------------
|
|
9308
|
+
useEffect(function () {
|
|
9309
|
+
if (open && menuOpen && openMenuId !== menuId) {
|
|
9310
|
+
setOpen(false);
|
|
9311
|
+
}
|
|
9312
|
+
}, [menuId, menuOpen, open, openMenuId]);
|
|
9313
|
+
// Memo --------------------------------------------------------------------------------------------------------------
|
|
9314
|
+
var sx = useMemo(function () { return (__assign$1({ minWidth: 0, px: !startIcon && !endIcon ? 0.7 : 1.7 }, initSx)); }, [endIcon, initSx, startIcon]);
|
|
9315
|
+
// Event Handler -----------------------------------------------------------------------------------------------------
|
|
9316
|
+
var handleClick = useCallback(function () {
|
|
9317
|
+
setOpen(function (old) { return !old; });
|
|
9318
|
+
if (!open) {
|
|
9319
|
+
setMenuOpen(true, menuId);
|
|
9320
|
+
}
|
|
9321
|
+
else {
|
|
9322
|
+
setMenuOpen(false, menuId);
|
|
9323
|
+
}
|
|
9324
|
+
}, [menuId, open, setMenuOpen]);
|
|
9325
|
+
var handleClose = useCallback(function () {
|
|
9326
|
+
if (open) {
|
|
9327
|
+
setOpen(false);
|
|
9328
|
+
setMenuOpen(false, menuId);
|
|
9329
|
+
}
|
|
9330
|
+
}, [menuId, open, setMenuOpen]);
|
|
9331
|
+
var handleListKeyDown = useCallback(function (event) {
|
|
9332
|
+
if (event.key === 'Tab') {
|
|
9333
|
+
event.preventDefault();
|
|
9334
|
+
if (open) {
|
|
9335
|
+
setOpen(false);
|
|
9336
|
+
setMenuOpen(false, menuId);
|
|
9337
|
+
}
|
|
9338
|
+
}
|
|
9339
|
+
else if (event.key === 'Escape') {
|
|
9340
|
+
if (open) {
|
|
9341
|
+
setOpen(false);
|
|
9342
|
+
setMenuOpen(false, menuId);
|
|
9343
|
+
}
|
|
9344
|
+
}
|
|
9345
|
+
}, [menuId, open, setMenuOpen]);
|
|
9346
|
+
// Memo --------------------------------------------------------------------------------------------------------------
|
|
9347
|
+
var finalMenuList = useMemo(function () {
|
|
9348
|
+
return React__default.cloneElement(menuList, {
|
|
9349
|
+
autoFocusItem: open,
|
|
9350
|
+
id: menuId,
|
|
9351
|
+
'aria-labelledby': buttonId,
|
|
9352
|
+
onKeyDown: handleListKeyDown,
|
|
9353
|
+
onClick: handleClose,
|
|
9354
|
+
});
|
|
9355
|
+
}, [buttonId, handleClose, handleListKeyDown, menuId, menuList, open]);
|
|
9356
|
+
// Render ----------------------------------------------------------------------------------------------------------
|
|
9357
|
+
return (React__default.createElement("span", null,
|
|
9358
|
+
React__default.createElement(Button, __assign$1({ ref: function (r) {
|
|
9359
|
+
if (ref) {
|
|
9360
|
+
if (typeof ref === 'function') {
|
|
9361
|
+
ref(r);
|
|
9362
|
+
}
|
|
9363
|
+
else {
|
|
9364
|
+
ref.current = r;
|
|
9365
|
+
}
|
|
9366
|
+
}
|
|
9367
|
+
anchorRef.current = r;
|
|
9368
|
+
}, id: buttonId, "aria-controls": open ? menuId : undefined, "aria-expanded": open ? 'true' : undefined, "aria-haspopup": 'true', className: classNames(className, 'TableMenuButton'), type: 'button', size: 'small', sx: sx, color: color, onClick: handleClick, startIcon: startIcon ? (React__default.createElement(TableIcon, { fontSize: 'small', sx: { mr: -0.5 } }, startIcon)) : undefined, endIcon: endIcon ? (React__default.createElement(TableIcon, { fontSize: 'small', sx: { ml: -0.5 } }, endIcon)) : undefined }, props),
|
|
9369
|
+
icon && (React__default.createElement(TableIcon, { fontSize: 'small', color: color }, icon)),
|
|
9370
|
+
children),
|
|
9371
|
+
React__default.createElement(Popper, { open: open, anchorEl: anchorRef.current, role: undefined, placement: placement, transition: true }, function (_a) {
|
|
9372
|
+
var TransitionProps = _a.TransitionProps, placement = _a.placement;
|
|
9373
|
+
return (React__default.createElement(Grow, __assign$1({}, TransitionProps, { style: {
|
|
9374
|
+
transformOrigin: placement === 'bottom-start' ? 'left top' : 'left bottom',
|
|
9375
|
+
} }),
|
|
9376
|
+
React__default.createElement(Paper, null,
|
|
9377
|
+
React__default.createElement(ClickAwayListener, { onClickAway: handleClose }, finalMenuList))));
|
|
9378
|
+
})));
|
|
9379
|
+
});
|
|
9380
|
+
TableMenuButton.displayName = 'TableMenuButton';
|
|
9381
|
+
TableMenuButton.defaultProps = TableMenuButtonDefaultProps;export{SearchTable,SearchTableDefaultProps,Table,TableButton,TableButtonDefaultProps,TableDefaultProps,TableIcon,TableIconDefaultProps,TableMenuButton,TableMenuButtonDefaultProps};//# sourceMappingURL=index.esm.js.map
|