datocms-react-ui 3.1.0-next.5 → 3.1.0-next.9
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 +3 -2
- package/dist/DateInput.d.ts +2 -0
- package/dist/DateInput.js +2 -0
- package/dist/DateTimeInput.d.ts +2 -0
- package/dist/DateTimeInput.js +2 -0
- package/dist/DateTimeRangeInput.d.ts +2 -0
- package/dist/DateTimeRangeInput.js +2 -0
- package/dist/FieldTypeAvatar.d.ts +2 -0
- package/dist/FieldTypeAvatar.js +2 -0
- package/dist/FieldTypeName.d.ts +2 -0
- package/dist/FieldTypeName.js +2 -0
- package/dist/FilterBuilder.d.ts +2 -0
- package/dist/FilterBuilder.js +2 -0
- package/dist/LICENSE-lucide.txt +43 -0
- package/dist/RecordRow.d.ts +2 -0
- package/dist/RecordRow.js +2 -0
- package/dist/UploadCard.js +2 -2
- package/dist/UploadPreview.d.ts +2 -2
- package/dist/UploadPreview.js +1 -1
- package/dist/UserRow.d.ts +2 -0
- package/dist/UserRow.js +2 -0
- package/dist/react-ui/src/Canvas.d.ts +7 -1
- package/dist/react-ui/src/Canvas.js +26 -4
- package/dist/react-ui/src/ctxAnswer.js +21 -0
- package/dist/react-ui/src/ctxDateSettings.js +7 -5
- package/dist/react-ui/src/ctxRecordPresentation.js +34 -0
- package/dist/react-ui/src/ctxUploads.js +23 -0
- package/dist/styles.css +669 -63
- package/dist/ui-public/icons/index.js +313 -379
- package/dist/ui-public/icons/lucide/app-window.js +33 -0
- package/dist/ui-public/icons/lucide/arrow-big-down.js +22 -0
- package/dist/ui-public/icons/lucide/arrow-down-a-z.js +28 -0
- package/dist/ui-public/icons/lucide/arrow-down-from-line.js +26 -0
- package/dist/ui-public/icons/lucide/arrow-down.js +22 -0
- package/dist/ui-public/icons/lucide/arrow-left.js +22 -0
- package/dist/ui-public/icons/lucide/arrow-right-left.js +27 -0
- package/dist/ui-public/icons/lucide/arrow-right.js +22 -0
- package/dist/ui-public/icons/lucide/arrow-up-down.js +27 -0
- package/dist/ui-public/icons/lucide/arrow-up-from-line.js +26 -0
- package/dist/ui-public/icons/lucide/arrow-up.js +22 -0
- package/dist/ui-public/icons/lucide/ban.js +26 -0
- package/dist/ui-public/icons/lucide/book.js +22 -0
- package/dist/ui-public/icons/lucide/bookmark.js +22 -0
- package/dist/ui-public/icons/lucide/braces.js +22 -0
- package/dist/ui-public/icons/lucide/calendar.js +33 -0
- package/dist/ui-public/icons/{regular → lucide}/check.js +9 -3
- package/dist/ui-public/icons/{regular → lucide}/chevron-down.js +9 -3
- package/dist/ui-public/icons/{regular → lucide}/chevron-left.js +9 -3
- package/dist/ui-public/icons/{regular → lucide}/chevron-right.js +9 -3
- package/dist/ui-public/icons/lucide/chevrons-down.js +22 -0
- package/dist/ui-public/icons/lucide/chevrons-left.js +22 -0
- package/dist/ui-public/icons/lucide/chevrons-right.js +22 -0
- package/dist/ui-public/icons/lucide/circle-arrow-up.js +30 -0
- package/dist/ui-public/icons/lucide/circle-check.js +26 -0
- package/dist/ui-public/icons/lucide/circle-dot.js +30 -0
- package/dist/ui-public/icons/lucide/circle-exclamation-point.js +40 -0
- package/dist/ui-public/icons/lucide/circle-question-mark.js +30 -0
- package/dist/ui-public/icons/lucide/clock.js +26 -0
- package/dist/ui-public/icons/lucide/code.js +22 -0
- package/dist/ui-public/icons/lucide/command.js +22 -0
- package/dist/ui-public/icons/lucide/copy-plus.js +44 -0
- package/dist/ui-public/icons/lucide/copy.js +29 -0
- package/dist/ui-public/icons/lucide/corner-left-up.js +22 -0
- package/dist/ui-public/icons/lucide/database.js +31 -0
- package/dist/ui-public/icons/lucide/download.js +26 -0
- package/dist/ui-public/icons/lucide/earth.js +31 -0
- package/dist/ui-public/icons/lucide/ellipsis-vertical.js +38 -0
- package/dist/ui-public/icons/lucide/ellipsis.js +38 -0
- package/dist/ui-public/icons/lucide/external-link.js +26 -0
- package/dist/ui-public/icons/lucide/eye-off.js +27 -0
- package/dist/ui-public/icons/lucide/eye.js +26 -0
- package/dist/ui-public/icons/lucide/file-code.js +27 -0
- package/dist/ui-public/icons/lucide/file-output.js +27 -0
- package/dist/ui-public/icons/lucide/flask-conical.js +26 -0
- package/dist/ui-public/icons/lucide/fold-vertical.js +31 -0
- package/dist/ui-public/icons/lucide/folder-open.js +22 -0
- package/dist/ui-public/icons/lucide/folder-plus.js +26 -0
- package/dist/ui-public/icons/lucide/folder.js +22 -0
- package/dist/ui-public/icons/lucide/folders.js +22 -0
- package/dist/ui-public/icons/lucide/funnel.js +22 -0
- package/dist/ui-public/icons/lucide/gift.js +33 -0
- package/dist/ui-public/icons/lucide/git-branch.js +34 -0
- package/dist/ui-public/icons/lucide/git-fork.js +40 -0
- package/dist/ui-public/icons/lucide/globe.js +30 -0
- package/dist/ui-public/icons/lucide/grip-vertical.js +53 -0
- package/dist/ui-public/icons/lucide/hand.js +27 -0
- package/dist/ui-public/icons/lucide/hard-hat.js +33 -0
- package/dist/ui-public/icons/lucide/hash.js +47 -0
- package/dist/ui-public/icons/lucide/heading-1.js +27 -0
- package/dist/ui-public/icons/lucide/heading-2.js +27 -0
- package/dist/ui-public/icons/lucide/heading-3.js +28 -0
- package/dist/ui-public/icons/lucide/heading-4.js +28 -0
- package/dist/ui-public/icons/lucide/heading-5.js +28 -0
- package/dist/ui-public/icons/lucide/heading-6.js +32 -0
- package/dist/ui-public/icons/lucide/highlighter.js +22 -0
- package/dist/ui-public/icons/lucide/hourglass.js +27 -0
- package/dist/ui-public/icons/lucide/house.js +22 -0
- package/dist/ui-public/icons/lucide/image.js +37 -0
- package/dist/ui-public/icons/lucide/images.js +38 -0
- package/dist/ui-public/icons/lucide/info.js +30 -0
- package/dist/ui-public/icons/lucide/italic.js +41 -0
- package/dist/ui-public/icons/lucide/keyboard.js +38 -0
- package/dist/ui-public/icons/lucide/languages.js +29 -0
- package/dist/ui-public/icons/lucide/layers.js +26 -0
- package/dist/ui-public/icons/lucide/layout-grid.js +51 -0
- package/dist/ui-public/icons/lucide/letter-b.js +22 -0
- package/dist/ui-public/icons/lucide/letter-text.js +28 -0
- package/dist/ui-public/icons/lucide/life-buoy.js +37 -0
- package/dist/ui-public/icons/lucide/link.js +22 -0
- package/dist/ui-public/icons/lucide/list-indent-decrease.js +27 -0
- package/dist/ui-public/icons/lucide/list-indent-increase.js +27 -0
- package/dist/ui-public/icons/lucide/list-ordered.js +29 -0
- package/dist/ui-public/icons/lucide/list-tree.js +28 -0
- package/dist/ui-public/icons/lucide/list.js +29 -0
- package/dist/ui-public/icons/lucide/log-out.js +26 -0
- package/dist/ui-public/icons/lucide/mail.js +28 -0
- package/dist/ui-public/icons/lucide/map-pin.js +26 -0
- package/dist/ui-public/icons/lucide/map-pinned.js +30 -0
- package/dist/ui-public/icons/lucide/maximize.js +27 -0
- package/dist/ui-public/icons/lucide/menu.js +26 -0
- package/dist/ui-public/icons/lucide/messages-square.js +22 -0
- package/dist/ui-public/icons/lucide/minimize.js +27 -0
- package/dist/ui-public/icons/lucide/minus.js +22 -0
- package/dist/ui-public/icons/lucide/notepad-text.js +36 -0
- package/dist/ui-public/icons/lucide/octagon-exclamation-point.js +26 -0
- package/dist/ui-public/icons/lucide/palette.js +48 -0
- package/dist/ui-public/icons/lucide/panel-left.js +28 -0
- package/dist/ui-public/icons/lucide/panel-right.js +28 -0
- package/dist/ui-public/icons/lucide/pause.js +34 -0
- package/dist/ui-public/icons/lucide/pen.js +22 -0
- package/dist/ui-public/icons/lucide/pilcrow.js +26 -0
- package/dist/ui-public/icons/lucide/pipette.js +26 -0
- package/dist/ui-public/icons/lucide/play.js +22 -0
- package/dist/ui-public/icons/lucide/plus.js +22 -0
- package/dist/ui-public/icons/lucide/quote.js +22 -0
- package/dist/ui-public/icons/lucide/redo-2.js +22 -0
- package/dist/ui-public/icons/lucide/refresh-cw.js +27 -0
- package/dist/ui-public/icons/lucide/rotate-ccw-clock.js +26 -0
- package/dist/ui-public/icons/lucide/rotate-ccw.js +22 -0
- package/dist/ui-public/icons/lucide/rows-3.js +32 -0
- package/dist/ui-public/icons/lucide/search.js +26 -0
- package/dist/ui-public/icons/lucide/send.js +22 -0
- package/dist/ui-public/icons/lucide/settings-2.js +35 -0
- package/dist/ui-public/icons/lucide/settings.js +26 -0
- package/dist/ui-public/icons/lucide/sliders-horizontal.js +32 -0
- package/dist/ui-public/icons/lucide/smartphone.js +29 -0
- package/dist/ui-public/icons/lucide/square-arrow-left.js +32 -0
- package/dist/ui-public/icons/lucide/square-arrow-up-right.js +32 -0
- package/dist/ui-public/icons/lucide/square-code.js +32 -0
- package/dist/ui-public/icons/lucide/square-dashed.js +35 -0
- package/dist/ui-public/icons/lucide/square-pen.js +22 -0
- package/dist/ui-public/icons/lucide/square-plus.js +32 -0
- package/dist/ui-public/icons/lucide/square-terminal.js +33 -0
- package/dist/ui-public/icons/lucide/store.js +26 -0
- package/dist/ui-public/icons/lucide/strikethrough.js +31 -0
- package/dist/ui-public/icons/lucide/table.js +33 -0
- package/dist/ui-public/icons/lucide/tag.js +27 -0
- package/dist/ui-public/icons/lucide/text-align-center.js +26 -0
- package/dist/ui-public/icons/lucide/text-align-end.js +26 -0
- package/dist/ui-public/icons/lucide/text-align-justify.js +26 -0
- package/dist/ui-public/icons/lucide/text-align-start.js +26 -0
- package/dist/ui-public/icons/lucide/toggle-right.js +32 -0
- package/dist/ui-public/icons/lucide/toolbox.js +28 -0
- package/dist/ui-public/icons/lucide/trash.js +28 -0
- package/dist/ui-public/icons/lucide/triangle-exclamation-point.js +26 -0
- package/dist/ui-public/icons/lucide/underline.js +27 -0
- package/dist/ui-public/icons/lucide/undo-2.js +22 -0
- package/dist/ui-public/icons/lucide/unfold-vertical.js +31 -0
- package/dist/ui-public/icons/lucide/user-lock.js +37 -0
- package/dist/ui-public/icons/lucide/user-minus.js +35 -0
- package/dist/ui-public/icons/lucide/user-round-arrow-left.js +31 -0
- package/dist/ui-public/icons/lucide/user.js +26 -0
- package/dist/ui-public/icons/lucide/x.js +22 -0
- package/dist/ui-public/locales/en.js +76 -5
- package/dist/ui-public/src/Message.d.ts +3 -4
- package/dist/ui-public/src/UiTextKey.d.ts +1 -1
- package/dist/ui-public/src/actions/Actions/ActionTooltip.js +1 -1
- package/dist/ui-public/src/actions/Actions/registry.d.ts +2 -2
- package/dist/ui-public/src/actions/Actions/registry.js +2 -2
- package/dist/ui-public/src/actions/Button.d.ts +16 -11
- package/dist/ui-public/src/actions/Button.js +7 -1
- package/dist/ui-public/src/actions/Dropdown/Menu.d.ts +2 -2
- package/dist/ui-public/src/actions/Dropdown/Option.d.ts +7 -7
- package/dist/ui-public/src/actions/Dropdown/index.d.ts +1 -1
- package/dist/ui-public/src/actions/Dropdown/triggers/ButtonTrigger.d.ts +5 -5
- package/dist/ui-public/src/actions/Dropdown/triggers/DropdownTriggerButton.d.ts +2 -2
- package/dist/ui-public/src/actions/Dropdown/triggers/IconTrigger.d.ts +6 -6
- package/dist/ui-public/src/actions/Dropdown/triggers/IconTrigger.js +1 -1
- package/dist/ui-public/src/actions/EditorToolbar/Button.d.ts +1 -1
- package/dist/ui-public/src/actions/MultipleSelectionActionBar.d.ts +1 -1
- package/dist/ui-public/src/actions/SplitButton/Caret.js +2 -2
- package/dist/ui-public/src/actions/SplitButton/Halves.js +1 -1
- package/dist/ui-public/src/actions/SplitButton/index.d.ts +3 -3
- package/dist/ui-public/src/actions/disabledReason.d.ts +4 -4
- package/dist/ui-public/src/actions/disabledReason.js +1 -1
- package/dist/ui-public/src/content/Avatar.d.ts +3 -3
- package/dist/ui-public/src/content/Avatar.js +2 -2
- package/dist/ui-public/src/content/CodeSnippet.d.ts +1 -1
- package/dist/ui-public/src/content/CopyableValue.d.ts +1 -1
- package/dist/ui-public/src/content/EnvironmentPill.d.ts +1 -1
- package/dist/ui-public/src/content/EnvironmentPill.js +1 -1
- package/dist/ui-public/src/content/FieldTypeAvatar.d.ts +22 -0
- package/dist/ui-public/src/content/FieldTypeAvatar.js +35 -0
- package/dist/ui-public/src/content/FieldTypeName.d.ts +19 -0
- package/dist/ui-public/src/content/FieldTypeName.js +25 -0
- package/dist/ui-public/src/content/IconAvatar.d.ts +3 -2
- package/dist/ui-public/src/content/ItemStatus.d.ts +1 -1
- package/dist/ui-public/src/content/Pill.d.ts +1 -1
- package/dist/ui-public/src/content/SmartDate.d.ts +1 -1
- package/dist/ui-public/src/content/UploadPreview/asset.js +200 -0
- package/dist/ui-public/src/content/UploadPreview/audio.js +120 -0
- package/dist/ui-public/src/content/{UploadPreview.d.ts → UploadPreview/box.d.ts} +10 -10
- package/dist/ui-public/src/content/{UploadPreview.js → UploadPreview/box.js} +7 -7
- package/dist/ui-public/src/content/{uploadPreviewFit.d.ts → UploadPreview/fit.d.ts} +2 -2
- package/dist/ui-public/src/content/{uploadPreviewFit.js → UploadPreview/fit.js} +3 -3
- package/dist/ui-public/src/content/UploadPreview/index.d.ts +61 -0
- package/dist/ui-public/src/content/UploadPreview/index.js +36 -0
- package/dist/ui-public/src/content/UploadPreview/presentation.js +63 -0
- package/dist/ui-public/src/content/UploadPreview/thumbhash.js +91 -0
- package/dist/ui-public/src/content/UploadPreview/upload.d.ts +104 -0
- package/dist/ui-public/src/content/UploadPreview/upload.js +112 -0
- package/dist/ui-public/src/content/UploadThreatTriangle.js +1 -1
- package/dist/ui-public/src/content/UsageMeter.d.ts +1 -1
- package/dist/ui-public/src/content/ValidityTriangles.d.ts +1 -1
- package/dist/ui-public/src/content/ValidityTriangles.js +1 -1
- package/dist/ui-public/src/feedback/BlankSlate.d.ts +5 -5
- package/dist/ui-public/src/feedback/Callout.d.ts +5 -5
- package/dist/ui-public/src/feedback/Callout.js +1 -1
- package/dist/ui-public/src/feedback/ProgressBar.d.ts +4 -4
- package/dist/ui-public/src/feedback/Spinner.d.ts +6 -6
- package/dist/ui-public/src/feedback/Spinner.js +1 -1
- package/dist/ui-public/src/form/DateInput.d.ts +13 -0
- package/dist/ui-public/src/form/DateInput.js +16 -0
- package/dist/ui-public/src/form/DateTimeInput/Base.d.ts +89 -0
- package/dist/ui-public/src/form/DateTimeInput/Base.js +330 -0
- package/dist/ui-public/src/form/DateTimeInput/CalendarGrid.d.ts +29 -0
- package/dist/ui-public/src/form/DateTimeInput/CalendarGrid.js +195 -0
- package/dist/ui-public/src/form/DateTimeInput/dateText.js +38 -0
- package/dist/ui-public/src/form/DateTimeInput/index.d.ts +10 -0
- package/dist/ui-public/src/form/DateTimeInput/index.js +18 -0
- package/dist/ui-public/src/form/DateTimeInput/value.js +31 -0
- package/dist/ui-public/src/form/DateTimeRangeInput/Panel.js +167 -0
- package/dist/ui-public/src/form/DateTimeRangeInput/index.d.ts +123 -0
- package/dist/ui-public/src/form/DateTimeRangeInput/index.js +186 -0
- package/dist/ui-public/src/form/DateTimeRangeInput/rangeLabel.js +46 -0
- package/dist/ui-public/src/form/FieldHint.d.ts +2 -2
- package/dist/ui-public/src/form/FieldWrapper.d.ts +9 -9
- package/dist/ui-public/src/form/FieldWrapper.js +3 -3
- package/dist/ui-public/src/form/FilterBuilder/Editor.js +123 -0
- package/dist/ui-public/src/form/FilterBuilder/index.d.ts +9 -0
- package/dist/ui-public/src/form/FilterBuilder/index.js +294 -0
- package/dist/ui-public/src/form/FilterBuilder/types.d.ts +188 -0
- package/dist/ui-public/src/form/FilterBuilder/values.js +86 -0
- package/dist/ui-public/src/form/InputGroup.d.ts +2 -2
- package/dist/ui-public/src/form/InputGroup.js +1 -1
- package/dist/ui-public/src/form/KeyValueList.d.ts +1 -1
- package/dist/ui-public/src/form/Label.d.ts +2 -2
- package/dist/ui-public/src/form/PasswordInput.js +1 -9
- package/dist/ui-public/src/form/RadioGroupInput.d.ts +2 -2
- package/dist/ui-public/src/form/RadioGroupInput.js +1 -1
- package/dist/ui-public/src/form/SelectInput/SelectMenu.d.ts +2 -2
- package/dist/ui-public/src/form/SelectInput/index.d.ts +3 -3
- package/dist/ui-public/src/form/SwitchInput.d.ts +2 -2
- package/dist/ui-public/src/form/SwitchList.d.ts +1 -1
- package/dist/ui-public/src/form/SwitchList.js +1 -1
- package/dist/ui-public/src/form/TableList.d.ts +2 -2
- package/dist/ui-public/src/form/TextareaInput.js +1 -1
- package/dist/ui-public/src/form/inputProps.d.ts +6 -6
- package/dist/ui-public/src/hooks/useAsyncSelectOptions.d.ts +1 -1
- package/dist/ui-public/src/hooks/useSmartRowClick.d.ts +1 -1
- package/dist/ui-public/src/hooks/useSmartRowClick.js +1 -1
- package/dist/ui-public/src/layout/Page/PageGroup.d.ts +2 -2
- package/dist/ui-public/src/layout/Page/PageGroup.js +1 -1
- package/dist/ui-public/src/layout/Pane/FormHeader.d.ts +1 -1
- package/dist/ui-public/src/layout/Pane/FormHeader.js +1 -1
- package/dist/ui-public/src/layout/Pane/ListFilter.d.ts +1 -1
- package/dist/ui-public/src/layout/Pane/ListPresets.d.ts +1 -1
- package/dist/ui-public/src/layout/Pane/PaneHeader.d.ts +1 -1
- package/dist/ui-public/src/layout/Pane/index.d.ts +8 -8
- package/dist/ui-public/src/layout/Pane/index.js +17 -8
- package/dist/ui-public/src/layout/SidebarPanel.d.ts +1 -1
- package/dist/ui-public/src/layout/SplitPane/Rail.js +1 -1
- package/dist/ui-public/src/layout/SplitPane/index.d.ts +6 -6
- package/dist/ui-public/src/layout/SplitPane/index.js +16 -2
- package/dist/ui-public/src/layout/Toolbar/AddNewButton.d.ts +2 -2
- package/dist/ui-public/src/layout/Toolbar/FilterToggle.d.ts +1 -1
- package/dist/ui-public/src/layout/Toolbar/FilterToggle.js +12 -4
- package/dist/ui-public/src/layout/Toolbar/Help.d.ts +3 -3
- package/dist/ui-public/src/layout/Toolbar/Help.js +2 -2
- package/dist/ui-public/src/layout/Toolbar/Note.d.ts +1 -1
- package/dist/ui-public/src/layout/Toolbar/Note.js +1 -1
- package/dist/ui-public/src/layout/Toolbar/Pagination.d.ts +1 -1
- package/dist/ui-public/src/layout/Toolbar/Pagination.js +1 -1
- package/dist/ui-public/src/layout/Toolbar/PresetsTitle.d.ts +3 -3
- package/dist/ui-public/src/layout/Toolbar/PresetsTitle.js +2 -2
- package/dist/ui-public/src/layout/Toolbar/PrimaryButton.d.ts +3 -3
- package/dist/ui-public/src/layout/Toolbar/Root.d.ts +1 -1
- package/dist/ui-public/src/layout/Toolbar/Root.js +4 -1
- package/dist/ui-public/src/layout/Toolbar/ToolbarTitleTrigger.js +1 -1
- package/dist/ui-public/src/lists/CardList.d.ts +3 -3
- package/dist/ui-public/src/lists/EmptySlot.d.ts +1 -1
- package/dist/ui-public/src/lists/InfoList/User.d.ts +1 -1
- package/dist/ui-public/src/lists/InfoList/Value.d.ts +1 -1
- package/dist/ui-public/src/lists/InfoList/Value.js +1 -1
- package/dist/ui-public/src/lists/InfoList/index.d.ts +3 -3
- package/dist/ui-public/src/lists/InfoList/index.js +1 -1
- package/dist/ui-public/src/lists/MediaCard.d.ts +7 -7
- package/dist/ui-public/src/lists/RecordRow/Image.d.ts +24 -0
- package/dist/ui-public/src/lists/RecordRow/Image.js +22 -0
- package/dist/ui-public/src/lists/RecordRow/List.d.ts +26 -0
- package/dist/ui-public/src/lists/RecordRow/List.js +30 -0
- package/dist/ui-public/src/lists/RecordRow/context.js +31 -0
- package/dist/ui-public/src/lists/RecordRow/index.d.ts +94 -0
- package/dist/ui-public/src/lists/RecordRow/index.js +122 -0
- package/dist/ui-public/src/lists/RecordRow/presentation.js +73 -0
- package/dist/ui-public/src/lists/RecordRow/types.d.ts +58 -0
- package/dist/ui-public/src/lists/RowList.d.ts +5 -5
- package/dist/ui-public/src/lists/SettingsList.d.ts +3 -3
- package/dist/ui-public/src/lists/SettingsList.js +2 -2
- package/dist/ui-public/src/lists/Table/Row.d.ts +5 -5
- package/dist/ui-public/src/lists/Table/Table.d.ts +3 -3
- package/dist/ui-public/src/lists/Table/TreeToggle.d.ts +2 -2
- package/dist/ui-public/src/lists/Table/TreeToggle.js +5 -4
- package/dist/ui-public/src/lists/Table/cells/LinkCell.d.ts +1 -1
- package/dist/ui-public/src/lists/TreeRow/Action.d.ts +1 -1
- package/dist/ui-public/src/lists/TreeRow/Action.js +1 -1
- package/dist/ui-public/src/lists/TreeRow/Link.d.ts +1 -1
- package/dist/ui-public/src/lists/TreeRow/Link.js +1 -1
- package/dist/ui-public/src/lists/UploadCard.d.ts +66 -3
- package/dist/ui-public/src/lists/UploadCard.js +116 -7
- package/dist/ui-public/src/lists/UserRow.d.ts +122 -0
- package/dist/ui-public/src/lists/UserRow.js +104 -0
- package/dist/ui-public/src/lists/dnd/DragHandle.d.ts +2 -2
- package/dist/ui-public/src/lists/dnd/SortableList.d.ts +1 -1
- package/dist/ui-public/src/lists/dnd/dropTargetClassName.d.ts +1 -1
- package/dist/ui-public/src/lists/dnd/tree/SortableTree.d.ts +2 -2
- package/dist/ui-public/src/navigation/Chevron.d.ts +4 -4
- package/dist/ui-public/src/navigation/Chevron.js +1 -1
- package/dist/ui-public/src/navigation/Link.d.ts +5 -5
- package/dist/ui-public/src/navigation/Link.js +1 -1
- package/dist/ui-public/src/navigation/NavList.d.ts +1 -1
- package/dist/ui-public/src/navigation/NavList.js +1 -1
- package/dist/ui-public/src/navigation/NavigationProvider.d.ts +1 -1
- package/dist/ui-public/src/navigation/SegmentedControl.d.ts +2 -2
- package/dist/ui-public/src/navigation/SettingsMenu.d.ts +8 -8
- package/dist/ui-public/src/navigation/SettingsMenu.js +1 -1
- package/dist/ui-public/src/navigation/SidebarTree/SidebarTreeNode.d.ts +4 -4
- package/dist/ui-public/src/navigation/SidebarTree/SidebarTreeNodeActions.d.ts +3 -0
- package/dist/ui-public/src/navigation/SidebarTree/SidebarTreeNodeActions.js +2 -1
- package/dist/ui-public/src/overlays/FullscreenModal/TitleContext.d.ts +1 -1
- package/dist/ui-public/src/overlays/FullscreenModal/TitleContext.js +1 -1
- package/dist/ui-public/src/overlays/HoverCard/index.js +1 -1
- package/dist/ui-public/src/overlays/NewZIndex.d.ts +1 -1
- package/dist/ui-public/src/overlays/NewZIndex.js +1 -1
- package/dist/ui-public/src/overlays/Popover.d.ts +1 -1
- package/dist/ui-public/src/overlays/PortalWrapper.js +1 -1
- package/dist/ui-public/src/overlays/useModalClose.js +3 -3
- package/dist/ui-public/src/patterns/ListDetail/FloatingDetail.js +71 -0
- package/dist/ui-public/src/patterns/ListDetail/Overview.js +2 -2
- package/dist/ui-public/src/patterns/ListDetail/Page.d.ts +8 -9
- package/dist/ui-public/src/patterns/ListDetail/Page.js +12 -9
- package/dist/ui-public/src/patterns/ListDetail/Panel.d.ts +2 -2
- package/dist/ui-public/src/patterns/ListDetail/Panel.js +12 -11
- package/dist/ui-public/src/patterns/ListDetail/Split.d.ts +25 -11
- package/dist/ui-public/src/patterns/ListDetail/Split.js +99 -115
- package/dist/ui-public/src/patterns/ListDetail/index.d.ts +4 -3
- package/dist/ui-public/src/patterns/ListDetail/useDetailWidthDrag.js +43 -0
- package/dist/ui-public/src/patterns/ListFormPage.d.ts +3 -3
- package/dist/ui-public/src/patterns/ListFormPage.js +1 -1
- package/dist/ui-public/src/semantic/Heading.d.ts +1 -1
- package/dist/ui-public/src/semantic/Heading.js +1 -1
- package/dist/ui-public/src/semantic/Image.js +1 -1
- package/dist/ui-public/src/semantic/Nav.d.ts +3 -3
- package/dist/ui-public/src/semantic/Nav.js +3 -3
- package/dist/ui-public/src/semantic/RawButton.d.ts +3 -3
- package/dist/ui-public/src/semantic/RawButton.js +1 -1
- package/dist/ui-public/src/semantic/Search.d.ts +1 -1
- package/dist/ui-public/src/semantic/Search.js +1 -1
- package/dist/ui-public/src/utils/fieldTypes.d.ts +29 -0
- package/dist/ui-public/src/utils/fieldTypes.js +94 -0
- package/dist/ui-public/src/utils/format.d.ts +21 -0
- package/dist/ui-public/src/utils/format.js +20 -0
- package/dist/ui-public/src/utils/formatDate.d.ts +10 -2
- package/dist/ui-public/src/utils/formatDate.js +4 -4
- package/dist/ui-public/src/utils/tickBatcher.js +44 -0
- package/dist/ui-public/src/utils/timezones.js +277 -0
- package/dist/ui-public/src/utils/weekStartForLocale.js +25 -0
- package/dist/utils/fieldTypes.d.ts +1 -0
- package/dist/utils/fieldTypes.js +2 -0
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/format.js +2 -0
- package/package.json +3 -3
- package/dist/ui-public/icons/brands/gitlab.js +0 -15
- package/dist/ui-public/icons/brands/markdown.js +0 -15
- package/dist/ui-public/icons/custom/fieldgroup-boolean.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-color.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-datetime.js +0 -49
- package/dist/ui-public/icons/custom/fieldgroup-json.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-location.js +0 -19
- package/dist/ui-public/icons/custom/fieldgroup-media.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-number.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-reference.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-rich_text.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-seo.js +0 -22
- package/dist/ui-public/icons/custom/fieldgroup-structured_text.js +0 -61
- package/dist/ui-public/icons/custom/language.js +0 -16
- package/dist/ui-public/icons/custom/masonry.js +0 -21
- package/dist/ui-public/icons/light/eye-slash.js +0 -16
- package/dist/ui-public/icons/light/eye.js +0 -16
- package/dist/ui-public/icons/regular/align-left.js +0 -15
- package/dist/ui-public/icons/regular/arrow-down-a-z.js +0 -16
- package/dist/ui-public/icons/regular/arrow-down-from-line.js +0 -16
- package/dist/ui-public/icons/regular/arrow-down-to-line.js +0 -15
- package/dist/ui-public/icons/regular/arrow-down.js +0 -16
- package/dist/ui-public/icons/regular/arrow-left.js +0 -16
- package/dist/ui-public/icons/regular/arrow-right-arrow-left.js +0 -16
- package/dist/ui-public/icons/regular/arrow-right-from-bracket.js +0 -16
- package/dist/ui-public/icons/regular/arrow-right.js +0 -16
- package/dist/ui-public/icons/regular/arrow-rotate-left.js +0 -15
- package/dist/ui-public/icons/regular/arrow-rotate-right.js +0 -16
- package/dist/ui-public/icons/regular/arrow-turn-up.js +0 -16
- package/dist/ui-public/icons/regular/arrow-up-arrow-down.js +0 -16
- package/dist/ui-public/icons/regular/arrow-up-from-line.js +0 -16
- package/dist/ui-public/icons/regular/arrow-up-right-from-square.js +0 -16
- package/dist/ui-public/icons/regular/arrow-up-to-line.js +0 -15
- package/dist/ui-public/icons/regular/arrow-up.js +0 -16
- package/dist/ui-public/icons/regular/arrows-from-line.js +0 -16
- package/dist/ui-public/icons/regular/arrows-rotate.js +0 -16
- package/dist/ui-public/icons/regular/arrows-to-line.js +0 -16
- package/dist/ui-public/icons/regular/arrows-turn-to-dots.js +0 -15
- package/dist/ui-public/icons/regular/badge-check.js +0 -15
- package/dist/ui-public/icons/regular/ballot-check.js +0 -15
- package/dist/ui-public/icons/regular/ban.js +0 -16
- package/dist/ui-public/icons/regular/bars.js +0 -16
- package/dist/ui-public/icons/regular/bold.js +0 -15
- package/dist/ui-public/icons/regular/bolt.js +0 -15
- package/dist/ui-public/icons/regular/book.js +0 -16
- package/dist/ui-public/icons/regular/bookmark.js +0 -16
- package/dist/ui-public/icons/regular/brackets-curly.js +0 -15
- package/dist/ui-public/icons/regular/browser.js +0 -16
- package/dist/ui-public/icons/regular/calendar-clock.js +0 -15
- package/dist/ui-public/icons/regular/calendar.js +0 -16
- package/dist/ui-public/icons/regular/chart-area.js +0 -15
- package/dist/ui-public/icons/regular/chevrons-down.js +0 -16
- package/dist/ui-public/icons/regular/chevrons-left.js +0 -16
- package/dist/ui-public/icons/regular/chevrons-right.js +0 -16
- package/dist/ui-public/icons/regular/circle-arrow-up.js +0 -16
- package/dist/ui-public/icons/regular/circle-check.js +0 -16
- package/dist/ui-public/icons/regular/circle-dot.js +0 -16
- package/dist/ui-public/icons/regular/circle-exclamation.js +0 -16
- package/dist/ui-public/icons/regular/circle-info.js +0 -16
- package/dist/ui-public/icons/regular/circle-question.js +0 -16
- package/dist/ui-public/icons/regular/clapperboard-play.js +0 -15
- package/dist/ui-public/icons/regular/clipboard.js +0 -15
- package/dist/ui-public/icons/regular/clock-rotate-left.js +0 -16
- package/dist/ui-public/icons/regular/clock.js +0 -16
- package/dist/ui-public/icons/regular/clone.js +0 -16
- package/dist/ui-public/icons/regular/cloud-arrow-down.js +0 -15
- package/dist/ui-public/icons/regular/code-branch.js +0 -16
- package/dist/ui-public/icons/regular/code-fork.js +0 -16
- package/dist/ui-public/icons/regular/command.js +0 -16
- package/dist/ui-public/icons/regular/comments.js +0 -16
- package/dist/ui-public/icons/regular/copy.js +0 -16
- package/dist/ui-public/icons/regular/cube.js +0 -15
- package/dist/ui-public/icons/regular/cubes.js +0 -15
- package/dist/ui-public/icons/regular/dash.js +0 -16
- package/dist/ui-public/icons/regular/database.js +0 -16
- package/dist/ui-public/icons/regular/diamond.js +0 -15
- package/dist/ui-public/icons/regular/down.js +0 -16
- package/dist/ui-public/icons/regular/download.js +0 -16
- package/dist/ui-public/icons/regular/earth-europe.js +0 -16
- package/dist/ui-public/icons/regular/ellipsis-vertical.js +0 -16
- package/dist/ui-public/icons/regular/ellipsis.js +0 -16
- package/dist/ui-public/icons/regular/envelope.js +0 -16
- package/dist/ui-public/icons/regular/expand.js +0 -16
- package/dist/ui-public/icons/regular/eye-dropper.js +0 -16
- package/dist/ui-public/icons/regular/eye.js +0 -16
- package/dist/ui-public/icons/regular/file-export.js +0 -16
- package/dist/ui-public/icons/regular/file-lines.js +0 -15
- package/dist/ui-public/icons/regular/file-shield.js +0 -15
- package/dist/ui-public/icons/regular/file.js +0 -15
- package/dist/ui-public/icons/regular/filter.js +0 -16
- package/dist/ui-public/icons/regular/fire-flame-curved.js +0 -15
- package/dist/ui-public/icons/regular/flask-gear.js +0 -16
- package/dist/ui-public/icons/regular/flask.js +0 -16
- package/dist/ui-public/icons/regular/folder-gear.js +0 -15
- package/dist/ui-public/icons/regular/folder-magnifying-glass.js +0 -15
- package/dist/ui-public/icons/regular/folder-open.js +0 -16
- package/dist/ui-public/icons/regular/folder-plus.js +0 -16
- package/dist/ui-public/icons/regular/folder.js +0 -16
- package/dist/ui-public/icons/regular/folders.js +0 -16
- package/dist/ui-public/icons/regular/gear.js +0 -16
- package/dist/ui-public/icons/regular/gift.js +0 -16
- package/dist/ui-public/icons/regular/globe.js +0 -16
- package/dist/ui-public/icons/regular/grid-2.js +0 -16
- package/dist/ui-public/icons/regular/grip-dots-vertical.js +0 -16
- package/dist/ui-public/icons/regular/hand.js +0 -16
- package/dist/ui-public/icons/regular/hourglass-clock.js +0 -16
- package/dist/ui-public/icons/regular/house.js +0 -16
- package/dist/ui-public/icons/regular/images.js +0 -16
- package/dist/ui-public/icons/regular/input-numeric.js +0 -15
- package/dist/ui-public/icons/regular/input-text.js +0 -15
- package/dist/ui-public/icons/regular/keyboard.js +0 -16
- package/dist/ui-public/icons/regular/layer-group.js +0 -16
- package/dist/ui-public/icons/regular/life-ring.js +0 -16
- package/dist/ui-public/icons/regular/link-simple.js +0 -15
- package/dist/ui-public/icons/regular/link.js +0 -16
- package/dist/ui-public/icons/regular/list-tree.js +0 -16
- package/dist/ui-public/icons/regular/list.js +0 -16
- package/dist/ui-public/icons/regular/magnifying-glass-chart.js +0 -15
- package/dist/ui-public/icons/regular/magnifying-glass.js +0 -16
- package/dist/ui-public/icons/regular/map-location-dot.js +0 -16
- package/dist/ui-public/icons/regular/memo.js +0 -16
- package/dist/ui-public/icons/regular/mobile-screen-button.js +0 -16
- package/dist/ui-public/icons/regular/octagon-exclamation.js +0 -16
- package/dist/ui-public/icons/regular/palette.js +0 -16
- package/dist/ui-public/icons/regular/paper-plane.js +0 -16
- package/dist/ui-public/icons/regular/paragraph.js +0 -15
- package/dist/ui-public/icons/regular/paste.js +0 -15
- package/dist/ui-public/icons/regular/pause.js +0 -16
- package/dist/ui-public/icons/regular/pen-paintbrush.js +0 -15
- package/dist/ui-public/icons/regular/pen-to-square.js +0 -16
- package/dist/ui-public/icons/regular/pen.js +0 -16
- package/dist/ui-public/icons/regular/people-arrows.js +0 -16
- package/dist/ui-public/icons/regular/photo-film.js +0 -15
- package/dist/ui-public/icons/regular/play.js +0 -16
- package/dist/ui-public/icons/regular/puzzle-piece.js +0 -15
- package/dist/ui-public/icons/regular/receipt.js +0 -16
- package/dist/ui-public/icons/regular/rectangle-barcode.js +0 -15
- package/dist/ui-public/icons/regular/rectangle-list.js +0 -15
- package/dist/ui-public/icons/regular/right-left.js +0 -15
- package/dist/ui-public/icons/regular/rotate-left.js +0 -16
- package/dist/ui-public/icons/regular/shield.js +0 -15
- package/dist/ui-public/icons/regular/sidebar-flip.js +0 -16
- package/dist/ui-public/icons/regular/sidebar.js +0 -16
- package/dist/ui-public/icons/regular/sliders.js +0 -16
- package/dist/ui-public/icons/regular/sparkles.js +0 -15
- package/dist/ui-public/icons/regular/square-caret-down.js +0 -15
- package/dist/ui-public/icons/regular/square-check.js +0 -15
- package/dist/ui-public/icons/regular/square-dashed.js +0 -15
- package/dist/ui-public/icons/regular/square-left.js +0 -16
- package/dist/ui-public/icons/regular/square-terminal.js +0 -16
- package/dist/ui-public/icons/regular/square-up-right.js +0 -16
- package/dist/ui-public/icons/regular/store.js +0 -16
- package/dist/ui-public/icons/regular/swap-arrows.js +0 -15
- package/dist/ui-public/icons/regular/table.js +0 -16
- package/dist/ui-public/icons/regular/tag.js +0 -16
- package/dist/ui-public/icons/regular/toggle-on.js +0 -15
- package/dist/ui-public/icons/regular/toolbox.js +0 -16
- package/dist/ui-public/icons/regular/trash-undo.js +0 -15
- package/dist/ui-public/icons/regular/trash.js +0 -16
- package/dist/ui-public/icons/regular/triangle-exclamation.js +0 -16
- package/dist/ui-public/icons/regular/turn-up.js +0 -16
- package/dist/ui-public/icons/regular/user-group.js +0 -15
- package/dist/ui-public/icons/regular/user-helmet-safety.js +0 -16
- package/dist/ui-public/icons/regular/user-lock.js +0 -16
- package/dist/ui-public/icons/regular/user-minus.js +0 -16
- package/dist/ui-public/icons/regular/user-tie.js +0 -15
- package/dist/ui-public/icons/regular/user.js +0 -16
- package/dist/ui-public/icons/regular/users.js +0 -15
- package/dist/ui-public/icons/regular/video.js +0 -15
- package/dist/ui-public/icons/regular/webhook.js +0 -15
- package/dist/ui-public/icons/regular/wrench.js +0 -15
- package/dist/ui-public/icons/regular/xmark.js +0 -16
- package/dist/ui-public/icons/solid/align-center.js +0 -16
- package/dist/ui-public/icons/solid/align-justify.js +0 -16
- package/dist/ui-public/icons/solid/align-left.js +0 -16
- package/dist/ui-public/icons/solid/align-right.js +0 -16
- package/dist/ui-public/icons/solid/arrow-rotate-left.js +0 -16
- package/dist/ui-public/icons/solid/arrow-rotate-right.js +0 -16
- package/dist/ui-public/icons/solid/bold.js +0 -16
- package/dist/ui-public/icons/solid/circle-exclamation.js +0 -16
- package/dist/ui-public/icons/solid/closed-captioning.js +0 -15
- package/dist/ui-public/icons/solid/code.js +0 -16
- package/dist/ui-public/icons/solid/compress.js +0 -16
- package/dist/ui-public/icons/solid/download.js +0 -15
- package/dist/ui-public/icons/solid/expand.js +0 -16
- package/dist/ui-public/icons/solid/file-arrow-down.js +0 -15
- package/dist/ui-public/icons/solid/file-code.js +0 -16
- package/dist/ui-public/icons/solid/grid-2.js +0 -16
- package/dist/ui-public/icons/solid/h1.js +0 -16
- package/dist/ui-public/icons/solid/h2.js +0 -16
- package/dist/ui-public/icons/solid/h3.js +0 -16
- package/dist/ui-public/icons/solid/h4.js +0 -16
- package/dist/ui-public/icons/solid/h5.js +0 -16
- package/dist/ui-public/icons/solid/h6.js +0 -16
- package/dist/ui-public/icons/solid/highlighter.js +0 -16
- package/dist/ui-public/icons/solid/horizontal-rule.js +0 -16
- package/dist/ui-public/icons/solid/image.js +0 -16
- package/dist/ui-public/icons/solid/indent.js +0 -16
- package/dist/ui-public/icons/solid/italic.js +0 -16
- package/dist/ui-public/icons/solid/link.js +0 -16
- package/dist/ui-public/icons/solid/list-ol.js +0 -16
- package/dist/ui-public/icons/solid/list-ul.js +0 -16
- package/dist/ui-public/icons/solid/location-dot.js +0 -16
- package/dist/ui-public/icons/solid/music.js +0 -15
- package/dist/ui-public/icons/solid/outdent.js +0 -16
- package/dist/ui-public/icons/solid/paragraph.js +0 -16
- package/dist/ui-public/icons/solid/plus.js +0 -16
- package/dist/ui-public/icons/solid/quote-right.js +0 -16
- package/dist/ui-public/icons/solid/rectangle-code.js +0 -16
- package/dist/ui-public/icons/solid/square-plus.js +0 -16
- package/dist/ui-public/icons/solid/strikethrough.js +0 -16
- package/dist/ui-public/icons/solid/subtitles.js +0 -15
- package/dist/ui-public/icons/solid/table.js +0 -16
- package/dist/ui-public/icons/solid/triangle-exclamation.js +0 -16
- package/dist/ui-public/icons/solid/underline.js +0 -16
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import Image from "../../semantic/Image.js";
|
|
2
|
+
import FileTypeIcon from "../FileTypeIcon.js";
|
|
3
|
+
import { useElementLayout } from "../../hooks/useElementLayout.js";
|
|
4
|
+
import { AudioPlayPause } from "./audio.js";
|
|
5
|
+
import { DEFAULT_PADDING, fitInBox, nonImagePadding } from "./fit.js";
|
|
6
|
+
import box_default from "./box.js";
|
|
7
|
+
import { ThumbhashCanvas } from "./thumbhash.js";
|
|
8
|
+
import { uploadDefaultPosterTime, uploadFileUrl, uploadPreviewKind, videoFrameUrl } from "./upload.js";
|
|
9
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region ../ui-public/src/content/UploadPreview/asset.tsx
|
|
12
|
+
var MAX_DOCUMENT_ICON_HEIGHT = 100;
|
|
13
|
+
var DOCUMENT_ICON_SIZE = {
|
|
14
|
+
width: 448 / 512 * MAX_DOCUMENT_ICON_HEIGHT,
|
|
15
|
+
height: MAX_DOCUMENT_ICON_HEIGHT
|
|
16
|
+
};
|
|
17
|
+
var FadeInImage = ({ style, src, ...props }) => {
|
|
18
|
+
const [loadedSrc, setLoadedSrc] = useState(void 0);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!src) return;
|
|
21
|
+
const image = new window.Image();
|
|
22
|
+
image.onload = () => {
|
|
23
|
+
setLoadedSrc(src);
|
|
24
|
+
};
|
|
25
|
+
image.src = src;
|
|
26
|
+
return () => {
|
|
27
|
+
image.onload = null;
|
|
28
|
+
image.src = "";
|
|
29
|
+
};
|
|
30
|
+
}, [src]);
|
|
31
|
+
return /* @__PURE__ */ jsx(Image, {
|
|
32
|
+
...props,
|
|
33
|
+
src: loadedSrc,
|
|
34
|
+
style: {
|
|
35
|
+
...style,
|
|
36
|
+
transition: "opacity 0.2s ease-in-out",
|
|
37
|
+
opacity: loadedSrc ? 1 : 0
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var ThumbhashImage = React.memo(function ThumbhashImage({ thumbhash, src, style }) {
|
|
42
|
+
const [isLoaded, setLoaded] = useState(false);
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
44
|
+
style: {
|
|
45
|
+
...style,
|
|
46
|
+
position: "relative"
|
|
47
|
+
},
|
|
48
|
+
className: "checkboard-bg",
|
|
49
|
+
children: [/* @__PURE__ */ jsx(ThumbhashCanvas, {
|
|
50
|
+
thumbhash,
|
|
51
|
+
style: {
|
|
52
|
+
position: "absolute",
|
|
53
|
+
left: 0,
|
|
54
|
+
top: 0,
|
|
55
|
+
width: "100%",
|
|
56
|
+
height: "100%",
|
|
57
|
+
opacity: isLoaded ? 0 : 1,
|
|
58
|
+
transition: "opacity 0.2s ease-in-out"
|
|
59
|
+
}
|
|
60
|
+
}), /* @__PURE__ */ jsx(FadeInImage, {
|
|
61
|
+
src,
|
|
62
|
+
style: {
|
|
63
|
+
...style,
|
|
64
|
+
position: "relative",
|
|
65
|
+
display: "block",
|
|
66
|
+
zIndex: "1"
|
|
67
|
+
},
|
|
68
|
+
onLoad: () => setLoaded(true),
|
|
69
|
+
alt: "",
|
|
70
|
+
draggable: "false"
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
function useHasBeenVisible(ref) {
|
|
75
|
+
const [visible, setVisible] = useState(false);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const element = ref.current;
|
|
78
|
+
if (visible || !element) return;
|
|
79
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
80
|
+
setVisible(true);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const observer = new IntersectionObserver((entries) => {
|
|
84
|
+
if (entries.some((entry) => entry.isIntersecting)) {
|
|
85
|
+
observer.disconnect();
|
|
86
|
+
setVisible(true);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
observer.observe(element);
|
|
90
|
+
return () => observer.disconnect();
|
|
91
|
+
}, [ref, visible]);
|
|
92
|
+
return visible;
|
|
93
|
+
}
|
|
94
|
+
function pixelRatio() {
|
|
95
|
+
return typeof window === "undefined" ? 1 : window.devicePixelRatio || 1;
|
|
96
|
+
}
|
|
97
|
+
function renderAsset({ upload, box, padding, posterTime, wrapImage, audioPlayback }) {
|
|
98
|
+
const iconPadding = nonImagePadding(padding);
|
|
99
|
+
if (!upload) {
|
|
100
|
+
const fit = fitInBox(box, iconPadding, DOCUMENT_ICON_SIZE, false);
|
|
101
|
+
return /* @__PURE__ */ jsx(FileTypeIcon, {
|
|
102
|
+
style: fit.style,
|
|
103
|
+
extension: ""
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const { attributes } = upload;
|
|
107
|
+
const kind = uploadPreviewKind(attributes);
|
|
108
|
+
if (kind === "audio") return /* @__PURE__ */ jsx(AudioPlayPause, {
|
|
109
|
+
url: attributes.url,
|
|
110
|
+
playback: audioPlayback,
|
|
111
|
+
width: box.width,
|
|
112
|
+
height: box.height
|
|
113
|
+
});
|
|
114
|
+
if (kind === "video-encoding") return /* @__PURE__ */ jsx(box_default.Progress, {
|
|
115
|
+
percent: 0,
|
|
116
|
+
label: { id: "uploadPreview.encodingVideo" }
|
|
117
|
+
});
|
|
118
|
+
if (kind === "file" || !attributes.width || !attributes.height) {
|
|
119
|
+
const fit = fitInBox(box, iconPadding, DOCUMENT_ICON_SIZE, false);
|
|
120
|
+
return /* @__PURE__ */ jsx(FileTypeIcon, {
|
|
121
|
+
style: fit.style,
|
|
122
|
+
extension: attributes.format ?? ""
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const content = {
|
|
126
|
+
width: attributes.width,
|
|
127
|
+
height: attributes.height
|
|
128
|
+
};
|
|
129
|
+
const upscale = attributes.format?.toLowerCase() === "svg";
|
|
130
|
+
const fit = fitInBox(box, padding, content, upscale);
|
|
131
|
+
const downloadWidth = Math.round(pixelRatio() * fit.width);
|
|
132
|
+
if (kind === "video" && attributes.mux_playback_id) {
|
|
133
|
+
const src = videoFrameUrl(attributes.mux_playback_id, downloadWidth, posterTime !== void 0 ? posterTime : uploadDefaultPosterTime(upload));
|
|
134
|
+
if (attributes.thumbhash) return /* @__PURE__ */ jsx(ThumbhashImage, {
|
|
135
|
+
thumbhash: attributes.thumbhash,
|
|
136
|
+
src,
|
|
137
|
+
style: fit.style
|
|
138
|
+
}, attributes.mux_playback_id);
|
|
139
|
+
return /* @__PURE__ */ jsx(box_default.Image, {
|
|
140
|
+
src,
|
|
141
|
+
...content,
|
|
142
|
+
alt: ""
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (kind === "image") {
|
|
146
|
+
const src = uploadFileUrl(attributes, {
|
|
147
|
+
auto: "format",
|
|
148
|
+
w: downloadWidth
|
|
149
|
+
});
|
|
150
|
+
const image = attributes.thumbhash ? /* @__PURE__ */ jsx(ThumbhashImage, {
|
|
151
|
+
thumbhash: attributes.thumbhash,
|
|
152
|
+
src,
|
|
153
|
+
style: fit.style
|
|
154
|
+
}, attributes.thumbhash) : /* @__PURE__ */ jsx(FadeInImage, {
|
|
155
|
+
style: fit.style,
|
|
156
|
+
src,
|
|
157
|
+
alt: ""
|
|
158
|
+
}, attributes.url);
|
|
159
|
+
return wrapImage ? wrapImage(image, fit.style) : image;
|
|
160
|
+
}
|
|
161
|
+
return /* @__PURE__ */ jsx(box_default.Image, {
|
|
162
|
+
src: uploadFileUrl(attributes),
|
|
163
|
+
...content,
|
|
164
|
+
upscale,
|
|
165
|
+
alt: ""
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The preview of an asset entity: the image, the frame of a video, the
|
|
170
|
+
* waveform of a sound, or the icon of the format. The `UploadPreview` and
|
|
171
|
+
* the `UploadCard` with `upload` render it.
|
|
172
|
+
*/
|
|
173
|
+
var UploadAssetPreview = forwardRef(function UploadAssetPreview({ upload, box: fixedBox, padding = DEFAULT_PADDING, transparent, link, posterTime, children, wrapImage, audioPlayback }, ref) {
|
|
174
|
+
const elementRef = useRef(null);
|
|
175
|
+
useImperativeHandle(ref, () => elementRef.current);
|
|
176
|
+
const rect = useElementLayout(elementRef);
|
|
177
|
+
const visible = useHasBeenVisible(elementRef);
|
|
178
|
+
const box = fixedBox ?? (rect.width && rect.height ? {
|
|
179
|
+
width: rect.width,
|
|
180
|
+
height: rect.height
|
|
181
|
+
} : null);
|
|
182
|
+
return /* @__PURE__ */ jsxs(box_default, {
|
|
183
|
+
ref: elementRef,
|
|
184
|
+
box,
|
|
185
|
+
fixedSize: !!fixedBox,
|
|
186
|
+
padding,
|
|
187
|
+
transparent,
|
|
188
|
+
link,
|
|
189
|
+
children: [visible && box && upload !== void 0 && renderAsset({
|
|
190
|
+
upload,
|
|
191
|
+
box,
|
|
192
|
+
padding,
|
|
193
|
+
posterTime,
|
|
194
|
+
wrapImage,
|
|
195
|
+
audioPlayback
|
|
196
|
+
}), children]
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
//#endregion
|
|
200
|
+
export { UploadAssetPreview };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Status } from "../../../icons/index.js";
|
|
2
|
+
import { useTranslation } from "../../i18n.js";
|
|
3
|
+
import RawButton from "../../semantic/RawButton.js";
|
|
4
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import classNames from "classnames";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region ../ui-public/src/content/UploadPreview/audio.tsx
|
|
8
|
+
var pauseListeners = /* @__PURE__ */ new Set();
|
|
9
|
+
/** Stops all the players of the page */
|
|
10
|
+
function pauseAllPlayers() {
|
|
11
|
+
for (const pause of pauseListeners) pause();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Calls `pause` when another player starts. Call `pauseAllPlayers` before
|
|
15
|
+
* a player starts. Returns the function that removes the listener.
|
|
16
|
+
*/
|
|
17
|
+
function addPauseListener(pause) {
|
|
18
|
+
pauseListeners.add(pause);
|
|
19
|
+
return () => {
|
|
20
|
+
pauseListeners.delete(pause);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Plays a sound file. The waveform of a preview and the play action of a
|
|
25
|
+
* card use this hook. The hook makes the audio element at the first play,
|
|
26
|
+
* thus a page with many cards does not load the files. Give `null` for no
|
|
27
|
+
* file.
|
|
28
|
+
*/
|
|
29
|
+
function useAudioPlayback(url) {
|
|
30
|
+
const audioRef = useRef(null);
|
|
31
|
+
const listenersRef = useRef(null);
|
|
32
|
+
const [isPlaying, setIsPlaying] = useState(false);
|
|
33
|
+
const [progress, setProgress] = useState(0);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setIsPlaying(false);
|
|
36
|
+
setProgress(0);
|
|
37
|
+
return () => {
|
|
38
|
+
listenersRef.current?.abort();
|
|
39
|
+
listenersRef.current = null;
|
|
40
|
+
audioRef.current?.pause();
|
|
41
|
+
audioRef.current = null;
|
|
42
|
+
};
|
|
43
|
+
}, [url]);
|
|
44
|
+
useEffect(() => addPauseListener(() => {
|
|
45
|
+
audioRef.current?.pause();
|
|
46
|
+
}), []);
|
|
47
|
+
const toggle = useCallback(() => {
|
|
48
|
+
if (!url) return;
|
|
49
|
+
if (!audioRef.current) {
|
|
50
|
+
const audio = new Audio(url);
|
|
51
|
+
const listeners = new AbortController();
|
|
52
|
+
const { signal } = listeners;
|
|
53
|
+
audio.addEventListener("play", () => setIsPlaying(true), { signal });
|
|
54
|
+
audio.addEventListener("pause", () => setIsPlaying(false), { signal });
|
|
55
|
+
audio.addEventListener("ended", () => setProgress(0), { signal });
|
|
56
|
+
audio.addEventListener("timeupdate", () => {
|
|
57
|
+
if (Number.isFinite(audio.duration) && audio.duration > 0) setProgress(audio.currentTime / audio.duration * 100);
|
|
58
|
+
}, { signal });
|
|
59
|
+
audioRef.current = audio;
|
|
60
|
+
listenersRef.current = listeners;
|
|
61
|
+
}
|
|
62
|
+
const audio = audioRef.current;
|
|
63
|
+
if (!audio.paused) {
|
|
64
|
+
audio.pause();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
pauseAllPlayers();
|
|
68
|
+
audio.play().catch(() => {});
|
|
69
|
+
}, [url]);
|
|
70
|
+
return useMemo(() => ({
|
|
71
|
+
isPlaying,
|
|
72
|
+
progress,
|
|
73
|
+
toggle
|
|
74
|
+
}), [
|
|
75
|
+
isPlaying,
|
|
76
|
+
progress,
|
|
77
|
+
toggle
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
/** The waveform of a sound file, with a play button */
|
|
81
|
+
var AudioPlayPause = React.memo(function AudioPlayPause({ url, width, height, playback }) {
|
|
82
|
+
const { t } = useTranslation();
|
|
83
|
+
const ownPlayback = useAudioPlayback(playback ? null : url);
|
|
84
|
+
const { isPlaying, progress, toggle } = playback ?? ownPlayback;
|
|
85
|
+
const handleClick = useCallback((e) => {
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
toggle();
|
|
89
|
+
}, [toggle]);
|
|
90
|
+
const waveStyle = useMemo(() => ({ "--AudioPlayPause-progress": `${progress}%` }), [progress]);
|
|
91
|
+
let style;
|
|
92
|
+
if (width > 110) {
|
|
93
|
+
const scale = Math.min(width / 300, height / 200);
|
|
94
|
+
style = {
|
|
95
|
+
width: `${300 * scale}px`,
|
|
96
|
+
height: `${200 * scale}px`
|
|
97
|
+
};
|
|
98
|
+
} else style = {
|
|
99
|
+
width,
|
|
100
|
+
height
|
|
101
|
+
};
|
|
102
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
103
|
+
className: classNames("AudioPlayPause", {
|
|
104
|
+
big: width >= 100,
|
|
105
|
+
small: width < 100
|
|
106
|
+
}),
|
|
107
|
+
style,
|
|
108
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: "AudioPlayPause__wave",
|
|
110
|
+
style: waveStyle
|
|
111
|
+
}), !playback && /* @__PURE__ */ jsx(RawButton, {
|
|
112
|
+
className: classNames("AudioPlayPause__button", { "button button--icon-only button--primary": width >= 100 }),
|
|
113
|
+
ariaLabel: t(isPlaying ? "audioPlayer.pause" : "audioPlayer.play"),
|
|
114
|
+
onClick: handleClick,
|
|
115
|
+
children: isPlaying ? /* @__PURE__ */ jsx(Status.PauseIcon, {}) : /* @__PURE__ */ jsx(Status.PlayIcon, {})
|
|
116
|
+
})]
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
//#endregion
|
|
120
|
+
export { AudioPlayPause, addPauseListener, pauseAllPlayers, useAudioPlayback };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import type { TextMessage } from '
|
|
3
|
-
import { type BoxSize, type UploadPreviewPadding } from './
|
|
4
|
-
export type { BoxSize, UploadPreviewPadding } from './
|
|
5
|
-
export type
|
|
2
|
+
import type { TextMessage } from '../../Message.js';
|
|
3
|
+
import { type BoxSize, type UploadPreviewPadding } from './fit.js';
|
|
4
|
+
export type { BoxSize, UploadPreviewPadding } from './fit.js';
|
|
5
|
+
export type UploadPreviewBoxProps = {
|
|
6
6
|
/**
|
|
7
7
|
* The size of the box in px, for the fit of the asset. A live host
|
|
8
|
-
* measures the box. A static host gives a constant. `null`
|
|
8
|
+
* measures the box. A static host gives a constant. `null` says that the
|
|
9
9
|
* size is not known yet: `UploadPreview.Image` then renders nothing.
|
|
10
10
|
*/
|
|
11
11
|
box: BoxSize | null;
|
|
@@ -20,7 +20,7 @@ export type UploadPreviewProps = {
|
|
|
20
20
|
* @default [10, 10]
|
|
21
21
|
*/
|
|
22
22
|
padding?: UploadPreviewPadding;
|
|
23
|
-
/** The box has no background,
|
|
23
|
+
/** The box has no background, so it shows the background of the parent. */
|
|
24
24
|
transparent?: boolean;
|
|
25
25
|
/** The box is a link to the file. */
|
|
26
26
|
link?: {
|
|
@@ -43,8 +43,8 @@ export type UploadPreviewImageProps = {
|
|
|
43
43
|
*/
|
|
44
44
|
upscale?: boolean;
|
|
45
45
|
/**
|
|
46
|
-
* The image shows
|
|
47
|
-
* video),
|
|
46
|
+
* The image shows instead of an icon (for example the poster of a
|
|
47
|
+
* video), so it always gets space around it, even when the
|
|
48
48
|
* `UploadPreview` has zero padding.
|
|
49
49
|
*/
|
|
50
50
|
icon?: boolean;
|
|
@@ -65,13 +65,13 @@ export type UploadPreviewProgressProps = {
|
|
|
65
65
|
percent: number;
|
|
66
66
|
/**
|
|
67
67
|
* The text above the bar, and the name of the bar. Without it, the name
|
|
68
|
-
* of the bar
|
|
68
|
+
* of the bar says the percent or the analysis.
|
|
69
69
|
*/
|
|
70
70
|
label?: TextMessage;
|
|
71
71
|
};
|
|
72
72
|
/** The progress of the upload, on the bottom edge of the box. */
|
|
73
73
|
declare function UploadPreviewProgress({ percent, label }: UploadPreviewProgressProps): React.JSX.Element;
|
|
74
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
74
|
+
declare const _default: React.ForwardRefExoticComponent<UploadPreviewBoxProps & React.RefAttributes<HTMLElement>> & {
|
|
75
75
|
Image: typeof UploadPreviewImage;
|
|
76
76
|
Progress: typeof UploadPreviewProgress;
|
|
77
77
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useTranslation } from "
|
|
2
|
-
import ProgressBar_default from "
|
|
3
|
-
import Image from "
|
|
4
|
-
import { DEFAULT_PADDING, fitInBox, nonImagePadding } from "./
|
|
1
|
+
import { useTranslation } from "../../i18n.js";
|
|
2
|
+
import ProgressBar_default from "../../feedback/ProgressBar.js";
|
|
3
|
+
import Image from "../../semantic/Image.js";
|
|
4
|
+
import { DEFAULT_PADDING, fitInBox, nonImagePadding } from "./fit.js";
|
|
5
5
|
import { createContext, forwardRef, useContext, useMemo } from "react";
|
|
6
6
|
import classNames from "classnames";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
//#region ../ui-public/src/content/UploadPreview.tsx
|
|
8
|
+
//#region ../ui-public/src/content/UploadPreview/box.tsx
|
|
9
9
|
var UploadPreviewContext = createContext({
|
|
10
10
|
box: null,
|
|
11
11
|
padding: DEFAULT_PADDING
|
|
@@ -87,9 +87,9 @@ function UploadPreviewProgress({ percent, label }) {
|
|
|
87
87
|
})
|
|
88
88
|
})] });
|
|
89
89
|
}
|
|
90
|
-
var
|
|
90
|
+
var box_default = Object.assign(UploadPreview, {
|
|
91
91
|
Image: UploadPreviewImage,
|
|
92
92
|
Progress: UploadPreviewProgress
|
|
93
93
|
});
|
|
94
94
|
//#endregion
|
|
95
|
-
export {
|
|
95
|
+
export { box_default as default };
|
|
@@ -6,8 +6,8 @@ export type BoxSize = {
|
|
|
6
6
|
/** The space around the asset, in px */
|
|
7
7
|
export type UploadPreviewPadding = [vertical: number, horizontal: number];
|
|
8
8
|
/**
|
|
9
|
-
* The space around the asset when
|
|
10
|
-
* can have no space around it: when
|
|
9
|
+
* The space around the asset when you give no padding. Only an image
|
|
10
|
+
* can have no space around it: when you give zero padding, an icon
|
|
11
11
|
* gets this space, because an icon without space touches the edges of the
|
|
12
12
|
* box.
|
|
13
13
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//#region ../ui-public/src/content/
|
|
1
|
+
//#region ../ui-public/src/content/UploadPreview/fit.ts
|
|
2
2
|
/**
|
|
3
|
-
* The space around the asset when
|
|
4
|
-
* can have no space around it: when
|
|
3
|
+
* The space around the asset when you give no padding. Only an image
|
|
4
|
+
* can have no space around it: when you give zero padding, an icon
|
|
5
5
|
* gets this space, because an icon without space touches the edges of the
|
|
6
6
|
* box.
|
|
7
7
|
*/
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type UploadPreviewBoxProps } from './box.js';
|
|
3
|
+
import type { BoxSize, UploadPreviewPadding } from './fit.js';
|
|
4
|
+
import type { UploadFieldValue, UploadPreviewUpload } from './upload.js';
|
|
5
|
+
export type { UploadPreviewImageProps, UploadPreviewProgressProps, } from './box.js';
|
|
6
|
+
export type { BoxSize, UploadPreviewPadding } from './fit.js';
|
|
7
|
+
export type { UploadFieldValue, UploadPreviewUpload } from './upload.js';
|
|
8
|
+
/**
|
|
9
|
+
* Mode "box": you draw the asset in the box, with `UploadPreview.Image`, an
|
|
10
|
+
* icon or a progress bar.
|
|
11
|
+
*/
|
|
12
|
+
export type UploadPreviewBoxModeProps = UploadPreviewBoxProps & {
|
|
13
|
+
upload?: never;
|
|
14
|
+
fieldValue?: never;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Mode "upload": the preview draws an asset of the Media Area, as DatoCMS
|
|
18
|
+
* draws it.
|
|
19
|
+
*/
|
|
20
|
+
export type UploadPreviewUploadModeProps = {
|
|
21
|
+
/**
|
|
22
|
+
* The asset as `ctx` gives it, or its ID. An ID loads through the
|
|
23
|
+
* provider of the host: `Canvas` mounts it. While the asset loads, the box
|
|
24
|
+
* is empty. An asset that does not exist, or `null`, shows a blank file
|
|
25
|
+
* icon.
|
|
26
|
+
*/
|
|
27
|
+
upload: string | UploadPreviewUpload | null;
|
|
28
|
+
/**
|
|
29
|
+
* The size of the box in px. The box gets this size. Without it, the CSS
|
|
30
|
+
* of the parent gives the size of the box, and the preview measures it.
|
|
31
|
+
*/
|
|
32
|
+
box?: BoxSize;
|
|
33
|
+
/**
|
|
34
|
+
* The space (vertical, horizontal) in px between the box and the asset.
|
|
35
|
+
* An icon always gets space: with `[0, 0]`, an icon gets `[10, 10]`.
|
|
36
|
+
* @default [10, 10]
|
|
37
|
+
*/
|
|
38
|
+
padding?: UploadPreviewPadding;
|
|
39
|
+
/** The box has no background, so it shows the background of the parent. */
|
|
40
|
+
transparent?: boolean;
|
|
41
|
+
/** The box is a link. */
|
|
42
|
+
link?: {
|
|
43
|
+
href: string;
|
|
44
|
+
target?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The value of the field that holds the asset, as in `UploadCard`. The
|
|
48
|
+
* preview reads its `poster_time`, the frame of a video. When it is not
|
|
49
|
+
* set, the frame is the default of the asset.
|
|
50
|
+
*/
|
|
51
|
+
fieldValue?: UploadFieldValue;
|
|
52
|
+
/** More content in the box, over the asset */
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
fixedSize?: never;
|
|
55
|
+
};
|
|
56
|
+
export type UploadPreviewProps = UploadPreviewBoxModeProps | UploadPreviewUploadModeProps;
|
|
57
|
+
declare const _default: React.ForwardRefExoticComponent<UploadPreviewProps & React.RefAttributes<HTMLElement>> & {
|
|
58
|
+
Image: ({ src, width, height, upscale, icon, alt, }: import("./box.js").UploadPreviewImageProps) => React.JSX.Element | null;
|
|
59
|
+
Progress: ({ percent, label }: import("./box.js").UploadPreviewProgressProps) => React.JSX.Element;
|
|
60
|
+
};
|
|
61
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useLoadedUpload } from "./presentation.js";
|
|
2
|
+
import box_default from "./box.js";
|
|
3
|
+
import { UploadAssetPreview } from "./asset.js";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region ../ui-public/src/content/UploadPreview/index.tsx
|
|
7
|
+
var UploadModePreview = forwardRef(function UploadModePreview({ upload, fieldValue, ...props }, ref) {
|
|
8
|
+
const loaded = useLoadedUpload(upload);
|
|
9
|
+
return /* @__PURE__ */ jsx(UploadAssetPreview, {
|
|
10
|
+
...props,
|
|
11
|
+
ref,
|
|
12
|
+
upload: loaded,
|
|
13
|
+
posterTime: fieldValue?.poster_time ?? void 0
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* The preview of an asset in a box: the asset is in the center, with space
|
|
18
|
+
* around it. With `upload`, the preview draws an asset of the Media Area.
|
|
19
|
+
* Without it, you draw the asset in the box.
|
|
20
|
+
*/
|
|
21
|
+
var UploadPreview = forwardRef(function UploadPreview(props, ref) {
|
|
22
|
+
if (props.upload !== void 0) return /* @__PURE__ */ jsx(UploadModePreview, {
|
|
23
|
+
...props,
|
|
24
|
+
ref
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsx(box_default, {
|
|
27
|
+
...props,
|
|
28
|
+
ref
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
var UploadPreview_default = Object.assign(UploadPreview, {
|
|
32
|
+
Image: box_default.Image,
|
|
33
|
+
Progress: box_default.Progress
|
|
34
|
+
});
|
|
35
|
+
//#endregion
|
|
36
|
+
export { UploadPreview_default as default };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createTickBatcher } from "../../utils/tickBatcher.js";
|
|
2
|
+
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region ../ui-public/src/content/UploadPreview/presentation.tsx
|
|
5
|
+
var UploadPresentationContext = createContext({
|
|
6
|
+
request: async () => null,
|
|
7
|
+
mainLocale: void 0
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Gives the loader of assets to the `UploadPreview`s and `UploadCard`s with
|
|
11
|
+
* an asset ID. The previews of one render ask for their assets in the same
|
|
12
|
+
* tick: the provider sends them in one call to the loader. It keeps no
|
|
13
|
+
* cache. A failed call gives null to its previews.
|
|
14
|
+
*/
|
|
15
|
+
function UploadPresentationProvider({ load, mainLocale, children }) {
|
|
16
|
+
const request = useMemo(() => {
|
|
17
|
+
const batch = createTickBatcher({
|
|
18
|
+
groupKey: () => "",
|
|
19
|
+
fallback: null,
|
|
20
|
+
load: async (_group, uploadIds) => load ? load(uploadIds) : uploadIds.map(() => null)
|
|
21
|
+
});
|
|
22
|
+
return (uploadId) => batch(null, uploadId);
|
|
23
|
+
}, [load]);
|
|
24
|
+
const value = useMemo(() => ({
|
|
25
|
+
request,
|
|
26
|
+
mainLocale
|
|
27
|
+
}), [request, mainLocale]);
|
|
28
|
+
return /* @__PURE__ */ jsx(UploadPresentationContext.Provider, {
|
|
29
|
+
value,
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The asset from the loader of the provider, or the asset itself when it is
|
|
35
|
+
* not an ID. It is undefined while it loads, and null when the asset does not
|
|
36
|
+
* exist or the loader failed.
|
|
37
|
+
*/
|
|
38
|
+
function useLoadedUpload(upload) {
|
|
39
|
+
const { request } = useContext(UploadPresentationContext);
|
|
40
|
+
const id = typeof upload === "string" ? upload : null;
|
|
41
|
+
const [state, setState] = useState(null);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (id === null) return;
|
|
44
|
+
let active = true;
|
|
45
|
+
request(id).then((value) => {
|
|
46
|
+
if (active) setState({
|
|
47
|
+
id,
|
|
48
|
+
value
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return () => {
|
|
52
|
+
active = false;
|
|
53
|
+
};
|
|
54
|
+
}, [request, id]);
|
|
55
|
+
if (typeof upload !== "string") return upload;
|
|
56
|
+
return state?.id === upload ? state.value : void 0;
|
|
57
|
+
}
|
|
58
|
+
/** The main locale of the project, from the provider */
|
|
59
|
+
function useUploadMainLocale() {
|
|
60
|
+
return useContext(UploadPresentationContext).mainLocale;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { UploadPresentationProvider, useLoadedUpload, useUploadMainLocale };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region ../ui-public/src/content/UploadPreview/thumbhash.tsx
|
|
4
|
+
function thumbHashToApproximateAspectRatio(hash) {
|
|
5
|
+
const header = hash[3];
|
|
6
|
+
const hasAlpha = hash[2] & 128;
|
|
7
|
+
const isLandscape = hash[4] & 128;
|
|
8
|
+
return (isLandscape ? hasAlpha ? 5 : 7 : header & 7) / (isLandscape ? header & 7 : hasAlpha ? 5 : 7);
|
|
9
|
+
}
|
|
10
|
+
function thumbHashToRGBA(hash) {
|
|
11
|
+
const { PI, min, max, cos, round } = Math;
|
|
12
|
+
const header24 = hash[0] | hash[1] << 8 | hash[2] << 16;
|
|
13
|
+
const header16 = hash[3] | hash[4] << 8;
|
|
14
|
+
const l_dc = (header24 & 63) / 63;
|
|
15
|
+
const p_dc = (header24 >> 6 & 63) / 31.5 - 1;
|
|
16
|
+
const q_dc = (header24 >> 12 & 63) / 31.5 - 1;
|
|
17
|
+
const l_scale = (header24 >> 18 & 31) / 31;
|
|
18
|
+
const hasAlpha = header24 >> 23;
|
|
19
|
+
const p_scale = (header16 >> 3 & 63) / 63;
|
|
20
|
+
const q_scale = (header16 >> 9 & 63) / 63;
|
|
21
|
+
const isLandscape = header16 >> 15;
|
|
22
|
+
const lx = max(3, isLandscape ? hasAlpha ? 5 : 7 : header16 & 7);
|
|
23
|
+
const ly = max(3, isLandscape ? header16 & 7 : hasAlpha ? 5 : 7);
|
|
24
|
+
const a_dc = hasAlpha ? (hash[5] & 15) / 15 : 1;
|
|
25
|
+
const a_scale = (hash[5] >> 4) / 15;
|
|
26
|
+
const ac_start = hasAlpha ? 6 : 5;
|
|
27
|
+
let ac_index = 0;
|
|
28
|
+
const decodeChannel = (nx, ny, scale) => {
|
|
29
|
+
const ac = [];
|
|
30
|
+
for (let cy = 0; cy < ny; cy++) for (let cx = cy ? 0 : 1; cx * ny < nx * (ny - cy); cx++) ac.push(((hash[ac_start + (ac_index >> 1)] >> ((ac_index++ & 1) << 2) & 15) / 7.5 - 1) * scale);
|
|
31
|
+
return ac;
|
|
32
|
+
};
|
|
33
|
+
const l_ac = decodeChannel(lx, ly, l_scale);
|
|
34
|
+
const p_ac = decodeChannel(3, 3, p_scale * 1.25);
|
|
35
|
+
const q_ac = decodeChannel(3, 3, q_scale * 1.25);
|
|
36
|
+
const a_ac = hasAlpha ? decodeChannel(5, 5, a_scale) : [];
|
|
37
|
+
const ratio = thumbHashToApproximateAspectRatio(hash);
|
|
38
|
+
const w = round(ratio > 1 ? 32 : 32 * ratio);
|
|
39
|
+
const h = round(ratio > 1 ? 32 / ratio : 32);
|
|
40
|
+
const rgba = new Uint8ClampedArray(w * h * 4);
|
|
41
|
+
const fx = [];
|
|
42
|
+
const fy = [];
|
|
43
|
+
for (let y = 0, i = 0; y < h; y++) for (let x = 0; x < w; x++, i += 4) {
|
|
44
|
+
let l = l_dc;
|
|
45
|
+
let p = p_dc;
|
|
46
|
+
let q = q_dc;
|
|
47
|
+
let a = a_dc;
|
|
48
|
+
for (let cx = 0, n = max(lx, hasAlpha ? 5 : 3); cx < n; cx++) fx[cx] = cos(PI / w * (x + .5) * cx);
|
|
49
|
+
for (let cy = 0, n = max(ly, hasAlpha ? 5 : 3); cy < n; cy++) fy[cy] = cos(PI / h * (y + .5) * cy);
|
|
50
|
+
for (let cy = 0, j = 0; cy < ly; cy++) for (let cx = cy ? 0 : 1, fy2 = fy[cy] * 2; cx * ly < lx * (ly - cy); cx++, j++) l += l_ac[j] * fx[cx] * fy2;
|
|
51
|
+
for (let cy = 0, j = 0; cy < 3; cy++) for (let cx = cy ? 0 : 1, fy2 = fy[cy] * 2; cx < 3 - cy; cx++, j++) {
|
|
52
|
+
const f = fx[cx] * fy2;
|
|
53
|
+
p += p_ac[j] * f;
|
|
54
|
+
q += q_ac[j] * f;
|
|
55
|
+
}
|
|
56
|
+
if (hasAlpha) for (let cy = 0, j = 0; cy < 5; cy++) for (let cx = cy ? 0 : 1, fy2 = fy[cy] * 2; cx < 5 - cy; cx++, j++) a += a_ac[j] * fx[cx] * fy2;
|
|
57
|
+
const b = l - 2 / 3 * p;
|
|
58
|
+
const r = (3 * l - b + q) / 2;
|
|
59
|
+
const g = r - q;
|
|
60
|
+
rgba[i] = max(0, 255 * min(1, r));
|
|
61
|
+
rgba[i + 1] = max(0, 255 * min(1, g));
|
|
62
|
+
rgba[i + 2] = max(0, 255 * min(1, b));
|
|
63
|
+
rgba[i + 3] = max(0, 255 * min(1, a));
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
w,
|
|
67
|
+
h,
|
|
68
|
+
rgba
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function decodeThumbhash(thumbhash) {
|
|
72
|
+
return thumbHashToRGBA(new Uint8ClampedArray(atob(thumbhash).split("").map((x) => x.charCodeAt(0))));
|
|
73
|
+
}
|
|
74
|
+
/** The blurred picture of a thumbhash, while the real image loads */
|
|
75
|
+
function ThumbhashCanvas({ thumbhash, style }) {
|
|
76
|
+
const canvasRef = useRef(null);
|
|
77
|
+
const result = useMemo(() => decodeThumbhash(thumbhash), [thumbhash]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const context = canvasRef.current?.getContext("2d");
|
|
80
|
+
if (!context) return;
|
|
81
|
+
context.putImageData(new ImageData(result.rgba, result.w, result.h), 0, 0);
|
|
82
|
+
}, [result]);
|
|
83
|
+
return /* @__PURE__ */ jsx("canvas", {
|
|
84
|
+
ref: canvasRef,
|
|
85
|
+
style,
|
|
86
|
+
width: result.w,
|
|
87
|
+
height: result.h
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { ThumbhashCanvas };
|