@krak-stack/registry 0.11.6 → 0.11.9

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 (123) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +39 -0
  3. package/dist/components/app-switcher/html.d.ts +2 -2
  4. package/dist/components/asset-input/html.d.ts +70 -0
  5. package/dist/components/asset-input/html.js +1549 -0
  6. package/dist/components/asset-input/index.d.ts +280 -0
  7. package/dist/components/asset-input/react.d.ts +32 -0
  8. package/dist/components/asset-input/react.js +2269 -0
  9. package/dist/components/asset-input/schema.d.ts +93 -0
  10. package/dist/components/asset-input/upload.d.ts +15 -0
  11. package/dist/components/asset-table/html.d.ts +110 -0
  12. package/dist/components/asset-table/html.js +4934 -0
  13. package/dist/components/asset-table/index.d.ts +225 -0
  14. package/dist/components/asset-table/react.d.ts +21 -0
  15. package/dist/components/asset-table/react.js +8241 -0
  16. package/dist/components/asset-table/schema.d.ts +73 -0
  17. package/dist/components/audit-log-table/classes.d.ts +1 -0
  18. package/dist/components/audit-log-table/html.d.ts +158 -0
  19. package/dist/components/audit-log-table/html.js +3294 -0
  20. package/dist/components/audit-log-table/index.d.ts +37 -0
  21. package/dist/components/audit-log-table/react.d.ts +3 -51
  22. package/dist/components/audit-log-table/react.js +130 -89
  23. package/dist/components/audit-log-table/schema.d.ts +122 -0
  24. package/dist/components/danger-confirmation/html.d.ts +2 -2
  25. package/dist/components/danger-confirmation/index.d.ts +2 -2
  26. package/dist/components/data-table/classes.d.ts +3 -0
  27. package/dist/components/data-table/html.d.ts +70 -12
  28. package/dist/components/data-table/html.js +56 -19
  29. package/dist/components/data-table/index.d.ts +51 -1
  30. package/dist/components/data-table/react.d.ts +1 -0
  31. package/dist/components/data-table/react.js +46 -16
  32. package/dist/components/data-table/schema.d.ts +93 -3
  33. package/dist/components/docs/html.js +22 -4
  34. package/dist/components/docs/react.js +33 -2
  35. package/dist/components/editable-text/html.d.ts +2 -2
  36. package/dist/components/editable-text/index.d.ts +4 -4
  37. package/dist/components/effect-form/react.js +343 -138
  38. package/dist/components/email-editor/legacy-editor.html.d.ts +6 -6
  39. package/dist/components/file-input/classes.d.ts +1 -1
  40. package/dist/components/file-input/file-type.d.ts +1 -0
  41. package/dist/components/file-input/html.d.ts +8 -1
  42. package/dist/components/file-input/html.js +170 -12
  43. package/dist/components/file-input/index.d.ts +1 -0
  44. package/dist/components/file-input/react.d.ts +9 -1
  45. package/dist/components/file-input/react.js +277 -127
  46. package/dist/components/file-input/schema.d.ts +1 -0
  47. package/dist/components/form/react.js +343 -138
  48. package/dist/components/icon-input/html.js +19 -5
  49. package/dist/components/icon-input/react.js +70 -13
  50. package/dist/components/map-menu/html.d.ts +6 -0
  51. package/dist/components/map-menu/html.js +13 -8
  52. package/dist/components/map-menu/index.d.ts +5 -4
  53. package/dist/components/map-menu/react.d.ts +28 -17
  54. package/dist/components/map-menu/react.js +84 -178
  55. package/dist/components/map-menu/schema.d.ts +6 -0
  56. package/dist/components/map-menu/shared.d.ts +4 -0
  57. package/dist/components/permissions-input/classes.d.ts +8 -0
  58. package/dist/components/permissions-input/html.d.ts +41 -0
  59. package/dist/components/permissions-input/html.js +130 -0
  60. package/dist/components/permissions-input/index.d.ts +80 -0
  61. package/dist/components/permissions-input/react.d.ts +7 -0
  62. package/dist/components/permissions-input/react.js +201 -0
  63. package/dist/components/permissions-input/schema.d.ts +33 -0
  64. package/dist/components/phone-number-input/html.js +48 -14
  65. package/dist/components/phone-number-input/react.js +67 -10
  66. package/dist/components/search-menu/html.d.ts +2 -2
  67. package/dist/components/select-with-custom-input/html.d.ts +2 -2
  68. package/dist/components/sidebar-layout/html.d.ts +3 -2
  69. package/dist/components/sidebar-layout/html.js +20 -2
  70. package/dist/components/sidebar-layout/index.d.ts +1 -0
  71. package/dist/components/sidebar-layout/react.js +33 -2
  72. package/dist/components/switch/react.d.ts +14 -0
  73. package/dist/components/switch/react.js +55 -0
  74. package/dist/components/theme-switcher/html.d.ts +2 -2
  75. package/dist/components/time-input/html.d.ts +2 -2
  76. package/dist/components/timezone-input/html.js +48 -14
  77. package/dist/components/timezone-input/react.js +67 -10
  78. package/dist/components/tracking-notice/classes.d.ts +6 -0
  79. package/dist/components/tracking-notice/html.d.ts +85 -0
  80. package/dist/components/tracking-notice/html.js +354 -0
  81. package/dist/components/tracking-notice/index.d.ts +95 -0
  82. package/dist/components/tracking-notice/react.d.ts +5 -27
  83. package/dist/components/tracking-notice/react.js +189 -59
  84. package/dist/components/tracking-notice/schema.d.ts +45 -0
  85. package/dist/components/upload-attachment/classes.d.ts +3 -2
  86. package/dist/components/upload-attachment/html.d.ts +5 -5
  87. package/dist/components/upload-attachment/html.js +7 -5
  88. package/dist/components/upload-attachment/react.d.ts +3 -1
  89. package/dist/components/upload-attachment/react.js +25 -17
  90. package/dist/components/virtualized-combobox/classes.d.ts +12 -0
  91. package/dist/components/virtualized-combobox/html.d.ts +42 -0
  92. package/dist/components/virtualized-combobox/html.js +48 -14
  93. package/dist/components/virtualized-combobox/index.d.ts +55 -4
  94. package/dist/components/virtualized-combobox/react.d.ts +6 -2
  95. package/dist/components/virtualized-combobox/react.js +67 -10
  96. package/dist/components/virtualized-combobox/schema.d.ts +60 -4
  97. package/dist/components/webhook-delivery-table/html.js +56 -19
  98. package/dist/components/webhook-delivery-table/react.js +46 -16
  99. package/dist/lib/access/index.d.ts +61 -0
  100. package/dist/lib/access/index.js +92 -0
  101. package/dist/lib/access/table/classes.d.ts +13 -0
  102. package/dist/lib/access/table/html.d.ts +39 -0
  103. package/dist/lib/access/table/html.js +157 -0
  104. package/dist/lib/access/table/index.d.ts +32 -0
  105. package/dist/lib/access/table/react.d.ts +3 -0
  106. package/dist/lib/access/table/react.js +195 -0
  107. package/dist/lib/access/table/schema.d.ts +43 -0
  108. package/dist/lib/docs.integrations.server.js +23 -1
  109. package/dist/lib/docs.js +33 -2
  110. package/dist/lib/docs.server.js +29 -2
  111. package/dist/lib/documentation-toolkit.js +23 -1
  112. package/dist/lib/effect-ui-adapter/use-model.d.ts +1 -1
  113. package/dist/lib/effect-ui-adapter/use-model.js +19 -11
  114. package/dist/lib/lucide-effect.d.ts +19 -19
  115. package/dist/lib/lucide-effect.js +38 -38
  116. package/dist/services/assets/library.d.ts +221 -0
  117. package/dist/services/assets/schema.d.ts +3 -0
  118. package/dist/services/assets/url.d.ts +12 -0
  119. package/dist/services/assets/use-library.d.ts +20 -0
  120. package/dist/services/events/browser.js +39 -26
  121. package/dist/services/events/index.js +23 -19
  122. package/dist/services/opentelemetry/web-vitals.js +27 -23
  123. package/package.json +21 -1
