@assistant-ui/react-mcp 0.1.17 → 0.1.19

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 (170) hide show
  1. package/dist/auth/buildHeaders.d.ts +1 -2
  2. package/dist/auth/buildHeaders.d.ts.map +1 -1
  3. package/dist/auth/createOAuthProvider.d.ts +5 -6
  4. package/dist/auth/createOAuthProvider.d.ts.map +1 -1
  5. package/dist/auth/types.d.ts +1 -2
  6. package/dist/auth/types.d.ts.map +1 -1
  7. package/dist/connector.d.ts +1 -2
  8. package/dist/connector.d.ts.map +1 -1
  9. package/dist/context/McpConnectorByIndexProvider.d.ts +1 -2
  10. package/dist/context/McpConnectorByIndexProvider.d.ts.map +1 -1
  11. package/dist/context/McpCustomServerByIndexProvider.d.ts +1 -2
  12. package/dist/context/McpCustomServerByIndexProvider.d.ts.map +1 -1
  13. package/dist/context/McpServerByIdProvider.d.ts +1 -2
  14. package/dist/context/McpServerByIdProvider.d.ts.map +1 -1
  15. package/dist/hooks/useMcpOAuthCallback.d.ts +5 -6
  16. package/dist/hooks/useMcpOAuthCallback.d.ts.map +1 -1
  17. package/dist/hooks/useMcpOAuthCallback.js +4 -0
  18. package/dist/hooks/useMcpOAuthCallback.js.map +1 -1
  19. package/dist/mcp-scope.d.ts +14 -15
  20. package/dist/mcp-scope.d.ts.map +1 -1
  21. package/dist/primitives/addForm/McpAddFormAuthFields.d.ts +4 -4
  22. package/dist/primitives/addForm/McpAddFormAuthFields.d.ts.map +1 -1
  23. package/dist/primitives/addForm/McpAddFormAuthFields.js +28 -38
  24. package/dist/primitives/addForm/McpAddFormAuthFields.js.map +1 -1
  25. package/dist/primitives/addForm/McpAddFormAuthSelect.d.ts +2 -3
  26. package/dist/primitives/addForm/McpAddFormAuthSelect.d.ts.map +1 -1
  27. package/dist/primitives/addForm/McpAddFormBearerTokenField.d.ts +10 -0
  28. package/dist/primitives/addForm/McpAddFormBearerTokenField.d.ts.map +1 -0
  29. package/dist/primitives/addForm/McpAddFormBearerTokenField.js +50 -0
  30. package/dist/primitives/addForm/McpAddFormBearerTokenField.js.map +1 -0
  31. package/dist/primitives/addForm/McpAddFormCancel.d.ts +2 -3
  32. package/dist/primitives/addForm/McpAddFormCancel.d.ts.map +1 -1
  33. package/dist/primitives/addForm/McpAddFormError.d.ts +2 -3
  34. package/dist/primitives/addForm/McpAddFormError.d.ts.map +1 -1
  35. package/dist/primitives/addForm/McpAddFormError.js +30 -10
  36. package/dist/primitives/addForm/McpAddFormError.js.map +1 -1
  37. package/dist/primitives/addForm/McpAddFormNameField.d.ts +2 -3
  38. package/dist/primitives/addForm/McpAddFormNameField.d.ts.map +1 -1
  39. package/dist/primitives/addForm/McpAddFormNameField.js +31 -18
  40. package/dist/primitives/addForm/McpAddFormNameField.js.map +1 -1
  41. package/dist/primitives/addForm/McpAddFormRoot.d.ts +2 -3
  42. package/dist/primitives/addForm/McpAddFormRoot.d.ts.map +1 -1
  43. package/dist/primitives/addForm/McpAddFormRoot.js +32 -11
  44. package/dist/primitives/addForm/McpAddFormRoot.js.map +1 -1
  45. package/dist/primitives/addForm/McpAddFormScopesField.d.ts +10 -0
  46. package/dist/primitives/addForm/McpAddFormScopesField.d.ts.map +1 -0
  47. package/dist/primitives/addForm/McpAddFormScopesField.js +38 -0
  48. package/dist/primitives/addForm/McpAddFormScopesField.js.map +1 -0
  49. package/dist/primitives/addForm/McpAddFormSubmit.d.ts +2 -3
  50. package/dist/primitives/addForm/McpAddFormSubmit.d.ts.map +1 -1
  51. package/dist/primitives/addForm/McpAddFormUrlField.d.ts +2 -3
  52. package/dist/primitives/addForm/McpAddFormUrlField.d.ts.map +1 -1
  53. package/dist/primitives/addForm/McpAddFormUrlField.js +31 -18
  54. package/dist/primitives/addForm/McpAddFormUrlField.js.map +1 -1
  55. package/dist/primitives/addForm/context.d.ts +13 -6
  56. package/dist/primitives/addForm/context.d.ts.map +1 -1
  57. package/dist/primitives/addForm/context.js.map +1 -1
  58. package/dist/primitives/addForm.d.ts +4 -2
  59. package/dist/primitives/addForm.js +5 -1
  60. package/dist/primitives/addForm.js.map +1 -1
  61. package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.d.ts +2 -3
  62. package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.d.ts.map +1 -1
  63. package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.d.ts +2 -3
  64. package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.d.ts.map +1 -1
  65. package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.d.ts +2 -3
  66. package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.d.ts.map +1 -1
  67. package/dist/primitives/elicitation/McpElicitationPrimitiveError.d.ts +2 -3
  68. package/dist/primitives/elicitation/McpElicitationPrimitiveError.d.ts.map +1 -1
  69. package/dist/primitives/elicitation/McpElicitationPrimitiveFields.d.ts +3 -3
  70. package/dist/primitives/elicitation/McpElicitationPrimitiveFields.d.ts.map +1 -1
  71. package/dist/primitives/elicitation/McpElicitationPrimitiveItems.d.ts +3 -3
  72. package/dist/primitives/elicitation/McpElicitationPrimitiveItems.d.ts.map +1 -1
  73. package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.d.ts +2 -3
  74. package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.d.ts.map +1 -1
  75. package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.d.ts +2 -3
  76. package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.d.ts.map +1 -1
  77. package/dist/primitives/elicitation/context.d.ts +7 -8
  78. package/dist/primitives/elicitation/context.d.ts.map +1 -1
  79. package/dist/primitives/elicitation/initialElicitationDraft.d.ts +1 -2
  80. package/dist/primitives/elicitation/initialElicitationDraft.d.ts.map +1 -1
  81. package/dist/primitives/elicitation/prepareElicitationContent.d.ts +1 -2
  82. package/dist/primitives/elicitation/prepareElicitationContent.d.ts.map +1 -1
  83. package/dist/primitives/elicitation/prepareElicitationContent.js +5 -1
  84. package/dist/primitives/elicitation/prepareElicitationContent.js.map +1 -1
  85. package/dist/primitives/manager/McpManagerAddCustomTrigger.d.ts +2 -3
  86. package/dist/primitives/manager/McpManagerAddCustomTrigger.d.ts.map +1 -1
  87. package/dist/primitives/manager/McpManagerConnectors.d.ts +2 -3
  88. package/dist/primitives/manager/McpManagerConnectors.d.ts.map +1 -1
  89. package/dist/primitives/manager/McpManagerCustomServers.d.ts +2 -3
  90. package/dist/primitives/manager/McpManagerCustomServers.d.ts.map +1 -1
  91. package/dist/primitives/manager/McpManagerRoot.d.ts +2 -3
  92. package/dist/primitives/manager/McpManagerRoot.d.ts.map +1 -1
  93. package/dist/primitives/server/McpServerConnectButton.d.ts +2 -3
  94. package/dist/primitives/server/McpServerConnectButton.d.ts.map +1 -1
  95. package/dist/primitives/server/McpServerDisconnectButton.d.ts +2 -3
  96. package/dist/primitives/server/McpServerDisconnectButton.d.ts.map +1 -1
  97. package/dist/primitives/server/McpServerError.d.ts +2 -3
  98. package/dist/primitives/server/McpServerError.d.ts.map +1 -1
  99. package/dist/primitives/server/McpServerIcon.d.ts +2 -3
  100. package/dist/primitives/server/McpServerIcon.d.ts.map +1 -1
  101. package/dist/primitives/server/McpServerName.d.ts +2 -3
  102. package/dist/primitives/server/McpServerName.d.ts.map +1 -1
  103. package/dist/primitives/server/McpServerOAuthLink.d.ts +2 -3
  104. package/dist/primitives/server/McpServerOAuthLink.d.ts.map +1 -1
  105. package/dist/primitives/server/McpServerRemoveButton.d.ts +2 -3
  106. package/dist/primitives/server/McpServerRemoveButton.d.ts.map +1 -1
  107. package/dist/primitives/server/McpServerRoot.d.ts +2 -3
  108. package/dist/primitives/server/McpServerRoot.d.ts.map +1 -1
  109. package/dist/primitives/server/McpServerStatus.d.ts +2 -3
  110. package/dist/primitives/server/McpServerStatus.d.ts.map +1 -1
  111. package/dist/primitives/server/McpServerToolName.d.ts +2 -3
  112. package/dist/primitives/server/McpServerToolName.d.ts.map +1 -1
  113. package/dist/primitives/server/McpServerTools.d.ts +3 -4
  114. package/dist/primitives/server/McpServerTools.d.ts.map +1 -1
  115. package/dist/resources/McpManagerResource.d.ts +2 -3
  116. package/dist/resources/McpManagerResource.d.ts.map +1 -1
  117. package/dist/resources/McpManagerResource.js +358 -244
  118. package/dist/resources/McpManagerResource.js.map +1 -1
  119. package/dist/resources/McpServerRemovalFence.d.ts +6 -0
  120. package/dist/resources/McpServerRemovalFence.d.ts.map +1 -0
  121. package/dist/resources/McpServerRemovalFence.js +11 -0
  122. package/dist/resources/McpServerRemovalFence.js.map +1 -0
  123. package/dist/resources/McpServerResource.d.ts +3 -4
  124. package/dist/resources/McpServerResource.d.ts.map +1 -1
  125. package/dist/resources/McpServerResource.js +9 -5
  126. package/dist/resources/McpServerResource.js.map +1 -1
  127. package/dist/resources/storage/McpCustomStorage.d.ts +1 -2
  128. package/dist/resources/storage/McpCustomStorage.d.ts.map +1 -1
  129. package/dist/resources/storage/McpLocalStorage.d.ts +4 -5
  130. package/dist/resources/storage/McpLocalStorage.d.ts.map +1 -1
  131. package/dist/resources/storage/McpLocalStorage.js +2 -1
  132. package/dist/resources/storage/McpLocalStorage.js.map +1 -1
  133. package/dist/resources/storage/McpMemoryStorage.d.ts +1 -2
  134. package/dist/resources/storage/McpMemoryStorage.d.ts.map +1 -1
  135. package/dist/resources/storage/types.d.ts +12 -11
  136. package/dist/resources/storage/types.d.ts.map +1 -1
  137. package/dist/resources/validateElicitationContent.d.ts +1 -2
  138. package/dist/resources/validateElicitationContent.d.ts.map +1 -1
  139. package/dist/utils/createMcpId.d.ts +1 -2
  140. package/dist/utils/createMcpId.d.ts.map +1 -1
  141. package/dist/utils/invokeMcpCallback.d.ts +1 -2
  142. package/dist/utils/invokeMcpCallback.d.ts.map +1 -1
  143. package/dist/utils/serverId.d.ts +2 -3
  144. package/dist/utils/serverId.d.ts.map +1 -1
  145. package/dist/utils/serverUrl.d.ts +3 -4
  146. package/dist/utils/serverUrl.d.ts.map +1 -1
  147. package/package.json +11 -10
  148. package/src/hooks/useMcpOAuthCallback.test.ts +53 -0
  149. package/src/hooks/useMcpOAuthCallback.tsx +12 -0
  150. package/src/index.ts +2 -1
  151. package/src/primitives/addForm/McpAddFormAccessibility.test.tsx +310 -0
  152. package/src/primitives/addForm/McpAddFormAuthFields.tsx +26 -16
  153. package/src/primitives/addForm/McpAddFormBearerTokenField.tsx +46 -0
  154. package/src/primitives/addForm/McpAddFormError.tsx +17 -3
  155. package/src/primitives/addForm/McpAddFormNameField.tsx +13 -1
  156. package/src/primitives/addForm/McpAddFormRoot.test.tsx +65 -0
  157. package/src/primitives/addForm/McpAddFormRoot.tsx +51 -8
  158. package/src/primitives/addForm/McpAddFormScopesField.tsx +34 -0
  159. package/src/primitives/addForm/McpAddFormUrlField.tsx +12 -1
  160. package/src/primitives/addForm/context.tsx +10 -0
  161. package/src/primitives/addForm.ts +2 -0
  162. package/src/primitives/elicitation/prepareElicitationContent.ts +8 -6
  163. package/src/resources/McpManagerResource.test.ts +797 -9
  164. package/src/resources/McpManagerResource.ts +242 -60
  165. package/src/resources/McpServerRemovalFence.ts +21 -0
  166. package/src/resources/McpServerResource.test.ts +9 -6
  167. package/src/resources/McpServerResource.ts +11 -6
  168. package/src/resources/storage/McpLocalStorage.test.ts +2 -0
  169. package/src/resources/storage/McpLocalStorage.ts +2 -1
  170. package/src/resources/storage/types.ts +10 -8
