@meshagent/meshagent-tailwind 0.5.7 → 0.5.8

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 (95) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/dist/cjs/Chat.js +28 -5
  3. package/dist/cjs/ChatInput.d.ts +4 -1
  4. package/dist/cjs/ChatInput.js +15 -3
  5. package/dist/cjs/ChatThread.js +1 -0
  6. package/dist/cjs/ChatTypingIndicator.js +2 -2
  7. package/dist/cjs/components/pane-example.d.ts +1 -0
  8. package/dist/cjs/components/pane-example.js +43 -0
  9. package/dist/cjs/components/ui/dialog.d.ts +15 -0
  10. package/dist/cjs/components/ui/dialog.js +166 -0
  11. package/dist/cjs/components/ui/form.d.ts +24 -0
  12. package/dist/cjs/components/ui/form.js +146 -0
  13. package/dist/cjs/components/ui/input.d.ts +3 -0
  14. package/dist/cjs/components/ui/input.js +41 -0
  15. package/dist/cjs/components/ui/label.d.ts +4 -0
  16. package/dist/cjs/components/ui/label.js +53 -0
  17. package/dist/cjs/components/ui/radio-group.d.ts +5 -0
  18. package/dist/cjs/components/ui/radio-group.js +76 -0
  19. package/dist/cjs/components/ui/select.d.ts +15 -0
  20. package/dist/cjs/components/ui/select.js +199 -0
  21. package/dist/cjs/components/ui/sheet.d.ts +13 -0
  22. package/dist/cjs/components/ui/sheet.js +110 -0
  23. package/dist/cjs/components/ui/sonner.d.ts +3 -0
  24. package/dist/cjs/components/ui/sonner.js +42 -0
  25. package/dist/cjs/lib/pane-service.d.ts +16 -0
  26. package/dist/cjs/lib/pane-service.js +35 -0
  27. package/dist/cjs/lib/utils.d.ts +4 -0
  28. package/dist/cjs/tools/ask-user-for-file.d.ts +10 -0
  29. package/dist/cjs/tools/ask-user-for-file.js +68 -0
  30. package/dist/cjs/tools/ask-user.d.ts +10 -0
  31. package/dist/cjs/tools/ask-user.js +161 -0
  32. package/dist/cjs/tools/build-schema.d.ts +3 -0
  33. package/dist/cjs/tools/build-schema.js +55 -0
  34. package/dist/cjs/tools/display-document.d.ts +10 -0
  35. package/dist/cjs/tools/display-document.js +49 -0
  36. package/dist/cjs/tools/file-dialog.d.ts +11 -0
  37. package/dist/cjs/tools/file-dialog.js +113 -0
  38. package/dist/cjs/tools/form-dialog.d.ts +12 -0
  39. package/dist/cjs/tools/form-dialog.js +92 -0
  40. package/dist/cjs/tools/form-schema.d.ts +41 -0
  41. package/dist/cjs/tools/form-schema.js +51 -0
  42. package/dist/cjs/tools/form.d.ts +16 -0
  43. package/dist/cjs/tools/form.js +81 -0
  44. package/dist/cjs/tools/toast.d.ts +10 -0
  45. package/dist/cjs/tools/toast.js +52 -0
  46. package/dist/cjs/tools/ui-toolkit.d.ts +6 -0
  47. package/dist/cjs/tools/ui-toolkit.js +44 -0
  48. package/dist/esm/Chat.js +29 -6
  49. package/dist/esm/ChatInput.d.ts +4 -1
  50. package/dist/esm/ChatInput.js +15 -3
  51. package/dist/esm/ChatThread.js +1 -0
  52. package/dist/esm/ChatTypingIndicator.js +2 -2
  53. package/dist/esm/components/pane-example.d.ts +1 -0
  54. package/dist/esm/components/pane-example.js +30 -0
  55. package/dist/esm/components/ui/dialog.d.ts +15 -0
  56. package/dist/esm/components/ui/dialog.js +136 -0
  57. package/dist/esm/components/ui/form.d.ts +24 -0
  58. package/dist/esm/components/ui/form.js +121 -0
  59. package/dist/esm/components/ui/input.d.ts +3 -0
  60. package/dist/esm/components/ui/input.js +21 -0
  61. package/dist/esm/components/ui/label.d.ts +4 -0
  62. package/dist/esm/components/ui/label.js +23 -0
  63. package/dist/esm/components/ui/radio-group.d.ts +5 -0
  64. package/dist/esm/components/ui/radio-group.js +46 -0
  65. package/dist/esm/components/ui/select.d.ts +15 -0
  66. package/dist/esm/components/ui/select.js +169 -0
  67. package/dist/esm/components/ui/sheet.d.ts +13 -0
  68. package/dist/esm/components/ui/sheet.js +80 -0
  69. package/dist/esm/components/ui/sonner.d.ts +3 -0
  70. package/dist/esm/components/ui/sonner.js +22 -0
  71. package/dist/esm/lib/pane-service.d.ts +16 -0
  72. package/dist/esm/lib/pane-service.js +15 -0
  73. package/dist/esm/lib/utils.d.ts +4 -0
  74. package/dist/esm/tools/ask-user-for-file.d.ts +10 -0
  75. package/dist/esm/tools/ask-user-for-file.js +48 -0
  76. package/dist/esm/tools/ask-user.d.ts +10 -0
  77. package/dist/esm/tools/ask-user.js +141 -0
  78. package/dist/esm/tools/build-schema.d.ts +3 -0
  79. package/dist/esm/tools/build-schema.js +25 -0
  80. package/dist/esm/tools/display-document.d.ts +10 -0
  81. package/dist/esm/tools/display-document.js +29 -0
  82. package/dist/esm/tools/file-dialog.d.ts +11 -0
  83. package/dist/esm/tools/file-dialog.js +101 -0
  84. package/dist/esm/tools/form-dialog.d.ts +12 -0
  85. package/dist/esm/tools/form-dialog.js +79 -0
  86. package/dist/esm/tools/form-schema.d.ts +41 -0
  87. package/dist/esm/tools/form-schema.js +31 -0
  88. package/dist/esm/tools/form.d.ts +16 -0
  89. package/dist/esm/tools/form.js +64 -0
  90. package/dist/esm/tools/toast.d.ts +10 -0
  91. package/dist/esm/tools/toast.js +32 -0
  92. package/dist/esm/tools/ui-toolkit.d.ts +6 -0
  93. package/dist/esm/tools/ui-toolkit.js +24 -0
  94. package/dist/index.css +1 -1
  95. package/package.json +7 -4
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var form_exports = {};
20
+ __export(form_exports, {
21
+ FormField: () => FormField
22
+ });
23
+ module.exports = __toCommonJS(form_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_react = require("react");
26
+ var import_react_hook_form = require("react-hook-form");
27
+ var import_form_schema = require("./form-schema");
28
+ function FormField({ fieldItem, control }) {
29
+ const field = (0, import_react.useMemo)(() => (0, import_form_schema.getFormField)(fieldItem), [fieldItem]);
30
+ const fieldKey = (0, import_react.useMemo)(() => (0, import_form_schema.getFormFieldType)(fieldItem), [fieldItem]);
31
+ const { field: controllerField } = (0, import_react_hook_form.useController)({
32
+ name: field.name,
33
+ control,
34
+ defaultValue: field.default_value
35
+ });
36
+ switch (fieldKey) {
37
+ case "checkbox": {
38
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "flex items-center space-x-2", children: [
39
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
40
+ "input",
41
+ {
42
+ type: "checkbox",
43
+ checked: controllerField.value,
44
+ onChange: (e) => controllerField.onChange(e.target.checked)
45
+ }
46
+ ),
47
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: field.description })
48
+ ] });
49
+ }
50
+ case "radio_group": {
51
+ const f2 = field;
52
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
53
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "block font-medium mb-1", children: field.description }),
54
+ (f2.options ?? []).map((opt) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "flex items-center space-x-2", children: [
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
+ "input",
57
+ {
58
+ type: "radio",
59
+ value: opt.value,
60
+ checked: controllerField.value === opt.value,
61
+ onChange: () => controllerField.onChange(opt.value)
62
+ }
63
+ ),
64
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: opt.name })
65
+ ] }, opt.value))
66
+ ] });
67
+ }
68
+ case "select": {
69
+ const f2 = field;
70
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
71
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "block font-medium mb-1", children: field.description }),
72
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { ...controllerField, className: "border p-2 w-full rounded", children: (f2.options ?? []).map((opt) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: opt.value, children: opt.name }, opt.value)) })
73
+ ] });
74
+ }
75
+ }
76
+ const f = field;
77
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-1", children: [
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "block font-medium", children: f.description }),
79
+ f.multiline ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { ...controllerField, className: "border p-2 w-full rounded" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "text", ...controllerField, className: "border p-2 w-full rounded" })
80
+ ] });
81
+ }
@@ -0,0 +1,10 @@
1
+ import { Tool } from '@meshagent/meshagent';
2
+ import type { Response } from '@meshagent/meshagent';
3
+ export declare class Toast extends Tool {
4
+ constructor({ name, description, title }?: {
5
+ name?: string;
6
+ description?: string;
7
+ title?: string;
8
+ });
9
+ execute(arguments_: Record<string, any>): Promise<Response>;
10
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var toast_exports = {};
20
+ __export(toast_exports, {
21
+ Toast: () => Toast
22
+ });
23
+ module.exports = __toCommonJS(toast_exports);
24
+ var import_meshagent = require("@meshagent/meshagent");
25
+ var import_sonner = require("sonner");
26
+ const toastSchema = {
27
+ type: "object",
28
+ additionalProperties: false,
29
+ required: ["title", "description"],
30
+ properties: {
31
+ title: {
32
+ type: "string",
33
+ description: "a very short summary suitable for a toast title"
34
+ }
35
+ }
36
+ };
37
+ class Toast extends import_meshagent.Tool {
38
+ constructor({ name, description, title } = {}) {
39
+ super({
40
+ name: name ?? "show_toast",
41
+ description: description ?? "let the user know something important (will be shown as a toast)",
42
+ title: title ?? "show user a toast",
43
+ inputSchema: toastSchema
44
+ });
45
+ }
46
+ async execute(arguments_) {
47
+ (0, import_sonner.toast)(arguments_.title, {
48
+ description: arguments_.description ?? ""
49
+ });
50
+ return new import_meshagent.EmptyResponse();
51
+ }
52
+ }
@@ -0,0 +1,6 @@
1
+ import { RoomClient, RemoteToolkit } from '@meshagent/meshagent';
2
+ export declare class UIToolkit extends RemoteToolkit {
3
+ constructor({ room }: {
4
+ room: RoomClient;
5
+ });
6
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var ui_toolkit_exports = {};
20
+ __export(ui_toolkit_exports, {
21
+ UIToolkit: () => UIToolkit
22
+ });
23
+ module.exports = __toCommonJS(ui_toolkit_exports);
24
+ var import_meshagent = require("@meshagent/meshagent");
25
+ var import_ask_user = require("./ask-user");
26
+ var import_ask_user_for_file = require("./ask-user-for-file");
27
+ var import_display_document = require("./display-document");
28
+ var import_toast = require("./toast");
29
+ class UIToolkit extends import_meshagent.RemoteToolkit {
30
+ constructor({ room }) {
31
+ super({
32
+ name: "ui",
33
+ title: "UI Tools",
34
+ description: "User interface tools",
35
+ room,
36
+ tools: [
37
+ new import_ask_user.AskUser(),
38
+ new import_ask_user_for_file.AskUserForFile(),
39
+ new import_toast.Toast(),
40
+ new import_display_document.DisplayDocument()
41
+ ]
42
+ });
43
+ }
44
+ }
package/dist/esm/Chat.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useChat } from "@meshagent/meshagent-react";
2
+ import { useMemo, useCallback } from "react";
3
+ import { useChat, useClientToolkits, useRoomIndicators } from "@meshagent/meshagent-react";
3
4
  import { ChatThread } from "./ChatThread";
4
5
  import { ChatInput } from "./ChatInput";
5
6
  import { ChatTypingIndicator } from "./ChatTypingIndicator";
7
+ import { UIToolkit } from "./tools/ui-toolkit";
8
+ import { Toaster } from "./components/ui/sonner";
6
9
  function Chat({ room, path, participants }) {
7
10
  const {
8
11
  messages,
@@ -10,11 +13,27 @@ function Chat({ room, path, participants }) {
10
13
  selectAttachments,
11
14
  attachments,
12
15
  setAttachments,
13
- schemaFileExists
16
+ schemaFileExists,
17
+ cancelRequest
14
18
  } = useChat({ room, path, participants });
15
- const localParticipantName = room.localParticipant.getAttribute("name");
19
+ const { thinking } = useRoomIndicators({ room, path });
20
+ const toolkits = useMemo(() => [
21
+ new UIToolkit({ room })
22
+ ], [room]);
23
+ useClientToolkits({ toolkits, public: true });
24
+ const onTextChange = useCallback((_) => {
25
+ const removeParticipant = room.messaging.remoteParticipants;
26
+ for (const part of removeParticipant) {
27
+ room.messaging.sendMessage({
28
+ to: part,
29
+ type: "typing",
30
+ message: { path }
31
+ });
32
+ }
33
+ }, [room, path]);
34
+ const localParticipantName = room.localParticipant?.getAttribute("name");
16
35
  if (schemaFileExists === false) {
17
- return /* @__PURE__ */ jsx("div", { className: "flex flex-col flex-1 min-h-0 gap-2 p-4", children: /* @__PURE__ */ jsx("p", { className: "text-red-500", children: 'No AI agent found in this room. Run `meshagent chatbot join --room [room-name] --agent-name "Chat Agent" --name "Chat Friend" and try again.' }) });
36
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col flex-1 min-h-0 gap-2 p-4", children: /* @__PURE__ */ jsx("p", { className: "text-red-500", children: 'No AI agent found in this room. Run `meshagent chatbot join --room [room-name] --agent-name "Chat Agent" --name "Chat Friend"` and try again.' }) });
18
37
  }
19
38
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1 min-h-0 gap-2 p-0", children: [
20
39
  /* @__PURE__ */ jsx(
@@ -32,9 +51,13 @@ function Chat({ room, path, participants }) {
32
51
  onSubmit: sendMessage,
33
52
  attachments,
34
53
  onFilesSelected: selectAttachments,
35
- setAttachments
54
+ setAttachments,
55
+ onTextChange,
56
+ onCancelRequest: cancelRequest,
57
+ showCancelButton: thinking
36
58
  }
37
- )
59
+ ),
60
+ /* @__PURE__ */ jsx(Toaster, {})
38
61
  ] });
