@protobase/ui 0.119.1 → 0.119.2
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.
- package/dist/account/messages.d.ts +2 -2
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/create/messages.d.ts +2 -2
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-types/runner-install/messages.d.ts +2 -2
- package/dist/app/field-types/workflow/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
- package/dist/app/file-viewers/messages.d.ts +2 -2
- package/dist/app/focus/messages.d.ts +2 -2
- package/dist/app/history/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/list-messages.d.ts +2 -2
- package/dist/app/messages.d.ts +2 -2
- package/dist/app/pages/messages.d.ts +2 -2
- package/dist/app/record-chart/messages.d.ts +2 -2
- package/dist/app/record-messages.d.ts +2 -2
- package/dist/app/record-mode/shown-layout.d.ts +1 -1
- package/dist/app/related-cards/messages.d.ts +2 -2
- package/dist/app/runtime/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/auth/messages.d.ts +2 -2
- package/dist/data-grid/messages.d.ts +2 -2
- package/dist/filter-panel/messages.d.ts +2 -2
- package/dist/mocks/customers.d.ts +1 -1
- package/dist/mocks/invoices.d.ts +1 -1
- package/dist/mocks/orders.d.ts +3 -3
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/plugins/messages.d.ts +2 -2
- package/dist/shell/assets/{account-page-BXnceUQo.js → account-page-CAJ1kqbM.js} +2 -2
- package/dist/shell/assets/{app-D3BCcbgE.js → app-CJRcPkz6.js} +5 -5
- package/dist/shell/assets/{assistant-shell-DKf9TfL2.js → assistant-shell-BfbbDVaC.js} +2 -2
- package/dist/shell/assets/{board-display-DJkQwIfT.js → board-display-NQNgdfOF.js} +2 -2
- package/dist/shell/assets/{calendar-display-BKyuHAAF.js → calendar-display-CFPrjZFk.js} +2 -2
- package/dist/shell/assets/{call-rings-D_kQbFd3.js → call-rings-B8E1WcyM.js} +2 -2
- package/dist/shell/assets/{calls-D6jSGMCo.js → calls-CdQzy7k0.js} +2 -2
- package/dist/shell/assets/{circle-alert-ytReRN_c.js → circle-alert-d8QhxvKR.js} +2 -2
- package/dist/shell/assets/{composed-page-CbNBBioS.js → composed-page-DMVnOjIP.js} +2 -2
- package/dist/shell/assets/{composer-section-cg-cdFZx.js → composer-section-DnZcEvIv.js} +2 -2
- package/dist/shell/assets/{connect-route-hMUPiAft.js → connect-route-4mPmCyC4.js} +2 -2
- package/dist/shell/assets/{copy-field-BoXXafL7.js → copy-field-BERLdksL.js} +2 -2
- package/dist/shell/assets/{create-route-BePHRkTZ.js → create-route-GDRDDl56.js} +2 -2
- package/dist/shell/assets/{custom-step-container-field-B3bsPeCV.js → custom-step-container-field-CdOcEE3E.js} +2 -2
- package/dist/shell/assets/{embedded-list-6lQyJozS.js → embedded-list-BfLZckNm.js} +3 -3
- package/dist/shell/assets/{export-dialog-BUbdSkkU.js → export-dialog-D4o9o8bz.js} +2 -2
- package/dist/shell/assets/{first-organization-page-BhQOFT5P.js → first-organization-page-B3iq4sHy.js} +2 -2
- package/dist/shell/assets/{graph-view-DZHMI-UQ.js → graph-view-Df89qpKC.js} +2 -2
- package/dist/shell/assets/{group-donut-Cu5Ny3gq.js → group-donut-CrztmwCW.js} +2 -2
- package/dist/shell/assets/{guest-call-page-DlAkbaRH.js → guest-call-page-BBIOrY9i.js} +3 -3
- package/dist/shell/assets/{html-viewer-DrSS-WnU.js → html-viewer--TQtevzN.js} +2 -2
- package/dist/shell/assets/{import-dialog-Dk_31-PT.js → import-dialog-BWTCBbXg.js} +2 -2
- package/dist/shell/assets/{import-table-dialog-vL-juOMH.js → import-table-dialog-DPkK6vH5.js} +2 -2
- package/dist/shell/assets/{index-CTmZ8-B4.js → index-Bh5wY9w1.js} +1 -1
- package/dist/shell/assets/{invitations-page-CfTEdorg.js → invitations-page-B9lumTnF.js} +2 -2
- package/dist/shell/assets/{layout-grid-CTlIrnH5.js → layout-grid-9bzmoNfC.js} +2 -2
- package/dist/shell/assets/{legend-item-CqkLpsWb.js → legend-item-CMOXfVzG.js} +2 -2
- package/dist/shell/assets/{list-page-Czg2Jaxx.js → list-page-DKvupZUF.js} +4 -4
- package/dist/shell/assets/{maplibre-Bd79IbdT.js → maplibre-BSd2GULM.js} +2 -2
- package/dist/shell/assets/{markdown-content-BGl9PFVi.js → markdown-content-CJbhy8aC.js} +2 -2
- package/dist/shell/assets/{members-page-CEB-Wkl8.js → members-page-q2id0vrY.js} +2 -2
- package/dist/shell/assets/{messages-Ce8dRRRN.js → messages-ZPG4Y__r.js} +2 -2
- package/dist/shell/assets/{organization-page-CTxtblmm.js → organization-page-DqYnaJRl.js} +2 -2
- package/dist/shell/assets/{organizations-page-DeNhUQDU.js → organizations-page-Dm5Y0fGB.js} +2 -2
- package/dist/shell/assets/{pending-invitation-row-BMp0ZxE8.js → pending-invitation-row-Ce5VDMYl.js} +2 -2
- package/dist/shell/assets/{period-chart-BDqtO8mc.js → period-chart-D3lbH2Ni.js} +2 -2
- package/dist/shell/assets/{person-row-DRqtbPma.js → person-row-D5tS8OTp.js} +2 -2
- package/dist/shell/assets/{public-form-page-XgK3-Nzh.js → public-form-page-aK2MyEzM.js} +2 -2
- package/dist/shell/assets/{record-lines-DdN5hlI_.js → record-lines-BVk1yL7T.js} +2 -2
- package/dist/shell/assets/{record-map-sOmjX80D.js → record-map-CQG_MBk2.js} +2 -2
- package/dist/shell/assets/{record-opens-DLfbC3xo.js → record-opens-583Ej1N1.js} +2 -2
- package/dist/shell/assets/{record-page-BntRofCL.js → record-page-CCop2gY_.js} +3 -3
- package/dist/shell/assets/{record-preview-QMV2lW2j.js → record-preview-DA3ekFy9.js} +2 -2
- package/dist/shell/assets/{records-map-DgTxGcbC.js → records-map-eORDbX4I.js} +2 -2
- package/dist/shell/assets/{render-node-CkL5Sgl_.js → render-node-DYlEB-c6.js} +3 -3
- package/dist/shell/assets/{reorder-button-8yWv8J72.js → reorder-button-CBM6uNGv.js} +2 -2
- package/dist/shell/assets/{run-trace-view-BPvPw3Ko.js → run-trace-view-Bc39GS76.js} +2 -2
- package/dist/shell/assets/{runner-install-field-CKP8E9ZO.js → runner-install-field-1DavXWJz.js} +2 -2
- package/dist/shell/assets/{runtime-update-DGbf2Nmm.js → runtime-update-BmJNn1bb.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-DN-uvpOy.js → shared-protobase-ui-CYjgvFkX.js} +1 -1
- package/dist/shell/assets/{sheet-source-cKJfUaud.js → sheet-source-DRkb3sPj.js} +2 -2
- package/dist/shell/assets/{sign-in-policy-page-Bty4Ih1x.js → sign-in-policy-page-J-Gl8EDX.js} +2 -2
- package/dist/shell/assets/{start-block-queries-x-gNbPt1.js → start-block-queries-Db9-BBtv.js} +2 -2
- package/dist/shell/assets/{step-catalog-CCAXc8kn.js → step-catalog-Dx8trv3T.js} +2 -2
- package/dist/shell/assets/{step-panel-jmfh86YA.js → step-panel-CollAT6S.js} +2 -2
- package/dist/shell/assets/{timeline-display-CtxOHPoJ.js → timeline-display-Db0NWucC.js} +2 -2
- package/dist/shell/assets/{trash-CFCBxAWq.js → trash-BgljKjXT.js} +2 -2
- package/dist/shell/assets/{update-set-BYNQUWVp.js → update-set-SMllxKkh.js} +2 -2
- package/dist/shell/assets/{use-calendar-move-BytgRG51.js → use-calendar-move-BcrMLvrG.js} +2 -2
- package/dist/shell/assets/{use-display-rows-DGw9J73C.js → use-display-rows-DT7QTMsG.js} +2 -2
- package/dist/shell/assets/{use-my-invitations-BcMFAcXl.js → use-my-invitations-oCZ6ZQ-U.js} +2 -2
- package/dist/shell/assets/{use-paged-search-CKcKKO6y.js → use-paged-search-BlDRyMbE.js} +2 -2
- package/dist/shell/assets/{use-run-trace-BRwbwZcf.js → use-run-trace-D_6T2CH7.js} +2 -2
- package/dist/shell/assets/{use-workflow-page-DsD276W-.js → use-workflow-page-CBp2KwrR.js} +2 -2
- package/dist/shell/assets/{use-workflow-types-Bn24Chp-.js → use-workflow-types-ygVBJ9Yg.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-BKd_Yd0v.js → workflow-canvas-BC2ifgGd.js} +2 -2
- package/dist/shell/assets/{workflow-field-DyBaV6m5.js → workflow-field-D_yT-vSa.js} +3 -3
- package/dist/shell/assets/{workflow-graph-editor-B8RJ52_E.js → workflow-graph-editor-BSTyuKLQ.js} +2 -2
- package/dist/shell/assets/{workflow-run-field-CzluYhjs.js → workflow-run-field-CKXk25MP.js} +3 -3
- package/dist/shell/assets/{workflow-status-field-_umgNjK4.js → workflow-status-field-BQDIaBJw.js} +2 -2
- package/dist/shell/assets/{workflow-workbench-CqOI36Oy.js → workflow-workbench-CHPH8qPu.js} +2 -2
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/{account-page-BXnceUQo.js.map → account-page-CAJ1kqbM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{app-D3BCcbgE.js.map → app-CJRcPkz6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{assistant-shell-DKf9TfL2.js.map → assistant-shell-BfbbDVaC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{board-display-DJkQwIfT.js.map → board-display-NQNgdfOF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calendar-display-BKyuHAAF.js.map → calendar-display-CFPrjZFk.js.map} +1 -1
- package/dist/shell-source-maps/assets/{call-rings-D_kQbFd3.js.map → call-rings-B8E1WcyM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calls-D6jSGMCo.js.map → calls-CdQzy7k0.js.map} +1 -1
- package/dist/shell-source-maps/assets/{circle-alert-ytReRN_c.js.map → circle-alert-d8QhxvKR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composed-page-CbNBBioS.js.map → composed-page-DMVnOjIP.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composer-section-cg-cdFZx.js.map → composer-section-DnZcEvIv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{connect-route-hMUPiAft.js.map → connect-route-4mPmCyC4.js.map} +1 -1
- package/dist/shell-source-maps/assets/{copy-field-BoXXafL7.js.map → copy-field-BERLdksL.js.map} +1 -1
- package/dist/shell-source-maps/assets/{create-route-BePHRkTZ.js.map → create-route-GDRDDl56.js.map} +1 -1
- package/dist/shell-source-maps/assets/{custom-step-container-field-B3bsPeCV.js.map → custom-step-container-field-CdOcEE3E.js.map} +1 -1
- package/dist/shell-source-maps/assets/{embedded-list-6lQyJozS.js.map → embedded-list-BfLZckNm.js.map} +1 -1
- package/dist/shell-source-maps/assets/{export-dialog-BUbdSkkU.js.map → export-dialog-D4o9o8bz.js.map} +1 -1
- package/dist/shell-source-maps/assets/{first-organization-page-BhQOFT5P.js.map → first-organization-page-B3iq4sHy.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-DZHMI-UQ.js.map → graph-view-Df89qpKC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{group-donut-Cu5Ny3gq.js.map → group-donut-CrztmwCW.js.map} +1 -1
- package/dist/shell-source-maps/assets/{guest-call-page-DlAkbaRH.js.map → guest-call-page-BBIOrY9i.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-DrSS-WnU.js.map → html-viewer--TQtevzN.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-dialog-Dk_31-PT.js.map → import-dialog-BWTCBbXg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-table-dialog-vL-juOMH.js.map → import-table-dialog-DPkK6vH5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{invitations-page-CfTEdorg.js.map → invitations-page-B9lumTnF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{layout-grid-CTlIrnH5.js.map → layout-grid-9bzmoNfC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{legend-item-CqkLpsWb.js.map → legend-item-CMOXfVzG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{list-page-Czg2Jaxx.js.map → list-page-DKvupZUF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-Bd79IbdT.js.map → maplibre-BSd2GULM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-BGl9PFVi.js.map → markdown-content-CJbhy8aC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{members-page-CEB-Wkl8.js.map → members-page-q2id0vrY.js.map} +1 -1
- package/dist/shell-source-maps/assets/{messages-Ce8dRRRN.js.map → messages-ZPG4Y__r.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organization-page-CTxtblmm.js.map → organization-page-DqYnaJRl.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organizations-page-DeNhUQDU.js.map → organizations-page-Dm5Y0fGB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{pending-invitation-row-BMp0ZxE8.js.map → pending-invitation-row-Ce5VDMYl.js.map} +1 -1
- package/dist/shell-source-maps/assets/{period-chart-BDqtO8mc.js.map → period-chart-D3lbH2Ni.js.map} +1 -1
- package/dist/shell-source-maps/assets/{person-row-DRqtbPma.js.map → person-row-D5tS8OTp.js.map} +1 -1
- package/dist/shell-source-maps/assets/{public-form-page-XgK3-Nzh.js.map → public-form-page-aK2MyEzM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-lines-DdN5hlI_.js.map → record-lines-BVk1yL7T.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-sOmjX80D.js.map → record-map-CQG_MBk2.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-opens-DLfbC3xo.js.map → record-opens-583Ej1N1.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-page-BntRofCL.js.map → record-page-CCop2gY_.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-preview-QMV2lW2j.js.map → record-preview-DA3ekFy9.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-DgTxGcbC.js.map → records-map-eORDbX4I.js.map} +1 -1
- package/dist/shell-source-maps/assets/{render-node-CkL5Sgl_.js.map → render-node-DYlEB-c6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{reorder-button-8yWv8J72.js.map → reorder-button-CBM6uNGv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-BPvPw3Ko.js.map → run-trace-view-Bc39GS76.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runner-install-field-CKP8E9ZO.js.map → runner-install-field-1DavXWJz.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runtime-update-DGbf2Nmm.js.map → runtime-update-BmJNn1bb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sheet-source-cKJfUaud.js.map → sheet-source-DRkb3sPj.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sign-in-policy-page-Bty4Ih1x.js.map → sign-in-policy-page-J-Gl8EDX.js.map} +1 -1
- package/dist/shell-source-maps/assets/{start-block-queries-x-gNbPt1.js.map → start-block-queries-Db9-BBtv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-CCAXc8kn.js.map → step-catalog-Dx8trv3T.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-jmfh86YA.js.map → step-panel-CollAT6S.js.map} +1 -1
- package/dist/shell-source-maps/assets/{timeline-display-CtxOHPoJ.js.map → timeline-display-Db0NWucC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{trash-CFCBxAWq.js.map → trash-BgljKjXT.js.map} +1 -1
- package/dist/shell-source-maps/assets/{update-set-BYNQUWVp.js.map → update-set-SMllxKkh.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-calendar-move-BytgRG51.js.map → use-calendar-move-BcrMLvrG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-display-rows-DGw9J73C.js.map → use-display-rows-DT7QTMsG.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-my-invitations-BcMFAcXl.js.map → use-my-invitations-oCZ6ZQ-U.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-paged-search-CKcKKO6y.js.map → use-paged-search-BlDRyMbE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-run-trace-BRwbwZcf.js.map → use-run-trace-D_6T2CH7.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-page-DsD276W-.js.map → use-workflow-page-CBp2KwrR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-types-Bn24Chp-.js.map → use-workflow-types-ygVBJ9Yg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-BKd_Yd0v.js.map → workflow-canvas-BC2ifgGd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-field-DyBaV6m5.js.map → workflow-field-D_yT-vSa.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-B8RJ52_E.js.map → workflow-graph-editor-BSTyuKLQ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-run-field-CzluYhjs.js.map → workflow-run-field-CKXk25MP.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-status-field-_umgNjK4.js.map → workflow-status-field-BQDIaBJw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-CqOI36Oy.js.map → workflow-workbench-CHPH8qPu.js.map} +1 -1
- package/dist/users/messages.d.ts +2 -2
- package/package.json +5 -5
package/dist/shell-source-maps/assets/{step-panel-jmfh86YA.js.map → step-panel-CollAT6S.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-panel-jmfh86YA.js","names":["useState","_Fragment","n","a","t","__toESM","require_react","require_jsx_runtime","formatTag","cn","JsonBlock","AppLink","messages","formatDateTime","Badge","buttonClass","useAdminMeta","Button","nodeStatusLabel","nodeTones","stateLabel","customStepOf","stateAt","splitPath","useRunSteps","import_react","scopeItems","scope","match","part","statePath","item","state","weight","nodeTraces","placed","within","counts","lastOfState","lastOfScope","step","steps","path","statuses","mark","known","status","inProgress","startAt","text","import_jsx_runtime","Part","title","children","logTime","at","Logs","logs","line","index","StepCard","meta","jobs","\"workflow_custom_step_jobs\"","heldBack","items","output","valueActions","runId","Heading","kind","name","StateSteps","trace","run","shown","setShown","blockRun","block","StepPanel","selected","definition","types","triggerLabel"],"sources":["../../../src/app/field-types/workflow-run/run-trace.ts","../../../src/app/field-types/workflow-run/messages.ts","../../../src/app/field-types/workflow-run/step-card.tsx","../../../src/app/field-types/workflow-run/step-panel.tsx"],"sourcesContent":["import type { NodeStatus, NodeTrace } from '../workflow/node-trace'\n\n/** What the graph reads of a run's step. */\nexport type TraceStep = { scope: string; state: string; status: Exclude<NodeStatus, 'current'>; next: string | null }\n\n/** A Map item a step ran in: the Map's name and the item's index from 0. */\nexport type ScopeItem = { map: string; index: number }\n\n/** The Map items of a step's scope, outermost first: `Each.3[0]` is item 0 of the Map `Each`. */\nexport const scopeItems = (scope: string): ScopeItem[] =>\n scope === ''\n ? []\n : scope.split('/').map((part) => {\n const match = /^(.*)\\.\\d+\\[(\\d+)\\]$/.exec(part)\n if (!match) throw new Error(`\"${scope}\" is not a step's scope`)\n return { map: decodeURIComponent(match[1]!), index: Number(match[2]) }\n })\n\n/** The graph's path of the state a step ran in its scope: the Maps it is inside, then its name. */\nexport const statePath = (scope: string, state: string) => [...scopeItems(scope).map((item) => item.map), state].join('/')\n\n// When a state's scopes disagree, such as a Map's items, the mark that most needs a look wins.\nconst weight: Record<NodeStatus, number> = { succeeded: 0, caught: 1, retrying: 2, failed: 3, current: 4 }\n\n/**\n * Each state's mark from the run's steps in the order they ran: how its last step in each scope ended, the worst of them\n * for a Map's items, and while the run goes on, `current` on the state each scope goes on to, or on the first state when\n * nothing ran yet. A block's run marks the states inside its Block, whose path is `within`.\n */\nexport const nodeTraces = (steps: readonly TraceStep[], { inProgress, startAt, within = [] }: { inProgress: boolean; startAt?: string | undefined; within?: readonly string[] }) => {\n const placed = (scope: string, state: string) => [...within, statePath(scope, state)].join('/')\n const counts = new Map<string, number>()\n const lastOfState = new Map<string, TraceStep>()\n const lastOfScope = new Map<string, TraceStep>()\n for (const step of steps) {\n const path = placed(step.scope, step.state)\n counts.set(path, (counts.get(path) ?? 0) + 1)\n lastOfState.set(`${step.scope}\\n${step.state}`, step)\n lastOfScope.set(step.scope, step)\n }\n const statuses = new Map<string, NodeStatus>()\n const mark = (path: string, status: NodeStatus) => {\n const known = statuses.get(path)\n if (known === undefined || weight[status] > weight[known]) statuses.set(path, status)\n }\n for (const step of lastOfState.values()) mark(placed(step.scope, step.state), step.status)\n if (inProgress) {\n if (!lastOfScope.has('') && startAt) mark([...within, startAt].join('/'), 'current')\n for (const step of lastOfScope.values()) if (step.status !== 'retrying' && step.next !== null) mark(placed(step.scope, step.next), 'current')\n }\n return new Map<string, NodeTrace>([...statuses].map(([path, status]) => [path, { status, steps: counts.get(path) ?? 0 }]))\n}\n","import { messages } from '../../../locale/messages'\n\nexport const text = messages('app/field-types/workflow-run')\n","import type { ReactNode } from 'react'\nimport { customStepOf, heldBackLog } from '@protobase/workflows'\nimport { formatDateTime } from '../../../format/date'\nimport { formatTag } from '../../../locale/active-locale'\nimport { cn } from '../../../lib/cn'\nimport { Badge } from '../../../primitives/badge'\nimport { buttonClass } from '../../../primitives/button'\nimport { useAdminMeta } from '../../meta-gate'\nimport { AppLink } from '../../use-app-address'\nimport { JsonBlock } from '../json/json-block'\nimport { nodeStatusLabel } from '../workflow/labels'\nimport { nodeTones, type NodeStatus } from '../workflow/node-trace'\nimport { scopeItems } from './run-trace'\nimport { text } from './messages'\n\n/** A step as the run's page shows it from the run's trace, keyed by its scope and number. */\nexport type StepRow = Record<string, unknown> & { id: string; scope: string; state: string; next: string | null; attempt: number; status: Exclude<NodeStatus, 'current'>; started_at: string; finished_at: string; logs: { at: string; message: string }[] | null }\n\n/** What can be done with a step's input or output where it shows, such as using it as a new run's input. */\nexport type ValueActions = (value: unknown, part: 'input' | 'output') => ReactNode\n\nexport const Part = ({ title, children }: { title: string; children: ReactNode }) => (\n <div className=\"grid gap-1\">\n <h5 className=\"text-xs font-medium text-muted-foreground\">{title}</h5>\n {children}\n </div>\n)\n\n\n// A log line's time to the second, on the viewer's clock: a step's lines are often within the same minute\nconst logTime = (at: string) => new Intl.DateTimeFormat(formatTag(), { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }).format(Date.parse(at))\n\nconst Logs = ({ logs }: { logs: NonNullable<StepRow['logs']> }) => (\n <ol className=\"grid gap-0.5 rounded-md bg-muted/60 px-3 py-2 font-mono text-xs\">\n {logs.map((line, index) => (\n <li key={index} className=\"whitespace-pre-wrap break-words\">\n <time dateTime={line.at} className=\"text-muted-foreground\">{logTime(line.at)}</time> {line.message}\n </li>\n ))}\n </ol>\n)\n\n/** The resource of custom steps' jobs, which a custom step's step links to. */\nexport const jobsResource = 'workflow_custom_step_jobs'\n\n/**\n * One step of a run: its try, item, status and timing, then its error, input, output, variables and logs, as the run's\n * trace keeps them, secrets blanked out. A step a replay did not send says so, a Block's step links to the block's\n * own run, which gave its result, and a custom step's step to the run's jobs, with the logs its container wrote, for\n * whoever may read them.\n */\nexport const StepCard = ({ step, runId, valueActions }: { step: StepRow; runId: string; valueActions?: ValueActions }) => {\n const meta = useAdminMeta()\n const jobs = typeof step.type === 'string' && customStepOf(step.type) !== undefined && meta.resources[jobsResource] !== undefined && meta.permissions[jobsResource]?.read !== false\n const heldBack = step.logs?.some((line) => line.message === heldBackLog) ?? false\n const items = scopeItems(step.scope)\n const output = step.output !== undefined && step.output !== null && <Part title={text('output')}><JsonBlock value={step.output} />{valueActions?.(step.output, 'output')}</Part>\n return (\n <article aria-label={text('stepTry', { attempt: step.attempt })} className=\"grid gap-3 rounded-lg border bg-background p-3\">\n <header className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-body\">\n <span className=\"font-medium text-foreground\">{text('stepTry', { attempt: step.attempt })}</span>\n {items.map((item, index) => (\n <span key={index} className=\"text-muted-foreground\">\n {text('itemOf', { index: item.index + 1, map: item.map })}\n </span>\n ))}\n <Badge tone={nodeTones[step.status]}>{nodeStatusLabel(step.status)}</Badge>\n {heldBack && <Badge tone=\"violet\">{text('notSent')}</Badge>}\n {step.reused === true && <Badge tone=\"blue\">{text('reused')}</Badge>}\n {step.joined === true && <Badge tone=\"blue\">{text('joined')}</Badge>}\n <time dateTime={step.started_at} className=\"text-muted-foreground\">{formatDateTime(Date.parse(step.started_at))}</time>\n <span className=\"tabular-nums text-muted-foreground\">{text('duration', { ms: Number(step.duration_ms ?? 0) })}</span>\n </header>\n {step.error != null && (\n <Part title={text('error')}>\n <p className=\"text-body text-danger-text\">\n <span className=\"font-mono\">{String(step.error)}</span>\n {step.cause != null && <span>: {String(step.cause)}</span>}\n </p>\n </Part>\n )}\n {typeof step.run === 'string' && (\n <div className=\"grid gap-1\">\n {step.reused === true && <p className=\"text-body text-muted-foreground\">{text('reusedResult')}</p>}\n {step.joined === true && <p className=\"text-body text-muted-foreground\">{text('joinedResult')}</p>}\n <AppLink to={{ kind: 'record', resource: 'workflow_runs', key: step.run }} className={cn(buttonClass({ size: 'sm' }), 'justify-self-start')}>\n {step.reused === true ? text('openEarlierBlockRun') : text('openBlockRun')}\n </AppLink>\n </div>\n )}\n {jobs && (\n <AppLink to={{ kind: 'list', resource: jobsResource, filter: `run_id = \"${runId}\"` }} className={cn(buttonClass({ size: 'sm' }), 'justify-self-start')}>\n {text('openJobs')}\n </AppLink>\n )}\n {step.status !== 'failed' && output}\n {step.input !== undefined && step.input !== null && <Part title={text('input')}><JsonBlock value={step.input} />{valueActions?.(step.input, 'input')}</Part>}\n {step.status === 'failed' && output}\n {step.assigned != null && <Part title={text('variables')}><JsonBlock value={step.assigned} /></Part>}\n {step.logs && step.logs.length > 0 && <Part title={text('logs')}><Logs logs={step.logs} /></Part>}\n </article>\n )\n}\n","import type { WorkflowTypeList } from '@protobase/client'\nimport type { Definition } from '@protobase/workflows'\nimport { useState } from 'react'\nimport { Button, buttonClass } from '../../../primitives/button'\nimport { AppLink } from '../../use-app-address'\nimport { splitPath, stateAt, triggerId } from '../workflow/definition'\nimport { stateLabel, triggerLabel } from '../workflow/labels'\nimport { JsonBlock } from '../json/json-block'\nimport { Part, StepCard, type ValueActions } from './step-card'\nimport { text } from './messages'\nimport { useRunSteps } from './use-run-steps'\n\n/** How many of a state's steps show at first, and with each Show more. */\nexport const stepPageSize = 20\n\n/** The run whose steps a panel shows. */\nexport type StepsRun = Record<string, unknown> & { id: string; created_at: string }\n\nconst Heading = ({ kind, name }: { kind: string; name: string }) => (\n <div>\n <div className=\"text-xs text-muted-foreground\">{kind}</div>\n <h4 className=\"truncate font-semibold text-foreground\">{name}</h4>\n </div>\n)\n\n/**\n * The steps a state took in the run, every try and item, in the order they ran: the trace the graph read, so no second\n * read. A state inside a Block, which `block` names, ran in the block's own run: the way there instead.\n */\nexport const StateSteps = ({ run, name, block, valueActions }: { run: StepsRun; name: string; block?: string; valueActions?: ValueActions }) => {\n const trace = useRunSteps(run.id, false)\n const [shown, setShown] = useState(stepPageSize)\n if (trace.isPending) return null\n const steps = (trace.data ?? []).filter((step) => step.state === name)\n const blockRun = block === undefined ? undefined : (trace.data ?? []).filter((step) => step.state === block && typeof step.run === 'string').at(-1)?.run\n if (steps.length === 0 && typeof blockRun === 'string') {\n return (\n <div className=\"grid gap-2 text-body text-muted-foreground\">\n <p>{text('ranInBlockRun', { block: block! })}</p>\n <AppLink to={{ kind: 'record', resource: 'workflow_runs', key: blockRun }} className={buttonClass({ size: 'sm' }) + ' justify-self-start'}>\n {text('openBlockRun')}\n </AppLink>\n </div>\n )\n }\n if (steps.length === 0) return <p className=\"text-body text-muted-foreground\">{text('notRun')}</p>\n return (\n <div className=\"grid gap-3\">\n {steps.slice(0, shown).map((step) => (\n <StepCard key={String(step.id)} step={step} runId={run.id} {...(valueActions && { valueActions })} />\n ))}\n {steps.length > shown && (\n <Button size=\"sm\" className=\"justify-self-start\" onClick={() => setShown(shown + stepPageSize)}>\n {text('showMore')}\n </Button>\n )}\n </div>\n )\n}\n\n/**\n * What the chosen node did in the run, in the side panel: the trigger's input, or each step of the state with its input,\n * output, logs, timing, try and error.\n */\nexport const StepPanel = ({ definition, run, selected, types }: { definition: Definition; run: StepsRun; selected: string; types?: WorkflowTypeList }) => {\n const state = selected === triggerId ? undefined : stateAt(definition, selected)\n return (\n <section aria-label={text('chosenStep')} className=\"grid gap-3 rounded-lg border bg-surface p-4\">\n {state ? (\n <>\n <Heading kind={stateLabel(state, types)} name={splitPath(selected).name} />\n <StateSteps run={run} name={splitPath(selected).name} />\n </>\n ) : (\n <>\n <Heading kind={text('trigger')} name={triggerLabel(definition.trigger, types)} />\n <Part title={text('runInput')}>\n <JsonBlock value={run.input ?? null} />\n </Part>\n </>\n )}\n </section>\n )\n}\n"],"mappings":"m2BASa0B,EAAc,GACzBC,IAAU,GACN,CAAC,EACDA,EAAM,MAAM,GAAG,CAAC,CAAC,IAAK,GAAS,CAC7B,IAAMC,EAAQ,uBAAuB,KAAKC,CAAI,EAC9C,GAAI,CAACD,EAAO,MAAU,MAAM,IAAID,EAAM,wBAAwB,EAC9D,MAAO,CAAE,IAAK,mBAAmBC,EAAM,EAAG,EAAG,MAAO,OAAOA,EAAM,EAAE,CAAE,CACvE,CAAC,EAGME,GAAa,EAAe,IAAkB,CAAC,GAAGJ,EAAWC,CAAK,CAAC,CAAC,IAAK,GAASI,EAAK,GAAG,EAAGC,CAAK,CAAC,CAAC,KAAK,GAAG,EAGnHC,EAAqC,CAAE,UAAW,EAAG,OAAQ,EAAG,SAAU,EAAG,OAAQ,EAAG,QAAS,CAAE,EAO5FC,GAAc,EAA6B,CAAE,aAAY,UAAS,SAAS,CAAC,KAA2F,CAClL,IAAMC,GAAU,EAAe,IAAkB,CAAC,GAAGC,EAAQN,EAAUH,EAAOK,CAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EACxFK,EAAS,IAAI,IACbC,E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,CAAA,GAC1E,EAAA9B,EAAA,IAAA,CAACsB,EAAD,CAAiB,MAAK,KAAMjD,EAAUyD,CAAQ,CAAC,CAAC,IAAO,CAAA,CACvD,CAAA,CAAA,GAEF,EAAA9B,EAAA,KAAA,CAAAjD,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAiD,EAAA,IAAA,CAACmB,EAAD,CAAS,KAAMpB,EAAK,SAAS,EAAG,KAAMkC,EAAaF,EAAW,QAASC,CAAK,CAAI,CAAA,GAChF,EAAAhC,EAAA,IAAA,CAACC,EAAD,CAAM,MAAOF,EAAK,UAAU,EAC1B,UAAA,EAAAC,EAAA,IAAA,CAACxC,EAAD,CAAW,MAAOgE,EAAI,OAAS,IAAO,CAAA,CAClC,CAAA,CACN,CAAA,CAAA,CAEG,CAAA,CAEb","debugId":"2399f87c-e980-477b-9661-e93a4d71fed6"}
|
|
1
|
+
{"version":3,"file":"step-panel-CollAT6S.js","names":["useState","_Fragment","n","a","t","__toESM","require_react","require_jsx_runtime","formatTag","cn","JsonBlock","AppLink","messages","formatDateTime","Badge","buttonClass","useAdminMeta","Button","nodeStatusLabel","nodeTones","stateLabel","customStepOf","stateAt","splitPath","useRunSteps","import_react","scopeItems","scope","match","part","statePath","item","state","weight","nodeTraces","placed","within","counts","lastOfState","lastOfScope","step","steps","path","statuses","mark","known","status","inProgress","startAt","text","import_jsx_runtime","Part","title","children","logTime","at","Logs","logs","line","index","StepCard","meta","jobs","\"workflow_custom_step_jobs\"","heldBack","items","output","valueActions","runId","Heading","kind","name","StateSteps","trace","run","shown","setShown","blockRun","block","StepPanel","selected","definition","types","triggerLabel"],"sources":["../../../src/app/field-types/workflow-run/run-trace.ts","../../../src/app/field-types/workflow-run/messages.ts","../../../src/app/field-types/workflow-run/step-card.tsx","../../../src/app/field-types/workflow-run/step-panel.tsx"],"sourcesContent":["import type { NodeStatus, NodeTrace } from '../workflow/node-trace'\n\n/** What the graph reads of a run's step. */\nexport type TraceStep = { scope: string; state: string; status: Exclude<NodeStatus, 'current'>; next: string | null }\n\n/** A Map item a step ran in: the Map's name and the item's index from 0. */\nexport type ScopeItem = { map: string; index: number }\n\n/** The Map items of a step's scope, outermost first: `Each.3[0]` is item 0 of the Map `Each`. */\nexport const scopeItems = (scope: string): ScopeItem[] =>\n scope === ''\n ? []\n : scope.split('/').map((part) => {\n const match = /^(.*)\\.\\d+\\[(\\d+)\\]$/.exec(part)\n if (!match) throw new Error(`\"${scope}\" is not a step's scope`)\n return { map: decodeURIComponent(match[1]!), index: Number(match[2]) }\n })\n\n/** The graph's path of the state a step ran in its scope: the Maps it is inside, then its name. */\nexport const statePath = (scope: string, state: string) => [...scopeItems(scope).map((item) => item.map), state].join('/')\n\n// When a state's scopes disagree, such as a Map's items, the mark that most needs a look wins.\nconst weight: Record<NodeStatus, number> = { succeeded: 0, caught: 1, retrying: 2, failed: 3, current: 4 }\n\n/**\n * Each state's mark from the run's steps in the order they ran: how its last step in each scope ended, the worst of them\n * for a Map's items, and while the run goes on, `current` on the state each scope goes on to, or on the first state when\n * nothing ran yet. A block's run marks the states inside its Block, whose path is `within`.\n */\nexport const nodeTraces = (steps: readonly TraceStep[], { inProgress, startAt, within = [] }: { inProgress: boolean; startAt?: string | undefined; within?: readonly string[] }) => {\n const placed = (scope: string, state: string) => [...within, statePath(scope, state)].join('/')\n const counts = new Map<string, number>()\n const lastOfState = new Map<string, TraceStep>()\n const lastOfScope = new Map<string, TraceStep>()\n for (const step of steps) {\n const path = placed(step.scope, step.state)\n counts.set(path, (counts.get(path) ?? 0) + 1)\n lastOfState.set(`${step.scope}\\n${step.state}`, step)\n lastOfScope.set(step.scope, step)\n }\n const statuses = new Map<string, NodeStatus>()\n const mark = (path: string, status: NodeStatus) => {\n const known = statuses.get(path)\n if (known === undefined || weight[status] > weight[known]) statuses.set(path, status)\n }\n for (const step of lastOfState.values()) mark(placed(step.scope, step.state), step.status)\n if (inProgress) {\n if (!lastOfScope.has('') && startAt) mark([...within, startAt].join('/'), 'current')\n for (const step of lastOfScope.values()) if (step.status !== 'retrying' && step.next !== null) mark(placed(step.scope, step.next), 'current')\n }\n return new Map<string, NodeTrace>([...statuses].map(([path, status]) => [path, { status, steps: counts.get(path) ?? 0 }]))\n}\n","import { messages } from '../../../locale/messages'\n\nexport const text = messages('app/field-types/workflow-run')\n","import type { ReactNode } from 'react'\nimport { customStepOf, heldBackLog } from '@protobase/workflows'\nimport { formatDateTime } from '../../../format/date'\nimport { formatTag } from '../../../locale/active-locale'\nimport { cn } from '../../../lib/cn'\nimport { Badge } from '../../../primitives/badge'\nimport { buttonClass } from '../../../primitives/button'\nimport { useAdminMeta } from '../../meta-gate'\nimport { AppLink } from '../../use-app-address'\nimport { JsonBlock } from '../json/json-block'\nimport { nodeStatusLabel } from '../workflow/labels'\nimport { nodeTones, type NodeStatus } from '../workflow/node-trace'\nimport { scopeItems } from './run-trace'\nimport { text } from './messages'\n\n/** A step as the run's page shows it from the run's trace, keyed by its scope and number. */\nexport type StepRow = Record<string, unknown> & { id: string; scope: string; state: string; next: string | null; attempt: number; status: Exclude<NodeStatus, 'current'>; started_at: string; finished_at: string; logs: { at: string; message: string }[] | null }\n\n/** What can be done with a step's input or output where it shows, such as using it as a new run's input. */\nexport type ValueActions = (value: unknown, part: 'input' | 'output') => ReactNode\n\nexport const Part = ({ title, children }: { title: string; children: ReactNode }) => (\n <div className=\"grid gap-1\">\n <h5 className=\"text-xs font-medium text-muted-foreground\">{title}</h5>\n {children}\n </div>\n)\n\n\n// A log line's time to the second, on the viewer's clock: a step's lines are often within the same minute\nconst logTime = (at: string) => new Intl.DateTimeFormat(formatTag(), { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }).format(Date.parse(at))\n\nconst Logs = ({ logs }: { logs: NonNullable<StepRow['logs']> }) => (\n <ol className=\"grid gap-0.5 rounded-md bg-muted/60 px-3 py-2 font-mono text-xs\">\n {logs.map((line, index) => (\n <li key={index} className=\"whitespace-pre-wrap break-words\">\n <time dateTime={line.at} className=\"text-muted-foreground\">{logTime(line.at)}</time> {line.message}\n </li>\n ))}\n </ol>\n)\n\n/** The resource of custom steps' jobs, which a custom step's step links to. */\nexport const jobsResource = 'workflow_custom_step_jobs'\n\n/**\n * One step of a run: its try, item, status and timing, then its error, input, output, variables and logs, as the run's\n * trace keeps them, secrets blanked out. A step a replay did not send says so, a Block's step links to the block's\n * own run, which gave its result, and a custom step's step to the run's jobs, with the logs its container wrote, for\n * whoever may read them.\n */\nexport const StepCard = ({ step, runId, valueActions }: { step: StepRow; runId: string; valueActions?: ValueActions }) => {\n const meta = useAdminMeta()\n const jobs = typeof step.type === 'string' && customStepOf(step.type) !== undefined && meta.resources[jobsResource] !== undefined && meta.permissions[jobsResource]?.read !== false\n const heldBack = step.logs?.some((line) => line.message === heldBackLog) ?? false\n const items = scopeItems(step.scope)\n const output = step.output !== undefined && step.output !== null && <Part title={text('output')}><JsonBlock value={step.output} />{valueActions?.(step.output, 'output')}</Part>\n return (\n <article aria-label={text('stepTry', { attempt: step.attempt })} className=\"grid gap-3 rounded-lg border bg-background p-3\">\n <header className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-body\">\n <span className=\"font-medium text-foreground\">{text('stepTry', { attempt: step.attempt })}</span>\n {items.map((item, index) => (\n <span key={index} className=\"text-muted-foreground\">\n {text('itemOf', { index: item.index + 1, map: item.map })}\n </span>\n ))}\n <Badge tone={nodeTones[step.status]}>{nodeStatusLabel(step.status)}</Badge>\n {heldBack && <Badge tone=\"violet\">{text('notSent')}</Badge>}\n {step.reused === true && <Badge tone=\"blue\">{text('reused')}</Badge>}\n {step.joined === true && <Badge tone=\"blue\">{text('joined')}</Badge>}\n <time dateTime={step.started_at} className=\"text-muted-foreground\">{formatDateTime(Date.parse(step.started_at))}</time>\n <span className=\"tabular-nums text-muted-foreground\">{text('duration', { ms: Number(step.duration_ms ?? 0) })}</span>\n </header>\n {step.error != null && (\n <Part title={text('error')}>\n <p className=\"text-body text-danger-text\">\n <span className=\"font-mono\">{String(step.error)}</span>\n {step.cause != null && <span>: {String(step.cause)}</span>}\n </p>\n </Part>\n )}\n {typeof step.run === 'string' && (\n <div className=\"grid gap-1\">\n {step.reused === true && <p className=\"text-body text-muted-foreground\">{text('reusedResult')}</p>}\n {step.joined === true && <p className=\"text-body text-muted-foreground\">{text('joinedResult')}</p>}\n <AppLink to={{ kind: 'record', resource: 'workflow_runs', key: step.run }} className={cn(buttonClass({ size: 'sm' }), 'justify-self-start')}>\n {step.reused === true ? text('openEarlierBlockRun') : text('openBlockRun')}\n </AppLink>\n </div>\n )}\n {jobs && (\n <AppLink to={{ kind: 'list', resource: jobsResource, filter: `run_id = \"${runId}\"` }} className={cn(buttonClass({ size: 'sm' }), 'justify-self-start')}>\n {text('openJobs')}\n </AppLink>\n )}\n {step.status !== 'failed' && output}\n {step.input !== undefined && step.input !== null && <Part title={text('input')}><JsonBlock value={step.input} />{valueActions?.(step.input, 'input')}</Part>}\n {step.status === 'failed' && output}\n {step.assigned != null && <Part title={text('variables')}><JsonBlock value={step.assigned} /></Part>}\n {step.logs && step.logs.length > 0 && <Part title={text('logs')}><Logs logs={step.logs} /></Part>}\n </article>\n )\n}\n","import type { WorkflowTypeList } from '@protobase/client'\nimport type { Definition } from '@protobase/workflows'\nimport { useState } from 'react'\nimport { Button, buttonClass } from '../../../primitives/button'\nimport { AppLink } from '../../use-app-address'\nimport { splitPath, stateAt, triggerId } from '../workflow/definition'\nimport { stateLabel, triggerLabel } from '../workflow/labels'\nimport { JsonBlock } from '../json/json-block'\nimport { Part, StepCard, type ValueActions } from './step-card'\nimport { text } from './messages'\nimport { useRunSteps } from './use-run-steps'\n\n/** How many of a state's steps show at first, and with each Show more. */\nexport const stepPageSize = 20\n\n/** The run whose steps a panel shows. */\nexport type StepsRun = Record<string, unknown> & { id: string; created_at: string }\n\nconst Heading = ({ kind, name }: { kind: string; name: string }) => (\n <div>\n <div className=\"text-xs text-muted-foreground\">{kind}</div>\n <h4 className=\"truncate font-semibold text-foreground\">{name}</h4>\n </div>\n)\n\n/**\n * The steps a state took in the run, every try and item, in the order they ran: the trace the graph read, so no second\n * read. A state inside a Block, which `block` names, ran in the block's own run: the way there instead.\n */\nexport const StateSteps = ({ run, name, block, valueActions }: { run: StepsRun; name: string; block?: string; valueActions?: ValueActions }) => {\n const trace = useRunSteps(run.id, false)\n const [shown, setShown] = useState(stepPageSize)\n if (trace.isPending) return null\n const steps = (trace.data ?? []).filter((step) => step.state === name)\n const blockRun = block === undefined ? undefined : (trace.data ?? []).filter((step) => step.state === block && typeof step.run === 'string').at(-1)?.run\n if (steps.length === 0 && typeof blockRun === 'string') {\n return (\n <div className=\"grid gap-2 text-body text-muted-foreground\">\n <p>{text('ranInBlockRun', { block: block! })}</p>\n <AppLink to={{ kind: 'record', resource: 'workflow_runs', key: blockRun }} className={buttonClass({ size: 'sm' }) + ' justify-self-start'}>\n {text('openBlockRun')}\n </AppLink>\n </div>\n )\n }\n if (steps.length === 0) return <p className=\"text-body text-muted-foreground\">{text('notRun')}</p>\n return (\n <div className=\"grid gap-3\">\n {steps.slice(0, shown).map((step) => (\n <StepCard key={String(step.id)} step={step} runId={run.id} {...(valueActions && { valueActions })} />\n ))}\n {steps.length > shown && (\n <Button size=\"sm\" className=\"justify-self-start\" onClick={() => setShown(shown + stepPageSize)}>\n {text('showMore')}\n </Button>\n )}\n </div>\n )\n}\n\n/**\n * What the chosen node did in the run, in the side panel: the trigger's input, or each step of the state with its input,\n * output, logs, timing, try and error.\n */\nexport const StepPanel = ({ definition, run, selected, types }: { definition: Definition; run: StepsRun; selected: string; types?: WorkflowTypeList }) => {\n const state = selected === triggerId ? undefined : stateAt(definition, selected)\n return (\n <section aria-label={text('chosenStep')} className=\"grid gap-3 rounded-lg border bg-surface p-4\">\n {state ? (\n <>\n <Heading kind={stateLabel(state, types)} name={splitPath(selected).name} />\n <StateSteps run={run} name={splitPath(selected).name} />\n </>\n ) : (\n <>\n <Heading kind={text('trigger')} name={triggerLabel(definition.trigger, types)} />\n <Part title={text('runInput')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A,CAEG,CAAA,CAEb","debugId":"a8965013-e925-4ead-b4b4-f1d169b203af"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-display-CtxOHPoJ.js","names":["useState","useRef","n","a","t","__toESM","require_react","require_jsx_runtime","formatMonthName","rowAllows","cn","formatDate","formatMonth","formatDayRange","dayIn","viewerZone","humanize","formatMonthRange","displayValue","Skeleton","ErrorBanner","formatWeekday","usePermissions","text","can","MouseSensor","KeyboardSensor","DragOverlay","TouchSensor","DndContext","useSensors","EventChip","monthOf","monday","CalendarEvent","PeriodControls","inStartOrder","useCalendarMove","eventTitle","useCalendarRows","movedRows","addDays","recordDays","import_react","dayMs","ms","day","quarterOf","date","step","normalised","scale","timelineView","at","now","zone","stepTimeline","view","timelineDays","first","count","index","timelineRange","scaledTimeline","today","days","timelineHeading","timelineTicks","firsts","barOf","span","record","display","model","last","noValue","timelineLanes","group","field","hints","lanes","row","rows","value","empty","key","label","known","order","compare","b","lane","import_jsx_runtime","timelineGrid","share","total","TimelineScale","trackRef","ticks","tick","TimelineLines","TimelineRow","bar","scales","TimelineDisplay","local","setLocal","shown","linkTo","list","moves","permissions","movable","name","active","setActive","dragged","shift","track","dayWidth","daysAcross","width","x","snap","transform","sensors","useSensor","event","currentCoordinates","title","picked","startText","announcements","release","start","moving","delta","end","move","groupLabel"],"sources":["../../../src/app/displays/timeline-range.ts","../../../src/app/displays/timeline-scale.tsx","../../../src/app/displays/timeline-row.tsx","../../../src/app/displays/timeline-display.tsx"],"sourcesContent":["import type { ListDisplayModel, ResourceModel, TimelineView, ViewModel } from '@protobase/schema'\nimport { formatDayRange, formatMonth, formatMonthName, formatMonthRange, formatWeekday } from '../../format/date'\nimport { dayIn, viewerZone } from '../../format/zone'\nimport { displayValue } from '../../live/display-value'\nimport { humanize } from '../../live/naming'\nimport { addDays, monday, monthOf, recordDays, type CalendarRange } from './calendar-range'\nimport type { ListDisplayRow } from './list-displays'\nimport { text } from './messages'\n\n// The days a timeline shows, as `YYYY-MM-DD` days, weeks from Monday and quarters from January, April, July and\n// October; where each record's bar lies on them, and the lanes of its `group`.\n\nexport type TimelineDisplayModel = Extract<ListDisplayModel, { kind: 'timeline' }>\n\nconst dayMs = 86_400_000\nconst ms = (day: string) => Date.parse(`${day}T00:00:00Z`)\n\nconst quarterOf = (day: string, step = 0) => {\n const date = new Date(ms(day))\n return new Date(Date.UTC(date.getUTCFullYear(), Math.floor(date.getUTCMonth() / 3) * 3 + 3 * step, 1)).toISOString().slice(0, 10)\n}\n\nconst normalised = ({ scale, day }: TimelineView): TimelineView => ({ scale, day: scale === 'week' ? monday(day) : scale === 'month' ? monthOf(day) : quarterOf(day) })\n\n/** The period a timeline shows: the address's, from the week's Monday, the month's 1st or the quarter's, else the month of `now`. */\nexport const timelineView = (at: TimelineView | undefined, now: number, zone = viewerZone()): TimelineView => normalised(at ?? { scale: 'month', day: dayIn(now, zone) })\n\n/** The week before (-1) or after (1) `view`, or the month or quarter. */\nexport const stepTimeline = (view: TimelineView, step: -1 | 1): TimelineView => {\n const { scale, day } = normalised(view)\n return { scale, day: scale === 'week' ? addDays(day, 7 * step) : scale === 'month' ? monthOf(day, step) : quarterOf(day, step) }\n}\n\n/** The days a timeline shows: the week's seven, the month's, or the quarter's. */\nexport const timelineDays = (view: TimelineView): string[] => {\n const first = normalised(view).day\n const count = (ms(stepTimeline(view, 1).day) - ms(first)) / dayMs\n return Array.from({ length: count }, (_, index) => addDays(first, index))\n}\n\n/** The days `view` shows, as a range from its first day to the day after its last. */\nexport const timelineRange = (view: TimelineView): CalendarRange => ({ from: normalised(view).day, to: stepTimeline(view, 1).day })\n\n/**\n * The period of `scale` a timeline switches to: the one holding today when the period shown holds it, else the one\n * holding the period's first day.\n */\nexport const scaledTimeline = (view: TimelineView, scale: TimelineView['scale'], now: number, zone = viewerZone()): TimelineView => {\n const today = dayIn(now, zone)\n const days = timelineDays(view)\n return normalised({ scale, day: today >= days[0]! && today <= days.at(-1)! ? today : days[0]! })\n}\n\n/** The heading of the period a timeline shows: \"12–18 Oct 2026\", \"October 2026\", \"October – December 2026\". */\nexport const timelineHeading = (view: TimelineView) => {\n const days = timelineDays(view)\n if (view.scale === 'week') return formatDayRange(ms(days[0]!), ms(days.at(-1)!))\n return view.scale === 'month' ? formatMonth(ms(days[0]!)) : formatMonthRange(ms(days[0]!), ms(monthOf(days.at(-1)!)))\n}\n\n/**\n * A mark on a timeline's scale: from the day at `index`, `span` days long. `minor` marks are left out where the scale\n * is narrow, on a phone.\n */\nexport type TimelineTick = { index: number; span: number; label: string; minor?: boolean }\n\n/** The marks of a timeline's scale: a week's days by weekday and number, a month's by number, a quarter's months by name. */\nexport const timelineTicks = (view: TimelineView): TimelineTick[] => {\n const days = timelineDays(view)\n if (view.scale === 'week') return days.map((day, index) => ({ index, span: 1, label: `${formatWeekday(ms(day))} ${Number(day.slice(8))}` }))\n if (view.scale === 'month') return days.map((day, index) => ({ index, span: 1, label: String(Number(day.slice(8))), ...(index % 7 !== 0 && { minor: true }) }))\n const firsts = days.flatMap((day, index) => (day.endsWith('-01') ? [index] : []))\n return firsts.map((index, at) => ({ index, span: (firsts[at + 1] ?? days.length) - index, label: formatMonthName(ms(days[index]!)) }))\n}\n\n/**\n * Where a record's bar lies on `days`: the index of its first and last day shown, and whether it starts before them or\n * ends after them; none for a record without a start or off them.\n */\nexport const barOf = (record: Record<string, unknown>, display: TimelineDisplayModel, model: ResourceModel, days: string[], zone = viewerZone()) => {\n const span = recordDays(record, display, model, zone)\n const first = days[0]\n const last = days.at(-1)\n if (!span || first === undefined || last === undefined || span.last < first || span.first > last) return undefined\n return {\n first: span.first < first ? 0 : days.indexOf(span.first),\n last: span.last > last ? days.length - 1 : days.indexOf(span.last),\n before: span.first < first,\n after: span.last > last,\n /** The day the record starts on, shown or not. */\n start: span.first,\n }\n}\n\n/** A lane of a timeline: the records with one value of its `group`, headed by that value; the one lane of a timeline without a group has no heading. */\nexport type TimelineLane = { key: string; label?: string; rows: ListDisplayRow[] }\n\nconst noValue = 'none'\n\n/**\n * The lanes of a timeline: one per value of its `group` that a record has, each with its records in their order; an\n * enum's in the order the field lists its values, a relation's by the name of the record it points at, others by value,\n * and last the records without a value, headed \"No <field>\" as a board's column is.\n */\nexport const timelineLanes = (rows: ListDisplayRow[], model: ResourceModel, view: ViewModel | undefined, display: TimelineDisplayModel): TimelineLane[] => {\n const group = display.group\n const field = group === undefined ? undefined : model.fields[group]\n if (group === undefined || !field) return [{ key: '', rows }]\n const hints = view?.fields[group]\n const lanes = new Map<string, { value: unknown; lane: TimelineLane }>()\n for (const row of rows) {\n const value = row.record[group]\n const empty = value === null || value === undefined || value === ''\n const key = empty ? noValue : `value:${String(value)}`\n const label = empty ? text('noValue', { label: hints?.label ?? humanize(group) }) : (row.labels[group] ?? displayValue(field, value, hints))\n const known = lanes.get(key) ?? { value: empty ? undefined : value, lane: { key, label, rows: [] } }\n known.lane.rows.push(row)\n lanes.set(key, known)\n }\n const order = field.enumValues ?? []\n const compare = (a: { value: unknown; lane: TimelineLane }, b: { value: unknown; lane: TimelineLane }) => {\n if (a.value === undefined || b.value === undefined) return Number(a.value === undefined) - Number(b.value === undefined)\n if (field.type === 'enum') return order.indexOf(String(a.value)) - order.indexOf(String(b.value))\n if (field.type === 'relation') return a.lane.label!.localeCompare(b.lane.label!)\n if (typeof a.value === 'number' && typeof b.value === 'number') return a.value - b.value\n return String(a.value).localeCompare(String(b.value), undefined, { numeric: true })\n }\n return [...lanes.values()].toSorted(compare).map(({ lane }) => lane)\n}\n","import type { Ref } from 'react'\nimport { cn } from '../../lib/cn'\nimport type { TimelineTick } from './timeline-range'\n\n/** A timeline's columns: the records' titles beside their bars, above them on a phone. */\nexport const timelineGrid = 'grid grid-cols-1 sm:grid-cols-[12rem_minmax(0,1fr)]'\n\n/** Where `count` days of `total` end, as a share of the bars' width. */\nexport const share = (count: number, total: number) => `${(count / total) * 100}%`\n\ntype ScaleProps = {\n ticks: TimelineTick[]\n days: string[]\n today: string\n /** The heading over the titles: the lanes' field, or the records. */\n label: string\n /** The bars' width, which a day dragged across is a share of. */\n trackRef: Ref<HTMLDivElement>\n}\n\n/** The scale over a timeline's rows: the marks of its days or months, today's marked. */\nexport const TimelineScale = ({ ticks, days, today, label, trackRef }: ScaleProps) => (\n <div className={cn(timelineGrid, 'border-b border-border bg-surface')}>\n <span className=\"hidden truncate px-2 py-1 text-xs font-medium text-muted-foreground sm:block\">{label}</span>\n <div ref={trackRef} aria-hidden className=\"relative h-6\">\n {ticks.map((tick) => (\n <span\n key={tick.index}\n className={cn(\n 'absolute inset-y-0 items-center truncate px-1 text-xs tabular-nums text-muted-foreground',\n // The first line, beside the titles, is the frame's own on a phone\n tick.index > 0 ? 'border-l border-border' : 'border-border sm:border-l',\n tick.minor ? 'hidden sm:flex' : 'flex',\n tick.span === 1 && days[tick.index] === today && 'font-medium text-primary',\n )}\n style={{ left: share(tick.index, days.length), width: share(tick.span, days.length) }}\n >\n {tick.label}\n </span>\n ))}\n </div>\n </div>\n)\n\n/** The lines behind a timeline's rows where each mark starts, and today's day shaded. */\nexport const TimelineLines = ({ ticks, days, today }: Omit<ScaleProps, 'label' | 'trackRef'>) => {\n const at = days.indexOf(today)\n return (\n <div aria-hidden className={cn(timelineGrid, 'pointer-events-none absolute inset-0')}>\n <span className=\"hidden sm:block\" />\n <div className=\"relative\">\n {at >= 0 && <span className=\"absolute inset-y-0 bg-primary/10\" style={{ left: share(at, days.length), width: share(1, days.length) }} />}\n {ticks.map((tick) => (\n <span key={tick.index} className={cn('absolute inset-y-0 w-px bg-border', (tick.minor || tick.index === 0) && 'hidden sm:block')} style={{ left: share(tick.index, days.length) }} />\n ))}\n </div>\n </div>\n )\n}\n","import type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { cn } from '../../lib/cn'\nimport { CalendarEvent, eventTitle } from './calendar-event'\nimport type { ListDisplayRow } from './list-displays'\nimport { barOf, type TimelineDisplayModel } from './timeline-range'\nimport { share, timelineGrid } from './timeline-scale'\n\ntype RowProps = {\n model: ResourceModel\n view: ViewModel | undefined\n display: TimelineDisplayModel\n row: ListDisplayRow\n days: string[]\n movable: boolean\n dragged: () => boolean\n}\n\n/**\n * A record of a timeline: its title, and its bar over the days it is on, an event chip as wide as those days, cut\n * square where it goes on before or after them. The bar is the link to the record, and is picked up to move it.\n */\nexport const TimelineRow = ({ model, view, display, row, days, movable, dragged }: RowProps) => {\n const bar = barOf(row.record, display, model, days)\n return (\n <div className={cn(timelineGrid, 'relative border-b border-border last:border-b-0')}>\n {/* The bar's link says the title to assistive technology */}\n <span aria-hidden className=\"truncate px-2 pt-1 text-body sm:py-1.5\">\n {eventTitle(model, view, display, row)}\n </span>\n <div className=\"relative h-7\">\n {bar && (\n <div className=\"absolute top-1/2 -translate-y-1/2\" style={{ left: share(bar.first, days.length), width: share(bar.last - bar.first + 1, days.length) }}>\n <CalendarEvent\n model={model}\n view={view}\n display={display}\n row={row}\n day={bar.start}\n movable={movable}\n dragged={dragged}\n className={cn(bar.before && 'rounded-l-none border-l-0', bar.after && 'rounded-r-none border-r-0')}\n />\n </div>\n )}\n </div>\n </div>\n )\n}\n","import { DndContext, DragOverlay, KeyboardSensor, MouseSensor, TouchSensor, useSensor, useSensors, type Announcements, type DragEndEvent, type DragMoveEvent, type DragStartEvent, type KeyboardCoordinateGetter, type Modifier } from '@dnd-kit/core'\nimport { useRef, useState } from 'react'\nimport type { AppAddress, ResourceModel, TimelineView, ViewModel } from '@protobase/schema'\nimport { formatDate } from '../../format/date'\nimport { dayIn, viewerZone } from '../../format/zone'\nimport { humanize } from '../../live/naming'\nimport { Skeleton } from '../../primitives/skeleton'\nimport { ErrorBanner } from '../error-banner'\nimport { usePermissions } from '../meta-gate'\nimport { can, rowAllows } from '../permissions'\nimport { addDays, inStartOrder, recordDays } from './calendar-range'\nimport { EventChip, eventTitle } from './calendar-event'\nimport type { ListDisplayRow } from './list-displays'\nimport { PeriodControls } from './period-controls'\nimport { scaledTimeline, stepTimeline, timelineDays, timelineHeading, timelineLanes, timelineRange, timelineTicks, timelineView, type TimelineDisplayModel } from './timeline-range'\nimport { TimelineRow } from './timeline-row'\nimport { TimelineLines, TimelineScale } from './timeline-scale'\nimport { calendarLimit, useCalendarRows } from './use-calendar-rows'\nimport { movedRows, useCalendarMove } from './use-calendar-move'\nimport { text } from './messages'\n\ntype TimelineProps = {\n model: ResourceModel\n view: ViewModel | undefined\n display: TimelineDisplayModel\n /** The fields the bars and lanes show, which the records' relations are labelled for. */\n fields: string[]\n /** The list's filter, its search included, as the list API takes it. */\n filter: string\n /** The period the address names; the month of today when it names none. */\n at?: TimelineView\n /** The address that shows the timeline at a period, for a timeline whose period is in the address; else it keeps its own. */\n linkTo?: (view: TimelineView) => AppAddress\n /** The time that is today, now unless a test fixes it. */\n now?: number\n}\n\nconst scales = (): Array<{ scale: TimelineView['scale']; label: string }> => [\n { scale: 'week', label: text('week') },\n { scale: 'month', label: text('month') },\n { scale: 'quarter', label: text('quarter') },\n]\n\n// What a bar being moved is: the record, and the day it starts on\ntype Picked = { row: ListDisplayRow; day: string }\n\n/**\n * The list's records as bars over the days of a week, a month or a quarter, in lanes by the display's `group`, loaded\n * for those days alone through the list API as a calendar's are; a bar dragged along its row, or moved with the\n * keyboard, saves the record with its dates moved by the same days.\n */\nexport const TimelineDisplay = ({ model, view, display, fields, filter, at, linkTo, now = Date.now() }: TimelineProps) => {\n const [local, setLocal] = useState<TimelineView | undefined>()\n const shown = timelineView(linkTo ? at : local, now)\n const days = timelineDays(shown)\n const ticks = timelineTicks(shown)\n const list = useCalendarRows({ model, display, range: timelineRange(shown), fields, filter })\n const { moves, move } = useCalendarMove(model, display)\n const lanes = timelineLanes(inStartOrder(movedRows(list.rows, moves), display), model, view, display)\n const permissions = usePermissions(model.name)\n const movable = can(permissions, 'update') && [display.start, display.end].every((name) => name === undefined || !model.fields[name]?.readOnly)\n const [active, setActive] = useState<Picked | undefined>()\n // The click that ends a drag with a mouse lands on the bar's link, which must not open the record\n const dragged = useRef(false)\n // How many days the bar being moved has gone, for what is announced\n const shift = useRef(0)\n const track = useRef<HTMLDivElement>(null)\n const dayWidth = () => (track.current?.getBoundingClientRect().width ?? 0) / days.length\n const daysAcross = (x: number) => {\n const width = dayWidth()\n return width > 0 ? Math.round(x / width) : 0\n }\n // A bar moves along its row alone, a whole day at a time\n const snap: Modifier = ({ transform }) => ({ ...transform, x: daysAcross(transform.x) * dayWidth(), y: 0 })\n const dayKeys: KeyboardCoordinateGetter = (event, { currentCoordinates }) => {\n const step = event.code === 'ArrowLeft' ? -1 : event.code === 'ArrowRight' ? 1 : 0\n if (step === 0) return undefined\n event.preventDefault()\n return { x: currentCoordinates.x + step * dayWidth(), y: currentCoordinates.y }\n }\n const sensors = useSensors(\n useSensor(MouseSensor, { activationConstraint: { distance: 4 } }),\n useSensor(TouchSensor, { activationConstraint: { delay: 250, tolerance: 5 } }),\n // Enter opens the bar's record, so only Space picks a bar up\n useSensor(KeyboardSensor, { keyboardCodes: { start: ['Space'], cancel: ['Escape'], end: ['Space', 'Enter'] }, coordinateGetter: dayKeys }),\n )\n\n const today = dayIn(now, viewerZone())\n const title = (picked: Picked) => eventTitle(model, view, display, picked.row)\n const startText = (picked: Picked) => formatDate(Date.parse(`${addDays(picked.day, shift.current)}T00:00:00Z`))\n const announcements: Announcements = {\n onDragStart: ({ active: picked }) => text('pickedUp', { title: title(picked.data.current as Picked) }),\n onDragMove: ({ active: picked }) => text('startsOn', { title: title(picked.data.current as Picked), day: startText(picked.data.current as Picked) }),\n onDragOver: () => undefined,\n onDragEnd: ({ active: picked }) => (shift.current === 0 ? text('putBack', { title: title(picked.data.current as Picked) }) : text('wasMovedTo', { title: title(picked.data.current as Picked), to: startText(picked.data.current as Picked) })),\n onDragCancel: ({ active: picked }) => text('cancelled', { title: title(picked.data.current as Picked) }),\n }\n const release = () => {\n setActive(undefined)\n setTimeout(() => (dragged.current = false))\n }\n const start = ({ active: picked }: DragStartEvent) => {\n dragged.current = true\n shift.current = 0\n setActive(picked.data.current as Picked)\n }\n const moving = ({ delta }: DragMoveEvent) => (shift.current = daysAcross(delta.x))\n const end = ({ active: picked, delta }: DragEndEvent) => {\n release()\n shift.current = daysAcross(delta.x)\n const { row } = picked.data.current as Picked\n const span = recordDays(row.record, display, model)\n if (span && shift.current !== 0) move(row, span.first, addDays(span.first, shift.current))\n }\n\n const groupLabel = display.group === undefined ? (view?.names?.plural ?? humanize(model.name)) : (view?.fields[display.group]?.label ?? humanize(display.group))\n const empty = !list.loading && !list.error && list.rows.length === 0\n return (\n <div className=\"flex min-w-0 flex-1 flex-col gap-3\">\n <PeriodControls\n heading={timelineHeading(shown)}\n unit={shown.scale}\n previous={stepTimeline(shown, -1)}\n today={timelineView({ scale: shown.scale, day: today }, now)}\n next={stepTimeline(shown, 1)}\n scales={scales().map(({ scale, label }) => ({ view: scaledTimeline(shown, scale, now), label, current: shown.scale === scale }))}\n scalesLabel={text('timelineScale')}\n linkTo={linkTo}\n onView={setLocal}\n />\n {list.error && <ErrorBanner title={text('couldNotLoadRows')} error={list.error} />}\n {list.capped && (\n <p className=\"text-xs text-muted-foreground\">\n {text('capped', { limit: calendarLimit, unit: shown.scale })}\n </p>\n )}\n <DndContext\n sensors={sensors}\n modifiers={[snap]}\n onDragStart={start}\n onDragMove={moving}\n onDragEnd={end}\n onDragCancel={release}\n accessibility={{\n announcements,\n screenReaderInstructions: {\n draggable: text('timelineInstructions'),\n },\n }}\n >\n {/* As tall as all its rows, scrolling with the page */}\n <div className=\"overflow-hidden rounded-lg border border-border\">\n <TimelineScale ticks={ticks} days={days} today={today} label={groupLabel} trackRef={track} />\n <div className=\"relative\">\n <TimelineLines ticks={ticks} days={days} today={today} />\n {list.loading && (\n <div className=\"relative flex flex-col gap-2 p-2\">\n <Skeleton className=\"h-4\" />\n <Skeleton className=\"h-4\" />\n </div>\n )}\n {empty && <p className=\"relative px-2 py-3 text-xs text-muted-foreground\">{text('nothingIn', { unit: shown.scale })}</p>}\n {!list.loading &&\n lanes.map((lane) => (\n <section key={lane.key} aria-label={lane.label} className=\"relative border-b border-border last:border-b-0\">\n {lane.label !== undefined && (\n <h3 className=\"flex items-center gap-1.5 border-b border-border bg-surface px-2 py-1 text-xs font-medium\">\n {lane.label}\n <span className=\"tabular-nums text-muted-foreground\">{lane.rows.length}</span>\n </h3>\n )}\n {lane.rows.map((row) => (\n <TimelineRow key={row.key} model={model} view={view} display={display} row={row} days={days} movable={movable && rowAllows(row.record, 'update')} dragged={() => dragged.current} />\n ))}\n </section>\n ))}\n </div>\n </div>\n <DragOverlay>{active && <EventChip model={model} view={view} display={display} row={active.row} day={active.day} />}</DragOverlay>\n </DndContext>\n </div>\n )\n}\n"],"mappings":"q9BAcM4C,EAAQ,MACRC,EAAM,GAAgB,KAAK,MAAM,GAAGC,EAAI,WAAW,EAEnDC,GAAa,EAAa,EAAO,IAAM,CAC3C,IAAMC,EAAO,IAAI,KAAKH,EAAGC,CAAG,CAAC,EAC7B,OAAO,IAAI,KAAK,KAAK,IAAIE,EAAK,eAAe,EAAG,KAAK,MAAMA,EAAK,YAAY,EAAI,CAAC,EAAI,EAAI,EAAIC,EAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,EAAG,EAAE,CAClI,EAEMC,GAAc,CAAE,QAAO,UAAuC,CAAE,QAAO,IAAKC,IAAU,OAASlB,EAAOa,CAAG,EAAIK,IAAU,QAAUnB,EAAQc,CAAG,EAAIC,EAAUD,CAAG,CAAE,GAGxJM,GAAgB,EAA8B,EAAa,EAAOrC,EAAW,IAAoBmC,EAAWG,GAAM,CAAE,MAAO,QAAS,IAAKvC,EAAMwC,EAAKC,CAAI,CAAE,CAAC,EAG3JC,GAAgB,EAAoB,IAA+B,CAC9E,GAAM,CAAE,QAAO,OAAQN,EAAWO,CAAI,EACtC,MAAO,CAAE,QAAO,IAAKN,IAAU,OAASV,EAAQK,EAAK,EAAIG,CAAI,EAAIE,IAAU,QAAUnB,EAAQc,EAAKG,CAAI,EAAIF,EAAUD,EAAKG,C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B,EAAM,IAAK,IACT,EAAAY,EAAA,KAAA,CAAC,UAAD,CAAwB,aAAYD,EAAK,MAAO,UAAU,kDAA1D,SAAA,CACGA,EAAK,QAAU,IAAA,KACd,EAAAC,EAAA,KAAA,CAAC,KAAD,CAAI,UAAU,4FAAd,SAAA,CACGD,EAAK,OACN,EAAAC,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,qCAAsC,SAAAD,EAAK,KAAK,MAAa,CAAA,CAC3E,CAEL,CAAA,EAAAA,EAAK,KAAK,IAAK,IACd,EAAAC,EAAA,IAAA,CAACS,GAAD,CAAkC,QAAa,OAAe,UAAc,MAAW,OAAM,QAASW,GAAWvG,EAAUwE,EAAI,OAAQ,QAAQ,EAAG,YAAemC,EAAQ,OAAU,EAAjKnC,EAAI,GAA6J,CACpL,CACM,CAVK,EAAAU,EAAK,GAUV,CACV,CACA,CACF,CAAA,CAAA,CACL,CAAA,GAAA,EAAAC,EAAA,IAAA,CAACjE,EAAD,CAAA,SAAcuF,IAAU,EAAAtB,EAAA,IAAA,CAAC7D,GAAD,CAAkB,QAAa,OAAe,UAAS,IAAKmF,EAAO,IAAK,IAAKA,EAAO,GAAM,CAAA,CAAe,CAAA,CACvH,GACT,GAET","debugId":"adc4e1cf-a09f-499d-adea-4c60e38ba382"}
|
|
1
|
+
{"version":3,"file":"timeline-display-Db0NWucC.js","names":["useState","useRef","n","a","t","__toESM","require_react","require_jsx_runtime","formatMonthName","rowAllows","cn","formatDate","formatMonth","formatDayRange","dayIn","viewerZone","humanize","formatMonthRange","displayValue","Skeleton","ErrorBanner","formatWeekday","usePermissions","text","can","MouseSensor","KeyboardSensor","DragOverlay","TouchSensor","DndContext","useSensors","EventChip","monthOf","monday","CalendarEvent","PeriodControls","inStartOrder","useCalendarMove","eventTitle","useCalendarRows","movedRows","addDays","recordDays","import_react","dayMs","ms","day","quarterOf","date","step","normalised","scale","timelineView","at","now","zone","stepTimeline","view","timelineDays","first","count","index","timelineRange","scaledTimeline","today","days","timelineHeading","timelineTicks","firsts","barOf","span","record","display","model","last","noValue","timelineLanes","group","field","hints","lanes","row","rows","value","empty","key","label","known","order","compare","b","lane","import_jsx_runtime","timelineGrid","share","total","TimelineScale","trackRef","ticks","tick","TimelineLines","TimelineRow","bar","scales","TimelineDisplay","local","setLocal","shown","linkTo","list","moves","permissions","movable","name","active","setActive","dragged","shift","track","dayWidth","daysAcross","width","x","snap","transform","sensors","useSensor","event","currentCoordinates","title","picked","startText","announcements","release","start","moving","delta","end","move","groupLabel"],"sources":["../../../src/app/displays/timeline-range.ts","../../../src/app/displays/timeline-scale.tsx","../../../src/app/displays/timeline-row.tsx","../../../src/app/displays/timeline-display.tsx"],"sourcesContent":["import type { ListDisplayModel, ResourceModel, TimelineView, ViewModel } from '@protobase/schema'\nimport { formatDayRange, formatMonth, formatMonthName, formatMonthRange, formatWeekday } from '../../format/date'\nimport { dayIn, viewerZone } from '../../format/zone'\nimport { displayValue } from '../../live/display-value'\nimport { humanize } from '../../live/naming'\nimport { addDays, monday, monthOf, recordDays, type CalendarRange } from './calendar-range'\nimport type { ListDisplayRow } from './list-displays'\nimport { text } from './messages'\n\n// The days a timeline shows, as `YYYY-MM-DD` days, weeks from Monday and quarters from January, April, July and\n// October; where each record's bar lies on them, and the lanes of its `group`.\n\nexport type TimelineDisplayModel = Extract<ListDisplayModel, { kind: 'timeline' }>\n\nconst dayMs = 86_400_000\nconst ms = (day: string) => Date.parse(`${day}T00:00:00Z`)\n\nconst quarterOf = (day: string, step = 0) => {\n const date = new Date(ms(day))\n return new Date(Date.UTC(date.getUTCFullYear(), Math.floor(date.getUTCMonth() / 3) * 3 + 3 * step, 1)).toISOString().slice(0, 10)\n}\n\nconst normalised = ({ scale, day }: TimelineView): TimelineView => ({ scale, day: scale === 'week' ? monday(day) : scale === 'month' ? monthOf(day) : quarterOf(day) })\n\n/** The period a timeline shows: the address's, from the week's Monday, the month's 1st or the quarter's, else the month of `now`. */\nexport const timelineView = (at: TimelineView | undefined, now: number, zone = viewerZone()): TimelineView => normalised(at ?? { scale: 'month', day: dayIn(now, zone) })\n\n/** The week before (-1) or after (1) `view`, or the month or quarter. */\nexport const stepTimeline = (view: TimelineView, step: -1 | 1): TimelineView => {\n const { scale, day } = normalised(view)\n return { scale, day: scale === 'week' ? addDays(day, 7 * step) : scale === 'month' ? monthOf(day, step) : quarterOf(day, step) }\n}\n\n/** The days a timeline shows: the week's seven, the month's, or the quarter's. */\nexport const timelineDays = (view: TimelineView): string[] => {\n const first = normalised(view).day\n const count = (ms(stepTimeline(view, 1).day) - ms(first)) / dayMs\n return Array.from({ length: count }, (_, index) => addDays(first, index))\n}\n\n/** The days `view` shows, as a range from its first day to the day after its last. */\nexport const timelineRange = (view: TimelineView): CalendarRange => ({ from: normalised(view).day, to: stepTimeline(view, 1).day })\n\n/**\n * The period of `scale` a timeline switches to: the one holding today when the period shown holds it, else the one\n * holding the period's first day.\n */\nexport const scaledTimeline = (view: TimelineView, scale: TimelineView['scale'], now: number, zone = viewerZone()): TimelineView => {\n const today = dayIn(now, zone)\n const days = timelineDays(view)\n return normalised({ scale, day: today >= days[0]! && today <= days.at(-1)! ? today : days[0]! })\n}\n\n/** The heading of the period a timeline shows: \"12–18 Oct 2026\", \"October 2026\", \"October – December 2026\". */\nexport const timelineHeading = (view: TimelineView) => {\n const days = timelineDays(view)\n if (view.scale === 'week') return formatDayRange(ms(days[0]!), ms(days.at(-1)!))\n return view.scale === 'month' ? formatMonth(ms(days[0]!)) : formatMonthRange(ms(days[0]!), ms(monthOf(days.at(-1)!)))\n}\n\n/**\n * A mark on a timeline's scale: from the day at `index`, `span` days long. `minor` marks are left out where the scale\n * is narrow, on a phone.\n */\nexport type TimelineTick = { index: number; span: number; label: string; minor?: boolean }\n\n/** The marks of a timeline's scale: a week's days by weekday and number, a month's by number, a quarter's months by name. */\nexport const timelineTicks = (view: TimelineView): TimelineTick[] => {\n const days = timelineDays(view)\n if (view.scale === 'week') return days.map((day, index) => ({ index, span: 1, label: `${formatWeekday(ms(day))} ${Number(day.slice(8))}` }))\n if (view.scale === 'month') return days.map((day, index) => ({ index, span: 1, label: String(Number(day.slice(8))), ...(index % 7 !== 0 && { minor: true }) }))\n const firsts = days.flatMap((day, index) => (day.endsWith('-01') ? [index] : []))\n return firsts.map((index, at) => ({ index, span: (firsts[at + 1] ?? days.length) - index, label: formatMonthName(ms(days[index]!)) }))\n}\n\n/**\n * Where a record's bar lies on `days`: the index of its first and last day shown, and whether it starts before them or\n * ends after them; none for a record without a start or off them.\n */\nexport const barOf = (record: Record<string, unknown>, display: TimelineDisplayModel, model: ResourceModel, days: string[], zone = viewerZone()) => {\n const span = recordDays(record, display, model, zone)\n const first = days[0]\n const last = days.at(-1)\n if (!span || first === undefined || last === undefined || span.last < first || span.first > last) return undefined\n return {\n first: span.first < first ? 0 : days.indexOf(span.first),\n last: span.last > last ? days.length - 1 : days.indexOf(span.last),\n before: span.first < first,\n after: span.last > last,\n /** The day the record starts on, shown or not. */\n start: span.first,\n }\n}\n\n/** A lane of a timeline: the records with one value of its `group`, headed by that value; the one lane of a timeline without a group has no heading. */\nexport type TimelineLane = { key: string; label?: string; rows: ListDisplayRow[] }\n\nconst noValue = 'none'\n\n/**\n * The lanes of a timeline: one per value of its `group` that a record has, each with its records in their order; an\n * enum's in the order the field lists its values, a relation's by the name of the record it points at, others by value,\n * and last the records without a value, headed \"No <field>\" as a board's column is.\n */\nexport const timelineLanes = (rows: ListDisplayRow[], model: ResourceModel, view: ViewModel | undefined, display: TimelineDisplayModel): TimelineLane[] => {\n const group = display.group\n const field = group === undefined ? undefined : model.fields[group]\n if (group === undefined || !field) return [{ key: '', rows }]\n const hints = view?.fields[group]\n const lanes = new Map<string, { value: unknown; lane: TimelineLane }>()\n for (const row of rows) {\n const value = row.record[group]\n const empty = value === null || value === undefined || value === ''\n const key = empty ? noValue : `value:${String(value)}`\n const label = empty ? text('noValue', { label: hints?.label ?? humanize(group) }) : (row.labels[group] ?? displayValue(field, value, hints))\n const known = lanes.get(key) ?? { value: empty ? undefined : value, lane: { key, label, rows: [] } }\n known.lane.rows.push(row)\n lanes.set(key, known)\n }\n const order = field.enumValues ?? []\n const compare = (a: { value: unknown; lane: TimelineLane }, b: { value: unknown; lane: TimelineLane }) => {\n if (a.value === undefined || b.value === undefined) return Number(a.value === undefined) - Number(b.value === undefined)\n if (field.type === 'enum') return order.indexOf(String(a.value)) - order.indexOf(String(b.value))\n if (field.type === 'relation') return a.lane.label!.localeCompare(b.lane.label!)\n if (typeof a.value === 'number' && typeof b.value === 'number') return a.value - b.value\n return String(a.value).localeCompare(String(b.value), undefined, { numeric: true })\n }\n return [...lanes.values()].toSorted(compare).map(({ lane }) => lane)\n}\n","import type { Ref } from 'react'\nimport { cn } from '../../lib/cn'\nimport type { TimelineTick } from './timeline-range'\n\n/** A timeline's columns: the records' titles beside their bars, above them on a phone. */\nexport const timelineGrid = 'grid grid-cols-1 sm:grid-cols-[12rem_minmax(0,1fr)]'\n\n/** Where `count` days of `total` end, as a share of the bars' width. */\nexport const share = (count: number, total: number) => `${(count / total) * 100}%`\n\ntype ScaleProps = {\n ticks: TimelineTick[]\n days: string[]\n today: string\n /** The heading over the titles: the lanes' field, or the records. */\n label: string\n /** The bars' width, which a day dragged across is a share of. */\n trackRef: Ref<HTMLDivElement>\n}\n\n/** The scale over a timeline's rows: the marks of its days or months, today's marked. */\nexport const TimelineScale = ({ ticks, days, today, label, trackRef }: ScaleProps) => (\n <div className={cn(timelineGrid, 'border-b border-border bg-surface')}>\n <span className=\"hidden truncate px-2 py-1 text-xs font-medium text-muted-foreground sm:block\">{label}</span>\n <div ref={trackRef} aria-hidden className=\"relative h-6\">\n {ticks.map((tick) => (\n <span\n key={tick.index}\n className={cn(\n 'absolute inset-y-0 items-center truncate px-1 text-xs tabular-nums text-muted-foreground',\n // The first line, beside the titles, is the frame's own on a phone\n tick.index > 0 ? 'border-l border-border' : 'border-border sm:border-l',\n tick.minor ? 'hidden sm:flex' : 'flex',\n tick.span === 1 && days[tick.index] === today && 'font-medium text-primary',\n )}\n style={{ left: share(tick.index, days.length), width: share(tick.span, days.length) }}\n >\n {tick.label}\n </span>\n ))}\n </div>\n </div>\n)\n\n/** The lines behind a timeline's rows where each mark starts, and today's day shaded. */\nexport const TimelineLines = ({ ticks, days, today }: Omit<ScaleProps, 'label' | 'trackRef'>) => {\n const at = days.indexOf(today)\n return (\n <div aria-hidden className={cn(timelineGrid, 'pointer-events-none absolute inset-0')}>\n <span className=\"hidden sm:block\" />\n <div className=\"relative\">\n {at >= 0 && <span className=\"absolute inset-y-0 bg-primary/10\" style={{ left: share(at, days.length), width: share(1, days.length) }} />}\n {ticks.map((tick) => (\n <span key={tick.index} className={cn('absolute inset-y-0 w-px bg-border', (tick.minor || tick.index === 0) && 'hidden sm:block')} style={{ left: share(tick.index, days.length) }} />\n ))}\n </div>\n </div>\n )\n}\n","import type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { cn } from '../../lib/cn'\nimport { CalendarEvent, eventTitle } from './calendar-event'\nimport type { ListDisplayRow } from './list-displays'\nimport { barOf, type TimelineDisplayModel } from './timeline-range'\nimport { share, timelineGrid } from './timeline-scale'\n\ntype RowProps = {\n model: ResourceModel\n view: ViewModel | undefined\n display: TimelineDisplayModel\n row: ListDisplayRow\n days: string[]\n movable: boolean\n dragged: () => boolean\n}\n\n/**\n * A record of a timeline: its title, and its bar over the days it is on, an event chip as wide as those days, cut\n * square where it goes on before or after them. The bar is the link to the record, and is picked up to move it.\n */\nexport const TimelineRow = ({ model, view, display, row, days, movable, dragged }: RowProps) => {\n const bar = barOf(row.record, display, model, days)\n return (\n <div className={cn(timelineGrid, 'relative border-b border-border last:border-b-0')}>\n {/* The bar's link says the title to assistive technology */}\n <span aria-hidden className=\"truncate px-2 pt-1 text-body sm:py-1.5\">\n {eventTitle(model, view, display, row)}\n </span>\n <div className=\"relative h-7\">\n {bar && (\n <div className=\"absolute top-1/2 -translate-y-1/2\" style={{ left: share(bar.first, days.length), width: share(bar.last - bar.first + 1, days.length) }}>\n <CalendarEvent\n model={model}\n view={view}\n display={display}\n row={row}\n day={bar.start}\n movable={movable}\n dragged={dragged}\n className={cn(bar.before && 'rounded-l-none border-l-0', bar.after && 'rounded-r-none border-r-0')}\n />\n </div>\n )}\n </div>\n </div>\n )\n}\n","import { DndContext, DragOverlay, KeyboardSensor, MouseSensor, TouchSensor, useSensor, useSensors, type Announcements, type DragEndEvent, type DragMoveEvent, type DragStartEvent, type KeyboardCoordinateGetter, type Modifier } from '@dnd-kit/core'\nimport { useRef, useState } from 'react'\nimport type { AppAddress, ResourceModel, TimelineView, ViewModel } from '@protobase/schema'\nimport { formatDate } from '../../format/date'\nimport { dayIn, viewerZone } from '../../format/zone'\nimport { humanize } from '../../live/naming'\nimport { Skeleton } from '../../primitives/skeleton'\nimport { ErrorBanner } from '../error-banner'\nimport { usePermissions } from '../meta-gate'\nimport { can, rowAllows } from '../permissions'\nimport { addDays, inStartOrder, recordDays } from './calendar-range'\nimport { EventChip, eventTitle } from './calendar-event'\nimport type { ListDisplayRow } from './list-displays'\nimport { PeriodControls } from './period-controls'\nimport { scaledTimeline, stepTimeline, timelineDays, timelineHeading, timelineLanes, timelineRange, timelineTicks, timelineView, type TimelineDisplayModel } from './timeline-range'\nimport { TimelineRow } from './timeline-row'\nimport { TimelineLines, TimelineScale } from './timeline-scale'\nimport { calendarLimit, useCalendarRows } from './use-calendar-rows'\nimport { movedRows, useCalendarMove } from './use-calendar-move'\nimport { text } from './messages'\n\ntype TimelineProps = {\n model: ResourceModel\n view: ViewModel | undefined\n display: TimelineDisplayModel\n /** The fields the bars and lanes show, which the records' relations are labelled for. */\n fields: string[]\n /** The list's filter, its search included, as the list API takes it. */\n filter: string\n /** The period the address names; the month of today when it names none. */\n at?: TimelineView\n /** The address that shows the timeline at a period, for a timeline whose period is in the address; else it keeps its own. */\n linkTo?: (view: TimelineView) => AppAddress\n /** The time that is today, now unless a test fixes it. */\n now?: number\n}\n\nconst scales = (): Array<{ scale: TimelineView['scale']; label: string }> => [\n { scale: 'week', label: text('week') },\n { scale: 'month', label: text('month') },\n { scale: 'quarter', label: text('quarter') },\n]\n\n// What a bar being moved is: the record, and the day it starts on\ntype Picked = { row: ListDisplayRow; day: string }\n\n/**\n * The list's records as bars over the days of a week, a month or a quarter, in lanes by the display's `group`, loaded\n * for those days alone through the list API as a calendar's are; a bar dragged along its row, or moved with the\n * keyboard, saves the record with its dates moved by the same days.\n */\nexport const TimelineDisplay = ({ model, view, display, fields, filter, at, linkTo, now = Date.now() }: TimelineProps) => {\n const [local, setLocal] = useState<TimelineView | undefined>()\n const shown = timelineView(linkTo ? at : local, now)\n const days = timelineDays(shown)\n const ticks = timelineTicks(shown)\n const list = useCalendarRows({ model, display, range: timelineRange(shown), fields, filter })\n const { moves, move } = useCalendarMove(model, display)\n const lanes = timelineLanes(inStartOrder(movedRows(list.rows, moves), display), model, view, display)\n const permissions = usePermissions(model.name)\n const movable = can(permissions, 'update') && [display.start, display.end].every((name) => name === undefined || !model.fields[name]?.readOnly)\n const [active, setActive] = useState<Picked | undefined>()\n // The click that ends a drag with a mouse lands on the bar's link, which must not open the record\n const dragged = useRef(false)\n // How many days the bar being moved has gone, for what is announced\n const shift = useRef(0)\n const track = useRef<HTMLDivElement>(null)\n const dayWidth = () => (track.current?.getBoundingClientRect().width ?? 0) / days.length\n const daysAcross = (x: number) => {\n const width = dayWidth()\n return width > 0 ? Math.round(x / width) : 0\n }\n // A bar moves along its row alone, a whole day at a time\n const snap: Modifier = ({ transform }) => ({ ...transform, x: daysAcross(transform.x) * dayWidth(), y: 0 })\n const dayKeys: KeyboardCoordinateGetter = (event, { currentCoordinates }) => {\n const step = event.code === 'ArrowLeft' ? -1 : event.code === 'ArrowRight' ? 1 : 0\n if (step === 0) return undefined\n event.preventDefault()\n return { x: currentCoordinates.x + step * dayWidth(), y: currentCoordinates.y }\n }\n const sensors = useSensors(\n useSensor(MouseSensor, { activationConstraint: { distance: 4 } }),\n useSensor(TouchSensor, { activationConstraint: { delay: 250, tolerance: 5 } }),\n // Enter opens the bar's record, so only Space picks a bar up\n useSensor(KeyboardSensor, { keyboardCodes: { start: ['Space'], cancel: ['Escape'], end: ['Space', 'Enter'] }, coordinateGetter: dayKeys }),\n )\n\n const today = dayIn(now, viewerZone())\n const title = (picked: Picked) => eventTitle(model, view, display, picked.row)\n const startText = (picked: Picked) => formatDate(Date.parse(`${addDays(picked.day, shift.current)}T00:00:00Z`))\n const announcements: Announcements = {\n onDragStart: ({ active: picked }) => text('pickedUp', { title: title(picked.data.current as Picked) }),\n onDragMove: ({ active: picked }) => text('startsOn', { title: title(picked.data.current as Picked), day: startText(picked.data.current as Picked) }),\n onDragOver: () => undefined,\n onDragEnd: ({ active: picked }) => (shift.current === 0 ? text('putBack', { title: title(picked.data.current as Picked) }) : text('wasMovedTo', { title: title(picked.data.current as Picked), to: startText(picked.data.current as Picked) })),\n onDragCancel: ({ active: picked }) => text('cancelled', { title: title(picked.data.current as Picked) }),\n }\n const release = () => {\n setActive(undefined)\n setTimeout(() => (dragged.current = false))\n }\n const start = ({ active: picked }: DragStartEvent) => {\n dragged.current = true\n shift.current = 0\n setActive(picked.data.current as Picked)\n }\n const moving = ({ delta }: DragMoveEvent) => (shift.current = daysAcross(delta.x))\n const end = ({ active: picked, delta }: DragEndEvent) => {\n release()\n shift.current = daysAcross(delta.x)\n const { row } = picked.data.current as Picked\n const span = recordDays(row.record, display, model)\n if (span && shift.current !== 0) move(row, span.first, addDays(span.first, shift.current))\n }\n\n const groupLabel = display.group === undefined ? (view?.names?.plural ?? humanize(model.name)) : (view?.fields[display.group]?.label ?? humanize(display.group))\n const empty = !list.loading && !list.error && list.rows.length === 0\n return (\n <div className=\"flex min-w-0 flex-1 flex-col gap-3\">\n <PeriodControls\n heading={timelineHeading(shown)}\n unit={shown.scale}\n previous={stepTimeline(shown, -1)}\n today={timelineView({ scale: shown.scale, day: today }, now)}\n next={stepTimeline(shown, 1)}\n scales={scales().map(({ scale, label }) => ({ view: scaledTimeline(shown, scale, now), label, current: shown.scale === scale }))}\n scalesLabel={text('timelineScale')}\n linkTo={linkTo}\n onView={setLocal}\n />\n {list.error && <ErrorBanner title={text('couldNotLoadRows')} error={list.error} />}\n {list.capped && (\n <p className=\"text-xs text-muted-foreground\">\n {text('capped', { limit: calendarLimit, unit: shown.scale })}\n </p>\n )}\n <DndContext\n sensors={sensors}\n modifiers={[snap]}\n onDragStart={start}\n onDragMove={moving}\n onDragEnd={end}\n onDragCancel={release}\n accessibility={{\n announcements,\n screenReaderInstructions: {\n draggable: text('timelineInstructions'),\n },\n }}\n >\n {/* As tall as all its rows, scrolling with the page */}\n <div className=\"overflow-hidden rounded-lg border border-border\">\n <TimelineScale ticks={ticks} days={days} today={today} label={groupLabel} trackRef={track} />\n <div className=\"relative\">\n <TimelineLines ticks={ticks} days={days} today={today} />\n {list.loading && (\n <div className=\"relative flex flex-col gap-2 p-2\">\n <Skeleton className=\"h-4\" />\n <Skeleton className=\"h-4\" />\n </div>\n )}\n {empty && <p className=\"relative px-2 py-3 text-xs text-muted-foreground\">{text('nothingIn', { unit: shown.scale })}</p>}\n {!list.loading &&\n lanes.map((lane) => (\n <section key={lane.key} aria-label={lane.label} className=\"relative border-b border-border last:border-b-0\">\n {lane.label !== undefined && (\n <h3 className=\"flex items-center gap-1.5 border-b border-border bg-surface px-2 py-1 text-xs font-medium\">\n {lane.label}\n <span className=\"tabular-nums text-muted-foreground\">{lane.rows.length}</span>\n </h3>\n )}\n {lane.rows.map((row) => (\n <TimelineRow key={row.key} model={model} view={view} display={display} row={row} days={days} movable={movable && rowAllows(row.record, 'update')} dragged={() => dragged.current} />\n ))}\n </section>\n ))}\n </div>\n </div>\n <DragOverlay>{active && <EventChip model={model} view={view} display={display} row={active.row} day={active.day} />}</DragOverlay>\n </DndContext>\n </div>\n )\n}\n"],"mappings":"q9BAcM4C,EAAQ,MACRC,EAAM,GAAgB,KAAK,MAAM,GAAGC,EAAI,WAAW,EAEnDC,GAAa,EAAa,EAAO,IAA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U,EAAK,GAUV,CACV,CACA,CACF,CAAA,CAAA,CACL,CAAA,GAAA,EAAAC,EAAA,IAAA,CAACjE,EAAD,CAAA,SAAcuF,IAAU,EAAAtB,EAAA,IAAA,CAAC7D,GAAD,CAAkB,QAAa,OAAe,UAAS,IAAKmF,EAAO,IAAK,IAAKA,EAAO,GAAM,CAAA,CAAe,CAAA,CACvH,GACT,GAET","debugId":"dbd0d5ae-7024-4d5a-b593-8645f506f545"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trash-
|
|
1
|
+
{"version":3,"file":"trash-BgljKjXT.js","names":["n","a","t","createLucideIcon","__iconData","Trash"],"sources":["../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/trash.mjs"],"sourcesContent":["/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"trash\",\n size: 24,\n node: [\n [\"path\", { d: \"M10 11v6\", key: \"nco0om\" }],\n [\"path\", { d: \"M14 11v6\", key: \"outv1u\" }],\n [\"path\", { d: \"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6\", key: \"miytrc\" }],\n [\"path\", { d: \"M3 6h18\", key: \"d0wm0j\" }],\n [\"path\", { d: \"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\", key: \"e791ji\" }]\n ],\n aliases: [\"trash-2\"]\n};\n__iconData.node;\nconst Trash = createLucideIcon(__iconData);\n\nexport { __iconData, Trash as default };\n//# sourceMappingURL=trash.mjs.map\n"],"ignoreList":[0],"mappings":"8fASA,IAAMI,EAAa,CACjB,KAAM,QACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,2CAA4C,IAAK,QAAS,CAAC,EACzE,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,yCAA0C,IAAK,QAAS,CAAC,CACzE,EACA,QAAS,CAAC,SAAS,CACrB,EACAA,EAAW,KACX,IAAMC,EAAQF,EAAiBC,CAAU","debugId":"609632a3-5d31-4217-bdc1-a25d9268e7cf"}
|
package/dist/shell-source-maps/assets/{update-set-BYNQUWVp.js.map → update-set-SMllxKkh.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-set-BYNQUWVp.js","names":["evaluate","n","a","t","checkFilter","hrefField","parseFilter","lift","functions","matchesSearch","evaluateFilter$1","needsDatabase","name","implementations","model","record","text","values","value","pattern","now","evaluateFilter","checked","options","input","o","kind","extra","inputs","filterTypes","inputField","entry","option","answersModel","entries","checkedWhen","source","index","parsed","error","checklistErrors","actionInputErrors","errors","other","when","shownInputs","shown","seen","visible","answers","updateSetErrors","set","field","candidate","updateValues"],"sources":["../../../../schema/src/filter/evaluate.ts","../../../../schema/src/action-inputs.ts","../../../../schema/src/update-set.ts"],"sourcesContent":["import { evaluateFilter as evaluate, type FunctionSpec } from 'aip-parsers/filter'\nimport type { CheckedFilter, ResourceModel } from '../model'\nimport { matchesSearch } from '../search-match'\nimport { lift } from './lift'\nimport { functions } from './profile'\n\n/** How `evaluateFilter` evaluates. */\nexport type EvaluateOptions = {\n /** Clock for `now()`; defaults to the current time. */\n now?: () => Date\n /**\n * The resource the record is of: `search(\"text\")` then looks in its search fields as the API's search does, instead of\n * throwing `Not implemented`.\n */\n search?: ResourceModel\n}\n\nconst needsDatabase = (name: string) => (): never => {\n throw new Error(`Not implemented: ${name}() needs the database (the resource's search fields, trigram matching), so it cannot be evaluated against a record`)\n}\n\n// `in` and `isNull` are expanded before evaluation. `regex` uses JavaScript regular expressions,\n// which differ from Postgres in corners such as lookbehind and POSIX classes.\nconst implementations = (now: () => Date, record: unknown, model: ResourceModel | undefined): Record<string, FunctionSpec> => ({\n ...functions,\n search: { ...functions.search!, evaluate: model ? (text) => matchesSearch(model, record as Record<string, unknown>, text as string) : needsDatabase('search') },\n similar: { ...functions.similar!, evaluate: needsDatabase('similar') },\n regex: {\n ...functions.regex!,\n evaluate: (values, pattern) => (values as unknown[]).some((value) => typeof value === 'string' && new RegExp(pattern as string).test(value)),\n },\n now: { ...functions.now!, evaluate: now },\n})\n\n/**\n * Evaluates a checked filter against a plain record keyed by field name, for rules such as access filters on create, or\n * whether a new record fits a saved search. Throws `Not implemented` for `similar`, and for `search` without the\n * `search` option.\n */\nexport const evaluateFilter = (checked: CheckedFilter, record: unknown, options: EvaluateOptions = {}) =>\n evaluate(lift(checked, { expand: true }), record, { functions: implementations(options.now ?? (() => new Date()), record, options.search) })\n","import { checkFilter, evaluateFilter, parseFilter } from './filter'\nimport type { ActionInputKind, ActionInputModel, CheckedFilter, FieldModel, FieldType, JsonValue, ResourceModel } from './model'\n\n/** @inline */\ntype InputOptions<D> = {\n label: string\n help?: string\n /** It may be left empty. */\n optional?: boolean\n /** An AIP-160 condition over the inputs before it, such as `plan = 'pro'`; it shows only while it holds. */\n when?: string\n /** What it holds when the dialog opens. */\n default?: D\n}\n\nconst input = (name: string, kind: ActionInputKind, o: InputOptions<JsonValue>, extra: Partial<ActionInputModel> = {}): ActionInputModel => ({\n name,\n kind,\n label: o.label,\n required: kind !== 'boolean' && !o.optional,\n ...(o.help !== undefined && { help: o.help }),\n ...(o.when !== undefined && { when: o.when }),\n ...(o.default !== undefined && { default: o.default }),\n ...extra,\n})\n\n/** The builders `inputs: (i) => [...]` gets, one per kind of answer. */\nexport const inputs = {\n /** A line of text, or several with `multiline`; `max` is the most characters it may have. */\n text: (name: string, o: InputOptions<string> & { multiline?: boolean; max?: number }) =>\n input(name, 'text', o, { ...(o.multiline && { multiline: true }), ...(o.max !== undefined && { max: o.max }) }),\n /** A whole number; the handler gets a number. */\n integer: (name: string, o: InputOptions<number>) => input(name, 'integer', o),\n /** A number with decimals; the handler gets its text, as the API gives decimals, so no digit is lost. */\n decimal: (name: string, o: InputOptions<string>) => input(name, 'decimal', o),\n /** A switch; the handler gets `true` or `false`, so it is never required. */\n boolean: (name: string, o: { label: string; help?: string; when?: string; default?: boolean }) => input(name, 'boolean', o),\n /**\n * A secret, such as an API key, in a masked field that browsers and password managers do not offer to save or fill.\n * It takes no default and no `when` reads it; the handler gets its text, and no update writes it.\n */\n secret: (name: string, o: { label: string; help?: string; optional?: boolean; when?: string }) => input(name, 'secret', o),\n /** A date as `YYYY-MM-DD`. */\n date: (name: string, o: InputOptions<string>) => input(name, 'date', o),\n /** One of `options`, each a value with its label, or a record of `resource`, whose key the handler gets. */\n choice: (name: string, o: InputOptions<string> & ({ options: Array<{ value: string; label: string }> } | { resource: string })) =>\n input(name, 'choice', o, 'options' in o ? { options: o.options.map(({ value, label }) => ({ value, label })) } : { resource: o.resource }),\n /**\n * Boxes the person ticks, every one, before the action runs: `items`, the same for every record, or `from`, the JSON\n * field that holds each record's own as a list of texts. For several records the dialog shows each box once; each\n * record gets the boxes it holds, ticked, as a list of texts.\n */\n checklist: (name: string, o: { label: string; help?: string; when?: string } & ({ items: string[] } | { from: string })) =>\n input(name, 'checklist', o, { ...('items' in o && { items: [...o.items] }), ...('from' in o && { from: o.from }) }),\n /**\n * What a project component edits, registered in `defineUi({ components })` under `component`: it gets the answer as\n * `value`, `onChange`, whether the answer is refused (`invalid`) and `props`.\n */\n custom: (name: string, o: InputOptions<JsonValue> & { component: string; props?: Record<string, JsonValue> }) =>\n input(name, 'custom', o, { component: o.component, ...(o.props !== undefined && { props: o.props }) }),\n}\n\nconst filterTypes: Record<ActionInputKind, FieldType> = { text: 'text', integer: 'integer', decimal: 'decimal', boolean: 'boolean', date: 'date', choice: 'text', secret: 'text', checklist: 'json', custom: 'json' }\n\nconst inputField = (entry: ActionInputModel): FieldModel => ({\n name: entry.name,\n column: entry.name,\n type: entry.options ? 'enum' : filterTypes[entry.kind],\n nullable: true,\n readOnly: false,\n filterable: entry.kind !== 'custom' && entry.kind !== 'checklist' && entry.kind !== 'secret',\n sortable: false,\n aliases: [],\n ...(entry.options && { enumValues: entry.options.map((option) => option.value) }),\n})\n\n// The inputs as the fields of a resource, so `when` is checked and evaluated as a filter over a record of answers.\nconst answersModel = (entries: ActionInputModel[]): ResourceModel => ({\n name: 'inputs',\n table: { name: 'inputs' },\n fields: Object.fromEntries(entries.map((entry) => [entry.name, inputField(entry)])),\n primaryKey: [],\n})\n\nconst checkedWhen = (entries: ActionInputModel[], index: number): CheckedFilter | string | undefined => {\n const source = entries[index]!.when\n if (source === undefined) return undefined\n const parsed = parseFilter(source)\n if (!parsed.ok) return parsed.errors.map((error) => error.message).join('; ')\n if (!parsed.ast) return 'it is empty'\n const checked = checkFilter(answersModel(entries.slice(0, index)), parsed.ast)\n return checked.ok ? checked.filter : checked.errors.map((error) => error.message).join('; ')\n}\n\n// A checklist has its boxes in `items`, at least one, or in a field of the record, never both.\nconst checklistErrors = (entry: ActionInputModel) => {\n if (entry.kind !== 'checklist') return []\n if ((entry.items === undefined) === (entry.from === undefined)) return [`input \"${entry.name}\": a checklist takes either \"items\" or \"from\"`]\n if (entry.items && entry.items.length === 0) return [`input \"${entry.name}\": a checklist needs at least one item`]\n return []\n}\n\n/** What is wrong with an action's inputs: a name given twice, a default that is no option or on a secret, a `when` over no input before it, a checklist without boxes. */\nexport const actionInputErrors = (entries: ActionInputModel[]) =>\n entries.flatMap((entry, index) => {\n const errors: string[] = []\n if (entries.findIndex((other) => other.name === entry.name) !== index) errors.push(`input \"${entry.name}\" is declared twice`)\n if (entry.kind === 'secret' && entry.default !== undefined) errors.push(`input \"${entry.name}\": a secret takes no default`)\n // A secret's default is refused above without naming it, so its value never lands in an error.\n if (entry.kind !== 'secret' && entry.options && entry.default !== undefined && !entry.options.some((option) => option.value === entry.default)) errors.push(`input \"${entry.name}\": default \"${String(entry.default)}\" is not one of its options`)\n const when = checkedWhen(entries, index)\n if (typeof when === 'string') errors.push(`input \"${entry.name}\": \"when\" is not a valid condition over the inputs before it: ${when}`)\n return [...errors, ...checklistErrors(entry)]\n })\n\n/**\n * The names of the inputs that show for these answers, keyed by input name (null when empty): each input whose `when`\n * holds, reading the answer of an input that does not show as null.\n */\nexport const shownInputs = (entries: ActionInputModel[], answers: Record<string, unknown>) => {\n const shown = new Set<string>()\n const seen: Record<string, unknown> = {}\n entries.forEach((entry, index) => {\n const when = checkedWhen(entries, index)\n if (typeof when === 'string') throw new Error(`Input \"${entry.name}\": ${when}`)\n const visible = when === undefined || evaluateFilter(when, seen) === true\n if (visible) shown.add(entry.name)\n seen[entry.name] = visible ? (answers[entry.name] ?? null) : null\n })\n return shown\n}\n","import { hrefField } from './address-template'\nimport type { ActionInputModel } from './model'\n\n/**\n * Why an update's `set` cannot be used: a value that is exactly `{{name}}` must name one of the inputs the action asks\n * for, and never a secret, which the update would store and send back.\n */\nexport const updateSetErrors = (set: Record<string, unknown>, inputs: ActionInputModel[] = []) =>\n Object.entries(set).flatMap(([field, value]) => {\n const input = typeof value === 'string' ? hrefField(value) : undefined\n if (input === undefined) return []\n const entry = inputs.find((candidate) => candidate.name === input)\n if (!entry) return [`set \"${field}\" names input \"${input}\", which it does not ask for`]\n return entry.kind === 'secret' ? [`set \"${field}\" names secret input \"${input}\", which an update never writes; take it in an action's handler`] : []\n })\n\n/**\n * The fields an update writes: a literal as it is, a value that is exactly `{{input}}` as that input's answer. A field whose\n * input was hidden has no answer in `values` and is left out, so it keeps what it holds.\n */\nexport const updateValues = (set: Record<string, unknown>, values: Record<string, unknown>) =>\n Object.fromEntries(\n Object.entries(set).flatMap(([field, value]): Array<[string, unknown]> => {\n const input = typeof value === 'string' ? hrefField(value) : undefined\n if (input === undefined) return [[field, value]]\n return Object.hasOwn(values, input) ? [[field, values[input]]] : []\n }),\n )\n"],"mappings":"+kBAiBA,IAAMW,EAAiB,OAA8B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AAOlC,KAAqC,CACxE,IAAMM,EAAQ,OAAON,GAAU,SAAWb,EAAUa,CAAK,EAAI,IAAA,GAE7D,OADIM,IAAU,IAAA,GAAkB,CAAC,CAAC4B,EAAOlC,CAAK,CAAC,EACxC,OAAO,OAAOD,EAAQO,CAAK,EAAI,CAAC,CAAC4B,EAAOnC,EAAOO,EAAM,CAAC,EAAI,CAAC,CACpE,CAAC,CACH","debugId":"58350516-569f-4a31-8d43-431492dab249"}
|
|
1
|
+
{"version":3,"file":"update-set-SMllxKkh.js","names":["evaluate","n","a","t","checkFilter","hrefField","parseFilter","lift","functions","matchesSearch","evaluateFilter$1","needsDatabase","name","implementations","model","record","text","values","value","pattern","now","evaluateFilter","checked","options","input","o","kind","extra","inputs","filterTypes","inputField","entry","option","answersModel","entries","checkedWhen","source","index","parsed","error","checklistErrors","actionInputErrors","errors","other","when","shownInputs","shown","seen","visible","answers","updateSetErrors","set","field","candidate","updateValues"],"sources":["../../../../schema/src/filter/evaluate.ts","../../../../schema/src/action-inputs.ts","../../../../schema/src/update-set.ts"],"sourcesContent":["import { evaluateFilter as evaluate, type FunctionSpec } from 'aip-parsers/filter'\nimport type { CheckedFilter, ResourceModel } from '../model'\nimport { matchesSearch } from '../search-match'\nimport { lift } from './lift'\nimport { functions } from './profile'\n\n/** How `evaluateFilter` evaluates. */\nexport type EvaluateOptions = {\n /** Clock for `now()`; defaults to the current time. */\n now?: () => Date\n /**\n * The resource the record is of: `search(\"text\")` then looks in its search fields as the API's search does, instead of\n * throwing `Not implemented`.\n */\n search?: ResourceModel\n}\n\nconst needsDatabase = (name: string) => (): never => {\n throw new Error(`Not implemented: ${name}() needs the database (the resource's search fields, trigram matching), so it cannot be evaluated against a record`)\n}\n\n// `in` and `isNull` are expanded before evaluation. `regex` uses JavaScript regular expressions,\n// which differ from Postgres in corners such as lookbehind and POSIX classes.\nconst implementations = (now: () => Date, record: unknown, model: ResourceModel | undefined): Record<string, FunctionSpec> => ({\n ...functions,\n search: { ...functions.search!, evaluate: model ? (text) => matchesSearch(model, record as Record<string, unknown>, text as string) : needsDatabase('search') },\n similar: { ...functions.similar!, evaluate: needsDatabase('similar') },\n regex: {\n ...functions.regex!,\n evaluate: (values, pattern) => (values as unknown[]).some((value) => typeof value === 'string' && new RegExp(pattern as string).test(value)),\n },\n now: { ...functions.now!, evaluate: now },\n})\n\n/**\n * Evaluates a checked filter against a plain record keyed by field name, for rules such as access filters on create, or\n * whether a new record fits a saved search. Throws `Not implemented` for `similar`, and for `search` without the\n * `search` option.\n */\nexport const evaluateFilter = (checked: CheckedFilter, record: unknown, options: EvaluateOptions = {}) =>\n evaluate(lift(checked, { expand: true }), record, { functions: implementations(options.now ?? (() => new Date()), record, options.search) })\n","import { checkFilter, evaluateFilter, parseFilter } from './filter'\nimport type { ActionInputKind, ActionInputModel, CheckedFilter, FieldModel, FieldType, JsonValue, ResourceModel } from './model'\n\n/** @inline */\ntype InputOptions<D> = {\n label: string\n help?: string\n /** It may be left empty. */\n optional?: boolean\n /** An AIP-160 condition over the inputs before it, such as `plan = 'pro'`; it shows only while it holds. */\n when?: string\n /** What it holds when the dialog opens. */\n default?: D\n}\n\nconst input = (name: string, kind: ActionInputKind, o: InputOptions<JsonValue>, extra: Partial<ActionInputModel> = {}): ActionInputModel => ({\n name,\n kind,\n label: o.label,\n required: kind !== 'boolean' && !o.optional,\n ...(o.help !== undefined && { help: o.help }),\n ...(o.when !== undefined && { when: o.when }),\n ...(o.default !== undefined && { default: o.default }),\n ...extra,\n})\n\n/** The builders `inputs: (i) => [...]` gets, one per kind of answer. */\nexport const inputs = {\n /** A line of text, or several with `multiline`; `max` is the most characters it may have. */\n text: (name: string, o: InputOptions<string> & { multiline?: boolean; max?: number }) =>\n input(name, 'text', o, { ...(o.multiline && { multiline: true }), ...(o.max !== undefined && { max: o.max }) }),\n /** A whole number; the handler gets a number. */\n integer: (name: string, o: InputOptions<number>) => input(name, 'integer', o),\n /** A number with decimals; the handler gets its text, as the API gives decimals, so no digit is lost. */\n decimal: (name: string, o: InputOptions<string>) => input(name, 'decimal', o),\n /** A switch; the handler gets `true` or `false`, so it is never required. */\n boolean: (name: string, o: { label: string; help?: string; when?: string; default?: boolean }) => input(name, 'boolean', o),\n /**\n * A secret, such as an API key, in a masked field that browsers and password managers do not offer to save or fill.\n * It takes no default and no `when` reads it; the handler gets its text, and no update writes it.\n */\n secret: (name: string, o: { label: string; help?: string; optional?: boolean; when?: string }) => input(name, 'secret', o),\n /** A date as `YYYY-MM-DD`. */\n date: (name: string, o: InputOptions<string>) => input(name, 'date', o),\n /** One of `options`, each a value with its label, or a record of `resource`, whose key the handler gets. */\n choice: (name: string, o: InputOptions<string> & ({ options: Array<{ value: string; label: string }> } | { resource: string })) =>\n input(name, 'choice', o, 'options' in o ? { options: o.options.map(({ value, label }) => ({ value, label })) } : { resource: o.resource }),\n /**\n * Boxes the person ticks, every one, before the action runs: `items`, the same for every record, or `from`, the JSON\n * field that holds each record's own as a list of texts. For several records the dialog shows each box once; each\n * record gets the boxes it holds, ticked, as a list of texts.\n */\n checklist: (name: string, o: { label: string; help?: string; when?: string } & ({ items: string[] } | { from: string })) =>\n input(name, 'checklist', o, { ...('items' in o && { items: [...o.items] }), ...('from' in o && { from: o.from }) }),\n /**\n * What a project component edits, registered in `defineUi({ components })` under `component`: it gets the answer as\n * `value`, `onChange`, whether the answer is refused (`invalid`) and `props`.\n */\n custom: (name: string, o: InputOptions<JsonValue> & { component: string; props?: Record<string, JsonValue> }) =>\n input(name, 'custom', o, { component: o.component, ...(o.props !== undefined && { props: o.props }) }),\n}\n\nconst filterTypes: Record<ActionInputKind, FieldType> = { text: 'text', integer: 'integer', decimal: 'decimal', boolean: 'boolean', date: 'date', choice: 'text', secret: 'text', checklist: 'json', custom: 'json' }\n\nconst inputField = (entry: ActionInputModel): FieldModel => ({\n name: entry.name,\n column: entry.name,\n type: entry.options ? 'enum' : filterTypes[entry.kind],\n nullable: true,\n readOnly: false,\n filterable: entry.kind !== 'custom' && entry.kind !== 'checklist' && entry.kind !== 'secret',\n sortable: false,\n aliases: [],\n ...(entry.options && { enumValues: entry.options.map((option) => option.value) }),\n})\n\n// The inputs as the fields of a resource, so `when` is checked and evaluated as a filter over a record of answers.\nconst answersModel = (entries: ActionInputModel[]): ResourceModel => ({\n name: 'inputs',\n table: { name: 'inputs' },\n fields: Object.fromEntries(entries.map((entry) => [entry.name, inputField(entry)])),\n primaryKey: [],\n})\n\nconst checkedWhen = (entries: ActionInputModel[], index: number): CheckedFilter | string | undefined => {\n const source = entries[index]!.when\n if (source === undefined) return undefined\n const parsed = parseFilter(source)\n if (!parsed.ok) return parsed.errors.map((error) => error.message).join('; ')\n if (!parsed.ast) return 'it is empty'\n const checked = checkFilter(answersModel(entries.slice(0, index)), parsed.ast)\n return checked.ok ? checked.filter : checked.errors.map((error) => error.message).join('; ')\n}\n\n// A checklist has its boxes in `items`, at least one, or in a field of the record, never both.\nconst checklistErrors = (entry: ActionInputModel) => {\n if (entry.kind !== 'checklist') return []\n if ((entry.items === undefined) === (entry.from === undefined)) return [`input \"${entry.name}\": a checklist takes either \"items\" or \"from\"`]\n if (entry.items && entry.items.length === 0) return [`input \"${entry.name}\": a checklist needs at least one item`]\n return []\n}\n\n/** What is wrong with an action's inputs: a name given twice, a default that is no option or on a secret, a `when` over no input before it, a checklist without boxes. */\nexport const actionInputErrors = (entries: ActionInputModel[]) =>\n entries.flatMap((entry, index) => {\n const errors: string[] = []\n if (entries.findIndex((other) => other.name === entry.name) !== index) errors.push(`input \"${entry.name}\" is declared twice`)\n if (entry.kind === 'secret' && entry.default !== undefined) errors.push(`input \"${entry.name}\": a secret takes no default`)\n // A secret's default is refused above without naming it, so its value never lands in an error.\n if (entry.kind !== 'secret' && entry.options && entry.default !== undefined && !entry.options.some((option) => option.value === entry.default)) errors.push(`input \"${entry.name}\": default \"${String(entry.default)}\" is not one of its options`)\n const when = checkedWhen(entries, index)\n if (typeof when === 'string') errors.push(`input \"${entry.name}\": \"when\" is not a valid condition over the inputs before it: ${when}`)\n return [...errors, ...checklistErrors(entry)]\n })\n\n/**\n * The names of the inputs that show for these answers, keyed by input name (null when empty): each input whose `when`\n * holds, reading the answer of an input that does not show as null.\n */\nexport const shownInputs = (entries: ActionInputModel[], answers: Record<string, unknown>) => {\n const shown = new Set<string>()\n const seen: Record<string, unknown> = {}\n entries.forEach((entry, index) => {\n const when = checkedWhen(entries, index)\n if (typeof when === 'string') throw new Error(`Input \"${entry.name}\": ${when}`)\n const visible = when === undefined || evaluateFilter(when, seen) === true\n if (visible) shown.add(entry.name)\n seen[entry.name] = visible ? (answers[entry.name] ?? null) : null\n })\n return shown\n}\n","import { hrefField } from './address-template'\nimport type { ActionInputModel } from './model'\n\n/**\n * Why an update's `set` cannot be used: a value that is exactly `{{name}}` must name one of the inputs the action asks\n * for, and never a secret, which the update would store and send back.\n */\nexport const updateSetErrors = (set: Record<string, unknown>, inputs: ActionInputModel[] = []) =>\n Object.entries(set).flatMap(([field, value]) => {\n const input = typeof value === 'string' ? hrefField(value) : undefined\n if (input === undefined) return []\n const entry = inputs.find((candidate) => candidate.name === input)\n if (!entry) return [`set \"${field}\" names input \"${input}\", which it does not ask for`]\n return entry.kind === 'secret' ? [`set \"${field}\" names secret input \"${input}\", which an update never writes; take it in an action's handler`] : []\n })\n\n/**\n * The fields an update writes: a literal as it is, a value that is exactly `{{input}}` as that input's answer. A field whose\n * input was hidden has no answer in `values` and is left out, so it keeps what it holds.\n */\nexport const updateValues = (set: Record<string, unknown>, values: Record<string, unknown>) =>\n Object.fromEntries(\n Object.entries(set).flatMap(([field, value]): Array<[string, unknown]> => {\n const input = typeof value === 'string' ? hrefField(value) : undefined\n if (input === undefined) return [[field, value]]\n return Object.hasOwn(values, input) ? [[field, values[input]]] : []\n }),\n )\n"],"mappings":"+kBAiBA,IAAMW,EAAiB,OAA8B,CACnD,MAAU,MAAM,oBAAoBC,EAAK,mHAAmH,CAC9J,EAIMC,GAAmB,EAAiB,EAAiB,KAAoE,CAC7H,GAAG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IAAA,GAAkB,CAAC,CAAC4B,EAAOlC,CAAK,CAAC,EACxC,OAAO,OAAOD,EAAQO,CAAK,EAAI,CAAC,CAAC4B,EAAOnC,EAAOO,EAAM,CAAC,EAAI,CAAC,CACpE,CAAC,CACH","debugId":"12325971-2a48-4684-9c85-1e040f860c47"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-calendar-move-BytgRG51.js","names":["Fragment","useState","n","a","t","__toESM","require_react","require_jsx_runtime","where","cn","formatDate","printFilter","AppLink","ChevronRight","useToast","ChevronLeft","dayIn","viewerZone","buttonClass","displayValue","zoneOffset","refusalReason","useClient","formatTime","useAdminMeta","instantAt","recordTitleField","startOfDayIn","text","useRefreshResource","recordKey","segmentedClass","useMutation","useLiveRows","useSeedRecord","useDraggable","useDisplayRows","import_react","import_jsx_runtime","dayMs","dayOf","ms","startOf","day","addDays","count","monday","monthOf","date","step","normalised","scale","calendarView","at","now","zone","todayView","stepView","view","gridDays","first","index","rangeOf","days","isTimestamp","model","display","rangeFilter","timestamp","instant","bound","within","range","ending","withRange","filter","instantOf","value","recordDays","start","record","end","eventDays","span","inStartOrder","rows","b","byDay","placed","row","movedPatch","to","from","moved","PeriodControls","control","linkTo","label","current","onView","square","heading","previous","today","next","scalesLabel","scales","dayPrefix","dayId","eventId","key","dayCoordinates","event","over","active","collisionRect","target","droppableRects","eventTitle","name","field","startTime","EventChip","seedRecord","time","className","CalendarEvent","props","movable","setNodeRef","element","setActivatorNodeRef","listeners","dragged","isDragging","useCalendarRows","fields","list","wanted","capped","movedRows","patches","moves","move","useCalendarMove","client","toast","refresh","setMoves","settle","mutation","etag","patch","error"],"sources":["../../../src/app/displays/calendar-range.ts","../../../src/app/displays/period-controls.tsx","../../../src/app/displays/calendar-dnd.ts","../../../src/app/displays/calendar-event.tsx","../../../src/app/displays/use-calendar-rows.ts","../../../src/app/displays/use-calendar-move.ts"],"sourcesContent":["import type { CalendarView, FilterValue, ListDisplayModel, ResourceModel } from '@protobase/schema'\nimport { printFilter, where } from '@protobase/schema'\nimport { dayIn, instantAt, startOfDayIn, viewerZone, zoneOffset } from '../../format/zone'\nimport type { ListDisplayRow } from './list-displays'\n\n// The days a calendar shows and the records on them, as `YYYY-MM-DD` days, weeks from Monday. A date is on its own day;\n// a timestamp, and today, on the viewer's day, in `zone`.\n\nexport type CalendarDisplayModel = Extract<ListDisplayModel, { kind: 'calendar' }>\n\n/** A display that places records on days by their `start` and `end`, with a `title` on each: a calendar, or a timeline. */\nexport type DatedDisplay = Pick<CalendarDisplayModel, 'start' | 'end' | 'title'>\n\n/** The days a calendar shows, as the half-open interval from the first day to the day after the last. */\nexport type CalendarRange = { from: string; to: string }\n\nconst dayMs = 86_400_000\n\nconst dayOf = (ms: number) => new Date(ms).toISOString().slice(0, 10)\nconst startOf = (day: string) => Date.parse(`${day}T00:00:00Z`)\n\n/** The day `count` days after `day`, or before it for a negative count. */\nexport const addDays = (day: string, count: number) => dayOf(startOf(day) + count * dayMs)\n\n/** The Monday on or before `day`. */\nexport const monday = (day: string) => addDays(day, -((new Date(startOf(day)).getUTCDay() + 6) % 7))\n\n/** The 1st of the month of `day`, or of the month `step` months on. */\nexport const monthOf = (day: string, step = 0) => {\n const date = new Date(startOf(day))\n return dayOf(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + step, 1))\n}\n\nconst normalised = ({ scale, day }: CalendarView): CalendarView => ({ scale, day: scale === 'month' ? monthOf(day) : monday(day) })\n\n/** The month or week a calendar shows: the address's, starting on the month's 1st or the week's Monday, else the month of `now`. */\nexport const calendarView = (at: CalendarView | undefined, now: number, zone = viewerZone()): CalendarView => normalised(at ?? { scale: 'month', day: dayIn(now, zone) })\n\n/** The month or week of `scale` that holds `now`. */\nexport const todayView = (scale: CalendarView['scale'], now: number, zone = viewerZone()): CalendarView => normalised({ scale, day: dayIn(now, zone) })\n\n/** The month or week before (-1) or after (1) `view`. */\nexport const stepView = (view: CalendarView, step: -1 | 1): CalendarView =>\n view.scale === 'month' ? { scale: 'month', day: monthOf(view.day, step) } : { scale: 'week', day: addDays(monday(view.day), 7 * step) }\n\n/** The days a calendar shows: whole weeks from the Monday on or before a month's 1st to the Sunday on or after its last day, or a week's seven. */\nexport const gridDays = (view: CalendarView): string[] => {\n const first = monday(view.scale === 'month' ? monthOf(view.day) : view.day)\n const last = view.scale === 'month' ? addDays(monday(addDays(monthOf(view.day, 1), -1)), 6) : addDays(first, 6)\n const count = (startOf(last) - startOf(first)) / dayMs + 1\n return Array.from({ length: count }, (_, index) => addDays(first, index))\n}\n\n/** The days `view` shows, as a range from its first day to the day after its last. */\nexport const rangeOf = (view: CalendarView): CalendarRange => {\n const days = gridDays(view)\n return { from: days[0]!, to: addDays(days.at(-1)!, 1) }\n}\n\nconst isTimestamp = (display: DatedDisplay, model: ResourceModel) => model.fields[display.start]?.type === 'timestamp'\n\n/**\n * The records on the days of `range`, as a list filter: those starting in it, and with an `end` those starting before\n * it and ending in or after its first day. A timestamp's `end` is the instant it is over, so one ending at midnight is\n * not on the day it starts. Each branch reads one indexed field.\n */\nexport const rangeFilter = (display: DatedDisplay, model: ResourceModel, range: CalendarRange, zone = viewerZone()) => {\n const timestamp = isTimestamp(display, model)\n const instant = (day: string) => new Date(startOfDayIn(day, zone)).toISOString().replace('.000Z', 'Z')\n const bound = (day: string): FilterValue => (timestamp ? { kind: 'timestamp', value: instant(day), span: { start: 0, end: 0 } } : { kind: 'string', value: day, span: { start: 0, end: 0 } })\n const within = where.and(where.gte(display.start, bound(range.from)), where.lt(display.start, bound(range.to)))\n if (display.end === undefined) return printFilter(within)\n const ending = timestamp ? where.gt(display.end, bound(range.from)) : where.gte(display.end, bound(range.from))\n return printFilter(where.or(within, where.and(where.lt(display.start, bound(range.from)), ending)))\n}\n\n/** The list's filter, its search included, narrowed to the calendar's days. */\nexport const withRange = (filter: string, range: string) => (filter === '' ? range : `(${filter}) AND (${range})`)\n\n// The instant a record's date or timestamp value stands for, or none for a missing or unreadable one\nconst instantOf = (value: unknown) => {\n if (typeof value !== 'string') return undefined\n const ms = Date.parse(/^\\d{4}-\\d{2}-\\d{2}$/.test(value) ? `${value}T00:00:00Z` : value)\n return Number.isNaN(ms) ? undefined : ms\n}\n\n/**\n * The first and last day a record is on: its start's day and its end's, where a timestamp `end` at midnight is over\n * before that day starts; its start day alone without an end or with one before its start, and none without a start.\n */\nexport const recordDays = (record: Record<string, unknown>, display: DatedDisplay, model: ResourceModel, zone = viewerZone()): { first: string; last: string } | undefined => {\n const start = instantOf(record[display.start])\n if (start === undefined) return undefined\n const timestamp = isTimestamp(display, model)\n const day = (ms: number) => (timestamp ? dayIn(ms, zone) : dayOf(ms))\n const first = day(start)\n const end = display.end === undefined ? undefined : instantOf(record[display.end])\n const ending = end === undefined ? first : day(timestamp ? end - 1 : end)\n return { first, last: ending < first ? first : ending }\n}\n\n/** The days of `days` a record is on, from its first through its last (`recordDays`). */\nexport const eventDays = (record: Record<string, unknown>, display: DatedDisplay, model: ResourceModel, days: string[], zone = viewerZone()): string[] => {\n const span = recordDays(record, display, model, zone)\n return span ? days.filter((day) => day >= span.first && day <= span.last) : []\n}\n\n/** The rows in the order they start, those without a start first. */\nexport const inStartOrder = (rows: ListDisplayRow[], display: DatedDisplay) => rows.toSorted((a, b) => (instantOf(a.record[display.start]) ?? 0) - (instantOf(b.record[display.start]) ?? 0))\n\n/** The rows on each day of `days`, each day's in start order. */\nexport const byDay = (rows: ListDisplayRow[], display: DatedDisplay, model: ResourceModel, days: string[], zone = viewerZone()): Map<string, ListDisplayRow[]> => {\n const placed = new Map(days.map((day) => [day, [] as ListDisplayRow[]]))\n for (const row of inStartOrder(rows, display)) for (const day of eventDays(row.record, display, model, days, zone)) placed.get(day)!.push(row)\n return placed\n}\n\n/**\n * The update that moves a record shown on `from` to `to`: its `start`, and its `end` when it has one, moved by the same\n * number of days, a timestamp keeping its time of day on the clock of `zone`.\n */\nexport const movedPatch = (record: Record<string, unknown>, display: DatedDisplay, model: ResourceModel, from: string, to: string, zone = viewerZone()): Record<string, string> => {\n const days = (startOf(to) - startOf(from)) / dayMs\n const timestamp = isTimestamp(display, model)\n const moved = (value: unknown) => {\n const ms = instantOf(value)\n if (ms === undefined) return undefined\n return timestamp ? new Date(instantAt(ms + zoneOffset(ms, zone) + days * dayMs, zone)).toISOString() : addDays(dayOf(ms), days)\n }\n const start = moved(record[display.start])\n const end = display.end === undefined ? undefined : moved(record[display.end])\n return { ...(start !== undefined && { [display.start]: start }), ...(end !== undefined && { [display.end!]: end }) }\n}\n","import { ChevronLeft, ChevronRight } from 'lucide-react'\nimport { Fragment, type ReactNode } from 'react'\nimport type { AppAddress } from '@protobase/schema'\nimport { buttonClass } from '../../primitives/button'\nimport { segmentedClass } from '../../primitives/segmented'\nimport { AppLink } from '../use-app-address'\nimport { text } from './messages'\n\n/** One choice of the scale switch: the period it opens, and whether it is the scale shown. */\nexport type ScaleChoice<V> = { view: V; label: string; current: boolean }\n\ntype PeriodControlsProps<V> = {\n /** The period shown, as its heading says it. */\n heading: string\n /** What one step is, for the step buttons' labels. */\n unit: 'week' | 'month' | 'quarter'\n previous: V\n today: V\n next: V\n scales: ScaleChoice<V>[]\n /** The scale switch's name for assistive technology. */\n scalesLabel: string\n /** The address that shows the display at a period: the controls are links to it. */\n linkTo?: (view: V) => AppAddress\n /** Shows the display at a period, for one without an address of its own: the controls are buttons. */\n onView?: (view: V) => void\n}\n\n/**\n * The period a calendar or a timeline shows, with the way to the one before, the one holding today, the one after, and\n * its scales: links when the period is in the address, so each opens in a new tab, else buttons.\n */\nexport const PeriodControls = <V,>({ heading, unit, previous, today, next, scales, scalesLabel, linkTo, onView }: PeriodControlsProps<V>) => {\n const control = (to: V, className: string, label: string, children: ReactNode, current?: boolean) =>\n linkTo ? (\n <AppLink to={linkTo(to)} className={className} aria-label={label} aria-current={current ? 'page' : undefined}>\n {children}\n </AppLink>\n ) : (\n <button type=\"button\" className={className} aria-label={label} aria-pressed={current} onClick={() => onView?.(to)}>\n {children}\n </button>\n )\n const square = buttonClass({ variant: 'secondary', size: 'sm' })\n return (\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <h2 className=\"text-sm font-medium\">{heading}</h2>\n <div className=\"flex items-center gap-2\">\n <div className=\"flex items-center gap-1\">\n {control(previous, square, text('previousPeriod', { unit }), <ChevronLeft className=\"size-3.5\" />)}\n {control(today, square, text('today'), text('today'))}\n {control(next, square, text('nextPeriod', { unit }), <ChevronRight className=\"size-3.5\" />)}\n </div>\n <span role=\"group\" aria-label={scalesLabel} className={segmentedClass.group()}>\n {scales.map((scale) => (\n <Fragment key={scale.label}>{control(scale.view, segmentedClass.option(scale.current), scale.label, scale.label, scale.current)}</Fragment>\n ))}\n </span>\n </div>\n </div>\n )\n}\n","import type { KeyboardCoordinateGetter } from '@dnd-kit/core'\nimport { addDays } from './calendar-range'\n\nconst dayPrefix = 'day:'\n\n/** The id a calendar's day is dropped on by. */\nexport const dayId = (day: string) => `${dayPrefix}${day}`\n\n/** The id of an event on one of its days: a record over several days shows on each. */\nexport const eventId = (key: string, day: string) => `${key}@${day}`\n\n/** The arrow keys move a picked-up event a day back or on (left and right) or a week (up and down), to that day's top. */\nexport const dayCoordinates: KeyboardCoordinateGetter = (event, { context: { active, collisionRect, droppableRects, over } }) => {\n const steps: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 }\n const step = steps[event.code]\n const day = over ? String(over.id).slice(dayPrefix.length) : (active?.data.current?.day as string | undefined)\n if (step === undefined || !collisionRect || day === undefined) return undefined\n event.preventDefault()\n const target = droppableRects.get(dayId(addDays(day, step)))\n if (!target) return undefined\n return { x: target.left + (target.width - collisionRect.width) / 2, y: target.top + 4 }\n}\n","import { useDraggable } from '@dnd-kit/core'\nimport type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { formatTime } from '../../format/date'\nimport { dayIn, viewerZone } from '../../format/zone'\nimport { cn } from '../../lib/cn'\nimport { displayValue } from '../../live/display-value'\nimport { recordTitleField } from '../../live/model-helpers'\nimport { useSeedRecord } from '../record-preview'\nimport { AppLink } from '../use-app-address'\nimport type { DatedDisplay } from './calendar-range'\nimport { eventId } from './calendar-dnd'\nimport type { ListDisplayRow } from './list-displays'\n\ntype EventProps = {\n model: ResourceModel\n view: ViewModel | undefined\n display: DatedDisplay\n row: ListDisplayRow\n /** The day it is shown on, which starts with its time when it starts that day at a time. */\n day: string\n /** Classes on the chip, such as a timeline bar's edges. */\n className?: string\n}\n\n/** The text an event shows: its `title` field, or the view's title, with the names of the records relations point at. */\nexport const eventTitle = (model: ResourceModel, view: ViewModel | undefined, display: DatedDisplay, row: ListDisplayRow) => {\n const name = display.title ?? recordTitleField(model, view)\n const field = model.fields[name]\n const text = row.labels[name] ?? (field ? displayValue(field, row.record[name], view?.fields[name]) : '')\n return text === '' ? row.key : text\n}\n\n// A timestamp event's time on the day it starts, both on the viewer's clock\nconst startTime = (model: ResourceModel, display: DatedDisplay, row: ListDisplayRow, day: string) => {\n const value = row.record[display.start]\n if (model.fields[display.start]?.type !== 'timestamp' || typeof value !== 'string') return undefined\n const ms = Date.parse(value)\n return dayIn(ms, viewerZone()) === day ? formatTime(ms) : undefined\n}\n\n/** An event as a one-line link to its record, its time first for a timestamp, styled as a small record card. */\nexport const EventChip = ({ model, view, display, row, day, className }: EventProps) => {\n const seedRecord = useSeedRecord(model)\n const time = startTime(model, display, row, day)\n return (\n <AppLink\n to={{ kind: 'record', resource: model.name, key: row.key }}\n onClick={() => seedRecord(row.record)}\n className={cn(\n 'flex min-w-0 items-baseline gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-xs hover:border-border-strong hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30',\n className,\n )}\n >\n {time && <span className=\"shrink-0 tabular-nums text-muted-foreground\">{time}</span>}\n <span className=\"min-w-0 truncate\">{eventTitle(model, view, display, row)}</span>\n </AppLink>\n )\n}\n\n/** An event on one of its days, picked up by dragging it or by Space on its link; one the user may not update stays put. */\nexport const CalendarEvent = ({ movable, dragged, ...props }: EventProps & { movable: boolean; dragged: () => boolean }) => {\n const { setNodeRef, setActivatorNodeRef, listeners, isDragging } = useDraggable({ id: eventId(props.row.key, props.day), data: { row: props.row, day: props.day }, disabled: !movable })\n return (\n <div\n ref={(element) => {\n setNodeRef(element)\n // Space picks the event up from its link, which has the focus\n setActivatorNodeRef(element?.querySelector('a') ?? element)\n }}\n {...listeners}\n // The event is a link, which the browser would drag as one\n onDragStart={(event) => event.preventDefault()}\n onClickCapture={(event) => {\n if (!dragged()) return\n event.preventDefault()\n event.stopPropagation()\n }}\n className={cn('min-w-0', movable && 'cursor-grab touch-manipulation', isDragging && 'opacity-40')}\n >\n <EventChip {...props} />\n </div>\n )\n}\n","import { useEffect } from 'react'\nimport type { ResourceModel } from '@protobase/schema'\nimport { useLiveRows } from '../../live/use-live-rows'\nimport { useAdminMeta } from '../meta-gate'\nimport { rangeFilter, withRange, type DatedDisplay, type CalendarRange } from './calendar-range'\nimport { useDisplayRows } from './use-display-rows'\n\n/** The most records a calendar loads for the days it shows, the most the list API gives in one page. */\nexport const calendarLimit = 500\n\nexport type CalendarRowsParams = {\n model: ResourceModel\n display: DatedDisplay\n range: CalendarRange\n /** The fields the events show, which the records' relations are labelled for. */\n fields: string[]\n /** The list's filter, its search included, as the list API takes it. */\n filter: string\n}\n\n/**\n * The records on the days a calendar shows, through the list API: the list's filter with the days added, in start\n * order, page after page up to `calendarLimit`; `capped` when more remain. A change to the resource reloads them, as it\n * does the table.\n */\nexport const useCalendarRows = ({ model, display, range, fields, filter }: CalendarRowsParams) => {\n const { resources, views } = useAdminMeta()\n const rows = useLiveRows({ resources, views, model, columns: fields, filter: withRange(filter, rangeFilter(display, model, range)), orderBy: `${display.start} asc` })\n const list = useDisplayRows(model, rows.page, rows.key, true)\n const wanted = list.more && !list.loading && list.rows.length < calendarLimit\n useEffect(() => {\n if (wanted) list.loadMore()\n }, [wanted, list.rows.length])\n const capped = list.rows.length > calendarLimit || (list.rows.length === calendarLimit && list.more)\n return { rows: list.rows.slice(0, calendarLimit), capped, loading: list.loading, error: list.error }\n}\n","import { useMutation } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport type { KeyValue, ResourceModel } from '@protobase/schema'\nimport { useClient } from '../../data/api-provider'\nimport { formatDate } from '../../format/date'\nimport { recordKey } from '../../live/model-helpers'\nimport { useToast } from '../../toasts'\nimport { useRefreshResource } from '../pages/use-layout-data'\nimport { refusalReason } from './board-columns'\nimport { movedPatch, type DatedDisplay } from './calendar-range'\nimport type { ListDisplayRow } from './list-displays'\nimport { text } from './messages'\n\n/** An event on its way to another day: the fields the update sets, shown until the calendar has reloaded. */\nexport type CalendarMove = { key: string; patch: Record<string, string> }\n\n/** The rows with each moving record's new dates, so an event shows on its new day at once. */\nexport const movedRows = (rows: ListDisplayRow[], moves: CalendarMove[]) => {\n const patches = new Map(moves.map((move) => [move.key, move.patch]))\n return rows.map((row) => (patches.has(row.key) ? { ...row, record: { ...row.record, ...patches.get(row.key) } } : row))\n}\n\n/**\n * Moving a calendar's event to another day: one update of the record with its `start` and `end` moved by the same days\n * and the ETag it was listed with, as a named update action sends, so the resource's access rules and `validate`\n * decide. The event shows on its new day at once; a refusal puts it back and says why, and either way every list of\n * the resource reloads.\n */\nexport const useCalendarMove = (model: ResourceModel, display: DatedDisplay) => {\n const client = useClient()\n const toast = useToast()\n const refresh = useRefreshResource()\n const [moves, setMoves] = useState<CalendarMove[]>([])\n const settle = (key: string) => setMoves((current) => current.filter((move) => move.key !== key))\n\n const mutation = useMutation({\n mutationFn: ({ row, patch }: { row: ListDisplayRow; patch: Record<string, string>; to: string }) => {\n const etag = typeof row.record.etag === 'string' ? row.record.etag : '*'\n return client.update(model.name, recordKey(model, row.record) as KeyValue, patch, etag)\n },\n onMutate: ({ row, patch }) => setMoves((current) => [...current.filter((move) => move.key !== row.key), { key: row.key, patch }]),\n onError: (error, { row, to }) => {\n settle(row.key)\n toast.show({ state: 'error', title: text('couldNotMoveTo', { to: formatDate(Date.parse(`${to}T00:00:00Z`)) }), description: refusalReason(error) })\n },\n onSettled: async (_result, _error, { row }) => {\n await refresh(model.name)\n settle(row.key)\n },\n })\n\n /** Moves the record of `row`, shown on the day `from`, to the day `to`. */\n const move = (row: ListDisplayRow, from: string, to: string) => mutation.mutate({ row, patch: movedPatch(row.record, display, model, from, to), to })\n return { moves, move }\n}\n"],"mappings":"8/BAgBMuC,EAAQ,MAERC,EAAS,GAAe,IAAI,KAAKC,CAAE,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,EAAG,EAAE,EAC9DC,EAAW,GAAgB,KAAK,MAAM,GAAGC,EAAI,WAAW,EAGjDC,GAAW,EAAa,IAAkBJ,EAAME,EAAQC,CAAG,EAAIE,EAAQN,CAAK,EAG5EO,EAAU,GAAgBF,EAAQD,EAAK,GAAG,IAAI,KAAKD,EAAQC,CAAG,CAAC,CAAC,CAAC,UAAU,EAAI,GAAK,EAAE,EAGtFI,GAAW,EAAa,EAAO,IAAM,CAChD,IAAMC,EAAO,IAAI,KAAKN,EAAQC,CAAG,CAAC,EAClC,OAAOH,EAAM,KAAK,IAAIQ,EAAK,eAAe,EAAGA,EAAK,YAAY,EAAIC,EAAM,CAAC,CAAC,CAC5E,EAEMC,GAAc,CAAE,QAAO,UAAuC,CAAE,QAAO,IAAKC,IAAU,QAAUJ,EAAQJ,CAAG,EAAIG,EAAOH,CAAG,CAAE,GAGpHS,GAAgB,EAA8B,EAAa,EAAOnC,EAAW,IAAoBiC,EAAWG,GAAM,CAAE,MAAO,QAAS,IAAKrC,EAAMsC,EAAKC,CAAI,CAAE,CAAC,EAG3JC,GAAa,EAA8B,EAAa,EAAOvC,EAAW,IAAoBiC,EAAW,CAAE,QAAO,IAAKlC,EAAMsC,EAAKC,CAAI,CAAE,CAAC,EAGzIE,GAAY,EAAoB,IAC3CC,EAAK,QAAU,QAAU,CAAE,MAAO,QAAS,IAAKX,EAAQW,EAAK,IAAKT,CAAI,CAAE,EAAI,CAAE,MAAO,OAAQ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":"72b60446-e75e-40d3-a551-6dc78bf8deac"}
|
|
1
|
+
{"version":3,"file":"use-calendar-move-BcrMLvrG.js","names":["Fragment","useState","n","a","t","__toESM","require_react","require_jsx_runtime","where","cn","formatDate","printFilter","AppLink","ChevronRight","useToast","ChevronLeft","dayIn","viewerZone","buttonClass","displayValue","zoneOffset","refusalReason","useClient","formatTime","useAdminMeta","instantAt","recordTitleField","startOfDayIn","text","useRefreshResource","recordKey","segmentedClass","useMutation","useLiveRows","useSeedRecord","useDraggable","useDisplayRows","import_react","import_jsx_runtime","dayMs","dayOf","ms","startOf","day","addDays","count","monday","monthOf","date","step","normalised","scale","calendarView","at","now","zone","todayView","stepView","view","gridDays","first","index","rangeOf","days","isTimestamp","model","display","rangeFilter","timestamp","instant","bound","within","range","ending","withRange","filter","instantOf","value","recordDays","start","record","end","eventDays","span","inStartOrder","rows","b","byDay","placed","row","movedPatch","to","from","moved","PeriodControls","control","linkTo","label","current","onView","square","heading","previous","today","next","scalesLabel","scales","dayPrefix","dayId","eventId","key","dayCoordinates","event","over","active","collisionRect","target","droppableRects","eventTitle","name","field","startTime","EventChip","seedRecord","time","className","CalendarEvent","props","movable","setNodeRef","element","setActivatorNodeRef","listeners","dragged","isDragging","useCalendarRows","fields","list","wanted","capped","movedRows","patches","moves","move","useCalendarMove","client","toast","refresh","setMoves","settle","mutation","etag","patch","error"],"sources":["../../../src/app/displays/calendar-range.ts","../../../src/app/displays/period-controls.tsx","../../../src/app/displays/calendar-dnd.ts","../../../src/app/displays/calendar-event.tsx","../../../src/app/displays/use-calendar-rows.ts","../../../src/app/displays/use-calendar-move.ts"],"sourcesContent":["import type { CalendarView, FilterValue, ListDisplayModel, ResourceModel } from '@protobase/schema'\nimport { printFilter, where } from '@protobase/schema'\nimport { dayIn, instantAt, startOfDayIn, viewerZone, zoneOffset } from '../../format/zone'\nimport type { ListDisplayRow } from './list-displays'\n\n// The days a calendar shows and the records on them, as `YYYY-MM-DD` days, weeks from Monday. A date is on its own day;\n// a timestamp, and today, on the viewer's day, in `zone`.\n\nexport type CalendarDisplayModel = Extract<ListDisplayModel, { kind: 'calendar' }>\n\n/** A display that places records on days by their `start` and `end`, with a `title` on each: a calendar, or a timeline. */\nexport type DatedDisplay = Pick<CalendarDisplayModel, 'start' | 'end' | 'title'>\n\n/** The days a calendar shows, as the half-open interval from the first day to the day after the last. */\nexport type CalendarRange = { from: string; to: string }\n\nconst dayMs = 86_400_000\n\nconst dayOf = (ms: number) => new Date(ms).toISOString().slice(0, 10)\nconst startOf = (day: string) => Date.parse(`${day}T00:00:00Z`)\n\n/** The day `count` days after `day`, or before it for a negative count. */\nexport const addDays = (day: string, count: number) => dayOf(startOf(day) + count * dayMs)\n\n/** The Monday on or before `day`. */\nexport const monday = (day: string) => addDays(day, -((new Date(startOf(day)).getUTCDay() + 6) % 7))\n\n/** The 1st of the month of `day`, or of the month `step` months on. */\nexport const monthOf = (day: string, step = 0) => {\n const date = new Date(startOf(day))\n return dayOf(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + step, 1))\n}\n\nconst normalised = ({ scale, day }: CalendarView): CalendarView => ({ scale, day: scale === 'month' ? monthOf(day) : monday(day) })\n\n/** The month or week a calendar shows: the address's, starting on the month's 1st or the week's Monday, else the month of `now`. */\nexport const calendarView = (at: CalendarView | undefined, now: number, zone = viewerZone()): CalendarView => normalised(at ?? { scale: 'month', day: dayIn(now, zone) })\n\n/** The month or week of `scale` that holds `now`. */\nexport const todayView = (scale: CalendarView['scale'], now: number, zone = viewerZone()): CalendarView => normalised({ scale, day: dayIn(now, zone) })\n\n/** The month or week before (-1) or after (1) `view`. */\nexport const stepView = (view: CalendarView, step: -1 | 1): CalendarView =>\n view.scale === 'month' ? { scale: 'month', day: monthOf(view.day, step) } : { scale: 'week', day: addDays(monday(view.day), 7 * step) }\n\n/** The days a calendar shows: whole weeks from the Monday on or before a month's 1st to the Sunday on or after its last day, or a week's seven. */\nexport const gridDays = (view: CalendarView): string[] => {\n const first = monday(view.scale === 'month' ? monthOf(view.day) : view.day)\n const last = view.scale === 'month' ? addDays(monday(addDays(monthOf(view.day, 1), -1)), 6) : addDays(first, 6)\n const count = (startOf(last) - startOf(first)) / dayMs + 1\n return Array.from({ length: count }, (_, index) => addDays(first, index))\n}\n\n/** The days `view` shows, as a range from its first day to the day after its last. */\nexport const rangeOf = (view: CalendarView): CalendarRange => {\n const days = gridDays(view)\n return { from: days[0]!, to: addDays(days.at(-1)!, 1) }\n}\n\nconst isTimestamp = (display: DatedDisplay, model: ResourceModel) => model.fields[display.start]?.type === 'timestamp'\n\n/**\n * The records on the days of `range`, as a list filter: those starting in it, and with an `end` those starting before\n * it and ending in or after its first day. A timestamp's `end` is the instant it is over, so one ending at midnight is\n * not on the day it starts. Each branch reads one indexed field.\n */\nexport const rangeFilter = (display: DatedDisplay, model: ResourceModel, range: CalendarRange, zone = viewerZone()) => {\n const timestamp = isTimestamp(display, model)\n const instant = (day: string) => new Date(startOfDayIn(day, zone)).toISOString().replace('.000Z', 'Z')\n const bound = (day: string): FilterValue => (timestamp ? { kind: 'timestamp', value: instant(day), span: { start: 0, end: 0 } } : { kind: 'string', value: day, span: { start: 0, end: 0 } })\n const within = where.and(where.gte(display.start, bound(range.from)), where.lt(display.start, bound(range.to)))\n if (display.end === undefined) return printFilter(within)\n const ending = timestamp ? where.gt(display.end, bound(range.from)) : where.gte(display.end, bound(range.from))\n return printFilter(where.or(within, where.and(where.lt(display.start, bound(range.from)), ending)))\n}\n\n/** The list's filter, its search included, narrowed to the calendar's days. */\nexport const withRange = (filter: string, range: string) => (filter === '' ? range : `(${filter}) AND (${range})`)\n\n// The instant a record's date or timestamp value stands for, or none for a missing or unreadable one\nconst instantOf = (value: unknown) => {\n if (typeof value !== 'string') return undefined\n const ms = Date.parse(/^\\d{4}-\\d{2}-\\d{2}$/.test(value) ? `${value}T00:00:00Z` : value)\n return Number.isNaN(ms) ? undefined : ms\n}\n\n/**\n * The first and last day a record is on: its start's day and its end's, where a timestamp `end` at midnight is over\n * before that day starts; its start day alone without an end or with one before its start, and none without a start.\n */\nexport const recordDays = (record: Record<string, unknown>, display: DatedDisplay, model: ResourceModel, zone = viewerZone()): { first: string; last: string } | undefined => {\n const start = instantOf(record[display.start])\n if (start === undefined) return undefined\n const timestamp = isTimestamp(display, model)\n const day = (ms: number) => (timestamp ? dayIn(ms, zone) : dayOf(ms))\n const first = day(start)\n const end = display.end === undefined ? undefined : instantOf(record[display.end])\n const ending = end === undefined ? first : day(timestamp ? end - 1 : end)\n return { first, last: ending < first ? first : ending }\n}\n\n/** The days of `days` a record is on, from its first through its last (`recordDays`). */\nexport const eventDays = (record: Record<string, unknown>, display: DatedDisplay, model: ResourceModel, days: string[], zone = viewerZone()): string[] => {\n const span = recordDays(record, display, model, zone)\n return span ? days.filter((day) => day >= span.first && day <= span.last) : []\n}\n\n/** The rows in the order they start, those without a start first. */\nexport const inStartOrder = (rows: ListDisplayRow[], display: DatedDisplay) => rows.toSorted((a, b) => (instantOf(a.record[display.start]) ?? 0) - (instantOf(b.record[display.start]) ?? 0))\n\n/** The rows on each day of `days`, each day's in start order. */\nexport const byDay = (rows: ListDisplayRow[], display: DatedDisplay, model: ResourceModel, days: string[], zone = viewerZone()): Map<string, ListDisplayRow[]> => {\n const placed = new Map(days.map((day) => [day, [] as ListDisplayRow[]]))\n for (const row of inStartOrder(rows, display)) for (const day of eventDays(row.record, display, model, days, zone)) placed.get(day)!.push(row)\n return placed\n}\n\n/**\n * The update that moves a record shown on `from` to `to`: its `start`, and its `end` when it has one, moved by the same\n * number of days, a timestamp keeping its time of day on the clock of `zone`.\n */\nexport const movedPatch = (record: Record<string, unknown>, display: DatedDisplay, model: ResourceModel, from: string, to: string, zone = viewerZone()): Record<string, string> => {\n const days = (startOf(to) - startOf(from)) / dayMs\n const timestamp = isTimestamp(display, model)\n const moved = (value: unknown) => {\n const ms = instantOf(value)\n if (ms === undefined) return undefined\n return timestamp ? new Date(instantAt(ms + zoneOffset(ms, zone) + days * dayMs, zone)).toISOString() : addDays(dayOf(ms), days)\n }\n const start = moved(record[display.start])\n const end = display.end === undefined ? undefined : moved(record[display.end])\n return { ...(start !== undefined && { [display.start]: start }), ...(end !== undefined && { [display.end!]: end }) }\n}\n","import { ChevronLeft, ChevronRight } from 'lucide-react'\nimport { Fragment, type ReactNode } from 'react'\nimport type { AppAddress } from '@protobase/schema'\nimport { buttonClass } from '../../primitives/button'\nimport { segmentedClass } from '../../primitives/segmented'\nimport { AppLink } from '../use-app-address'\nimport { text } from './messages'\n\n/** One choice of the scale switch: the period it opens, and whether it is the scale shown. */\nexport type ScaleChoice<V> = { view: V; label: string; current: boolean }\n\ntype PeriodControlsProps<V> = {\n /** The period shown, as its heading says it. */\n heading: string\n /** What one step is, for the step buttons' labels. */\n unit: 'week' | 'month' | 'quarter'\n previous: V\n today: V\n next: V\n scales: ScaleChoice<V>[]\n /** The scale switch's name for assistive technology. */\n scalesLabel: string\n /** The address that shows the display at a period: the controls are links to it. */\n linkTo?: (view: V) => AppAddress\n /** Shows the display at a period, for one without an address of its own: the controls are buttons. */\n onView?: (view: V) => void\n}\n\n/**\n * The period a calendar or a timeline shows, with the way to the one before, the one holding today, the one after, and\n * its scales: links when the period is in the address, so each opens in a new tab, else buttons.\n */\nexport const PeriodControls = <V,>({ heading, unit, previous, today, next, scales, scalesLabel, linkTo, onView }: PeriodControlsProps<V>) => {\n const control = (to: V, className: string, label: string, children: ReactNode, current?: boolean) =>\n linkTo ? (\n <AppLink to={linkTo(to)} className={className} aria-label={label} aria-current={current ? 'page' : undefined}>\n {children}\n </AppLink>\n ) : (\n <button type=\"button\" className={className} aria-label={label} aria-pressed={current} onClick={() => onView?.(to)}>\n {children}\n </button>\n )\n const square = buttonClass({ variant: 'secondary', size: 'sm' })\n return (\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <h2 className=\"text-sm font-medium\">{heading}</h2>\n <div className=\"flex items-center gap-2\">\n <div className=\"flex items-center gap-1\">\n {control(previous, square, text('previousPeriod', { unit }), <ChevronLeft className=\"size-3.5\" />)}\n {control(today, square, text('today'), text('today'))}\n {control(next, square, text('nextPeriod', { unit }), <ChevronRight className=\"size-3.5\" />)}\n </div>\n <span role=\"group\" aria-label={scalesLabel} className={segmentedClass.group()}>\n {scales.map((scale) => (\n <Fragment key={scale.label}>{control(scale.view, segmentedClass.option(scale.current), scale.label, scale.label, scale.current)}</Fragment>\n ))}\n </span>\n </div>\n </div>\n )\n}\n","import type { KeyboardCoordinateGetter } from '@dnd-kit/core'\nimport { addDays } from './calendar-range'\n\nconst dayPrefix = 'day:'\n\n/** The id a calendar's day is dropped on by. */\nexport const dayId = (day: string) => `${dayPrefix}${day}`\n\n/** The id of an event on one of its days: a record over several days shows on each. */\nexport const eventId = (key: string, day: string) => `${key}@${day}`\n\n/** The arrow keys move a picked-up event a day back or on (left and right) or a week (up and down), to that day's top. */\nexport const dayCoordinates: KeyboardCoordinateGetter = (event, { context: { active, collisionRect, droppableRects, over } }) => {\n const steps: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 }\n const step = steps[event.code]\n const day = over ? String(over.id).slice(dayPrefix.length) : (active?.data.current?.day as string | undefined)\n if (step === undefined || !collisionRect || day === undefined) return undefined\n event.preventDefault()\n const target = droppableRects.get(dayId(addDays(day, step)))\n if (!target) return undefined\n return { x: target.left + (target.width - collisionRect.width) / 2, y: target.top + 4 }\n}\n","import { useDraggable } from '@dnd-kit/core'\nimport type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { formatTime } from '../../format/date'\nimport { dayIn, viewerZone } from '../../format/zone'\nimport { cn } from '../../lib/cn'\nimport { displayValue } from '../../live/display-value'\nimport { recordTitleField } from '../../live/model-helpers'\nimport { useSeedRecord } from '../record-preview'\nimport { AppLink } from '../use-app-address'\nimport type { DatedDisplay } from './calendar-range'\nimport { eventId } from './calendar-dnd'\nimport type { ListDisplayRow } from './list-displays'\n\ntype EventProps = {\n model: ResourceModel\n view: ViewModel | undefined\n display: DatedDisplay\n row: ListDisplayRow\n /** The day it is shown on, which starts with its time when it starts that day at a time. */\n day: string\n /** Classes on the chip, such as a timeline bar's edges. */\n className?: string\n}\n\n/** The text an event shows: its `title` field, or the view's title, with the names of the records relations point at. */\nexport const eventTitle = (model: ResourceModel, view: ViewModel | undefined, display: DatedDisplay, row: ListDisplayRow) => {\n const name = display.title ?? recordTitleField(model, view)\n const field = model.fields[name]\n const text = row.labels[name] ?? (field ? displayValue(field, row.record[name], view?.fields[name]) : '')\n return text === '' ? row.key : text\n}\n\n// A timestamp event's time on the day it starts, both on the viewer's clock\nconst startTime = (model: ResourceModel, display: DatedDisplay, row: ListDisplayRow, day: string) => {\n const value = row.record[display.start]\n if (model.fields[display.start]?.type !== 'timestamp' || typeof value !== 'string') return undefined\n const ms = Date.parse(value)\n return dayIn(ms, viewerZone()) === day ? formatTime(ms) : undefined\n}\n\n/** An event as a one-line link to its record, its time first for a timestamp, styled as a small record card. */\nexport const EventChip = ({ model, view, display, row, day, className }: EventProps) => {\n const seedRecord = useSeedRecord(model)\n const time = startTime(model, display, row, day)\n return (\n <AppLink\n to={{ kind: 'record', resource: model.name, key: row.key }}\n onClick={() => seedRecord(row.record)}\n className={cn(\n 'flex min-w-0 items-baseline gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-xs hover:border-border-strong hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30',\n className,\n )}\n >\n {time && <span className=\"shrink-0 tabular-nums text-muted-foreground\">{time}</span>}\n <span className=\"min-w-0 truncate\">{eventTitle(model, view, display, row)}</span>\n </AppLink>\n )\n}\n\n/** An event on one of its days, picked up by dragging it or by Space on its link; one the user may not update stays put. */\nexport const CalendarEvent = ({ movable, dragged, ...props }: EventProps & { movable: boolean; dragged: () => boolean }) => {\n const { setNodeRef, setActivatorNodeRef, listeners, isDragging } = useDraggable({ id: eventId(props.row.key, props.day), data: { row: props.row, day: props.day }, disabled: !movable })\n return (\n <div\n ref={(element) => {\n setNodeRef(element)\n // Space picks the event up from its link, which has the focus\n setActivatorNodeRef(element?.querySelector('a') ?? element)\n }}\n {...listeners}\n // The event is a link, which the browser would drag as one\n onDragStart={(event) => event.preventDefault()}\n onClickCapture={(event) => {\n if (!dragged()) return\n event.preventDefault()\n event.stopPropagation()\n }}\n className={cn('min-w-0', movable && 'cursor-grab touch-manipulation', isDragging && 'opacity-40')}\n >\n <EventChip {...props} />\n </div>\n )\n}\n","import { useEffect } from 'react'\nimport type { ResourceModel } from '@protobase/schema'\nimport { useLiveRows } from '../../live/use-live-rows'\nimport { useAdminMeta } from '../meta-gate'\nimport { rangeFilter, withRange, type DatedDisplay, type CalendarRange } from './calendar-range'\nimport { useDisplayRows } from './use-display-rows'\n\n/** The most records a calendar loads for the days it shows, the most the list API gives in one page. */\nexport const calendarLimit = 500\n\nexport type CalendarRowsParams = {\n model: ResourceModel\n display: DatedDisplay\n range: CalendarRange\n /** The fields the events show, which the records' relations are labelled for. */\n fields: string[]\n /** The list's filter, its search included, as the list API takes it. */\n filter: string\n}\n\n/**\n * The records on the days a calendar shows, through the list API: the list's filter with the days added, in start\n * order, page after page up to `calendarLimit`; `capped` when more remain. A change to the resource reloads them, as it\n * does the table.\n */\nexport const useCalendarRows = ({ model, display, range, fields, filter }: CalendarRowsParams) => {\n const { resources, views } = useAdminMeta()\n const rows = useLiveRows({ resources, views, model, columns: fields, filter: withRange(filter, rangeFilter(display, model, range)), orderBy: `${display.start} asc` })\n const list = useDisplayRows(model, rows.page, rows.key, true)\n const wanted = list.more && !list.loading && list.rows.length < calendarLimit\n useEffect(() => {\n if (wanted) list.loadMore()\n }, [wanted, list.rows.length])\n const capped = list.rows.length > calendarLimit || (list.rows.length === calendarLimit && list.more)\n return { rows: list.rows.slice(0, calendarLimit), capped, loading: list.loading, error: list.error }\n}\n","import { useMutation } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport type { KeyValue, ResourceModel } from '@protobase/schema'\nimport { useClient } from '../../data/api-provider'\nimport { formatDate } from '../../format/date'\nimport { recordKey } from '../../live/model-helpers'\nimport { useToast } from '../../toasts'\nimport { useRefreshResource } from '../pages/use-layout-data'\nimport { refusalReason } from './board-columns'\nimport { movedPatch, type DatedDisplay } from './calendar-range'\nimport type { ListDisplayRow } from './list-displays'\nimport { text } from './messages'\n\n/** An event on its way to another day: the fields the update sets, shown until the calendar has reloaded. */\nexport type CalendarMove = { key: string; patch: Record<string, string> }\n\n/** The rows with each moving record's new dates, so an event shows on its new day at once. */\nexport const movedRows = (rows: ListDisplayRow[], moves: CalendarMove[]) => {\n const patches = new Map(moves.map((move) => [move.key, move.patch]))\n return rows.map((row) => (patches.has(row.key) ? { ...row, record: { ...row.record, ...patches.get(row.key) } } : row))\n}\n\n/**\n * Moving a calendar's event to another day: one update of the record with its `start` and `end` moved by the same days\n * and the ETag it was listed with, as a named update action sends, so the resource's access rules and `validate`\n * decide. The event shows on its new day at once; a refusal puts it back and says why, and either way every list of\n * the resource reloads.\n */\nexport const useCalendarMove = (model: ResourceModel, display: DatedDisplay) => {\n const client = useClient()\n const toast = useToast()\n const refresh = useRefreshResource()\n const [moves, setMoves] = useState<CalendarMove[]>([])\n const settle = (key: string) => setMoves((current) => current.filter((move) => move.key !== key))\n\n const mutation = useMutation({\n mutationFn: ({ row, patch }: { row: ListDisplayRow; patch: Record<string, string>; to: string }) => {\n const etag = typeof row.record.etag === 'string' ? row.record.etag : '*'\n return client.update(model.name, recordKey(model, row.record) as KeyValue, patch, etag)\n },\n onMutate: ({ row, patch }) => setMoves((current) => [...current.filter((move) => move.key !== row.key), { key: row.key, patch }]),\n onError: (error, { row, to }) => {\n settle(row.key)\n toast.show({ state: 'error', title: text('couldNotMoveTo', { to: formatDate(Date.parse(`${to}T00:00:00Z`)) }), description: refusalReason(error) })\n },\n onSettled: async (_result, _error, { row }) => {\n await refresh(model.name)\n settle(row.key)\n },\n })\n\n /** Moves the record of `row`, shown on the day `from`, to the day `to`. */\n const move = (row: ListDisplayRow, from: string, to: string) => mutation.m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