@@ -1,13 +1,12 @@
1
1
  import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
2
  import { Primitive } from "@radix-ui/react-primitive";
3
3
  //#region src/primitives/addForm/McpAddFormError.d.ts
4
- declare namespace McpAddFormPrimitiveError {
4
+ export declare namespace McpAddFormPrimitiveError {
5
5
  type Element = ComponentRef<typeof Primitive.div>;
6
6
  type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
7
7
  }
8
- declare const McpAddFormPrimitiveError: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
8
+ export declare const McpAddFormPrimitiveError: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
9
9
  asChild?: boolean;
10
10
  }, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
11
11
  //#endregion
12
- export { McpAddFormPrimitiveError };
13
12
  //# sourceMappingURL=McpAddFormError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpAddFormError.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormError.tsx"],"mappings":";;;kBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;cAGnD,0CAAwB,0BAAA,qBAAA,gBAAA,kCAAA,eAAA;;4BAWnC,cAAA"}
1
+ {"version":3,"file":"McpAddFormError.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormError.tsx"],"mappings":";;;yBASiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;qBAGnD,0CAAwB,0BAAA,qBAAA,gBAAA,kCAAA,eAAA;;4BAwBnC,cAAA"}
@@ -1,27 +1,47 @@
1
1
  import { useAddForm } from "./context.js";
2
2
  import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
3
- import { forwardRef } from "@assistant-ui/tap/react-shim";
3
+ import { forwardRef, isValidElement } from "@assistant-ui/tap/react-shim";
4
4
  import { Primitive } from "@radix-ui/react-primitive";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/primitives/addForm/McpAddFormError.tsx
