@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.
Files changed (47) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/components/audit-log-table/classes.d.ts +1 -0
  3. package/dist/components/audit-log-table/html.d.ts +158 -0
  4. package/dist/components/audit-log-table/html.js +3260 -0
  5. package/dist/components/audit-log-table/index.d.ts +37 -0
  6. package/dist/components/audit-log-table/react.d.ts +3 -51
  7. package/dist/components/audit-log-table/react.js +246 -92
  8. package/dist/components/audit-log-table/schema.d.ts +122 -0
  9. package/dist/components/copy-button/html.d.ts +2 -2
  10. package/dist/components/danger-confirmation/index.d.ts +2 -2
  11. package/dist/components/data-table/classes.d.ts +10 -3
  12. package/dist/components/data-table/html.d.ts +93 -21
  13. package/dist/components/data-table/html.js +122 -32
  14. package/dist/components/data-table/index.d.ts +97 -9
  15. package/dist/components/data-table/react.d.ts +14 -3
  16. package/dist/components/data-table/react.js +162 -19
  17. package/dist/components/data-table/schema.d.ts +175 -16
  18. package/dist/components/date-input/html.d.ts +2 -2
  19. package/dist/components/docs/html.js +1 -1
  20. package/dist/components/editable-text/html.d.ts +2 -2
  21. package/dist/components/editable-text/index.d.ts +4 -4
  22. package/dist/components/editing-locale-switcher/html.d.ts +2 -2
  23. package/dist/components/email-editor/legacy-editor.html.d.ts +6 -6
  24. package/dist/components/form/react.d.ts +5 -5
  25. package/dist/components/locale-switcher/html.d.ts +2 -2
  26. package/dist/components/map-menu/html.d.ts +4 -4
  27. package/dist/components/presence-transition/index.d.ts +2 -2
  28. package/dist/components/select-with-custom-input/html.d.ts +2 -2
  29. package/dist/components/sidebar-layout/html.js +1 -1
  30. package/dist/components/switch/react.d.ts +14 -0
  31. package/dist/components/switch/react.js +55 -0
  32. package/dist/components/theme-switcher/html.d.ts +2 -2
  33. package/dist/components/tracking-notice/classes.d.ts +6 -0
  34. package/dist/components/tracking-notice/html.d.ts +85 -0
  35. package/dist/components/tracking-notice/html.js +354 -0
  36. package/dist/components/tracking-notice/index.d.ts +95 -0
  37. package/dist/components/tracking-notice/react.d.ts +5 -27
  38. package/dist/components/tracking-notice/react.js +189 -59
  39. package/dist/components/tracking-notice/schema.d.ts +45 -0
  40. package/dist/components/upload-attachment/html.d.ts +4 -4
  41. package/dist/components/virtualized-combobox/html.d.ts +3 -3
  42. package/dist/components/webhook-delivery-table/html.js +122 -32
  43. package/dist/components/webhook-delivery-table/react.js +162 -19
  44. package/dist/services/events/browser.js +39 -26
  45. package/dist/services/events/index.js +23 -19
  46. package/dist/services/opentelemetry/web-vitals.js +27 -23
  47. package/package.json +9 -1
@@ -614,6 +614,13 @@ import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
614
614
  import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
615
615
 
616
616
  // ../../src/components/data-table/classes.ts
617
+ 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";
618
+ var cellTriggerFocus = "focus-visible:ring-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring";
619
+ var tableBadgeTones = {
620
+ success: "border-emerald-200 bg-emerald-100 text-emerald-900 dark:border-emerald-900/50 dark:bg-emerald-950/50 dark:text-emerald-200",
621
+ info: "border-blue-200 bg-blue-100 text-blue-900 dark:border-blue-900/50 dark:bg-blue-950/50 dark:text-blue-200",
622
+ muted: "border-muted bg-muted text-muted-foreground dark:bg-muted/50"
623
+ };
617
624
  var tableClasses = {
618
625
  selectionCell: "w-10 p-0 align-middle",
619
626
  selectionCenter: "grid place-items-center",
@@ -625,16 +632,16 @@ var tableClasses = {
625
632
  menubar: "h-auto w-full flex-wrap justify-start border border-input bg-transparent",
626
633
  cell: "overflow-hidden",
627
634
  cellContent: "min-w-0 wrap-anywhere",
628
- actionTrigger: "size-8 focus-visible:ring-inset",
635
+ actionTrigger: `size-8 ${cellTriggerFocus}`,
629
636
  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))]",
