@btst/stack 1.5.2 → 1.7.0

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 (241) hide show
  1. package/dist/api/index.cjs +7 -1
  2. package/dist/api/index.d.cts +2 -2
  3. package/dist/api/index.d.mts +2 -2
  4. package/dist/api/index.d.ts +2 -2
  5. package/dist/api/index.mjs +7 -1
  6. package/dist/client/index.d.cts +1 -1
  7. package/dist/client/index.d.mts +1 -1
  8. package/dist/client/index.d.ts +1 -1
  9. package/dist/index.d.cts +1 -1
  10. package/dist/index.d.mts +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@19.2.0/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.cjs +68 -0
  13. package/dist/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@19.2.0/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.mjs +60 -0
  14. package/dist/node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@dnd-kit/core/dist/core.esm.cjs +3937 -0
  15. package/dist/node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@dnd-kit/core/dist/core.esm.mjs +3907 -0
  16. package/dist/node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.cjs +30 -0
  17. package/dist/node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.mjs +28 -0
  18. package/dist/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.cjs +675 -0
  19. package/dist/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.mjs +661 -0
  20. package/dist/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@19.2.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.cjs +358 -0
  21. package/dist/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@19.2.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.mjs +332 -0
  22. package/dist/node_modules/.pnpm/@radix-ui_react-tabs@1.1.13_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_865f042350eb43f3338b0fffb33f6246/node_modules/@radix-ui/react-tabs/dist/index.cjs +211 -0
  23. package/dist/node_modules/.pnpm/@radix-ui_react-tabs@1.1.13_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_865f042350eb43f3338b0fffb33f6246/node_modules/@radix-ui/react-tabs/dist/index.mjs +188 -0
  24. package/dist/packages/better-stack/src/plugins/cms/api/plugin.cjs +3 -2
  25. package/dist/packages/better-stack/src/plugins/cms/api/plugin.mjs +3 -2
  26. package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.cjs +15 -15
  27. package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.mjs +16 -16
  28. package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.cjs +588 -0
  29. package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.mjs +586 -0
  30. package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +131 -0
  31. package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +129 -0
  32. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.cjs +32 -0
  33. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.mjs +30 -0
  34. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.cjs +21 -0
  35. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.mjs +19 -0
  36. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.cjs +34 -0
  37. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.mjs +32 -0
  38. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.cjs +20 -0
  39. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.mjs +18 -0
  40. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +19 -0
  41. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +186 -0
  42. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +184 -0
  43. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +17 -0
  44. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +19 -0
  45. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +165 -0
  46. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +163 -0
  47. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +17 -0
  48. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +19 -0
  49. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +177 -0
  50. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +175 -0
  51. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +17 -0
  52. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.cjs +17 -0
  53. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.mjs +15 -0
  54. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.cjs +16 -0
  55. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.mjs +14 -0
  56. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +27 -0
  57. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +25 -0
  58. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.cjs +39 -0
  59. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.mjs +37 -0
  60. package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +551 -0
  61. package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +537 -0
  62. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.cjs +36 -0
  63. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.mjs +34 -0
  64. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.cjs +19 -0
  65. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.mjs +17 -0
  66. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.cjs +21 -0
  67. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.mjs +19 -0
  68. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.cjs +19 -0
  69. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.mjs +17 -0
  70. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.cjs +14 -0
  71. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.mjs +12 -0
  72. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.cjs +17 -0
  73. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.mjs +15 -0
  74. package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.cjs +278 -0
  75. package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.mjs +276 -0
  76. package/dist/packages/better-stack/src/plugins/form-builder/db.cjs +99 -0
  77. package/dist/packages/better-stack/src/plugins/form-builder/db.mjs +97 -0
  78. package/dist/packages/better-stack/src/plugins/form-builder/schemas.cjs +82 -0
  79. package/dist/packages/better-stack/src/plugins/form-builder/schemas.mjs +74 -0
  80. package/dist/packages/better-stack/src/plugins/form-builder/utils.cjs +37 -0
  81. package/dist/packages/better-stack/src/plugins/form-builder/utils.mjs +29 -0
  82. package/dist/packages/better-stack/src/plugins/open-api/api/generator.cjs +300 -0
  83. package/dist/packages/better-stack/src/plugins/open-api/api/generator.mjs +284 -0
  84. package/dist/packages/better-stack/src/plugins/open-api/api/plugin.cjs +115 -0
  85. package/dist/packages/better-stack/src/plugins/open-api/api/plugin.mjs +113 -0
  86. package/dist/packages/better-stack/src/plugins/open-api/db.cjs +7 -0
  87. package/dist/packages/better-stack/src/plugins/open-api/db.mjs +5 -0
  88. package/dist/packages/better-stack/src/plugins/open-api/logo.cjs +8 -0
  89. package/dist/packages/better-stack/src/plugins/open-api/logo.mjs +6 -0
  90. package/dist/packages/ui/src/components/auto-form/index.cjs +2 -12
  91. package/dist/packages/ui/src/components/auto-form/index.mjs +2 -9
  92. package/dist/packages/ui/src/components/auto-form/stepped-auto-form.cjs +377 -0
  93. package/dist/packages/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
  94. package/dist/packages/ui/src/components/auto-form/utils.cjs +1 -56
  95. package/dist/packages/ui/src/components/auto-form/utils.mjs +2 -56
  96. package/dist/packages/ui/src/components/form-builder/canvas.cjs +111 -0
  97. package/dist/packages/ui/src/components/form-builder/canvas.mjs +109 -0
  98. package/dist/packages/ui/src/components/form-builder/components/index.cjs +570 -0
  99. package/dist/packages/ui/src/components/form-builder/components/index.mjs +553 -0
  100. package/dist/packages/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
  101. package/dist/packages/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
  102. package/dist/packages/ui/src/components/form-builder/form-preview.cjs +73 -0
  103. package/dist/packages/ui/src/components/form-builder/form-preview.mjs +71 -0
  104. package/dist/packages/ui/src/components/form-builder/index.cjs +353 -0
  105. package/dist/packages/ui/src/components/form-builder/index.mjs +344 -0
  106. package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
  107. package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
  108. package/dist/packages/ui/src/components/form-builder/palette.cjs +52 -0
  109. package/dist/packages/ui/src/components/form-builder/palette.mjs +49 -0
  110. package/dist/packages/ui/src/components/form-builder/schema-utils.cjs +120 -0
  111. package/dist/packages/ui/src/components/form-builder/schema-utils.mjs +114 -0
  112. package/dist/packages/ui/src/components/form-builder/sortable-field.cjs +151 -0
  113. package/dist/packages/ui/src/components/form-builder/sortable-field.mjs +148 -0
  114. package/dist/packages/ui/src/components/form-builder/step-tabs.cjs +180 -0
  115. package/dist/packages/ui/src/components/form-builder/step-tabs.mjs +178 -0
  116. package/dist/packages/ui/src/components/form-builder/types.cjs +7 -0
  117. package/dist/packages/ui/src/components/form-builder/types.mjs +5 -0
  118. package/dist/packages/ui/src/components/form-builder/validation-schemas.cjs +67 -0
  119. package/dist/packages/ui/src/components/form-builder/validation-schemas.mjs +56 -0
  120. package/dist/packages/ui/src/components/tabs.cjs +70 -0
  121. package/dist/packages/ui/src/components/tabs.mjs +65 -0
  122. package/dist/packages/ui/src/lib/schema-converter.cjs +130 -0
  123. package/dist/packages/ui/src/lib/schema-converter.mjs +124 -0
  124. package/dist/plugins/api/index.d.cts +2 -2
  125. package/dist/plugins/api/index.d.mts +2 -2
  126. package/dist/plugins/api/index.d.ts +2 -2
  127. package/dist/plugins/blog/api/index.d.cts +1 -1
  128. package/dist/plugins/blog/api/index.d.mts +1 -1
  129. package/dist/plugins/blog/api/index.d.ts +1 -1
  130. package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
  131. package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
  132. package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
  133. package/dist/plugins/blog/client/index.d.cts +1 -1
  134. package/dist/plugins/blog/client/index.d.mts +1 -1
  135. package/dist/plugins/blog/client/index.d.ts +1 -1
  136. package/dist/plugins/blog/query-keys.d.cts +2 -2
  137. package/dist/plugins/blog/query-keys.d.mts +2 -2
  138. package/dist/plugins/blog/query-keys.d.ts +2 -2
  139. package/dist/plugins/client/index.d.cts +2 -2
  140. package/dist/plugins/client/index.d.mts +2 -2
  141. package/dist/plugins/client/index.d.ts +2 -2
  142. package/dist/plugins/cms/client/index.cjs +6 -0
  143. package/dist/plugins/cms/client/index.d.cts +6 -113
  144. package/dist/plugins/cms/client/index.d.mts +6 -113
  145. package/dist/plugins/cms/client/index.d.ts +6 -113
  146. package/dist/plugins/cms/client/index.mjs +1 -0
  147. package/dist/plugins/form-builder/api/index.cjs +7 -0
  148. package/dist/plugins/form-builder/api/index.d.cts +141 -0
  149. package/dist/plugins/form-builder/api/index.d.mts +141 -0
  150. package/dist/plugins/form-builder/api/index.d.ts +141 -0
  151. package/dist/plugins/form-builder/api/index.mjs +1 -0
  152. package/dist/plugins/form-builder/client/components/index.cjs +29 -0
  153. package/dist/plugins/form-builder/client/components/index.d.cts +93 -0
  154. package/dist/plugins/form-builder/client/components/index.d.mts +93 -0
  155. package/dist/plugins/form-builder/client/components/index.d.ts +93 -0
  156. package/dist/plugins/form-builder/client/components/index.mjs +18 -0
  157. package/dist/plugins/form-builder/client/hooks/index.cjs +19 -0
  158. package/dist/plugins/form-builder/client/hooks/index.d.cts +154 -0
  159. package/dist/plugins/form-builder/client/hooks/index.d.mts +154 -0
  160. package/dist/plugins/form-builder/client/hooks/index.d.ts +154 -0
  161. package/dist/plugins/form-builder/client/hooks/index.mjs +1 -0
  162. package/dist/plugins/form-builder/client/index.cjs +13 -0
  163. package/dist/plugins/form-builder/client/index.d.cts +381 -0
  164. package/dist/plugins/form-builder/client/index.d.mts +381 -0
  165. package/dist/plugins/form-builder/client/index.d.ts +381 -0
  166. package/dist/plugins/form-builder/client/index.mjs +2 -0
  167. package/dist/plugins/form-builder/client.css +3 -0
  168. package/dist/plugins/form-builder/query-keys.cjs +143 -0
  169. package/dist/plugins/form-builder/query-keys.d.cts +74 -0
  170. package/dist/plugins/form-builder/query-keys.d.mts +74 -0
  171. package/dist/plugins/form-builder/query-keys.d.ts +74 -0
  172. package/dist/plugins/form-builder/query-keys.mjs +141 -0
  173. package/dist/plugins/form-builder/style.css +19 -0
  174. package/dist/plugins/open-api/api/index.cjs +9 -0
  175. package/dist/plugins/open-api/api/index.d.cts +95 -0
  176. package/dist/plugins/open-api/api/index.d.mts +95 -0
  177. package/dist/plugins/open-api/api/index.d.ts +95 -0
  178. package/dist/plugins/open-api/api/index.mjs +2 -0
  179. package/dist/shared/stack.AX5nZ6A3.d.cts +86 -0
  180. package/dist/shared/stack.AX5nZ6A3.d.mts +86 -0
  181. package/dist/shared/stack.AX5nZ6A3.d.ts +86 -0
  182. package/dist/shared/stack.BIh2AXaW.d.cts +123 -0
  183. package/dist/shared/stack.BIh2AXaW.d.mts +123 -0
  184. package/dist/shared/stack.BIh2AXaW.d.ts +123 -0
  185. package/dist/shared/{stack.ByOugz9d.d.cts → stack.CSce37mX.d.cts} +15 -2
  186. package/dist/shared/{stack.ByOugz9d.d.mts → stack.CSce37mX.d.mts} +15 -2
  187. package/dist/shared/{stack.ByOugz9d.d.ts → stack.CSce37mX.d.ts} +15 -2
  188. package/dist/shared/stack.DzH_wcvr.d.cts +195 -0
  189. package/dist/shared/stack.DzH_wcvr.d.mts +195 -0
  190. package/dist/shared/stack.DzH_wcvr.d.ts +195 -0
  191. package/package.json +67 -1
  192. package/src/api/index.ts +14 -2
  193. package/src/plugins/cms/api/plugin.ts +9 -4
  194. package/src/plugins/cms/client/components/forms/content-form.tsx +23 -25
  195. package/src/plugins/cms/client/index.ts +11 -0
  196. package/src/plugins/form-builder/api/index.ts +1 -0
  197. package/src/plugins/form-builder/api/plugin.ts +776 -0
  198. package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +253 -0
  199. package/src/plugins/form-builder/client/components/index.tsx +24 -0
  200. package/src/plugins/form-builder/client/components/loading/form-builder-skeleton.tsx +42 -0
  201. package/src/plugins/form-builder/client/components/loading/form-list-skeleton.tsx +25 -0
  202. package/src/plugins/form-builder/client/components/loading/index.tsx +3 -0
  203. package/src/plugins/form-builder/client/components/loading/submissions-skeleton.tsx +40 -0
  204. package/src/plugins/form-builder/client/components/pages/404-page.tsx +28 -0
  205. package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +253 -0
  206. package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +26 -0
  207. package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +231 -0
  208. package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +22 -0
  209. package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +268 -0
  210. package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +26 -0
  211. package/src/plugins/form-builder/client/components/shared/default-error.tsx +30 -0
  212. package/src/plugins/form-builder/client/components/shared/empty-state.tsx +26 -0
  213. package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +32 -0
  214. package/src/plugins/form-builder/client/components/shared/pagination.tsx +52 -0
  215. package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +799 -0
  216. package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
  217. package/src/plugins/form-builder/client/index.ts +22 -0
  218. package/src/plugins/form-builder/client/localization/form-builder-common.ts +36 -0
  219. package/src/plugins/form-builder/client/localization/form-builder-editor.ts +18 -0
  220. package/src/plugins/form-builder/client/localization/form-builder-list.ts +17 -0
  221. package/src/plugins/form-builder/client/localization/form-builder-submissions.ts +17 -0
  222. package/src/plugins/form-builder/client/localization/form-builder-toasts.ts +10 -0
  223. package/src/plugins/form-builder/client/localization/index.ts +15 -0
  224. package/src/plugins/form-builder/client/overrides.ts +146 -0
  225. package/src/plugins/form-builder/client/plugin.tsx +488 -0
  226. package/src/plugins/form-builder/client.css +3 -0
  227. package/src/plugins/form-builder/db.ts +99 -0
  228. package/src/plugins/form-builder/query-keys.ts +198 -0
  229. package/src/plugins/form-builder/schemas.ts +122 -0
  230. package/src/plugins/form-builder/style.css +19 -0
  231. package/src/plugins/form-builder/types.ts +317 -0
  232. package/src/plugins/form-builder/utils.ts +63 -0
  233. package/src/plugins/open-api/api/generator.ts +433 -0
  234. package/src/plugins/open-api/api/index.ts +8 -0
  235. package/src/plugins/open-api/api/plugin.ts +243 -0
  236. package/src/plugins/open-api/db.ts +7 -0
  237. package/src/plugins/open-api/logo.ts +7 -0
  238. package/src/types.ts +15 -1
  239. package/dist/shared/{stack.DLhzx1-D.d.mts → stack.CcI4sYJP.d.cts} +1 -1
  240. package/dist/shared/{stack.DLhzx1-D.d.ts → stack.CcI4sYJP.d.mts} +1 -1
  241. package/dist/shared/{stack.DLhzx1-D.d.cts → stack.CcI4sYJP.d.ts} +1 -1