7
7
  const McpAddFormPrimitiveError = forwardRef((props, ref) => {
8
- const $ = c(4);
9
- const { state } = useAddForm();
8
+ const $ = c(10);
9
+ const { state, ids } = useAddForm();
10
10
  if (!state.error) return null;
11
- const t0 = props.children ?? state.error;
12
- let t1;
13
- if ($[0] !== props || $[1] !== ref || $[2] !== t0) {
14
- t1 = /* @__PURE__ */ jsx(Primitive.div, {
11
+ const customId = (props.asChild && isValidElement(props.children) ? props.children.props.id : void 0) ?? props.id;
12
+ const needsDescriptionWrapper = customId !== void 0 && customId !== ids.error;
13
+ const t0 = needsDescriptionWrapper ? props.id : ids.error;
14
+ const t1 = props.role ?? "alert";
15
+ const t2 = props.children ?? state.error;
16
+ let t3;
17
+ if ($[0] !== props || $[1] !== ref || $[2] !== t0 || $[3] !== t1 || $[4] !== t2) {
18
+ t3 = /* @__PURE__ */ jsx(Primitive.div, {
15
19
  ...props,
20
+ id: t0,
21
+ role: t1,
16
22
  ref,
17
- children: t0
23
+ children: t2
18
24
  });
19
25
  $[0] = props;
20
26
  $[1] = ref;
21
27
  $[2] = t0;
22
28
  $[3] = t1;
23
- } else t1 = $[3];
24
- return t1;
29
+ $[4] = t2;
30
+ $[5] = t3;
31
+ } else t3 = $[5];
32
+ const error = t3;
33
+ let t4;
34
+ if ($[6] !== error || $[7] !== ids || $[8] !== needsDescriptionWrapper) {
35
+ t4 = needsDescriptionWrapper ? /* @__PURE__ */ jsx("div", {
36
+ id: ids.error,
37
+ children: error
38
+ }) : error;
39
+ $[6] = error;
40
+ $[7] = ids;
41
+ $[8] = needsDescriptionWrapper;
42
+ $[9] = t4;
43
+ } else t4 = $[9];
44
+ return t4;
25
45
  });
26
46
  McpAddFormPrimitiveError.displayName = "McpAddFormPrimitive.Error";
27
47
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"McpAddFormError.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useAddForm","McpAddFormPrimitiveError","Element","div","Props","props","ref","$","_c","state","error","t0","children","t1","displayName"],"sources":["../../../src/primitives/addForm/McpAddFormError.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAddForm } from \"./context\";\n\nexport namespace McpAddFormPrimitiveError {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\nexport const McpAddFormPrimitiveError = forwardRef<\n McpAddFormPrimitiveError.Element,\n McpAddFormPrimitiveError.Props\n>((props, ref) => {\n const { state } = useAddForm();\n if (!state.error) return null;\n return (\n <Primitive.div {...props} ref={ref}>\n {props.children ?? state.error}\n </Primitive.div>\n );\n});\n\nMcpAddFormPrimitiveError.displayName = \"McpAddFormPrimitive.Error\";\n"],"mappings":";;;;;;AAaA,MAAaK,2BAA2BH,YAGtCO,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACA,MAAA,EAAAC,UAAkBT,WAAW;CAC7B,IAAI,CAACS,MAAKC,OAAM,OAAS;CAGpB,MAAAC,KAAAN,MAAKO,YAAaH,MAAKC;CAAM,IAAAG;CAAA,IAAAN,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAI,IAAA;EADhCE,KAAA,oBAAA,UAAA,KAAA;GAAA,GAAmBR;GAAYC;GAC5BK,UAAAA;EACH,CAAA;EAAgBJ,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAI;EAAAJ,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,OAFhBM;AAEgB,CAEnB;AAEDZ,yBAAyBa,cAAc"}
1
+ {"version":3,"file":"McpAddFormError.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","isValidElement","Primitive","useAddForm","McpAddFormPrimitiveError","Element","div","Props","props","ref","$","_c","state","ids","error","childId","asChild","children","id","undefined","customId","needsDescriptionWrapper","t0","t1","role","t2","t3","t4","displayName"],"sources":["../../../src/primitives/addForm/McpAddFormError.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n isValidElement,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAddForm } from \"./context\";\n\nexport namespace McpAddFormPrimitiveError {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\nexport const McpAddFormPrimitiveError = forwardRef<\n McpAddFormPrimitiveError.Element,\n McpAddFormPrimitiveError.Props\n>((props, ref) => {\n const { state, ids } = useAddForm();\n if (!state.error) return null;\n const childId =\n props.asChild && isValidElement<{ id?: string }>(props.children)\n ? props.children.props.id\n : undefined;\n const customId = childId ?? props.id;\n const needsDescriptionWrapper =\n customId !== undefined && customId !== ids.error;\n const error = (\n <Primitive.div\n {...props}\n id={needsDescriptionWrapper ? props.id : ids.error}\n role={props.role ?? \"alert\"}\n ref={ref}\n >\n {props.children ?? state.error}\n </Primitive.div>\n );\n return needsDescriptionWrapper ? <div id={ids.error}>{error}</div> : error;\n});\n\nMcpAddFormPrimitiveError.displayName = \"McpAddFormPrimitive.Error\";\n"],"mappings":";;;;;;AAcA,MAAaM,2BAA2BJ,YAGtCQ,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACA,MAAA,EAAAC,OAAAC,QAAuBV,WAAW;CAClC,IAAI,CAACS,MAAKE,OAAM,OAAS;CAKzB,MAAAM,YAHEZ,MAAKQ,WAAYf,eAAgCO,MAAKS,QAAS,IAC3DT,MAAKS,SAAST,MAAMU,KADxBC,KAAAA,MAG0BX,MAAKU;CACjC,MAAAG,0BACED,aAAaD,KAAAA,KAAaC,aAAaP,IAAGC;CAIpC,MAAAQ,KAAAD,0BAA0Bb,MAAKU,KAAML,IAAGC;CACtC,MAAAS,KAAAf,MAAKgB,QAAL;CAGL,MAAAC,KAAAjB,MAAKS,YAAaL,MAAKE;CAAM,IAAAY;CAAA,IAAAhB,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAY,MAAAZ,EAAA,OAAAa,MAAAb,EAAA,OAAAe,IAAA;EANhCC,KAAA,oBAAA,UAAA,KAAA;GAAA,GACMlB;GACA,IAAAc;GACE,MAAAC;GACDd;GAEJgB,UAAAA;EACH,CAAA;EAAgBf,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAY;EAAAZ,EAAA,KAAAa;EAAAb,EAAA,KAAAe;EAAAf,EAAA,KAAAgB;CAAA,OAAAA,KAAAhB,EAAA;CARlB,MAAAI,QACEY;CAQA,IAAAC;CAAA,IAAAjB,EAAA,OAAAI,SAAAJ,EAAA,OAAAG,OAAAH,EAAA,OAAAW,yBAAA;EACKM,KAAAN,0BAA0B,oBAAA,OAAA;GAAS,IAAAR,IAAGC;GAASA,UAAAA;EAAY,CAAA,IAA3DA;EAAmEJ,EAAA,KAAAI;EAAAJ,EAAA,KAAAG;EAAAH,EAAA,KAAAW;EAAAX,EAAA,KAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,OAAnEiB;AAAmE,CAC3E;AAEDvB,yBAAyBwB,cAAc"}
@@ -1,11 +1,10 @@
1
1
  import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
2
  import { Primitive } from "@radix-ui/react-primitive";
3
3
  //#region src/primitives/addForm/McpAddFormNameField.d.ts
