@skalfa/skalfa-component 1.0.32 → 1.0.34
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/supervision/TableSupervision.component.d.ts +2 -1
- package/dist/supervision/TableSupervision.component.js +2 -2
- package/dist/table/Table.component.d.ts +2 -1
- package/dist/table/Table.component.js +2 -2
- package/dist/wrap/ContentWrapper.component.js +13 -5
- package/package.json +1 -1
- package/src/supervision/TableSupervision.component.tsx +3 -0
- package/src/table/Table.component.tsx +5 -0
- package/src/wrap/ContentWrapper.component.tsx +13 -5
|
@@ -63,6 +63,7 @@ export type TableSupervisionProps = {
|
|
|
63
63
|
noIndex?: boolean;
|
|
64
64
|
actionBulkingControl?: TableProps["actionBulking"];
|
|
65
65
|
controlBar?: (ControlBarOptionType | "CREATE" | "IMPORT" | "EXPORT" | "PRINT")[];
|
|
66
|
+
filterBar?: ReactNode;
|
|
66
67
|
responsiveControl?: {
|
|
67
68
|
mobile?: boolean | {
|
|
68
69
|
item?: (item: Record<string, any>, key: number) => ReactNode;
|
|
@@ -75,4 +76,4 @@ export type TableSupervisionProps = {
|
|
|
75
76
|
};
|
|
76
77
|
};
|
|
77
78
|
};
|
|
78
|
-
export declare function TableSupervisionComponent({ title, id, fetchControl, columnControl, formControl, onRowClick, detailControl, actionControl, actionBulkingControl, block, controlBar, noIndex, responsiveControl, urlParam, }: TableSupervisionProps): import("@types/react").JSX.Element;
|
|
79
|
+
export declare function TableSupervisionComponent({ title, id, fetchControl, columnControl, formControl, onRowClick, detailControl, actionControl, actionBulkingControl, block, controlBar, filterBar, noIndex, responsiveControl, urlParam, }: TableSupervisionProps): import("@types/react").JSX.Element;
|
|
@@ -12,7 +12,7 @@ const ExportExcel = _utils_1.registry.get("ExportExcel");
|
|
|
12
12
|
const ImportExcel = _utils_1.registry.get("ImportExcel");
|
|
13
13
|
;
|
|
14
14
|
;
|
|
15
|
-
function TableSupervisionComponent({ title, id, fetchControl, columnControl, formControl, onRowClick, detailControl, actionControl, actionBulkingControl, block, controlBar, noIndex, responsiveControl, urlParam, }) {
|
|
15
|
+
function TableSupervisionComponent({ title, id, fetchControl, columnControl, formControl, onRowClick, detailControl, actionControl, actionBulkingControl, block, controlBar, filterBar, noIndex, responsiveControl, urlParam, }) {
|
|
16
16
|
const l = (0, skalfa_lang_1.useLang)();
|
|
17
17
|
const { tableKey, tableControl, data, selected, setSelected, checks, setChecks, reset, focus, setFocus } = (0, _utils_1.useTable)(fetchControl, id, title, (urlParam || true));
|
|
18
18
|
const { setToggle, toggle } = (0, _contexts_1.useToggleContext)();
|
|
@@ -243,7 +243,7 @@ function TableSupervisionComponent({ title, id, fetchControl, columnControl, for
|
|
|
243
243
|
...(columns?.filter((c) => !!c.filterable)?.length ? ["FILTER"] : []),
|
|
244
244
|
...(columns?.filter((c) => !!c.sortable)?.length ? ["SORT"] : []),
|
|
245
245
|
"SELECTABLE", "REFRESH",
|
|
246
|
-
], columns: columns, data: dataTables, onRowClick: onRowClick ? onRowClick : detailControl != false ? (e) => {
|
|
246
|
+
], filterBar: filterBar, columns: columns, data: dataTables, onRowClick: onRowClick ? onRowClick : detailControl != false ? (e) => {
|
|
247
247
|
setToggle(`MODAL_SHOW_${toggleKey}`);
|
|
248
248
|
setSelected(e);
|
|
249
249
|
} : undefined, actionBulking: actionBulkingControl, checks: checks || [], onChangeChecks: (e) => setChecks(e), block: block, focus: focus, noIndex: noIndex, responsiveControl: responsiveControl ? {
|
|
@@ -26,6 +26,7 @@ export interface TableColumnType {
|
|
|
26
26
|
export interface TableProps {
|
|
27
27
|
id?: string;
|
|
28
28
|
controlBar?: false | ControlBarOptionType[];
|
|
29
|
+
filterBar?: ReactNode;
|
|
29
30
|
columns: TableColumnType[];
|
|
30
31
|
data: Record<string, any>[];
|
|
31
32
|
pagination?: PaginationProps | false;
|
|
@@ -61,4 +62,4 @@ export interface TableProps {
|
|
|
61
62
|
/** Use custom class with: "controller-bar::", "head-column::", "column::", "floating-action::", "row::". */
|
|
62
63
|
className?: string;
|
|
63
64
|
}
|
|
64
|
-
export declare function TableComponent({ id, controlBar, columns, data, pagination, loading, sortBy, onChangeSortBy, search, onChangeSearch, searchableColumn, onChangeSearchableColumn, filter, onChangeFilter, checks, onChangeChecks, actionBulking, focus, onRowClick, onRefresh, block, noIndex, responsiveControl, className, }: TableProps): import("@types/react").JSX.Element;
|
|
65
|
+
export declare function TableComponent({ id, controlBar, filterBar, columns, data, pagination, loading, sortBy, onChangeSortBy, search, onChangeSearch, searchableColumn, onChangeSearchableColumn, filter, onChangeFilter, checks, onChangeChecks, actionBulking, focus, onRowClick, onRefresh, block, noIndex, responsiveControl, className, }: TableProps): import("@types/react").JSX.Element;
|
|
@@ -12,7 +12,7 @@ const ScrollContainer_component_1 = require("../wrap/ScrollContainer.component")
|
|
|
12
12
|
const Checkbox_component_1 = require("../input/Checkbox.component");
|
|
13
13
|
const Swipe_component_1 = require("../wrap/Swipe.component");
|
|
14
14
|
const skalfa_lang_1 = require("@skalfa/skalfa-lang");
|
|
15
|
-
function TableComponent({ id, controlBar, columns, data, pagination, loading, sortBy, onChangeSortBy, search, onChangeSearch, searchableColumn, onChangeSearchableColumn, filter, onChangeFilter, checks, onChangeChecks, actionBulking, focus, onRowClick, onRefresh, block, noIndex, responsiveControl, className = "", }) {
|
|
15
|
+
function TableComponent({ id, controlBar, filterBar, columns, data, pagination, loading, sortBy, onChangeSortBy, search, onChangeSearch, searchableColumn, onChangeSearchableColumn, filter, onChangeFilter, checks, onChangeChecks, actionBulking, focus, onRowClick, onRefresh, block, noIndex, responsiveControl, className = "", }) {
|
|
16
16
|
const l = (0, skalfa_lang_1.useLang)();
|
|
17
17
|
const [displayColumns, setDisplayColumns] = (0, react_1.useState)([]);
|
|
18
18
|
const [showFloatingAction, setShowFloatingAction] = (0, react_1.useState)(false);
|
|
@@ -97,7 +97,7 @@ function TableComponent({ id, controlBar, columns, data, pagination, loading, so
|
|
|
97
97
|
selector: c.selector,
|
|
98
98
|
type: typeof c?.filterable == "object" ? c?.filterable?.type : "text",
|
|
99
99
|
options: typeof c?.filterable == "object" && c?.filterable?.type == "select" ? c?.filterable?.options : undefined
|
|
100
|
-
})), onFilter: (filters) => onChangeFilter?.(filters), filter: filter, className: (0, _utils_1.pcn)(className, "controller-bar") || "" })), (0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)(ScrollContainer_component_1.ScrollContainerComponent, { scrollFloating: !isSm && block, className: `w-full ${block ? "pb-12" : ""}`, onScroll: (e) => {
|
|
100
|
+
})), onFilter: (filters) => onChangeFilter?.(filters), filter: filter, className: (0, _utils_1.pcn)(className, "controller-bar") || "" })), filterBar, (0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)(ScrollContainer_component_1.ScrollContainerComponent, { scrollFloating: !isSm && block, className: `w-full ${block ? "pb-12" : ""}`, onScroll: (e) => {
|
|
101
101
|
actionColumnRef.current?.clientWidth && e.scrollLeft &&
|
|
102
102
|
setShowFloatingAction(e.scrollLeft + e.clientWidth <= e.scrollWidth - actionColumnRef.current?.clientWidth);
|
|
103
103
|
}, footer: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: block && pagination && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "py-6" }), (0, jsx_runtime_1.jsx)("div", { className: "my-2 absolute bottom-0 w-full", children: (0, jsx_runtime_1.jsx)(Pagination_component_1.PaginationComponent, { ...pagination }) })] })) }), children: loading ? ((0, jsx_runtime_1.jsx)("div", { className: "w-max min-w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "table-loading-container", children: (0, jsx_runtime_1.jsx)("h1", { className: "table-loading-text", children: l.base.tableLoading ? l.base.tableLoading() : "" }) }) })) : !data || !data.length ? ((0, jsx_runtime_1.jsx)("div", { className: "table-empty-container", children: (0, jsx_runtime_1.jsx)("h1", { className: "table-empty-text", children: l.base.tableEmpty ? l.base.tableEmpty() : "Data empty" }) })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !isSm || !responsiveControl?.mobile ? ((0, jsx_runtime_1.jsxs)("div", { className: "w-max min-w-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("table-head-row", (0, _utils_1.pcn)(className, "row")), children: [!!actionBulking && ((0, jsx_runtime_1.jsx)("div", { className: "table-head-column w-max", children: (0, jsx_runtime_1.jsx)(Checkbox_component_1.CheckboxComponent, { name: "selected_table", className: "w-5 h-5", checked: data.length > 0 && checks?.length === data.length, onChange: () => data.length > 0 && checks?.length === data.length ? onChangeChecks?.([]) : onChangeChecks?.(data.map((d) => d.id)) }) })), !noIndex && (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("table-head-column w-8", (0, _utils_1.pcn)(className, "head-column")), children: "#" }), renderHead()] }), (0, jsx_runtime_1.jsx)("div", { className: "table-body", children: data.map((item, key) => {
|
|
@@ -40,7 +40,7 @@ function parseInlineFormats(text) {
|
|
|
40
40
|
function parseContentToHtml(content) {
|
|
41
41
|
if (!content)
|
|
42
42
|
return "";
|
|
43
|
-
const lines = content.split("\n");
|
|
43
|
+
const lines = content.replace(/\r/g, "").split("\n");
|
|
44
44
|
const htmlParts = [];
|
|
45
45
|
let i = 0;
|
|
46
46
|
while (i < lines.length) {
|
|
@@ -58,27 +58,35 @@ function parseContentToHtml(content) {
|
|
|
58
58
|
}
|
|
59
59
|
if (line.match(/^\[list:bullet\]/)) {
|
|
60
60
|
const items = [];
|
|
61
|
+
let matchedAny = false;
|
|
61
62
|
while (i < lines.length) {
|
|
62
63
|
const bm = lines[i].match(/^\[list:bullet\](.*?)\[list\]$/);
|
|
63
64
|
if (!bm)
|
|
64
65
|
break;
|
|
66
|
+
matchedAny = true;
|
|
65
67
|
items.push(`<li>${parseInlineFormats(bm[1])}</li>`);
|
|
66
68
|
i++;
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
if (matchedAny) {
|
|
71
|
+
htmlParts.push(`<ul>${items.join("")}</ul>`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
if (line.match(/^\[list:number\]/)) {
|
|
72
76
|
const items = [];
|
|
77
|
+
let matchedAny = false;
|
|
73
78
|
while (i < lines.length) {
|
|
74
79
|
const nm = lines[i].match(/^\[list:number\](.*?)\[list\]$/);
|
|
75
80
|
if (!nm)
|
|
76
81
|
break;
|
|
82
|
+
matchedAny = true;
|
|
77
83
|
items.push(`<li>${parseInlineFormats(nm[1])}</li>`);
|
|
78
84
|
i++;
|
|
79
85
|
}
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
if (matchedAny) {
|
|
87
|
+
htmlParts.push(`<ol>${items.join("")}</ol>`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
82
90
|
}
|
|
83
91
|
const alignMatch = line.match(/^\[align:(left|center|right|justify)\](.*?)\[align\]$/);
|
|
84
92
|
if (alignMatch) {
|
package/package.json
CHANGED
|
@@ -75,6 +75,7 @@ export type TableSupervisionProps = {
|
|
|
75
75
|
noIndex ?: boolean;
|
|
76
76
|
actionBulkingControl ?: TableProps["actionBulking"],
|
|
77
77
|
controlBar ?: (ControlBarOptionType | "CREATE" | "IMPORT" | "EXPORT" | "PRINT")[];
|
|
78
|
+
filterBar ?: ReactNode;
|
|
78
79
|
responsiveControl ?: {
|
|
79
80
|
mobile ?: boolean | {
|
|
80
81
|
item ?: (item: Record<string, any>, key: number) => ReactNode,
|
|
@@ -98,6 +99,7 @@ export function TableSupervisionComponent({
|
|
|
98
99
|
actionBulkingControl,
|
|
99
100
|
block,
|
|
100
101
|
controlBar,
|
|
102
|
+
filterBar,
|
|
101
103
|
noIndex,
|
|
102
104
|
responsiveControl,
|
|
103
105
|
urlParam,
|
|
@@ -500,6 +502,7 @@ export function TableSupervisionComponent({
|
|
|
500
502
|
...(columns?.filter((c) => !!(c as { sortable?: any }).sortable)?.length ? ["SORT"] : []),
|
|
501
503
|
"SELECTABLE", "REFRESH",
|
|
502
504
|
]}
|
|
505
|
+
filterBar={filterBar}
|
|
503
506
|
columns={columns as TableColumnType[]}
|
|
504
507
|
data={dataTables}
|
|
505
508
|
onRowClick={onRowClick ? onRowClick : detailControl != false ? (e) => {
|
|
@@ -36,6 +36,8 @@ export interface TableProps {
|
|
|
36
36
|
id ?: string;
|
|
37
37
|
|
|
38
38
|
controlBar ?: false | ControlBarOptionType[];
|
|
39
|
+
filterBar ?: ReactNode;
|
|
40
|
+
|
|
39
41
|
|
|
40
42
|
columns : TableColumnType[];
|
|
41
43
|
data : Record<string, any>[];
|
|
@@ -76,6 +78,7 @@ export interface TableProps {
|
|
|
76
78
|
export function TableComponent({
|
|
77
79
|
id,
|
|
78
80
|
controlBar,
|
|
81
|
+
filterBar,
|
|
79
82
|
columns,
|
|
80
83
|
data,
|
|
81
84
|
pagination,
|
|
@@ -290,6 +293,8 @@ export function TableComponent({
|
|
|
290
293
|
/>
|
|
291
294
|
)}
|
|
292
295
|
|
|
296
|
+
{filterBar}
|
|
297
|
+
|
|
293
298
|
<div className="relative">
|
|
294
299
|
<ScrollContainerComponent
|
|
295
300
|
scrollFloating={!isSm && block}
|
|
@@ -44,7 +44,7 @@ export function parseInlineFormats(text: string): string {
|
|
|
44
44
|
export function parseContentToHtml(content: string): string {
|
|
45
45
|
if (!content) return "";
|
|
46
46
|
|
|
47
|
-
const lines = content.split("\n");
|
|
47
|
+
const lines = content.replace(/\r/g, "").split("\n");
|
|
48
48
|
const htmlParts: string[] = [];
|
|
49
49
|
let i = 0;
|
|
50
50
|
|
|
@@ -66,26 +66,34 @@ export function parseContentToHtml(content: string): string {
|
|
|
66
66
|
|
|
67
67
|
if (line.match(/^\[list:bullet\]/)) {
|
|
68
68
|
const items: string[] = [];
|
|
69
|
+
let matchedAny = false;
|
|
69
70
|
while (i < lines.length) {
|
|
70
71
|
const bm = lines[i].match(/^\[list:bullet\](.*?)\[list\]$/);
|
|
71
72
|
if (!bm) break;
|
|
73
|
+
matchedAny = true;
|
|
72
74
|
items.push(`<li>${parseInlineFormats(bm[1])}</li>`);
|
|
73
75
|
i++;
|
|
74
76
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
if (matchedAny) {
|
|
78
|
+
htmlParts.push(`<ul>${items.join("")}</ul>`);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
if (line.match(/^\[list:number\]/)) {
|
|
80
84
|
const items: string[] = [];
|
|
85
|
+
let matchedAny = false;
|
|
81
86
|
while (i < lines.length) {
|
|
82
87
|
const nm = lines[i].match(/^\[list:number\](.*?)\[list\]$/);
|
|
83
88
|
if (!nm) break;
|
|
89
|
+
matchedAny = true;
|
|
84
90
|
items.push(`<li>${parseInlineFormats(nm[1])}</li>`);
|
|
85
91
|
i++;
|
|
86
92
|
}
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
if (matchedAny) {
|
|
94
|
+
htmlParts.push(`<ol>${items.join("")}</ol>`);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
const alignMatch = line.match(/^\[align:(left|center|right|justify)\](.*?)\[align\]$/);
|