@burdenoff/microfe-bigconsole 2026.1110.8 → 2026.1111.1

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.
@@ -1,8 +1,9 @@
1
- import { memo as e, useCallback as t, useEffect as n, useMemo as r, useState as i } from "react";
2
- import { useI18n as a } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
3
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
1
+ import { resolveDefaultSort as e } from "./tableSort.js";
2
+ import { memo as t, useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
3
+ import { useI18n as o } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
4
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
4
5
  // src/bigconsole/components/widgets/table/TableConfig.tsx
5
- var c = [
6
+ var l = [
6
7
  {
7
8
  value: "gt",
8
9
  labelKey: "bigconsole.widget.config.table.operator.gt",
@@ -48,7 +49,7 @@ var c = [
48
49
  labelKey: "bigconsole.widget.config.table.operator.contains",
49
50
  labelDefault: "contains"
50
51
  }
51
- ], l = [
52
+ ], u = [
52
53
  {
53
54
  value: "danger",
54
55
  labelKey: "bigconsole.widget.config.table.intent.danger",
@@ -74,46 +75,46 @@ var c = [
74
75
  labelKey: "bigconsole.widget.config.table.intent.neutral",
75
76
  labelDefault: "Neutral"
76
77
  }
77
- ], u = "px-2 py-1 text-xs text-text-primary bg-bg-surface border border-border-default rounded-md focus:outline-none focus:ring-2 focus:ring-action-primary-bg", d = e(function({ config: e, onChange: d }) {
78
- let { t: f } = a(), p = r(() => (e.columns || []).map((e) => typeof e == "string" ? {
78
+ ], d = "px-2 py-1 text-xs text-text-primary bg-bg-surface border border-border-default rounded-md focus:outline-none focus:ring-2 focus:ring-action-primary-bg", f = t(function({ config: t, onChange: f }) {
79
+ let { t: p } = o(), m = i(() => (t.columns || []).map((e) => typeof e == "string" ? {
79
80
  field: e,
80
81
  header: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " ")
81
- } : e), []), [m, h] = i(p);
82
- n(() => {
83
- JSON.stringify(e.columns) !== JSON.stringify(m) && m.length > 0 && d({
84
- ...e,
85
- columns: m
82
+ } : e), []), [h, g] = a(m);
83
+ r(() => {
84
+ JSON.stringify(t.columns) !== JSON.stringify(h) && h.length > 0 && f({
85
+ ...t,
86
+ columns: h
86
87
  });
87
- }, [m]), n(() => {
88
- let t = (e.columns || []).map((e) => typeof e == "string" ? {
88
+ }, [h]), r(() => {
89
+ let e = (t.columns || []).map((e) => typeof e == "string" ? {
89
90
  field: e,
90
91
  header: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " ")
91
92
  } : e);
92
- h(t);
93
- }, [e.columns]);
94
- let g = t((t, n) => {
95
- d({
96
- ...e,
97
- [t]: n
93
+ g(e);
94
+ }, [t.columns]);
95
+ let _ = n((e, n) => {
96
+ f({
97
+ ...t,
98
+ [e]: n
98
99
  });
99
- }, [e, d]), _ = t((e, t, n) => {
100
- h((r) => {
100
+ }, [t, f]), v = n((e, t, n) => {
101
+ g((r) => {
101
102
  let i = [...r];
102
103
  return i[e] = {
103
104
  ...i[e],
104
105
  [t]: n
105
106
  }, i;
106
107
  });
107
- }, []), v = t((e, t) => {
108
- h((n) => {
108
+ }, []), y = n((e, t) => {
109
+ g((n) => {
109
110
  let r = [...n];
110
111
  return r[e] = {
111
112
  ...r[e],
112
113
  conditionalRules: t
113
114
  }, r;
114
115
  });
115
- }, []), y = t((e) => {
116
- let t = m[e]?.conditionalRules ?? [], n = {
116
+ }, []), b = n((e) => {
117
+ let t = h[e]?.conditionalRules ?? [], n = {
117
118
  operator: "gt",
118
119
  value: 0,
119
120
  style: {
@@ -122,15 +123,15 @@ var c = [
122
123
  bold: !0
123
124
  }
124
125
  };
125
- v(e, [...t, n]);
126
- }, [m, v]), b = t((e, t, n) => {
127
- let r = (m[e]?.conditionalRules ?? []).map((e, r) => r === t ? {
126
+ y(e, [...t, n]);
127
+ }, [h, y]), x = n((e, t, n) => {
128
+ let r = (h[e]?.conditionalRules ?? []).map((e, r) => r === t ? {
128
129
  ...e,
129
130
  ...n
130
131
  } : e);
131
- v(e, r);
132
- }, [m, v]), x = t((e, t, n) => {
133
- let r = (m[e]?.conditionalRules ?? []).map((e, r) => r === t ? {
132
+ y(e, r);
133
+ }, [h, y]), S = n((e, t, n) => {
134
+ let r = (h[e]?.conditionalRules ?? []).map((e, r) => r === t ? {
134
135
  ...e,
135
136
  style: {
136
137
  ...e.style,
@@ -138,84 +139,146 @@ var c = [
138
139
  textColor: n
139
140
  }
140
141
  } : e);
141
- v(e, r);
142
- }, [m, v]), S = t((e, t) => {
143
- let n = m[e]?.conditionalRules ?? [];
144
- v(e, n.filter((e, n) => n !== t));
145
- }, [m, v]), C = t(() => {
146
- h((e) => [...e, {
142
+ y(e, r);
143
+ }, [h, y]), C = n((e, t) => {
144
+ let n = h[e]?.conditionalRules ?? [];
145
+ y(e, n.filter((e, n) => n !== t));
146
+ }, [h, y]), w = i(() => h.map((e) => ({
147
+ field: (e.key || e.field || "").trim(),
148
+ header: e.label || e.header || ""
149
+ })).filter((e) => e.field), [h]), T = e(t), E = T.column !== null && !w.some((e) => e.field === T.column), D = n((e) => {
150
+ f({
151
+ ...t,
152
+ defaultSortColumn: e || void 0,
153
+ defaultSortDirection: e ? t.defaultSortDirection === "desc" ? "desc" : "asc" : void 0
154
+ });
155
+ }, [t, f]), O = n(() => {
156
+ g((e) => [...e, {
147
157
  field: "",
148
158
  header: ""
149
159
  }]);
150
- }, []), w = t((e) => {
151
- h((t) => t.filter((t, n) => n !== e));
160
+ }, []), k = n((e) => {
161
+ g((t) => t.filter((t, n) => n !== e));
152
162
  }, []);
153
- return /* @__PURE__ */ s("div", {
163
+ return /* @__PURE__ */ c("div", {
154
164
  className: "min-w-0 space-y-form-gap",
155
165
  children: [
156
- /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
166
+ /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("label", {
157
167
  className: "block text-sm font-medium text-text-primary mb-1",
158
- children: f("bigconsole.widget.config.table.pageSize.label", "Page Size")
159
- }), /* @__PURE__ */ s("select", {
160
- value: e.pageSize || 10,
161
- onChange: (e) => g("pageSize", Number(e.target.value)),
168
+ children: p("bigconsole.widget.config.table.pageSize.label", "Page Size")
169
+ }), /* @__PURE__ */ c("select", {
170
+ value: t.pageSize || 10,
171
+ onChange: (e) => _("pageSize", Number(e.target.value)),
162
172
  className: "\n w-full px-3 py-2\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n ",
163
173
  children: [
164
- /* @__PURE__ */ o("option", {
174
+ /* @__PURE__ */ s("option", {
165
175
  value: 10,
166
- children: f("bigconsole.widget.config.table.pageSize.rows", "{{count}} rows", { count: 10 })
176
+ children: p("bigconsole.widget.config.table.pageSize.rows", "{{count}} rows", { count: 10 })
167
177
  }),
168
- /* @__PURE__ */ o("option", {
178
+ /* @__PURE__ */ s("option", {
169
179
  value: 25,
170
- children: f("bigconsole.widget.config.table.pageSize.rows", "{{count}} rows", { count: 25 })
180
+ children: p("bigconsole.widget.config.table.pageSize.rows", "{{count}} rows", { count: 25 })
171
181
  }),
172
- /* @__PURE__ */ o("option", {
182
+ /* @__PURE__ */ s("option", {
173
183
  value: 50,
174
- children: f("bigconsole.widget.config.table.pageSize.rows", "{{count}} rows", { count: 50 })
184
+ children: p("bigconsole.widget.config.table.pageSize.rows", "{{count}} rows", { count: 50 })
175
185
  }),
176
- /* @__PURE__ */ o("option", {
186
+ /* @__PURE__ */ s("option", {
177
187
  value: 100,
178
- children: f("bigconsole.widget.config.table.pageSize.rows", "{{count}} rows", { count: 100 })
188
+ children: p("bigconsole.widget.config.table.pageSize.rows", "{{count}} rows", { count: 100 })
179
189
  })
180
190
  ]
181
191
  })] }),
182
- /* @__PURE__ */ s("div", { children: [
183
- /* @__PURE__ */ s("div", {
192
+ /* @__PURE__ */ c("div", { children: [
193
+ /* @__PURE__ */ s("label", {
194
+ htmlFor: "table-default-sort-column",
195
+ className: "block text-sm font-medium text-text-primary mb-1",
196
+ children: p("bigconsole.widget.config.table.defaultSort.label", "Default sort")
197
+ }),
198
+ /* @__PURE__ */ s("p", {
199
+ className: "text-sm text-text-secondary mb-2",
200
+ children: p("bigconsole.widget.config.table.defaultSort.help", "The table starts sorted like this every time it opens. Viewers can still click a column title to sort differently.")
201
+ }),
202
+ /* @__PURE__ */ c("div", {
203
+ className: "grid grid-cols-1 gap-2 sm:grid-cols-2",
204
+ children: [/* @__PURE__ */ c("select", {
205
+ id: "table-default-sort-column",
206
+ value: T.column ?? "",
207
+ onChange: (e) => D(e.target.value),
208
+ disabled: w.length === 0 && !E,
209
+ "aria-label": p("bigconsole.widget.config.table.defaultSort.column", "Sort by"),
210
+ className: "\n w-full px-3 py-2\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n disabled:opacity-60\n ",
211
+ children: [
212
+ /* @__PURE__ */ s("option", {
213
+ value: "",
214
+ children: p("bigconsole.widget.config.table.defaultSort.none", "No default sort")
215
+ }),
216
+ E && T.column && /* @__PURE__ */ s("option", {
217
+ value: T.column,
218
+ children: T.column
219
+ }),
220
+ w.map((e) => /* @__PURE__ */ s("option", {
221
+ value: e.field,
222
+ children: e.header && e.header !== e.field ? `${e.header} (${e.field})` : e.field
223
+ }, e.field))
224
+ ]
225
+ }), /* @__PURE__ */ c("select", {
226
+ value: T.direction ?? "asc",
227
+ onChange: (e) => _("defaultSortDirection", e.target.value === "desc" ? "desc" : "asc"),
228
+ disabled: T.column === null,
229
+ "aria-label": p("bigconsole.widget.config.table.defaultSort.direction", "Direction"),
230
+ className: "\n w-full px-3 py-2\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n disabled:opacity-60\n ",
231
+ children: [/* @__PURE__ */ s("option", {
232
+ value: "asc",
233
+ children: p("bigconsole.widget.config.table.defaultSort.asc", "Ascending (A to Z, low to high)")
234
+ }), /* @__PURE__ */ s("option", {
235
+ value: "desc",
236
+ children: p("bigconsole.widget.config.table.defaultSort.desc", "Descending (Z to A, high to low)")
237
+ })]
238
+ })]
239
+ }),
240
+ w.length === 0 && !E && /* @__PURE__ */ s("p", {
241
+ className: "text-sm text-text-secondary mt-2",
242
+ children: p("bigconsole.widget.config.table.defaultSort.needColumns", "Add columns below to choose the column to sort by.")
243
+ })
244
+ ] }),
245
+ /* @__PURE__ */ c("div", { children: [
246
+ /* @__PURE__ */ c("div", {
184
247
  className: "flex items-center justify-between mb-2",
185
- children: [/* @__PURE__ */ o("label", {
248
+ children: [/* @__PURE__ */ s("label", {
186
249
  className: "text-sm font-medium text-text-primary",
187
- children: f("bigconsole.widget.config.table.columns.label", "Columns")
188
- }), /* @__PURE__ */ o("button", {
250
+ children: p("bigconsole.widget.config.table.columns.label", "Columns")
251
+ }), /* @__PURE__ */ s("button", {
189
252
  type: "button",
190
- onClick: C,
253
+ onClick: O,
191
254
  className: "\n text-sm text-action-primary-bg\n hover:text-action-primary-bgHover\n ",
192
- children: f("bigconsole.widget.config.table.columns.add", "+ Add Column")
255
+ children: p("bigconsole.widget.config.table.columns.add", "+ Add Column")
193
256
  })]
194
257
  }),
195
- /* @__PURE__ */ o("p", {
258
+ /* @__PURE__ */ s("p", {
196
259
  className: "text-sm text-text-secondary mb-3",
197
- children: f("bigconsole.widget.config.table.columns.replacementHelp", "Adding columns here replaces auto-generated columns. Only configured columns will be shown, in this order. In edit mode, drag table headers to reorder.")
260
+ children: p("bigconsole.widget.config.table.columns.replacementHelp", "Adding columns here replaces auto-generated columns. Only configured columns will be shown, in this order. In edit mode, drag table headers to reorder.")
198
261
  }),
199
- /* @__PURE__ */ s("div", {
262
+ /* @__PURE__ */ c("div", {
200
263
  className: "space-y-3",
201
- children: [m.map((e, t) => /* @__PURE__ */ s("div", {
264
+ children: [h.map((e, t) => /* @__PURE__ */ c("div", {
202
265
  className: "\n p-3\n bg-bg-sunken\n rounded-md\n space-y-2\n ",
203
266
  children: [
204
- /* @__PURE__ */ s("div", {
267
+ /* @__PURE__ */ c("div", {
205
268
  className: "flex items-center justify-between",
206
- children: [/* @__PURE__ */ o("span", {
269
+ children: [/* @__PURE__ */ s("span", {
207
270
  className: "text-xs text-text-secondary",
208
- children: f("bigconsole.widget.config.table.columns.columnN", "Column {{index}}", { index: t + 1 })
209
- }), /* @__PURE__ */ o("button", {
271
+ children: p("bigconsole.widget.config.table.columns.columnN", "Column {{index}}", { index: t + 1 })
272
+ }), /* @__PURE__ */ s("button", {
210
273
  type: "button",
211
- onClick: () => w(t),
274
+ onClick: () => k(t),
212
275
  className: "text-status-error-text hover:text-status-error-text/80",
213
- children: /* @__PURE__ */ o("svg", {
276
+ children: /* @__PURE__ */ s("svg", {
214
277
  className: "w-4 h-4",
215
278
  fill: "none",
216
279
  stroke: "currentColor",
217
280
  viewBox: "0 0 24 24",
218
- children: /* @__PURE__ */ o("path", {
281
+ children: /* @__PURE__ */ s("path", {
219
282
  strokeLinecap: "round",
220
283
  strokeLinejoin: "round",
221
284
  strokeWidth: 2,
@@ -224,166 +287,166 @@ var c = [
224
287
  })
225
288
  })]
226
289
  }),
227
- /* @__PURE__ */ s("div", {
290
+ /* @__PURE__ */ c("div", {
228
291
  className: "grid grid-cols-1 gap-2 sm:grid-cols-2",
229
- children: [/* @__PURE__ */ o("input", {
292
+ children: [/* @__PURE__ */ s("input", {
230
293
  type: "text",
231
294
  value: e.field || "",
232
- onChange: (e) => _(t, "field", e.target.value),
233
- placeholder: f("bigconsole.widget.config.table.column.fieldPlaceholder", "Field name"),
295
+ onChange: (e) => v(t, "field", e.target.value),
296
+ placeholder: p("bigconsole.widget.config.table.column.fieldPlaceholder", "Field name"),
234
297
  className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n "
235
- }), /* @__PURE__ */ o("input", {
298
+ }), /* @__PURE__ */ s("input", {
236
299
  type: "text",
237
300
  value: e.header || "",
238
- onChange: (e) => _(t, "header", e.target.value),
239
- placeholder: f("bigconsole.widget.config.table.column.headerPlaceholder", "Header label"),
301
+ onChange: (e) => v(t, "header", e.target.value),
302
+ placeholder: p("bigconsole.widget.config.table.column.headerPlaceholder", "Header label"),
240
303
  className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n "
241
304
  })]
242
305
  }),
243
- /* @__PURE__ */ s("div", {
306
+ /* @__PURE__ */ c("div", {
244
307
  className: "grid grid-cols-1 gap-2 sm:grid-cols-2",
245
- children: [/* @__PURE__ */ s("select", {
308
+ children: [/* @__PURE__ */ c("select", {
246
309
  value: e.format || "text",
247
- onChange: (e) => _(t, "format", e.target.value),
310
+ onChange: (e) => v(t, "format", e.target.value),
248
311
  className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n ",
249
312
  children: [
250
- /* @__PURE__ */ o("option", {
313
+ /* @__PURE__ */ s("option", {
251
314
  value: "text",
252
- children: f("bigconsole.widget.config.table.format.text", "Text")
315
+ children: p("bigconsole.widget.config.table.format.text", "Text")
253
316
  }),
254
- /* @__PURE__ */ o("option", {
317
+ /* @__PURE__ */ s("option", {
255
318
  value: "number",
256
- children: f("bigconsole.widget.config.table.format.number", "Number")
319
+ children: p("bigconsole.widget.config.table.format.number", "Number")
257
320
  }),
258
- /* @__PURE__ */ o("option", {
321
+ /* @__PURE__ */ s("option", {
259
322
  value: "currency",
260
- children: f("bigconsole.widget.config.table.format.currency", "Currency")
323
+ children: p("bigconsole.widget.config.table.format.currency", "Currency")
261
324
  }),
262
- /* @__PURE__ */ o("option", {
325
+ /* @__PURE__ */ s("option", {
263
326
  value: "percentage",
264
- children: f("bigconsole.widget.config.table.format.percentage", "Percentage")
327
+ children: p("bigconsole.widget.config.table.format.percentage", "Percentage")
265
328
  }),
266
- /* @__PURE__ */ o("option", {
329
+ /* @__PURE__ */ s("option", {
267
330
  value: "date",
268
- children: f("bigconsole.widget.config.table.format.date", "Date")
331
+ children: p("bigconsole.widget.config.table.format.date", "Date")
269
332
  }),
270
- /* @__PURE__ */ o("option", {
333
+ /* @__PURE__ */ s("option", {
271
334
  value: "badge",
272
- children: f("bigconsole.widget.config.table.format.badge", "Badge")
335
+ children: p("bigconsole.widget.config.table.format.badge", "Badge")
273
336
  })
274
337
  ]
275
- }), /* @__PURE__ */ s("select", {
338
+ }), /* @__PURE__ */ c("select", {
276
339
  value: e.align || "left",
277
- onChange: (e) => _(t, "align", e.target.value),
340
+ onChange: (e) => v(t, "align", e.target.value),
278
341
  className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n ",
279
342
  children: [
280
- /* @__PURE__ */ o("option", {
343
+ /* @__PURE__ */ s("option", {
281
344
  value: "left",
282
- children: f("bigconsole.widget.config.table.align.left", "Left")
345
+ children: p("bigconsole.widget.config.table.align.left", "Left")
283
346
  }),
284
- /* @__PURE__ */ o("option", {
347
+ /* @__PURE__ */ s("option", {
285
348
  value: "center",
286
- children: f("bigconsole.widget.config.table.align.center", "Center")
349
+ children: p("bigconsole.widget.config.table.align.center", "Center")
287
350
  }),
288
- /* @__PURE__ */ o("option", {
351
+ /* @__PURE__ */ s("option", {
289
352
  value: "right",
290
- children: f("bigconsole.widget.config.table.align.right", "Right")
353
+ children: p("bigconsole.widget.config.table.align.right", "Right")
291
354
  })
292
355
  ]
293
356
  })]
294
357
  }),
295
- /* @__PURE__ */ s("div", {
358
+ /* @__PURE__ */ c("div", {
296
359
  className: "pt-2 border-t border-border-default/60",
297
360
  children: [
298
- /* @__PURE__ */ s("div", {
361
+ /* @__PURE__ */ c("div", {
299
362
  className: "flex items-center justify-between mb-1",
300
- children: [/* @__PURE__ */ o("span", {
363
+ children: [/* @__PURE__ */ s("span", {
301
364
  className: "text-xs font-medium text-text-secondary",
302
- children: f("bigconsole.widget.config.table.conditionalFormatting.title", "Conditional formatting")
303
- }), /* @__PURE__ */ o("button", {
365
+ children: p("bigconsole.widget.config.table.conditionalFormatting.title", "Conditional formatting")
366
+ }), /* @__PURE__ */ s("button", {
304
367
  type: "button",
305
- onClick: () => y(t),
368
+ onClick: () => b(t),
306
369
  className: "text-xs text-action-primary-bg hover:text-action-primary-bgHover",
307
- children: f("bigconsole.widget.config.table.conditionalFormatting.addRule", "+ Add rule")
370
+ children: p("bigconsole.widget.config.table.conditionalFormatting.addRule", "+ Add rule")
308
371
  })]
309
372
  }),
310
- (e.conditionalRules?.length ?? 0) === 0 && /* @__PURE__ */ o("p", {
373
+ (e.conditionalRules?.length ?? 0) === 0 && /* @__PURE__ */ s("p", {
311
374
  className: "text-xs text-text-secondary",
312
- children: f("bigconsole.widget.config.table.conditionalFormatting.noRules", "No rules — cell shows its plain value.")
375
+ children: p("bigconsole.widget.config.table.conditionalFormatting.noRules", "No rules — cell shows its plain value.")
313
376
  }),
314
- /* @__PURE__ */ o("div", {
377
+ /* @__PURE__ */ s("div", {
315
378
  className: "space-y-2",
316
379
  children: (e.conditionalRules ?? []).map((n, r) => {
317
- let i = n.operator !== "isEmpty" && n.operator !== "isNotEmpty", a = i && n.valueType === "field", d = n.operator === "between" || n.operator === "outside", p = n.style?.bgColor ?? n.style?.textColor ?? "danger";
318
- return /* @__PURE__ */ s("div", {
380
+ let i = n.operator !== "isEmpty" && n.operator !== "isNotEmpty", a = i && n.valueType === "field", o = n.operator === "between" || n.operator === "outside", f = n.style?.bgColor ?? n.style?.textColor ?? "danger";
381
+ return /* @__PURE__ */ c("div", {
319
382
  className: "p-2 bg-bg-surface rounded-md border border-border-default space-y-2",
320
- children: [/* @__PURE__ */ s("div", {
383
+ children: [/* @__PURE__ */ c("div", {
321
384
  className: "flex items-center gap-2",
322
385
  children: [
323
- /* @__PURE__ */ o("select", {
386
+ /* @__PURE__ */ s("select", {
324
387
  value: n.operator,
325
- onChange: (e) => b(t, r, { operator: e.target.value }),
326
- className: `${u} flex-1`,
327
- children: c.map((e) => /* @__PURE__ */ o("option", {
388
+ onChange: (e) => x(t, r, { operator: e.target.value }),
389
+ className: `${d} flex-1`,
390
+ children: l.map((e) => /* @__PURE__ */ s("option", {
328
391
  value: e.value,
329
- children: f(e.labelKey, e.labelDefault)
392
+ children: p(e.labelKey, e.labelDefault)
330
393
  }, e.value))
331
394
  }),
332
- i && /* @__PURE__ */ s("select", {
395
+ i && /* @__PURE__ */ c("select", {
333
396
  value: a ? "field" : "constant",
334
- onChange: (e) => b(t, r, e.target.value === "field" ? { valueType: "field" } : {
397
+ onChange: (e) => x(t, r, e.target.value === "field" ? { valueType: "field" } : {
335
398
  valueType: "constant",
336
399
  fieldRef: void 0
337
400
  }),
338
- "aria-label": f("bigconsole.widget.config.table.rule.valueTypeLabel", "Compare to"),
339
- className: `${u} w-20`,
340
- children: [/* @__PURE__ */ o("option", {
401
+ "aria-label": p("bigconsole.widget.config.table.rule.valueTypeLabel", "Compare to"),
402
+ className: `${d} w-20`,
403
+ children: [/* @__PURE__ */ s("option", {
341
404
  value: "constant",
342
- children: f("bigconsole.widget.config.table.rule.valueTypeConstant", "Value")
343
- }), /* @__PURE__ */ o("option", {
405
+ children: p("bigconsole.widget.config.table.rule.valueTypeConstant", "Value")
406
+ }), /* @__PURE__ */ s("option", {
344
407
  value: "field",
345
- children: f("bigconsole.widget.config.table.rule.valueTypeField", "Field")
408
+ children: p("bigconsole.widget.config.table.rule.valueTypeField", "Field")
346
409
  })]
347
410
  }),
348
- a ? /* @__PURE__ */ s("select", {
411
+ a ? /* @__PURE__ */ c("select", {
349
412
  value: n.fieldRef ?? "",
350
- onChange: (e) => b(t, r, {
413
+ onChange: (e) => x(t, r, {
351
414
  valueType: "field",
352
415
  fieldRef: e.target.value
353
416
  }),
354
- className: `${u} w-28`,
355
- children: [/* @__PURE__ */ o("option", {
417
+ className: `${d} w-28`,
418
+ children: [/* @__PURE__ */ s("option", {
356
419
  value: "",
357
- children: f("bigconsole.widget.config.table.rule.fieldRefPlaceholder", "Select field")
358
- }), m.filter((t) => t.key !== e.key).map((e) => /* @__PURE__ */ o("option", {
420
+ children: p("bigconsole.widget.config.table.rule.fieldRefPlaceholder", "Select field")
421
+ }), h.filter((t) => t.key !== e.key).map((e) => /* @__PURE__ */ s("option", {
359
422
  value: e.key,
360
423
  children: e.key
361
424
  }, e.key))]
362
- }) : /* @__PURE__ */ o("input", {
425
+ }) : /* @__PURE__ */ s("input", {
363
426
  type: "text",
364
427
  value: n.value ?? "",
365
- onChange: (e) => b(t, r, { value: e.target.value }),
366
- placeholder: f("bigconsole.widget.config.table.rule.valuePlaceholder", "value"),
367
- className: `${u} w-20`
428
+ onChange: (e) => x(t, r, { value: e.target.value }),
429
+ placeholder: p("bigconsole.widget.config.table.rule.valuePlaceholder", "value"),
430
+ className: `${d} w-20`
368
431
  }),
369
- d && /* @__PURE__ */ o("input", {
432
+ o && /* @__PURE__ */ s("input", {
370
433
  type: "text",
371
434
  value: n.value2 ?? "",
372
- onChange: (e) => b(t, r, { value2: e.target.value }),
373
- placeholder: f("bigconsole.widget.config.table.rule.value2Placeholder", "and"),
374
- className: `${u} w-20`
435
+ onChange: (e) => x(t, r, { value2: e.target.value }),
436
+ placeholder: p("bigconsole.widget.config.table.rule.value2Placeholder", "and"),
437
+ className: `${d} w-20`
375
438
  }),
376
- /* @__PURE__ */ o("button", {
439
+ /* @__PURE__ */ s("button", {
377
440
  type: "button",
378
- onClick: () => S(t, r),
441
+ onClick: () => C(t, r),
379
442
  className: "text-status-error-text hover:text-status-error-text/80",
380
- "aria-label": f("bigconsole.widget.config.table.rule.remove", "Remove rule"),
381
- children: /* @__PURE__ */ o("svg", {
443
+ "aria-label": p("bigconsole.widget.config.table.rule.remove", "Remove rule"),
444
+ children: /* @__PURE__ */ s("svg", {
382
445
  className: "w-3.5 h-3.5",
383
446
  fill: "none",
384
447
  stroke: "currentColor",
385
448
  viewBox: "0 0 24 24",
386
- children: /* @__PURE__ */ o("path", {
449
+ children: /* @__PURE__ */ s("path", {
387
450
  strokeLinecap: "round",
388
451
  strokeLinejoin: "round",
389
452
  strokeWidth: 2,
@@ -392,27 +455,27 @@ var c = [
392
455
  })
393
456
  })
394
457
  ]
395
- }), /* @__PURE__ */ s("div", {
458
+ }), /* @__PURE__ */ c("div", {
396
459
  className: "flex items-center gap-2",
397
- children: [/* @__PURE__ */ o("select", {
398
- value: p,
399
- onChange: (e) => x(t, r, e.target.value),
400
- className: `${u} flex-1`,
401
- children: l.map((e) => /* @__PURE__ */ o("option", {
460
+ children: [/* @__PURE__ */ s("select", {
461
+ value: f,
462
+ onChange: (e) => S(t, r, e.target.value),
463
+ className: `${d} flex-1`,
464
+ children: u.map((e) => /* @__PURE__ */ s("option", {
402
465
  value: e.value,
403
- children: f(e.labelKey, e.labelDefault)
466
+ children: p(e.labelKey, e.labelDefault)
404
467
  }, e.value))
405
- }), /* @__PURE__ */ s("label", {
468
+ }), /* @__PURE__ */ c("label", {
406
469
  className: "flex items-center gap-1 text-xs text-text-primary",
407
- children: [/* @__PURE__ */ o("input", {
470
+ children: [/* @__PURE__ */ s("input", {
408
471
  type: "checkbox",
409
472
  checked: n.style?.bold === !0,
410
- onChange: (e) => b(t, r, { style: {
473
+ onChange: (e) => x(t, r, { style: {
411
474
  ...n.style,
412
475
  bold: e.target.checked
413
476
  } }),
414
477
  className: "w-3.5 h-3.5 text-action-primary-bg bg-bg-surface border-border-default rounded focus:ring-action-primary-bg"
415
- }), f("bigconsole.widget.config.table.rule.bold", "Bold")]
478
+ }), p("bigconsole.widget.config.table.rule.bold", "Bold")]
416
479
  })]
417
480
  })]
418
481
  }, r);
@@ -421,79 +484,79 @@ var c = [
421
484
  ]
422
485
  })
423
486
  ]
424
- }, t)), m.length === 0 && /* @__PURE__ */ o("p", {
487
+ }, t)), h.length === 0 && /* @__PURE__ */ s("p", {
425
488
  className: "text-sm text-text-secondary text-center py-4",
426
- children: f("bigconsole.widget.config.table.columns.empty", "No columns configured. Columns will be auto-generated from data.")
489
+ children: p("bigconsole.widget.config.table.columns.empty", "No columns configured. Columns will be auto-generated from data.")
427
490
  })]
428
491
  })
429
492
  ] }),
430
- /* @__PURE__ */ s("div", {
493
+ /* @__PURE__ */ c("div", {
431
494
  role: "group",
432
495
  "aria-label": "Display options",
433
496
  className: "space-y-3 border-t border-[var(--color-border-subtle)] pt-form-gap",
434
497
  children: [
435
- /* @__PURE__ */ o("p", {
498
+ /* @__PURE__ */ s("p", {
436
499
  className: "text-xs font-bold uppercase tracking-wider text-text-secondary",
437
500
  children: "Display options"
438
501
  }),
439
- /* @__PURE__ */ s("label", {
502
+ /* @__PURE__ */ c("label", {
440
503
  className: "flex items-center gap-3",
441
- children: [/* @__PURE__ */ o("input", {
504
+ children: [/* @__PURE__ */ s("input", {
442
505
  type: "checkbox",
443
- checked: e.showSearch !== !1,
444
- onChange: (e) => g("showSearch", e.target.checked),
506
+ checked: t.showSearch !== !1,
507
+ onChange: (e) => _("showSearch", e.target.checked),
445
508
  className: "\n w-4 h-4\n text-action-primary-bg\n bg-bg-surface\n border-border-default\n rounded\n focus:ring-action-primary-bg\n "
446
- }), /* @__PURE__ */ o("span", {
509
+ }), /* @__PURE__ */ s("span", {
447
510
  className: "text-sm text-text-primary",
448
- children: f("bigconsole.widget.config.table.showSearch", "Show search box")
511
+ children: p("bigconsole.widget.config.table.showSearch", "Show search box")
449
512
  })]
450
513
  }),
451
- /* @__PURE__ */ s("label", {
514
+ /* @__PURE__ */ c("label", {
452
515
  className: "flex items-center gap-3",
453
- children: [/* @__PURE__ */ o("input", {
516
+ children: [/* @__PURE__ */ s("input", {
454
517
  type: "checkbox",
455
- checked: e.showPagination !== !1,
456
- onChange: (e) => g("showPagination", e.target.checked),
518
+ checked: t.showPagination !== !1,
519
+ onChange: (e) => _("showPagination", e.target.checked),
457
520
  className: "\n w-4 h-4\n text-action-primary-bg\n bg-bg-surface\n border-border-default\n rounded\n focus:ring-action-primary-bg\n "
458
- }), /* @__PURE__ */ o("span", {
521
+ }), /* @__PURE__ */ s("span", {
459
522
  className: "text-sm text-text-primary",
460
- children: f("bigconsole.widget.config.table.showPagination", "Show pagination")
523
+ children: p("bigconsole.widget.config.table.showPagination", "Show pagination")
461
524
  })]
462
525
  }),
463
- /* @__PURE__ */ s("label", {
526
+ /* @__PURE__ */ c("label", {
464
527
  className: "flex items-center gap-3",
465
- children: [/* @__PURE__ */ o("input", {
528
+ children: [/* @__PURE__ */ s("input", {
466
529
  type: "checkbox",
467
- checked: e.showExport !== !1,
468
- onChange: (e) => g("showExport", e.target.checked),
530
+ checked: t.showExport !== !1,
531
+ onChange: (e) => _("showExport", e.target.checked),
469
532
  className: "\n w-4 h-4\n text-action-primary-bg\n bg-bg-surface\n border-border-default\n rounded\n focus:ring-action-primary-bg\n "
470
- }), /* @__PURE__ */ o("span", {
533
+ }), /* @__PURE__ */ s("span", {
471
534
  className: "text-sm text-text-primary",
472
- children: f("bigconsole.widget.config.table.showExport", "Show export button")
535
+ children: p("bigconsole.widget.config.table.showExport", "Show export button")
473
536
  })]
474
537
  }),
475
- /* @__PURE__ */ s("label", {
538
+ /* @__PURE__ */ c("label", {
476
539
  className: "flex items-center gap-3",
477
- children: [/* @__PURE__ */ o("input", {
540
+ children: [/* @__PURE__ */ s("input", {
478
541
  type: "checkbox",
479
- checked: e.stickyHeader === !0,
480
- onChange: (e) => g("stickyHeader", e.target.checked),
542
+ checked: t.stickyHeader === !0,
543
+ onChange: (e) => _("stickyHeader", e.target.checked),
481
544
  className: "\n w-4 h-4\n text-action-primary-bg\n bg-bg-surface\n border-border-default\n rounded\n focus:ring-action-primary-bg\n "
482
- }), /* @__PURE__ */ o("span", {
545
+ }), /* @__PURE__ */ s("span", {
483
546
  className: "text-sm text-text-primary",
484
- children: f("bigconsole.widget.config.table.stickyHeader", "Sticky header")
547
+ children: p("bigconsole.widget.config.table.stickyHeader", "Sticky header")
485
548
  })]
486
549
  }),
487
- /* @__PURE__ */ s("label", {
550
+ /* @__PURE__ */ c("label", {
488
551
  className: "flex items-center gap-3",
489
- children: [/* @__PURE__ */ o("input", {
552
+ children: [/* @__PURE__ */ s("input", {
490
553
  type: "checkbox",
491
- checked: e.stripedRows === !0,
492
- onChange: (e) => g("stripedRows", e.target.checked),
554
+ checked: t.stripedRows === !0,
555
+ onChange: (e) => _("stripedRows", e.target.checked),
493
556
  className: "\n w-4 h-4\n text-action-primary-bg\n bg-bg-surface\n border-border-default\n rounded\n focus:ring-action-primary-bg\n "
494
- }), /* @__PURE__ */ o("span", {
557
+ }), /* @__PURE__ */ s("span", {
495
558
  className: "text-sm text-text-primary",
496
- children: f("bigconsole.widget.config.table.stripedRows", "Striped rows")
559
+ children: p("bigconsole.widget.config.table.stripedRows", "Striped rows")
497
560
  })]
498
561
  })
499
562
  ]
@@ -501,4 +564,4 @@ var c = [
501
564
  ]
502
565
  });
503
566
  });
504
- export { d as TableConfig, d as default };
567
+ export { f as TableConfig, f as default };
@@ -4,15 +4,16 @@ import { useCrossFilterContext as n, useWidgetCrossFilter as r } from "../../../
4
4
  import { TableCell as i } from "./TableCell.js";
5
5
  import a from "../../../hooks/useWidgetConfigPersist.js";
6
6
  import { TablePagination as ee } from "./TablePagination.js";
7
- import { resolveRowClassName as te } from "../utils/conditionalFormat.js";
7
+ import { resolveDefaultSort as te } from "./tableSort.js";
8
+ import { resolveRowClassName as ne } from "../utils/conditionalFormat.js";
8
9
  import "../../../contexts/index.js";
9
10
  import "../../../store/index.js";
10
11
  import "../../../hooks/index.js";
11
- import { memo as o, useCallback as s, useEffect as ne, useMemo as c, useRef as re, useState as l } from "react";
12
- import { useI18n as ie } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
12
+ import { memo as o, useCallback as s, useEffect as re, useMemo as c, useRef as ie, useState as l } from "react";
13
+ import { useI18n as ae } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
13
14
  import { jsx as u, jsxs as d } from "react/jsx-runtime";
14
15
  // src/bigconsole/components/widgets/table/TableWidget.tsx
15
- function ae(e, t) {
16
+ function oe(e, t) {
16
17
  return !t.column || !t.direction ? e : [...e].sort((e, n) => {
17
18
  let r = e[t.column], i = n[t.column];
18
19
  if (r == null && i == null) return 0;
@@ -30,7 +31,7 @@ function f(e, t, n) {
30
31
  return n != null && String(n).toLowerCase().includes(r);
31
32
  }));
32
33
  }
33
- function oe(e, t, n) {
34
+ function se(e, t, n) {
34
35
  switch (t) {
35
36
  case "currency": return new Intl.NumberFormat("en-US", {
36
37
  style: "currency",
@@ -42,7 +43,7 @@ function oe(e, t, n) {
42
43
  }
43
44
  }
44
45
  var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
45
- let { t: g } = ie(), _ = o.config, v = c(() => {
46
+ let { t: g } = ae(), _ = o.config, v = c(() => {
46
47
  if (Array.isArray(p)) return p;
47
48
  if (p && typeof p == "object") {
48
49
  for (let e of [
@@ -61,14 +62,13 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
61
62
  return [p];
62
63
  }
63
64
  return [];
64
- }, [p]), { handleDataClick: y, enabled: b } = r(o.id, _?.crossFilterMappings), { clearAllCrossFilters: x, hasCrossFilters: S } = n(), [C, se] = l({
65
- column: _?.defaultSortColumn || null,
66
- direction: _?.defaultSortDirection || null
67
- }), [w, ce] = l(""), [T, E] = l({
65
+ }, [p]), { handleDataClick: y, enabled: b } = r(o.id, _?.crossFilterMappings), { clearAllCrossFilters: ce, hasCrossFilters: le } = n(), x = te(_), [S, C] = l(x), [w, ue] = l(x);
66
+ (w.column !== x.column || w.direction !== x.direction) && (ue(x), C(x));
67
+ let [T, de] = l(""), [E, D] = l({
68
68
  page: 0,
69
69
  pageSize: _?.pageSize || 10,
70
70
  totalItems: 0
71
- }), D = e(), { persistConfig: O } = a(o), [k, A] = l({}), [j, le] = l(null), M = c(() => _?.columns?.length ? _.columns.map((e) => {
71
+ }), O = e(), { persistConfig: k } = a(o), [A, j] = l({}), [M, fe] = l(null), N = c(() => _?.columns?.length ? _.columns.map((e) => {
72
72
  if (typeof e == "string") return {
73
73
  key: e,
74
74
  header: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " "),
@@ -86,28 +86,28 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
86
86
  key: e,
87
87
  header: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " "),
88
88
  sortable: !0
89
- })) : [], [_?.columns, v]), N = c(() => {
90
- let e = M;
91
- if (j) {
92
- let t = new Map(M.map((e) => [e.key, e])), n = j.map((e) => t.get(e)).filter((e) => e !== void 0), r = M.filter((e) => !j.includes(e.key));
89
+ })) : [], [_?.columns, v]), P = c(() => {
90
+ let e = N;
91
+ if (M) {
92
+ let t = new Map(N.map((e) => [e.key, e])), n = M.map((e) => t.get(e)).filter((e) => e !== void 0), r = N.filter((e) => !M.includes(e.key));
93
93
  e = [...n, ...r];
94
94
  }
95
- return Object.keys(k).length > 0 && (e = e.map((e) => k[e.key] == null ? e : {
95
+ return Object.keys(A).length > 0 && (e = e.map((e) => A[e.key] == null ? e : {
96
96
  ...e,
97
- width: `${k[e.key]}px`
97
+ width: `${A[e.key]}px`
98
98
  })), e;
99
99
  }, [
100
+ N,
100
101
  M,
101
- j,
102
- k
103
- ]), P = s((e, t) => {
102
+ A
103
+ ]), F = s((e, t) => {
104
104
  let n = /* @__PURE__ */ new Map();
105
105
  _?.columns?.forEach((e) => {
106
106
  let t = e.key || e.field;
107
107
  t && n.set(t, e);
108
108
  });
109
- let r = M.map((e) => e.key), i = [...e.filter((e) => r.includes(e)), ...r.filter((t) => !e.includes(t))].map((e) => {
110
- let r = M.find((t) => t.key === e), i = {
109
+ let r = N.map((e) => e.key), i = [...e.filter((e) => r.includes(e)), ...r.filter((t) => !e.includes(t))].map((e) => {
110
+ let r = N.find((t) => t.key === e), i = {
111
111
  ...n.get(e) ?? {},
112
112
  key: e
113
113
  };
@@ -115,42 +115,42 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
115
115
  let a = t[e];
116
116
  return a != null && (i.width = a), i;
117
117
  });
118
- O({ columns: i });
118
+ k({ columns: i });
119
119
  }, [
120
- M,
120
+ N,
121
121
  _?.columns,
122
- O
123
- ]), F = s((e, t) => {
124
- A((n) => ({
122
+ k
123
+ ]), pe = s((e, t) => {
124
+ j((n) => ({
125
125
  ...n,
126
126
  [e]: t
127
127
  }));
128
- }, []), ue = s((e, t) => {
128
+ }, []), me = s((e, t) => {
129
129
  let n = {
130
- ...k,
130
+ ...A,
131
131
  [e]: t
132
132
  };
133
- A(n);
134
- let r = j ?? M.map((e) => e.key);
135
- P(r, n);
133
+ j(n);
134
+ let r = M ?? N.map((e) => e.key);
135
+ F(r, n);
136
136
  }, [
137
- k,
138
- j,
137
+ A,
139
138
  M,
140
- P
141
- ]), de = s((e, t) => {
142
- let n = j ?? M.map((e) => e.key), r = n.indexOf(e);
139
+ N,
140
+ F
141
+ ]), I = s((e, t) => {
142
+ let n = M ?? N.map((e) => e.key), r = n.indexOf(e);
143
143
  if (r < 0 || e === t) return;
144
144
  let i = [...n];
145
145
  i.splice(r, 1);
146
146
  let a = i.indexOf(t);
147
- a < 0 || (i.splice(a, 0, e), le(i), P(i, k));
147
+ a < 0 || (i.splice(a, 0, e), fe(i), F(i, A));
148
148
  }, [
149
- j,
150
149
  M,
151
- k,
152
- P
153
- ]), I = c(() => {
150
+ N,
151
+ A,
152
+ F
153
+ ]), L = c(() => {
154
154
  let e = {};
155
155
  return _?.columns?.forEach((t) => {
156
156
  t.format && (t.key || t.field) && (e[t.key || t.field || ""] = {
@@ -158,110 +158,110 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
158
158
  ...t.linkPattern ? { linkPattern: t.linkPattern } : {}
159
159
  });
160
160
  }), e;
161
- }, [_?.columns]), L = c(() => {
161
+ }, [_?.columns]), R = c(() => {
162
162
  let e = {};
163
163
  return _?.columns?.forEach((t) => {
164
164
  let n = t.key || t.field;
165
165
  n && t.cellChart && (e[n] = t.cellChart);
166
166
  }), e;
167
- }, [_?.columns]), R = _?.conditionalRules, z = _?.rowRules, B = c(() => {
167
+ }, [_?.columns]), z = _?.conditionalRules, he = _?.rowRules, ge = c(() => {
168
168
  let e = {};
169
169
  return _?.columns?.forEach((t) => {
170
170
  let n = t.key || t.field;
171
171
  n && t.conditionalRules?.length && (e[n] = t.conditionalRules);
172
172
  }), e;
173
- }, [_?.columns]), V = c(() => {
173
+ }, [_?.columns]), B = c(() => {
174
174
  let e = {};
175
175
  return _?.columns?.forEach((t) => {
176
176
  let n = t.key || t.field;
177
177
  n && t.total && t.total !== "none" && (e[n] = t.total);
178
178
  }), e;
179
- }, [_?.columns]), H = _?.showTotals === !0 || Object.keys(V).length > 0, U = c(() => {
179
+ }, [_?.columns]), V = _?.showTotals === !0 || Object.keys(B).length > 0, H = c(() => {
180
180
  let e = v;
181
- return _?.showSearch !== !1 && (e = f(e, w, N)), e = ae(e, C), e;
181
+ return _?.showSearch !== !1 && (e = f(e, T, P)), e = oe(e, S), e;
182
182
  }, [
183
183
  v,
184
- w,
185
- C,
186
- N,
184
+ T,
185
+ S,
186
+ P,
187
187
  _?.showSearch
188
- ]), fe = c(() => {
188
+ ]), _e = c(() => {
189
189
  let e = {};
190
- for (let t of N) {
190
+ for (let t of P) {
191
191
  let n = 0;
192
- for (let e of U) {
192
+ for (let e of H) {
193
193
  let r = e[t.key];
194
194
  typeof r == "number" && Number.isFinite(r) && (n = Math.max(n, Math.abs(r)));
195
195
  }
196
196
  e[t.key] = n;
197
197
  }
198
198
  return e;
199
- }, [N, U]), pe = c(() => {
200
- if (!H) return {};
199
+ }, [P, H]), ve = c(() => {
200
+ if (!V) return {};
201
201
  let e = {};
202
- for (let t of N) {
203
- let n = V[t.key];
202
+ for (let t of P) {
203
+ let n = B[t.key];
204
204
  if (!n) {
205
205
  e[t.key] = null;
206
206
  continue;
207
207
  }
208
- let r = U.map((e) => e[t.key]).filter((e) => typeof e == "number" && Number.isFinite(e));
209
- n === "count" ? e[t.key] = U.length : r.length === 0 ? e[t.key] = null : n === "sum" ? e[t.key] = r.reduce((e, t) => e + t, 0) : n === "avg" ? e[t.key] = r.reduce((e, t) => e + t, 0) / r.length : n === "min" ? e[t.key] = Math.min(...r) : n === "max" ? e[t.key] = Math.max(...r) : e[t.key] = null;
208
+ let r = H.map((e) => e[t.key]).filter((e) => typeof e == "number" && Number.isFinite(e));
209
+ n === "count" ? e[t.key] = H.length : r.length === 0 ? e[t.key] = null : n === "sum" ? e[t.key] = r.reduce((e, t) => e + t, 0) : n === "avg" ? e[t.key] = r.reduce((e, t) => e + t, 0) / r.length : n === "min" ? e[t.key] = Math.min(...r) : n === "max" ? e[t.key] = Math.max(...r) : e[t.key] = null;
210
210
  }
211
211
  return e;
212
212
  }, [
213
- H,
214
- N,
215
213
  V,
216
- U
214
+ P,
215
+ B,
216
+ H
217
217
  ]);
218
218
  c(() => {
219
- E((e) => ({
219
+ D((e) => ({
220
220
  ...e,
221
- totalItems: U.length
221
+ totalItems: H.length
222
222
  }));
223
- }, [U.length]);
224
- let me = c(() => {
225
- if (_?.showPagination === !1) return U;
226
- let e = T.page * T.pageSize;
227
- return U.slice(e, e + T.pageSize);
223
+ }, [H.length]);
224
+ let ye = c(() => {
225
+ if (_?.showPagination === !1) return H;
226
+ let e = E.page * E.pageSize;
227
+ return H.slice(e, e + E.pageSize);
228
228
  }, [
229
- U,
230
- T,
229
+ H,
230
+ E,
231
231
  _?.showPagination
232
- ]), W = _?.virtualized === !0, G = _?.rowHeight && _.rowHeight > 0 ? _.rowHeight : 44, K = re(null), [q, he] = l(0), [J, Y] = l(0);
233
- ne(() => {
234
- if (!W) return;
235
- let e = K.current;
232
+ ]), U = _?.virtualized === !0, W = _?.rowHeight && _.rowHeight > 0 ? _.rowHeight : 44, G = ie(null), [K, be] = l(0), [q, J] = l(0);
233
+ re(() => {
234
+ if (!U) return;
235
+ let e = G.current;
236
236
  if (!e) return;
237
- Y(e.clientHeight);
238
- let t = typeof ResizeObserver < "u" ? new ResizeObserver(() => Y(e.clientHeight)) : void 0;
237
+ J(e.clientHeight);
238
+ let t = typeof ResizeObserver < "u" ? new ResizeObserver(() => J(e.clientHeight)) : void 0;
239
239
  return t?.observe(e), () => t?.disconnect();
240
- }, [W]);
241
- let X = c(() => {
242
- if (!W) return null;
243
- let e = U.length, t = J > 0 ? Math.ceil(J / G) : 20, n = Math.max(0, Math.floor(q / G) - 6), r = Math.min(e, n + t + 12);
240
+ }, [U]);
241
+ let Y = c(() => {
242
+ if (!U) return null;
243
+ let e = H.length, t = q > 0 ? Math.ceil(q / W) : 20, n = Math.max(0, Math.floor(K / W) - 6), r = Math.min(e, n + t + 12);
244
244
  return {
245
- rows: U.slice(n, r),
246
- topSpacer: n * G,
247
- bottomSpacer: Math.max(0, (e - r) * G),
245
+ rows: H.slice(n, r),
246
+ topSpacer: n * W,
247
+ bottomSpacer: Math.max(0, (e - r) * W),
248
248
  startIndex: n
249
249
  };
250
250
  }, [
251
- W,
252
251
  U,
253
- J,
252
+ H,
254
253
  q,
255
- G
256
- ]), ge = W && X ? X.rows : me, _e = W && X ? X.startIndex : 0, Z = _?.frozenColumns && _.frozenColumns > 0 ? _.frozenColumns : 0, { displayColumns: Q, frozenLefts: $ } = c(() => {
257
- if (Z <= 0) return {
258
- displayColumns: N,
254
+ K,
255
+ W
256
+ ]), xe = U && Y ? Y.rows : ye, Se = U && Y ? Y.startIndex : 0, X = _?.frozenColumns && _.frozenColumns > 0 ? _.frozenColumns : 0, { displayColumns: Z, frozenLefts: Q } = c(() => {
257
+ if (X <= 0) return {
258
+ displayColumns: P,
259
259
  frozenLefts: {}
260
260
  };
261
261
  let e = {}, t = 0;
262
262
  return {
263
- displayColumns: N.map((n, r) => {
264
- if (r < Z) {
263
+ displayColumns: P.map((n, r) => {
264
+ if (r < X) {
265
265
  let r = n.width && parseInt(n.width, 10) || 160;
266
266
  return e[n.key] = t, t += r, {
267
267
  ...n,
@@ -272,8 +272,8 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
272
272
  }),
273
273
  frozenLefts: e
274
274
  };
275
- }, [N, Z]), ve = s((e) => {
276
- se((t) => {
275
+ }, [P, X]), Ce = s((e) => {
276
+ C((t) => {
277
277
  if (t.column !== e) return {
278
278
  column: e,
279
279
  direction: "asc"
@@ -284,21 +284,21 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
284
284
  direction: n
285
285
  };
286
286
  });
287
- }, []), ye = s((e) => {
288
- E((t) => ({
287
+ }, []), we = s((e) => {
288
+ D((t) => ({
289
289
  ...t,
290
290
  page: e
291
291
  }));
292
- }, []), be = s((e) => {
293
- E((t) => ({
292
+ }, []), Te = s((e) => {
293
+ D((t) => ({
294
294
  ...t,
295
295
  pageSize: e,
296
296
  page: 0
297
297
  }));
298
- }, []), xe = s((e, t) => {
298
+ }, []), Ee = s((e, t) => {
299
299
  let n = _?.crossFilterMappings?.length || _?.enableCrossFilter;
300
300
  if (b && n) {
301
- let t = N[0]?.key, n = t ? String(e[t]) : void 0;
301
+ let t = P[0]?.key, n = t ? String(e[t]) : void 0;
302
302
  y(e, n);
303
303
  }
304
304
  h ? h(e) : m && o.drilldowns?.length && m(e, t);
@@ -308,11 +308,11 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
308
308
  o.drilldowns,
309
309
  b,
310
310
  y,
311
- N,
311
+ P,
312
312
  _?.crossFilterMappings,
313
313
  _?.enableCrossFilter
314
- ]), Se = s(() => {
315
- let e = [N.map((e) => e.header).join(","), ...U.map((e) => N.map((t) => {
314
+ ]), $ = s(() => {
315
+ let e = [P.map((e) => e.header).join(","), ...H.map((e) => P.map((t) => {
316
316
  let n = e[t.key];
317
317
  if (n == null) return "";
318
318
  let r = String(n);
@@ -320,19 +320,19 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
320
320
  }).join(","))].join("\n"), t = new Blob([e], { type: "text/csv" }), n = URL.createObjectURL(t), r = document.createElement("a");
321
321
  r.href = n, r.download = `${o.title || "table"}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`, r.click(), URL.revokeObjectURL(n);
322
322
  }, [
323
- N,
324
- U,
323
+ P,
324
+ H,
325
325
  o.title
326
- ]), Ce = _?.crossFilterMappings?.length || _?.enableCrossFilter, we = !!(h || m && o.drilldowns?.length || Ce);
326
+ ]), De = _?.crossFilterMappings?.length || _?.enableCrossFilter, Oe = !!(h || m && o.drilldowns?.length || De);
327
327
  return /* @__PURE__ */ d("div", {
328
328
  className: "flex flex-col h-full",
329
329
  children: [
330
- S && /* @__PURE__ */ u("div", {
330
+ le && /* @__PURE__ */ u("div", {
331
331
  className: "flex items-center gap-2 px-3 py-2 border-b border-border-default",
332
332
  children: /* @__PURE__ */ d("button", {
333
333
  type: "button",
334
334
  onClick: (e) => {
335
- e.stopPropagation(), x();
335
+ e.stopPropagation(), ce();
336
336
  },
337
337
  className: "\n inline-flex items-center gap-1.5\n px-2.5 py-1 rounded-md\n text-xs font-medium\n bg-action-primary-bg/10 text-action-primary-text\n hover:bg-action-primary-bg/20\n transition-colors\n ",
338
338
  children: [/* @__PURE__ */ u("svg", {
@@ -368,13 +368,13 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
368
368
  type: "text",
369
369
  placeholder: g("bigconsole.widget.table.search", "Search…"),
370
370
  "aria-label": g("bigconsole.widget.table.search", "Search…"),
371
- value: w,
372
- onChange: (e) => ce(e.target.value),
371
+ value: T,
372
+ onChange: (e) => de(e.target.value),
373
373
  className: "\n pl-10 pr-4 py-2\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg focus:border-action-primary-bg\n w-48 sm:w-64\n placeholder:text-text-muted\n "
374
374
  })]
375
375
  }), _?.showExport !== !1 && /* @__PURE__ */ d("button", {
376
376
  type: "button",
377
- onClick: Se,
377
+ onClick: $,
378
378
  className: "\n inline-flex items-center gap-2\n px-3 py-2\n text-sm font-medium\n text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n hover:bg-bg-sunken\n transition-colors\n ",
379
379
  children: [/* @__PURE__ */ u("svg", {
380
380
  className: "w-4 h-4",
@@ -391,61 +391,61 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
391
391
  })]
392
392
  }),
393
393
  /* @__PURE__ */ d("div", {
394
- ref: K,
394
+ ref: G,
395
395
  className: "flex-1 overflow-auto",
396
- onScroll: W ? (e) => he(e.target.scrollTop) : void 0,
396
+ onScroll: U ? (e) => be(e.target.scrollTop) : void 0,
397
397
  children: [/* @__PURE__ */ d("table", {
398
398
  className: "w-full",
399
399
  children: [
400
400
  /* @__PURE__ */ u(t, {
401
- columns: Q,
402
- sortState: C,
403
- onSort: ve,
404
- frozenLefts: Z > 0 ? $ : void 0,
405
- editable: D,
406
- onColumnResize: D ? F : void 0,
407
- onColumnResizeEnd: D ? ue : void 0,
408
- onColumnReorder: D ? de : void 0
401
+ columns: Z,
402
+ sortState: S,
403
+ onSort: Ce,
404
+ frozenLefts: X > 0 ? Q : void 0,
405
+ editable: O,
406
+ onColumnResize: O ? pe : void 0,
407
+ onColumnResizeEnd: O ? me : void 0,
408
+ onColumnReorder: O ? I : void 0
409
409
  }),
410
410
  /* @__PURE__ */ d("tbody", { children: [
411
- W && X && X.topSpacer > 0 && /* @__PURE__ */ u("tr", {
411
+ U && Y && Y.topSpacer > 0 && /* @__PURE__ */ u("tr", {
412
412
  "aria-hidden": "true",
413
- style: { height: X.topSpacer },
413
+ style: { height: Y.topSpacer },
414
414
  children: /* @__PURE__ */ u("td", {
415
- colSpan: Q.length,
415
+ colSpan: Z.length,
416
416
  style: {
417
417
  padding: 0,
418
418
  border: "none"
419
419
  }
420
420
  })
421
421
  }),
422
- ge.map((e, t) => {
423
- let n = _e + t;
422
+ xe.map((e, t) => {
423
+ let n = Se + t;
424
424
  return /* @__PURE__ */ u("tr", {
425
425
  className: `
426
- ${we ? "cursor-pointer hover:bg-bg-sunken/50" : ""}
426
+ ${Oe ? "cursor-pointer hover:bg-bg-sunken/50" : ""}
427
427
  ${n % 2 == 0 ? "bg-bg-surface" : "bg-bg-sunken/30"}
428
- ${te(e, z)}
428
+ ${ne(e, he)}
429
429
  `,
430
- style: W ? { height: G } : void 0,
431
- onClick: () => xe(e, n),
432
- children: Q.map((t) => /* @__PURE__ */ u(i, {
430
+ style: U ? { height: W } : void 0,
431
+ onClick: () => Ee(e, n),
432
+ children: Z.map((t) => /* @__PURE__ */ u(i, {
433
433
  value: e[t.key],
434
434
  column: t,
435
- format: I[t.key],
435
+ format: L[t.key],
436
436
  rowData: e,
437
- conditionalRules: B[t.key] ?? R,
438
- dataBarMax: fe[t.key],
439
- stickyLeft: $[t.key],
440
- cellChart: L[t.key]
437
+ conditionalRules: ge[t.key] ?? z,
438
+ dataBarMax: _e[t.key],
439
+ stickyLeft: Q[t.key],
440
+ cellChart: R[t.key]
441
441
  }, t.key))
442
442
  }, n);
443
443
  }),
444
- W && X && X.bottomSpacer > 0 && /* @__PURE__ */ u("tr", {
444
+ U && Y && Y.bottomSpacer > 0 && /* @__PURE__ */ u("tr", {
445
445
  "aria-hidden": "true",
446
- style: { height: X.bottomSpacer },
446
+ style: { height: Y.bottomSpacer },
447
447
  children: /* @__PURE__ */ u("td", {
448
- colSpan: Q.length,
448
+ colSpan: Z.length,
449
449
  style: {
450
450
  padding: 0,
451
451
  border: "none"
@@ -453,10 +453,10 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
453
453
  })
454
454
  })
455
455
  ] }),
456
- H && U.length > 0 && /* @__PURE__ */ u("tfoot", { children: /* @__PURE__ */ u("tr", {
456
+ V && H.length > 0 && /* @__PURE__ */ u("tfoot", { children: /* @__PURE__ */ u("tr", {
457
457
  className: "bg-bg-sunken/50 font-semibold border-t-2 border-border-default",
458
- children: Q.map((e, t) => {
459
- let n = pe[e.key], r = I[e.key], i = $[e.key];
458
+ children: Z.map((e, t) => {
459
+ let n = ve[e.key], r = L[e.key], i = Q[e.key];
460
460
  return /* @__PURE__ */ u("td", {
461
461
  className: `
462
462
  px-4 py-3 text-sm text-text-primary
@@ -465,23 +465,23 @@ var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
465
465
  ${i == null ? "" : "sticky z-10 bg-bg-sunken"}
466
466
  `,
467
467
  style: i == null ? void 0 : { left: i },
468
- children: n == null ? t === 0 ? "Total" : "" : oe(n, r?.type, r?.currency)
468
+ children: n == null ? t === 0 ? "Total" : "" : se(n, r?.type, r?.currency)
469
469
  }, e.key);
470
470
  })
471
471
  }) })
472
472
  ]
473
- }), U.length === 0 && /* @__PURE__ */ u("div", {
473
+ }), H.length === 0 && /* @__PURE__ */ u("div", {
474
474
  className: "flex items-center justify-center py-12 text-text-secondary",
475
- children: w ? "No matching records found" : "No data available"
475
+ children: T ? "No matching records found" : "No data available"
476
476
  })]
477
477
  }),
478
- !W && _?.showPagination !== !1 && U.length > 0 && /* @__PURE__ */ u(ee, {
478
+ !U && _?.showPagination !== !1 && H.length > 0 && /* @__PURE__ */ u(ee, {
479
479
  pagination: {
480
- ...T,
481
- totalItems: U.length
480
+ ...E,
481
+ totalItems: H.length
482
482
  },
483
- onPageChange: ye,
484
- onPageSizeChange: be
483
+ onPageChange: we,
484
+ onPageSizeChange: Te
485
485
  })
486
486
  ]
487
487
  });
@@ -0,0 +1,12 @@
1
+ import { TableConfig } from '../../../types';
2
+ import { SortState } from './TableHeader';
3
+ type DefaultSortConfig = Pick<TableConfig, 'defaultSortColumn' | 'defaultSortDirection'>;
4
+ /**
5
+ * The sort a table starts with: the column and direction saved in its config.
6
+ *
7
+ * A column without a direction sorts ascending. Before this, a column saved
8
+ * without a direction left the table unsorted, because the sort needs both.
9
+ * Without a column there is no sort, whatever direction is saved.
10
+ */
11
+ export declare function resolveDefaultSort(config: DefaultSortConfig | undefined): SortState;
12
+ export {};
@@ -0,0 +1,12 @@
1
+ // src/bigconsole/components/widgets/table/tableSort.ts
2
+ function e(e) {
3
+ let t = e?.defaultSortColumn?.trim();
4
+ return t ? {
5
+ column: t,
6
+ direction: e?.defaultSortDirection === "desc" ? "desc" : "asc"
7
+ } : {
8
+ column: null,
9
+ direction: null
10
+ };
11
+ }
12
+ export { e as resolveDefaultSort };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-bigconsole",
3
- "version": "2026.1110.8",
3
+ "version": "2026.1111.1",
4
4
  "description": "BigConsole - AI-powered analytics and dashboard platform",
5
5
  "repository": {
6
6
  "type": "git",