@krak-stack/registry 0.11.5 → 0.11.6

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.
@@ -465,9 +465,16 @@ import { Csv } from "effect/encoding";
465
465
  import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
466
466
 
467
467
  // ../../src/components/data-table/schema.ts
468
- import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
468
+ import { DateTime as DateTime2, Option as Option2, Predicate, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
469
469
 
470
470
  // ../../src/components/data-table/classes.ts
471
+ var booleanCellControl = "flex min-h-16 w-full items-center justify-start px-2 in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0 has-[:focus-visible]:outline-2 has-[:focus-visible]:-outline-offset-2 has-[:focus-visible]:outline-ring";
472
+ var cellTriggerFocus = "focus-visible:ring-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring";
473
+ var tableBadgeTones = {
474
+ success: "border-emerald-200 bg-emerald-100 text-emerald-900 dark:border-emerald-900/50 dark:bg-emerald-950/50 dark:text-emerald-200",
475
+ info: "border-blue-200 bg-blue-100 text-blue-900 dark:border-blue-900/50 dark:bg-blue-950/50 dark:text-blue-200",
476
+ muted: "border-muted bg-muted text-muted-foreground dark:bg-muted/50"
477
+ };
471
478
  var tableClasses = {
472
479
  selectionCell: "w-10 p-0 align-middle",
473
480
  selectionCenter: "grid place-items-center",
@@ -479,16 +486,16 @@ var tableClasses = {
479
486
  menubar: "h-auto w-full flex-wrap justify-start border border-input bg-transparent",
480
487
  cell: "overflow-hidden",
481
488
  cellContent: "min-w-0 wrap-anywhere",
482
- actionTrigger: "size-8 focus-visible:ring-inset",
489
+ actionTrigger: `size-8 ${cellTriggerFocus}`,
483
490
  actionsCell: "sticky right-0 z-20 w-10 min-w-10 cursor-default bg-background p-0 transition-colors group-hover/row:bg-[color-mix(in_oklab,var(--muted)_50%,var(--background))]",
484
491
  actionsAlign: "flex min-h-12 items-center justify-end pe-1",
485
492
  header: "relative h-12 p-0",
486
493
  stickyHeader: "sticky top-0 z-30 bg-background",
487
494
  stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
488
- headerTrigger: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 focus-visible:ring-inset",
495
+ headerTrigger: `absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 ${cellTriggerFocus}`,
489
496
  resizeHandle: "absolute inset-y-0 right-0 z-10 w-2 cursor-col-resize touch-none outline-none after:absolute after:inset-y-3 after:right-0 after:w-px after:bg-border hover:after:w-0.5 hover:after:bg-primary/60 focus-visible:after:w-0.5 focus-visible:after:bg-ring",
490
497
  relationshipCell: "grid min-h-16 in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0",
491
- relationshipTrigger: "h-full w-full min-w-0 justify-between rounded-none px-2 text-start focus-visible:ring-inset",
498
+ relationshipTrigger: `h-full w-full min-w-0 justify-between rounded-none px-2 text-start ${cellTriggerFocus}`,
492
499
  reference: "flex min-w-0 items-center gap-2",
493
500
  referenceAvatar: "relative grid size-8 shrink-0 place-items-center overflow-hidden bg-muted text-xs font-medium",
494
501
  referenceText: "flex min-w-0 flex-col leading-tight",
@@ -612,8 +619,33 @@ var column = {
612
619
  emptyLabel: Schema4.optionalKey(Schema4.String),
613
620
  nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
614
621
  };
622
+ var DataTableBadgeOptionSchema = Schema4.Struct({
623
+ value: Schema4.NonEmptyString,
624
+ label: Schema4.optionalKey(Schema4.String),
625
+ variant: Schema4.optionalKey(Schema4.Literals([
626
+ "default",
627
+ "secondary",
628
+ "outline",
629
+ "destructive",
630
+ "success",
631
+ "info",
632
+ "muted"
633
+ ]))
634
+ }).annotate({ identifier: "DataTableBadgeOption" });
635
+ var BadgeIcon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableBadgeIcon" });
636
+ var DataTableBadgeOptionsSchema = Schema4.Struct({
637
+ options: Schema4.optionalKey(Schema4.Array(DataTableBadgeOptionSchema.mapFields((fields) => ({
638
+ ...fields,
639
+ icon: Schema4.optionalKey(BadgeIcon)
640
+ }))))
641
+ }).annotate({ identifier: "DataTableBadgeOptions" });
615
642
  var DataTableFieldSchema = Schema4.Union([
616
- Schema4.Struct({ ...column, type: Schema4.Literal("text") }),
643
+ Schema4.Struct({
644
+ ...column,
645
+ type: Schema4.Literal("text"),
646
+ display: Schema4.optionalKey(Schema4.Literal("badge")),
647
+ typeOptions: Schema4.optionalKey(DataTableBadgeOptionsSchema)
648
+ }),
617
649
  Schema4.Struct({
618
650
  ...column,
619
651
  type: Schema4.Literal("number"),
@@ -656,7 +688,7 @@ var DataTableFieldSchema = Schema4.Union([
656
688
  options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
657
689
  allowRemove: Schema4.optionalKey(Schema4.Boolean),
658
690
  itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
659
- display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
691
+ display: Schema4.optionalKey(Schema4.Literals(["list", "icon", "badge"])),
660
692
  visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
661
693
  actionsLabel: Schema4.optionalKey(Schema4.String),
662
694
  manageLabel: Schema4.optionalKey(Schema4.String)
@@ -958,7 +990,33 @@ var matchesFilterText = (value, filter) => {
958
990
  return text.endsWith(query);
959
991
  }
960
992
  };
961
- var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
993
+ var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" || column.display === "badge" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
994
+ var tableBadgeValue = (value) => isTableText(value) && value !== "" ? value : null;
995
+ var tableBadge = (input, config) => {
996
+ const value = tableBadgeValue(input);
997
+ if (value === null)
998
+ return null;
999
+ const option = config?.options?.find((option) => option.value === value);
1000
+ return {
1001
+ value,
1002
+ label: option?.label ?? value,
1003
+ variant: option?.variant ?? "secondary",
1004
+ option
1005
+ };
1006
+ };
1007
+ var tableBadgeFilterOptions = (values, config) => {
1008
+ const options = new Map(config?.options?.map(({ value, label }) => [value, label ?? value]));
1009
+ for (const input of values) {
1010
+ const value = tableBadgeValue(input);
1011
+ if (value !== null && !options.has(value))
1012
+ options.set(value, value);
1013
+ }
1014
+ return [...options].map(([value, label]) => ({ value, label }));
1015
+ };
1016
+ var tableBadgeSearchText = (value, config) => {
1017
+ const badge = tableBadge(value, config);
1018
+ return badge ? `${badge.label} ${badge.value}` : "";
1019
+ };
962
1020
  var matchesTableFilter = (filter, value, type, text, values) => {
963
1021
  switch (filter.kind) {
964
1022
  case "text":
@@ -1003,13 +1061,20 @@ var filterTableColumns = (rows, columns, filters) => {
1003
1061
  return rows;
1004
1062
  return rows.filter((row) => active.every((filter) => {
1005
1063
  const value = row.cells[filter.id];
1006
- return matchesTableFilter(filter, value, byId.get(filter.id)?.type, () => isTableText(value) ? value : isTableReference(value) ? `${value.label} ${value.description ?? ""}`.trim() : "", () => isTableList(value) ? value.map(({ value }) => value) : []);
1064
+ const column = byId.get(filter.id);
1065
+ return matchesTableFilter(filter, value, column?.type, () => isTableText(value) ? value : isTableReference(value) ? `${value.label} ${value.description ?? ""}`.trim() : "", () => {
1066
+ if (column?.type === "text" && column.display === "badge") {
1067
+ const key = tableBadgeValue(value);
1068
+ return key === null ? [] : [key];
1069
+ }
1070
+ return isTableList(value) ? value.map(({ value }) => value) : [];
1071
+ });
1007
1072
  }));
1008
1073
  };
1009
1074
  var columnValue = (column, value) => {
1010
1075
  switch (column.type) {
1011
1076
  case "text":
1012
- return isTableText(value) ? value : null;
1077
+ return column.display === "badge" ? tableBadgeValue(value) : isTableText(value) ? value : null;
1013
1078
  case "number":
1014
1079
  case "boolean":
1015
1080
  case "date":
@@ -1063,6 +1128,8 @@ var filterTableRows = (rows, columns, search, locale) => {
1063
1128
  const searchable = columns.filter(({ searchable }) => searchable !== false);
1064
1129
  return rows.filter((row) => searchable.some((column) => {
1065
1130
  const value = row.cells[column.id];
1131
+ if (column.type === "text" && column.display === "badge")
1132
+ return tableBadgeSearchText(value, column.typeOptions).toLocaleLowerCase(locale).includes(query);
1066
1133
  if (column.type === "date" || column.type === "dateTime") {
1067
1134
  const date = resolveDate(value, column.type);
1068
1135
  return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
@@ -1818,6 +1885,14 @@ var dataTableBehaviours = {
1818
1885
  // ../../src/components/data-table/html.ts
1819
1886
  var keyOf = (...parts) => JSON.stringify(parts);
1820
1887
  var cellClass = "px-3 py-2 align-middle";
1888
+ var badgeVariants = {
1889
+ ...tableBadgeTones,
1890
+ default: "bg-primary text-primary-foreground",
1891
+ secondary: "bg-secondary text-secondary-foreground",
1892
+ outline: "border-border text-foreground",
1893
+ destructive: "bg-destructive/10 text-destructive dark:bg-destructive/20"
1894
+ };
1895
+ var badgeClass = "inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap";
1821
1896
  var isTextFilterOperator = Schema6.is(TextFilterOperator);
1822
1897
  var RowDrag = "application/x-krakstack-table-row";
1823
1898
  var PersistPreferences = Mount.makeStream("DataTable/PersistPreferences", {
@@ -2088,11 +2163,13 @@ var DataTable = Html2.component({
2088
2163
  })))));
2089
2164
  }
2090
2165
  });
2091
- const check = (key, label, checked, onToggle, options) => Checkbox(h, {
2166
+ const check = (key, label, checked, onToggle, options, inCell = false) => Checkbox(h, {
2092
2167
  key,
2093
2168
  props: { checked, ...options },
2094
2169
  onEmit: { Toggled: ({ checked }) => onToggle(checked) },
2095
- view: (checkbox) => h.span.class("grid size-4 shrink-0 place-items-center").children(CheckboxRoot(h, checkbox).attr("aria-label", label).children(CheckboxIndicator(h, checkbox, {
2170
+ view: (checkbox) => h.span.class("grid size-4 shrink-0 place-items-center").children(CheckboxRoot(h, checkbox, {
2171
+ class: inCell ? "focus-visible:outline-none" : undefined
2172
+ }).attr("aria-label", label).children(CheckboxIndicator(h, checkbox, {
2096
2173
  class: "pointer-events-none"
2097
2174
  })))
2098
2175
  });
@@ -2148,9 +2225,9 @@ var DataTable = Html2.component({
2148
2225
  filter: { id, kind: "boolean", value }
2149
2226
  })
2150
2227
  }));
2151
- } else if (column.type === "list") {
2228
+ } else if (column.type === "list" || column.type === "text" && column.display === "badge") {
2152
2229
  const selected = current?.kind === "values" ? current.values : [];
2153
- const options = column.filterOptions ?? tableFilterOptions(props.rowData, id, locale);
2230
+ const options = column.type === "text" ? tableBadgeFilterOptions(props.rowData.map((row) => row.cells[id]), column.typeOptions) : column.filterOptions ?? tableFilterOptions(props.rowData, id, locale);
2154
2231
  children = options.map(({ value, label }) => {
2155
2232
  const checked = selected.includes(value);
2156
2233
  const values = updateSelectedRows(selected, [value], !checked);
@@ -2183,6 +2260,12 @@ var DataTable = Html2.component({
2183
2260
  const disabled = row.disabledColumnIds?.includes(column.id);
2184
2261
  const edit = (edit) => DataTableMessage.CellEditRequested({ rowId: row.id, columnId: column.id, edit });
2185
2262
  switch (column.type) {
2263
+ case "text": {
2264
+ if (column.display !== "badge")
2265
+ return isTableText(value) ? value : empty;
2266
+ const badge = tableBadge(value, column.typeOptions);
2267
+ return badge ? h.span.class(cn(badgeClass, badgeVariants[badge.variant])).children(badge.option?.icon && h.span.attr("aria-hidden", "true").class("inline-flex shrink-0").children(badge.option.icon(h, { size: 12 })), badge.label) : empty;
2268
+ }
2186
2269
  case "number":
2187
2270
  return isTableNumber(value) ? formatNumberValue(value, column.typeOptions, locale) : empty;
2188
2271
  case "date":
@@ -2191,7 +2274,7 @@ var DataTable = Html2.component({
2191
2274
  return date ? h.time.attr("datetime", dateIsoValue(date)).children(formatDateValue(date, column, locale)) : empty;
2192
2275
  }
2193
2276
  case "boolean":
2194
- return isTableBoolean(value) ? props.rowActivation && (!column.editable || disabled) ? value ? column.typeOptions?.trueLabel ?? copy.filterTrue : column.typeOptions?.falseLabel ?? copy.filterFalse : check(keyOf("edit", row.id, column.id), `${column.headerName}: ${row.label}`, value, (value) => edit(DataTableEdit.SetBoolean({ value })), { readOnly: !column.editable || disabled }) : empty;
2277
+ return isTableBoolean(value) ? h.label.attr("data-slot", "data-table-boolean-cell").class(cn(booleanCellControl, column.editable && !disabled && "hover:bg-muted/50 cursor-pointer")).children(check(keyOf("edit", row.id, column.id), `${column.headerName}: ${row.label}`, value, (value) => edit(DataTableEdit.SetBoolean({ value })), { readOnly: !column.editable || disabled }, true)) : empty;
2195
2278
  case "reference":
2196
2279
  return isTableReference(value) ? h.div.class(tableClasses.reference).children(h.span.class(cn(tableClasses.referenceAvatar, "rounded-full")).children(h.span.attr("aria-hidden", "true").children(tableInitials(value.label)), value.imageSrc && !model.failedImages.includes(value.imageSrc) && h.img.attrs({
2197
2280
  src: value.imageSrc,
@@ -2200,6 +2283,9 @@ var DataTable = Html2.component({
2200
2283
  }).class("absolute inset-0 size-full object-cover").on("error", DataTableMessage.ReferenceImageFailed({ src: value.imageSrc }))), h.div.class(tableClasses.referenceText).children(h.span.class(tableClasses.referenceName).children(value.label), value.description && h.span.class(tableClasses.referenceDescription).children(value.description))) : empty;
2201
2284
  case "list": {
2202
2285
  const current = isTableList(value) ? value : [];
2286
+ const visible = current.slice(0, column.visibleCount ?? 3);
2287
+ const overflow = current.length - visible.length;
2288
+ const badgeSummary = () => h.span.class("inline-flex min-w-0 flex-wrap items-center gap-1").children(visible.map(({ value, label }) => h.span.key(value).class(cn(badgeClass, badgeVariants.secondary)).children(label)), overflow > 0 && h.span.class(cn(badgeClass, badgeVariants.secondary)).children(`+${overflow}`));
2203
2289
  if (column.manageLabel && !disabled && (column.options || column.allowRemove)) {
2204
2290
  const used = new Set(current.map(({ value }) => value));
2205
2291
  const available = (column.options ?? []).filter(({ value }) => !used.has(value));
@@ -2235,15 +2321,13 @@ var DataTable = Html2.component({
2235
2321
  }
2236
2322
  ] : []
2237
2323
  ], false, undefined, false, {
2238
- relationship: h.span.class("min-w-0 truncate").children(current.length ? `${current.slice(0, column.visibleCount ?? 3).map(({ label }) => label).join(", ")}${current.length > (column.visibleCount ?? 3) ? ` +${current.length - (column.visibleCount ?? 3)}` : ""}` : empty)
2324
+ relationship: column.display === "badge" && current.length ? badgeSummary() : h.span.class("min-w-0 truncate").children(current.length ? `${current.slice(0, column.visibleCount ?? 3).map(({ label }) => label).join(", ")}${current.length > (column.visibleCount ?? 3) ? ` +${current.length - (column.visibleCount ?? 3)}` : ""}` : empty)
2239
2325
  }));
2240
2326
  }
2241
2327
  if (column.display && !column.options && !column.allowRemove) {
2242
- const visible = current.slice(0, column.visibleCount ?? 3);
2243
- const overflow = current.length - visible.length;
2244
2328
  const label = column.actionsLabel ?? (column.itemActions?.length ? copy.actions : copy.listDetails);
2245
- const summary = column.display === "icon" ? h.span.class("flex min-w-0 items-center gap-1 overflow-hidden").children(visible.map(({ value, label }) => h.span.key(value).attr("title", label).class("inline-grid size-7 place-items-center rounded-full bg-muted text-xs").children(tableInitials(label))), overflow > 0 && `+${overflow}`) : h.span.class("min-w-0 truncate").children(`${visible.map(({ label }) => label).join(", ")}${overflow > 0 ? ` +${overflow}` : ""}`);
2246
- return !current.length ? empty : overflow > 0 || column.itemActions?.length ? h.div.class("min-w-0").children(menu(keyOf("items", row.id, column.id), label, `${label}: ${row.label}`, current.map(({ value, label }) => ({
2329
+ const summary = column.display === "icon" ? h.span.class("flex min-w-0 items-center gap-1 overflow-hidden").children(visible.map(({ value, label }) => h.span.key(value).attr("title", label).class("inline-grid size-7 place-items-center rounded-full bg-muted text-xs").children(tableInitials(label))), overflow > 0 && `+${overflow}`) : column.display === "badge" ? badgeSummary() : h.span.class("min-w-0 truncate").children(`${visible.map(({ label }) => label).join(", ")}${overflow > 0 ? ` +${overflow}` : ""}`);
2330
+ return !current.length ? empty : h.div.class("min-w-0").children(menu(keyOf("items", row.id, column.id), label, `${label}: ${row.label}`, current.map(({ value, label }) => ({
2247
2331
  id: value,
2248
2332
  name: label,
2249
2333
  ...column.itemActions?.length ? {
@@ -2257,11 +2341,11 @@ var DataTable = Html2.component({
2257
2341
  })
2258
2342
  }))
2259
2343
  } : { disabled: true }
2260
- })), false, undefined, false, { relationship: summary })) : summary;
2344
+ })), false, undefined, false, { relationship: summary }));
2261
2345
  }
2262
2346
  const used = new Set(current.map(({ value }) => value));
2263
2347
  const add = (column.options ?? []).filter(({ value }) => !used.has(value));
2264
- return h.div.class("grid gap-1").children(current.length > 0 ? h.ul.class("flex flex-wrap gap-1").children(current.map(({ value, label }) => h.li.key(value).class("bg-muted rounded-sm ps-2 inline-flex items-center gap-1").children(label, !!column.itemActions?.length && menu(keyOf("item", row.id, column.id, value), copy.actions, `${copy.actions}: ${label} — ${row.label}`, column.itemActions.map((action) => ({
2348
+ return h.div.class("grid gap-1").children(current.length > 0 ? h.ul.class("flex flex-wrap gap-1").children(current.map(({ value, label }) => h.li.key(value).class(column.display === "badge" ? cn(badgeClass, badgeVariants.secondary) : "bg-muted rounded-sm ps-2 inline-flex items-center gap-1").children(label, !!column.itemActions?.length && menu(keyOf("item", row.id, column.id, value), copy.actions, `${copy.actions}: ${label} — ${row.label}`, column.itemActions.map((action) => ({
2265
2349
  ...action,
2266
2350
  message: DataTableMessage.ItemActionRequested({
2267
2351
  rowId: row.id,
@@ -2279,8 +2363,6 @@ var DataTable = Html2.component({
2279
2363
  message: edit(DataTableEdit.AddItem({ itemId: value }))
2280
2364
  })), false, copy.addItem));
2281
2365
  }
2282
- case "text":
2283
- return isTableText(value) ? value : empty;
2284
2366
  }
2285
2367
  };
2286
2368
  const dragHandle = (row) => draggable && h.span.attr("aria-hidden", "true").class("inline-flex size-8 cursor-grab items-center justify-center text-muted-foreground").draggable({ [RowDrag]: row.id }, { effectAllowed: "move" }).on("dragstart", DataTableMessage.DragStarted({ rowId: row.id })).on("dragend", DataTableMessage.DragEnded()).children(GripVertical(h, { size: 16 }));
@@ -2298,9 +2380,9 @@ var DataTable = Html2.component({
2298
2380
  };
2299
2381
  const drop = dropOnRow(row.id, group);
2300
2382
  return (drop ? rowElement.dropTarget({ accepts: [RowDrag], dropEffect: "move" }).on("drop", drop) : rowElement).children(selection && h.td.class(tableClasses.selectionCell).on("click", ignoreActivation).on("keydown", ignoreActivation).children(h.div.class(tableClasses.selectionCenter).children(check(keyOf("select", key, row.id), `${copy.selectRow}: ${row.label}`, selected.has(row.id), (checked) => DataTableMessage.SelectionRequested({ rowIds: [row.id], checked }), { disabled: row.selectable === false }))), draggable && h.td.class("w-10 ps-1").on("click", ignoreActivation).on("keydown", ignoreActivation).children(dragHandle(row)), columns.map((column) => {
2301
- const td = h.td.key(column.id).attr("data-slot", "table-cell").class(cn(cellClass, tableClasses.cell, column.truncate ? "whitespace-nowrap" : "whitespace-normal", column.type === "list" && "p-0", "has-[[data-slot=data-table-list-cell]]:relative has-[[data-slot=data-table-list-cell]]:h-16"));
2383
+ const td = h.td.key(column.id).attr("data-slot", "table-cell").attr("data-column-id", column.id).class(cn(cellClass, tableClasses.cell, column.truncate ? "whitespace-nowrap" : "whitespace-normal", column.type === "list" && "p-0", column.type === "boolean" && "min-w-24 has-[[data-slot=data-table-boolean-cell]]:relative has-[[data-slot=data-table-boolean-cell]]:p-0", "has-[[data-slot=data-table-list-cell]]:relative has-[[data-slot=data-table-list-cell]]:h-16"));
2302
2384
  const content = () => h.div.class(cn(tableClasses.cellContent, column.truncate && "truncate")).children(cell(column, row));
2303
- if (column.type === "list" || column.type === "boolean" && column.editable && !row.disabledColumnIds?.includes(column.id)) {
2385
+ if (column.type === "list" || column.type === "boolean" && isTableBoolean(row.cells[column.id])) {
2304
2386
  return td.on("click", ignoreActivation).on("keydown", ignoreActivation).children(content());
2305
2387
  }
2306
2388
  return (!props.rowActivation && activate && column.type !== "boolean" ? td.class("cursor-pointer").on("click", activate) : td).children(content());
@@ -2326,7 +2408,12 @@ var DataTable = Html2.component({
2326
2408
  return (drop ? card.dropTarget({ accepts: [RowDrag], dropEffect: "move" }).on("drop", drop) : card).children(isTableText(image) && h.img.attrs({ src: image, alt: "", loading: "lazy" }).class("aspect-video w-full rounded object-cover"), h.h3.class("font-medium").children(activate ? Button2(h, {
2327
2409
  variant: "ghost",
2328
2410
  onPress: activate
2329
- }).children(name) : name), gallery.description && h.div.class("text-muted-foreground text-sm").children(galleryValue(gallery.description, row)), h.div.class("flex flex-wrap gap-2").children(gallery.tags?.map((id) => h.span.key(id).class("bg-muted rounded px-2 py-1 text-xs").children(galleryValue(id, row)))), selection && check(keyOf("select", key, row.id), `${copy.selectRow}: ${row.label}`, selected.has(row.id), (checked) => DataTableMessage.SelectionRequested({ rowIds: [row.id], checked }), { disabled: row.selectable === false }), h.div.class("flex items-center justify-end gap-1").children(dragHandle(row), rowControls(row, siblings, key)));
2411
+ }).children(name) : name), gallery.description && h.div.class("text-muted-foreground text-sm").children(galleryValue(gallery.description, row)), h.div.class("flex flex-wrap gap-2").children(gallery.tags?.map((id) => {
2412
+ const column = props.columnDefs.find((column) => column.id === id);
2413
+ if ((column?.type === "text" || column?.type === "list") && column.display === "badge")
2414
+ return h.div.key(id).children(cell(column, row));
2415
+ return h.span.key(id).class("bg-muted rounded px-2 py-1 text-xs").children(galleryValue(id, row));
2416
+ })), selection && check(keyOf("select", key, row.id), `${copy.selectRow}: ${row.label}`, selected.has(row.id), (checked) => DataTableMessage.SelectionRequested({ rowIds: [row.id], checked }), { disabled: row.selectable === false }), h.div.class("flex items-center justify-end gap-1").children(dragHandle(row), rowControls(row, siblings, key)));
2330
2417
  };
2331
2418
  const renderGroups = (members, depth, parent, parentTarget) => {
2332
2419
  const field = grouping[depth];
@@ -1,7 +1,7 @@
1
1
  import { DateTime, Option, Schema } from "effect";
2
2
  import { Component, Subscription, UiSchema } from "effect/ui";
3
3
  import { ColumnFilter } from "../../lib/query.js";
4
- import { DataTableFilterDraftSchema, DataTablePreferencesSchema, type DataTableColumn, type DataTableDateTimeFormat, type DataTableLabelsSchema, type DataTableProps, type DataTablePublicState, type DataTableRow, type DataTableSort } from "./schema.js";
4
+ import { DataTableFilterDraftSchema, DataTablePreferencesSchema, type DataTableColumn, type DataTableDateTimeFormat, type DataTableLabelsSchema, type DataTableProps, type DataTablePublicState, type DataTableRow, type DataTableSort, type DataTableBadgeOption } from "./schema.js";
5
5
  type Labels = Required<typeof DataTableLabelsSchema.Type>;
6
6
  export declare const defaultMessages: {
7
7
  en: {
@@ -135,7 +135,23 @@ export declare const matchesFilterText: (value: string, filter: Extract<ColumnFi
135
135
  }>) => boolean;
136
136
  export declare const tableFilterKind: (column: {
137
137
  type?: DataTableColumn["type"];
138
+ display?: string;
138
139
  }, hasOptions?: boolean) => ColumnFilter["kind"];
140
+ export declare const tableBadgeValue: <Value>(value: Value) => (Value & string) | null;
141
+ type BadgeConfig<Option extends DataTableBadgeOption = DataTableBadgeOption> = {
142
+ options?: readonly Option[];
143
+ };
144
+ export declare const tableBadge: <Value, Option extends DataTableBadgeOption>(input: Value, config?: BadgeConfig<Option>) => {
145
+ value: Value & string;
146
+ label: string;
147
+ variant: "default" | "destructive" | "info" | "muted" | "outline" | "secondary" | "success";
148
+ option: Option | undefined;
149
+ } | null;
150
+ export declare const tableBadgeFilterOptions: <Value>(values: Iterable<Value>, config?: BadgeConfig) => {
151
+ value: string;
152
+ label: string;
153
+ }[];
154
+ export declare const tableBadgeSearchText: <Value>(value: Value, config?: BadgeConfig) => string;
139
155
  export declare const matchesTableFilter: <Value>(filter: ColumnFilter, value: Value, type: DataTableColumn["type"] | undefined, text: () => string, values: () => readonly string[]) => boolean;
140
156
  /** Resolve the same public field IDs as React without adding visible cells. */
141
157
  export declare const tableDataColumns: (columns: readonly DataTableColumn[]) => readonly DataTableColumn[];
@@ -578,6 +594,15 @@ export declare const dataTableOptions: {
578
594
  readonly emptyLabel: Schema.optionalKey<Schema.String>;
579
595
  readonly nulls: Schema.optionalKey<Schema.Literals<readonly ["first", "last"]>>;
580
596
  readonly type: Schema.Literal<"text">;
597
+ readonly display: Schema.optionalKey<Schema.Literal<"badge">>;
598
+ readonly typeOptions: Schema.optionalKey<Schema.Struct<{
599
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.Struct<{
600
+ readonly value: Schema.NonEmptyString;
601
+ readonly label: Schema.optionalKey<Schema.String>;
602
+ readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "secondary", "outline", "destructive", "success", "info", "muted"]>>;
603
+ readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">, <Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">>>;
604
+ }>>>;
605
+ }>>;
581
606
  readonly fields: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
582
607
  readonly id: Schema.NonEmptyString;
583
608
  readonly headerName: Schema.String;
@@ -594,6 +619,15 @@ export declare const dataTableOptions: {
594
619
  readonly emptyLabel: Schema.optionalKey<Schema.String>;
595
620
  readonly nulls: Schema.optionalKey<Schema.Literals<readonly ["first", "last"]>>;
596
621
  readonly type: Schema.Literal<"text">;
622
+ readonly display: Schema.optionalKey<Schema.Literal<"badge">>;
623
+ readonly typeOptions: Schema.optionalKey<Schema.Struct<{
624
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.Struct<{
625
+ readonly value: Schema.NonEmptyString;
626
+ readonly label: Schema.optionalKey<Schema.String>;
627
+ readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "secondary", "outline", "destructive", "success", "info", "muted"]>>;
628
+ readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">, <Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">>>;
629
+ }>>>;
630
+ }>>;
597
631
  }>, Schema.Struct<{
598
632
  readonly id: Schema.NonEmptyString;
599
633
  readonly headerName: Schema.String;
@@ -735,7 +769,7 @@ export declare const dataTableOptions: {
735
769
  readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "destructive"]>>;
736
770
  readonly disabled: Schema.optionalKey<Schema.Boolean>;
737
771
  }>>>;
738
- readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon"]>>;
772
+ readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon", "badge"]>>;
739
773
  readonly visibleCount: Schema.optionalKey<Schema.Int>;
740
774
  readonly actionsLabel: Schema.optionalKey<Schema.String>;
741
775
  readonly manageLabel: Schema.optionalKey<Schema.String>;
@@ -782,6 +816,15 @@ export declare const dataTableOptions: {
782
816
  readonly emptyLabel: Schema.optionalKey<Schema.String>;
783
817
  readonly nulls: Schema.optionalKey<Schema.Literals<readonly ["first", "last"]>>;
784
818
  readonly type: Schema.Literal<"text">;
819
+ readonly display: Schema.optionalKey<Schema.Literal<"badge">>;
820
+ readonly typeOptions: Schema.optionalKey<Schema.Struct<{
821
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.Struct<{
822
+ readonly value: Schema.NonEmptyString;
823
+ readonly label: Schema.optionalKey<Schema.String>;
824
+ readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "secondary", "outline", "destructive", "success", "info", "muted"]>>;
825
+ readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">, <Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">>>;
826
+ }>>>;
827
+ }>>;
785
828
  }>, Schema.Struct<{
786
829
  readonly id: Schema.NonEmptyString;
787
830
  readonly headerName: Schema.String;
@@ -923,7 +966,7 @@ export declare const dataTableOptions: {
923
966
  readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "destructive"]>>;
924
967
  readonly disabled: Schema.optionalKey<Schema.Boolean>;
925
968
  }>>>;
926
- readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon"]>>;
969
+ readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon", "badge"]>>;
927
970
  readonly visibleCount: Schema.optionalKey<Schema.Int>;
928
971
  readonly actionsLabel: Schema.optionalKey<Schema.String>;
929
972
  readonly manageLabel: Schema.optionalKey<Schema.String>;
@@ -960,6 +1003,15 @@ export declare const dataTableOptions: {
960
1003
  readonly emptyLabel: Schema.optionalKey<Schema.String>;
961
1004
  readonly nulls: Schema.optionalKey<Schema.Literals<readonly ["first", "last"]>>;
962
1005
  readonly type: Schema.Literal<"text">;
1006
+ readonly display: Schema.optionalKey<Schema.Literal<"badge">>;
1007
+ readonly typeOptions: Schema.optionalKey<Schema.Struct<{
1008
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1009
+ readonly value: Schema.NonEmptyString;
1010
+ readonly label: Schema.optionalKey<Schema.String>;
1011
+ readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "secondary", "outline", "destructive", "success", "info", "muted"]>>;
1012
+ readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">, <Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">>>;
1013
+ }>>>;
1014
+ }>>;
963
1015
  }>, Schema.Struct<{
964
1016
  readonly id: Schema.NonEmptyString;
965
1017
  readonly headerName: Schema.String;
@@ -1101,7 +1153,7 @@ export declare const dataTableOptions: {
1101
1153
  readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "destructive"]>>;
1102
1154
  readonly disabled: Schema.optionalKey<Schema.Boolean>;
1103
1155
  }>>>;
1104
- readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon"]>>;
1156
+ readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon", "badge"]>>;
1105
1157
  readonly visibleCount: Schema.optionalKey<Schema.Int>;
1106
1158
  readonly actionsLabel: Schema.optionalKey<Schema.String>;
1107
1159
  readonly manageLabel: Schema.optionalKey<Schema.String>;
@@ -1144,6 +1196,15 @@ export declare const dataTableOptions: {
1144
1196
  readonly emptyLabel: Schema.optionalKey<Schema.String>;
1145
1197
  readonly nulls: Schema.optionalKey<Schema.Literals<readonly ["first", "last"]>>;
1146
1198
  readonly type: Schema.Literal<"text">;
1199
+ readonly display: Schema.optionalKey<Schema.Literal<"badge">>;
1200
+ readonly typeOptions: Schema.optionalKey<Schema.Struct<{
1201
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1202
+ readonly value: Schema.NonEmptyString;
1203
+ readonly label: Schema.optionalKey<Schema.String>;
1204
+ readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "secondary", "outline", "destructive", "success", "info", "muted"]>>;
1205
+ readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">, <Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">>>;
1206
+ }>>>;
1207
+ }>>;
1147
1208
  }>, Schema.Struct<{
1148
1209
  readonly id: Schema.NonEmptyString;
1149
1210
  readonly headerName: Schema.String;
@@ -1285,7 +1346,7 @@ export declare const dataTableOptions: {
1285
1346
  readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "destructive"]>>;
1286
1347
  readonly disabled: Schema.optionalKey<Schema.Boolean>;
1287
1348
  }>>>;
1288
- readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon"]>>;
1349
+ readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon", "badge"]>>;
1289
1350
  readonly visibleCount: Schema.optionalKey<Schema.Int>;
1290
1351
  readonly actionsLabel: Schema.optionalKey<Schema.String>;
1291
1352
  readonly manageLabel: Schema.optionalKey<Schema.String>;
@@ -1330,6 +1391,15 @@ export declare const dataTableOptions: {
1330
1391
  readonly emptyLabel: Schema.optionalKey<Schema.String>;
1331
1392
  readonly nulls: Schema.optionalKey<Schema.Literals<readonly ["first", "last"]>>;
1332
1393
  readonly type: Schema.Literal<"text">;
1394
+ readonly display: Schema.optionalKey<Schema.Literal<"badge">>;
1395
+ readonly typeOptions: Schema.optionalKey<Schema.Struct<{
1396
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1397
+ readonly value: Schema.NonEmptyString;
1398
+ readonly label: Schema.optionalKey<Schema.String>;
1399
+ readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "secondary", "outline", "destructive", "success", "info", "muted"]>>;
1400
+ readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">, <Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">>>;
1401
+ }>>>;
1402
+ }>>;
1333
1403
  }>, Schema.Struct<{
1334
1404
  readonly id: Schema.NonEmptyString;
1335
1405
  readonly headerName: Schema.String;
@@ -1471,7 +1541,7 @@ export declare const dataTableOptions: {
1471
1541
  readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "destructive"]>>;
1472
1542
  readonly disabled: Schema.optionalKey<Schema.Boolean>;
1473
1543
  }>>>;
1474
- readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon"]>>;
1544
+ readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon", "badge"]>>;
1475
1545
  readonly visibleCount: Schema.optionalKey<Schema.Int>;
1476
1546
  readonly actionsLabel: Schema.optionalKey<Schema.String>;
1477
1547
  readonly manageLabel: Schema.optionalKey<Schema.String>;
@@ -1514,6 +1584,15 @@ export declare const dataTableOptions: {
1514
1584
  readonly emptyLabel: Schema.optionalKey<Schema.String>;
1515
1585
  readonly nulls: Schema.optionalKey<Schema.Literals<readonly ["first", "last"]>>;
1516
1586
  readonly type: Schema.Literal<"text">;
1587
+ readonly display: Schema.optionalKey<Schema.Literal<"badge">>;
1588
+ readonly typeOptions: Schema.optionalKey<Schema.Struct<{
1589
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1590
+ readonly value: Schema.NonEmptyString;
1591
+ readonly label: Schema.optionalKey<Schema.String>;
1592
+ readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "secondary", "outline", "destructive", "success", "info", "muted"]>>;
1593
+ readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">, <Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">>>;
1594
+ }>>>;
1595
+ }>>;
1517
1596
  }>, Schema.Struct<{
1518
1597
  readonly id: Schema.NonEmptyString;
1519
1598
  readonly headerName: Schema.String;
@@ -1655,7 +1734,7 @@ export declare const dataTableOptions: {
1655
1734
  readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "destructive"]>>;
1656
1735
  readonly disabled: Schema.optionalKey<Schema.Boolean>;
1657
1736
  }>>>;
1658
- readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon"]>>;
1737
+ readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon", "badge"]>>;
1659
1738
  readonly visibleCount: Schema.optionalKey<Schema.Int>;
1660
1739
  readonly actionsLabel: Schema.optionalKey<Schema.String>;
1661
1740
  readonly manageLabel: Schema.optionalKey<Schema.String>;
@@ -1691,7 +1770,7 @@ export declare const dataTableOptions: {
1691
1770
  readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "destructive"]>>;
1692
1771
  readonly disabled: Schema.optionalKey<Schema.Boolean>;
1693
1772
  }>>>;
1694
- readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon"]>>;
1773
+ readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon", "badge"]>>;
1695
1774
  readonly visibleCount: Schema.optionalKey<Schema.Int>;
1696
1775
  readonly actionsLabel: Schema.optionalKey<Schema.String>;
1697
1776
  readonly manageLabel: Schema.optionalKey<Schema.String>;
@@ -1711,6 +1790,15 @@ export declare const dataTableOptions: {
1711
1790
  readonly emptyLabel: Schema.optionalKey<Schema.String>;
1712
1791
  readonly nulls: Schema.optionalKey<Schema.Literals<readonly ["first", "last"]>>;
1713
1792
  readonly type: Schema.Literal<"text">;
1793
+ readonly display: Schema.optionalKey<Schema.Literal<"badge">>;
1794
+ readonly typeOptions: Schema.optionalKey<Schema.Struct<{
1795
+ readonly options: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1796
+ readonly value: Schema.NonEmptyString;
1797
+ readonly label: Schema.optionalKey<Schema.String>;
1798
+ readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "secondary", "outline", "destructive", "success", "info", "muted"]>>;
1799
+ readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">, <Msg>(h: import("effect/ui/html/Html").H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => import("effect/ui/html/Html").SvgElement<Msg, never, SVGSVGElement, "svg">>>;
1800
+ }>>>;
1801
+ }>>;
1714
1802
  }>, Schema.Struct<{
1715
1803
  readonly id: Schema.NonEmptyString;
1716
1804
  readonly headerName: Schema.String;
@@ -1852,7 +1940,7 @@ export declare const dataTableOptions: {
1852
1940
  readonly variant: Schema.optionalKey<Schema.Literals<readonly ["default", "destructive"]>>;
1853
1941
  readonly disabled: Schema.optionalKey<Schema.Boolean>;
1854
1942
  }>>>;
1855
- readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon"]>>;
1943
+ readonly display: Schema.optionalKey<Schema.Literals<readonly ["list", "icon", "badge"]>>;
1856
1944
  readonly visibleCount: Schema.optionalKey<Schema.Int>;
1857
1945
  readonly actionsLabel: Schema.optionalKey<Schema.String>;
1858
1946
  readonly manageLabel: Schema.optionalKey<Schema.String>;
@@ -1,7 +1,13 @@
1
1
  import { type ReactElement, type ReactNode } from "react";
2
2
  import { type PaginationMessages } from "../ui/pagination.js";
3
3
  import { ColumnFilter, type QueryType } from "../../lib/query.js";
4
- import type { DataTableCommonFeatures, DataTableCommonProps, DataTableDateFormat, DataTableDateTimeFormat, DataTablePublicState } from "./schema.js";
4
+ import type { DataTableCommonFeatures, DataTableCommonProps, DataTableDateFormat, DataTableDateTimeFormat, DataTablePublicState, DataTableBadgeOption } from "./schema.js";
5
+ export type DataTableBadgeOptions = {
6
+ options?: readonly (DataTableBadgeOption & {
7
+ icon?: ReactNode;
8
+ })[];
9
+ emptyLabel?: ReactNode;
10
+ };
5
11
  /** Presentation only. Popup classes are applied inside portals, not to their triggers. */
6
12
  export type DataTableClassNames = {
7
13
  table?: Partial<Record<"content" | "header" | "body" | "row" | "head" | "cell", string>>;
@@ -61,7 +67,7 @@ export interface DataTableListItemContext<TData> {
61
67
  }
62
68
  export interface DataTableListOptions {
63
69
  emptyLabel: ReactNode;
64
- display?: "list" | "icon" | undefined;
70
+ display?: "list" | "icon" | "badge" | undefined;
65
71
  locale?: string | undefined;
66
72
  messages?: DataTableMessageTranslations | undefined;
67
73
  visibleCount?: number | undefined;
@@ -159,7 +165,8 @@ export interface DataTableBooleanOptions<TData> {
159
165
  disabled?: (row: TData) => boolean;
160
166
  }
161
167
  type DataTableColumnType<TData> = {
162
- type?: undefined;
168
+ type?: undefined | "text";
169
+ display?: never;
163
170
  typeOptions?: never;
164
171
  } | DataTableDateType | {
165
172
  type: "number";
@@ -167,6 +174,10 @@ type DataTableColumnType<TData> = {
167
174
  } | {
168
175
  type: "boolean";
169
176
  typeOptions?: DataTableBooleanOptions<TData>;
177
+ } | {
178
+ type: "text";
179
+ display: "badge";
180
+ typeOptions?: DataTableBadgeOptions;
170
181
  } | {
171
182
  type: "reference";
172
183
  typeOptions: DataTableReferenceOptions<TData>;