@vantageos/mosaic-blocks 0.5.14-alpha → 0.5.19-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { Button } from '@base-ui/react/button';
4
4
  import { cva } from 'class-variance-authority';
5
5
  import * as React28 from 'react';
6
- import { useState, useEffect, useRef, useId, useLayoutEffect, useCallback } from 'react';
6
+ import { useState, useEffect, useRef, useId, useLayoutEffect, useCallback, useMemo } from 'react';
7
7
  import { Accordion } from '@base-ui/react/accordion';
8
8
  export { Accordion } from '@base-ui/react/accordion';
9
9
  import { Checkbox } from '@base-ui/react/checkbox';
@@ -27,7 +27,7 @@ import { Menu } from '@base-ui/react/menu';
27
27
  import { AlertDialog } from '@base-ui/react/alert-dialog';
28
28
 
29
29
  // src/version.ts
30
- var version = "0.5.14-alpha";
30
+ var version = "0.5.19-alpha";
31
31
  function Placeholder({ label = "mosaic-blocks placeholder" }) {
32
32
  return /* @__PURE__ */ jsx("div", { "data-mosaic-block": "placeholder", children: label });
33
33
  }
@@ -11464,7 +11464,8 @@ var chatThreadRootVariants = cva([
11464
11464
  "relative flex min-h-0 flex-1 flex-col overflow-y-auto"
11465
11465
  ]);
11466
11466
  var chatThreadContentVariants = cva([
11467
- "mx-auto flex w-full max-w-2xl flex-col gap-4 px-4 py-6 sm:px-6"
11467
+ "mx-auto flex w-full max-w-2xl flex-col gap-4 px-4 py-6 sm:px-6",
11468
+ "[&>*]:[content-visibility:auto] [&>*]:[contain-intrinsic-size:auto_4rem]"
11468
11469
  ]);
