@pagamio/frontend-commons-lib 0.8.358 → 0.8.360

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.
@@ -11,6 +11,12 @@ import { Popover, PopoverContent, PopoverTrigger } from './Popover';
11
11
  // =============================================================================
12
12
  // PRESET DEFINITIONS (used for display text + preset detection)
13
13
  // =============================================================================
14
+ // "All Time" is intentionally not in PRESET_RANGES because it has no concrete
15
+ // date range — it represents the absence of a date filter. It is surfaced in
16
+ // the trigger label and the picker treats `selectedPreset === 'all_time'` as
17
+ // "no value", letting consumers pass empty startDate/endDate to the backend.
18
+ const ALL_TIME_PRESET_VALUE = 'all_time';
19
+ const ALL_TIME_PRESET_LABEL = 'All Time';
14
20
  const PRESET_RANGES = [
15
21
  {
16
22
  label: 'Today',
@@ -113,6 +119,9 @@ const DateRangePickerWithPresets = ({ value, onChange, selectedPreset = 'last_7_
113
119
  }
114
120
  return format(value.from, dateFormat);
115
121
  }
122
+ if (selectedPreset === ALL_TIME_PRESET_VALUE) {
123
+ return ALL_TIME_PRESET_LABEL;
124
+ }
116
125
  if (selectedPreset && selectedPreset !== 'custom') {
117
126
  const match = PRESET_RANGES.find((p) => p.value === selectedPreset);
118
127
  if (match)
@@ -139,7 +148,9 @@ const DateRangePickerWithPresets = ({ value, onChange, selectedPreset = 'last_7_
139
148
  e.stopPropagation();
140
149
  onChange?.(undefined, undefined);
141
150
  };
142
- return (_jsxs(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", disabled: disabled, className: cn('w-auto justify-start text-left font-normal', !value && 'text-muted-foreground', className), children: [_jsx(CalendarIcon, { className: "mr-2 h-4 w-4" }), _jsx("span", { children: displayText }), showClearButton && value?.from && (_jsx(X, { className: "ml-2 h-4 w-4 opacity-50 hover:opacity-100 cursor-pointer", onClick: handleClear }))] }) }), _jsx(PopoverContent, { className: "w-auto p-0 bg-popover text-popover-foreground border border-border shadow-lg", align: "start", sideOffset: 8, children: _jsx(DateRangePicker, { ranges: [selectionRange], onChange: handleRangeChange, moveRangeOnFirstSelection: false, months: numberOfMonths, direction: "horizontal", showDateDisplay: false, showPreview: true, minDate: minDate, maxDate: maxDate, rangeColors: rangeColors, staticRanges: staticRanges, inputRanges: [] }) })] }));
151
+ return (_jsxs(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", disabled: disabled, className: cn('w-auto justify-start text-left font-normal', !value && 'text-muted-foreground', className), children: [_jsx(CalendarIcon, { className: "mr-2 h-4 w-4" }), _jsx("span", { children: displayText }), showClearButton && value?.from && (_jsx(X, { className: "ml-2 h-4 w-4 opacity-50 hover:opacity-100 cursor-pointer", onClick: handleClear }))] }) }), _jsxs(PopoverContent, { className: "w-auto p-0 bg-popover text-popover-foreground border border-border shadow-lg", align: "start", sideOffset: 8, children: [_jsx("button", { type: "button", onClick: () => onChange?.(undefined, ALL_TIME_PRESET_VALUE), className: cn('w-full border-b border-border px-4 py-3 text-left text-sm transition-colors hover:bg-accent hover:text-accent-foreground', selectedPreset === ALL_TIME_PRESET_VALUE && !value?.from
152
+ ? 'bg-accent font-semibold text-accent-foreground'
153
+ : 'text-popover-foreground'), children: ALL_TIME_PRESET_LABEL }), _jsx(DateRangePicker, { ranges: [selectionRange], onChange: handleRangeChange, moveRangeOnFirstSelection: false, months: numberOfMonths, direction: "horizontal", showDateDisplay: false, showPreview: true, minDate: minDate, maxDate: maxDate, rangeColors: rangeColors, staticRanges: staticRanges, inputRanges: [] })] })] }));
143
154
  };
144
155
  DateRangePickerWithPresets.displayName = 'DateRangePickerWithPresets';
145
156
  export default DateRangePickerWithPresets;
@@ -80,7 +80,7 @@ const ChartRenderer = ({ config, loading }) => {
80
80
  case 'heatmap': {
81
81
  // Heatmap expects series: { name, data: { x, y }[] }[]
82
82
  const data = config.data;
83
- return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(HeatmapChartV2, { series: data.series, height: chartHeight, colors: chartColors, className: config.chartClassName }) }));
83
+ return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, actions: config.action, footer: config.footer, className: config.cardClassName, children: _jsx(HeatmapChartV2, { series: data.series, height: chartHeight, colors: chartColors, options: config.options, className: config.chartClassName }) }));
84
84
  }