630
637
  actionsAlign: "flex min-h-12 items-center justify-end pe-1",
631
638
  header: "relative h-12 p-0",
632
639
  stickyHeader: "sticky top-0 z-30 bg-background",
633
640
  stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
634
- headerTrigger: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 focus-visible:ring-inset",
641
+ headerTrigger: `absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 ${cellTriggerFocus}`,
635
642
  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",
636
643
  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",
637
- relationshipTrigger: "h-full w-full min-w-0 justify-between rounded-none px-2 text-start focus-visible:ring-inset",
644
+ relationshipTrigger: `h-full w-full min-w-0 justify-between rounded-none px-2 text-start ${cellTriggerFocus}`,
638
645
  reference: "flex min-w-0 items-center gap-2",
639
646
  referenceAvatar: "relative grid size-8 shrink-0 place-items-center overflow-hidden bg-muted text-xs font-medium",
640
647
  referenceText: "flex min-w-0 flex-col leading-tight",
@@ -645,6 +652,7 @@ var tableClasses = {
645
652
  referenceName: "truncate font-medium",
646
653
  referenceDescription: "text-muted-foreground truncate text-xs"
647
654
  };
655
+ var tableResultsFooterClass = "bg-background text-muted-foreground sticky bottom-0 z-30 shrink-0 border-t px-2 py-2 text-sm";
648
656
  var resolveTableClasses = (overrides) => ({
649
657
  ...tableClasses,
650
658
  ...overrides
@@ -656,7 +664,7 @@ import { Csv } from "effect/encoding";
656
664
  import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
657
665
 
658
666
  // ../../src/components/data-table/schema.ts
659
- import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
667
+ import { DateTime as DateTime2, Option as Option2, Predicate, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
660
668
  var TableClassesOverridesSchema = Schema4.Record(Schema4.Literals(Struct2.keys(tableClasses)), Schema4.optionalKey(Schema4.String)).annotate({ identifier: "TableClassesOverrides" });
661
669
  var DataTableCommonPropsSchema = Schema4.Struct({
662
670
  classes: Schema4.optional(TableClassesOverridesSchema),
@@ -764,8 +772,33 @@ var column = {
764
772
  emptyLabel: Schema4.optionalKey(Schema4.String),
765
773
  nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
766
774
  };
775
+ var DataTableBadgeOptionSchema = Schema4.Struct({
776
+ value: Schema4.NonEmptyString,
777
+ label: Schema4.optionalKey(Schema4.String),
778
+ variant: Schema4.optionalKey(Schema4.Literals([
779
+ "default",
780
+ "secondary",
781
+ "outline",
782
+ "destructive",
783
+ "success",
784
+ "info",
785
+ "muted"
786
+ ]))
787
+ }).annotate({ identifier: "DataTableBadgeOption" });
788
+ var BadgeIcon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableBadgeIcon" });
789
+ var DataTableBadgeOptionsSchema = Schema4.Struct({
790
+ options: Schema4.optionalKey(Schema4.Array(DataTableBadgeOptionSchema.mapFields((fields) => ({
791
+ ...fields,
792
+ icon: Schema4.optionalKey(BadgeIcon)
793
+ }))))
794
+ }).annotate({ identifier: "DataTableBadgeOptions" });
767
795
  var DataTableFieldSchema = Schema4.Union([
768
- Schema4.Struct({ ...column, type: Schema4.Literal("text") }),
796
+ Schema4.Struct({
797
+ ...column,
798
+ type: Schema4.Literal("text"),
799
+ display: Schema4.optionalKey(Schema4.Literal("badge")),
800
+ typeOptions: Schema4.optionalKey(DataTableBadgeOptionsSchema)
801
+ }),
769
802
  Schema4.Struct({
770
803
  ...column,
771
804
  type: Schema4.Literal("number"),
@@ -808,7 +841,7 @@ var DataTableFieldSchema = Schema4.Union([
808
841
  options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
809
842
  allowRemove: Schema4.optionalKey(Schema4.Boolean),
810
843
  itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
811
- display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
844
+ display: Schema4.optionalKey(Schema4.Literals(["list", "icon", "badge"])),
812
845
  visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
813
846
  actionsLabel: Schema4.optionalKey(Schema4.String),
814
847
  manageLabel: Schema4.optionalKey(Schema4.String)
@@ -1102,7 +1135,33 @@ var matchesFilterText = (value, filter) => {
1102
1135
  return text.endsWith(query);
1103
1136
  }
1104
1137
  };
1105
- var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
1138
+ var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" || column.display === "badge" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
1139
+ var tableBadgeValue = (value) => isTableText(value) && value !== "" ? value : null;
1140
+ var tableBadge = (input, config) => {
1141
+ const value = tableBadgeValue(input);
1142
+ if (value === null)
1143
+ return null;
1144
+ const option = config?.options?.find((option) => option.value === value);
1145
+ return {
1146
+ value,
1147
+ label: option?.label ?? value,
1148
+ variant: option?.variant ?? "secondary",
1149
+ option
1150
+ };
1151
+ };
1152
+ var tableBadgeFilterOptions = (values, config) => {
1153
+ const options = new Map(config?.options?.map(({ value, label }) => [value, label ?? value]));
1154
+ for (const input of values) {
1155
+ const value = tableBadgeValue(input);
1156
+ if (value !== null && !options.has(value))
1157
+ options.set(value, value);
1158
+ }
1159
+ return [...options].map(([value, label]) => ({ value, label }));
1160
+ };
1161
+ var tableBadgeSearchText = (value, config) => {
1162
+ const badge = tableBadge(value, config);
1163
+ return badge ? `${badge.label} ${badge.value}` : "";
1164
+ };
1106
1165
  var matchesTableFilter = (filter, value, type, text, values) => {
1107
1166
  switch (filter.kind) {
1108
1167
  case "text":
@@ -1136,13 +1195,20 @@ var filterTableColumns = (rows, columns, filters) => {
1136
1195
  return rows;
1137
1196
  return rows.filter((row) => active.every((filter) => {
1138
1197
  const value = row.cells[filter.id];
1139
- 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) : []);
1198
+ const column = byId.get(filter.id);
1199
+ return matchesTableFilter(filter, value, column?.type, () => isTableText(value) ? value : isTableReference(value) ? `${value.label} ${value.description ?? ""}`.trim() : "", () => {
1200
+ if (column?.type === "text" && column.display === "badge") {
1201
+ const key = tableBadgeValue(value);
1202
+ return key === null ? [] : [key];
1203
+ }
1204
+ return isTableList(value) ? value.map(({ value }) => value) : [];
1205
+ });
1140
1206
  }));
1141
1207
  };
1142
1208
  var columnValue = (column, value) => {
1143
1209
  switch (column.type) {
1144
1210
  case "text":
1145
- return isTableText(value) ? value : null;
1211
+ return column.display === "badge" ? tableBadgeValue(value) : isTableText(value) ? value : null;
1146
1212
  case "number":
1147
1213
  case "boolean":
1148
1214
  case "date":
@@ -1196,6 +1262,8 @@ var filterTableRows = (rows, columns, search, locale) => {
1196
1262
  const searchable = columns.filter(({ searchable }) => searchable !== false);
1197
1263
  return rows.filter((row) => searchable.some((column) => {
1198
1264
  const value = row.cells[column.id];
1265
+ if (column.type === "text" && column.display === "badge")
1266
+ return tableBadgeSearchText(value, column.typeOptions).toLocaleLowerCase(locale).includes(query);
1199
1267
  if (column.type === "date" || column.type === "dateTime") {
1200
1268
  const date = resolveDate(value, column.type);
1201
1269
  return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
@@ -2125,6 +2193,8 @@ var booleanLabel = (value, options) => value ? options?.trueLabel : options?.fal
2125
2193
  var getDataTableExportValue = (row, column, locale = "en") => {
2126
2194
  const value = row.values.get(column.id);
2127
2195
  const colDef = column.colDef;
2196
+ if (colDef.type === "text" && colDef.display === "badge")
2197
+ return tableBadgeValue(value);
2128
2198
  if (colDef.type === "number") {
2129
2199
  const number = Option4.getOrUndefined(decodeNumberValue(value));
2130
2200
  if (number === undefined)
@@ -2153,7 +2223,9 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
2153
2223
  const value = row.values.get(column.id);
2154
2224
  const colDef = column.colDef;
2155
2225
  let text = dataTableValueText(value);
2156
- if (colDef.type === "date" || colDef.type === "dateTime") {
2226
+ if (colDef.type === "text" && colDef.display === "badge") {
2227
+ text = tableBadgeSearchText(value, colDef.typeOptions);
2228
+ } else if (colDef.type === "date" || colDef.type === "dateTime") {
2157
2229
  const date = resolveDate(value, colDef.type);
2158
2230
  text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
2159
2231
  } else if (colDef.type === "number") {
@@ -2169,11 +2241,14 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
2169
2241
  var getDataTableFilterColumns = (columns) => columns.flatMap((column) => column.colDef.filterable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.filterable !== false));
2170
2242
  var getDataTableFilterKind = ({
2171
2243
  colDef
2172
- }) => tableFilterKind(colDef, !!colDef.filterOptions);
2244
+ }) => tableFilterKind(colDef.type === "text" ? colDef : { type: colDef.type }, !!colDef.filterOptions);
2173
2245
  var getDataTableFilterOptions = (rows, column) => {
2174
2246
  const { colDef } = column;
2175
2247
  if (colDef.filterOptions)
2176
2248
  return colDef.filterOptions;
2249
+ if (colDef.type === "text" && colDef.display === "badge") {
2250
+ return tableBadgeFilterOptions(rows.map((row) => row.values.get(column.id)), colDef.typeOptions);
2251
+ }
2177
2252
  const options = new Map;
2178
2253
  if (colDef.type === "list") {
2179
2254
  for (const row of rows) {
@@ -2198,7 +2273,15 @@ var filterDataTableColumnRows = (rows, columns, filters) => {
2198
2273
  colDef: column.colDef
2199
2274
  }) : row.values.get(column.id);
2200
2275
  const { colDef } = column;
2201
- return matchesTableFilter(filter, value, colDef.type, () => dataTableValueText(value), () => colDef.type === "list" ? colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label) : [dataTableValueText(value)]);
2276
+ return matchesTableFilter(filter, value, colDef.type, () => dataTableValueText(value), () => {
2277
+ if (colDef.type === "list")
2278
+ return colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label);
2279
+ if (colDef.type === "text" && colDef.display === "badge") {
2280
+ const key = tableBadgeValue(value);
2281
+ return key === null ? [] : [key];
2282
+ }
2283
+ return [dataTableValueText(value)];
2284
+ });
2202
2285
  }));
2203
2286
  };
2204
2287
  var sortDataTableRows = (rows, columns, sorting) => {
@@ -2214,6 +2297,12 @@ var sortDataTableRows = (rows, columns, sorting) => {
2214
2297
  const leftValue = left.row.values.get(sort.id);
2215
2298
  const rightValue = right.row.values.get(sort.id);
2216
2299
  const colDef = column.colDef;
2300
+ if (!colDef.comparator && colDef.type === "text" && colDef.display === "badge") {
2301
+ const comparison = compareTableSortValues(tableBadgeValue(leftValue), tableBadgeValue(rightValue), sort.direction);
2302
+ if (comparison !== 0)
2303
+ return comparison;
2304
+ continue;
2305
+ }
2217
2306
  if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean" || colDef.type === "date" || colDef.type === "dateTime")) {
2218
2307
  const comparison = compareTableSortValues(tableSortScalar(colDef.type, leftValue), tableSortScalar(colDef.type, rightValue), sort.direction, colDef.typeOptions?.nulls);
2219
2308
  if (comparison !== 0)
@@ -2365,6 +2454,27 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
2365
2454
  ...params
2366
2455
  });
2367
2456
  const colDef = column.colDef;
2457
+ if (colDef.type === "text" && colDef.display === "badge") {
2458
+ if (colDef.valueFormatter)
2459
+ return colDef.valueFormatter(params);
2460
+ const badge = tableBadge(value, colDef.typeOptions);
2461
+ if (!badge)
2462
+ return colDef.typeOptions?.emptyLabel ?? "—";
2463
+ const { variant, label, option } = badge;
2464
+ const tone = variant === "success" || variant === "info" || variant === "muted" ? tableBadgeTones[variant] : undefined;
2465
+ return /* @__PURE__ */ jsxs3(Badge, {
2466
+ variant: variant === "success" || variant === "info" || variant === "muted" ? "outline" : variant,
2467
+ className: tone,
2468
+ children: [
2469
+ option?.icon && /* @__PURE__ */ jsx3("span", {
2470
+ "aria-hidden": "true",
2471
+ className: "inline-flex shrink-0 [&_svg]:size-3",
2472
+ children: option.icon
2473
+ }),
2474
+ label
2475
+ ]
2476
+ });
2477
+ }
2368
2478
  if (colDef.type === "reference") {
2369
2479
  if (colDef.valueFormatter)
2370
2480
  return colDef.valueFormatter(params);
@@ -2392,7 +2502,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
2392
2502
  const options = colDef.typeOptions;
2393
2503
  return /* @__PURE__ */ jsx3("label", {
2394
2504
  "data-slot": "data-table-boolean-cell",
2395
- className: cn("focus-within:border-ring focus-within:ring-ring/50 flex min-h-16 w-full items-center justify-start border border-transparent px-2 outline-none focus-within:ring-3 focus-within:ring-inset in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0", options?.onChange && !options.disabled?.(row.data) && "hover:bg-muted/50 cursor-pointer"),
2505
+ className: cn(booleanCellControl, options?.onChange && !options.disabled?.(row.data) && "hover:bg-muted/50 cursor-pointer"),
2396
2506
  onClick: (event) => event.stopPropagation(),
2397
2507
  onPointerDown: (event) => event.stopPropagation(),
2398
2508
  children: /* @__PURE__ */ jsx3(Checkbox, {
@@ -4064,7 +4174,9 @@ var GalleryTag = ({
4064
4174
  if ((value == null || value === "") && !column.colDef.cellRenderer)
4065
4175
  return null;
4066
4176
  const content = renderCell(row, column, locale, labels);
4067
- return column.colDef.cellRenderer || column.colDef.valueFormatter ? /* @__PURE__ */ jsxs3("div", {
4177
+ const { colDef } = column;
4178
+ const displaysBadges = colDef.type === "text" && colDef.display === "badge" || colDef.type === "list" && colDef.typeOptions.display === "badge";
4179
+ return colDef.cellRenderer || colDef.valueFormatter || displaysBadges ? /* @__PURE__ */ jsxs3("div", {
4068
4180
  className: "flex min-w-0 items-center gap-1",
4069
4181
  children: [
4070
4182
  icon,
@@ -4273,7 +4385,7 @@ var DataTableGallery = ({
4273
4385
  children: renderSections(sections)
4274
4386
  });
4275
4387
  };
4276
- var DataTablePagination = ({
4388
+ var DataTableFooter = ({
4277
4389
  table
4278
4390
  }) => {
4279
4391
  const styles = useContext(DataTableStylesContext);
@@ -4287,8 +4399,13 @@ var DataTablePagination = ({
4287
4399
  send(DataTableMessage.PageRequested({ page }));
4288
4400
  }
4289
4401
  }, [page, pageIndex, pagination, paginationVisible, send]);
4290
- if (!paginationVisible || !pagination)
4291
- return null;
4402
+ if (!paginationVisible || !pagination) {
4403
+ return /* @__PURE__ */ jsx3("div", {
4404
+ className: tableResultsFooterClass,
4405
+ role: "status",
4406
+ children: store.config.labels.results(model.totalRows)
4407
+ });
4408
+ }
4292
4409
  const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
4293
4410
  return /* @__PURE__ */ jsx3("div", {
4294
4411
  "data-table-slot": "pagination",
@@ -4485,7 +4602,7 @@ var HydratedDataTable = (props) => {
4485
4602
  /* @__PURE__ */ jsx3(DataTableContent, {
4486
4603
  table
4487
4604
  }),
4488
- /* @__PURE__ */ jsx3(DataTablePagination, {
4605
+ /* @__PURE__ */ jsx3(DataTableFooter, {
4489
4606
  table
4490
4607
  })
4491
4608
  ]
@@ -4781,7 +4898,7 @@ var EditableDataTableListCell = ({
4781
4898
  } : undefined,
4782
4899
  trigger: /* @__PURE__ */ jsxs3(Button2, {
4783
4900
  "aria-label": manageLabel,
4784
- className: "h-full w-full min-w-0 justify-between rounded-none px-2 focus-visible:ring-inset",
4901
+ className: tableClasses.relationshipTrigger,
4785
4902
  variant: "ghost",
4786
4903
  children: [
4787
4904
  /* @__PURE__ */ jsx3(DataTableListSummaryContent, {
@@ -5022,6 +5139,32 @@ var DataTableListSummaryContent = ({
5022
5139
  })
5023
5140
  });
5024
5141
  }
5142
+ if (display === "badge") {
5143
+ return /* @__PURE__ */ jsxs3("span", {
5144
+ className: "inline-flex min-w-0 flex-wrap items-center gap-1",
5145
+ children: [
5146
+ visible.map((item, index) => /* @__PURE__ */ jsx3(Badge, {
5147
+ variant: "secondary",
5148
+ children: item.label
5149
+ }, item.value ?? `${item.label}-${index}`)),
5150
+ remaining ? /* @__PURE__ */ jsxs3(Badge, {
5151
+ variant: "secondary",
5152
+ children: [
5153
+ "+",
5154
+ remaining
5155
+ ]
5156
+ }) : null,
5157
+ remaining && showMenu ? /* @__PURE__ */ jsx3(DataTableListMenu, {
5158
+ actions: [],
5159
+ display,
5160
+ force: true,
5161
+ items: normalized,
5162
+ locale,
5163
+ messages
5164
+ }) : null
5165
+ ]
5166
+ });
5167
+ }
5025
5168
  return /* @__PURE__ */ jsxs3("span", {
5026
5169
  className: "inline-flex min-w-0 items-center gap-2 text-sm",
5027
5170
  children: [
@@ -5104,9 +5247,11 @@ var TextArrayValue = Schema7.Struct({
5104
5247
  }).annotate({ identifier: "EventTextArrayValue" });
5105
5248
  var eventTextAttribute = (record, key) => Schema7.decodeUnknownOption(TextValue)(record.attributes.find((attribute) => attribute.key === key)?.value).pipe(Option5.map((value) => value.stringValue), Option5.getOrNull);
5106
5249
 
5107
- // ../../src/components/audit-log-table/react.tsx
5108
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
5109
- var translations = {
5250
+ // ../../src/components/audit-log-table/classes.ts
5251
+ var auditTableLayout = "flex min-h-0 flex-1 flex-col";
5252
+
5253
+ // ../../src/components/audit-log-table/index.ts
5254
+ var defaultMessages2 = {
5110
5255
  en: {
5111
5256
  title: "Activity history",
5112
5257
  event: "Action",
@@ -5140,6 +5285,65 @@ var translations = {
5140
5285
  methodUnknown: "Inconnue"
5141
5286
  }
5142
5287
  };
5288
+ var auditLogMessages = (locale, messages) => {
5289
+ const base = locale.split("-")[0];
5290
+ return {
5291
+ ...base === "fr" ? defaultMessages2.fr : defaultMessages2.en,
5292
+ ...messages?.[base],
5293
+ ...messages?.[locale]
5294
+ };
5295
+ };
5296
+ var auditTableState = (state) => state?.eventName && !state.filters?.some(({ id }) => id === "eventName") ? {
5297
+ ...state,
5298
+ filters: [
5299
+ ...state.filters ?? [],
5300
+ { id: "eventName", kind: "values", values: [state.eventName] }
5301
+ ]
5302
+ } : state;
5303
+ var auditRowId = (entry) => eventTextAttribute(entry, "log.record.uid") ?? `${entry.timeUnixNano}:${entry.eventName}`;
5304
+ var auditRowTime = (entry) => Number(BigInt(entry.timeUnixNano) / 1000000n);
5305
+ var auditActionLabel = (entry, events) => events.find(({ value }) => value === entry.eventName)?.label ?? entry.eventName;
5306
+ var auditActor = (entry, labels) => {
5307
+ const type = eventTextAttribute(entry, "app.actor.type");
5308
+ const userId = eventTextAttribute(entry, "user.id");
5309
+ const id = eventTextAttribute(entry, "app.actor.id") ?? userId;
5310
+ if (type === "organization")
5311
+ return { label: labels.actorOrganization, description: id ?? undefined };
5312
+ if (type === "user" || userId !== null) {
5313
+ const name = eventTextAttribute(entry, "user.full_name") || eventTextAttribute(entry, "user.name");
5314
+ const email = eventTextAttribute(entry, "user.email");
5315
+ return {
5316
+ label: name || email || labels.actorMember,
5317
+ description: (name ? email || id : id) ?? undefined
5318
+ };
5319
+ }
5320
+ return { label: type ?? labels.actor, description: id ?? undefined };
5321
+ };
5322
+ var auditTarget = (entry, labels) => {
5323
+ const id = eventTextAttribute(entry, "app.audit.target.id");
5324
+ const name = eventTextAttribute(entry, "app.audit.target.name");
5325
+ const type = eventTextAttribute(entry, "app.audit.target.type");
5326
+ return id === null ? null : {
5327
+ label: name && name !== id ? name : type || labels.target,
5328
+ description: name && name !== id && type ? `${type} · ${id}` : id
5329
+ };
5330
+ };
5331
+ var auditImpersonation = (entry, labels) => {
5332
+ const id = eventTextAttribute(entry, "app.auth.impersonator.id");
5333
+ return id === null ? undefined : `${labels.impersonatedBy}: ${id}`;
5334
+ };
5335
+ var auditMethod = (entry) => {
5336
+ const method = eventTextAttribute(entry, "app.auth.method");
5337
+ return method === "session" || method === "api_key" ? method : "unknown";
5338
+ };
5339
+ var auditMethods = (labels) => ({
5340
+ session: labels.methodSession,
5341
+ api_key: labels.methodApiKey,
5342
+ unknown: labels.methodUnknown
5343
+ });
5344
+
5345
+ // ../../src/components/audit-log-table/react.tsx
5346
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
5143
5347
  var AuditLogTable = ({
5144
5348
  entries,
5145
5349
  events = [],
@@ -5153,54 +5357,22 @@ var AuditLogTable = ({
5153
5357
  ...status
5154
5358
  }) => {
5155
5359
  const locale = useKrakstackLocale4(localeOverride);
5156
- const base = locale.split("-")[0];
5157
- const labels = {
5158
- ...translations.en,
5159
- ...base === "fr" ? translations.fr : translations.en,
5160
- ...messages?.[base],
5161
- ...messages?.[locale]
5162
- };
5163
- const methods = new Map([
5164
- ["session", labels.methodSession],
5165
- ["api_key", labels.methodApiKey]
5166
- ]);
5167
- const tableState = state?.eventName && !state.filters?.some((filter) => filter.id === "eventName") ? {
5168
- ...state,
5169
- filters: [
5170
- ...state.filters ?? [],
5171
- { id: "eventName", kind: "values", values: [state.eventName] }
5172
- ]
5173
- } : state;
5174
- const getActor = (entry) => {
5175
- const type = eventTextAttribute(entry, "app.actor.type");
5176
- const id = eventTextAttribute(entry, "app.actor.id") ?? eventTextAttribute(entry, "user.id");
5177
- if (type === "organization") {
5178
- return { label: labels.actorOrganization, description: id };
5179
- }
5180
- if (type === "user" || eventTextAttribute(entry, "user.id") !== null) {
5181
- const fullName = eventTextAttribute(entry, "user.full_name");
5182
- const name = eventTextAttribute(entry, "user.name");
5183
- const email = eventTextAttribute(entry, "user.email");
5184
- return {
5185
- label: fullName || name || email || labels.actorMember,
5186
- description: fullName || name ? email || id : id
5187
- };
5188
- }
5189
- return { label: type ?? labels.actor, description: id };
5190
- };
5360
+ const labels = auditLogMessages(locale, messages);
5361
+ const methods = auditMethods(labels);
5362
+ const getActor = (entry) => auditActor(entry, labels);
5191
5363
  const columns = [
5192
5364
  {
5193
5365
  colId: "time",
5194
5366
  headerName: labels.time,
5195
5367
  type: "dateTime",
5196
5368
  typeOptions: { timeZone },
5197
- valueGetter: ({ data }) => new Date(Number(BigInt(data.timeUnixNano) / 1000000n))
5369
+ valueGetter: ({ data }) => new Date(auditRowTime(data))
5198
5370
  },
5199
5371
  {
5200
5372
  field: "eventName",
5201
5373
  headerName: labels.action,
5202
5374
  filterOptions: events,
5203
- cellRenderer: ({ data }) => renderAction?.(data) ?? events.find((event) => event.value === data.eventName)?.label ?? data.eventName
5375
+ cellRenderer: ({ data }) => renderAction?.(data) ?? auditActionLabel(data, events)
5204
5376
  },
5205
5377
  {
5206
5378
  colId: "record",
@@ -5213,15 +5385,7 @@ var AuditLogTable = ({
5213
5385
  type: "reference",
5214
5386
  typeOptions: {
5215
5387
  imageVariant: "square",
5216
- getItem: (entry) => {
5217
- const id = eventTextAttribute(entry, "app.audit.target.id");
5218
- const name = eventTextAttribute(entry, "app.audit.target.name");
5219
- const type = eventTextAttribute(entry, "app.audit.target.type");
5220
- return id === null ? null : {
5221
- label: name && name !== id ? name : type || labels.target,
5222
- description: name && name !== id && type ? `${type} · ${id}` : id
5223
- };
5224
- }
5388
+ getItem: (entry) => auditTarget(entry, labels)
5225
5389
  }
5226
5390
  },
5227
5391
  {
@@ -5238,20 +5402,16 @@ var AuditLogTable = ({
5238
5402
  getItem: getActor
5239
5403
  },
5240
5404
  cellRenderer: ({ data }) => {
5241
- const impersonatorId = eventTextAttribute(data, "app.auth.impersonator.id");
5405
+ const impersonation = auditImpersonation(data, labels);
5242
5406
  return /* @__PURE__ */ jsxs4("div", {
5243
5407
  className: "flex min-w-0 flex-col gap-1",
5244
5408
  children: [
5245
5409
  /* @__PURE__ */ jsx4(DataTableReferenceCell, {
5246
5410
  item: getActor(data)
5247
5411
  }),
5248
- impersonatorId !== null ? /* @__PURE__ */ jsxs4("span", {
5412
+ impersonation !== undefined ? /* @__PURE__ */ jsx4("span", {
5249
5413
  className: "text-muted-foreground text-xs",
5250
- children: [
5251
- labels.impersonatedBy,
5252
- ": ",
5253
- impersonatorId
5254
- ]
5414
+ children: impersonation
5255
5415
  }) : null
5256
5416
  ]
5257
5417
  });
@@ -5260,40 +5420,34 @@ var AuditLogTable = ({
5260
5420
  {
5261
5421
  colId: "method",
5262
5422
  headerName: labels.method,
5263
- filterOptions: [
5264
- { value: "session", label: labels.methodSession },
5265
- { value: "api_key", label: labels.methodApiKey },
5266
- { value: "unknown", label: labels.methodUnknown }
5267
- ],
5268
- filterValueGetter: ({ data }) => {
5269
- const method = eventTextAttribute(data, "app.auth.method");
5270
- return method === "session" || method === "api_key" ? method : "unknown";
5271
- },
5423
+ filterOptions: Object.entries(methods).map(([value, label]) => ({
5424
+ value,
5425
+ label
5426
+ })),
5427
+ filterValueGetter: ({ data }) => auditMethod(data),
5272
5428
  sortable: false,
5273
- valueGetter: ({ data }) => {
5274
- const method = eventTextAttribute(data, "app.auth.method");
5275
- return method === null ? labels.methodUnknown : methods.get(method) ?? labels.methodUnknown;
5276
- }
5429
+ valueGetter: ({ data }) => methods[auditMethod(data)]
5277
5430
  }
5278
5431
  ];
5279
5432
  return /* @__PURE__ */ jsx4("section", {
5280
5433
  "aria-label": labels.title,
5281
- className: "flex flex-col gap-4",
5434
+ className: auditTableLayout,
5282
5435
  children: /* @__PURE__ */ jsx4(DataTable, {
5283
5436
  locale,
5284
5437
  status,
5285
- state: tableState,
5438
+ state: auditTableState(state),
5286
5439
  onStateChange: onStateChange ? (next) => onStateChange({
5287
5440
  ...next,
5288
5441
  eventName: undefined
5289
5442
  }) : undefined,
5290
5443
  features: {
5291
5444
  filtering: !!onStateChange,
5292
- pagination: { mode: "server", rowCount }
5445
+ pagination: { mode: "server", rowCount },
5446
+ virtualization: { scroll: "internal" }
5293
5447
  },
5294
5448
  columnDefs: columns,
5295
5449
  rowData: entries,
5296
- getRowId: (entry) => eventTextAttribute(entry, "log.record.uid") ?? `${entry.timeUnixNano}:${entry.eventName}`
5450
+ getRowId: auditRowId
5297
5451
  })
5298
5452
  });
5299
5453
  };