@pdg/react-table 1.0.71 → 1.0.73

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.
@@ -11,3 +11,4 @@ export declare const ValueClipboard: import("@emotion/styled").StyledComponent<i
11
11
  export declare const ClipboardIconButton: import("@emotion/styled").StyledComponent<import("@mui/material").IconButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
12
12
  ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
13
13
  }, "style" | "className" | "tabIndex" | "color" | "children" | "sx" | "classes" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "edge" | "size"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
14
+ export declare const Line: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -4,9 +4,10 @@ import { CommonSxProps } from '../@types';
4
4
  export interface InfoTableInfo {
5
5
  [key: string]: any;
6
6
  }
7
- export type InfoTableItemType = 'text' | 'number' | 'tel' | 'url' | 'email' | 'date' | 'datetime' | 'date-hour' | 'date-minute';
7
+ export type InfoTableItemType = 'text' | 'number' | 'tel' | 'url' | 'email' | 'date' | 'datetime' | 'date-hour' | 'date-minute' | 'company_no' | 'personal_no' | 'divider';
8
8
  export interface InfoTableItem<T = InfoTableInfo> {
9
- label: ReactNode;
9
+ icon?: string;
10
+ label?: ReactNode;
10
11
  name?: keyof T;
11
12
  type?: InfoTableItemType;
12
13
  ellipsis?: boolean;
@@ -15,6 +16,8 @@ export interface InfoTableItem<T = InfoTableInfo> {
15
16
  dateTwoLine?: boolean;
16
17
  numberPrefix?: string;
17
18
  numberSuffix?: string;
19
+ dividerColor?: TypographyProps['color'];
20
+ dividerLine?: boolean;
18
21
  style?: CommonSxProps['style'];
19
22
  sx?: BoxProps['sx'];
20
23
  labelClassName?: string;
@@ -56,6 +59,7 @@ export interface InfoTableProps<T = InfoTableInfo> {
56
59
  labelColor?: TypographyProps['color'];
57
60
  labelStyle?: CommonSxProps['style'];
58
61
  labelSx?: BoxProps['sx'];
62
+ dividerColor?: TypographyProps['color'];
59
63
  valueClassName?: string;
60
64
  valueStyle?: CommonSxProps['style'];
61
65
  valueSx?: CommonSxProps['sx'];
@@ -65,4 +69,4 @@ export interface InfoTableProps<T = InfoTableInfo> {
65
69
  items: InfoTableItems<T>;
66
70
  onCopyToClipboard?(item: InfoTableItem<T>, text: string): void;
67
71
  }
68
- export declare const InfoTableDefaultProps: Pick<InfoTableProps, 'spacing' | 'columnSpacing' | 'rowSpacing' | 'labelColor'>;
72
+ export declare const InfoTableDefaultProps: Pick<InfoTableProps, 'spacing' | 'columnSpacing' | 'rowSpacing' | 'labelColor' | 'dividerColor'>;
@@ -8,7 +8,7 @@ export interface TableItem {
8
8
  }
9
9
  export interface TableColumn<T = TableItem> {
10
10
  id?: string;
11
- type?: 'text' | 'number' | 'tel' | 'date' | 'datetime' | 'date-hour' | 'date-minute' | 'img' | 'button' | 'buttons' | 'check';
11
+ type?: 'text' | 'number' | 'tel' | 'date' | 'datetime' | 'date-hour' | 'date-minute' | 'company_no' | 'personal_no' | 'img' | 'button' | 'buttons' | 'check';
12
12
  label?: ReactNode;
13
13
  name?: keyof T;
14
14
  align?: TableCellProps['align'];
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import*as React from'react';import React__default,{useRef,useState,useCallback,useEffect,isValidElement,createRef,cloneElement,PureComponent,createContext,useContext,useMemo,useLayoutEffect,useId}from'react';import {styled,TableRow,lighten,TableCell,Box,Tooltip,Checkbox,Stack,Pagination,useTheme,TableHead,TableBody,Icon,TableFooter,Paper,Table as Table$1,Grid,Button,Popper,Grow,ClickAwayListener,IconButton}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,useState,useCallback,useEffect,isValidElement,createRef,cloneElement,PureComponent,createContext,useContext,useMemo,useLayoutEffect,useId}from'react';import {styled,TableRow,lighten,TableCell,Box,Tooltip,Checkbox,Stack,Pagination,useTheme,TableHead,TableBody,Icon,TableFooter,Paper,Table as Table$1,Grid,Button,Popper,Grow,ClickAwayListener,IconButton}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,FormIcon}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
@@ -2787,6 +2787,30 @@ function typographyColorToSxColor(color) {
2787
2787
  }
2788
2788
  }
2789
2789
  return tmp;
2790
+ }/********************************************************************************************************************
2791
+ * 사업자등록번호 하이픈 추가
2792
+ * @param companyNo 사업자등록번호
2793
+ * @returns 하이픈이 추가된 사업자등록번호
2794
+ * ******************************************************************************************************************/
2795
+ function companyNoAutoDash(companyNo) {
2796
+ var str = companyNo.replace(/[^0-9]/g, '');
2797
+ var values = [str.slice(0, 3)];
2798
+ if (str.length > 3)
2799
+ values.push(str.slice(3, 5));
2800
+ if (str.length > 5)
2801
+ values.push(str.slice(5));
2802
+ return values.join('-');
2803
+ }/********************************************************************************************************************
2804
+ * 주민등록번호에 하이픈 추가하는 함수
2805
+ * @param personalNo 주민등록번호
2806
+ * @returns 하이픈 추가된 주민등록번호
2807
+ * ******************************************************************************************************************/
2808
+ function personalNoAutoDash(personalNo) {
2809
+ var str = personalNo.replace(/[^0-9]/g, '');
2810
+ var values = [str.slice(0, 6)];
2811
+ if (str.length > 6)
2812
+ values.push(str.slice(6));
2813
+ return values.join('-');
2790
2814
  }var TableContextDefaultValue = {
2791
2815
  menuOpen: false,
2792
2816
  openMenuId: undefined,
@@ -3037,6 +3061,16 @@ var TableBodyCell = function (_a) {
3037
3061
  data = getTelAutoDash(data);
3038
3062
  }
3039
3063
  break;
3064
+ case 'company_no':
3065
+ if (typeof data === 'string') {
3066
+ data = companyNoAutoDash(data);
3067
+ }
3068
+ break;
3069
+ case 'personal_no':
3070
+ if (typeof data === 'string') {
3071
+ data = personalNoAutoDash(data);
3072
+ }
3073
+ break;
3040
3074
  case 'check':
3041
3075
  data = (React__default.createElement(Box, { className: 'TableBoxyCell-check-box', onClick: menuOpen ? undefined : function (e) { return e.stopPropagation(); } },
3042
3076
  React__default.createElement(Checkbox, { checked: checked, disabled: checkDisabled, onChange: function (e, newChecked) {
@@ -4573,13 +4607,15 @@ TableMenuButton.defaultProps = TableMenuButtonDefaultProps;var InfoTableDefaultP
4573
4607
  spacing: 2,
4574
4608
  rowSpacing: 3,
4575
4609
  labelColor: 'primary',
4610
+ dividerColor: 'gray',
4576
4611
  };var Label = styled(Box)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-size: 12px;\n font-weight: bold;\n"], ["\n font-size: 12px;\n font-weight: bold;\n"])));
4577
4612
  var ValueWrap = styled(Box)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-top: 3px;\n position: relative;\n display: flex;\n flex-direction: row;\n"], ["\n margin-top: 3px;\n position: relative;\n display: flex;\n flex-direction: row;\n"])));
4578
4613
  var Value = styled('div')(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n flex: 1;\n"], ["\n flex: 1;\n"])));
4579
4614
  var ValueEllipsis = styled('div')(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n flex: 1;\n position: relative;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"], ["\n flex: 1;\n position: relative;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
4580
4615
  var ValueClipboard = styled('div')(templateObject_5 || (templateObject_5 = __makeTemplateObject([""], [""])));
4581
4616
  var ClipboardIconButton = styled(IconButton)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n margin-top: -10px;\n margin-bottom: -10px;\n"], ["\n margin-top: -10px;\n margin-bottom: -10px;\n"])));
4582
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;var Component = {};var toggleSelection = function () {
4617
+ var Line = styled('div')(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n border-top: 1px solid #efefef;\n height: 1px;\n flex: 1;\n"], ["\n border-top: 1px solid #efefef;\n height: 1px;\n flex: 1;\n"])));
4618
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;var Component = {};var toggleSelection = function () {
4583
4619
  var selection = document.getSelection();
4584
4620
  if (!selection.rangeCount) {
4585
4621
  return function () {};
@@ -4844,7 +4880,7 @@ _defineProperty(CopyToClipboard$1, "defaultProps", {
4844
4880
 
4845
4881
  CopyToClipboard.CopyToClipboard = CopyToClipboard;
4846
4882
  var lib = CopyToClipboard;var InfoTable = function (_a) {
4847
- var cols = _a.cols, spacing = _a.spacing, columnSpacing = _a.columnSpacing, rowSpacing = _a.rowSpacing, className = _a.className, style = _a.style, sx = _a.sx, labelClassName = _a.labelClassName, labelColor = _a.labelColor, labelStyle = _a.labelStyle, labelSx = _a.labelSx, valueClassName = _a.valueClassName, valueStyle = _a.valueStyle, valueSx = _a.valueSx, ellipsis = _a.ellipsis, valueUnderline = _a.valueUnderline, info = _a.info, items = _a.items, onCopyToClipboard = _a.onCopyToClipboard;
4883
+ var cols = _a.cols, spacing = _a.spacing, columnSpacing = _a.columnSpacing, rowSpacing = _a.rowSpacing, className = _a.className, style = _a.style, sx = _a.sx, labelClassName = _a.labelClassName, labelColor = _a.labelColor, labelStyle = _a.labelStyle, labelSx = _a.labelSx, dividerColor = _a.dividerColor, valueClassName = _a.valueClassName, valueStyle = _a.valueStyle, valueSx = _a.valueSx, ellipsis = _a.ellipsis, valueUnderline = _a.valueUnderline, info = _a.info, items = _a.items, onCopyToClipboard = _a.onCopyToClipboard;
4848
4884
  var sizeProps = useMemo(function () {
4849
4885
  var value = {};
4850
4886
  if (typeof cols === 'number') {
@@ -4866,7 +4902,7 @@ var lib = CopyToClipboard;var InfoTable = function (_a) {
4866
4902
  }, [cols]);
4867
4903
  return (React__default.createElement(Grid, { container: true, spacing: spacing, columnSpacing: columnSpacing, rowSpacing: rowSpacing, className: classNames('InfoTable', className), style: style, sx: sx }, items.map(function (item, idx) {
4868
4904
  if (item) {
4869
- var finalLabelColor = typographyColorToSxColor(item.labelColor || labelColor);
4905
+ var finalLabelColor = typographyColorToSxColor(item.type === 'divider' ? item.dividerColor || dividerColor : item.labelColor || labelColor);
4870
4906
  var finalLabelSx = combineSx(labelSx, item.labelSx, !!finalLabelColor && { color: finalLabelColor });
4871
4907
  var finalValueSx = combineSx(valueSx, item.valueSx);
4872
4908
  var valueUnderlineStyle = valueUnderline
@@ -4934,6 +4970,16 @@ var lib = CopyToClipboard;var InfoTable = function (_a) {
4934
4970
  React__default.createElement("a", { href: data, target: '_blank' }, data)));
4935
4971
  }
4936
4972
  break;
4973
+ case 'company_no':
4974
+ if (typeof data === 'string') {
4975
+ data = companyNoAutoDash(data);
4976
+ }
4977
+ break;
4978
+ case 'personal_no':
4979
+ if (typeof data === 'string') {
4980
+ data = personalNoAutoDash(data);
4981
+ }
4982
+ break;
4937
4983
  case 'date':
4938
4984
  if (typeof data === 'string' || typeof data === 'number') {
4939
4985
  data = dayjs(data, item.dateFormat).format('YYYY-MM-DD');
@@ -4971,8 +5017,15 @@ var lib = CopyToClipboard;var InfoTable = function (_a) {
4971
5017
  if (empty(data))
4972
5018
  data = item.onRenderEmpty ? item.onRenderEmpty(info) : React__default.createElement(React__default.Fragment, null, "\u00A0");
4973
5019
  var copyToClipboardText_1 = item.clipboardText || (typeof data === 'string' ? data : typeof data === 'number' ? data.toString() : '');
4974
- return (React__default.createElement(Grid, __assign$3({ key: idx, item: true }, finalSizeProps, { className: item.className, style: item.style, sx: item.sx }),
4975
- React__default.createElement(Label, { className: classNames(labelClassName, item.labelClassName), style: __assign$3(__assign$3({}, item.labelStyle), labelStyle), sx: finalLabelSx }, item.label),
5020
+ return item.type === 'divider' ? (React__default.createElement(Grid, { key: idx, item: true, xs: 12 },
5021
+ React__default.createElement(Stack, { direction: 'row', spacing: 0.5, alignItems: 'center' },
5022
+ item.icon && (React__default.createElement(FormIcon, { sx: { color: item.dividerColor || dividerColor }, fontSize: 'small' }, item.icon)),
5023
+ item.label && (React__default.createElement(Label, { className: classNames(labelClassName, item.labelClassName), style: __assign$3(__assign$3({}, item.labelStyle), labelStyle), sx: finalLabelSx }, item.label)),
5024
+ item.dividerLine && (React__default.createElement(React__default.Fragment, null, item.icon || item.label ? (React__default.createElement("div", { style: { flex: 1, paddingLeft: 5 } },
5025
+ React__default.createElement(Line, null))) : (React__default.createElement(Line, null))))))) : (React__default.createElement(Grid, __assign$3({ key: idx, item: true }, finalSizeProps, { className: item.className, style: item.style, sx: item.sx }),
5026
+ React__default.createElement(Stack, { direction: 'row', spacing: 0.5, alignItems: 'center' },
5027
+ item.icon && (React__default.createElement(FormIcon, { sx: { color: finalLabelColor }, fontSize: 'small' }, "CalendarMonth")),
5028
+ React__default.createElement(Label, { className: classNames(labelClassName, item.labelClassName), style: __assign$3(__assign$3({}, item.labelStyle), labelStyle), sx: finalLabelSx }, item.label)),
4976
5029
  React__default.createElement(ValueWrap, { className: classNames(valueClassName, item.valueClassName), style: __assign$3(__assign$3(__assign$3({}, valueStyle), item.valueStyle), valueUnderlineStyle), sx: finalValueSx },
4977
5030
  item.ellipsis || ellipsis ? React__default.createElement(ValueEllipsis, null, data) : React__default.createElement(Value, null, data),
4978
5031
  item.clipboard && notEmpty(copyToClipboardText_1) && (React__default.createElement(ValueClipboard, null,