@pallasoft/ps-table-components 1.28.3 → 1.29.0
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/ps-data-table.js +52 -50
- package/dist/components/ps-report-table-skeleton.d.ts +10 -0
- package/dist/components/ps-report-table-skeleton.js +29 -0
- package/dist/components/ps-report-table.d.ts +28 -0
- package/dist/components/ps-report-table.js +45 -0
- package/dist/constants/ps-report-column-align.d.ts +6 -0
- package/dist/constants/ps-report-column-align.js +8 -0
- package/dist/constants/ps-report-row-kind.d.ts +7 -0
- package/dist/constants/ps-report-row-kind.js +9 -0
- package/dist/constants/ps-report-row-tone.d.ts +7 -0
- package/dist/constants/ps-report-row-tone.js +9 -0
- package/dist/constants/ps-report-table-classes.d.ts +52 -0
- package/dist/constants/ps-report-table-classes.js +59 -0
- package/dist/constants/ps-report-table-config.d.ts +9 -0
- package/dist/constants/ps-report-table-config.js +9 -0
- package/dist/constants/ps-report-table-density.d.ts +5 -0
- package/dist/constants/ps-report-table-density.js +7 -0
- package/dist/constants/ps-table-sticky-config.d.ts +1 -1
- package/dist/constants/ps-table-sticky-config.js +1 -1
- package/dist/esm/components/ps-data-table.js +52 -50
- package/dist/esm/components/ps-report-table-skeleton.js +25 -0
- package/dist/esm/components/ps-report-table.js +41 -0
- package/dist/esm/constants/ps-report-column-align.js +5 -0
- package/dist/esm/constants/ps-report-row-kind.js +6 -0
- package/dist/esm/constants/ps-report-row-tone.js +6 -0
- package/dist/esm/constants/ps-report-table-classes.js +56 -0
- package/dist/esm/constants/ps-report-table-config.js +6 -0
- package/dist/esm/constants/ps-report-table-density.js +4 -0
- package/dist/esm/constants/ps-table-sticky-config.js +1 -1
- package/dist/esm/hooks/use-ps-sticky-head.js +34 -22
- package/dist/esm/index.js +8 -0
- package/dist/esm/interfaces/ps-report-cell-plan.js +1 -0
- package/dist/esm/interfaces/ps-report-column.js +1 -0
- package/dist/esm/interfaces/ps-table-sticky-head-inputs.js +1 -0
- package/dist/esm/services/ps-report-table-service.js +67 -0
- package/dist/esm/services/ps-table-sticky-head-service.js +11 -3
- package/dist/hooks/use-ps-sticky-head.d.ts +1 -1
- package/dist/hooks/use-ps-sticky-head.js +33 -21
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/interfaces/ps-report-cell-plan.d.ts +6 -0
- package/dist/interfaces/ps-report-cell-plan.js +2 -0
- package/dist/interfaces/ps-report-column.d.ts +12 -0
- package/dist/interfaces/ps-report-column.js +2 -0
- package/dist/interfaces/ps-sticky-head-refs.d.ts +1 -1
- package/dist/interfaces/ps-table-sticky-head-inputs.d.ts +7 -0
- package/dist/interfaces/ps-table-sticky-head-inputs.js +2 -0
- package/dist/services/ps-report-table-service.d.ts +17 -0
- package/dist/services/ps-report-table-service.js +71 -0
- package/dist/services/ps-table-sticky-head-service.d.ts +3 -1
- package/dist/services/ps-table-sticky-head-service.js +11 -3
- package/package.json +1 -1
|
@@ -99,8 +99,8 @@ const PsDataTable = ({ caption, className, clearSelectionKey, columns, cursorPag
|
|
|
99
99
|
const [openedGroupKeys, setOpenedGroupKeys] = (0, react_1.useState)([]);
|
|
100
100
|
const [seenClearKey, setSeenClearKey] = (0, react_1.useState)(clearSelectionKey);
|
|
101
101
|
const stickyRegionRef = (0, react_1.useRef)(null);
|
|
102
|
-
const stickySentinelRef = (0, react_1.useRef)(null);
|
|
103
102
|
const stickyCardRef = (0, react_1.useRef)(null);
|
|
103
|
+
const stickyContentRef = (0, react_1.useRef)(null);
|
|
104
104
|
const stickyHeadRef = (0, react_1.useRef)(null);
|
|
105
105
|
const currentQuery = query ? query : uncontrolledQuery;
|
|
106
106
|
if (seenClearKey !== clearSelectionKey) {
|
|
@@ -129,12 +129,12 @@ const PsDataTable = ({ caption, className, clearSelectionKey, columns, cursorPag
|
|
|
129
129
|
const pins = ps_table_pin_service_1.PsTablePinService.leading(pinFirstColumn, Boolean(reorder), isSelectable);
|
|
130
130
|
const placementOf = (column, columnIndex) => ps_design_system_1.PallasoftClassNameService.merge(column.hideBelow === undefined ? '' : table_breakpoint_1.PsTableHideBelowClasses[column.hideBelow], columnIndex === 0 ? pins.first : '', ps_table_pin_service_1.PsTablePinService.end(column.pinEnd === true));
|
|
131
131
|
const overflow = (0, use_ps_table_overflow_1.usePsTableOverflow)(`${visibleColumns.map((column) => column.id).join(',')}:${rows.length}`);
|
|
132
|
-
|
|
132
|
+
(0, use_ps_sticky_head_1.usePsStickyHead)({
|
|
133
133
|
cardRef: stickyCardRef,
|
|
134
|
+
contentRef: stickyContentRef,
|
|
134
135
|
headRef: stickyHeadRef,
|
|
135
136
|
layoutKey: `${visibleColumns.map((column) => column.id).join(',')}:${rows.length}:${isLoading}`,
|
|
136
137
|
regionRef: stickyRegionRef,
|
|
137
|
-
sentinelRef: stickySentinelRef,
|
|
138
138
|
stickyTop,
|
|
139
139
|
});
|
|
140
140
|
const deferredSearch = (0, react_1.useDeferredValue)(search);
|
|
@@ -397,52 +397,54 @@ const PsDataTable = ({ caption, className, clearSelectionKey, columns, cursorPag
|
|
|
397
397
|
updateQuery({ search: next });
|
|
398
398
|
resetPage();
|
|
399
399
|
}, rows: rows, search: search, searchPlaceholder: searchPlaceholder })) : null, banner] }));
|
|
400
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: ps_design_system_1.PallasoftClassNameService.merge('flex min-w-0 flex-col gap-3', className), children: [stickyTop === undefined ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [stickyLeading, topContent] })) : ((0, jsx_runtime_1.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
400
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: ps_design_system_1.PallasoftClassNameService.merge('flex min-w-0 flex-col gap-3', className), children: [stickyTop === undefined ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [stickyLeading, topContent] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('sticky z-sticky flex flex-col gap-3', stickyClassName), ref: stickyRegionRef, style: { top: stickyTop }, children: [stickyLeading, topContent] }) })), (0, jsx_runtime_1.jsx)("div", { className: 'min-w-0 overflow-clip rounded-[1.25rem]', children: (0, jsx_runtime_1.jsx)("div", { "aria-busy": isRefreshing, className: 'min-w-0 overflow-hidden rounded-[1.25rem] border border-line bg-surface', ref: stickyCardRef, children: (0, jsx_runtime_1.jsxs)("div", { ref: stickyContentRef, children: [showsPagination &&
|
|
401
|
+
paginationPosition !== ps_table_pagination_position_1.PsTablePaginationPosition.bottom &&
|
|
402
|
+
rowCount > ps_table_pagination_config_1.PsTablePaginationConfig.topMinRows
|
|
403
|
+
? renderPagination('border-b border-t-0')
|
|
404
|
+
: null, mobileLayout === 'cards' ? ((0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('sm:hidden', isRefreshing ? ps_table_body_classes_1.PsTableBodyClasses.refreshing : ''), children: [reorder && reorder.cardsReason ? ((0, jsx_runtime_1.jsx)("p", { className: 'border-b border-line px-4 py-2 text-xs text-ink/55', children: reorder.cardsReason })) : null, grouping
|
|
405
|
+
? groups.map((group, groupIndex) => {
|
|
406
|
+
const isExpanded = isGroupExpanded(group.key, groupIndex);
|
|
407
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: 'border-b border-line last:border-b-0', children: [(0, jsx_runtime_1.jsx)(ps_table_group_header_1.PsTableGroupHeader, { count: group.rows.length, isExpanded: isExpanded, label: grouping.getGroupLabel(group.key, group.rows), onToggle: () => toggleGroup(group.key, isExpanded), summary: grouping.renderGroupSummary
|
|
408
|
+
? grouping.renderGroupSummary(group.rows)
|
|
409
|
+
: undefined }), (0, jsx_runtime_1.jsx)(ps_motion_components_1.PsCollapse, { isOpen: isExpanded && !closingGroupKeys.includes(group.key), children: renderCardList(group.rows, null) })] }, `group-${group.key}`));
|
|
410
|
+
})
|
|
411
|
+
: renderCardList(shouldVirtualize ? visibleRows.slice(0, cards.count) : visibleRows, visibleRows.length === 0 && isSearching ? ((0, jsx_runtime_1.jsx)(ps_table_searching_state_1.PsTableSearchingState, { label: searchingLabel, skeletonRows: table_config_1.PsTableConfig.searchingSkeletonRows })) : visibleRows.length === 0 && isQueried ? ((0, jsx_runtime_1.jsxs)("div", { className: 'px-4 py-10 text-center', children: [(0, jsx_runtime_1.jsx)("p", { className: 'text-sm font-semibold text-ink', children: table_config_1.PsTableConfig.noMatchesTitle }), (0, jsx_runtime_1.jsx)("button", { className: ps_design_system_1.PallasoftClassNameService.merge(ps_table_control_classes_1.PsTableControlClasses.textButton, 'mt-2 text-primary'), onClick: clearFilters, type: 'button', children: "Clear search and filters" })] })) : null), !grouping && shouldVirtualize && cards.count < visibleRows.length ? ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": 'true', className: 'h-px', ref: cards.sentinelRef })) : null] })) : null, (0, jsx_runtime_1.jsx)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('ps-scrollbar overflow-x-auto overflow-y-hidden overscroll-x-contain', isRefreshing ? ps_table_body_classes_1.PsTableBodyClasses.refreshing : '', mobileLayout === 'cards' ? 'hidden sm:block' : ''), "data-overflow-end": overflow.edges.end, "data-overflow-start": overflow.edges.start, onScroll: overflow.update, ref: overflow.ref, children: renderReorder((api) => ((0, jsx_runtime_1.jsxs)("table", { className: ps_design_system_1.PallasoftClassNameService.merge('w-full border-collapse text-left', layout === 'fixed' ? 'table-fixed' : ''), children: [caption ? (0, jsx_runtime_1.jsx)("caption", { className: 'sr-only', children: caption }) : null, (0, jsx_runtime_1.jsx)("thead", { className: ps_design_system_1.PallasoftClassNameService.merge('bg-mist/70 text-[0.68rem] font-semibold uppercase tracking-[0.18em] text-ink/45', stickyTop === undefined
|
|
412
|
+
? ''
|
|
413
|
+
: 'relative z-docked bg-surface will-change-transform [&_th]:border-b [&_th]:border-line [&>tr]:bg-mist/70'), ref: stickyHeadRef, children: (0, jsx_runtime_1.jsxs)("tr", { children: [reorder ? ((0, jsx_runtime_1.jsx)("th", { className: ps_design_system_1.PallasoftClassNameService.merge('w-9 min-w-9 pl-3 pr-0', pins.reorder), scope: 'col', children: reorder.enabled ? ((0, jsx_runtime_1.jsx)("span", { className: 'sr-only', children: reorder.columnLabel })) : reorder.disabledReason ? ((0, jsx_runtime_1.jsx)("span", { "aria-label": reorder.disabledReason, className: 'inline-flex cursor-help opacity-40', role: 'img', title: reorder.disabledReason, children: (0, jsx_runtime_1.jsx)(ps_core_components_1.PsDragGrip, {}) })) : null })) : null, isSelectable ? ((0, jsx_runtime_1.jsx)("th", { className: ps_design_system_1.PallasoftClassNameService.merge('w-10 min-w-10 pl-4 pr-0', pins.select), scope: 'col', children: (0, jsx_runtime_1.jsx)(ps_input_components_1.PsCheckbox, { isIndeterminate: !isPageSelected && pageIds.some((rowId) => selectedIdSet.has(rowId)), isSelected: isPageSelected, label: 'Select all rows on this page', onChange: togglePage }) })) : null, visibleColumns.map((column, columnIndex) => {
|
|
414
|
+
const align = column.align !== null && column.align !== undefined
|
|
415
|
+
? column.align
|
|
416
|
+
: 'left';
|
|
417
|
+
const isSorted = sort !== null && sort.columnId === column.id;
|
|
418
|
+
return ((0, jsx_runtime_1.jsx)("th", { "aria-sort": isSorted
|
|
419
|
+
? sort.direction
|
|
420
|
+
: column.sortValue && isQueryable
|
|
421
|
+
? 'none'
|
|
422
|
+
: undefined, className: ps_design_system_1.PallasoftClassNameService.merge(densityClassNames[density].head, alignClassNames[align], placementOf(column, columnIndex), 'whitespace-nowrap'), scope: 'col', style: columnStyle(column, fittedWidths.get(column.id)), children: column.sortValue && isQueryable ? ((0, jsx_runtime_1.jsx)(ps_table_sort_header_1.PsTableSortHeader, { align: align, columnId: column.id, label: column.label, onSort: updateSort, sort: sort })) : (column.label) }, column.id));
|
|
423
|
+
})] }) }), (0, jsx_runtime_1.jsxs)("tbody", { className: 'divide-y divide-line', ref: bodyRef, children: [visibleRows.length === 0 && isSearching ? ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { className: 'p-0', colSpan: columnCount, children: (0, jsx_runtime_1.jsx)(ps_table_searching_state_1.PsTableSearchingState, { label: searchingLabel, skeletonRows: table_config_1.PsTableConfig.searchingSkeletonRows }) }) })) : null, visibleRows.length === 0 && isQueried && !isSearching ? ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsxs)("td", { className: 'px-4 py-12 text-center', colSpan: columnCount, children: [(0, jsx_runtime_1.jsx)("p", { className: 'text-sm font-semibold text-ink', children: table_config_1.PsTableConfig.noMatchesTitle }), (0, jsx_runtime_1.jsx)("p", { className: 'mt-1 text-sm text-ink/55', children: table_config_1.PsTableConfig.noMatchesDescription }), (0, jsx_runtime_1.jsx)("button", { className: ps_design_system_1.PallasoftClassNameService.merge(ps_table_control_classes_1.PsTableControlClasses.textButton, 'mt-3 text-primary hover:underline'), onClick: clearFilters, type: 'button', children: "Clear search and filters" })] }) })) : null, grouping
|
|
424
|
+
? groups.map((group, groupIndex) => {
|
|
425
|
+
const isExpanded = isGroupExpanded(group.key, groupIndex);
|
|
426
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { className: 'p-0', colSpan: columnCount, children: (0, jsx_runtime_1.jsx)(ps_table_group_header_1.PsTableGroupHeader, { count: group.rows.length, isExpanded: isExpanded, label: grouping.getGroupLabel(group.key, group.rows), onToggle: () => toggleGroup(group.key, isExpanded), summary: grouping.renderGroupSummary
|
|
427
|
+
? grouping.renderGroupSummary(group.rows)
|
|
428
|
+
: undefined }) }) }), isExpanded
|
|
429
|
+
? renderEntries(api, group.rows.map((row, rowIndex) => ({
|
|
430
|
+
motion: groupRowMotion(group.key, rowIndex),
|
|
431
|
+
row,
|
|
432
|
+
})))
|
|
433
|
+
: null] }, `group-${group.key}`));
|
|
434
|
+
})
|
|
435
|
+
: shouldVirtualize
|
|
436
|
+
? [
|
|
437
|
+
(0, jsx_runtime_1.jsx)("tr", { "aria-hidden": 'true', children: (0, jsx_runtime_1.jsx)("td", { className: 'p-0', colSpan: columnCount, style: { height: virtualTop } }) }, 'virtual-top'),
|
|
438
|
+
...renderEntries(api, virtualItems.map((item) => ({
|
|
439
|
+
row: visibleRows[item.index],
|
|
440
|
+
virtualItem: item,
|
|
441
|
+
}))),
|
|
442
|
+
(0, jsx_runtime_1.jsx)("tr", { "aria-hidden": 'true', children: (0, jsx_runtime_1.jsx)("td", { className: 'p-0', colSpan: columnCount, style: { height: virtualBottom } }) }, 'virtual-bottom'),
|
|
443
|
+
]
|
|
444
|
+
: renderEntries(api, visibleRows.map((row) => ({ row })))] }), hasFooter ? ((0, jsx_runtime_1.jsx)("tfoot", { className: 'border-t-2 border-line bg-mist/50 text-sm font-semibold text-ink', children: (0, jsx_runtime_1.jsxs)("tr", { children: [reorder ? (0, jsx_runtime_1.jsx)("td", { className: pins.reorder }) : null, isSelectable ? (0, jsx_runtime_1.jsx)("td", { className: pins.select }) : null, visibleColumns.map((column, columnIndex) => ((0, jsx_runtime_1.jsx)("td", { className: ps_design_system_1.PallasoftClassNameService.merge(densityClassNames[density].cell, placementOf(column, columnIndex), alignClassNames[column.align !== null && column.align !== undefined
|
|
445
|
+
? column.align
|
|
446
|
+
: 'left'], 'whitespace-nowrap'), children: column.footer }, column.id)))] }) })) : null] }))) }), visibleRows.length > 0 && isSearching ? ((0, jsx_runtime_1.jsx)(ps_table_searching_state_1.PsTableSearchingState, { className: 'border-t border-line py-3', label: searchingLabel })) : null, showsPagination && paginationPosition !== ps_table_pagination_position_1.PsTablePaginationPosition.top
|
|
447
|
+
? renderPagination('')
|
|
448
|
+
: null] }) }) })] }));
|
|
447
449
|
};
|
|
448
450
|
exports.PsDataTable = PsDataTable;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PsReportTableDensity } from '../constants/ps-report-table-density';
|
|
2
|
+
import type { PsReportColumn } from '../interfaces/ps-report-column';
|
|
3
|
+
export interface PsReportTableSkeletonProps<RowData> {
|
|
4
|
+
className?: string;
|
|
5
|
+
columns: PsReportColumn<RowData>[];
|
|
6
|
+
density?: PsReportTableDensity;
|
|
7
|
+
isFramed?: boolean;
|
|
8
|
+
rows?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const PsReportTableSkeleton: <RowData>({ className, columns, density, isFramed, rows, }: PsReportTableSkeletonProps<RowData>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsReportTableSkeleton = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ps_core_components_1 = require("@pallasoft/ps-core-components");
|
|
6
|
+
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
7
|
+
const ps_report_column_align_1 = require("../constants/ps-report-column-align");
|
|
8
|
+
const ps_report_table_classes_1 = require("../constants/ps-report-table-classes");
|
|
9
|
+
const ps_report_table_config_1 = require("../constants/ps-report-table-config");
|
|
10
|
+
const ps_report_table_density_1 = require("../constants/ps-report-table-density");
|
|
11
|
+
const ps_report_table_service_1 = require("../services/ps-report-table-service");
|
|
12
|
+
const PsReportTableSkeleton = ({ className, columns, density = ps_report_table_density_1.PsReportTableDensity.normal, isFramed = true, rows = ps_report_table_config_1.PsReportTableConfig.skeletonRows, }) => {
|
|
13
|
+
const isEnd = (column) => ps_report_table_service_1.PsReportTableService.alignOf(column) === ps_report_column_align_1.PsReportColumnAlign.right;
|
|
14
|
+
const headClass = (column, index) => {
|
|
15
|
+
if (isEnd(column))
|
|
16
|
+
return ps_report_table_classes_1.PsReportTableClasses.skeleton.headEnd;
|
|
17
|
+
return index === 0
|
|
18
|
+
? ps_report_table_classes_1.PsReportTableClasses.skeleton.headFirst
|
|
19
|
+
: ps_report_table_classes_1.PsReportTableClasses.skeleton.headOther;
|
|
20
|
+
};
|
|
21
|
+
const cellClass = (column, rowIndex, index) => isEnd(column)
|
|
22
|
+
? ps_report_table_classes_1.PsReportTableClasses.skeleton.cellEnd
|
|
23
|
+
: ps_report_table_classes_1.PsReportTableClasses.skeleton.cellWidths[(rowIndex + index) % ps_report_table_classes_1.PsReportTableClasses.skeleton.cellWidths.length];
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(ps_core_components_1.PsSkeletonGroup, { className: ps_design_system_1.PallasoftClassNameService.merge(isFramed ? ps_report_table_classes_1.PsReportTableClasses.frame : ps_report_table_classes_1.PsReportTableClasses.skeleton.plain, className), children: (0, jsx_runtime_1.jsxs)("table", { className: ps_report_table_classes_1.PsReportTableClasses.table, children: [(0, jsx_runtime_1.jsx)("thead", { className: ps_report_table_classes_1.PsReportTableClasses.head, children: (0, jsx_runtime_1.jsx)("tr", { children: columns.map((column, index) => ((0, jsx_runtime_1.jsx)("th", { className: ps_report_table_classes_1.PsReportTableClasses.headCell[density], style: ps_report_table_service_1.PsReportTableService.indent(0, density), children: (0, jsx_runtime_1.jsx)(ps_core_components_1.PsSkeleton, { className: headClass(column, index) }) }, column.id))) }) }), (0, jsx_runtime_1.jsx)("tbody", { className: ps_report_table_classes_1.PsReportTableClasses.body, children: Array.from({ length: rows }, (_, rowIndex) => ((0, jsx_runtime_1.jsx)("tr", { children: columns.map((column, index) => ((0, jsx_runtime_1.jsx)("td", { className: ps_report_table_classes_1.PsReportTableClasses.cell[density], style: {
|
|
25
|
+
...ps_report_table_service_1.PsReportTableService.columnStyle(column),
|
|
26
|
+
...ps_report_table_service_1.PsReportTableService.indent(0, density),
|
|
27
|
+
}, children: (0, jsx_runtime_1.jsx)(ps_core_components_1.PsSkeleton, { className: cellClass(column, rowIndex, index) }) }, column.id))) }, rowIndex))) })] }) }));
|
|
28
|
+
};
|
|
29
|
+
exports.PsReportTableSkeleton = PsReportTableSkeleton;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { PsReportRowKind } from '../constants/ps-report-row-kind';
|
|
3
|
+
import { PsReportRowTone } from '../constants/ps-report-row-tone';
|
|
4
|
+
import { PsReportTableDensity } from '../constants/ps-report-table-density';
|
|
5
|
+
import type { PsReportColumn } from '../interfaces/ps-report-column';
|
|
6
|
+
export interface PsReportTableProps<RowData> {
|
|
7
|
+
caption: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
columns: PsReportColumn<RowData>[];
|
|
10
|
+
density?: PsReportTableDensity;
|
|
11
|
+
emptyState?: ReactNode;
|
|
12
|
+
getLeadSpan?: (row: RowData) => number;
|
|
13
|
+
getRowId: (row: RowData) => string;
|
|
14
|
+
getRowKind?: (row: RowData) => PsReportRowKind;
|
|
15
|
+
getRowLevel?: (row: RowData) => number;
|
|
16
|
+
getRowTone?: (row: RowData) => PsReportRowTone;
|
|
17
|
+
isFirstColumnSticky?: boolean;
|
|
18
|
+
isFramed?: boolean;
|
|
19
|
+
isHeaderHidden?: boolean;
|
|
20
|
+
isHeaderSticky?: boolean;
|
|
21
|
+
isLoading?: boolean;
|
|
22
|
+
isRefreshing?: boolean;
|
|
23
|
+
maxHeight?: string;
|
|
24
|
+
minWidth?: string;
|
|
25
|
+
renderLead?: (row: RowData) => ReactNode;
|
|
26
|
+
rows: RowData[];
|
|
27
|
+
}
|
|
28
|
+
export declare const PsReportTable: <RowData>({ caption, className, columns, density, emptyState, getLeadSpan, getRowId, getRowKind, getRowLevel, getRowTone, isFirstColumnSticky, isFramed, isHeaderHidden, isHeaderSticky, isLoading, isRefreshing, maxHeight, minWidth, renderLead, rows, }: PsReportTableProps<RowData>) => import("react").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsReportTable = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
6
|
+
const ps_report_row_kind_1 = require("../constants/ps-report-row-kind");
|
|
7
|
+
const ps_report_row_tone_1 = require("../constants/ps-report-row-tone");
|
|
8
|
+
const ps_report_table_classes_1 = require("../constants/ps-report-table-classes");
|
|
9
|
+
const ps_report_table_config_1 = require("../constants/ps-report-table-config");
|
|
10
|
+
const ps_report_table_density_1 = require("../constants/ps-report-table-density");
|
|
11
|
+
const use_ps_table_overflow_1 = require("../hooks/use-ps-table-overflow");
|
|
12
|
+
const ps_report_table_service_1 = require("../services/ps-report-table-service");
|
|
13
|
+
const ps_report_table_skeleton_1 = require("./ps-report-table-skeleton");
|
|
14
|
+
const PsReportTable = ({ caption, className, columns, density = ps_report_table_density_1.PsReportTableDensity.normal, emptyState, getLeadSpan, getRowId, getRowKind, getRowLevel, getRowTone, isFirstColumnSticky = false, isFramed = true, isHeaderHidden = false, isHeaderSticky = false, isLoading = false, isRefreshing = false, maxHeight, minWidth, renderLead, rows, }) => {
|
|
15
|
+
const overflow = (0, use_ps_table_overflow_1.usePsTableOverflow)(String(rows.length));
|
|
16
|
+
if (isLoading)
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(ps_report_table_skeleton_1.PsReportTableSkeleton, { className: className, columns: columns, density: density, isFramed: isFramed }));
|
|
18
|
+
const kindOf = (row) => getRowKind !== undefined ? getRowKind(row) : ps_report_row_kind_1.PsReportRowKind.data;
|
|
19
|
+
const toneOf = (row) => getRowTone !== undefined ? getRowTone(row) : ps_report_row_tone_1.PsReportRowTone.neutral;
|
|
20
|
+
const levelOf = (row) => ps_report_table_service_1.PsReportTableService.levelOf(getRowLevel !== undefined ? getRowLevel(row) : undefined);
|
|
21
|
+
const leadOf = (row) => (getLeadSpan !== undefined ? getLeadSpan(row) : 1);
|
|
22
|
+
const renderRow = (row) => {
|
|
23
|
+
const kind = kindOf(row);
|
|
24
|
+
const tone = toneOf(row);
|
|
25
|
+
const level = levelOf(row);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)("tr", { className: ps_report_table_classes_1.PsReportTableClasses.kind[kind], children: ps_report_table_service_1.PsReportTableService.cells(columns, leadOf(row)).map((plan) => {
|
|
27
|
+
const className = ps_design_system_1.PallasoftClassNameService.merge(ps_report_table_service_1.PsReportTableService.cellClass(plan.column, plan.index, density, tone, isFirstColumnSticky), plan.index === 0 ? ps_report_table_classes_1.PsReportTableClasses.rowHeader : '');
|
|
28
|
+
const style = {
|
|
29
|
+
...ps_report_table_service_1.PsReportTableService.columnStyle(plan.column),
|
|
30
|
+
...(plan.index === 0 ? ps_report_table_service_1.PsReportTableService.indent(level, density) : {}),
|
|
31
|
+
};
|
|
32
|
+
return plan.index === 0 ? ((0, jsx_runtime_1.jsx)("th", { className: className, colSpan: plan.colSpan, scope: kind === ps_report_row_kind_1.PsReportRowKind.group && plan.colSpan === columns.length
|
|
33
|
+
? 'colgroup'
|
|
34
|
+
: 'row', style: style, children: plan.colSpan > 1 && renderLead !== undefined
|
|
35
|
+
? renderLead(row)
|
|
36
|
+
: plan.column.render(row) }, plan.column.id)) : ((0, jsx_runtime_1.jsx)("td", { className: className, colSpan: plan.colSpan, style: style, children: plan.column.render(row) }, plan.column.id));
|
|
37
|
+
}) }, getRowId(row)));
|
|
38
|
+
};
|
|
39
|
+
const content = ((0, jsx_runtime_1.jsx)("div", { className: ps_design_system_1.PallasoftClassNameService.merge(ps_report_table_classes_1.PsReportTableClasses.scroll, maxHeight !== undefined ? ps_report_table_classes_1.PsReportTableClasses.scrollBounded : '', isRefreshing ? ps_report_table_classes_1.PsReportTableClasses.refreshing : ''), "data-overflow-end": overflow.edges.end, "data-overflow-start": overflow.edges.start, onScroll: overflow.update, ref: overflow.ref, style: { maxHeight }, children: (0, jsx_runtime_1.jsxs)("table", { className: ps_report_table_classes_1.PsReportTableClasses.table, style: { minWidth }, children: [(0, jsx_runtime_1.jsx)("caption", { className: ps_report_table_classes_1.PsReportTableClasses.caption, children: caption }), (0, jsx_runtime_1.jsx)("thead", { className: ps_design_system_1.PallasoftClassNameService.merge(ps_report_table_classes_1.PsReportTableClasses.head, isHeaderHidden ? ps_report_table_classes_1.PsReportTableClasses.headHidden : ''), children: (0, jsx_runtime_1.jsx)("tr", { children: columns.map((column, index) => ((0, jsx_runtime_1.jsx)("th", { className: ps_report_table_service_1.PsReportTableService.headClass(column, index, density, isHeaderSticky, isFirstColumnSticky), scope: 'col', style: {
|
|
40
|
+
...ps_report_table_service_1.PsReportTableService.columnStyle(column),
|
|
41
|
+
...ps_report_table_service_1.PsReportTableService.indent(0, density),
|
|
42
|
+
}, children: column.label }, column.id))) }) }), (0, jsx_runtime_1.jsx)("tbody", { className: ps_report_table_classes_1.PsReportTableClasses.body, children: rows.length === 0 ? ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { className: ps_report_table_classes_1.PsReportTableClasses.empty, colSpan: columns.length, children: emptyState !== undefined ? emptyState : ps_report_table_config_1.PsReportTableConfig.emptyLabel }) })) : (rows.map(renderRow)) })] }) }));
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)("div", { "aria-busy": isRefreshing, className: ps_design_system_1.PallasoftClassNameService.merge(isFramed ? ps_report_table_classes_1.PsReportTableClasses.frame : ps_report_table_classes_1.PsReportTableClasses.framePlain, className), children: content }));
|
|
44
|
+
};
|
|
45
|
+
exports.PsReportTable = PsReportTable;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const PsReportTableClasses: {
|
|
2
|
+
readonly align: {
|
|
3
|
+
readonly center: "text-center";
|
|
4
|
+
readonly left: "text-left";
|
|
5
|
+
readonly right: "text-right tabular-nums";
|
|
6
|
+
};
|
|
7
|
+
readonly body: "divide-y divide-line/60";
|
|
8
|
+
readonly caption: "sr-only";
|
|
9
|
+
readonly cell: {
|
|
10
|
+
readonly compact: "py-1.5 pr-3 text-[0.8125rem] leading-5";
|
|
11
|
+
readonly normal: "py-3 pr-5 text-sm";
|
|
12
|
+
};
|
|
13
|
+
readonly empty: "px-4 py-10 text-center text-sm text-ink/55";
|
|
14
|
+
readonly framePlain: "min-w-0";
|
|
15
|
+
readonly frame: "min-w-0 overflow-hidden rounded-[1.25rem] border border-line bg-surface";
|
|
16
|
+
readonly head: "bg-mist/70 text-[0.68rem] font-semibold uppercase tracking-[0.18em] text-ink/45";
|
|
17
|
+
readonly headCell: {
|
|
18
|
+
readonly compact: "py-2 pr-3 whitespace-nowrap";
|
|
19
|
+
readonly normal: "py-3.5 pr-5 whitespace-nowrap";
|
|
20
|
+
};
|
|
21
|
+
readonly headHidden: "sr-only";
|
|
22
|
+
readonly kind: {
|
|
23
|
+
readonly data: "text-ink";
|
|
24
|
+
readonly group: "bg-mist/40 font-semibold text-ink [--ps-table-pin-fill:inset_0_0_0_100vmax_rgb(var(--ps-color-mist-rgb)/0.4)]";
|
|
25
|
+
readonly subtotal: "border-t border-line font-semibold text-ink";
|
|
26
|
+
readonly total: "border-t-2 border-line bg-mist/50 font-semibold text-ink [--ps-table-pin-fill:inset_0_0_0_100vmax_rgb(var(--ps-color-mist-rgb)/0.5)]";
|
|
27
|
+
};
|
|
28
|
+
readonly nowrap: "whitespace-nowrap";
|
|
29
|
+
readonly refreshing: "opacity-60";
|
|
30
|
+
readonly rowHeader: "[font-weight:inherit]";
|
|
31
|
+
readonly scroll: "ps-scrollbar overflow-x-auto overscroll-x-contain";
|
|
32
|
+
readonly scrollBounded: "overflow-y-auto overscroll-contain";
|
|
33
|
+
readonly skeleton: {
|
|
34
|
+
readonly cellEnd: "ml-auto w-16";
|
|
35
|
+
readonly cellWidths: readonly ["w-3/4", "w-1/2"];
|
|
36
|
+
readonly headEnd: "ml-auto h-2.5 w-12";
|
|
37
|
+
readonly headFirst: "h-2.5 w-20";
|
|
38
|
+
readonly headOther: "h-2.5 w-14";
|
|
39
|
+
readonly plain: "min-w-0 overflow-hidden";
|
|
40
|
+
};
|
|
41
|
+
readonly stickyFirstBody: "ps-table-pin left-0";
|
|
42
|
+
readonly stickyFirstHead: "ps-table-pin left-0 top-0 z-[3]";
|
|
43
|
+
readonly stickyHead: "ps-table-pin top-0 z-[2]";
|
|
44
|
+
readonly table: "w-full border-collapse text-left";
|
|
45
|
+
readonly tone: {
|
|
46
|
+
readonly danger: "bg-danger-soft/60 text-danger [--ps-table-pin-fill:inset_0_0_0_100vmax_rgb(var(--ps-color-danger-soft-rgb)/0.6)]";
|
|
47
|
+
readonly muted: "text-ink/60";
|
|
48
|
+
readonly neutral: "";
|
|
49
|
+
readonly primary: "bg-primary/10 text-primary [--ps-table-pin-fill:inset_0_0_0_100vmax_rgb(var(--ps-color-primary-rgb)/0.1)]";
|
|
50
|
+
};
|
|
51
|
+
readonly truncate: "truncate";
|
|
52
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsReportTableClasses = void 0;
|
|
4
|
+
const ps_report_column_align_1 = require("./ps-report-column-align");
|
|
5
|
+
const ps_report_row_kind_1 = require("./ps-report-row-kind");
|
|
6
|
+
const ps_report_row_tone_1 = require("./ps-report-row-tone");
|
|
7
|
+
const ps_report_table_density_1 = require("./ps-report-table-density");
|
|
8
|
+
exports.PsReportTableClasses = {
|
|
9
|
+
align: {
|
|
10
|
+
[ps_report_column_align_1.PsReportColumnAlign.center]: 'text-center',
|
|
11
|
+
[ps_report_column_align_1.PsReportColumnAlign.left]: 'text-left',
|
|
12
|
+
[ps_report_column_align_1.PsReportColumnAlign.right]: 'text-right tabular-nums',
|
|
13
|
+
},
|
|
14
|
+
body: 'divide-y divide-line/60',
|
|
15
|
+
caption: 'sr-only',
|
|
16
|
+
cell: {
|
|
17
|
+
[ps_report_table_density_1.PsReportTableDensity.compact]: 'py-1.5 pr-3 text-[0.8125rem] leading-5',
|
|
18
|
+
[ps_report_table_density_1.PsReportTableDensity.normal]: 'py-3 pr-5 text-sm',
|
|
19
|
+
},
|
|
20
|
+
empty: 'px-4 py-10 text-center text-sm text-ink/55',
|
|
21
|
+
framePlain: 'min-w-0',
|
|
22
|
+
frame: 'min-w-0 overflow-hidden rounded-[1.25rem] border border-line bg-surface',
|
|
23
|
+
head: 'bg-mist/70 text-[0.68rem] font-semibold uppercase tracking-[0.18em] text-ink/45',
|
|
24
|
+
headCell: {
|
|
25
|
+
[ps_report_table_density_1.PsReportTableDensity.compact]: 'py-2 pr-3 whitespace-nowrap',
|
|
26
|
+
[ps_report_table_density_1.PsReportTableDensity.normal]: 'py-3.5 pr-5 whitespace-nowrap',
|
|
27
|
+
},
|
|
28
|
+
headHidden: 'sr-only',
|
|
29
|
+
kind: {
|
|
30
|
+
[ps_report_row_kind_1.PsReportRowKind.data]: 'text-ink',
|
|
31
|
+
[ps_report_row_kind_1.PsReportRowKind.group]: 'bg-mist/40 font-semibold text-ink [--ps-table-pin-fill:inset_0_0_0_100vmax_rgb(var(--ps-color-mist-rgb)/0.4)]',
|
|
32
|
+
[ps_report_row_kind_1.PsReportRowKind.subtotal]: 'border-t border-line font-semibold text-ink',
|
|
33
|
+
[ps_report_row_kind_1.PsReportRowKind.total]: 'border-t-2 border-line bg-mist/50 font-semibold text-ink [--ps-table-pin-fill:inset_0_0_0_100vmax_rgb(var(--ps-color-mist-rgb)/0.5)]',
|
|
34
|
+
},
|
|
35
|
+
nowrap: 'whitespace-nowrap',
|
|
36
|
+
refreshing: 'opacity-60',
|
|
37
|
+
rowHeader: '[font-weight:inherit]',
|
|
38
|
+
scroll: 'ps-scrollbar overflow-x-auto overscroll-x-contain',
|
|
39
|
+
scrollBounded: 'overflow-y-auto overscroll-contain',
|
|
40
|
+
skeleton: {
|
|
41
|
+
cellEnd: 'ml-auto w-16',
|
|
42
|
+
cellWidths: ['w-3/4', 'w-1/2'],
|
|
43
|
+
headEnd: 'ml-auto h-2.5 w-12',
|
|
44
|
+
headFirst: 'h-2.5 w-20',
|
|
45
|
+
headOther: 'h-2.5 w-14',
|
|
46
|
+
plain: 'min-w-0 overflow-hidden',
|
|
47
|
+
},
|
|
48
|
+
stickyFirstBody: 'ps-table-pin left-0',
|
|
49
|
+
stickyFirstHead: 'ps-table-pin left-0 top-0 z-[3]',
|
|
50
|
+
stickyHead: 'ps-table-pin top-0 z-[2]',
|
|
51
|
+
table: 'w-full border-collapse text-left',
|
|
52
|
+
tone: {
|
|
53
|
+
[ps_report_row_tone_1.PsReportRowTone.danger]: 'bg-danger-soft/60 text-danger [--ps-table-pin-fill:inset_0_0_0_100vmax_rgb(var(--ps-color-danger-soft-rgb)/0.6)]',
|
|
54
|
+
[ps_report_row_tone_1.PsReportRowTone.muted]: 'text-ink/60',
|
|
55
|
+
[ps_report_row_tone_1.PsReportRowTone.neutral]: '',
|
|
56
|
+
[ps_report_row_tone_1.PsReportRowTone.primary]: 'bg-primary/10 text-primary [--ps-table-pin-fill:inset_0_0_0_100vmax_rgb(var(--ps-color-primary-rgb)/0.1)]',
|
|
57
|
+
},
|
|
58
|
+
truncate: 'truncate',
|
|
59
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsReportTableConfig = void 0;
|
|
4
|
+
exports.PsReportTableConfig = {
|
|
5
|
+
baseIndentRem: { compact: 0.75, normal: 1.25 },
|
|
6
|
+
emptyLabel: 'Nothing to show',
|
|
7
|
+
indentRem: 1.25,
|
|
8
|
+
skeletonRows: 6,
|
|
9
|
+
};
|