@middag-io/react 0.44.1 → 0.45.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/README.md +7 -0
- package/dist-lib/{FormField-Bj43PjHH.js → FormField-Csx8hGAW.js} +1956 -1936
- package/dist-lib/{FormPanelBlock-C6eDfGoI.js → FormPanelBlock-Bmd0DpiX.js} +337 -337
- package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/LinkListBlock.d.ts +2 -1
- package/dist-lib/base/blocks/LinkListBlock.d.ts.map +1 -1
- package/dist-lib/base/form/FormField.d.ts.map +1 -1
- package/dist-lib/base/layout/DashboardLayout.d.ts.map +1 -1
- package/dist-lib/base/partials/ConfirmationDialog/index.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/cell-renderers.d.ts +1 -1
- package/dist-lib/base/partials/DataTable/cell-renderers.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/index.d.ts +1 -1
- package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/sanitize-html.d.ts +17 -0
- package/dist-lib/base/partials/DataTable/sanitize-html.d.ts.map +1 -0
- package/dist-lib/base/partials/DataTable/types.d.ts +15 -0
- package/dist-lib/base/partials/DataTable/types.d.ts.map +1 -1
- package/dist-lib/base/partials/FilterBar/index.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.js +1 -1
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +38 -24
- package/dist-lib/base/shell/partials/PageActionButton.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/PageActionButton.js +1 -1
- package/dist-lib/chunks/subpath-Bh1MAmBT.js +165 -0
- package/dist-lib/chunks/{subpath-AeMdleNB.js → subpath-fEhy6n_U.js} +10 -6
- package/dist-lib/contracts/block-data/data-display.d.ts +51 -2
- package/dist-lib/contracts/block-data/data-display.d.ts.map +1 -1
- package/dist-lib/contracts/generated/contract-schema.d.ts +1 -1
- package/dist-lib/contracts/generated/contract-types.d.ts +4 -2
- package/dist-lib/contracts/generated/contract-types.d.ts.map +1 -1
- package/dist-lib/contracts/generated/index.d.ts +1 -1
- package/dist-lib/i18n/I18nProvider.js +1 -1
- package/dist-lib/i18n/instance.js +1 -1
- package/dist-lib/i18n/locales/en/ui.json +5 -3
- package/dist-lib/i18n/locales/pt-BR/ui.json +5 -3
- package/dist-lib/i18n/register-strings.js +1 -1
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/middag-react.css +1 -1
- package/dist-lib/middag-react.js +18641 -13317
- package/dist-lib/primitives/reui/chart.d.ts.map +1 -1
- package/dist-lib/primitives/reui/chart.js +35 -31
- package/docs/public/schemas/ai-contract-manifest.json +1820 -0
- package/docs/public/schemas/blocks.json +445 -0
- package/docs/public/schemas/components.json +166 -0
- package/docs/public/schemas/connectors.json +97 -0
- package/docs/public/schemas/fragment.json +2329 -0
- package/docs/public/schemas/manifest.json +119 -0
- package/docs/public/schemas/navigation.json +72 -0
- package/docs/public/schemas/page-contract.json +2329 -0
- package/docs/public/schemas/shared-props.json +118 -0
- package/docs/public/schemas/theme-defaults.json +253 -0
- package/docs/public/schemas/theme.json +401 -0
- package/package.json +109 -3
- package/src/assets/lottie/calendar/schedule-1.json +1 -0
- package/src/assets/lottie/calendar/schedule-2.json +1 -0
- package/src/assets/lottie/celebration/confetti-1.json +1 -0
- package/src/assets/lottie/celebration/confetti-2.json +1 -0
- package/src/assets/lottie/celebration/confetti-3.json +1 -0
- package/src/assets/lottie/cloud/cloud-1.json +1 -0
- package/src/assets/lottie/cloud/cloud-2.json +1 -0
- package/src/assets/lottie/connection/network-1.json +1 -0
- package/src/assets/lottie/connection/network-2.json +1 -0
- package/src/assets/lottie/connection/network-3.json +1 -0
- package/src/assets/lottie/dashboard/analytics-1.json +1 -0
- package/src/assets/lottie/dashboard/analytics-2.json +1 -0
- package/src/assets/lottie/dashboard/analytics-3.json +1 -0
- package/src/assets/lottie/email/mail-1.json +1 -0
- package/src/assets/lottie/email/mail-2.json +1 -0
- package/src/assets/lottie/email/mail-3.json +1 -0
- package/src/assets/lottie/empty-state/empty-1.json +1 -0
- package/src/assets/lottie/empty-state/empty-2.json +1 -0
- package/src/assets/lottie/empty-state/empty-3.json +1 -0
- package/src/assets/lottie/error/warning-1.json +1 -0
- package/src/assets/lottie/error/warning-2.json +1 -0
- package/src/assets/lottie/error/warning-3.json +1 -0
- package/src/assets/lottie/index.ts +49 -0
- package/src/assets/lottie/loading/spinner-1.json +1 -0
- package/src/assets/lottie/loading/spinner-2.json +1 -0
- package/src/assets/lottie/loading/spinner-3.json +1 -0
- package/src/assets/lottie/maintenance/construction-1.json +1 -0
- package/src/assets/lottie/maintenance/construction-2.json +1 -0
- package/src/assets/lottie/maintenance/construction-3.json +1 -0
- package/src/assets/lottie/not-found/404-1.json +1 -0
- package/src/assets/lottie/not-found/404-2.json +1 -0
- package/src/assets/lottie/not-found/404-3.json +1 -0
- package/src/assets/lottie/notification/bell-1.json +1 -0
- package/src/assets/lottie/notification/bell-2.json +1 -0
- package/src/assets/lottie/notification/bell-3.json +1 -0
- package/src/assets/lottie/onboarding/welcome-1.json +1 -0
- package/src/assets/lottie/onboarding/welcome-2.json +1 -0
- package/src/assets/lottie/onboarding/welcome-3.json +1 -0
- package/src/assets/lottie/payment/wallet-1.json +1 -0
- package/src/assets/lottie/payment/wallet-2.json +1 -0
- package/src/assets/lottie/payment/wallet-3.json +1 -0
- package/src/assets/lottie/search/search-1.json +1 -0
- package/src/assets/lottie/search/search-2.json +1 -0
- package/src/assets/lottie/search/search-3.json +1 -0
- package/src/assets/lottie/security/lock-1.json +1 -0
- package/src/assets/lottie/security/lock-2.json +1 -0
- package/src/assets/lottie/security/lock-3.json +1 -0
- package/src/assets/lottie/settings/gear-1.json +1 -0
- package/src/assets/lottie/settings/gear-2.json +1 -0
- package/src/assets/lottie/settings/gear-3.json +1 -0
- package/src/assets/lottie/success/check-1.json +1 -0
- package/src/assets/lottie/success/check-2.json +1 -0
- package/src/assets/lottie/success/check-3.json +1 -0
- package/src/assets/lottie/upload/upload-1.json +1 -0
- package/src/assets/lottie/upload/upload-2.json +1 -0
- package/src/assets/lottie/upload/upload-3.json +1 -0
- package/src/assets/lottie/user/profile-1.json +1 -0
- package/src/assets/lottie/user/profile-2.json +1 -0
- package/src/assets/lottie/user/profile-3.json +1 -0
- package/src/base/blocks/ActionGridBlock.tsx +151 -0
- package/src/base/blocks/ActivityTimelineBlock.tsx +180 -0
- package/src/base/blocks/CardGridBlock.tsx +384 -0
- package/src/base/blocks/ChartBlock.tsx +81 -0
- package/src/base/blocks/DenseTableBlock.tsx +403 -0
- package/src/base/blocks/DetailPanelBlock.tsx +189 -0
- package/src/base/blocks/EmptyStateBlock.tsx +46 -0
- package/src/base/blocks/FormPanelBlock.lazy.tsx +38 -0
- package/src/base/blocks/FormPanelBlock.tsx +480 -0
- package/src/base/blocks/LinkListBlock.tsx +94 -0
- package/src/base/blocks/MarkdownPanelBlock.tsx +60 -0
- package/src/base/blocks/MetricCardBlock.tsx +128 -0
- package/src/base/blocks/StatusStripBlock.tsx +43 -0
- package/src/base/blocks/TabsBlock.tsx +94 -0
- package/src/base/form/FormField.tsx +607 -0
- package/src/base/form/fields/CheckboxField.tsx +56 -0
- package/src/base/form/fields/ColorField.tsx +76 -0
- package/src/base/form/fields/CurrencyField.tsx +126 -0
- package/src/base/form/fields/DateField.tsx +168 -0
- package/src/base/form/fields/DateRangeField.tsx +66 -0
- package/src/base/form/fields/DocumentField.tsx +222 -0
- package/src/base/form/fields/EntityPickerField.tsx +244 -0
- package/src/base/form/fields/FileUploadField.tsx +253 -0
- package/src/base/form/fields/MultiSelectField.tsx +286 -0
- package/src/base/form/fields/NativeSelectField.tsx +67 -0
- package/src/base/form/fields/NumberField.tsx +67 -0
- package/src/base/form/fields/OtpField.tsx +88 -0
- package/src/base/form/fields/PasswordField.tsx +69 -0
- package/src/base/form/fields/PhoneField.tsx +64 -0
- package/src/base/form/fields/RadioField.tsx +66 -0
- package/src/base/form/fields/RatingField.tsx +52 -0
- package/src/base/form/fields/SelectField.tsx +76 -0
- package/src/base/form/fields/SliderField.tsx +77 -0
- package/src/base/form/fields/SlugField.tsx +114 -0
- package/src/base/form/fields/StaticField.tsx +25 -0
- package/src/base/form/fields/SwitchField.tsx +56 -0
- package/src/base/form/fields/TagsField.tsx +128 -0
- package/src/base/form/fields/TextField.tsx +55 -0
- package/src/base/form/fields/TextareaField.tsx +55 -0
- package/src/base/form/fields/document-validation.ts +126 -0
- package/src/base/form/fields/field-registry.ts +53 -0
- package/src/base/form/fields/register-default-fields.ts +86 -0
- package/src/base/form/form-schema-builder.ts +192 -0
- package/src/base/form/form-utils.ts +71 -0
- package/src/base/hooks/useIsDark.ts +50 -0
- package/src/base/hooks/useLazyTabs.ts +98 -0
- package/src/base/hooks/usePolling.ts +43 -0
- package/src/base/hooks/useRemember.ts +58 -0
- package/src/base/hooks/useToast.ts +27 -0
- package/src/base/layout/BlockRegion.tsx +39 -0
- package/src/base/layout/DashboardLayout.tsx +110 -0
- package/src/base/layout/SidebarLayout.tsx +38 -0
- package/src/base/layout/StackLayout.tsx +32 -0
- package/src/base/layout/WizardLayout.tsx +49 -0
- package/src/base/partials/ActionBar/index.tsx +115 -0
- package/src/base/partials/ConfirmationDialog/index.tsx +128 -0
- package/src/base/partials/DataTable/cell-registry.ts +50 -0
- package/src/base/partials/DataTable/cell-renderers.tsx +372 -0
- package/src/base/partials/DataTable/index.tsx +1282 -0
- package/src/base/partials/DataTable/register-default-cells.ts +37 -0
- package/src/base/partials/DataTable/sanitize-html.ts +45 -0
- package/src/base/partials/DataTable/types.ts +229 -0
- package/src/base/partials/DetailSection/index.tsx +316 -0
- package/src/base/partials/EmptyPlaceholder/index.tsx +162 -0
- package/src/base/partials/EntityItem/index.tsx +154 -0
- package/src/base/partials/FilterBar/index.tsx +256 -0
- package/src/base/partials/FormSection/index.tsx +87 -0
- package/src/base/partials/LogViewer/JsonBlock.tsx +39 -0
- package/src/base/partials/LogViewer/LogEntry.tsx +68 -0
- package/src/base/partials/LogViewer/LogViewerToolbar.tsx +71 -0
- package/src/base/partials/LogViewer/index.tsx +110 -0
- package/src/base/partials/LogViewer/types.ts +28 -0
- package/src/base/partials/MarkdownContent/index.tsx +307 -0
- package/src/base/partials/MenuBar/index.tsx +80 -0
- package/src/base/partials/QuickRecordSheet/index.tsx +59 -0
- package/src/base/partials/ResizableSidebar/index.tsx +70 -0
- package/src/base/partials/StatRow/index.tsx +28 -0
- package/src/base/partials/StatusBar/index.tsx +126 -0
- package/src/base/partials/StatusIndicator/index.tsx +61 -0
- package/src/base/partials/StepIndicator/index.tsx +63 -0
- package/src/base/partials/TableOfContents/index.tsx +78 -0
- package/src/base/partials/TimelineList/index.tsx +273 -0
- package/src/base/partials/ToggleGroupControl/index.tsx +100 -0
- package/src/base/partials/TreeView/index.tsx +75 -0
- package/src/base/partials/index.ts +23 -0
- package/src/base/shell/AuthShell.tsx +54 -0
- package/src/base/shell/BasicShell.tsx +286 -0
- package/src/base/shell/ImmersiveShell.tsx +85 -0
- package/src/base/shell/partials/EditablePanelContext.tsx +82 -0
- package/src/base/shell/partials/EditablePanelProvider.tsx +122 -0
- package/src/base/shell/partials/InlineEditablePanel.tsx +239 -0
- package/src/base/shell/partials/InspectorContext.tsx +173 -0
- package/src/base/shell/partials/InspectorPanel.tsx +65 -0
- package/src/base/shell/partials/NavErrorBoundary.tsx +82 -0
- package/src/base/shell/partials/OverlayScreen.tsx +67 -0
- package/src/base/shell/partials/PageActionButton.tsx +203 -0
- package/src/base/theme/appearance.ts +133 -0
- package/src/base/theme/host-layout-detector.ts +119 -0
- package/src/base/theme/host-theme-detector.ts +146 -0
- package/src/base/theme/sidebar-safelist.txt +20 -0
- package/src/base/theme/tailwind-theme.css +136 -0
- package/src/base/theme/theme-bridge.css +164 -0
- package/src/base/theme/theme-context.tsx +142 -0
- package/src/base/theme/themes/classic.css +174 -0
- package/src/base/theme/tokens.css +290 -0
- package/src/base/theme/useHostTheme.ts +95 -0
- package/src/base/utils/clipboard.ts +39 -0
- package/src/base/utils/conditions.ts +27 -0
- package/src/base/utils/icon-registry.ts +78 -0
- package/src/base/utils/icons.ts +31 -0
- package/src/base/utils/interpolate.ts +9 -0
- package/src/base/utils/register-default-icons.ts +163 -0
- package/src/base/utils/storage.ts +65 -0
- package/src/base/utils/time.ts +139 -0
- package/src/contracts/block-data/actions.ts +73 -0
- package/src/contracts/block-data/data-display.ts +343 -0
- package/src/contracts/block-data/form.ts +164 -0
- package/src/contracts/block-data/index.ts +15 -0
- package/src/contracts/block-data/interactive.ts +34 -0
- package/src/contracts/block-data/shared.ts +44 -0
- package/src/contracts/connectors.ts +60 -0
- package/src/contracts/generated/contract-schema.ts +1237 -0
- package/src/contracts/generated/contract-types.ts +675 -0
- package/src/contracts/generated/index.ts +15 -0
- package/src/contracts/navigation.ts +59 -0
- package/src/contracts/page-contract-schema.ts +40 -0
- package/src/contracts/page-contract.ts +79 -0
- package/src/contracts/shared-props.ts +92 -0
- package/src/engine/ContractPage.tsx +178 -0
- package/src/engine/EntityRoutes.tsx +72 -0
- package/src/engine/HostSlot.tsx +126 -0
- package/src/engine/LazyBlock.tsx +92 -0
- package/src/engine/bootstrap.tsx +20 -0
- package/src/engine/providers/auth.tsx +87 -0
- package/src/engine/providers/error-reporter.tsx +89 -0
- package/src/engine/providers/flash.tsx +44 -0
- package/src/engine/providers/index.ts +18 -0
- package/src/engine/providers/inertia-error-reporter.tsx +61 -0
- package/src/engine/providers/progress.tsx +56 -0
- package/src/engine/providers/scope.tsx +51 -0
- package/src/engine/register-defaults.ts +88 -0
- package/src/engine/registries.ts +96 -0
- package/src/i18n/I18nProvider.tsx +53 -0
- package/src/i18n/MANIFEST.md +101 -0
- package/src/i18n/host-resolver.ts +18 -0
- package/src/i18n/instance.ts +69 -0
- package/src/i18n/locales/en/ui.json +277 -0
- package/src/i18n/locales/en/validators.json +13 -0
- package/src/i18n/locales/pt-BR/ui.json +277 -0
- package/src/i18n/locales/pt-BR/validators.json +13 -0
- package/src/i18n/register-strings.ts +10 -0
- package/src/i18n/render-label.ts +33 -0
- package/src/i18n/resolve-field-error.ts +29 -0
- package/src/i18n/useHostString.ts +50 -0
- package/src/i18n/useTranslation.ts +83 -0
- package/src/lib/actions/resolve-action-target.ts +151 -0
- package/src/lib/hooks/use-copy-to-clipboard.ts +37 -0
- package/src/lib/hooks/use-file-upload.ts +406 -0
- package/src/lib/hooks/use-mobile.ts +21 -0
- package/src/lib/host-pending.ts +76 -0
- package/src/lib/portal-container.ts +16 -0
- package/src/lib/test-ids.ts +40 -0
- package/src/lib/utils.ts +6 -0
- package/src/primitives/reui/MANIFEST.md +97 -0
- package/src/primitives/reui/accordion.tsx +64 -0
- package/src/primitives/reui/alert-dialog.tsx +196 -0
- package/src/primitives/reui/alert.tsx +92 -0
- package/src/primitives/reui/aspect-ratio.tsx +9 -0
- package/src/primitives/reui/autocomplete.tsx +343 -0
- package/src/primitives/reui/avatar.tsx +109 -0
- package/src/primitives/reui/badge.tsx +94 -0
- package/src/primitives/reui/breadcrumb.tsx +109 -0
- package/src/primitives/reui/button-group.tsx +83 -0
- package/src/primitives/reui/button.tsx +64 -0
- package/src/primitives/reui/calendar.tsx +220 -0
- package/src/primitives/reui/card.tsx +92 -0
- package/src/primitives/reui/carousel.tsx +239 -0
- package/src/primitives/reui/chart.tsx +388 -0
- package/src/primitives/reui/checkbox.tsx +30 -0
- package/src/primitives/reui/collapsible.tsx +31 -0
- package/src/primitives/reui/combobox.tsx +308 -0
- package/src/primitives/reui/command.tsx +182 -0
- package/src/primitives/reui/context-menu.tsx +250 -0
- package/src/primitives/reui/data-grid/data-grid-column-filter.tsx +172 -0
- package/src/primitives/reui/data-grid/data-grid-column-header.tsx +420 -0
- package/src/primitives/reui/data-grid/data-grid-column-visibility.tsx +51 -0
- package/src/primitives/reui/data-grid/data-grid-pagination.tsx +235 -0
- package/src/primitives/reui/data-grid/data-grid-scroll-area.tsx +427 -0
- package/src/primitives/reui/data-grid/data-grid-table-dnd-rows.tsx +308 -0
- package/src/primitives/reui/data-grid/data-grid-table-dnd.tsx +318 -0
- package/src/primitives/reui/data-grid/data-grid-table-virtual.tsx +491 -0
- package/src/primitives/reui/data-grid/data-grid-table.tsx +1430 -0
- package/src/primitives/reui/data-grid/data-grid.tsx +269 -0
- package/src/primitives/reui/data-grid-pagination.tsx +235 -0
- package/src/primitives/reui/date-selector.tsx +1353 -0
- package/src/primitives/reui/dialog.tsx +158 -0
- package/src/primitives/reui/drawer.tsx +133 -0
- package/src/primitives/reui/dropdown-menu.tsx +257 -0
- package/src/primitives/reui/empty.tsx +104 -0
- package/src/primitives/reui/field.tsx +246 -0
- package/src/primitives/reui/filters.tsx +1891 -0
- package/src/primitives/reui/frame.tsx +170 -0
- package/src/primitives/reui/hover-card.tsx +42 -0
- package/src/primitives/reui/icon-placeholder.tsx +39 -0
- package/src/primitives/reui/index.ts +98 -0
- package/src/primitives/reui/input-group.tsx +170 -0
- package/src/primitives/reui/input-otp.tsx +75 -0
- package/src/primitives/reui/input.tsx +21 -0
- package/src/primitives/reui/item.tsx +193 -0
- package/src/primitives/reui/kanban.tsx +743 -0
- package/src/primitives/reui/kbd.tsx +28 -0
- package/src/primitives/reui/label.tsx +22 -0
- package/src/primitives/reui/menubar.tsx +274 -0
- package/src/primitives/reui/native-select.tsx +62 -0
- package/src/primitives/reui/navigation-menu.tsx +168 -0
- package/src/primitives/reui/number-field.tsx +250 -0
- package/src/primitives/reui/pagination.tsx +127 -0
- package/src/primitives/reui/phone-input.tsx +231 -0
- package/src/primitives/reui/popover.tsx +87 -0
- package/src/primitives/reui/progress.tsx +31 -0
- package/src/primitives/reui/radio-group.tsx +43 -0
- package/src/primitives/reui/rating.tsx +177 -0
- package/src/primitives/reui/resizable.tsx +51 -0
- package/src/primitives/reui/scroll-area.tsx +58 -0
- package/src/primitives/reui/scrollspy.tsx +240 -0
- package/src/primitives/reui/select.tsx +188 -0
- package/src/primitives/reui/separator.tsx +28 -0
- package/src/primitives/reui/sheet.tsx +141 -0
- package/src/primitives/reui/sidebar.tsx +732 -0
- package/src/primitives/reui/skeleton.tsx +13 -0
- package/src/primitives/reui/slider.tsx +61 -0
- package/src/primitives/reui/sonner.tsx +47 -0
- package/src/primitives/reui/sortable.tsx +414 -0
- package/src/primitives/reui/spinner.tsx +16 -0
- package/src/primitives/reui/stepper.tsx +484 -0
- package/src/primitives/reui/svgs/claudeAiIcon.tsx +12 -0
- package/src/primitives/reui/svgs/gemini.tsx +171 -0
- package/src/primitives/reui/svgs/openai.tsx +9 -0
- package/src/primitives/reui/svgs/openaiDark.tsx +12 -0
- package/src/primitives/reui/switch.tsx +33 -0
- package/src/primitives/reui/table.tsx +114 -0
- package/src/primitives/reui/tabs.tsx +91 -0
- package/src/primitives/reui/textarea.tsx +18 -0
- package/src/primitives/reui/timeline.tsx +219 -0
- package/src/primitives/reui/toggle-group.tsx +83 -0
- package/src/primitives/reui/toggle.tsx +45 -0
- package/src/primitives/reui/tooltip.tsx +55 -0
- package/src/primitives/reui/tree.tsx +247 -0
- package/src/theme.css +71 -0
- package/dist-lib/chunks/subpath-q4Q2zg_p.js +0 -153
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EntityPickerField — searchable entity selection with avatar support.
|
|
3
|
+
*
|
|
4
|
+
* Two modes:
|
|
5
|
+
* - Static: options provided directly, filtered locally
|
|
6
|
+
* - Async: fetches from autocompleteHref on input (debounced 300ms)
|
|
7
|
+
*
|
|
8
|
+
* Each item can display: avatar image, primary label, subtitle line.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { useCallback, useEffect, useMemo, useRef, useState, type ReactElement } from "react";
|
|
12
|
+
|
|
13
|
+
import { useTranslation } from "@/i18n/useTranslation";
|
|
14
|
+
import { beginPending, trackedFetch } from "@/lib/host-pending";
|
|
15
|
+
import { Avatar, AvatarFallback, AvatarImage } from "@/primitives/reui/avatar";
|
|
16
|
+
import {
|
|
17
|
+
Combobox,
|
|
18
|
+
ComboboxContent,
|
|
19
|
+
ComboboxEmpty,
|
|
20
|
+
ComboboxInput,
|
|
21
|
+
ComboboxItem,
|
|
22
|
+
ComboboxList,
|
|
23
|
+
} from "@/primitives/reui/combobox";
|
|
24
|
+
|
|
25
|
+
export interface EntityOption {
|
|
26
|
+
value: string;
|
|
27
|
+
label: string;
|
|
28
|
+
subtitle?: string;
|
|
29
|
+
avatarUrl?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface EntityPickerFieldProps {
|
|
33
|
+
id: string;
|
|
34
|
+
value: string;
|
|
35
|
+
onChange: (value: string) => void;
|
|
36
|
+
options?: EntityOption[];
|
|
37
|
+
/** Pre-selected option so the current value renders before async search loads (edit mode). */
|
|
38
|
+
initialOption?: EntityOption;
|
|
39
|
+
autocompleteHref?: string;
|
|
40
|
+
autocompleteMinChars?: number;
|
|
41
|
+
entityAvatarField?: string;
|
|
42
|
+
entitySubtitleField?: string;
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
required?: boolean;
|
|
46
|
+
error?: string;
|
|
47
|
+
helpTextId?: string;
|
|
48
|
+
errorId?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getInitials(name: string): string {
|
|
52
|
+
return name
|
|
53
|
+
.split(/\s+/)
|
|
54
|
+
.slice(0, 2)
|
|
55
|
+
.map((w) => w[0]?.toUpperCase() ?? "")
|
|
56
|
+
.join("");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function EntityPickerField({
|
|
60
|
+
id,
|
|
61
|
+
value,
|
|
62
|
+
onChange,
|
|
63
|
+
options: staticOptions,
|
|
64
|
+
initialOption,
|
|
65
|
+
autocompleteHref,
|
|
66
|
+
autocompleteMinChars = 2,
|
|
67
|
+
entityAvatarField,
|
|
68
|
+
entitySubtitleField,
|
|
69
|
+
placeholder,
|
|
70
|
+
disabled,
|
|
71
|
+
required,
|
|
72
|
+
error,
|
|
73
|
+
helpTextId,
|
|
74
|
+
errorId,
|
|
75
|
+
}: EntityPickerFieldProps): ReactElement {
|
|
76
|
+
const { t } = useTranslation();
|
|
77
|
+
// Seed the visible input from the preselected option so edit-mode renders the
|
|
78
|
+
// current selection's label (the ComboboxInput shows the search text, which is
|
|
79
|
+
// empty on load — without this the field looks unselected despite holding a value).
|
|
80
|
+
const [searchQuery, setSearchQuery] = useState(
|
|
81
|
+
initialOption && value && initialOption.value === value ? initialOption.label : "",
|
|
82
|
+
);
|
|
83
|
+
const [asyncOptions, setAsyncOptions] = useState<EntityOption[]>([]);
|
|
84
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
85
|
+
const debounceRef = useRef<ReturnType<typeof setTimeout>>(undefined);
|
|
86
|
+
|
|
87
|
+
const isAsync = !!autocompleteHref;
|
|
88
|
+
|
|
89
|
+
const describedBy =
|
|
90
|
+
[error ? errorId : undefined, helpTextId].filter(Boolean).join(" ") || undefined;
|
|
91
|
+
|
|
92
|
+
// Stable empty array to avoid re-renders
|
|
93
|
+
const emptyOptions = useMemo<EntityOption[]>(() => [], []);
|
|
94
|
+
const safeStaticOptions = useMemo(
|
|
95
|
+
() => staticOptions ?? emptyOptions,
|
|
96
|
+
[staticOptions, emptyOptions],
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// Async fetch with debounce — setState only inside the timeout callback (async),
|
|
100
|
+
// never synchronously in the effect body.
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (!isAsync) return;
|
|
103
|
+
|
|
104
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
105
|
+
|
|
106
|
+
if (searchQuery.length < autocompleteMinChars) {
|
|
107
|
+
// Clear via a microtask to avoid synchronous setState in the effect body
|
|
108
|
+
debounceRef.current = setTimeout(() => setAsyncOptions([]), 0);
|
|
109
|
+
return () => {
|
|
110
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Pending from the moment the search is scheduled, not from when the request
|
|
115
|
+
// leaves: a host waiting on pending work (Moodle's Behat) would otherwise see
|
|
116
|
+
// an idle page during the debounce and read the still-empty list.
|
|
117
|
+
const release = beginPending();
|
|
118
|
+
|
|
119
|
+
debounceRef.current = setTimeout(async () => {
|
|
120
|
+
setIsLoading(true);
|
|
121
|
+
try {
|
|
122
|
+
const url = new URL(autocompleteHref!, window.location.origin);
|
|
123
|
+
url.searchParams.set("q", searchQuery);
|
|
124
|
+
const res = await trackedFetch(url.toString());
|
|
125
|
+
if (res.ok) {
|
|
126
|
+
const json = await res.json();
|
|
127
|
+
const items: EntityOption[] = (json.items ?? json.data ?? json).map(
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- server response
|
|
129
|
+
(item: any) => ({
|
|
130
|
+
value: String(item.value ?? item.id),
|
|
131
|
+
label: String(item.label ?? item.name ?? item.title ?? ""),
|
|
132
|
+
subtitle: entitySubtitleField ? String(item[entitySubtitleField] ?? "") : undefined,
|
|
133
|
+
avatarUrl: entityAvatarField ? String(item[entityAvatarField] ?? "") : undefined,
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
setAsyncOptions(items);
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
// Silent — field remains usable
|
|
140
|
+
} finally {
|
|
141
|
+
setIsLoading(false);
|
|
142
|
+
release();
|
|
143
|
+
}
|
|
144
|
+
}, 300);
|
|
145
|
+
|
|
146
|
+
return () => {
|
|
147
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
148
|
+
release();
|
|
149
|
+
};
|
|
150
|
+
}, [
|
|
151
|
+
searchQuery,
|
|
152
|
+
isAsync,
|
|
153
|
+
autocompleteHref,
|
|
154
|
+
autocompleteMinChars,
|
|
155
|
+
entitySubtitleField,
|
|
156
|
+
entityAvatarField,
|
|
157
|
+
]);
|
|
158
|
+
|
|
159
|
+
const baseOptions = isAsync ? asyncOptions : safeStaticOptions;
|
|
160
|
+
// Keep the currently-selected value renderable. In async mode the option list
|
|
161
|
+
// is empty until the user searches, so an edit-mode preset value (an id with no
|
|
162
|
+
// loaded label) renders blank. Splice the server-provided initialOption in until
|
|
163
|
+
// live results include it.
|
|
164
|
+
const options = useMemo<EntityOption[]>(() => {
|
|
165
|
+
if (
|
|
166
|
+
initialOption &&
|
|
167
|
+
value &&
|
|
168
|
+
initialOption.value === value &&
|
|
169
|
+
!baseOptions.some((o) => o.value === value)
|
|
170
|
+
) {
|
|
171
|
+
return [initialOption, ...baseOptions];
|
|
172
|
+
}
|
|
173
|
+
return baseOptions;
|
|
174
|
+
}, [baseOptions, initialOption, value]);
|
|
175
|
+
|
|
176
|
+
// Filter static options locally
|
|
177
|
+
const filteredOptions = useMemo(() => {
|
|
178
|
+
if (isAsync) return options;
|
|
179
|
+
if (!searchQuery) return options;
|
|
180
|
+
const q = searchQuery.toLowerCase();
|
|
181
|
+
return options.filter(
|
|
182
|
+
(o) => o.label.toLowerCase().includes(q) || o.subtitle?.toLowerCase().includes(q),
|
|
183
|
+
);
|
|
184
|
+
}, [options, searchQuery, isAsync]);
|
|
185
|
+
|
|
186
|
+
const handleValueChange = useCallback(
|
|
187
|
+
(val: string | null) => {
|
|
188
|
+
onChange(val ?? "");
|
|
189
|
+
},
|
|
190
|
+
[onChange],
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const emptyMessage = isLoading
|
|
194
|
+
? t("middag.ui.form.entity_loading")
|
|
195
|
+
: searchQuery.length < autocompleteMinChars && isAsync
|
|
196
|
+
? t("middag.ui.form.entity_min_chars").replace("{min}", String(autocompleteMinChars))
|
|
197
|
+
: t("middag.ui.form.entity_no_results");
|
|
198
|
+
|
|
199
|
+
const showAvatars = !!entityAvatarField || options.some((o) => o.avatarUrl);
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
<Combobox items={filteredOptions} value={value || null} onValueChange={handleValueChange}>
|
|
203
|
+
<ComboboxInput
|
|
204
|
+
id={id}
|
|
205
|
+
placeholder={placeholder ?? t("middag.ui.form.entity_search")}
|
|
206
|
+
disabled={disabled}
|
|
207
|
+
aria-invalid={error ? true : undefined}
|
|
208
|
+
aria-required={required || undefined}
|
|
209
|
+
aria-describedby={describedBy}
|
|
210
|
+
showClear={!!value}
|
|
211
|
+
showTrigger
|
|
212
|
+
value={searchQuery}
|
|
213
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
214
|
+
/>
|
|
215
|
+
<ComboboxContent>
|
|
216
|
+
<ComboboxEmpty className="px-4 py-3 text-sm">{emptyMessage}</ComboboxEmpty>
|
|
217
|
+
<ComboboxList>
|
|
218
|
+
{filteredOptions.map((option) => (
|
|
219
|
+
<ComboboxItem
|
|
220
|
+
key={option.value}
|
|
221
|
+
value={option.value}
|
|
222
|
+
className="flex items-center gap-2.5 px-3 py-2"
|
|
223
|
+
>
|
|
224
|
+
{showAvatars && (
|
|
225
|
+
<Avatar className="h-7 w-7 shrink-0">
|
|
226
|
+
{option.avatarUrl && <AvatarImage src={option.avatarUrl} alt={option.label} />}
|
|
227
|
+
<AvatarFallback className="text-[10px]">
|
|
228
|
+
{getInitials(option.label)}
|
|
229
|
+
</AvatarFallback>
|
|
230
|
+
</Avatar>
|
|
231
|
+
)}
|
|
232
|
+
<div className="min-w-0 flex-1">
|
|
233
|
+
<div className="truncate text-sm">{option.label}</div>
|
|
234
|
+
{option.subtitle && (
|
|
235
|
+
<div className="text-muted-foreground truncate text-xs">{option.subtitle}</div>
|
|
236
|
+
)}
|
|
237
|
+
</div>
|
|
238
|
+
</ComboboxItem>
|
|
239
|
+
))}
|
|
240
|
+
</ComboboxList>
|
|
241
|
+
</ComboboxContent>
|
|
242
|
+
</Combobox>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileUploadField — drag-drop file upload with previews and error handling.
|
|
3
|
+
*
|
|
4
|
+
* Uses the useFileUpload hook for drag-drop, file validation, and previews.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { useState, type ReactElement } from "react";
|
|
8
|
+
import { Cancel01Icon, FileEmpty02Icon, Upload01Icon } from "@hugeicons/core-free-icons";
|
|
9
|
+
import { HugeiconsIcon } from "@hugeicons/react";
|
|
10
|
+
|
|
11
|
+
import type { FileValue } from "@/contracts/generated";
|
|
12
|
+
import { useTranslation } from "@/i18n/useTranslation";
|
|
13
|
+
import {
|
|
14
|
+
formatBytes,
|
|
15
|
+
useFileUpload,
|
|
16
|
+
type FileMetadata,
|
|
17
|
+
type FileWithPreview,
|
|
18
|
+
} from "@/lib/hooks/use-file-upload";
|
|
19
|
+
import { cn } from "@/lib/utils";
|
|
20
|
+
import { Button } from "@/primitives/reui/button";
|
|
21
|
+
|
|
22
|
+
export interface FileUploadFieldProps {
|
|
23
|
+
id: string;
|
|
24
|
+
value: unknown;
|
|
25
|
+
onChange: (value: File[] | File | null) => void;
|
|
26
|
+
accept?: string;
|
|
27
|
+
multiple?: boolean;
|
|
28
|
+
maxFiles?: number;
|
|
29
|
+
maxSize?: number;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
required?: boolean;
|
|
32
|
+
error?: string;
|
|
33
|
+
helpTextId?: string;
|
|
34
|
+
errorId?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Server-provided shape for an already-uploaded file (edit mode). */
|
|
38
|
+
// The object form of a wire file value (the bare-URL string shorthand is
|
|
39
|
+
// handled separately). Derived from the generated FileValue contract so the
|
|
40
|
+
// field's parser tracks the PHP source of truth.
|
|
41
|
+
type ExistingFileValue = Exclude<FileValue, string>;
|
|
42
|
+
|
|
43
|
+
/** Derive a display name from a URL (strips query/hash and directories). */
|
|
44
|
+
function fileNameFromUrl(url: string): string {
|
|
45
|
+
const clean = url.split(/[?#]/)[0];
|
|
46
|
+
const segments = clean.split("/");
|
|
47
|
+
return segments[segments.length - 1] || clean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Normalize a single controlled value entry into FileMetadata.
|
|
52
|
+
* Accepts a URL string or an object with url/name. Real `File` instances and
|
|
53
|
+
* unrecognized shapes return null — those are new uploads managed by the hook,
|
|
54
|
+
* not pre-existing server files.
|
|
55
|
+
*/
|
|
56
|
+
function toFileMetadata(entry: unknown): FileMetadata | null {
|
|
57
|
+
if (entry == null || entry === "") return null;
|
|
58
|
+
|
|
59
|
+
if (typeof entry === "string") {
|
|
60
|
+
const name = fileNameFromUrl(entry);
|
|
61
|
+
return { name, size: 0, type: "", url: entry, id: entry };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (typeof entry === "object" && !(entry instanceof File)) {
|
|
65
|
+
const v = entry as ExistingFileValue;
|
|
66
|
+
const url = typeof v.url === "string" ? v.url : "";
|
|
67
|
+
const name = typeof v.name === "string" ? v.name : url ? fileNameFromUrl(url) : "";
|
|
68
|
+
if (!url && !name) return null;
|
|
69
|
+
return {
|
|
70
|
+
name,
|
|
71
|
+
size: typeof v.size === "number" ? v.size : 0,
|
|
72
|
+
type: typeof v.type === "string" ? v.type : "",
|
|
73
|
+
url,
|
|
74
|
+
id: typeof v.id === "string" && v.id ? v.id : url || name,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Normalize the controlled value into the FileMetadata[] the hook seeds at mount. */
|
|
82
|
+
function normalizeInitialFiles(value: unknown): FileMetadata[] {
|
|
83
|
+
const entries = Array.isArray(value) ? value : [value];
|
|
84
|
+
return entries.map(toFileMetadata).filter((f): f is FileMetadata => f !== null);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function FileUploadField({
|
|
88
|
+
id,
|
|
89
|
+
value,
|
|
90
|
+
onChange,
|
|
91
|
+
accept = "*",
|
|
92
|
+
multiple = false,
|
|
93
|
+
maxFiles = 10,
|
|
94
|
+
maxSize = 10 * 1024 * 1024,
|
|
95
|
+
disabled,
|
|
96
|
+
required,
|
|
97
|
+
error,
|
|
98
|
+
helpTextId,
|
|
99
|
+
errorId,
|
|
100
|
+
}: FileUploadFieldProps): ReactElement {
|
|
101
|
+
const { t } = useTranslation();
|
|
102
|
+
|
|
103
|
+
// Seed existing (server-provided) files once at mount — the hook reads
|
|
104
|
+
// initialFiles only in its state initializer. This mirrors edit-mode
|
|
105
|
+
// semantics: an untouched existing file stays in the RHF value (it is never
|
|
106
|
+
// re-uploaded because FileMetadata is filtered out of onChange below), a
|
|
107
|
+
// removal fires onChange, and a new upload replaces/adds as before.
|
|
108
|
+
const [initialFiles] = useState<FileMetadata[]>(() => normalizeInitialFiles(value));
|
|
109
|
+
|
|
110
|
+
const [
|
|
111
|
+
{ files, isDragging, errors: uploadErrors },
|
|
112
|
+
{
|
|
113
|
+
removeFile,
|
|
114
|
+
handleDragEnter,
|
|
115
|
+
handleDragLeave,
|
|
116
|
+
handleDragOver,
|
|
117
|
+
handleDrop,
|
|
118
|
+
openFileDialog,
|
|
119
|
+
getInputProps,
|
|
120
|
+
},
|
|
121
|
+
] = useFileUpload({
|
|
122
|
+
maxFiles: multiple ? maxFiles : 1,
|
|
123
|
+
maxSize,
|
|
124
|
+
accept,
|
|
125
|
+
multiple,
|
|
126
|
+
initialFiles,
|
|
127
|
+
onFilesChange: (items: FileWithPreview[]) => {
|
|
128
|
+
const rawFiles = items.map((f) => f.file).filter((f): f is File => f instanceof File);
|
|
129
|
+
if (multiple) {
|
|
130
|
+
onChange(rawFiles);
|
|
131
|
+
} else {
|
|
132
|
+
onChange(rawFiles[0] ?? null);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const describedBy =
|
|
138
|
+
[error ? errorId : undefined, helpTextId].filter(Boolean).join(" ") || undefined;
|
|
139
|
+
|
|
140
|
+
const isImage = (file: File | { type: string }) => file.type.startsWith("image/");
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<div>
|
|
144
|
+
{/* Drop zone */}
|
|
145
|
+
<div
|
|
146
|
+
className={cn(
|
|
147
|
+
"rounded-lg border border-dashed p-4 transition-colors",
|
|
148
|
+
isDragging
|
|
149
|
+
? "border-primary bg-primary/5"
|
|
150
|
+
: "border-muted-foreground/25 hover:border-muted-foreground/50",
|
|
151
|
+
disabled && "pointer-events-none opacity-50",
|
|
152
|
+
)}
|
|
153
|
+
onDragEnter={handleDragEnter}
|
|
154
|
+
onDragLeave={handleDragLeave}
|
|
155
|
+
onDragOver={handleDragOver}
|
|
156
|
+
onDrop={handleDrop}
|
|
157
|
+
>
|
|
158
|
+
<input
|
|
159
|
+
{...getInputProps()}
|
|
160
|
+
id={id}
|
|
161
|
+
className="sr-only"
|
|
162
|
+
disabled={disabled}
|
|
163
|
+
aria-invalid={error ? true : undefined}
|
|
164
|
+
aria-required={required || undefined}
|
|
165
|
+
aria-describedby={describedBy}
|
|
166
|
+
/>
|
|
167
|
+
|
|
168
|
+
{files.length === 0 ? (
|
|
169
|
+
/* Empty state */
|
|
170
|
+
<div className="flex flex-col items-center gap-2 py-4">
|
|
171
|
+
<HugeiconsIcon
|
|
172
|
+
icon={Upload01Icon}
|
|
173
|
+
className={cn("size-8", isDragging ? "text-primary" : "text-muted-foreground")}
|
|
174
|
+
/>
|
|
175
|
+
<p className="text-muted-foreground text-sm">{t("middag.ui.form.file_drop_hint")}</p>
|
|
176
|
+
<Button
|
|
177
|
+
type="button"
|
|
178
|
+
variant="outline"
|
|
179
|
+
size="sm"
|
|
180
|
+
onClick={openFileDialog}
|
|
181
|
+
disabled={disabled}
|
|
182
|
+
>
|
|
183
|
+
{t("middag.ui.form.file_browse")}
|
|
184
|
+
</Button>
|
|
185
|
+
<p className="text-muted-foreground text-xs">
|
|
186
|
+
{t("middag.ui.form.file_max_size")} {formatBytes(maxSize)}
|
|
187
|
+
</p>
|
|
188
|
+
</div>
|
|
189
|
+
) : (
|
|
190
|
+
/* File list */
|
|
191
|
+
<div className="space-y-2">
|
|
192
|
+
{files.map((fileItem) => (
|
|
193
|
+
<div
|
|
194
|
+
key={fileItem.id}
|
|
195
|
+
className="bg-muted/50 flex items-center gap-3 rounded-md px-3 py-2"
|
|
196
|
+
>
|
|
197
|
+
{isImage(fileItem.file) && fileItem.preview ? (
|
|
198
|
+
<img
|
|
199
|
+
src={fileItem.preview}
|
|
200
|
+
alt={fileItem.file.name}
|
|
201
|
+
className="size-10 shrink-0 rounded border object-cover"
|
|
202
|
+
/>
|
|
203
|
+
) : (
|
|
204
|
+
<div className="bg-muted flex size-10 shrink-0 items-center justify-center rounded border">
|
|
205
|
+
<HugeiconsIcon
|
|
206
|
+
icon={FileEmpty02Icon}
|
|
207
|
+
className="text-muted-foreground size-5"
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
)}
|
|
211
|
+
<div className="min-w-0 flex-1">
|
|
212
|
+
<p className="truncate text-sm font-medium">{fileItem.file.name}</p>
|
|
213
|
+
<p className="text-muted-foreground text-xs">{formatBytes(fileItem.file.size)}</p>
|
|
214
|
+
</div>
|
|
215
|
+
<Button
|
|
216
|
+
type="button"
|
|
217
|
+
variant="ghost"
|
|
218
|
+
size="icon-xs"
|
|
219
|
+
onClick={() => removeFile(fileItem.id)}
|
|
220
|
+
disabled={disabled}
|
|
221
|
+
>
|
|
222
|
+
<HugeiconsIcon icon={Cancel01Icon} className="size-3.5" />
|
|
223
|
+
</Button>
|
|
224
|
+
</div>
|
|
225
|
+
))}
|
|
226
|
+
{multiple && files.length < maxFiles && (
|
|
227
|
+
<Button
|
|
228
|
+
type="button"
|
|
229
|
+
variant="outline"
|
|
230
|
+
size="sm"
|
|
231
|
+
onClick={openFileDialog}
|
|
232
|
+
disabled={disabled}
|
|
233
|
+
>
|
|
234
|
+
{t("middag.ui.form.file_add_more")}
|
|
235
|
+
</Button>
|
|
236
|
+
)}
|
|
237
|
+
</div>
|
|
238
|
+
)}
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
{/* Upload errors */}
|
|
242
|
+
{uploadErrors.length > 0 && (
|
|
243
|
+
<div className="mt-1.5 space-y-0.5">
|
|
244
|
+
{uploadErrors.map((err, i) => (
|
|
245
|
+
<p key={i} className="text-destructive text-xs">
|
|
246
|
+
{err}
|
|
247
|
+
</p>
|
|
248
|
+
))}
|
|
249
|
+
</div>
|
|
250
|
+
)}
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
}
|