react-table-edit 1.2.18 → 1.2.20
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/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +46 -13
- package/dist/index.mjs +45 -13
- package/package.json +1 -3
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,7 @@ type IFColumnSelectTable = {
|
|
|
18
18
|
};
|
|
19
19
|
type IFTableSelectFormat = {
|
|
20
20
|
dateFormat?: string;
|
|
21
|
+
datetimeFormat?: string;
|
|
21
22
|
decimalSeparator?: string;
|
|
22
23
|
thousandSeparator?: string;
|
|
23
24
|
colorNegative?: string;
|
|
@@ -40,6 +41,7 @@ type Props$1 = {
|
|
|
40
41
|
rowData?: any;
|
|
41
42
|
value: any;
|
|
42
43
|
onKeyDown?: any;
|
|
44
|
+
onOpenMenu?: any;
|
|
43
45
|
formatOptionLabel?: any;
|
|
44
46
|
handleAdd?: any;
|
|
45
47
|
options: any[];
|
|
@@ -99,6 +101,7 @@ type ISettingSelectElement = {
|
|
|
99
101
|
validateOption?: any;
|
|
100
102
|
optionsField?: string;
|
|
101
103
|
columns?: IFColumnSelectTable[];
|
|
104
|
+
onOpenMenu?: any;
|
|
102
105
|
};
|
|
103
106
|
type ISettingNumericElement = {
|
|
104
107
|
min?: number;
|
|
@@ -170,6 +173,7 @@ type IFTableEditSearchSetting = {
|
|
|
170
173
|
};
|
|
171
174
|
type IFTableEditFormat = {
|
|
172
175
|
dateFormat?: string;
|
|
176
|
+
datetimeFormat?: string;
|
|
173
177
|
decimalSeparator?: string;
|
|
174
178
|
thousandSeparator?: string;
|
|
175
179
|
colorNegative?: string;
|
|
@@ -267,6 +271,7 @@ declare const generateUUID: () => string;
|
|
|
267
271
|
*/
|
|
268
272
|
declare const formartNumberic: (str: string | number, decimalSeparator: string, thousandSeparator: string, fraction?: number, isDone?: boolean, haveNegative?: boolean) => string;
|
|
269
273
|
declare const roundNumber: (num: number, fraction: number) => number;
|
|
274
|
+
declare const formatDateTime: (data: any, format?: string) => string;
|
|
270
275
|
|
|
271
276
|
type IFDataProps = {
|
|
272
277
|
buttonWidth?: number;
|
|
@@ -330,6 +335,7 @@ type Props = {
|
|
|
330
335
|
showFooter?: boolean;
|
|
331
336
|
selectChilds?: boolean;
|
|
332
337
|
formatSetting?: IFTableTreeSelectFormat;
|
|
338
|
+
onOpenMenu?: any;
|
|
333
339
|
onPaste?: any;
|
|
334
340
|
};
|
|
335
341
|
declare const SelectTableTree: react__default.ForwardRefExoticComponent<Props & react__default.RefAttributes<unknown>>;
|
|
@@ -357,4 +363,4 @@ interface IFDataInputStyle {
|
|
|
357
363
|
}
|
|
358
364
|
declare const InputStyleComponent: (props: IFDataInputStyle) => react_jsx_runtime.JSX.Element;
|
|
359
365
|
|
|
360
|
-
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFColumnSelectTable, type IFColumnSelectTableTree, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditButton, type IFTableEditFormat, type IFTableEditPaging, type IFTableEditProps, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFTableSelectFormat, type IFTableTreeSelectFormat, type IFToolbarOptions, type IHeaderColumnTable, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, InputStyleComponent, SelectTable, SelectTableTree, TabsMenuComponent, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, formartNumberic, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
|
|
366
|
+
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFColumnSelectTable, type IFColumnSelectTableTree, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditButton, type IFTableEditFormat, type IFTableEditPaging, type IFTableEditProps, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFTableSelectFormat, type IFTableTreeSelectFormat, type IFToolbarOptions, type IHeaderColumnTable, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, InputStyleComponent, SelectTable, SelectTableTree, TabsMenuComponent, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, formartNumberic, formatDateTime, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ type IFColumnSelectTable = {
|
|
|
18
18
|
};
|
|
19
19
|
type IFTableSelectFormat = {
|
|
20
20
|
dateFormat?: string;
|
|
21
|
+
datetimeFormat?: string;
|
|
21
22
|
decimalSeparator?: string;
|
|
22
23
|
thousandSeparator?: string;
|
|
23
24
|
colorNegative?: string;
|
|
@@ -40,6 +41,7 @@ type Props$1 = {
|
|
|
40
41
|
rowData?: any;
|
|
41
42
|
value: any;
|
|
42
43
|
onKeyDown?: any;
|
|
44
|
+
onOpenMenu?: any;
|
|
43
45
|
formatOptionLabel?: any;
|
|
44
46
|
handleAdd?: any;
|
|
45
47
|
options: any[];
|
|
@@ -99,6 +101,7 @@ type ISettingSelectElement = {
|
|
|
99
101
|
validateOption?: any;
|
|
100
102
|
optionsField?: string;
|
|
101
103
|
columns?: IFColumnSelectTable[];
|
|
104
|
+
onOpenMenu?: any;
|
|
102
105
|
};
|
|
103
106
|
type ISettingNumericElement = {
|
|
104
107
|
min?: number;
|
|
@@ -170,6 +173,7 @@ type IFTableEditSearchSetting = {
|
|
|
170
173
|
};
|
|
171
174
|
type IFTableEditFormat = {
|
|
172
175
|
dateFormat?: string;
|
|
176
|
+
datetimeFormat?: string;
|
|
173
177
|
decimalSeparator?: string;
|
|
174
178
|
thousandSeparator?: string;
|
|
175
179
|
colorNegative?: string;
|
|
@@ -267,6 +271,7 @@ declare const generateUUID: () => string;
|
|
|
267
271
|
*/
|
|
268
272
|
declare const formartNumberic: (str: string | number, decimalSeparator: string, thousandSeparator: string, fraction?: number, isDone?: boolean, haveNegative?: boolean) => string;
|
|
269
273
|
declare const roundNumber: (num: number, fraction: number) => number;
|
|
274
|
+
declare const formatDateTime: (data: any, format?: string) => string;
|
|
270
275
|
|
|
271
276
|
type IFDataProps = {
|
|
272
277
|
buttonWidth?: number;
|
|
@@ -330,6 +335,7 @@ type Props = {
|
|
|
330
335
|
showFooter?: boolean;
|
|
331
336
|
selectChilds?: boolean;
|
|
332
337
|
formatSetting?: IFTableTreeSelectFormat;
|
|
338
|
+
onOpenMenu?: any;
|
|
333
339
|
onPaste?: any;
|
|
334
340
|
};
|
|
335
341
|
declare const SelectTableTree: react__default.ForwardRefExoticComponent<Props & react__default.RefAttributes<unknown>>;
|
|
@@ -357,4 +363,4 @@ interface IFDataInputStyle {
|
|
|
357
363
|
}
|
|
358
364
|
declare const InputStyleComponent: (props: IFDataInputStyle) => react_jsx_runtime.JSX.Element;
|
|
359
365
|
|
|
360
|
-
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFColumnSelectTable, type IFColumnSelectTableTree, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditButton, type IFTableEditFormat, type IFTableEditPaging, type IFTableEditProps, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFTableSelectFormat, type IFTableTreeSelectFormat, type IFToolbarOptions, type IHeaderColumnTable, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, InputStyleComponent, SelectTable, SelectTableTree, TabsMenuComponent, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, formartNumberic, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
|
|
366
|
+
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFColumnSelectTable, type IFColumnSelectTableTree, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditButton, type IFTableEditFormat, type IFTableEditPaging, type IFTableEditProps, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFTableSelectFormat, type IFTableTreeSelectFormat, type IFToolbarOptions, type IHeaderColumnTable, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, InputStyleComponent, SelectTable, SelectTableTree, TabsMenuComponent, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, formartNumberic, formatDateTime, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
checkThousandSeparator: () => checkThousandSeparator,
|
|
39
39
|
default: () => src_default,
|
|
40
40
|
formartNumberic: () => formartNumberic,
|
|
41
|
+
formatDateTime: () => formatDateTime,
|
|
41
42
|
generateUUID: () => generateUUID,
|
|
42
43
|
isNullOrUndefined: () => isNullOrUndefined,
|
|
43
44
|
messageBoxConfirm: () => messageBoxConfirm,
|
|
@@ -356,9 +357,20 @@ var roundNumber = (num, fraction) => {
|
|
|
356
357
|
const result = Math.round(num * base) / base;
|
|
357
358
|
return result;
|
|
358
359
|
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
var formatDateTime = (data, format = "dd/MM/yyyy") => {
|
|
361
|
+
if (!data) {
|
|
362
|
+
return "";
|
|
363
|
+
}
|
|
364
|
+
const date = new Date(data);
|
|
365
|
+
const map = {
|
|
366
|
+
dd: String(date.getDate()).padStart(2, "0"),
|
|
367
|
+
MM: String(date.getMonth() + 1).padStart(2, "0"),
|
|
368
|
+
yyyy: date.getFullYear(),
|
|
369
|
+
HH: String(date.getHours()).padStart(2, "0"),
|
|
370
|
+
mm: String(date.getMinutes()).padStart(2, "0")
|
|
371
|
+
};
|
|
372
|
+
return format.replace(/dd|MM|yyyy|HH|mm/g, (match) => map[match]);
|
|
373
|
+
};
|
|
362
374
|
|
|
363
375
|
// src/component/edit-form/index.tsx
|
|
364
376
|
var import_react8 = require("react");
|
|
@@ -604,7 +616,6 @@ var import_react6 = __toESM(require("react"));
|
|
|
604
616
|
var import_reactstrap4 = require("reactstrap");
|
|
605
617
|
var import_react_i18next3 = require("react-i18next");
|
|
606
618
|
var import_classnames4 = __toESM(require("classnames"));
|
|
607
|
-
var import_moment = __toESM(require("moment"));
|
|
608
619
|
var import_becoxy_icons2 = require("becoxy-icons");
|
|
609
620
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
610
621
|
var defaultMaxHeight = 250;
|
|
@@ -636,6 +647,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
|
|
|
636
647
|
footerComponent,
|
|
637
648
|
formatSetting,
|
|
638
649
|
allowCreate,
|
|
650
|
+
onOpenMenu,
|
|
639
651
|
onPaste
|
|
640
652
|
} = props;
|
|
641
653
|
const selectTableRef = (0, import_react6.useRef)();
|
|
@@ -695,6 +707,11 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
|
|
|
695
707
|
setIndexFocus(0);
|
|
696
708
|
}
|
|
697
709
|
}, [searchTerm]);
|
|
710
|
+
(0, import_react6.useEffect)(() => {
|
|
711
|
+
if (dropdownOpen && onOpenMenu) {
|
|
712
|
+
onOpenMenu();
|
|
713
|
+
}
|
|
714
|
+
}, [dropdownOpen]);
|
|
698
715
|
const handleOpenClose = () => {
|
|
699
716
|
setSearchTerm("");
|
|
700
717
|
if (dropdownOpen) {
|
|
@@ -927,9 +944,9 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
|
|
|
927
944
|
if (col.type === "numeric" || col.typeCondition && col.typeCondition(row) === "numeric") {
|
|
928
945
|
valueDisplay = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ".", formatSetting?.thousandSeparator ?? ",", col.fraction ?? 0, true, false) ?? 0;
|
|
929
946
|
} else if (col.type === "date") {
|
|
930
|
-
valueDisplay = valueDisplay ? (
|
|
947
|
+
valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat) : "";
|
|
931
948
|
} else if (col.type === "datetime") {
|
|
932
|
-
valueDisplay = valueDisplay ? (
|
|
949
|
+
valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
933
950
|
}
|
|
934
951
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react6.Fragment, { children: [
|
|
935
952
|
col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -2276,7 +2293,6 @@ var import_react15 = __toESM(require("react"));
|
|
|
2276
2293
|
var import_reactstrap10 = require("reactstrap");
|
|
2277
2294
|
var import_react_i18next11 = require("react-i18next");
|
|
2278
2295
|
var import_classnames13 = __toESM(require("classnames"));
|
|
2279
|
-
var import_moment2 = __toESM(require("moment"));
|
|
2280
2296
|
var import_becoxy_icons6 = require("becoxy-icons");
|
|
2281
2297
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2282
2298
|
var defaultMaxHeight2 = 250;
|
|
@@ -2308,6 +2324,7 @@ var SelectTableTree = (0, import_react15.forwardRef)((props, ref) => {
|
|
|
2308
2324
|
selectChilds,
|
|
2309
2325
|
footerComponent,
|
|
2310
2326
|
formatSetting,
|
|
2327
|
+
onOpenMenu,
|
|
2311
2328
|
onPaste
|
|
2312
2329
|
} = props;
|
|
2313
2330
|
const selectTableRef = (0, import_react15.useRef)();
|
|
@@ -2330,6 +2347,11 @@ var SelectTableTree = (0, import_react15.forwardRef)((props, ref) => {
|
|
|
2330
2347
|
const isSelectedAll = (0, import_react15.useMemo)(() => {
|
|
2331
2348
|
return isMulti === true && options.length > 0 && areAllItemsSelected(value, options, fieldValue ?? "value");
|
|
2332
2349
|
}, [options, value]);
|
|
2350
|
+
(0, import_react15.useEffect)(() => {
|
|
2351
|
+
if (dropdownOpen && onOpenMenu) {
|
|
2352
|
+
onOpenMenu();
|
|
2353
|
+
}
|
|
2354
|
+
}, [dropdownOpen]);
|
|
2333
2355
|
const defaultColumns = [
|
|
2334
2356
|
{
|
|
2335
2357
|
headerText: "Name",
|
|
@@ -2551,9 +2573,9 @@ var SelectTableTree = (0, import_react15.forwardRef)((props, ref) => {
|
|
|
2551
2573
|
if (col.type === "numeric" || col.typeCondition && col.typeCondition(row) === "numeric") {
|
|
2552
2574
|
valueDisplay = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ".", formatSetting?.thousandSeparator ?? ",", col.fraction ?? 0, true) ?? 0;
|
|
2553
2575
|
} else if (col.type === "date") {
|
|
2554
|
-
valueDisplay = valueDisplay ? (
|
|
2576
|
+
valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat) : "";
|
|
2555
2577
|
} else if (col.type === "datetime") {
|
|
2556
|
-
valueDisplay = valueDisplay ? (
|
|
2578
|
+
valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
2557
2579
|
}
|
|
2558
2580
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react15.Fragment, { children: [
|
|
2559
2581
|
col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
@@ -3053,7 +3075,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3053
3075
|
{
|
|
3054
3076
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
3055
3077
|
style: { textAlign: col.textAlign, height: 29 },
|
|
3056
|
-
value: row[col.field] ? (
|
|
3078
|
+
value: row[col.field] ? formatDateTime(row[col.field], "yyyy-MM-dd") : row[col.field],
|
|
3057
3079
|
onChange: (val) => {
|
|
3058
3080
|
row[col.field] = val.target.value;
|
|
3059
3081
|
if (col.callback) {
|
|
@@ -3082,7 +3104,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3082
3104
|
{
|
|
3083
3105
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
3084
3106
|
style: { textAlign: col.textAlign, height: 29 },
|
|
3085
|
-
value: row[col.field] ? (
|
|
3107
|
+
value: row[col.field] ? formatDateTime(row[col.field], "yyyy-MM-dd HH:mm") : row[col.field],
|
|
3086
3108
|
onChange: (val) => {
|
|
3087
3109
|
row[col.field] = val.target.value;
|
|
3088
3110
|
if (col.callback) {
|
|
@@ -3161,6 +3183,11 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3161
3183
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
3162
3184
|
}
|
|
3163
3185
|
},
|
|
3186
|
+
onOpenMenu: () => {
|
|
3187
|
+
if (col.selectSettings?.onOpenMenu) {
|
|
3188
|
+
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
3189
|
+
}
|
|
3190
|
+
},
|
|
3164
3191
|
onPaste: (e) => {
|
|
3165
3192
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable) {
|
|
3166
3193
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
@@ -3227,6 +3254,11 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3227
3254
|
isClearable: col.selectSettings?.isClearable ?? false,
|
|
3228
3255
|
formatSetting,
|
|
3229
3256
|
placeholder: t("Select"),
|
|
3257
|
+
onOpenMenu: () => {
|
|
3258
|
+
if (col.selectSettings?.onOpenMenu) {
|
|
3259
|
+
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
3260
|
+
}
|
|
3261
|
+
},
|
|
3230
3262
|
loadOptions: col.selectSettings?.loadOptions,
|
|
3231
3263
|
handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : void 0,
|
|
3232
3264
|
fieldChildren: col.selectSettings?.fieldChild ?? "children",
|
|
@@ -3939,9 +3971,9 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3939
3971
|
if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
|
|
3940
3972
|
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction, true, false) ?? 0;
|
|
3941
3973
|
} else if (col.editType === "date") {
|
|
3942
|
-
value = value ? (
|
|
3974
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat) : "";
|
|
3943
3975
|
} else if (col.editType === "datetime") {
|
|
3944
|
-
value = value ? (
|
|
3976
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
3945
3977
|
}
|
|
3946
3978
|
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
|
|
3947
3979
|
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
@@ -5348,6 +5380,7 @@ var src_default = table_default;
|
|
|
5348
5380
|
checkDecimalSeparator,
|
|
5349
5381
|
checkThousandSeparator,
|
|
5350
5382
|
formartNumberic,
|
|
5383
|
+
formatDateTime,
|
|
5351
5384
|
generateUUID,
|
|
5352
5385
|
isNullOrUndefined,
|
|
5353
5386
|
messageBoxConfirm,
|
package/dist/index.mjs
CHANGED
|
@@ -301,9 +301,20 @@ var roundNumber = (num, fraction) => {
|
|
|
301
301
|
const result = Math.round(num * base) / base;
|
|
302
302
|
return result;
|
|
303
303
|
};
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
var formatDateTime = (data, format = "dd/MM/yyyy") => {
|
|
305
|
+
if (!data) {
|
|
306
|
+
return "";
|
|
307
|
+
}
|
|
308
|
+
const date = new Date(data);
|
|
309
|
+
const map = {
|
|
310
|
+
dd: String(date.getDate()).padStart(2, "0"),
|
|
311
|
+
MM: String(date.getMonth() + 1).padStart(2, "0"),
|
|
312
|
+
yyyy: date.getFullYear(),
|
|
313
|
+
HH: String(date.getHours()).padStart(2, "0"),
|
|
314
|
+
mm: String(date.getMinutes()).padStart(2, "0")
|
|
315
|
+
};
|
|
316
|
+
return format.replace(/dd|MM|yyyy|HH|mm/g, (match) => map[match]);
|
|
317
|
+
};
|
|
307
318
|
|
|
308
319
|
// src/component/edit-form/index.tsx
|
|
309
320
|
import { forwardRef as forwardRef2, useEffect as useEffect4, useRef as useRef2, useState as useState3 } from "react";
|
|
@@ -567,7 +578,6 @@ import {
|
|
|
567
578
|
} from "reactstrap";
|
|
568
579
|
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
569
580
|
import classnames3 from "classnames";
|
|
570
|
-
import moment from "moment";
|
|
571
581
|
import { Plus } from "becoxy-icons";
|
|
572
582
|
import { Fragment as Fragment6, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
573
583
|
var defaultMaxHeight = 250;
|
|
@@ -599,6 +609,7 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
599
609
|
footerComponent,
|
|
600
610
|
formatSetting,
|
|
601
611
|
allowCreate,
|
|
612
|
+
onOpenMenu,
|
|
602
613
|
onPaste
|
|
603
614
|
} = props;
|
|
604
615
|
const selectTableRef = useRef();
|
|
@@ -658,6 +669,11 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
658
669
|
setIndexFocus(0);
|
|
659
670
|
}
|
|
660
671
|
}, [searchTerm]);
|
|
672
|
+
useEffect3(() => {
|
|
673
|
+
if (dropdownOpen && onOpenMenu) {
|
|
674
|
+
onOpenMenu();
|
|
675
|
+
}
|
|
676
|
+
}, [dropdownOpen]);
|
|
661
677
|
const handleOpenClose = () => {
|
|
662
678
|
setSearchTerm("");
|
|
663
679
|
if (dropdownOpen) {
|
|
@@ -890,9 +906,9 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
890
906
|
if (col.type === "numeric" || col.typeCondition && col.typeCondition(row) === "numeric") {
|
|
891
907
|
valueDisplay = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ".", formatSetting?.thousandSeparator ?? ",", col.fraction ?? 0, true, false) ?? 0;
|
|
892
908
|
} else if (col.type === "date") {
|
|
893
|
-
valueDisplay = valueDisplay ?
|
|
909
|
+
valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat) : "";
|
|
894
910
|
} else if (col.type === "datetime") {
|
|
895
|
-
valueDisplay = valueDisplay ?
|
|
911
|
+
valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
896
912
|
}
|
|
897
913
|
return /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
898
914
|
col.visible !== false && /* @__PURE__ */ jsx5(
|
|
@@ -2247,7 +2263,6 @@ import {
|
|
|
2247
2263
|
} from "reactstrap";
|
|
2248
2264
|
import { useTranslation as useTranslation11 } from "react-i18next";
|
|
2249
2265
|
import classnames8 from "classnames";
|
|
2250
|
-
import moment2 from "moment";
|
|
2251
2266
|
import { ChevronRight as ChevronRight3, Plus as Plus3 } from "becoxy-icons";
|
|
2252
2267
|
import { Fragment as Fragment19, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2253
2268
|
var defaultMaxHeight2 = 250;
|
|
@@ -2279,6 +2294,7 @@ var SelectTableTree = forwardRef3((props, ref) => {
|
|
|
2279
2294
|
selectChilds,
|
|
2280
2295
|
footerComponent,
|
|
2281
2296
|
formatSetting,
|
|
2297
|
+
onOpenMenu,
|
|
2282
2298
|
onPaste
|
|
2283
2299
|
} = props;
|
|
2284
2300
|
const selectTableRef = useRef3();
|
|
@@ -2301,6 +2317,11 @@ var SelectTableTree = forwardRef3((props, ref) => {
|
|
|
2301
2317
|
const isSelectedAll = useMemo2(() => {
|
|
2302
2318
|
return isMulti === true && options.length > 0 && areAllItemsSelected(value, options, fieldValue ?? "value");
|
|
2303
2319
|
}, [options, value]);
|
|
2320
|
+
useEffect8(() => {
|
|
2321
|
+
if (dropdownOpen && onOpenMenu) {
|
|
2322
|
+
onOpenMenu();
|
|
2323
|
+
}
|
|
2324
|
+
}, [dropdownOpen]);
|
|
2304
2325
|
const defaultColumns = [
|
|
2305
2326
|
{
|
|
2306
2327
|
headerText: "Name",
|
|
@@ -2522,9 +2543,9 @@ var SelectTableTree = forwardRef3((props, ref) => {
|
|
|
2522
2543
|
if (col.type === "numeric" || col.typeCondition && col.typeCondition(row) === "numeric") {
|
|
2523
2544
|
valueDisplay = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ".", formatSetting?.thousandSeparator ?? ",", col.fraction ?? 0, true) ?? 0;
|
|
2524
2545
|
} else if (col.type === "date") {
|
|
2525
|
-
valueDisplay = valueDisplay ?
|
|
2546
|
+
valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat) : "";
|
|
2526
2547
|
} else if (col.type === "datetime") {
|
|
2527
|
-
valueDisplay = valueDisplay ?
|
|
2548
|
+
valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
2528
2549
|
}
|
|
2529
2550
|
return /* @__PURE__ */ jsxs14(Fragment18, { children: [
|
|
2530
2551
|
col.visible !== false && /* @__PURE__ */ jsxs14(
|
|
@@ -3024,7 +3045,7 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
3024
3045
|
{
|
|
3025
3046
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
3026
3047
|
style: { textAlign: col.textAlign, height: 29 },
|
|
3027
|
-
value: row[col.field] ?
|
|
3048
|
+
value: row[col.field] ? formatDateTime(row[col.field], "yyyy-MM-dd") : row[col.field],
|
|
3028
3049
|
onChange: (val) => {
|
|
3029
3050
|
row[col.field] = val.target.value;
|
|
3030
3051
|
if (col.callback) {
|
|
@@ -3053,7 +3074,7 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
3053
3074
|
{
|
|
3054
3075
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
3055
3076
|
style: { textAlign: col.textAlign, height: 29 },
|
|
3056
|
-
value: row[col.field] ?
|
|
3077
|
+
value: row[col.field] ? formatDateTime(row[col.field], "yyyy-MM-dd HH:mm") : row[col.field],
|
|
3057
3078
|
onChange: (val) => {
|
|
3058
3079
|
row[col.field] = val.target.value;
|
|
3059
3080
|
if (col.callback) {
|
|
@@ -3132,6 +3153,11 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
3132
3153
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
3133
3154
|
}
|
|
3134
3155
|
},
|
|
3156
|
+
onOpenMenu: () => {
|
|
3157
|
+
if (col.selectSettings?.onOpenMenu) {
|
|
3158
|
+
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
3159
|
+
}
|
|
3160
|
+
},
|
|
3135
3161
|
onPaste: (e) => {
|
|
3136
3162
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable) {
|
|
3137
3163
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
@@ -3198,6 +3224,11 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
3198
3224
|
isClearable: col.selectSettings?.isClearable ?? false,
|
|
3199
3225
|
formatSetting,
|
|
3200
3226
|
placeholder: t("Select"),
|
|
3227
|
+
onOpenMenu: () => {
|
|
3228
|
+
if (col.selectSettings?.onOpenMenu) {
|
|
3229
|
+
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
3230
|
+
}
|
|
3231
|
+
},
|
|
3201
3232
|
loadOptions: col.selectSettings?.loadOptions,
|
|
3202
3233
|
handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : void 0,
|
|
3203
3234
|
fieldChildren: col.selectSettings?.fieldChild ?? "children",
|
|
@@ -3910,9 +3941,9 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
3910
3941
|
if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
|
|
3911
3942
|
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction, true, false) ?? 0;
|
|
3912
3943
|
} else if (col.editType === "date") {
|
|
3913
|
-
value = value ?
|
|
3944
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat) : "";
|
|
3914
3945
|
} else if (col.editType === "datetime") {
|
|
3915
|
-
value = value ?
|
|
3946
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
3916
3947
|
}
|
|
3917
3948
|
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
|
|
3918
3949
|
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
@@ -5319,6 +5350,7 @@ export {
|
|
|
5319
5350
|
checkThousandSeparator,
|
|
5320
5351
|
src_default as default,
|
|
5321
5352
|
formartNumberic,
|
|
5353
|
+
formatDateTime,
|
|
5322
5354
|
generateUUID,
|
|
5323
5355
|
isNullOrUndefined,
|
|
5324
5356
|
messageBoxConfirm,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-table-edit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.20",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,9 +25,7 @@
|
|
|
25
25
|
"@hookform/resolvers": "^2.8.10",
|
|
26
26
|
"@types/react-resizable": "^3.0.7",
|
|
27
27
|
"becoxy-icons": "1.8.1",
|
|
28
|
-
"bootstrap": "5.1.0",
|
|
29
28
|
"classnames": "2.3.1",
|
|
30
|
-
"moment": "^2.29.3",
|
|
31
29
|
"react": "^18.1.0",
|
|
32
30
|
"react-dom": "^18.1.0",
|
|
33
31
|
"react-hook-form": "7.43.9",
|