@@ -0,0 +1,113 @@
1
+ import { defineBackendPlugin, createEndpoint } from '@btst/stack/plugins/api';
2
+ import { openApiSchema } from '../db.mjs';
3
+ import { generateOpenAPISchema } from './generator.mjs';
4
+ import { logo } from '../logo.mjs';
5
+
6
+ function escapeHtml(str) {
7
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
8
+ }
9
+ function escapeJsonForHtml(json) {
10
+ return json.replace(/</g, "\\u003c");
11
+ }
12
+ function getScalarHTML(schema, theme = "default", nonce) {
13
+ const nonceAttr = nonce ? ` nonce="${escapeHtml(nonce)}"` : "";
14
+ const encodedLogo = encodeURIComponent(logo);
15
+ const title = schema.info?.title || "API Reference";
16
+ const description = schema.info?.description || "API Reference";
17
+ return `<!doctype html>
18
+ <html>
19
+ <head>
20
+ <title>${escapeHtml(title)}</title>
21
+ <meta charset="utf-8" />
22
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
23
+ </head>
24
+ <body>
25
+ <script
26
+ id="api-reference"
27
+ type="application/json"${nonceAttr}>
28
+ ${escapeJsonForHtml(JSON.stringify(schema))}
29
+ <\/script>
30
+ <script${nonceAttr}>
31
+ var configuration = {
32
+ favicon: "data:image/svg+xml;utf8,${encodedLogo}",
33
+ theme: "${theme}",
34
+ metaData: {
35
+ title: ${JSON.stringify(title)},
36
+ description: ${JSON.stringify(description)},
37
+ }
38
+ }
39
+
40
+ document.getElementById('api-reference').dataset.configuration =
41
+ JSON.stringify(configuration)
42
+ <\/script>
43
+ <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"${nonceAttr}><\/script>
44
+ </body>
45
+ </html>`;
46
+ }
47
+ const openApiBackendPlugin = (options) => {
48
+ const referencePath = options?.path ?? "/reference";
49
+ let storedContext = null;
50
+ return defineBackendPlugin({
51
+ name: "open-api",
52
+ dbPlugin: openApiSchema,
53
+ routes: (_adapter, context) => {
54
+ storedContext = context ?? null;
55
+ const generateSchema = createEndpoint(
56
+ "/open-api/schema",
57
+ {
58
+ method: "GET"
59
+ },
60
+ async (ctx) => {
61
+ if (!storedContext) {
62
+ throw ctx.error(500, {
63
+ message: "OpenAPI context not available"
64
+ });
65
+ }
66
+ const schema = generateOpenAPISchema(storedContext, {
67
+ title: options?.title,
68
+ description: options?.description,
69
+ version: options?.version
70
+ });
71
+ return schema;
72
+ }
73
+ );
74
+ const reference = createEndpoint(
75
+ referencePath,
76
+ {
77
+ method: "GET"
78
+ },
79
+ async (ctx) => {
80
+ if (options?.disableDefaultReference) {
81
+ throw ctx.error(404, {
82
+ message: "Reference page is disabled"
83
+ });
84
+ }
85
+ if (!storedContext) {
86
+ throw ctx.error(500, {
87
+ message: "OpenAPI context not available"
88
+ });
89
+ }
90
+ const schema = generateOpenAPISchema(storedContext, {
91
+ title: options?.title,
92
+ description: options?.description,
93
+ version: options?.version
94
+ });
95
+ return new Response(
96
+ getScalarHTML(schema, options?.theme, options?.nonce),
97
+ {
98
+ headers: {
99
+ "Content-Type": "text/html; charset=utf-8"
100
+ }
101
+ }
102
+ );
103
+ }
104
+ );
105
+ return {
106
+ generateSchema,
107
+ reference
108
+ };
109
+ }
110
+ });
111
+ };
112
+
113
+ export { openApiBackendPlugin };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const db = require('@btst/db');
4
+
5
+ const openApiSchema = db.createDbPlugin("openApi", {});
6
+
7
+ exports.openApiSchema = openApiSchema;
@@ -0,0 +1,5 @@
1
+ import { createDbPlugin } from '@btst/db';
2
+
3
+ const openApiSchema = createDbPlugin("openApi", {});
4
+
5
+ export { openApiSchema };
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const logo = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" fill="none">
4
+ <rect width="100" height="100" rx="20" fill="#0ea5e9"/>
5
+ <path d="M25 35h50M25 50h50M25 65h35" stroke="white" stroke-width="8" stroke-linecap="round"/>
6
+ </svg>`;
7
+
8
+ exports.logo = logo;
@@ -0,0 +1,6 @@
1
+ const logo = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" fill="none">
2
+ <rect width="100" height="100" rx="20" fill="#0ea5e9"/>
3
+ <path d="M25 35h50M25 50h50M25 65h35" stroke="white" stroke-width="8" stroke-linecap="round"/>
4
+ </svg>`;
5
+
6
+ export { logo };
@@ -1,13 +1,11 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
4
  const jsxRuntime = require('react/jsx-runtime');