11469
11470
  var chatThreadScrollButtonVariants = cva([
11470
11471
  "absolute bottom-4 left-1/2 -translate-x-1/2 inline-flex size-9",
@@ -11478,6 +11479,7 @@ var BOTTOM_THRESHOLD_PX = 24;
11478
11479
  function isNearBottom(element) {
11479
11480
  return element.scrollHeight - element.scrollTop - element.clientHeight <= BOTTOM_THRESHOLD_PX;
11480
11481
  }
11482
+ var NAVIGATION_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "PageUp", "PageDown", "Home", "End"]);
11481
11483
  function MosaicChatThread({
11482
11484
  children,
11483
11485
  scrollToBottomLabel,
@@ -11509,6 +11511,37 @@ function MosaicChatThread({
11509
11511
  isAtBottomRef.current = true;
11510
11512
  setIsAtBottom(true);
11511
11513
  }
11514
+ function disengageBottomAnchor() {
11515
+ isAtBottomRef.current = false;
11516
+ setIsAtBottom(false);
11517
+ }
11518
+ function handleKeyDown(event) {
11519
+ if (NAVIGATION_KEYS.has(event.key)) {
11520
+ disengageBottomAnchor();
11521
+ }
11522
+ }
11523
+ useEffect(() => {
11524
+ function handleSelectionChange() {
11525
+ const container = containerRef.current;
11526
+ if (!container) {
11527
+ return;
11528
+ }
11529
+ const selection = document.getSelection();
11530
+ if (!selection || selection.isCollapsed || selection.rangeCount === 0) {
11531
+ return;
11532
+ }
11533
+ const { anchorNode, focusNode } = selection;
11534
+ const touchesThread = anchorNode !== null && container.contains(anchorNode) || focusNode !== null && container.contains(focusNode);
11535
+ if (touchesThread) {
11536
+ isAtBottomRef.current = false;
11537
+ setIsAtBottom(false);
11538
+ }
11539
+ }
11540
+ document.addEventListener("selectionchange", handleSelectionChange);
11541
+ return () => {
11542
+ document.removeEventListener("selectionchange", handleSelectionChange);
11543
+ };
11544
+ }, []);
11512
11545
  useLayoutEffect(() => {
11513
11546
  const element = containerRef.current;
11514
11547
  if (element && isAtBottomRef.current) {
@@ -11522,6 +11555,7 @@ function MosaicChatThread({
11522
11555
  "data-slot": "chat-thread",
11523
11556
  role: "log",
11524
11557
  onScroll: handleScroll,
11558
+ onKeyDown: handleKeyDown,
11525
11559
  className: cn73(chatThreadRootVariants(), className),
11526
11560
  children: [
11527
11561
  /* @__PURE__ */ jsx("div", { "data-slot": "chat-thread-content", className: chatThreadContentVariants(), children }),
@@ -12837,7 +12871,582 @@ function MosaicAgentChat(props) {
12837
12871
  ] });
12838
12872
  }
12839
12873
  MosaicAgentChat.displayName = "MosaicAgentChat";
12874
+ var toastCardVariants = cva(
12875
+ ["flex w-full items-start gap-3 rounded-lg border p-4 shadow-lg sm:max-w-sm"],
12876
+ {
12877
+ variants: {
12878
+ variant: {
12879
+ success: "border-border bg-card",
12880
+ error: "border-destructive/40 bg-destructive/5",
12881
+ info: "border-border bg-card",
12882
+ warning: "border-amber-500/40 bg-amber-500/5"
12883
+ }
12884
+ },
12885
+ defaultVariants: {
12886
+ variant: "info"
12887
+ }
12888
+ }
12889
+ );
12890
+ var toastTitleVariants = cva(["text-sm font-medium"], {
12891
+ variants: {
12892
+ variant: {
12893
+ success: "text-foreground",
12894
+ error: "text-destructive",
12895
+ info: "text-foreground",
12896
+ warning: "text-amber-600 dark:text-amber-400"
12897
+ }
12898
+ },
12899
+ defaultVariants: {
12900
+ variant: "info"
12901
+ }
12902
+ });
12903
+ var toastDismissButtonVariants = cva([
12904
+ "inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground"
12905
+ ]);
12906
+ var toastProviderPositionVariants = cva(
12907
+ ["pointer-events-none fixed z-50 flex flex-col gap-2 p-4"],
12908
+ {
12909
+ variants: {
12910
+ position: {
12911
+ "top-right": "top-0 right-0 items-end",
12912
+ "top-center": "top-0 left-1/2 -translate-x-1/2 items-center",
12913
+ "bottom-right": "bottom-0 right-0 items-end",
12914
+ "bottom-center": "bottom-0 left-1/2 -translate-x-1/2 items-center"
12915
+ }
12916
+ },
12917
+ defaultVariants: {
12918
+ position: "top-right"
12919
+ }
12920
+ }
12921
+ );
12922
+ function cn81(...classes) {
12923
+ return classes.filter(Boolean).join(" ");
12924
+ }
12925
+ function MosaicToast({
12926
+ variant,
12927
+ title,
12928
+ description,
12929
+ action,
12930
+ onDismiss,
12931
+ dismissAriaLabel,
12932
+ durationMs,
12933
+ className,
12934
+ ref
12935
+ }) {
12936
+ useEffect(() => {
12937
+ if (durationMs === void 0) return;
12938
+ const timer = setTimeout(onDismiss, durationMs);
12939
+ return () => clearTimeout(timer);
12940
+ }, [durationMs, onDismiss]);
12941
+ const role = variant === "error" ? "alert" : "status";
12942
+ return /* @__PURE__ */ jsxs(
12943
+ "div",
12944
+ {
12945
+ ref,
12946
+ "data-slot": "toast",
12947
+ role,
12948
+ className: cn81(toastCardVariants({ variant }), className),
12949
+ children: [
12950
+ /* @__PURE__ */ jsxs("div", { "data-slot": "toast-body", className: "flex min-w-0 flex-1 flex-col gap-1", children: [
12951
+ /* @__PURE__ */ jsx("p", { "data-slot": "toast-title", className: toastTitleVariants({ variant }), children: title }),
12952
+ description !== void 0 && /* @__PURE__ */ jsx("p", { "data-slot": "toast-description", className: "text-sm text-muted-foreground", children: description }),
12953
+ action !== void 0 && /* @__PURE__ */ jsx("div", { "data-slot": "toast-action", children: action })
12954
+ ] }),
12955
+ /* @__PURE__ */ jsx(
12956
+ "button",
12957
+ {
12958
+ type: "button",
12959
+ "data-slot": "toast-dismiss-button",
12960
+ onClick: onDismiss,
12961
+ "aria-label": dismissAriaLabel,
12962
+ className: toastDismissButtonVariants(),
12963
+ children: /* @__PURE__ */ jsxs(
12964
+ "svg",
12965
+ {
12966
+ "aria-hidden": "true",
12967
+ viewBox: "0 0 24 24",
12968
+ width: "16",
12969
+ height: "16",
12970
+ fill: "none",
12971
+ stroke: "currentColor",
12972
+ strokeWidth: "2",
12973
+ strokeLinecap: "round",
12974
+ strokeLinejoin: "round",
12975
+ children: [
12976
+ /* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }),
12977
+ /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })
12978
+ ]
12979
+ }
12980
+ )
12981
+ }
12982
+ )
12983
+ ]
12984
+ }
12985
+ );
12986
+ }
12987
+ MosaicToast.displayName = "MosaicToast";
12988
+ function cn82(...classes) {
12989
+ return classes.filter(Boolean).join(" ");
12990
+ }
12991
+ function MosaicToastProvider({
12992
+ children,
12993
+ position = "top-right",
12994
+ className,
12995
+ ref
12996
+ }) {
12997
+ return /* @__PURE__ */ jsx(
12998
+ "div",
12999
+ {
13000
+ ref,
13001
+ "data-slot": "toast-provider",
13002
+ className: cn82(toastProviderPositionVariants({ position }), className),
13003
+ children
13004
+ }
13005
+ );
13006
+ }
13007
+ MosaicToastProvider.displayName = "MosaicToastProvider";
13008
+ var pdfViewerFrameVariants = cva([
13009
+ "relative min-h-64 w-full flex-1 overflow-hidden rounded-lg border border-border bg-card"
13010
+ ]);
13011
+ var pdfViewerStatusVariants = cva(
13012
+ ["flex h-full w-full flex-col items-center justify-center gap-2 p-4 text-center text-sm"],
13013
+ {
13014
+ variants: {
13015
+ tone: {
13016
+ loading: "text-muted-foreground",
13017
+ error: "text-destructive"
13018
+ }
13019
+ },
13020
+ defaultVariants: {
13021
+ tone: "loading"
13022
+ }
13023
+ }
13024
+ );
13025
+ var pdfViewerToolbarButtonVariants = cva([
13026
+ "inline-flex min-h-8 min-w-8 items-center justify-center rounded-md border border-border text-sm",
13027
+ "transition-colors hover:bg-accent/50 disabled:opacity-50 disabled:hover:bg-transparent"
13028
+ ]);
13029
+ function cn83(...classes) {
13030
+ return classes.filter(Boolean).join(" ");
13031
+ }
13032
+ function buildFrameSrc(fileUrl, currentPage, zoom) {
13033
+ const fragmentParts = [];
13034
+ if (currentPage !== void 0) fragmentParts.push(`page=${currentPage}`);
13035
+ if (zoom !== void 0) fragmentParts.push(`zoom=${Math.round(zoom * 100)}`);
13036
+ if (fragmentParts.length === 0) return fileUrl;
13037
+ const separator = fileUrl.includes("#") ? "&" : "#";
13038
+ return `${fileUrl}${separator}${fragmentParts.join("&")}`;
13039
+ }
13040
+ function MosaicPdfViewer({
13041
+ fileUrl,
13042
+ currentPage,
13043
+ onPageChange,
13044
+ totalPages,
13045
+ zoom,
13046
+ onZoomChange,
13047
+ loadingLabel,
13048
+ errorLabel,
13049
+ className,
13050
+ ref
13051
+ }) {
13052
+ const [status, setStatus] = useState("loading");
13053
+ const [trackedFileUrl, setTrackedFileUrl] = useState(fileUrl);
13054
+ const frameRef = useRef(null);
13055
+ if (fileUrl !== trackedFileUrl) {
13056
+ setTrackedFileUrl(fileUrl);
13057
+ setStatus("loading");
13058
+ }
13059
+ useEffect(() => {
13060
+ const node = frameRef.current;
13061
+ if (!node) return;
13062
+ function handleLoad() {
13063
+ setStatus("loaded");
13064
+ }
13065
+ function handleError() {
13066
+ setStatus("error");
13067
+ }
13068
+ node.addEventListener("load", handleLoad);
13069
+ node.addEventListener("error", handleError);
13070
+ return () => {
13071
+ node.removeEventListener("load", handleLoad);
13072
+ node.removeEventListener("error", handleError);
13073
+ };
13074
+ }, []);
13075
+ const showPageControls = currentPage !== void 0;
13076
+ const showZoomControls = zoom !== void 0;
13077
+ function handlePrevPage() {
13078
+ if (currentPage === void 0 || onPageChange === void 0 || currentPage <= 1) return;
13079
+ onPageChange(currentPage - 1);
13080
+ }
13081
+ function handleNextPage() {
13082
+ if (currentPage === void 0 || onPageChange === void 0) return;
13083
+ if (totalPages !== void 0 && currentPage >= totalPages) return;
13084
+ onPageChange(currentPage + 1);
13085
+ }
13086
+ function handleZoomOut() {
13087
+ if (zoom === void 0 || onZoomChange === void 0) return;
13088
+ onZoomChange(Math.round((zoom - 0.1) * 100) / 100);
13089
+ }
13090
+ function handleZoomIn() {
13091
+ if (zoom === void 0 || onZoomChange === void 0) return;
13092
+ onZoomChange(Math.round((zoom + 0.1) * 100) / 100);
13093
+ }
13094
+ return /* @__PURE__ */ jsxs("div", { ref, "data-slot": "pdf-viewer", className: cn83("flex flex-col gap-2", className), children: [
13095
+ (showPageControls || showZoomControls) && /* @__PURE__ */ jsxs(
13096
+ "div",
13097
+ {
13098
+ "data-slot": "pdf-viewer-toolbar",
13099
+ className: "flex items-center justify-between gap-2 text-sm",
13100
+ children: [
13101
+ showPageControls && /* @__PURE__ */ jsxs("div", { "data-slot": "pdf-viewer-page-controls", className: "flex items-center gap-2", children: [
13102
+ /* @__PURE__ */ jsx(
13103
+ "button",
13104
+ {
13105
+ type: "button",
13106
+ "data-slot": "pdf-viewer-prev-page-button",
13107
+ onClick: handlePrevPage,
13108
+ disabled: (currentPage ?? 1) <= 1,
13109
+ className: pdfViewerToolbarButtonVariants(),
13110
+ children: "\u2039"
13111
+ }
13112
+ ),
13113
+ /* @__PURE__ */ jsxs("span", { "data-slot": "pdf-viewer-page-indicator", children: [
13114
+ currentPage,
13115
+ totalPages !== void 0 ? ` / ${totalPages}` : ""
13116
+ ] }),
13117
+ /* @__PURE__ */ jsx(
13118
+ "button",
13119
+ {
13120
+ type: "button",
13121
+ "data-slot": "pdf-viewer-next-page-button",
13122
+ onClick: handleNextPage,
13123
+ disabled: totalPages !== void 0 && (currentPage ?? 0) >= totalPages,
13124
+ className: pdfViewerToolbarButtonVariants(),
13125
+ children: "\u203A"
13126
+ }
13127
+ )
13128
+ ] }),
13129
+ showZoomControls && /* @__PURE__ */ jsxs("div", { "data-slot": "pdf-viewer-zoom-controls", className: "flex items-center gap-2", children: [
13130
+ /* @__PURE__ */ jsx(
13131
+ "button",
13132
+ {
13133
+ type: "button",
13134
+ "data-slot": "pdf-viewer-zoom-out-button",
13135
+ onClick: handleZoomOut,
13136
+ className: pdfViewerToolbarButtonVariants(),
13137
+ children: "\u2212"
13138
+ }
13139
+ ),
13140
+ /* @__PURE__ */ jsxs("span", { "data-slot": "pdf-viewer-zoom-indicator", children: [
13141
+ Math.round((zoom ?? 1) * 100),
13142
+ "%"
13143
+ ] }),
13144
+ /* @__PURE__ */ jsx(
13145
+ "button",
13146
+ {
13147
+ type: "button",
13148
+ "data-slot": "pdf-viewer-zoom-in-button",
13149
+ onClick: handleZoomIn,
13150
+ className: pdfViewerToolbarButtonVariants(),
13151
+ children: "+"
13152
+ }
13153
+ )
13154
+ ] })
13155
+ ]
13156
+ }
13157
+ ),
13158
+ /* @__PURE__ */ jsxs("div", { "data-slot": "pdf-viewer-frame-container", className: pdfViewerFrameVariants(), children: [
13159
+ status === "loading" && /* @__PURE__ */ jsx(
13160
+ "output",
13161
+ {
13162
+ "data-slot": "pdf-viewer-loading",
13163
+ className: pdfViewerStatusVariants({ tone: "loading" }),
13164
+ children: loadingLabel
13165
+ }
13166
+ ),
13167
+ status === "error" && /* @__PURE__ */ jsx(
13168
+ "div",
13169
+ {
13170
+ "data-slot": "pdf-viewer-error",
13171
+ role: "alert",
13172
+ className: pdfViewerStatusVariants({ tone: "error" }),
13173
+ children: errorLabel
13174
+ }
13175
+ ),
13176
+ /* @__PURE__ */ jsx(
13177
+ "iframe",
13178
+ {
13179
+ ref: frameRef,
13180
+ "data-slot": "pdf-viewer-frame",
13181
+ src: buildFrameSrc(fileUrl, currentPage, zoom),
13182
+ title: fileUrl,
13183
+ className: cn83(
13184
+ "h-full min-h-64 w-full border-0",
13185
+ status !== "loaded" && "pointer-events-none absolute inset-0 opacity-0"
13186
+ )
13187
+ }
13188
+ )
13189
+ ] })
13190
+ ] });
13191
+ }
13192
+ MosaicPdfViewer.displayName = "MosaicPdfViewer";
13193
+ var splitPaneRootVariants = cva(["flex h-full w-full min-h-0"]);
13194
+ var splitPaneHandleVariants = cva([
13195
+ "relative w-1 shrink-0 cursor-col-resize touch-none select-none bg-border",
13196
+ "transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
13197
+ ]);
13198
+ var splitPaneCollapseButtonVariants = cva([
13199
+ "inline-flex h-11 w-6 shrink-0 items-center justify-center self-center rounded-md border border-border text-sm",
13200
+ "transition-colors hover:bg-accent/50"
13201
+ ]);
13202
+ function cn84(...classes) {
13203
+ return classes.filter(Boolean).join(" ");
13204
+ }
13205
+ function mergeRefs(externalRef, node) {
13206
+ if (typeof externalRef === "function") {
13207
+ externalRef(node);
13208
+ } else if (externalRef && typeof externalRef === "object") {
13209
+ externalRef.current = node;
13210
+ }
13211
+ }
13212
+ var DEFAULT_SIDE_WIDTH = 30;
13213
+ var MIN_SIDE_WIDTH = 15;
13214
+ var MAX_SIDE_WIDTH = 70;
13215
+ var KEYBOARD_STEP = 5;
13216
+ function clampSideWidth(width) {
13217
+ return Math.min(MAX_SIDE_WIDTH, Math.max(MIN_SIDE_WIDTH, width));
13218
+ }
13219
+ function MosaicResizableSplitPane({
13220
+ main,
13221
+ side,
13222
+ sideWidth = DEFAULT_SIDE_WIDTH,
13223
+ onSideWidthChange,
13224
+ isSideCollapsed = false,
13225
+ onToggleSideCollapsed,
13226
+ collapseButtonAriaLabel,
13227
+ resizeHandleAriaLabel,
13228
+ className,
13229
+ ref
13230
+ }) {
13231
+ const rootRef = useRef(null);
13232
+ const isDraggingRef = useRef(false);
13233
+ useEffect(() => {
13234
+ function handlePointerMove(event) {
13235
+ if (!isDraggingRef.current) return;
13236
+ const rootNode = rootRef.current;
13237
+ if (!rootNode || onSideWidthChange === void 0) return;
13238
+ const rect = rootNode.getBoundingClientRect();
13239
+ if (rect.width === 0) return;
13240
+ const distanceFromRight = rect.right - event.clientX;
13241
+ const rawWidth = distanceFromRight / rect.width * 100;
13242
+ onSideWidthChange(clampSideWidth(rawWidth));
13243
+ }
13244
+ function handlePointerUp() {
13245
+ isDraggingRef.current = false;
13246
+ }
13247
+ window.addEventListener("pointermove", handlePointerMove);
13248
+ window.addEventListener("pointerup", handlePointerUp);
13249
+ return () => {
13250
+ window.removeEventListener("pointermove", handlePointerMove);
13251
+ window.removeEventListener("pointerup", handlePointerUp);
13252
+ };
13253
+ }, [onSideWidthChange]);
13254
+ function handleHandlePointerDown() {
13255
+ isDraggingRef.current = true;
13256
+ }
13257
+ function handleHandleKeyDown(event) {
13258
+ if (onSideWidthChange === void 0) return;
13259
+ if (event.key === "ArrowLeft") {
13260
+ event.preventDefault();
13261
+ onSideWidthChange(clampSideWidth(sideWidth - KEYBOARD_STEP));
13262
+ } else if (event.key === "ArrowRight") {
13263
+ event.preventDefault();
13264
+ onSideWidthChange(clampSideWidth(sideWidth + KEYBOARD_STEP));
13265
+ }
13266
+ }
13267
+ return /* @__PURE__ */ jsxs(
13268
+ "div",
13269
+ {
13270
+ ref: (node) => {
13271
+ rootRef.current = node;
13272
+ mergeRefs(ref, node);
13273
+ },
13274
+ "data-slot": "resizable-split-pane",
13275
+ className: cn84(splitPaneRootVariants(), className),
13276
+ children: [
13277
+ /* @__PURE__ */ jsx("div", { "data-slot": "resizable-split-pane-main", className: "min-h-0 min-w-0 flex-1 overflow-auto", children: main }),
13278
+ !isSideCollapsed && /* @__PURE__ */ jsxs(Fragment, { children: [
13279
+ /* @__PURE__ */ jsx(
13280
+ "div",
13281
+ {
13282
+ role: "separator",
13283
+ "aria-orientation": "vertical",
13284
+ "aria-valuenow": Math.round(sideWidth),
13285
+ "aria-valuemin": MIN_SIDE_WIDTH,
13286
+ "aria-valuemax": MAX_SIDE_WIDTH,
13287
+ "aria-label": resizeHandleAriaLabel,
13288
+ tabIndex: 0,
13289
+ "data-slot": "resizable-split-pane-handle",
13290
+ onPointerDown: handleHandlePointerDown,
13291
+ onKeyDown: handleHandleKeyDown,
13292
+ className: splitPaneHandleVariants()
13293
+ }
13294
+ ),
13295
+ /* @__PURE__ */ jsx(
13296
+ "div",
13297
+ {
13298
+ "data-slot": "resizable-split-pane-side",
13299
+ style: { width: `${sideWidth}%` },
13300
+ className: "min-h-0 shrink-0 overflow-auto",
13301
+ children: side
13302
+ }
13303
+ )
13304
+ ] }),
13305
+ /* @__PURE__ */ jsx(
13306
+ "button",
13307
+ {
13308
+ type: "button",
13309
+ "data-slot": "resizable-split-pane-collapse-button",
13310
+ "aria-label": collapseButtonAriaLabel,
13311
+ "aria-expanded": !isSideCollapsed,
13312
+ onClick: onToggleSideCollapsed,
13313
+ className: splitPaneCollapseButtonVariants(),
13314
+ children: isSideCollapsed ? "\u2039" : "\u203A"
13315
+ }
13316
+ )
13317
+ ]
13318
+ }
13319
+ );
13320
+ }
13321
+ MosaicResizableSplitPane.displayName = "MosaicResizableSplitPane";
13322
+ var tagInputRootVariants = cva([
13323
+ "flex w-full flex-wrap items-center gap-1.5 rounded-md border border-border",
13324
+ "bg-background px-2 py-1.5 text-sm shadow-xs",
13325
+ "focus-within:ring-ring focus-within:ring-[3px]",
13326
+ "has-[input[aria-disabled='true']]:cursor-not-allowed has-[input[aria-disabled='true']]:opacity-50"
13327
+ ]);
13328
+ var tagInputTagVariants = cva([
13329
+ "inline-flex items-center gap-1 rounded-md bg-accent px-2 py-0.5",
13330
+ "text-sm text-accent-foreground"
13331
+ ]);
13332
+ var tagInputRemoveButtonVariants = cva([
13333
+ "inline-flex size-4 shrink-0 items-center justify-center rounded-sm",
13334
+ "text-accent-foreground/70 outline-none transition-colors",
13335
+ "hover:bg-accent-foreground/10 hover:text-accent-foreground",
13336
+ "focus-visible:ring-ring focus-visible:ring-[2px]"
13337
+ ]);
13338
+ var tagInputFieldVariants = cva([
13339
+ "min-w-[6ch] flex-1 border-none bg-transparent px-1 py-0.5 text-sm text-foreground outline-none",
13340
+ "placeholder:text-muted-foreground"
13341
+ ]);
13342
+ function cn85(...classes) {
13343
+ return classes.filter(Boolean).join(" ");
13344
+ }
13345
+ function mergeRefs2(externalRef, node) {
13346
+ if (typeof externalRef === "function") {
13347
+ externalRef(node);
13348
+ } else if (externalRef && typeof externalRef === "object") {
13349
+ externalRef.current = node;
13350
+ }
13351
+ }
13352
+ function MosaicTagInput({
13353
+ tags,
13354
+ onAddTag,
13355
+ onRemoveTag,
13356
+ placeholder,
13357
+ removeTagAriaLabel,
13358
+ suggestions,
13359
+ maxTags,
13360
+ className,
13361
+ ref
13362
+ }) {
13363
+ const [inputValue, setInputValue] = useState("");
13364
+ const inputRef = useRef(null);
13365
+ const filter = Combobox.useFilter({ sensitivity: "base" });
13366
+ const isMaxReached = maxTags !== void 0 && tags.length >= maxTags;
13367
+ const trimmedValue = inputValue.trim();
13368
+ const filteredSuggestions = useMemo(() => {
13369
+ if (!suggestions || trimmedValue.length === 0) return [];
13370
+ return suggestions.filter(
13371
+ (suggestion) => !tags.includes(suggestion) && filter.contains(suggestion, trimmedValue)
13372
+ );
13373
+ }, [suggestions, tags, trimmedValue, filter]);
13374
+ function commitTag(rawValue) {
13375
+ if (isMaxReached) return;
13376
+ const trimmed = rawValue.trim();
13377
+ if (trimmed.length === 0) return;
13378
+ if (tags.includes(trimmed)) return;
13379
+ onAddTag(trimmed);
13380
+ setInputValue("");
13381
+ }
13382
+ function handleKeyDown(event) {
13383
+ if (event.key === "Enter") {
13384
+ event.preventDefault();
13385
+ commitTag(inputValue);
13386
+ return;
13387
+ }
13388
+ if (event.key === "Backspace" && inputValue.length === 0 && tags.length > 0) {
13389
+ const lastTag = tags[tags.length - 1];
13390
+ if (lastTag !== void 0) onRemoveTag(lastTag);
13391
+ }
13392
+ }
13393
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "tag-input", className: cn85(tagInputRootVariants(), className), children: [
13394
+ tags.map((tag) => /* @__PURE__ */ jsxs("span", { "data-slot": "tag-input-tag", className: tagInputTagVariants(), children: [
13395
+ tag,
13396
+ /* @__PURE__ */ jsx(
13397
+ "button",
13398
+ {
13399
+ type: "button",
13400
+ "aria-label": removeTagAriaLabel(tag),
13401
+ "data-slot": "tag-input-remove-button",
13402
+ className: tagInputRemoveButtonVariants(),
13403
+ onClick: () => onRemoveTag(tag),
13404
+ children: "\xD7"
13405
+ }
13406
+ )
13407
+ ] }, tag)),
13408
+ /* @__PURE__ */ jsx(
13409
+ "input",
13410
+ {
13411
+ ref: (node) => {
13412
+ inputRef.current = node;
13413
+ mergeRefs2(ref, node);
13414
+ },
13415
+ type: "text",
13416
+ value: inputValue,
13417
+ placeholder,
13418
+ onChange: (event) => setInputValue(event.target.value),
13419
+ onKeyDown: handleKeyDown,
13420
+ "aria-disabled": isMaxReached ? true : void 0,
13421
+ "data-max-reached": isMaxReached ? true : void 0,
13422
+ "data-slot": "tag-input-field",
13423
+ className: tagInputFieldVariants()
13424
+ }
13425
+ ),
13426
+ filteredSuggestions.length > 0 && /* @__PURE__ */ jsx(
13427
+ "ul",
13428
+ {
13429
+ "data-slot": "tag-input-suggestions",
13430
+ className: cn85(
13431
+ "z-50 mt-1 w-full min-w-[8rem] overflow-hidden rounded-md border border-border",
13432
+ "bg-popover p-1 text-sm text-popover-foreground shadow-md"
13433
+ ),
13434
+ children: filteredSuggestions.map((suggestion) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
13435
+ "button",
13436
+ {
13437
+ type: "button",
13438
+ "data-slot": "tag-input-suggestion",
13439
+ className: "w-full cursor-pointer select-none rounded-sm px-2 py-1.5 text-left outline-none hover:bg-accent hover:text-accent-foreground focus-visible:ring-ring focus-visible:ring-[2px]",
13440
+ onClick: () => commitTag(suggestion),
13441
+ children: suggestion
13442
+ }
13443
+ ) }, suggestion))
13444
+ }
13445
+ )
13446
+ ] });
13447
+ }
13448
+ MosaicTagInput.displayName = "MosaicTagInput";
12840
13449
 
12841
- export { MosaicAccordion, MosaicAccordionItem, MosaicAccordionPanel, MosaicAccordionTrigger, MosaicActivityFeed, MosaicActivityItem, MosaicAdaptiveGrid, MosaicAdaptiveModal, MosaicAdaptiveNavigation, MosaicAgentCard, MosaicAgentChat, MosaicAgentComposer, MosaicAgentComposerDesktop, MosaicAgentComposerMobile, MosaicAgentList, AgentListDesktop as MosaicAgentListDesktop, AgentListMobile as MosaicAgentListMobile, MosaicAgentTeamPreview, MosaicAnimatedList, MosaicApiKeyPanel, MosaicAppSidebar, MosaicApprovalPrompt, MosaicAvatar, MosaicBadge, MosaicBlurredOrb, MosaicButton, MosaicCard, MosaicCardContent, MosaicCardDescription, MosaicCardFooter, MosaicCardHeader, MosaicCardTitle, MosaicChatComposer, MosaicChatMessage, MosaicChatThread, MosaicCheckbox, MosaicClerkOrgSwitcher, MosaicClerkWebhookHandler, MosaicCollapsible, MosaicCollapsiblePanel, MosaicCollapsibleTrigger, MosaicCombobox, MosaicCounter, MosaicCreateOrgDialog, MosaicDashboardContent, MosaicDashboardHeader, MosaicDashboardLayout, MosaicDataTable, MosaicDeleteConfirmationDialog, MosaicDeviceProvider, MosaicDocumentUpload, MosaicDropdownMenu, MosaicEmptyState, MosaicFallingPattern, MosaicFeature3Col, MosaicFeatureCenteredMedia, MosaicField, MosaicFieldControl, MosaicFieldDescription, MosaicFieldError, MosaicFieldLabel, MosaicFilterBar, MosaicFilterSidebar, MosaicFooterSimple, MosaicHeroSplit, MosaicInput, MosaicInputGroup, MosaicIntegrationsBadge, MosaicInviteMemberDialog, MosaicKanbanBoard, MosaicKanbanColumn, MosaicLogosGrid, MosaicMainNav, MosaicMarkdown, MosaicMarketplaceList, MarketplaceListDesktop as MosaicMarketplaceListDesktop, MarketplaceListMobile as MosaicMarketplaceListMobile, MosaicMemberList, MosaicMemoryCard, MosaicMessageCard, MosaicMessageList, MessageListDesktop as MosaicMessageListDesktop, MessageListMobile as MosaicMessageListMobile, MosaicModuleCard, MosaicModuleForm, MosaicModuleLibrary, MosaicMultiOrgIndicator, MosaicMultiTenantProvider, MosaicNavbar, MosaicOrgPanel, MosaicOrgProfilePage, MosaicOrgRoleBadge, MosaicOrgSwitcher, MosaicPreferencesPanel, MosaicPricingCard, MosaicProfilePanel, MosaicProgress, MosaicQuickActionCard, MosaicQuickActionsMenu, MosaicQuickAgentSelector, MosaicQuickStartPanel, MosaicRadioGroup, MosaicRadioGroupItem, MosaicScrollArea, MosaicSelect, MosaicSelectorModal, MosaicSeparator, MosaicSignInLayout, MosaicSignUpLayout, MosaicSkeleton, MosaicSlider, MosaicStatsGrid, MosaicStepPipeline, MosaicSwitch, MosaicTabs, MosaicTabsList, MosaicTabsPanel, MosaicTabsTrigger, MosaicTemplateCard, MosaicTemplateGallery, MosaicTemplatePreview, MosaicTestimonialsGrid, MosaicTextarea, MosaicThemeProvider, MosaicThemeToggle, MosaicToolToggleList, MosaicTooltip, MosaicTooltipContent, MosaicTooltipProvider, MosaicTooltipRoot, MosaicTooltipTrigger, MosaicUrlScraper, MosaicUserButton, Placeholder, agentChatRootVariants, badgeVariants, buttonVariants, chatMessageBubbleVariants, chatMessageContainerVariants, chatMessageToolStatusVariants, skeletonVariants, toolToggleListRowVariants, toolToggleListSectionVariants, useBreakpoint, useDevice, useMosaicWorkspace as useEffectiveWorkspaceId, useIsDesktop, useIsMobile, useIsTablet, useMediaQuery, useMosaicWorkspace, useOrientation, useViewport, version };
13450
+ export { MosaicAccordion, MosaicAccordionItem, MosaicAccordionPanel, MosaicAccordionTrigger, MosaicActivityFeed, MosaicActivityItem, MosaicAdaptiveGrid, MosaicAdaptiveModal, MosaicAdaptiveNavigation, MosaicAgentCard, MosaicAgentChat, MosaicAgentComposer, MosaicAgentComposerDesktop, MosaicAgentComposerMobile, MosaicAgentList, AgentListDesktop as MosaicAgentListDesktop, AgentListMobile as MosaicAgentListMobile, MosaicAgentTeamPreview, MosaicAnimatedList, MosaicApiKeyPanel, MosaicAppSidebar, MosaicApprovalPrompt, MosaicAvatar, MosaicBadge, MosaicBlurredOrb, MosaicButton, MosaicCard, MosaicCardContent, MosaicCardDescription, MosaicCardFooter, MosaicCardHeader, MosaicCardTitle, MosaicChatComposer, MosaicChatMessage, MosaicChatThread, MosaicCheckbox, MosaicClerkOrgSwitcher, MosaicClerkWebhookHandler, MosaicCollapsible, MosaicCollapsiblePanel, MosaicCollapsibleTrigger, MosaicCombobox, MosaicCounter, MosaicCreateOrgDialog, MosaicDashboardContent, MosaicDashboardHeader, MosaicDashboardLayout, MosaicDataTable, MosaicDeleteConfirmationDialog, MosaicDeviceProvider, MosaicDocumentUpload, MosaicDropdownMenu, MosaicEmptyState, MosaicFallingPattern, MosaicFeature3Col, MosaicFeatureCenteredMedia, MosaicField, MosaicFieldControl, MosaicFieldDescription, MosaicFieldError, MosaicFieldLabel, MosaicFilterBar, MosaicFilterSidebar, MosaicFooterSimple, MosaicHeroSplit, MosaicInput, MosaicInputGroup, MosaicIntegrationsBadge, MosaicInviteMemberDialog, MosaicKanbanBoard, MosaicKanbanColumn, MosaicLogosGrid, MosaicMainNav, MosaicMarkdown, MosaicMarketplaceList, MarketplaceListDesktop as MosaicMarketplaceListDesktop, MarketplaceListMobile as MosaicMarketplaceListMobile, MosaicMemberList, MosaicMemoryCard, MosaicMessageCard, MosaicMessageList, MessageListDesktop as MosaicMessageListDesktop, MessageListMobile as MosaicMessageListMobile, MosaicModuleCard, MosaicModuleForm, MosaicModuleLibrary, MosaicMultiOrgIndicator, MosaicMultiTenantProvider, MosaicNavbar, MosaicOrgPanel, MosaicOrgProfilePage, MosaicOrgRoleBadge, MosaicOrgSwitcher, MosaicPdfViewer, MosaicPreferencesPanel, MosaicPricingCard, MosaicProfilePanel, MosaicProgress, MosaicQuickActionCard, MosaicQuickActionsMenu, MosaicQuickAgentSelector, MosaicQuickStartPanel, MosaicRadioGroup, MosaicRadioGroupItem, MosaicResizableSplitPane, MosaicScrollArea, MosaicSelect, MosaicSelectorModal, MosaicSeparator, MosaicSignInLayout, MosaicSignUpLayout, MosaicSkeleton, MosaicSlider, MosaicStatsGrid, MosaicStepPipeline, MosaicSwitch, MosaicTabs, MosaicTabsList, MosaicTabsPanel, MosaicTabsTrigger, MosaicTagInput, MosaicTemplateCard, MosaicTemplateGallery, MosaicTemplatePreview, MosaicTestimonialsGrid, MosaicTextarea, MosaicThemeProvider, MosaicThemeToggle, MosaicToast, MosaicToastProvider, MosaicToolToggleList, MosaicTooltip, MosaicTooltipContent, MosaicTooltipProvider, MosaicTooltipRoot, MosaicTooltipTrigger, MosaicUrlScraper, MosaicUserButton, Placeholder, agentChatRootVariants, badgeVariants, buttonVariants, chatMessageBubbleVariants, chatMessageContainerVariants, chatMessageToolStatusVariants, pdfViewerFrameVariants, pdfViewerStatusVariants, pdfViewerToolbarButtonVariants, skeletonVariants, splitPaneCollapseButtonVariants, splitPaneHandleVariants, splitPaneRootVariants, tagInputFieldVariants, tagInputRemoveButtonVariants, tagInputRootVariants, tagInputTagVariants, toastCardVariants, toastDismissButtonVariants, toastProviderPositionVariants, toastTitleVariants, toolToggleListRowVariants, toolToggleListSectionVariants, useBreakpoint, useDevice, useMosaicWorkspace as useEffectiveWorkspaceId, useIsDesktop, useIsMobile, useIsTablet, useMediaQuery, useMosaicWorkspace, useOrientation, useViewport, version };
12842
13451
  //# sourceMappingURL=index.js.map
12843
13452
  //# sourceMappingURL=index.js.map