datocms-react-ui 3.1.0-next.5 → 4.0.0-next.7
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 +2 -1
- 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/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 +627 -29
- package/dist/ui-public/icons/index.js +294 -367
- 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/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/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/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/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/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 +45 -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/IconAvatar.d.ts +1 -1
- 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 +2 -2
- 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/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 +1 -1
- 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/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/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/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,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type DateInputCommonProps } from './DateTimeInput/Base.js';
|
|
3
|
+
/**
|
|
4
|
+
* The props of `DateInput`. The value is a date as `"yyyy-MM-dd"`, for
|
|
5
|
+
* example `"2026-11-17"`, or `null`.
|
|
6
|
+
*/
|
|
7
|
+
export type DateInputProps = DateInputCommonProps;
|
|
8
|
+
export type { DateInputVariant, SelectableDays } from './DateTimeInput/Base.js';
|
|
9
|
+
/**
|
|
10
|
+
* An input for a date, with a calendar. The user types the date in the
|
|
11
|
+
* format of their settings, or picks the day in the calendar.
|
|
12
|
+
*/
|
|
13
|
+
export default function DateInput(props: DateInputProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import DateTimeInputBase from "./DateTimeInput/Base.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region ../ui-public/src/form/DateInput.tsx
|
|
5
|
+
/**
|
|
6
|
+
* An input for a date, with a calendar. The user types the date in the
|
|
7
|
+
* format of their settings, or picks the day in the calendar.
|
|
8
|
+
*/
|
|
9
|
+
function DateInput(props) {
|
|
10
|
+
return /* @__PURE__ */ jsx(DateTimeInputBase, {
|
|
11
|
+
...props,
|
|
12
|
+
withTime: false
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DateInput as default };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type TextMessage } from '../../Message.js';
|
|
3
|
+
import { type PopoverProps } from '../../overlays/Popover.js';
|
|
4
|
+
import { type FieldInputProps } from '../FieldWrapper.js';
|
|
5
|
+
import { BaseInputComponentPropsFieldWithReadOnly } from '../inputProps.js';
|
|
6
|
+
import { type SelectableDays } from './CalendarGrid.js';
|
|
7
|
+
export type { SelectableDays } from './CalendarGrid.js';
|
|
8
|
+
/** The look of the input, and the props that only one look has */
|
|
9
|
+
export type DateInputVariant =
|
|
10
|
+
/** A field with a border, a calendar button and a clear button */
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* The look of the input. "default" is a field with a border and a
|
|
14
|
+
* calendar button. "filter" has no border, no buttons and a small
|
|
15
|
+
* text, for the value of a filter: the calendar opens when the user
|
|
16
|
+
* clicks the date.
|
|
17
|
+
* @default 'default'
|
|
18
|
+
*/
|
|
19
|
+
variant?: 'default';
|
|
20
|
+
/**
|
|
21
|
+
* Shows a button that clears the value, when the input has a value.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
clearable?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The field is as wide as its content, not as wide as its container.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
autosize?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The value of a filter: no border, no buttons, a small text. It is as
|
|
33
|
+
* wide as its content.
|
|
34
|
+
*/
|
|
35
|
+
| {
|
|
36
|
+
variant: 'filter';
|
|
37
|
+
clearable?: never;
|
|
38
|
+
autosize?: never;
|
|
39
|
+
};
|
|
40
|
+
/** The props that `DateInput` and `DateTimeInput` share */
|
|
41
|
+
export type DateInputCommonProps = BaseInputComponentPropsFieldWithReadOnly<string | null> & Omit<FieldInputProps, 'id'> & DateInputVariant & {
|
|
42
|
+
/**
|
|
43
|
+
* The accessible name of the date text. Give it when the input is not in
|
|
44
|
+
* a `FieldWrapper` with a `label`.
|
|
45
|
+
*/
|
|
46
|
+
ariaLabel?: TextMessage;
|
|
47
|
+
/**
|
|
48
|
+
* The side of the field where the calendar opens. It moves to the other
|
|
49
|
+
* side when there is no space.
|
|
50
|
+
* @default 'bottom-start'
|
|
51
|
+
*/
|
|
52
|
+
calendarPlacement?: PopoverProps['placement'];
|
|
53
|
+
/**
|
|
54
|
+
* The days that the user can pick in the calendar. "future" is today and
|
|
55
|
+
* the days after it, "past" is today and the days before it. The
|
|
56
|
+
* calendar disables the other days. The user can still type a date out
|
|
57
|
+
* of the limit: check the value in your code.
|
|
58
|
+
* @default 'all'
|
|
59
|
+
*/
|
|
60
|
+
selectableDays?: SelectableDays;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The props of `DateTimeInput`. The value is an ISO 8601 date and time with
|
|
64
|
+
* an offset, for example `"2026-11-17T09:30:00+01:00"`, or `null`.
|
|
65
|
+
*/
|
|
66
|
+
export type DateTimeInputProps = DateInputCommonProps & {
|
|
67
|
+
/**
|
|
68
|
+
* The time has the seconds. Without them, the user types the hours and
|
|
69
|
+
* the minutes, and the seconds of the value are 0.
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
seconds?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* When the field shows the time zone menu. "always" shows it. "whenDifferent"
|
|
75
|
+
* shows it only when the time zone of the user is not the time zone of the
|
|
76
|
+
* project, so the user sees which time zone the time is in.
|
|
77
|
+
* @default 'always'
|
|
78
|
+
*/
|
|
79
|
+
timezoneSelect?: 'always' | 'whenDifferent';
|
|
80
|
+
};
|
|
81
|
+
type DateTimeInputBaseProps = DateTimeInputProps & {
|
|
82
|
+
withTime: boolean;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* The input of `DateInput` and of `DateTimeInput`. A date has no time zone:
|
|
86
|
+
* it uses the time zone of the project for the instant of its midnight, and
|
|
87
|
+
* shows the same day.
|
|
88
|
+
*/
|
|
89
|
+
export default function DateTimeInputBase({ value, onChange, onBlur, disabled: disabledProp, readOnly, withTime, seconds, timezoneSelect, variant, clearable, calendarPlacement, selectableDays, autosize, ariaLabel, id, name, ...ariaProps }: DateTimeInputBaseProps): React.JSX.Element;
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { Generic, UI } 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 Button from "../../actions/Button.js";
|
|
6
|
+
import AutosizeInput_default from "../AutosizeInput.js";
|
|
7
|
+
import FieldWrapper_default, { useFieldInput } from "../FieldWrapper.js";
|
|
8
|
+
import { timezoneOptions } from "../../utils/timezones.js";
|
|
9
|
+
import { getEditState } from "../getEditState.js";
|
|
10
|
+
import SelectInput from "../SelectInput/index.js";
|
|
11
|
+
import { parseDateText, timeInputFormats } from "./dateText.js";
|
|
12
|
+
import CalendarGrid, { CALENDAR_FOCUS_TARGET } from "./CalendarGrid.js";
|
|
13
|
+
import { DATE_TIME_VALUE_FORMAT, DATE_VALUE_FORMAT, formatInstantInTimezone } from "./value.js";
|
|
14
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
15
|
+
import classNames from "classnames";
|
|
16
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { TZDate, tzOffset } from "@date-fns/tz";
|
|
18
|
+
import { format } from "date-fns";
|
|
19
|
+
//#region ../ui-public/src/form/DateTimeInput/Base.tsx
|
|
20
|
+
/**
|
|
21
|
+
* Creates a TZDate for midnight (00:00) of a 'yyyy-MM-dd' date in an IANA
|
|
22
|
+
* time zone.
|
|
23
|
+
*
|
|
24
|
+
* Example:
|
|
25
|
+
* createTzMidnight("2025-11-01", "America/Manaus")
|
|
26
|
+
* → TZDate for 2025-11-01T00:00:00-04:00 (2025-11-01T04:00:00Z)
|
|
27
|
+
*/
|
|
28
|
+
function createTzMidnight(dateString, timeZone) {
|
|
29
|
+
const [year, month, day] = dateString.split("-").map(Number);
|
|
30
|
+
if (!year || Number.isNaN(month) || Number.isNaN(day) || month < 1 || month > 12 || day < 1 || day > 31) throw new Error(`Invalid date string: ${dateString}`);
|
|
31
|
+
return new TZDate(year, month - 1, day, timeZone);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns a TZDate for 00:00:00 of today in the time zone.
|
|
35
|
+
*
|
|
36
|
+
* Example: at 15:34 of 2025-10-25 in "America/Los_Angeles", it returns
|
|
37
|
+
* 2025-10-25T00:00:00 in "America/Los_Angeles". Its getTime() is the UTC
|
|
38
|
+
* instant of that wall clock.
|
|
39
|
+
*/
|
|
40
|
+
function tzStartOfDay(timezone) {
|
|
41
|
+
const currentTimeInTz = TZDate.tz(timezone);
|
|
42
|
+
return TZDate.tz(timezone, currentTimeInTz.getFullYear(), currentTimeInTz.getMonth(), currentTimeInTz.getDate());
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parses the text of the user with the first format that matches. Then
|
|
46
|
+
* `copyFn` copies the parsed parts (the day, or the time) as the wall clock
|
|
47
|
+
* of `inputTimezone` onto the base instant. Without a base instant, the base
|
|
48
|
+
* is 00:00 of today in `inputTimezone`. It returns null when no format
|
|
49
|
+
* matches.
|
|
50
|
+
*
|
|
51
|
+
* Example (a time):
|
|
52
|
+
* base = "2025-10-25T09:00:00.000Z", text = "11:00:00",
|
|
53
|
+
* inputTimezone = "America/Los_Angeles"
|
|
54
|
+
* 1) "11:00:00" gives a Date with the hours 11 and the minutes 0.
|
|
55
|
+
* 2) The base becomes a TZDate in Los Angeles.
|
|
56
|
+
* 3) copyFn sets 11:00:00 on it: the instant is now 11:00 in Los Angeles.
|
|
57
|
+
*/
|
|
58
|
+
function applyInputAsWallClock(baseInstantISOString, copyFn, { inputText, inputFormats, inputTimezone }) {
|
|
59
|
+
const parsedUserInput = parseDateText(inputText, inputFormats);
|
|
60
|
+
if (!parsedUserInput) return null;
|
|
61
|
+
const modifiableInstanceInInputTz = baseInstantISOString ? TZDate.tz(inputTimezone, baseInstantISOString) : tzStartOfDay(inputTimezone);
|
|
62
|
+
copyFn(parsedUserInput, modifiableInstanceInInputTz);
|
|
63
|
+
return modifiableInstanceInInputTz;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The offset of the time zone at the instant, in a short form: "UTC",
|
|
67
|
+
* "UTC+2", "UTC-3:30". The instant is necessary, because the offset changes
|
|
68
|
+
* with daylight saving time.
|
|
69
|
+
*/
|
|
70
|
+
function shortTimezoneLabel(timezone, instant) {
|
|
71
|
+
const minutes = tzOffset(timezone, instant);
|
|
72
|
+
if (minutes === 0) return "UTC";
|
|
73
|
+
const sign = minutes > 0 ? "+" : "-";
|
|
74
|
+
const hours = Math.floor(Math.abs(minutes) / 60);
|
|
75
|
+
const rest = Math.abs(minutes) % 60;
|
|
76
|
+
return `UTC${sign}${hours}${rest ? `:${String(rest).padStart(2, "0")}` : ""}`;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The text that sets the width of a date or time input (see AutosizeInput).
|
|
80
|
+
* It has one line for each of these: a sample with the widest digits
|
|
81
|
+
* ("28/12/2026", "08:58:58 PM"), the placeholder (the format), and the text
|
|
82
|
+
* of the user. The width is the width of the longest line. So the input
|
|
83
|
+
* keeps its width when the user sets or clears the value, and the text never
|
|
84
|
+
* gets cut.
|
|
85
|
+
*/
|
|
86
|
+
var widestSample = new Date(2026, 11, 28, 20, 58, 58);
|
|
87
|
+
function sizerText(inputFormat, input) {
|
|
88
|
+
return [
|
|
89
|
+
format(widestSample, inputFormat),
|
|
90
|
+
inputFormat,
|
|
91
|
+
input
|
|
92
|
+
].join("\n");
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The input of `DateInput` and of `DateTimeInput`. A date has no time zone:
|
|
96
|
+
* it uses the time zone of the project for the instant of its midnight, and
|
|
97
|
+
* shows the same day.
|
|
98
|
+
*/
|
|
99
|
+
function DateTimeInputBase({ value, onChange, onBlur, disabled: disabledProp, readOnly, withTime, seconds = true, timezoneSelect = "always", variant = "default", clearable = true, calendarPlacement = "bottom-start", selectableDays = "all", autosize = false, ariaLabel, id, name, ...ariaProps }) {
|
|
100
|
+
const { t, tm } = useTranslation();
|
|
101
|
+
const fieldProps = useFieldInput({
|
|
102
|
+
id,
|
|
103
|
+
...ariaProps
|
|
104
|
+
});
|
|
105
|
+
const { locked, disabled, showsReadOnly, stateClass } = getEditState({
|
|
106
|
+
disabled: disabledProp,
|
|
107
|
+
readOnly
|
|
108
|
+
});
|
|
109
|
+
const { dateFormat, twentyFourHour, timezone: userTimezone, projectTimezone } = useDateSettings();
|
|
110
|
+
const apiTimezone = projectTimezone ?? userTimezone;
|
|
111
|
+
const filter = variant === "filter";
|
|
112
|
+
const commit = (newValue) => {
|
|
113
|
+
onChange?.(newValue);
|
|
114
|
+
onBlur?.(newValue);
|
|
115
|
+
};
|
|
116
|
+
const timeFormats = timeInputFormats(twentyFourHour, seconds);
|
|
117
|
+
const serializationFormat = withTime ? DATE_TIME_VALUE_FORMAT : DATE_VALUE_FORMAT;
|
|
118
|
+
const timeFormat = timeFormats[0];
|
|
119
|
+
const [selectedTimezone, setSelectedTimezone] = useState(withTime ? userTimezone : apiTimezone);
|
|
120
|
+
const canonicalInstantISO = value ? withTime ? new Date(value).toISOString() : createTzMidnight(value, apiTimezone).toISOString() : null;
|
|
121
|
+
const formattedDateDisplay = canonicalInstantISO ? format(TZDate.tz(selectedTimezone, canonicalInstantISO), dateFormat) : "";
|
|
122
|
+
const formattedTimeDisplay = canonicalInstantISO ? format(TZDate.tz(selectedTimezone, canonicalInstantISO), timeFormat) : "";
|
|
123
|
+
const [calendarOpener, setCalendarOpener] = useState(null);
|
|
124
|
+
const calendarVisible = calendarOpener !== null;
|
|
125
|
+
const [userDateInput, setUserDateInput] = useState(formattedDateDisplay);
|
|
126
|
+
const [userTimeInput, setUserTimeInput] = useState(formattedTimeDisplay);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
setUserDateInput(formattedDateDisplay);
|
|
129
|
+
setUserTimeInput(formattedTimeDisplay);
|
|
130
|
+
}, [
|
|
131
|
+
value,
|
|
132
|
+
formattedDateDisplay,
|
|
133
|
+
formattedTimeDisplay
|
|
134
|
+
]);
|
|
135
|
+
const dateInputRef = useRef(null);
|
|
136
|
+
const calendarRef = useRef(null);
|
|
137
|
+
const skipOpenOnFocus = useRef(false);
|
|
138
|
+
const closeCalendar = useCallback(() => {
|
|
139
|
+
const focusInCalendar = Boolean(calendarRef.current?.contains(document.activeElement));
|
|
140
|
+
setCalendarOpener(null);
|
|
141
|
+
if (calendarOpener === "field" && focusInCalendar) {
|
|
142
|
+
skipOpenOnFocus.current = true;
|
|
143
|
+
dateInputRef.current?.focus();
|
|
144
|
+
}
|
|
145
|
+
}, [calendarOpener]);
|
|
146
|
+
const handleChangeDay = (date) => {
|
|
147
|
+
const dateTimeInSelectedTz = canonicalInstantISO ? TZDate.tz(selectedTimezone, canonicalInstantISO) : tzStartOfDay(selectedTimezone);
|
|
148
|
+
dateTimeInSelectedTz.setFullYear(date.getFullYear());
|
|
149
|
+
dateTimeInSelectedTz.setMonth(date.getMonth(), date.getDate());
|
|
150
|
+
commit(formatInstantInTimezone(dateTimeInSelectedTz, apiTimezone, serializationFormat));
|
|
151
|
+
closeCalendar();
|
|
152
|
+
};
|
|
153
|
+
const transformedDate = applyInputAsWallClock(canonicalInstantISO, (src, dest) => {
|
|
154
|
+
dest.setFullYear(src.getFullYear());
|
|
155
|
+
dest.setMonth(src.getMonth(), src.getDate());
|
|
156
|
+
}, {
|
|
157
|
+
inputText: userDateInput,
|
|
158
|
+
inputFormats: [dateFormat],
|
|
159
|
+
inputTimezone: selectedTimezone
|
|
160
|
+
});
|
|
161
|
+
const serializedDateValue = transformedDate ? formatInstantInTimezone(transformedDate, apiTimezone, serializationFormat) : null;
|
|
162
|
+
const selectedDay = transformedDate ? format(transformedDate, "yyyy-MM-dd") : null;
|
|
163
|
+
const handleDateTextBlur = () => {
|
|
164
|
+
if (!serializedDateValue) {
|
|
165
|
+
setUserDateInput(formattedDateDisplay);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
commit(serializedDateValue);
|
|
169
|
+
};
|
|
170
|
+
const handleTimeTextBlur = () => {
|
|
171
|
+
const transformedTime = applyInputAsWallClock(canonicalInstantISO, (src, dest) => {
|
|
172
|
+
dest.setHours(src.getHours());
|
|
173
|
+
dest.setMinutes(src.getMinutes());
|
|
174
|
+
dest.setSeconds(seconds ? src.getSeconds() : 0);
|
|
175
|
+
}, {
|
|
176
|
+
inputText: userTimeInput,
|
|
177
|
+
inputFormats: timeFormats,
|
|
178
|
+
inputTimezone: selectedTimezone
|
|
179
|
+
});
|
|
180
|
+
if (!transformedTime) {
|
|
181
|
+
setUserTimeInput(formattedTimeDisplay);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
commit(formatInstantInTimezone(transformedTime, apiTimezone, serializationFormat));
|
|
185
|
+
};
|
|
186
|
+
const handleDateTextFocus = () => {
|
|
187
|
+
if (skipOpenOnFocus.current) {
|
|
188
|
+
skipOpenOnFocus.current = false;
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (!locked) setCalendarOpener("field");
|
|
192
|
+
};
|
|
193
|
+
const handleDateTextKeyDown = (event) => {
|
|
194
|
+
if (event.key !== "ArrowDown" || !calendarVisible) return;
|
|
195
|
+
const target = calendarRef.current?.querySelector(CALENDAR_FOCUS_TARGET);
|
|
196
|
+
if (target) {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
target.focus();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
const handleCalendarButtonClick = () => {
|
|
202
|
+
setCalendarOpener(calendarVisible ? null : "button");
|
|
203
|
+
};
|
|
204
|
+
const handleTimezoneChange = (newTimezone) => {
|
|
205
|
+
if (newTimezone === null) return;
|
|
206
|
+
if (!canonicalInstantISO) {
|
|
207
|
+
setSelectedTimezone(newTimezone);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const instantInOldTz = TZDate.tz(selectedTimezone, canonicalInstantISO);
|
|
211
|
+
const instantInNewTz = new TZDate(instantInOldTz.getTime(), newTimezone);
|
|
212
|
+
commit(formatInstantInTimezone(instantInNewTz, apiTimezone, serializationFormat));
|
|
213
|
+
setSelectedTimezone(newTimezone);
|
|
214
|
+
};
|
|
215
|
+
const [fieldElement, setFieldElement] = useState(null);
|
|
216
|
+
const handleBlur = (event) => {
|
|
217
|
+
const next = event.relatedTarget;
|
|
218
|
+
if (calendarOpener === "field" && next && !event.currentTarget.contains(next) && !calendarRef.current?.contains(next)) setCalendarOpener(null);
|
|
219
|
+
};
|
|
220
|
+
const formatTimezoneLabel = useCallback((option, { context }) => context === "value" ? shortTimezoneLabel(option.value, canonicalInstantISO ? new Date(canonicalInstantISO) : /* @__PURE__ */ new Date()) : option.label, [canonicalInstantISO]);
|
|
221
|
+
const showTimezone = withTime && (timezoneSelect === "always" || apiTimezone !== userTimezone);
|
|
222
|
+
const showClear = Boolean(value) && !filter && clearable && Boolean(onChange) && !locked;
|
|
223
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
224
|
+
onBlur: handleBlur,
|
|
225
|
+
className: classNames("DateTimeInput", stateClass, {
|
|
226
|
+
"DateTimeInput--smaller": filter,
|
|
227
|
+
"DateTimeInput--with-time": withTime,
|
|
228
|
+
"DateTimeInput--autosize": autosize || filter,
|
|
229
|
+
"is-open": calendarVisible
|
|
230
|
+
}),
|
|
231
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
232
|
+
className: classNames("InputFrame DateTimeInput__field", stateClass, { "is-open": calendarVisible }),
|
|
233
|
+
ref: setFieldElement,
|
|
234
|
+
children: [
|
|
235
|
+
!filter && /* @__PURE__ */ jsx(Button, {
|
|
236
|
+
tone: "ghost",
|
|
237
|
+
size: "micro",
|
|
238
|
+
iconOnly: true,
|
|
239
|
+
icon: UI.CalendarIcon,
|
|
240
|
+
label: t("dateTimeInput.openCalendar"),
|
|
241
|
+
className: "InputFrame__control DateTimeInput__calendar-button",
|
|
242
|
+
onClick: handleCalendarButtonClick,
|
|
243
|
+
disabled: locked,
|
|
244
|
+
"aria-expanded": calendarVisible
|
|
245
|
+
}),
|
|
246
|
+
/* @__PURE__ */ jsx(AutosizeInput_default, {
|
|
247
|
+
text: sizerText(dateFormat, userDateInput),
|
|
248
|
+
className: "DateTimeInput__sizer DateTimeInput__sizer--date",
|
|
249
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
250
|
+
...fieldProps,
|
|
251
|
+
ref: dateInputRef,
|
|
252
|
+
name,
|
|
253
|
+
"aria-label": ariaLabel ? tm(ariaLabel) : void 0,
|
|
254
|
+
type: "text",
|
|
255
|
+
placeholder: dateFormat,
|
|
256
|
+
value: userDateInput,
|
|
257
|
+
onChange: (event) => setUserDateInput(event.target.value),
|
|
258
|
+
onFocus: handleDateTextFocus,
|
|
259
|
+
onBlur: handleDateTextBlur,
|
|
260
|
+
onKeyDown: handleDateTextKeyDown,
|
|
261
|
+
className: "InputFrame__input DateTimeInput__date",
|
|
262
|
+
disabled,
|
|
263
|
+
readOnly: showsReadOnly,
|
|
264
|
+
spellCheck: false,
|
|
265
|
+
autoComplete: "off"
|
|
266
|
+
})
|
|
267
|
+
}),
|
|
268
|
+
/* @__PURE__ */ jsxs(FieldWrapper_default.Boundary, { children: [withTime && /* @__PURE__ */ jsx(AutosizeInput_default, {
|
|
269
|
+
text: sizerText(timeFormat, userTimeInput),
|
|
270
|
+
className: "DateTimeInput__sizer DateTimeInput__sizer--time",
|
|
271
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
272
|
+
"aria-label": t("dateTimeInput.time"),
|
|
273
|
+
type: "text",
|
|
274
|
+
placeholder: timeFormat,
|
|
275
|
+
value: userTimeInput,
|
|
276
|
+
onChange: (event) => setUserTimeInput(event.target.value),
|
|
277
|
+
onBlur: handleTimeTextBlur,
|
|
278
|
+
className: "InputFrame__input DateTimeInput__time",
|
|
279
|
+
disabled,
|
|
280
|
+
readOnly: showsReadOnly,
|
|
281
|
+
spellCheck: false,
|
|
282
|
+
autoComplete: "off"
|
|
283
|
+
})
|
|
284
|
+
}), showTimezone && /* @__PURE__ */ jsx(SelectInput, {
|
|
285
|
+
"aria-label": t("dateTimeInput.timezone"),
|
|
286
|
+
options: timezoneOptions,
|
|
287
|
+
value: selectedTimezone,
|
|
288
|
+
onChange: handleTimezoneChange,
|
|
289
|
+
onBlur: handleTimezoneChange,
|
|
290
|
+
className: "DateTimeInput__timezone",
|
|
291
|
+
classNamePrefix: "DateTimeInput__timezone",
|
|
292
|
+
formatOptionLabel: formatTimezoneLabel,
|
|
293
|
+
autosize: true,
|
|
294
|
+
variant: "embedded",
|
|
295
|
+
disabled: locked
|
|
296
|
+
})] }),
|
|
297
|
+
showClear && /* @__PURE__ */ jsx(Button, {
|
|
298
|
+
tone: "ghost",
|
|
299
|
+
size: "micro",
|
|
300
|
+
iconOnly: true,
|
|
301
|
+
icon: Generic.CloseIcon,
|
|
302
|
+
label: t("field.clearValue"),
|
|
303
|
+
className: "InputFrame__control DateTimeInput__clear",
|
|
304
|
+
onClick: () => commit(null)
|
|
305
|
+
})
|
|
306
|
+
]
|
|
307
|
+
}), calendarVisible && fieldElement && /* @__PURE__ */ jsx(Popover, {
|
|
308
|
+
anchorElement: fieldElement,
|
|
309
|
+
placement: calendarPlacement,
|
|
310
|
+
offset: 4,
|
|
311
|
+
onClose: closeCalendar,
|
|
312
|
+
ariaLabel: { id: "dateTimeInput.calendar" },
|
|
313
|
+
autoFocus: calendarOpener === "button" ? ".DateTimeInput__CalendarDayCell[tabindex=\"0\"]" : void 0,
|
|
314
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
315
|
+
ref: calendarRef,
|
|
316
|
+
className: "DateTimeInput__date-popper",
|
|
317
|
+
children: /* @__PURE__ */ jsx(CalendarGrid, {
|
|
318
|
+
selection: {
|
|
319
|
+
start: selectedDay,
|
|
320
|
+
end: selectedDay
|
|
321
|
+
},
|
|
322
|
+
onChange: handleChangeDay,
|
|
323
|
+
selectableDays
|
|
324
|
+
})
|
|
325
|
+
})
|
|
326
|
+
})]
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
//#endregion
|
|
330
|
+
export { DateTimeInputBase as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** The selector of the day that has the focus, or that gets it with Tab */
|
|
3
|
+
export declare const CALENDAR_FOCUS_TARGET = ".DateTimeInput__CalendarDayCell[tabindex=\"0\"]";
|
|
4
|
+
/**
|
|
5
|
+
* The selected days, as 'yyyy-MM-dd'. One date has the same day in `start`
|
|
6
|
+
* and `end`. A range that has only one end has null in the other.
|
|
7
|
+
*/
|
|
8
|
+
export type CalendarSelection = {
|
|
9
|
+
start: string | null;
|
|
10
|
+
end: string | null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The days that the user can pick in the calendar. "future" is today and the
|
|
14
|
+
* days after it. "past" is today and the days before it.
|
|
15
|
+
*/
|
|
16
|
+
export type SelectableDays = 'all' | 'future' | 'past';
|
|
17
|
+
type CalendarGridProps = {
|
|
18
|
+
selection: CalendarSelection;
|
|
19
|
+
selectableDays: SelectableDays;
|
|
20
|
+
onChange: (day: Date) => void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The days of a month in a grid, for one date or for a range. The arrows,
|
|
24
|
+
* Home, End, Page Up and Page Down move the focus between the days, as in
|
|
25
|
+
* the date picker of the WAI-ARIA Authoring Practices. Only one day is in
|
|
26
|
+
* the Tab order.
|
|
27
|
+
*/
|
|
28
|
+
export default function CalendarGrid({ selection, selectableDays, onChange, }: CalendarGridProps): React.JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { Navigation, UI } from "../../../icons/index.js";
|
|
2
|
+
import { useTranslation } from "../../i18n.js";
|
|
3
|
+
import { useDateSettings } from "../../content/DateSettings.js";
|
|
4
|
+
import RawButton from "../../semantic/RawButton.js";
|
|
5
|
+
import Button from "../../actions/Button.js";
|
|
6
|
+
import { useAutoincrementIntegerId } from "../../hooks/useAutoincrementIntegerId.js";
|
|
7
|
+
import { weekStartForLocale } from "../../utils/weekStartForLocale.js";
|
|
8
|
+
import { intlDateTimeFormat } from "./dateText.js";
|
|
9
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
10
|
+
import classNames from "classnames";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { addDays, addMonths, addYears, differenceInCalendarWeeks, endOfMonth, endOfWeek, format, isAfter, isBefore, isSameDay, isSameMonth, isToday, parseISO, startOfDay, startOfMonth, startOfWeek } from "date-fns";
|
|
13
|
+
//#region ../ui-public/src/form/DateTimeInput/CalendarGrid.tsx
|
|
14
|
+
function generateMatrix(month, weekStartsOn) {
|
|
15
|
+
const firstDay = startOfMonth(month);
|
|
16
|
+
const lastDay = endOfMonth(month);
|
|
17
|
+
const start = startOfWeek(firstDay, { weekStartsOn });
|
|
18
|
+
const rows = differenceInCalendarWeeks(lastDay, firstDay, { weekStartsOn }) + 1;
|
|
19
|
+
return Array.from({ length: rows }, (_, row) => Array.from({ length: 7 }, (_, col) => addDays(start, row * 7 + col)));
|
|
20
|
+
}
|
|
21
|
+
function useCalendarNames(locale) {
|
|
22
|
+
return useMemo(() => ({
|
|
23
|
+
month: intlDateTimeFormat(locale, {
|
|
24
|
+
month: "long",
|
|
25
|
+
year: "numeric"
|
|
26
|
+
}),
|
|
27
|
+
weekdayShort: intlDateTimeFormat(locale, { weekday: "short" }),
|
|
28
|
+
weekdayLong: intlDateTimeFormat(locale, { weekday: "long" }),
|
|
29
|
+
day: intlDateTimeFormat(locale, { dateStyle: "full" })
|
|
30
|
+
}), [locale]);
|
|
31
|
+
}
|
|
32
|
+
/** The day that a key moves the focus to, or null for another key */
|
|
33
|
+
function dayForKey(event, day, weekStartsOn) {
|
|
34
|
+
switch (event.key) {
|
|
35
|
+
case "ArrowLeft": return addDays(day, -1);
|
|
36
|
+
case "ArrowRight": return addDays(day, 1);
|
|
37
|
+
case "ArrowUp": return addDays(day, -7);
|
|
38
|
+
case "ArrowDown": return addDays(day, 7);
|
|
39
|
+
case "Home": return startOfWeek(day, { weekStartsOn });
|
|
40
|
+
case "End": return startOfDay(endOfWeek(day, { weekStartsOn }));
|
|
41
|
+
case "PageUp": return event.shiftKey ? addYears(day, -1) : addMonths(day, -1);
|
|
42
|
+
case "PageDown": return event.shiftKey ? addYears(day, 1) : addMonths(day, 1);
|
|
43
|
+
default: return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** The selector of the day that has the focus, or that gets it with Tab */
|
|
47
|
+
var CALENDAR_FOCUS_TARGET = ".DateTimeInput__CalendarDayCell[tabindex=\"0\"]";
|
|
48
|
+
/**
|
|
49
|
+
* Moves the focused day to an end of the selection when the end changes
|
|
50
|
+
* from outside the grid: the user types a date in the text. A pick in the
|
|
51
|
+
* grid does not move it, because the focus stays on the picked day. The
|
|
52
|
+
* effect runs after each render, so a pick that does not change the
|
|
53
|
+
* selection clears its flag on the next render.
|
|
54
|
+
*/
|
|
55
|
+
function useFollowSelection(selection, setFocusedDay) {
|
|
56
|
+
const previous = useRef(selection);
|
|
57
|
+
const pickedInGrid = useRef(false);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const { start, end } = previous.current;
|
|
60
|
+
const picked = pickedInGrid.current;
|
|
61
|
+
previous.current = selection;
|
|
62
|
+
pickedInGrid.current = false;
|
|
63
|
+
const moved = selection.end !== end ? selection.end : selection.start !== start ? selection.start : null;
|
|
64
|
+
if (moved && !picked) setFocusedDay(parseISO(moved));
|
|
65
|
+
});
|
|
66
|
+
return pickedInGrid;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The days of a month in a grid, for one date or for a range. The arrows,
|
|
70
|
+
* Home, End, Page Up and Page Down move the focus between the days, as in
|
|
71
|
+
* the date picker of the WAI-ARIA Authoring Practices. Only one day is in
|
|
72
|
+
* the Tab order.
|
|
73
|
+
*/
|
|
74
|
+
function CalendarGrid({ selection, selectableDays, onChange }) {
|
|
75
|
+
const { t } = useTranslation();
|
|
76
|
+
const { locale } = useDateSettings();
|
|
77
|
+
const names = useCalendarNames(locale);
|
|
78
|
+
const weekStartsOn = weekStartForLocale(locale);
|
|
79
|
+
const titleId = `DateTimeInput-calendar-${useAutoincrementIntegerId()}`;
|
|
80
|
+
const startDate = selection.start ? parseISO(selection.start) : null;
|
|
81
|
+
const endDate = selection.end ? parseISO(selection.end) : null;
|
|
82
|
+
const [focusedDay, setFocusedDay] = useState(() => startOfDay(startDate ?? endDate ?? /* @__PURE__ */ new Date()));
|
|
83
|
+
const pickedInGrid = useFollowSelection(selection, setFocusedDay);
|
|
84
|
+
const month = startOfMonth(focusedDay);
|
|
85
|
+
const monthKey = month.getTime();
|
|
86
|
+
const matrix = useMemo(() => generateMatrix(month, weekStartsOn), [monthKey, weekStartsOn]);
|
|
87
|
+
const gridRef = useRef(null);
|
|
88
|
+
const focusAfterRender = useRef(false);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!focusAfterRender.current) return;
|
|
91
|
+
focusAfterRender.current = false;
|
|
92
|
+
gridRef.current?.querySelector(CALENDAR_FOCUS_TARGET)?.focus({ preventScroll: true });
|
|
93
|
+
}, [focusedDay]);
|
|
94
|
+
const handleKeyDown = (event) => {
|
|
95
|
+
const next = dayForKey(event, focusedDay, weekStartsOn);
|
|
96
|
+
if (!next) return;
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
focusAfterRender.current = true;
|
|
99
|
+
setFocusedDay(next);
|
|
100
|
+
};
|
|
101
|
+
const handlePick = (day) => {
|
|
102
|
+
pickedInGrid.current = true;
|
|
103
|
+
onChange(day);
|
|
104
|
+
};
|
|
105
|
+
const today = startOfDay(/* @__PURE__ */ new Date());
|
|
106
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
107
|
+
className: "DateTimeInput__CalendarHeader",
|
|
108
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: "DateTimeInput__CalendarHeader__title",
|
|
110
|
+
id: titleId,
|
|
111
|
+
"aria-live": "polite",
|
|
112
|
+
children: names.month.format(month)
|
|
113
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
114
|
+
className: "DateTimeInput__CalendarHeader__actions",
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ jsx(Button, {
|
|
117
|
+
tone: "ghost",
|
|
118
|
+
size: "micro",
|
|
119
|
+
iconOnly: true,
|
|
120
|
+
icon: Navigation.ChevronLeftIcon,
|
|
121
|
+
label: t("dateTimeInput.previousMonth"),
|
|
122
|
+
className: "DateTimeInput__CalendarHeader__action--prev",
|
|
123
|
+
onClick: () => setFocusedDay((day) => addMonths(day, -1))
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ jsx(Button, {
|
|
126
|
+
tone: "ghost",
|
|
127
|
+
size: "micro",
|
|
128
|
+
iconOnly: true,
|
|
129
|
+
icon: UI.CircleDotIcon,
|
|
130
|
+
label: t("dateTimeInput.currentMonth"),
|
|
131
|
+
className: "DateTimeInput__CalendarHeader__action--today",
|
|
132
|
+
onClick: () => setFocusedDay(startOfDay(/* @__PURE__ */ new Date()))
|
|
133
|
+
}),
|
|
134
|
+
/* @__PURE__ */ jsx(Button, {
|
|
135
|
+
tone: "ghost",
|
|
136
|
+
size: "micro",
|
|
137
|
+
iconOnly: true,
|
|
138
|
+
icon: Navigation.ChevronRightIcon,
|
|
139
|
+
label: t("dateTimeInput.nextMonth"),
|
|
140
|
+
className: "DateTimeInput__CalendarHeader__action--next",
|
|
141
|
+
onClick: () => setFocusedDay((day) => addMonths(day, 1))
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
})]
|
|
145
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
146
|
+
ref: gridRef,
|
|
147
|
+
role: "grid",
|
|
148
|
+
"aria-labelledby": titleId,
|
|
149
|
+
className: "DateTimeInput__CalendarGrid",
|
|
150
|
+
style: { gridTemplateRows: `auto repeat(${matrix.length}, 1fr)` },
|
|
151
|
+
onKeyDown: handleKeyDown,
|
|
152
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
153
|
+
role: "row",
|
|
154
|
+
className: "DateTimeInput__CalendarRow",
|
|
155
|
+
children: matrix[0].map((day) => /* @__PURE__ */ jsx("div", {
|
|
156
|
+
role: "columnheader",
|
|
157
|
+
className: "DateTimeInput__CalendarWeekDay",
|
|
158
|
+
"aria-label": names.weekdayLong.format(day),
|
|
159
|
+
children: names.weekdayShort.format(day)
|
|
160
|
+
}, day.getTime()))
|
|
161
|
+
}), matrix.map((week) => /* @__PURE__ */ jsx("div", {
|
|
162
|
+
role: "row",
|
|
163
|
+
className: "DateTimeInput__CalendarRow",
|
|
164
|
+
children: week.map((day) => {
|
|
165
|
+
const isEdge = Boolean(startDate && isSameDay(day, startDate) || endDate && isSameDay(day, endDate));
|
|
166
|
+
const isBetween = Boolean(startDate && endDate && isAfter(day, startDate) && isBefore(day, endDate));
|
|
167
|
+
const isDisabled = selectableDays === "future" ? isBefore(day, today) : selectableDays === "past" ? isAfter(day, today) : false;
|
|
168
|
+
return /* @__PURE__ */ jsx("div", {
|
|
169
|
+
role: "gridcell",
|
|
170
|
+
className: "DateTimeInput__CalendarCell",
|
|
171
|
+
"aria-selected": isEdge || isBetween,
|
|
172
|
+
children: /* @__PURE__ */ jsx(RawButton, {
|
|
173
|
+
className: classNames("DateTimeInput__CalendarDayCell", {
|
|
174
|
+
"DateTimeInput__CalendarDayCell--isToday": isToday(day),
|
|
175
|
+
"DateTimeInput__CalendarDayCell--isSelected": isEdge,
|
|
176
|
+
"DateTimeInput__CalendarDayCell--inRange": isBetween,
|
|
177
|
+
"DateTimeInput__CalendarDayCell--inAdjacentMonth": !isSameMonth(day, month)
|
|
178
|
+
}),
|
|
179
|
+
ariaLabel: names.day.format(day),
|
|
180
|
+
"aria-current": isToday(day) ? "date" : void 0,
|
|
181
|
+
tabIndex: isSameDay(day, focusedDay) ? 0 : -1,
|
|
182
|
+
disabled: isDisabled ? "focusable" : false,
|
|
183
|
+
onFocus: () => {
|
|
184
|
+
if (isSameMonth(day, month)) setFocusedDay(day);
|
|
185
|
+
},
|
|
186
|
+
onClick: () => handlePick(day),
|
|
187
|
+
children: format(day, "d")
|
|
188
|
+
})
|
|
189
|
+
}, day.getTime());
|
|
190
|
+
})
|
|
191
|
+
}, week[0].getTime()))]
|
|
192
|
+
})] });
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
export { CALENDAR_FOCUS_TARGET, CalendarGrid as default };
|