4
- declare namespace McpAddFormPrimitiveNameField {
4
+ export declare namespace McpAddFormPrimitiveNameField {
5
5
  type Element = ComponentRef<typeof Primitive.input>;
6
6
  type Props = Omit<ComponentPropsWithoutRef<typeof Primitive.input>, "value" | "onChange" | "type">;
7
7
  }
8
- declare const McpAddFormPrimitiveNameField: import("react").ForwardRefExoticComponent<McpAddFormPrimitiveNameField.Props & import("react").RefAttributes<HTMLInputElement>>;
8
+ export declare const McpAddFormPrimitiveNameField: import("react").ForwardRefExoticComponent<McpAddFormPrimitiveNameField.Props & import("react").RefAttributes<HTMLInputElement>>;
9
9
  //#endregion
10
- export { McpAddFormPrimitiveNameField };
11
10
  //# sourceMappingURL=McpAddFormNameField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpAddFormNameField.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormNameField.tsx"],"mappings":";;;kBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,KAClB,gCAAgC,UAAU;;cAKjC,8CAA4B,0BAAA,6BAAA,wBAAA,cAAA"}
1
+ {"version":3,"file":"McpAddFormNameField.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormNameField.tsx"],"mappings":";;;yBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,KAClB,gCAAgC,UAAU;;qBAKjC,8CAA4B,0BAAA,6BAAA,wBAAA,cAAA"}
@@ -5,31 +5,44 @@ import { Primitive } from "@radix-ui/react-primitive";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/primitives/addForm/McpAddFormNameField.tsx
7
7
  const McpAddFormPrimitiveNameField = forwardRef((props, ref) => {
8
- const $ = c(7);
9
- const { state, setField } = useAddForm();
10
- let t0;
11
- if ($[0] !== setField) {
12
- t0 = (e) => setField("name", e.target.value);
13
- $[0] = setField;
14
- $[1] = t0;
15
- } else t0 = $[1];
8
+ const $ = c(13);
9
+ const { state, ids, setField } = useAddForm();
10
+ const t0 = props["aria-invalid"] ?? (state.errorField === "name" ? true : void 0);
16
11
  let t1;
17
- if ($[2] !== props || $[3] !== ref || $[4] !== state.name || $[5] !== t0) {
18
- t1 = /* @__PURE__ */ jsx(Primitive.input, {
12
+ if ($[0] !== ids || $[1] !== props || $[2] !== state.errorField) {
13
+ t1 = [props["aria-describedby"], state.errorField === "name" ? ids.error : null].filter(Boolean).join(" ") || void 0;
14
+ $[0] = ids;
15
+ $[1] = props;
16
+ $[2] = state.errorField;
17
+ $[3] = t1;
18
+ } else t1 = $[3];
19
+ let t2;
20
+ if ($[4] !== setField) {
21
+ t2 = (e) => setField("name", e.target.value);
22
+ $[4] = setField;
23
+ $[5] = t2;
24
+ } else t2 = $[5];
25
+ let t3;
26
+ if ($[6] !== props || $[7] !== ref || $[8] !== state.name || $[9] !== t0 || $[10] !== t1 || $[11] !== t2) {
27
+ t3 = /* @__PURE__ */ jsx(Primitive.input, {
19
28
  type: "text",
20
29
  placeholder: "Name",
21
30
  ...props,
31
+ "aria-invalid": t0,
32
+ "aria-describedby": t1,
22
33
  ref,
23
34
  value: state.name,
24
- onChange: t0
35
+ onChange: t2
25
36
  });
26
- $[2] = props;
27
- $[3] = ref;
28
- $[4] = state.name;
29
- $[5] = t0;
30
- $[6] = t1;
31
- } else t1 = $[6];
32
- return t1;
37
+ $[6] = props;
38
+ $[7] = ref;
39
+ $[8] = state.name;
40
+ $[9] = t0;
41
+ $[10] = t1;
42
+ $[11] = t2;
43
+ $[12] = t3;
44
+ } else t3 = $[12];
45
+ return t3;
33
46
  });
34
47
  McpAddFormPrimitiveNameField.displayName = "McpAddFormPrimitive.NameField";
35
48
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"McpAddFormNameField.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useAddForm","McpAddFormPrimitiveNameField","Element","input","Props","Omit","props","ref","$","_c","state","setField","t0","e","target","value","t1","name","displayName"],"sources":["../../../src/primitives/addForm/McpAddFormNameField.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAddForm } from \"./context\";\n\nexport namespace McpAddFormPrimitiveNameField {\n export type Element = ComponentRef<typeof Primitive.input>;\n export type Props = Omit<\n ComponentPropsWithoutRef<typeof Primitive.input>,\n \"value\" | \"onChange\" | \"type\"\n >;\n}\n\nexport const McpAddFormPrimitiveNameField = forwardRef<\n McpAddFormPrimitiveNameField.Element,\n McpAddFormPrimitiveNameField.Props\n>((props, ref) => {\n const { state, setField } = useAddForm();\n return (\n <Primitive.input\n type=\"text\"\n placeholder=\"Name\"\n {...props}\n ref={ref}\n value={state.name}\n onChange={(e) => setField(\"name\", e.target.value)}\n />\n );\n});\n\nMcpAddFormPrimitiveNameField.displayName = \"McpAddFormPrimitive.NameField\";\n"],"mappings":";;;;;;AAgBA,MAAaK,+BAA+BH,YAG1CQ,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACA,MAAA,EAAAC,OAAAC,aAA4BX,WAAW;CAAE,IAAAY;CAAA,IAAAJ,EAAA,OAAAG,UAAA;EAQ3BC,MAAAC,MAAOF,SAAS,QAAQE,EAACC,OAAOC,KAAM;EAACP,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAE,MAAAO,QAAAT,EAAA,OAAAI,IAAA;EANnDI,KAAA,oBAAA,UAAA,OAAA;GACO,MAAA;GACO,aAAA;GAAM,GACdV;GACCC;GACE,OAAAG,MAAKO;GACF,UAAAL;EAAuC,CAAA;EACjDJ,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAE,MAAAO;EAAAT,EAAA,KAAAI;EAAAJ,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAPFQ;AAOE,CAEL;AAEDf,6BAA6BiB,cAAc"}
1
+ {"version":3,"file":"McpAddFormNameField.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useAddForm","McpAddFormPrimitiveNameField","Element","input","Props","Omit","props","ref","$","_c","state","ids","setField","t0","errorField","undefined","t1","error","filter","Boolean","join","t2","e","target","value","t3","name","displayName"],"sources":["../../../src/primitives/addForm/McpAddFormNameField.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAddForm } from \"./context\";\n\nexport namespace McpAddFormPrimitiveNameField {\n export type Element = ComponentRef<typeof Primitive.input>;\n export type Props = Omit<\n ComponentPropsWithoutRef<typeof Primitive.input>,\n \"value\" | \"onChange\" | \"type\"\n >;\n}\n\nexport const McpAddFormPrimitiveNameField = forwardRef<\n McpAddFormPrimitiveNameField.Element,\n McpAddFormPrimitiveNameField.Props\n>((props, ref) => {\n const { state, ids, setField } = useAddForm();\n return (\n <Primitive.input\n type=\"text\"\n placeholder=\"Name\"\n {...props}\n aria-invalid={\n props[\"aria-invalid\"] ??\n (state.errorField === \"name\" ? true : undefined)\n }\n aria-describedby={\n [\n props[\"aria-describedby\"],\n state.errorField === \"name\" ? ids.error : null,\n ]\n .filter(Boolean)\n .join(\" \") || undefined\n }\n ref={ref}\n value={state.name}\n onChange={(e) => setField(\"name\", e.target.value)}\n />\n );\n});\n\nMcpAddFormPrimitiveNameField.displayName = \"McpAddFormPrimitive.NameField\";\n"],"mappings":";;;;;;AAgBA,MAAaK,+BAA+BH,YAG1CQ,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACA,MAAA,EAAAC,OAAAC,KAAAC,aAAiCZ,WAAW;CAOtC,MAAAa,KAAAP,MAAM,oBACLI,MAAKI,eAAgB,SAArB,OAAAC,KAAAA;CAA+C,IAAAC;CAAA,IAAAR,EAAA,OAAAG,OAAAH,EAAA,OAAAF,SAAAE,EAAA,OAAAE,MAAAI,YAAA;EAGhDE,KAAA,CACEV,MAAM,qBACNI,MAAKI,eAAgB,SAASH,IAAGM,QAAjC,IAA8C,CAC/C,CAAAC,OACSC,OAAO,CAAC,CAAAC,KACV,GAAgB,KALxBL,KAAAA;EAKyBP,EAAA,KAAAG;EAAAH,EAAA,KAAAF;EAAAE,EAAA,KAAAE,MAAAI;EAAAN,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,OAAAI,UAAA;EAIjBS,MAAAC,MAAOV,SAAS,QAAQU,EAACC,OAAOC,KAAM;EAAChB,EAAA,KAAAI;EAAAJ,EAAA,KAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,IAAAiB;CAAA,IAAAjB,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAE,MAAAgB,QAAAlB,EAAA,OAAAK,MAAAL,EAAA,QAAAQ,MAAAR,EAAA,QAAAa,IAAA;EAlBnDI,KAAA,oBAAA,UAAA,OAAA;GACO,MAAA;GACO,aAAA;GAAM,GACdnB;GAEF,gBAAAO;GAIA,oBAAAG;GAOGT;GACE,OAAAG,MAAKgB;GACF,UAAAL;EAAuC,CAAA;EACjDb,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAE,MAAAgB;EAAAlB,EAAA,KAAAK;EAAAL,EAAA,MAAAQ;EAAAR,EAAA,MAAAa;EAAAb,EAAA,MAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,OAnBFiB;AAmBE,CAEL;AAEDxB,6BAA6B0B,cAAc"}
@@ -1,19 +1,18 @@
1
1
  import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
2
  import { Primitive } from "@radix-ui/react-primitive";
3
3
  //#region src/primitives/addForm/McpAddFormRoot.d.ts
4
- declare namespace McpAddFormPrimitiveRoot {
4
+ export declare namespace McpAddFormPrimitiveRoot {
5
5
  type Element = ComponentRef<typeof Primitive.form>;
6
6
  type Props = Omit<ComponentPropsWithoutRef<typeof Primitive.form>, "onSubmit"> & {
7
7
  onSubmitted?: (id: string) => void;
8
8
  onCancel?: () => void;
9
9
  };
10
10
  }
11
- declare const McpAddFormPrimitiveRoot: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").ClassAttributes<HTMLFormElement> & import("react").FormHTMLAttributes<HTMLFormElement> & {
11
+ export declare const McpAddFormPrimitiveRoot: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").ClassAttributes<HTMLFormElement> & import("react").FormHTMLAttributes<HTMLFormElement> & {
12
12
  asChild?: boolean;
13
13
  }, "ref">, "onSubmit"> & {
14
14
  onSubmitted?: (id: string) => void;
15
15
  onCancel?: () => void;
16
16
  } & import("react").RefAttributes<HTMLFormElement>>;
17
17
  //#endregion
18
- export { McpAddFormPrimitiveRoot };
19
18
  //# sourceMappingURL=McpAddFormRoot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpAddFormRoot.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormRoot.tsx"],"mappings":";;;kBAwCiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,KAClB,gCAAgC,UAAU;IAG1C,eAAe;IACf;;;cAIS,yCAAuB,0BAAA,KAAA,qBAAA,gBAAA,mCAAA,mBAAA;;;EALlB,eAAC;EACJ;oBA4Fb,cAAA"}
1
+ {"version":3,"file":"McpAddFormRoot.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormRoot.tsx"],"mappings":";;;yBA8CiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,KAClB,gCAAgC,UAAU;IAG1C,eAAe;IACf;;;qBAIS,yCAAuB,0BAAA,KAAA,qBAAA,gBAAA,mCAAA,mBAAA;;;EALlB,eAAC;EACJ;oBAiIb,cAAA"}
@@ -1,7 +1,7 @@
1
1
  import { AddFormContext } from "./context.js";
