@krak-stack/registry 0.11.5 → 0.11.7
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 +36 -0
- package/dist/components/audit-log-table/classes.d.ts +1 -0
- package/dist/components/audit-log-table/html.d.ts +158 -0
- package/dist/components/audit-log-table/html.js +3260 -0
- package/dist/components/audit-log-table/index.d.ts +37 -0
- package/dist/components/audit-log-table/react.d.ts +3 -51
- package/dist/components/audit-log-table/react.js +246 -92
- package/dist/components/audit-log-table/schema.d.ts +122 -0
- package/dist/components/copy-button/html.d.ts +2 -2
- package/dist/components/danger-confirmation/index.d.ts +2 -2
- package/dist/components/data-table/classes.d.ts +10 -3
- package/dist/components/data-table/html.d.ts +93 -21
- package/dist/components/data-table/html.js +122 -32
- 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 +162 -19
- package/dist/components/data-table/schema.d.ts +175 -16
- package/dist/components/date-input/html.d.ts +2 -2
- package/dist/components/docs/html.js +1 -1
- package/dist/components/editable-text/html.d.ts +2 -2
- package/dist/components/editable-text/index.d.ts +4 -4
- package/dist/components/editing-locale-switcher/html.d.ts +2 -2
- package/dist/components/email-editor/legacy-editor.html.d.ts +6 -6
- package/dist/components/form/react.d.ts +5 -5
- package/dist/components/locale-switcher/html.d.ts +2 -2
- package/dist/components/map-menu/html.d.ts +4 -4
- package/dist/components/presence-transition/index.d.ts +2 -2
- package/dist/components/select-with-custom-input/html.d.ts +2 -2
- package/dist/components/sidebar-layout/html.js +1 -1
- package/dist/components/switch/react.d.ts +14 -0
- package/dist/components/switch/react.js +55 -0
- package/dist/components/theme-switcher/html.d.ts +2 -2
- package/dist/components/tracking-notice/classes.d.ts +6 -0
- package/dist/components/tracking-notice/html.d.ts +85 -0
- package/dist/components/tracking-notice/html.js +354 -0
- package/dist/components/tracking-notice/index.d.ts +95 -0
- package/dist/components/tracking-notice/react.d.ts +5 -27
- package/dist/components/tracking-notice/react.js +189 -59
- package/dist/components/tracking-notice/schema.d.ts +45 -0
- package/dist/components/upload-attachment/html.d.ts +4 -4
- package/dist/components/virtualized-combobox/html.d.ts +3 -3
- package/dist/components/webhook-delivery-table/html.js +122 -32
- package/dist/components/webhook-delivery-table/react.js +162 -19
- package/dist/services/events/browser.js +39 -26
- package/dist/services/events/index.js +23 -19
- package/dist/services/opentelemetry/web-vitals.js +27 -23
- package/package.json +9 -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",
|
|
@@ -503,6 +510,7 @@ var tableClasses = {
|
|
|
503
510
|
referenceName: "truncate font-medium",
|
|
504
511
|
referenceDescription: "text-muted-foreground truncate text-xs"
|
|
505
512
|
};
|
|
513
|
+
var tableResultsFooterClass = "bg-background text-muted-foreground sticky bottom-0 z-30 shrink-0 border-t px-2 py-2 text-sm";
|
|
506
514
|
var resolveTableClasses = (overrides) => ({
|
|
507
515
|
...tableClasses,
|
|
508
516
|
...overrides
|
|
@@ -616,8 +624,33 @@ var column = {
|
|
|
616
624
|
emptyLabel: Schema4.optionalKey(Schema4.String),
|
|
617
625
|
nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
|
|
618
626
|
};
|
|
627
|
+
var DataTableBadgeOptionSchema = Schema4.Struct({
|
|
628
|
+
value: Schema4.NonEmptyString,
|
|
629
|
+
label: Schema4.optionalKey(Schema4.String),
|
|
630
|
+
variant: Schema4.optionalKey(Schema4.Literals([
|
|
631
|
+
"default",
|
|
632
|
+
"secondary",
|
|
633
|
+
"outline",
|
|
634
|
+
"destructive",
|
|
635
|
+
"success",
|
|
636
|
+
"info",
|
|
637
|
+
"muted"
|
|
638
|
+
]))
|
|
639
|
+
}).annotate({ identifier: "DataTableBadgeOption" });
|
|
640
|
+
var BadgeIcon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableBadgeIcon" });
|
|
641
|
+
var DataTableBadgeOptionsSchema = Schema4.Struct({
|
|
642
|
+
options: Schema4.optionalKey(Schema4.Array(DataTableBadgeOptionSchema.mapFields((fields) => ({
|
|
643
|
+
...fields,
|
|
644
|
+
icon: Schema4.optionalKey(BadgeIcon)
|
|
645
|
+
}))))
|
|
646
|
+
}).annotate({ identifier: "DataTableBadgeOptions" });
|
|
619
647
|
var DataTableFieldSchema = Schema4.Union([
|
|
620
|
-
Schema4.Struct({
|
|
648
|
+
Schema4.Struct({
|
|
649
|
+
...column,
|
|
650
|
+
type: Schema4.Literal("text"),
|
|
651
|
+
display: Schema4.optionalKey(Schema4.Literal("badge")),
|
|
652
|
+
typeOptions: Schema4.optionalKey(DataTableBadgeOptionsSchema)
|
|
653
|
+
}),
|
|
621
654
|
Schema4.Struct({
|
|
622
655
|
...column,
|
|
623
656
|
type: Schema4.Literal("number"),
|
|
@@ -660,7 +693,7 @@ var DataTableFieldSchema = Schema4.Union([
|
|
|
660
693
|
options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
661
694
|
allowRemove: Schema4.optionalKey(Schema4.Boolean),
|
|
662
695
|
itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
663
|
-
display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
|
|
696
|
+
display: Schema4.optionalKey(Schema4.Literals(["list", "icon", "badge"])),
|
|
664
697
|
visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
|
|
665
698
|
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
666
699
|
manageLabel: Schema4.optionalKey(Schema4.String)
|
|
@@ -962,7 +995,33 @@ var matchesFilterText = (value, filter) => {
|
|
|
962
995
|
return text.endsWith(query);
|
|
963
996
|
}
|
|
964
997
|
};
|
|
965
|
-
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
998
|
+
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" || column.display === "badge" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
999
|
+
var tableBadgeValue = (value) => isTableText(value) && value !== "" ? value : null;
|
|
1000
|
+
var tableBadge = (input, config) => {
|
|
1001
|
+
const value = tableBadgeValue(input);
|
|
1002
|
+
if (value === null)
|
|
1003
|
+
return null;
|
|
1004
|
+
const option = config?.options?.find((option) => option.value === value);
|
|
1005
|
+
return {
|
|
1006
|
+
value,
|
|
1007
|
+
label: option?.label ?? value,
|
|
1008
|
+
variant: option?.variant ?? "secondary",
|
|
1009
|
+
option
|
|
1010
|
+
};
|
|
1011
|
+
};
|
|
1012
|
+
var tableBadgeFilterOptions = (values, config) => {
|
|
1013
|
+
const options = new Map(config?.options?.map(({ value, label }) => [value, label ?? value]));
|
|
1014
|
+
for (const input of values) {
|
|
1015
|
+
const value = tableBadgeValue(input);
|
|
1016
|
+
if (value !== null && !options.has(value))
|
|
1017
|
+
options.set(value, value);
|
|
1018
|
+
}
|
|
1019
|
+
return [...options].map(([value, label]) => ({ value, label }));
|
|
1020
|
+
};
|
|
1021
|
+
var tableBadgeSearchText = (value, config) => {
|
|
1022
|
+
const badge = tableBadge(value, config);
|
|
1023
|
+
return badge ? `${badge.label} ${badge.value}` : "";
|
|
1024
|
+
};
|
|
966
1025
|
var matchesTableFilter = (filter, value, type, text, values) => {
|
|
967
1026
|
switch (filter.kind) {
|
|
968
1027
|
case "text":
|
|
@@ -1007,13 +1066,20 @@ var filterTableColumns = (rows, columns, filters) => {
|
|
|
1007
1066
|
return rows;
|
|
1008
1067
|
return rows.filter((row) => active.every((filter) => {
|
|
1009
1068
|
const value = row.cells[filter.id];
|
|
1010
|
-
|
|
1069
|
+
const column = byId.get(filter.id);
|
|
1070
|
+
return matchesTableFilter(filter, value, column?.type, () => isTableText(value) ? value : isTableReference(value) ? `${value.label} ${value.description ?? ""}`.trim() : "", () => {
|
|
1071
|
+
if (column?.type === "text" && column.display === "badge") {
|
|
1072
|
+
const key = tableBadgeValue(value);
|
|
1073
|
+
return key === null ? [] : [key];
|
|
1074
|
+
}
|
|
1075
|
+
return isTableList(value) ? value.map(({ value }) => value) : [];
|
|
1076
|
+
});
|
|
1011
1077
|
}));
|
|
1012
1078
|
};
|
|
1013
1079
|
var columnValue = (column, value) => {
|
|
1014
1080
|
switch (column.type) {
|
|
1015
1081
|
case "text":
|
|
1016
|
-
return isTableText(value) ? value : null;
|
|
1082
|
+
return column.display === "badge" ? tableBadgeValue(value) : isTableText(value) ? value : null;
|
|
1017
1083
|
case "number":
|
|
1018
1084
|
case "boolean":
|
|
1019
1085
|
case "date":
|
|
@@ -1067,6 +1133,8 @@ var filterTableRows = (rows, columns, search, locale) => {
|
|
|
1067
1133
|
const searchable = columns.filter(({ searchable }) => searchable !== false);
|
|
1068
1134
|
return rows.filter((row) => searchable.some((column) => {
|
|
1069
1135
|
const value = row.cells[column.id];
|
|
1136
|
+
if (column.type === "text" && column.display === "badge")
|
|
1137
|
+
return tableBadgeSearchText(value, column.typeOptions).toLocaleLowerCase(locale).includes(query);
|
|
1070
1138
|
if (column.type === "date" || column.type === "dateTime") {
|
|
1071
1139
|
const date = resolveDate(value, column.type);
|
|
1072
1140
|
return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
|
|
@@ -1822,6 +1890,14 @@ var dataTableBehaviours = {
|
|
|
1822
1890
|
// ../../src/components/data-table/html.ts
|
|
1823
1891
|
var keyOf = (...parts) => JSON.stringify(parts);
|
|
1824
1892
|
var cellClass = "px-3 py-2 align-middle";
|
|
1893
|
+
var badgeVariants = {
|
|
1894
|
+
...tableBadgeTones,
|
|
1895
|
+
default: "bg-primary text-primary-foreground",
|
|
1896
|
+
secondary: "bg-secondary text-secondary-foreground",
|
|
1897
|
+
outline: "border-border text-foreground",
|
|
1898
|
+
destructive: "bg-destructive/10 text-destructive dark:bg-destructive/20"
|
|
1899
|
+
};
|
|
1900
|
+
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
1901
|
var isTextFilterOperator = Schema6.is(TextFilterOperator);
|
|
1826
1902
|
var RowDrag = "application/x-krakstack-table-row";
|
|
1827
1903
|
var PersistPreferences = Mount.makeStream("DataTable/PersistPreferences", {
|
|
@@ -1926,7 +2002,9 @@ var DataTable = Html2.component({
|
|
|
1926
2002
|
const dropOnRow = (rowId, group) => group ? DataTableMessage.GroupDropped(group) : reorder ? DataTableMessage.DragDropped({ targetId: rowId }) : undefined;
|
|
1927
2003
|
const rowActions = reorder || props.rowData.some(({ actions }) => actions?.length);
|
|
1928
2004
|
const span = Math.max(1, columns.length + Number(!!selection) + Number(rowActions) + Number(draggable));
|
|
1929
|
-
const
|
|
2005
|
+
const virtualization = features.virtualization;
|
|
2006
|
+
const fillHeight = virtualization && virtualization !== true && virtualization.scroll === "internal";
|
|
2007
|
+
const virtual = tableVirtualization(rows.length, virtualization, !grouping.length && !gallery && !features.reordering && props.status?.error === undefined && rows.length > 0);
|
|
1930
2008
|
const ids = rows.filter(({ selectable }) => selectable !== false).map(({ id }) => id);
|
|
1931
2009
|
const selectedHere = ids.filter((id) => selected.has(id)).length;
|
|
1932
2010
|
const status = props.status;
|
|
@@ -2092,11 +2170,13 @@ var DataTable = Html2.component({
|
|
|
2092
2170
|
})))));
|
|
2093
2171
|
}
|
|
2094
2172
|
});
|
|
2095
|
-
const check = (key, label, checked, onToggle, options) => Checkbox(h, {
|
|
2173
|
+
const check = (key, label, checked, onToggle, options, inCell = false) => Checkbox(h, {
|
|
2096
2174
|
key,
|
|
2097
2175
|
props: { checked, ...options },
|
|
2098
2176
|
onEmit: { Toggled: ({ checked }) => onToggle(checked) },
|
|
2099
|
-
view: (checkbox) => h.span.class("grid size-4 shrink-0 place-items-center").children(CheckboxRoot(h, checkbox
|
|
2177
|
+
view: (checkbox) => h.span.class("grid size-4 shrink-0 place-items-center").children(CheckboxRoot(h, checkbox, {
|
|
2178
|
+
class: inCell ? "focus-visible:outline-none" : undefined
|
|
2179
|
+
}).attr("aria-label", label).children(CheckboxIndicator(h, checkbox, {
|
|
2100
2180
|
class: "pointer-events-none"
|
|
2101
2181
|
})))
|
|
2102
2182
|
});
|
|
@@ -2152,9 +2232,9 @@ var DataTable = Html2.component({
|
|
|
2152
2232
|
filter: { id, kind: "boolean", value }
|
|
2153
2233
|
})
|
|
2154
2234
|
}));
|
|
2155
|
-
} else if (column.type === "list") {
|
|
2235
|
+
} else if (column.type === "list" || column.type === "text" && column.display === "badge") {
|
|
2156
2236
|
const selected = current?.kind === "values" ? current.values : [];
|
|
2157
|
-
const options = column.filterOptions ?? tableFilterOptions(props.rowData, id, locale);
|
|
2237
|
+
const options = column.type === "text" ? tableBadgeFilterOptions(props.rowData.map((row) => row.cells[id]), column.typeOptions) : column.filterOptions ?? tableFilterOptions(props.rowData, id, locale);
|
|
2158
2238
|
children = options.map(({ value, label }) => {
|
|
2159
2239
|
const checked = selected.includes(value);
|
|
2160
2240
|
const values = updateSelectedRows(selected, [value], !checked);
|
|
@@ -2187,6 +2267,12 @@ var DataTable = Html2.component({
|
|
|
2187
2267
|
const disabled = row.disabledColumnIds?.includes(column.id);
|
|
2188
2268
|
const edit = (edit) => DataTableMessage.CellEditRequested({ rowId: row.id, columnId: column.id, edit });
|
|
2189
2269
|
switch (column.type) {
|
|
2270
|
+
case "text": {
|
|
2271
|
+
if (column.display !== "badge")
|
|
2272
|
+
return isTableText(value) ? value : empty;
|
|
2273
|
+
const badge = tableBadge(value, column.typeOptions);
|
|
2274
|
+
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;
|
|
2275
|
+
}
|
|
2190
2276
|
case "number":
|
|
2191
2277
|
return isTableNumber(value) ? formatNumberValue(value, column.typeOptions, locale) : empty;
|
|
2192
2278
|
case "date":
|
|
@@ -2195,7 +2281,7 @@ var DataTable = Html2.component({
|
|
|
2195
2281
|
return date ? h.time.attr("datetime", dateIsoValue(date)).children(formatDateValue(date, column, locale)) : empty;
|
|
2196
2282
|
}
|
|
2197
2283
|
case "boolean":
|
|
2198
|
-
return isTableBoolean(value) ?
|
|
2284
|
+
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
2285
|
case "reference":
|
|
2200
2286
|
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
2287
|
src: value.imageSrc,
|
|
@@ -2204,6 +2290,9 @@ var DataTable = Html2.component({
|
|
|
2204
2290
|
}).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
2291
|
case "list": {
|
|
2206
2292
|
const current = isTableList(value) ? value : [];
|
|
2293
|
+
const visible = current.slice(0, column.visibleCount ?? 3);
|
|
2294
|
+
const overflow = current.length - visible.length;
|
|
2295
|
+
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
2296
|
if (column.manageLabel && !disabled && (column.options || column.allowRemove)) {
|
|
2208
2297
|
const used = new Set(current.map(({ value }) => value));
|
|
2209
2298
|
const available = (column.options ?? []).filter(({ value }) => !used.has(value));
|
|
@@ -2239,15 +2328,13 @@ var DataTable = Html2.component({
|
|
|
2239
2328
|
}
|
|
2240
2329
|
] : []
|
|
2241
2330
|
], 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)
|
|
2331
|
+
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
2332
|
}));
|
|
2244
2333
|
}
|
|
2245
2334
|
if (column.display && !column.options && !column.allowRemove) {
|
|
2246
|
-
const visible = current.slice(0, column.visibleCount ?? 3);
|
|
2247
|
-
const overflow = current.length - visible.length;
|
|
2248
2335
|
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 :
|
|
2336
|
+
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}` : ""}`);
|
|
2337
|
+
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
2338
|
id: value,
|
|
2252
2339
|
name: label,
|
|
2253
2340
|
...column.itemActions?.length ? {
|
|
@@ -2261,11 +2348,11 @@ var DataTable = Html2.component({
|
|
|
2261
2348
|
})
|
|
2262
2349
|
}))
|
|
2263
2350
|
} : { disabled: true }
|
|
2264
|
-
})), false, undefined, false, { relationship: summary }))
|
|
2351
|
+
})), false, undefined, false, { relationship: summary }));
|
|
2265
2352
|
}
|
|
2266
2353
|
const used = new Set(current.map(({ value }) => value));
|
|
2267
2354
|
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) => ({
|
|
2355
|
+
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
2356
|
...action,
|
|
2270
2357
|
message: DataTableMessage.ItemActionRequested({
|
|
2271
2358
|
rowId: row.id,
|
|
@@ -2283,8 +2370,6 @@ var DataTable = Html2.component({
|
|
|
2283
2370
|
message: edit(DataTableEdit.AddItem({ itemId: value }))
|
|
2284
2371
|
})), false, copy.addItem));
|
|
2285
2372
|
}
|
|
2286
|
-
case "text":
|
|
2287
|
-
return isTableText(value) ? value : empty;
|
|
2288
2373
|
}
|
|
2289
2374
|
};
|
|
2290
2375
|
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 +2387,9 @@ var DataTable = Html2.component({
|
|
|
2302
2387
|
};
|
|
2303
2388
|
const drop = dropOnRow(row.id, group);
|
|
2304
2389
|
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"));
|
|
2390
|
+
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
2391
|
const content = () => h.div.class(cn(tableClasses.cellContent, column.truncate && "truncate")).children(cell(column, row));
|
|
2307
|
-
if (column.type === "list" || column.type === "boolean" &&
|
|
2392
|
+
if (column.type === "list" || column.type === "boolean" && isTableBoolean(row.cells[column.id])) {
|
|
2308
2393
|
return td.on("click", ignoreActivation).on("keydown", ignoreActivation).children(content());
|
|
2309
2394
|
}
|
|
2310
2395
|
return (!props.rowActivation && activate && column.type !== "boolean" ? td.class("cursor-pointer").on("click", activate) : td).children(content());
|
|
@@ -2330,7 +2415,12 @@ var DataTable = Html2.component({
|
|
|
2330
2415
|
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
2416
|
variant: "ghost",
|
|
2332
2417
|
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) =>
|
|
2418
|
+
}).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) => {
|
|
2419
|
+
const column = props.columnDefs.find((column) => column.id === id);
|
|
2420
|
+
if ((column?.type === "text" || column?.type === "list") && column.display === "badge")
|
|
2421
|
+
return h.div.key(id).children(cell(column, row));
|
|
2422
|
+
return h.span.key(id).class("bg-muted rounded px-2 py-1 text-xs").children(galleryValue(id, row));
|
|
2423
|
+
})), 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
2424
|
};
|
|
2335
2425
|
const renderGroups = (members, depth, parent, parentTarget) => {
|
|
2336
2426
|
const field = grouping[depth];
|
|
@@ -2365,7 +2455,7 @@ var DataTable = Html2.component({
|
|
|
2365
2455
|
];
|
|
2366
2456
|
});
|
|
2367
2457
|
};
|
|
2368
|
-
return h.section.class(cn("
|
|
2458
|
+
return h.section.class(cn("min-w-0 gap-2", fillHeight ? "flex min-h-0 flex-1 flex-col" : "grid", props.className)).onMount(PersistPreferences({
|
|
2369
2459
|
columns: props.columnDefs.map(({ id }) => id),
|
|
2370
2460
|
gallery: !!features.gallery,
|
|
2371
2461
|
preferences: tablePreferences(model)
|
|
@@ -2599,7 +2689,7 @@ var DataTable = Html2.component({
|
|
|
2599
2689
|
] : [];
|
|
2600
2690
|
}) : renderGroups(rows, 0, "")));
|
|
2601
2691
|
};
|
|
2602
|
-
const viewport = () => h.div.class("@container overflow-auto");
|
|
2692
|
+
const viewport = () => h.div.class(cn("@container overflow-auto", fillHeight && "min-h-0 flex-1"));
|
|
2603
2693
|
if (!virtual)
|
|
2604
2694
|
return viewport().children(renderTable());
|
|
2605
2695
|
return VirtualList(h, {
|
|
@@ -2611,11 +2701,11 @@ var DataTable = Html2.component({
|
|
|
2611
2701
|
overscan: virtual.overscan,
|
|
2612
2702
|
initialCount: virtual.initialCount
|
|
2613
2703
|
},
|
|
2614
|
-
view: (list) => virtual.scroll === "page" ? h.div.children(renderTable(list)) : list.viewport(viewport().style({
|
|
2704
|
+
view: (list) => virtual.scroll === "page" ? h.div.children(renderTable(list)) : list.viewport(fillHeight ? viewport() : viewport().style({
|
|
2615
2705
|
maxHeight: `${virtual.height}px`
|
|
2616
2706
|
})).children(renderTable(list))
|
|
2617
2707
|
});
|
|
2618
|
-
})(), paginationVisible
|
|
2708
|
+
})(), paginationVisible ? Pagination(h, {
|
|
2619
2709
|
props: {
|
|
2620
2710
|
locale,
|
|
2621
2711
|
page,
|
|
@@ -2629,7 +2719,7 @@ var DataTable = Html2.component({
|
|
|
2629
2719
|
PageChanged: ({ page }) => DataTableMessage.PageRequested({ page }),
|
|
2630
2720
|
PageSizeChanged: ({ pageSize }) => DataTableMessage.PageSizeRequested({ pageSize })
|
|
2631
2721
|
}
|
|
2632
|
-
}));
|
|
2722
|
+
}) : h.div.attr("role", "status").class(tableResultsFooterClass).children(paginationMessages(locale).results(totalRows)));
|
|
2633
2723
|
}
|
|
2634
2724
|
});
|
|
2635
2725
|
|