85
85
  default:
86
86
  return (_jsx(DashboardCard, { title: config.title, subtitle: config.subtitle, className: config.cardClassName, children: _jsxs("div", { className: "flex items-center justify-center text-muted-foreground", style: { height: chartHeight }, children: ["Unsupported chart type: ", config.type] }) }));
@@ -1,3 +1,3 @@
1
1
  import type { PagamioTableProps } from './types';
2
- declare const PagamioTable: <T extends Record<string, any>>({ columns, data, isLoading, isFetching, rowCount, sorting, pagination, filtering, search, onRowClick, rowClassName, expandable, renderDetailPanel, toolbar, toolbarMode, enableColumnResizing, enableColumnPinning, enableColumnOrdering, enableColumnFilters, enableHiding, enableRowSelection, enableRowActions, enableRowVirtualization, enableGrouping, enableEditing, enableDensityToggle, enableFullScreenToggle, enableClickToCopy, enableRowNumbers, enableMultiSort, enableStickyHeader, enableStickyFooter, editDisplayMode, onEditingRowSave, onEditingRowCancel, renderRowActions, renderRowActionMenuItems, positionActionsColumn, renderTopToolbarCustomActions, renderBottomToolbarCustomActions, layoutMode, defaultColumn, mantineTableOptions, }: PagamioTableProps<T>) => import("react/jsx-runtime").JSX.Element;
2
+ declare const PagamioTable: <T extends Record<string, any>>({ columns, data, isLoading, isFetching, rowCount, sorting, pagination, filtering, search, onRowClick, rowClassName, expandable, renderDetailPanel, toolbar, toolbarMode, fetchAllData, enableColumnResizing, enableColumnPinning, enableColumnOrdering, enableColumnFilters, enableHiding, enableRowSelection, enableRowActions, enableRowVirtualization, enableGrouping, enableEditing, enableDensityToggle, enableFullScreenToggle, enableClickToCopy, enableRowNumbers, enableMultiSort, enableStickyHeader, enableStickyFooter, editDisplayMode, onEditingRowSave, onEditingRowCancel, renderRowActions, renderRowActionMenuItems, positionActionsColumn, renderTopToolbarCustomActions, renderBottomToolbarCustomActions, layoutMode, defaultColumn, mantineTableOptions, }: PagamioTableProps<T>) => import("react/jsx-runtime").JSX.Element;
3
3
  export default PagamioTable;
@@ -101,7 +101,7 @@ function CustomToolbar({ filters, appliedFilters, onFilterChange, onApply, onCle
101
101
  (typeof addButton === 'boolean' ? (_jsx(IconButton, { onClick: onAdd ?? (() => { }), icon: HiPlusSm, label: "add-new-entry", className: cn('items-center text-nowrap', isNarrow ? 'w-full' : undefined), children: addText ?? 'Add New Entry' })) : (addButton))] }) }));
102
102
  }
103
103
  // ─── PagamioTable Component ──────────────────────────────────────────