7
5
  const form = require('../form.cjs');
8
6
  const React = require('react');
9
7
  const reactHookForm = require('react-hook-form');
10
- const button = require('../button.cjs');
8
+ require('../button.cjs');
11
9
  const utils$1 = require('../../lib/utils.cjs');
12
10
  const zod = require('@hookform/resolvers/zod');
13
11
  const object = require('./fields/object.cjs');
@@ -17,13 +15,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
17
15
 
18
16
  const React__default = /*#__PURE__*/_interopDefaultCompat(React);
19
17
 
20
- function AutoFormSubmit({
21
- children,
22
- className,
23
- disabled
24
- }) {
25
- return /* @__PURE__ */ jsxRuntime.jsx(button.Button, { type: "submit", disabled, className, children: children ?? "Submit" });
26
- }
27
18
  function AutoForm({
28
19
  formSchema,
29
20
  values: valuesProp,
@@ -83,5 +74,4 @@ function AutoForm({
83
74
  ) }) });
84
75
  }
85
76
 
86
- exports.AutoFormSubmit = AutoFormSubmit;
87
- exports.default = AutoForm;
77
+ module.exports = AutoForm;
@@ -3,19 +3,12 @@ import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { Form } from '../form.mjs';
4
4
  import React__default from 'react';
