@ramesesinc/platform-core 0.1.9 → 0.1.11
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/components/action/DeleteData.d.ts +1 -0
- package/dist/components/action/DeleteData.js +16 -5
- package/dist/components/action/LookupPage.d.ts +2 -1
- package/dist/components/action/LookupPage.js +4 -3
- package/dist/components/action/Play.d.ts +6 -0
- package/dist/components/action/Play.js +40 -0
- package/dist/components/action/ProgressBar.d.ts +8 -0
- package/dist/components/action/ProgressBar.js +146 -0
- package/dist/components/action/ViewPage.d.ts +3 -1
- package/dist/components/action/ViewPage.js +22 -10
- package/dist/components/common/UIMenu.d.ts +1 -0
- package/dist/components/common/UIMenu.js +5 -3
- package/dist/components/index.d.ts +4 -1
- package/dist/components/index.js +4 -1
- package/dist/components/input/Combo.d.ts +21 -0
- package/dist/components/input/Combo.js +137 -0
- package/dist/components/input/DateField.js +7 -14
- package/dist/components/input/Text.d.ts +5 -0
- package/dist/components/input/Text.js +42 -7
- package/dist/components/input/YearPicker.js +3 -2
- package/dist/components/list/EditableMenu.d.ts +2 -0
- package/dist/components/list/EditableMenu.js +128 -0
- package/dist/components/list/TabMenu.js +2 -2
- package/dist/components/list/TreeMenu.js +35 -13
- package/dist/components/table/DataList.d.ts +1 -1
- package/dist/components/table/DataList.js +56 -29
- package/dist/components/table/DataTable.d.ts +2 -0
- package/dist/components/table/DataTable.js +31 -22
- package/dist/components/view/FilterView.js +1 -1
- package/dist/components/view/HtmlForm.js +12 -9
- package/dist/components/view/HtmlView.js +1 -1
- package/dist/components/view/PageView.d.ts +1 -0
- package/dist/components/view/PageView.js +38 -11
- package/dist/components/view/PopupView.d.ts +1 -0
- package/dist/components/view/PopupView.js +4 -4
- package/dist/components/view/RootView.d.ts +1 -0
- package/dist/components/view/RootView.js +18 -18
- package/dist/components/view/WizardView.d.ts +1 -1
- package/dist/components/view/WizardView.js +7 -25
- package/dist/core/AuthContext.js +1 -1
- package/dist/core/DynamicComponent.d.ts +2 -1
- package/dist/core/DynamicComponent.js +24 -2
- package/dist/core/Page.d.ts +1 -0
- package/dist/core/Page.js +6 -5
- package/dist/core/PageCache.d.ts +0 -2
- package/dist/core/PageCache.js +3 -8
- package/dist/core/PageContext.d.ts +1 -0
- package/dist/core/PageContext.js +16 -2
- package/dist/core/PageViewContext.d.ts +8 -2
- package/dist/core/PageViewContext.js +155 -86
- package/dist/core/Panel.js +34 -12
- package/dist/core/StepHandler.d.ts +1 -1
- package/dist/core/StepHandler.js +58 -21
- package/dist/index.css +98 -0
- package/dist/layouts/CardLayout.d.ts +2 -2
- package/dist/layouts/CardLayout.js +3 -4
- package/dist/layouts/HPanel.d.ts +2 -2
- package/dist/layouts/HPanel.js +1 -2
- package/dist/layouts/VPanel.d.ts +2 -2
- package/dist/layouts/VPanel.js +1 -2
- package/dist/layouts/index.d.ts +2 -3
- package/dist/layouts/index.js +2 -3
- package/dist/lib/utils/ExprUtil.js +18 -29
- package/dist/lib/utils/ResourceLoader.js +19 -7
- package/dist/lib/utils/SectionProvider.js +1 -1
- package/dist/lib/utils/initResourceLoader.d.ts +2 -0
- package/dist/lib/utils/initResourceLoader.js +64 -95
- package/dist/lib/utils/nunjucks.d.ts +2 -0
- package/dist/lib/utils/nunjucks.js +8 -0
- package/dist/templates/CrudFormTemplate.js +2 -3
- package/dist/templates/DataListTemplate.js +1 -1
- package/dist/templates/WizardTemplate.d.ts +3 -0
- package/dist/templates/WizardTemplate.js +17 -10
- package/package.json +1 -1
- package/dist/components/input/Select.d.ts +0 -14
- package/dist/components/input/Select.js +0 -40
|
@@ -10,8 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { Tooltip } from "@ramesesinc/client";
|
|
14
|
+
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, Columns, Eye, Funnel, RefreshCcw, Search, Trash, } from "lucide-react";
|
|
15
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
15
16
|
import { useApp } from "../../core/AppContext";
|
|
16
17
|
import { useDataContext } from "../../core/DataContext";
|
|
17
18
|
import { DynamicComponent } from "../../core/DynamicComponent";
|
|
@@ -20,10 +21,12 @@ import Panel from "../../core/Panel";
|
|
|
20
21
|
import useDependHandler from "../../core/UIDependHandler";
|
|
21
22
|
import { replaceValues } from "../../lib/utils/BeanUtils";
|
|
22
23
|
import { getUrlPageParams } from "../../lib/utils/PageUtils";
|
|
24
|
+
import LookupPage from "../action/LookupPage";
|
|
23
25
|
import { DataTable } from "./DataTable";
|
|
24
26
|
import ListHandler from "./ListHandler";
|
|
25
27
|
import { TableProvider, useTableContext } from "./TableContext";
|
|
26
|
-
const InnerDataList = ({ cols, emptyMessage = "No data available", errorMessage, striped = false, bordered = false, hover = true, dense = false, showPagination = true, paginationPosition = "bottom", showPageInfo = true, showTotalCount = true, showRowsPerPage = true, rowsPerPageOptions = [5, 10, 20, 50, 100], searchable = false, searchPlaceholder = "Search...", searchDebounce = 300, onSearchChange, filters = [],
|
|
28
|
+
const InnerDataList = ({ cols, emptyMessage = "No data available", errorMessage, striped = false, bordered = false, hover = true, dense = false, showPagination = true, paginationPosition = "bottom", showPageInfo = true, showTotalCount = true, showRowsPerPage = true, rowsPerPageOptions = [5, 10, 20, 50, 100], searchable = false, searchPlaceholder = "Search...", searchDebounce = 300, onSearchChange, filters = [], filterPage, onFilterChange, sortable = true, showSortIndicator = true, selectable = false, selectionMode = "multiple", onSelectionChange, selectOnRowClick = false, onRowClick, rowActions = [], bulkActions = [], showBulkActions = true, toolbarActions = [], showToolbar = true, toolbarTitle, showRefreshButton = true, showExportButton = false, onLoad, onError, onRefresh, onExport, className = "", rowClassName, depends, handle, }) => {
|
|
29
|
+
var _a;
|
|
27
30
|
const { listHandler, columns, rows, setRows, loading: ctxLoading, setLoading } = useTableContext();
|
|
28
31
|
// ============================================================================
|
|
29
32
|
// STATE
|
|
@@ -192,7 +195,9 @@ const InnerDataList = ({ cols, emptyMessage = "No data available", errorMessage,
|
|
|
192
195
|
handleSelectionChange([key]);
|
|
193
196
|
}
|
|
194
197
|
else {
|
|
195
|
-
const newSelection = selectedRows.includes(key)
|
|
198
|
+
const newSelection = selectedRows.includes(key)
|
|
199
|
+
? selectedRows.filter((k) => k !== key)
|
|
200
|
+
: [...selectedRows, key];
|
|
196
201
|
handleSelectionChange(newSelection);
|
|
197
202
|
}
|
|
198
203
|
}
|
|
@@ -215,15 +220,15 @@ const InnerDataList = ({ cols, emptyMessage = "No data available", errorMessage,
|
|
|
215
220
|
// ============================================================================
|
|
216
221
|
// DISPLAY COLUMNS — actions + sort indicators
|
|
217
222
|
// ============================================================================
|
|
223
|
+
const actionUuid = useRef(Math.random().toString(36).slice(2));
|
|
218
224
|
const renderActionCell = (row, rowIndex) => {
|
|
219
225
|
const visible = rowActions.filter((a) => !a.show || a.show(row));
|
|
220
226
|
if (visible.length === 0)
|
|
221
227
|
return null;
|
|
222
|
-
const uuid = Math.random().toString(36).slice(2);
|
|
223
228
|
return (_jsx("div", { className: "dl-actions flex justify-center items-center", children: visible.map((action, i) => (_jsx("div", { children: _jsx(DynamicComponent, { config: {
|
|
224
229
|
component: action.component,
|
|
225
230
|
attr: Object.assign(Object.assign({}, action.attr), { opt: { data: row } }),
|
|
226
|
-
} }) }, `${
|
|
231
|
+
} }) }, `${actionUuid.current}-${i}`))) }));
|
|
227
232
|
};
|
|
228
233
|
const displayColumns = rowActions.length > 0 && visibleUserColumns.length > 0
|
|
229
234
|
? [
|
|
@@ -241,22 +246,29 @@ const InnerDataList = ({ cols, emptyMessage = "No data available", errorMessage,
|
|
|
241
246
|
return col;
|
|
242
247
|
const currentSort = listHandler.getCurrentSortedColumn();
|
|
243
248
|
const currentDirection = listHandler.getCurrentSortDirection();
|
|
244
|
-
return Object.assign(Object.assign({}, col), { title: (_jsxs("div", { className: "dl-sortable-header", onClick: () => col.id && col.id !== "_actions" && handleSort(col.id), style: { cursor: col.id !== "_actions" ? "pointer" : "default" }, children: [col.title, currentSort === col.id && _jsx("span", { className: `dl-sort-icon dl-sort-${currentDirection}`, children: currentDirection === "asc" ? "▲" : "▼" })] })) });
|
|
249
|
+
return Object.assign(Object.assign({}, col), { title: (_jsxs("div", { className: "dl-sortable-header", onClick: () => col.id && col.id !== "_actions" && handleSort(col.id), style: { cursor: col.id !== "_actions" ? "pointer" : "default" }, children: [col.title, currentSort === col.id && (_jsx("span", { className: `dl-sort-icon dl-sort-${currentDirection}`, children: currentDirection === "asc" ? "▲" : "▼" }))] })) });
|
|
245
250
|
});
|
|
246
251
|
// ============================================================================
|
|
247
252
|
// RENDER TOOLBAR
|
|
248
253
|
// ============================================================================
|
|
254
|
+
const toolbarUuid = useRef(Math.random().toString(36).slice(2));
|
|
249
255
|
const renderToolbar = () => {
|
|
250
256
|
if (!showToolbar)
|
|
251
257
|
return null;
|
|
252
|
-
const uuid = Math.random().toString(36).slice(2);
|
|
253
258
|
return (_jsxs("div", { className: "dl-toolbar", children: [_jsxs("div", { className: "dl-toolbar-left", children: [toolbarTitle && _jsx("h3", { className: "dl-toolbar-title", children: toolbarTitle }), _jsxs("div", { className: "dl-toolbar-right", children: [showBulkActions &&
|
|
254
259
|
selectedRows.length > 0 &&
|
|
255
260
|
bulkActions.map((action, i) => (_jsxs("button", { className: `dl-btn dl-btn-${action.variant || "default"}`, onClick: () => {
|
|
256
261
|
const selectedData = rows.filter((row) => selectedRows.includes(row.id || JSON.stringify(row)));
|
|
257
262
|
action.onClick(selectedData);
|
|
258
|
-
}, children: [action.icon && _jsx("span", { children: action.icon }), action.label] }, action.label || i))),
|
|
263
|
+
}, children: [action.icon && _jsx("span", { children: action.icon }), action.label] }, action.label || i))), _jsx(SearchBox, { searchable: searchable, searchPlaceholder: searchPlaceholder, searchText: searchText, onSearch: handleSearch })] })] }), MemoizedToolbar] }));
|
|
259
264
|
};
|
|
265
|
+
const handleRefreshRef = useRef(handleRefresh);
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
handleRefreshRef.current = handleRefresh;
|
|
268
|
+
}, [handleRefresh]);
|
|
269
|
+
const MemoizedToolbar = useMemo(() => {
|
|
270
|
+
return (_jsxs("div", { className: "flex items-center gap-1", children: [toolbarActions.map((action, i) => (_jsx("div", { children: _jsx(DynamicComponent, { config: { component: action.component, attr: action.attr || {} } }) }, `${toolbarUuid.current}-${i}`))), _jsx(FilterButton, { filterPage: filterPage }), _jsx(RefreshButton, { show: showRefreshButton, onClick: handleRefresh }), _jsx(ColumnToggle, { columns: columns, hiddenColumns: hiddenColumns, setHiddenColumns: setHiddenColumns })] }));
|
|
271
|
+
}, [toolbarActions, filterPage, showRefreshButton, hiddenColumns, columns]);
|
|
260
272
|
// ============================================================================
|
|
261
273
|
// RENDER FILTER PANEL
|
|
262
274
|
// ============================================================================
|
|
@@ -279,11 +291,11 @@ const InnerDataList = ({ cols, emptyMessage = "No data available", errorMessage,
|
|
|
279
291
|
const hasPrev = listHandler.hasPrevPage();
|
|
280
292
|
const startRecord = (currentPage - 1) * rowsPerPage + 1;
|
|
281
293
|
const endRecord = Math.min(currentPage * rowsPerPage, totalRecords);
|
|
282
|
-
return (_jsxs("div", { className: "dl-pagination", children: [
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
294
|
+
return (_jsxs("div", { className: "dl-pagination", children: [_jsx("div", { className: "dl-pagination-info", children: showPageInfo && !showTotalCount && _jsxs("span", { children: ["Page ", currentPage] }) }), _jsxs("div", { className: "dl-pagination-controls", children: [showRowsPerPage && (_jsxs("div", { className: "dl-rows-per-page", children: [_jsx("span", { children: "Rows per page" }), _jsx("select", { value: rowsPerPage, onChange: (e) => handleRowsPerPage(Number(e.target.value)), children: rowsPerPageOptions.map((o) => (_jsx("option", { value: o, children: o }, o))) })] })), showPageInfo && showTotalCount && (_jsxs("span", { className: "text-sm", children: ["Page ", startRecord, " of ", endRecord] })), _jsxs("div", { className: "flex gap-2", children: [_jsx("button", { className: "dl-page-btn", disabled: !hasPrev, onClick: handleFirstPage, children: _jsx(ChevronLeft, { size: 16 }) }), _jsx("button", { className: "dl-page-btn", disabled: !hasPrev, onClick: handlePrevPage, children: _jsx(ChevronsLeft, { size: 16 }) }), totalPages > 0 &&
|
|
295
|
+
[...Array(Math.min(totalPages, 5))].map((_, i) => {
|
|
296
|
+
const page = i + 1;
|
|
297
|
+
return (_jsx("button", { className: `dl-page-btn ${currentPage === page ? "active" : ""}`, onClick: () => handlePageChange(page), children: page }, page));
|
|
298
|
+
}), _jsx("button", { className: "dl-page-btn", disabled: !hasNext, onClick: handleNextPage, children: _jsx(ChevronRight, { size: 16 }) }), _jsx("button", { className: "dl-page-btn", disabled: !hasNext, onClick: handleLastPage, children: _jsx(ChevronsRight, { size: 16 }) })] })] })] }));
|
|
287
299
|
};
|
|
288
300
|
// ============================================================================
|
|
289
301
|
// ERROR STATE
|
|
@@ -294,7 +306,8 @@ const InnerDataList = ({ cols, emptyMessage = "No data available", errorMessage,
|
|
|
294
306
|
// ============================================================================
|
|
295
307
|
// MAIN RENDER
|
|
296
308
|
// ============================================================================
|
|
297
|
-
|
|
309
|
+
const rowsPerPage = (_a = listHandler === null || listHandler === void 0 ? void 0 : listHandler.getRowsPerPage()) !== null && _a !== void 0 ? _a : 10;
|
|
310
|
+
return (_jsxs("div", { className: `data-list ${className}`, children: [renderToolbar(), renderFilterPanel(), (paginationPosition === "both" || paginationPosition === "top") && renderPagination(), _jsx(DataTable, { data: rows, columns: sortableColumns, loading: isLoading, emptyMessage: emptyMessage, striped: striped, bordered: bordered, hover: hover, dense: dense, rowKey: "id", onRowClick: handleRowClick, selectedRows: selectedRows, onSelectionChange: handleSelectionChange, selectable: selectable, rowClassName: rowClassName, rowsPerPage: rowsPerPage }), (paginationPosition === "both" || paginationPosition === "bottom") && rows.length > 0 && renderPagination()] }));
|
|
298
311
|
};
|
|
299
312
|
export const DataList = ({ attr }) => {
|
|
300
313
|
const { title, depends, cols, data, rowsPerPage, disableTotalCount, commonActions, rowActions, toolbarActions } = attr, rest = __rest(attr, ["title", "depends", "cols", "data", "rowsPerPage", "disableTotalCount", "commonActions", "rowActions", "toolbarActions"]);
|
|
@@ -320,13 +333,13 @@ export const DataList = ({ attr }) => {
|
|
|
320
333
|
if (commonActions === null || commonActions === void 0 ? void 0 : commonActions.viewPage) {
|
|
321
334
|
newRowActions.unshift({
|
|
322
335
|
component: "ViewPage",
|
|
323
|
-
attr: Object.assign(Object.assign({}, commonActions.viewPage), { title: "View", icon: _jsx(Eye, { size: 20 }), iconOnly: true }),
|
|
336
|
+
attr: Object.assign(Object.assign({}, commonActions.viewPage), { title: "View", icon: _jsx(Eye, { size: 20, color: "blue" }), iconOnly: true }),
|
|
324
337
|
});
|
|
325
338
|
}
|
|
326
339
|
if (commonActions === null || commonActions === void 0 ? void 0 : commonActions.deleteData) {
|
|
327
340
|
newRowActions.push({
|
|
328
341
|
component: "DeleteData",
|
|
329
|
-
attr: Object.assign(Object.assign({}, commonActions.deleteData), { title: "Delete", icon: _jsx(Trash, { size: 20 }), iconOnly: true }),
|
|
342
|
+
attr: Object.assign(Object.assign({}, commonActions.deleteData), { title: "Delete", icon: _jsx(Trash, { size: 20, color: "red" }), iconOnly: true }),
|
|
330
343
|
});
|
|
331
344
|
}
|
|
332
345
|
const newToolbarActions = [...(toolbarActions || [])];
|
|
@@ -334,16 +347,20 @@ export const DataList = ({ attr }) => {
|
|
|
334
347
|
newToolbarActions.unshift({
|
|
335
348
|
label: "New",
|
|
336
349
|
component: "ViewPage",
|
|
337
|
-
attr: Object.assign(Object.assign({}, commonActions.newPage), { title: "New" }),
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
if (commonActions === null || commonActions === void 0 ? void 0 : commonActions.filterPage) {
|
|
341
|
-
newToolbarActions.push({
|
|
342
|
-
label: "Filter",
|
|
343
|
-
component: "LookupPage",
|
|
344
|
-
attr: Object.assign(Object.assign({}, commonActions.filterPage), { name: "customFilter", title: "Filter" }),
|
|
350
|
+
attr: Object.assign(Object.assign({}, commonActions.newPage), { title: "New", action: "create" }),
|
|
345
351
|
});
|
|
346
352
|
}
|
|
353
|
+
// if (commonActions?.filterPage) {
|
|
354
|
+
// newToolbarActions.push({
|
|
355
|
+
// label: "Filter",
|
|
356
|
+
// component: "LookupPage",
|
|
357
|
+
// attr: {
|
|
358
|
+
// ...commonActions.filterPage,
|
|
359
|
+
// name: "customFilter",
|
|
360
|
+
// title: "Filter",
|
|
361
|
+
// },
|
|
362
|
+
// });
|
|
363
|
+
// }
|
|
347
364
|
const handleRef = useRef(null);
|
|
348
365
|
const onRefresh = () => {
|
|
349
366
|
var _a;
|
|
@@ -356,17 +373,21 @@ export const DataList = ({ attr }) => {
|
|
|
356
373
|
handleRef.current = ref;
|
|
357
374
|
},
|
|
358
375
|
};
|
|
359
|
-
return (_jsx(TableProvider, { data: data, columns: cols, rowsPerPage: rowsPerPage, disableTotalCount: disableTotalCount, listHandlerFactory: listHandlerFactory, tenant: tenant !== null && tenant !== void 0 ? tenant : "", module: module !== null && module !== void 0 ? module : "", resolvedParams: resolveParams(), children: _jsx(InnerDataList, Object.assign({}, rest, { toolbarTitle: title, cols: cols, rowActions: newRowActions, toolbarActions: newToolbarActions, depends: depends, handle: innerHandle })) }));
|
|
376
|
+
return (_jsx(TableProvider, { data: data, columns: cols, rowsPerPage: rowsPerPage, disableTotalCount: disableTotalCount, listHandlerFactory: listHandlerFactory, tenant: tenant !== null && tenant !== void 0 ? tenant : "", module: module !== null && module !== void 0 ? module : "", resolvedParams: resolveParams(), children: _jsx(InnerDataList, Object.assign({}, rest, { toolbarTitle: title, cols: cols, rowActions: newRowActions, toolbarActions: newToolbarActions, depends: depends, handle: innerHandle, filterPage: commonActions === null || commonActions === void 0 ? void 0 : commonActions.filterPage })) }));
|
|
360
377
|
};
|
|
361
378
|
export default DataList;
|
|
362
379
|
const RefreshButton = ({ show, onClick, size = 18 }) => {
|
|
363
380
|
if (!show)
|
|
364
381
|
return null;
|
|
365
|
-
return (_jsx("span", { className: "text-gray-600 hover:bg-gray-200 rounded p-2", children: _jsx(RefreshCcw, { size: size
|
|
382
|
+
return (_jsx(Tooltip, { content: "Refresh", children: _jsx("span", { className: "text-gray-600 hover:bg-gray-200 rounded p-2 cursor-pointer flex items-center", onClick: onClick, children: _jsx(RefreshCcw, { size: size }) }) })
|
|
383
|
+
// <Button onClick={onClick} variant="outlined" icon={<RefreshCcw size={size} />} className="text-black border-gray-300 hover:bg-gray-100">
|
|
384
|
+
// Refresh
|
|
385
|
+
// </Button>
|
|
386
|
+
);
|
|
366
387
|
};
|
|
367
388
|
const ColumnToggle = ({ columns, hiddenColumns, setHiddenColumns }) => {
|
|
368
389
|
const [showColumnToggle, setShowColumnToggle] = useState(false);
|
|
369
|
-
return (_jsxs("div", { className: "relative", children: [_jsx("span", { className: "text-gray-600 hover:bg-gray-200 rounded p-2 cursor-pointer flex items-center", onClick: () => setShowColumnToggle(!showColumnToggle), children: _jsx(Columns, { size: 18 }) }), showColumnToggle && (_jsxs("div", { className: "absolute right-0 top-8 z-50 bg-white border
|
|
390
|
+
return (_jsxs("div", { className: "relative", children: [_jsx(Tooltip, { content: "Columns", children: _jsx("span", { className: "text-gray-600 hover:bg-gray-200 rounded p-2 cursor-pointer flex items-center", onClick: () => setShowColumnToggle(!showColumnToggle), children: _jsx(Columns, { size: 18 }) }) }), showColumnToggle && (_jsxs("div", { className: "absolute right-0 top-8 z-50 bg-white border rounded-lg shadow-lg p-3 min-w-[180px]", children: [_jsx("p", { className: "text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2", children: "Columns" }), columns.map((col) => {
|
|
370
391
|
const colId = col.id || String(col.title);
|
|
371
392
|
const isHidden = hiddenColumns.includes(colId);
|
|
372
393
|
return (_jsxs("label", { className: "flex items-center gap-2 py-1 cursor-pointer hover:bg-gray-50 px-1 rounded", children: [_jsx("input", { type: "checkbox", checked: !isHidden, onChange: () => setHiddenColumns((prev) => (isHidden ? prev.filter((id) => id !== colId) : [...prev, colId])) }), _jsx("span", { className: "text-sm text-gray-700", children: String(col.title || col.id) })] }, colId));
|
|
@@ -375,5 +396,11 @@ const ColumnToggle = ({ columns, hiddenColumns, setHiddenColumns }) => {
|
|
|
375
396
|
const SearchBox = ({ searchable, searchPlaceholder, searchText, onSearch }) => {
|
|
376
397
|
if (!searchable)
|
|
377
398
|
return null;
|
|
378
|
-
return (_jsxs("div", { className: "dl-search-box
|
|
399
|
+
return (_jsxs("div", { className: "dl-search-box", children: [_jsx("span", { children: _jsx(Search, { size: 16 }) }), _jsx("input", { type: "text", placeholder: searchPlaceholder, value: searchText, onChange: (e) => onSearch(e.target.value), className: "focus:outline-none focus:ring-0 focus:shadow-none focus:bg-white" })] }));
|
|
400
|
+
};
|
|
401
|
+
const FilterButton = ({ filterPage }) => {
|
|
402
|
+
const { url, name, icon } = filterPage || {};
|
|
403
|
+
if (!filterPage)
|
|
404
|
+
return null;
|
|
405
|
+
return (_jsx(Tooltip, { content: "Filter", children: _jsx(LookupPage, { url: url, name: name, title: "Filter", icon: icon || _jsx(Funnel, { size: 18, className: "cursor-pointer text-black " }), iconOnly: true, variant: "outlined", className: "text-gray-600 hover:bg-gray-200 rounded p-2 flex items-center" }) }));
|
|
379
406
|
};
|
|
@@ -16,6 +16,7 @@ export interface ColumnDefinition {
|
|
|
16
16
|
expr?: string;
|
|
17
17
|
primary?: boolean;
|
|
18
18
|
component?: string | null;
|
|
19
|
+
attr?: Record<string, any>;
|
|
19
20
|
}
|
|
20
21
|
export interface DataTableProps {
|
|
21
22
|
data?: any[];
|
|
@@ -41,6 +42,7 @@ export interface DataTableProps {
|
|
|
41
42
|
multiRowHeader?: ColumnDefinition[][];
|
|
42
43
|
rowActions?: (row: any, rowIndex: number) => React.ReactNode;
|
|
43
44
|
rowsPerItem?: number;
|
|
45
|
+
rowsPerPage?: number;
|
|
44
46
|
}
|
|
45
47
|
export declare const DataTable: React.FC<DataTableProps>;
|
|
46
48
|
export default DataTable;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React, { memo, useMemo } from "react";
|
|
3
|
+
import { DynamicComponent } from "../../core/DynamicComponent";
|
|
3
4
|
import { RowProvider } from "../../core/RowContext";
|
|
4
5
|
import { render } from "../../lib/utils/ExprUtil";
|
|
5
6
|
import { useTableContext } from "./TableContext";
|
|
@@ -53,7 +54,7 @@ const TableHeader = memo(({ visibleColumns, selectable, rowActions, data, select
|
|
|
53
54
|
return (_jsx("th", { style: { width: column.width, textAlign: column.align || "left" }, className: column.sortable ? "sortable" : "", children: renderHeader(column) }, getColumnKey(column, index)));
|
|
54
55
|
}), rowActions && _jsx("th", { className: "dt-actions-cell", children: "Actions" })] }));
|
|
55
56
|
});
|
|
56
|
-
const TableBody = memo(({ sortedData, visibleColumns, emptyMessage, selectable, rowActions, selectedRows, handleSelectRow, handleRowClick, handleCellClick, rowClassName, rowKey, rowsPerItem, cellRenderer, }) => {
|
|
57
|
+
const TableBody = memo(({ sortedData, visibleColumns, emptyMessage, selectable, rowActions, selectedRows, handleSelectRow, handleRowClick, handleCellClick, rowClassName, rowKey, rowsPerItem, cellRenderer, rowsPerPage, }) => {
|
|
57
58
|
const generateKey = () => `RP-${Math.random().toString(36).slice(2)}`;
|
|
58
59
|
const getNestedValue = (obj, path) => {
|
|
59
60
|
if (!path)
|
|
@@ -63,6 +64,8 @@ const TableBody = memo(({ sortedData, visibleColumns, emptyMessage, selectable,
|
|
|
63
64
|
const getRowKey = (row) => row[rowKey] || JSON.stringify(row);
|
|
64
65
|
const isRowSelected = (row) => selectedRows.includes(getRowKey(row));
|
|
65
66
|
const getColumnKey = (column, index) => column.id || column.expr || `col-${index}`;
|
|
67
|
+
const colCount = visibleColumns.length + (selectable ? 1 : 0) + (rowActions ? 1 : 0);
|
|
68
|
+
const fillerCount = rowsPerPage ? Math.max(0, rowsPerPage - sortedData.length) : 0;
|
|
66
69
|
/*
|
|
67
70
|
const renderExpression = (expr: string, row: any): string => {
|
|
68
71
|
try {
|
|
@@ -92,6 +95,12 @@ const TableBody = memo(({ sortedData, visibleColumns, emptyMessage, selectable,
|
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
const renderCellContent = (row, column, rowIndex) => {
|
|
98
|
+
if (column.component) {
|
|
99
|
+
return (_jsx(DynamicComponent, { config: {
|
|
100
|
+
component: column.component,
|
|
101
|
+
attr: Object.assign(Object.assign({}, column.attr), { opt: { data: row } }),
|
|
102
|
+
} }));
|
|
103
|
+
}
|
|
95
104
|
if (column.expr) {
|
|
96
105
|
const rendered = render(column.expr, row);
|
|
97
106
|
if (column.render)
|
|
@@ -110,35 +119,35 @@ const TableBody = memo(({ sortedData, visibleColumns, emptyMessage, selectable,
|
|
|
110
119
|
if (!sortedData || sortedData.length === 0) {
|
|
111
120
|
return (_jsx("tr", { children: _jsx("td", { colSpan: visibleColumns.length + (selectable ? 1 : 0) + (rowActions ? 1 : 0), style: { textAlign: "center", padding: "24px" }, children: emptyMessage }) }));
|
|
112
121
|
}
|
|
113
|
-
return (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
return (_jsxs(_Fragment, { children: [sortedData.map((row, itemIndex) => {
|
|
123
|
+
const isSelected = isRowSelected(row);
|
|
124
|
+
const customRowClass = rowClassName ? rowClassName(row, itemIndex) : "";
|
|
125
|
+
const rows = [];
|
|
126
|
+
for (let subrowIndex = 0; subrowIndex < rowsPerItem; subrowIndex++) {
|
|
127
|
+
const rowClasses = [isSelected && "dt-selected", customRowClass].filter(Boolean).join(" ");
|
|
128
|
+
rows.push(_jsx(RowProvider, { data: row, children: _jsxs("tr", { className: rowClasses, onClick: () => handleRowClick(row, itemIndex), children: [selectable && subrowIndex === 0 && (_jsx("td", { className: "dt-checkbox-cell", rowSpan: rowsPerItem, children: _jsx("input", { type: "checkbox", checked: isSelected, onChange: () => handleSelectRow(row), onClick: (e) => e.stopPropagation() }) })), visibleColumns.map((column, colIndex) => {
|
|
129
|
+
if (!column.id && !column.expr && !column.component)
|
|
130
|
+
return null;
|
|
131
|
+
if ((column.subrow || 0) !== subrowIndex)
|
|
132
|
+
return null;
|
|
133
|
+
if (column.subrow && column.subrow > 0 && subrowIndex > 0)
|
|
134
|
+
return null;
|
|
135
|
+
const value = column.id ? getNestedValue(row, column.id) : null;
|
|
136
|
+
return (_jsx("td", { style: { textAlign: column.align || "left" }, className: `
|
|
128
137
|
${column.datatype === "number" || column.datatype === "currency" ? "dt-numeric" : ""}
|
|
129
138
|
${column.datatype === "boolean" ? "dt-boolean" : ""}
|
|
130
139
|
`.trim(), onClick: (e) => handleCellClick(e, value, row, column, itemIndex, colIndex), children: renderCellContent(row, column, itemIndex) }, getColumnKey(column, colIndex)));
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
}), rowActions && subrowIndex === 0 && (_jsx("td", { className: "dt-actions-cell", rowSpan: rowsPerItem, children: rowActions(row, itemIndex) }))] }, `${getRowKey(row)}-subrow-${subrowIndex}`) }, generateKey()));
|
|
141
|
+
}
|
|
142
|
+
return rows;
|
|
143
|
+
}), [...Array(fillerCount)].map((_, i) => (_jsx("tr", { className: "filler-row", children: [...Array(colCount)].map((_, j) => (_jsx("td", { children: "\u00A0" }, j))) }, `filler-${i}`)))] }));
|
|
135
144
|
});
|
|
136
145
|
// ============================================================================
|
|
137
146
|
// DATATABLE COMPONENT
|
|
138
147
|
// ============================================================================
|
|
139
148
|
export const DataTable = ({
|
|
140
149
|
// Direct props (fallback when used outside TableProvider)
|
|
141
|
-
data: propData, columns: propColumns, loading: propLoading = false, emptyMessage = "No data available", striped = false, bordered = false, hover = true, dense = false, stickyHeader = false, maxHeight, rowKey = "id", onRowClick, onCellClick, selectedRows = [], onSelectionChange, selectable = false, className = "", rowClassName, cellRenderer, headerRenderer, multiRowHeader, rowActions, rowsPerItem = 1, }) => {
|
|
150
|
+
data: propData, columns: propColumns, loading: propLoading = false, emptyMessage = "No data available", striped = false, bordered = false, hover = true, dense = false, stickyHeader = false, maxHeight, rowKey = "id", onRowClick, onCellClick, selectedRows = [], onSelectionChange, selectable = false, className = "", rowClassName, cellRenderer, headerRenderer, multiRowHeader, rowActions, rowsPerItem = 1, rowsPerPage = 10, }) => {
|
|
142
151
|
var _a, _b;
|
|
143
152
|
// Try to consume context; if not inside a provider, ctx will be null.
|
|
144
153
|
let ctxColumns;
|
|
@@ -248,6 +257,6 @@ data: propData, columns: propColumns, loading: propLoading = false, emptyMessage
|
|
|
248
257
|
if (loading) {
|
|
249
258
|
return (_jsxs("div", { className: "dt-loading", children: [_jsx("div", { className: "dt-spinner" }), _jsx("p", { children: "Loading..." })] }));
|
|
250
259
|
}
|
|
251
|
-
return (_jsx("div", { className: "dt-container", style: containerStyle, children: _jsxs("table", { className: tableClasses, children: [_jsx("thead", { children: _jsx(TableHeader, { visibleColumns: visibleColumns, selectable: selectable, rowActions: rowActions, data: data, selectedRows: selectedRows, handleSelectAll: handleSelectAll, sortConfig: sortConfig, handleSort: handleSort, headerRenderer: headerRenderer, multiRowHeader: multiRowHeader }) }), _jsx("tbody", { children: _jsx(TableBody, { sortedData: sortedData, visibleColumns: visibleColumns, emptyMessage: emptyMessage, selectable: selectable, rowActions: rowActions, selectedRows: selectedRows, handleSelectRow: handleSelectRow, handleRowClick: handleRowClick, handleCellClick: handleCellClick, rowClassName: rowClassName, rowKey: rowKey, rowsPerItem: rowsPerItem, cellRenderer: cellRenderer }) })] }) }));
|
|
260
|
+
return (_jsx("div", { className: "dt-container", style: containerStyle, children: _jsxs("table", { className: tableClasses, children: [_jsx("thead", { children: _jsx(TableHeader, { visibleColumns: visibleColumns, selectable: selectable, rowActions: rowActions, data: data, selectedRows: selectedRows, handleSelectAll: handleSelectAll, sortConfig: sortConfig, handleSort: handleSort, headerRenderer: headerRenderer, multiRowHeader: multiRowHeader }) }), _jsx("tbody", { children: _jsx(TableBody, { sortedData: sortedData, visibleColumns: visibleColumns, emptyMessage: emptyMessage, selectable: selectable, rowActions: rowActions, selectedRows: selectedRows, handleSelectRow: handleSelectRow, handleRowClick: handleRowClick, handleCellClick: handleCellClick, rowClassName: rowClassName, rowKey: rowKey, rowsPerItem: rowsPerItem, cellRenderer: cellRenderer, rowsPerPage: rowsPerPage }) })] }) }));
|
|
252
261
|
};
|
|
253
262
|
export default DataTable;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import VPanel from "../../layouts/VPanel";
|
|
2
|
+
import { VPanel } from "../../layouts/VPanel";
|
|
3
3
|
import { renderListDef } from "../../lib/utils/SectionProvider";
|
|
4
4
|
const FilterView = (props) => {
|
|
5
5
|
const { items = [] } = props !== null && props !== void 0 ? props : {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { localAPI } from "@ramesesinc/lib/local-api";
|
|
3
|
-
import React, { useEffect, useMemo, useState } from "react";
|
|
4
|
-
import { useApp } from "../../core/AppContext";
|
|
5
2
|
import { DynamicComponent } from "../../core/DynamicComponent";
|
|
3
|
+
import { useApp } from "../../core/AppContext";
|
|
6
4
|
import useDependHandler from "../../core/UIDependHandler";
|
|
5
|
+
import { localAPI } from "@ramesesinc/lib/local-api";
|
|
6
|
+
import { useEffect, useMemo, useState } from "react";
|
|
7
7
|
import UIComponent from "../common/UIComponent";
|
|
8
|
+
import React from "react";
|
|
8
9
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
9
10
|
// Attr Parser
|
|
10
11
|
// Handles both strict JSON {"key":"value"} and JS object literals {key: "value"}
|
|
@@ -18,9 +19,7 @@ function parseAttr(attrStr) {
|
|
|
18
19
|
catch (_a) {
|
|
19
20
|
try {
|
|
20
21
|
// eslint-disable-next-line no-new-func
|
|
21
|
-
|
|
22
|
-
const normalized = attrStr.replace(/([{,]\s*)([a-zA-Z_$][a-zA-Z0-9_$]*)(\s*:)/g, '$1"$2"$3').replace(/'([^'\\]*(\\.[^'\\]*)*)'/g, '"$1"');
|
|
23
|
-
return JSON.parse(normalized);
|
|
22
|
+
return new Function(`"use strict"; return (${attrStr})`)();
|
|
24
23
|
}
|
|
25
24
|
catch (_b) {
|
|
26
25
|
console.warn("HtmlForm: could not parse attr →", attrStr);
|
|
@@ -60,7 +59,9 @@ function domAttrsToProps(el) {
|
|
|
60
59
|
if (["component", "attr"].includes(attr.name))
|
|
61
60
|
continue;
|
|
62
61
|
const reactName = (_a = ATTR_MAP[attr.name]) !== null && _a !== void 0 ? _a : attr.name;
|
|
63
|
-
props[reactName] = attr.name === "style"
|
|
62
|
+
props[reactName] = attr.name === "style"
|
|
63
|
+
? styleStringToObject(attr.value)
|
|
64
|
+
: attr.value;
|
|
64
65
|
}
|
|
65
66
|
return props;
|
|
66
67
|
}
|
|
@@ -94,14 +95,16 @@ function walkNode(node, parentTag) {
|
|
|
94
95
|
if (tag === "span" && componentName) {
|
|
95
96
|
const attr = parseAttr(el.getAttribute("attr"));
|
|
96
97
|
const config = { component: componentName, attr };
|
|
97
|
-
return _jsx(DynamicComponent, { config: config }, nextKey());
|
|
98
|
+
return (_jsx(DynamicComponent, { config: config }, nextKey()));
|
|
98
99
|
}
|
|
99
100
|
// ── Regular element → recurse ──────────────────────────────────────────
|
|
100
101
|
const props = Object.assign(Object.assign({}, domAttrsToProps(el)), { key: nextKey() });
|
|
101
102
|
const children = Array.from(el.childNodes)
|
|
102
103
|
.map((child) => walkNode(child, tag)) // pass current tag as parentTag
|
|
103
104
|
.filter((n) => n !== null && n !== undefined);
|
|
104
|
-
return children.length > 0
|
|
105
|
+
return children.length > 0
|
|
106
|
+
? React.createElement(tag, props, ...children)
|
|
107
|
+
: React.createElement(tag, props);
|
|
105
108
|
}
|
|
106
109
|
return null;
|
|
107
110
|
}
|
|
@@ -81,6 +81,6 @@ const Html = (props) => {
|
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
useDependHandler({ name: depends, onRefresh });
|
|
84
|
-
return (_jsx(UIComponent, Object.assign({}, (props !== null && props !== void 0 ? props : {}), { children: _jsx("div", { className: "
|
|
84
|
+
return (_jsx(UIComponent, Object.assign({}, (props !== null && props !== void 0 ? props : {}), { children: _jsx("div", { className: "", dangerouslySetInnerHTML: { __html: renderedHtml } }) })));
|
|
85
85
|
};
|
|
86
86
|
export default Html;
|
|
@@ -4,6 +4,7 @@ interface PageViewProps extends UIComponentProps {
|
|
|
4
4
|
depends?: string;
|
|
5
5
|
url?: string;
|
|
6
6
|
fallback?: React.ReactNode;
|
|
7
|
+
options?: Record<string, any>;
|
|
7
8
|
}
|
|
8
9
|
declare const PageView: React.MemoExoticComponent<(props: PageViewProps) => import("react/jsx-runtime").JSX.Element>;
|
|
9
10
|
export default PageView;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createElement as _createElement } from "react";
|
|
3
3
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
-
import { forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
4
|
+
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
5
5
|
import Page from "../../core/Page";
|
|
6
6
|
import { usePageContext } from "../../core/PageContext";
|
|
7
7
|
import { PageViewProvider, usePageViewContext } from "../../core/PageViewContext";
|
|
8
8
|
import useDependHandler from "../../core/UIDependHandler";
|
|
9
|
-
import { useUrlParams } from "../../hooks/useUrlParams";
|
|
10
9
|
import UIComponent from "../common/UIComponent";
|
|
11
10
|
const StableShell = memo((props) => {
|
|
12
11
|
const { uiProps, slotRef, handle, paths } = props !== null && props !== void 0 ? props : {};
|
|
13
12
|
return (_jsx(UIComponent, Object.assign({}, uiProps, { children: _jsx(PageViewProvider, { handle: handle, paths: paths !== null && paths !== void 0 ? paths : [], children: _jsx(PageSlot, { ref: slotRef }) }) })));
|
|
14
13
|
});
|
|
15
14
|
const PageView = memo((props) => {
|
|
16
|
-
const { name = "selectedPage", depends, url } = props !== null && props !== void 0 ? props : {};
|
|
15
|
+
const { name = "selectedPage", depends, url, options = {} } = props !== null && props !== void 0 ? props : {};
|
|
17
16
|
const [forceUpdate, setForceUpdate] = useState({});
|
|
18
17
|
const providerRef = useRef({});
|
|
19
|
-
const { setAnchorPath } = useUrlParams();
|
|
20
18
|
const slotRef = useRef(null);
|
|
21
19
|
const pageContext = usePageContext();
|
|
22
|
-
const [ownPaths, setOwnPaths] = useState([]);
|
|
23
20
|
const isEmpty = (value) => value == null || value.trim() === "";
|
|
24
21
|
const pageView = usePageViewContext();
|
|
22
|
+
const [ownPaths, setOwnPaths] = useState([]);
|
|
23
|
+
const pathsRef = useRef([]);
|
|
25
24
|
let preferredName = isEmpty(name) ? depends : name;
|
|
26
25
|
let preferredDepends = isEmpty(depends) ? preferredName : depends;
|
|
27
|
-
const newProps =
|
|
26
|
+
// const newProps = { ...props, name: preferredName, depends: preferredDepends };
|
|
27
|
+
const newProps = useMemo(() => (Object.assign(Object.assign({}, props), { name: preferredName, depends: preferredDepends })), [props, preferredName, preferredDepends]);
|
|
28
28
|
const propsRef = useRef(newProps);
|
|
29
29
|
useEffect(() => {
|
|
30
30
|
propsRef.current = newProps;
|
|
@@ -40,6 +40,32 @@ const PageView = memo((props) => {
|
|
|
40
40
|
useEffect(() => {
|
|
41
41
|
getUrlRef.current = getUrl;
|
|
42
42
|
});
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
var _a;
|
|
45
|
+
let paths = [];
|
|
46
|
+
let firstPath = null;
|
|
47
|
+
if (url == null) {
|
|
48
|
+
const value = pageContext.get(preferredName !== null && preferredName !== void 0 ? preferredName : "");
|
|
49
|
+
if (value == null) {
|
|
50
|
+
// only use subPaths if this pageView is directly under root
|
|
51
|
+
if (pageView.isRootView()) {
|
|
52
|
+
paths = (_a = pageView.getSubPaths()) !== null && _a !== void 0 ? _a : [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
paths = String(value).split("#");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
paths = String(url).split("#");
|
|
61
|
+
}
|
|
62
|
+
[firstPath] = paths;
|
|
63
|
+
if (firstPath == null || firstPath.trim() === "")
|
|
64
|
+
return;
|
|
65
|
+
pathsRef.current = paths;
|
|
66
|
+
setOwnPaths([firstPath]); // ← track own paths
|
|
67
|
+
pageViewHandleRef.current.renderPage(firstPath);
|
|
68
|
+
}, []);
|
|
43
69
|
// Stable handle — never recreated
|
|
44
70
|
const pageViewHandleRef = useRef({
|
|
45
71
|
displayName: "PageView#pageViewHandle",
|
|
@@ -55,15 +81,15 @@ const PageView = memo((props) => {
|
|
|
55
81
|
}
|
|
56
82
|
setOwnPaths([page]); // ← track own paths
|
|
57
83
|
const key = "page-" + Math.random().toString(36).slice(2);
|
|
58
|
-
const comp = _createElement(Page, Object.assign({}, propsRef.current, { url: page, key: key }));
|
|
84
|
+
const comp = _createElement(Page, Object.assign({}, propsRef.current, { url: page, key: key, options: options }));
|
|
59
85
|
(_b = slotRef.current) === null || _b === void 0 ? void 0 : _b.update(comp, page);
|
|
60
86
|
},
|
|
61
87
|
isStandalone: () => {
|
|
62
88
|
return pageView == null ? true : pageView.isStandalone();
|
|
63
89
|
},
|
|
64
90
|
});
|
|
65
|
-
const onRefresh = (
|
|
66
|
-
setForceUpdate({
|
|
91
|
+
const onRefresh = () => {
|
|
92
|
+
setForceUpdate({});
|
|
67
93
|
};
|
|
68
94
|
useDependHandler({ name: newProps.depends, onRefresh });
|
|
69
95
|
useEffect(() => {
|
|
@@ -71,10 +97,11 @@ const PageView = memo((props) => {
|
|
|
71
97
|
if (prov == null || typeof prov.setPage !== "function")
|
|
72
98
|
return;
|
|
73
99
|
const url = getUrlRef.current();
|
|
74
|
-
// console.log("pageView forceUpdate", url, providerRef.current);
|
|
75
100
|
providerRef.current.setPage(url);
|
|
76
101
|
}, [forceUpdate]);
|
|
77
|
-
return _jsx(StableShell, { uiProps: newProps, handle: pageViewHandleRef.current, slotRef: slotRef,
|
|
102
|
+
return (_jsx(StableShell, { uiProps: newProps, handle: pageViewHandleRef.current, slotRef: slotRef,
|
|
103
|
+
// paths={pathsRef.current}
|
|
104
|
+
paths: ownPaths }));
|
|
78
105
|
});
|
|
79
106
|
const PageSlot = memo(forwardRef((_, ref) => {
|
|
80
107
|
const [content, setContent] = useState(null);
|
|
@@ -7,7 +7,7 @@ import Page from "../../core/Page";
|
|
|
7
7
|
import { PageViewProvider } from "../../core/PageViewContext";
|
|
8
8
|
import { usePopupManager } from "../../core/PopupContext";
|
|
9
9
|
const PopupView = (props) => {
|
|
10
|
-
const { url, popupClassName, onClose = () => { }, eventHandler, title } = props !== null && props !== void 0 ? props : {};
|
|
10
|
+
const { url, popupClassName, onClose = () => { }, eventHandler, title, options = {} } = props !== null && props !== void 0 ? props : {};
|
|
11
11
|
const [paths, setPaths] = useState([]);
|
|
12
12
|
const providerRef = useRef({});
|
|
13
13
|
const slotRef = useRef(null);
|
|
@@ -22,7 +22,7 @@ const PopupView = (props) => {
|
|
|
22
22
|
let comp = null;
|
|
23
23
|
try {
|
|
24
24
|
const key = "page-" + Math.random().toString(36).slice(2);
|
|
25
|
-
comp = _jsx(Page, { url: path }, key);
|
|
25
|
+
comp = _jsx(Page, { url: path, options: options }, key);
|
|
26
26
|
}
|
|
27
27
|
catch (error) {
|
|
28
28
|
const e = getError(error);
|
|
@@ -79,9 +79,9 @@ const ChildrenSlot = memo(forwardRef((_, ref) => {
|
|
|
79
79
|
export const usePopupView = () => {
|
|
80
80
|
const popupManager = usePopupManager();
|
|
81
81
|
const create = (props) => {
|
|
82
|
-
const { url, onClose, eventHandler, title } = props !== null && props !== void 0 ? props : {};
|
|
82
|
+
const { url, onClose, eventHandler, title, options: optionProps = {} } = props !== null && props !== void 0 ? props : {};
|
|
83
83
|
const show = (options) => {
|
|
84
|
-
const content = _jsx(PopupView, { url: url, onClose: onClose, eventHandler: eventHandler });
|
|
84
|
+
const content = _jsx(PopupView, { url: url, onClose: onClose, eventHandler: eventHandler, options: optionProps });
|
|
85
85
|
const popup = popupManager.create(options);
|
|
86
86
|
popup.setContent(content);
|
|
87
87
|
popup.show();
|