104
- const PagamioTable = ({ columns, data, isLoading = false, isFetching = false, rowCount, sorting, pagination, filtering, search, onRowClick, rowClassName, expandable = false, renderDetailPanel, toolbar, toolbarMode = 'custom', enableColumnResizing, enableColumnPinning, enableColumnOrdering, enableColumnFilters, enableHiding, enableRowSelection, enableRowActions, enableRowVirtualization, enableGrouping, enableEditing, enableDensityToggle, enableFullScreenToggle, enableClickToCopy, enableRowNumbers, enableMultiSort, enableStickyHeader, enableStickyFooter, editDisplayMode, onEditingRowSave, onEditingRowCancel, renderRowActions, renderRowActionMenuItems, positionActionsColumn, renderTopToolbarCustomActions, renderBottomToolbarCustomActions, layoutMode, defaultColumn, mantineTableOptions, }) => {
104
+ const PagamioTable = ({ columns, data, isLoading = false, isFetching = false, rowCount, sorting, pagination, filtering, search, onRowClick, rowClassName, expandable = false, renderDetailPanel, toolbar, toolbarMode = 'custom', fetchAllData, enableColumnResizing, enableColumnPinning, enableColumnOrdering, enableColumnFilters, enableHiding, enableRowSelection, enableRowActions, enableRowVirtualization, enableGrouping, enableEditing, enableDensityToggle, enableFullScreenToggle, enableClickToCopy, enableRowNumbers, enableMultiSort, enableStickyHeader, enableStickyFooter, editDisplayMode, onEditingRowSave, onEditingRowCancel, renderRowActions, renderRowActionMenuItems, positionActionsColumn, renderTopToolbarCustomActions, renderBottomToolbarCustomActions, layoutMode, defaultColumn, mantineTableOptions, }) => {
105
105
  const [expanded, setExpanded] = useState({});
106
106
  const tableRef = useRef(null);
107
107
  // ── Internal max-height ─────────────────────────────────────────────
@@ -332,6 +332,14 @@ const PagamioTable = ({ columns, data, isLoading = false, isFetching = false, ro
332
332
  });
333
333
  // ── Toolbar rendering ──────────────────────────────────────────────
334
334
  const showCustomToolbar = toolbarMode === 'custom' && (!!toolbar || !!search || !!filtering);
335
- return (_jsxs("div", { children: [showCustomToolbar && (_jsx(CustomToolbar, { filters: toolbar?.filters ?? [], appliedFilters: filtering?.appliedFilters ?? {}, onFilterChange: filtering?.onFilterChange ?? (() => { }), onApply: filtering?.onApply ?? (() => { }), onClearFilters: toolbar?.onClearFilters, showClearFilters: toolbar?.showClearFilters ?? false, showApplyFilterButton: toolbar?.showApplyFilterButton ?? true, searchEnabled: !!search, searchQuery: search?.query ?? '', onSearch: search?.onChange ?? (() => { }), searchPlaceholder: search?.placeholder, exportConfig: toolbar?.export, columns: columns, data: data, addButton: toolbar?.addButton, addText: toolbar?.addText, onAdd: toolbar?.onAdd })), _jsx("div", { ref: tableRef, className: "border border-border rounded-md overflow-y-hidden", children: _jsx(MantineReactTable, { table: table }) })] }));
335
+ return (_jsxs("div", { children: [showCustomToolbar && (_jsx(CustomToolbar, { filters: toolbar?.filters ?? [], appliedFilters: filtering?.appliedFilters ?? {}, onFilterChange: filtering?.onFilterChange ?? (() => { }), onApply: filtering?.onApply ?? (() => { }), onClearFilters: toolbar?.onClearFilters, showClearFilters: toolbar?.showClearFilters ?? false, showApplyFilterButton: toolbar?.showApplyFilterButton ?? true, searchEnabled: !!search, searchQuery: search?.query ?? '', onSearch: search?.onChange ?? (() => { }), searchPlaceholder: search?.placeholder, exportConfig: toolbar?.export
336
+ ? {
337
+ ...toolbar.export,
338
+ // Fall back to the hook's top-level fetcher when a consumer's
339
+ // toolbar override didn't carry one — keeps "Export all data"
340
+ // working even when `toolbar` is replaced wholesale.
341
+ fetchAllData: toolbar.export.fetchAllData ?? fetchAllData,
342
+ }
343
+ : undefined, columns: columns, data: data, addButton: toolbar?.addButton, addText: toolbar?.addText, onAdd: toolbar?.onAdd })), _jsx("div", { ref: tableRef, className: "border border-border rounded-md overflow-y-hidden", children: _jsx(MantineReactTable, { table: table }) })] }));
336
344
  };
337
345
  export default PagamioTable;
@@ -172,6 +172,17 @@ export interface PagamioTableProps<T extends Record<string, any>> {
172
172
  }) => ReactNode;
173
173
  toolbar?: ToolbarConfig<T>;
174
174
  toolbarMode?: 'custom' | 'mrt' | 'none';
175
+ /**
176
+ * Server-side "export all" fetcher, auto-wired by `usePagamioTable` as a
177
+ * TOP-LEVEL prop (not just inside `toolbar.export`). Consumers spread
178
+ * `{...tableProps}` but frequently pass their own `toolbar={{...}}` for
179
+ * add-buttons/filters, which would otherwise drop the hook's
180
+ * `toolbar.export.fetchAllData` and silently break "Export all data".
181
+ * PagamioTable falls back to this when `toolbar.export.fetchAllData` is unset,
182
+ * so export-all keeps working regardless of a toolbar override. A consumer
183
+ * can still override by setting `toolbar.export.fetchAllData` explicitly.
184
+ */
185
+ fetchAllData?: (params?: Record<string, string>, onProgress?: (fetched: number, total: number) => void) => Promise<T[]>;
175
186
  enableColumnResizing?: boolean;
176
187
  enableColumnPinning?: boolean;
177
188
  enableColumnOrdering?: boolean;
