@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,163 @@
1
+ "use client";
2
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+ import { usePluginOverrides, useBasePath } from '@btst/stack/context';
5
+ import { Button } from '../../../../../../../ui/src/components/button.mjs';
6
+ import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from '../../../../../../../ui/src/components/table.mjs';
7
+ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '../../../../../../../ui/src/components/dropdown-menu.mjs';
8
+ import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from '../../../../../../../ui/src/components/alert-dialog.mjs';
9
+ import { Plus, MoreHorizontal, Pencil, FileText, Trash2 } from 'lucide-react';
10
+ import { toast } from 'sonner';
11
+ import { useSuspenseForms, useDeleteForm } from '../../hooks/form-builder-hooks.mjs';
12
+ import { FORM_BUILDER_LOCALIZATION } from '../../localization/index.mjs';
13
+ import { PageWrapper } from '../shared/page-wrapper.mjs';
14
+ import { EmptyState } from '../shared/empty-state.mjs';
15
+ import { Pagination } from '../shared/pagination.mjs';
16
+
17
+ function FormListPage() {
18
+ const { navigate, Link, localization } = usePluginOverrides("form-builder", {
19
+ localization: FORM_BUILDER_LOCALIZATION
20
+ });
21
+ const basePath = useBasePath();
22
+ const { forms, total, hasMore, isLoadingMore, loadMore, refetch } = useSuspenseForms();
23
+ const deleteMutation = useDeleteForm();
24
+ const [deleteId, setDeleteId] = useState(null);
25
+ const loc = localization || FORM_BUILDER_LOCALIZATION;
26
+ const LinkComponent = Link || "a";
27
+ const handleDelete = async () => {
28
+ if (!deleteId) return;
29
+ try {
30
+ await deleteMutation.mutateAsync(deleteId);
31
+ toast.success(loc.FORM_BUILDER_TOAST_DELETE_SUCCESS);
32
+ setDeleteId(null);
33
+ await refetch();
34
+ } catch (error) {
35
+ toast.error(loc.FORM_BUILDER_TOAST_ERROR);
36
+ }
37
+ };
38
+ const getStatusBadge = (status) => {
39
+ const colors = {
40
+ active: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",
41
+ inactive: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",
42
+ archived: "bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200"
43
+ };
44
+ return /* @__PURE__ */ jsx(
45
+ "span",
46
+ {
47
+ className: `px-2 py-1 rounded-full text-xs font-medium ${colors[status] || colors.inactive}`,
48
+ children: status
49
+ }
50
+ );
51
+ };
52
+ return /* @__PURE__ */ jsxs(PageWrapper, { testId: "form-list-page", children: [
53
+ /* @__PURE__ */ jsxs("div", { className: "w-full max-w-5xl space-y-6", children: [
54
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
55
+ /* @__PURE__ */ jsxs("div", { children: [
56
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold", children: loc.FORM_BUILDER_LIST_TITLE }),
57
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: loc.FORM_BUILDER_LIST_SUBTITLE })
58
+ ] }),
59
+ /* @__PURE__ */ jsx(Button, { asChild: true, children: /* @__PURE__ */ jsxs(LinkComponent, { href: `${basePath}/forms/new`, children: [
60
+ /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
61
+ loc.FORM_BUILDER_BUTTON_NEW_FORM
62
+ ] }) })
63
+ ] }),
64
+ forms.length === 0 ? /* @__PURE__ */ jsx(
65
+ EmptyState,
66
+ {
67
+ title: loc.FORM_BUILDER_LIST_EMPTY,
68
+ description: loc.FORM_BUILDER_LIST_EMPTY_DESCRIPTION,
69
+ action: /* @__PURE__ */ jsx(Button, { asChild: true, children: /* @__PURE__ */ jsxs(LinkComponent, { href: `${basePath}/forms/new`, children: [
70
+ /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
71
+ loc.FORM_BUILDER_BUTTON_NEW_FORM
72
+ ] }) })
73
+ }
74
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
75
+ /* @__PURE__ */ jsx("div", { className: "rounded-lg border", children: /* @__PURE__ */ jsxs(Table, { children: [
76
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
77
+ /* @__PURE__ */ jsx(TableHead, { children: loc.FORM_BUILDER_LIST_COLUMN_NAME }),
78
+ /* @__PURE__ */ jsx(TableHead, { children: loc.FORM_BUILDER_LIST_COLUMN_SLUG }),
79
+ /* @__PURE__ */ jsx(TableHead, { children: loc.FORM_BUILDER_LIST_COLUMN_STATUS }),
80
+ /* @__PURE__ */ jsx(TableHead, { children: loc.FORM_BUILDER_LIST_COLUMN_CREATED }),
81
+ /* @__PURE__ */ jsx(TableHead, { className: "w-12", children: loc.FORM_BUILDER_LIST_COLUMN_ACTIONS })
82
+ ] }) }),
83
+ /* @__PURE__ */ jsx(TableBody, { children: forms.map((form) => /* @__PURE__ */ jsxs(TableRow, { children: [
84
+ /* @__PURE__ */ jsx(TableCell, { className: "font-medium", children: form.name }),
85
+ /* @__PURE__ */ jsx(TableCell, { className: "text-muted-foreground font-mono text-sm", children: form.slug }),
86
+ /* @__PURE__ */ jsx(TableCell, { children: getStatusBadge(form.status) }),
87
+ /* @__PURE__ */ jsx(TableCell, { className: "text-muted-foreground", children: new Date(form.createdAt).toLocaleDateString() }),
88
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
89
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "icon", children: [
90
+ /* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" }),
91
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Actions" })
92
+ ] }) }),
93
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
94
+ /* @__PURE__ */ jsxs(
95
+ DropdownMenuItem,
96
+ {
97
+ onClick: () => navigate?.(`${basePath}/forms/${form.id}/edit`),
98
+ children: [
99
+ /* @__PURE__ */ jsx(Pencil, { className: "mr-2 h-4 w-4" }),
100
+ loc.FORM_BUILDER_LIST_ACTION_EDIT
101
+ ]
102
+ }
103
+ ),
104
+ /* @__PURE__ */ jsxs(
105
+ DropdownMenuItem,
106
+ {
107
+ onClick: () => navigate?.(
108
+ `${basePath}/forms/${form.id}/submissions`
109
+ ),
110
+ children: [
111
+ /* @__PURE__ */ jsx(FileText, { className: "mr-2 h-4 w-4" }),
112
+ loc.FORM_BUILDER_LIST_ACTION_SUBMISSIONS
113
+ ]
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsxs(
117
+ DropdownMenuItem,
118
+ {
119
+ className: "text-destructive",
120
+ onClick: () => setDeleteId(form.id),
121
+ children: [
122
+ /* @__PURE__ */ jsx(Trash2, { className: "mr-2 h-4 w-4" }),
123
+ loc.FORM_BUILDER_LIST_ACTION_DELETE
124
+ ]
125
+ }
126
+ )
127
+ ] })
128
+ ] }) })
129
+ ] }, form.id)) })
130
+ ] }) }),
131
+ /* @__PURE__ */ jsx(
132
+ Pagination,
133
+ {
134
+ total,
135
+ showing: forms.length,
136
+ hasMore,
137
+ isLoadingMore,
138
+ onLoadMore: loadMore
139
+ }
140
+ )
141
+ ] })
142
+ ] }),
143
+ /* @__PURE__ */ jsx(AlertDialog, { open: !!deleteId, onOpenChange: () => setDeleteId(null), children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
144
+ /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
145
+ /* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete Form" }),
146
+ /* @__PURE__ */ jsx(AlertDialogDescription, { children: loc.FORM_BUILDER_EDITOR_DELETE_CONFIRM })
147
+ ] }),
148
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
149
+ /* @__PURE__ */ jsx(AlertDialogCancel, { children: loc.FORM_BUILDER_BUTTON_CANCEL }),
150
+ /* @__PURE__ */ jsx(
151
+ AlertDialogAction,
152
+ {
153
+ onClick: handleDelete,
154
+ className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
155
+ children: deleteMutation.isPending ? loc.FORM_BUILDER_STATUS_DELETING : loc.FORM_BUILDER_BUTTON_DELETE
156
+ }
157
+ )
158
+ ] })
159
+ ] }) })
160
+ ] });
161
+ }
162
+
163
+ export { FormListPage };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { Suspense, lazy } from 'react';
4
+ import { FormListSkeleton } from '../loading/form-list-skeleton.mjs';
5
+ import { ErrorBoundary } from 'react-error-boundary';
6
+ import { DefaultError } from '../shared/default-error.mjs';
7
+
8
+ const FormListPage = lazy(
9
+ () => import('./form-list-page.internal.mjs').then((m) => ({
10
+ default: m.FormListPage
11
+ }))
12
+ );
13
+ function FormListPageComponent() {
14
+ return /* @__PURE__ */ jsx(ErrorBoundary, { FallbackComponent: DefaultError, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(FormListSkeleton, {}), children: /* @__PURE__ */ jsx(FormListPage, {}) }) });
15
+ }
16
+
17
+ export { FormListPageComponent };
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ const jsxRuntime = require('react/jsx-runtime');
5
+ const React = require('react');
6
+ const submissionsSkeleton = require('../loading/submissions-skeleton.cjs');
7
+ const reactErrorBoundary = require('react-error-boundary');
8
+ const defaultError = require('../shared/default-error.cjs');
9
+
10
+ const SubmissionsPage = React.lazy(
11
+ () => import('./submissions-page.internal.cjs').then((m) => ({
12
+ default: m.SubmissionsPage
13
+ }))
14
+ );
15
+ function SubmissionsPageComponent({ formId }) {
16
+ return /* @__PURE__ */ jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, { FallbackComponent: defaultError.DefaultError, children: /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(submissionsSkeleton.SubmissionsSkeleton, {}), children: /* @__PURE__ */ jsxRuntime.jsx(SubmissionsPage, { formId }) }) });
17
+ }
18
+
19
+ exports.SubmissionsPageComponent = SubmissionsPageComponent;
@@ -0,0 +1,177 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ const jsxRuntime = require('react/jsx-runtime');
5
+ const React = require('react');
6
+ const context = require('@btst/stack/context');
7
+ const button = require('../../../../../../../ui/src/components/button.cjs');
8
+ const table = require('../../../../../../../ui/src/components/table.cjs');
9
+ const alertDialog = require('../../../../../../../ui/src/components/alert-dialog.cjs');
10
+ const dialog = require('../../../../../../../ui/src/components/dialog.cjs');
11
+ const lucideReact = require('lucide-react');
12
+ const sonner = require('sonner');
13
+ const formBuilderHooks = require('../../hooks/form-builder-hooks.cjs');
14
+ const index = require('../../localization/index.cjs');
15
+ const pageWrapper = require('../shared/page-wrapper.cjs');
16
+ const emptyState = require('../shared/empty-state.cjs');
17
+ const pagination = require('../shared/pagination.cjs');
18
+
19
+ function SubmissionsPage({ formId }) {
20
+ const { navigate, Link, localization } = context.usePluginOverrides("form-builder", {
21
+ localization: index.FORM_BUILDER_LOCALIZATION
22
+ });
23
+ const basePath = context.useBasePath();
24
+ const { form } = formBuilderHooks.useSuspenseFormById(formId);
25
+ const { submissions, total, hasMore, isLoadingMore, loadMore, refetch } = formBuilderHooks.useSuspenseSubmissions(formId);
26
+ const deleteMutation = formBuilderHooks.useDeleteSubmission(formId);
27
+ const [deleteId, setDeleteId] = React.useState(null);
28
+ const [viewSubmission, setViewSubmission] = React.useState(null);
29
+ const loc = localization || index.FORM_BUILDER_LOCALIZATION;
30
+ const LinkComponent = Link || "a";
31
+ const handleDelete = async () => {
32
+ if (!deleteId) return;
33
+ try {
34
+ await deleteMutation.mutateAsync(deleteId);
35
+ sonner.toast.success(loc.FORM_BUILDER_TOAST_SUBMISSION_DELETED);
36
+ setDeleteId(null);
37
+ await refetch();
38
+ } catch (error) {
39
+ sonner.toast.error(loc.FORM_BUILDER_TOAST_ERROR);
40
+ }
41
+ };
42
+ const formatSubmissionData = (data) => {
43
+ const entries = Object.entries(data).slice(0, 3);
44
+ return entries.map(([key, value]) => {
45
+ const strValue = typeof value === "string" ? value : JSON.stringify(value);
46
+ const truncated = strValue.length > 30 ? `${strValue.slice(0, 30)}...` : strValue;
47
+ return `${key}: ${truncated}`;
48
+ }).join(", ");
49
+ };
50
+ return /* @__PURE__ */ jsxRuntime.jsxs(pageWrapper.PageWrapper, { testId: "submissions-page", children: [
51
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-5xl space-y-6", children: [
52
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
53
+ /* @__PURE__ */ jsxRuntime.jsx(button.Button, { variant: "ghost", size: "icon", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(LinkComponent, { href: `${basePath}/forms`, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { className: "h-4 w-4" }) }) }),
54
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
55
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-bold", children: form?.name || loc.FORM_BUILDER_SUBMISSIONS_TITLE }),
56
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: loc.FORM_BUILDER_SUBMISSIONS_SUBTITLE })
57
+ ] })
58
+ ] }),
59
+ submissions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
60
+ emptyState.EmptyState,
61
+ {
62
+ title: loc.FORM_BUILDER_SUBMISSIONS_EMPTY,
63
+ description: loc.FORM_BUILDER_SUBMISSIONS_EMPTY_DESCRIPTION
64
+ }
65
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
66
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border", children: /* @__PURE__ */ jsxRuntime.jsxs(table.Table, { children: [
67
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { children: [
68
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { className: "w-24", children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_ID }),
69
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_DATA }),
70
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_SUBMITTED_AT }),
71
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_IP_ADDRESS }),
72
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { className: "w-24", children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_ACTIONS })
73
+ ] }) }),
74
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableBody, { children: submissions.map((sub) => /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { children: [
75
+ /* @__PURE__ */ jsxRuntime.jsxs(table.TableCell, { className: "font-mono text-xs", children: [
76
+ sub.id.slice(0, 8),
77
+ "..."
78
+ ] }),
79
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "max-w-xs truncate text-sm text-muted-foreground", children: formatSubmissionData(sub.parsedData) }),
80
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "text-muted-foreground", children: new Date(sub.submittedAt).toLocaleString() }),
81
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "text-muted-foreground font-mono text-xs", children: sub.ipAddress || "-" }),
82
+ /* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
83
+ /* @__PURE__ */ jsxRuntime.jsxs(
84
+ button.Button,
85
+ {
86
+ variant: "ghost",
87
+ size: "icon",
88
+ onClick: () => setViewSubmission(sub),
89
+ children: [
90
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "h-4 w-4" }),
91
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "View" })
92
+ ]
93
+ }
94
+ ),
95
+ /* @__PURE__ */ jsxRuntime.jsxs(
96
+ button.Button,
97
+ {
98
+ variant: "ghost",
99
+ size: "icon",
100
+ className: "text-destructive",
101
+ onClick: () => setDeleteId(sub.id),
102
+ children: [
103
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "h-4 w-4" }),
104
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Delete" })
105
+ ]
106
+ }
107
+ )
108
+ ] }) })
109
+ ] }, sub.id)) })
110
+ ] }) }),
111
+ /* @__PURE__ */ jsxRuntime.jsx(
112
+ pagination.Pagination,
113
+ {
114
+ total,
115
+ showing: submissions.length,
116
+ hasMore,
117
+ isLoadingMore,
118
+ onLoadMore: loadMore
119
+ }
120
+ )
121
+ ] })
122
+ ] }),
123
+ /* @__PURE__ */ jsxRuntime.jsx(
124
+ dialog.Dialog,
125
+ {
126
+ open: !!viewSubmission,
127
+ onOpenChange: () => setViewSubmission(null),
128
+ children: /* @__PURE__ */ jsxRuntime.jsxs(dialog.DialogContent, { className: "max-w-2xl max-h-[80vh] overflow-auto", children: [
129
+ /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(dialog.DialogTitle, { children: "Submission Details" }) }),
130
+ viewSubmission && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
131
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4 text-sm", children: [
132
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
133
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "ID:" }),
134
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-mono truncate", children: viewSubmission.id })
135
+ ] }),
136
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
137
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Submitted:" }),
138
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate", children: new Date(viewSubmission.submittedAt).toLocaleString() })
139
+ ] }),
140
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
141
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "IP Address:" }),
142
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-mono truncate", children: viewSubmission.ipAddress || "-" })
143
+ ] }),
144
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
145
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "User Agent:" }),
146
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs truncate", children: viewSubmission.userAgent || "-" })
147
+ ] })
148
+ ] }),
149
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
150
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Data:" }),
151
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "mt-2 p-4 bg-muted rounded-lg text-sm overflow-auto", children: JSON.stringify(viewSubmission.parsedData, null, 2) })
152
+ ] })
153
+ ] })
154
+ ] })
155
+ }
156
+ ),
157
+ /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialog, { open: !!deleteId, onOpenChange: () => setDeleteId(null), children: /* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogContent, { children: [
158
+ /* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogHeader, { children: [
159
+ /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogTitle, { children: "Delete Submission" }),
160
+ /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogDescription, { children: loc.FORM_BUILDER_SUBMISSIONS_DELETE_CONFIRM })
161
+ ] }),
162
+ /* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogFooter, { children: [
163
+ /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogCancel, { children: loc.FORM_BUILDER_BUTTON_CANCEL }),
164
+ /* @__PURE__ */ jsxRuntime.jsx(
165
+ alertDialog.AlertDialogAction,
166
+ {
167
+ onClick: handleDelete,
168
+ className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
169
+ children: deleteMutation.isPending ? loc.FORM_BUILDER_STATUS_DELETING : loc.FORM_BUILDER_BUTTON_DELETE
170
+ }
171
+ )
172
+ ] })
173
+ ] }) })
174
+ ] });
175
+ }
176
+
177
+ exports.SubmissionsPage = SubmissionsPage;
@@ -0,0 +1,175 @@
1
+ "use client";
2
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+ import { usePluginOverrides, useBasePath } from '@btst/stack/context';
5
+ import { Button } from '../../../../../../../ui/src/components/button.mjs';
6
+ import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from '../../../../../../../ui/src/components/table.mjs';
7
+ import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from '../../../../../../../ui/src/components/alert-dialog.mjs';
8
+ import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../../../../../../ui/src/components/dialog.mjs';
9
+ import { ArrowLeft, Eye, Trash2 } from 'lucide-react';
10
+ import { toast } from 'sonner';
11
+ import { useSuspenseFormById, useSuspenseSubmissions, useDeleteSubmission } from '../../hooks/form-builder-hooks.mjs';
12
+ import { FORM_BUILDER_LOCALIZATION } from '../../localization/index.mjs';
13
+ import { PageWrapper } from '../shared/page-wrapper.mjs';
14
+ import { EmptyState } from '../shared/empty-state.mjs';
15
+ import { Pagination } from '../shared/pagination.mjs';
16
+
17
+ function SubmissionsPage({ formId }) {
18
+ const { navigate, Link, localization } = usePluginOverrides("form-builder", {
19
+ localization: FORM_BUILDER_LOCALIZATION
20
+ });
21
+ const basePath = useBasePath();
22
+ const { form } = useSuspenseFormById(formId);
23
+ const { submissions, total, hasMore, isLoadingMore, loadMore, refetch } = useSuspenseSubmissions(formId);
24
+ const deleteMutation = useDeleteSubmission(formId);
25
+ const [deleteId, setDeleteId] = useState(null);
26
+ const [viewSubmission, setViewSubmission] = useState(null);
27
+ const loc = localization || FORM_BUILDER_LOCALIZATION;
28
+ const LinkComponent = Link || "a";
29
+ const handleDelete = async () => {
30
+ if (!deleteId) return;
31
+ try {
32
+ await deleteMutation.mutateAsync(deleteId);
33
+ toast.success(loc.FORM_BUILDER_TOAST_SUBMISSION_DELETED);
34
+ setDeleteId(null);
35
+ await refetch();
36
+ } catch (error) {
37
+ toast.error(loc.FORM_BUILDER_TOAST_ERROR);
38
+ }
39
+ };
40
+ const formatSubmissionData = (data) => {
41
+ const entries = Object.entries(data).slice(0, 3);
42
+ return entries.map(([key, value]) => {
43
+ const strValue = typeof value === "string" ? value : JSON.stringify(value);
44
+ const truncated = strValue.length > 30 ? `${strValue.slice(0, 30)}...` : strValue;
45
+ return `${key}: ${truncated}`;
46
+ }).join(", ");
47
+ };
48
+ return /* @__PURE__ */ jsxs(PageWrapper, { testId: "submissions-page", children: [
49
+ /* @__PURE__ */ jsxs("div", { className: "w-full max-w-5xl space-y-6", children: [
50
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
51
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", asChild: true, children: /* @__PURE__ */ jsx(LinkComponent, { href: `${basePath}/forms`, children: /* @__PURE__ */ jsx(ArrowLeft, { className: "h-4 w-4" }) }) }),
52
+ /* @__PURE__ */ jsxs("div", { children: [
53
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold", children: form?.name || loc.FORM_BUILDER_SUBMISSIONS_TITLE }),
54
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: loc.FORM_BUILDER_SUBMISSIONS_SUBTITLE })
55
+ ] })
56
+ ] }),
57
+ submissions.length === 0 ? /* @__PURE__ */ jsx(
58
+ EmptyState,
59
+ {
60
+ title: loc.FORM_BUILDER_SUBMISSIONS_EMPTY,
61
+ description: loc.FORM_BUILDER_SUBMISSIONS_EMPTY_DESCRIPTION
62
+ }
63
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
64
+ /* @__PURE__ */ jsx("div", { className: "rounded-lg border", children: /* @__PURE__ */ jsxs(Table, { children: [
65
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
66
+ /* @__PURE__ */ jsx(TableHead, { className: "w-24", children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_ID }),
67
+ /* @__PURE__ */ jsx(TableHead, { children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_DATA }),
68
+ /* @__PURE__ */ jsx(TableHead, { children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_SUBMITTED_AT }),
69
+ /* @__PURE__ */ jsx(TableHead, { children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_IP_ADDRESS }),
70
+ /* @__PURE__ */ jsx(TableHead, { className: "w-24", children: loc.FORM_BUILDER_SUBMISSIONS_COLUMN_ACTIONS })
71
+ ] }) }),
72
+ /* @__PURE__ */ jsx(TableBody, { children: submissions.map((sub) => /* @__PURE__ */ jsxs(TableRow, { children: [
73
+ /* @__PURE__ */ jsxs(TableCell, { className: "font-mono text-xs", children: [
74
+ sub.id.slice(0, 8),
75
+ "..."
76
+ ] }),
77
+ /* @__PURE__ */ jsx(TableCell, { className: "max-w-xs truncate text-sm text-muted-foreground", children: formatSubmissionData(sub.parsedData) }),
78
+ /* @__PURE__ */ jsx(TableCell, { className: "text-muted-foreground", children: new Date(sub.submittedAt).toLocaleString() }),
79
+ /* @__PURE__ */ jsx(TableCell, { className: "text-muted-foreground font-mono text-xs", children: sub.ipAddress || "-" }),
80
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
81
+ /* @__PURE__ */ jsxs(
82
+ Button,
83
+ {
84
+ variant: "ghost",
85
+ size: "icon",
86
+ onClick: () => setViewSubmission(sub),
87
+ children: [
88
+ /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" }),
89
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "View" })
90
+ ]
91
+ }
92
+ ),
93
+ /* @__PURE__ */ jsxs(
94
+ Button,
95
+ {
96
+ variant: "ghost",
97
+ size: "icon",
98
+ className: "text-destructive",
99
+ onClick: () => setDeleteId(sub.id),
100
+ children: [
101
+ /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }),
102
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Delete" })
103
+ ]
104
+ }
105
+ )
106
+ ] }) })
107
+ ] }, sub.id)) })
108
+ ] }) }),
109
+ /* @__PURE__ */ jsx(
110
+ Pagination,
111
+ {
112
+ total,
113
+ showing: submissions.length,
114
+ hasMore,
115
+ isLoadingMore,
116
+ onLoadMore: loadMore
117
+ }
118
+ )
119
+ ] })
120
+ ] }),
121
+ /* @__PURE__ */ jsx(
122
+ Dialog,
123
+ {
124
+ open: !!viewSubmission,
125
+ onOpenChange: () => setViewSubmission(null),
126
+ children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-2xl max-h-[80vh] overflow-auto", children: [
127
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Submission Details" }) }),
128
+ viewSubmission && /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
129
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4 text-sm", children: [
130
+ /* @__PURE__ */ jsxs("div", { children: [
131
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "ID:" }),
132
+ /* @__PURE__ */ jsx("p", { className: "font-mono truncate", children: viewSubmission.id })
133
+ ] }),
134
+ /* @__PURE__ */ jsxs("div", { children: [
135
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Submitted:" }),
136
+ /* @__PURE__ */ jsx("p", { className: "truncate", children: new Date(viewSubmission.submittedAt).toLocaleString() })
137
+ ] }),
138
+ /* @__PURE__ */ jsxs("div", { children: [
139
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "IP Address:" }),
140
+ /* @__PURE__ */ jsx("p", { className: "font-mono truncate", children: viewSubmission.ipAddress || "-" })
141
+ ] }),
142
+ /* @__PURE__ */ jsxs("div", { children: [
143
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "User Agent:" }),
144
+ /* @__PURE__ */ jsx("p", { className: "text-xs truncate", children: viewSubmission.userAgent || "-" })
145
+ ] })
146
+ ] }),
147
+ /* @__PURE__ */ jsxs("div", { children: [
148
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-sm", children: "Data:" }),
149
+ /* @__PURE__ */ jsx("pre", { className: "mt-2 p-4 bg-muted rounded-lg text-sm overflow-auto", children: JSON.stringify(viewSubmission.parsedData, null, 2) })
150
+ ] })
151
+ ] })
152
+ ] })
153
+ }
154
+ ),
155
+ /* @__PURE__ */ jsx(AlertDialog, { open: !!deleteId, onOpenChange: () => setDeleteId(null), children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
156
+ /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
157
+ /* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete Submission" }),
158
+ /* @__PURE__ */ jsx(AlertDialogDescription, { children: loc.FORM_BUILDER_SUBMISSIONS_DELETE_CONFIRM })
159
+ ] }),
160
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
161
+ /* @__PURE__ */ jsx(AlertDialogCancel, { children: loc.FORM_BUILDER_BUTTON_CANCEL }),
162
+ /* @__PURE__ */ jsx(
163
+ AlertDialogAction,
164
+ {
165
+ onClick: handleDelete,
166
+ className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
167
+ children: deleteMutation.isPending ? loc.FORM_BUILDER_STATUS_DELETING : loc.FORM_BUILDER_BUTTON_DELETE
168
+ }
169
+ )
170
+ ] })
171
+ ] }) })
172
+ ] });
173
+ }
174
+
175
+ export { SubmissionsPage };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { Suspense, lazy } from 'react';
4
+ import { SubmissionsSkeleton } from '../loading/submissions-skeleton.mjs';
5
+ import { ErrorBoundary } from 'react-error-boundary';
6
+ import { DefaultError } from '../shared/default-error.mjs';
7
+
8
+ const SubmissionsPage = lazy(
9
+ () => import('./submissions-page.internal.mjs').then((m) => ({
10
+ default: m.SubmissionsPage
11
+ }))
12
+ );
13
+ function SubmissionsPageComponent({ formId }) {
14
+ return /* @__PURE__ */ jsx(ErrorBoundary, { FallbackComponent: DefaultError, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(SubmissionsSkeleton, {}), children: /* @__PURE__ */ jsx(SubmissionsPage, { formId }) }) });
15
+ }
16
+
17
+ export { SubmissionsPageComponent };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ const jsxRuntime = require('react/jsx-runtime');
5
+ const lucideReact = require('lucide-react');
6
+ const button = require('../../../../../../../ui/src/components/button.cjs');
7
+
8
+ function DefaultError({ error, resetErrorBoundary }) {
9
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
10
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-full bg-destructive/10 p-4 mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-8 w-8 text-destructive" }) }),
11
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-medium text-foreground mb-2", children: "Something went wrong" }),
12
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mb-4 max-w-sm", children: error.message || "An unexpected error occurred" }),
13
+ resetErrorBoundary && /* @__PURE__ */ jsxRuntime.jsx(button.Button, { variant: "outline", onClick: resetErrorBoundary, children: "Try again" })
14
+ ] });
15
+ }
16
+
17
+ exports.DefaultError = DefaultError;
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { AlertCircle } from 'lucide-react';
4
+ import { Button } from '../../../../../../../ui/src/components/button.mjs';
5
+
6
+ function DefaultError({ error, resetErrorBoundary }) {
7
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
8
+ /* @__PURE__ */ jsx("div", { className: "rounded-full bg-destructive/10 p-4 mb-4", children: /* @__PURE__ */ jsx(AlertCircle, { className: "h-8 w-8 text-destructive" }) }),
9
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-medium text-foreground mb-2", children: "Something went wrong" }),
10
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-4 max-w-sm", children: error.message || "An unexpected error occurred" }),
11
+ resetErrorBoundary && /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: resetErrorBoundary, children: "Try again" })
12
+ ] });
13
+ }
14
+
15
+ export { DefaultError };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ const jsxRuntime = require('react/jsx-runtime');
5
+ const lucideReact = require('lucide-react');
6
+
7
+ function EmptyState({ title, description, action }) {
8
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
9
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-full bg-muted p-4 mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Inbox, { className: "h-8 w-8 text-muted-foreground" }) }),
10
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-medium text-foreground mb-2", children: title }),
11
+ description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mb-4 max-w-sm", children: description }),
12
+ action
13
+ ] });
14
+ }
15
+
16
+ exports.EmptyState = EmptyState;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { Inbox } from 'lucide-react';
4
+
5
+ function EmptyState({ title, description, action }) {
6
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
7
+ /* @__PURE__ */ jsx("div", { className: "rounded-full bg-muted p-4 mb-4", children: /* @__PURE__ */ jsx(Inbox, { className: "h-8 w-8 text-muted-foreground" }) }),
8
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-medium text-foreground mb-2", children: title }),
9
+ description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-4 max-w-sm", children: description }),
10
+ action
11
+ ] });
12
+ }
13
+
14
+ export { EmptyState };