@@ -1,5 +1,6 @@
1
1
  // ../../src/components/sidebar-layout/html.ts
2
- import { Predicate, Schema as Schema3 } from "effect";
2
+ import { Effect, Predicate, Schema as Schema3 } from "effect";
3
+ import { Component as Component2, Mount } from "effect/ui";
3
4
  import { Html, HtmlSubscription } from "effect/ui/html";
4
5
  import { Dialog, Tooltip } from "effect/ui/kit";
5
6
  import { buttonVariants } from "@/components/effectcn/button";
@@ -92,6 +93,22 @@ var isNavItemActive = (path, item) => {
92
93
  const target = normalize(item.href);
93
94
  return current === target || !item.exact && target !== "/" && current.startsWith(`${target}/`);
94
95
  };
96
+ var centerActiveSidebarLink = (sidebar) => {
97
+ if (!sidebar?.clientHeight)
98
+ return;
99
+ let active;
100
+ for (const link of sidebar.querySelectorAll('a[aria-current="page"]')) {
101
+ if (!link.getClientRects().length)
102
+ continue;
103
+ if (!active || link.pathname.length > active.pathname.length)
104
+ active = link;
105
+ }
106
+ if (!active)
107
+ return;
108
+ const link = active.getBoundingClientRect();
109
+ const sidebarTop = sidebar.getBoundingClientRect().top;
110
+ sidebar.scrollTop += link.top + link.height / 2 - (sidebarTop + sidebar.clientHeight / 2);
111
+ };
95
112
  var SidebarLayoutMessage = UiSchema.TaggedEnum({
96
113
  SetOpen: { open: Schema2.Boolean },
97
114
  SetMobileOpen: { open: Schema2.Boolean },
@@ -127,6 +144,7 @@ var sidebarLayoutBehaviours = {
127
144
  };
128
145
 
129
146
  // ../../src/components/sidebar-layout/html.ts
147
+ var CenterActiveLink = Mount.make("SidebarLayout/CenterActiveLink", { args: {} }, (sidebar) => Effect.sync(() => centerActiveSidebarLink(sidebar)).pipe(Effect.as(Component2.noop)));
130
148
  var badges = {
131
149
  default: "bg-primary text-primary-foreground",
132
150
  secondary: "bg-secondary text-secondary-foreground",
@@ -193,7 +211,7 @@ var SidebarLayout = Html.component({
193
211
  const mobile = model.mobile && !fixed;
194
212
  const compact = !model.open && sidebarCollapsible === "icon";
195
213
  const offcanvasClosed = !model.open && sidebarCollapsible === "offcanvas";
196
- const rail = (narrow, mobile) => h.nav.attr("aria-label", toggleLabel).attr("inert", !mobile && offcanvasClosed ? "" : undefined).class("flex min-h-0 min-w-0 flex-1 flex-col").children(h.div.attr("data-collapsible", narrow ? "icon" : undefined).class("group shrink-0 overflow-x-clip").children(h.div.class(cn("flex flex-col gap-2 p-2 empty:hidden", !mobile && "[&_[data-slot=app-brand]]:transition-[padding] [&_[data-slot=app-brand]]:duration-200 [&_[data-slot=app-brand]]:ease-in-out motion-reduce:[&_[data-slot=app-brand]]:transition-none", narrow && "[&_[data-slot=app-brand]]:px-0", !mobile && "w-64")).children(h.slots.sidebarHeader)), h.div.attr("data-collapsible", narrow ? "icon" : undefined).class("group no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden").children(groups.map((group) => h.section.key(group.label).class("flex min-w-0 flex-col p-2").children(h.h2.class(cn("text-sidebar-foreground/70 flex h-8 shrink-0 items-center px-2 text-xs font-medium", narrow && "sr-only")).children(group.label), h.ul.class("grid gap-1").children(...group.items.map((item) => {
214
+ const rail = (narrow, mobile) => h.nav.attr("aria-label", toggleLabel).attr("inert", !mobile && offcanvasClosed ? "" : undefined).class("flex min-h-0 min-w-0 flex-1 flex-col").children(h.div.attr("data-collapsible", narrow ? "icon" : undefined).class("group shrink-0 overflow-x-clip").children(h.div.class(cn("flex flex-col gap-2 p-2 empty:hidden", !mobile && "[&_[data-slot=app-brand]]:transition-[padding] [&_[data-slot=app-brand]]:duration-200 [&_[data-slot=app-brand]]:ease-in-out motion-reduce:[&_[data-slot=app-brand]]:transition-none", narrow && "[&_[data-slot=app-brand]]:px-0", !mobile && "w-64")).children(h.slots.sidebarHeader)), h.div.attr("data-collapsible", narrow ? "icon" : undefined).class("group no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden").onMount(CenterActiveLink({})).children(groups.map((group) => h.section.key(group.label).class("flex min-w-0 flex-col p-2").children(h.h2.class(cn("text-sidebar-foreground/70 flex h-8 shrink-0 items-center px-2 text-xs font-medium", narrow && "sr-only")).children(group.label), h.ul.class("grid gap-1").children(...group.items.map((item) => {
197
215
  const active = isNavItemActive(currentPath, item);
198
216
  const icon = Predicate.isFunction(item.icon) ? item.icon : item.icon && createLucideIcon(item.icon);
199
217
  const link = h.a.attrs({
@@ -4,6 +4,7 @@ import { SidebarLayoutPropsSchema, type NavItem } from "./schema.js";
4
4
  export declare const getSidebarDefaultOpen: (defaultOpen: boolean) => boolean;
5
5
  export declare const persistSidebar: (open: boolean) => void;
6
6
  export declare const isNavItemActive: (path: string | undefined, item: NavItem) => boolean;
7
+ export declare const centerActiveSidebarLink: (sidebar: HTMLElement | null) => void;
7
8
  export declare const SidebarLayoutMessage: UiSchema.TaggedEnum<{
8
9
  readonly SetItemTooltip: Schema.TaggedStruct<"SetItemTooltip", {
9
10
  readonly href: Schema.String;
@@ -1,6 +1,7 @@
1
1
  // ../../src/components/sidebar-layout/react.tsx
2
- import { Link, Outlet } from "@tanstack/react-router";
2
+ import { Link, Outlet, ScriptOnce } from "@tanstack/react-router";
3
3
  import { Component as Component2, View } from "effect/ui";
4
+ import { useLayoutEffect, useRef } from "react";
4
5
  import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
5
6
  import { Badge } from "@/components/ui/badge";
6
7
  import {
@@ -93,6 +94,22 @@ var SidebarOpenCookie = Schema2.Literals(["true", "false"]).annotate({
93
94
  identifier: "SidebarOpenCookie"
94
95
  });
95
96
  var getSidebarDefaultOpen = (defaultOpen) => Schema2.decodeUnknownOption(SidebarOpenCookie)(Cookies.parseHeader(globalThis.document?.cookie ?? "")[cookieName]).pipe(Option.map((value) => value === "true"), Option.getOrElse(() => defaultOpen));
97
+ var centerActiveSidebarLink = (sidebar) => {
98
+ if (!sidebar?.clientHeight)
99
+ return;
100
+ let active;
101
+ for (const link of sidebar.querySelectorAll('a[aria-current="page"]')) {
102
+ if (!link.getClientRects().length)
103
+ continue;
104
+ if (!active || link.pathname.length > active.pathname.length)
105
+ active = link;
106
+ }
107
+ if (!active)
108
+ return;
109
+ const link = active.getBoundingClientRect();
110
+ const sidebarTop = sidebar.getBoundingClientRect().top;
111
+ sidebar.scrollTop += link.top + link.height / 2 - (sidebarTop + sidebar.clientHeight / 2);
112
+ };
96
113
  var SidebarLayoutMessage = UiSchema.TaggedEnum({
97
114
  SetOpen: { open: Schema2.Boolean },
98
115
  SetMobileOpen: { open: Schema2.Boolean },
@@ -137,8 +154,18 @@ var useSidebarLayout = () => {
137
154
  const { isMobile } = useSidebar();
138
155
  return { isMobile };
139
156
  };
157
+ var sidebarScrollScript = `requestAnimationFrame(
158
+ (${centerActiveSidebarLink.toString()}).bind(null,
159
+ document.currentScript.parentElement.querySelector(':scope > [data-slot="sidebar-content"]')
160
+ )
161
+ )`;
140
162
  function AppSidebar({ collapsible, footer, groups, header }) {
141
- const { isMobile, setOpenMobile } = useSidebar();
163
+ const { isMobile, openMobile, setOpenMobile } = useSidebar();
164
+ const contentRef = useRef(null);
165
+ const drawerOpen = isMobile && collapsible !== "none" && openMobile;
166
+ useLayoutEffect(() => {
167
+ centerActiveSidebarLink(contentRef.current);
168
+ }, [isMobile, drawerOpen]);
142
169
  const closeMobileSidebar = () => {
143
170
  if (isMobile)
144
171
  setOpenMobile(false);
@@ -150,6 +177,7 @@ function AppSidebar({ collapsible, footer, groups, header }) {
150
177
  children: header
151
178
  }),
152
179
  /* @__PURE__ */ jsx(SidebarContent, {
180
+ ref: contentRef,
153
181
  className: "group-data-[collapsible=icon]:overflow-x-hidden group-data-[collapsible=icon]:overflow-y-auto",
154
182
  children: groups.map((group) => /* @__PURE__ */ jsxs(SidebarGroup, {
155
183
  children: [
@@ -221,6 +249,9 @@ function AppSidebar({ collapsible, footer, groups, header }) {
221
249
  footer ? /* @__PURE__ */ jsx(SidebarFooter, {
222
250
  children: footer
223
251
  }) : null,
252
+ /* @__PURE__ */ jsx(ScriptOnce, {
253
+ children: sidebarScrollScript
254
+ }),
224
255
  /* @__PURE__ */ jsx(SidebarRail, {})
225
256
  ]
226
257
  });
@@ -0,0 +1,14 @@
1
+ import type { ComponentProps } from "react";
2
+ import { Switch as Primitive } from "@base-ui/react/switch";
3
+ export type SwitchProps = Omit<ComponentProps<typeof Primitive.Root>, "children" | "className" | "nativeButton" | "render"> & {
4
+ className?: string;
5
+ variant?: "rectangular" | "rounded";
6
+ showText?: boolean;
7
+ animated?: boolean;
8
+ locale?: string;
9
+ labels?: {
10
+ on: string;
11
+ off: string;
12
+ };
13
+ };
14
+ export declare const Switch: ({ variant, showText, animated, locale, labels, className, ...props }: SwitchProps) => import("react").JSX.Element;
@@ -0,0 +1,55 @@
1
+ // ../../src/components/switch/react.tsx
2
+ import { Switch as Primitive } from "@base-ui/react/switch";
3
+ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
4
+
5
+ // ../../src/lib/utils.ts
6
+ import { cn } from "cn";
7
+
8
+ // ../../src/components/switch/react.tsx
9
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
10
+ "use client";
11
+ var Switch = ({
12
+ variant = "rectangular",
13
+ showText = true,
14
+ animated = false,
15
+ locale,
16
+ labels,
17
+ className,
18
+ ...props
19
+ }) => {
20
+ const language = useKrakstackLocale(locale).split("-")[0]?.toLowerCase();
21
+ const text = labels ?? (language === "fr" ? { on: "OUI", off: "NON" } : { on: "ON", off: "OFF" });
22
+ return /* @__PURE__ */ jsxs(Primitive.Root, {
23
+ ...props,
24
+ nativeButton: true,
25
+ render: /* @__PURE__ */ jsx("button", {
26
+ type: "button"
27
+ }),
28
+ "data-slot": "switch",
29
+ "data-variant": variant,
30
+ className: cn("group/switch bg-muted text-muted-foreground ring-input data-checked:bg-primary data-checked:text-primary-foreground relative inline-grid h-7 min-w-14 shrink-0 grid-cols-2 items-center ring-1 select-none ring-inset", "focus-visible:outline-ring focus-visible:outline-2 focus-visible:outline-offset-2 data-disabled:opacity-50", variant === "rounded" ? "rounded-full" : "rounded-[4px]", animated && "focus-visible:transition-none motion-safe:transition-colors motion-safe:duration-150", className),
31
+ children: [
32
+ showText && /* @__PURE__ */ jsxs(Fragment, {
33
+ children: [
34
+ /* @__PURE__ */ jsx("span", {
35
+ "aria-hidden": "true",
36
+ className: cn("px-0.5 text-center text-[9px] font-bold opacity-0 group-data-checked/switch:opacity-100", animated && "group-focus-visible/switch:transition-none motion-safe:transition-opacity motion-safe:duration-150"),
37
+ children: text.on
38
+ }),
39
+ /* @__PURE__ */ jsx("span", {
40
+ "aria-hidden": "true",
41
+ className: cn("px-0.5 text-center text-[9px] font-bold group-data-checked/switch:opacity-0", animated && "group-focus-visible/switch:transition-none motion-safe:transition-opacity motion-safe:duration-150"),
42
+ children: text.off
43
+ })
44
+ ]
45
+ }),
46
+ /* @__PURE__ */ jsx(Primitive.Thumb, {
47
+ "data-slot": "switch-thumb",
48
+ className: cn("bg-background ring-border pointer-events-none absolute start-[3px] top-[3px] size-[22px] shadow-sm ring-1 data-checked:start-[calc(100%-25px)]", animated && "group-focus-visible/switch:transition-none motion-safe:transition-[inset-inline-start] motion-safe:duration-150 motion-safe:ease-[cubic-bezier(0.2,0.8,0.2,1)]", variant === "rounded" ? "rounded-full" : "rounded-[3px]")
49
+ })
50
+ ]
51
+ });
52
+ };
53
+ export {
54
+ Switch
55
+ };
@@ -16,9 +16,9 @@ export declare const ThemeSwitcher: import("effect/ui/Component").Component<"The
16
16
  readonly options?: readonly ("dark" | "light" | "system")[] | undefined;
17
17
  readonly value: "dark" | "light" | "system";
18
18
  }, boolean, {
19
- readonly _tag: "Closed";
20
- } | {
21
19
  readonly _tag: "Opened";
20
+ } | {
21
+ readonly _tag: "Closed";
22
22
  } | {
23
23
  readonly _tag: "Picked";
24
24
  readonly value: "dark" | "light" | "system";
@@ -58,9 +58,9 @@ export declare const TimeInput: Component.Component<"TimeInput", {
58
58
  }, {
59
59
  readonly open: boolean;
60
60
  }, {
61
- readonly _tag: "Closed";
62
- } | {
63
61
  readonly _tag: "Opened";
62
+ } | {
63
+ readonly _tag: "Closed";
64
64
  } | {
65
65
  readonly _tag: "Cleared";
66
66
  } | {
@@ -6,6 +6,7 @@ import { krakstackLocaleRead as krakstackLocaleRead2 } from "@krak-stack/registr
6
6
  // ../../src/components/virtualized-combobox/html.ts
7
7
  import { Html } from "effect/ui/html";
8
8
  import { Combobox, VirtualList } from "effect/ui/kit";
9
+ import { buttonVariants } from "@/components/effectcn/button";
9
10
  import {
10
11
  ComboboxButton,
11
12
  ComboboxClear,
@@ -20,8 +21,15 @@ import { krakstackLocaleRead } from "@krak-stack/registry/krakstack-provider/htm
20
21
 
21
22
  // ../../src/components/virtualized-combobox/classes.ts
22
23
  var virtualizedComboboxClasses = {
23
- itemLabel: "min-w-0 truncate"
24
+ itemLabel: "min-w-0 truncate",
25
+ groupLabel: "text-muted-foreground px-2 pt-3 pb-1 text-start text-xs",
26
+ itemContent: "flex min-w-0 flex-1 items-center gap-2 text-start",
27
+ itemMedia: "bg-muted grid size-8 shrink-0 place-items-center overflow-hidden rounded-md [&_svg]:size-4",
28
+ itemImage: "size-full object-cover",
29
+ itemDescription: "text-muted-foreground block truncate text-xs"
24
30
  };
31
+ var virtualizedComboboxGroupHeight = 36;
32
+ var virtualizedComboboxDetailHeight = 52;
25
33
  var resolveVirtualizedComboboxClasses = (overrides) => ({
26
34
  ...virtualizedComboboxClasses,
27
35
  ...overrides
@@ -32,10 +40,14 @@ import { Schema as Schema2 } from "effect";
32
40
  import { Component, UiSchema } from "effect/ui";
33
41
 
34
42
  // ../../src/components/virtualized-combobox/schema.ts
35
- import { Schema, Struct } from "effect";
43
+ import { Predicate, Schema, Struct } from "effect";
44
+ var Icon = Schema.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "VirtualizedComboboxIcon" });
36
45
  var VirtualizedComboboxOptionSchema = Schema.Struct({
37
46
  value: Schema.String.pipe(Schema.mutableKey),
38
- label: Schema.String.pipe(Schema.mutableKey)
47
+ label: Schema.String.pipe(Schema.mutableKey),
48
+ description: Schema.optionalKey(Schema.String),
49
+ imageSrc: Schema.optionalKey(Schema.String),
50
+ icon: Schema.optionalKey(Icon)
39
51
  }).annotate({ identifier: "VirtualizedComboboxOption" });
40
52
  var VirtualizedComboboxLabelsSchema = Schema.Struct({
41
53
  clear: Schema.optionalKey(Schema.String),
@@ -60,6 +72,8 @@ var htmlFields = {
60
72
  emptyLabel: Schema.String,
61
73
  placeholder: Schema.String,
62
74
  triggerLabel: Schema.optionalKey(Schema.String),
75
+ triggerIcon: Schema.optionalKey(Icon),
76
+ itemHeight: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
63
77
  filter: Schema.optionalKey(Schema.Literals(["contains", "none"])),
64
78
  messages: Schema.optionalKey(Schema.Record(Schema.String, Schema.Struct({
65
79
  ...VirtualizedComboboxLabelsSchema.fields,
@@ -151,7 +165,8 @@ var VirtualizedComboboxEvents = UiSchema.TaggedEnum(events).annotate({
151
165
  });
152
166
  var VirtualizedComboboxMessage = UiSchema.TaggedEnum({
153
167
  ...events,
154
- Highlighted: { value: Schema2.String }
168
+ Highlighted: { value: Schema2.String },
169
+ ImageFailed: { src: Schema2.String }
155
170
  }).annotate({ identifier: "VirtualizedComboboxMessage" });
156
171
  var virtualizedComboboxOptions = {
157
172
  name: "VirtualizedCombobox",
@@ -159,6 +174,7 @@ var virtualizedComboboxOptions = {
159
174
  model: Schema2.Struct({
160
175
  open: Schema2.Boolean,
161
176
  searchValue: Schema2.String,
177
+ failedImages: Schema2.Array(Schema2.String),
162
178
  highlight: Schema2.NullOr(Schema2.Struct({ value: Schema2.String, id: Schema2.Int }))
163
179
  }).annotate({ identifier: "VirtualizedComboboxModel" }),
164
180
  message: VirtualizedComboboxMessage,
@@ -178,15 +194,20 @@ var update = Component.define(virtualizedComboboxOptions).update({
178
194
  ValueChanged: ($, { value }) => $.set($.model).emit(VirtualizedComboboxEvents.ValueChanged({ value })),
179
195
  Highlighted: ($, { value }) => $.evolve({
180
196
  highlight: { value, id: ($.model.highlight?.id ?? 0) + 1 }
181
- })
197
+ }),
198
+ ImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] })
182
199
  });
183
200
  var virtualizedComboboxBehaviours = {
184
- init: () => ({ open: false, searchValue: "", highlight: null }),
201
+ init: () => ({
202
+ open: false,
203
+ searchValue: "",
204
+ highlight: null,
205
+ failedImages: []
206
+ }),
185
207
  update
186
208
  };
187
209
 
188
210
  // ../../src/components/virtualized-combobox/html.ts
189
- var rowHeight = 36;
190
211
  var visibleRows = 8;
191
212
  var itemKey = (value) => `item:${value}`;
192
213
  var VirtualizedCombobox = Html.component({
@@ -197,6 +218,8 @@ var VirtualizedCombobox = Html.component({
197
218
  view: (h, model) => {
198
219
  const virtualizedComboboxClasses = resolveVirtualizedComboboxClasses(h.props.classes);
199
220
  const props = h.props;
221
+ const optionsByValue = new Map(props.items.map((item) => [item.value, item]));
222
+ const rowHeight = props.itemHeight ?? (props.items.some(({ description, imageSrc, icon }) => description || imageSrc || icon) ? virtualizedComboboxDetailHeight : 36);
200
223
  const locale = props.locale ?? h.reads.localeConfig?.locale ?? "en";
201
224
  const labels = virtualizedComboboxMessages(locale, props.messages);
202
225
  const value = props.multiple ? props.value.map((item) => item.value) : props.value?.value ?? null;
@@ -205,7 +228,7 @@ var VirtualizedCombobox = Html.component({
205
228
  props: {
206
229
  open: props.open ?? model.open,
207
230
  inputValue: props.searchValue ?? model.searchValue,
208
- items: props.items,
231
+ items: props.items.map(({ value, label }) => ({ value, label })),
209
232
  value,
210
233
  locale,
211
234
  multiple: props.multiple,
@@ -232,14 +255,14 @@ var VirtualizedCombobox = Html.component({
232
255
  const entries = selectionEntries(combo.items, selected, props.multiple === true, labels);
233
256
  const keys = entries.map((entry) => entry.kind === "group" ? `group:${entry.key}` : itemKey(entry.item.value));
234
257
  const highlight = model.highlight && keys.includes(itemKey(model.highlight.value)) ? model.highlight : undefined;
235
- return h.div.class("relative min-w-0").children(ComboboxButton(h, combo, {
258
+ return h.div.class("relative min-w-0").children((props.triggerIcon ? combo.trigger(h.button.class(buttonVariants({ variant: "outline" }))).children(props.triggerIcon(h, { size: 16 }), props.triggerLabel ?? selectedLabel(props.value, props.placeholder)) : ComboboxButton(h, combo, {
236
259
  class: "w-full min-w-0 aria-invalid:border-destructive",
237
260
  value: props.triggerLabel ?? selectedLabel(props.value, props.placeholder),
238
261
  valueClass: selected.size > 0 ? "pr-7" : undefined
239
- }).attrs({
262
+ })).attrs({
240
263
  "aria-label": props.ariaLabel,
241
264
  "aria-invalid": props.ariaInvalid ? "true" : undefined
242
- }), selected.size > 0 && ComboboxClear(h, combo, {
265
+ }), !props.triggerIcon && selected.size > 0 && ComboboxClear(h, combo, {
243
266
  class: "absolute right-7 top-1/2 -translate-y-1/2"
244
267
  })?.attrs({ "aria-label": labels.clear, tabindex: "0" }), ComboboxPositioner(h, combo, {
245
268
  class: "overflow-visible border-0 bg-transparent p-0 text-inherit"
@@ -249,6 +272,7 @@ var VirtualizedCombobox = Html.component({
249
272
  props: {
250
273
  count: entries.length,
251
274
  itemSize: rowHeight,
275
+ sizes: entries.some(({ kind }) => kind === "group") ? entries.map(({ kind }) => kind === "group" ? virtualizedComboboxGroupHeight : rowHeight) : undefined,
252
276
  measure: false,
253
277
  keys,
254
278
  initialCount: visibleRows,
@@ -259,16 +283,18 @@ var VirtualizedCombobox = Html.component({
259
283
  align: "nearest"
260
284
  }
261
285
  },
262
- view: (list) => list.viewport(h.div.class("min-h-0 overflow-auto overscroll-contain")).attr("style", `max-height:${rowHeight * visibleRows}px`).attr("tabindex", "-1").children(list.list(combo.list(h.div)).children(...list.items.map((index) => {
286
+ view: (list) => list.viewport(h.div.class("min-h-0 overflow-auto overscroll-contain py-1")).attr("style", `max-height:${rowHeight * visibleRows}px`).attr("tabindex", "-1").children(list.list(combo.list(h.div)).children(...list.items.map((index) => {
263
287
  const entry = entries[index];
264
288
  const element = h.div.key(keys[index]);
265
289
  if (entry.kind === "group") {
266
290
  return list.item({
267
291
  element: element.attr("role", "presentation"),
268
292
  index
269
- }).class("text-muted-foreground px-2 pt-3 text-xs").children(entry.label);
293
+ }).class("px-1").children(h.div.class(virtualizedComboboxClasses.groupLabel).children(entry.label));
270
294
  }
271
295
  const { value, label } = entry.item;
296
+ const details = optionsByValue.get(value);
297
+ const image = details?.imageSrc && !model.failedImages.includes(details.imageSrc) ? details.imageSrc : undefined;
272
298
  return list.item({
273
299
  element: element.attr("role", "presentation"),
274
300
  index
@@ -278,7 +304,15 @@ var VirtualizedCombobox = Html.component({
278
304
  }).attrs({
279
305
  "aria-posinset": String(entry.index + 1),
280
306
  "aria-setsize": String(combo.items.length)
281
- }).children(h.span.class(virtualizedComboboxClasses.itemLabel).children(label), ComboboxItemIndicator(h, combo, { value })));
307
+ }).children(h.span.class(virtualizedComboboxClasses.itemContent).children((image || details?.icon) && h.span.attr("aria-hidden", "true").class(virtualizedComboboxClasses.itemMedia).children(image ? h.img.attrs({
308
+ src: image,
309
+ alt: "",
310
+ loading: "lazy"
311
+ }).class(virtualizedComboboxClasses.itemImage).on("error", VirtualizedComboboxMessage.ImageFailed({
312
+ src: image
313
+ })) : details?.icon?.(h, {
314
+ size: 16
315
+ })), h.span.class("min-w-0 flex-1").children(h.span.class(`block ${virtualizedComboboxClasses.itemLabel}`).children(label), details?.description && h.span.class(virtualizedComboboxClasses.itemDescription).children(details.description))), ComboboxItemIndicator(h, combo, { value })));
282
316
  })))
283
317
  }))));
284
318
  }
@@ -16,7 +16,8 @@ import {
16
16
  useCallback,
17
17
  useEffect,
18
18
  useImperativeHandle,
19
- useRef
19
+ useRef,
20
+ useState
20
21
  } from "react";
21
22
  import { Button } from "@/components/ui/button";
22
23
  import { InputGroup, InputGroupInput } from "@/components/ui/input-group";
@@ -24,8 +25,15 @@ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/reac
24
25
 
25
26
  // ../../src/components/virtualized-combobox/classes.ts
26
27
  var virtualizedComboboxClasses = {
27
- itemLabel: "min-w-0 truncate"
28
+ itemLabel: "min-w-0 truncate",
29
+ groupLabel: "text-muted-foreground px-2 pt-3 pb-1 text-start text-xs",
30
+ itemContent: "flex min-w-0 flex-1 items-center gap-2 text-start",
31
+ itemMedia: "bg-muted grid size-8 shrink-0 place-items-center overflow-hidden rounded-md [&_svg]:size-4",
32
+ itemImage: "size-full object-cover",
33
+ itemDescription: "text-muted-foreground block truncate text-xs"
28
34
  };
35
+ var virtualizedComboboxGroupHeight = 36;
36
+ var virtualizedComboboxDetailHeight = 52;
29
37
  var resolveVirtualizedComboboxClasses = (overrides) => ({
30
38
  ...virtualizedComboboxClasses,
31
39
  ...overrides
@@ -36,10 +44,14 @@ import { Schema as Schema2 } from "effect";
36
44
  import { Component, UiSchema } from "effect/ui";
37
45
 
38
46
  // ../../src/components/virtualized-combobox/schema.ts
39
- import { Schema, Struct } from "effect";
47
+ import { Predicate, Schema, Struct } from "effect";
48
+ var Icon = Schema.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "VirtualizedComboboxIcon" });
40
49
  var VirtualizedComboboxOptionSchema = Schema.Struct({
41
50
  value: Schema.String.pipe(Schema.mutableKey),
42
- label: Schema.String.pipe(Schema.mutableKey)
51
+ label: Schema.String.pipe(Schema.mutableKey),
52
+ description: Schema.optionalKey(Schema.String),
53
+ imageSrc: Schema.optionalKey(Schema.String),
54
+ icon: Schema.optionalKey(Icon)
43
55
  }).annotate({ identifier: "VirtualizedComboboxOption" });
44
56
  var VirtualizedComboboxLabelsSchema = Schema.Struct({
45
57
  clear: Schema.optionalKey(Schema.String),
@@ -64,6 +76,8 @@ var htmlFields = {
64
76
  emptyLabel: Schema.String,
65
77
  placeholder: Schema.String,
66
78
  triggerLabel: Schema.optionalKey(Schema.String),
79
+ triggerIcon: Schema.optionalKey(Icon),
80
+ itemHeight: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
67
81
  filter: Schema.optionalKey(Schema.Literals(["contains", "none"])),
68
82
  messages: Schema.optionalKey(Schema.Record(Schema.String, Schema.Struct({
69
83
  ...VirtualizedComboboxLabelsSchema.fields,
@@ -153,7 +167,8 @@ var VirtualizedComboboxEvents = UiSchema.TaggedEnum(events).annotate({
153
167
  });
154
168
  var VirtualizedComboboxMessage = UiSchema.TaggedEnum({
155
169
  ...events,
156
- Highlighted: { value: Schema2.String }
170
+ Highlighted: { value: Schema2.String },
171
+ ImageFailed: { src: Schema2.String }
157
172
  }).annotate({ identifier: "VirtualizedComboboxMessage" });
158
173
  var virtualizedComboboxOptions = {
159
174
  name: "VirtualizedCombobox",
@@ -161,6 +176,7 @@ var virtualizedComboboxOptions = {
161
176
  model: Schema2.Struct({
162
177
  open: Schema2.Boolean,
163
178
  searchValue: Schema2.String,
179
+ failedImages: Schema2.Array(Schema2.String),
164
180
  highlight: Schema2.NullOr(Schema2.Struct({ value: Schema2.String, id: Schema2.Int }))
165
181
  }).annotate({ identifier: "VirtualizedComboboxModel" }),
166
182
  message: VirtualizedComboboxMessage,
@@ -180,17 +196,24 @@ var update = Component.define(virtualizedComboboxOptions).update({
180
196
  ValueChanged: ($, { value }) => $.set($.model).emit(VirtualizedComboboxEvents.ValueChanged({ value })),
181
197
  Highlighted: ($, { value }) => $.evolve({
182
198
  highlight: { value, id: ($.model.highlight?.id ?? 0) + 1 }
183
- })
199
+ }),
200
+ ImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] })
184
201
  });
185
202
 
186
203
  // ../../src/components/virtualized-combobox/react.tsx
187
204
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
188
205
  "use client";
189
206
  var optionEquals = (item, selected) => item.value === selected.value;
207
+ var hasOptionDetails = ({
208
+ description,
209
+ imageSrc,
210
+ icon
211
+ }) => Boolean(description || imageSrc || icon);
190
212
  var VirtualizedComboboxList = ({
191
213
  classes,
192
214
  emptyLabel,
193
215
  groupSelections,
216
+ itemHeight,
194
217
  itemIndexRef,
195
218
  locale = "en",
196
219
  messages: messageOverrides,
@@ -203,6 +226,8 @@ var VirtualizedComboboxList = ({
203
226
  const labels = virtualizedComboboxMessages(locale, messageOverrides);
204
227
  const entries = selectionEntries(filteredItems, selectedValues, groupSelections, labels);
205
228
  const scrollRef = useRef(null);
229
+ const [failedImages, setFailedImages] = useState(() => new Set);
230
+ const rowHeight = itemHeight ?? (filteredItems.some(hasOptionDetails) ? virtualizedComboboxDetailHeight : 36);
206
231
  const virtualizer = useVirtualizer({
207
232
  count: entries.length,
208
233
  getScrollElement: () => scrollRef.current,
@@ -210,7 +235,7 @@ var VirtualizedComboboxList = ({
210
235
  const entry = entries[index];
211
236
  return entry?.kind === "group" ? `group-${entry.key}` : entry?.item.value ?? index;
212
237
  },
213
- estimateSize: () => 36,
238
+ estimateSize: (index) => entries[index]?.kind === "group" ? virtualizedComboboxGroupHeight : rowHeight,
214
239
  overscan: 8
215
240
  });
216
241
  useEffect(() => {
@@ -252,7 +277,7 @@ var VirtualizedComboboxList = ({
252
277
  return /* @__PURE__ */ jsx(ComboboxPrimitive.Group, {
253
278
  className: "contents",
254
279
  children: /* @__PURE__ */ jsx(ComboboxPrimitive.GroupLabel, {
255
- className: "text-muted-foreground absolute top-0 left-0 w-full px-2 pt-3 pb-1 text-xs",
280
+ className: `absolute top-0 left-0 w-full ${virtualizedComboboxClasses.groupLabel}`,
256
281
  "data-index": virtualItem.index,
257
282
  ref: virtualizer.measureElement,
258
283
  style,
@@ -260,6 +285,8 @@ var VirtualizedComboboxList = ({
260
285
  })
261
286
  }, entry.key);
262
287
  }
288
+ const details = entry.item;
289
+ const image = details.imageSrc && !failedImages.has(details.imageSrc) ? details.imageSrc : undefined;
263
290
  return /* @__PURE__ */ jsxs(ComboboxPrimitive.Item, {
264
291
  "aria-posinset": entry.index + 1,
265
292
  "aria-setsize": filteredItems.length,
@@ -270,10 +297,38 @@ var VirtualizedComboboxList = ({
270
297
  style,
271
298
  value: entry.item,
272
299
  children: [
273
- renderItem?.(entry.item) ?? /* @__PURE__ */ jsx("span", {
300
+ renderItem?.(entry.item) ?? (hasOptionDetails(details) ? /* @__PURE__ */ jsxs("span", {
301
+ className: virtualizedComboboxClasses.itemContent,
302
+ children: [
303
+ (image || details.icon) && /* @__PURE__ */ jsx("span", {
304
+ "aria-hidden": "true",
305
+ className: virtualizedComboboxClasses.itemMedia,
306
+ children: image ? /* @__PURE__ */ jsx("img", {
307
+ src: image,
308
+ alt: "",
309
+ loading: "lazy",
310
+ onError: () => setFailedImages((failed) => new Set(failed).add(image)),
311
+ className: virtualizedComboboxClasses.itemImage
312
+ }) : details.icon
313
+ }),
314
+ /* @__PURE__ */ jsxs("span", {
315
+ className: "min-w-0 flex-1",
316
+ children: [
317
+ /* @__PURE__ */ jsx("span", {
318
+ className: cn("block", virtualizedComboboxClasses.itemLabel),
319
+ children: entry.item.label
320
+ }),
321
+ details.description && /* @__PURE__ */ jsx("span", {
322
+ className: virtualizedComboboxClasses.itemDescription,
323
+ children: details.description
324
+ })
325
+ ]
326
+ })
327
+ ]
328
+ }) : /* @__PURE__ */ jsx("span", {
274
329
  className: virtualizedComboboxClasses.itemLabel,
275
330
  children: entry.item.label
276
- }),
331
+ })),
277
332
  /* @__PURE__ */ jsx(ComboboxPrimitive.ItemIndicator, {
278
333
  className: "absolute right-2 flex size-4 items-center justify-center",
279
334
  children: /* @__PURE__ */ jsx(Check, {})
@@ -291,6 +346,7 @@ var VirtualizedComboboxContent = ({
291
346
  contentClassName,
292
347
  emptyLabel,
293
348
  groupSelections,
349
+ itemHeight,
294
350
  itemIndexRef,
295
351
  locale = "en",
296
352
  messages: messageOverrides,
@@ -322,6 +378,7 @@ var VirtualizedComboboxContent = ({
322
378
  classes,
323
379
  emptyLabel,
324
380
  groupSelections,
381
+ itemHeight,
325
382
  itemIndexRef,
326
383
  locale,
327
384
  messages: messageOverrides,
@@ -0,0 +1,6 @@
1
+ export declare const trackingNoticeClasses: {
2
+ trigger: string;
3
+ banner: string;
4
+ dismiss: string;
5
+ bannerActions: string;
6
+ };