@issonujha/sdui-web 0.1.4 → 0.1.5

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.
Files changed (53) hide show
  1. package/dist/cjs/DynamicComponentLoader.js +16 -0
  2. package/dist/cjs/DynamicTabRenderer.js +10 -0
  3. package/dist/cjs/DynamicTable.js +856 -0
  4. package/dist/cjs/EndpointTable.js +57 -0
  5. package/dist/cjs/NavBar.js +14 -0
  6. package/dist/cjs/SduiWebProvider.js +25 -0
  7. package/dist/cjs/index.js +22 -0
  8. package/dist/cjs/package.json +1 -0
  9. package/dist/esm/DynamicComponentLoader.d.ts.map +1 -0
  10. package/dist/esm/DynamicComponentLoader.js.map +1 -0
  11. package/dist/esm/DynamicTabRenderer.d.ts.map +1 -0
  12. package/dist/esm/DynamicTabRenderer.js.map +1 -0
  13. package/dist/esm/DynamicTable.d.ts +48 -0
  14. package/dist/esm/DynamicTable.d.ts.map +1 -0
  15. package/dist/esm/DynamicTable.js +821 -0
  16. package/dist/esm/DynamicTable.js.map +1 -0
  17. package/dist/esm/EndpointTable.d.ts.map +1 -0
  18. package/dist/esm/EndpointTable.js.map +1 -0
  19. package/dist/esm/NavBar.d.ts.map +1 -0
  20. package/dist/esm/NavBar.js.map +1 -0
  21. package/dist/esm/SduiWebProvider.d.ts.map +1 -0
  22. package/dist/esm/SduiWebProvider.js.map +1 -0
  23. package/dist/esm/index.d.ts.map +1 -0
  24. package/dist/esm/index.js.map +1 -0
  25. package/package.json +9 -7
  26. package/dist/DynamicComponentLoader.d.ts.map +0 -1
  27. package/dist/DynamicComponentLoader.js.map +0 -1
  28. package/dist/DynamicTabRenderer.d.ts.map +0 -1
  29. package/dist/DynamicTabRenderer.js.map +0 -1
  30. package/dist/DynamicTable.d.ts +0 -26
  31. package/dist/DynamicTable.d.ts.map +0 -1
  32. package/dist/DynamicTable.js +0 -419
  33. package/dist/DynamicTable.js.map +0 -1
  34. package/dist/EndpointTable.d.ts.map +0 -1
  35. package/dist/EndpointTable.js.map +0 -1
  36. package/dist/NavBar.d.ts.map +0 -1
  37. package/dist/NavBar.js.map +0 -1
  38. package/dist/SduiWebProvider.d.ts.map +0 -1
  39. package/dist/SduiWebProvider.js.map +0 -1
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/index.js.map +0 -1
  42. /package/dist/{DynamicComponentLoader.d.ts → esm/DynamicComponentLoader.d.ts} +0 -0
  43. /package/dist/{DynamicComponentLoader.js → esm/DynamicComponentLoader.js} +0 -0
  44. /package/dist/{DynamicTabRenderer.d.ts → esm/DynamicTabRenderer.d.ts} +0 -0
  45. /package/dist/{DynamicTabRenderer.js → esm/DynamicTabRenderer.js} +0 -0
  46. /package/dist/{EndpointTable.d.ts → esm/EndpointTable.d.ts} +0 -0
  47. /package/dist/{EndpointTable.js → esm/EndpointTable.js} +0 -0
  48. /package/dist/{NavBar.d.ts → esm/NavBar.d.ts} +0 -0
  49. /package/dist/{NavBar.js → esm/NavBar.js} +0 -0
  50. /package/dist/{SduiWebProvider.d.ts → esm/SduiWebProvider.d.ts} +0 -0
  51. /package/dist/{SduiWebProvider.js → esm/SduiWebProvider.js} +0 -0
  52. /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
  53. /package/dist/{index.js → esm/index.js} +0 -0
