@protobase/ui 0.117.4 → 0.117.5

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 (206) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/app/app.js +40 -34
  3. package/dist/app/charts/messages.d.ts +2 -2
  4. package/dist/app/comments/messages.d.ts +2 -2
  5. package/dist/app/delete/messages.d.ts +2 -2
  6. package/dist/app/displays/messages.d.ts +2 -2
  7. package/dist/app/export/messages.d.ts +2 -2
  8. package/dist/app/field-messages.d.ts +2 -2
  9. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  10. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  11. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  12. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  13. package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
  14. package/dist/app/file-viewers/messages.d.ts +2 -2
  15. package/dist/app/focus/messages.d.ts +2 -2
  16. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  17. package/dist/app/gallery/messages.d.ts +2 -2
  18. package/dist/app/history/messages.d.ts +2 -2
  19. package/dist/app/import/messages.d.ts +2 -2
  20. package/dist/app/list-messages.d.ts +2 -2
  21. package/dist/app/messages.d.ts +2 -2
  22. package/dist/app/meta-gate-messages.d.ts +2 -2
  23. package/dist/app/new-version/messages.d.ts +2 -2
  24. package/dist/app/pages/messages.d.ts +2 -2
  25. package/dist/app/record-chart/messages.d.ts +2 -2
  26. package/dist/app/record-messages.d.ts +2 -2
  27. package/dist/app/record-mode/shown-layout.d.ts +1 -1
  28. package/dist/app/record-row/messages.d.ts +2 -2
  29. package/dist/app/router.d.ts +2 -0
  30. package/dist/app/router.js +23 -10
  31. package/dist/app/runtime/messages.d.ts +2 -2
  32. package/dist/app/saved/messages.d.ts +2 -2
  33. package/dist/app/saved/use-favorite.d.ts +1 -1
  34. package/dist/app/search/messages.d.ts +2 -2
  35. package/dist/app/searches/messages.d.ts +2 -2
  36. package/dist/app/searches/use-save-search.d.ts +1 -1
  37. package/dist/app/use-app-address.d.ts +3 -1
  38. package/dist/app/use-app-address.js +5 -3
  39. package/dist/app-shell/app-shell.d.ts +3 -1
  40. package/dist/app-shell/app-shell.js +38 -5
  41. package/dist/app-shell/drawer.d.ts +10 -2
  42. package/dist/app-shell/drawer.js +16 -4
  43. package/dist/app-shell/edge-swipe.d.ts +49 -0
  44. package/dist/app-shell/edge-swipe.js +39 -0
  45. package/dist/app-shell/messages.d.ts +2 -2
  46. package/dist/app-shell/top-bar.js +1 -1
  47. package/dist/app-shell/use-edge-swipe.d.ts +25 -0
  48. package/dist/app-shell/use-edge-swipe.js +128 -0
  49. package/dist/assistant-dock/messages.d.ts +2 -2
  50. package/dist/auth/messages.d.ts +2 -2
  51. package/dist/calls/messages.d.ts +2 -2
  52. package/dist/chat/messages.d.ts +2 -2
  53. package/dist/data-grid/messages.d.ts +2 -2
  54. package/dist/filter-panel/messages.d.ts +2 -2
  55. package/dist/invitations/messages.d.ts +2 -2
  56. package/dist/notifications/bell/messages.d.ts +2 -2
  57. package/dist/organizations/messages.d.ts +2 -2
  58. package/dist/package.js +1 -1
  59. package/dist/primitives/messages.d.ts +2 -2
  60. package/dist/primitives/use-drawer-drag.d.ts +2 -0
  61. package/dist/primitives/use-drawer-drag.js +18 -6
  62. package/dist/record-view/messages.d.ts +2 -2
  63. package/dist/shell/assets/{account-page-BKgO5U-X.js → account-page-BPtyska2.js} +2 -2
  64. package/dist/shell/assets/app-DKn-6fgf.js +34 -0
  65. package/dist/shell/assets/{assistant-shell-DuqVM626.js → assistant-shell-BW59by36.js} +2 -2
  66. package/dist/shell/assets/{board-display-DddxG38M.js → board-display-uC4sMccF.js} +2 -2
  67. package/dist/shell/assets/{calendar-display-zLyE7rhF.js → calendar-display-BZhTapxV.js} +2 -2
  68. package/dist/shell/assets/{call-rings-uudxTLcY.js → call-rings-DwyQO_zl.js} +2 -2
  69. package/dist/shell/assets/{calls-7JJIY2v0.js → calls-DeHPxZSF.js} +2 -2
  70. package/dist/shell/assets/{circle-alert-CoX9nLsD.js → circle-alert-mtPRl_1e.js} +2 -2
  71. package/dist/shell/assets/{composed-page-DnCccgH0.js → composed-page-CqjAO9Zv.js} +2 -2
  72. package/dist/shell/assets/{composer-section-84NNbJ4X.js → composer-section-D16PrwJe.js} +2 -2
  73. package/dist/shell/assets/{connect-route-DXEPuBjl.js → connect-route-BHjM-n0c.js} +2 -2
  74. package/dist/shell/assets/{copy-field-BlooSgn7.js → copy-field-C7SgGBWe.js} +2 -2
  75. package/dist/shell/assets/{create-route-BNcDypty.js → create-route-CV6sScUu.js} +2 -2
  76. package/dist/shell/assets/{custom-step-container-field-CyvWLsF0.js → custom-step-container-field-DbXZzPJp.js} +2 -2
  77. package/dist/shell/assets/{embedded-list-B8K84K5b.js → embedded-list-CG1SyUtd.js} +3 -3
  78. package/dist/shell/assets/{export-dialog-IWSkZoEf.js → export-dialog-CMPyzZa3.js} +2 -2
  79. package/dist/shell/assets/{graph-view-D6ueoFs9.js → graph-view-CfO5HJXO.js} +2 -2
  80. package/dist/shell/assets/{group-donut-BnDzQhIS.js → group-donut-UrNllcKD.js} +2 -2
  81. package/dist/shell/assets/{guest-call-page-IwcmjkTm.js → guest-call-page-CgISSPNH.js} +3 -3
  82. package/dist/shell/assets/{html-viewer-DjlpP883.js → html-viewer-GgauWEUE.js} +2 -2
  83. package/dist/shell/assets/{import-dialog-DrDyc76O.js → import-dialog-BppJUUoF.js} +2 -2
  84. package/dist/shell/assets/{import-table-dialog-DYBhyBp7.js → import-table-dialog-cfWZMJfg.js} +2 -2
  85. package/dist/shell/assets/{index-fxThWO9s.js → index-C6CE4Yqt.js} +1 -1
  86. package/dist/shell/assets/{invitations-page-BmkBa0fB.js → invitations-page-Cx960zfb.js} +2 -2
  87. package/dist/shell/assets/{layout-grid-DGOCHAPH.js → layout-grid-IdJUsNk6.js} +2 -2
  88. package/dist/shell/assets/{legend-item-DxdIZ1pf.js → legend-item-FRGENXpR.js} +2 -2
  89. package/dist/shell/assets/{list-page-BhWOEaP6.js → list-page-Di8ApAmU.js} +4 -4
  90. package/dist/shell/assets/{maplibre-k6sh-ts2.js → maplibre-B0oPa_5e.js} +2 -2
  91. package/dist/shell/assets/{markdown-content-vMCleJqq.js → markdown-content-CA74ofB3.js} +2 -2
  92. package/dist/shell/assets/{members-page-NrAKIuOb.js → members-page-UO-o4WSG.js} +2 -2
  93. package/dist/shell/assets/{messages-Cjox3dPW.js → messages-CjRWJI05.js} +2 -2
  94. package/dist/shell/assets/{organization-page-HRjNwewQ.js → organization-page-DaGSJbur.js} +2 -2
  95. package/dist/shell/assets/{organizations-page-D-Is15Iq.js → organizations-page-C5oK_zsd.js} +2 -2
  96. package/dist/shell/assets/{pending-invitation-row-MATld1YG.js → pending-invitation-row-BEvgmW-N.js} +2 -2
  97. package/dist/shell/assets/{period-chart-xv3RhzW9.js → period-chart-CW2NUL07.js} +2 -2
  98. package/dist/shell/assets/{person-row-DPsUV5XA.js → person-row-5VQjyq5t.js} +2 -2
  99. package/dist/shell/assets/{public-form-page-CK0NgO4L.js → public-form-page-CqU7Cg33.js} +2 -2
  100. package/dist/shell/assets/{record-lines-CDGK7ZyR.js → record-lines-CJgNIVFS.js} +2 -2
  101. package/dist/shell/assets/{record-map-C8QpQBwW.js → record-map-DHkY7hYE.js} +2 -2
  102. package/dist/shell/assets/{record-opens-jhy0UcRX.js → record-opens-B0MlYjrH.js} +2 -2
  103. package/dist/shell/assets/{record-page-BQtAOfUN.js → record-page-whDNzf71.js} +3 -3
  104. package/dist/shell/assets/{record-preview-Cnz2q7jF.js → record-preview-BUnzkT7g.js} +2 -2
  105. package/dist/shell/assets/{records-map-Cpt0N4k2.js → records-map-DjcDdJBM.js} +2 -2
  106. package/dist/shell/assets/{render-node-CQddajXn.js → render-node-DGmdm-wr.js} +3 -3
  107. package/dist/shell/assets/{reorder-button-2tg9wf42.js → reorder-button-q4oqy3UR.js} +2 -2
  108. package/dist/shell/assets/{run-trace-view-C8KR_auS.js → run-trace-view-DjtMSojN.js} +2 -2
  109. package/dist/shell/assets/{runner-install-field-Dfnq3Rqy.js → runner-install-field-Ddxc9XB0.js} +2 -2
  110. package/dist/shell/assets/{runtime-update-BkP2MEsM.js → runtime-update-CKEA5P-k.js} +2 -2
  111. package/dist/shell/assets/{shared-protobase-ui-CbwI3ULn.js → shared-protobase-ui-tTqz9hwW.js} +1 -1
  112. package/dist/shell/assets/{sheet-source-Bsx98FTk.js → sheet-source-CAIVzfnw.js} +2 -2
  113. package/dist/shell/assets/{sign-in-policy-page-hgTJtin9.js → sign-in-policy-page-CdTIudi-.js} +2 -2
  114. package/dist/shell/assets/{start-block-queries-Cmx56hgU.js → start-block-queries-DjQjQ2Ef.js} +2 -2
  115. package/dist/shell/assets/{step-catalog-BJyr7gmH.js → step-catalog-Dit0IJvs.js} +2 -2
  116. package/dist/shell/assets/{step-panel-D-jkWWLs.js → step-panel-9kx6xfm1.js} +2 -2
  117. package/dist/shell/assets/{timeline-display-FKWlqzyN.js → timeline-display-CoQETrmW.js} +2 -2
  118. package/dist/shell/assets/{trash-BNguTSbA.js → trash-DJwJPifF.js} +2 -2
  119. package/dist/shell/assets/{update-set-CaKid6Bl.js → update-set-DPSGWrcI.js} +2 -2
  120. package/dist/shell/assets/{use-calendar-move-UCTCC4Mu.js → use-calendar-move-CgXeokRh.js} +2 -2
  121. package/dist/shell/assets/{use-display-rows-BeUN0NEn.js → use-display-rows-DFSNvNWx.js} +2 -2
  122. package/dist/shell/assets/{use-paged-search-33KMMcrt.js → use-paged-search-B52iaj1D.js} +2 -2
  123. package/dist/shell/assets/{use-run-trace-Bx9X8OOk.js → use-run-trace-KAufJAqD.js} +2 -2
  124. package/dist/shell/assets/{use-workflow-page-BiyvMPJr.js → use-workflow-page-171SXJ7G.js} +2 -2
  125. package/dist/shell/assets/{use-workflow-types-Dv4j1fdw.js → use-workflow-types-ZGEaDrEJ.js} +2 -2
  126. package/dist/shell/assets/{workflow-canvas-CXQvv_wT.js → workflow-canvas-CCu4twlF.js} +2 -2
  127. package/dist/shell/assets/{workflow-field-f3yIRcdj.js → workflow-field-BFNHwCjK.js} +3 -3
  128. package/dist/shell/assets/{workflow-graph-editor-Dkn-LYZl.js → workflow-graph-editor-DTSyabCd.js} +2 -2
  129. package/dist/shell/assets/{workflow-run-field-Btst6LE9.js → workflow-run-field-D2fpm1Vk.js} +3 -3
  130. package/dist/shell/assets/{workflow-status-field-DwvvkBQe.js → workflow-status-field-D_4-8JIF.js} +2 -2
  131. package/dist/shell/assets/{workflow-workbench-KEqXjmsY.js → workflow-workbench-CN5-OYpd.js} +2 -2
  132. package/dist/shell/index.html +3 -3
  133. package/dist/shell/protobase.shell.json +2 -2
  134. package/dist/shell/protobase.sw.js +2 -2
  135. package/dist/shell-source-maps/assets/{account-page-BKgO5U-X.js.map → account-page-BPtyska2.js.map} +1 -1
  136. package/dist/shell-source-maps/assets/app-DKn-6fgf.js.map +1 -0
  137. package/dist/shell-source-maps/assets/{assistant-shell-DuqVM626.js.map → assistant-shell-BW59by36.js.map} +1 -1
  138. package/dist/shell-source-maps/assets/{board-display-DddxG38M.js.map → board-display-uC4sMccF.js.map} +1 -1
  139. package/dist/shell-source-maps/assets/{calendar-display-zLyE7rhF.js.map → calendar-display-BZhTapxV.js.map} +1 -1
  140. package/dist/shell-source-maps/assets/{call-rings-uudxTLcY.js.map → call-rings-DwyQO_zl.js.map} +1 -1
  141. package/dist/shell-source-maps/assets/{calls-7JJIY2v0.js.map → calls-DeHPxZSF.js.map} +1 -1
  142. package/dist/shell-source-maps/assets/{circle-alert-CoX9nLsD.js.map → circle-alert-mtPRl_1e.js.map} +1 -1
  143. package/dist/shell-source-maps/assets/{composed-page-DnCccgH0.js.map → composed-page-CqjAO9Zv.js.map} +1 -1
  144. package/dist/shell-source-maps/assets/{composer-section-84NNbJ4X.js.map → composer-section-D16PrwJe.js.map} +1 -1
  145. package/dist/shell-source-maps/assets/{connect-route-DXEPuBjl.js.map → connect-route-BHjM-n0c.js.map} +1 -1
  146. package/dist/shell-source-maps/assets/{copy-field-BlooSgn7.js.map → copy-field-C7SgGBWe.js.map} +1 -1
  147. package/dist/shell-source-maps/assets/{create-route-BNcDypty.js.map → create-route-CV6sScUu.js.map} +1 -1
  148. package/dist/shell-source-maps/assets/{custom-step-container-field-CyvWLsF0.js.map → custom-step-container-field-DbXZzPJp.js.map} +1 -1
  149. package/dist/shell-source-maps/assets/{embedded-list-B8K84K5b.js.map → embedded-list-CG1SyUtd.js.map} +1 -1
  150. package/dist/shell-source-maps/assets/{export-dialog-IWSkZoEf.js.map → export-dialog-CMPyzZa3.js.map} +1 -1
  151. package/dist/shell-source-maps/assets/{graph-view-D6ueoFs9.js.map → graph-view-CfO5HJXO.js.map} +1 -1
  152. package/dist/shell-source-maps/assets/{group-donut-BnDzQhIS.js.map → group-donut-UrNllcKD.js.map} +1 -1
  153. package/dist/shell-source-maps/assets/{guest-call-page-IwcmjkTm.js.map → guest-call-page-CgISSPNH.js.map} +1 -1
  154. package/dist/shell-source-maps/assets/{html-viewer-DjlpP883.js.map → html-viewer-GgauWEUE.js.map} +1 -1
  155. package/dist/shell-source-maps/assets/{import-dialog-DrDyc76O.js.map → import-dialog-BppJUUoF.js.map} +1 -1
  156. package/dist/shell-source-maps/assets/{import-table-dialog-DYBhyBp7.js.map → import-table-dialog-cfWZMJfg.js.map} +1 -1
  157. package/dist/shell-source-maps/assets/{invitations-page-BmkBa0fB.js.map → invitations-page-Cx960zfb.js.map} +1 -1
  158. package/dist/shell-source-maps/assets/{layout-grid-DGOCHAPH.js.map → layout-grid-IdJUsNk6.js.map} +1 -1
  159. package/dist/shell-source-maps/assets/{legend-item-DxdIZ1pf.js.map → legend-item-FRGENXpR.js.map} +1 -1
  160. package/dist/shell-source-maps/assets/{list-page-BhWOEaP6.js.map → list-page-Di8ApAmU.js.map} +1 -1
  161. package/dist/shell-source-maps/assets/{maplibre-k6sh-ts2.js.map → maplibre-B0oPa_5e.js.map} +1 -1
  162. package/dist/shell-source-maps/assets/{markdown-content-vMCleJqq.js.map → markdown-content-CA74ofB3.js.map} +1 -1
  163. package/dist/shell-source-maps/assets/{members-page-NrAKIuOb.js.map → members-page-UO-o4WSG.js.map} +1 -1
  164. package/dist/shell-source-maps/assets/{messages-Cjox3dPW.js.map → messages-CjRWJI05.js.map} +1 -1
  165. package/dist/shell-source-maps/assets/{organization-page-HRjNwewQ.js.map → organization-page-DaGSJbur.js.map} +1 -1
  166. package/dist/shell-source-maps/assets/{organizations-page-D-Is15Iq.js.map → organizations-page-C5oK_zsd.js.map} +1 -1
  167. package/dist/shell-source-maps/assets/{pending-invitation-row-MATld1YG.js.map → pending-invitation-row-BEvgmW-N.js.map} +1 -1
  168. package/dist/shell-source-maps/assets/{period-chart-xv3RhzW9.js.map → period-chart-CW2NUL07.js.map} +1 -1
  169. package/dist/shell-source-maps/assets/{person-row-DPsUV5XA.js.map → person-row-5VQjyq5t.js.map} +1 -1
  170. package/dist/shell-source-maps/assets/{public-form-page-CK0NgO4L.js.map → public-form-page-CqU7Cg33.js.map} +1 -1
  171. package/dist/shell-source-maps/assets/{record-lines-CDGK7ZyR.js.map → record-lines-CJgNIVFS.js.map} +1 -1
  172. package/dist/shell-source-maps/assets/{record-map-C8QpQBwW.js.map → record-map-DHkY7hYE.js.map} +1 -1
  173. package/dist/shell-source-maps/assets/{record-opens-jhy0UcRX.js.map → record-opens-B0MlYjrH.js.map} +1 -1
  174. package/dist/shell-source-maps/assets/{record-page-BQtAOfUN.js.map → record-page-whDNzf71.js.map} +1 -1
  175. package/dist/shell-source-maps/assets/{record-preview-Cnz2q7jF.js.map → record-preview-BUnzkT7g.js.map} +1 -1
  176. package/dist/shell-source-maps/assets/{records-map-Cpt0N4k2.js.map → records-map-DjcDdJBM.js.map} +1 -1
  177. package/dist/shell-source-maps/assets/{render-node-CQddajXn.js.map → render-node-DGmdm-wr.js.map} +1 -1
  178. package/dist/shell-source-maps/assets/{reorder-button-2tg9wf42.js.map → reorder-button-q4oqy3UR.js.map} +1 -1
  179. package/dist/shell-source-maps/assets/{run-trace-view-C8KR_auS.js.map → run-trace-view-DjtMSojN.js.map} +1 -1
  180. package/dist/shell-source-maps/assets/{runner-install-field-Dfnq3Rqy.js.map → runner-install-field-Ddxc9XB0.js.map} +1 -1
  181. package/dist/shell-source-maps/assets/{runtime-update-BkP2MEsM.js.map → runtime-update-CKEA5P-k.js.map} +1 -1
  182. package/dist/shell-source-maps/assets/{sheet-source-Bsx98FTk.js.map → sheet-source-CAIVzfnw.js.map} +1 -1
  183. package/dist/shell-source-maps/assets/{sign-in-policy-page-hgTJtin9.js.map → sign-in-policy-page-CdTIudi-.js.map} +1 -1
  184. package/dist/shell-source-maps/assets/{start-block-queries-Cmx56hgU.js.map → start-block-queries-DjQjQ2Ef.js.map} +1 -1
  185. package/dist/shell-source-maps/assets/{step-catalog-BJyr7gmH.js.map → step-catalog-Dit0IJvs.js.map} +1 -1
  186. package/dist/shell-source-maps/assets/{step-panel-D-jkWWLs.js.map → step-panel-9kx6xfm1.js.map} +1 -1
  187. package/dist/shell-source-maps/assets/{timeline-display-FKWlqzyN.js.map → timeline-display-CoQETrmW.js.map} +1 -1
  188. package/dist/shell-source-maps/assets/{trash-BNguTSbA.js.map → trash-DJwJPifF.js.map} +1 -1
  189. package/dist/shell-source-maps/assets/{update-set-CaKid6Bl.js.map → update-set-DPSGWrcI.js.map} +1 -1
  190. package/dist/shell-source-maps/assets/{use-calendar-move-UCTCC4Mu.js.map → use-calendar-move-CgXeokRh.js.map} +1 -1
  191. package/dist/shell-source-maps/assets/{use-display-rows-BeUN0NEn.js.map → use-display-rows-DFSNvNWx.js.map} +1 -1
  192. package/dist/shell-source-maps/assets/{use-paged-search-33KMMcrt.js.map → use-paged-search-B52iaj1D.js.map} +1 -1
  193. package/dist/shell-source-maps/assets/{use-run-trace-Bx9X8OOk.js.map → use-run-trace-KAufJAqD.js.map} +1 -1
  194. package/dist/shell-source-maps/assets/{use-workflow-page-BiyvMPJr.js.map → use-workflow-page-171SXJ7G.js.map} +1 -1
  195. package/dist/shell-source-maps/assets/{use-workflow-types-Dv4j1fdw.js.map → use-workflow-types-ZGEaDrEJ.js.map} +1 -1
  196. package/dist/shell-source-maps/assets/{workflow-canvas-CXQvv_wT.js.map → workflow-canvas-CCu4twlF.js.map} +1 -1
  197. package/dist/shell-source-maps/assets/{workflow-field-f3yIRcdj.js.map → workflow-field-BFNHwCjK.js.map} +1 -1
  198. package/dist/shell-source-maps/assets/{workflow-graph-editor-Dkn-LYZl.js.map → workflow-graph-editor-DTSyabCd.js.map} +1 -1
  199. package/dist/shell-source-maps/assets/{workflow-run-field-Btst6LE9.js.map → workflow-run-field-D2fpm1Vk.js.map} +1 -1
  200. package/dist/shell-source-maps/assets/{workflow-status-field-DwvvkBQe.js.map → workflow-status-field-D_4-8JIF.js.map} +1 -1
  201. package/dist/shell-source-maps/assets/{workflow-workbench-KEqXjmsY.js.map → workflow-workbench-CN5-OYpd.js.map} +1 -1
  202. package/dist/status/messages.d.ts +2 -2
  203. package/dist/users/messages.d.ts +2 -2
  204. package/package.json +5 -5
  205. package/dist/shell/assets/app-D5KGkwJq.js +0 -34
  206. package/dist/shell-source-maps/assets/app-D5KGkwJq.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"public-form-page-CK0NgO4L.js","names":["metaText","useState","n","a","t","__toESM","require_react","require_jsx_runtime","humanize","keys","isApiError","text$1","Button","Field","messages","Notice","useFocusFirstInvalid","hasDatabaseDefault","FieldEditor","isRequired","Spinner","createBody","useDocumentTitle","ErrorBanner","AuthLayout","initialDraft","useClient","numberDefault","fieldErrors","fieldMessage","useQuery","solveChallenge","deriveKey","import_react","text","proveHuman","challenge","client","name","solution","import_jsx_runtime","PublicFormPage","form","LoadedForm","model","title","view","draft","setDraft","errors","setErrors","failure","setFailure","sending","setSending","sent","setSent","rejections","setRejections","formRef","change","current","field","value","send","error","found","count","event","hints","label","problem","next"],"sources":["../../../src/forms/messages.ts","../../../src/forms/prove-human.ts","../../../src/forms/public-form-page.tsx"],"sourcesContent":["import { messages } from '../locale/messages'\n\nexport const text = messages('forms')\n","import { solveChallenge } from 'altcha-lib'\nimport { deriveKey } from 'altcha-lib/algorithms/web/sha'\nimport type { Client, FormProof } from '@protobase/client'\nimport { text } from './messages'\n\n/**\n * The bot check of a public form, done: fetches a fresh challenge and solves it in this browser, about a second of its\n * work, so a check never expires while someone types.\n */\nexport const proveHuman = async (client: Pick<Client, 'formChallenge'>, name: string): Promise<FormProof> => {\n const challenge = await client.formChallenge(name)\n const solution = await solveChallenge({ challenge, deriveKey })\n if (!solution) throw new Error(text('checkTooLong'))\n return { challenge, solution: { counter: solution.counter, derivedKey: solution.derivedKey } }\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport { isApiError, type ProblemError, type PublicForm } from '@protobase/client'\nimport { AuthLayout } from '../auth/auth-layout'\nimport { useClient } from '../data/api-provider'\nimport { keys } from '../data/query-keys'\nimport { humanize } from '../live/naming'\nimport { Button } from '../primitives/button'\nimport { Spinner } from '../primitives/spinner'\nimport { Field } from '../record-view'\nimport { createBody, hasDatabaseDefault, initialDraft, numberDefault, isRequired, type Draft } from '../app/create/create-values'\nimport { useDocumentTitle } from '../app/document-title'\nimport { ErrorBanner } from '../app/error-banner'\nimport { FieldEditor } from '../app/field-editor'\nimport { fieldErrors, fieldMessage } from '../app/field-errors'\nimport { Notice } from '../app/meta-gate'\nimport { useFocusFirstInvalid } from '../app/use-focus-first-invalid'\nimport { text as metaText } from '../app/meta-gate-messages'\nimport { text } from './messages'\nimport { proveHuman } from './prove-human'\n\n/**\n * `/-/forms/<name>`: a public form, for anyone, signed in or not. It sends with a bot check its browser solves, and\n * then shows the form's thanks in its place.\n */\nexport const PublicFormPage = ({ name }: { name: string }) => {\n const client = useClient()\n const form = useQuery({ queryKey: keys.publicForm(name), queryFn: () => client.form(name) })\n if (form.isPending) {\n return (\n <div className=\"flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground\">\n <Spinner /> {text('loading')}\n </div>\n )\n }\n if (form.error) {\n if (isApiError(form.error) && form.error.status === 404) return <Notice title={text('notFound')}>{text('noForm')}</Notice>\n return <Notice title={metaText('cannotReach')}>{isApiError(form.error) ? form.error.message : metaText('noAnswer')}</Notice>\n }\n return <LoadedForm form={form.data} />\n}\n\nconst LoadedForm = ({ form }: { form: PublicForm }) => {\n const client = useClient()\n const { resource: model, view } = form\n const title = form.title ?? view.names?.singular ?? humanize(view.resource)\n useDocumentTitle(title)\n const [draft, setDraft] = useState<Draft>(() => initialDraft(model, [{ title, fields: form.fields }]))\n const [errors, setErrors] = useState<Record<string, ProblemError>>({})\n const [failure, setFailure] = useState<unknown>()\n const [sending, setSending] = useState(false)\n const [sent, setSent] = useState(false)\n // How many submissions the server turned down for their fields\n const [rejections, setRejections] = useState(0)\n const formRef = useFocusFirstInvalid<HTMLFormElement>(rejections)\n\n if (sent) {\n return (\n <AuthLayout title={title} size=\"md\">\n <p role=\"status\" className=\"rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text\">\n {form.thanks}\n </p>\n </AuthLayout>\n )\n }\n\n const change = (name: string, value: unknown) => {\n setErrors((current) => Object.fromEntries(Object.entries(current).filter(([field]) => field !== name)))\n setDraft((current) => ({ ...current, [name]: value }))\n }\n\n const send = async () => {\n setSending(true)\n setFailure(undefined)\n try {\n await client.submitForm(form.name, createBody(model, {}, draft), await proveHuman(client, form.name))\n setSent(true)\n } catch (error) {\n // A field's problem shows under it; anything else, such as too many submissions or a failed check, above the button\n const found = fieldErrors(error)\n setErrors(found)\n if (Object.keys(found).length > 0) setRejections((count) => count + 1)\n else setFailure(error)\n } finally {\n setSending(false)\n }\n }\n\n return (\n <AuthLayout title={title} size=\"md\">\n <form\n ref={formRef}\n className=\"flex flex-col gap-4\"\n onSubmit={(event) => {\n event.preventDefault()\n void send()\n }}\n >\n {form.fields.map((name) => {\n const field = model.fields[name]!\n const hints = view.fields[name]\n const label = hints?.label ?? humanize(name)\n const problem = errors[name]\n return (\n <Field key={name} name={name} label={label} help={hints?.help} required={isRequired(field)} error={problem && fieldMessage(field, label, problem)}>\n <FieldEditor\n field={field}\n hints={hints}\n value={draft[name] ?? (field.type === 'boolean' ? false : '')}\n stored={undefined}\n placeholder={hasDatabaseDefault(field) ? text('setByDatabase') : numberDefault(field)}\n invalid={Boolean(problem)}\n onChange={(next) => change(name, next)}\n />\n </Field>\n )\n })}\n {failure !== undefined && <ErrorBanner title={text('notSent')} error={failure} />}\n <Button variant=\"primary\" type=\"submit\" loading={sending} className=\"min-h-10\">\n {text('send')}\n </Button>\n </form>\n </AuthLayout>\n )\n}\n"],"mappings":"82BAEakC,EAAOpB,EAAS,OAAO,ECOvBqB,EAAa,MAAO,EAAuC,IAAqC,CAC3G,IAAMC,EAAY,MAAMC,EAAO,cAAcC,CAAI,EAC3CC,EAAW,MAAMR,EAAe,CAAE,YAAW,WAAU,CAAC,EAC9D,GAAI,CAACQ,EAAU,MAAU,MAAML,EAAK,cAAc,CAAC,EACnD,MAAO,CAAE,YAAW,SAAU,CAAE,QAASK,EAAS,QAAS,WAAYA,EAAS,UAAW,CAAE,CAC/F,aCWaE,GAAkB,CAAE,UAA6B,CAC5D,IAAMJ,EAASX,EAAU,EACnBgB,EAAOZ,EAAS,CAAE,SAAUrB,EAAK,WAAW6B,CAAI,EAAG,YAAeD,EAAO,KAAKC,CAAI,CAAE,CAAC,EAY3F,OAXII,EAAK,WAEL,EAAAF,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,+EAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAACpB,EAAD,CAAU,CAAA,EAAC,IAAEc,EAAK,SAAS,CACxB,IAGLQ,EAAK,MACHhC,EAAWgC,EAAK,KAAK,GAAKA,EAAK,MAAM,SAAW,KAAY,EAAAF,EAAA,IAAA,CAACzB,EAAD,CAAQ,MAAOmB,EAAK,UAAU,EAAI,SAAAA,EAAK,QAAQ,CAAU,CAAA,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GAASX,EAAOtB,EAAMkC,CAAI,CACtC,CAAA,CACI,EAVKlC,CAUL,CAEX,CAAC,EACAa,IAAY,IAAA,KAAa,EAAAX,EAAA,IAAA,CAACjB,EAAD,CAAa,MAAOW,EAAK,SAAS,EAAG,MAAOiB,CAAU,CAAA,GAChF,EAAAX,EAAA,IAAA,CAAC5B,EAAD,CAAQ,QAAQ,UAAU,KAAK,SAAS,QAASyC,EAAS,UAAU,WACjE,SAAAnB,EAAK,MAAM,CACN,CAAA,CACJ,GACI,CAAA,CAEhB","debugId":"8ad0d80e-e0bc-4092-866c-45dca8ca1783"}