@@ -327,6 +327,10 @@ export const usePagamioTable = ({ queryKey, queryFn, enabled: queryEnabled = tru
327
327
  isLoading,
328
328
  isFetching,
329
329
  rowCount: totalItems,
330
+ // Top-level so it survives a consumer's `toolbar={{...}}` override.
331
+ // PagamioTable falls back to this for export-all. Only for server mode
332
+ // (client tables already hold the whole set).
333
+ ...(isServerMode && { fetchAllData: fetchAllPages }),
330
334
  ...(paginationConfig.enabled && {
331
335
  pagination: {
332
336
  pageIndex: currentPage,
package/lib/styles.css CHANGED
@@ -3936,6 +3936,84 @@ video {
3936
3936
  width: auto !important;
3937
3937
  min-width: 0 !important;
3938
3938
  }
3939
+
3940
+ /* react-date-range ships a light-only theme. Re-skin its surfaces with our
3941
+ * popover / muted / border tokens so the date-range picker matches dark mode.
3942
+ * Selection highlight stays untouched — the component already drives that
3943
+ * via the `rangeColors` prop pulled from `--primary` at runtime.
3944
+ */
3945
+ .dark .rdrCalendarWrapper,
3946
+ .dark .rdrDateRangeWrapper,
3947
+ .dark .rdrDefinedRangesWrapper {
3948
+ background: hsl(var(--popover)) !important;
3949
+ color: hsl(var(--popover-foreground)) !important;
3950
+ }
3951
+ .dark .rdrDefinedRangesWrapper {
3952
+ border-right: 1px solid hsl(var(--border)) !important;
3953
+ }
3954
+ .dark .rdrStaticRanges {
3955
+ background: transparent !important;
3956
+ }
3957
+ .dark .rdrStaticRange {
3958
+ background: transparent !important;
3959
+ border-bottom: 1px solid hsl(var(--border)) !important;
3960
+ }
3961
+ .dark .rdrStaticRange:hover .rdrStaticRangeLabel,
3962
+ .dark .rdrStaticRange:focus .rdrStaticRangeLabel {
3963
+ background: hsl(var(--accent)) !important;
3964
+ color: hsl(var(--accent-foreground)) !important;
3965
+ }
3966
+ .dark .rdrStaticRangeLabel {
3967
+ color: hsl(var(--popover-foreground)) !important;
3968
+ }
3969
+ .dark .rdrStaticRangeSelected .rdrStaticRangeLabel {
3970
+ color: hsl(var(--primary)) !important;
3971
+ font-weight: 600;
3972
+ }
3973
+ .dark .rdrMonthAndYearWrapper,
3974
+ .dark .rdrMonth {
3975
+ background: transparent !important;
3976
+ color: hsl(var(--popover-foreground)) !important;
3977
+ }
3978
+ .dark .rdrMonthName,
3979
+ .dark .rdrWeekDay {
3980
+ color: hsl(var(--muted-foreground)) !important;
3981
+ }
3982
+ .dark .rdrMonthAndYearPickers select {
3983
+ color: hsl(var(--popover-foreground)) !important;
3984
+ background-color: transparent !important;
3985
+ }
3986
+ .dark .rdrMonthAndYearPickers select:hover {
3987
+ background-color: hsl(var(--accent)) !important;
3988
+ }
3989
+ .dark .rdrNextPrevButton {
3990
+ background: hsl(var(--muted)) !important;
3991
+ }
3992
+ .dark .rdrNextPrevButton:hover {
3993
+ background: hsl(var(--accent)) !important;
3994
+ }
3995
+ .dark .rdrPprevButton i {
3996
+ border-color: transparent hsl(var(--popover-foreground)) transparent transparent !important;
3997
+ }
3998
+ .dark .rdrNextButton i {
3999
+ border-color: transparent transparent transparent hsl(var(--popover-foreground)) !important;
4000
+ }
4001
+ .dark .rdrDayNumber span {
4002
+ color: hsl(var(--popover-foreground)) !important;
4003
+ }
4004
+ .dark .rdrDayPassive .rdrDayNumber span {
4005
+ color: hsl(var(--muted-foreground)) !important;
4006
+ }
4007
+ .dark .rdrDayDisabled {
4008
+ background: transparent !important;
4009
+ }
4010
+ .dark .rdrDayDisabled .rdrDayNumber span {
4011
+ color: hsl(var(--muted-foreground)) !important;
4012
+ opacity: 0.5;
4013
+ }
4014
+ .dark .rdrDayToday .rdrDayNumber span:after {
4015
+ background: hsl(var(--primary)) !important;
4016
+ }
3939
4017
  .file\:-ms-4::file-selector-button {
3940
4018
  margin-inline-start: -1rem;
3941
4019
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pagamio/frontend-commons-lib",
3
3
  "description": "Pagamio library for Frontend reusable components like the form engine and table container",
4
- "version": "0.8.358",
4
+ "version": "0.8.360",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": false