@skalfa/skalfa-component 1.0.7 → 1.0.9
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.js +2 -3
- package/dist/breadcrumb/Breadcrumb.component.js +2 -3
- package/dist/button/Button.component.d.ts +2 -1
- package/dist/button/Button.component.js +2 -2
- package/dist/carousel/Carousel.component.js +2 -3
- package/dist/chip/Chip.component.js +2 -3
- package/dist/contexts-mock.d.ts +2 -0
- package/dist/contexts-mock.js +10 -0
- package/dist/input/Checkbox.component.js +2 -3
- package/dist/input/Input.component.d.ts +3 -2
- package/dist/input/Input.component.js +3 -3
- package/dist/input/InputCheckbox.component.js +1 -1
- package/dist/input/InputCurrency.component.d.ts +3 -2
- package/dist/input/InputCurrency.component.js +3 -3
- package/dist/input/InputDate.component.js +4 -5
- package/dist/input/InputDatetime.component.d.ts +3 -2
- package/dist/input/InputDatetime.component.js +3 -3
- package/dist/input/InputDocument.component.js +7 -8
- package/dist/input/InputImage.component.js +3 -4
- package/dist/input/InputNumber.component.js +3 -4
- package/dist/input/InputPassword.component.js +3 -3
- package/dist/input/InputRadio.component.js +1 -1
- package/dist/input/InputTime.component.js +3 -3
- package/dist/input/InputValues.component.js +3 -4
- package/dist/input/Select.component.js +6 -7
- package/dist/modal/FloatingPage.component.d.ts +3 -1
- package/dist/modal/FloatingPage.component.js +7 -3
- package/dist/modal/Modal.component.js +1 -2
- package/dist/modal/ModalConfirm.component.d.ts +2 -2
- package/dist/modal/ModalConfirm.component.js +14 -12
- package/dist/modal/Toast.component.js +1 -2
- package/dist/nav/Bottombar.component.d.ts +2 -2
- package/dist/nav/Bottombar.component.js +7 -8
- package/dist/nav/Footer.component.d.ts +2 -2
- package/dist/nav/Footer.component.js +6 -7
- package/dist/nav/Headbar.component.js +2 -3
- package/dist/nav/Navbar.component.d.ts +2 -2
- package/dist/nav/Navbar.component.js +3 -4
- package/dist/nav/Sidebar.component.d.ts +3 -7
- package/dist/nav/Sidebar.component.js +14 -17
- package/dist/supervision/FormSupervision.component.d.ts +4 -29
- package/dist/supervision/FormSupervision.component.js +84 -136
- package/dist/supervision/TableSupervision.component.d.ts +17 -26
- package/dist/supervision/TableSupervision.component.js +207 -193
- package/dist/table/ControlBar.component.js +15 -16
- package/dist/table/FilterComponent.js +4 -6
- package/dist/table/Pagination.component.js +2 -3
- package/dist/table/Table.component.js +3 -4
- package/dist/wrap/Swipe.component.js +2 -2
- package/package.json +18 -10
- package/src/accordion/Accordion.component.tsx +87 -0
- package/src/breadcrumb/Breadcrumb.component.tsx +79 -0
- package/src/button/Button.component.tsx +89 -0
- package/src/card/AlertCard.component.tsx +69 -0
- package/src/card/Card.component.tsx +25 -0
- package/src/card/DashboardCard.component.tsx +44 -0
- package/src/card/GalleryCard.component.tsx +50 -0
- package/src/card/ProductCard.component.tsx +65 -0
- package/src/card/ProfileCard.component.tsx +71 -0
- package/src/carousel/Carousel.component.tsx +111 -0
- package/src/chip/Chip.component.tsx +38 -0
- package/src/contexts-mock.ts +6 -0
- package/src/index.ts +70 -0
- package/src/input/Checkbox.component.tsx +102 -0
- package/src/input/Input.component.tsx +334 -0
- package/src/input/InputCheckbox.component.tsx +174 -0
- package/src/input/InputCurrency.component.tsx +165 -0
- package/src/input/InputDate.component.tsx +355 -0
- package/src/input/InputDatetime.component.tsx +267 -0
- package/src/input/InputDocument.component.tsx +360 -0
- package/src/input/InputImage.component.tsx +534 -0
- package/src/input/InputNumber.component.tsx +193 -0
- package/src/input/InputOtp.component.tsx +169 -0
- package/src/input/InputPassword.component.tsx +245 -0
- package/src/input/InputRadio.component.tsx +174 -0
- package/src/input/InputTime.component.tsx +280 -0
- package/src/input/InputValues.component.tsx +70 -0
- package/src/input/Radio.component.tsx +98 -0
- package/src/input/Select.component.tsx +557 -0
- package/src/modal/BottomSheet.component.tsx +246 -0
- package/src/modal/FloatingPage.component.tsx +133 -0
- package/src/modal/Modal.component.tsx +94 -0
- package/src/modal/ModalConfirm.component.tsx +204 -0
- package/src/modal/Toast.component.tsx +124 -0
- package/src/nav/Bottombar.component.tsx +71 -0
- package/src/nav/Footer.component.tsx +176 -0
- package/src/nav/Headbar.component.tsx +33 -0
- package/src/nav/Navbar.component.tsx +137 -0
- package/src/nav/Sidebar.component.tsx +307 -0
- package/src/nav/Tabbar.component.tsx +61 -0
- package/src/nav/Wizard.component.tsx +80 -0
- package/src/supervision/FormSupervision.component.tsx +404 -0
- package/src/supervision/TableSupervision.component.tsx +653 -0
- package/src/table/ControlBar.component.tsx +501 -0
- package/src/table/FilterComponent.tsx +517 -0
- package/src/table/Pagination.component.tsx +152 -0
- package/src/table/Table.component.tsx +436 -0
- package/src/typography/TypographyArticle.component.tsx +26 -0
- package/src/typography/TypographyColumn.component.tsx +20 -0
- package/src/typography/TypographyContent.component.tsx +20 -0
- package/src/typography/TypographyTips.component.tsx +20 -0
- package/src/wrap/Draggable.component.tsx +303 -0
- package/src/wrap/Image.component.tsx +10 -0
- package/src/wrap/OutsideClick.component.tsx +48 -0
- package/src/wrap/ScrollContainer.component.tsx +107 -0
- package/src/wrap/ShortcutProvider.tsx +57 -0
- package/src/wrap/Swipe.component.tsx +121 -0
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.ControlBarComponent = ControlBarComponent;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const skalfa_icon_1 = require("@skalfa/skalfa-icon");
|
|
6
7
|
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
8
|
const _utils_1 = require("@utils");
|
|
10
9
|
const _contexts_1 = require("@contexts");
|
|
11
10
|
const InputCheckbox_component_1 = require("../input/InputCheckbox.component");
|
|
@@ -70,7 +69,7 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
71
|
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 ? [
|
|
73
|
-
...(options?.filter((op
|
|
72
|
+
...(options?.filter((op) => op == "SEARCH" || op == "REFRESH") || []),
|
|
74
73
|
...(options && options?.length > 1 ? ['MOBILE_OPTION'] : [])
|
|
75
74
|
] : options)?.map((option, key) => {
|
|
76
75
|
{
|
|
@@ -79,7 +78,7 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
79
78
|
// =========================>
|
|
80
79
|
}
|
|
81
80
|
if (option == "CREATE") {
|
|
82
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-create-wrapper", children: (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon:
|
|
81
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-create-wrapper", children: (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/plus", label: "Tambah Data", size: "sm", onClick: () => setToggle(`MODAL_FORM_${_utils_1.conversion.strSnake(id).toUpperCase()}`) }) }, "button-add"));
|
|
83
82
|
}
|
|
84
83
|
{
|
|
85
84
|
// =========================>
|
|
@@ -88,7 +87,7 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
88
87
|
}
|
|
89
88
|
if (option == "SEARCH") {
|
|
90
89
|
const searchable = !!options?.find((option) => option == "SEARCHABLE");
|
|
91
|
-
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)(Input_component_1.InputComponent, { ref: searchRef, name: "search", placeholder: "Cari disini...", rightIcon:
|
|
90
|
+
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)(Input_component_1.InputComponent, { ref: searchRef, name: "search", placeholder: "Cari disini...", rightIcon: "solid/magnifying-glass", value: search, onChange: (e) => onSearch?.(e), className: (0, _utils_1.cn)("control-bar-search-input", searchable && "control-bar-search-input-searchable") }) }, key));
|
|
92
91
|
}
|
|
93
92
|
{
|
|
94
93
|
// =========================>
|
|
@@ -96,7 +95,7 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
96
95
|
// =========================>
|
|
97
96
|
}
|
|
98
97
|
if (option == "SEARCHABLE") {
|
|
99
|
-
return searchableOptions?.length ? ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-searchable-wrapper", children: (0, jsx_runtime_1.jsx)(Select_component_1.SelectComponent, { name: "searchableColumn", leftIcon:
|
|
98
|
+
return searchableOptions?.length ? ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-searchable-wrapper", children: (0, jsx_runtime_1.jsx)(Select_component_1.SelectComponent, { name: "searchableColumn", leftIcon: "solid/search", options: searchableOptions?.map((column) => {
|
|
100
99
|
return {
|
|
101
100
|
label: column.label,
|
|
102
101
|
value: column.selector,
|
|
@@ -109,7 +108,7 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
109
108
|
// =========================>
|
|
110
109
|
}
|
|
111
110
|
if (option == "SELECTABLE") {
|
|
112
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "control-bar-button-wrapper", children: [(0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon:
|
|
111
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "control-bar-button-wrapper", children: [(0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/eye-low-vision", variant: "outline", className: "control-bar-icon-button", onClick: () => setToggle("SELECTABLE"), size: "sm" }), (0, jsx_runtime_1.jsx)(OutsideClick_component_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)(InputCheckbox_component_1.InputCheckboxComponent, { vertical: true, name: "show_column", options: selectableOptions?.map((option) => {
|
|
113
112
|
return {
|
|
114
113
|
label: option.label,
|
|
115
114
|
value: option.selector,
|
|
@@ -122,9 +121,9 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
122
121
|
// =========================>
|
|
123
122
|
}
|
|
124
123
|
if (option == "SORT") {
|
|
125
|
-
return sortableOptions?.length ? ((0, jsx_runtime_1.jsxs)("div", { className: "control-bar-button-wrapper", children: [(0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon:
|
|
124
|
+
return sortableOptions?.length ? ((0, jsx_runtime_1.jsxs)("div", { className: "control-bar-button-wrapper", children: [(0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/sort", variant: "outline", className: "control-bar-icon-button", onClick: () => setToggle("SORT"), size: "sm" }), (0, jsx_runtime_1.jsx)(OutsideClick_component_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) => {
|
|
126
125
|
const sortBy = sort?.find((s) => s.split(" ")?.at(0) == option?.selector)?.split(" ")?.at(1) || "";
|
|
127
|
-
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)(
|
|
126
|
+
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)(skalfa_icon_1.Icon, { icon: sortBy == "desc" ? "solid/arrow-down-z-a" : "solid/arrow-up-a-z", 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));
|
|
128
127
|
}) })] }) })] }, key)) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
129
128
|
}
|
|
130
129
|
{
|
|
@@ -133,7 +132,7 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
133
132
|
// =========================>
|
|
134
133
|
}
|
|
135
134
|
if (option == "REFRESH") {
|
|
136
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper-refresh", children: (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon:
|
|
135
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper-refresh", children: (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/refresh", variant: "outline", className: "control-bar-icon-button", onClick: () => onRefresh?.(), size: "sm" }) }, key));
|
|
137
136
|
}
|
|
138
137
|
{
|
|
139
138
|
// =========================>
|
|
@@ -141,7 +140,7 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
141
140
|
// =========================>
|
|
142
141
|
}
|
|
143
142
|
if (option == "FILTER") {
|
|
144
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper", children: (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon:
|
|
143
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper", children: (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/sliders", label: "Filter", variant: "outline", className: "control-bar-filter-button", onClick: () => setToggle("FILTER"), size: "sm" }) }, key));
|
|
145
144
|
}
|
|
146
145
|
{
|
|
147
146
|
// =========================>
|
|
@@ -149,17 +148,17 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
149
148
|
// =========================>
|
|
150
149
|
}
|
|
151
150
|
if (option == "MOBILE_OPTION") {
|
|
152
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper", children: (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon:
|
|
151
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "control-bar-button-wrapper", children: (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/ellipsis-v", variant: "outline", className: "control-bar-icon-button", onClick: () => setToggle("MOBILE_OPTION"), size: "sm" }) }, key));
|
|
153
152
|
}
|
|
154
153
|
return option;
|
|
155
|
-
}) }), !!filterableColumns && !!filterableColumns?.length && ((0, jsx_runtime_1.jsx)(FilterComponent_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)(BottomSheet_component_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) => {
|
|
154
|
+
}) }), !!filterableColumns && !!filterableColumns?.length && ((0, jsx_runtime_1.jsx)(FilterComponent_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)(BottomSheet_component_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 != "SEARCH" && op != "REFRESH"))?.map((option, key) => {
|
|
156
155
|
{
|
|
157
156
|
// =========================>
|
|
158
157
|
// ## Search Field
|
|
159
158
|
// =========================>
|
|
160
159
|
}
|
|
161
160
|
if (option == "SEARCH") {
|
|
162
|
-
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(Input_component_1.InputComponent, { name: "search", placeholder: "Cari disini...", rightIcon:
|
|
161
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(Input_component_1.InputComponent, { name: "search", placeholder: "Cari disini...", rightIcon: "solid/magnifying-glass", value: search, onChange: (e) => onSearch?.(e) }) }, key));
|
|
163
162
|
}
|
|
164
163
|
{
|
|
165
164
|
// =========================>
|
|
@@ -167,7 +166,7 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
167
166
|
// =========================>
|
|
168
167
|
}
|
|
169
168
|
if (option == "SEARCHABLE") {
|
|
170
|
-
return searchableOptions?.length ? ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(Select_component_1.SelectComponent, { name: "searchableColumn", leftIcon:
|
|
169
|
+
return searchableOptions?.length ? ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(Select_component_1.SelectComponent, { name: "searchableColumn", leftIcon: "solid/search", options: searchableOptions?.map((column) => {
|
|
171
170
|
return {
|
|
172
171
|
label: column.label,
|
|
173
172
|
value: column.selector,
|
|
@@ -195,7 +194,7 @@ function ControlBarComponent({ id = "", options, className, search, onSearch, se
|
|
|
195
194
|
if (option == "SORT") {
|
|
196
195
|
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) => {
|
|
197
196
|
const sortBy = sort?.find((s) => s.split(" ")?.at(0) == option?.selector)?.split(" ")?.at(1) || "";
|
|
198
|
-
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)(
|
|
197
|
+
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)(skalfa_icon_1.Icon, { icon: sortBy == "desc" ? "solid/arrow-down-z-a" : "solid/arrow-up-a-z", 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));
|
|
199
198
|
}) })] }, key)) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
200
199
|
}
|
|
201
200
|
{
|
|
@@ -5,7 +5,6 @@ exports.FilterComponent = FilterComponent;
|
|
|
5
5
|
exports.InputFilterValueComponent = InputFilterValueComponent;
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("react");
|
|
8
|
-
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
9
8
|
const _utils_1 = require("@utils");
|
|
10
9
|
const Button_component_1 = require("../button/Button.component");
|
|
11
10
|
const Chip_component_1 = require("../chip/Chip.component");
|
|
@@ -16,7 +15,6 @@ const InputNumber_component_1 = require("../input/InputNumber.component");
|
|
|
16
15
|
const Modal_component_1 = require("../modal/Modal.component");
|
|
17
16
|
const Select_component_1 = require("../input/Select.component");
|
|
18
17
|
const _contexts_1 = require("@contexts");
|
|
19
|
-
const free_regular_svg_icons_1 = require("@fortawesome/free-regular-svg-icons");
|
|
20
18
|
const FILTER_OPERATORS = [
|
|
21
19
|
{ label: "Cari", value: "li" },
|
|
22
20
|
{ label: "Sama", value: "eq" },
|
|
@@ -65,16 +63,16 @@ function FilterComponent({ columns, onChange, value, onMinimize, className = "",
|
|
|
65
63
|
(0, react_1.useEffect)(() => {
|
|
66
64
|
localStorage.setItem(BOOKMARK_KEY, JSON.stringify(bookmarks));
|
|
67
65
|
}, [bookmarks]);
|
|
68
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("filter-panel", (0, _utils_1.pcn)(className, "base")), children: [(0, jsx_runtime_1.jsxs)("div", { className: "filter-panel-header", children: [(0, jsx_runtime_1.jsx)("p", { className: (0, _utils_1.cn)((0, _utils_1.pcn)(className, "title")), children: "Filter" }), (0, jsx_runtime_1.jsxs)("div", { className: "filter-panel-controls", children: [(0, jsx_runtime_1.jsxs)("div", { className: "filter-panel-bookmarks-wrapper", children: [(0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon:
|
|
66
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("filter-panel", (0, _utils_1.pcn)(className, "base")), children: [(0, jsx_runtime_1.jsxs)("div", { className: "filter-panel-header", children: [(0, jsx_runtime_1.jsx)("p", { className: (0, _utils_1.cn)((0, _utils_1.pcn)(className, "title")), children: "Filter" }), (0, jsx_runtime_1.jsxs)("div", { className: "filter-panel-controls", children: [(0, jsx_runtime_1.jsxs)("div", { className: "filter-panel-bookmarks-wrapper", children: [(0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/bookmark", variant: "outline", paint: "primary", className: "filter-panel-bookmark-btn icon::text-slate-400", size: "xs", onClick: () => setToggle("MODAL_BOOKMARK", { bookmark_id: "new" }) }), !!bookmarks?.length && ((0, jsx_runtime_1.jsx)(Chip_component_1.ChipComponent, { items: bookmarks.slice(0, 5).map((b) => b.name), onClick: (_, index) => setFilters(bookmarks[index]?.filters), onDelete: (_, index) => setBookmarks(bookmarks.filter((_, bi) => bi != index)) })), bookmarks?.length > 5 && ((0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/ellipsis-h", variant: "outline", paint: "primary", className: "filter-panel-bookmark-btn icon::text-slate-400", size: "xs", onClick: () => setToggle("MODAL_BOOKMARK_LIST") }))] }), (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/rotate", label: "Bersihkan", variant: "outline", paint: "primary", className: "filter-panel-bookmark-btn icon::text-slate-400", size: "xs", onClick: () => setFilters([]) }), onMinimize && ((0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/chevron-up", variant: "outline", paint: "primary", className: "filter-panel-bookmark-btn icon::text-slate-400", size: "xs", onClick: onMinimize }))] })] }), filters.map((f, i) => {
|
|
69
67
|
const column = columns.find((c) => c.selector === f.column);
|
|
70
68
|
return ((0, jsx_runtime_1.jsxs)("div", { className: "filter-row", children: [i > 0 && ((0, jsx_runtime_1.jsx)("div", { className: "filter-col-logic", children: (0, jsx_runtime_1.jsx)(Select_component_1.SelectComponent, { name: `filter_logic_${i}`, options: LOGIC_OPTIONS, placeholder: "Dan/Atau", value: f.logic, onChange: (e) => handleChange(i, "logic", e), className: "filter-input-field" }) })), (0, jsx_runtime_1.jsx)("div", { className: i > 0 ? "filter-col-column-with-logic" : "filter-col-column", children: (0, jsx_runtime_1.jsx)(Select_component_1.SelectComponent, { name: `filter_column_${i}`, options: columns.map((c) => ({
|
|
71
69
|
label: c.label,
|
|
72
70
|
value: c.selector,
|
|
73
|
-
})), placeholder: "Kolom", value: f.column, onChange: (e) => handleChange(i, "column", e), className: "filter-input-field" }) }), (0, jsx_runtime_1.jsx)("div", { className: "filter-col-operator", children: (0, jsx_runtime_1.jsx)(Select_component_1.SelectComponent, { name: `filter_operator_${i}`, options: FILTER_OPERATORS, placeholder: "Operator", value: f.type, onChange: (e) => handleChange(i, "type", e), className: "filter-input-field" }) }), isSm && ((0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon:
|
|
74
|
-
}), (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { label: "Tambahkan", icon:
|
|
71
|
+
})), placeholder: "Kolom", value: f.column, onChange: (e) => handleChange(i, "column", e), className: "filter-input-field" }) }), (0, jsx_runtime_1.jsx)("div", { className: "filter-col-operator", children: (0, jsx_runtime_1.jsx)(Select_component_1.SelectComponent, { name: `filter_operator_${i}`, options: FILTER_OPERATORS, placeholder: "Operator", value: f.type, onChange: (e) => handleChange(i, "type", e), className: "filter-input-field" }) }), isSm && ((0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/times", paint: "danger", variant: "outline", onClick: () => removeFilter(i), size: "xs" })), column && ((0, jsx_runtime_1.jsx)("div", { className: "filter-col-value", children: (0, jsx_runtime_1.jsx)(InputFilterValueComponent, { type: column.type, name: `filter_value_${i}`, placeholder: "...", value: f.value || "", onChange: (e) => handleChange(i, "value", e), options: column.type === "select" && column.options ? column.options : [], className: "filter-input-field", between: f.type === "bw", multiple: ["in", "ni"].includes(f.type || "") }) })), !isSm && ((0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/times", paint: "danger", variant: "outline", onClick: () => removeFilter(i), size: "xs" }))] }, i));
|
|
72
|
+
}), (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { label: "Tambahkan", icon: "solid/plus", variant: "outline", paint: "primary", size: isSm ? "xs" : "sm", onClick: addFilter, className: "filter-add-btn" })] }), (0, jsx_runtime_1.jsx)(Modal_component_1.ModalComponent, { show: !!toggle["MODAL_BOOKMARK_LIST"], onClose: () => setToggle("MODAL_BOOKMARK_LIST", false), title: "Bookmark Filter", children: (0, jsx_runtime_1.jsx)("div", { className: "filter-bookmark-list-container", children: bookmarks?.length ? bookmarks?.map((b, key) => ((0, jsx_runtime_1.jsxs)("div", { className: "filter-bookmark-row", children: [(0, jsx_runtime_1.jsx)("p", { className: "filter-bookmark-name", children: b.name }), (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2", children: [(0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/plus", variant: "outline", paint: "primary", className: "", size: "xs", onClick: () => {
|
|
75
73
|
setFilters(b.filters);
|
|
76
74
|
setToggle("MODAL_BOOKMARK_LIST", false);
|
|
77
|
-
} }), (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon:
|
|
75
|
+
} }), (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/times", variant: "outline", paint: "danger", className: "", size: "xs", onClick: () => setBookmarks(bookmarks.filter((_, bi) => bi != key)) })] })] }, key))) : ((0, jsx_runtime_1.jsx)("div", { className: "filter-bookmark-empty-text", children: " -- Tidak ada Bookmark --" })) }) }), (0, jsx_runtime_1.jsx)(Modal_component_1.ModalComponent, { show: !!toggle["MODAL_BOOKMARK"], onClose: () => setToggle("MODAL_BOOKMARK", false), title: "Bookmark Filter", footer: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-end", children: (0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { label: "Terapkan", onClick: () => {
|
|
78
76
|
let updated = [];
|
|
79
77
|
if (toggle["MODAL_BOOKMARK"]?.bookmark_id == "new") {
|
|
80
78
|
const newBookmark = {
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.PaginationComponent = PaginationComponent;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const skalfa_icon_1 = require("@skalfa/skalfa-icon");
|
|
6
7
|
const react_1 = require("react");
|
|
7
|
-
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
8
|
-
const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
9
8
|
const _utils_1 = require("@utils");
|
|
10
9
|
const Button_component_1 = require("../button/Button.component");
|
|
11
10
|
const InputRadio_component_1 = require("../input/InputRadio.component");
|
|
@@ -29,5 +28,5 @@ function PaginationComponent({ paginate = 10, page = 1, totalRow = 0, onChange,
|
|
|
29
28
|
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("pagination-container", (0, _utils_1.pcn)(className, "base")), children: [(0, jsx_runtime_1.jsxs)("div", { className: "pagination-desktop-wrapper", children: [(0, jsx_runtime_1.jsx)(InputRadio_component_1.InputRadioComponent, { name: "paginate", options: [10, 20, 50].map((val) => ({
|
|
30
29
|
value: val,
|
|
31
30
|
label: String(val),
|
|
32
|
-
})), value: paginate, onChange: (e) => onChange?.(totalRow, Number(e), 1), className: "pagination-paginate-select" }), totalRow > paginate && ((0, jsx_runtime_1.jsxs)("div", { className: "pagination-desktop-pages", children: [page > 1 && ((0, jsx_runtime_1.jsx)("button", { className: "pagination-overflow", onClick: () => onChange?.(totalRow, paginate, page - 1), children: (0, jsx_runtime_1.jsx)(
|
|
31
|
+
})), value: paginate, onChange: (e) => onChange?.(totalRow, Number(e), 1), className: "pagination-paginate-select" }), totalRow > paginate && ((0, jsx_runtime_1.jsxs)("div", { className: "pagination-desktop-pages", children: [page > 1 && ((0, jsx_runtime_1.jsx)("button", { className: "pagination-overflow", onClick: () => onChange?.(totalRow, paginate, page - 1), children: (0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { icon: "solid/chevron-left" }) })), page > 2 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { className: (0, _utils_1.cn)("pagination-item", (0, _utils_1.pcn)(className, "item")), onClick: () => onChange?.(totalRow, paginate, 1), children: "1" }), page > 3 && (0, jsx_runtime_1.jsx)("span", { className: "pagination-overflow", children: "..." })] })), pages.map((p) => ((0, jsx_runtime_1.jsx)("button", { className: (0, _utils_1.cn)("pagination-item", (0, _utils_1.pcn)(className, "item"), p === page && (0, _utils_1.cn)("pagination-item-active", (0, _utils_1.pcn)(className, "active"))), onClick: () => onChange?.(totalRow, paginate, p), children: p }, p))), page < lastPage - 1 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [page < lastPage - 2 && ((0, jsx_runtime_1.jsx)("span", { className: "pagination-overflow", children: "..." })), (0, jsx_runtime_1.jsx)("button", { className: (0, _utils_1.cn)("pagination-item", (0, _utils_1.pcn)(className, "item")), onClick: () => onChange?.(totalRow, paginate, lastPage), children: lastPage })] })), page < lastPage && ((0, jsx_runtime_1.jsx)("button", { className: "pagination-overflow", onClick: () => onChange?.(totalRow, paginate, page + 1), children: (0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { icon: "solid/chevron-right" }) }))] }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "pagination-desktop-info", children: [Math.min(totalRow, paginate * (page - 1) + 1), " - ", Math.min(totalRow, paginate * page), " / ", totalRow] }), (0, jsx_runtime_1.jsxs)("div", { className: "pagination-mobile-wrapper", children: [(0, jsx_runtime_1.jsxs)("div", { className: "pagination-mobile-info", children: [Math.min(totalRow, paginate * (page - 1) + 1), " - ", Math.min(totalRow, paginate * page), " / ", totalRow] }), totalRow > paginate && ((0, jsx_runtime_1.jsxs)("div", { className: "pagination-mobile-controls", children: [page > 1 && ((0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/chevron-left", onClick: () => onChange?.(totalRow, paginate, page - 1), size: "sm" })), page < lastPage && ((0, jsx_runtime_1.jsx)(Button_component_1.ButtonComponent, { icon: "solid/chevron-right", onClick: () => onChange?.(totalRow, paginate, page + 1), size: "sm" }))] }))] })] }));
|
|
33
32
|
}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.TableComponent = TableComponent;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const skalfa_icon_1 = require("@skalfa/skalfa-icon");
|
|
6
7
|
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
8
|
const _utils_1 = require("@utils");
|
|
10
9
|
const ControlBar_component_1 = require("./ControlBar.component");
|
|
11
10
|
const Pagination_component_1 = require("./Pagination.component");
|
|
@@ -41,7 +40,7 @@ function TableComponent({ id, controlBar, columns, data, pagination, loading, so
|
|
|
41
40
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: columnMapping?.map((column, key) => {
|
|
42
41
|
const sortColumn = sortBy?.find((e) => e.split(" ")?.at(0) == column.selector)?.split(" ")?.at(0) || "";
|
|
43
42
|
const sortDirection = sortBy?.find((e) => e.split(" ")?.at(0) == column.selector)?.split(" ")?.at(1) || "";
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("table-head-column", column.sortable && "cursor-pointer", (0, _utils_1.pcn)(className, "head-column")), style: { width: column.width ? column.width : 200 }, onClick: () => column.sortable && onChangeSortBy?.([`${column.selector} ${sortDirection == "desc" ? "asc" : "desc"}`]), children: [column.label, !!sortColumn && ((0, jsx_runtime_1.jsx)(
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("table-head-column", column.sortable && "cursor-pointer", (0, _utils_1.pcn)(className, "head-column")), style: { width: column.width ? column.width : 200 }, onClick: () => column.sortable && onChangeSortBy?.([`${column.selector} ${sortDirection == "desc" ? "asc" : "desc"}`]), children: [column.label, !!sortColumn && ((0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { icon: sortDirection == "desc" ? "solid/arrow-down-z-a" : "solid/arrow-up-a-z", className: "text-light-foreground/70" }))] }, key));
|
|
45
44
|
}) }));
|
|
46
45
|
}
|
|
47
46
|
function renderItem(item, itemKey) {
|
|
@@ -101,7 +100,7 @@ function TableComponent({ id, controlBar, columns, data, pagination, loading, so
|
|
|
101
100
|
setShowFloatingAction(e.scrollLeft + e.clientWidth <= e.scrollWidth - actionColumnRef.current?.clientWidth);
|
|
102
101
|
}, 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: "Memuat data..." }) }) })) : !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: "Belum Ada Data" }) })) : ((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) => {
|
|
103
102
|
return ((0, jsx_runtime_1.jsxs)("div", { style: { animationDelay: `${(key + 1) * 0.05}s` }, className: (0, _utils_1.cn)("table-body-row", key % 2 ? "bg-light-primary/10" : "bg-white", focus == key && "bg-light-primary/30", (0, _utils_1.pcn)(className, "row")), children: [!!actionBulking && ((0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("table-body-column w-max", (0, _utils_1.pcn)(className, "column")), children: (0, jsx_runtime_1.jsx)(Checkbox_component_1.CheckboxComponent, { name: "selected_table", className: "w-5 h-5", checked: checks?.includes(item?.id), onChange: () => checks?.includes(item?.id) ? onChangeChecks?.(checks.filter((i) => i !== item?.id)) : onChangeChecks?.([...(checks || []), item?.id]) }) })), !noIndex && (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("table-body-column w-8", (0, _utils_1.pcn)(className, "column")), children: numberOfRow(key) }), renderItem(item, key), (0, jsx_runtime_1.jsx)("div", { ref: actionColumnRef, className: "table-action-column", children: item["action"] }), item["action"] && showFloatingAction && ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("table-floating-action", (0, _utils_1.pcn)(className, "floating-action")), onClick: () => floatingActionActive !== false &&
|
|
104
|
-
floatingActionActive == key ? setFloatingActionActive(false) : setFloatingActionActive(key), children: [(0, jsx_runtime_1.jsx)("div", { className: "table-floating-action-icon-wrapper", children: (0, jsx_runtime_1.jsx)(
|
|
103
|
+
floatingActionActive == key ? setFloatingActionActive(false) : setFloatingActionActive(key), children: [(0, jsx_runtime_1.jsx)("div", { className: "table-floating-action-icon-wrapper", children: (0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { icon: floatingActionActive === false || floatingActionActive != key ? "solid/chevron-left" : "solid/chevron-right" }) }), (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("table-floating-action-content", floatingActionActive === key && "table-floating-action-content-active"), children: item["action"] })] }))] }, key));
|
|
105
104
|
}) })] })) : ((0, jsx_runtime_1.jsx)("div", { className: "table-mobile-list", children: data.map((item, key) => {
|
|
106
105
|
return ((0, jsx_runtime_1.jsx)("div", { style: { animationDelay: `${(key + 1) * 0.05}s` }, children: renderItem(item, key) }, key));
|
|
107
106
|
}) })) })) }) }), !!actionBulking && !!checks?.length && ((0, jsx_runtime_1.jsxs)("div", { className: "table-bulk-actions-bar", children: [(0, jsx_runtime_1.jsxs)("div", { className: "table-bulk-actions-title", children: [checks?.length, " Data Terpilih"] }), (0, jsx_runtime_1.jsx)("div", { className: "table-bulk-actions-buttons", children: actionBulking?.(checks) })] })), !block && pagination && ((0, jsx_runtime_1.jsx)("div", { className: "table-pagination-desktop", children: (0, jsx_runtime_1.jsx)(Pagination_component_1.PaginationComponent, { ...pagination }) })), pagination && ((0, jsx_runtime_1.jsx)("div", { className: "table-pagination-mobile", children: (0, jsx_runtime_1.jsx)(Pagination_component_1.PaginationComponent, { ...pagination }) }))] }));
|
|
@@ -5,7 +5,7 @@ exports.SwipeComponent = SwipeComponent;
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const _utils_1 = require("@utils");
|
|
8
|
-
const
|
|
8
|
+
const skalfa_icon_1 = require("@skalfa/skalfa-icon");
|
|
9
9
|
function SwipeComponent({ leftActionControl, rightActionControl, children, className, }) {
|
|
10
10
|
const startX = (0, react_1.useRef)(0);
|
|
11
11
|
const [offset, setOffset] = (0, react_1.useState)(0);
|
|
@@ -49,7 +49,7 @@ function SwipeComponent({ leftActionControl, rightActionControl, children, class
|
|
|
49
49
|
control?.onAction?.();
|
|
50
50
|
setOffset(0);
|
|
51
51
|
}
|
|
52
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("swipe-container", className), children: [(0, jsx_runtime_1.jsxs)("div", { onClick: () => handleAction('left'), className: (0, _utils_1.cn)("swipe-left-action", leftActionControl?.className, offset > 0 ? "opacity-100" : "opacity-0"), children: [leftActionControl?.icon && (0, jsx_runtime_1.jsx)(
|
|
52
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("swipe-container", className), children: [(0, jsx_runtime_1.jsxs)("div", { onClick: () => handleAction('left'), className: (0, _utils_1.cn)("swipe-left-action", leftActionControl?.className, offset > 0 ? "opacity-100" : "opacity-0"), children: [leftActionControl?.icon && (0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { icon: leftActionControl?.icon }), " ", leftActionControl?.label] }), (0, jsx_runtime_1.jsxs)("div", { onClick: () => handleAction('right'), className: (0, _utils_1.cn)("swipe-right-action", rightActionControl?.className, offset < 0 ? "opacity-100" : "opacity-0"), children: [rightActionControl?.icon && (0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { icon: rightActionControl?.icon }), " ", rightActionControl?.label] }), (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("swipe-content", className), style: {
|
|
53
53
|
transform: `translateX(${offset}px)`,
|
|
54
54
|
transition: dragging ? "none" : "transform 0.2s ease",
|
|
55
55
|
}, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onTouchEnd, onClickCapture: (e) => {
|
package/package.json
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skalfa/skalfa-component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Reusable UI components for Skalfa App.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"keywords": [
|
|
6
|
+
"keywords": [
|
|
7
|
+
"skalfa",
|
|
8
|
+
"skalfa-app",
|
|
9
|
+
"skalfa-component",
|
|
10
|
+
"next-framework",
|
|
11
|
+
"next-template"
|
|
12
|
+
],
|
|
7
13
|
"main": "dist/index.js",
|
|
8
14
|
"types": "dist/index.d.ts",
|
|
9
|
-
"files": [
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
10
19
|
"scripts": {
|
|
11
20
|
"build": "tsc -p tsconfig.json",
|
|
12
21
|
"postbuild": "bun fix-exports.js"
|
|
13
22
|
},
|
|
14
23
|
"peerDependencies": {
|
|
15
24
|
"@skalfa/skalfa-app-core": "*",
|
|
16
|
-
"@
|
|
25
|
+
"@skalfa/skalfa-lang": "*",
|
|
26
|
+
"@skalfa/skalfa-icon": "*",
|
|
17
27
|
"next": "^15.0.0 || ^16.0.0",
|
|
18
28
|
"react": "^19.0.0",
|
|
19
29
|
"react-dom": "^19.0.0"
|
|
20
30
|
},
|
|
21
31
|
"devDependencies": {
|
|
22
32
|
"@skalfa/skalfa-app-core": "*",
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"
|
|
26
|
-
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
|
27
|
-
"@fortawesome/react-fontawesome": "^0.2.2",
|
|
33
|
+
"@skalfa/skalfa-lang": "*",
|
|
34
|
+
"@skalfa/skalfa-icon": "*",
|
|
35
|
+
"moment": "^2.30.1",
|
|
28
36
|
"@react-google-maps/api": "^2.20.7",
|
|
29
37
|
"@types/google.maps": "^3.58.1",
|
|
30
38
|
"@types/node": "^20.0.0",
|
|
@@ -35,4 +43,4 @@
|
|
|
35
43
|
"react-dom": "^19.2.1",
|
|
36
44
|
"typescript": "^6.0.3"
|
|
37
45
|
}
|
|
38
|
-
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { Icon, type IconName } from "@skalfa/skalfa-icon";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import { ReactNode, useEffect, useState } from "react";
|
|
6
|
+
import { cn, pcn } from "@utils";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
type CT = "container" | "head" | "active" | "base";
|
|
11
|
+
|
|
12
|
+
export interface AccordionProps {
|
|
13
|
+
setActive ?: number | null;
|
|
14
|
+
items : { head: ReactNode; content: ReactNode }[];
|
|
15
|
+
horizontal ?: boolean;
|
|
16
|
+
className ?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export function AccordionComponent({
|
|
22
|
+
items,
|
|
23
|
+
setActive = null,
|
|
24
|
+
horizontal = false,
|
|
25
|
+
|
|
26
|
+
/** Use custom class with: "container::", "head::", "active::". */
|
|
27
|
+
className = "",
|
|
28
|
+
}: AccordionProps) {
|
|
29
|
+
const [isActive, setIsActive] = useState<number | null>(setActive);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setIsActive(setActive);
|
|
33
|
+
}, [setActive]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div
|
|
37
|
+
className={cn(
|
|
38
|
+
"accordion",
|
|
39
|
+
horizontal ? "accordion-horizontal" : "accordion-vertical",
|
|
40
|
+
pcn<CT>(className, "container"),
|
|
41
|
+
)}
|
|
42
|
+
>
|
|
43
|
+
{items.map(({ head, content }, key) => (
|
|
44
|
+
<div
|
|
45
|
+
key={key}
|
|
46
|
+
className={cn(
|
|
47
|
+
"accordion-item",
|
|
48
|
+
horizontal ? "accordion-item-horizontal" : "accordion-item-vertical",
|
|
49
|
+
)}
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
className={cn(
|
|
53
|
+
"accordion-head",
|
|
54
|
+
horizontal ? "accordion-head-horizontal" : "accordion-head-vertical",
|
|
55
|
+
pcn<CT>(className, "head"),
|
|
56
|
+
)}
|
|
57
|
+
onClick={() => setIsActive(isActive === key ? null : key)}
|
|
58
|
+
>
|
|
59
|
+
<div>{head}</div>
|
|
60
|
+
<div
|
|
61
|
+
className={cn(
|
|
62
|
+
"w-min transition-transform",
|
|
63
|
+
isActive !== key && "rotate-180",
|
|
64
|
+
)}
|
|
65
|
+
>
|
|
66
|
+
<Icon icon={horizontal ? "solid/chevron-left" : "solid/chevron-down"} />
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
<div
|
|
70
|
+
className={cn(
|
|
71
|
+
"accordion-content",
|
|
72
|
+
horizontal
|
|
73
|
+
? isActive === key
|
|
74
|
+
? "accordion-content-horizontal-active"
|
|
75
|
+
: "accordion-content-horizontal-inactive"
|
|
76
|
+
: isActive === key
|
|
77
|
+
? "accordion-content-vertical-active"
|
|
78
|
+
: "accordion-content-vertical-inactive",
|
|
79
|
+
pcn<CT>(className, "base"),
|
|
80
|
+
isActive === key && pcn<CT>(className, "active"),
|
|
81
|
+
)}
|
|
82
|
+
>{content}</div>
|
|
83
|
+
</div>
|
|
84
|
+
))}
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { Icon, type IconName } from "@skalfa/skalfa-icon";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import { Fragment, ReactNode } from "react";
|
|
6
|
+
import Link from "next/link";
|
|
7
|
+
import { cn, pcn } from "@utils";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
type CT = "container" | "active" | "base";
|
|
12
|
+
|
|
13
|
+
export interface BreadcrumbItemProps {
|
|
14
|
+
path : string;
|
|
15
|
+
label : string;
|
|
16
|
+
className ?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export interface BreadcrumbProps {
|
|
20
|
+
items : BreadcrumbItemProps[];
|
|
21
|
+
square ?: boolean;
|
|
22
|
+
separatorContent ?: string | ReactNode;
|
|
23
|
+
|
|
24
|
+
/** Use custom class with: "container::", "active::". */
|
|
25
|
+
className ?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export function BreadcrumbComponent({
|
|
30
|
+
items,
|
|
31
|
+
className = "",
|
|
32
|
+
square = false,
|
|
33
|
+
separatorContent,
|
|
34
|
+
}: BreadcrumbProps) {
|
|
35
|
+
return (
|
|
36
|
+
<nav
|
|
37
|
+
className={cn(
|
|
38
|
+
"breadcrumb",
|
|
39
|
+
pcn<CT>(className, "container"),
|
|
40
|
+
)}
|
|
41
|
+
>
|
|
42
|
+
<ol className="breadcrumb-list">
|
|
43
|
+
{items.map((item, index) => {
|
|
44
|
+
const isActive = index === items.length - 1;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Fragment key={item.path}>
|
|
48
|
+
<li>
|
|
49
|
+
<Link
|
|
50
|
+
href={item.path}
|
|
51
|
+
className={cn(
|
|
52
|
+
"breadcrumb-link",
|
|
53
|
+
square && "breadcrumb-link-square",
|
|
54
|
+
isActive && !square && "breadcrumb-link-active",
|
|
55
|
+
isActive && square && "breadcrumb-link-square-active",
|
|
56
|
+
pcn<CT>(className, "base"),
|
|
57
|
+
isActive && pcn<CT>(className, "active"),
|
|
58
|
+
)}
|
|
59
|
+
>
|
|
60
|
+
{item.label}
|
|
61
|
+
</Link>
|
|
62
|
+
</li>
|
|
63
|
+
|
|
64
|
+
{!isActive && (
|
|
65
|
+
<li className="breadcrumb-separator">
|
|
66
|
+
{separatorContent || (
|
|
67
|
+
<Icon
|
|
68
|
+
icon="solid/chevron-right"
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
</li>
|
|
72
|
+
)}
|
|
73
|
+
</Fragment>
|
|
74
|
+
);
|
|
75
|
+
})}
|
|
76
|
+
</ol>
|
|
77
|
+
</nav>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { Icon, type IconName } from "@skalfa/skalfa-icon";
|
|
6
|
+
import { cn, pcn } from "@utils";
|
|
7
|
+
|
|
8
|
+
type CT = "icon" | "loading" | "base";
|
|
9
|
+
|
|
10
|
+
export interface ButtonProps {
|
|
11
|
+
type ?: "submit" | "button";
|
|
12
|
+
label ?: string | ReactNode;
|
|
13
|
+
variant ?: "solid" | "outline" | "light" | "simple";
|
|
14
|
+
paint ?: "primary" | "secondary" | "success" | "danger" | "warning";
|
|
15
|
+
rounded ?: boolean | string;
|
|
16
|
+
block ?: boolean;
|
|
17
|
+
disabled ?: boolean;
|
|
18
|
+
size ?: "xs" | "sm" | "md" | "lg";
|
|
19
|
+
onClick ?: any;
|
|
20
|
+
href ?: string;
|
|
21
|
+
icon ?: IconName;
|
|
22
|
+
loading ?: boolean;
|
|
23
|
+
hover ?: boolean;
|
|
24
|
+
tips ?: string; // Tooltip / title attribute
|
|
25
|
+
title ?: string;
|
|
26
|
+
|
|
27
|
+
/** Use custom class with: "icon::", "loading::". */
|
|
28
|
+
className?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function ButtonComponent({
|
|
32
|
+
type = "button",
|
|
33
|
+
label,
|
|
34
|
+
variant = "solid",
|
|
35
|
+
paint = "primary",
|
|
36
|
+
rounded,
|
|
37
|
+
block,
|
|
38
|
+
disabled,
|
|
39
|
+
size = "md",
|
|
40
|
+
onClick,
|
|
41
|
+
href,
|
|
42
|
+
icon,
|
|
43
|
+
loading,
|
|
44
|
+
tips,
|
|
45
|
+
title,
|
|
46
|
+
className = "",
|
|
47
|
+
}: ButtonProps) {
|
|
48
|
+
const isIconButton = icon && !label;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<ButtonComponentWrapper
|
|
52
|
+
type={type}
|
|
53
|
+
className={cn(
|
|
54
|
+
"button",
|
|
55
|
+
`button-${variant}-${paint}`,
|
|
56
|
+
isIconButton ? `icon-button-${size}` : `button-${size}`,
|
|
57
|
+
rounded && "rounded-full",
|
|
58
|
+
!isIconButton && block && "w-full justify-center",
|
|
59
|
+
pcn<CT>(className, "base"),
|
|
60
|
+
)}
|
|
61
|
+
disabled={disabled || loading}
|
|
62
|
+
onClick={onClick}
|
|
63
|
+
href={href}
|
|
64
|
+
title={tips || title}
|
|
65
|
+
>
|
|
66
|
+
{loading ? (
|
|
67
|
+
<div className={cn("button-loading", pcn<CT>(className, "loading"))}></div>
|
|
68
|
+
) : (
|
|
69
|
+
icon && (
|
|
70
|
+
<Icon
|
|
71
|
+
icon={icon}
|
|
72
|
+
className={cn("button-icon", pcn<CT>(className, "icon"))}
|
|
73
|
+
/>
|
|
74
|
+
)
|
|
75
|
+
)}
|
|
76
|
+
{!isIconButton && label}
|
|
77
|
+
</ButtonComponentWrapper>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const ButtonComponentWrapper = ({ children, href, ...props }: ButtonProps & { children?: ReactNode }) => {
|
|
82
|
+
return !href ? (
|
|
83
|
+
<button {...(props as any)}>{children}</button>
|
|
84
|
+
) : (
|
|
85
|
+
<Link href={href} {...(props as any)}>
|
|
86
|
+
{children}
|
|
87
|
+
</Link>
|
|
88
|
+
);
|
|
89
|
+
};
|