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,167 @@
|
|
|
1
|
+
import { useTranslation } from "../../i18n.js";
|
|
2
|
+
import { useDateSettings } from "../../content/DateSettings.js";
|
|
3
|
+
import Button from "../../actions/Button.js";
|
|
4
|
+
import { useAutoincrementIntegerId } from "../../hooks/useAutoincrementIntegerId.js";
|
|
5
|
+
import { timezoneOptions } from "../../utils/timezones.js";
|
|
6
|
+
import SelectInput from "../SelectInput/index.js";
|
|
7
|
+
import { parseDateText, timeInputFormats } from "../DateTimeInput/dateText.js";
|
|
8
|
+
import CalendarGrid from "../DateTimeInput/CalendarGrid.js";
|
|
9
|
+
import { formatDateTimeValue } from "../DateTimeInput/value.js";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
import classNames from "classnames";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { TZDate } from "@date-fns/tz";
|
|
14
|
+
import { format } from "date-fns";
|
|
15
|
+
//#region ../ui-public/src/form/DateTimeRangeInput/Panel.tsx
|
|
16
|
+
/** An end that the user picks as a day gets this time */
|
|
17
|
+
var DAY_EDGE_TIME = {
|
|
18
|
+
start: [0, 0],
|
|
19
|
+
end: [23, 59]
|
|
20
|
+
};
|
|
21
|
+
/** The instant of a wall clock: the day and the time in the time zone */
|
|
22
|
+
function atTime(day, [hours, minutes], tz) {
|
|
23
|
+
const wallClock = new TZDate(day.getFullYear(), day.getMonth(), day.getDate(), hours, minutes, 0, tz);
|
|
24
|
+
return new Date(wallClock.getTime());
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The date text and the time text of one end. A text is read when the user
|
|
28
|
+
* leaves it, and a text that is not a date or a time goes back to the value.
|
|
29
|
+
*/
|
|
30
|
+
function EdgeInputs({ edge, value, timezone, valueTimezone, active, onActivate, onChange }) {
|
|
31
|
+
const { t } = useTranslation();
|
|
32
|
+
const { dateFormat, twentyFourHour } = useDateSettings();
|
|
33
|
+
const timeFormats = timeInputFormats(twentyFourHour, false);
|
|
34
|
+
const dateInputId = `DateTimeRangeInput-${edge}-${useAutoincrementIntegerId()}`;
|
|
35
|
+
const local = value ? new TZDate(value, timezone) : null;
|
|
36
|
+
const dateText = local ? format(local, dateFormat) : "";
|
|
37
|
+
const timeText = local ? format(local, timeFormats[0]) : "";
|
|
38
|
+
const [dateInput, setDateInput] = useState(dateText);
|
|
39
|
+
const [timeInput, setTimeInput] = useState(timeText);
|
|
40
|
+
useEffect(() => setDateInput(dateText), [dateText]);
|
|
41
|
+
useEffect(() => setTimeInput(timeText), [timeText]);
|
|
42
|
+
const handleDateBlur = () => {
|
|
43
|
+
const day = parseDateText(dateInput, [dateFormat]);
|
|
44
|
+
if (!day) {
|
|
45
|
+
setDateInput(dateText);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const time = local ? [local.getHours(), local.getMinutes()] : DAY_EDGE_TIME[edge];
|
|
49
|
+
onChange(formatDateTimeValue(atTime(day, time, timezone), valueTimezone));
|
|
50
|
+
};
|
|
51
|
+
const handleTimeBlur = () => {
|
|
52
|
+
const time = parseDateText(timeInput, timeFormats);
|
|
53
|
+
if (!time || !local) {
|
|
54
|
+
setTimeInput(timeText);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
onChange(formatDateTimeValue(atTime(local, [time.getHours(), time.getMinutes()], timezone), valueTimezone));
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
60
|
+
className: "DateTimeRangeInput__edge",
|
|
61
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
62
|
+
htmlFor: dateInputId,
|
|
63
|
+
className: "DateTimeRangeInput__edge-label",
|
|
64
|
+
children: t(edge === "start" ? "dateTimeRangeInput.start" : "dateTimeRangeInput.end")
|
|
65
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
66
|
+
className: "DateTimeRangeInput__edge-inputs",
|
|
67
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
68
|
+
id: dateInputId,
|
|
69
|
+
type: "text",
|
|
70
|
+
className: classNames("DateTimeRangeInput__edge-date", { "is-active": active }),
|
|
71
|
+
placeholder: dateFormat,
|
|
72
|
+
value: dateInput,
|
|
73
|
+
onChange: (event) => setDateInput(event.target.value),
|
|
74
|
+
onFocus: onActivate,
|
|
75
|
+
onBlur: handleDateBlur,
|
|
76
|
+
spellCheck: false,
|
|
77
|
+
autoComplete: "off"
|
|
78
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
79
|
+
type: "text",
|
|
80
|
+
"aria-label": t(edge === "start" ? "dateTimeRangeInput.startTime" : "dateTimeRangeInput.endTime"),
|
|
81
|
+
className: "DateTimeRangeInput__edge-time",
|
|
82
|
+
placeholder: timeFormats[0],
|
|
83
|
+
value: timeInput,
|
|
84
|
+
onChange: (event) => setTimeInput(event.target.value),
|
|
85
|
+
onBlur: handleTimeBlur,
|
|
86
|
+
spellCheck: false,
|
|
87
|
+
autoComplete: "off"
|
|
88
|
+
})]
|
|
89
|
+
})]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The custom range: a calendar, the texts of the two ends, the time zone and
|
|
94
|
+
* the Apply button. The range changes only on Apply.
|
|
95
|
+
*/
|
|
96
|
+
function Panel({ initial, timezone, valueTimezone, showsTimezone, onTimezoneChange, selectableDays, onApply }) {
|
|
97
|
+
const { t } = useTranslation();
|
|
98
|
+
const [range, setRange] = useState(initial);
|
|
99
|
+
const [activeEdge, setActiveEdge] = useState("start");
|
|
100
|
+
const toValue = (instant) => formatDateTimeValue(instant, valueTimezone);
|
|
101
|
+
const dayOf = (value) => value ? format(new TZDate(value, timezone), "yyyy-MM-dd") : null;
|
|
102
|
+
const handlePickDay = (day) => {
|
|
103
|
+
if (activeEdge === "start") {
|
|
104
|
+
setRange((current) => ({
|
|
105
|
+
...current,
|
|
106
|
+
start: toValue(atTime(day, DAY_EDGE_TIME.start, timezone))
|
|
107
|
+
}));
|
|
108
|
+
setActiveEdge("end");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const end = atTime(day, DAY_EDGE_TIME.end, timezone);
|
|
112
|
+
const start = range.start ? new TZDate(range.start, timezone) : null;
|
|
113
|
+
if (start && end.getTime() < start.getTime()) setRange({
|
|
114
|
+
start: toValue(atTime(day, DAY_EDGE_TIME.start, timezone)),
|
|
115
|
+
end: toValue(atTime(start, DAY_EDGE_TIME.end, timezone))
|
|
116
|
+
});
|
|
117
|
+
else setRange((current) => ({
|
|
118
|
+
...current,
|
|
119
|
+
end: toValue(end)
|
|
120
|
+
}));
|
|
121
|
+
setActiveEdge("start");
|
|
122
|
+
};
|
|
123
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
124
|
+
className: "DateTimeRangeInput__panel",
|
|
125
|
+
children: [/* @__PURE__ */ jsx(CalendarGrid, {
|
|
126
|
+
selection: {
|
|
127
|
+
start: dayOf(range.start),
|
|
128
|
+
end: dayOf(range.end)
|
|
129
|
+
},
|
|
130
|
+
selectableDays,
|
|
131
|
+
onChange: handlePickDay
|
|
132
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
133
|
+
className: "DateTimeRangeInput__edges",
|
|
134
|
+
children: [
|
|
135
|
+
["start", "end"].map((edge) => /* @__PURE__ */ jsx(EdgeInputs, {
|
|
136
|
+
edge,
|
|
137
|
+
value: range[edge],
|
|
138
|
+
timezone,
|
|
139
|
+
valueTimezone,
|
|
140
|
+
active: activeEdge === edge,
|
|
141
|
+
onActivate: () => setActiveEdge(edge),
|
|
142
|
+
onChange: (value) => setRange((current) => ({
|
|
143
|
+
...current,
|
|
144
|
+
[edge]: value
|
|
145
|
+
}))
|
|
146
|
+
}, edge)),
|
|
147
|
+
/* @__PURE__ */ jsx(Button, {
|
|
148
|
+
tone: "primary",
|
|
149
|
+
size: "small",
|
|
150
|
+
expand: true,
|
|
151
|
+
label: t("dateTimeRangeInput.apply"),
|
|
152
|
+
className: "DateTimeRangeInput__apply",
|
|
153
|
+
onClick: () => onApply(range)
|
|
154
|
+
}),
|
|
155
|
+
showsTimezone && /* @__PURE__ */ jsx(SelectInput, {
|
|
156
|
+
"aria-label": t("dateTimeInput.timezone"),
|
|
157
|
+
className: "DateTimeRangeInput__timezone",
|
|
158
|
+
options: timezoneOptions,
|
|
159
|
+
value: timezone,
|
|
160
|
+
onChange: (value) => value && onTimezoneChange(value)
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
})]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
export { Panel as default };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type TextMessage } from '../../Message.js';
|
|
3
|
+
import { type PopoverProps } from '../../overlays/Popover.js';
|
|
4
|
+
import { type SelectableDays } from '../DateTimeInput/CalendarGrid.js';
|
|
5
|
+
import { type FieldInputProps } from '../FieldWrapper.js';
|
|
6
|
+
import { type BaseInputComponentPropsFieldWithReadOnly } from '../inputProps.js';
|
|
7
|
+
export type { SelectableDays } from '../DateTimeInput/CalendarGrid.js';
|
|
8
|
+
/** An option of the menu: a range that your code computes, for example "Last 7 days" */
|
|
9
|
+
export type DateTimeRangePreset = {
|
|
10
|
+
/** The key of the preset. It goes in the `preset` of the value. */
|
|
11
|
+
value: string;
|
|
12
|
+
/** The text of the option, and of the trigger when the preset is the value */
|
|
13
|
+
label: TextMessage;
|
|
14
|
+
};
|
|
15
|
+
/** The presets of the menu, and the preset that the clear button sets */
|
|
16
|
+
export type DateTimeRangePresets = {
|
|
17
|
+
/**
|
|
18
|
+
* The ranges of the menu, in their order. "Custom range" comes after
|
|
19
|
+
* them.
|
|
20
|
+
*/
|
|
21
|
+
options: DateTimeRangePreset[];
|
|
22
|
+
/**
|
|
23
|
+
* The `value` of the preset that the clear button of a custom range sets.
|
|
24
|
+
* Without it, the clear button sets the first option.
|
|
25
|
+
*/
|
|
26
|
+
default?: string;
|
|
27
|
+
};
|
|
28
|
+
/** The value of `DateTimeRangeInput`: a preset, or a custom range */
|
|
29
|
+
export type DateTimeRangeValue =
|
|
30
|
+
/** A preset of the menu, as its `value` */
|
|
31
|
+
{
|
|
32
|
+
preset: string;
|
|
33
|
+
start?: never;
|
|
34
|
+
end?: never;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A custom range. Each end is an ISO 8601 date and time with the offset
|
|
38
|
+
* of the time zone of the project, for example
|
|
39
|
+
* `"2026-11-03T00:00:00+01:00"`, or `null` for no limit on that side. The
|
|
40
|
+
* input accepts any ISO 8601 string as an end.
|
|
41
|
+
*/
|
|
42
|
+
| {
|
|
43
|
+
preset?: never;
|
|
44
|
+
start: string | null;
|
|
45
|
+
end: string | null;
|
|
46
|
+
};
|
|
47
|
+
/** The look of the input, and the props that only one look has */
|
|
48
|
+
export type DateTimeRangeInputVariant =
|
|
49
|
+
/** A trigger with the look of a field */
|
|
50
|
+
{
|
|
51
|
+
/**
|
|
52
|
+
* The look of the trigger. "default" has the look of a field. "filter"
|
|
53
|
+
* has no border and a small text, for the value of a filter.
|
|
54
|
+
* @default 'default'
|
|
55
|
+
*/
|
|
56
|
+
variant?: 'default';
|
|
57
|
+
/**
|
|
58
|
+
* Shows a button that sets the value back to the default preset (see
|
|
59
|
+
* `presets`), or to an empty range when there are no presets.
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
clearable?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The trigger is as wide as its text, not as wide as its container.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
autosize?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The value of a filter: no border, no clear button, a small text. The
|
|
71
|
+
* trigger is as wide as its text.
|
|
72
|
+
*/
|
|
73
|
+
| {
|
|
74
|
+
variant: 'filter';
|
|
75
|
+
clearable?: never;
|
|
76
|
+
autosize?: never;
|
|
77
|
+
};
|
|
78
|
+
/** The props of `DateTimeRangeInput` */
|
|
79
|
+
export type DateTimeRangeInputProps = BaseInputComponentPropsFieldWithReadOnly<DateTimeRangeValue> & Omit<FieldInputProps, 'id'> & DateTimeRangeInputVariant & {
|
|
80
|
+
/**
|
|
81
|
+
* The ranges of the menu, and the preset that the clear button sets.
|
|
82
|
+
* Without presets, the trigger opens the custom range directly.
|
|
83
|
+
*/
|
|
84
|
+
presets?: DateTimeRangePresets;
|
|
85
|
+
/**
|
|
86
|
+
* The text of the trigger when the custom range has no ends.
|
|
87
|
+
* @default "Custom range"
|
|
88
|
+
*/
|
|
89
|
+
placeholder?: TextMessage;
|
|
90
|
+
/**
|
|
91
|
+
* The accessible name of the input. Give it when the input is not in a
|
|
92
|
+
* `FieldWrapper` with a `label`.
|
|
93
|
+
*/
|
|
94
|
+
ariaLabel?: TextMessage;
|
|
95
|
+
/**
|
|
96
|
+
* When the custom range shows the time zone menu. "always" shows it.
|
|
97
|
+
* "whenDifferent" shows it only when the time zone of the user is not
|
|
98
|
+
* the time zone of the project.
|
|
99
|
+
* @default 'always'
|
|
100
|
+
*/
|
|
101
|
+
timezoneSelect?: 'always' | 'whenDifferent';
|
|
102
|
+
/**
|
|
103
|
+
* The side of the input where the custom range opens. It moves to the
|
|
104
|
+
* other side when there is no space.
|
|
105
|
+
* @default 'bottom-start'
|
|
106
|
+
*/
|
|
107
|
+
calendarPlacement?: PopoverProps['placement'];
|
|
108
|
+
/**
|
|
109
|
+
* The days that the user can pick in the calendar. "future" is today
|
|
110
|
+
* and the days after it. "past" is today and the days before it, for
|
|
111
|
+
* a range of past events. The calendar disables the other days. The
|
|
112
|
+
* user can still type a date out of the limit: check the value in your
|
|
113
|
+
* code.
|
|
114
|
+
* @default 'all'
|
|
115
|
+
*/
|
|
116
|
+
selectableDays?: SelectableDays;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* An input for a range of dates and times, for example the time range of a
|
|
120
|
+
* log. The trigger opens a menu with your presets and "Custom range", which
|
|
121
|
+
* opens a calendar with the two ends of the range.
|
|
122
|
+
*/
|
|
123
|
+
export default function DateTimeRangeInput({ value, onChange, onBlur, disabled: disabledProp, readOnly, presets: presetsProp, placeholder, ariaLabel, timezoneSelect, variant, clearable, calendarPlacement, selectableDays, autosize, id, name, ...ariaProps }: DateTimeRangeInputProps): React.JSX.Element;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Generic, Status } from "../../../icons/index.js";
|
|
2
|
+
import { useTranslation } from "../../i18n.js";
|
|
3
|
+
import { useDateSettings } from "../../content/DateSettings.js";
|
|
4
|
+
import Popover from "../../overlays/Popover.js";
|
|
5
|
+
import RawButton from "../../semantic/RawButton.js";
|
|
6
|
+
import Button from "../../actions/Button.js";
|
|
7
|
+
import { MenuChevron } from "../../navigation/Chevron.js";
|
|
8
|
+
import DropdownTriggerButton_default from "../../actions/Dropdown/triggers/DropdownTriggerButton.js";
|
|
9
|
+
import { Dropdown } from "../../actions/Dropdown/index.js";
|
|
10
|
+
import FieldWrapper_default, { useFieldInput } from "../FieldWrapper.js";
|
|
11
|
+
import { getEditState } from "../getEditState.js";
|
|
12
|
+
import "../DateTimeInput/CalendarGrid.js";
|
|
13
|
+
import Panel from "./Panel.js";
|
|
14
|
+
import { formatRangeEnds } from "./rangeLabel.js";
|
|
15
|
+
import React, { useCallback, useRef, useState } from "react";
|
|
16
|
+
import classNames from "classnames";
|
|
17
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
//#region ../ui-public/src/form/DateTimeRangeInput/index.tsx
|
|
19
|
+
var EMPTY_RANGE = {
|
|
20
|
+
start: null,
|
|
21
|
+
end: null
|
|
22
|
+
};
|
|
23
|
+
var NO_PRESETS = [];
|
|
24
|
+
function TriggerContent({ label, chevron }) {
|
|
25
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
26
|
+
/* @__PURE__ */ jsx(Status.ClockIcon, { className: "DateTimeRangeInput__trigger-icon" }),
|
|
27
|
+
/* @__PURE__ */ jsx("span", {
|
|
28
|
+
className: "DateTimeRangeInput__trigger-label",
|
|
29
|
+
children: label
|
|
30
|
+
}),
|
|
31
|
+
chevron && /* @__PURE__ */ jsx(MenuChevron, {})
|
|
32
|
+
] });
|
|
33
|
+
}
|
|
34
|
+
var PresetTrigger = React.memo(function PresetTrigger({ open, onTrigger, disabled, ...content }) {
|
|
35
|
+
return /* @__PURE__ */ jsx(DropdownTriggerButton_default, {
|
|
36
|
+
open,
|
|
37
|
+
onTrigger,
|
|
38
|
+
className: "DateTimeRangeInput__trigger",
|
|
39
|
+
disabled,
|
|
40
|
+
children: /* @__PURE__ */ jsx(TriggerContent, { ...content })
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* An input for a range of dates and times, for example the time range of a
|
|
45
|
+
* log. The trigger opens a menu with your presets and "Custom range", which
|
|
46
|
+
* opens a calendar with the two ends of the range.
|
|
47
|
+
*/
|
|
48
|
+
function DateTimeRangeInput({ value, onChange, onBlur, disabled: disabledProp, readOnly, presets: presetsProp, placeholder, ariaLabel, timezoneSelect = "always", variant = "default", clearable = true, calendarPlacement = "bottom-start", selectableDays = "all", autosize = false, id, name, ...ariaProps }) {
|
|
49
|
+
const { t, tm } = useTranslation();
|
|
50
|
+
const field = useFieldInput({
|
|
51
|
+
id,
|
|
52
|
+
...ariaProps
|
|
53
|
+
});
|
|
54
|
+
const { locked, stateClass } = getEditState({
|
|
55
|
+
disabled: disabledProp,
|
|
56
|
+
readOnly
|
|
57
|
+
});
|
|
58
|
+
const { locale, twentyFourHour, timezone: userTimezone, projectTimezone } = useDateSettings();
|
|
59
|
+
const [timezone, setTimezone] = useState(userTimezone);
|
|
60
|
+
const [panelOpen, setPanelOpen] = useState(false);
|
|
61
|
+
const [rootElement, setRootElement] = useState(null);
|
|
62
|
+
const panelRef = useRef(null);
|
|
63
|
+
const filter = variant === "filter";
|
|
64
|
+
const presets = presetsProp?.options ?? NO_PRESETS;
|
|
65
|
+
const defaultPreset = presetsProp?.default ?? presets[0]?.value;
|
|
66
|
+
const isCustom = value.preset === void 0;
|
|
67
|
+
const custom = isCustom ? {
|
|
68
|
+
start: value.start,
|
|
69
|
+
end: value.end
|
|
70
|
+
} : EMPTY_RANGE;
|
|
71
|
+
const commit = (newValue) => {
|
|
72
|
+
onChange?.(newValue);
|
|
73
|
+
onBlur?.(newValue);
|
|
74
|
+
};
|
|
75
|
+
const triggerLabel = (() => {
|
|
76
|
+
if (!isCustom) {
|
|
77
|
+
const preset = presets.find((p) => p.value === value.preset);
|
|
78
|
+
return preset ? tm(preset.label) : value.preset;
|
|
79
|
+
}
|
|
80
|
+
if (!custom.start && !custom.end) return placeholder ? tm(placeholder) : t("dateTimeRangeInput.custom");
|
|
81
|
+
const ends = formatRangeEnds(custom.start ? new Date(custom.start) : null, custom.end ? new Date(custom.end) : null, {
|
|
82
|
+
locale,
|
|
83
|
+
timezone,
|
|
84
|
+
twentyFourHour
|
|
85
|
+
});
|
|
86
|
+
return ends.kind === "both" ? ends.text : t(ends.kind === "start" ? "dateTimeRangeInput.from" : "dateTimeRangeInput.until", { date: ends.text });
|
|
87
|
+
})();
|
|
88
|
+
const closePanel = useCallback(() => {
|
|
89
|
+
const focusInPanel = Boolean(panelRef.current?.contains(document.activeElement));
|
|
90
|
+
setPanelOpen(false);
|
|
91
|
+
if (focusInPanel) rootElement?.querySelector(".DateTimeRangeInput__trigger")?.focus();
|
|
92
|
+
}, [rootElement]);
|
|
93
|
+
const handleApply = (range) => {
|
|
94
|
+
commit(range);
|
|
95
|
+
closePanel();
|
|
96
|
+
};
|
|
97
|
+
const clearValue = () => commit(defaultPreset ? { preset: defaultPreset } : EMPTY_RANGE);
|
|
98
|
+
const showsClear = !filter && clearable && !locked && isCustom && (presets.length > 0 || Boolean(custom.start || custom.end));
|
|
99
|
+
const valueTimezone = projectTimezone ?? userTimezone;
|
|
100
|
+
const showsTimezone = timezoneSelect === "always" || valueTimezone !== userTimezone;
|
|
101
|
+
const chevron = !showsClear;
|
|
102
|
+
return /* @__PURE__ */ jsx("div", {
|
|
103
|
+
ref: setRootElement,
|
|
104
|
+
role: "group",
|
|
105
|
+
id: field.id,
|
|
106
|
+
"aria-label": ariaLabel ? tm(ariaLabel) : void 0,
|
|
107
|
+
"aria-labelledby": ariaLabel ? void 0 : field["aria-labelledby"],
|
|
108
|
+
"aria-describedby": field["aria-describedby"],
|
|
109
|
+
className: classNames("DateTimeRangeInput", stateClass, {
|
|
110
|
+
"DateTimeRangeInput--filter": filter,
|
|
111
|
+
"DateTimeRangeInput--autosize": autosize || filter,
|
|
112
|
+
"DateTimeRangeInput--clearable": showsClear
|
|
113
|
+
}),
|
|
114
|
+
children: /* @__PURE__ */ jsxs(FieldWrapper_default.Boundary, { children: [
|
|
115
|
+
name && /* @__PURE__ */ jsx("input", {
|
|
116
|
+
type: "hidden",
|
|
117
|
+
name,
|
|
118
|
+
value: JSON.stringify(value)
|
|
119
|
+
}),
|
|
120
|
+
presets.length > 0 ? /* @__PURE__ */ jsx(Dropdown, {
|
|
121
|
+
className: "DateTimeRangeInput__dropdown",
|
|
122
|
+
triggerComponent: PresetTrigger,
|
|
123
|
+
label: triggerLabel,
|
|
124
|
+
chevron,
|
|
125
|
+
disabled: locked,
|
|
126
|
+
children: /* @__PURE__ */ jsxs(Dropdown.Menu, { children: [
|
|
127
|
+
presets.map((preset) => /* @__PURE__ */ jsx(Dropdown.Option, {
|
|
128
|
+
active: value.preset === preset.value,
|
|
129
|
+
onPick: () => {
|
|
130
|
+
setPanelOpen(false);
|
|
131
|
+
commit({ preset: preset.value });
|
|
132
|
+
},
|
|
133
|
+
children: tm(preset.label)
|
|
134
|
+
}, preset.value)),
|
|
135
|
+
/* @__PURE__ */ jsx(Dropdown.Separator, {}),
|
|
136
|
+
/* @__PURE__ */ jsx(Dropdown.Option, {
|
|
137
|
+
active: isCustom,
|
|
138
|
+
onPick: () => setPanelOpen(true),
|
|
139
|
+
children: t("dateTimeRangeInput.custom")
|
|
140
|
+
})
|
|
141
|
+
] })
|
|
142
|
+
}) : /* @__PURE__ */ jsx(RawButton, {
|
|
143
|
+
className: "DateTimeRangeInput__trigger",
|
|
144
|
+
disabled: locked,
|
|
145
|
+
haspopup: "dialog",
|
|
146
|
+
expandable: { open: panelOpen },
|
|
147
|
+
onClick: () => panelOpen ? closePanel() : setPanelOpen(true),
|
|
148
|
+
children: /* @__PURE__ */ jsx(TriggerContent, {
|
|
149
|
+
label: triggerLabel,
|
|
150
|
+
chevron
|
|
151
|
+
})
|
|
152
|
+
}),
|
|
153
|
+
showsClear && /* @__PURE__ */ jsx(Button, {
|
|
154
|
+
tone: "ghost",
|
|
155
|
+
size: "micro",
|
|
156
|
+
iconOnly: true,
|
|
157
|
+
icon: Generic.CloseIcon,
|
|
158
|
+
label: t("field.clearValue"),
|
|
159
|
+
className: "DateTimeRangeInput__clear",
|
|
160
|
+
onClick: clearValue
|
|
161
|
+
}),
|
|
162
|
+
panelOpen && rootElement && /* @__PURE__ */ jsx(Popover, {
|
|
163
|
+
anchorElement: rootElement,
|
|
164
|
+
placement: calendarPlacement,
|
|
165
|
+
offset: 4,
|
|
166
|
+
onClose: closePanel,
|
|
167
|
+
ariaLabel: { id: "dateTimeRangeInput.custom" },
|
|
168
|
+
autoFocus: ".DateTimeInput__CalendarDayCell[tabindex=\"0\"]",
|
|
169
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
170
|
+
ref: panelRef,
|
|
171
|
+
children: /* @__PURE__ */ jsx(Panel, {
|
|
172
|
+
initial: custom,
|
|
173
|
+
timezone,
|
|
174
|
+
valueTimezone,
|
|
175
|
+
showsTimezone,
|
|
176
|
+
onTimezoneChange: setTimezone,
|
|
177
|
+
selectableDays,
|
|
178
|
+
onApply: handleApply
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
] })
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
export { DateTimeRangeInput as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { intlDateTimeFormat } from "../DateTimeInput/dateText.js";
|
|
2
|
+
import { TZDate } from "@date-fns/tz";
|
|
3
|
+
//#region ../ui-public/src/form/DateTimeRangeInput/rangeLabel.ts
|
|
4
|
+
function formatRange(format, start, end) {
|
|
5
|
+
return format.formatRange(start, end);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The texts of the ends of a custom range for the trigger. A range in one
|
|
9
|
+
* day shows the times, and a range out of the current year shows the year.
|
|
10
|
+
* Intl puts the parts in the order of the language ("Nov 3 – 5", "3–5 nov").
|
|
11
|
+
*/
|
|
12
|
+
function formatRangeEnds(start, end, { locale, timezone, twentyFourHour }) {
|
|
13
|
+
const dayOf = (date) => {
|
|
14
|
+
const local = new TZDate(date.getTime(), timezone);
|
|
15
|
+
return {
|
|
16
|
+
year: local.getFullYear(),
|
|
17
|
+
key: `${local.getFullYear()}-${local.getMonth()}-${local.getDate()}`
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const ends = [start, end].filter((date) => date !== null);
|
|
21
|
+
const currentYear = dayOf(/* @__PURE__ */ new Date()).year;
|
|
22
|
+
const showsYear = ends.some((date) => dayOf(date).year !== currentYear);
|
|
23
|
+
const oneDay = Boolean(start && end && dayOf(start).key === dayOf(end).key);
|
|
24
|
+
const format = intlDateTimeFormat(locale, {
|
|
25
|
+
timeZone: timezone,
|
|
26
|
+
month: "short",
|
|
27
|
+
day: "numeric",
|
|
28
|
+
year: showsYear ? "numeric" : void 0,
|
|
29
|
+
hour: oneDay ? "numeric" : void 0,
|
|
30
|
+
minute: oneDay ? "2-digit" : void 0,
|
|
31
|
+
hourCycle: oneDay ? twentyFourHour ? "h23" : "h12" : void 0
|
|
32
|
+
});
|
|
33
|
+
if (start && end) return {
|
|
34
|
+
kind: "both",
|
|
35
|
+
text: formatRange(format, start, end)
|
|
36
|
+
};
|
|
37
|
+
return start ? {
|
|
38
|
+
kind: "start",
|
|
39
|
+
text: format.format(start)
|
|
40
|
+
} : {
|
|
41
|
+
kind: "end",
|
|
42
|
+
text: format.format(end)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { formatRangeEnds };
|
|
@@ -9,9 +9,9 @@ export type FieldHintProps = {
|
|
|
9
9
|
/**
|
|
10
10
|
* The text of the hint. A string is plain text. For markup, give
|
|
11
11
|
* `{ html }`: unlike the other `Message` props, the component does NOT
|
|
12
|
-
* sanitize this HTML (the sanitizer removes `data-router-link`),
|
|
12
|
+
* sanitize this HTML (the sanitizer removes `data-router-link`), so only
|
|
13
13
|
* give HTML that you trust. A link with the `data-router-link` attribute
|
|
14
|
-
* in it opens with the router of
|
|
14
|
+
* in it opens with the router of DatoCMS.
|
|
15
15
|
*/
|
|
16
16
|
hint?: Message;
|
|
17
17
|
/**
|
|
@@ -7,7 +7,7 @@ export type FieldWrapperLabelExtras = {
|
|
|
7
7
|
* of the input. Use it when a text near the input shows what it is.
|
|
8
8
|
*/
|
|
9
9
|
hidden?: boolean;
|
|
10
|
-
/** Adds the icon that
|
|
10
|
+
/** Adds the icon that says that the value is different for each locale. */
|
|
11
11
|
localized?: boolean;
|
|
12
12
|
/**
|
|
13
13
|
* The validators of the field, for the `FieldValidations` component of
|
|
@@ -38,7 +38,7 @@ export type FieldWrapperLabelProps =
|
|
|
38
38
|
labelExtras?: never;
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
|
-
* A required field shows an asterisk,
|
|
41
|
+
* A required field shows an asterisk, so it cannot also show "(optional)".
|
|
42
42
|
*/
|
|
43
43
|
export type FieldWrapperRequirementProps =
|
|
44
44
|
/** A field that is not required, with "(optional)" after the label */
|
|
@@ -69,7 +69,7 @@ export type FieldWrapperProps = FieldWrapperLabelProps & FieldWrapperRequirement
|
|
|
69
69
|
id?: string;
|
|
70
70
|
/**
|
|
71
71
|
* A short help under the input. A string is plain text. For markup, give
|
|
72
|
-
* `{ html }`: this HTML is not sanitized,
|
|
72
|
+
* `{ html }`: this HTML is not sanitized, so give only HTML that you
|
|
73
73
|
* trust. A screen reader reads it as the description of the input.
|
|
74
74
|
*/
|
|
75
75
|
hint?: Message;
|
|
@@ -135,11 +135,11 @@ export type FieldInputProps = {
|
|
|
135
135
|
/**
|
|
136
136
|
* Gives the `id` and the ARIA props of an input in a `FieldWrapper`. It
|
|
137
137
|
* takes the props of the input and reads the five props of
|
|
138
|
-
* `FieldInputProps
|
|
139
|
-
* of a `FieldWrapper`, it gives
|
|
138
|
+
* `FieldInputProps`. A prop that you give wins over the field. Out
|
|
139
|
+
* of a `FieldWrapper`, it gives your props as they are.
|
|
140
140
|
*
|
|
141
141
|
* All the inputs of the package call it. A custom input of a plugin calls it
|
|
142
|
-
* too, and puts the result on the element that gets the focus
|
|
142
|
+
* too, and puts the result on the element that gets the focus. So the
|
|
143
143
|
* input works in a `FieldWrapper`.
|
|
144
144
|
* @example const fieldProps = useFieldInput(props); return <input {...fieldProps} />;
|
|
145
145
|
*/
|
|
@@ -181,7 +181,7 @@ declare const _default: React.ForwardRefExoticComponent<(({
|
|
|
181
181
|
id?: string;
|
|
182
182
|
/**
|
|
183
183
|
* A short help under the input. A string is plain text. For markup, give
|
|
184
|
-
* `{ html }`: this HTML is not sanitized,
|
|
184
|
+
* `{ html }`: this HTML is not sanitized, so give only HTML that you
|
|
185
185
|
* trust. A screen reader reads it as the description of the input.
|
|
186
186
|
*/
|
|
187
187
|
hint?: Message;
|
|
@@ -239,7 +239,7 @@ declare const _default: React.ForwardRefExoticComponent<(({
|
|
|
239
239
|
id?: string;
|
|
240
240
|
/**
|
|
241
241
|
* A short help under the input. A string is plain text. For markup, give
|
|
242
|
-
* `{ html }`: this HTML is not sanitized,
|
|
242
|
+
* `{ html }`: this HTML is not sanitized, so give only HTML that you
|
|
243
243
|
* trust. A screen reader reads it as the description of the input.
|
|
244
244
|
*/
|
|
245
245
|
hint?: Message;
|
|
@@ -291,7 +291,7 @@ declare const _default: React.ForwardRefExoticComponent<(({
|
|
|
291
291
|
id?: string;
|
|
292
292
|
/**
|
|
293
293
|
* A short help under the input. A string is plain text. For markup, give
|
|
294
|
-
* `{ html }`: this HTML is not sanitized,
|
|
294
|
+
* `{ html }`: this HTML is not sanitized, so give only HTML that you
|
|
295
295
|
* trust. A screen reader reads it as the description of the input.
|
|
296
296
|
*/
|
|
297
297
|
hint?: Message;
|
|
@@ -10,11 +10,11 @@ var FieldContext = createContext(void 0);
|
|
|
10
10
|
/**
|
|
11
11
|
* Gives the `id` and the ARIA props of an input in a `FieldWrapper`. It
|
|
12
12
|
* takes the props of the input and reads the five props of
|
|
13
|
-
* `FieldInputProps
|
|
14
|
-
* of a `FieldWrapper`, it gives
|
|
13
|
+
* `FieldInputProps`. A prop that you give wins over the field. Out
|
|
14
|
+
* of a `FieldWrapper`, it gives your props as they are.
|
|
15
15
|
*
|
|
16
16
|
* All the inputs of the package call it. A custom input of a plugin calls it
|
|
17
|
-
* too, and puts the result on the element that gets the focus
|
|
17
|
+
* too, and puts the result on the element that gets the focus. So the
|
|
18
18
|
* input works in a `FieldWrapper`.
|
|
19
19
|
* @example const fieldProps = useFieldInput(props); return <input {...fieldProps} />;
|
|
20
20
|
*/
|