@pdg/react-table 1.0.64 → 1.0.65
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/@util/index.d.ts +1 -0
- package/dist/@util/tel.d.ts +1 -0
- package/dist/Table/Table.types.d.ts +2 -1
- package/dist/index.esm.js +94 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +94 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/@util/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTelAutoDash(tel: string | null | undefined): string | null;
|
|
@@ -8,7 +8,7 @@ export interface TableItem {
|
|
|
8
8
|
}
|
|
9
9
|
export interface TableColumn<T = TableItem> {
|
|
10
10
|
id: string;
|
|
11
|
-
type?: 'text' | 'number' | 'date' | 'datetime' | 'img' | 'button' | 'buttons' | 'check';
|
|
11
|
+
type?: 'text' | 'number' | 'tel' | 'date' | 'datetime' | 'date-hour' | 'date-minute' | 'img' | 'button' | 'buttons' | 'check';
|
|
12
12
|
label?: ReactNode;
|
|
13
13
|
name?: string;
|
|
14
14
|
align?: TableCellProps['align'];
|
|
@@ -16,6 +16,7 @@ export interface TableColumn<T = TableItem> {
|
|
|
16
16
|
minWidth?: string | number;
|
|
17
17
|
ellipsis?: boolean;
|
|
18
18
|
dateFormat?: string;
|
|
19
|
+
dateTwoLine?: boolean;
|
|
19
20
|
hideAllCheck?: boolean;
|
|
20
21
|
tooltipProps?: Omit<TooltipProps, 'children' | 'title'>;
|
|
21
22
|
display?: {
|
package/dist/index.esm.js
CHANGED
|
@@ -2721,6 +2721,72 @@ function typographyColorToSxColor(color) {
|
|
|
2721
2721
|
else {
|
|
2722
2722
|
return color;
|
|
2723
2723
|
}
|
|
2724
|
+
}function getTelAutoDash(tel) {
|
|
2725
|
+
if (tel == null)
|
|
2726
|
+
return null;
|
|
2727
|
+
var str = tel.replace(/[^0-9*]/g, '');
|
|
2728
|
+
var isLastDash = tel.substr(tel.length - 1, 1) === '-';
|
|
2729
|
+
if (str.substr(0, 1) !== '0' && !['15', '16', '18'].includes(str.substr(0, 2))) {
|
|
2730
|
+
return tel;
|
|
2731
|
+
}
|
|
2732
|
+
var tmp = '';
|
|
2733
|
+
var preLen;
|
|
2734
|
+
switch (str.substr(0, 2)) {
|
|
2735
|
+
case '02':
|
|
2736
|
+
preLen = 2;
|
|
2737
|
+
break;
|
|
2738
|
+
case '15':
|
|
2739
|
+
case '16':
|
|
2740
|
+
case '18':
|
|
2741
|
+
preLen = 4;
|
|
2742
|
+
break;
|
|
2743
|
+
default:
|
|
2744
|
+
preLen = 3;
|
|
2745
|
+
}
|
|
2746
|
+
if (['15', '16', '18'].includes(str.substr(0, 2))) {
|
|
2747
|
+
if (str.length <= preLen) {
|
|
2748
|
+
tmp = str;
|
|
2749
|
+
}
|
|
2750
|
+
else if (str.length <= preLen + 4) {
|
|
2751
|
+
tmp += str.substr(0, preLen);
|
|
2752
|
+
tmp += '-';
|
|
2753
|
+
tmp += str.substr(preLen);
|
|
2754
|
+
}
|
|
2755
|
+
else {
|
|
2756
|
+
tmp = str;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
else if (str.length <= preLen) {
|
|
2760
|
+
tmp = str;
|
|
2761
|
+
}
|
|
2762
|
+
else if (str.length <= preLen + 3) {
|
|
2763
|
+
tmp += str.substr(0, preLen);
|
|
2764
|
+
tmp += '-';
|
|
2765
|
+
tmp += str.substr(preLen);
|
|
2766
|
+
}
|
|
2767
|
+
else if (str.length <= preLen + 7) {
|
|
2768
|
+
tmp += str.substr(0, preLen);
|
|
2769
|
+
tmp += '-';
|
|
2770
|
+
tmp += str.substr(preLen, 3);
|
|
2771
|
+
tmp += '-';
|
|
2772
|
+
tmp += str.substr(preLen + 3);
|
|
2773
|
+
}
|
|
2774
|
+
else if (str.length <= preLen + 8) {
|
|
2775
|
+
tmp += str.substr(0, preLen);
|
|
2776
|
+
tmp += '-';
|
|
2777
|
+
tmp += str.substr(preLen, 4);
|
|
2778
|
+
tmp += '-';
|
|
2779
|
+
tmp += str.substr(preLen + 4);
|
|
2780
|
+
}
|
|
2781
|
+
else {
|
|
2782
|
+
tmp = str;
|
|
2783
|
+
}
|
|
2784
|
+
if (isLastDash) {
|
|
2785
|
+
if (str.length === preLen) {
|
|
2786
|
+
tmp += '-';
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
return tmp;
|
|
2724
2790
|
}var TableContextDefaultValue = {
|
|
2725
2791
|
menuOpen: false,
|
|
2726
2792
|
openMenuId: undefined,
|
|
@@ -2956,6 +3022,11 @@ var TableBodyCell = function (_a) {
|
|
|
2956
3022
|
data = numberWithThousandSeparator(data);
|
|
2957
3023
|
}
|
|
2958
3024
|
break;
|
|
3025
|
+
case 'tel':
|
|
3026
|
+
if (typeof data === 'string') {
|
|
3027
|
+
data = getTelAutoDash(data);
|
|
3028
|
+
}
|
|
3029
|
+
break;
|
|
2959
3030
|
case 'check':
|
|
2960
3031
|
data = (React__default.createElement(Box, { className: 'TableBoxyCell-check-box', onClick: menuOpen ? undefined : function (e) { return e.stopPropagation(); } },
|
|
2961
3032
|
React__default.createElement(Checkbox, { checked: checked, disabled: checkDisabled, onChange: function (e, newChecked) {
|
|
@@ -2991,7 +3062,29 @@ var TableBodyCell = function (_a) {
|
|
|
2991
3062
|
break;
|
|
2992
3063
|
case 'datetime':
|
|
2993
3064
|
if (data) {
|
|
2994
|
-
|
|
3065
|
+
var dt = dayjs(data, column.dateFormat);
|
|
3066
|
+
data = (React__default.createElement(React__default.Fragment, null,
|
|
3067
|
+
React__default.createElement("span", null, dt.format('YYYY-MM-DD')),
|
|
3068
|
+
column.dateTwoLine ? React__default.createElement("br", null) : ' ',
|
|
3069
|
+
React__default.createElement("span", { style: { opacity: 0.5 } }, dt.format('HH:mm:ss'))));
|
|
3070
|
+
}
|
|
3071
|
+
break;
|
|
3072
|
+
case 'date-hour':
|
|
3073
|
+
if (data) {
|
|
3074
|
+
var dt = dayjs(data, column.dateFormat);
|
|
3075
|
+
data = (React__default.createElement(React__default.Fragment, null,
|
|
3076
|
+
React__default.createElement("span", null, dt.format('YYYY-MM-DD')),
|
|
3077
|
+
column.dateTwoLine ? React__default.createElement("br", null) : ' ',
|
|
3078
|
+
React__default.createElement("span", { style: { opacity: 0.5 } }, dt.format('HH시'))));
|
|
3079
|
+
}
|
|
3080
|
+
break;
|
|
3081
|
+
case 'date-minute':
|
|
3082
|
+
if (data) {
|
|
3083
|
+
var dt = dayjs(data, column.dateFormat);
|
|
3084
|
+
data = (React__default.createElement(React__default.Fragment, null,
|
|
3085
|
+
React__default.createElement("span", null, dt.format('YYYY-MM-DD')),
|
|
3086
|
+
column.dateTwoLine ? React__default.createElement("br", null) : ' ',
|
|
3087
|
+
React__default.createElement("span", { style: { opacity: 0.5 } }, dt.format('HH시 MM분'))));
|
|
2995
3088
|
}
|
|
2996
3089
|
break;
|
|
2997
3090
|
}
|