5
5
  import { useForm } from 'react-hook-form';
6
- import { Button } from '../button.mjs';
6
+ import '../button.mjs';
7
7
  import { cn } from '../../lib/utils.mjs';
8
8
  import { zodResolver } from '@hookform/resolvers/zod';
9
9
  import AutoFormObject from './fields/object.mjs';
10
10
  import { getObjectFormSchema, getDefaultValues } from './utils.mjs';
11
11
 
12
- function AutoFormSubmit({
13
- children,
14
- className,
15
- disabled
16
- }) {
17
- return /* @__PURE__ */ jsx(Button, { type: "submit", disabled, className, children: children ?? "Submit" });
18
- }
19
12
  function AutoForm({
20
13
  formSchema,
21
14
  values: valuesProp,
@@ -75,4 +68,4 @@ function AutoForm({
75
68
  ) }) });
76
69
  }
77
70
 
78
- export { AutoFormSubmit, AutoForm as default };
71
+ export { AutoForm as default };
@@ -0,0 +1,377 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const jsxRuntime = require('react/jsx-runtime');
7
+ const React = require('react');
8
+ const z = require('zod');
9
+ const index = require('./index.cjs');
10
+ const button = require('../button.cjs');
11
+ const separator = require('../separator.cjs');
12
+ const utils = require('../../lib/utils.cjs');
13
+
14
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
15
+
16
+ const React__default = /*#__PURE__*/_interopDefaultCompat(React);
17
+
18
+ function extractStepsFromSchema(schema) {
19
+ try {
20
+ const jsonSchema = schema.toJSONSchema();
21
+ if (jsonSchema.steps && Array.isArray(jsonSchema.steps)) {
22
+ return jsonSchema.steps;
23
+ }
24
+ } catch {
25
+ }
26
+ return [];
27
+ }
28
+ function getFieldStepAssignments(schema) {
29
+ const assignments = /* @__PURE__ */ new Map();
30
+ try {
31
+ const jsonSchema = schema.toJSONSchema();
32
+ const stepGroupMap = jsonSchema.stepGroupMap;
33
+ if (stepGroupMap) {
34
+ for (const [fieldName, stepGroup] of Object.entries(stepGroupMap)) {
35
+ assignments.set(fieldName, stepGroup);
36
+ }
37
+ return assignments;
38
+ }
39
+ const properties = jsonSchema.properties;
40
+ if (properties) {
41
+ for (const [fieldName, fieldSchema] of Object.entries(properties)) {
42
+ const stepGroup = fieldSchema.stepGroup;
43
+ if (typeof stepGroup === "number") {
44
+ assignments.set(fieldName, stepGroup);
45
+ } else {
46
+ assignments.set(fieldName, 0);
47
+ }
48
+ }
49
+ }
50
+ } catch {
51
+ }
52
+ return assignments;
53
+ }
54
+ function createStepSchema(fullSchema, stepIndex, fieldAssignments) {
55
+ const fieldsForStep = Array.from(fieldAssignments.entries()).filter(([, step]) => step === stepIndex).map(([field]) => field);
56
+ if (fieldsForStep.length === 0) {
57
+ return z.z.object({});
58
+ }
59
+ const pickObject = {};
60
+ for (const field of fieldsForStep) {
61
+ pickObject[field] = true;
62
+ }
63
+ return fullSchema.pick(pickObject);
64
+ }
65
+ function getObjectSchema(schema) {
66
+ if (schema instanceof z.z.ZodObject) {
67
+ return schema;
68
+ }
69
+ const schemaDef = schema._zod?.def ?? schema._def;
70
+ if (schemaDef) {
71
+ if (schemaDef.schema) {
72
+ return getObjectSchema(schemaDef.schema);
73
+ }
74
+ if (schemaDef.innerType) {
75
+ return getObjectSchema(schemaDef.innerType);
76
+ }
77
+ }
78
+ return null;
79
+ }
80
+ function DefaultStepper({
81
+ steps,
82
+ currentStepIndex,
83
+ onStepClick
84
+ }) {
85
+ return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": "Form Steps", className: "mb-6", children: /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex items-center justify-between gap-2", children: steps.map((step, index) => /* @__PURE__ */ jsxRuntime.jsxs(React__default.Fragment, { children: [
86
+ /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-center gap-2 shrink-0", children: [
87
+ /* @__PURE__ */ jsxRuntime.jsx(
88
+ button.Button,
89
+ {
90
+ type: "button",
91
+ variant: index <= currentStepIndex ? "default" : "secondary",
92
+ "aria-current": currentStepIndex === index ? "step" : void 0,
93
+ "aria-posinset": index + 1,
94
+ "aria-setsize": steps.length,
95
+ className: "size-10 rounded-full p-0",
96
+ onClick: () => onStepClick?.(step.id),
97
+ children: index + 1
98
+ }
99
+ ),
100
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium hidden sm:inline", children: step.label })
101
+ ] }),
102
+ index < steps.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(
103
+ separator.Separator,
104
+ {
105
+ className: utils.cn(
106
+ "flex-1 min-w-4",
107
+ index < currentStepIndex ? "bg-primary" : "bg-muted"
108
+ )
109
+ }
110
+ )
111
+ ] }, step.id)) }) });
112
+ }
113
+ function SteppedAutoForm({
114
+ formSchema,
115
+ values: initialValues,
116
+ onValuesChange,
117
+ onSubmit,
118
+ fieldConfig,
119
+ children,
120
+ className,
121
+ nextButtonText = "Next",
122
+ backButtonText = "Back",
123
+ submitButtonText = "Submit",
124
+ StepperComponent = DefaultStepper,
125
+ isSubmitting = false
126
+ }) {
127
+ const steps = React.useMemo(() => extractStepsFromSchema(formSchema), [formSchema]);
128
+ const hasMultipleSteps = steps.length > 1;
129
+ const fieldAssignments = React.useMemo(
130
+ () => getFieldStepAssignments(formSchema),
131
+ [formSchema]
132
+ );
133
+ const [currentStepIndex, setCurrentStepIndex] = React.useState(0);
134
+ const [accumulatedValues, setAccumulatedValues] = React.useState(
135
+ initialValues ?? {}
136
+ );
137
+ const [completedSteps, setCompletedSteps] = React.useState(/* @__PURE__ */ new Set());
138
+ const [schemaErrors, setSchemaErrors] = React.useState(null);
139
+ const accumulatedValuesRef = React.useRef(accumulatedValues);
140
+ const onValuesChangeRef = React.useRef(onValuesChange);
141
+ React.useEffect(() => {
142
+ accumulatedValuesRef.current = accumulatedValues;
143
+ }, [accumulatedValues]);
144
+ React.useEffect(() => {
145
+ onValuesChangeRef.current = onValuesChange;
146
+ }, [onValuesChange]);
147
+ React.useEffect(() => {
148
+ if (initialValues) {
149
+ const newValues = {
150
+ ...accumulatedValuesRef.current,
151
+ ...initialValues
152
+ };
153
+ accumulatedValuesRef.current = newValues;
154
+ setAccumulatedValues(newValues);
155
+ }
156
+ }, [initialValues]);
157
+ const objectSchema = React.useMemo(() => getObjectSchema(formSchema), [formSchema]);
158
+ const stepSchemas = React.useMemo(() => {
159
+ if (!hasMultipleSteps || !objectSchema) return [];
160
+ return steps.map(
161
+ (_, index) => createStepSchema(objectSchema, index, fieldAssignments)
162
+ );
163
+ }, [hasMultipleSteps, objectSchema, steps, fieldAssignments]);
164
+ const currentStep = steps[currentStepIndex];
165
+ const currentStepSchema = stepSchemas[currentStepIndex];
166
+ const isFirst = currentStepIndex === 0;
167
+ const isLast = currentStepIndex === steps.length - 1;
168
+ const currentStepFieldConfig = React.useMemo(() => {
169
+ if (!fieldConfig) return void 0;
170
+ const stepFields = Array.from(fieldAssignments.entries()).filter(([, step]) => step === currentStepIndex).map(([field]) => field);
171
+ const filtered = {};
172
+ for (const field of stepFields) {
173
+ if (field in fieldConfig) {
174
+ filtered[field] = fieldConfig[field];
175
+ }
176
+ }
177
+ return filtered;
178
+ }, [fieldConfig, fieldAssignments, currentStepIndex]);
179
+ const currentStepValues = React.useMemo(() => {
180
+ const stepFields = Array.from(fieldAssignments.entries()).filter(([, step]) => step === currentStepIndex).map(([field]) => field);
181
+ const values = {};
182
+ for (const field of stepFields) {
183
+ if (field in accumulatedValues) {
184
+ values[field] = accumulatedValues[field];
185
+ }
186
+ }
187
+ return values;
188
+ }, [fieldAssignments, currentStepIndex, accumulatedValues]);
189
+ const handleStepClick = React.useCallback(
190
+ (stepId) => {
191
+ const stepIndex = steps.findIndex((s) => s.id === stepId);
192
+ if (stepIndex === -1) return;
193
+ const canNavigate = stepIndex === currentStepIndex || completedSteps.has(stepIndex) || stepIndex === currentStepIndex + 1 && completedSteps.has(currentStepIndex);
194
+ if (canNavigate) {
195
+ setCurrentStepIndex(stepIndex);
196
+ setSchemaErrors(null);
197
+ }
198
+ },
199
+ [steps, currentStepIndex, completedSteps]
200
+ );
201
+ const handleStepValuesChange = React.useCallback(
202
+ (stepValues, form) => {
203
+ const newAccumulated = { ...accumulatedValuesRef.current, ...stepValues };
204
+ accumulatedValuesRef.current = newAccumulated;
205
+ setAccumulatedValues(newAccumulated);
206
+ onValuesChangeRef.current?.(newAccumulated, form);
207
+ },
208
+ []
209
+ );
210
+ const handleStepSubmit = React.useCallback(
211
+ (stepValues) => {
212
+ const newAccumulated = { ...accumulatedValuesRef.current, ...stepValues };
213
+ accumulatedValuesRef.current = newAccumulated;
214
+ setAccumulatedValues(newAccumulated);
215
+ onValuesChangeRef.current?.(newAccumulated, void 0);
216
+ setCompletedSteps((prev) => /* @__PURE__ */ new Set([...prev, currentStepIndex]));
217
+ if (isLast) {
218
+ const allStepsCompleted = steps.every(
219
+ (_, index) => index === currentStepIndex || completedSteps.has(index)
220
+ );
221
+ if (!allStepsCompleted) {
222
+ const firstIncompleteStep = steps.findIndex(
223
+ (_, index) => index !== currentStepIndex && !completedSteps.has(index)
224
+ );
225
+ if (firstIncompleteStep !== -1) {
226
+ setCurrentStepIndex(firstIncompleteStep);
227
+ return;
228
+ }
229
+ }
230
+ const parseResult = formSchema.safeParse(newAccumulated);
231
+ if (parseResult.success) {
232
+ setSchemaErrors(null);
233
+ onSubmit?.(parseResult.data);
234
+ } else {
235
+ setSchemaErrors(parseResult.error);
236
+ const firstErrorPath = parseResult.error.issues[0]?.path[0];
237
+ if (typeof firstErrorPath === "string") {
238
+ const errorFieldStep = fieldAssignments.get(firstErrorPath);
239
+ if (errorFieldStep !== void 0 && errorFieldStep !== currentStepIndex) {
240
+ setCurrentStepIndex(errorFieldStep);
241
+ }
242
+ }
243
+ }
244
+ } else {
245
+ setCurrentStepIndex((prev) => prev + 1);
246
+ }
247
+ },
248
+ [isLast, onSubmit, currentStepIndex, steps, completedSteps, formSchema, fieldAssignments]
249
+ );
250
+ const handleBack = React.useCallback(() => {
251
+ if (!isFirst) {
252
+ setCurrentStepIndex((prev) => prev - 1);
253
+ setSchemaErrors(null);
254
+ }
255
+ }, [isFirst]);
256
+ if (!hasMultipleSteps) {
257
+ return /* @__PURE__ */ jsxRuntime.jsxs(
258
+ index,
259
+ {
260
+ formSchema,
261
+ values: initialValues,
262
+ onValuesChange,
263
+ onSubmit,
264
+ fieldConfig,
265
+ className,
266
+ children: [
267
+ /* @__PURE__ */ jsxRuntime.jsx(button.Button, { type: "submit", disabled: isSubmitting, className: "w-full mt-4", children: submitButtonText }),
268
+ children
269
+ ]
270
+ }
271
+ );
272
+ }
273
+ if (!currentStepSchema || !currentStep) {
274
+ return null;
275
+ }
276
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: utils.cn("w-full", className), children: [
277
+ /* @__PURE__ */ jsxRuntime.jsx(
278
+ StepperComponent,
279
+ {
280
+ steps: steps.map((s) => ({ id: s.id, label: s.title })),
281
+ currentStepIndex,
282
+ currentStepId: currentStep.id,
283
+ onStepClick: handleStepClick,
284
+ isFirst,
285
+ isLast
286
+ }
287
+ ),
288
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", children: [
289
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold", children: currentStep.title }),
290
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
291
+ "Step ",
292
+ currentStepIndex + 1,
293
+ " of ",
294
+ steps.length
295
+ ] })
296
+ ] }),
297
+ schemaErrors && schemaErrors.issues.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
298
+ "div",
299
+ {
300
+ role: "alert",
301
+ "aria-live": "assertive",
302
+ className: "rounded-md border border-destructive/50 bg-destructive/10 p-4 mb-4",
303
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
304
+ /* @__PURE__ */ jsxRuntime.jsx(
305
+ "svg",
306
+ {
307
+ className: "h-5 w-5 text-destructive shrink-0 mt-0.5",
308
+ fill: "none",
309
+ viewBox: "0 0 24 24",
310
+ stroke: "currentColor",
311
+ strokeWidth: 2,
312
+ children: /* @__PURE__ */ jsxRuntime.jsx(
313
+ "path",
314
+ {
315
+ strokeLinecap: "round",
316
+ strokeLinejoin: "round",
317
+ d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
318
+ }
319
+ )
320
+ }
321
+ ),
322
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
323
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-sm font-medium text-destructive", children: "Validation Failed" }),
324
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mt-2 text-sm text-destructive/90 list-disc list-inside space-y-1", children: schemaErrors.issues.map((issue, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
325
+ issue.path.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
326
+ issue.path.join("."),
327
+ ": "
328
+ ] }),
329
+ issue.message
330
+ ] }, index)) })
331
+ ] }),
332
+ /* @__PURE__ */ jsxRuntime.jsx(
333
+ "button",
334
+ {
335
+ type: "button",
336
+ onClick: () => setSchemaErrors(null),
337
+ className: "text-destructive/70 hover:text-destructive shrink-0",
338
+ "aria-label": "Dismiss errors",
339
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "h-4 w-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
340
+ }
341
+ )
342
+ ] })
343
+ }
344
+ ),
345
+ /* @__PURE__ */ jsxRuntime.jsxs(
346
+ index,
347
+ {
348
+ formSchema: currentStepSchema,
349
+ values: currentStepValues,
350
+ onValuesChange: handleStepValuesChange,
351
+ onSubmit: handleStepSubmit,
352
+ fieldConfig: currentStepFieldConfig,
353
+ className: "space-y-4",
354
+ children: [
355
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between pt-4", children: [
356
+ /* @__PURE__ */ jsxRuntime.jsx(
357
+ button.Button,
358
+ {
359
+ type: "button",
360
+ variant: "outline",
361
+ onClick: handleBack,
362
+ disabled: isFirst || isSubmitting,
363
+ children: backButtonText
364
+ }
365
+ ),
366
+ /* @__PURE__ */ jsxRuntime.jsx(button.Button, { type: "submit", disabled: isSubmitting, children: isLast ? submitButtonText : nextButtonText })
367
+ ] }),
368
+ children
369
+ ]
370
+ },
371
+ currentStep.id
372
+ )
373
+ ] });
374
+ }
375
+
376
+ exports.SteppedAutoForm = SteppedAutoForm;
377
+ exports.default = SteppedAutoForm;