@jini-ai/admin 0.4.2 → 0.4.4
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/CHANGELOG.md +15 -0
- package/README.md +7 -0
- package/dist/agent-plugins/react/components/AgentPluginListPanel.d.ts +1 -1
- package/dist/agent-plugins/react/hooks/AgentPluginInspector.hooks.js +1 -1
- package/dist/agent-plugins/react/hooks/AgentPluginPanel.hooks.d.ts +1 -1
- package/dist/agent-plugins/react/hooks/AgentPluginsPage.hooks.d.ts +1 -1
- package/dist/agent-plugins/react/hooks/AgentPluginsPage.hooks.js +1 -1
- package/dist/agent-plugins/react/hooks/MarketplaceTab.hooks.d.ts +1 -1
- package/dist/agent-plugins/react/index.js +1 -1
- package/dist/agent-plugins/react/pages/AgentPluginsPage.d.ts +1 -1
- package/dist/agent-plugins/react/tabs/DownloadedTab.d.ts +1 -1
- package/dist/agent-plugins/react/tabs/InstalledTab.d.ts +1 -1
- package/dist/agent-plugins/react/tabs/MarketplaceTab.d.ts +1 -1
- package/dist/comments/adapters/http.d.ts +29 -0
- package/dist/comments/adapters/http.js +50 -0
- package/dist/comments/adapters/memory.d.ts +17 -0
- package/dist/comments/adapters/memory.js +61 -0
- package/dist/comments/comments.module.d.ts +73 -0
- package/dist/comments/comments.module.js +16 -0
- package/dist/comments/conformance/comments-api.conformance.d.ts +9 -0
- package/dist/comments/conformance/comments-api.conformance.js +63 -0
- package/dist/comments/controllers/comment-queue.controller.d.ts +48 -0
- package/dist/comments/controllers/comment-queue.controller.js +164 -0
- package/dist/comments/controllers/comment-settings.controller.d.ts +32 -0
- package/dist/comments/controllers/comment-settings.controller.js +77 -0
- package/dist/comments/controllers/comments.controller.d.ts +16 -0
- package/dist/comments/controllers/comments.controller.js +16 -0
- package/dist/comments/index.d.ts +13 -0
- package/dist/comments/index.js +8 -0
- package/dist/comments/messages.en.d.ts +54 -0
- package/dist/comments/messages.en.js +56 -0
- package/dist/comments/models.d.ts +22 -0
- package/dist/comments/models.js +2 -0
- package/dist/comments/ports.d.ts +14 -0
- package/dist/comments/ports.js +5 -0
- package/dist/comments/react/components/QueueSection.d.ts +30 -0
- package/dist/comments/react/components/QueueSection.js +57 -0
- package/dist/comments/react/components/SettingsSection.d.ts +14 -0
- package/dist/comments/react/components/SettingsSection.js +23 -0
- package/dist/comments/react/hooks/CommentsPage.hooks.d.ts +9 -0
- package/dist/comments/react/hooks/CommentsPage.hooks.js +10 -0
- package/dist/comments/react/hooks/CommentsPorts.hooks.d.ts +13 -0
- package/dist/comments/react/hooks/CommentsPorts.hooks.js +15 -0
- package/dist/comments/react/hooks/QueueSection.hooks.d.ts +62 -0
- package/dist/comments/react/hooks/QueueSection.hooks.js +57 -0
- package/dist/comments/react/hooks/SettingsSection.hooks.d.ts +12 -0
- package/dist/comments/react/hooks/SettingsSection.hooks.js +21 -0
- package/dist/comments/react/hooks/use-comment-queue.hooks.d.ts +34 -0
- package/dist/comments/react/hooks/use-comment-queue.hooks.js +47 -0
- package/dist/comments/react/hooks/use-comment-settings.hooks.d.ts +22 -0
- package/dist/comments/react/hooks/use-comment-settings.hooks.js +30 -0
- package/dist/comments/react/hooks/use-comments.hooks.d.ts +15 -0
- package/dist/comments/react/hooks/use-comments.hooks.js +20 -0
- package/dist/comments/react/index.d.ts +316 -0
- package/dist/comments/react/index.js +35 -0
- package/dist/comments/react/pages/CommentsPage.d.ts +12 -0
- package/dist/comments/react/pages/CommentsPage.js +15 -0
- package/dist/comments/rules.d.ts +140 -0
- package/dist/comments/rules.js +199 -0
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.js +1 -0
- package/dist/core/ledger-slice.d.ts +90 -0
- package/dist/core/ledger-slice.js +81 -0
- package/dist/core/ports/comments.d.ts +2 -0
- package/dist/core/ports/forms.d.ts +19 -7
- package/dist/core/ports/forms.js +4 -4
- package/dist/core/ports/index.d.ts +1 -1
- package/dist/core/ports/seo.d.ts +33 -6
- package/dist/core/react/bind-react.d.ts +46 -0
- package/dist/core/react/bind-react.js +28 -0
- package/dist/core/react/index.d.ts +3 -0
- package/dist/core/react/index.js +3 -0
- package/dist/core/react/use-controller.d.ts +16 -0
- package/dist/core/react/use-controller.js +18 -0
- package/dist/forms/adapters/http.d.ts +26 -0
- package/dist/forms/adapters/http.js +43 -0
- package/dist/forms/adapters/memory.d.ts +14 -0
- package/dist/forms/adapters/memory.js +77 -0
- package/dist/forms/conformance/forms-api.conformance.d.ts +17 -0
- package/dist/forms/conformance/forms-api.conformance.js +71 -0
- package/dist/forms/controllers/draft-store.d.ts +18 -0
- package/dist/forms/controllers/draft-store.js +17 -0
- package/dist/forms/controllers/field-attributes-dialog.controller.d.ts +37 -0
- package/dist/forms/controllers/field-attributes-dialog.controller.js +27 -0
- package/dist/forms/controllers/form-editor.controller.d.ts +36 -0
- package/dist/forms/controllers/form-editor.controller.js +22 -0
- package/dist/forms/controllers/form-fields-editor.controller.d.ts +20 -0
- package/dist/forms/controllers/form-fields-editor.controller.js +10 -0
- package/dist/forms/controllers/form-submission-detail.controller.d.ts +20 -0
- package/dist/forms/controllers/form-submission-detail.controller.js +10 -0
- package/dist/forms/controllers/form-submissions.controller.d.ts +25 -0
- package/dist/forms/controllers/form-submissions.controller.js +10 -0
- package/dist/forms/controllers/forms-list.controller.d.ts +22 -0
- package/dist/forms/controllers/forms-list.controller.js +10 -0
- package/dist/forms/forms.module.d.ts +138 -0
- package/dist/forms/forms.module.js +17 -0
- package/dist/forms/html-rules.d.ts +34 -0
- package/dist/forms/html-rules.js +34 -0
- package/dist/forms/index.d.ts +14 -0
- package/dist/forms/index.js +12 -0
- package/dist/forms/messages.en.d.ts +101 -0
- package/dist/forms/messages.en.js +105 -0
- package/dist/forms/models.d.ts +29 -0
- package/dist/forms/models.js +8 -0
- package/dist/forms/ports.d.ts +26 -0
- package/dist/forms/ports.js +6 -0
- package/dist/forms/react/components/FieldAttributesDialog.d.ts +14 -0
- package/dist/forms/react/components/FieldAttributesDialog.js +47 -0
- package/dist/forms/react/components/FormEditorFieldsBody.d.ts +28 -0
- package/dist/forms/react/components/FormEditorFieldsBody.js +24 -0
- package/dist/forms/react/components/FormEditorHeaderText.d.ts +7 -0
- package/dist/forms/react/components/FormEditorHeaderText.js +8 -0
- package/dist/forms/react/components/FormEditorMainPanel.d.ts +12 -0
- package/dist/forms/react/components/FormEditorMainPanel.js +13 -0
- package/dist/forms/react/components/FormEditorTabStrip.d.ts +13 -0
- package/dist/forms/react/components/FormEditorTabStrip.js +14 -0
- package/dist/forms/react/components/FormFieldsEditor.d.ts +13 -0
- package/dist/forms/react/components/FormFieldsEditor.js +39 -0
- package/dist/forms/react/components/FormSubmissionDate.d.ts +8 -0
- package/dist/forms/react/components/FormSubmissionDate.js +5 -0
- package/dist/forms/react/components/FormSubmissionDetail.d.ts +15 -0
- package/dist/forms/react/components/FormSubmissionDetail.js +30 -0
- package/dist/forms/react/components/FormSubmissions.d.ts +12 -0
- package/dist/forms/react/components/FormSubmissions.js +46 -0
- package/dist/forms/react/hooks/FormsPorts.hooks.d.ts +41 -0
- package/dist/forms/react/hooks/FormsPorts.hooks.js +16 -0
- package/dist/forms/react/hooks/forms-view.hooks.d.ts +117 -0
- package/dist/forms/react/hooks/forms-view.hooks.js +78 -0
- package/dist/forms/react/hooks/use-field-attributes-dialog.hooks.d.ts +31 -0
- package/dist/forms/react/hooks/use-field-attributes-dialog.hooks.js +22 -0
- package/dist/forms/react/hooks/use-form-editor.hooks.d.ts +118 -0
- package/dist/forms/react/hooks/use-form-editor.hooks.js +208 -0
- package/dist/forms/react/hooks/use-form-fields-editor.hooks.d.ts +34 -0
- package/dist/forms/react/hooks/use-form-fields-editor.hooks.js +36 -0
- package/dist/forms/react/hooks/use-form-submission-date.hooks.d.ts +12 -0
- package/dist/forms/react/hooks/use-form-submission-date.hooks.js +9 -0
- package/dist/forms/react/hooks/use-form-submission-detail.hooks.d.ts +68 -0
- package/dist/forms/react/hooks/use-form-submission-detail.hooks.js +81 -0
- package/dist/forms/react/hooks/use-form-submissions.hooks.d.ts +67 -0
- package/dist/forms/react/hooks/use-form-submissions.hooks.js +110 -0
- package/dist/forms/react/hooks/use-forms-list.hooks.d.ts +78 -0
- package/dist/forms/react/hooks/use-forms-list.hooks.js +103 -0
- package/dist/forms/react/index.d.ts +452 -0
- package/dist/forms/react/index.js +35 -0
- package/dist/forms/react/pages/FormEditor.d.ts +19 -0
- package/dist/forms/react/pages/FormEditor.js +40 -0
- package/dist/forms/react/pages/FormsList.d.ts +39 -0
- package/dist/forms/react/pages/FormsList.js +50 -0
- package/dist/forms/rules.d.ts +291 -0
- package/dist/forms/rules.js +338 -0
- package/dist/media/react/hooks/EditMediaPanel.hooks.js +1 -1
- package/dist/media/react/hooks/LibraryTab.hooks.d.ts +1 -1
- package/dist/media/react/hooks/LibraryTab.hooks.js +1 -1
- package/dist/media/react/hooks/MediaCard.hooks.js +6 -20
- package/dist/media/react/hooks/MediaGrid.hooks.d.ts +2 -2
- package/dist/media/react/hooks/MediaPage.hooks.d.ts +1 -1
- package/dist/media/react/hooks/MediaPage.hooks.js +1 -1
- package/dist/media/react/hooks/MediaPicker.hooks.js +1 -1
- package/dist/media/react/index.js +1 -1
- package/dist/media/react/tabs/LibraryTab.d.ts +1 -1
- package/dist/media/react/tabs/ProvidersTab.d.ts +1 -1
- package/dist/playground/react/components/Canvas.d.ts +1 -1
- package/dist/playground/react/hooks/Canvas.hooks.d.ts +1 -1
- package/dist/playground/react/hooks/Canvas.hooks.js +1 -1
- package/dist/playground/react/hooks/PlaygroundPage.hooks.d.ts +1 -1
- package/dist/playground/react/index.js +1 -1
- package/dist/playground/react/pages/PlaygroundPage.d.ts +1 -1
- package/dist/playground/react/tabs/CanvasTab.d.ts +1 -1
- package/dist/react/bind-react.d.ts +1 -45
- package/dist/react/bind-react.js +2 -27
- package/dist/react/components/ConfirmDialog/ConfirmDialog.d.ts +22 -5
- package/dist/react/components/ConfirmDialog/ConfirmDialog.hooks.d.ts +2 -2
- package/dist/react/components/ConfirmDialog/ConfirmDialog.hooks.js +17 -55
- package/dist/react/components/ConfirmDialog/ConfirmDialog.js +33 -70
- package/dist/react/components/RowMenu/RowMenu.hooks.js +14 -3
- package/dist/react/use-controller.d.ts +1 -15
- package/dist/react/use-controller.js +2 -17
- package/dist/redirects/adapters/http.d.ts +20 -0
- package/dist/redirects/adapters/http.js +31 -0
- package/dist/redirects/adapters/memory.d.ts +13 -0
- package/dist/redirects/adapters/memory.js +83 -0
- package/dist/redirects/conformance/redirects-api.conformance.d.ts +12 -0
- package/dist/redirects/conformance/redirects-api.conformance.js +66 -0
- package/dist/redirects/controllers/hit-count.controller.d.ts +14 -0
- package/dist/redirects/controllers/hit-count.controller.js +10 -0
- package/dist/redirects/controllers/import-redirects.controller.d.ts +28 -0
- package/dist/redirects/controllers/import-redirects.controller.js +29 -0
- package/dist/redirects/controllers/redirects.controller.d.ts +37 -0
- package/dist/redirects/controllers/redirects.controller.js +38 -0
- package/dist/redirects/index.d.ts +11 -0
- package/dist/redirects/index.js +10 -0
- package/dist/redirects/messages.en.d.ts +58 -0
- package/dist/redirects/messages.en.js +60 -0
- package/dist/redirects/models.d.ts +14 -0
- package/dist/redirects/models.js +2 -0
- package/dist/redirects/ports.d.ts +9 -0
- package/dist/redirects/ports.js +4 -0
- package/dist/redirects/react/components/HitCountCell.d.ts +19 -0
- package/dist/redirects/react/components/HitCountCell.js +19 -0
- package/dist/redirects/react/components/ImportRedirectsForm.d.ts +17 -0
- package/dist/redirects/react/components/ImportRedirectsForm.js +12 -0
- package/dist/redirects/react/hooks/RedirectsOptions.hooks.d.ts +27 -0
- package/dist/redirects/react/hooks/RedirectsOptions.hooks.js +15 -0
- package/dist/redirects/react/hooks/RedirectsPage.hooks.d.ts +50 -0
- package/dist/redirects/react/hooks/RedirectsPage.hooks.js +30 -0
- package/dist/redirects/react/hooks/RedirectsPorts.hooks.d.ts +10 -0
- package/dist/redirects/react/hooks/RedirectsPorts.hooks.js +11 -0
- package/dist/redirects/react/hooks/use-hit-count-cell.hooks.d.ts +19 -0
- package/dist/redirects/react/hooks/use-hit-count-cell.hooks.js +15 -0
- package/dist/redirects/react/hooks/use-import-redirects-form.hooks.d.ts +21 -0
- package/dist/redirects/react/hooks/use-import-redirects-form.hooks.js +25 -0
- package/dist/redirects/react/hooks/use-redirects.hooks.d.ts +34 -0
- package/dist/redirects/react/hooks/use-redirects.hooks.js +63 -0
- package/dist/redirects/react/hooks/wired.hooks.d.ts +55 -0
- package/dist/redirects/react/hooks/wired.hooks.js +31 -0
- package/dist/redirects/react/index.d.ts +324 -0
- package/dist/redirects/react/index.js +28 -0
- package/dist/redirects/react/pages/RedirectsPage.d.ts +15 -0
- package/dist/redirects/react/pages/RedirectsPage.js +20 -0
- package/dist/redirects/redirects.module.d.ts +77 -0
- package/dist/redirects/redirects.module.js +13 -0
- package/dist/redirects/rules.d.ts +131 -0
- package/dist/redirects/rules.js +134 -0
- package/dist/security/react/hooks/AccessTokensTab.hooks.d.ts +1 -1
- package/dist/security/react/hooks/AccessTokensTab.hooks.js +1 -1
- package/dist/security/react/hooks/RootKeyTab.hooks.d.ts +1 -1
- package/dist/security/react/hooks/RootKeyTab.hooks.js +1 -1
- package/dist/security/react/hooks/SecurityPage.hooks.d.ts +1 -1
- package/dist/security/react/index.js +1 -1
- package/dist/security/react/pages/SecurityPage.d.ts +1 -1
- package/dist/security/react/tabs/AccessTokensTab.d.ts +1 -1
- package/dist/security/react/tabs/RootKeyTab.d.ts +1 -1
- package/dist/seo/adapters/http.d.ts +31 -0
- package/dist/seo/adapters/http.js +37 -0
- package/dist/seo/adapters/memory.d.ts +28 -0
- package/dist/seo/adapters/memory.js +129 -0
- package/dist/seo/conformance/seo-api.conformance.d.ts +8 -0
- package/dist/seo/conformance/seo-api.conformance.js +44 -0
- package/dist/seo/controllers/entry-picker.controller.d.ts +21 -0
- package/dist/seo/controllers/entry-picker.controller.js +17 -0
- package/dist/seo/controllers/entry-section.controller.d.ts +20 -0
- package/dist/seo/controllers/entry-section.controller.js +7 -0
- package/dist/seo/controllers/media-ref.controller.d.ts +26 -0
- package/dist/seo/controllers/media-ref.controller.js +14 -0
- package/dist/seo/controllers/seo-entry.controller.d.ts +31 -0
- package/dist/seo/controllers/seo-entry.controller.js +52 -0
- package/dist/seo/controllers/seo.controller.d.ts +29 -0
- package/dist/seo/controllers/seo.controller.js +50 -0
- package/dist/seo/controllers/sitemap.controller.d.ts +25 -0
- package/dist/seo/controllers/sitemap.controller.js +27 -0
- package/dist/seo/index.d.ts +14 -0
- package/dist/seo/index.js +12 -0
- package/dist/seo/messages.en.d.ts +79 -0
- package/dist/seo/messages.en.js +79 -0
- package/dist/seo/models.d.ts +179 -0
- package/dist/seo/models.js +8 -0
- package/dist/seo/ports.d.ts +11 -0
- package/dist/seo/ports.js +4 -0
- package/dist/seo/react/components/MediaPickerBridge.d.ts +4 -0
- package/dist/seo/react/components/MediaPickerBridge.js +8 -0
- package/dist/seo/react/components/MediaRefField.d.ts +40 -0
- package/dist/seo/react/components/MediaRefField.js +12 -0
- package/dist/seo/react/components/SeoIcons.d.ts +13 -0
- package/dist/seo/react/components/SeoIcons.js +32 -0
- package/dist/seo/react/components/SitemapModal.d.ts +48 -0
- package/dist/seo/react/components/SitemapModal.js +72 -0
- package/dist/seo/react/hooks/MediaPickerBridge.hooks.d.ts +6 -0
- package/dist/seo/react/hooks/MediaPickerBridge.hooks.js +27 -0
- package/dist/seo/react/hooks/MediaRefField.hooks.d.ts +25 -0
- package/dist/seo/react/hooks/MediaRefField.hooks.js +30 -0
- package/dist/seo/react/hooks/SeoModuleTabs.d.ts +14 -0
- package/dist/seo/react/hooks/SeoModuleTabs.js +18 -0
- package/dist/seo/react/hooks/SeoPage.hooks.d.ts +69 -0
- package/dist/seo/react/hooks/SeoPage.hooks.js +37 -0
- package/dist/seo/react/hooks/SeoPorts.hooks.d.ts +19 -0
- package/dist/seo/react/hooks/SeoPorts.hooks.js +22 -0
- package/dist/seo/react/hooks/SitemapModal.hooks.d.ts +26 -0
- package/dist/seo/react/hooks/SitemapModal.hooks.js +20 -0
- package/dist/seo/react/hooks/use-entry-picker.hooks.d.ts +11 -0
- package/dist/seo/react/hooks/use-entry-picker.hooks.js +20 -0
- package/dist/seo/react/hooks/use-seo-entry-panel.hooks.d.ts +14 -0
- package/dist/seo/react/hooks/use-seo-entry-panel.hooks.js +26 -0
- package/dist/seo/react/hooks/use-seo-entry-section.hooks.d.ts +4 -0
- package/dist/seo/react/hooks/use-seo-entry-section.hooks.js +7 -0
- package/dist/seo/react/hooks/use-seo.hooks.d.ts +11 -0
- package/dist/seo/react/hooks/use-seo.hooks.js +29 -0
- package/dist/seo/react/hooks/use-sitemap-modal.hooks.d.ts +10 -0
- package/dist/seo/react/hooks/use-sitemap-modal.hooks.js +18 -0
- package/dist/seo/react/index.d.ts +369 -0
- package/dist/seo/react/index.js +30 -0
- package/dist/seo/react/options.d.ts +26 -0
- package/dist/seo/react/options.js +2 -0
- package/dist/seo/react/pages/SeoPage.d.ts +161 -0
- package/dist/seo/react/pages/SeoPage.js +215 -0
- package/dist/seo/rules.d.ts +142 -0
- package/dist/seo/rules.js +220 -0
- package/dist/seo/seo.module.d.ts +115 -0
- package/dist/seo/seo.module.js +14 -0
- package/dist/source-control/react/hooks/ProvidersTab.hooks.d.ts +1 -1
- package/dist/source-control/react/hooks/ProvidersTab.hooks.js +1 -1
- package/dist/source-control/react/hooks/SourceControlPage.hooks.d.ts +1 -1
- package/dist/source-control/react/index.js +1 -1
- package/dist/source-control/react/pages/SourceControlPage.d.ts +1 -1
- package/dist/source-control/react/tabs/ProvidersTab.d.ts +1 -1
- package/dist/widgets/adapters/http.d.ts +19 -0
- package/dist/widgets/adapters/http.js +33 -0
- package/dist/widgets/adapters/memory.d.ts +22 -0
- package/dist/widgets/adapters/memory.js +93 -0
- package/dist/widgets/conformance/widgets-api.conformance.d.ts +6 -0
- package/dist/widgets/conformance/widgets-api.conformance.js +55 -0
- package/dist/widgets/controllers/instance-editor.controller.d.ts +49 -0
- package/dist/widgets/controllers/instance-editor.controller.js +87 -0
- package/dist/widgets/controllers/library.controller.d.ts +33 -0
- package/dist/widgets/controllers/library.controller.js +53 -0
- package/dist/widgets/controllers/region-editor.controller.d.ts +42 -0
- package/dist/widgets/controllers/region-editor.controller.js +69 -0
- package/dist/widgets/controllers/regions.controller.d.ts +27 -0
- package/dist/widgets/controllers/regions.controller.js +44 -0
- package/dist/widgets/index.d.ts +11 -0
- package/dist/widgets/index.js +9 -0
- package/dist/widgets/messages.en.d.ts +78 -0
- package/dist/widgets/messages.en.js +83 -0
- package/dist/widgets/models.d.ts +62 -0
- package/dist/widgets/models.js +2 -0
- package/dist/widgets/ports.d.ts +79 -0
- package/dist/widgets/ports.js +5 -0
- package/dist/widgets/react/components/WidgetInstanceNotices.d.ts +14 -0
- package/dist/widgets/react/components/WidgetInstanceNotices.js +25 -0
- package/dist/widgets/react/components/WidgetRegionEditorHeaderActions.d.ts +22 -0
- package/dist/widgets/react/components/WidgetRegionEditorHeaderActions.js +18 -0
- package/dist/widgets/react/components/WidgetsLibraryNotices.d.ts +13 -0
- package/dist/widgets/react/components/WidgetsLibraryNotices.js +10 -0
- package/dist/widgets/react/hooks/WidgetsPorts.hooks.d.ts +270 -0
- package/dist/widgets/react/hooks/WidgetsPorts.hooks.js +17 -0
- package/dist/widgets/react/hooks/navigation.hooks.d.ts +9 -0
- package/dist/widgets/react/hooks/navigation.hooks.js +6 -0
- package/dist/widgets/react/hooks/page-views.hooks.d.ts +87 -0
- package/dist/widgets/react/hooks/page-views.hooks.js +30 -0
- package/dist/widgets/react/hooks/use-widget-instance-editor.hooks.d.ts +56 -0
- package/dist/widgets/react/hooks/use-widget-instance-editor.hooks.js +38 -0
- package/dist/widgets/react/hooks/use-widget-region-editor.hooks.d.ts +32 -0
- package/dist/widgets/react/hooks/use-widget-region-editor.hooks.js +22 -0
- package/dist/widgets/react/hooks/use-widget-regions.hooks.d.ts +23 -0
- package/dist/widgets/react/hooks/use-widget-regions.hooks.js +22 -0
- package/dist/widgets/react/hooks/use-widgets-library.hooks.d.ts +37 -0
- package/dist/widgets/react/hooks/use-widgets-library.hooks.js +23 -0
- package/dist/widgets/react/index.d.ts +391 -0
- package/dist/widgets/react/index.js +31 -0
- package/dist/widgets/react/pages/WidgetInstanceEditor.d.ts +23 -0
- package/dist/widgets/react/pages/WidgetInstanceEditor.js +37 -0
- package/dist/widgets/react/pages/WidgetRegionEditor.d.ts +22 -0
- package/dist/widgets/react/pages/WidgetRegionEditor.js +25 -0
- package/dist/widgets/react/pages/WidgetRegions.d.ts +21 -0
- package/dist/widgets/react/pages/WidgetRegions.js +31 -0
- package/dist/widgets/react/pages/WidgetsLibrary.d.ts +24 -0
- package/dist/widgets/react/pages/WidgetsLibrary.js +61 -0
- package/dist/widgets/rules.d.ts +94 -0
- package/dist/widgets/rules.js +83 -0
- package/dist/widgets/widgets.module.d.ts +122 -0
- package/dist/widgets/widgets.module.js +21 -0
- package/package.json +206 -9
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { AdminFormsPort } from "../../../core/ports/forms.js";
|
|
2
|
+
import type { AdminFormSubmission } from "../../models.js";
|
|
3
|
+
/**
|
|
4
|
+
* @file `FormSubmissions`'s own state and paginated load, so the submissions list in
|
|
5
|
+
* `FormEditor.tsx` is only markup.
|
|
6
|
+
*
|
|
7
|
+
* Moved from the host — same cursor-append load shape, same error strings. `load` keeps its original
|
|
8
|
+
* `(cursor?: string) => void` signature rather than being split into separate "load"/"loadMore"
|
|
9
|
+
* functions, so both call sites (`load(nextCursor)` for "Load more", `load()` after a submission
|
|
10
|
+
* delete) carry over unchanged.
|
|
11
|
+
*
|
|
12
|
+
* Naming follows `hooks/use-settings-slice.hooks.ts`: `use-<thing>.hooks.ts`. Feature-local because
|
|
13
|
+
* nothing outside `features/forms` needs it.
|
|
14
|
+
*
|
|
15
|
+
* `port` is injected — see `core/ports/forms.ts` (shared with `use-form-submission-
|
|
16
|
+
* detail.hooks.ts`, since both read/write the same submissions list for a form) — rather than
|
|
17
|
+
* importing `lib/api` directly, so a test can describe list outcomes against
|
|
18
|
+
* `the memory adapter` instead of stubbing global `fetch`. `useWiredFormSubmissions`
|
|
19
|
+
* below is the zero-argument pair `FormEditor.tsx` actually mounts.
|
|
20
|
+
*
|
|
21
|
+
* `@jini-ai/ui/fetch-query` migration (2026-08-12): the FIRST page is one `useFetchQuery` keyed on
|
|
22
|
+
* `KEYS.submissionsList(formId)` — a query cannot commit a response belonging to a prior key, which
|
|
23
|
+
* eliminates the load race an external audit flagged at this file's old line 56 (a plain
|
|
24
|
+
* `.then()`/`.catch()` effect with no cancellation guard) for that page. Subsequent "Load more"
|
|
25
|
+
* pages are NOT folded into that same query: `@jini-ai/ui/fetch-query`'s `QueryKey` doc binds one
|
|
26
|
+
* hook to one FIXED key, and a cursor-appended page list is exactly the "moving-target key" shape
|
|
27
|
+
* that doc's own Skip precedent (`useSettingsContainer`, see this migration's dispatch brief) warns
|
|
28
|
+
* against faking — so accumulated pages live in the section controller, fetched directly through `port`
|
|
29
|
+
* (bypassing the cache, since an appended page is not a cacheable "the current state of X", it's an
|
|
30
|
+
* accumulating view built by this one screen). `pageSettlement` (`useSettlementGeneration`) guards
|
|
31
|
+
* that accumulation against the SAME class of race the base query gets for free: a `loadMore` in
|
|
32
|
+
* flight when `formId` changes, or when a first-page refetch (e.g. a delete's invalidate) resets
|
|
33
|
+
* the list, must not append its page once it resolves — see `resetMorePages` below, which mints a
|
|
34
|
+
* fresh generation on every reset so any older in-flight page fetch is superseded. A synchronous
|
|
35
|
+
* `loadingMoreRef` lock, checked before minting a generation, covers the other half: two `loadMore`
|
|
36
|
+
* calls issued in the SAME tick (a double click) must send only one request
|
|
37
|
+
* (2026-09-20, `plan-content2.md` #3/#5/S2).
|
|
38
|
+
*
|
|
39
|
+
* The audit's second, more serious finding at this file — `selectedId` surviving a `formId` change
|
|
40
|
+
* untouched, so a delete could fire against a submission id belonging to the PREVIOUS form while its
|
|
41
|
+
* stale rows were still on screen — is fixed by the identity-reset effect below, which clears both
|
|
42
|
+
* `selectedId` and the accumulated "more" pages whenever `formId` changes.
|
|
43
|
+
*/
|
|
44
|
+
export interface FormSubmissionsController {
|
|
45
|
+
/** `null` until the initial load settles — the caller renders a loading state. */
|
|
46
|
+
submissions: AdminFormSubmission[] | null;
|
|
47
|
+
nextCursor: string | null;
|
|
48
|
+
error: string | null;
|
|
49
|
+
/** The submission `FormSubmissions` is showing `FormSubmissionDetail` for — `null` shows the
|
|
50
|
+
* plain list. */
|
|
51
|
+
selectedId: string | null;
|
|
52
|
+
setSelectedId: (id: string | null) => void;
|
|
53
|
+
/** Re-fetches. Passing a cursor appends to `submissions`; omitting it replaces the list from the
|
|
54
|
+
* start (used after a submission is deleted, so the list reflects the removal). */
|
|
55
|
+
load: (cursor?: string) => void;
|
|
56
|
+
/** True while a "Load more" page fetch is in flight — drives the button's `disabled` and
|
|
57
|
+
* "Loading…" label in `FormEditor.tsx`. */
|
|
58
|
+
loadingMore: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare function useFormSubmissions(props: {
|
|
61
|
+
formId: string;
|
|
62
|
+
port: AdminFormsPort;
|
|
63
|
+
}, _optional?: {}): FormSubmissionsController;
|
|
64
|
+
export declare function useWiredFormSubmissions(props: {
|
|
65
|
+
formId: string;
|
|
66
|
+
}, _optional?: {}): FormSubmissionsController;
|
|
67
|
+
//# sourceMappingURL=use-form-submissions.hooks.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { submissionView } from "../../models.js";
|
|
2
|
+
import { useFormsPorts } from "./FormsPorts.hooks.js";
|
|
3
|
+
import { useController } from "../../../core/react/use-controller.js";
|
|
4
|
+
import { createFormSubmissionsController, initialFormSubmissionsState } from "../../controllers/form-submissions.controller.js";
|
|
5
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
6
|
+
import { describeApiError as describeCoreApiError } from "../../../core/transport/errors.js";
|
|
7
|
+
const describeApiError = (e, fallback) => describeCoreApiError({ e, fallback });
|
|
8
|
+
import { useFetchQuery, useInvalidate } from "@jini-ai/ui/fetch-query";
|
|
9
|
+
import { useSettlementGeneration } from "@jini-ai/ui/panel-kit";
|
|
10
|
+
import { KEYS } from "../../rules.js";
|
|
11
|
+
export function useFormSubmissions(props, _optional = {}) {
|
|
12
|
+
const { port } = props;
|
|
13
|
+
const invalidate = useInvalidate();
|
|
14
|
+
const firstPage = useFetchQuery({
|
|
15
|
+
key: KEYS.submissionsList(props.formId),
|
|
16
|
+
fetch: () => port.listFormSubmissions({ formId: props.formId }, {}).then(page => ({ data: page.items.map(submission => submissionView({ submission })), nextCursor: page.nextCursor })),
|
|
17
|
+
});
|
|
18
|
+
const { controller: stateController, snapshot: stateSnapshot } = useController({ create: () => createFormSubmissionsController({}), dependencies: [] });
|
|
19
|
+
const state = stateSnapshot ?? initialFormSubmissionsState({});
|
|
20
|
+
const morePages = state.morePages;
|
|
21
|
+
const setMorePages = (value) => stateController?.update({ key: "morePages", value });
|
|
22
|
+
const moreCursor = state.moreCursor;
|
|
23
|
+
const setMoreCursor = (value) => stateController?.update({ key: "moreCursor", value });
|
|
24
|
+
const moreError = state.moreError;
|
|
25
|
+
const setMoreError = (value) => stateController?.update({ key: "moreError", value });
|
|
26
|
+
const selectedId = state.selectedId;
|
|
27
|
+
const setSelectedId = (value) => stateController?.update({ key: "selectedId", value });
|
|
28
|
+
const loadingMore = state.loadingMore;
|
|
29
|
+
const setLoadingMore = (value) => stateController?.update({ key: "loadingMore", value });
|
|
30
|
+
// The "latest call wins" guard for accumulated pages — see the file header. `loadingMoreRef` is
|
|
31
|
+
// the synchronous half (blocks a same-tick double `loadMore`); `pageSettlement` is the async half
|
|
32
|
+
// (a superseded fetch's response must not land once a reset or a form switch has moved on).
|
|
33
|
+
const loadingMoreRef = useRef(false);
|
|
34
|
+
const pageSettlement = useSettlementGeneration();
|
|
35
|
+
// Supersedes any in-flight "Load more" fetch and clears the accumulated pages/cursor/error back
|
|
36
|
+
// to "just the first page" — called wherever the previous code did a bare `setMorePages([])`, so
|
|
37
|
+
// there is one reset path instead of three ad hoc ones.
|
|
38
|
+
const resetMorePages = useCallback(() => {
|
|
39
|
+
pageSettlement.next();
|
|
40
|
+
loadingMoreRef.current = false;
|
|
41
|
+
setLoadingMore(false);
|
|
42
|
+
setMorePages([]);
|
|
43
|
+
setMoreError(null);
|
|
44
|
+
}, [pageSettlement, stateController]);
|
|
45
|
+
// One effect, not two: the identity reset below fixes the audit's data-loss finding at this
|
|
46
|
+
// file — `selectedId` used to survive a `formId` change untouched, so a delete could fire
|
|
47
|
+
// against a submission id belonging to the PREVIOUS form while its stale rows were still on
|
|
48
|
+
// screen. `resetMorePages()` drops accumulated "more" pages, which belong to the previous form's
|
|
49
|
+
// cursor walk, and supersedes any of that form's `loadMore` still in flight.
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
setSelectedId(null);
|
|
52
|
+
resetMorePages();
|
|
53
|
+
setMoreCursor(null);
|
|
54
|
+
}, [props.formId, resetMorePages]);
|
|
55
|
+
// S2 fix: a refetched first page (e.g. S5's delete invalidating the list) must drop the "more"
|
|
56
|
+
// pages it used to leave stale — they are always a continuation of the CURRENT first page, not
|
|
57
|
+
// whichever first page was on screen when they were fetched. `resetMorePages()` also supersedes
|
|
58
|
+
// any `loadMore` already in flight when the refetch lands, so its page can't append afterward.
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
resetMorePages();
|
|
61
|
+
setMoreCursor(firstPage.data?.nextCursor ?? null);
|
|
62
|
+
}, [firstPage.data, resetMorePages]);
|
|
63
|
+
async function loadMore(cursor) {
|
|
64
|
+
if (loadingMoreRef.current)
|
|
65
|
+
return; // #3: a same-tick double click sends only one request
|
|
66
|
+
loadingMoreRef.current = true;
|
|
67
|
+
const generation = pageSettlement.next();
|
|
68
|
+
setLoadingMore(true);
|
|
69
|
+
setMoreError(null); // #5: a retry clears the previous failure
|
|
70
|
+
try {
|
|
71
|
+
const r = await port.listFormSubmissions({ formId: props.formId }, { cursor });
|
|
72
|
+
if (!pageSettlement.isCurrent({ generation }))
|
|
73
|
+
return; // superseded by a reset or a form switch
|
|
74
|
+
setMorePages((prev) => [...prev, ...r.items.map(submission => submissionView({ submission }))]);
|
|
75
|
+
setMoreCursor(r.nextCursor);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
if (!pageSettlement.isCurrent({ generation }))
|
|
79
|
+
return;
|
|
80
|
+
setMoreError(e instanceof Error ? e.message : "failed to load submissions");
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
// A superseded call's lock was already released by `resetMorePages`; only the still-current
|
|
84
|
+
// call releases it here.
|
|
85
|
+
if (pageSettlement.isCurrent({ generation })) {
|
|
86
|
+
loadingMoreRef.current = false;
|
|
87
|
+
setLoadingMore(false);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Passing a cursor appends via `loadMore`; omitting it re-reads the first page from scratch
|
|
92
|
+
* (used after a submission delete, so the list reflects the removal) and drops accumulated pages,
|
|
93
|
+
* matching the pre-migration `load()`'s own "no cursor replaces everything" behavior. */
|
|
94
|
+
function load(cursor) {
|
|
95
|
+
if (cursor) {
|
|
96
|
+
void loadMore(cursor);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
resetMorePages();
|
|
100
|
+
invalidate({ key: KEYS.submissionsList(props.formId) });
|
|
101
|
+
}
|
|
102
|
+
const submissions = firstPage.data ? [...firstPage.data.data, ...morePages] : null;
|
|
103
|
+
const error = moreError ?? (firstPage.error ? describeApiError(firstPage.error, "failed to load submissions") : null);
|
|
104
|
+
return { submissions, nextCursor: moreCursor, error, selectedId, setSelectedId, load, loadingMore };
|
|
105
|
+
}
|
|
106
|
+
export function useWiredFormSubmissions(props, _optional = {}) {
|
|
107
|
+
const { formsApi } = useFormsPorts();
|
|
108
|
+
return useFormSubmissions({ ...props, port: formsApi });
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=use-form-submissions.hooks.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { AdminFormsPort } from "../../../core/ports/forms.js";
|
|
2
|
+
import type { FormsTrashPort, FormsEventsPort } from "../../ports.js";
|
|
3
|
+
import type { AdminFormDefinition } from "../../models.js";
|
|
4
|
+
import { type FormDateLine } from "../../rules.js";
|
|
5
|
+
/**
|
|
6
|
+
* @file Everything the Forms LIST does, so `FormsList.tsx` is only markup.
|
|
7
|
+
*
|
|
8
|
+
* Moved from the host — same state, same order, same effect, same error strings. Naming follows
|
|
9
|
+
* `hooks/use-settings-slice.hooks.ts` and `hooks/use-dirty-guard.hooks.ts`: `use-<thing>.hooks.ts`.
|
|
10
|
+
* Feature-local because nothing outside `features/forms` needs it; promote to `src/hooks/` only
|
|
11
|
+
* when a second feature actually does.
|
|
12
|
+
*
|
|
13
|
+
* `port` is injected — see `core/ports/forms.ts` (shared with `use-form-editor.hooks.ts`, since
|
|
14
|
+
* both read/write the same `AdminFormDefinition` resource) — rather than importing `lib/api`
|
|
15
|
+
* directly, so a test can describe list/write outcomes against `the memory adapter` instead of
|
|
16
|
+
* stubbing global `fetch`. `useWiredFormsList` below is the zero-argument pair `FormsList.tsx`
|
|
17
|
+
* actually mounts.
|
|
18
|
+
*
|
|
19
|
+
* `t` (standing i18n rule — a component with a hook gets a BOUND `t` from that hook, not its own
|
|
20
|
+
* `useAdminLocale()`/dictionary import, same shape `use-post-editor.hooks.ts` established for this
|
|
21
|
+
* conversion): injected alongside `port` rather than `FormsList.tsx` importing `useAdminLocale`
|
|
22
|
+
* and `FORMS_DICT` itself. Pre-bound to `(key: string) => string` so a test can inject
|
|
23
|
+
* `t: (k) => k` and every assertion stays stable against copy changes. `useAdminLocale()` and
|
|
24
|
+
* `FORMS_DICT` are called/read only inside {@link useWiredFormsList}.
|
|
25
|
+
*
|
|
26
|
+
* `@jini-ai/ui/fetch-query` migration (2026-08-12): `toggleStatus` is one `useFetchMutation` that
|
|
27
|
+
* `invalidates: [KEYS.list]` — same idiom `use-taxonomy.hooks.ts`'s deletes use, so this list stays
|
|
28
|
+
* in sync with a status change made from `FormEditor.tsx` too (a `KEYS.list`-invalidating write
|
|
29
|
+
* elsewhere in the app, not just this screen's own toggle). This DOES cost one extra background GET
|
|
30
|
+
* per toggle that the pre-migration `setForms((prev) => prev.map(...))` optimistic patch avoided —
|
|
31
|
+
* a deliberate trade for cross-screen consistency (`@jini-ai/ui/fetch-query`'s own header names
|
|
32
|
+
* this exact "two screens showing the same resource silently drift apart" bug as the reason the
|
|
33
|
+
* library exists at all); `FormsList.unit.test.tsx`'s old "only one GET" assertion is updated
|
|
34
|
+
* accordingly, not preserved. `rowSavingId` lives in the section controller rather than reading off the
|
|
35
|
+
* mutation directly — one shared `useFetchMutation` object has no per-call "which row" of its own,
|
|
36
|
+
* the exact case this migration's own dispatch brief calls out as the intended `useState` out.
|
|
37
|
+
*
|
|
38
|
+
* the scoped formsEvents subscription (staleness-bug generalization pass, see that hook's own header):
|
|
39
|
+
* `forms_create_definition`/`forms_update_definition`/`forms_set_definition_status`
|
|
40
|
+
* (`apps/website/src/features/forms/agent-tools.ts`) are agent-callable, so this list re-invalidates
|
|
41
|
+
* `KEYS.list` on an out-of-band content-refresh notification the same way `use-taxonomy.hooks.ts`
|
|
42
|
+
* does for its own resource.
|
|
43
|
+
*/
|
|
44
|
+
export interface FormsListController {
|
|
45
|
+
forms: AdminFormDefinition[] | null;
|
|
46
|
+
/** The "Created / Updated" cell's one or two lines — see `rules.ts`'s `formDatesLines`. */
|
|
47
|
+
formatFormDates: (form: AdminFormDefinition) => FormDateLine[];
|
|
48
|
+
error: string | null;
|
|
49
|
+
/** In-flight row action (status toggle, or the confirmed delete) — one at a time, same
|
|
50
|
+
* `rowSavingId` convention `Posts.tsx`/`Pages.tsx` use for their own row actions. Shared between
|
|
51
|
+
* {@link FormsListController.toggleStatus} and {@link FormsListController.removeForm} so a
|
|
52
|
+
* Disable click and a Delete confirm on two different rows can never race each other. */
|
|
53
|
+
rowSavingId: string | null;
|
|
54
|
+
/** No-op while a previous call is still in flight (`rowSavingId` set) — see this function's own
|
|
55
|
+
* comment; the caller never has to guard against a double toggle itself. */
|
|
56
|
+
toggleStatus: (form: AdminFormDefinition) => Promise<void>;
|
|
57
|
+
/** The form a `RowMenu` "Delete" selection is asking to confirm; `null` when the `ConfirmDialog`
|
|
58
|
+
* is closed. `FormsList.tsx` drives the dialog's `open` prop from this. */
|
|
59
|
+
pendingDelete: AdminFormDefinition | null;
|
|
60
|
+
setPendingDelete: (form: AdminFormDefinition | null) => void;
|
|
61
|
+
/** Runs the trash move for {@link FormsListController.pendingDelete}. No-op with no
|
|
62
|
+
* `pendingDelete` (Cancel never reaches the port) or while another row action is already
|
|
63
|
+
* in-flight (`rowSavingId` set) — see this function's own comment. */
|
|
64
|
+
removeForm: () => Promise<void>;
|
|
65
|
+
/** Bound translator — see this file's own header for why it arrives via the hook rather than
|
|
66
|
+
* `FormsList.tsx` calling `useAdminLocale()`/`FORMS_DICT` directly. */
|
|
67
|
+
t: (key: string) => string;
|
|
68
|
+
}
|
|
69
|
+
export declare function useFormsList(deps: {
|
|
70
|
+
port: AdminFormsPort;
|
|
71
|
+
trash: FormsTrashPort;
|
|
72
|
+
t: (key: string) => string;
|
|
73
|
+
events?: FormsEventsPort;
|
|
74
|
+
}, { locale }?: {
|
|
75
|
+
locale?: string;
|
|
76
|
+
}): FormsListController;
|
|
77
|
+
export declare function useWiredFormsList(_required?: Record<string, never>, _optional?: {}): FormsListController;
|
|
78
|
+
//# sourceMappingURL=use-forms-list.hooks.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { formView } from "../../models.js";
|
|
2
|
+
import { useFormsPorts, useFormsOptions } from "./FormsPorts.hooks.js";
|
|
3
|
+
import { useController } from "../../../core/react/use-controller.js";
|
|
4
|
+
import { createFormsListController, initialFormsListState } from "../../controllers/forms-list.controller.js";
|
|
5
|
+
import { useCallback, useEffect, useMemo } from "react";
|
|
6
|
+
import { useFetchMutation, useFetchQuery, useInvalidate } from "@jini-ai/ui/fetch-query";
|
|
7
|
+
import { KEYS, describeTrashError, formDatesLines, formsListError, newestUpdatedForms } from "../../rules.js";
|
|
8
|
+
export function useFormsList(deps, { locale = "en" } = {}) {
|
|
9
|
+
const { port, trash, t, events } = deps;
|
|
10
|
+
const list = useFetchQuery({ key: KEYS.list, fetch: () => port.listFormDefinitions({}).then(data => ({ data: data.map(form => formView({ form })) })) });
|
|
11
|
+
const invalidate = useInvalidate();
|
|
12
|
+
// Stable identity — see `use-media.hooks.ts`'s identical `invalidateList` for why an inline arrow
|
|
13
|
+
// here would resubscribe the scoped formsEvents subscription on every render for no benefit.
|
|
14
|
+
const invalidateList = useCallback(() => invalidate({ key: KEYS.list }), [invalidate]);
|
|
15
|
+
useEffect(() => events?.subscribe({ onRefresh: invalidateList }), [events, invalidateList]);
|
|
16
|
+
const { controller: stateController, snapshot: stateSnapshot } = useController({ create: () => createFormsListController({}), dependencies: [] });
|
|
17
|
+
const state = stateSnapshot ?? initialFormsListState({});
|
|
18
|
+
const rowSavingId = state.rowSavingId;
|
|
19
|
+
const setRowSavingId = (value) => stateController?.update({ key: "rowSavingId", value });
|
|
20
|
+
const toggleMutation = useFetchMutation({
|
|
21
|
+
run: ({ input: form }) => port.updateFormDefinition({ id: form.id }, { status: form.status === "active" ? "disabled" : "active" }),
|
|
22
|
+
}, {
|
|
23
|
+
invalidates: [KEYS.list],
|
|
24
|
+
});
|
|
25
|
+
// The form a `RowMenu` "Delete" selection is asking to confirm — `null` when the `ConfirmDialog`
|
|
26
|
+
// is closed. `ConfirmDialog` stays mounted unconditionally in `FormsList.tsx`; this is what drives
|
|
27
|
+
// its `open` prop — same shape `use-posts.hooks.ts`'s `pendingDelete` uses for its own row delete.
|
|
28
|
+
const pendingDelete = state.pendingDelete;
|
|
29
|
+
const setPendingDelete = (value) => stateController?.update({ key: "pendingDelete", value });
|
|
30
|
+
const deleteMutation = useFetchMutation({
|
|
31
|
+
run: ({ input: form }) => trash.trash({ type: "form", id: form.id }),
|
|
32
|
+
}, {
|
|
33
|
+
invalidates: [KEYS.list],
|
|
34
|
+
});
|
|
35
|
+
// In-flight guard lives here, not in `FormsList.tsx`'s `onToggleStatus` closure — `RowMenu` has no
|
|
36
|
+
// per-item `disabled`, so this is what stops a second toggle firing while the first is still
|
|
37
|
+
// saving. Same shape `use-redirects.hooks.ts`'s own `onToggleStatus` uses for its identical
|
|
38
|
+
// `if (saving) return;` guard (that hook's own comment on why: `disabled={saving}` on the old
|
|
39
|
+
// inline buttons moved into each handler once `RowMenu` replaced them). Shared `rowSavingId` with
|
|
40
|
+
// `removeForm` below (T7a) — only clears THIS row's own lock in `finally`, so a Delete confirm on
|
|
41
|
+
// a DIFFERENT row that lands while this toggle is still in flight doesn't get its own lock wiped,
|
|
42
|
+
// same guard `use-posts.hooks.ts`'s `togglePostPublish`/`removePost` pair documents.
|
|
43
|
+
async function toggleStatus(form) {
|
|
44
|
+
if (rowSavingId)
|
|
45
|
+
return;
|
|
46
|
+
setRowSavingId(form.id);
|
|
47
|
+
try {
|
|
48
|
+
await toggleMutation.mutate({ input: form });
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// already surfaced through toggleMutation.error -> error below
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
setRowSavingId((cur) => (cur === form.id ? null : cur));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Moves `pendingDelete` to the Trash via `formsTrash.trash` — reached only through the
|
|
58
|
+
* `ConfirmDialog`'s Confirm button, never the `RowMenu` selection itself (that only opens the
|
|
59
|
+
* dialog via `setPendingDelete`), so a click alone can never delete. A 404 (`describeTrashError`'s
|
|
60
|
+
* `alreadyGone`) means the row is already gone: a quiet list refresh instead of an error banner
|
|
61
|
+
* blaming the operator for something that already happened — see that function's own doc. Every
|
|
62
|
+
* other outcome closes the dialog and leaves the failure (if any) for `error` below to surface. */
|
|
63
|
+
async function removeForm() {
|
|
64
|
+
if (!pendingDelete)
|
|
65
|
+
return;
|
|
66
|
+
if (rowSavingId)
|
|
67
|
+
return;
|
|
68
|
+
const form = pendingDelete;
|
|
69
|
+
setRowSavingId(form.id);
|
|
70
|
+
try {
|
|
71
|
+
await deleteMutation.mutate({ input: form });
|
|
72
|
+
setPendingDelete(null);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
if (describeTrashError({ error: e instanceof Error ? e : null, fallback: t("failed to delete form"), versionChangedMessage: t("This item changed since you loaded it. Reload and try again.") }).alreadyGone) {
|
|
76
|
+
invalidateList();
|
|
77
|
+
}
|
|
78
|
+
setPendingDelete(null);
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
setRowSavingId((cur) => (cur === form.id ? null : cur));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const forms = useMemo(() => list.data ? newestUpdatedForms({ forms: list.data.data }) : null, [list.data]);
|
|
85
|
+
const formatFormDates = (form) => formDatesLines({ form, locale, t });
|
|
86
|
+
const error = formsListError({
|
|
87
|
+
toggleError: toggleMutation.error,
|
|
88
|
+
deleteError: deleteMutation.error,
|
|
89
|
+
listError: list.error,
|
|
90
|
+
hasForms: forms !== null,
|
|
91
|
+
deleteFallback: t("failed to delete form"),
|
|
92
|
+
statusUpdateFallback: t("failed to update form status"),
|
|
93
|
+
loadFormsFallback: t("failed to load forms"),
|
|
94
|
+
versionChangedMessage: t("This item changed since you loaded it. Reload and try again."),
|
|
95
|
+
});
|
|
96
|
+
return { forms, formatFormDates, error, rowSavingId, toggleStatus, pendingDelete, setPendingDelete, removeForm, t };
|
|
97
|
+
}
|
|
98
|
+
export function useWiredFormsList(_required = {}, _optional = {}) {
|
|
99
|
+
const { formsApi, formsTrash, formsEvents } = useFormsPorts();
|
|
100
|
+
const { t, locale } = useFormsOptions();
|
|
101
|
+
return useFormsList({ port: formsApi, trash: formsTrash, ...(formsEvents === undefined ? {} : { events: formsEvents }), t }, { locale });
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=use-forms-list.hooks.js.map
|