39
62
  }
40
63
  export {
@@ -4,6 +4,9 @@ interface ChatInputProps {
4
4
  onFilesSelected: (files: File[]) => void;
5
5
  attachments: FileUpload[];
6
6
  setAttachments: (attachments: FileUpload[]) => void;
7
+ onTextChange?: (text: string) => void;
8
+ onCancelRequest?: () => void;
9
+ showCancelButton?: boolean;
7
10
  }
8
- export declare function ChatInput({ onSubmit, onFilesSelected, attachments, setAttachments }: ChatInputProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function ChatInput({ onSubmit, onFilesSelected, attachments, setAttachments, onTextChange, onCancelRequest, showCancelButton }: ChatInputProps): import("react/jsx-runtime").JSX.Element;
9
12
  export {};
@@ -6,7 +6,15 @@ import { Button } from "./components/ui/button";
6
6
  import { Textarea } from "./components/ui/textarea";
7
7
  import { FileUploader } from "./FileUploader";
8
8
  import { UploadPill } from "./UploadPill";
9
- function ChatInput({ onSubmit, onFilesSelected, attachments, setAttachments }) {
9
+ function ChatInput({
10
+ onSubmit,
11
+ onFilesSelected,
12
+ attachments,
13
+ setAttachments,
14
+ onTextChange,
15
+ onCancelRequest,
16
+ showCancelButton
17
+ }) {
10
18
  const [value, setValue] = React.useState("");
11
19
  const handleSend = useCallback(() => {
12
20
  const trimmed2 = value.trim();
@@ -30,6 +38,10 @@ function ChatInput({ onSubmit, onFilesSelected, attachments, setAttachments }) {
30
38
  const cancelAttachment = useCallback((attachment) => {
31
39
  setAttachments(attachments.filter((f) => f.path !== attachment.path));
32
40
  }, [attachments, setAttachments]);
41
+ const _onChange = useCallback((e) => {
42
+ setValue(e.currentTarget.value);
43
+ onTextChange?.(e.currentTarget.value);
44
+ }, [onTextChange]);
33
45
  const trimmed = value.trim();
34
46
  const disabled = !trimmed && attachments.length === 0;
35
47
  return /* @__PURE__ */ jsxs("div", { className: "border-t py-3 gap-3 flex flex-col", children: [
@@ -49,11 +61,11 @@ function ChatInput({ onSubmit, onFilesSelected, attachments, setAttachments }) {
49
61
  placeholder: "Type a message and press Enter",
50
62
  className: "flex-1 resize-none h-20",
51
63
  value,
52
- onChange: (e) => setValue(e.currentTarget.value),
64
+ onChange: _onChange,
53
65
  onKeyDown
54
66
  }
55
67
  ),
56
- /* @__PURE__ */ jsx(Button, { onClick: handleSend, disabled, children: "Send" })
68
+ showCancelButton === true ? /* @__PURE__ */ jsx(Button, { onClick: onCancelRequest, children: "Cancel" }) : /* @__PURE__ */ jsx(Button, { onClick: handleSend, disabled, children: "Send" })
57
69
  ] })
58
70
  ] });
59
71
  }
@@ -25,6 +25,7 @@ function timeAgo(iso) {
25
25
  const rtf = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
26
26
  const date = new Date(iso);
27
27
  const now = /* @__PURE__ */ new Date();
28
+ if (isNaN(date.getTime())) return "";
28
29
  const seconds = Math.round((date.getTime() - now.getTime()) / 1e3);
29
30
  const minutes = Math.round(seconds / 60);
30
31
  const hours = Math.round(minutes / 60);
@@ -1,8 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useRoomIndicators } from "@meshagent/meshagent-react";
3
3
  function ChatTypingIndicator({ room, path }) {
4
- const { typing } = useRoomIndicators({ room, path });
5
- return typing ? /* @__PURE__ */ jsxs("div", { className: "flex items-end space-x-1 h-6 p-6", children: [
4
+ const { typing, thinking } = useRoomIndicators({ room, path });
5
+ return typing || thinking ? /* @__PURE__ */ jsxs("div", { className: "flex items-end space-x-1 h-6 p-6", children: [
6
6
  [0, 1, 2].map((index) => /* @__PURE__ */ jsx(
7
7
  "span",
8
8
  {
@@ -0,0 +1 @@
1
+ export default function PaneExample(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState, useEffect } from "react";
4
+ import { Button } from "@/components/ui/button";
5
+ import {
6
+ Sheet,
7
+ SheetContent,
8
+ SheetHeader,
9
+ SheetTitle,
10
+ SheetDescription,
11
+ SheetFooter
12
+ } from "@/components/ui/sheet";
13
+ import { registerPane, closePane } from "@/lib/pane-service";
14
+ function PaneExample() {
15
+ const [open, setOpen] = useState(false);
16
+ useEffect(() => {
17
+ registerPane(setOpen);
18
+ }, []);
19
+ return /* @__PURE__ */ jsx(Sheet, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(SheetContent, { side: "right", className: "w-full sm:w-[700px] sm:max-w-1/2", children: [
20
+ /* @__PURE__ */ jsxs(SheetHeader, { children: [
21
+ /* @__PURE__ */ jsx(SheetTitle, { children: "My Side Pane" }),
22
+ /* @__PURE__ */ jsx(SheetDescription, { children: "Here's a panel you can open/close programmatically." })
23
+ ] }),
24
+ /* @__PURE__ */ jsx("div", { className: "p-4 space-y-4 flex-1 overflow-auto p-4 space-y-4", children: /* @__PURE__ */ jsx("p", { children: "This is the pane content area. Add any React nodes here." }) }),
25
+ /* @__PURE__ */ jsx(SheetFooter, { children: /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: closePane, children: "Close Pane" }) })
26
+ ] }) });
27
+ }
28
+ export {
29
+ PaneExample as default
30
+ };
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
3
+ declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
+ declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
5
+ declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
6
+ declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): import("react/jsx-runtime").JSX.Element;
7
+ declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): import("react/jsx-runtime").JSX.Element;
8
+ declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
9
+ showCloseButton?: boolean;
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ declare function DialogHeader({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
12
+ declare function DialogFooter({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
13
+ declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
14
+ declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
15
+ export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };
@@ -0,0 +1,136 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
3
+ import { XIcon } from "lucide-react";
4
+ import { cn } from "@/lib/utils";
5
+ function Dialog({
6
+ ...props
7
+ }) {
8
+ return /* @__PURE__ */ jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
9
+ }
10
+ function DialogTrigger({
11
+ ...props
12
+ }) {
13
+ return /* @__PURE__ */ jsx(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
14
+ }
15
+ function DialogPortal({
16
+ ...props
17
+ }) {
18
+ return /* @__PURE__ */ jsx(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
19
+ }
20
+ function DialogClose({
21
+ ...props
22
+ }) {
23
+ return /* @__PURE__ */ jsx(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
24
+ }
25
+ function DialogOverlay({
26
+ className,
27
+ ...props
28
+ }) {
29
+ return /* @__PURE__ */ jsx(
30
+ DialogPrimitive.Overlay,
31
+ {
32
+ "data-slot": "dialog-overlay",
33
+ className: cn(
34
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
35
+ className
36
+ ),
37
+ ...props
38
+ }
39
+ );
40
+ }
41
+ function DialogContent({
42
+ className,
43
+ children,
44
+ showCloseButton = true,
45
+ ...props
46
+ }) {
47
+ return /* @__PURE__ */ jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [
48
+ /* @__PURE__ */ jsx(DialogOverlay, {}),
49
+ /* @__PURE__ */ jsxs(
50
+ DialogPrimitive.Content,
51
+ {
52
+ "data-slot": "dialog-content",
53
+ className: cn(
54
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
55
+ className
56
+ ),
57
+ ...props,
58
+ children: [
59
+ children,
60
+ showCloseButton && /* @__PURE__ */ jsxs(
61
+ DialogPrimitive.Close,
62
+ {
63
+ "data-slot": "dialog-close",
64
+ className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
65
+ children: [
66
+ /* @__PURE__ */ jsx(XIcon, {}),
67
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
68
+ ]
69
+ }
70
+ )
71
+ ]
72
+ }
73
+ )
74
+ ] });
75
+ }
76
+ function DialogHeader({ className, ...props }) {
77
+ return /* @__PURE__ */ jsx(
78
+ "div",
79
+ {
80
+ "data-slot": "dialog-header",
81
+ className: cn("flex flex-col gap-2 text-center sm:text-left", className),
82
+ ...props
83
+ }
84
+ );
85
+ }
86
+ function DialogFooter({ className, ...props }) {
87
+ return /* @__PURE__ */ jsx(
88
+ "div",
89
+ {
90
+ "data-slot": "dialog-footer",
91
+ className: cn(
92
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
93
+ className
94
+ ),
95
+ ...props
96
+ }
97
+ );
98
+ }
99
+ function DialogTitle({
100
+ className,
101
+ ...props
102
+ }) {
103
+ return /* @__PURE__ */ jsx(
104
+ DialogPrimitive.Title,
105
+ {
106
+ "data-slot": "dialog-title",
107
+ className: cn("text-lg leading-none font-semibold", className),
108
+ ...props
109
+ }
110
+ );
111
+ }
112
+ function DialogDescription({
113
+ className,
114
+ ...props
115
+ }) {
116
+ return /* @__PURE__ */ jsx(
117
+ DialogPrimitive.Description,
118
+ {
119
+ "data-slot": "dialog-description",
120
+ className: cn("text-muted-foreground text-sm", className),
121
+ ...props
122
+ }
123
+ );
124
+ }
125
+ export {
126
+ Dialog,
127
+ DialogClose,
128
+ DialogContent,
129
+ DialogDescription,
130
+ DialogFooter,
131
+ DialogHeader,
132
+ DialogOverlay,
133
+ DialogPortal,
134
+ DialogTitle,
135
+ DialogTrigger
136
+ };
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import * as LabelPrimitive from "@radix-ui/react-label";
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import { type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
5
+ declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
6
+ declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => import("react/jsx-runtime").JSX.Element;
7
+ declare const useFormField: () => {
8
+ invalid: boolean;
9
+ isDirty: boolean;
10
+ isTouched: boolean;
11
+ isValidating: boolean;
12
+ error?: import("react-hook-form").FieldError;
13
+ id: string;
14
+ name: string;
15
+ formItemId: string;
16
+ formDescriptionId: string;
17
+ formMessageId: string;
18
+ };
19
+ declare function FormItem({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
20
+ declare function FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
21
+ declare function FormControl({ ...props }: React.ComponentProps<typeof Slot>): import("react/jsx-runtime").JSX.Element;
22
+ declare function FormDescription({ className, ...props }: React.ComponentProps<"p">): import("react/jsx-runtime").JSX.Element;
23
+ declare function FormMessage({ className, ...props }: React.ComponentProps<"p">): import("react/jsx-runtime").JSX.Element | null;
24
+ export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, };
@@ -0,0 +1,121 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import {
5
+ Controller,
6
+ FormProvider,
7
+ useFormContext,
8
+ useFormState
9
+ } from "react-hook-form";
10
+ import { cn } from "@/lib/utils";
11
+ import { Label } from "@/components/ui/label";
12
+ const Form = FormProvider;
13
+ const FormFieldContext = React.createContext(
14
+ {}
15
+ );
16
+ const FormField = ({
17
+ ...props
18
+ }) => {
19
+ return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
20
+ };
21
+ const useFormField = () => {
22
+ const fieldContext = React.useContext(FormFieldContext);
23
+ const itemContext = React.useContext(FormItemContext);
24
+ const { getFieldState } = useFormContext();
25
+ const formState = useFormState({ name: fieldContext.name });
26
+ const fieldState = getFieldState(fieldContext.name, formState);
27
+ if (!fieldContext) {
28
+ throw new Error("useFormField should be used within <FormField>");
29
+ }
30
+ const { id } = itemContext;
31
+ return {
32
+ id,
33
+ name: fieldContext.name,
34
+ formItemId: `${id}-form-item`,
35
+ formDescriptionId: `${id}-form-item-description`,
36
+ formMessageId: `${id}-form-item-message`,
37
+ ...fieldState
38
+ };
39
+ };
40
+ const FormItemContext = React.createContext(
41
+ {}
42
+ );
43
+ function FormItem({ className, ...props }) {
44
+ const id = React.useId();
45
+ return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx(
46
+ "div",
47
+ {
48
+ "data-slot": "form-item",
49
+ className: cn("grid gap-2", className),
50
+ ...props
51
+ }
52
+ ) });
53
+ }
54
+ function FormLabel({
55
+ className,
56
+ ...props
57
+ }) {
58
+ const { error, formItemId } = useFormField();
59
+ return /* @__PURE__ */ jsx(
60
+ Label,
61
+ {
62
+ "data-slot": "form-label",
63
+ "data-error": !!error,
64
+ className: cn("data-[error=true]:text-destructive", className),
65
+ htmlFor: formItemId,
66
+ ...props
67
+ }
68
+ );
69
+ }
70
+ function FormControl({ ...props }) {
71
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
72
+ return /* @__PURE__ */ jsx(
73
+ Slot,
74
+ {
75
+ "data-slot": "form-control",
76
+ id: formItemId,
77
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
78
+ "aria-invalid": !!error,
79
+ ...props
80
+ }
81
+ );
82
+ }
83
+ function FormDescription({ className, ...props }) {
84
+ const { formDescriptionId } = useFormField();
85
+ return /* @__PURE__ */ jsx(
86
+ "p",
87
+ {
88
+ "data-slot": "form-description",
89
+ id: formDescriptionId,
90
+ className: cn("text-muted-foreground text-sm", className),
91
+ ...props
92
+ }
93
+ );
94
+ }
95
+ function FormMessage({ className, ...props }) {
96
+ const { error, formMessageId } = useFormField();
97
+ const body = error ? String(error?.message ?? "") : props.children;
98
+ if (!body) {
99
+ return null;
100
+ }
101
+ return /* @__PURE__ */ jsx(
102
+ "p",
103
+ {
104
+ "data-slot": "form-message",
105
+ id: formMessageId,
106
+ className: cn("text-destructive text-sm", className),
107
+ ...props,
108
+ children: body
109
+ }
110
+ );
111
+ }
112
+ export {
113
+ Form,
114
+ FormControl,
115
+ FormDescription,
116
+ FormField,
117
+ FormItem,
118
+ FormLabel,
119
+ FormMessage,
120
+ useFormField
121
+ };
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare function Input({ className, type, ...props }: React.ComponentProps<"input">): import("react/jsx-runtime").JSX.Element;
3
+ export { Input };