2
2
  import { invokeMcpCallback } from "../../utils/invokeMcpCallback.js";
3
3
  import { useAui } from "@assistant-ui/store";
4
- import { forwardRef, useCallback, useMemo, useState } from "@assistant-ui/tap/react-shim";
4
+ import { forwardRef, useCallback, useId, useMemo, useState } from "@assistant-ui/tap/react-shim";
5
5
  import { Primitive } from "@radix-ui/react-primitive";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  //#region src/primitives/addForm/McpAddFormRoot.tsx
@@ -12,7 +12,8 @@ const INITIAL = {
12
12
  bearerToken: "",
13
13
  scopes: "",
14
14
  submitting: false,
15
- error: null
15
+ error: null,
16
+ errorField: null
16
17
  };
17
18
  function validateUrl(raw) {
18
19
  const trimmed = raw.trim();
@@ -28,12 +29,25 @@ function validateUrl(raw) {
28
29
  }
29
30
  const McpAddFormPrimitiveRoot = forwardRef(({ onSubmitted, onCancel, ...props }, ref) => {
30
31
  const aui = useAui();
32
+ const formId = useId();
31
33
  const [state, setState] = useState(INITIAL);
34
+ const ids = useMemo(() => ({
35
+ bearerToken: `${formId}-bearer-token`,
36
+ scopes: `${formId}-oauth-scopes`,
37
+ error: `${formId}-error`
38
+ }), [formId]);
32
39
  const setField = useCallback((key, value) => {
33
- setState((prev) => ({
34
- ...prev,
35
- [key]: value
36
- }));
40
+ setState((prev) => {
41
+ const clearsError = prev.errorField === "form" || prev.errorField === key || key === "authType" && prev.errorField === "bearerToken";
42
+ return {
43
+ ...prev,
44
+ [key]: value,
45
+ ...clearsError ? {
46
+ error: null,
47
+ errorField: null
48
+ } : {}
49
+ };
50
+ });
37
51
  }, []);
38
52
  const reset = useCallback(() => setState(INITIAL), []);
39
53
  const buildAuth = useCallback(() => {
@@ -61,14 +75,16 @@ const McpAddFormPrimitiveRoot = forwardRef(({ onSubmitted, onCancel, ...props },
61
75
  if (!state.name.trim()) {
62
76
  setState((p) => ({
63
77
  ...p,
64
- error: "Name is required"
78
+ error: "Name is required",
79
+ errorField: "name"
65
80
  }));
66
81
  return;
67
82
  }
68
83
  if (state.authType === "bearer" && !state.bearerToken.trim()) {
69
84
  setState((p_0) => ({
70
85
  ...p_0,
71
- error: "Bearer token is required"
86
+ error: "Bearer token is required",
87
+ errorField: "bearerToken"
72
88
  }));
73
89
  return;
74
90
  }
@@ -76,14 +92,16 @@ const McpAddFormPrimitiveRoot = forwardRef(({ onSubmitted, onCancel, ...props },
76
92
  if ("error" in urlResult) {
77
93
  setState((p_1) => ({
78
94
  ...p_1,
79
- error: urlResult.error
95
+ error: urlResult.error,
96
+ errorField: "url"
80
97
  }));
81
98
  return;
82
99
  }
83
100
  setState((p_2) => ({
84
101
  ...p_2,
85
102
  submitting: true,
86
- error: null
103
+ error: null,
104
+ errorField: null
87
105
  }));
88
106
  try {
89
107
  const id = await aui.mcp.addCustomServer({
@@ -97,7 +115,8 @@ const McpAddFormPrimitiveRoot = forwardRef(({ onSubmitted, onCancel, ...props },
97
115
  setState((p_3) => ({
98
116
  ...p_3,
99
117
  submitting: false,
100
- error: err instanceof Error ? err.message : String(err)
118
+ error: err instanceof Error ? err.message : String(err),
119
+ errorField: "form"
101
120
  }));
102
121
  }
103
122
  }, [
@@ -112,12 +131,14 @@ const McpAddFormPrimitiveRoot = forwardRef(({ onSubmitted, onCancel, ...props },
112
131
  }, [onCancel]);
113
132
  const value_0 = useMemo(() => ({
114
133
  state,
134
+ ids,
115
135
  setField,
116
136
  reset,
117
137
  submit,
118
138
  cancel
119
139
  }), [
120
140
  state,
141
+ ids,
121
142
  setField,
122
143
  reset,
123
144
  submit,
@@ -1 +1 @@
1
- {"version":3,"file":"McpAddFormRoot.js","names":["ComponentPropsWithoutRef","ComponentRef","FormEventHandler","forwardRef","useCallback","useMemo","useState","Primitive","useAui","AddFormContext","AddFormState","MCPAuthConfig","invokeMcpCallback","INITIAL","name","url","authType","bearerToken","scopes","submitting","error","validateUrl","raw","trimmed","trim","parsed","URL","protocol","McpAddFormPrimitiveRoot","Element","form","Props","Omit","onSubmitted","id","onCancel","props","ref","aui","state","setState","setField","key","K","value","prev","reset","buildAuth","type","token","undefined","scopeList","split","map","s","filter","Boolean","length","submit","p","urlResult","mcp","addCustomServer","auth","err","Error","message","String","cancel","onFormSubmit","HTMLFormElement","e","preventDefault","displayName"],"sources":["../../../src/primitives/addForm/McpAddFormRoot.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type FormEventHandler,\n forwardRef,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { AddFormContext, type AddFormState } from \"./context\";\nimport type { MCPAuthConfig } from \"../../mcp-scope\";\nimport { invokeMcpCallback } from \"../../utils/invokeMcpCallback\";\n\nconst INITIAL: AddFormState = {\n name: \"\",\n url: \"\",\n authType: \"oauth\",\n bearerToken: \"\",\n scopes: \"\",\n submitting: false,\n error: null,\n};\n\nfunction validateUrl(raw: string): { url: string } | { error: string } {\n const trimmed = raw.trim();\n if (!trimmed) return { error: \"URL is required\" };\n let parsed: URL;\n try {\n parsed = new URL(trimmed);\n } catch {\n return { error: \"Invalid URL\" };\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return { error: \"URL must be http(s)\" };\n }\n return { url: trimmed };\n}\n\nexport namespace McpAddFormPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.form>;\n export type Props = Omit<\n ComponentPropsWithoutRef<typeof Primitive.form>,\n \"onSubmit\"\n > & {\n onSubmitted?: (id: string) => void;\n onCancel?: () => void;\n };\n}\n\nexport const McpAddFormPrimitiveRoot = forwardRef<\n McpAddFormPrimitiveRoot.Element,\n McpAddFormPrimitiveRoot.Props\n>(({ onSubmitted, onCancel, ...props }, ref) => {\n const aui = useAui();\n const [state, setState] = useState<AddFormState>(INITIAL);\n\n const setField = useCallback(\n <K extends keyof AddFormState>(key: K, value: AddFormState[K]) => {\n setState((prev) => ({ ...prev, [key]: value }));\n },\n [],\n );\n\n const reset = useCallback(() => setState(INITIAL), []);\n\n const buildAuth = useCallback((): MCPAuthConfig => {\n switch (state.authType) {\n case \"none\":\n return { type: \"none\" };\n case \"bearer\":\n return { type: \"bearer\", token: state.bearerToken || undefined };\n case \"oauth\": {\n const scopeList = state.scopes\n .split(/[\\s,]+/)\n .map((s) => s.trim())\n .filter(Boolean);\n return {\n type: \"oauth\",\n scopes: scopeList.length > 0 ? scopeList : undefined,\n };\n }\n }\n }, [state.authType, state.bearerToken, state.scopes]);\n\n const submit = useCallback(async () => {\n if (state.submitting) return;\n if (!state.name.trim()) {\n setState((p) => ({ ...p, error: \"Name is required\" }));\n return;\n }\n if (state.authType === \"bearer\" && !state.bearerToken.trim()) {\n setState((p) => ({ ...p, error: \"Bearer token is required\" }));\n return;\n }\n const urlResult = validateUrl(state.url);\n if (\"error\" in urlResult) {\n setState((p) => ({ ...p, error: urlResult.error }));\n return;\n }\n setState((p) => ({ ...p, submitting: true, error: null }));\n try {\n const id = await aui.mcp.addCustomServer({\n name: state.name.trim(),\n url: urlResult.url,\n auth: buildAuth(),\n });\n setState(INITIAL);\n invokeMcpCallback(\"onSubmitted\", onSubmitted, id);\n } catch (err) {\n setState((p) => ({\n ...p,\n submitting: false,\n error: err instanceof Error ? err.message : String(err),\n }));\n }\n }, [aui, buildAuth, onSubmitted, state]);\n\n const cancel = useCallback(() => {\n setState(INITIAL);\n onCancel?.();\n }, [onCancel]);\n\n const value = useMemo(\n () => ({ state, setField, reset, submit, cancel }),\n [state, setField, reset, submit, cancel],\n );\n\n const onFormSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n void submit();\n };\n\n return (\n <AddFormContext.Provider value={value}>\n <Primitive.form {...props} ref={ref} onSubmit={onFormSubmit} />\n </AddFormContext.Provider>\n );\n});\n\nMcpAddFormPrimitiveRoot.displayName = \"McpAddFormPrimitive.Root\";\n"],"mappings":"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"}
1
+ {"version":3,"file":"McpAddFormRoot.js","names":["ComponentPropsWithoutRef","ComponentRef","FormEventHandler","forwardRef","useCallback","useId","useMemo","useState","Primitive","useAui","AddFormContext","AddFormFieldIds","AddFormState","MCPAuthConfig","invokeMcpCallback","INITIAL","name","url","authType","bearerToken","scopes","submitting","error","errorField","validateUrl","raw","trimmed","trim","parsed","URL","protocol","McpAddFormPrimitiveRoot","Element","form","Props","Omit","onSubmitted","id","onCancel","props","ref","aui","formId","state","setState","ids","setField","key","K","value","prev","clearsError","reset","buildAuth","type","token","undefined","scopeList","split","map","s","filter","Boolean","length","submit","p","urlResult","mcp","addCustomServer","auth","err","Error","message","String","cancel","onFormSubmit","HTMLFormElement","e","preventDefault","displayName"],"sources":["../../../src/primitives/addForm/McpAddFormRoot.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type FormEventHandler,\n forwardRef,\n useCallback,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAui } from \"@assistant-ui/store\";\nimport {\n AddFormContext,\n type AddFormFieldIds,\n type AddFormState,\n} from \"./context\";\nimport type { MCPAuthConfig } from \"../../mcp-scope\";\nimport { invokeMcpCallback } from \"../../utils/invokeMcpCallback\";\n\nconst INITIAL: AddFormState = {\n name: \"\",\n url: \"\",\n authType: \"oauth\",\n bearerToken: \"\",\n scopes: \"\",\n submitting: false,\n error: null,\n errorField: null,\n};\n\nfunction validateUrl(raw: string): { url: string } | { error: string } {\n const trimmed = raw.trim();\n if (!trimmed) return { error: \"URL is required\" };\n let parsed: URL;\n try {\n parsed = new URL(trimmed);\n } catch {\n return { error: \"Invalid URL\" };\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return { error: \"URL must be http(s)\" };\n }\n return { url: trimmed };\n}\n\nexport namespace McpAddFormPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.form>;\n export type Props = Omit<\n ComponentPropsWithoutRef<typeof Primitive.form>,\n \"onSubmit\"\n > & {\n onSubmitted?: (id: string) => void;\n onCancel?: () => void;\n };\n}\n\nexport const McpAddFormPrimitiveRoot = forwardRef<\n McpAddFormPrimitiveRoot.Element,\n McpAddFormPrimitiveRoot.Props\n>(({ onSubmitted, onCancel, ...props }, ref) => {\n const aui = useAui();\n const formId = useId();\n const [state, setState] = useState<AddFormState>(INITIAL);\n const ids = useMemo<AddFormFieldIds>(\n () => ({\n bearerToken: `${formId}-bearer-token`,\n scopes: `${formId}-oauth-scopes`,\n error: `${formId}-error`,\n }),\n [formId],\n );\n\n const setField = useCallback(\n <K extends keyof AddFormState>(key: K, value: AddFormState[K]) => {\n setState((prev) => {\n const clearsError =\n prev.errorField === \"form\" ||\n prev.errorField === key ||\n (key === \"authType\" && prev.errorField === \"bearerToken\");\n return {\n ...prev,\n [key]: value,\n ...(clearsError ? { error: null, errorField: null } : {}),\n };\n });\n },\n [],\n );\n\n const reset = useCallback(() => setState(INITIAL), []);\n\n const buildAuth = useCallback((): MCPAuthConfig => {\n switch (state.authType) {\n case \"none\":\n return { type: \"none\" };\n case \"bearer\":\n return { type: \"bearer\", token: state.bearerToken || undefined };\n case \"oauth\": {\n const scopeList = state.scopes\n .split(/[\\s,]+/)\n .map((s) => s.trim())\n .filter(Boolean);\n return {\n type: \"oauth\",\n scopes: scopeList.length > 0 ? scopeList : undefined,\n };\n }\n }\n }, [state.authType, state.bearerToken, state.scopes]);\n\n const submit = useCallback(async () => {\n if (state.submitting) return;\n if (!state.name.trim()) {\n setState((p) => ({\n ...p,\n error: \"Name is required\",\n errorField: \"name\",\n }));\n return;\n }\n if (state.authType === \"bearer\" && !state.bearerToken.trim()) {\n setState((p) => ({\n ...p,\n error: \"Bearer token is required\",\n errorField: \"bearerToken\",\n }));\n return;\n }\n const urlResult = validateUrl(state.url);\n if (\"error\" in urlResult) {\n setState((p) => ({\n ...p,\n error: urlResult.error,\n errorField: \"url\",\n }));\n return;\n }\n setState((p) => ({\n ...p,\n submitting: true,\n error: null,\n errorField: null,\n }));\n try {\n const id = await aui.mcp.addCustomServer({\n name: state.name.trim(),\n url: urlResult.url,\n auth: buildAuth(),\n });\n setState(INITIAL);\n invokeMcpCallback(\"onSubmitted\", onSubmitted, id);\n } catch (err) {\n setState((p) => ({\n ...p,\n submitting: false,\n error: err instanceof Error ? err.message : String(err),\n errorField: \"form\",\n }));\n }\n }, [aui, buildAuth, onSubmitted, state]);\n\n const cancel = useCallback(() => {\n setState(INITIAL);\n onCancel?.();\n }, [onCancel]);\n\n const value = useMemo(\n () => ({ state, ids, setField, reset, submit, cancel }),\n [state, ids, setField, reset, submit, cancel],\n );\n\n const onFormSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n void submit();\n };\n\n return (\n <AddFormContext.Provider value={value}>\n <Primitive.form {...props} ref={ref} onSubmit={onFormSubmit} />\n </AddFormContext.Provider>\n );\n});\n\nMcpAddFormPrimitiveRoot.displayName = \"McpAddFormPrimitive.Root\";\n"],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
+ import { Primitive } from "@radix-ui/react-primitive";
3
+ //#region src/primitives/addForm/McpAddFormScopesField.d.ts
4
+ export declare namespace McpAddFormPrimitiveScopesField {
5
+ type Element = ComponentRef<typeof Primitive.input>;
6
+ type Props = Omit<ComponentPropsWithoutRef<typeof Primitive.input>, "value" | "onChange" | "type">;
7
+ }
8
+ export declare const McpAddFormPrimitiveScopesField: import("react").ForwardRefExoticComponent<McpAddFormPrimitiveScopesField.Props & import("react").RefAttributes<HTMLInputElement>>;
9
+ //#endregion
10
+ //# sourceMappingURL=McpAddFormScopesField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpAddFormScopesField.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormScopesField.tsx"],"mappings":";;;yBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,KAClB,gCAAgC,UAAU;;qBAKjC,gDAA8B,0BAAA,+BAAA,wBAAA,cAAA"}
@@ -0,0 +1,38 @@
1
+ import { useAddForm } from "./context.js";
2
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
3
+ import { forwardRef } from "@assistant-ui/tap/react-shim";
4
+ import { Primitive } from "@radix-ui/react-primitive";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/primitives/addForm/McpAddFormScopesField.tsx
7
+ const McpAddFormPrimitiveScopesField = forwardRef((props, ref) => {
8
+ const $ = c(7);
9
+ const { state, setField } = useAddForm();
10
+ let t0;
11
+ if ($[0] !== setField) {
12
+ t0 = (e) => setField("scopes", e.target.value);
13
+ $[0] = setField;
14
+ $[1] = t0;
15
+ } else t0 = $[1];
16
+ let t1;
17
+ if ($[2] !== props || $[3] !== ref || $[4] !== state.scopes || $[5] !== t0) {
18
+ t1 = /* @__PURE__ */ jsx(Primitive.input, {
19
+ type: "text",
20
+ placeholder: "Scopes (space-separated, optional)",
21
+ ...props,
22
+ ref,
23
+ value: state.scopes,
24
+ onChange: t0
25
+ });
26
+ $[2] = props;
27
+ $[3] = ref;
28
+ $[4] = state.scopes;
29
+ $[5] = t0;
30
+ $[6] = t1;
31
+ } else t1 = $[6];
32
+ return t1;
33
+ });
34
+ McpAddFormPrimitiveScopesField.displayName = "McpAddFormPrimitive.ScopesField";
35
+ //#endregion
36
+ export { McpAddFormPrimitiveScopesField };
37
+
38
+ //# sourceMappingURL=McpAddFormScopesField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpAddFormScopesField.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useAddForm","McpAddFormPrimitiveScopesField","Element","input","Props","Omit","props","ref","$","_c","state","setField","t0","e","target","value","t1","scopes","displayName"],"sources":["../../../src/primitives/addForm/McpAddFormScopesField.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAddForm } from \"./context\";\n\nexport namespace McpAddFormPrimitiveScopesField {\n export type Element = ComponentRef<typeof Primitive.input>;\n export type Props = Omit<\n ComponentPropsWithoutRef<typeof Primitive.input>,\n \"value\" | \"onChange\" | \"type\"\n >;\n}\n\nexport const McpAddFormPrimitiveScopesField = forwardRef<\n McpAddFormPrimitiveScopesField.Element,\n McpAddFormPrimitiveScopesField.Props\n>((props, ref) => {\n const { state, setField } = useAddForm();\n return (\n <Primitive.input\n type=\"text\"\n placeholder=\"Scopes (space-separated, optional)\"\n {...props}\n ref={ref}\n value={state.scopes}\n onChange={(e) => setField(\"scopes\", e.target.value)}\n />\n );\n});\n\nMcpAddFormPrimitiveScopesField.displayName = \"McpAddFormPrimitive.ScopesField\";\n"],"mappings":";;;;;;AAgBA,MAAaK,iCAAiCH,YAG5CQ,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACA,MAAA,EAAAC,OAAAC,aAA4BX,WAAW;CAAE,IAAAY;CAAA,IAAAJ,EAAA,OAAAG,UAAA;EAQ3BC,MAAAC,MAAOF,SAAS,UAAUE,EAACC,OAAOC,KAAM;EAACP,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAE,MAAAO,UAAAT,EAAA,OAAAI,IAAA;EANrDI,KAAA,oBAAA,UAAA,OAAA;GACO,MAAA;GACO,aAAA;GAAoC,GAC5CV;GACCC;GACE,OAAAG,MAAKO;GACF,UAAAL;EAAyC,CAAA;EACnDJ,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAE,MAAAO;EAAAT,EAAA,KAAAI;EAAAJ,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAPFQ;AAOE,CAEL;AAEDf,+BAA+BiB,cAAc"}
@@ -1,13 +1,12 @@
1
1
  import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
2
  import { Primitive } from "@radix-ui/react-primitive";
3
3
  //#region src/primitives/addForm/McpAddFormSubmit.d.ts
4
- declare namespace McpAddFormPrimitiveSubmit {
4
+ export declare namespace McpAddFormPrimitiveSubmit {
5
5
  type Element = ComponentRef<typeof Primitive.button>;
6
6
  type Props = ComponentPropsWithoutRef<typeof Primitive.button>;
7
7
  }
8
- declare const McpAddFormPrimitiveSubmit: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
8
+ export declare const McpAddFormPrimitiveSubmit: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
9
9
  asChild?: boolean;
10
10
  }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
11
11
  //#endregion
12
- export { McpAddFormPrimitiveSubmit };
13
12
  //# sourceMappingURL=McpAddFormSubmit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpAddFormSubmit.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormSubmit.tsx"],"mappings":";;;kBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;cAGnD,2CAAyB,0BAAA,qBAAA,gBAAA,qCAAA,qBAAA;;4BAcpC,cAAA"}
1
+ {"version":3,"file":"McpAddFormSubmit.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormSubmit.tsx"],"mappings":";;;yBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;qBAGnD,2CAAyB,0BAAA,qBAAA,gBAAA,qCAAA,qBAAA;;4BAcpC,cAAA"}
@@ -1,11 +1,10 @@
1
1
  import { ComponentPropsWithoutRef, ComponentRef } from "react";
2
2
  import { Primitive } from "@radix-ui/react-primitive";
3
3
  //#region src/primitives/addForm/McpAddFormUrlField.d.ts
4
- declare namespace McpAddFormPrimitiveUrlField {
4
+ export declare namespace McpAddFormPrimitiveUrlField {
5
5
  type Element = ComponentRef<typeof Primitive.input>;
6
6
  type Props = Omit<ComponentPropsWithoutRef<typeof Primitive.input>, "value" | "onChange" | "type">;
7
7
  }
8
- declare const McpAddFormPrimitiveUrlField: import("react").ForwardRefExoticComponent<McpAddFormPrimitiveUrlField.Props & import("react").RefAttributes<HTMLInputElement>>;
8
+ export declare const McpAddFormPrimitiveUrlField: import("react").ForwardRefExoticComponent<McpAddFormPrimitiveUrlField.Props & import("react").RefAttributes<HTMLInputElement>>;
9
9
  //#endregion
10
- export { McpAddFormPrimitiveUrlField };
11
10
  //# sourceMappingURL=McpAddFormUrlField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpAddFormUrlField.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormUrlField.tsx"],"mappings":";;;kBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,KAClB,gCAAgC,UAAU;;cAKjC,6CAA2B,0BAAA,4BAAA,wBAAA,cAAA"}
1
+ {"version":3,"file":"McpAddFormUrlField.d.ts","names":[],"sources":["../../../src/primitives/addForm/McpAddFormUrlField.tsx"],"mappings":";;;yBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,KAClB,gCAAgC,UAAU;;qBAKjC,6CAA2B,0BAAA,4BAAA,wBAAA,cAAA"}
@@ -5,32 +5,45 @@ import { Primitive } from "@radix-ui/react-primitive";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/primitives/addForm/McpAddFormUrlField.tsx
7
7
  const McpAddFormPrimitiveUrlField = forwardRef((props, ref) => {
8
- const $ = c(7);
9
- const { state, setField } = useAddForm();
10
- let t0;
11
- if ($[0] !== setField) {
12
- t0 = (e) => setField("url", e.target.value);
13
- $[0] = setField;
14
- $[1] = t0;
15
- } else t0 = $[1];
8
+ const $ = c(13);
9
+ const { state, ids, setField } = useAddForm();
10
+ const t0 = props["aria-invalid"] ?? (state.errorField === "url" ? true : void 0);
16
11
  let t1;
17
- if ($[2] !== props || $[3] !== ref || $[4] !== state.url || $[5] !== t0) {
18
- t1 = /* @__PURE__ */ jsx(Primitive.input, {
12
+ if ($[0] !== ids || $[1] !== props || $[2] !== state.errorField) {
13
+ t1 = [props["aria-describedby"], state.errorField === "url" ? ids.error : null].filter(Boolean).join(" ") || void 0;
14
+ $[0] = ids;
15
+ $[1] = props;
16
+ $[2] = state.errorField;
17
+ $[3] = t1;
18
+ } else t1 = $[3];
19
+ let t2;
20
+ if ($[4] !== setField) {
21
+ t2 = (e) => setField("url", e.target.value);
22
+ $[4] = setField;
23
+ $[5] = t2;
24
+ } else t2 = $[5];
25
+ let t3;
26
+ if ($[6] !== props || $[7] !== ref || $[8] !== state.url || $[9] !== t0 || $[10] !== t1 || $[11] !== t2) {
27
+ t3 = /* @__PURE__ */ jsx(Primitive.input, {
19
28
  type: "url",
20
29
  inputMode: "url",
21
30
  placeholder: "https://example.com/mcp",
22
31
  ...props,
32
+ "aria-invalid": t0,
33
+ "aria-describedby": t1,
23
34
  ref,
24
35
  value: state.url,
25
- onChange: t0
36
+ onChange: t2
26
37
  });
27
- $[2] = props;
28
- $[3] = ref;
29
- $[4] = state.url;
30
- $[5] = t0;
31
- $[6] = t1;
32
- } else t1 = $[6];
33
- return t1;
38
+ $[6] = props;
39
+ $[7] = ref;
40
+ $[8] = state.url;
41
+ $[9] = t0;
42
+ $[10] = t1;
43
+ $[11] = t2;
44
+ $[12] = t3;
45
+ } else t3 = $[12];
46
+ return t3;
34
47
  });
35
48
  McpAddFormPrimitiveUrlField.displayName = "McpAddFormPrimitive.UrlField";
36
49
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"McpAddFormUrlField.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useAddForm","McpAddFormPrimitiveUrlField","Element","input","Props","Omit","props","ref","$","_c","state","setField","t0","e","target","value","t1","url","displayName"],"sources":["../../../src/primitives/addForm/McpAddFormUrlField.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAddForm } from \"./context\";\n\nexport namespace McpAddFormPrimitiveUrlField {\n export type Element = ComponentRef<typeof Primitive.input>;\n export type Props = Omit<\n ComponentPropsWithoutRef<typeof Primitive.input>,\n \"value\" | \"onChange\" | \"type\"\n >;\n}\n\nexport const McpAddFormPrimitiveUrlField = forwardRef<\n McpAddFormPrimitiveUrlField.Element,\n McpAddFormPrimitiveUrlField.Props\n>((props, ref) => {\n const { state, setField } = useAddForm();\n return (\n <Primitive.input\n type=\"url\"\n inputMode=\"url\"\n placeholder=\"https://example.com/mcp\"\n {...props}\n ref={ref}\n value={state.url}\n onChange={(e) => setField(\"url\", e.target.value)}\n />\n );\n});\n\nMcpAddFormPrimitiveUrlField.displayName = \"McpAddFormPrimitive.UrlField\";\n"],"mappings":";;;;;;AAgBA,MAAaK,8BAA8BH,YAGzCQ,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACA,MAAA,EAAAC,OAAAC,aAA4BX,WAAW;CAAE,IAAAY;CAAA,IAAAJ,EAAA,OAAAG,UAAA;EAS3BC,MAAAC,MAAOF,SAAS,OAAOE,EAACC,OAAOC,KAAM;EAACP,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAE,MAAAO,OAAAT,EAAA,OAAAI,IAAA;EAPlDI,KAAA,oBAAA,UAAA,OAAA;GACO,MAAA;GACK,WAAA;GACE,aAAA;GAAyB,GACjCV;GACCC;GACE,OAAAG,MAAKO;GACF,UAAAL;EAAsC,CAAA;EAChDJ,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAE,MAAAO;EAAAT,EAAA,KAAAI;EAAAJ,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OARFQ;AAQE,CAEL;AAEDf,4BAA4BiB,cAAc"}
1
+ {"version":3,"file":"McpAddFormUrlField.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useAddForm","McpAddFormPrimitiveUrlField","Element","input","Props","Omit","props","ref","$","_c","state","ids","setField","t0","errorField","undefined","t1","error","filter","Boolean","join","t2","e","target","value","t3","url","displayName"],"sources":["../../../src/primitives/addForm/McpAddFormUrlField.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useAddForm } from \"./context\";\n\nexport namespace McpAddFormPrimitiveUrlField {\n export type Element = ComponentRef<typeof Primitive.input>;\n export type Props = Omit<\n ComponentPropsWithoutRef<typeof Primitive.input>,\n \"value\" | \"onChange\" | \"type\"\n >;\n}\n\nexport const McpAddFormPrimitiveUrlField = forwardRef<\n McpAddFormPrimitiveUrlField.Element,\n McpAddFormPrimitiveUrlField.Props\n>((props, ref) => {\n const { state, ids, setField } = useAddForm();\n return (\n <Primitive.input\n type=\"url\"\n inputMode=\"url\"\n placeholder=\"https://example.com/mcp\"\n {...props}\n aria-invalid={\n props[\"aria-invalid\"] ?? (state.errorField === \"url\" ? true : undefined)\n }\n aria-describedby={\n [\n props[\"aria-describedby\"],\n state.errorField === \"url\" ? ids.error : null,\n ]\n .filter(Boolean)\n .join(\" \") || undefined\n }\n ref={ref}\n value={state.url}\n onChange={(e) => setField(\"url\", e.target.value)}\n />\n );\n});\n\nMcpAddFormPrimitiveUrlField.displayName = \"McpAddFormPrimitive.UrlField\";\n"],"mappings":";;;;;;AAgBA,MAAaK,8BAA8BH,YAGzCQ,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACA,MAAA,EAAAC,OAAAC,KAAAC,aAAiCZ,WAAW;CAQtC,MAAAa,KAAAP,MAAM,oBAAoBI,MAAKI,eAAgB,QAArB,OAAAC,KAAAA;CAA8C,IAAAC;CAAA,IAAAR,EAAA,OAAAG,OAAAH,EAAA,OAAAF,SAAAE,EAAA,OAAAE,MAAAI,YAAA;EAGxEE,KAAA,CACEV,MAAM,qBACNI,MAAKI,eAAgB,QAAQH,IAAGM,QAAhC,IAA6C,CAC9C,CAAAC,OACSC,OAAO,CAAC,CAAAC,KACV,GAAgB,KALxBL,KAAAA;EAKyBP,EAAA,KAAAG;EAAAH,EAAA,KAAAF;EAAAE,EAAA,KAAAE,MAAAI;EAAAN,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,OAAAI,UAAA;EAIjBS,MAAAC,MAAOV,SAAS,OAAOU,EAACC,OAAOC,KAAM;EAAChB,EAAA,KAAAI;EAAAJ,EAAA,KAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,IAAAiB;CAAA,IAAAjB,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAE,MAAAgB,OAAAlB,EAAA,OAAAK,MAAAL,EAAA,QAAAQ,MAAAR,EAAA,QAAAa,IAAA;EAlBlDI,KAAA,oBAAA,UAAA,OAAA;GACO,MAAA;GACK,WAAA;GACE,aAAA;GAAyB,GACjCnB;GAEF,gBAAAO;GAGA,oBAAAG;GAOGT;GACE,OAAAG,MAAKgB;GACF,UAAAL;EAAsC,CAAA;EAChDb,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAE,MAAAgB;EAAAlB,EAAA,KAAAK;EAAAL,EAAA,MAAAQ;EAAAR,EAAA,MAAAa;EAAAb,EAAA,MAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,OAnBFiB;AAmBE,CAEL;AAEDxB,4BAA4B0B,cAAc"}
@@ -1,7 +1,13 @@
1
1
  import { MCPAuthConfig } from "../../mcp-scope.js";
2
2
  //#region src/primitives/addForm/context.d.ts
3
- type AddFormAuthType = MCPAuthConfig["type"];
4
- type AddFormState = {
3
+ export type AddFormAuthType = MCPAuthConfig["type"];
4
+ export type AddFormErrorField = "name" | "url" | "bearerToken" | "form" | null;
5
+ export type AddFormFieldIds = {
6
+ bearerToken: string;
7
+ scopes: string;
8
+ error: string;
9
+ };
10
+ export type AddFormState = {
5
11
  name: string;
6
12
  url: string;
7
13
  authType: AddFormAuthType;
@@ -9,16 +15,17 @@ type AddFormState = {
9
15
  scopes: string;
10
16
  submitting: boolean;
11
17
  error: string | null;
18
+ errorField: AddFormErrorField;
12
19
  };
13
- type AddFormContextValue = {
20
+ export type AddFormContextValue = {
14
21
  state: AddFormState;
22
+ ids: AddFormFieldIds;
15
23
  setField: <K extends keyof AddFormState>(key: K, value: AddFormState[K]) => void;
16
24
  reset: () => void;
17
25
  submit: () => Promise<void>;
18
26
  cancel: () => void;
19
27
  };
20
- declare const AddFormContext: import("react").Context<AddFormContextValue | null>;
21
- declare const useAddForm: () => AddFormContextValue;
28
+ export declare const AddFormContext: import("react").Context<AddFormContextValue | null>;
29
+ export declare const useAddForm: () => AddFormContextValue;
22
30
  //#endregion
23
- export { AddFormAuthType, AddFormContext, AddFormContextValue, AddFormState, useAddForm };
24
31
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/primitives/addForm/context.tsx"],"mappings":";;KAGY,kBAAkB;KAElB;EACV;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;;KAGU;EACV,OAAO;EACP,WAAW,gBAAgB,cACzB,KAAK,GACL,OAAO,aAAa;EAEtB;EACA,cAAc;EACd;;cAGW,gCAAc,QAAA;cAEd,kBAAiB"}
1
+ {"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/primitives/addForm/context.tsx"],"mappings":";;YAGY,kBAAkB;YAElB;YAEA;EACV;EACA;EACA;;YAGU;EACV;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA,YAAY;;YAGF;EACV,OAAO;EACP,KAAK;EACL,WAAW,gBAAgB,cACzB,KAAK,GACL,OAAO,aAAa;EAEtB;EACA,cAAc;EACd;;qBAGW,gCAAc,QAAA;qBAEd,kBAAiB"}