react-table-edit 0.4.6 → 0.4.7
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 +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +104 -0
- package/dist/index.mjs +103 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, Dispatch, SetStateAction } from 'react';
|
|
3
3
|
import { TFunction } from 'react-i18next';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
6
|
type ITextAlign = 'center' | 'left' | 'right';
|
|
6
7
|
type IEditType = 'text' | 'numeric' | 'asyncSelect' | 'datetime' | 'selectMulti' | 'selectTree' | 'date' | 'select' | 'checkbox' | 'form' | 'color';
|
|
@@ -184,4 +185,14 @@ declare const objSymbolThousand: any;
|
|
|
184
185
|
declare const formartNumberic: (str: string | number, decimalSeparator: string, thousandSeparator: string, fraction?: number, isDone?: boolean) => string;
|
|
185
186
|
declare const roundNumber: (num: number, fraction: number) => number;
|
|
186
187
|
|
|
187
|
-
|
|
188
|
+
type IFDataProps = {
|
|
189
|
+
buttonWidth?: number;
|
|
190
|
+
tabParent?: boolean;
|
|
191
|
+
tabChild?: boolean;
|
|
192
|
+
resourceCodeParent?: string;
|
|
193
|
+
resourceCode: string;
|
|
194
|
+
resources: any[];
|
|
195
|
+
};
|
|
196
|
+
declare const TabsMenuComponent: ({ buttonWidth, tabParent, tabChild, resourceCodeParent, resources, resourceCode }: IFDataProps) => react_jsx_runtime.JSX.Element;
|
|
197
|
+
|
|
198
|
+
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditButton, type IFTableEditPaging, type IFTableEditProps, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFToolbarOptions, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, TabsMenuComponent, TableEdit as default, formartNumberic, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, objSymbolDecimal, objSymbolThousand, roundNumber, useOnClickOutside };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, Dispatch, SetStateAction } from 'react';
|
|
3
3
|
import { TFunction } from 'react-i18next';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
6
|
type ITextAlign = 'center' | 'left' | 'right';
|
|
6
7
|
type IEditType = 'text' | 'numeric' | 'asyncSelect' | 'datetime' | 'selectMulti' | 'selectTree' | 'date' | 'select' | 'checkbox' | 'form' | 'color';
|
|
@@ -184,4 +185,14 @@ declare const objSymbolThousand: any;
|
|
|
184
185
|
declare const formartNumberic: (str: string | number, decimalSeparator: string, thousandSeparator: string, fraction?: number, isDone?: boolean) => string;
|
|
185
186
|
declare const roundNumber: (num: number, fraction: number) => number;
|
|
186
187
|
|
|
187
|
-
|
|
188
|
+
type IFDataProps = {
|
|
189
|
+
buttonWidth?: number;
|
|
190
|
+
tabParent?: boolean;
|
|
191
|
+
tabChild?: boolean;
|
|
192
|
+
resourceCodeParent?: string;
|
|
193
|
+
resourceCode: string;
|
|
194
|
+
resources: any[];
|
|
195
|
+
};
|
|
196
|
+
declare const TabsMenuComponent: ({ buttonWidth, tabParent, tabChild, resourceCodeParent, resources, resourceCode }: IFDataProps) => react_jsx_runtime.JSX.Element;
|
|
197
|
+
|
|
198
|
+
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditButton, type IFTableEditPaging, type IFTableEditProps, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFToolbarOptions, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, TabsMenuComponent, TableEdit as default, formartNumberic, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, objSymbolDecimal, objSymbolThousand, roundNumber, useOnClickOutside };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// index.ts
|
|
31
31
|
var Table_edit_exports = {};
|
|
32
32
|
__export(Table_edit_exports, {
|
|
33
|
+
TabsMenuComponent: () => TabsMenuComponent,
|
|
33
34
|
default: () => Table_edit_default,
|
|
34
35
|
formartNumberic: () => formartNumberic,
|
|
35
36
|
generateUUID: () => generateUUID,
|
|
@@ -2989,11 +2990,114 @@ var import_react13 = require("react");
|
|
|
2989
2990
|
var import_react_router_dom = require("react-router-dom");
|
|
2990
2991
|
var import_reactstrap9 = require("reactstrap");
|
|
2991
2992
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2993
|
+
var TabsMenuComponent = ({
|
|
2994
|
+
buttonWidth,
|
|
2995
|
+
tabParent,
|
|
2996
|
+
tabChild,
|
|
2997
|
+
resourceCodeParent,
|
|
2998
|
+
resources,
|
|
2999
|
+
resourceCode
|
|
3000
|
+
}) => {
|
|
3001
|
+
const [dataMenu, setDataMenu] = (0, import_react13.useState)([]);
|
|
3002
|
+
const [openMenu, setOpenMenu] = (0, import_react13.useState)(false);
|
|
3003
|
+
const [url, setUrl] = (0, import_react13.useState)("");
|
|
3004
|
+
const [contentWidth, setContentWidth] = (0, import_react13.useState)(0);
|
|
3005
|
+
const [componentWidth, setComponentWidth] = (0, import_react13.useState)(0);
|
|
3006
|
+
const [scrollPosition, setScrollPosition] = (0, import_react13.useState)(0);
|
|
3007
|
+
const handleWindowResize = () => {
|
|
3008
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
3009
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
3010
|
+
if (tabEle && tabContent) {
|
|
3011
|
+
setComponentWidth(tabEle?.offsetWidth ?? 0);
|
|
3012
|
+
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
3013
|
+
}
|
|
3014
|
+
};
|
|
3015
|
+
(0, import_react13.useEffect)(() => {
|
|
3016
|
+
setUrl(window.location.pathname);
|
|
3017
|
+
window.addEventListener("resize", handleWindowResize);
|
|
3018
|
+
setTimeout(() => {
|
|
3019
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
3020
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
3021
|
+
if (tabEle && tabContent) {
|
|
3022
|
+
setComponentWidth(tabEle?.offsetWidth ?? 0);
|
|
3023
|
+
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
3024
|
+
}
|
|
3025
|
+
}, 100);
|
|
3026
|
+
return () => {
|
|
3027
|
+
window.removeEventListener("resize", handleWindowResize);
|
|
3028
|
+
};
|
|
3029
|
+
}, []);
|
|
3030
|
+
(0, import_react13.useEffect)(() => {
|
|
3031
|
+
const item = resources?.find((x) => x.code === (resourceCodeParent ? resourceCodeParent : resourceCode));
|
|
3032
|
+
if (item) {
|
|
3033
|
+
if (resourceCodeParent) {
|
|
3034
|
+
const data = item.children?.find((x) => x.code === resourceCode);
|
|
3035
|
+
if (data) {
|
|
3036
|
+
setDataMenu([...data.children]);
|
|
3037
|
+
}
|
|
3038
|
+
} else {
|
|
3039
|
+
setDataMenu([...item.children]);
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
3042
|
+
}, [resources]);
|
|
3043
|
+
const toggleMenu = () => {
|
|
3044
|
+
setOpenMenu(!openMenu);
|
|
3045
|
+
};
|
|
3046
|
+
const handleScroll = (scrollAmount) => {
|
|
3047
|
+
let newScrollPosition = scrollPosition + scrollAmount;
|
|
3048
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
3049
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
3050
|
+
if (tabEle && tabContent && tabContent?.offsetWidth - tabEle?.offsetWidth - newScrollPosition > -200) {
|
|
3051
|
+
if (newScrollPosition < 0) {
|
|
3052
|
+
newScrollPosition = 0;
|
|
3053
|
+
}
|
|
3054
|
+
setScrollPosition(newScrollPosition);
|
|
3055
|
+
tabEle.scrollLeft = newScrollPosition;
|
|
3056
|
+
}
|
|
3057
|
+
};
|
|
3058
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: (0, import_classnames11.default)("tab-custom", { "tab-parent": tabParent }, { "tab-child": tabChild }), style: { width: `calc(100% - ${buttonWidth ?? 100}px` }, children: [
|
|
3059
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3060
|
+
"div",
|
|
3061
|
+
{
|
|
3062
|
+
onClick: () => handleScroll(-200),
|
|
3063
|
+
className: (0, import_classnames11.default)("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3064
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_becoxy_icons5.ChevronLeft, {})
|
|
3065
|
+
}
|
|
3066
|
+
),
|
|
3067
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { id: `tab-component-${resourceCode}`, className: "tab-component", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { id: `content-component-${resourceCode}`, children: dataMenu.map((item) => {
|
|
3068
|
+
if (item?.resAttributes?.IS_MENU === "1") {
|
|
3069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_reactstrap9.UncontrolledDropdown, { className: "tab-custom-item", isOpen: openMenu, toggle: toggleMenu, direction: "down", style: { backgroundColor: openMenu ? "#e0e0e0" : "" }, children: [
|
|
3070
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.DropdownToggle, { color: "#00000", style: { border: "none", boxShadow: "none", margin: 0, padding: 0 }, className: "background-none", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: item.name }) }),
|
|
3071
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.DropdownMenu, { container: document.body, end: true, style: { width: 300 }, children: item?.children?.map((x) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.DropdownItem, { style: { borderRadius: "5px", margin: "0 0.5rem", width: "95%", padding: "0.5rem 0.5rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_router_dom.Link, { to: x.url, style: { display: "block", width: "100%" }, children: x.name }) }, x.code)) })
|
|
3072
|
+
] }, item.code);
|
|
3073
|
+
} else {
|
|
3074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3075
|
+
import_react_router_dom.Link,
|
|
3076
|
+
{
|
|
3077
|
+
to: item.url,
|
|
3078
|
+
className: (0, import_classnames11.default)("tab-custom-item", { active: item.url === url || tabParent && url?.split("/").length > 3 && item.url.startsWith(url.substring(0, url.lastIndexOf("/"))) }),
|
|
3079
|
+
children: item.name
|
|
3080
|
+
},
|
|
3081
|
+
item.code
|
|
3082
|
+
);
|
|
3083
|
+
}
|
|
3084
|
+
}) }) }),
|
|
3085
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3086
|
+
"div",
|
|
3087
|
+
{
|
|
3088
|
+
onClick: () => handleScroll(200),
|
|
3089
|
+
className: (0, import_classnames11.default)("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3090
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_becoxy_icons5.ChevronRight, {})
|
|
3091
|
+
}
|
|
3092
|
+
)
|
|
3093
|
+
] }) });
|
|
3094
|
+
};
|
|
2992
3095
|
|
|
2993
3096
|
// index.ts
|
|
2994
3097
|
var Table_edit_default = table_default;
|
|
2995
3098
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2996
3099
|
0 && (module.exports = {
|
|
3100
|
+
TabsMenuComponent,
|
|
2997
3101
|
formartNumberic,
|
|
2998
3102
|
generateUUID,
|
|
2999
3103
|
isNullOrUndefined,
|
package/dist/index.mjs
CHANGED
|
@@ -2948,10 +2948,113 @@ import { Fragment as Fragment14, useEffect as useEffect6, useState as useState6
|
|
|
2948
2948
|
import { Link } from "react-router-dom";
|
|
2949
2949
|
import { DropdownItem as DropdownItem2, DropdownMenu as DropdownMenu3, DropdownToggle as DropdownToggle3, UncontrolledDropdown as UncontrolledDropdown2 } from "reactstrap";
|
|
2950
2950
|
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2951
|
+
var TabsMenuComponent = ({
|
|
2952
|
+
buttonWidth,
|
|
2953
|
+
tabParent,
|
|
2954
|
+
tabChild,
|
|
2955
|
+
resourceCodeParent,
|
|
2956
|
+
resources,
|
|
2957
|
+
resourceCode
|
|
2958
|
+
}) => {
|
|
2959
|
+
const [dataMenu, setDataMenu] = useState6([]);
|
|
2960
|
+
const [openMenu, setOpenMenu] = useState6(false);
|
|
2961
|
+
const [url, setUrl] = useState6("");
|
|
2962
|
+
const [contentWidth, setContentWidth] = useState6(0);
|
|
2963
|
+
const [componentWidth, setComponentWidth] = useState6(0);
|
|
2964
|
+
const [scrollPosition, setScrollPosition] = useState6(0);
|
|
2965
|
+
const handleWindowResize = () => {
|
|
2966
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
2967
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
2968
|
+
if (tabEle && tabContent) {
|
|
2969
|
+
setComponentWidth(tabEle?.offsetWidth ?? 0);
|
|
2970
|
+
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
2971
|
+
}
|
|
2972
|
+
};
|
|
2973
|
+
useEffect6(() => {
|
|
2974
|
+
setUrl(window.location.pathname);
|
|
2975
|
+
window.addEventListener("resize", handleWindowResize);
|
|
2976
|
+
setTimeout(() => {
|
|
2977
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
2978
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
2979
|
+
if (tabEle && tabContent) {
|
|
2980
|
+
setComponentWidth(tabEle?.offsetWidth ?? 0);
|
|
2981
|
+
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
2982
|
+
}
|
|
2983
|
+
}, 100);
|
|
2984
|
+
return () => {
|
|
2985
|
+
window.removeEventListener("resize", handleWindowResize);
|
|
2986
|
+
};
|
|
2987
|
+
}, []);
|
|
2988
|
+
useEffect6(() => {
|
|
2989
|
+
const item = resources?.find((x) => x.code === (resourceCodeParent ? resourceCodeParent : resourceCode));
|
|
2990
|
+
if (item) {
|
|
2991
|
+
if (resourceCodeParent) {
|
|
2992
|
+
const data = item.children?.find((x) => x.code === resourceCode);
|
|
2993
|
+
if (data) {
|
|
2994
|
+
setDataMenu([...data.children]);
|
|
2995
|
+
}
|
|
2996
|
+
} else {
|
|
2997
|
+
setDataMenu([...item.children]);
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
}, [resources]);
|
|
3001
|
+
const toggleMenu = () => {
|
|
3002
|
+
setOpenMenu(!openMenu);
|
|
3003
|
+
};
|
|
3004
|
+
const handleScroll = (scrollAmount) => {
|
|
3005
|
+
let newScrollPosition = scrollPosition + scrollAmount;
|
|
3006
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
3007
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
3008
|
+
if (tabEle && tabContent && tabContent?.offsetWidth - tabEle?.offsetWidth - newScrollPosition > -200) {
|
|
3009
|
+
if (newScrollPosition < 0) {
|
|
3010
|
+
newScrollPosition = 0;
|
|
3011
|
+
}
|
|
3012
|
+
setScrollPosition(newScrollPosition);
|
|
3013
|
+
tabEle.scrollLeft = newScrollPosition;
|
|
3014
|
+
}
|
|
3015
|
+
};
|
|
3016
|
+
return /* @__PURE__ */ jsx13(Fragment14, { children: /* @__PURE__ */ jsxs12("div", { className: classNames5("tab-custom", { "tab-parent": tabParent }, { "tab-child": tabChild }), style: { width: `calc(100% - ${buttonWidth ?? 100}px` }, children: [
|
|
3017
|
+
/* @__PURE__ */ jsx13(
|
|
3018
|
+
"div",
|
|
3019
|
+
{
|
|
3020
|
+
onClick: () => handleScroll(-200),
|
|
3021
|
+
className: classNames5("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3022
|
+
children: /* @__PURE__ */ jsx13(ChevronLeft2, {})
|
|
3023
|
+
}
|
|
3024
|
+
),
|
|
3025
|
+
/* @__PURE__ */ jsx13("div", { id: `tab-component-${resourceCode}`, className: "tab-component", children: /* @__PURE__ */ jsx13("div", { id: `content-component-${resourceCode}`, children: dataMenu.map((item) => {
|
|
3026
|
+
if (item?.resAttributes?.IS_MENU === "1") {
|
|
3027
|
+
return /* @__PURE__ */ jsxs12(UncontrolledDropdown2, { className: "tab-custom-item", isOpen: openMenu, toggle: toggleMenu, direction: "down", style: { backgroundColor: openMenu ? "#e0e0e0" : "" }, children: [
|
|
3028
|
+
/* @__PURE__ */ jsx13(DropdownToggle3, { color: "#00000", style: { border: "none", boxShadow: "none", margin: 0, padding: 0 }, className: "background-none", children: /* @__PURE__ */ jsx13("div", { children: item.name }) }),
|
|
3029
|
+
/* @__PURE__ */ jsx13(DropdownMenu3, { container: document.body, end: true, style: { width: 300 }, children: item?.children?.map((x) => /* @__PURE__ */ jsx13(DropdownItem2, { style: { borderRadius: "5px", margin: "0 0.5rem", width: "95%", padding: "0.5rem 0.5rem" }, children: /* @__PURE__ */ jsx13(Link, { to: x.url, style: { display: "block", width: "100%" }, children: x.name }) }, x.code)) })
|
|
3030
|
+
] }, item.code);
|
|
3031
|
+
} else {
|
|
3032
|
+
return /* @__PURE__ */ jsx13(
|
|
3033
|
+
Link,
|
|
3034
|
+
{
|
|
3035
|
+
to: item.url,
|
|
3036
|
+
className: classNames5("tab-custom-item", { active: item.url === url || tabParent && url?.split("/").length > 3 && item.url.startsWith(url.substring(0, url.lastIndexOf("/"))) }),
|
|
3037
|
+
children: item.name
|
|
3038
|
+
},
|
|
3039
|
+
item.code
|
|
3040
|
+
);
|
|
3041
|
+
}
|
|
3042
|
+
}) }) }),
|
|
3043
|
+
/* @__PURE__ */ jsx13(
|
|
3044
|
+
"div",
|
|
3045
|
+
{
|
|
3046
|
+
onClick: () => handleScroll(200),
|
|
3047
|
+
className: classNames5("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3048
|
+
children: /* @__PURE__ */ jsx13(ChevronRight2, {})
|
|
3049
|
+
}
|
|
3050
|
+
)
|
|
3051
|
+
] }) });
|
|
3052
|
+
};
|
|
2951
3053
|
|
|
2952
3054
|
// index.ts
|
|
2953
3055
|
var Table_edit_default = table_default;
|
|
2954
3056
|
export {
|
|
3057
|
+
TabsMenuComponent,
|
|
2955
3058
|
Table_edit_default as default,
|
|
2956
3059
|
formartNumberic,
|
|
2957
3060
|
generateUUID,
|