1
+ {"version":3,"file":"public-form-page-CqU7Cg33.js","names":["metaText","useState","n","a","t","__toESM","require_react","require_jsx_runtime","humanize","keys","isApiError","text$1","Button","Field","messages","Notice","useFocusFirstInvalid","hasDatabaseDefault","FieldEditor","isRequired","Spinner","createBody","useDocumentTitle","ErrorBanner","AuthLayout","initialDraft","useClient","numberDefault","fieldErrors","fieldMessage","useQuery","solveChallenge","deriveKey","import_react","text","proveHuman","challenge","client","name","solution","import_jsx_runtime","PublicFormPage","form","LoadedForm","model","title","view","draft","setDraft","errors","setErrors","failure","setFailure","sending","setSending","sent","setSent","rejections","setRejections","formRef","change","current","field","value","send","error","found","count","event","hints","label","problem","next"],"sources":["../../../src/forms/messages.ts","../../../src/forms/prove-human.ts","../../../src/forms/public-form-page.tsx"],"sourcesContent":["import { messages } from '../locale/messages'\n\nexport const text = messages('forms')\n","import { solveChallenge } from 'altcha-lib'\nimport { deriveKey } from 'altcha-lib/algorithms/web/sha'\nimport type { Client, FormProof } from '@protobase/client'\nimport { text } from './messages'\n\n/**\n * The bot check of a public form, done: fetches a fresh challenge and solves it in this browser, about a second of its\n * work, so a check never expires while someone types.\n */\nexport const proveHuman = async (client: Pick<Client, 'formChallenge'>, name: string): Promise<FormProof> => {\n const challenge = await client.formChallenge(name)\n const solution = await solveChallenge({ challenge, deriveKey })\n if (!solution) throw new Error(text('checkTooLong'))\n return { challenge, solution: { counter: solution.counter, derivedKey: solution.derivedKey } }\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport { isApiError, type ProblemError, type PublicForm } from '@protobase/client'\nimport { AuthLayout } from '../auth/auth-layout'\nimport { useClient } from '../data/api-provider'\nimport { keys } from '../data/query-keys'\nimport { humanize } from '../live/naming'\nimport { Button } from '../primitives/button'\nimport { Spinner } from '../primitives/spinner'\nimport { Field } from '../record-view'\nimport { createBody, hasDatabaseDefault, initialDraft, numberDefault, isRequired, type Draft } from '../app/create/create-values'\nimport { useDocumentTitle } from '../app/document-title'\nimport { ErrorBanner } from '../app/error-banner'\nimport { FieldEditor } from '../app/field-editor'\nimport { fieldErrors, fieldMessage } from '../app/field-errors'\nimport { Notice } from '../app/meta-gate'\nimport { useFocusFirstInvalid } from '../app/use-focus-first-invalid'\nimport { text as metaText } from '../app/meta-gate-messages'\nimport { text } from './messages'\nimport { proveHuman } from './prove-human'\n\n/**\n * `/-/forms/<name>`: a public form, for anyone, signed in or not. It sends with a bot check its browser solves, and\n * then shows the form's thanks in its place.\n */\nexport const PublicFormPage = ({ name }: { name: string }) => {\n const client = useClient()\n const form = useQuery({ queryKey: keys.publicForm(name), queryFn: () => client.form(name) })\n if (form.isPending) {\n return (\n <div className=\"flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground\">\n <Spinner /> {text('loading')}\n </div>\n )\n }\n if (form.error) {\n if (isApiError(form.error) && form.error.status === 404) return <Notice title={text('notFound')}>{text('noForm')}</Notice>\n return <Notice title={metaText('cannotReach')}>{isApiError(form.error) ? form.error.message : metaText('noAnswer')}</Notice>\n }\n return <LoadedForm form={form.data} />\n}\n\nconst LoadedForm = ({ form }: { form: PublicForm }) => {\n const client = useClient()\n const { resource: model, view } = form\n const title = form.title ?? view.names?.singular ?? humanize(view.resource)\n useDocumentTitle(title)\n const [draft, setDraft] = useState<Draft>(() => initialDraft(model, [{ title, fields: form.fields }]))\n const [errors, setErrors] = useState<Record<string, ProblemError>>({})\n const [failure, setFailure] = useState<unknown>()\n const [sending, setSending] = useState(false)\n const [sent, setSent] = useState(false)\n // How many submissions the server turned down for their fields\n const [rejections, setRejections] = useState(0)\n const formRef = useFocusFirstInvalid<HTMLFormElement>(rejections)\n\n if (sent) {\n return (\n <AuthLayout title={title} size=\"md\">\n <p role=\"status\" className=\"rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text\">\n {form.thanks}\n </p>\n </AuthLayout>\n )\n }\n\n const change = (name: string, value: unknown) => {\n setErrors((current) => Object.fromEntries(Object.entries(current).filter(([field]) => field !== name)))\n setDraft((current) => ({ ...current, [name]: value }))\n }\n\n const send = async () => {\n setSending(true)\n setFailure(undefined)\n try {\n await client.submitForm(form.name, createBody(model, {}, draft), await proveHuman(client, form.name))\n setSent(true)\n } catch (error) {\n // A field's problem shows under it; anything else, such as too many submissions or a failed check, above the button\n const found = fieldErrors(error)\n setErrors(found)\n if (Object.keys(found).length > 0) setRejections((count) => count + 1)\n else setFailure(error)\n } finally {\n setSending(false)\n }\n }\n\n return (\n <AuthLayout title={title} size=\"md\">\n <form\n ref={formRef}\n className=\"flex flex-col gap-4\"\n onSubmit={(event) => {\n event.preventDefault()\n void send()\n }}\n >\n {form.fields.map((name) => {\n const field = model.fields[name]!\n const hints = view.fields[name]\n const label = hints?.label ?? humanize(name)\n const problem = errors[name]\n return (\n <Field key={name} name={name} label={label} help={hints?.help} required={isRequired(field)} error={problem && fieldMessage(field, label, problem)}>\n <FieldEditor\n field={field}\n hints={hints}\n value={draft[name] ?? (field.type === 'boolean' ? false : '')}\n stored={undefined}\n placeholder={hasDatabaseDefault(field) ? text('setByDatabase') : numberDefault(field)}\n invalid={Boolean(problem)}\n onChange={(next) => change(name, next)}\n />\n </Field>\n )\n })}\n {failure !== undefined && <ErrorBanner title={text('notSent')} error={failure} />}\n <Button variant=\"primary\" type=\"submit\" loading={sending} className=\"min-h-10\">\n {text('send')}\n </Button>\n </form>\n </AuthLayout>\n )\n}\n"],"mapp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":["useState","useRef","MoreHorizontal","useId","text","useState","text","n","a","t","__toESM","require_react","require_jsx_runtime","humanize","cn","formatInt","Section","Button","can","FieldControlContext","messages","recordTitle","useAdminMeta","usePermissions","FieldEditor","useMenuTop","keyValue","isChosen","Plus","Ellipsis","rowAllows","fieldMessage","useMenuRight","GripVertical","useSensor","MouseSensor","KeyboardSensor","TouchSensor","closestCenter","DndContext","useSensors","verticalListSortingStrategy","useSortable","sortableKeyboardCoordinates","SortableContext","track","column","lineGridStyle","columns","lineTableMinWidth","sum","lineGrid","import_react","import_jsx_runtime","LineMenu","open","setOpen","root","menu","right","top","close","event","label","items","item","text","LineRow","line","reorderable","position","onMove","count","onRemove","setNodeRef","error","transform","isDragging","setActivatorNodeRef","attributes","listeners","reorder","from","to","next","moved","headerCell","announcementsFor","name","lines","each","id","lineName","place","active","over","InlineChildTable","onReorder","sensors","move","index","removable","lineError","onAdd","footer","LineCell","message","problem","field","text$1","lineNumber","RecordLines","permissions","model","view","views","picked","setPicked","editable","data","saving","canUpdate","canCreate","canDelete","writable","placeOf","draft","rejected","tableColumns","hints","target","resources","pickable","value","chosen","current","rejection"],"sources":["../../../src/inline-child-table/columns.ts","../../../src/inline-child-table/line-menu.tsx","../../../src/inline-child-table/messages.ts","../../../src/inline-child-table/line-row.tsx","../../../src/inline-child-table/reorder.ts","../../../src/inline-child-table/inline-child-table.tsx","../../../src/app/record-lines-cell.tsx","../../../src/app/record-lines.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react'\n\n/** One column of the line table: its heading, the grid track it takes, and what each line shows in it. */\nexport type LineColumn<L> = {\n key: string\n label: string\n align?: 'right'\n /** A CSS grid track, such as `88px`; a share of the free width, at least 8rem, when omitted. */\n width?: string\n cell: (line: L) => ReactNode\n}\n\nconst track = (column: LineColumn<never>) => column.width ?? 'minmax(8rem,1fr)'\n\n/** The columns' tracks, between the drag handle and the menu that `lineGrid` places around them. */\nexport const lineGridStyle = (columns: LineColumn<never>[]) => ({ '--line-columns': columns.map(track).join(' ') }) as CSSProperties\n\n/** The narrowest the table gets before it scrolls sideways: each column's least width, and the handle and menu. */\nexport const lineTableMinWidth = (columns: LineColumn<never>[]) => `${columns.reduce((sum, column) => sum + (column.width?.endsWith('px') ? parseInt(column.width) / 16 : 8), 6)}rem`\n\nexport const lineGrid = 'grid grid-cols-[28px_var(--line-columns)_32px] items-center gap-2 pointer-coarse:grid-cols-[44px_var(--line-columns)_44px]'\n","import { MoreHorizontal } from 'lucide-react'\nimport { useEffect, useRef, useState } from 'react'\nimport { cn } from '../lib/cn'\nimport { useMenuRight, useMenuTop } from '../primitives/menu-edge'\n\nexport type LineMenuItem = { label: string; disabled?: boolean; destructive?: boolean; onSelect: () => void }\n\n/** The \"...\" at the end of a line: the keyboard-and-screen-reader way to reorder, besides the drag handle. */\nexport const LineMenu = ({ items, label }: { items: LineMenuItem[]; label: string }) => {\n const [open, setOpen] = useState(false)\n const root = useRef<HTMLDivElement>(null)\n const menu = useRef<HTMLUListElement>(null)\n const right = useMenuRight(open, root, menu)\n const top = useMenuTop(open, root, menu, right?.right)\n\n useEffect(() => {\n if (!open) return\n const close = (event: Event) => {\n if (event instanceof KeyboardEvent ? event.key === 'Escape' : !root.current?.contains(event.target as Node)) setOpen(false)\n }\n document.addEventListener('mousedown', close)\n document.addEventListener('keydown', close)\n return () => {\n document.removeEventListener('mousedown', close)\n document.removeEventListener('keydown', close)\n }\n }, [open])\n\n return (\n <div ref={root} className=\"relative flex justify-center\">\n <button\n type=\"button\"\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={() => setOpen(!open)}\n className=\"inline-flex size-7 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground pointer-coarse:size-11\"\n >\n <MoreHorizontal className=\"size-4\" />\n </button>\n {open && (\n <ul ref={menu} role=\"menu\" style={{ ...right, ...top }} className=\"absolute right-0 top-full z-30 mt-1 w-max min-w-36 rounded-md border bg-background py-1 shadow-pop\">\n {items.map((item) => (\n <li key={item.label} role=\"none\">\n <button\n type=\"button\"\n role=\"menuitem\"\n disabled={item.disabled}\n className={cn('block min-h-9 w-full px-3 py-1.5 text-left hover:bg-muted disabled:text-faint-foreground disabled:hover:bg-transparent', item.destructive && 'text-danger-text')}\n onClick={() => {\n setOpen(false)\n item.onSelect()\n }}\n >\n {item.label}\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n )\n}\n","import { messages } from '../locale/messages'\n\nexport const text = messages('inline-child-table')\n","import { useSortable } from '@dnd-kit/sortable'\nimport { GripVertical } from 'lucide-react'\nimport { cn } from '../lib/cn'\nimport { lineGrid, type LineColumn } from './columns'\nimport { LineMenu, type LineMenuItem } from './line-menu'\nimport { text } from './messages'\n\nexport type LineRowProps<L extends { id: string }> = {\n line: L\n /** How the line is named to a screen reader and in its menu. */\n name: string\n columns: LineColumn<L>[]\n position: number\n count: number\n /** The line can be dragged and moved with the menu. */\n reorderable: boolean\n /** The menu has \"Remove line\", which calls this. */\n onRemove?: () => void\n onMove: (to: number) => void\n /** Why the server turned the line down, under its cells. */\n error?: string\n}\n\nexport const LineRow = <L extends { id: string }>({ line, name, columns, position, count, reorderable, onRemove, onMove, error }: LineRowProps<L>) => {\n const { attributes, listeners, setNodeRef, setActivatorNodeRef, transform, transition, isDragging } = useSortable({ id: line.id, disabled: !reorderable })\n const menu: LineMenuItem[] = [\n ...(reorderable\n ? [\n { label: text('moveUp'), disabled: position === 0, onSelect: () => onMove(position - 1) },\n { label: text('moveDown'), disabled: position === count - 1, onSelect: () => onMove(position + 1) },\n ]\n : []),\n ...(onRemove ? [{ label: text('removeLine'), destructive: true, onSelect: onRemove }] : []),\n ]\n\n return (\n <div\n ref={setNodeRef}\n data-line-id={line.id}\n aria-invalid={error ? true : undefined}\n style={{ transform: transform ? `translate3d(0, ${transform.y}px, 0)` : undefined, transition }}\n className={cn('group relative border-b border-border bg-background px-2 py-1 last:border-b-0 hover:bg-surface', lineGrid, isDragging && 'z-10 bg-surface opacity-80 shadow-pop', error && 'bg-danger-soft')}\n >\n {reorderable ? (\n <button\n ref={setActivatorNodeRef}\n type=\"button\"\n aria-label={text('dragToReorder', { name })}\n {...attributes}\n {...listeners}\n style={{ touchAction: 'none' }}\n className=\"flex size-7 cursor-grab items-center justify-center rounded text-faint-foreground opacity-60 hover:bg-muted hover:opacity-100 focus-visible:opacity-100 active:cursor-grabbing pointer-coarse:size-11\"\n >\n <GripVertical className=\"size-4\" />\n </button>\n ) : (\n <span />\n )}\n {columns.map((column) => (\n <div key={column.key} className={cn('min-w-0', column.align === 'right' && 'text-right')}>\n {column.cell(line)}\n </div>\n ))}\n {menu.length > 0 ? <LineMenu label={text('actionsFor', { name })} items={menu} /> : <span />}\n {error && (\n <p role=\"alert\" className=\"col-span-full px-2 pb-1 text-xs text-danger-text\">\n {error}\n </p>\n )}\n </div>\n )\n}\n","export const reorder = <T>(items: readonly T[], from: number, to: number) => {\n if (from === to || from < 0 || from >= items.length) return [...items]\n const next = [...items]\n const [moved] = next.splice(from, 1)\n next.splice(Math.min(Math.max(to, 0), next.length), 0, moved!)\n return next\n}\n","import { DndContext, KeyboardSensor, MouseSensor, TouchSensor, closestCenter, useSensor, useSensors, type Announcements, type DragEndEvent } from '@dnd-kit/core'\nimport { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { Plus } from 'lucide-react'\nimport type { ReactNode } from 'react'\nimport { cn } from '../lib/cn'\nimport { Button } from '../primitives/button'\nimport { lineGrid, lineGridStyle, type LineColumn } from './columns'\nimport { LineRow } from './line-row'\nimport { reorder } from './reorder'\nimport { text } from './messages'\n\nexport type LineMove = { id: string; from: number; to: number }\n\nexport type InlineChildTableProps<L extends { id: string }> = {\n lines: L[]\n columns: LineColumn<L>[]\n /** How a line is named to a screen reader and in its menu. */\n lineName: (line: L) => string\n /** Called with the new order after a drag or a \"Move up\" / \"Move down\". */\n onReorder?: (lines: L[], move: LineMove) => void\n /** Show the drag handle and the move items; defaults to whether `onReorder` is given. */\n reorderable?: boolean\n /** Shows \"Add line\" under the lines. */\n onAdd?: () => void\n /** Gives the menu of each line that is `removable` \"Remove line\". */\n onRemove?: (line: L) => void\n /** Whether a line can be removed; every line when omitted. */\n removable?: (line: L) => boolean\n /** Why the server turned a line down, shown under it. */\n lineError?: (line: L) => string | undefined\n /** Under the table, such as the totals. */\n footer?: ReactNode\n}\n\nconst headerCell = 'px-2 text-[0.6875rem] font-medium uppercase tracking-wide text-muted-foreground'\n\nconst announcementsFor = <L extends { id: string }>(lines: L[], lineName: (line: L) => string): Announcements => {\n const name = (id: string | number) => {\n const line = lines.find((each) => each.id === id)\n return line ? lineName(line) : text('line')\n }\n const place = (id: string | number | undefined) => lines.findIndex((line) => line.id === id) + 1\n return {\n onDragStart: ({ active }) => text('pickedUp', { name: name(active.id), place: place(active.id), count: lines.length }),\n onDragOver: ({ active, over }) => (over ? text('over', { name: name(active.id), place: place(over.id), count: lines.length }) : undefined),\n onDragEnd: ({ active, over }) => (over ? text('dropped', { name: name(active.id), place: place(over.id), count: lines.length }) : text('droppedAtStart', { name: name(active.id) })),\n onDragCancel: ({ active }) => text('cancelled', { name: name(active.id), place: place(active.id) }),\n }\n}\n\n/** The lines of a record as rows of the given columns, put in order by dragging or from each row's menu. */\nexport const InlineChildTable = <L extends { id: string }>({ lines, columns, lineName, onReorder, reorderable = Boolean(onReorder), onAdd, onRemove, removable = () => true, lineError, footer }: InlineChildTableProps<L>) => {\n // A mouse starts dragging after a few pixels; a finger only after a short press, so scrolling still works.\n const sensors = useSensors(\n useSensor(MouseSensor, { activationConstraint: { distance: 4 } }),\n useSensor(TouchSensor, { activationConstraint: { delay: 250, tolerance: 5 } }),\n useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),\n )\n const move = (from: number, to: number) => {\n const line = lines[from]\n if (!line || !onReorder || to < 0 || to >= lines.length || from === to) return\n onReorder(reorder(lines, from, to), { id: line.id, from, to })\n }\n\n const onDragEnd = ({ active, over }: DragEndEvent) => {\n if (!over || active.id === over.id) return\n move(lines.findIndex((line) => line.id === active.id), lines.findIndex((line) => line.id === over.id))\n }\n\n return (\n <div>\n <div className=\"overflow-hidden rounded-lg border border-border bg-background\" style={lineGridStyle(columns)}>\n <div className={`${lineGrid} border-b border-border bg-surface px-2 py-2`}>\n <span />\n {columns.map((column) => (\n <span key={column.key} className={cn(headerCell, column.align === 'right' && 'text-right')}>\n {column.label}\n </span>\n ))}\n <span />\n </div>\n {lines.length === 0 && <p className=\"px-4 py-3 text-muted-foreground\">{text('noLines')}</p>}\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragEnd={onDragEnd}\n accessibility={{ announcements: announcementsFor(lines, lineName), screenReaderInstructions: { draggable: text('instructions') } }}\n >\n <SortableContext items={lines.map((line) => line.id)} strategy={verticalListSortingStrategy}>\n {lines.map((line, index) => (\n <LineRow\n key={line.id}\n line={line}\n name={lineName(line)}\n columns={columns}\n position={index}\n count={lines.length}\n reorderable={reorderable}\n onRemove={onRemove && removable(line) ? () => onRemove(line) : undefined}\n onMove={(to) => move(index, to)}\n error={lineError?.(line)}\n />\n ))}\n </SortableContext>\n </DndContext>\n {onAdd && (\n <div className=\"border-t border-border bg-surface px-2 py-1.5\">\n <Button variant=\"ghost\" size=\"sm\" onClick={onAdd}>\n <Plus className=\"size-3.5\" />\n {text('addLine')}\n </Button>\n </div>\n )}\n </div>\n {footer}\n </div>\n )\n}\n","import { useId } from 'react'\nimport type { ProblemError } from '@protobase/client'\nimport type { AppAddress, FieldModel, FieldViewModel, ResourceModel, ViewModel } from '@protobase/schema'\nimport { FieldControlContext } from '../primitives/field-control'\nimport { FieldEditor } from './field-editor'\nimport { fieldMessage } from './field-errors'\nimport { text } from './record-messages'\n\nexport type LineCellProps = {\n field: FieldModel\n hints: FieldViewModel | undefined\n /** The column's label, which names the cell to a screen reader with the line's number. */\n label: string\n lineNumber: number\n resource: string\n value: unknown\n stored: unknown\n relationLabel?: string\n relationTo?: AppAddress\n relationPicker?: { target: ResourceModel; view: ViewModel | undefined }\n locked: boolean\n /** The server's problem with this field of the line, from the last save. */\n problem?: ProblemError\n onChange: (next: unknown) => void\n}\n\n/** One field of a line, edited with the record page's own editor; its label is for screen readers, as the column heading shows it. */\nexport const LineCell = ({ field, hints, label, lineNumber, resource, value, stored, relationLabel, relationTo, relationPicker, locked, problem, onChange }: LineCellProps) => {\n const id = useId()\n const message = problem && fieldMessage(field, label, problem)\n return (\n <FieldControlContext.Provider value={{ id, invalid: Boolean(problem), required: false, ...(message && { describedBy: `${id}-error` }) }}>\n <label htmlFor={id} className=\"sr-only\">\n {text('lineField', { label, place: lineNumber })}\n </label>\n <FieldEditor\n field={field}\n hints={hints}\n value={value}\n stored={stored}\n relationLabel={relationLabel}\n relationTo={relationTo}\n relationPicker={relationPicker}\n locked={locked}\n invalid={Boolean(problem)}\n resource={resource}\n onChange={onChange}\n />\n {message && (\n <p id={`${id}-error`} className=\"px-1 pt-0.5 text-xs text-danger-text\">\n {message}\n </p>\n )}\n </FieldControlContext.Provider>\n )\n}\n","import { useState } from 'react'\nimport { InlineChildTable, lineTableMinWidth, type LineColumn } from '../inline-child-table'\nimport { recordTitle } from '../live/model-helpers'\nimport { humanize } from '../live/naming'\nimport { formatInt } from '../format'\nimport { Section } from '../record-view'\nimport { isChosen, keyValue } from './create/create-values'\nimport { useAdminMeta, usePermissions } from './meta-gate'\nimport { can, rowAllows } from './permissions'\nimport { LineCell } from './record-lines-cell'\nimport { linesLimit } from './use-lines'\nimport type { ShownLine } from './use-lines-draft'\nimport type { RecordLinesData } from './use-record-lines'\nimport { text } from './record-messages'\n\ntype RecordLinesProps = {\n lines: RecordLinesData & { model: NonNullable<RecordLinesData['model']>; item: NonNullable<RecordLinesData['item']> }\n /** The record's form is open and its lines may change; on the read view, or a record that cannot change, they only show. */\n editable: boolean\n saving: boolean\n}\n\n/**\n * The lines of a record as a table of their view's columns, edited in place: a line's fields, new lines, removed ones\n * and their order only change the draft; the record's Save writes it all, in one batch. A line the server turns down\n * says why on its row.\n */\nexport const RecordLines = ({ lines, editable, saving }: RecordLinesProps) => {\n const { resources, views } = useAdminMeta()\n const { item, model, columns, data, draft } = lines\n const permissions = usePermissions(model.name)\n const view = views[model.name]\n // The name of the record a relation was just set to, by line and field, until the saved lines name it\n const [picked, setPicked] = useState<Record<string, string>>({})\n const open = editable && data.complete && !data.loading && !saving\n const canUpdate = open && can(permissions, 'update')\n const canCreate = open && can(permissions, 'create')\n const canDelete = open && can(permissions, 'delete')\n const writable = (line: ShownLine) => (line.stored ? canUpdate && rowAllows(line.stored, 'update') : canCreate)\n const placeOf = (line: ShownLine) => draft.shown.indexOf(line) + 1\n const rejected = (line: ShownLine) => (draft.rejection?.id === line.id ? draft.rejection : undefined)\n\n const tableColumns: LineColumn<ShownLine>[] = columns.map((name) => {\n const field = model.fields[name]!\n const hints = view?.fields[name]\n const label = hints?.label ?? humanize(name)\n const target = field.relation ? resources[field.relation.resource] : undefined\n const pickable = target && target.primaryKey.length === 1 ? target : undefined\n return {\n key: name,\n label,\n ...(['integer', 'bigint', 'decimal'].includes(field.type) && { align: 'right' as const, width: 'minmax(6rem,0.6fr)' }),\n cell: (line) => {\n const value = draft.value(line.id, name)\n const chosen = value === null || value === undefined || value === '' ? undefined : String(value)\n return (\n <LineCell\n field={field}\n hints={hints}\n label={label}\n lineNumber={placeOf(line)}\n resource={model.name}\n value={value}\n stored={line.stored?.[name]}\n relationLabel={chosen === undefined ? undefined : (picked[`${line.id}/${name}`] ?? data.labels[name]?.[chosen])}\n relationTo={pickable && chosen !== undefined ? { kind: 'record', resource: pickable.name, key: chosen } : undefined}\n relationPicker={pickable && { target: pickable, view: views[pickable.name] }}\n locked={!writable(line)}\n problem={rejected(line)?.fields[name]}\n onChange={(next) => {\n if (!pickable || !isChosen(next)) return draft.change(line.id, name, next)\n setPicked((current) => ({ ...current, [`${line.id}/${name}`]: next.label }))\n draft.change(line.id, name, keyValue(pickable, next.key))\n }}\n />\n )\n },\n }\n })\n\n // A refusal that names none of the fields on screen says why under the line\n const lineError = (line: ShownLine) => {\n const rejection = rejected(line)\n if (!rejection || columns.some((name) => rejection.fields[name])) return undefined\n return rejection.message\n }\n\n return (\n <Section title={item.title} help={item.help}>\n {!data.complete && <p className=\"mb-2 text-muted-foreground\">{text('tooManyLines', { limit: formatInt(linesLimit) })}</p>}\n <div className=\"-mx-4 overflow-x-auto px-4 [-webkit-overflow-scrolling:touch] md:mx-0 md:px-0\">\n <div style={{ minWidth: lineTableMinWidth(tableColumns) }}>\n <InlineChildTable\n lines={draft.shown}\n columns={tableColumns}\n lineName={(line) => recordTitle(model, view, line.stored ?? {}, '') || text('lineNumber', { place: placeOf(line) })}\n onReorder={(next) => draft.setOrder(next.map((line) => line.id))}\n reorderable={canUpdate}\n onAdd={canCreate ? () => void draft.add() : undefined}\n onRemove={canCreate || canDelete ? (line) => draft.remove(line.id) : undefined}\n removable={(line) => (line.stored ? canDelete && rowAllows(line.stored, 'delete') : canCreate)}\n lineError={lineError}\n />\n </div>\n </div>\n </Section>\n )\n}\n"],"mappings":"i/BAYA,IAAM6C,EAAS,GAA8BC,EAAO,OAAS,mBAGhDC,EAAiB,IAAkC,CAAE,iBAAkBC,EAAQ,IAAIH,CAAK,CAAC,CAAC,KAAK,GAAG,CAAE,GAGpGI,EAAqB,GAAiC,GAAGD,EAAQ,QAAQ,EAAK,IAAWE,GAAOJ,EAAO,OAAO,SAAS,IAAI,EAAI,SAASA,EAAO,KAAK,EAAI,GAAK,GAAI,CAAC,EAAE,KAEpKK,EAAW,mJCZXG,GAAY,CAAE,QAAO,WAAsD,CACtF,GAAM,CAACC,EAAMC,IAAA,EAAWxD,EAAAA,SAAAA,CAAS,EAAK,EAChCyD,GAAA,EAAOxD,EAAAA,OAAAA,CAAuB,IAAI,EAClCyD,GAAA,EAAOzD,EAAAA,OAAAA,CAAyB,IAAI,EACpC0D,EAAQ3B,EAAauB,EAAME,EAAMC,CAAI,EACrCE,EAAMnC,EAAW8B,EAAME,EA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,GAAaC,EAAa,GAASG,EAAM,OAAO1D,EAAK,EAAE,EAAI,IAAA,GACrE,UAAY,GAAUA,EAAK,OAASuD,GAAa7F,EAAUsC,EAAK,OAAQ,QAAQ,EAAIsD,EACzE,UApBF,GAAoB,CACrC,IAAMc,EAAYT,EAAS3D,CAAI,EAC/B,GAAKoE,GAAa,GAAQ,KAAM,GAASA,EAAU,OAAOhD,EAAK,EAC/D,OAAOgD,EAAU,OACnB,CAiBS,CAAA,CACE,CAAA,CACF,CAAA,CACE,GAEb","debugId":"8318aed9-c913-463e-a063-217826ffff74"}
1
+ {"version":3,"file":"record-lines-CJgNIVFS.js","names":["useState","useRef","MoreHorizontal","useId","text","useState","text","n","a","t","__toESM","require_react","require_jsx_runtime","humanize","cn","formatInt","Section","Button","can","FieldControlContext","messages","recordTitle","useAdminMeta","usePermissions","FieldEditor","useMenuTop","keyValue","isChosen","Plus","Ellipsis","rowAllows","fieldMessage","useMenuRight","GripVertical","useSensor","MouseSensor","KeyboardSensor","TouchSensor","closestCenter","DndContext","useSensors","verticalListSortingStrategy","useSortable","sortableKeyboardCoordinates","SortableContext","track","column","lineGridStyle","columns","lineTableMinWidth","sum","lineGrid","import_react","import_jsx_runtime","LineMenu","open","setOpen","root","menu","right","top","close","event","label","items","item","text","LineRow","line","reorderable","position","onMove","count","onRemove","setNodeRef","error","transform","isDragging","setActivatorNodeRef","attributes","listeners","reorder","from","to","next","moved","headerCell","announcementsFor","name","lines","each","id","lineName","place","active","over","InlineChildTable","onReorder","sensors","move","index","removable","lineError","onAdd","footer","LineCell","message","problem","field","text$1","lineNumber","RecordLines","permissions","model","view","views","picked","setPicked","editable","data","saving","canUpdate","canCreate","canDelete","writable","placeOf","draft","rejected","tableColumns","hints","target","resources","pickable","value","chosen","current","rejection"],"sources":["../../../src/inline-child-table/columns.ts","../../../src/inline-child-table/line-menu.tsx","../../../src/inline-child-table/messages.ts","../../../src/inline-child-table/line-row.tsx","../../../src/inline-child-table/reorder.ts","../../../src/inline-child-table/inline-child-table.tsx","../../../src/app/record-lines-cell.tsx","../../../src/app/record-lines.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react'\n\n/** One column of the line table: its heading, the grid track it takes, and what each line shows in it. */\nexport type LineColumn<L> = {\n key: string\n label: string\n align?: 'right'\n /** A CSS grid track, such as `88px`; a share of the free width, at least 8rem, when omitted. */\n width?: string\n cell: (line: L) => ReactNode\n}\n\nconst track = (column: LineColumn<never>) => column.width ?? 'minmax(8rem,1fr)'\n\n/** The columns' tracks, between the drag handle and the menu that `lineGrid` places around them. */\nexport const lineGridStyle = (columns: LineColumn<never>[]) => ({ '--line-columns': columns.map(track).join(' ') }) as CSSProperties\n\n/** The narrowest the table gets before it scrolls sideways: each column's least width, and the handle and menu. */\nexport const lineTableMinWidth = (columns: LineColumn<never>[]) => `${columns.reduce((sum, column) => sum + (column.width?.endsWith('px') ? parseInt(column.width) / 16 : 8), 6)}rem`\n\nexport const lineGrid = 'grid grid-cols-[28px_var(--line-columns)_32px] items-center gap-2 pointer-coarse:grid-cols-[44px_var(--line-columns)_44px]'\n","import { MoreHorizontal } from 'lucide-react'\nimport { useEffect, useRef, useState } from 'react'\nimport { cn } from '../lib/cn'\nimport { useMenuRight, useMenuTop } from '../primitives/menu-edge'\n\nexport type LineMenuItem = { label: string; disabled?: boolean; destructive?: boolean; onSelect: () => void }\n\n/** The \"...\" at the end of a line: the keyboard-and-screen-reader way to reorder, besides the drag handle. */\nexport const LineMenu = ({ items, label }: { items: LineMenuItem[]; label: string }) => {\n const [open, setOpen] = useState(false)\n const root = useRef<HTMLDivElement>(null)\n const menu = useRef<HTMLUListElement>(null)\n const right = useMenuRight(open, root, menu)\n const top = useMenuTop(open, root, menu, right?.right)\n\n useEffect(() => {\n if (!open) return\n const close = (event: Event) => {\n if (event instanceof KeyboardEvent ? event.key === 'Escape' : !root.current?.contains(event.target as Node)) setOpen(false)\n }\n document.addEventListener('mousedown', close)\n document.addEventListener('keydown', close)\n return () => {\n document.removeEventListener('mousedown', close)\n document.removeEventListener('keydown', close)\n }\n }, [open])\n\n return (\n <div ref={root} className=\"relative flex justify-center\">\n <button\n type=\"button\"\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={() => setOpen(!open)}\n className=\"inline-flex size-7 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground pointer-coarse:size-11\"\n >\n <MoreHorizontal className=\"size-4\" />\n </button>\n {open && (\n <ul ref={menu} role=\"menu\" style={{ ...right, ...top }} className=\"absolute right-0 top-full z-30 mt-1 w-max min-w-36 rounded-md border bg-background py-1 shadow-pop\">\n {items.map((item) => (\n <li key={item.label} role=\"none\">\n <button\n type=\"button\"\n role=\"menuitem\"\n disabled={item.disabled}\n className={cn('block min-h-9 w-full px-3 py-1.5 text-left hover:bg-muted disabled:text-faint-foreground disabled:hover:bg-transparent', item.destructive && 'text-danger-text')}\n onClick={() => {\n setOpen(false)\n item.onSelect()\n }}\n >\n {item.label}\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n )\n}\n","import { messages } from '../locale/messages'\n\nexport const text = messages('inline-child-table')\n","import { useSortable } from '@dnd-kit/sortable'\nimport { GripVertical } from 'lucide-react'\nimport { cn } from '../lib/cn'\nimport { lineGrid, type LineColumn } from './columns'\nimport { LineMenu, type LineMenuItem } from './line-menu'\nimport { text } from './messages'\n\nexport type LineRowProps<L extends { id: string }> = {\n line: L\n /** How the line is named to a screen reader and in its menu. */\n name: string\n columns: LineColumn<L>[]\n position: number\n count: number\n /** The line can be dragged and moved with the menu. */\n reorderable: boolean\n /** The menu has \"Remove line\", which calls this. */\n onRemove?: () => void\n onMove: (to: number) => void\n /** Why the server turned the line down, under its cells. */\n error?: string\n}\n\nexport const LineRow = <L extends { id: string }>({ line, name, columns, position, count, reorderable, onRemove, onMove, error }: LineRowProps<L>) => {\n const { attributes, listeners, setNodeRef, setActivatorNodeRef, transform, transition, isDragging } = useSortable({ id: line.id, disabled: !reorderable })\n const menu: LineMenuItem[] = [\n ...(reorderable\n ? [\n { label: text('moveUp'), disabled: position === 0, onSelect: () => onMove(position - 1) },\n { label: text('moveDown'), disabled: position === count - 1, onSelect: () => onMove(position + 1) },\n ]\n : []),\n ...(onRemove ? [{ label: text('removeLine'), destructive: true, onSelect: onRemove }] : []),\n ]\n\n return (\n <div\n ref={setNodeRef}\n data-line-id={line.id}\n aria-invalid={error ? true : undefined}\n style={{ transform: transform ? `translate3d(0, ${transform.y}px, 0)` : undefined, transition }}\n className={cn('group relative border-b border-border bg-background px-2 py-1 last:border-b-0 hover:bg-surface', lineGrid, isDragging && 'z-10 bg-surface opacity-80 shadow-pop', error && 'bg-danger-soft')}\n >\n {reorderable ? (\n <button\n ref={setActivatorNodeRef}\n type=\"button\"\n aria-label={text('dragToReorder', { name })}\n {...attributes}\n {...listeners}\n style={{ touchAction: 'none' }}\n className=\"flex size-7 cursor-grab items-center justify-center rounded text-faint-foreground opacity-60 hover:bg-muted hover:opacity-100 focus-visible:opacity-100 active:cursor-grabbing pointer-coarse:size-11\"\n >\n <GripVertical className=\"size-4\" />\n </button>\n ) : (\n <span />\n )}\n {columns.map((column) => (\n <div key={column.key} className={cn('min-w-0', column.align === 'right' && 'text-right')}>\n {column.cell(line)}\n </div>\n ))}\n {menu.length > 0 ? <LineMenu label={text('actionsFor', { name })} items={menu} /> : <span />}\n {error && (\n <p role=\"alert\" className=\"col-span-full px-2 pb-1 text-xs text-danger-text\">\n {error}\n </p>\n )}\n </div>\n )\n}\n","export const reorder = <T>(items: readonly T[], from: number, to: number) => {\n if (from === to || from < 0 || from >= items.length) return [...items]\n const next = [...items]\n const [moved] = next.splice(from, 1)\n next.splice(Math.min(Math.max(to, 0), next.length), 0, moved!)\n return next\n}\n","import { DndContext, KeyboardSensor, MouseSensor, TouchSensor, closestCenter, useSensor, useSensors, type Announcements, type DragEndEvent } from '@dnd-kit/core'\nimport { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { Plus } from 'lucide-react'\nimport type { ReactNode } from 'react'\nimport { cn } from '../lib/cn'\nimport { Button } from '../primitives/button'\nimport { lineGrid, lineGridStyle, type LineColumn } from './columns'\nimport { LineRow } from './line-row'\nimport { reorder } from './reorder'\nimport { text } from './messages'\n\nexport type LineMove = { id: string; from: number; to: number }\n\nexport type InlineChildTableProps<L extends { id: string }> = {\n lines: L[]\n columns: LineColumn<L>[]\n /** How a line is named to a screen reader and in its menu. */\n lineName: (line: L) => string\n /** Called with the new order after a drag or a \"Move up\" / \"Move down\". */\n onReorder?: (lines: L[], move: LineMove) => void\n /** Show the drag handle and the move items; defaults to whether `onReorder` is given. */\n reorderable?: boolean\n /** Shows \"Add line\" under the lines. */\n onAdd?: () => void\n /** Gives the menu of each line that is `removable` \"Remove line\". */\n onRemove?: (line: L) => void\n /** Whether a line can be removed; every line when omitted. */\n removable?: (line: L) => boolean\n /** Why the server turned a line down, shown under it. */\n lineError?: (line: L) => string | undefined\n /** Under the table, such as the totals. */\n footer?: ReactNode\n}\n\nconst headerCell = 'px-2 text-[0.6875rem] font-medium uppercase tracking-wide text-muted-foreground'\n\nconst announcementsFor = <L extends { id: string }>(lines: L[], lineName: (line: L) => string): Announcements => {\n const name = (id: string | number) => {\n const line = lines.find((each) => each.id === id)\n return line ? lineName(line) : text('line')\n }\n const place = (id: string | number | undefined) => lines.findIndex((line) => line.id === id) + 1\n return {\n onDragStart: ({ active }) => text('pickedUp', { name: name(active.id), place: place(active.id), count: lines.length }),\n onDragOver: ({ active, over }) => (over ? text('over', { name: name(active.id), place: place(over.id), count: lines.length }) : undefined),\n onDragEnd: ({ active, over }) => (over ? text('dropped', { name: name(active.id), place: place(over.id), count: lines.length }) : text('droppedAtStart', { name: name(active.id) })),\n onDragCancel: ({ active }) => text('cancelled', { name: name(active.id), place: place(active.id) }),\n }\n}\n\n/** The lines of a record as rows of the given columns, put in order by dragging or from each row's menu. */\nexport const InlineChildTable = <L extends { id: string }>({ lines, columns, lineName, onReorder, reorderable = Boolean(onReorder), onAdd, onRemove, removable = () => true, lineError, footer }: InlineChildTableProps<L>) => {\n // A mouse starts dragging after a few pixels; a finger only after a short press, so scrolling still works.\n const sensors = useSensors(\n useSensor(MouseSensor, { activationConstraint: { distance: 4 } }),\n useSensor(TouchSensor, { activationConstraint: { delay: 250, tolerance: 5 } }),\n useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),\n )\n const move = (from: number, to: number) => {\n const line = lines[from]\n if (!line || !onReorder || to < 0 || to >= lines.length || from === to) return\n onReorder(reorder(lines, from, to), { id: line.id, from, to })\n }\n\n const onDragEnd = ({ active, over }: DragEndEvent) => {\n if (!over || active.id === over.id) return\n move(lines.findIndex((line) => line.id === active.id), lines.findIndex((line) => line.id === over.id))\n }\n\n return (\n <div>\n <div className=\"overflow-hidden rounded-lg border border-border bg-background\" style={lineGridStyle(columns)}>\n <div className={`${lineGrid} border-b border-border bg-surface px-2 py-2`}>\n <span />\n {columns.map((column) => (\n <span key={column.key} className={cn(headerCell, column.align === 'right' && 'text-right')}>\n {column.label}\n </span>\n ))}\n <span />\n </div>\n {lines.length === 0 && <p className=\"px-4 py-3 text-muted-foreground\">{text('noLines')}</p>}\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragEnd={onDragEnd}\n accessibility={{ announcements: announcementsFor(lines, lineName), screenReaderInstructions: { draggable: text('instructions') } }}\n >\n <SortableContext items={lines.map((line) => line.id)} strategy={verticalListSortingStrategy}>\n {lines.map((line, index) => (\n <LineRow\n key={line.id}\n line={line}\n name={lineName(line)}\n columns={columns}\n position={index}\n count={lines.length}\n reorderable={reorderable}\n onRemove={onRemove && removable(line) ? () => onRemove(line) : undefined}\n onMove={(to) => move(index, to)}\n error={lineError?.(line)}\n />\n ))}\n </SortableContext>\n </DndContext>\n {onAdd && (\n <div className=\"border-t border-border bg-surface px-2 py-1.5\">\n <Button variant=\"ghost\" size=\"sm\" onClick={onAdd}>\n <Plus className=\"size-3.5\" />\n {text('addLine')}\n </Button>\n </div>\n )}\n </div>\n {footer}\n </div>\n )\n}\n","import { useId } from 'react'\nimport type { ProblemError } from '@protobase/client'\nimport type { AppAddress, FieldModel, FieldViewModel, ResourceModel, ViewModel } from '@protobase/schema'\nimport { FieldControlContext } from '../primitives/field-control'\nimport { FieldEditor } from './field-editor'\nimport { fieldMessage } from './field-errors'\nimport { text } from './record-messages'\n\nexport type LineCellProps = {\n field: FieldModel\n hints: FieldViewModel | undefined\n /** The column's label, which names the cell to a screen reader with the line's number. */\n label: string\n lineNumber: number\n resource: string\n value: unknown\n stored: unknown\n relationLabel?: string\n relationTo?: AppAddress\n relationPicker?: { target: ResourceModel; view: ViewModel | undefined }\n locked: boolean\n /** The server's problem with this field of the line, from the last save. */\n problem?: ProblemError\n onChange: (next: unknown) => void\n}\n\n/** One field of a line, edited with the record page's own editor; its label is for screen readers, as the column heading shows it. */\nexport const LineCell = ({ field, hints, label, lineNumber, resource, value, stored, relationLabel, relationTo, relationPicker, locked, problem, onChange }: LineCellProps) => {\n const id = useId()\n const message = problem && fieldMessage(field, label, problem)\n return (\n <FieldControlContext.Provider value={{ id, invalid: Boolean(problem), required: false, ...(message && { describedBy: `${id}-error` }) }}>\n <label htmlFor={id} className=\"sr-only\">\n {text('lineField', { label, place: lineNumber })}\n </label>\n <FieldEditor\n field={field}\n hints={hints}\n value={value}\n stored={stored}\n relationLabel={relationLabel}\n relationTo={relationTo}\n relationPicker={relationPicker}\n locked={locked}\n invalid={Boolean(problem)}\n resource={resource}\n onChange={onChange}\n />\n {message && (\n <p id={`${id}-error`} className=\"px-1 pt-0.5 text-xs text-danger-text\">\n {message}\n </p>\n )}\n </FieldControlContext.Provider>\n )\n}\n","import { useState } from 'react'\nimport { InlineChildTable, lineTableMinWidth, type LineColumn } from '../inline-child-table'\nimport { recordTitle } from '../live/model-helpers'\nimport { humanize } from '../live/naming'\nimport { formatInt } from '../format'\nimport { Section } from '../record-view'\nimport { isChosen, keyValue } from './create/create-values'\nimport { useAdminMeta, usePermissions } from './meta-gate'\nimport { can, rowAllows } from './permissions'\nimport { LineCell } from './record-lines-cell'\nimport { linesLimit } from './use-lines'\nimport type { ShownLine } from './use-lines-draft'\nimport type { RecordLinesData } from './use-record-lines'\nimport { text } from './record-messages'\n\ntype RecordLinesProps = {\n lines: RecordLinesData & { model: NonNullable<RecordLinesData['model']>; item: NonNullable<RecordLinesData['item']> }\n /** The record's form is open and its lines may change; on the read view, or a record that cannot change, they only show. */\n editable: boolean\n saving: boolean\n}\n\n/**\n * The lines of a record as a table of their view's columns, edited in place: a line's fields, new lines, removed ones\n * and their order only change the draft; the record's Save writes it all, in one batch. A line the server turns down\n * says why on its row.\n */\nexport const RecordLines = ({ lines, editable, saving }: RecordLinesProps) => {\n const { resources, views } = useAdminMeta()\n const { item, model, columns, data, draft } = lines\n const permissions = usePermissions(model.name)\n const view = views[model.name]\n // The name of the record a relation was just set to, by line and field, until the saved lines name it\n const [picked, setPicked] = useState<Record<string, string>>({})\n const open = editable && data.complete && !data.loading && !saving\n const canUpdate = open && can(permissions, 'update')\n const canCreate = open && can(permissions, 'create')\n const canDelete = open && can(permissions, 'delete')\n const writable = (line: ShownLine) => (line.stored ? canUpdate && rowAllows(line.stored, 'update') : canCreate)\n const placeOf = (line: ShownLine) => draft.shown.indexOf(line) + 1\n const rejected = (line: ShownLine) => (draft.rejection?.id === line.id ? draft.rejection : undefined)\n\n const tableColumns: LineColumn<ShownLine>[] = columns.map((name) => {\n const field = model.fields[name]!\n const hints = view?.fields[name]\n const label = hints?.label ?? humanize(name)\n const target = field.relation ? resources[field.relation.resource] : undefined\n const pickable = target && target.primaryKey.length === 1 ? target : undefined\n return {\n key: name,\n label,\n ...(['integer', 'bigint', 'decimal'].includes(field.type) && { align: 'right' as const, width: 'minmax(6rem,0.6fr)' }),\n cell: (line) => {\n const value = draft.value(line.id, name)\n const chosen = value === null || value === undefined || value === '' ? undefined : String(value)\n return (\n <LineCell\n field={field}\n hints={hints}\n label={label}\n lineNumber={placeOf(line)}\n resource={model.name}\n value={value}\n stored={line.stored?.[name]}\n relationLabel={chosen === undefined ? undefined : (picked[`${line.id}/${name}`] ?? data.labels[name]?.[chosen])}\n relationTo={pickable && chosen !== undefined ? { kind: 'record', resource: pickable.name, key: chosen } : undefined}\n relationPicker={pickable && { target: pickable, view: views[pickable.name] }}\n locked={!writable(line)}\n problem={rejected(line)?.fields[name]}\n onChange={(next) => {\n if (!pickable || !isChosen(next)) return draft.change(line.id, name, next)\n setPicked((current) => ({ ...current, [`${line.id}/${name}`]: next.label }))\n draft.change(line.id, name, keyValue(pickable, next.key))\n }}\n />\n )\n },\n }\n })\n\n // A refusal that names none of the fields on screen says why under the line\n const lineError = (line: ShownLine) => {\n const rejection = rejected(line)\n if (!rejection || columns.some((name) => rejection.fields[name])) return undefined\n return rejection.message\n }\n\n return (\n <Section title={item.title} help={item.help}>\n {!data.complete && <p className=\"mb-2 text-muted-foreground\">{text('tooManyLines', { limit: formatInt(linesLimit) })}</p>}\n <div className=\"-mx-4 overflow-x-auto px-4 [-webkit-overflow-scrolling:touch] md:mx-0 md:px-0\">\n <div style={{ minWidth: lineTableMinWidth(tableColumns) }}>\n <InlineChildTable\n lines={draft.shown}\n columns={tableColumns}\n lineName={(line) => recordTitle(model, view, line.stored ?? {}, '') || text('lineNumber', { place: placeOf(line) })}\n onReorder={(next) => draft.setOrder(next.map((line) => line.id))}\n reorderable={canUpdate}\n onAdd={canCreate ? () => void draft.add() : undefined}\n onRemove={canCreate || canDelete ? (line) => draft.remove(line.id) : undefined}\n removable={(line) => (line.stored ? canDelete && rowAllows(line.stored, 'delete') : canCreate)}\n lineError={lineError}\n />\n </div>\n </div>\n </Section>\n )\n}\n"],"mappings":"i/BAYA,IAAM6C,EAAS,GAA8BC,EAAO,OAAS,mBAGhDC,EAAiB,IAAkC,CAAE,iBAAkBC,EAAQ,IAAIH,CAAK,CAAC,CAAC,KAAK,GAAG,CAAE,GAGpGI,EAAqB,GAAiC,GAAGD,EAAQ,Q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AE,SAAUJ,EAAkB+E,CAAY,CAAE,EACtD,UAAA,EAAA3E,EAAA,IAAA,CAAC2C,EAAD,CACE,MAAO8B,EAAM,MACb,QAASE,EACT,SAAW,GAAS3G,EAAY4F,EAAOC,EAAM9C,EAAK,QAAU,CAAC,EAAG,EAAE,GAAK9D,EAAK,aAAc,CAAE,MAAOuH,EAAQzD,CAAI,CAAE,CAAC,EAClH,UAAY,GAAS0D,EAAM,SAAS1C,EAAK,IAAK,GAAShB,EAAK,EAAE,CAAC,EAC/D,YAAaqD,EACb,MAAOC,MAAkB,KAAKI,EAAM,IAAI,EAAI,IAAA,GAC5C,SAAUJ,GAAaC,EAAa,GAASG,EAAM,OAAO1D,EAAK,EAAE,EAAI,IAAA,GACrE,UAAY,GAAUA,EAAK,OAASuD,GAAa7F,EAAUsC,EAAK,OAAQ,QAAQ,EAAIsD,EACzE,UApBF,GAAoB,CACrC,IAAMc,EAAYT,EAAS3D,CAAI,EAC/B,GAAKoE,GAAa,GAAQ,KAAM,GAASA,EAAU,OAAOhD,EAAK,EAC/D,OAAOgD,EAAU,OACnB,CAiBS,CAAA,CACE,CAAA,CACF,CAAA,CACE,GAEb","debugId":"8980d215-1521-491a-8b29-0102359aa447"}
@@ -1 +1 @@
1
- {"version":3,"file":"record-map-C8QpQBwW.js","names":["n","a","t","__toESM","mapLib","Marker","NavigationControl","import_jsx_runtime","require_jsx_runtime","RecordMap","Map","style","position","MapLayerSwitch","MapPin"],"sources":["../../../src/app/map/record-map.tsx"],"sourcesContent":["import { MapPin } from 'lucide-react'\nimport { Map, Marker, NavigationControl } from 'react-map-gl/maplibre'\nimport type { MapLayerModel } from '@protobase/client'\nimport { MapLayerSwitch } from './map-layer-switch'\nimport { mapLib } from './maplibre'\nimport type { Position } from './record-position'\n\n/**\n * A map of `style` centred on `position` at `zoom`, with a pin on it. It pans and zooms with two fingers on a phone and\n * with Ctrl or Cmd and the wheel, so scrolling the page past it does not move it. With `layers`, it switches to them.\n */\nexport const RecordMap = ({ style, layers, position, zoom }: { style: string; layers?: MapLayerModel[]; position: Position; zoom: number }) => (\n <Map mapLib={mapLib} mapStyle={style} initialViewState={{ ...position, zoom }} cooperativeGestures style={{ width: '100%', height: '100%' }}>\n <NavigationControl showCompass={false} />\n <MapLayerSwitch layers={layers} />\n <Marker latitude={position.latitude} longitude={position.longitude} anchor=\"bottom\">\n <MapPin aria-hidden className=\"size-8 fill-primary text-primary-foreground drop-shadow\" strokeWidth={1.5} />\n </Marker>\n </Map>\n)\n"],"mappings":"grBAWaS,GAAa,CAAE,QAAO,SAAQ,WAAU,WACnD,EAAAF,EAAA,KAAA,CAACG,EAAD,CAAa,SAAQ,SAAUC,EAAO,iBAAkB,CAAE,GAAGC,EAAU,MAAK,EAAG,oBAAA,GAAoB,MAAO,CAAE,MAAO,OAAQ,OAAQ,MAAO,EAA1I,SAAA,EACE,EAAAL,EAAA,IAAA,CAACD,EAAD,CAAmB,YAAa,EAAQ,CAAA,GACxC,EAAAC,EAAA,IAAA,CAACM,EAAD,CAAwB,QAAS,CAAA,GACjC,EAAAN,EAAA,IAAA,CAACF,EAAD,CAAQ,SAAUO,EAAS,SAAU,UAAWA,EAAS,UAAW,OAAO,SACzE,UAAA,EAAAL,EAAA,IAAA,CAACO,EAAD,CAAQ,cAAA,GAAY,UAAU,0DAA0D,YAAa,GAAM,CAAA,CACrG,CAAA,CACL","debugId":"bc429401-c161-43a1-8257-640cd611251e"}
1
+ {"version":3,"file":"record-map-DHkY7hYE.js","names":["n","a","t","__toESM","mapLib","Marker","NavigationControl","import_jsx_runtime","require_jsx_runtime","RecordMap","Map","style","position","MapLayerSwitch","MapPin"],"sources":["../../../src/app/map/record-map.tsx"],"sourcesContent":["import { MapPin } from 'lucide-react'\nimport { Map, Marker, NavigationControl } from 'react-map-gl/maplibre'\nimport type { MapLayerModel } from '@protobase/client'\nimport { MapLayerSwitch } from './map-layer-switch'\nimport { mapLib } from './maplibre'\nimport type { Position } from './record-position'\n\n/**\n * A map of `style` centred on `position` at `zoom`, with a pin on it. It pans and zooms with two fingers on a phone and\n * with Ctrl or Cmd and the wheel, so scrolling the page past it does not move it. With `layers`, it switches to them.\n */\nexport const RecordMap = ({ style, layers, position, zoom }: { style: string; layers?: MapLayerModel[]; position: Position; zoom: number }) => (\n <Map mapLib={mapLib} mapStyle={style} initialViewState={{ ...position, zoom }} cooperativeGestures style={{ width: '100%', height: '100%' }}>\n <NavigationControl showCompass={false} />\n <MapLayerSwitch layers={layers} />\n <Marker latitude={position.latitude} longitude={position.longitude} anchor=\"bottom\">\n <MapPin aria-hidden className=\"size-8 fill-primary text-primary-foreground drop-shadow\" strokeWidth={1.5} />\n </Marker>\n </Map>\n)\n"],"mappings":"grBAWaS,GAAa,CAAE,QAAO,SAAQ,WAAU,WACnD,EAAAF,EAAA,KAAA,CAACG,EAAD,CAAa,SAAQ,SAAUC,EAAO,iBAAkB,CAAE,GAAGC,EAAU,MAAK,EAAG,oBAAA,GAAoB,MAAO,CAAE,MAAO,OAAQ,OAAQ,MAAO,EAA1I,SAAA,EACE,EAAAL,EAAA,IAAA,CAACD,EAAD,CAAmB,YAAa,EAAQ,CAAA,GACxC,EAAAC,EAAA,IAAA,CAACM,EAAD,CAAwB,QAAS,CAAA,GACjC,EAAAN,EAAA,IAAA,CAACF,EAAD,CAAQ,SAAUO,EAAS,SAAU,UAAWA,EAAS,UAAW,OAAO,SACzE,UAAA,EAAAL,EAAA,IAAA,CAACO,EAAD,CAAQ,cAAA,GAAY,UAAU,0DAA0D,YAAa,GAAM,CAAA,CACrG,CAAA,CACL","debugId":"c7918ee1-604f-4357-be34-f0fc25b67c61"}
@@ -1 +1 @@
1
- {"version":3,"file":"record-opens-jhy0UcRX.js","names":["n","a","t","__toESM","require_react","require_jsx_runtime","useAppAddress","fillAddress","Notice","text","import_react","import_jsx_runtime","openedAddress","filled","to","record","part","RecordOpens","go"],"sources":["../../../src/app/record-opens.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport type { AppAddress } from '@protobase/schema'\nimport { fillAddress } from '@protobase/schema/internal'\nimport { Notice } from './meta-gate'\nimport { useAppAddress } from './use-app-address'\nimport { text } from './record-messages'\n\n/**\n * The address a record's page opens in its place, its `{{field}}`s filled from the record; none when it would open a\n * record by an empty key, as a field it names is empty, so the record's own page shows instead.\n */\nexport const openedAddress = (to: AppAddress, record: Record<string, unknown>): AppAddress | undefined => {\n const filled = fillAddress(to, record)\n if (filled.kind !== 'record') return filled\n const parts = Array.isArray(filled.key) ? filled.key : [filled.key]\n return parts.some((part) => part === '') ? undefined : filled\n}\n\n/**\n * A record's page that opens another address in its place (`.recordOpens(...)`), as `openedAddress` fills it,\n * replacing this address in the history so Back skips it.\n */\nexport const RecordOpens = ({ to }: { to: AppAddress }) => {\n const { go } = useAppAddress()\n useEffect(() => go(to, { replace: true }), [to, go])\n return <Notice title={text('loading')}>{text('fetching')}</Notice>\n}\n"],"mappings":"ipBAWaY,GAAiB,EAAgB,IAA4D,CACxG,IAAMC,EAASN,EAAYO,EAAIC,CAAM,EAGrC,OAFIF,EAAO,OAAS,WACN,MAAM,QAAQA,EAAO,GAAG,EAAIA,EAAO,IAAM,CAACA,EAAO,GAAG,EAAA,CACrD,KAAM,GAASG,IAAS,EAAE,EAAI,IAAA,GAAYH,CACzD,EAMaI,GAAe,CAAE,QAA6B,CACzD,GAAM,CAAE,MAAOX,EAAc,EAE7B,OADA,EAAAI,EAAA,UAAA,KAAgBQ,EAAGJ,EAAI,CAAE,QAAS,EAAK,CAAC,EAAG,CAACA,EAAII,CAAE,CAAC,GAC5C,EAAAP,EAAA,IAAA,CAACH,EAAD,CAAQ,MAAOC,EAAK,SAAS,EAAI,SAAAA,EAAK,UAAU,CAAU,CAAA,CACnE","debugId":"23872d14-7115-46fe-869e-af3318f4ad0e"}
1
+ {"version":3,"file":"record-opens-B0MlYjrH.js","names":["n","a","t","__toESM","require_react","require_jsx_runtime","useAppAddress","fillAddress","Notice","text","import_react","import_jsx_runtime","openedAddress","filled","to","record","part","RecordOpens","go"],"sources":["../../../src/app/record-opens.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport type { AppAddress } from '@protobase/schema'\nimport { fillAddress } from '@protobase/schema/internal'\nimport { Notice } from './meta-gate'\nimport { useAppAddress } from './use-app-address'\nimport { text } from './record-messages'\n\n/**\n * The address a record's page opens in its place, its `{{field}}`s filled from the record; none when it would open a\n * record by an empty key, as a field it names is empty, so the record's own page shows instead.\n */\nexport const openedAddress = (to: AppAddress, record: Record<string, unknown>): AppAddress | undefined => {\n const filled = fillAddress(to, record)\n if (filled.kind !== 'record') return filled\n const parts = Array.isArray(filled.key) ? filled.key : [filled.key]\n return parts.some((part) => part === '') ? undefined : filled\n}\n\n/**\n * A record's page that opens another address in its place (`.recordOpens(...)`), as `openedAddress` fills it,\n * replacing this address in the history so Back skips it.\n */\nexport const RecordOpens = ({ to }: { to: AppAddress }) => {\n const { go } = useAppAddress()\n useEffect(() => go(to, { replace: true }), [to, go])\n return <Notice title={text('loading')}>{text('fetching')}</Notice>\n}\n"],"mappings":"ipBAWaY,GAAiB,EAAgB,IAA4D,CACxG,IAAMC,EAASN,EAAYO,EAAIC,CAAM,EAGrC,OAFIF,EAAO,OAAS,WACN,MAAM,QAAQA,EAAO,GAAG,EAAIA,EAAO,IAAM,CAACA,EAAO,GAAG,EAAA,CACrD,KAAM,GAASG,IAAS,EAAE,EAAI,IAAA,GAAYH,CACzD,EAMaI,GAAe,CAAE,QAA6B,CACzD,GAAM,CAAE,MAAOX,EAAc,EAE7B,OADA,EAAAI,EAAA,UAAA,KAAgBQ,EAAGJ,EAAI,CAAE,QAAS,EAAK,CAAC,EAAG,CAACA,EAAII,CAAE,CAAC,GAC5C,EAAAP,EAAA,IAAA,CAACH,EAAD,CAAQ,MAAOC,EAAK,SAAS,EAAI,SAAAA,EAAK,UAAU,CAAU,CAAA,CACnE","debugId":"74325623-ac78-4d0c-ad93-5f135560ec7e"}