@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.
- package/CHANGELOG.md +10 -0
- package/dist/components/audit-log-table/react.js +152 -15
- package/dist/components/data-table/classes.d.ts +9 -3
- package/dist/components/data-table/html.d.ts +81 -9
- package/dist/components/data-table/html.js +113 -26
- package/dist/components/data-table/index.d.ts +97 -9
- package/dist/components/data-table/react.d.ts +14 -3
- package/dist/components/data-table/react.js +152 -15
- package/dist/components/data-table/schema.d.ts +175 -16
- package/dist/components/docs/html.js +1 -1
- package/dist/components/sidebar-layout/html.js +1 -1
- package/dist/components/webhook-delivery-table/html.js +113 -26
- package/dist/components/webhook-delivery-table/react.js +152 -15
- package/package.json +1 -1
|
@@ -469,9 +469,16 @@ import { Csv } from "effect/encoding";
|
|
|
469
469
|
import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
|
|
470
470
|
|
|
471
471
|
// ../../src/components/data-table/schema.ts
|
|
472
|
-
import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
|
|
472
|
+
import { DateTime as DateTime2, Option as Option2, Predicate, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
|
|
473
473
|
|
|
474
474
|
// ../../src/components/data-table/classes.ts
|
|
475
|
+
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";
|
|
476
|
+
var cellTriggerFocus = "focus-visible:ring-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring";
|
|
477
|
+
var tableBadgeTones = {
|
|
478
|
+
success: "border-emerald-200 bg-emerald-100 text-emerald-900 dark:border-emerald-900/50 dark:bg-emerald-950/50 dark:text-emerald-200",
|
|
479
|
+
info: "border-blue-200 bg-blue-100 text-blue-900 dark:border-blue-900/50 dark:bg-blue-950/50 dark:text-blue-200",
|
|
480
|
+
muted: "border-muted bg-muted text-muted-foreground dark:bg-muted/50"
|
|
481
|
+
};
|
|
475
482
|
var tableClasses = {
|
|
476
483
|
selectionCell: "w-10 p-0 align-middle",
|
|
477
484
|
selectionCenter: "grid place-items-center",
|
|
@@ -483,16 +490,16 @@ var tableClasses = {
|
|
|
483
490
|
menubar: "h-auto w-full flex-wrap justify-start border border-input bg-transparent",
|
|
484
491
|
cell: "overflow-hidden",
|
|
485
492
|
cellContent: "min-w-0 wrap-anywhere",
|
|
486
|
-
actionTrigger:
|
|
493
|
+
actionTrigger: `size-8 ${cellTriggerFocus}`,
|
|
487
494
|
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))]",
|
|
488
495
|
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
489
496
|
header: "relative h-12 p-0",
|
|
490
497
|
stickyHeader: "sticky top-0 z-30 bg-background",
|
|
491
498
|
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
492
|
-
headerTrigger:
|
|
499
|
+
headerTrigger: `absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 ${cellTriggerFocus}`,
|
|
493
500
|
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",
|
|
494
501
|
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",
|
|
495
|
-
relationshipTrigger:
|
|
502
|
+
relationshipTrigger: `h-full w-full min-w-0 justify-between rounded-none px-2 text-start ${cellTriggerFocus}`,
|
|
496
503
|
reference: "flex min-w-0 items-center gap-2",
|
|
497
504
|
referenceAvatar: "relative grid size-8 shrink-0 place-items-center overflow-hidden bg-muted text-xs font-medium",
|
|
498
505
|
referenceText: "flex min-w-0 flex-col leading-tight",
|
|
@@ -616,8 +623,33 @@ var column = {
|
|
|
616
623
|
emptyLabel: Schema4.optionalKey(Schema4.String),
|
|
617
624
|
nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
|
|
618
625
|
};
|
|
626
|
+
var DataTableBadgeOptionSchema = Schema4.Struct({
|
|
627
|
+
value: Schema4.NonEmptyString,
|
|
628
|
+
label: Schema4.optionalKey(Schema4.String),
|
|
629
|
+
variant: Schema4.optionalKey(Schema4.Literals([
|
|
630
|
+
"default",
|
|
631
|
+
"secondary",
|
|
632
|
+
"outline",
|
|
633
|
+
"destructive",
|
|
634
|
+
"success",
|
|
635
|
+
"info",
|
|
636
|
+
"muted"
|
|
637
|
+
]))
|
|
638
|
+
}).annotate({ identifier: "DataTableBadgeOption" });
|
|
639
|
+
var BadgeIcon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableBadgeIcon" });
|
|
640
|
+
var DataTableBadgeOptionsSchema = Schema4.Struct({
|
|
641
|
+
options: Schema4.optionalKey(Schema4.Array(DataTableBadgeOptionSchema.mapFields((fields) => ({
|
|
642
|
+
...fields,
|
|
643
|
+
icon: Schema4.optionalKey(BadgeIcon)
|
|
644
|
+
}))))
|
|
645
|
+
}).annotate({ identifier: "DataTableBadgeOptions" });
|
|
619
646
|
var DataTableFieldSchema = Schema4.Union([
|
|
620
|
-
Schema4.Struct({
|
|
647
|
+
Schema4.Struct({
|
|
648
|
+
...column,
|
|
649
|
+
type: Schema4.Literal("text"),
|
|
650
|
+
display: Schema4.optionalKey(Schema4.Literal("badge")),
|
|
651
|
+
typeOptions: Schema4.optionalKey(DataTableBadgeOptionsSchema)
|
|
652
|
+
}),
|
|
621
653
|
Schema4.Struct({
|
|
622
654
|
...column,
|
|
623
655
|
type: Schema4.Literal("number"),
|
|
@@ -660,7 +692,7 @@ var DataTableFieldSchema = Schema4.Union([
|
|
|
660
692
|
options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
661
693
|
allowRemove: Schema4.optionalKey(Schema4.Boolean),
|
|
662
694
|
itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
663
|
-
display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
|
|
695
|
+
display: Schema4.optionalKey(Schema4.Literals(["list", "icon", "badge"])),
|
|
664
696
|
visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
|
|
665
697
|
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
666
698
|
manageLabel: Schema4.optionalKey(Schema4.String)
|
|
@@ -962,7 +994,33 @@ var matchesFilterText = (value, filter) => {
|
|
|
962
994
|
return text.endsWith(query);
|
|
963
995
|
}
|
|
964
996
|
};
|
|
965
|
-
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
997
|
+
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" || column.display === "badge" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
998
|
+
var tableBadgeValue = (value) => isTableText(value) && value !== "" ? value : null;
|
|
999
|
+
var tableBadge = (input, config) => {
|
|
1000
|
+
const value = tableBadgeValue(input);
|
|
1001
|
+
if (value === null)
|
|
1002
|
+
return null;
|
|
1003
|
+
const option = config?.options?.find((option) => option.value === value);
|
|
1004
|
+
return {
|
|
1005
|
+
value,
|
|
1006
|
+
label: option?.label ?? value,
|
|
1007
|
+
variant: option?.variant ?? "secondary",
|
|
1008
|
+
option
|
|
1009
|
+
};
|
|
1010
|
+
};
|
|
1011
|
+
var tableBadgeFilterOptions = (values, config) => {
|
|
1012
|
+
const options = new Map(config?.options?.map(({ value, label }) => [value, label ?? value]));
|
|
1013
|
+
for (const input of values) {
|
|
1014
|
+
const value = tableBadgeValue(input);
|
|
1015
|
+
if (value !== null && !options.has(value))
|
|
1016
|
+
options.set(value, value);
|
|
1017
|
+
}
|
|
1018
|
+
return [...options].map(([value, label]) => ({ value, label }));
|
|
1019
|
+
};
|
|
1020
|
+
var tableBadgeSearchText = (value, config) => {
|
|
1021
|
+
const badge = tableBadge(value, config);
|
|
1022
|
+
return badge ? `${badge.label} ${badge.value}` : "";
|
|
1023
|
+
};
|
|
966
1024
|
var matchesTableFilter = (filter, value, type, text, values) => {
|
|
967
1025
|
switch (filter.kind) {
|
|
968
1026
|
case "text":
|
|
@@ -1007,13 +1065,20 @@ var filterTableColumns = (rows, columns, filters) => {
|
|
|
1007
1065
|
return rows;
|
|
1008
1066
|
return rows.filter((row) => active.every((filter) => {
|
|
1009
1067
|
const value = row.cells[filter.id];
|
|
1010
|
-
|
|
1068
|
+
const column = byId.get(filter.id);
|
|
1069
|
+
return matchesTableFilter(filter, value, column?.type, () => isTableText(value) ? value : isTableReference(value) ? `${value.label} ${value.description ?? ""}`.trim() : "", () => {
|
|
1070
|
+
if (column?.type === "text" && column.display === "badge") {
|
|
1071
|
+
const key = tableBadgeValue(value);
|
|
1072
|
+
return key === null ? [] : [key];
|
|
1073
|
+
}
|
|
1074
|
+
return isTableList(value) ? value.map(({ value }) => value) : [];
|
|
1075
|
+
});
|
|
1011
1076
|
}));
|
|
1012
1077
|
};
|
|
1013
1078
|
var columnValue = (column, value) => {
|
|
1014
1079
|
switch (column.type) {
|
|
1015
1080
|
case "text":
|
|
1016
|
-
return isTableText(value) ? value : null;
|
|
1081
|
+
return column.display === "badge" ? tableBadgeValue(value) : isTableText(value) ? value : null;
|
|
1017
1082
|
case "number":
|
|
1018
1083
|
case "boolean":
|
|
1019
1084
|
case "date":
|
|
@@ -1067,6 +1132,8 @@ var filterTableRows = (rows, columns, search, locale) => {
|
|
|
1067
1132
|
const searchable = columns.filter(({ searchable }) => searchable !== false);
|
|
1068
1133
|
return rows.filter((row) => searchable.some((column) => {
|
|
1069
1134
|
const value = row.cells[column.id];
|
|
1135
|
+
if (column.type === "text" && column.display === "badge")
|
|
1136
|
+
return tableBadgeSearchText(value, column.typeOptions).toLocaleLowerCase(locale).includes(query);
|
|
1070
1137
|
if (column.type === "date" || column.type === "dateTime") {
|
|
1071
1138
|
const date = resolveDate(value, column.type);
|
|
1072
1139
|
return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
|
|
@@ -1822,6 +1889,14 @@ var dataTableBehaviours = {
|
|
|
1822
1889
|
// ../../src/components/data-table/html.ts
|
|
1823
1890
|
var keyOf = (...parts) => JSON.stringify(parts);
|
|
1824
1891
|
var cellClass = "px-3 py-2 align-middle";
|
|
1892
|
+
var badgeVariants = {
|
|
1893
|
+
...tableBadgeTones,
|
|
1894
|
+
default: "bg-primary text-primary-foreground",
|
|
1895
|
+
secondary: "bg-secondary text-secondary-foreground",
|
|
1896
|
+
outline: "border-border text-foreground",
|
|
1897
|
+
destructive: "bg-destructive/10 text-destructive dark:bg-destructive/20"
|
|
1898
|
+
};
|
|
1899
|
+
var badgeClass = "inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap";
|
|
1825
1900
|
var isTextFilterOperator = Schema6.is(TextFilterOperator);
|
|
1826
1901
|
var RowDrag = "application/x-krakstack-table-row";
|
|
1827
1902
|
var PersistPreferences = Mount.makeStream("DataTable/PersistPreferences", {
|
|
@@ -2092,11 +2167,13 @@ var DataTable = Html2.component({
|
|
|
2092
2167
|
})))));
|
|
2093
2168
|
}
|
|
2094
2169
|
});
|
|
2095
|
-
const check = (key, label, checked, onToggle, options) => Checkbox(h, {
|
|
2170
|
+
const check = (key, label, checked, onToggle, options, inCell = false) => Checkbox(h, {
|
|
2096
2171
|
key,
|
|
2097
2172
|
props: { checked, ...options },
|
|
2098
2173
|
onEmit: { Toggled: ({ checked }) => onToggle(checked) },
|
|
2099
|
-
view: (checkbox) => h.span.class("grid size-4 shrink-0 place-items-center").children(CheckboxRoot(h, checkbox
|
|
2174
|
+
view: (checkbox) => h.span.class("grid size-4 shrink-0 place-items-center").children(CheckboxRoot(h, checkbox, {
|
|
2175
|
+
class: inCell ? "focus-visible:outline-none" : undefined
|
|
2176
|
+
}).attr("aria-label", label).children(CheckboxIndicator(h, checkbox, {
|
|
2100
2177
|
class: "pointer-events-none"
|
|
2101
2178
|
})))
|
|
2102
2179
|
});
|
|
@@ -2152,9 +2229,9 @@ var DataTable = Html2.component({
|
|
|
2152
2229
|
filter: { id, kind: "boolean", value }
|
|
2153
2230
|
})
|
|
2154
2231
|
}));
|
|
2155
|
-
} else if (column.type === "list") {
|
|
2232
|
+
} else if (column.type === "list" || column.type === "text" && column.display === "badge") {
|
|
2156
2233
|
const selected = current?.kind === "values" ? current.values : [];
|
|
2157
|
-
const options = column.filterOptions ?? tableFilterOptions(props.rowData, id, locale);
|
|
2234
|
+
const options = column.type === "text" ? tableBadgeFilterOptions(props.rowData.map((row) => row.cells[id]), column.typeOptions) : column.filterOptions ?? tableFilterOptions(props.rowData, id, locale);
|
|
2158
2235
|
children = options.map(({ value, label }) => {
|
|
2159
2236
|
const checked = selected.includes(value);
|
|
2160
2237
|
const values = updateSelectedRows(selected, [value], !checked);
|
|
@@ -2187,6 +2264,12 @@ var DataTable = Html2.component({
|
|
|
2187
2264
|
const disabled = row.disabledColumnIds?.includes(column.id);
|
|
2188
2265
|
const edit = (edit) => DataTableMessage.CellEditRequested({ rowId: row.id, columnId: column.id, edit });
|
|
2189
2266
|
switch (column.type) {
|
|
2267
|
+
case "text": {
|
|
2268
|
+
if (column.display !== "badge")
|
|
2269
|
+
return isTableText(value) ? value : empty;
|
|
2270
|
+
const badge = tableBadge(value, column.typeOptions);
|
|
2271
|
+
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;
|
|
2272
|
+
}
|
|
2190
2273
|
case "number":
|
|
2191
2274
|
return isTableNumber(value) ? formatNumberValue(value, column.typeOptions, locale) : empty;
|
|
2192
2275
|
case "date":
|
|
@@ -2195,7 +2278,7 @@ var DataTable = Html2.component({
|
|
|
2195
2278
|
return date ? h.time.attr("datetime", dateIsoValue(date)).children(formatDateValue(date, column, locale)) : empty;
|
|
2196
2279
|
}
|
|
2197
2280
|
case "boolean":
|
|
2198
|
-
return isTableBoolean(value) ?
|
|
2281
|
+
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;
|
|
2199
2282
|
case "reference":
|
|
2200
2283
|
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({
|
|
2201
2284
|
src: value.imageSrc,
|
|
@@ -2204,6 +2287,9 @@ var DataTable = Html2.component({
|
|
|
2204
2287
|
}).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;
|
|
2205
2288
|
case "list": {
|
|
2206
2289
|
const current = isTableList(value) ? value : [];
|
|
2290
|
+
const visible = current.slice(0, column.visibleCount ?? 3);
|
|
2291
|
+
const overflow = current.length - visible.length;
|
|
2292
|
+
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}`));
|
|
2207
2293
|
if (column.manageLabel && !disabled && (column.options || column.allowRemove)) {
|
|
2208
2294
|
const used = new Set(current.map(({ value }) => value));
|
|
2209
2295
|
const available = (column.options ?? []).filter(({ value }) => !used.has(value));
|
|
@@ -2239,15 +2325,13 @@ var DataTable = Html2.component({
|
|
|
2239
2325
|
}
|
|
2240
2326
|
] : []
|
|
2241
2327
|
], false, undefined, false, {
|
|
2242
|
-
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)
|
|
2328
|
+
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)
|
|
2243
2329
|
}));
|
|
2244
2330
|
}
|
|
2245
2331
|
if (column.display && !column.options && !column.allowRemove) {
|
|
2246
|
-
const visible = current.slice(0, column.visibleCount ?? 3);
|
|
2247
|
-
const overflow = current.length - visible.length;
|
|
2248
2332
|
const label = column.actionsLabel ?? (column.itemActions?.length ? copy.actions : copy.listDetails);
|
|
2249
|
-
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}` : ""}`);
|
|
2250
|
-
return !current.length ? empty :
|
|
2333
|
+
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}` : ""}`);
|
|
2334
|
+
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 }) => ({
|
|
2251
2335
|
id: value,
|
|
2252
2336
|
name: label,
|
|
2253
2337
|
...column.itemActions?.length ? {
|
|
@@ -2261,11 +2345,11 @@ var DataTable = Html2.component({
|
|
|
2261
2345
|
})
|
|
2262
2346
|
}))
|
|
2263
2347
|
} : { disabled: true }
|
|
2264
|
-
})), false, undefined, false, { relationship: summary }))
|
|
2348
|
+
})), false, undefined, false, { relationship: summary }));
|
|
2265
2349
|
}
|
|
2266
2350
|
const used = new Set(current.map(({ value }) => value));
|
|
2267
2351
|
const add = (column.options ?? []).filter(({ value }) => !used.has(value));
|
|
2268
|
-
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) => ({
|
|
2352
|
+
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) => ({
|
|
2269
2353
|
...action,
|
|
2270
2354
|
message: DataTableMessage.ItemActionRequested({
|
|
2271
2355
|
rowId: row.id,
|
|
@@ -2283,8 +2367,6 @@ var DataTable = Html2.component({
|
|
|
2283
2367
|
message: edit(DataTableEdit.AddItem({ itemId: value }))
|
|
2284
2368
|
})), false, copy.addItem));
|
|
2285
2369
|
}
|
|
2286
|
-
case "text":
|
|
2287
|
-
return isTableText(value) ? value : empty;
|
|
2288
2370
|
}
|
|
2289
2371
|
};
|
|
2290
2372
|
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 }));
|
|
@@ -2302,9 +2384,9 @@ var DataTable = Html2.component({
|
|
|
2302
2384
|
};
|
|
2303
2385
|
const drop = dropOnRow(row.id, group);
|
|
2304
2386
|
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) => {
|
|
2305
|
-
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"));
|
|
2387
|
+
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"));
|
|
2306
2388
|
const content = () => h.div.class(cn(tableClasses.cellContent, column.truncate && "truncate")).children(cell(column, row));
|
|
2307
|
-
if (column.type === "list" || column.type === "boolean" &&
|
|
2389
|
+
if (column.type === "list" || column.type === "boolean" && isTableBoolean(row.cells[column.id])) {
|
|
2308
2390
|
return td.on("click", ignoreActivation).on("keydown", ignoreActivation).children(content());
|
|
2309
2391
|
}
|
|
2310
2392
|
return (!props.rowActivation && activate && column.type !== "boolean" ? td.class("cursor-pointer").on("click", activate) : td).children(content());
|
|
@@ -2330,7 +2412,12 @@ var DataTable = Html2.component({
|
|
|
2330
2412
|
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, {
|
|
2331
2413
|
variant: "ghost",
|
|
2332
2414
|
onPress: activate
|
|
2333
|
-
}).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) =>
|
|
2415
|
+
}).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) => {
|
|
2416
|
+
const column = props.columnDefs.find((column) => column.id === id);
|
|
2417
|
+
if ((column?.type === "text" || column?.type === "list") && column.display === "badge")
|
|
2418
|
+
return h.div.key(id).children(cell(column, row));
|
|
2419
|
+
return h.span.key(id).class("bg-muted rounded px-2 py-1 text-xs").children(galleryValue(id, row));
|
|
2420
|
+
})), 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)));
|
|
2334
2421
|
};
|
|
2335
2422
|
const renderGroups = (members, depth, parent, parentTarget) => {
|
|
2336
2423
|
const field = grouping[depth];
|
|
@@ -618,6 +618,13 @@ import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
|
618
618
|
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
|
|
619
619
|
|
|
620
620
|
// ../../src/components/data-table/classes.ts
|
|
621
|
+
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";
|
|
622
|
+
var cellTriggerFocus = "focus-visible:ring-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring";
|
|
623
|
+
var tableBadgeTones = {
|
|
624
|
+
success: "border-emerald-200 bg-emerald-100 text-emerald-900 dark:border-emerald-900/50 dark:bg-emerald-950/50 dark:text-emerald-200",
|
|
625
|
+
info: "border-blue-200 bg-blue-100 text-blue-900 dark:border-blue-900/50 dark:bg-blue-950/50 dark:text-blue-200",
|
|
626
|
+
muted: "border-muted bg-muted text-muted-foreground dark:bg-muted/50"
|
|
627
|
+
};
|
|
621
628
|
var tableClasses = {
|
|
622
629
|
selectionCell: "w-10 p-0 align-middle",
|
|
623
630
|
selectionCenter: "grid place-items-center",
|
|
@@ -629,16 +636,16 @@ var tableClasses = {
|
|
|
629
636
|
menubar: "h-auto w-full flex-wrap justify-start border border-input bg-transparent",
|
|
630
637
|
cell: "overflow-hidden",
|
|
631
638
|
cellContent: "min-w-0 wrap-anywhere",
|
|
632
|
-
actionTrigger:
|
|
639
|
+
actionTrigger: `size-8 ${cellTriggerFocus}`,
|
|
633
640
|
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))]",
|
|
634
641
|
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
635
642
|
header: "relative h-12 p-0",
|
|
636
643
|
stickyHeader: "sticky top-0 z-30 bg-background",
|
|
637
644
|
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
638
|
-
headerTrigger:
|
|
645
|
+
headerTrigger: `absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 ${cellTriggerFocus}`,
|
|
639
646
|
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",
|
|
640
647
|
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",
|
|
641
|
-
relationshipTrigger:
|
|
648
|
+
relationshipTrigger: `h-full w-full min-w-0 justify-between rounded-none px-2 text-start ${cellTriggerFocus}`,
|
|
642
649
|
reference: "flex min-w-0 items-center gap-2",
|
|
643
650
|
referenceAvatar: "relative grid size-8 shrink-0 place-items-center overflow-hidden bg-muted text-xs font-medium",
|
|
644
651
|
referenceText: "flex min-w-0 flex-col leading-tight",
|
|
@@ -660,7 +667,7 @@ import { Csv } from "effect/encoding";
|
|
|
660
667
|
import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
|
|
661
668
|
|
|
662
669
|
// ../../src/components/data-table/schema.ts
|
|
663
|
-
import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
|
|
670
|
+
import { DateTime as DateTime2, Option as Option2, Predicate, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
|
|
664
671
|
var TableClassesOverridesSchema = Schema4.Record(Schema4.Literals(Struct2.keys(tableClasses)), Schema4.optionalKey(Schema4.String)).annotate({ identifier: "TableClassesOverrides" });
|
|
665
672
|
var DataTableCommonPropsSchema = Schema4.Struct({
|
|
666
673
|
classes: Schema4.optional(TableClassesOverridesSchema),
|
|
@@ -768,8 +775,33 @@ var column = {
|
|
|
768
775
|
emptyLabel: Schema4.optionalKey(Schema4.String),
|
|
769
776
|
nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
|
|
770
777
|
};
|
|
778
|
+
var DataTableBadgeOptionSchema = Schema4.Struct({
|
|
779
|
+
value: Schema4.NonEmptyString,
|
|
780
|
+
label: Schema4.optionalKey(Schema4.String),
|
|
781
|
+
variant: Schema4.optionalKey(Schema4.Literals([
|
|
782
|
+
"default",
|
|
783
|
+
"secondary",
|
|
784
|
+
"outline",
|
|
785
|
+
"destructive",
|
|
786
|
+
"success",
|
|
787
|
+
"info",
|
|
788
|
+
"muted"
|
|
789
|
+
]))
|
|
790
|
+
}).annotate({ identifier: "DataTableBadgeOption" });
|
|
791
|
+
var BadgeIcon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableBadgeIcon" });
|
|
792
|
+
var DataTableBadgeOptionsSchema = Schema4.Struct({
|
|
793
|
+
options: Schema4.optionalKey(Schema4.Array(DataTableBadgeOptionSchema.mapFields((fields) => ({
|
|
794
|
+
...fields,
|
|
795
|
+
icon: Schema4.optionalKey(BadgeIcon)
|
|
796
|
+
}))))
|
|
797
|
+
}).annotate({ identifier: "DataTableBadgeOptions" });
|
|
771
798
|
var DataTableFieldSchema = Schema4.Union([
|
|
772
|
-
Schema4.Struct({
|
|
799
|
+
Schema4.Struct({
|
|
800
|
+
...column,
|
|
801
|
+
type: Schema4.Literal("text"),
|
|
802
|
+
display: Schema4.optionalKey(Schema4.Literal("badge")),
|
|
803
|
+
typeOptions: Schema4.optionalKey(DataTableBadgeOptionsSchema)
|
|
804
|
+
}),
|
|
773
805
|
Schema4.Struct({
|
|
774
806
|
...column,
|
|
775
807
|
type: Schema4.Literal("number"),
|
|
@@ -812,7 +844,7 @@ var DataTableFieldSchema = Schema4.Union([
|
|
|
812
844
|
options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
813
845
|
allowRemove: Schema4.optionalKey(Schema4.Boolean),
|
|
814
846
|
itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
815
|
-
display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
|
|
847
|
+
display: Schema4.optionalKey(Schema4.Literals(["list", "icon", "badge"])),
|
|
816
848
|
visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
|
|
817
849
|
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
818
850
|
manageLabel: Schema4.optionalKey(Schema4.String)
|
|
@@ -1106,7 +1138,33 @@ var matchesFilterText = (value, filter) => {
|
|
|
1106
1138
|
return text.endsWith(query);
|
|
1107
1139
|
}
|
|
1108
1140
|
};
|
|
1109
|
-
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
1141
|
+
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" || column.display === "badge" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
1142
|
+
var tableBadgeValue = (value) => isTableText(value) && value !== "" ? value : null;
|
|
1143
|
+
var tableBadge = (input, config) => {
|
|
1144
|
+
const value = tableBadgeValue(input);
|
|
1145
|
+
if (value === null)
|
|
1146
|
+
return null;
|
|
1147
|
+
const option = config?.options?.find((option) => option.value === value);
|
|
1148
|
+
return {
|
|
1149
|
+
value,
|
|
1150
|
+
label: option?.label ?? value,
|
|
1151
|
+
variant: option?.variant ?? "secondary",
|
|
1152
|
+
option
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
var tableBadgeFilterOptions = (values, config) => {
|
|
1156
|
+
const options = new Map(config?.options?.map(({ value, label }) => [value, label ?? value]));
|
|
1157
|
+
for (const input of values) {
|
|
1158
|
+
const value = tableBadgeValue(input);
|
|
1159
|
+
if (value !== null && !options.has(value))
|
|
1160
|
+
options.set(value, value);
|
|
1161
|
+
}
|
|
1162
|
+
return [...options].map(([value, label]) => ({ value, label }));
|
|
1163
|
+
};
|
|
1164
|
+
var tableBadgeSearchText = (value, config) => {
|
|
1165
|
+
const badge = tableBadge(value, config);
|
|
1166
|
+
return badge ? `${badge.label} ${badge.value}` : "";
|
|
1167
|
+
};
|
|
1110
1168
|
var matchesTableFilter = (filter, value, type, text, values) => {
|
|
1111
1169
|
switch (filter.kind) {
|
|
1112
1170
|
case "text":
|
|
@@ -1140,13 +1198,20 @@ var filterTableColumns = (rows, columns, filters) => {
|
|
|
1140
1198
|
return rows;
|
|
1141
1199
|
return rows.filter((row) => active.every((filter) => {
|
|
1142
1200
|
const value = row.cells[filter.id];
|
|
1143
|
-
|
|
1201
|
+
const column = byId.get(filter.id);
|
|
1202
|
+
return matchesTableFilter(filter, value, column?.type, () => isTableText(value) ? value : isTableReference(value) ? `${value.label} ${value.description ?? ""}`.trim() : "", () => {
|
|
1203
|
+
if (column?.type === "text" && column.display === "badge") {
|
|
1204
|
+
const key = tableBadgeValue(value);
|
|
1205
|
+
return key === null ? [] : [key];
|
|
1206
|
+
}
|
|
1207
|
+
return isTableList(value) ? value.map(({ value }) => value) : [];
|
|
1208
|
+
});
|
|
1144
1209
|
}));
|
|
1145
1210
|
};
|
|
1146
1211
|
var columnValue = (column, value) => {
|
|
1147
1212
|
switch (column.type) {
|
|
1148
1213
|
case "text":
|
|
1149
|
-
return isTableText(value) ? value : null;
|
|
1214
|
+
return column.display === "badge" ? tableBadgeValue(value) : isTableText(value) ? value : null;
|
|
1150
1215
|
case "number":
|
|
1151
1216
|
case "boolean":
|
|
1152
1217
|
case "date":
|
|
@@ -1200,6 +1265,8 @@ var filterTableRows = (rows, columns, search, locale) => {
|
|
|
1200
1265
|
const searchable = columns.filter(({ searchable }) => searchable !== false);
|
|
1201
1266
|
return rows.filter((row) => searchable.some((column) => {
|
|
1202
1267
|
const value = row.cells[column.id];
|
|
1268
|
+
if (column.type === "text" && column.display === "badge")
|
|
1269
|
+
return tableBadgeSearchText(value, column.typeOptions).toLocaleLowerCase(locale).includes(query);
|
|
1203
1270
|
if (column.type === "date" || column.type === "dateTime") {
|
|
1204
1271
|
const date = resolveDate(value, column.type);
|
|
1205
1272
|
return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
|
|
@@ -2129,6 +2196,8 @@ var booleanLabel = (value, options) => value ? options?.trueLabel : options?.fal
|
|
|
2129
2196
|
var getDataTableExportValue = (row, column, locale = "en") => {
|
|
2130
2197
|
const value = row.values.get(column.id);
|
|
2131
2198
|
const colDef = column.colDef;
|
|
2199
|
+
if (colDef.type === "text" && colDef.display === "badge")
|
|
2200
|
+
return tableBadgeValue(value);
|
|
2132
2201
|
if (colDef.type === "number") {
|
|
2133
2202
|
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
2134
2203
|
if (number === undefined)
|
|
@@ -2157,7 +2226,9 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
2157
2226
|
const value = row.values.get(column.id);
|
|
2158
2227
|
const colDef = column.colDef;
|
|
2159
2228
|
let text = dataTableValueText(value);
|
|
2160
|
-
if (colDef.type === "
|
|
2229
|
+
if (colDef.type === "text" && colDef.display === "badge") {
|
|
2230
|
+
text = tableBadgeSearchText(value, colDef.typeOptions);
|
|
2231
|
+
} else if (colDef.type === "date" || colDef.type === "dateTime") {
|
|
2161
2232
|
const date = resolveDate(value, colDef.type);
|
|
2162
2233
|
text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
|
|
2163
2234
|
} else if (colDef.type === "number") {
|
|
@@ -2173,11 +2244,14 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
2173
2244
|
var getDataTableFilterColumns = (columns) => columns.flatMap((column) => column.colDef.filterable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.filterable !== false));
|
|
2174
2245
|
var getDataTableFilterKind = ({
|
|
2175
2246
|
colDef
|
|
2176
|
-
}) => tableFilterKind(colDef, !!colDef.filterOptions);
|
|
2247
|
+
}) => tableFilterKind(colDef.type === "text" ? colDef : { type: colDef.type }, !!colDef.filterOptions);
|
|
2177
2248
|
var getDataTableFilterOptions = (rows, column) => {
|
|
2178
2249
|
const { colDef } = column;
|
|
2179
2250
|
if (colDef.filterOptions)
|
|
2180
2251
|
return colDef.filterOptions;
|
|
2252
|
+
if (colDef.type === "text" && colDef.display === "badge") {
|
|
2253
|
+
return tableBadgeFilterOptions(rows.map((row) => row.values.get(column.id)), colDef.typeOptions);
|
|
2254
|
+
}
|
|
2181
2255
|
const options = new Map;
|
|
2182
2256
|
if (colDef.type === "list") {
|
|
2183
2257
|
for (const row of rows) {
|
|
@@ -2202,7 +2276,15 @@ var filterDataTableColumnRows = (rows, columns, filters) => {
|
|
|
2202
2276
|
colDef: column.colDef
|
|
2203
2277
|
}) : row.values.get(column.id);
|
|
2204
2278
|
const { colDef } = column;
|
|
2205
|
-
return matchesTableFilter(filter, value, colDef.type, () => dataTableValueText(value), () =>
|
|
2279
|
+
return matchesTableFilter(filter, value, colDef.type, () => dataTableValueText(value), () => {
|
|
2280
|
+
if (colDef.type === "list")
|
|
2281
|
+
return colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label);
|
|
2282
|
+
if (colDef.type === "text" && colDef.display === "badge") {
|
|
2283
|
+
const key = tableBadgeValue(value);
|
|
2284
|
+
return key === null ? [] : [key];
|
|
2285
|
+
}
|
|
2286
|
+
return [dataTableValueText(value)];
|
|
2287
|
+
});
|
|
2206
2288
|
}));
|
|
2207
2289
|
};
|
|
2208
2290
|
var sortDataTableRows = (rows, columns, sorting) => {
|
|
@@ -2218,6 +2300,12 @@ var sortDataTableRows = (rows, columns, sorting) => {
|
|
|
2218
2300
|
const leftValue = left.row.values.get(sort.id);
|
|
2219
2301
|
const rightValue = right.row.values.get(sort.id);
|
|
2220
2302
|
const colDef = column.colDef;
|
|
2303
|
+
if (!colDef.comparator && colDef.type === "text" && colDef.display === "badge") {
|
|
2304
|
+
const comparison = compareTableSortValues(tableBadgeValue(leftValue), tableBadgeValue(rightValue), sort.direction);
|
|
2305
|
+
if (comparison !== 0)
|
|
2306
|
+
return comparison;
|
|
2307
|
+
continue;
|
|
2308
|
+
}
|
|
2221
2309
|
if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean" || colDef.type === "date" || colDef.type === "dateTime")) {
|
|
2222
2310
|
const comparison = compareTableSortValues(tableSortScalar(colDef.type, leftValue), tableSortScalar(colDef.type, rightValue), sort.direction, colDef.typeOptions?.nulls);
|
|
2223
2311
|
if (comparison !== 0)
|
|
@@ -2369,6 +2457,27 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
2369
2457
|
...params
|
|
2370
2458
|
});
|
|
2371
2459
|
const colDef = column.colDef;
|
|
2460
|
+
if (colDef.type === "text" && colDef.display === "badge") {
|
|
2461
|
+
if (colDef.valueFormatter)
|
|
2462
|
+
return colDef.valueFormatter(params);
|
|
2463
|
+
const badge = tableBadge(value, colDef.typeOptions);
|
|
2464
|
+
if (!badge)
|
|
2465
|
+
return colDef.typeOptions?.emptyLabel ?? "—";
|
|
2466
|
+
const { variant, label, option } = badge;
|
|
2467
|
+
const tone = variant === "success" || variant === "info" || variant === "muted" ? tableBadgeTones[variant] : undefined;
|
|
2468
|
+
return /* @__PURE__ */ jsxs3(Badge, {
|
|
2469
|
+
variant: variant === "success" || variant === "info" || variant === "muted" ? "outline" : variant,
|
|
2470
|
+
className: tone,
|
|
2471
|
+
children: [
|
|
2472
|
+
option?.icon && /* @__PURE__ */ jsx3("span", {
|
|
2473
|
+
"aria-hidden": "true",
|
|
2474
|
+
className: "inline-flex shrink-0 [&_svg]:size-3",
|
|
2475
|
+
children: option.icon
|
|
2476
|
+
}),
|
|
2477
|
+
label
|
|
2478
|
+
]
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2372
2481
|
if (colDef.type === "reference") {
|
|
2373
2482
|
if (colDef.valueFormatter)
|
|
2374
2483
|
return colDef.valueFormatter(params);
|
|
@@ -2396,7 +2505,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
2396
2505
|
const options = colDef.typeOptions;
|
|
2397
2506
|
return /* @__PURE__ */ jsx3("label", {
|
|
2398
2507
|
"data-slot": "data-table-boolean-cell",
|
|
2399
|
-
className: cn(
|
|
2508
|
+
className: cn(booleanCellControl, options?.onChange && !options.disabled?.(row.data) && "hover:bg-muted/50 cursor-pointer"),
|
|
2400
2509
|
onClick: (event) => event.stopPropagation(),
|
|
2401
2510
|
onPointerDown: (event) => event.stopPropagation(),
|
|
2402
2511
|
children: /* @__PURE__ */ jsx3(Checkbox, {
|
|
@@ -4068,7 +4177,9 @@ var GalleryTag = ({
|
|
|
4068
4177
|
if ((value == null || value === "") && !column.colDef.cellRenderer)
|
|
4069
4178
|
return null;
|
|
4070
4179
|
const content = renderCell(row, column, locale, labels);
|
|
4071
|
-
|
|
4180
|
+
const { colDef } = column;
|
|
4181
|
+
const displaysBadges = colDef.type === "text" && colDef.display === "badge" || colDef.type === "list" && colDef.typeOptions.display === "badge";
|
|
4182
|
+
return colDef.cellRenderer || colDef.valueFormatter || displaysBadges ? /* @__PURE__ */ jsxs3("div", {
|
|
4072
4183
|
className: "flex min-w-0 items-center gap-1",
|
|
4073
4184
|
children: [
|
|
4074
4185
|
icon,
|
|
@@ -4785,7 +4896,7 @@ var EditableDataTableListCell = ({
|
|
|
4785
4896
|
} : undefined,
|
|
4786
4897
|
trigger: /* @__PURE__ */ jsxs3(Button2, {
|
|
4787
4898
|
"aria-label": manageLabel,
|
|
4788
|
-
className:
|
|
4899
|
+
className: tableClasses.relationshipTrigger,
|
|
4789
4900
|
variant: "ghost",
|
|
4790
4901
|
children: [
|
|
4791
4902
|
/* @__PURE__ */ jsx3(DataTableListSummaryContent, {
|
|
@@ -5026,6 +5137,32 @@ var DataTableListSummaryContent = ({
|
|
|
5026
5137
|
})
|
|
5027
5138
|
});
|
|
5028
5139
|
}
|
|
5140
|
+
if (display === "badge") {
|
|
5141
|
+
return /* @__PURE__ */ jsxs3("span", {
|
|
5142
|
+
className: "inline-flex min-w-0 flex-wrap items-center gap-1",
|
|
5143
|
+
children: [
|
|
5144
|
+
visible.map((item, index) => /* @__PURE__ */ jsx3(Badge, {
|
|
5145
|
+
variant: "secondary",
|
|
5146
|
+
children: item.label
|
|
5147
|
+
}, item.value ?? `${item.label}-${index}`)),
|
|
5148
|
+
remaining ? /* @__PURE__ */ jsxs3(Badge, {
|
|
5149
|
+
variant: "secondary",
|
|
5150
|
+
children: [
|
|
5151
|
+
"+",
|
|
5152
|
+
remaining
|
|
5153
|
+
]
|
|
5154
|
+
}) : null,
|
|
5155
|
+
remaining && showMenu ? /* @__PURE__ */ jsx3(DataTableListMenu, {
|
|
5156
|
+
actions: [],
|
|
5157
|
+
display,
|
|
5158
|
+
force: true,
|
|
5159
|
+
items: normalized,
|
|
5160
|
+
locale,
|
|
5161
|
+
messages
|
|
5162
|
+
}) : null
|
|
5163
|
+
]
|
|
5164
|
+
});
|
|
5165
|
+
}
|
|
5029
5166
|
return /* @__PURE__ */ jsxs3("span", {
|
|
5030
5167
|
className: "inline-flex min-w-0 items-center gap-2 text-sm",
|
|
5031
5168
|
children: [
|