@skalfa/skalfa-component 1.0.2 → 1.0.4
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/accordion/Accordion.component.d.ts +1 -1
- package/dist/breadcrumb/Breadcrumb.component.d.ts +1 -1
- package/dist/button/Button.component.d.ts +1 -1
- package/dist/card/AlertCard.component.d.ts +1 -1
- package/dist/card/Card.component.d.ts +1 -1
- package/dist/card/DashboardCard.component.d.ts +1 -1
- package/dist/card/GalleryCard.component.d.ts +1 -1
- package/dist/card/ProductCard.component.d.ts +1 -1
- package/dist/card/ProfileCard.component.d.ts +1 -1
- package/dist/carousel/Carousel.component.d.ts +1 -1
- package/dist/chip/Chip.component.d.ts +1 -1
- package/dist/input/Checkbox.component.d.ts +1 -1
- package/dist/input/Input.component.d.ts +1 -1
- package/dist/input/InputCheckbox.component.d.ts +1 -1
- package/dist/input/InputCurrency.component.d.ts +1 -1
- package/dist/input/InputDate.component.d.ts +1 -1
- package/dist/input/InputDate.component.js +4 -4
- package/dist/input/InputDatetime.component.d.ts +1 -1
- package/dist/input/InputDocument.component.d.ts +1 -1
- package/dist/input/InputMap.component.d.ts +1 -1
- package/dist/input/InputNumber.component.d.ts +1 -1
- package/dist/input/InputPassword.component.d.ts +1 -1
- package/dist/input/InputRadio.component.d.ts +1 -1
- package/dist/input/InputTime.component.d.ts +1 -1
- package/dist/input/InputValues.component.d.ts +1 -1
- package/dist/input/Radio.component.d.ts +1 -1
- package/dist/input/Select.component.d.ts +1 -1
- package/dist/modal/FloatingPage.component.d.ts +1 -1
- package/dist/modal/Modal.component.d.ts +1 -1
- package/dist/modal/ModalConfirm.component.d.ts +1 -1
- package/dist/modal/Toast.component.d.ts +1 -1
- package/dist/nav/Bottombar.component.d.ts +1 -1
- package/dist/nav/Footer.component.d.ts +1 -1
- package/dist/nav/Headbar.component.d.ts +4 -11
- package/dist/nav/Headbar.component.js +3 -23
- package/dist/nav/Navbar.component.d.ts +1 -1
- package/dist/nav/Sidebar.component.d.ts +2 -2
- package/dist/nav/Tabbar.component.d.ts +1 -1
- package/dist/nav/Wizard.component.d.ts +1 -1
- package/dist/supervision/FormSupervision.component.d.ts +1 -1
- package/dist/supervision/TableSupervision.component.d.ts +1 -1
- package/dist/table/ControlBar.component.d.ts +1 -1
- package/dist/table/FilterComponent.d.ts +2 -2
- package/dist/table/Pagination.component.d.ts +1 -1
- package/dist/table/Table.component.d.ts +1 -1
- package/dist/typography/TypographyArticle.component.d.ts +1 -1
- package/dist/typography/TypographyColumn.component.d.ts +1 -1
- package/dist/typography/TypographyContent.component.d.ts +1 -1
- package/dist/typography/TypographyTips.component.d.ts +1 -1
- package/dist/wrap/Image.component.d.ts +1 -1
- package/dist/wrap/ScrollContainer.component.d.ts +1 -1
- package/dist/wrap/ShortcutProvider.d.ts +1 -1
- package/dist/wrap/Swipe.component.d.ts +1 -1
- package/package.json +2 -2
- package/dist/src/accordion/Accordion.component.d.ts +0 -13
- package/dist/src/accordion/Accordion.component.js +0 -25
- package/dist/src/breadcrumb/Breadcrumb.component.d.ts +0 -14
- package/dist/src/breadcrumb/Breadcrumb.component.js +0 -21
- package/dist/src/button/Button.component.d.ts +0 -21
- package/dist/src/button/Button.component.js +0 -19
- package/dist/src/card/AlertCard.component.d.ts +0 -11
- package/dist/src/card/AlertCard.component.js +0 -9
- package/dist/src/card/Card.component.d.ts +0 -5
- package/dist/src/card/Card.component.js +0 -9
- package/dist/src/card/DashboardCard.component.d.ts +0 -9
- package/dist/src/card/DashboardCard.component.js +0 -13
- package/dist/src/card/GalleryCard.component.d.ts +0 -7
- package/dist/src/card/GalleryCard.component.js +0 -13
- package/dist/src/card/ProductCard.component.d.ts +0 -9
- package/dist/src/card/ProductCard.component.js +0 -13
- package/dist/src/card/ProfileCard.component.d.ts +0 -10
- package/dist/src/card/ProfileCard.component.js +0 -13
- package/dist/src/carousel/Carousel.component.d.ts +0 -13
- package/dist/src/carousel/Carousel.component.js +0 -37
- package/dist/src/chip/Chip.component.d.ts +0 -6
- package/dist/src/chip/Chip.component.js +0 -12
- package/dist/src/index.d.ts +0 -13
- package/dist/src/index.js +0 -29
- package/dist/src/input/Checkbox.component.d.ts +0 -13
- package/dist/src/input/Checkbox.component.js +0 -23
- package/dist/src/input/Input.component.d.ts +0 -23
- package/dist/src/input/Input.component.js +0 -134
- package/dist/src/input/InputCheckbox.component.d.ts +0 -27
- package/dist/src/input/InputCheckbox.component.js +0 -53
- package/dist/src/input/InputCurrency.component.d.ts +0 -21
- package/dist/src/input/InputCurrency.component.js +0 -30
- package/dist/src/input/InputDate.component.d.ts +0 -24
- package/dist/src/input/InputDate.component.js +0 -107
- package/dist/src/input/InputDatetime.component.d.ts +0 -17
- package/dist/src/input/InputDatetime.component.js +0 -75
- package/dist/src/input/InputDocument.component.d.ts +0 -22
- package/dist/src/input/InputDocument.component.js +0 -88
- package/dist/src/input/InputImage.component.d.ts +0 -23
- package/dist/src/input/InputImage.component.js +0 -260
- package/dist/src/input/InputMap.component.d.ts +0 -25
- package/dist/src/input/InputMap.component.js +0 -101
- package/dist/src/input/InputNumber.component.d.ts +0 -19
- package/dist/src/input/InputNumber.component.js +0 -40
- package/dist/src/input/InputOtp.component.d.ts +0 -14
- package/dist/src/input/InputOtp.component.js +0 -65
- package/dist/src/input/InputPassword.component.d.ts +0 -17
- package/dist/src/input/InputPassword.component.js +0 -59
- package/dist/src/input/InputRadio.component.d.ts +0 -27
- package/dist/src/input/InputRadio.component.js +0 -56
- package/dist/src/input/InputTime.component.d.ts +0 -23
- package/dist/src/input/InputTime.component.js +0 -73
- package/dist/src/input/InputValues.component.d.ts +0 -9
- package/dist/src/input/InputValues.component.js +0 -19
- package/dist/src/input/Radio.component.d.ts +0 -12
- package/dist/src/input/Radio.component.js +0 -22
- package/dist/src/input/Select.component.d.ts +0 -47
- package/dist/src/input/Select.component.js +0 -275
- package/dist/src/modal/BottomSheet.component.d.ts +0 -12
- package/dist/src/modal/BottomSheet.component.js +0 -161
- package/dist/src/modal/FloatingPage.component.d.ts +0 -12
- package/dist/src/modal/FloatingPage.component.js +0 -27
- package/dist/src/modal/Modal.component.d.ts +0 -12
- package/dist/src/modal/Modal.component.js +0 -27
- package/dist/src/modal/ModalConfirm.component.d.ts +0 -26
- package/dist/src/modal/ModalConfirm.component.js +0 -68
- package/dist/src/modal/Toast.component.d.ts +0 -11
- package/dist/src/modal/Toast.component.js +0 -58
- package/dist/src/nav/Bottombar.component.d.ts +0 -12
- package/dist/src/nav/Bottombar.component.js +0 -32
- package/dist/src/nav/Footer.component.d.ts +0 -37
- package/dist/src/nav/Footer.component.js +0 -49
- package/dist/src/nav/Headbar.component.d.ts +0 -14
- package/dist/src/nav/Headbar.component.js +0 -32
- package/dist/src/nav/Navbar.component.d.ts +0 -22
- package/dist/src/nav/Navbar.component.js +0 -26
- package/dist/src/nav/Sidebar.component.d.ts +0 -33
- package/dist/src/nav/Sidebar.component.js +0 -87
- package/dist/src/nav/Tabbar.component.d.ts +0 -13
- package/dist/src/nav/Tabbar.component.js +0 -17
- package/dist/src/nav/Wizard.component.d.ts +0 -9
- package/dist/src/nav/Wizard.component.js +0 -24
- package/dist/src/supervision/FormSupervision.component.d.ts +0 -93
- package/dist/src/supervision/FormSupervision.component.js +0 -168
- package/dist/src/supervision/TableSupervision.component.d.ts +0 -78
- package/dist/src/supervision/TableSupervision.component.js +0 -273
- package/dist/src/table/ControlBar.component.d.ts +0 -34
- package/dist/src/table/ControlBar.component.js +0 -205
- package/dist/src/table/FilterComponent.d.ts +0 -45
- package/dist/src/table/FilterComponent.js +0 -132
- package/dist/src/table/Pagination.component.d.ts +0 -8
- package/dist/src/table/Pagination.component.js +0 -32
- package/dist/src/table/Table.component.d.ts +0 -61
- package/dist/src/table/Table.component.js +0 -101
- package/dist/src/typography/TypographyArticle.component.d.ts +0 -8
- package/dist/src/typography/TypographyArticle.component.js +0 -7
- package/dist/src/typography/TypographyColumn.component.d.ts +0 -6
- package/dist/src/typography/TypographyColumn.component.js +0 -7
- package/dist/src/typography/TypographyContent.component.d.ts +0 -6
- package/dist/src/typography/TypographyContent.component.js +0 -7
- package/dist/src/typography/TypographyTips.component.d.ts +0 -6
- package/dist/src/typography/TypographyTips.component.js +0 -7
- package/dist/src/wrap/Draggable.component.d.ts +0 -34
- package/dist/src/wrap/Draggable.component.js +0 -214
- package/dist/src/wrap/Image.component.d.ts +0 -2
- package/dist/src/wrap/Image.component.js +0 -13
- package/dist/src/wrap/OutsideClick.component.d.ts +0 -6
- package/dist/src/wrap/OutsideClick.component.js +0 -34
- package/dist/src/wrap/ScrollContainer.component.d.ts +0 -10
- package/dist/src/wrap/ScrollContainer.component.js +0 -54
- package/dist/src/wrap/ShortcutProvider.d.ts +0 -1
- package/dist/src/wrap/ShortcutProvider.js +0 -42
- package/dist/src/wrap/Swipe.component.d.ts +0 -14
- package/dist/src/wrap/Swipe.component.js +0 -61
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TableSupervisionComponent = TableSupervisionComponent;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const free_regular_svg_icons_1 = require("@fortawesome/free-regular-svg-icons");
|
|
8
|
-
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
9
|
-
const _utils_1 = require("@utils");
|
|
10
|
-
const _contexts_1 = require("@contexts");
|
|
11
|
-
const _components_1 = require("@components");
|
|
12
|
-
const ExportExcel = _utils_1.registry.get("ExportExcel");
|
|
13
|
-
const ImportExcel = _utils_1.registry.get("ImportExcel");
|
|
14
|
-
function TableSupervisionComponent({ title, id, fetchControl, columnControl, formControl, detailControl, actionControl, actionBulkingControl, block, controlBar, noIndex, responsiveControl, urlParam, importControl, }) {
|
|
15
|
-
const { tableKey, tableControl, data, selected, setSelected, checks, setChecks, reset, focus } = (0, _utils_1.useTable)(fetchControl, id, title, (urlParam || true));
|
|
16
|
-
const { setToggle, toggle } = (0, _contexts_1.useToggleContext)();
|
|
17
|
-
const { isSm } = (0, _utils_1.useResponsive)();
|
|
18
|
-
const isDetailControlObject = detailControl && typeof detailControl === "object" && !Array.isArray(detailControl);
|
|
19
|
-
const detailAction = isDetailControlObject
|
|
20
|
-
? detailControl?.action
|
|
21
|
-
: (typeof detailControl === "function" ? detailControl : undefined);
|
|
22
|
-
const detailContent = isDetailControlObject
|
|
23
|
-
? detailControl?.content
|
|
24
|
-
: (typeof detailControl === "function" ? undefined : detailControl);
|
|
25
|
-
const detailModalProps = isDetailControlObject
|
|
26
|
-
? detailControl?.modal
|
|
27
|
-
: undefined;
|
|
28
|
-
const toggleKey = (0, react_1.useMemo)(() => _utils_1.conversion.strSnake(tableKey).toUpperCase(), [tableKey]);
|
|
29
|
-
// ============================
|
|
30
|
-
// ## Shortcut register
|
|
31
|
-
// ============================
|
|
32
|
-
(0, react_1.useEffect)(() => {
|
|
33
|
-
if (!isSm) {
|
|
34
|
-
if (controlBar == undefined || controlBar?.includes("CREATE")) {
|
|
35
|
-
_utils_1.shortcut.register("alt+n", () => {
|
|
36
|
-
setToggle(`MODAL_FORM_${toggleKey}`);
|
|
37
|
-
setSelected(null);
|
|
38
|
-
}, "Tambah Data Baru");
|
|
39
|
-
}
|
|
40
|
-
if (controlBar?.includes("IMPORT")) {
|
|
41
|
-
_utils_1.shortcut.register("alt+i", () => {
|
|
42
|
-
setToggle(`MODAL_IMPORT_${toggleKey}`);
|
|
43
|
-
}, "Import Data Dari Excel");
|
|
44
|
-
}
|
|
45
|
-
if (controlBar?.includes("EXPORT")) {
|
|
46
|
-
_utils_1.shortcut.register("alt+e", () => {
|
|
47
|
-
setToggle(`MODAL_EXPORT_${toggleKey}`);
|
|
48
|
-
}, "Export Data Ke Excel");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return () => {
|
|
52
|
-
if (!isSm) {
|
|
53
|
-
_utils_1.shortcut.unregister("alt+n");
|
|
54
|
-
_utils_1.shortcut.unregister("alt+i");
|
|
55
|
-
_utils_1.shortcut.unregister("alt+e");
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}, [controlBar, isSm]);
|
|
59
|
-
(0, react_1.useEffect)(() => {
|
|
60
|
-
if (actionControl && Array.isArray(actionControl) && selected) {
|
|
61
|
-
actionControl.filter((ac) => typeof ac == "object")?.forEach((ac) => {
|
|
62
|
-
if (typeof ac == "object" && ac?.shortcut) {
|
|
63
|
-
_utils_1.shortcut.register(ac.shortcut.key, () => {
|
|
64
|
-
setToggle(`MODAL_${_utils_1.conversion.strSnake(ac.label).toUpperCase()}_${toggleKey}`);
|
|
65
|
-
}, ac.shortcut.description);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return () => {
|
|
70
|
-
if (actionControl && Array.isArray(actionControl)) {
|
|
71
|
-
actionControl.filter((ac) => typeof ac == "object")?.forEach((ac) => {
|
|
72
|
-
if (typeof ac == "object" && ac?.shortcut) {
|
|
73
|
-
_utils_1.shortcut.unregister(ac.shortcut.key);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}, [actionControl, selected]);
|
|
79
|
-
const columns = (0, react_1.useMemo)(() => {
|
|
80
|
-
return columnControl ? columnControl.map((col) => {
|
|
81
|
-
if (typeof col == "string") {
|
|
82
|
-
return {
|
|
83
|
-
selector: col,
|
|
84
|
-
label: col,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return { ...col };
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
: data?.columns || data?.data?.at(0) ? Object.keys(data.data[0]).map((col) => {
|
|
92
|
-
return {
|
|
93
|
-
selector: col,
|
|
94
|
-
label: col,
|
|
95
|
-
};
|
|
96
|
-
})
|
|
97
|
-
: [];
|
|
98
|
-
}, [columnControl, data]);
|
|
99
|
-
const renderTableAction = (actions, item, options) => {
|
|
100
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("table-supervision-action-list", options?.className), children: (Array.isArray(actions) ? actions : (actions || actions == undefined) ? ['EDIT', "DELETE"] : [])?.map((action, key) => {
|
|
101
|
-
if (action == "EDIT") {
|
|
102
|
-
return ((0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faEdit, label: "Ubah", variant: "outline", paint: "warning", size: options?.size || "xs", rounded: true, onClick: () => {
|
|
103
|
-
setToggle(`MODAL_FORM_${toggleKey}`);
|
|
104
|
-
item && setSelected?.(item);
|
|
105
|
-
} }, key));
|
|
106
|
-
}
|
|
107
|
-
if (action == "DELETE") {
|
|
108
|
-
return ((0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faTrash, label: "Hapus", variant: "outline", paint: "danger", size: options?.size || "xs", rounded: true, onClick: () => {
|
|
109
|
-
setToggle(`MODAL_DELETE_${toggleKey}`);
|
|
110
|
-
item && setSelected?.(item);
|
|
111
|
-
} }, key));
|
|
112
|
-
}
|
|
113
|
-
if (typeof action == "object") {
|
|
114
|
-
return ((0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { label: action.label, variant: "outline", paint: "primary", size: options?.size || "xs", rounded: true, onClick: () => {
|
|
115
|
-
setToggle(`MODAL_${_utils_1.conversion.strSnake(action.label).toUpperCase()}_${toggleKey}`);
|
|
116
|
-
item && setSelected?.(item);
|
|
117
|
-
}, ...action.button }, key));
|
|
118
|
-
}
|
|
119
|
-
if (typeof action == "function") {
|
|
120
|
-
return ((0, jsx_runtime_1.jsx)("div", { children: action(item || {}, (type) => {
|
|
121
|
-
setToggle(`MODAL_${type}_${toggleKey}`);
|
|
122
|
-
item && setSelected?.(item);
|
|
123
|
-
}, () => item && setSelected?.(item)) }, key));
|
|
124
|
-
}
|
|
125
|
-
}) }) }));
|
|
126
|
-
};
|
|
127
|
-
// ============================
|
|
128
|
-
// ## Render detail page
|
|
129
|
-
// ============================
|
|
130
|
-
const detailPage = (0, react_1.useMemo)(() => {
|
|
131
|
-
if (detailContent === false || detailContent === undefined)
|
|
132
|
-
return null;
|
|
133
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "table-supervision-detail-container", children: (0, jsx_runtime_1.jsx)("div", { className: "table-supervision-detail-body", children: !!selected && (typeof detailContent === "object" && Array.isArray(detailContent) ? detailContent?.map((column, key) => {
|
|
134
|
-
if (typeof column === "string") {
|
|
135
|
-
return ((0, jsx_runtime_1.jsx)(_components_1.TypographyColumnComponent, { title: columns?.find((c) => c.selector == column)?.label, content: selected[column] }, key));
|
|
136
|
-
}
|
|
137
|
-
else if (typeof column === "object" && column !== null) {
|
|
138
|
-
const colObj = column;
|
|
139
|
-
const rawContent = typeof colObj.item === "string" ? selected[colObj.item] : colObj.item(selected);
|
|
140
|
-
const conversionKey = colObj.conversion;
|
|
141
|
-
const content = conversionKey && _utils_1.conversion[conversionKey] ? _utils_1.conversion[conversionKey](rawContent) : rawContent;
|
|
142
|
-
return ((0, jsx_runtime_1.jsx)(_components_1.TypographyColumnComponent, { title: colObj.label, content: content }, key));
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
return column?.(selected);
|
|
146
|
-
}
|
|
147
|
-
}) : typeof detailContent === "function" ? detailContent(selected) : columns?.map((column, key) => ((0, jsx_runtime_1.jsx)(_components_1.TypographyColumnComponent, { title: column.label, content: selected[column.selector] }, key)))) }) }));
|
|
148
|
-
}, [selected, detailContent, columns]);
|
|
149
|
-
// ============================
|
|
150
|
-
// ## Form preparation
|
|
151
|
-
// ============================
|
|
152
|
-
const fields = (0, react_1.useMemo)(() => {
|
|
153
|
-
return formControl?.fields?.length ? formControl?.fields.map((form) => {
|
|
154
|
-
return typeof form === "string" ? {
|
|
155
|
-
label: form,
|
|
156
|
-
name: _utils_1.conversion.strSnake(form),
|
|
157
|
-
type: "text",
|
|
158
|
-
visibility: "*"
|
|
159
|
-
} : {
|
|
160
|
-
...form,
|
|
161
|
-
visibility: form.visibility || "*"
|
|
162
|
-
};
|
|
163
|
-
}) : [];
|
|
164
|
-
}, [formControl]);
|
|
165
|
-
const formPage = (0, react_1.useMemo)(() => {
|
|
166
|
-
return ((0, jsx_runtime_1.jsx)(_components_1.FormSupervisionComponent, { fields: fields, defaultValue: formControl?.defaultValue, payload: formControl?.payload, submitControl: fetchControl, onSuccess: () => {
|
|
167
|
-
setToggle(`MODAL_FORM_${toggleKey}`, false);
|
|
168
|
-
reset();
|
|
169
|
-
} }));
|
|
170
|
-
}, [selected, fields]);
|
|
171
|
-
const dataTables = (0, react_1.useMemo)(() => {
|
|
172
|
-
return data?.data?.map((item) => {
|
|
173
|
-
return {
|
|
174
|
-
...item,
|
|
175
|
-
action: renderTableAction(actionControl, item)
|
|
176
|
-
};
|
|
177
|
-
}) || [];
|
|
178
|
-
}, [actionControl, data]);
|
|
179
|
-
(0, react_1.useEffect)(() => {
|
|
180
|
-
if (toggle[`REFRESH_${toggleKey}`] != undefined)
|
|
181
|
-
reset();
|
|
182
|
-
}, [toggle[`REFRESH_${toggleKey}`]]);
|
|
183
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)("div", { children: "Loading..." }), children: [title && (0, jsx_runtime_1.jsx)("h1", { className: "table-supervision-title", children: title }), (0, jsx_runtime_1.jsx)(_components_1.TableComponent, { id: tableKey, controlBar: controlBar?.map((cb) => {
|
|
184
|
-
if (cb == "CREATE") {
|
|
185
|
-
if (isSm)
|
|
186
|
-
return;
|
|
187
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-create-wrapper", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faPlus, label: "Tambah Data", size: "sm", onClick: () => {
|
|
188
|
-
setToggle(`MODAL_FORM_${toggleKey}`);
|
|
189
|
-
setSelected(null);
|
|
190
|
-
} }) }, "button-add"));
|
|
191
|
-
}
|
|
192
|
-
if (cb == "IMPORT") {
|
|
193
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faFileExcel, label: "Import", variant: "outline", className: "table-supervision-control-button", onClick: () => setToggle(`MODAL_IMPORT_${toggleKey}`), size: "sm" }) }, "import"));
|
|
194
|
-
}
|
|
195
|
-
if (cb == "EXPORT") {
|
|
196
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faFileExcel, label: "Export", variant: "outline", className: "table-supervision-control-button", onClick: () => setToggle(`MODAL_EXPORT_${toggleKey}`), size: "sm" }) }, "export-excel"));
|
|
197
|
-
}
|
|
198
|
-
if (cb == "PRINT") {
|
|
199
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faFilePdf, label: "Cetak", variant: "outline", className: "table-supervision-control-button", onClick: () => setToggle(`MODAL_PRINT_${toggleKey}`), size: "sm" }) }, "export-pdf"));
|
|
200
|
-
}
|
|
201
|
-
return cb;
|
|
202
|
-
}) || [
|
|
203
|
-
...(!isSm ? [
|
|
204
|
-
(0, jsx_runtime_1.jsx)("div", { className: "control-bar-create-wrapper", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faPlus, label: "Tambah Data", size: "sm", onClick: () => {
|
|
205
|
-
setToggle(`MODAL_FORM_${toggleKey}`);
|
|
206
|
-
setSelected(null);
|
|
207
|
-
} }) }, "button-add")
|
|
208
|
-
] : []),
|
|
209
|
-
"SEARCH",
|
|
210
|
-
...(columns?.filter((c) => !!c.filterable)?.length ? ["FILTER"] : []),
|
|
211
|
-
...(columns?.filter((c) => !!c.sortable)?.length ? ["SORT"] : []),
|
|
212
|
-
"SELECTABLE", "REFRESH",
|
|
213
|
-
], columns: columns, data: dataTables, onRowClick: detailAction ? detailAction : (detailContent !== false && detailContent !== undefined) ? (e) => {
|
|
214
|
-
setToggle(`MODAL_SHOW_${toggleKey}`);
|
|
215
|
-
setSelected(e);
|
|
216
|
-
} : undefined, actionBulking: actionBulkingControl, checks: checks || [], onChangeChecks: (e) => setChecks(e), block: block, focus: focus, noIndex: noIndex, responsiveControl: responsiveControl ? {
|
|
217
|
-
mobile: responsiveControl?.mobile == true ? {
|
|
218
|
-
leftActionControl: (Array.isArray(actionControl) ? actionControl : (actionControl || actionControl == undefined) ? ['EDIT', "DELETE"] : []).includes('EDIT') ? {
|
|
219
|
-
icon: free_solid_svg_icons_1.faEdit,
|
|
220
|
-
onAction: (item) => {
|
|
221
|
-
setToggle(`MODAL_FORM_${toggleKey}`);
|
|
222
|
-
item && setSelected?.(item);
|
|
223
|
-
}
|
|
224
|
-
} : undefined,
|
|
225
|
-
rightActionControl: (Array.isArray(actionControl) ? actionControl : (actionControl || actionControl == undefined) ? ['EDIT', "DELETE"] : []).includes('DELETE') ? {
|
|
226
|
-
icon: free_solid_svg_icons_1.faTrash,
|
|
227
|
-
onAction: (item) => {
|
|
228
|
-
setToggle(`MODAL_DELETE_${toggleKey}`);
|
|
229
|
-
item && setSelected?.(item);
|
|
230
|
-
}
|
|
231
|
-
} : undefined
|
|
232
|
-
} : responsiveControl?.mobile || undefined,
|
|
233
|
-
} : undefined, ...tableControl }), (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faPlus, className: "table-supervision-mobile-add-btn", size: "lg", rounded: true, onClick: () => {
|
|
234
|
-
setToggle(`MODAL_FORM_${toggleKey}`);
|
|
235
|
-
setSelected(null);
|
|
236
|
-
} }), (detailContent !== false && detailContent !== undefined) && (isSm ? ((0, jsx_runtime_1.jsx)(_components_1.BottomSheetComponent, { show: !!toggle[`MODAL_SHOW_${toggleKey}`], onClose: () => setToggle(`MODAL_SHOW_${toggleKey}`, false), className: "table-supervision-modal", footer: renderTableAction(actionControl, undefined, { className: isSm ? "justify-end p-2 bg-background" : "justify-end", size: isSm ? "sm" : "md" }), size: "98vh", ...detailModalProps, children: detailPage })) : ((0, jsx_runtime_1.jsx)(_components_1.FloatingPageComponent, { show: !!toggle[`MODAL_SHOW_${toggleKey}`], onClose: () => setToggle(`MODAL_SHOW_${toggleKey}`, false), title: "Detail", className: "table-supervision-modal", footer: renderTableAction(actionControl, undefined, { className: isSm ? "justify-end p-2 bg-background" : "justify-end", size: isSm ? "sm" : "md" }), ...detailModalProps, children: detailPage }))), isSm ? ((0, jsx_runtime_1.jsx)(_components_1.BottomSheetComponent, { show: !!toggle[`MODAL_FORM_${toggleKey}`], onClose: () => setToggle(`MODAL_FORM_${toggleKey}`, false), className: (0, _utils_1.cn)("table-supervision-modal", formControl?.modalControl?.className), size: "98vh", children: (0, jsx_runtime_1.jsx)("div", { className: "table-supervision-form-mobile-container", children: formPage }) })) : ((0, jsx_runtime_1.jsx)(_components_1.FloatingPageComponent, { show: !!toggle[`MODAL_FORM_${toggleKey}`], onClose: () => setToggle(`MODAL_FORM_${toggleKey}`, false), title: !!selected ? "Ubah Data" : "Tambah Data", className: (0, _utils_1.cn)("table-supervision-modal", formControl?.modalControl?.className), children: (0, jsx_runtime_1.jsx)("div", { className: "table-supervision-form-container", children: formPage }) })), ExportExcel && ((0, jsx_runtime_1.jsx)(_components_1.FloatingPageComponent, { show: !!toggle[`MODAL_EXPORT_${toggleKey}`], onClose: () => setToggle(`MODAL_EXPORT_${toggleKey}`, false), title: "Export Ke Excel", className: "table-supervision-large-modal", children: (0, jsx_runtime_1.jsx)(ExportExcel, { fetchControl: fetchControl, filename: "Export - " + title, columnControl: columns?.map((cc) => ({
|
|
237
|
-
label: cc.label || "",
|
|
238
|
-
selector: cc.selector || "",
|
|
239
|
-
status: cc.exportable === false ? "hidden" : cc.exportable === true ? "default" : typeof cc.exportable === "string" ? cc.exportable : undefined,
|
|
240
|
-
})) }) })), ImportExcel && ((0, jsx_runtime_1.jsx)(_components_1.FloatingPageComponent, { show: !!toggle[`MODAL_IMPORT_${toggleKey}`], onClose: () => setToggle(`MODAL_IMPORT_${toggleKey}`, false), title: "Import Dari Excel", className: "table-supervision-large-modal", children: (0, jsx_runtime_1.jsx)(ImportExcel, { submitControl: importControl, fetchControl: fetchControl.path ? {
|
|
241
|
-
path: fetchControl.path,
|
|
242
|
-
} : undefined, columnControl: columns?.filter((cc) => cc.importable !== false).map((cc) => ({
|
|
243
|
-
label: cc.label || "",
|
|
244
|
-
selector: cc.selector || "",
|
|
245
|
-
})) }) })), (0, jsx_runtime_1.jsx)(_components_1.ModalConfirmComponent, { show: !!toggle[`MODAL_DELETE_${toggleKey}`], onClose: () => setToggle(`MODAL_DELETE_${toggleKey}`, false), icon: free_regular_svg_icons_1.faQuestionCircle, title: `Menghapus Data?`, submitControl: {
|
|
246
|
-
onSubmit: {
|
|
247
|
-
...(fetchControl.path
|
|
248
|
-
? { path: `${fetchControl.path}/${selected?.id || ""}` }
|
|
249
|
-
: fetchControl.url ? { url: `${fetchControl.url}/${selected?.id || ""}` }
|
|
250
|
-
: { idb: { ...fetchControl?.idb, id: selected?.id || "" } }),
|
|
251
|
-
method: "DELETE",
|
|
252
|
-
},
|
|
253
|
-
onSuccess: () => {
|
|
254
|
-
reset();
|
|
255
|
-
setToggle(`MODAL_DELETE_${toggleKey}`, false);
|
|
256
|
-
},
|
|
257
|
-
}, children: columns?.at(0)?.selector && selected ? ((0, jsx_runtime_1.jsxs)("p", { className: "table-supervision-confirm-text", children: ["Yakin menghapus ", (0, jsx_runtime_1.jsxs)("span", { className: "table-supervision-confirm-item-name", children: ["\"", selected[columns?.at(0)?.selector || ""], "\""] }), "?"] })) : ((0, jsx_runtime_1.jsx)("p", { className: "table-supervision-confirm-text", children: "Yakin yang dihapus sudah benar?" })) }), actionControl && Array.isArray(actionControl) && actionControl.filter((ac) => typeof ac == "object")?.map((ac, acKey) => {
|
|
258
|
-
const submitControl = ac.modal?.submitControl?.onSubmit;
|
|
259
|
-
return ((0, jsx_runtime_1.jsx)(_components_1.ModalConfirmComponent, { show: !!toggle[`MODAL_${_utils_1.conversion.strSnake(ac.label).toUpperCase()}_${toggleKey}`], onClose: () => setToggle(`MODAL_${_utils_1.conversion.strSnake(ac.label).toUpperCase()}_${toggleKey}`, false), icon: free_regular_svg_icons_1.faQuestionCircle, title: `${ac.label} Data?`, submitControl: {
|
|
260
|
-
onSubmit: {
|
|
261
|
-
...(submitControl?.path
|
|
262
|
-
? { path: `${submitControl.path}/${selected?.id || ""}` }
|
|
263
|
-
: submitControl?.url ? { url: `${submitControl.url}/${selected?.id || ""}` }
|
|
264
|
-
: { idb: { ...submitControl?.idb, id: selected?.id || "" } }),
|
|
265
|
-
...ac.modal?.submitControl?.onSubmit,
|
|
266
|
-
},
|
|
267
|
-
onSuccess: () => {
|
|
268
|
-
reset();
|
|
269
|
-
setToggle(`MODAL_${_utils_1.conversion.strSnake(ac.label).toUpperCase()}_${toggleKey}`, false);
|
|
270
|
-
},
|
|
271
|
-
}, ...ac.modal, children: columns?.at(0)?.selector && selected ? ((0, jsx_runtime_1.jsxs)("p", { className: "table-supervision-confirm-text", children: ["Yakin melakukan aksi untuk data ", (0, jsx_runtime_1.jsxs)("span", { className: "table-supervision-confirm-item-name", children: ["\"", selected[columns?.at(0)?.selector || ""], "\""] }), "?"] })) : ((0, jsx_runtime_1.jsx)("p", { className: "table-supervision-confirm-text", children: "Yakin aksi yang dilakukan sudah benar?" })) }, acKey));
|
|
272
|
-
})] }) }));
|
|
273
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { ApiFilterType } from '@utils';
|
|
3
|
-
import { FilterColumnOption } from '@components';
|
|
4
|
-
export type ControlBarOptionType = "SEARCH" | "SEARCHABLE" | "FILTER" | "SELECTABLE" | "REFRESH" | ReactNode;
|
|
5
|
-
export interface ControlBarProps {
|
|
6
|
-
id?: string;
|
|
7
|
-
options?: ControlBarOptionType[];
|
|
8
|
-
className?: string;
|
|
9
|
-
search?: string;
|
|
10
|
-
onSearch?: (searchable: string) => void;
|
|
11
|
-
searchableOptions?: {
|
|
12
|
-
label: string | ReactNode;
|
|
13
|
-
selector: string;
|
|
14
|
-
}[];
|
|
15
|
-
searchable?: string[];
|
|
16
|
-
onSearchable?: (searchable: string[]) => void;
|
|
17
|
-
selectableOptions?: {
|
|
18
|
-
label: string | ReactNode;
|
|
19
|
-
selector: string;
|
|
20
|
-
}[];
|
|
21
|
-
selectable?: string[];
|
|
22
|
-
onSelectable?: (searchable: string[]) => void;
|
|
23
|
-
sortableOptions?: {
|
|
24
|
-
label: string | ReactNode;
|
|
25
|
-
selector: string;
|
|
26
|
-
}[];
|
|
27
|
-
sort?: string[];
|
|
28
|
-
onSort?: (sort: string[]) => void;
|
|
29
|
-
filterableColumns?: FilterColumnOption[];
|
|
30
|
-
onFilter?: (filters: ApiFilterType[]) => void;
|
|
31
|
-
filter?: ApiFilterType[];
|
|
32
|
-
onRefresh?: () => void;
|
|
33
|
-
}
|
|
34
|
-
export declare function ControlBarComponent({ id, options, className, search, onSearch, searchableOptions, searchable, onSearchable, selectableOptions, selectable, onSelectable, sortableOptions, sort, onSort, filterableColumns, onFilter, filter, onRefresh }: ControlBarProps): import("react").JSX.Element;
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ControlBarComponent = ControlBarComponent;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
8
|
-
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
9
|
-
const _utils_1 = require("@utils");
|
|
10
|
-
const _contexts_1 = require("@contexts");
|
|
11
|
-
const _components_1 = require("@components");
|
|
12
|
-
function ControlBarComponent({ id = "", options, className, search, onSearch, searchableOptions, searchable, onSearchable, selectableOptions, selectable, onSelectable, sortableOptions, sort, onSort, filterableColumns, onFilter, filter, onRefresh }) {
|
|
13
|
-
const { toggle, setToggle } = (0, _contexts_1.useToggleContext)();
|
|
14
|
-
const { isSm } = (0, _utils_1.useResponsive)();
|
|
15
|
-
const searchRef = (0, react_1.useRef)(null);
|
|
16
|
-
(0, react_1.useEffect)(() => {
|
|
17
|
-
if (options?.includes("SEARCH")) {
|
|
18
|
-
_utils_1.shortcut.register("ctrl+s", () => {
|
|
19
|
-
searchRef.current?.focus();
|
|
20
|
-
}, "Cari");
|
|
21
|
-
}
|
|
22
|
-
if (options?.includes("FILTER")) {
|
|
23
|
-
_utils_1.shortcut.register("ctrl+f", () => {
|
|
24
|
-
setToggle("FILTER");
|
|
25
|
-
}, "Filter");
|
|
26
|
-
}
|
|
27
|
-
if (options?.includes("SORT")) {
|
|
28
|
-
_utils_1.shortcut.register("ctrl+o", () => {
|
|
29
|
-
setToggle("SORT");
|
|
30
|
-
}, "Urutkan");
|
|
31
|
-
}
|
|
32
|
-
if (options?.includes("SELECTABLE")) {
|
|
33
|
-
_utils_1.shortcut.register("ctrl+l", () => {
|
|
34
|
-
setToggle("SELECTABLE");
|
|
35
|
-
}, "Kolom Ditampilkan");
|
|
36
|
-
}
|
|
37
|
-
if (options?.includes("REFRESH")) {
|
|
38
|
-
_utils_1.shortcut.register("ctrl+shift+r", () => {
|
|
39
|
-
onRefresh?.();
|
|
40
|
-
}, "Refresh Tabel");
|
|
41
|
-
}
|
|
42
|
-
return () => {
|
|
43
|
-
options?.includes("SEARCH") && _utils_1.shortcut.unregister("ctrl+s");
|
|
44
|
-
options?.includes("FILTER") && _utils_1.shortcut.unregister("ctrl+f");
|
|
45
|
-
options?.includes("SORT") && _utils_1.shortcut.unregister("ctrl+o");
|
|
46
|
-
options?.includes("SELECTABLE") && _utils_1.shortcut.unregister("ctrl+l");
|
|
47
|
-
options?.includes("REFRESH") && _utils_1.shortcut.unregister("ctrl+shift+r");
|
|
48
|
-
};
|
|
49
|
-
}, [options]);
|
|
50
|
-
const onChangeSort = (item) => {
|
|
51
|
-
if (!!sort?.find((s) => s.split(" ")?.at(0) == item)) {
|
|
52
|
-
const findSort = sort.find((s) => s.split(" ")?.at(0) == item);
|
|
53
|
-
if (findSort?.split(" ")?.at(1) == "desc") {
|
|
54
|
-
onSort?.(sort.filter((s) => s != findSort));
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
const newSorts = [...sort];
|
|
58
|
-
newSorts[newSorts?.findIndex((s) => s == findSort)] = `${item} desc`;
|
|
59
|
-
onSort?.(newSorts);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
onSort?.([...(sort || []), `${item} asc`]);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("control-bar", className), children: (isSm ? [
|
|
67
|
-
...(options?.filter((op, iop) => iop == 0 || op == "REFRESH") || []),
|
|
68
|
-
...(options && options?.length > 1 ? ['MOBILE_OPTION'] : [])
|
|
69
|
-
] : options)?.map((option, key) => {
|
|
70
|
-
{
|
|
71
|
-
// =========================>
|
|
72
|
-
// ## Create button
|
|
73
|
-
// =========================>
|
|
74
|
-
}
|
|
75
|
-
if (option == "CREATE") {
|
|
76
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-create-wrapper", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faPlus, label: "Tambah Data", size: "sm", onClick: () => setToggle(`MODAL_FORM_${_utils_1.conversion.strSnake(id).toUpperCase()}`) }) }, "button-add"));
|
|
77
|
-
}
|
|
78
|
-
{
|
|
79
|
-
// =========================>
|
|
80
|
-
// ## Search Field
|
|
81
|
-
// =========================>
|
|
82
|
-
}
|
|
83
|
-
if (option == "SEARCH") {
|
|
84
|
-
const searchable = !!options?.find((option) => option == "SEARCHABLE");
|
|
85
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("control-bar-search-wrapper", searchable ? "control-bar-search-wrapper-searchable" : "control-bar-search-wrapper-standalone"), children: (0, jsx_runtime_1.jsx)(_components_1.InputComponent, { ref: searchRef, name: "search", placeholder: "Cari disini...", rightIcon: free_solid_svg_icons_1.faMagnifyingGlass, value: search, onChange: (e) => onSearch?.(e), className: (0, _utils_1.cn)("control-bar-search-input", searchable && "control-bar-search-input-searchable") }) }, key));
|
|
86
|
-
}
|
|
87
|
-
{
|
|
88
|
-
// =========================>
|
|
89
|
-
// ## Searchable Field
|
|
90
|
-
// =========================>
|
|
91
|
-
}
|
|
92
|
-
if (option == "SEARCHABLE") {
|
|
93
|
-
return searchableOptions?.length ? ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-searchable-wrapper", children: (0, jsx_runtime_1.jsx)(_components_1.SelectComponent, { name: "searchableColumn", leftIcon: free_solid_svg_icons_1.faSearch, options: searchableOptions?.map((column) => {
|
|
94
|
-
return {
|
|
95
|
-
label: column.label,
|
|
96
|
-
value: column.selector,
|
|
97
|
-
};
|
|
98
|
-
}) || [], value: searchable, onChange: (e) => onSearchable?.(e), className: "control-bar-searchable-select", multiple: true }) }, key)) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
99
|
-
}
|
|
100
|
-
{
|
|
101
|
-
// =========================>
|
|
102
|
-
// ## Selectable Button
|
|
103
|
-
// =========================>
|
|
104
|
-
}
|
|
105
|
-
if (option == "SELECTABLE") {
|
|
106
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "control-bar-button-wrapper", children: [(0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faEyeLowVision, variant: "outline", className: "control-bar-icon-button", onClick: () => setToggle("SELECTABLE"), size: "sm" }), (0, jsx_runtime_1.jsx)(_components_1.OutsideClickComponent, { onOutsideClick: () => setToggle("SELECTABLE", false), children: (0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("control-bar-dropdown", !toggle.SELECTABLE && "control-bar-dropdown-hidden"), children: [(0, jsx_runtime_1.jsx)("p", { className: 'control-bar-dropdown-title', children: "Kolom Ditampilkan" }), (0, jsx_runtime_1.jsx)(_components_1.InputCheckboxComponent, { vertical: true, name: "show_column", options: selectableOptions?.map((option) => {
|
|
107
|
-
return {
|
|
108
|
-
label: option.label,
|
|
109
|
-
value: option.selector,
|
|
110
|
-
};
|
|
111
|
-
}), onChange: (e) => onSelectable?.(Array().concat(e).map((val) => String(val))), value: selectable, className: 'control-bar-selectable-checkbox-list', classNameCheckbox: 'control-bar-selectable-checkbox label::text-xs' })] }) })] }, key));
|
|
112
|
-
}
|
|
113
|
-
{
|
|
114
|
-
// =========================>
|
|
115
|
-
// ## Sort Button
|
|
116
|
-
// =========================>
|
|
117
|
-
}
|
|
118
|
-
if (option == "SORT") {
|
|
119
|
-
return sortableOptions?.length ? ((0, jsx_runtime_1.jsxs)("div", { className: "control-bar-button-wrapper", children: [(0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faSort, variant: "outline", className: "control-bar-icon-button", onClick: () => setToggle("SORT"), size: "sm" }), (0, jsx_runtime_1.jsx)(_components_1.OutsideClickComponent, { onOutsideClick: () => setToggle("SORT", false), children: (0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("control-bar-dropdown", !toggle.SORT && "control-bar-dropdown-hidden"), children: [(0, jsx_runtime_1.jsx)("p", { className: 'control-bar-dropdown-title', children: "Urut Berdasarkan" }), (0, jsx_runtime_1.jsx)("div", { className: 'control-bar-sort-list', children: sortableOptions?.map((option, key) => {
|
|
120
|
-
const sortBy = sort?.find((s) => s.split(" ")?.at(0) == option?.selector)?.split(" ")?.at(1) || "";
|
|
121
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)('control-bar-sort-item', !!sortBy && "control-bar-sort-item-active"), onClick: () => onChangeSort(option.selector), children: [(0, jsx_runtime_1.jsx)("p", { children: option.label }), sortBy && ((0, jsx_runtime_1.jsxs)("div", { className: 'control-bar-sort-active-icon', children: [(0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: sortBy == "desc" ? free_solid_svg_icons_1.faArrowDownZA : free_solid_svg_icons_1.faArrowUpAZ, className: 'control-bar-sort-icon' }), sort?.length && sort?.length > 1 && (0, jsx_runtime_1.jsx)("span", { className: 'control-bar-sort-badge', children: sort.findIndex((s) => s.split(" ")?.at(0) == option?.selector) + 1 })] }))] }, key));
|
|
122
|
-
}) })] }) })] }, key)) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
123
|
-
}
|
|
124
|
-
{
|
|
125
|
-
// =========================>
|
|
126
|
-
// ## Refresh Button
|
|
127
|
-
// =========================>
|
|
128
|
-
}
|
|
129
|
-
if (option == "REFRESH") {
|
|
130
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper-refresh", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faRefresh, variant: "outline", className: "control-bar-icon-button", onClick: () => onRefresh?.(), size: "sm" }) }, key));
|
|
131
|
-
}
|
|
132
|
-
{
|
|
133
|
-
// =========================>
|
|
134
|
-
// ## Filter Button
|
|
135
|
-
// =========================>
|
|
136
|
-
}
|
|
137
|
-
if (option == "FILTER") {
|
|
138
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faSliders, label: "Filter", variant: "outline", className: "control-bar-filter-button", onClick: () => setToggle("FILTER"), size: "sm" }) }, key));
|
|
139
|
-
}
|
|
140
|
-
{
|
|
141
|
-
// =========================>
|
|
142
|
-
// ## Mobile option button
|
|
143
|
-
// =========================>
|
|
144
|
-
}
|
|
145
|
-
if (option == "MOBILE_OPTION") {
|
|
146
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper", children: (0, jsx_runtime_1.jsx)(_components_1.ButtonComponent, { icon: free_solid_svg_icons_1.faEllipsisV, variant: "outline", className: "control-bar-icon-button", onClick: () => setToggle("MOBILE_OPTION"), size: "sm" }) }, key));
|
|
147
|
-
}
|
|
148
|
-
return option;
|
|
149
|
-
}) }), !!filterableColumns && !!filterableColumns?.length && ((0, jsx_runtime_1.jsx)(_components_1.FilterComponent, { className: (0, _utils_1.cn)(!toggle.FILTER ? "control-bar-filter-panel-hidden" : "control-bar-filter-panel"), columns: filterableColumns, onChange: onFilter, value: filter, onMinimize: () => setToggle("FILTER") })), isSm && ((0, jsx_runtime_1.jsx)(_components_1.BottomSheetComponent, { show: !!toggle["MOBILE_OPTION"], onClose: () => setToggle("MOBILE_OPTION", false), maxSize: "98vh", children: (0, jsx_runtime_1.jsx)("div", { className: 'control-bar-mobile-container', children: options?.filter((op, iop) => (iop != 0 && op != "CREATE" && op != "REFRESH"))?.map((option, key) => {
|
|
150
|
-
{
|
|
151
|
-
// =========================>
|
|
152
|
-
// ## Search Field
|
|
153
|
-
// =========================>
|
|
154
|
-
}
|
|
155
|
-
if (option == "SEARCH") {
|
|
156
|
-
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(_components_1.InputComponent, { name: "search", placeholder: "Cari disini...", rightIcon: free_solid_svg_icons_1.faMagnifyingGlass, value: search, onChange: (e) => onSearch?.(e) }) }, key));
|
|
157
|
-
}
|
|
158
|
-
{
|
|
159
|
-
// =========================>
|
|
160
|
-
// ## Searchable Field
|
|
161
|
-
// =========================>
|
|
162
|
-
}
|
|
163
|
-
if (option == "SEARCHABLE") {
|
|
164
|
-
return searchableOptions?.length ? ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(_components_1.SelectComponent, { name: "searchableColumn", leftIcon: free_solid_svg_icons_1.faSearch, options: searchableOptions?.map((column) => {
|
|
165
|
-
return {
|
|
166
|
-
label: column.label,
|
|
167
|
-
value: column.selector,
|
|
168
|
-
};
|
|
169
|
-
}) || [], value: searchable, onChange: (e) => onSearchable?.(e), multiple: true }) }, key)) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
170
|
-
}
|
|
171
|
-
{
|
|
172
|
-
// =========================>
|
|
173
|
-
// ## Selectable Button
|
|
174
|
-
// =========================>
|
|
175
|
-
}
|
|
176
|
-
if (option == "SELECTABLE") {
|
|
177
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("p", { className: 'control-bar-mobile-title', children: "Kolom Ditampilkan" }), (0, jsx_runtime_1.jsx)(_components_1.InputCheckboxComponent, { vertical: true, name: "show_column", options: selectableOptions?.map((option) => {
|
|
178
|
-
return {
|
|
179
|
-
label: option.label,
|
|
180
|
-
value: option.selector,
|
|
181
|
-
};
|
|
182
|
-
}), onChange: (e) => onSelectable?.(Array().concat(e).map((val) => String(val))), value: selectable, className: 'control-bar-mobile-checkbox-list', classNameCheckbox: 'control-bar-selectable-checkbox label::text-xs' })] }, key));
|
|
183
|
-
}
|
|
184
|
-
{
|
|
185
|
-
// =========================>
|
|
186
|
-
// ## Sort Button
|
|
187
|
-
// =========================>
|
|
188
|
-
}
|
|
189
|
-
if (option == "SORT") {
|
|
190
|
-
return sortableOptions?.length ? ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("p", { className: 'control-bar-mobile-title', children: "Urut Berdasarkan" }), (0, jsx_runtime_1.jsx)("div", { className: 'flex flex-col', children: sortableOptions?.map((option, key) => {
|
|
191
|
-
const sortBy = sort?.find((s) => s.split(" ")?.at(0) == option?.selector)?.split(" ")?.at(1) || "";
|
|
192
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)('control-bar-mobile-sort-item', !!sortBy && "control-bar-mobile-sort-item-active"), onClick: () => onChangeSort(option.selector), children: [(0, jsx_runtime_1.jsx)("p", { children: option.label }), sortBy && ((0, jsx_runtime_1.jsxs)("div", { className: 'text-primary', children: [(0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: sortBy == "desc" ? free_solid_svg_icons_1.faArrowDownZA : free_solid_svg_icons_1.faArrowUpAZ, className: 'text-xs' }), sort?.length && sort?.length > 1 && (0, jsx_runtime_1.jsx)("span", { className: 'text-[9px] ml-1', children: sort.findIndex((s) => s.split(" ")?.at(0) == option?.selector) + 1 })] }))] }, key));
|
|
193
|
-
}) })] }, key)) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
194
|
-
}
|
|
195
|
-
{
|
|
196
|
-
// =========================>
|
|
197
|
-
// ## Filter
|
|
198
|
-
// =========================>
|
|
199
|
-
}
|
|
200
|
-
if (option == "FILTER") {
|
|
201
|
-
return ((0, jsx_runtime_1.jsx)("div", { children: filterableColumns && filterableColumns?.length && ((0, jsx_runtime_1.jsx)(_components_1.FilterComponent, { className: 'control-bar-mobile-filter title::text-xs', columns: filterableColumns, onChange: onFilter, value: filter })) }, key));
|
|
202
|
-
}
|
|
203
|
-
return option;
|
|
204
|
-
}) }) }))] }));
|
|
205
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ApiFilterType } from "@utils";
|
|
2
|
-
export type FilterColumnOption = {
|
|
3
|
-
label: string;
|
|
4
|
-
selector: string;
|
|
5
|
-
type: "text" | "number" | "currency" | "date";
|
|
6
|
-
} | {
|
|
7
|
-
label: string;
|
|
8
|
-
selector: string;
|
|
9
|
-
type: "select";
|
|
10
|
-
options: {
|
|
11
|
-
label: string;
|
|
12
|
-
value: any;
|
|
13
|
-
}[];
|
|
14
|
-
};
|
|
15
|
-
export type FilterBookmark = {
|
|
16
|
-
id: string;
|
|
17
|
-
name: string;
|
|
18
|
-
filters: ApiFilterType[];
|
|
19
|
-
createdAt: number;
|
|
20
|
-
};
|
|
21
|
-
export interface AdvancedFilterProps {
|
|
22
|
-
columns: FilterColumnOption[];
|
|
23
|
-
onChange?: (filters: ApiFilterType[]) => void;
|
|
24
|
-
value?: ApiFilterType[];
|
|
25
|
-
onMinimize?: () => void;
|
|
26
|
-
/** Use custom class with: "title::". */
|
|
27
|
-
className?: string;
|
|
28
|
-
}
|
|
29
|
-
export declare function FilterComponent({ columns, onChange, value, onMinimize, className, }: AdvancedFilterProps): import("react").JSX.Element;
|
|
30
|
-
interface FilterInputProps {
|
|
31
|
-
type?: string | null;
|
|
32
|
-
name: string;
|
|
33
|
-
value: string | number | number[] | string[] | null;
|
|
34
|
-
onChange: (value: any) => void;
|
|
35
|
-
options?: {
|
|
36
|
-
label: string;
|
|
37
|
-
value: any;
|
|
38
|
-
}[];
|
|
39
|
-
placeholder?: string;
|
|
40
|
-
className?: string;
|
|
41
|
-
between?: boolean;
|
|
42
|
-
multiple?: boolean;
|
|
43
|
-
}
|
|
44
|
-
export declare function InputFilterValueComponent({ type, name, value, onChange, options, placeholder, className, between, multiple, }: FilterInputProps): import("react").JSX.Element;
|
|
45
|
-
export {};
|