@@ -0,0 +1,821 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useState, useMemo } from 'react';
3
+ const STAGE_PALETTES = [
4
+ { color: '#6366F1', bg: '#EEF2FF', text: '#4338CA', border: '#C7D2FE' }, // Indigo
5
+ { color: '#F59E0B', bg: '#FEF3C7', text: '#B45309', border: '#FDE68A' }, // Amber
6
+ { color: '#3B82F6', bg: '#EFF6FF', text: '#1D4ED8', border: '#BFDBFE' }, // Blue
7
+ { color: '#10B981', bg: '#D1FAE5', text: '#047857', border: '#A7F3D0' }, // Emerald
8
+ { color: '#EF4444', bg: '#FEE2E2', text: '#B91C1C', border: '#FECACA' }, // Red
9
+ { color: '#8B5CF6', bg: '#EDE9FE', text: '#6D28D9', border: '#DDD6FE' }, // Purple
10
+ { color: '#EC4899', bg: '#FCE7F3', text: '#BE185D', border: '#FBCFE8' }, // Pink
11
+ { color: '#14B8A6', bg: '#CCFBF1', text: '#0F766E', border: '#99F6E4' }, // Teal
12
+ ];
13
+ function formatStageLabel(code) {
14
+ if (!code)
15
+ return '';
16
+ return code
17
+ .replace(/[_-]+/g, ' ')
18
+ .toLowerCase()
19
+ .replace(/\b\w/g, (c) => c.toUpperCase());
20
+ }
21
+ function normalizeStageDef(raw, index = 0) {
22
+ const key = String(raw.key || raw.code || raw.id || '').toUpperCase();
23
+ const label = raw.label || raw.name || formatStageLabel(key);
24
+ const palette = STAGE_PALETTES[index % STAGE_PALETTES.length];
25
+ return {
26
+ key,
27
+ label,
28
+ color: raw.color || palette.color,
29
+ textColor: raw.textColor || palette.text,
30
+ borderColor: raw.borderColor || palette.border,
31
+ statuses: Array.isArray(raw.statuses) && raw.statuses.length > 0 ? raw.statuses : [key],
32
+ };
33
+ }
34
+ function getRowStage(row, stageKey) {
35
+ if (!row)
36
+ return '';
37
+ const r = row;
38
+ const val = (stageKey && r[stageKey]) || r.deliveryStatus || r.stageCode || r.stageName || r.status || r.stage || '';
39
+ return String(val).toUpperCase();
40
+ }
41
+ function getBadgeStyle(val) {
42
+ const s = String(val || '').toUpperCase();
43
+ if (['ACTIVE', 'APPROVED', 'SUCCESS', 'DELIVERED', 'PAID', 'COMPLETED', 'OPEN', 'TRUE'].includes(s)) {
44
+ return { bg: '#ECFDF5', text: '#065F46', border: '#A7F3D0' };
45
+ }
46
+ if (['PENDING', 'PROCESSING', 'IN_TRANSIT', 'PLACED', 'ACCEPTED', 'PACKED', 'DISPATCHED', 'WARN', 'WARNING'].includes(s)) {
47
+ return { bg: '#FFFBEB', text: '#92400E', border: '#FDE68A' };
48
+ }
49
+ if (['CANCELLED', 'REJECTED', 'FAILED', 'SUSPENDED', 'BLOCKED', 'BANNED', 'ERROR', 'FALSE'].includes(s)) {
50
+ return { bg: '#FEF2F2', text: '#991B1B', border: '#FECACA' };
51
+ }
52
+ if (['SIMULATED', 'INFO', 'SELLER', 'WEB', 'EMAIL', 'SMS', 'IN_APP'].includes(s)) {
53
+ return { bg: '#EFF6FF', text: '#1E40AF', border: '#BFDBFE' };
54
+ }
55
+ if (s.includes('OTP') || s.includes('SECURITY')) {
56
+ return { bg: '#FAF5FF', text: '#6B21A8', border: '#E9D5FF' };
57
+ }
58
+ return { bg: '#F1F5F9', text: '#334155', border: '#E2E8F0' };
59
+ }
60
+ export function DynamicTable({ data: rawData, columns: customColumns, filters: customFilters, loading = false, error = null, userRoles = [], viewMode: controlledViewMode, onViewModeChange, availableViews: propAvailableViews, kanbanStages: explicitKanbanStages, stageKey, canDragRecord = true, onTransitionStage, onPageChange, onRowsPerPageChange, onSortChange, onFilterChange, onSearchChange, onSearch, searchValue: controlledSearchValue, onRowClick, onExportCsv, onRefresh, title, subtitle, pageSizeOptions = [10, 15, 25, 50, 100], defaultRowsPerPage = 10, renderCustomCard, actions, rowActions, renderExpandedRow, activeFilters, emptyMessage, exportFilename, tableActions, extraHeaderActions, compact = false, enableExport, enableLiveReload, defaultLiveReload, showGlobalFilters, }) {
61
+ // Normalize incoming data (can be DataTableResponse or Array)
62
+ const isResponseObject = Boolean(rawData && typeof rawData === 'object' && !Array.isArray(rawData));
63
+ const normalizedData = useMemo(() => {
64
+ if (isResponseObject) {
65
+ const resp = rawData;
66
+ return {
67
+ content: Array.isArray(resp.content) ? resp.content : [],
68
+ totalElements: typeof resp.totalElements === 'number' ? resp.totalElements : (resp.content?.length || 0),
69
+ totalPages: typeof resp.totalPages === 'number' ? resp.totalPages : 1,
70
+ pageNumber: typeof resp.pageNumber === 'number' ? resp.pageNumber : 0,
71
+ pageSize: typeof resp.pageSize === 'number' ? resp.pageSize : defaultRowsPerPage,
72
+ last: typeof resp.last === 'boolean' ? resp.last : true,
73
+ columns: Array.isArray(resp.columns) ? resp.columns : [],
74
+ filters: Array.isArray(resp.filters) ? resp.filters : [],
75
+ sortBy: resp.sortBy,
76
+ sortDir: resp.sortDir,
77
+ stages: resp.stages,
78
+ enableExport: typeof enableExport === 'boolean' ? enableExport : resp.enableExport,
79
+ enableLiveReload: typeof enableLiveReload === 'boolean' ? enableLiveReload : resp.enableLiveReload,
80
+ enableColumnVisibility: resp.enableColumnVisibility,
81
+ };
82
+ }
83
+ const arr = Array.isArray(rawData) ? rawData : [];
84
+ return {
85
+ content: arr,
86
+ totalElements: arr.length,
87
+ totalPages: 1,
88
+ pageNumber: 0,
89
+ pageSize: arr.length || defaultRowsPerPage,
90
+ last: true,
91
+ columns: [],
92
+ filters: [],
93
+ enableExport: typeof enableExport === 'boolean' ? enableExport : true,
94
+ enableLiveReload: typeof enableLiveReload === 'boolean' ? enableLiveReload : true,
95
+ };
96
+ }, [rawData, isResponseObject, defaultRowsPerPage, enableExport, enableLiveReload]);
97
+ // Dynamic View Mode
98
+ const [internalViewMode, setInternalViewMode] = useState('table');
99
+ const activeView = controlledViewMode ?? internalViewMode;
100
+ const setViewMode = (mode) => {
101
+ setInternalViewMode(mode);
102
+ onViewModeChange?.(mode);
103
+ };
104
+ // Search state
105
+ const [internalSearch, setInternalSearch] = useState('');
106
+ const activeSearch = controlledSearchValue !== undefined ? controlledSearchValue : internalSearch;
107
+ const handleSearchInput = (val) => {
108
+ setInternalSearch(val);
109
+ onSearchChange?.(val);
110
+ onSearch?.(val);
111
+ };
112
+ // Filter drawer / panel state
113
+ const [filterDrawerOpen, setFilterDrawerOpen] = useState(false);
114
+ const [filterDrawerSearch, setFilterDrawerSearch] = useState('');
115
+ const [internalFilters, setInternalFilters] = useState({});
116
+ const effectiveFilters = useMemo(() => {
117
+ return activeFilters !== undefined ? activeFilters : internalFilters;
118
+ }, [activeFilters, internalFilters]);
119
+ const [hiddenColumns, setHiddenColumns] = useState(new Set());
120
+ // Columns resolution
121
+ const columns = useMemo(() => {
122
+ let base = customColumns && customColumns.length > 0
123
+ ? customColumns
124
+ : normalizedData.columns && normalizedData.columns.length > 0
125
+ ? normalizedData.columns
126
+ : [];
127
+ if (base.length === 0 && normalizedData.content.length > 0) {
128
+ const sample = normalizedData.content[0];
129
+ base = Object.keys(sample).slice(0, 8).map((k) => ({
130
+ key: k,
131
+ label: formatStageLabel(k),
132
+ type: typeof sample[k] === 'number' ? 'number' : 'text',
133
+ sortable: true,
134
+ }));
135
+ }
136
+ return base.filter((c) => !c.rolesAllowed || c.rolesAllowed.length === 0 || c.rolesAllowed.some((r) => userRoles.includes(r)));
137
+ }, [customColumns, normalizedData.columns, normalizedData.content, userRoles]);
138
+ const visibleColumns = useMemo(() => {
139
+ return columns.filter((c) => !hiddenColumns.has(c.key));
140
+ }, [columns, hiddenColumns]);
141
+ // Filters resolution
142
+ const filters = useMemo(() => {
143
+ const base = customFilters && customFilters.length > 0 ? customFilters : normalizedData.filters || [];
144
+ return base.filter((f) => !f.rolesAllowed || f.rolesAllowed.length === 0 || f.rolesAllowed.some((r) => userRoles.includes(r)));
145
+ }, [customFilters, normalizedData.filters, userRoles]);
146
+ // Dynamic Kanban Stages
147
+ const kanbanStages = useMemo(() => {
148
+ if (explicitKanbanStages && explicitKanbanStages.length > 0) {
149
+ return explicitKanbanStages.map((s, i) => normalizeStageDef(s, i));
150
+ }
151
+ if (Array.isArray(normalizedData.stages) && normalizedData.stages.length > 0) {
152
+ return normalizedData.stages.map((s, i) => normalizeStageDef(s, i));
153
+ }
154
+ // Derive dynamically from content
155
+ const stageMap = new Map();
156
+ const ordered = [];
157
+ normalizedData.content.forEach((item) => {
158
+ const key = getRowStage(item, stageKey);
159
+ if (key && !stageMap.has(key)) {
160
+ const label = item.stageName || formatStageLabel(key);
161
+ stageMap.set(key, { label });
162
+ ordered.push(key);
163
+ }
164
+ });
165
+ if (ordered.length === 0) {
166
+ return [normalizeStageDef({ key: 'DEFAULT', label: 'All Records' }, 0)];
167
+ }
168
+ return ordered.map((k, idx) => {
169
+ const info = stageMap.get(k);
170
+ return normalizeStageDef({ key: k, label: info.label }, idx);
171
+ });
172
+ }, [explicitKanbanStages, normalizedData.stages, normalizedData.content, stageKey]);
173
+ // Available Views
174
+ const availableViews = useMemo(() => {
175
+ if (propAvailableViews && propAvailableViews.length > 0) {
176
+ return propAvailableViews;
177
+ }
178
+ return ['table', 'kanban', 'cards'];
179
+ }, [propAvailableViews]);
180
+ // Drag and drop state for Kanban
181
+ const [draggedItem, setDraggedItem] = useState(null);
182
+ const [dragOverCol, setDragOverCol] = useState(null);
183
+ const isDraggable = (row) => {
184
+ if (typeof canDragRecord === 'function')
185
+ return canDragRecord(row);
186
+ return Boolean(canDragRecord);
187
+ };
188
+ const handleDragStart = (e, item) => {
189
+ setDraggedItem(item);
190
+ e.dataTransfer.setData('text/plain', String(item.id ?? ''));
191
+ e.dataTransfer.effectAllowed = 'move';
192
+ };
193
+ const handleDragOver = (e, colKey) => {
194
+ e.preventDefault();
195
+ e.dataTransfer.dropEffect = 'move';
196
+ if (dragOverCol !== colKey)
197
+ setDragOverCol(colKey);
198
+ };
199
+ const handleDrop = async (e, colKey) => {
200
+ e.preventDefault();
201
+ setDragOverCol(null);
202
+ if (!draggedItem)
203
+ return;
204
+ const currentStage = getRowStage(draggedItem, stageKey);
205
+ if (currentStage !== colKey && onTransitionStage) {
206
+ await onTransitionStage(draggedItem, colKey);
207
+ }
208
+ setDraggedItem(null);
209
+ };
210
+ // Export CSV
211
+ const handleExport = () => {
212
+ if (onExportCsv) {
213
+ onExportCsv();
214
+ return;
215
+ }
216
+ if (!normalizedData.content || normalizedData.content.length === 0)
217
+ return;
218
+ const headers = visibleColumns.map((c) => c.label || c.header || c.key);
219
+ const rows = normalizedData.content.map((row) => visibleColumns.map((c) => {
220
+ const v = typeof c.accessor === 'function'
221
+ ? c.accessor(row)
222
+ : row[c.key];
223
+ return typeof v === 'object' ? JSON.stringify(v) : String(v ?? '');
224
+ }));
225
+ const csvContent = 'data:text/csv;charset=utf-8,' +
226
+ [headers.join(','), ...rows.map((r) => r.map((cell) => `"${cell.replace(/"/g, '""')}"`).join(','))].join('\n');
227
+ const encodedUri = encodeURI(csvContent);
228
+ const link = document.createElement('a');
229
+ link.setAttribute('href', encodedUri);
230
+ link.setAttribute('download', `${exportFilename || title || 'export'}_${Date.now()}.csv`);
231
+ document.body.appendChild(link);
232
+ link.click();
233
+ document.body.removeChild(link);
234
+ };
235
+ // Active filter count
236
+ const activeFiltersCount = Object.keys(effectiveFilters).filter((k) => effectiveFilters[k] !== '' && effectiveFilters[k] !== null && effectiveFilters[k] !== undefined).length;
237
+ // Filter drawer toggle column
238
+ const toggleColumnVisibility = (key) => {
239
+ setHiddenColumns((prev) => {
240
+ const next = new Set(prev);
241
+ if (next.has(key))
242
+ next.delete(key);
243
+ else
244
+ next.add(key);
245
+ return next;
246
+ });
247
+ };
248
+ // Render cell content based on ColumnDef
249
+ const renderCellContent = (row, column) => {
250
+ if (typeof column.render === 'function') {
251
+ const cellVal = typeof column.accessor === 'function'
252
+ ? column.accessor(row)
253
+ : row[column.key];
254
+ return column.render(cellVal, row);
255
+ }
256
+ const val = typeof column.accessor === 'function'
257
+ ? column.accessor(row)
258
+ : row[column.key];
259
+ const type = String(column.type || '').toLowerCase();
260
+ const keyLower = String(column.key || '').toLowerCase();
261
+ if (val === null || val === undefined || val === '') {
262
+ return _jsx("span", { style: { color: '#94A3B8' }, children: "\u2014" });
263
+ }
264
+ if (type === 'badge' || keyLower === 'status' || keyLower === 'role' || keyLower.includes('stage')) {
265
+ const badgeStyle = getBadgeStyle(String(val));
266
+ return (_jsx("span", { style: {
267
+ display: 'inline-flex',
268
+ alignItems: 'center',
269
+ padding: '3px 9px',
270
+ borderRadius: 9999,
271
+ fontSize: '0.72rem',
272
+ fontWeight: 700,
273
+ backgroundColor: badgeStyle.bg,
274
+ color: badgeStyle.text,
275
+ border: `1px solid ${badgeStyle.border}`,
276
+ letterSpacing: '0.01em',
277
+ textTransform: 'capitalize',
278
+ }, children: String(val).replace(/_/g, ' ') }));
279
+ }
280
+ if (type === 'money' || keyLower.includes('amount') || keyLower.includes('price') || keyLower.includes('total')) {
281
+ const num = Number(val);
282
+ const symbol = column.currency === 'USD' ? '$' : '₹';
283
+ return (_jsxs("span", { style: { fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, monospace', fontWeight: 800, color: '#0F172A' }, children: [symbol, isNaN(num) ? String(val) : num.toLocaleString('en-IN')] }));
284
+ }
285
+ if (type === 'date' || keyLower.includes('date') || keyLower.includes('at') || keyLower === 'timestamp') {
286
+ const d = new Date(val);
287
+ if (!isNaN(d.getTime())) {
288
+ return (_jsx("span", { style: { fontSize: '0.78rem', color: '#475569' }, children: d.toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' }) }));
289
+ }
290
+ }
291
+ if (type === 'image' || keyLower.includes('avatar') || keyLower.includes('logo')) {
292
+ const src = String(val);
293
+ if (src.startsWith('http') || src.startsWith('/')) {
294
+ return (_jsx("img", { src: src, alt: "thumbnail", style: { width: 32, height: 32, borderRadius: 8, objectFit: 'cover', border: '1px solid #E2E8F0' } }));
295
+ }
296
+ }
297
+ return (_jsx("span", { style: { fontSize: '0.82rem', color: '#1E293B', fontWeight: 500 }, children: String(val) }));
298
+ };
299
+ return (_jsxs("div", { className: "sdui-dynamic-table-root", style: {
300
+ width: '100%',
301
+ boxSizing: 'border-box',
302
+ display: 'flex',
303
+ flexDirection: 'column',
304
+ gap: 12,
305
+ fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
306
+ }, children: [_jsxs("div", { className: "sdui-dt-header", style: {
307
+ display: 'flex',
308
+ justifyContent: 'space-between',
309
+ alignItems: 'center',
310
+ flexWrap: 'wrap',
311
+ gap: 12,
312
+ padding: '14px 18px',
313
+ background: 'var(--surface-card, #FFFFFF)',
314
+ borderRadius: 16,
315
+ border: '1px solid var(--border-subtle, #E2E8F0)',
316
+ boxShadow: '0 1px 3px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.02)',
317
+ }, children: [_jsxs("div", { style: { minWidth: 200 }, children: [title && (_jsx("h2", { style: { margin: 0, fontSize: '1.18rem', fontWeight: 800, color: 'var(--text-main, #0F172A)', letterSpacing: '-0.02em' }, children: title })), subtitle && (_jsxs("div", { style: { marginTop: 3, fontSize: '0.78rem', color: 'var(--text-muted, #64748B)', fontWeight: 500 }, children: [subtitle, normalizedData.totalElements > 0 && (_jsxs("span", { children: [" \u00B7 ", _jsx("strong", { style: { color: 'var(--color-primary, #6366F1)' }, children: normalizedData.totalElements.toLocaleString() }), " records"] }))] }))] }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap', marginLeft: 'auto' }, children: [_jsxs("div", { style: {
318
+ display: 'flex',
319
+ alignItems: 'center',
320
+ background: 'var(--surface-subtle, #F8FAFC)',
321
+ border: '1px solid var(--border-subtle, #E2E8F0)',
322
+ borderRadius: 10,
323
+ padding: '4px 10px',
324
+ gap: 6,
325
+ minWidth: 180,
326
+ }, children: [_jsx("span", { style: { fontSize: '0.82rem', color: '#94A3B8' }, children: "\uD83D\uDD0D" }), _jsx("input", { type: "text", placeholder: "Search records\u2026", value: activeSearch, onChange: (e) => handleSearchInput(e.target.value), style: {
327
+ border: 'none',
328
+ background: 'transparent',
329
+ outline: 'none',
330
+ fontSize: '0.8rem',
331
+ color: '#0F172A',
332
+ width: '100%',
333
+ } }), activeSearch && (_jsx("button", { type: "button", onClick: () => handleSearchInput(''), style: {
334
+ border: 'none',
335
+ background: 'transparent',
336
+ cursor: 'pointer',
337
+ color: '#94A3B8',
338
+ fontSize: '0.82rem',
339
+ padding: 0,
340
+ }, children: "\u2715" }))] }), availableViews.length > 1 && (_jsxs("div", { style: {
341
+ display: 'inline-flex',
342
+ background: 'var(--surface-subtle, #F8FAFC)',
343
+ border: '1px solid var(--border-subtle, #E2E8F0)',
344
+ borderRadius: 10,
345
+ padding: 3,
346
+ gap: 2,
347
+ }, children: [availableViews.includes('table') && (_jsxs("button", { type: "button", title: "Table View", onClick: () => setViewMode('table'), style: {
348
+ padding: '5px 11px',
349
+ borderRadius: 7,
350
+ border: 'none',
351
+ fontSize: '0.78rem',
352
+ fontWeight: 700,
353
+ cursor: 'pointer',
354
+ display: 'flex',
355
+ alignItems: 'center',
356
+ gap: 5,
357
+ backgroundColor: activeView === 'table' ? 'var(--surface-card, #FFFFFF)' : 'transparent',
358
+ color: activeView === 'table' ? 'var(--color-primary, #6366F1)' : '#64748B',
359
+ boxShadow: activeView === 'table' ? '0 1px 3px rgba(15, 23, 42, 0.08)' : 'none',
360
+ transition: 'all 0.15s ease',
361
+ }, children: [_jsx("span", { children: "\u2630" }), _jsx("span", { children: "Table" })] })), availableViews.includes('kanban') && (_jsxs("button", { type: "button", title: "Kanban Board", onClick: () => setViewMode('kanban'), style: {
362
+ padding: '5px 11px',
363
+ borderRadius: 7,
364
+ border: 'none',
365
+ fontSize: '0.78rem',
366
+ fontWeight: 700,
367
+ cursor: 'pointer',
368
+ display: 'flex',
369
+ alignItems: 'center',
370
+ gap: 5,
371
+ backgroundColor: activeView === 'kanban' ? 'var(--surface-card, #FFFFFF)' : 'transparent',
372
+ color: activeView === 'kanban' ? 'var(--color-primary, #6366F1)' : '#64748B',
373
+ boxShadow: activeView === 'kanban' ? '0 1px 3px rgba(15, 23, 42, 0.08)' : 'none',
374
+ transition: 'all 0.15s ease',
375
+ }, children: [_jsx("span", { children: "\u229E" }), _jsx("span", { children: "Kanban" })] })), availableViews.includes('cards') && (_jsxs("button", { type: "button", title: "Cards Grid", onClick: () => setViewMode('cards'), style: {
376
+ padding: '5px 11px',
377
+ borderRadius: 7,
378
+ border: 'none',
379
+ fontSize: '0.78rem',
380
+ fontWeight: 700,
381
+ cursor: 'pointer',
382
+ display: 'flex',
383
+ alignItems: 'center',
384
+ gap: 5,
385
+ backgroundColor: activeView === 'cards' ? 'var(--surface-card, #FFFFFF)' : 'transparent',
386
+ color: activeView === 'cards' ? 'var(--color-primary, #6366F1)' : '#64748B',
387
+ boxShadow: activeView === 'cards' ? '0 1px 3px rgba(15, 23, 42, 0.08)' : 'none',
388
+ transition: 'all 0.15s ease',
389
+ }, children: [_jsx("span", { children: "\u25A6" }), _jsx("span", { children: "Cards" })] }))] })), onRefresh && (_jsxs("button", { type: "button", onClick: onRefresh, title: "Refresh Records", style: {
390
+ padding: '6px 12px',
391
+ borderRadius: 10,
392
+ border: '1px solid var(--border-subtle, #E2E8F0)',
393
+ background: 'var(--surface-card, #FFFFFF)',
394
+ fontSize: '0.78rem',
395
+ fontWeight: 700,
396
+ color: '#475569',
397
+ cursor: 'pointer',
398
+ display: 'flex',
399
+ alignItems: 'center',
400
+ gap: 5,
401
+ }, children: [_jsx("span", { children: "\u21BB" }), _jsx("span", { children: "Refresh" })] })), normalizedData.enableExport !== false && (_jsxs("button", { type: "button", onClick: handleExport, title: "Export Records CSV", style: {
402
+ padding: '6px 12px',
403
+ borderRadius: 10,
404
+ border: '1px solid var(--border-subtle, #E2E8F0)',
405
+ background: 'var(--surface-card, #FFFFFF)',
406
+ fontSize: '0.78rem',
407
+ fontWeight: 700,
408
+ color: '#475569',
409
+ cursor: 'pointer',
410
+ display: 'flex',
411
+ alignItems: 'center',
412
+ gap: 5,
413
+ }, children: [_jsx("span", { children: "\u2B73" }), _jsx("span", { children: "Export" })] })), _jsxs("button", { type: "button", onClick: () => setFilterDrawerOpen(true), style: {
414
+ padding: '6px 14px',
415
+ borderRadius: 10,
416
+ border: `1px solid ${activeFiltersCount > 0 ? 'var(--color-primary, #6366F1)' : 'var(--border-subtle, #E2E8F0)'}`,
417
+ background: activeFiltersCount > 0 ? 'rgba(99, 102, 241, 0.08)' : 'var(--surface-card, #FFFFFF)',
418
+ color: activeFiltersCount > 0 ? 'var(--color-primary, #6366F1)' : '#0F172A',
419
+ fontSize: '0.78rem',
420
+ fontWeight: 700,
421
+ cursor: 'pointer',
422
+ display: 'flex',
423
+ alignItems: 'center',
424
+ gap: 6,
425
+ }, children: [_jsx("span", { children: "\u2699" }), _jsx("span", { children: "Filters & Columns" }), activeFiltersCount > 0 && (_jsx("span", { style: {
426
+ background: 'var(--color-primary, #6366F1)',
427
+ color: '#FFFFFF',
428
+ borderRadius: 9999,
429
+ fontSize: '0.65rem',
430
+ fontWeight: 800,
431
+ padding: '1px 6px',
432
+ }, children: activeFiltersCount }))] }), extraHeaderActions, tableActions] })] }), filterDrawerOpen && (_jsx("div", { style: {
433
+ position: 'fixed',
434
+ top: 0,
435
+ left: 0,
436
+ right: 0,
437
+ bottom: 0,
438
+ backgroundColor: 'rgba(15, 23, 42, 0.3)',
439
+ backdropFilter: 'blur(3px)',
440
+ zIndex: 9999,
441
+ display: 'flex',
442
+ justifyContent: 'flex-end',
443
+ }, onClick: () => setFilterDrawerOpen(false), children: _jsxs("div", { style: {
444
+ width: 380,
445
+ maxWidth: '90vw',
446
+ height: '100%',
447
+ backgroundColor: '#FFFFFF',
448
+ boxShadow: '-8px 0 32px rgba(15, 23, 42, 0.16)',
449
+ display: 'flex',
450
+ flexDirection: 'column',
451
+ boxSizing: 'border-box',
452
+ }, onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { style: {
453
+ padding: '16px 20px',
454
+ borderBottom: '1px solid #E2E8F0',
455
+ display: 'flex',
456
+ justifyContent: 'space-between',
457
+ alignItems: 'center',
458
+ }, children: [_jsxs("div", { children: [_jsx("h3", { style: { margin: 0, fontSize: '1rem', fontWeight: 800, color: '#0F172A' }, children: "Filters & Columns" }), _jsxs("div", { style: { fontSize: '0.74rem', color: '#64748B', marginTop: 2 }, children: [visibleColumns.length, " of ", columns.length, " columns visible"] })] }), _jsx("button", { type: "button", onClick: () => setFilterDrawerOpen(false), style: {
459
+ border: 'none',
460
+ background: 'transparent',
461
+ cursor: 'pointer',
462
+ fontSize: '1.2rem',
463
+ color: '#64748B',
464
+ }, children: "\u2715" })] }), _jsx("div", { style: { padding: '12px 20px', borderBottom: '1px solid #E2E8F0' }, children: _jsx("input", { type: "text", placeholder: "Find a column or filter\u2026", value: filterDrawerSearch, onChange: (e) => setFilterDrawerSearch(e.target.value), style: {
465
+ width: '100%',
466
+ padding: '8px 12px',
467
+ borderRadius: 8,
468
+ border: '1px solid #CBD5E1',
469
+ fontSize: '0.8rem',
470
+ outline: 'none',
471
+ boxSizing: 'border-box',
472
+ } }) }), _jsxs("div", { style: { padding: '16px 20px', flex: 1, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: 14 }, children: [_jsx("div", { style: { fontSize: '0.7rem', fontWeight: 800, color: '#94A3B8', letterSpacing: '0.06em', textTransform: 'uppercase' }, children: "Columns & Active Dimensions" }), columns
473
+ .filter((c) => !filterDrawerSearch || c.label.toLowerCase().includes(filterDrawerSearch.toLowerCase()))
474
+ .map((col) => {
475
+ const isVisible = !hiddenColumns.has(col.key);
476
+ const boundFilter = filters.find((f) => f.key === col.key || f.columnKey === col.key);
477
+ return (_jsxs("div", { style: {
478
+ padding: '10px 12px',
479
+ borderRadius: 10,
480
+ border: '1px solid #E2E8F0',
481
+ backgroundColor: isVisible ? '#FFFFFF' : '#F8FAFC',
482
+ }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs("label", { style: { display: 'flex', alignItems: 'center', gap: 8, cursor: 'pointer', fontSize: '0.82rem', fontWeight: 700, color: isVisible ? '#0F172A' : '#94A3B8' }, children: [_jsx("input", { type: "checkbox", checked: isVisible, onChange: () => toggleColumnVisibility(col.key), style: { cursor: 'pointer' } }), _jsx("span", { children: col.label })] }), _jsx("span", { style: { fontSize: '0.68rem', fontWeight: 600, color: '#94A3B8', textTransform: 'uppercase' }, children: col.type || 'text' })] }), boundFilter && isVisible && (_jsx("div", { style: { marginTop: 8, paddingTop: 8, borderTop: '1px dashed #E2E8F0' }, children: boundFilter.type === 'SELECT' ? (_jsxs("select", { value: String(effectiveFilters[boundFilter.key] || ''), onChange: (e) => {
483
+ const next = { ...effectiveFilters, [boundFilter.key]: e.target.value };
484
+ if (!e.target.value)
485
+ delete next[boundFilter.key];
486
+ setInternalFilters(next);
487
+ onFilterChange?.(next);
488
+ }, style: {
489
+ width: '100%',
490
+ padding: '6px 8px',
491
+ borderRadius: 6,
492
+ border: '1px solid #CBD5E1',
493
+ fontSize: '0.78rem',
494
+ color: '#0F172A',
495
+ backgroundColor: '#FFFFFF',
496
+ }, children: [_jsxs("option", { value: "", children: ["All ", boundFilter.label] }), (boundFilter.options || []).map((opt) => (_jsx("option", { value: String(opt.value), children: opt.label }, String(opt.value))))] })) : (_jsx("input", { type: "text", placeholder: `Filter by ${boundFilter.label}…`, value: String(effectiveFilters[boundFilter.key] || ''), onChange: (e) => {
497
+ const next = { ...effectiveFilters, [boundFilter.key]: e.target.value };
498
+ if (!e.target.value)
499
+ delete next[boundFilter.key];
500
+ setInternalFilters(next);
501
+ onFilterChange?.(next);
502
+ }, style: {
503
+ width: '100%',
504
+ padding: '6px 8px',
505
+ borderRadius: 6,
506
+ border: '1px solid #CBD5E1',
507
+ fontSize: '0.78rem',
508
+ boxSizing: 'border-box',
509
+ } })) }))] }, col.key));
510
+ })] }), _jsxs("div", { style: {
511
+ padding: '14px 20px',
512
+ borderTop: '1px solid #E2E8F0',
513
+ display: 'flex',
514
+ justifyContent: 'space-between',
515
+ alignItems: 'center',
516
+ backgroundColor: '#F8FAFC',
517
+ }, children: [_jsx("button", { type: "button", onClick: () => {
518
+ setInternalFilters({});
519
+ setHiddenColumns(new Set());
520
+ onFilterChange?.({});
521
+ }, style: {
522
+ border: 'none',
523
+ background: 'transparent',
524
+ color: '#EF4444',
525
+ fontSize: '0.78rem',
526
+ fontWeight: 700,
527
+ cursor: 'pointer',
528
+ }, children: "Clear all filters" }), _jsx("button", { type: "button", onClick: () => setFilterDrawerOpen(false), style: {
529
+ padding: '7px 18px',
530
+ borderRadius: 8,
531
+ border: 'none',
532
+ background: 'var(--color-primary, #6366F1)',
533
+ color: '#FFFFFF',
534
+ fontSize: '0.8rem',
535
+ fontWeight: 700,
536
+ cursor: 'pointer',
537
+ }, children: "Done" })] })] }) })), error && (_jsx("div", { style: {
538
+ padding: '12px 16px',
539
+ borderRadius: 12,
540
+ backgroundColor: '#FEF2F2',
541
+ border: '1px solid #FECACA',
542
+ color: '#B91C1C',
543
+ fontSize: '0.84rem',
544
+ fontWeight: 600,
545
+ }, children: error })), activeView === 'table' && (_jsx("div", { className: "sdui-dt-surface", style: {
546
+ width: '100%',
547
+ overflowX: 'auto',
548
+ background: 'var(--surface-card, #FFFFFF)',
549
+ borderRadius: 16,
550
+ border: '1px solid var(--border-subtle, #E2E8F0)',
551
+ boxShadow: '0 1px 3px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.02)',
552
+ }, children: _jsxs("table", { style: { width: '100%', borderCollapse: 'collapse', textAlign: 'left', fontSize: '0.82rem' }, children: [_jsx("thead", { children: _jsxs("tr", { style: { background: 'var(--surface-subtle, #F8FAFC)', borderBottom: '1px solid var(--border-subtle, #E2E8F0)' }, children: [visibleColumns.map((col) => {
553
+ const isSorted = normalizedData.sortBy === col.key;
554
+ const sortDir = normalizedData.sortDir?.toLowerCase();
555
+ return (_jsx("th", { style: {
556
+ padding: compact ? '8px 12px' : '12px 16px',
557
+ fontWeight: 700,
558
+ color: '#475569',
559
+ fontSize: '0.74rem',
560
+ letterSpacing: '0.04em',
561
+ textTransform: 'uppercase',
562
+ textAlign: col.align || 'left',
563
+ cursor: col.sortable !== false ? 'pointer' : 'default',
564
+ userSelect: 'none',
565
+ whiteSpace: 'nowrap',
566
+ }, onClick: () => col.sortable !== false && onSortChange?.(col.key, sortDir === 'asc' ? 'desc' : 'asc'), children: _jsxs("div", { style: { display: 'inline-flex', alignItems: 'center', gap: 6 }, children: [_jsx("span", { children: col.label || col.header || col.key }), col.sortable !== false && (_jsx("span", { style: { fontSize: '0.7rem', color: isSorted ? 'var(--color-primary, #6366F1)' : '#CBD5E1' }, children: isSorted ? (sortDir === 'desc' ? '▼' : '▲') : '⇅' }))] }) }, col.key));
567
+ }), Boolean(actions || rowActions) && (_jsx("th", { style: {
568
+ padding: compact ? '8px 12px' : '12px 16px',
569
+ fontWeight: 800,
570
+ color: '#475569',
571
+ fontSize: '0.74rem',
572
+ letterSpacing: '0.04em',
573
+ textTransform: 'uppercase',
574
+ textAlign: 'right',
575
+ }, children: "Actions" }))] }) }), _jsx("tbody", { children: loading ? (_jsx("tr", { children: _jsxs("td", { colSpan: visibleColumns.length + (actions || rowActions ? 1 : 0), style: { padding: 48, textAlign: 'center', color: '#64748B' }, children: [_jsx("div", { style: { fontSize: '1.2rem', marginBottom: 6 }, children: "\u23F3" }), _jsx("div", { style: { fontWeight: 600 }, children: "Loading records\u2026" })] }) })) : normalizedData.content.length === 0 ? (_jsx("tr", { children: _jsxs("td", { colSpan: visibleColumns.length + (actions || rowActions ? 1 : 0), style: { padding: 48, textAlign: 'center', color: '#64748B' }, children: [_jsx("div", { style: { fontSize: '1.4rem', marginBottom: 6 }, children: "\uD83D\uDCED" }), _jsx("div", { style: { fontWeight: 700, color: '#0F172A', marginBottom: 2 }, children: emptyMessage || 'No records found' }), _jsx("div", { style: { fontSize: '0.76rem' }, children: "Try clearing filters or search terms" })] }) })) : (normalizedData.content.map((row, idx) => {
576
+ const rowId = row.id || idx;
577
+ return (_jsxs(React.Fragment, { children: [_jsxs("tr", { onClick: (e) => {
578
+ const target = e.target;
579
+ if (target.closest('button') || target.closest('a') || target.closest('select'))
580
+ return;
581
+ onRowClick?.(row);
582
+ }, style: {
583
+ borderBottom: '1px solid #F1F5F9',
584
+ cursor: onRowClick ? 'pointer' : 'default',
585
+ transition: 'background-color 0.15s ease',
586
+ }, onMouseEnter: (e) => (e.currentTarget.style.backgroundColor = 'rgba(99, 102, 241, 0.04)'), onMouseLeave: (e) => (e.currentTarget.style.backgroundColor = 'transparent'), children: [visibleColumns.map((col) => (_jsx("td", { style: {
587
+ padding: compact ? '8px 12px' : '12px 16px',
588
+ textAlign: col.align || 'left',
589
+ verticalAlign: 'middle',
590
+ }, children: renderCellContent(row, col) }, col.key))), Boolean(actions || rowActions) && (_jsx("td", { style: {
591
+ padding: compact ? '8px 12px' : '12px 16px',
592
+ textAlign: 'right',
593
+ verticalAlign: 'middle',
594
+ }, onClick: (e) => e.stopPropagation(), children: (actions || rowActions)(row) }))] }), renderExpandedRow && (_jsx("tr", { children: _jsx("td", { colSpan: visibleColumns.length + (actions || rowActions ? 1 : 0), style: {
595
+ padding: compact ? '8px 12px' : '12px 16px',
596
+ backgroundColor: 'rgba(99, 102, 241, 0.02)',
597
+ borderBottom: '1px solid #E2E8F0',
598
+ }, children: renderExpandedRow(row) }) }))] }, rowId));
599
+ })) })] }) })), activeView === 'kanban' && (_jsx("div", { className: "sdui-kanban-board", style: {
600
+ display: 'flex',
601
+ gap: 16,
602
+ overflowX: 'auto',
603
+ paddingBottom: 14,
604
+ minHeight: 520,
605
+ alignItems: 'stretch',
606
+ }, children: kanbanStages.map((stage) => {
607
+ const isColOver = dragOverCol === stage.key;
608
+ const stageRecords = normalizedData.content.filter((item) => {
609
+ const itemStage = getRowStage(item, stageKey);
610
+ if (stage.statuses && stage.statuses.length > 0) {
611
+ return stage.statuses.includes(itemStage) || itemStage === stage.key;
612
+ }
613
+ return itemStage === stage.key;
614
+ });
615
+ return (_jsxs("div", { onDragOver: (e) => handleDragOver(e, stage.key), onDragLeave: () => setDragOverCol(null), onDrop: (e) => handleDrop(e, stage.key), style: {
616
+ flex: '0 0 310px',
617
+ background: isColOver ? 'rgba(99, 102, 241, 0.08)' : 'var(--surface-subtle, #F8FAFC)',
618
+ border: `1px ${isColOver ? 'dashed var(--color-primary, #6366F1)' : 'solid var(--border-subtle, #E2E8F0)'}`,
619
+ borderRadius: 16,
620
+ display: 'flex',
621
+ flexDirection: 'column',
622
+ maxHeight: 'calc(100vh - 280px)',
623
+ transition: 'all 0.15s ease',
624
+ boxShadow: '0 1px 3px rgba(15, 23, 42, 0.04)',
625
+ }, children: [_jsxs("div", { style: {
626
+ padding: '12px 14px',
627
+ display: 'flex',
628
+ alignItems: 'center',
629
+ justifyContent: 'space-between',
630
+ borderBottom: '1px solid var(--border-subtle, #E2E8F0)',
631
+ background: 'var(--surface-card, #FFFFFF)',
632
+ borderTopLeftRadius: 16,
633
+ borderTopRightRadius: 16,
634
+ borderTop: `3px solid ${stage.color || '#6366F1'}`,
635
+ }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 7 }, children: [_jsx("span", { style: {
636
+ width: 8,
637
+ height: 8,
638
+ borderRadius: '50%',
639
+ backgroundColor: stage.color || '#6366F1',
640
+ } }), _jsx("span", { style: { fontWeight: 800, fontSize: '0.82rem', color: '#0F172A' }, children: stage.label })] }), _jsx("span", { style: {
641
+ fontSize: '0.72rem',
642
+ fontWeight: 800,
643
+ padding: '2px 8px',
644
+ borderRadius: 9999,
645
+ background: 'var(--surface-subtle, #F8FAFC)',
646
+ color: '#64748B',
647
+ border: '1px solid var(--border-subtle, #E2E8F0)',
648
+ }, children: stageRecords.length })] }), _jsx("div", { style: {
649
+ padding: 10,
650
+ display: 'flex',
651
+ flexDirection: 'column',
652
+ gap: 10,
653
+ overflowY: 'auto',
654
+ flex: 1,
655
+ }, children: stageRecords.length === 0 ? (_jsx("div", { style: { padding: '36px 16px', textAlign: 'center', color: '#94A3B8', fontSize: '0.78rem', fontStyle: 'italic' }, children: "No records in this stage" })) : (stageRecords.map((item, i) => {
656
+ const draggable = isDraggable(item);
657
+ const isDragged = draggedItem && draggedItem.id === item.id;
658
+ const allowedNext = item.allowedNextTransitions || [];
659
+ if (renderCustomCard) {
660
+ return (_jsx("div", { draggable: draggable, onDragStart: (e) => handleDragStart(e, item), onDragEnd: () => setDraggedItem(null), onClick: () => onRowClick?.(item), children: renderCustomCard(item, (target) => onTransitionStage?.(item, target)) }, item.id ?? i));
661
+ }
662
+ return (_jsxs("div", { draggable: draggable, onDragStart: (e) => handleDragStart(e, item), onDragEnd: () => setDraggedItem(null), onClick: (e) => {
663
+ const target = e.target;
664
+ if (target.closest('button') || target.closest('select'))
665
+ return;
666
+ onRowClick?.(item);
667
+ }, style: {
668
+ background: 'var(--surface-card, #FFFFFF)',
669
+ border: '1px solid var(--border-subtle, #E2E8F0)',
670
+ borderRadius: 12,
671
+ padding: '12px 14px',
672
+ cursor: draggable ? 'grab' : onRowClick ? 'pointer' : 'default',
673
+ opacity: isDragged ? 0.4 : 1,
674
+ boxShadow: '0 1px 3px rgba(15, 23, 42, 0.04)',
675
+ transition: 'all 0.15s ease',
676
+ }, onMouseEnter: (e) => {
677
+ e.currentTarget.style.transform = 'translateY(-2px)';
678
+ e.currentTarget.style.boxShadow = '0 8px 20px rgba(15, 23, 42, 0.08)';
679
+ }, onMouseLeave: (e) => {
680
+ e.currentTarget.style.transform = 'none';
681
+ e.currentTarget.style.boxShadow = '0 1px 3px rgba(15, 23, 42, 0.04)';
682
+ }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: 6, marginBottom: 6 }, children: [_jsx("span", { style: { fontWeight: 800, fontSize: '0.82rem', color: '#0F172A', letterSpacing: '-0.01em' }, children: item.code || `#${String(item.id || i + 1).slice(0, 8)}` }), (item.stageCode || item.deliveryStatus || item.status) && (_jsx("span", { style: {
683
+ fontSize: '0.66rem',
684
+ fontWeight: 700,
685
+ padding: '2px 7px',
686
+ borderRadius: 9999,
687
+ backgroundColor: getBadgeStyle(item.stageCode || item.deliveryStatus || item.status).bg,
688
+ color: getBadgeStyle(item.stageCode || item.deliveryStatus || item.status).text,
689
+ border: `1px solid ${getBadgeStyle(item.stageCode || item.deliveryStatus || item.status).border}`,
690
+ }, children: String(item.stageName || item.stageCode || item.deliveryStatus || item.status).replace(/_/g, ' ') }))] }), (item.customerName || item.storeName) && (_jsx("div", { style: { fontSize: '0.78rem', fontWeight: 600, color: '#1E293B', marginBottom: 2 }, children: item.customerName || item.storeName })), item.itemsSummary && (_jsx("div", { style: { fontSize: '0.72rem', color: '#64748B', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', marginBottom: 6 }, children: item.itemsSummary })), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 4 }, children: [item.totalAmount !== undefined && (_jsxs("span", { style: { fontWeight: 800, fontSize: '0.84rem', color: 'var(--color-primary, #6366F1)', fontFamily: 'ui-monospace, monospace' }, children: ["\u20B9", Number(item.totalAmount || 0).toLocaleString('en-IN')] })), item.createdAt && (_jsx("span", { style: { fontSize: '0.68rem', color: '#94A3B8' }, children: new Date(item.createdAt).toLocaleDateString() }))] }), allowedNext.length > 0 && onTransitionStage && (_jsx("div", { style: {
691
+ marginTop: 8,
692
+ paddingTop: 8,
693
+ borderTop: '1px solid #F1F5F9',
694
+ display: 'flex',
695
+ gap: 4,
696
+ flexWrap: 'wrap',
697
+ }, onClick: (e) => e.stopPropagation(), children: allowedNext.map((opt) => (_jsxs("button", { type: "button", onClick: () => onTransitionStage(item, opt.code || opt.id, opt), style: {
698
+ fontSize: '0.66rem',
699
+ fontWeight: 700,
700
+ padding: '2px 8px',
701
+ borderRadius: 9999,
702
+ border: '1px solid #BFDBFE',
703
+ backgroundColor: '#EFF6FF',
704
+ color: '#1D4ED8',
705
+ cursor: 'pointer',
706
+ }, children: ["\u2192 ", opt.name || opt.code?.replace(/_/g, ' ')] }, opt.id || opt.code))) })), Boolean(actions || rowActions) && (_jsx("div", { style: {
707
+ marginTop: 6,
708
+ paddingTop: 6,
709
+ borderTop: '1px solid #F1F5F9',
710
+ display: 'flex',
711
+ justifyContent: 'flex-end',
712
+ gap: 4,
713
+ }, onClick: (e) => e.stopPropagation(), children: (actions || rowActions)(item) }))] }, item.id ?? i));
714
+ })) })] }, stage.key));
715
+ }) })), activeView === 'cards' && (_jsx("div", { className: "sdui-cards-grid", style: {
716
+ display: 'grid',
717
+ gridTemplateColumns: 'repeat(auto-fill, minmax(290px, 1fr))',
718
+ gap: 12,
719
+ }, children: loading ? (_jsx("div", { style: { gridColumn: '1 / -1', padding: 48, textAlign: 'center', color: '#64748B' }, children: "Loading cards\u2026" })) : normalizedData.content.length === 0 ? (_jsxs("div", { style: { gridColumn: '1 / -1', padding: 48, textAlign: 'center', color: '#64748B' }, children: [_jsx("div", { style: { fontSize: '1.4rem', marginBottom: 6 }, children: "\uD83D\uDCED" }), _jsx("div", { style: { fontWeight: 700, color: '#0F172A', marginBottom: 2 }, children: emptyMessage || 'No records found' }), _jsx("div", { style: { fontSize: '0.76rem' }, children: "Try clearing filters or search terms" })] })) : (normalizedData.content.map((item, idx) => {
720
+ const currentStage = getRowStage(item, stageKey);
721
+ const allowedNext = item.allowedNextTransitions || [];
722
+ if (renderCustomCard) {
723
+ return (_jsx("div", { onClick: () => onRowClick?.(item), children: renderCustomCard(item, (target) => onTransitionStage?.(item, target)) }, item.id ?? idx));
724
+ }
725
+ return (_jsxs("div", { onClick: (e) => {
726
+ const target = e.target;
727
+ if (target.closest('button'))
728
+ return;
729
+ onRowClick?.(item);
730
+ }, style: {
731
+ background: 'var(--surface-card, #FFFFFF)',
732
+ border: '1px solid var(--border-subtle, #E2E8F0)',
733
+ borderRadius: 14,
734
+ padding: 16,
735
+ display: 'flex',
736
+ flexDirection: 'column',
737
+ gap: 8,
738
+ cursor: onRowClick ? 'pointer' : 'default',
739
+ boxShadow: '0 1px 3px rgba(15, 23, 42, 0.04)',
740
+ transition: 'all 0.15s ease',
741
+ }, onMouseEnter: (e) => {
742
+ e.currentTarget.style.transform = 'translateY(-2px)';
743
+ e.currentTarget.style.boxShadow = '0 8px 24px rgba(15, 23, 42, 0.08)';
744
+ }, onMouseLeave: (e) => {
745
+ e.currentTarget.style.transform = 'none';
746
+ e.currentTarget.style.boxShadow = '0 1px 3px rgba(15, 23, 42, 0.04)';
747
+ }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' }, children: [_jsx("span", { style: { fontWeight: 800, fontSize: '0.85rem', color: '#0F172A' }, children: item.code || `#${String(item.id || idx + 1).slice(0, 8)}` }), currentStage && (_jsx("span", { style: {
748
+ fontSize: '0.68rem',
749
+ fontWeight: 700,
750
+ padding: '2px 8px',
751
+ borderRadius: 9999,
752
+ backgroundColor: getBadgeStyle(currentStage).bg,
753
+ color: getBadgeStyle(currentStage).text,
754
+ border: `1px solid ${getBadgeStyle(currentStage).border}`,
755
+ }, children: currentStage.replace(/_/g, ' ') }))] }), (item.customerName || item.storeName) && (_jsx("div", { style: { fontSize: '0.8rem', fontWeight: 600, color: '#1E293B' }, children: item.customerName || item.storeName })), item.itemsSummary && (_jsx("div", { style: { fontSize: '0.74rem', color: '#64748B' }, children: item.itemsSummary })), _jsxs("div", { style: {
756
+ display: 'flex',
757
+ justifyContent: 'space-between',
758
+ alignItems: 'center',
759
+ marginTop: 'auto',
760
+ paddingTop: 10,
761
+ borderTop: '1px solid #F1F5F9',
762
+ }, children: [item.totalAmount !== undefined && (_jsxs("span", { style: { fontWeight: 800, fontSize: '0.88rem', color: 'var(--color-primary, #6366F1)', fontFamily: 'ui-monospace, monospace' }, children: ["\u20B9", Number(item.totalAmount || 0).toLocaleString('en-IN')] })), allowedNext.length > 0 && onTransitionStage && (_jsxs("button", { type: "button", onClick: () => onTransitionStage(item, allowedNext[0].code || allowedNext[0].id, allowedNext[0]), style: {
763
+ fontSize: '0.68rem',
764
+ fontWeight: 700,
765
+ padding: '3px 10px',
766
+ borderRadius: 9999,
767
+ border: '1px solid #BFDBFE',
768
+ backgroundColor: '#EFF6FF',
769
+ color: '#1D4ED8',
770
+ cursor: 'pointer',
771
+ }, children: ["\u2192 ", allowedNext[0].name || allowedNext[0].code?.replace(/_/g, ' ')] }))] }), Boolean(actions || rowActions) && (_jsx("div", { style: {
772
+ marginTop: 6,
773
+ paddingTop: 8,
774
+ borderTop: '1px solid #F1F5F9',
775
+ display: 'flex',
776
+ justifyContent: 'flex-end',
777
+ gap: 6,
778
+ }, onClick: (e) => e.stopPropagation(), children: (actions || rowActions)(item) }))] }, item.id ?? idx));
779
+ })) })), _jsxs("div", { className: "sdui-dt-footer", style: {
780
+ display: 'flex',
781
+ justifyContent: 'space-between',
782
+ alignItems: 'center',
783
+ flexWrap: 'wrap',
784
+ gap: 12,
785
+ padding: '10px 16px',
786
+ background: 'var(--surface-card, #FFFFFF)',
787
+ borderRadius: 14,
788
+ border: '1px solid var(--border-subtle, #E2E8F0)',
789
+ fontSize: '0.78rem',
790
+ color: '#64748B',
791
+ }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 10 }, children: [_jsx("span", { children: "Rows per page:" }), _jsx("select", { value: normalizedData.pageSize, onChange: (e) => onRowsPerPageChange?.(Number(e.target.value)), style: {
792
+ padding: '3px 6px',
793
+ borderRadius: 6,
794
+ border: '1px solid #CBD5E1',
795
+ fontSize: '0.78rem',
796
+ backgroundColor: '#FFFFFF',
797
+ color: '#0F172A',
798
+ }, children: pageSizeOptions.map((sz) => (_jsx("option", { value: sz, children: sz }, sz))) }), _jsx("span", { children: normalizedData.totalElements > 0
799
+ ? `${normalizedData.pageNumber * normalizedData.pageSize + 1}–${Math.min((normalizedData.pageNumber + 1) * normalizedData.pageSize, normalizedData.totalElements)} of ${normalizedData.totalElements}`
800
+ : '0 records' })] }), _jsxs("div", { style: { display: 'flex', gap: 6, alignItems: 'center' }, children: [_jsx("button", { type: "button", disabled: normalizedData.pageNumber <= 0, onClick: () => onPageChange?.(normalizedData.pageNumber - 1), style: {
801
+ padding: '4px 10px',
802
+ borderRadius: 6,
803
+ border: '1px solid #CBD5E1',
804
+ backgroundColor: '#FFFFFF',
805
+ fontSize: '0.78rem',
806
+ fontWeight: 600,
807
+ cursor: normalizedData.pageNumber <= 0 ? 'not-allowed' : 'pointer',
808
+ opacity: normalizedData.pageNumber <= 0 ? 0.4 : 1,
809
+ }, children: "\u2039 Prev" }), _jsxs("span", { style: { fontSize: '0.78rem', color: '#0F172A', fontWeight: 600 }, children: ["Page ", normalizedData.pageNumber + 1, " of ", Math.max(1, normalizedData.totalPages)] }), _jsx("button", { type: "button", disabled: normalizedData.last, onClick: () => onPageChange?.(normalizedData.pageNumber + 1), style: {
810
+ padding: '4px 10px',
811
+ borderRadius: 6,
812
+ border: '1px solid #CBD5E1',
813
+ backgroundColor: '#FFFFFF',
814
+ fontSize: '0.78rem',
815
+ fontWeight: 600,
816
+ cursor: normalizedData.last ? 'not-allowed' : 'pointer',
817
+ opacity: normalizedData.last ? 0.4 : 1,
818
+ }, children: "Next \u203A" })] })] })] }));
819
+ }
820
+ export default DynamicTable;
821
+ //# sourceMappingURL=DynamicTable.js.map