@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
@@ -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: "size-8 focus-visible:ring-inset",
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: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 focus-visible:ring-inset",
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: "h-full w-full min-w-0 justify-between rounded-none px-2 text-start focus-visible:ring-inset",
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",
@@ -649,6 +656,7 @@ var tableClasses = {
649
656
  referenceName: "truncate font-medium",
650
657
  referenceDescription: "text-muted-foreground truncate text-xs"
651
658
  };
659
+ var tableResultsFooterClass = "bg-background text-muted-foreground sticky bottom-0 z-30 shrink-0 border-t px-2 py-2 text-sm";
652
660
  var resolveTableClasses = (overrides) => ({
653
661
  ...tableClasses,
654
662
  ...overrides
@@ -660,7 +668,7 @@ import { Csv } from "effect/encoding";
660
668
  import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
661
669
 
662
670
  // ../../src/components/data-table/schema.ts
663
- import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
671
+ import { DateTime as DateTime2, Option as Option2, Predicate, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
664
672
  var TableClassesOverridesSchema = Schema4.Record(Schema4.Literals(Struct2.keys(tableClasses)), Schema4.optionalKey(Schema4.String)).annotate({ identifier: "TableClassesOverrides" });
665
673
  var DataTableCommonPropsSchema = Schema4.Struct({
666
674
  classes: Schema4.optional(TableClassesOverridesSchema),
@@ -768,8 +776,33 @@ var column = {
768
776
  emptyLabel: Schema4.optionalKey(Schema4.String),
769
777
  nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
770
778
  };
779
+ var DataTableBadgeOptionSchema = Schema4.Struct({
780
+ value: Schema4.NonEmptyString,
781
+ label: Schema4.optionalKey(Schema4.String),
782
+ variant: Schema4.optionalKey(Schema4.Literals([
783
+ "default",
784
+ "secondary",
785
+ "outline",
786
+ "destructive",
787
+ "success",
788
+ "info",
789
+ "muted"
790
+ ]))
791
+ }).annotate({ identifier: "DataTableBadgeOption" });
792
+ var BadgeIcon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableBadgeIcon" });
793
+ var DataTableBadgeOptionsSchema = Schema4.Struct({
794
+ options: Schema4.optionalKey(Schema4.Array(DataTableBadgeOptionSchema.mapFields((fields) => ({
795
+ ...fields,
796
+ icon: Schema4.optionalKey(BadgeIcon)
797
+ }))))
798
+ }).annotate({ identifier: "DataTableBadgeOptions" });
771
799
  var DataTableFieldSchema = Schema4.Union([
772
- Schema4.Struct({ ...column, type: Schema4.Literal("text") }),
800
+ Schema4.Struct({
801
+ ...column,
802
+ type: Schema4.Literal("text"),
803
+ display: Schema4.optionalKey(Schema4.Literal("badge")),
804
+ typeOptions: Schema4.optionalKey(DataTableBadgeOptionsSchema)
805
+ }),
773
806
  Schema4.Struct({
774
807
  ...column,
775
808
  type: Schema4.Literal("number"),
@@ -812,7 +845,7 @@ var DataTableFieldSchema = Schema4.Union([
812
845
  options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
813
846
  allowRemove: Schema4.optionalKey(Schema4.Boolean),
814
847
  itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
815
- display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
848
+ display: Schema4.optionalKey(Schema4.Literals(["list", "icon", "badge"])),
816
849
  visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
817
850
  actionsLabel: Schema4.optionalKey(Schema4.String),
818
851
  manageLabel: Schema4.optionalKey(Schema4.String)
@@ -1106,7 +1139,33 @@ var matchesFilterText = (value, filter) => {
1106
1139
  return text.endsWith(query);
1107
1140
  }
1108
1141
  };
1109
- var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
1142
+ var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" || column.display === "badge" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
1143
+ var tableBadgeValue = (value) => isTableText(value) && value !== "" ? value : null;
1144
+ var tableBadge = (input, config) => {
1145
+ const value = tableBadgeValue(input);
1146
+ if (value === null)
1147
+ return null;
1148
+ const option = config?.options?.find((option) => option.value === value);
1149
+ return {
1150
+ value,
1151
+ label: option?.label ?? value,
1152
+ variant: option?.variant ?? "secondary",
1153
+ option
1154
+ };
1155
+ };
1156
+ var tableBadgeFilterOptions = (values, config) => {
1157
+ const options = new Map(config?.options?.map(({ value, label }) => [value, label ?? value]));
1158
+ for (const input of values) {
1159
+ const value = tableBadgeValue(input);
1160
+ if (value !== null && !options.has(value))
1161
+ options.set(value, value);
1162
+ }
1163
+ return [...options].map(([value, label]) => ({ value, label }));
1164
+ };
1165
+ var tableBadgeSearchText = (value, config) => {
1166
+ const badge = tableBadge(value, config);
1167
+ return badge ? `${badge.label} ${badge.value}` : "";
1168
+ };
1110
1169
  var matchesTableFilter = (filter, value, type, text, values) => {
1111
1170
  switch (filter.kind) {
1112
1171
  case "text":
@@ -1140,13 +1199,20 @@ var filterTableColumns = (rows, columns, filters) => {
1140
1199
  return rows;
1141
1200
  return rows.filter((row) => active.every((filter) => {
1142
1201
  const value = row.cells[filter.id];
1143
- 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) : []);
1202
+ const column = byId.get(filter.id);
1203
+ return matchesTableFilter(filter, value, column?.type, () => isTableText(value) ? value : isTableReference(value) ? `${value.label} ${value.description ?? ""}`.trim() : "", () => {
1204
+ if (column?.type === "text" && column.display === "badge") {
1205
+ const key = tableBadgeValue(value);
1206
+ return key === null ? [] : [key];
1207
+ }
1208
+ return isTableList(value) ? value.map(({ value }) => value) : [];
1209
+ });
1144
1210
  }));
1145
1211
  };
1146
1212
  var columnValue = (column, value) => {
1147
1213
  switch (column.type) {
1148
1214
  case "text":
1149
- return isTableText(value) ? value : null;
1215
+ return column.display === "badge" ? tableBadgeValue(value) : isTableText(value) ? value : null;
1150
1216
  case "number":
1151
1217
  case "boolean":
1152
1218
  case "date":
@@ -1200,6 +1266,8 @@ var filterTableRows = (rows, columns, search, locale) => {
1200
1266
  const searchable = columns.filter(({ searchable }) => searchable !== false);
1201
1267
  return rows.filter((row) => searchable.some((column) => {
1202
1268
  const value = row.cells[column.id];
1269
+ if (column.type === "text" && column.display === "badge")
1270
+ return tableBadgeSearchText(value, column.typeOptions).toLocaleLowerCase(locale).includes(query);
1203
1271
  if (column.type === "date" || column.type === "dateTime") {
1204
1272
  const date = resolveDate(value, column.type);
1205
1273
  return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
@@ -2129,6 +2197,8 @@ var booleanLabel = (value, options) => value ? options?.trueLabel : options?.fal
2129
2197
  var getDataTableExportValue = (row, column, locale = "en") => {
2130
2198
  const value = row.values.get(column.id);
2131
2199
  const colDef = column.colDef;
2200
+ if (colDef.type === "text" && colDef.display === "badge")
2201
+ return tableBadgeValue(value);
2132
2202
  if (colDef.type === "number") {
2133
2203
  const number = Option4.getOrUndefined(decodeNumberValue(value));
2134
2204
  if (number === undefined)
@@ -2157,7 +2227,9 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
2157
2227
  const value = row.values.get(column.id);
2158
2228
  const colDef = column.colDef;
2159
2229
  let text = dataTableValueText(value);
2160
- if (colDef.type === "date" || colDef.type === "dateTime") {
2230
+ if (colDef.type === "text" && colDef.display === "badge") {
2231
+ text = tableBadgeSearchText(value, colDef.typeOptions);
2232
+ } else if (colDef.type === "date" || colDef.type === "dateTime") {
2161
2233
  const date = resolveDate(value, colDef.type);
2162
2234
  text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
2163
2235
  } else if (colDef.type === "number") {
@@ -2173,11 +2245,14 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
2173
2245
  var getDataTableFilterColumns = (columns) => columns.flatMap((column) => column.colDef.filterable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.filterable !== false));
2174
2246
  var getDataTableFilterKind = ({
2175
2247
  colDef
2176
- }) => tableFilterKind(colDef, !!colDef.filterOptions);
2248
+ }) => tableFilterKind(colDef.type === "text" ? colDef : { type: colDef.type }, !!colDef.filterOptions);
2177
2249
  var getDataTableFilterOptions = (rows, column) => {
2178
2250
  const { colDef } = column;
2179
2251
  if (colDef.filterOptions)
2180
2252
  return colDef.filterOptions;
2253
+ if (colDef.type === "text" && colDef.display === "badge") {
2254
+ return tableBadgeFilterOptions(rows.map((row) => row.values.get(column.id)), colDef.typeOptions);
2255
+ }
2181
2256
  const options = new Map;
2182
2257
  if (colDef.type === "list") {
2183
2258
  for (const row of rows) {
@@ -2202,7 +2277,15 @@ var filterDataTableColumnRows = (rows, columns, filters) => {
2202
2277
  colDef: column.colDef
2203
2278
  }) : row.values.get(column.id);
2204
2279
  const { colDef } = column;
2205
- return matchesTableFilter(filter, value, colDef.type, () => dataTableValueText(value), () => colDef.type === "list" ? colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label) : [dataTableValueText(value)]);
2280
+ return matchesTableFilter(filter, value, colDef.type, () => dataTableValueText(value), () => {
2281
+ if (colDef.type === "list")
2282
+ return colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label);
2283
+ if (colDef.type === "text" && colDef.display === "badge") {
2284
+ const key = tableBadgeValue(value);
2285
+ return key === null ? [] : [key];
2286
+ }
2287
+ return [dataTableValueText(value)];
2288
+ });
2206
2289
  }));
2207
2290
  };
2208
2291
  var sortDataTableRows = (rows, columns, sorting) => {
@@ -2218,6 +2301,12 @@ var sortDataTableRows = (rows, columns, sorting) => {
2218
2301
  const leftValue = left.row.values.get(sort.id);
2219
2302
  const rightValue = right.row.values.get(sort.id);
2220
2303
  const colDef = column.colDef;
2304
+ if (!colDef.comparator && colDef.type === "text" && colDef.display === "badge") {
2305
+ const comparison = compareTableSortValues(tableBadgeValue(leftValue), tableBadgeValue(rightValue), sort.direction);
2306
+ if (comparison !== 0)
2307
+ return comparison;
2308
+ continue;
2309
+ }
2221
2310
  if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean" || colDef.type === "date" || colDef.type === "dateTime")) {
2222
2311
  const comparison = compareTableSortValues(tableSortScalar(colDef.type, leftValue), tableSortScalar(colDef.type, rightValue), sort.direction, colDef.typeOptions?.nulls);
2223
2312
  if (comparison !== 0)
@@ -2369,6 +2458,27 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
2369
2458
  ...params
2370
2459
  });
2371
2460
  const colDef = column.colDef;
2461
+ if (colDef.type === "text" && colDef.display === "badge") {
2462
+ if (colDef.valueFormatter)
2463
+ return colDef.valueFormatter(params);
2464
+ const badge = tableBadge(value, colDef.typeOptions);
2465
+ if (!badge)
2466
+ return colDef.typeOptions?.emptyLabel ?? "—";
2467
+ const { variant, label, option } = badge;
2468
+ const tone = variant === "success" || variant === "info" || variant === "muted" ? tableBadgeTones[variant] : undefined;
2469
+ return /* @__PURE__ */ jsxs3(Badge, {
2470
+ variant: variant === "success" || variant === "info" || variant === "muted" ? "outline" : variant,
2471
+ className: tone,
2472
+ children: [
2473
+ option?.icon && /* @__PURE__ */ jsx3("span", {
2474
+ "aria-hidden": "true",
2475
+ className: "inline-flex shrink-0 [&_svg]:size-3",
2476
+ children: option.icon
2477
+ }),
2478
+ label
2479
+ ]
2480
+ });
2481
+ }
2372
2482
  if (colDef.type === "reference") {
2373
2483
  if (colDef.valueFormatter)
2374
2484
  return colDef.valueFormatter(params);
@@ -2396,7 +2506,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
2396
2506
  const options = colDef.typeOptions;
2397
2507
  return /* @__PURE__ */ jsx3("label", {
2398
2508
  "data-slot": "data-table-boolean-cell",
2399
- 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"),
2509
+ className: cn(booleanCellControl, options?.onChange && !options.disabled?.(row.data) && "hover:bg-muted/50 cursor-pointer"),
2400
2510
  onClick: (event) => event.stopPropagation(),
2401
2511
  onPointerDown: (event) => event.stopPropagation(),
2402
2512
  children: /* @__PURE__ */ jsx3(Checkbox, {
@@ -4068,7 +4178,9 @@ var GalleryTag = ({
4068
4178
  if ((value == null || value === "") && !column.colDef.cellRenderer)
4069
4179
  return null;
4070
4180
  const content = renderCell(row, column, locale, labels);
4071
- return column.colDef.cellRenderer || column.colDef.valueFormatter ? /* @__PURE__ */ jsxs3("div", {
4181
+ const { colDef } = column;
4182
+ const displaysBadges = colDef.type === "text" && colDef.display === "badge" || colDef.type === "list" && colDef.typeOptions.display === "badge";
4183
+ return colDef.cellRenderer || colDef.valueFormatter || displaysBadges ? /* @__PURE__ */ jsxs3("div", {
4072
4184
  className: "flex min-w-0 items-center gap-1",
4073
4185
  children: [
4074
4186
  icon,
@@ -4277,7 +4389,7 @@ var DataTableGallery = ({
4277
4389
  children: renderSections(sections)
4278
4390
  });
4279
4391
  };
4280
- var DataTablePagination = ({
4392
+ var DataTableFooter = ({
4281
4393
  table
4282
4394
  }) => {
4283
4395
  const styles = useContext(DataTableStylesContext);
@@ -4291,8 +4403,13 @@ var DataTablePagination = ({
4291
4403
  send(DataTableMessage.PageRequested({ page }));
4292
4404
  }
4293
4405
  }, [page, pageIndex, pagination, paginationVisible, send]);
4294
- if (!paginationVisible || !pagination)
4295
- return null;
4406
+ if (!paginationVisible || !pagination) {
4407
+ return /* @__PURE__ */ jsx3("div", {
4408
+ className: tableResultsFooterClass,
4409
+ role: "status",
4410
+ children: store.config.labels.results(model.totalRows)
4411
+ });
4412
+ }
4296
4413
  const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
4297
4414
  return /* @__PURE__ */ jsx3("div", {
4298
4415
  "data-table-slot": "pagination",
@@ -4489,7 +4606,7 @@ var HydratedDataTable = (props) => {
4489
4606
  /* @__PURE__ */ jsx3(DataTableContent, {
4490
4607
  table
4491
4608
  }),
4492
- /* @__PURE__ */ jsx3(DataTablePagination, {
4609
+ /* @__PURE__ */ jsx3(DataTableFooter, {
4493
4610
  table
4494
4611
  })
4495
4612
  ]
@@ -4785,7 +4902,7 @@ var EditableDataTableListCell = ({
4785
4902
  } : undefined,
4786
4903
  trigger: /* @__PURE__ */ jsxs3(Button2, {
4787
4904
  "aria-label": manageLabel,
4788
- className: "h-full w-full min-w-0 justify-between rounded-none px-2 focus-visible:ring-inset",
4905
+ className: tableClasses.relationshipTrigger,
4789
4906
  variant: "ghost",
4790
4907
  children: [
4791
4908
  /* @__PURE__ */ jsx3(DataTableListSummaryContent, {
@@ -5026,6 +5143,32 @@ var DataTableListSummaryContent = ({
5026
5143
  })
5027
5144
  });
5028
5145
  }
5146
+ if (display === "badge") {
5147
+ return /* @__PURE__ */ jsxs3("span", {
5148
+ className: "inline-flex min-w-0 flex-wrap items-center gap-1",
5149
+ children: [
5150
+ visible.map((item, index) => /* @__PURE__ */ jsx3(Badge, {
5151
+ variant: "secondary",
5152
+ children: item.label
5153
+ }, item.value ?? `${item.label}-${index}`)),
5154
+ remaining ? /* @__PURE__ */ jsxs3(Badge, {
5155
+ variant: "secondary",
5156
+ children: [
5157
+ "+",
5158
+ remaining
5159
+ ]
5160
+ }) : null,
5161
+ remaining && showMenu ? /* @__PURE__ */ jsx3(DataTableListMenu, {
5162
+ actions: [],
5163
+ display,
5164
+ force: true,
5165
+ items: normalized,
5166
+ locale,
5167
+ messages
5168
+ }) : null
5169
+ ]
5170
+ });
5171
+ }
5029
5172
  return /* @__PURE__ */ jsxs3("span", {
5030
5173
  className: "inline-flex min-w-0 items-center gap-2 text-sm",
5031
5174
  children: [
@@ -157,13 +157,17 @@ var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
157
157
  var ANALYTICS_NOTICE_VERSION = "1";
158
158
  var changedEvent = "krakstack:analytics-consent";
159
159
  var lifetime = 180 * 24 * 60 * 60 * 1000;
160
+ var cookiePrefix = `${ANALYTICS_CONSENT_COOKIE}=`;
160
161
  var codec = Schema3.StringFromUriComponent.pipe(Schema3.decodeTo(Schema3.fromJsonString(BrowserAnalyticsPreference)));
161
- var readCookie = (cookie) => cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith(`${ANALYTICS_CONSENT_COOKIE}=`))?.slice(ANALYTICS_CONSENT_COOKIE.length + 1);
162
+ var decodePreference = Schema3.decodeOption(codec);
163
+ var encodePreference = Schema3.encodeSync(codec);
164
+ var decodePrivacySignals = Schema3.decodeUnknownOption(BrowserPrivacySignals);
165
+ var readCookie = (cookie) => cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith(cookiePrefix))?.slice(cookiePrefix.length);
162
166
  var analyticsPreference = (cookie, now = Date.now()) => {
163
167
  const value = readCookie(cookie);
164
168
  if (!value)
165
169
  return;
166
- const decoded = Schema3.decodeOption(codec)(value);
170
+ const decoded = decodePreference(value);
167
171
  if (Option2.isNone(decoded))
168
172
  return;
169
173
  const preference = decoded.value;
@@ -172,49 +176,58 @@ var analyticsPreference = (cookie, now = Date.now()) => {
172
176
  var browserPrivacyEnabled = () => {
173
177
  if (globalThis.navigator === undefined)
174
178
  return false;
175
- const value = Schema3.decodeUnknownOption(BrowserPrivacySignals)(navigator);
179
+ const value = decodePrivacySignals(navigator);
176
180
  return navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || Option2.isSome(value) && value.value.globalPrivacyControl === true;
177
181
  };
178
- var browserPreference = () => {
179
- if (globalThis.document === undefined)
180
- return;
181
- const cookie = Effect2.runSync(Effect2.try({
182
- try: () => document.cookie,
183
- catch: () => new AnalyticsPreferenceStorageError({
184
- message: "Analytics preference storage unavailable"
185
- })
186
- }).pipe(Effect2.orElseSucceed(() => "")));
187
- return analyticsPreference(cookie);
188
- };
182
+ var cookieOperation = (operation) => Effect2.try({
183
+ try: operation,
184
+ catch: (cause) => new AnalyticsPreferenceStorageError({
185
+ message: "Analytics preference storage unavailable",
186
+ cause
187
+ })
188
+ });
189
+ var browserPreference = () => analyticsPreference(Effect2.runSync(cookieOperation(() => globalThis.document?.cookie ?? "").pipe(Effect2.orElseSucceed(() => ""))));
189
190
  var consentGeneration = 0;
190
191
  var previousSnapshot;
191
- var analyticsConsentSnapshot = () => {
192
- const preference = browserPreference();
193
- const snapshot = browserPrivacyEnabled() ? "blocked" : preference ? `${preference.choice}:${preference.revision}` : "pending";
192
+ var observeBrowserConsent = () => {
193
+ const blocked = browserPrivacyEnabled();
194
+ const preference = blocked ? undefined : browserPreference();
195
+ const snapshot = blocked ? "blocked" : preference ? `${preference.choice}:${preference.revision}` : "pending";
194
196
  if (snapshot !== previousSnapshot) {
195
197
  consentGeneration++;
196
198
  previousSnapshot = snapshot;
197
199
  }
198
- return snapshot;
200
+ return { preference, snapshot, generation: consentGeneration };
199
201
  };
200
- var analyticsAllowed = () => analyticsConsentSnapshot().startsWith("accepted:");
202
+ var analyticsConsentSnapshot = () => observeBrowserConsent().snapshot;
203
+ var analyticsAllowed = () => observeBrowserConsent().preference?.choice === "accepted";
201
204
  var analyticsExportGuard = () => {
202
- const snapshot = analyticsConsentSnapshot();
203
- const generation = consentGeneration;
204
- return () => snapshot.startsWith("accepted:") && analyticsConsentSnapshot() === snapshot && consentGeneration === generation;
205
+ const initial = observeBrowserConsent();
206
+ return () => initial.preference?.choice === "accepted" && observeBrowserConsent().generation === initial.generation;
205
207
  };
206
208
  var saveAnalyticsPreference = (choice) => {
209
+ const host = globalThis.document;
210
+ if (host === undefined)
211
+ return false;
207
212
  const issuedAt = Date.now();
208
- const value = Schema3.encodeSync(codec)({
213
+ const revision = Effect2.runSync(SecureRandom.SecureRandom.use((random) => random.uuidV7()).pipe(Effect2.provide(SecureRandom.layerWebCrypto)));
214
+ const value = encodePreference({
209
215
  choice,
210
- revision: Effect2.runSync(SecureRandom.SecureRandom.use((random) => random.uuidV7()).pipe(Effect2.provide(SecureRandom.layerWebCrypto))),
216
+ revision,
211
217
  version: ANALYTICS_NOTICE_VERSION,
212
218
  issuedAt,
213
219
  expiresAt: issuedAt + lifetime
214
220
  });
215
- document.cookie = `${ANALYTICS_CONSENT_COOKIE}=${value}; Path=/; Max-Age=${lifetime / 1000}; SameSite=Lax${location.protocol === "https:" ? "; Secure" : ""}`;
221
+ const secure = host.location?.protocol === "https:" ? "; Secure" : "";
222
+ const written = Effect2.runSync(cookieOperation(() => {
223
+ host.cookie = `${cookiePrefix}${value}; Path=/; Max-Age=${lifetime / 1000}; SameSite=Lax${secure}`;
224
+ return true;
225
+ }).pipe(Effect2.orElseSucceed(() => false)));
226
+ if (!written)
227
+ return false;
228
+ const saved = browserPreference();
216
229
  globalThis.dispatchEvent(new Event(changedEvent));
217
- return analyticsPreference(document.cookie)?.choice === choice;
230
+ return saved?.choice === choice && saved.revision === revision;
218
231
  };
219
232
  var subscribeAnalyticsConsent = (listener) => {
220
233
  let previous = analyticsConsentSnapshot();
@@ -624,15 +624,15 @@ var cloudflareGeolocation = (headers) => ({
624
624
  region: Option4.getOrUndefined(Schema7.decodeUnknownOption(EventRegion)(headers["cf-region-code"])),
625
625
  city: Option4.getOrUndefined(Schema7.decodeUnknownOption(EventCity)(decodeCloudflareCity(headers["cf-ipcity"])))
626
626
  });
627
- var geolocationAttributes = (location2) => {
627
+ var geolocationAttributes = (location) => {
628
628
  const attributes = {};
629
- if (location2?.country) {
630
- attributes["geo.country.iso_code"] = location2.country;
631
- if (location2.region)
632
- attributes["geo.region.iso_code"] = `${location2.country}-${location2.region}`;
629
+ if (location?.country) {
630
+ attributes["geo.country.iso_code"] = location.country;
631
+ if (location.region)
632
+ attributes["geo.region.iso_code"] = `${location.country}-${location.region}`;
633
633
  }
634
- if (location2?.city)
635
- attributes["geo.locality.name"] = location2.city;
634
+ if (location?.city)
635
+ attributes["geo.locality.name"] = location.city;
636
636
  return attributes;
637
637
  };
638
638
  var deviceContext = (userAgent) => {
@@ -692,13 +692,17 @@ class AnalyticsPreferenceStorageError extends Data.TaggedError("AnalyticsPrefere
692
692
  var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
693
693
  var ANALYTICS_NOTICE_VERSION = "1";
694
694
  var lifetime = 180 * 24 * 60 * 60 * 1000;
695
+ var cookiePrefix = `${ANALYTICS_CONSENT_COOKIE}=`;
695
696
  var codec = Schema8.StringFromUriComponent.pipe(Schema8.decodeTo(Schema8.fromJsonString(BrowserAnalyticsPreference)));
696
- var readCookie = (cookie) => cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith(`${ANALYTICS_CONSENT_COOKIE}=`))?.slice(ANALYTICS_CONSENT_COOKIE.length + 1);
697
+ var decodePreference = Schema8.decodeOption(codec);
698
+ var encodePreference = Schema8.encodeSync(codec);
699
+ var decodePrivacySignals = Schema8.decodeUnknownOption(BrowserPrivacySignals);
700
+ var readCookie = (cookie) => cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith(cookiePrefix))?.slice(cookiePrefix.length);
697
701
  var analyticsPreference = (cookie, now = Date.now()) => {
698
702
  const value = readCookie(cookie);
699
703
  if (!value)
700
704
  return;
701
- const decoded = Schema8.decodeOption(codec)(value);
705
+ const decoded = decodePreference(value);
702
706
  if (Option5.isNone(decoded))
703
707
  return;
704
708
  const preference = decoded.value;
@@ -877,15 +881,15 @@ class Events extends Context4.Service()("krakstack/events/Events", {
877
881
  };
878
882
  }) : undefined;
879
883
  const resolveGeolocation = Effect8.fnUntraced(function* (request) {
880
- const location2 = configuration.geolocation === "cloudflare" ? cloudflareGeolocation(request.headers) : configuration.geolocation ? yield* configuration.geolocation(request) : null;
881
- return yield* Schema9.decodeEffect(Schema9.NullOr(EventGeolocation))(location2);
884
+ const location = configuration.geolocation === "cloudflare" ? cloudflareGeolocation(request.headers) : configuration.geolocation ? yield* configuration.geolocation(request) : null;
885
+ return yield* Schema9.decodeEffect(Schema9.NullOr(EventGeolocation))(location);
882
886
  }, Effect8.mapError(() => new EventGeolocationError({})));
883
- const resolveRequestContext = Effect8.fnUntraced(function* (request, now, location2) {
887
+ const resolveRequestContext = Effect8.fnUntraced(function* (request, now, location) {
884
888
  const userAgent = request.headers["user-agent"]?.slice(0, 2048) ?? "";
885
- const visitorId = location2?.ip && userAgent ? yield* dailyVisitorId({
889
+ const visitorId = location?.ip && userAgent ? yield* dailyVisitorId({
886
890
  serviceName: configuration.serviceName,
887
891
  secret: options.secret,
888
- ip: location2.ip,
892
+ ip: location.ip,
889
893
  userAgent,
890
894
  day: DateTime3.formatIsoDate(now)
891
895
  }) : undefined;
@@ -902,7 +906,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
902
906
  identity["session.id"] = sessionId;
903
907
  return {
904
908
  ...deviceContext(userAgent),
905
- ...geolocationAttributes(location2),
909
+ ...geolocationAttributes(location),
906
910
  "analytics.identity.mode": visitorId ? "daily" : "unattributed",
907
911
  ...identity
908
912
  };
@@ -1013,14 +1017,14 @@ class Events extends Context4.Service()("krakstack/events/Events", {
1013
1017
  attributes["app.event.source"] = "server";
1014
1018
  attributes["app.event.category"] = category;
1015
1019
  const span = yield* Effect8.currentSpan.pipe(Effect8.option);
1016
- const location2 = Option6.isSome(request) && (!options.requireConsent || hasAnalyticsConsent(request.value.headers.cookie ?? "", request.value.headers)) ? yield* resolveGeolocation(request.value).pipe(Effect8.mapError(() => new EventsPersistenceError({ operation: "geolocation" }))) : null;
1020
+ const location = Option6.isSome(request) && (!options.requireConsent || hasAnalyticsConsent(request.value.headers.cookie ?? "", request.value.headers)) ? yield* resolveGeolocation(request.value).pipe(Effect8.mapError(() => new EventsPersistenceError({ operation: "geolocation" }))) : null;
1017
1021
  const entry = {
1018
1022
  eventName: event.name,
1019
1023
  timeUnixNano: (BigInt(event.timestamp ? DateTime3.toEpochMillis(event.timestamp) : now) * 1000000n).toString(),
1020
1024
  observedTimeUnixNano: (BigInt(now) * 1000000n).toString()
1021
1025
  };
1022
1026
  return yield* Effect8.gen(function* () {
1023
- const requestContext = Option6.isSome(request) && (!options.requireConsent || hasAnalyticsConsent(request.value.headers.cookie ?? "", request.value.headers)) ? yield* resolveRequestContext(request.value, receivedAt, location2) : {};
1027
+ const requestContext = Option6.isSome(request) && (!options.requireConsent || hasAnalyticsConsent(request.value.headers.cookie ?? "", request.value.headers)) ? yield* resolveRequestContext(request.value, receivedAt, location) : {};
1024
1028
  const validated = yield* Schema9.decodeUnknownEffect(EventLogRecord)({
1025
1029
  ...entry,
1026
1030
  attributes: OtlpResource3.entriesToAttributes(Object.entries({ ...requestContext, ...attributes })),
@@ -1228,9 +1232,9 @@ class Events extends Context4.Service()("krakstack/events/Events", {
1228
1232
  ...identityAttributes(trustedIdentity),
1229
1233
  ...trustedActor
1230
1234
  };
1231
- const location2 = yield* resolveGeolocation(request).pipe(Effect8.mapError(() => new OtlpProcessingError({ status: 503 })));
1235
+ const location = yield* resolveGeolocation(request).pipe(Effect8.mapError(() => new OtlpProcessingError({ status: 503 })));
1232
1236
  const ingest = Effect8.gen(function* () {
1233
- const requestContext = yield* resolveRequestContext(request, now, location2);
1237
+ const requestContext = yield* resolveRequestContext(request, now, location);
1234
1238
  let index = 0;
1235
1239
  const resourceLogs = payload.resourceLogs.map((resource) => ({
1236
1240
  ...resource,
@@ -155,13 +155,17 @@ var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
155
155
  var ANALYTICS_NOTICE_VERSION = "1";
156
156
  var changedEvent = "krakstack:analytics-consent";
157
157
  var lifetime = 180 * 24 * 60 * 60 * 1000;
158
+ var cookiePrefix = `${ANALYTICS_CONSENT_COOKIE}=`;
158
159
  var codec = Schema3.StringFromUriComponent.pipe(Schema3.decodeTo(Schema3.fromJsonString(BrowserAnalyticsPreference)));
159
- var readCookie = (cookie) => cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith(`${ANALYTICS_CONSENT_COOKIE}=`))?.slice(ANALYTICS_CONSENT_COOKIE.length + 1);
160
+ var decodePreference = Schema3.decodeOption(codec);
161
+ var encodePreference = Schema3.encodeSync(codec);
162
+ var decodePrivacySignals = Schema3.decodeUnknownOption(BrowserPrivacySignals);
163
+ var readCookie = (cookie) => cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith(cookiePrefix))?.slice(cookiePrefix.length);
160
164
  var analyticsPreference = (cookie, now = Date.now()) => {
161
165
  const value = readCookie(cookie);
162
166
  if (!value)
163
167
  return;
164
- const decoded = Schema3.decodeOption(codec)(value);
168
+ const decoded = decodePreference(value);
165
169
  if (Option2.isNone(decoded))
166
170
  return;
167
171
  const preference = decoded.value;
@@ -170,37 +174,37 @@ var analyticsPreference = (cookie, now = Date.now()) => {
170
174
  var browserPrivacyEnabled = () => {
171
175
  if (globalThis.navigator === undefined)
172
176
  return false;
173
- const value = Schema3.decodeUnknownOption(BrowserPrivacySignals)(navigator);
177
+ const value = decodePrivacySignals(navigator);
174
178
  return navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || Option2.isSome(value) && value.value.globalPrivacyControl === true;
175
179
  };
176
- var browserPreference = () => {
177
- if (globalThis.document === undefined)
178
- return;
179
- const cookie = Effect2.runSync(Effect2.try({
180
- try: () => document.cookie,
181
- catch: () => new AnalyticsPreferenceStorageError({
182
- message: "Analytics preference storage unavailable"
183
- })
184
- }).pipe(Effect2.orElseSucceed(() => "")));
185
- return analyticsPreference(cookie);
186
- };
180
+ var cookieOperation = (operation) => Effect2.try({
181
+ try: operation,
182
+ catch: (cause) => new AnalyticsPreferenceStorageError({
183
+ message: "Analytics preference storage unavailable",
184
+ cause
185
+ })
186
+ });
187
+ var browserPreference = () => analyticsPreference(Effect2.runSync(cookieOperation(() => globalThis.document?.cookie ?? "").pipe(Effect2.orElseSucceed(() => ""))));
187
188
  var consentGeneration = 0;
188
189
  var previousSnapshot;
189
- var analyticsConsentSnapshot = () => {
190
- const preference = browserPreference();
191
- const snapshot = browserPrivacyEnabled() ? "blocked" : preference ? `${preference.choice}:${preference.revision}` : "pending";
190
+ var observeBrowserConsent = () => {
191
+ const blocked = browserPrivacyEnabled();
192
+ const preference = blocked ? undefined : browserPreference();
193
+ const snapshot = blocked ? "blocked" : preference ? `${preference.choice}:${preference.revision}` : "pending";
192
194
  if (snapshot !== previousSnapshot) {
193
195
  consentGeneration++;
194
196
  previousSnapshot = snapshot;
195
197
  }
196
- return snapshot;
198
+ return { preference, snapshot, generation: consentGeneration };
199
+ };
200
+ var analyticsConsentSnapshot = () => observeBrowserConsent().snapshot;
201
+ var analyticsAcceptedBefore = (timestamp) => {
202
+ const { preference } = observeBrowserConsent();
203
+ return preference?.choice === "accepted" && preference.issuedAt <= timestamp;
197
204
  };
198
- var analyticsAllowed = () => analyticsConsentSnapshot().startsWith("accepted:");
199
- var analyticsAcceptedBefore = (timestamp) => analyticsAllowed() && (browserPreference()?.issuedAt ?? Infinity) <= timestamp;
200
205
  var analyticsExportGuard = () => {
201
- const snapshot = analyticsConsentSnapshot();
202
- const generation = consentGeneration;
203
- return () => snapshot.startsWith("accepted:") && analyticsConsentSnapshot() === snapshot && consentGeneration === generation;
206
+ const initial = observeBrowserConsent();
207
+ return () => initial.preference?.choice === "accepted" && observeBrowserConsent().generation === initial.generation;
204
208
  };
205
209
  var subscribeAnalyticsConsent = (listener) => {
206
210
  let previous = analyticsConsentSnapshot();