frappe-ui 1.0.0-beta.2 → 1.0.0-beta.21
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/experimental/FloatingWindow/FloatingWindow.cy.ts +328 -0
- package/experimental/FloatingWindow/FloatingWindow.vue +303 -0
- package/experimental/FloatingWindow/index.ts +8 -0
- package/experimental/FloatingWindow/types.ts +31 -0
- package/experimental/FloatingWindow/useFloatingWindow.ts +236 -0
- package/experimental/MultiEmailInput/MultiEmailInput.cy.ts +155 -0
- package/experimental/MultiEmailInput/MultiEmailInput.vue +472 -0
- package/experimental/MultiEmailInput/index.ts +17 -0
- package/experimental/MultiEmailInput/stories/AsyncSuggestions.vue +54 -0
- package/experimental/MultiEmailInput/stories/Basic.vue +18 -0
- package/experimental/MultiEmailInput/stories/CustomChip.vue +39 -0
- package/experimental/MultiEmailInput/stories/Labeling.vue +28 -0
- package/experimental/MultiEmailInput/types.ts +138 -0
- package/experimental/MultiEmailInput/utils.ts +60 -0
- package/experimental.ts +12 -0
- package/frappe/Billing/SignupBanner.vue +1 -1
- package/frappe/Billing/TrialBanner.vue +1 -1
- package/frappe/DataImport/DataImport.vue +1 -1
- package/frappe/DataImport/DataImportList.vue +1 -1
- package/frappe/DataImport/ImportSteps.vue +6 -6
- package/frappe/DataImport/MappingStep.vue +1 -1
- package/frappe/DataImport/PreviewStep.vue +9 -9
- package/frappe/DataImport/TemplateModal.vue +1 -1
- package/frappe/DataImport/UploadStep.vue +5 -5
- package/frappe/Filter/Filter.vue +1 -1
- package/frappe/Help/HelpModal.vue +1 -1
- package/frappe/Link/stories/Suffix.vue +2 -2
- package/frappe/Onboarding/GettingStartedBanner.vue +1 -1
- package/frappe/drive/components/AppSwitcher.vue +1 -1
- package/frappe/drive/components/InfoDialog.vue +3 -3
- package/frappe/drive/components/MoveDialog.vue +2 -2
- package/frappe/drive/components/Select/Select.vue +2 -2
- package/frappe/drive/components/ShareDialog.vue +1 -1
- package/frappe/telemetry/index.ts +88 -14
- package/frappe/telemetry/pulse.ts +78 -164
- package/frappe/telemetry/telemetry.test.ts +13 -79
- package/icons/IconPicker.vue +1 -1
- package/package.json +104 -34
- package/src/components/Alert/Alert.md +4 -0
- package/src/components/Alert/Alert.vue +4 -4
- package/src/components/Autocomplete/Autocomplete.vue +6 -6
- package/src/components/Avatar/Avatar.md +4 -0
- package/src/components/Avatar/Avatar.vue +23 -4
- package/src/components/Badge/Badge.api.md +1 -1
- package/src/components/Badge/Badge.cy.ts +34 -16
- package/src/components/Badge/Badge.md +20 -4
- package/src/components/Badge/Badge.vue +60 -45
- package/src/components/Badge/stories/CallMeta.vue +35 -0
- package/src/components/Badge/stories/EventStatus.vue +16 -0
- package/src/components/Badge/stories/ListStatus.vue +91 -0
- package/src/components/Badge/stories/Reactions.vue +33 -0
- package/src/components/Badge/stories/RowTags.vue +39 -0
- package/src/components/Badge/types.ts +1 -2
- package/src/components/BottomSheet/BottomSheet.api.md +57 -0
- package/src/components/BottomSheet/BottomSheet.vue +232 -0
- package/src/components/BottomSheet/index.ts +6 -0
- package/src/components/BottomSheet/types.ts +23 -0
- package/src/components/Breadcrumbs/Breadcrumbs.md +4 -0
- package/src/components/Breadcrumbs/Breadcrumbs.vue +3 -3
- package/src/components/Button/Button.api.md +37 -32
- package/src/components/Button/Button.cy.ts +18 -2
- package/src/components/Button/Button.md +20 -8
- package/src/components/Button/Button.vue +304 -284
- package/src/components/Button/stories/InlineActions.vue +10 -0
- package/src/components/Button/stories/LiveClassCard.vue +34 -0
- package/src/components/Button/stories/SectionAction.vue +17 -0
- package/src/components/Button/stories/SectionControls.vue +28 -0
- package/src/components/Button/stories/SelectionToolbar.vue +20 -0
- package/src/components/Button/stories/StackedActions.vue +10 -0
- package/src/components/Button/types.ts +38 -32
- package/src/components/Calendar/Calendar.api.md +16 -16
- package/src/components/Calendar/Calendar.vue +100 -73
- package/src/components/Calendar/CalendarDaily.vue +21 -20
- package/src/components/Calendar/CalendarMonthEvent.vue +30 -9
- package/src/components/Calendar/CalendarMonthly.vue +60 -39
- package/src/components/Calendar/CalendarTimeMarker.vue +9 -8
- package/src/components/Calendar/CalendarWeekDayEvent.vue +98 -42
- package/src/components/Calendar/CalendarWeekly.vue +77 -41
- package/src/components/Calendar/EventModalContent.vue +32 -16
- package/src/components/Calendar/NewEventModal.vue +19 -16
- package/src/components/Calendar/ShowMoreCalendarEvent.vue +11 -17
- package/src/components/Calendar/{calendarUtils.js → calendarUtils.ts} +76 -52
- package/src/components/Calendar/composables/{useCalendarData.js → useCalendarData.ts} +23 -11
- package/src/components/Calendar/composables/{useEventModal.js → useEventModal.ts} +16 -12
- package/src/components/Calendar/index.ts +12 -2
- package/src/components/Calendar/stories/CustomHeader.vue +1 -1
- package/src/components/Calendar/types.ts +106 -0
- package/src/components/Calendar/{useEventBase.js → useEventBase.ts} +40 -26
- package/src/components/Card.vue +2 -2
- package/src/components/Charts/ECharts.vue +1 -1
- package/src/components/Charts/NumberChart.vue +7 -7
- package/src/components/Charts/eChartOptions.ts +28 -13
- package/src/components/Checkbox/Checkbox.api.md +6 -0
- package/src/components/Checkbox/Checkbox.cy.ts +10 -2
- package/src/components/Checkbox/Checkbox.md +28 -0
- package/src/components/Checkbox/Checkbox.vue +9 -22
- package/src/components/Checkbox/stories/Group.vue +27 -0
- package/src/components/Checkbox/stories/HorizontalGroup.vue +24 -0
- package/src/components/Checkbox/stories/SettingRow.vue +23 -0
- package/src/components/Checkbox/stories/WithDescription.vue +27 -0
- package/src/components/Checkbox/types.ts +7 -0
- package/src/components/CodeEditor/CodeEditor.api.md +139 -0
- package/src/components/CodeEditor/CodeEditor.cy.ts +160 -0
- package/src/components/CodeEditor/CodeEditor.md +104 -0
- package/src/components/CodeEditor/CodeEditor.vue +556 -0
- package/src/components/CodeEditor/CodePreview.test.ts +49 -0
- package/src/components/CodeEditor/CodePreview.vue +45 -0
- package/src/components/CodeEditor/index.ts +17 -0
- package/src/components/CodeEditor/languages.ts +63 -0
- package/src/components/CodeEditor/stories/Default.vue +16 -0
- package/src/components/CodeEditor/stories/Labeling.vue +25 -0
- package/src/components/CodeEditor/stories/MaxHeight.vue +24 -0
- package/src/components/CodeEditor/stories/Preview.vue +36 -0
- package/src/components/CodeEditor/stories/Sizes.vue +15 -0
- package/src/components/CodeEditor/stories/Variants.vue +13 -0
- package/src/components/CodeEditor/theme.ts +272 -0
- package/src/components/CodeEditor/types.ts +69 -0
- package/src/components/Combobox/Combobox.api.md +19 -20
- package/src/components/Combobox/Combobox.cy.ts +54 -14
- package/src/components/Combobox/Combobox.md +4 -0
- package/src/components/Combobox/Combobox.vue +233 -247
- package/src/components/Combobox/ComboboxResults.vue +1 -1
- package/src/components/Combobox/stories/Clearable.vue +2 -2
- package/src/components/Combobox/stories/CreateNew.vue +1 -1
- package/src/components/Combobox/stories/Footer.vue +10 -2
- package/src/components/Combobox/stories/InDialog.vue +1 -1
- package/src/components/Combobox/types.ts +8 -29
- package/src/components/CommandPalette/CommandPaletteItem.vue +1 -1
- package/src/components/ContextMenu/ContextMenu.api.md +52 -0
- package/src/components/ContextMenu/ContextMenu.cy.ts +191 -0
- package/src/components/ContextMenu/ContextMenu.md +25 -0
- package/src/components/ContextMenu/ContextMenu.vue +106 -0
- package/src/components/ContextMenu/index.ts +2 -0
- package/src/components/ContextMenu/stories/FileList.vue +105 -0
- package/src/components/ContextMenu/stories/Groups.vue +95 -0
- package/src/components/ContextMenu/stories/Simple.vue +72 -0
- package/src/components/ContextMenu/types.ts +39 -0
- package/src/components/DatePicker/CalendarPanel.vue +128 -86
- package/src/components/DatePicker/DatePicker.vue +3 -9
- package/src/components/DatePicker/DateRangePicker.vue +4 -8
- package/src/components/DatePicker/DateTimePicker.cy.ts +4 -2
- package/src/components/DatePicker/DateTimePicker.vue +3 -9
- package/src/components/DatePicker/composables.ts +15 -37
- package/src/components/DatePicker/stories/Range.vue +1 -1
- package/src/components/DatePicker/types.ts +1 -1
- package/src/components/DesktopShell/DesktopShell.api.md +40 -0
- package/src/components/DesktopShell/DesktopShell.cy.ts +39 -0
- package/src/components/DesktopShell/DesktopShell.md +31 -0
- package/src/components/DesktopShell/DesktopShell.vue +81 -0
- package/src/components/DesktopShell/index.ts +3 -0
- package/src/components/DesktopShell/stories/Default.vue +97 -0
- package/src/components/DesktopShell/types.ts +2 -0
- package/src/components/Dialog/Dialog.api.md +7 -8
- package/src/components/Dialog/Dialog.md +4 -0
- package/src/components/Dialog/Dialog.vue +8 -7
- package/src/components/Dialog/stories/CommandPalette.vue +1 -1
- package/src/components/Dialog/stories/Wizard.vue +1 -1
- package/src/components/Dialogs.vue +11 -9
- package/src/components/Divider/Divider.api.md +1 -1
- package/src/components/Divider/Divider.md +4 -0
- package/src/components/Dropdown/Dropdown.api.md +10 -35
- package/src/components/Dropdown/Dropdown.md +10 -6
- package/src/components/Dropdown/Dropdown.vue +33 -47
- package/src/components/Dropdown/stories/{05_KebabMenu.vue → KebabMenu.vue} +3 -1
- package/src/components/Dropdown/stories/{06_UserMenu.vue → UserMenu.vue} +1 -1
- package/src/components/Dropdown/types.ts +25 -189
- package/src/components/Duration/Duration.api.md +92 -0
- package/src/components/Duration/Duration.cy.ts +183 -0
- package/src/components/Duration/Duration.md +98 -0
- package/src/components/Duration/Duration.vue +114 -0
- package/src/components/Duration/duration.ts +185 -0
- package/src/components/Duration/index.ts +8 -0
- package/src/components/Duration/stories/Default.vue +10 -0
- package/src/components/Duration/stories/Formats.vue +16 -0
- package/src/components/Duration/stories/RealWorld.vue +50 -0
- package/src/components/Duration/stories/Sizes.vue +15 -0
- package/src/components/Duration/stories/States.vue +21 -0
- package/src/components/Duration/types.ts +52 -0
- package/src/components/ErrorMessage/ErrorMessage.cy.ts +1 -1
- package/src/components/ErrorMessage/ErrorMessage.md +4 -0
- package/src/components/ErrorMessage/ErrorMessage.vue +1 -1
- package/src/components/FileUploader/FileUploader.api.md +36 -11
- package/src/components/FileUploader/FileUploader.cy.ts +66 -0
- package/src/components/FileUploader/FileUploader.md +4 -1
- package/src/components/FileUploader/FileUploader.vue +147 -106
- package/src/components/FileUploader/index.ts +6 -0
- package/src/components/FileUploader/types.ts +43 -0
- package/src/components/FormControl/FormControl.api.md +3 -4
- package/src/components/FormControl/FormControl.md +4 -0
- package/src/components/FormControl/stories/RealForm.vue +3 -3
- package/src/components/FormLabel.vue +5 -8
- package/src/components/HoverCard/HoverCard.api.md +100 -0
- package/src/components/HoverCard/HoverCard.cy.ts +103 -0
- package/src/components/HoverCard/HoverCard.md +52 -0
- package/src/components/HoverCard/HoverCard.vue +91 -0
- package/src/components/HoverCard/index.ts +2 -0
- package/src/components/HoverCard/stories/Arrow.vue +28 -0
- package/src/components/HoverCard/stories/Delays.vue +16 -0
- package/src/components/HoverCard/stories/Example.vue +28 -0
- package/src/components/HoverCard/types.ts +47 -0
- package/src/components/Icon/Icon.cy.ts +78 -0
- package/src/components/Icon/Icon.vue +50 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/InputLabeling/InputDescription.vue +1 -1
- package/src/components/InputLabeling/InputError.vue +1 -1
- package/src/components/InputLabeling/InputLabel.vue +21 -7
- package/src/components/InputLabeling/RequiredIndicator.vue +1 -1
- package/src/components/ItemListRow/ItemListRow.vue +1 -1
- package/src/components/ItemListRow/stories/RowStates.vue +1 -1
- package/src/components/KeyboardShortcut.vue +4 -8
- package/src/components/KeyboardShortcutsModal/KeyboardShortcutsModal.api.md +22 -14
- package/src/components/KeyboardShortcutsModal/KeyboardShortcutsModal.vue +2 -2
- package/src/components/ListFilter/ListFilter.api.md +5 -6
- package/src/components/ListFilter/ListFilter.vue +161 -57
- package/src/components/ListFilter/NestedPopover.vue +17 -10
- package/src/components/ListFilter/SearchComplete.vue +31 -38
- package/src/components/ListItem.vue +1 -1
- package/src/components/ListView/ListEmptyState.vue +1 -1
- package/src/components/ListView/ListGroupHeader.vue +2 -2
- package/src/components/ListView/ListRow.vue +1 -1
- package/src/components/ListView/ListSelectBanner.vue +1 -1
- package/src/components/ListView/ListView.api.md +322 -6
- package/src/components/ListView/index.ts +25 -0
- package/src/components/ListView/stories/CustomList.vue +1 -1
- package/src/components/ListView/stories/GroupedRows.vue +1 -1
- package/src/components/LoadingIndicator.vue +13 -22
- package/src/components/LoadingText.vue +3 -13
- package/src/components/{Dropdown/DropdownMenuList.vue → Menu/Menu.vue} +110 -75
- package/src/components/{Dropdown/DropdownMenuItemContent.vue → Menu/MenuItemContent.vue} +23 -33
- package/src/components/{Dropdown/DropdownRenderContent.vue → Menu/MenuRenderContent.vue} +1 -1
- package/src/components/Menu/types.ts +225 -0
- package/src/components/{Dropdown → Menu}/utils.ts +36 -40
- package/src/components/MobileNav/MobileNav.api.md +70 -0
- package/src/components/MobileNav/MobileNav.cy.ts +89 -0
- package/src/components/MobileNav/MobileNav.md +34 -0
- package/src/components/MobileNav/MobileNav.vue +15 -0
- package/src/components/MobileNav/MobileNavItem.vue +125 -0
- package/src/components/MobileNav/index.ts +4 -0
- package/src/components/MobileNav/stories/Default.vue +40 -0
- package/src/components/MobileNav/types.ts +33 -0
- package/src/components/MobileShell/MobileShell.api.md +23 -0
- package/src/components/MobileShell/MobileShell.cy.ts +25 -0
- package/src/components/MobileShell/MobileShell.md +24 -0
- package/src/components/MobileShell/MobileShell.vue +41 -0
- package/src/components/MobileShell/index.ts +3 -0
- package/src/components/MobileShell/stories/Default.vue +75 -0
- package/src/components/MobileShell/types.ts +7 -0
- package/src/components/MonthPicker/MonthPicker.cy.ts +16 -0
- package/src/components/MonthPicker/MonthPicker.vue +19 -8
- package/src/components/MultiSelect/MultiSelect.api.md +3 -4
- package/src/components/MultiSelect/MultiSelect.md +42 -10
- package/src/components/MultiSelect/MultiSelect.vue +199 -227
- package/src/components/MultiSelect/MultiSelectResults.vue +1 -1
- package/src/components/MultiSelect/stories/Members.vue +1 -1
- package/src/components/MultiSelect/stories/TagsTrigger.vue +3 -3
- package/src/components/MultiSelect/types.ts +3 -3
- package/src/components/PageHeader/PageHeader.api.md +112 -0
- package/src/components/PageHeader/PageHeader.cy.ts +68 -0
- package/src/components/PageHeader/PageHeader.md +25 -0
- package/src/components/PageHeader/PageHeader.vue +13 -0
- package/src/components/PageHeader/PageHeaderBackButton.vue +29 -0
- package/src/components/PageHeader/PageHeaderBase.vue +51 -0
- package/src/components/PageHeader/PageHeaderMobile.vue +68 -0
- package/src/components/PageHeader/PageHeaderMobileTitle.vue +16 -0
- package/src/components/PageHeader/PageHeaderTarget.vue +13 -0
- package/src/components/PageHeader/PageHeaderTitle.vue +12 -0
- package/src/components/PageHeader/index.ts +7 -0
- package/src/components/PageHeader/stories/Default.vue +19 -0
- package/src/components/PageHeader/stories/Mobile.vue +24 -0
- package/src/components/PageHeader/target.ts +19 -0
- package/src/components/PageHeader/types.ts +19 -0
- package/src/components/Password/Password.md +4 -0
- package/src/components/Password/Password.vue +2 -2
- package/src/components/Popover/Popover.api.md +126 -42
- package/src/components/Popover/Popover.cy.ts +425 -41
- package/src/components/Popover/Popover.md +99 -4
- package/src/components/Popover/Popover.vue +288 -215
- package/src/components/Popover/index.ts +8 -1
- package/src/components/Popover/stories/Arrow.vue +16 -0
- package/src/components/Popover/stories/Bare.vue +20 -0
- package/src/components/Popover/stories/Click.vue +7 -4
- package/src/components/Popover/stories/Controlled.vue +22 -0
- package/src/components/Popover/stories/Dismissible.vue +19 -0
- package/src/components/Popover/stories/MatchTriggerWidth.vue +16 -0
- package/src/components/Popover/stories/SideAlign.vue +17 -0
- package/src/components/Popover/types.ts +101 -23
- package/src/components/Progress/Progress.cy.ts +2 -2
- package/src/components/Progress/Progress.md +4 -0
- package/src/components/Progress/Progress.vue +4 -4
- package/src/components/Rail/Rail.api.md +91 -0
- package/src/components/Rail/Rail.cy.ts +84 -0
- package/src/components/Rail/Rail.md +30 -0
- package/src/components/Rail/Rail.vue +16 -0
- package/src/components/Rail/RailItem.vue +134 -0
- package/src/components/Rail/RailItemBadge.vue +64 -0
- package/src/components/Rail/index.ts +2 -0
- package/src/components/Rail/stories/Default.vue +44 -0
- package/src/components/Rail/types.ts +37 -0
- package/src/components/Rating/Rating.md +4 -0
- package/src/components/Rating/Rating.vue +5 -8
- package/src/components/Rating/stories/CustomSlot.vue +2 -2
- package/src/components/ScrollArea/ScrollArea.api.md +59 -0
- package/src/components/ScrollArea/ScrollArea.vue +46 -0
- package/src/components/ScrollArea/ScrollBar.vue +101 -0
- package/src/components/ScrollArea/index.ts +2 -0
- package/src/components/Select/Select.cy.ts +16 -15
- package/src/components/Select/Select.md +4 -0
- package/src/components/Select/Select.vue +217 -203
- package/src/components/Select/stories/Example.vue +4 -3
- package/src/components/Select/stories/States.vue +1 -1
- package/src/components/Select/stories/TriggerSlots.vue +2 -2
- package/src/components/Select/utils.ts +4 -3
- package/src/components/SettingsDialog/SettingsBody.vue +23 -0
- package/src/components/SettingsDialog/SettingsContent.vue +7 -0
- package/src/components/SettingsDialog/SettingsDialog.api.md +273 -0
- package/src/components/SettingsDialog/SettingsDialog.cy.ts +126 -0
- package/src/components/SettingsDialog/SettingsDialog.md +43 -0
- package/src/components/SettingsDialog/SettingsDialog.vue +76 -0
- package/src/components/SettingsDialog/SettingsHeader.vue +36 -0
- package/src/components/SettingsDialog/SettingsNavGroup.vue +20 -0
- package/src/components/SettingsDialog/SettingsNavItem.vue +33 -0
- package/src/components/SettingsDialog/SettingsPanel.cy.ts +77 -0
- package/src/components/SettingsDialog/SettingsPanel.vue +26 -0
- package/src/components/SettingsDialog/SettingsRow.vue +52 -0
- package/src/components/SettingsDialog/SettingsSidebar.vue +16 -0
- package/src/components/SettingsDialog/index.ts +10 -0
- package/src/components/SettingsDialog/stories/Default.vue +99 -0
- package/src/components/SettingsDialog/stories/PanelBasic.vue +52 -0
- package/src/components/SettingsDialog/stories/panels/NotificationsPanel.vue +57 -0
- package/src/components/SettingsDialog/stories/panels/PreferencesPanel.vue +57 -0
- package/src/components/SettingsDialog/stories/panels/ProfilePanel.vue +38 -0
- package/src/components/SettingsDialog/stories/panels/UsersPanel.vue +83 -0
- package/src/components/SettingsDialog/types.ts +21 -0
- package/src/components/Sidebar/Sidebar.api.md +124 -65
- package/src/components/Sidebar/Sidebar.cy.ts +127 -76
- package/src/components/Sidebar/Sidebar.md +47 -3
- package/src/components/Sidebar/Sidebar.vue +64 -56
- package/src/components/Sidebar/SidebarCollapseToggle.vue +23 -0
- package/src/components/Sidebar/SidebarHeader.vue +76 -52
- package/src/components/Sidebar/SidebarItem.vue +159 -95
- package/src/components/Sidebar/SidebarItemIcon.vue +25 -0
- package/src/components/Sidebar/SidebarLabel.vue +34 -0
- package/src/components/Sidebar/SidebarSection.vue +29 -14
- package/src/components/Sidebar/index.ts +13 -2
- package/src/components/Sidebar/stories/Collapsed.vue +40 -0
- package/src/components/Sidebar/stories/Default.vue +153 -0
- package/src/components/Sidebar/stories/Legacy.vue +36 -0
- package/src/components/Sidebar/types.ts +105 -20
- package/src/components/Skeleton/Skeleton.cy.ts +21 -0
- package/src/components/Skeleton/Skeleton.md +21 -0
- package/src/components/Skeleton/Skeleton.vue +6 -0
- package/src/components/Skeleton/index.ts +1 -0
- package/src/components/Skeleton/stories/Card.vue +12 -0
- package/src/components/Skeleton/stories/List.vue +15 -0
- package/src/components/Skeleton/stories/Text.vue +11 -0
- package/src/components/Slider/Slider.api.md +1 -1
- package/src/components/Slider/Slider.cy.ts +29 -0
- package/src/components/Slider/Slider.md +10 -0
- package/src/components/Slider/Slider.vue +37 -9
- package/src/components/Slider/stories/NegativeValues.vue +12 -0
- package/src/components/Slider/types.ts +1 -1
- package/src/components/Spinner/Spinner.api.md +32 -0
- package/src/components/Spinner/Spinner.cy.ts +87 -0
- package/src/components/Spinner/Spinner.md +21 -0
- package/src/components/Spinner/Spinner.vue +168 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Spinner/stories/InContext.vue +49 -0
- package/src/components/Spinner/stories/Sizes.vue +12 -0
- package/src/components/Spinner/stories/Themes.vue +10 -0
- package/src/components/Spinner/stories/Track.vue +12 -0
- package/src/components/Spinner/types.ts +14 -0
- package/src/components/Switch/Switch.md +4 -0
- package/src/components/Switch/Switch.vue +6 -23
- package/src/components/TabButtons/Pill.vue +161 -0
- package/src/components/TabButtons/TabButtons.api.md +52 -2
- package/src/components/TabButtons/TabButtons.cy.ts +18 -5
- package/src/components/TabButtons/TabButtons.md +49 -0
- package/src/components/TabButtons/TabButtons.vue +207 -109
- package/src/components/TabButtons/index.ts +11 -1
- package/src/components/TabButtons/pillTypes.ts +43 -0
- package/src/components/TabButtons/stories/PrefixSuffix.vue +65 -0
- package/src/components/TabButtons/stories/Sizes.vue +26 -0
- package/src/components/TabButtons/stories/Variants.vue +40 -0
- package/src/components/TabButtons/stories/Vertical.vue +64 -0
- package/src/components/TabButtons/types.ts +49 -0
- package/src/components/Tabs/Tabs.md +4 -0
- package/src/components/Tabs/Tabs.vue +1 -1
- package/src/components/TextEditor/TextEditor.cy.ts +1 -1
- package/src/components/TextEditor/TextEditor.md +3 -0
- package/src/components/TextEditor/TextEditor.vue +7 -4
- package/src/components/TextEditor/components/CodeBlockComponent.vue +4 -194
- package/src/components/TextEditor/components/FontColor.vue +1 -1
- package/src/components/TextEditor/components/LinkPopup.vue +1 -1
- package/src/components/TextEditor/components/MediaNodeView.vue +17 -17
- package/src/components/TextEditor/components/MentionList.vue +1 -1
- package/src/components/TextEditor/components/TextEditorBubbleMenu.vue +14 -5
- package/src/components/TextEditor/components/TextEditorFixedMenu.vue +3 -3
- package/src/components/TextEditor/components/{Menu.vue → TextEditorMenu.vue} +3 -3
- package/src/components/TextEditor/extensions/iframe/InsertIframe.vue +2 -2
- package/src/components/TextEditor/extensions/iframe/iframe-extension.ts +62 -19
- package/src/components/TextEditor/extensions/image-group/ImageGroupNodeView.vue +1 -1
- package/src/components/TextEditor/extensions/image-group/ImageGroupUploadDialog.vue +4 -4
- package/src/components/TextEditor/extensions/suggestion/SuggestionList.vue +1 -1
- package/src/components/TextEditor/extensions/toc-node/TocNodeView.vue +1 -1
- package/src/components/TextEditor/hljs-github.css +197 -0
- package/src/components/TextEditor/index.ts +13 -0
- package/src/components/TextInput/TextInput.cy.ts +8 -3
- package/src/components/TextInput/TextInput.md +4 -0
- package/src/components/TextInput/TextInput.vue +11 -15
- package/src/components/TextInput/stories/Slots.vue +1 -1
- package/src/components/Textarea/Textarea.cy.ts +1 -1
- package/src/components/Textarea/Textarea.md +4 -0
- package/src/components/Textarea/Textarea.vue +11 -15
- package/src/components/ThemeSwitcher/ThemePreview.vue +74 -0
- package/src/components/ThemeSwitcher/ThemeSwitcher.api.md +82 -0
- package/src/components/ThemeSwitcher/ThemeSwitcher.cy.ts +101 -0
- package/src/components/ThemeSwitcher/ThemeSwitcher.md +70 -0
- package/src/components/ThemeSwitcher/ThemeSwitcher.vue +145 -0
- package/src/components/ThemeSwitcher/index.ts +2 -0
- package/src/components/ThemeSwitcher/previews/PreviewWindow.vue +74 -0
- package/src/components/ThemeSwitcher/stories/Branded.vue +12 -0
- package/src/components/ThemeSwitcher/stories/Default.vue +7 -0
- package/src/components/ThemeSwitcher/stories/Menu.vue +53 -0
- package/src/components/ThemeSwitcher/stories/Toggle.vue +25 -0
- package/src/components/ThemeSwitcher/types.ts +35 -0
- package/src/components/TimePicker/TimePicker.api.md +67 -15
- package/src/components/TimePicker/TimePicker.cy.ts +130 -14
- package/src/components/TimePicker/TimePicker.md +6 -0
- package/src/components/TimePicker/TimePicker.vue +74 -19
- package/src/components/TimePicker/stories/Labeling.vue +21 -0
- package/src/components/TimePicker/stories/Range.vue +1 -1
- package/src/components/TimePicker/stories/SizesAndVariants.vue +23 -0
- package/src/components/TimePicker/stories/TwentyFour.vue +1 -1
- package/src/components/TimePicker/types.ts +15 -3
- package/src/components/TimePicker/utils.ts +82 -21
- package/src/components/Toast/Toast.md +1 -1
- package/src/components/Toast/Toast.sanitize.test.ts +50 -0
- package/src/components/Toast/Toast.test.ts +5 -0
- package/src/components/Toast/Toast.vue +7 -7
- package/src/components/Toast/ToastProvider.vue +18 -9
- package/src/components/Toast/stories/CustomIcon.vue +1 -1
- package/src/components/Toast/toast.ts +32 -8
- package/src/components/Tooltip/Tooltip.api.md +43 -5
- package/src/components/Tooltip/Tooltip.cy.ts +48 -0
- package/src/components/Tooltip/Tooltip.md +10 -0
- package/src/components/Tooltip/Tooltip.vue +20 -5
- package/src/components/Tooltip/TooltipBubble.vue +2 -2
- package/src/components/Tooltip/TooltipProvider.vue +53 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/components/Tooltip/stories/Group.vue +22 -0
- package/src/components/Tooltip/stories/Slots.vue +2 -2
- package/src/components/Tooltip/types.ts +1 -1
- package/src/components/Tree/Tree.api.md +76 -18
- package/src/components/Tree/Tree.md +144 -2
- package/src/components/Tree/Tree.vue +276 -97
- package/src/components/Tree/TreeItem.vue +263 -0
- package/src/components/Tree/index.ts +9 -1
- package/src/components/Tree/stories/DragDrop.vue +94 -0
- package/src/components/Tree/stories/Example.vue +11 -34
- package/src/components/Tree/stories/ExpandAll.vue +48 -0
- package/src/components/Tree/stories/Guides.vue +49 -0
- package/src/components/Tree/stories/ListView.vue +74 -0
- package/src/components/Tree/tree.cy.ts +218 -90
- package/src/components/Tree/types.ts +114 -24
- package/src/components/Tree/useTreeDragDrop.ts +203 -0
- package/src/components/Tree/useTreeKeyboard.ts +109 -0
- package/src/components/VueGridLayout/Layout.vue +1 -1
- package/src/components/shared/picker/PickerShell.vue +20 -15
- package/src/components/shared/popover/PopoverPanel.vue +67 -0
- package/src/components/shared/popover/popoverPanel.css +102 -0
- package/src/components/shared/selection/utils.ts +6 -6
- package/src/composables/useAutofocusOnOpen.ts +2 -0
- package/src/composables/useScreenSize.ts +46 -0
- package/src/composables/useScrollContainer.ts +108 -0
- package/src/composables/useShortcut.ts +3 -0
- package/src/data-fetching/docStore.test.ts +74 -0
- package/src/data-fetching/docStore.ts +18 -7
- package/src/data-fetching/useCall/types.ts +1 -0
- package/src/data-fetching/useCall/useCall.test.ts +43 -0
- package/src/data-fetching/useCall/useCall.ts +17 -4
- package/src/data-fetching/useDoc/useDoc.test.ts +61 -2
- package/src/data-fetching/useDoc/useDoc.ts +35 -15
- package/src/data-fetching/useDoctype/useDoctype.ts +6 -5
- package/src/data-fetching/useFrappeFetch.ts +17 -4
- package/src/data-fetching/useList/types.ts +1 -0
- package/src/data-fetching/useList/useList.test.ts +40 -0
- package/src/data-fetching/useList/useList.ts +20 -13
- package/src/data-fetching/useNewDoc/useNewDoc.ts +9 -5
- package/src/directives/focus.ts +3 -3
- package/src/index.ts +105 -74
- package/src/mocks/handlers.ts +8 -0
- package/src/molecules/editor/Editor.cy.ts +6 -1
- package/src/molecules/editor/EditorBubbleMenu.vue +1 -1
- package/src/molecules/editor/EditorContent.vue +50 -9
- package/src/molecules/editor/EditorFixedMenu.vue +2 -1
- package/src/molecules/editor/EditorFloatingMenu.vue +1 -1
- package/src/molecules/editor/EditorTableMenu.vue +303 -0
- package/src/molecules/editor/MenuItems.vue +81 -69
- package/src/molecules/editor/commands.ts +10 -2
- package/src/molecules/editor/components/AttachmentNodeView.vue +115 -0
- package/src/molecules/editor/components/EditorDropZone.vue +105 -0
- package/src/molecules/editor/components/EditorPopover.vue +89 -0
- package/src/molecules/editor/components/MediaNodeView.vue +156 -49
- package/src/molecules/editor/components/MediaResizeHandles.vue +38 -0
- package/src/molecules/editor/components/MediaToolbar.vue +108 -54
- package/src/molecules/editor/components/TableContextMenu.vue +144 -0
- package/src/molecules/editor/components/UploadProgressIndicator.vue +33 -0
- package/src/molecules/editor/components/VideoControls.vue +208 -0
- package/src/molecules/editor/components/font-color/ColorSwatchGrid.vue +3 -5
- package/src/molecules/editor/components/font-color/fontColorController.ts +28 -23
- package/src/molecules/editor/components/font-color/swatches.ts +1 -1
- package/src/molecules/editor/components/media-node-view-controller.ts +4 -4
- package/src/molecules/editor/components/media-node-view-utils.test.ts +0 -13
- package/src/molecules/editor/components/media-node-view-utils.ts +0 -10
- package/src/molecules/editor/components/table-color/tableCellColorController.ts +80 -0
- package/src/molecules/editor/components/table-size-picker/TableSizePicker.vue +92 -0
- package/src/molecules/editor/components/table-size-picker/tableSizePickerController.ts +40 -0
- package/src/molecules/editor/composables/useEditorFileDrop.ts +117 -0
- package/src/molecules/editor/composables/useFloatingPopup.ts +46 -2
- package/src/molecules/editor/composables/useNodeViewResize.test.ts +60 -11
- package/src/molecules/editor/composables/useNodeViewResize.ts +80 -21
- package/src/molecules/editor/composables/useTableCellColorState.ts +78 -0
- package/src/molecules/editor/composables/useWindowFileDragging.ts +68 -0
- package/src/molecules/editor/extensions/attachment/attachment-engine.ts +250 -0
- package/src/molecules/editor/extensions/attachment/attachment-extension.ts +248 -0
- package/src/molecules/editor/extensions/attachment/attachment.flow.test.ts +80 -0
- package/src/molecules/editor/extensions/attachment/attachment.roundtrip.test.ts +50 -0
- package/src/molecules/editor/extensions/attachment/index.ts +5 -0
- package/src/molecules/editor/extensions/code-block/CodeBlockComponent.css +16 -26
- package/src/molecules/editor/extensions/code-block/CodeBlockComponent.vue +107 -22
- package/src/molecules/editor/extensions/content-paste/content-paste-extension.ts +5 -3
- package/src/molecules/editor/extensions/iframe/IframeInsertDialog.vue +34 -7
- package/src/molecules/editor/extensions/iframe/IframeNodeView.vue +54 -48
- package/src/molecules/editor/extensions/iframe/iframe-allowlist.ts +33 -4
- package/src/molecules/editor/extensions/iframe/iframe-commands.ts +49 -5
- package/src/molecules/editor/extensions/iframe/iframe-embed-utils.ts +30 -0
- package/src/molecules/editor/extensions/iframe/iframe-extension.ts +4 -4
- package/src/molecules/editor/extensions/iframe/iframeInsertDialogController.ts +12 -1
- package/src/molecules/editor/extensions/iframe/index.ts +4 -4
- package/src/molecules/editor/extensions/iframe/useIframeDialog.ts +25 -13
- package/src/molecules/editor/extensions/image/image-extension.ts +29 -11
- package/src/molecules/editor/extensions/image-group/ImageGroupGrid.vue +27 -11
- package/src/molecules/editor/extensions/image-group/ImageGroupGridCell.vue +55 -11
- package/src/molecules/editor/extensions/image-group/ImageGroupNodeView.vue +64 -31
- package/src/molecules/editor/extensions/image-group/ImageGroupUploadDialog.vue +84 -40
- package/src/molecules/editor/extensions/image-group/image-group-extension.ts +4 -3
- package/src/molecules/editor/extensions/image-group/useImageGroupDialog.ts +116 -17
- package/src/molecules/editor/extensions/link/LinkEditorPopup.vue +214 -71
- package/src/molecules/editor/extensions/link/link-click-plugin.ts +10 -15
- package/src/molecules/editor/extensions/link/link-commands.ts +24 -3
- package/src/molecules/editor/extensions/link/link-extension.ts +11 -2
- package/src/molecules/editor/extensions/link/link-popup-controller.test.ts +49 -0
- package/src/molecules/editor/extensions/link/link-popup-controller.ts +67 -2
- package/src/molecules/editor/extensions/link/link-shortcut-plugin.ts +7 -2
- package/src/molecules/editor/extensions/media-drop/media-drop-extension.ts +177 -0
- package/src/molecules/editor/extensions/shared/media-dimensions.ts +36 -3
- package/src/molecules/editor/extensions/shared/media-node-ops.ts +17 -0
- package/src/molecules/editor/extensions/shared/media-plugin.test.ts +60 -0
- package/src/molecules/editor/extensions/shared/media-plugin.ts +7 -37
- package/src/molecules/editor/extensions/shared/media-upload-engine.test.ts +39 -2
- package/src/molecules/editor/extensions/shared/media-upload-engine.ts +104 -10
- package/src/molecules/editor/extensions/shared/media-upload-state.ts +55 -0
- package/src/molecules/editor/extensions/shared/media-upload-types.ts +52 -1
- package/src/molecules/editor/extensions/shared/suggestion-helpers.ts +20 -0
- package/src/molecules/editor/extensions/shared/suggestion-types.ts +7 -0
- package/src/molecules/editor/extensions/shared/upload-types.ts +1 -0
- package/src/molecules/editor/extensions/slash-commands/slash-commands-extension.test.ts +38 -0
- package/src/molecules/editor/extensions/slash-commands/slash-commands-extension.ts +119 -55
- package/src/molecules/editor/extensions/suggestion/SuggestionList.vue +62 -22
- package/src/molecules/editor/extensions/suggestion/SuggestionListItem.vue +1 -1
- package/src/molecules/editor/extensions/suggestion/createSuggestionExtension.ts +4 -0
- package/src/molecules/editor/extensions/table/drag-scroll.ts +154 -0
- package/src/molecules/editor/extensions/table/table-cell-color.ts +188 -0
- package/src/molecules/editor/extensions/table/table-navigation.ts +560 -0
- package/src/molecules/editor/extensions/table/table-selection-overlay.ts +137 -0
- package/src/molecules/editor/extensions/toc-node/TocNodeView.vue +1 -1
- package/src/molecules/editor/extensions/toc-node/toc-render.ts +7 -3
- package/src/molecules/editor/extensions/video/video-extension.ts +72 -5
- package/src/molecules/editor/extensions.ts +176 -8
- package/src/molecules/editor/index.ts +9 -4
- package/src/molecules/editor/kits.test.ts +21 -1
- package/src/molecules/editor/kits.ts +56 -33
- package/src/molecules/editor/menu.test.ts +3 -1
- package/src/molecules/editor/menu.ts +180 -18
- package/src/molecules/editor/stories/Comment.vue +4 -4
- package/src/molecules/editor/stories/Inline.vue +1 -1
- package/src/molecules/editor/stories/Primitives.vue +1 -1
- package/src/molecules/editor/stories/RichText.vue +1 -1
- package/src/molecules/editor/style.css +80 -3
- package/src/molecules/editor/useEditor.test.ts +4 -0
- package/src/molecules/editor/useEditor.ts +7 -3
- package/src/molecules/list/List.cy.ts +626 -0
- package/src/molecules/list/List.vue +93 -0
- package/src/molecules/list/ListCell.vue +15 -0
- package/src/molecules/list/ListGroup.vue +40 -0
- package/src/molecules/list/ListHeader.vue +62 -0
- package/src/molecules/list/ListHeaderCell.vue +26 -0
- package/src/molecules/list/ListHeaderCellSort.vue +106 -0
- package/src/molecules/list/ListRow.vue +55 -0
- package/src/molecules/list/ListRowBase.vue +103 -0
- package/src/molecules/list/ListRows.vue +120 -0
- package/src/molecules/list/index.ts +24 -0
- package/src/molecules/list/list-context.ts +44 -0
- package/src/molecules/list/list.api.md +276 -0
- package/src/molecules/list/list.md +119 -0
- package/src/molecules/list/stories/Columns.vue +103 -0
- package/src/molecules/list/stories/Feed.vue +105 -0
- package/src/molecules/list/stories/Virtual.vue +31 -0
- package/src/molecules/list/style.css +173 -0
- package/src/molecules/list/types.ts +82 -0
- package/src/molecules/list/useVirtualRows.ts +80 -0
- package/src/resources/documentResource.d.ts +28 -0
- package/src/resources/documentResource.js +32 -4
- package/src/resources/documentResource.test.ts +111 -0
- package/src/resources/listResource.d.ts +33 -0
- package/src/resources/plugin.d.ts +7 -0
- package/src/resources/resources.d.ts +35 -0
- package/src/utils/{call.js → call.ts} +50 -9
- package/src/utils/config.ts +16 -1
- package/src/utils/confirmDialog.d.ts +17 -0
- package/src/utils/debounce.ts +6 -7
- package/src/utils/dialog.cy.ts +9 -9
- package/src/utils/fileSize.ts +36 -0
- package/src/utils/fileUploadHandler.ts +46 -6
- package/src/utils/frappeRequest.test.ts +79 -0
- package/src/utils/{frappeRequest.js → frappeRequest.ts} +76 -13
- package/src/utils/pageMeta.ts +1 -1
- package/src/utils/plugin.ts +58 -0
- package/src/utils/{request.js → request.ts} +28 -3
- package/src/utils/{socketio.js → socketio.ts} +11 -1
- package/src/utils/theme.ts +48 -57
- package/src/utils/useFileUpload.ts +80 -23
- package/tailwind/audit-token-drift.cjs +176 -0
- package/tailwind/colorPalette.js +69 -8
- package/tailwind/colors.json +1115 -397
- package/tailwind/figma-tokens-to-theme.js +364 -0
- package/tailwind/generated/colors.json +1217 -0
- package/tailwind/generated/effects.json +41 -0
- package/tailwind/generated/radius.json +20 -0
- package/tailwind/generated/typography.json +479 -0
- package/tailwind/migrate-tokens-v2.js +453 -0
- package/tailwind/migrate-tokens-v2.test.js +55 -0
- package/tailwind/plugin.js +220 -15
- package/tailwind/preset.js +15 -0
- package/tailwind/tokens.js +35 -37
- package/tsconfig.base.json +2 -2
- package/vitepress/components/Docs/CommandPalette.vue +214 -0
- package/vitepress/components/Docs/Demo.vue +60 -0
- package/vitepress/components/Docs/EmitsTable.vue +99 -0
- package/vitepress/components/Docs/MobileNavSheet.vue +148 -0
- package/vitepress/components/Docs/OnThisPage.vue +74 -0
- package/vitepress/components/Docs/PrevNextBtns.vue +58 -0
- package/vitepress/components/Docs/PropsTable.vue +185 -0
- package/vitepress/components/Docs/Search.vue +34 -0
- package/vitepress/components/Docs/Sidebar.vue +91 -0
- package/vitepress/components/Docs/SlotsTable.vue +99 -0
- package/vitepress/components/Docs/index.ts +13 -0
- package/vitepress/components/Docs/sidebarList.ts +33 -0
- package/vitepress/components/Layout.vue +58 -0
- package/vitepress/components/Navbar.vue +126 -0
- package/vitepress/components/index.ts +3 -0
- package/vitepress/composables/index.ts +3 -0
- package/vitepress/composables/useTheme.ts +39 -0
- package/vitepress/css/fonts/Inter-Italic.var.woff2 +0 -0
- package/vitepress/css/fonts/Inter.var.woff2 +0 -0
- package/vitepress/css/style.css +198 -0
- package/vitepress/index.d.ts +23 -0
- package/vitepress/index.node.ts +175 -0
- package/vitepress/index.ts +17 -0
- package/vitepress/plugins/colocatedComponentDocs.ts +164 -0
- package/vitepress/plugins/componentTransformer.ts +286 -0
- package/vitepress/plugins/index.ts +12 -0
- package/vitepress/state.ts +10 -0
- package/vitepress/theme/index.ts +21 -0
- package/frappe/telemetry/utils.ts +0 -15
- package/src/components/Badge/stories/Themes.vue +0 -10
- package/src/components/Badge/stories/Variants.vue +0 -10
- package/src/components/Button/stories/Icons.vue +0 -27
- package/src/components/Button/stories/Sizes.vue +0 -11
- package/src/components/Button/stories/Themes.vue +0 -10
- package/src/components/Button/stories/Variants.vue +0 -10
- package/src/components/Popover/stories/Hover.vue +0 -14
- package/src/components/Resource.vue +0 -21
- package/src/components/Sidebar/stories/Example.vue +0 -76
- package/src/components/Spinner.vue +0 -3
- package/src/components/TabButtons/TabButtons.story.vue +0 -22
- package/src/utils/plugin.js +0 -24
- /package/src/components/Dropdown/stories/{02_Shortcuts.vue → Shortcuts.vue} +0 -0
- /package/src/components/Dropdown/stories/{01_Simple.vue → Simple.vue} +0 -0
- /package/src/components/Dropdown/stories/{03_Submenus.vue → Submenus.vue} +0 -0
- /package/src/components/Dropdown/stories/{04_Switches.vue → Switches.vue} +0 -0
- /package/src/components/{Dropdown/DropdownRenderContentAsChild.vue → Menu/MenuRenderContentAsChild.vue} +0 -0
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type {
|
|
2
|
+
CalendarColor,
|
|
3
|
+
CalendarConfig,
|
|
4
|
+
CalendarEvent,
|
|
5
|
+
CalendarTimeFormat,
|
|
6
|
+
} from './types'
|
|
7
|
+
|
|
8
|
+
export function getCalendarDates(month: number, year: number): Date[] {
|
|
2
9
|
let daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
|
3
10
|
let firstDay = new Date(year, month, 1)
|
|
4
11
|
let leftPadding = firstDay.getDay()
|
|
@@ -12,7 +19,7 @@ export function getCalendarDates(month, year) {
|
|
|
12
19
|
|
|
13
20
|
return allDates
|
|
14
21
|
|
|
15
|
-
function getCurrentMonthDates(date) {
|
|
22
|
+
function getCurrentMonthDates(date: Date): Date[] {
|
|
16
23
|
let month = date.getMonth()
|
|
17
24
|
if (month == 1 && isLeapYear(date)) {
|
|
18
25
|
daysInMonth[month] = 29
|
|
@@ -23,13 +30,13 @@ export function getCalendarDates(month, year) {
|
|
|
23
30
|
return allDates
|
|
24
31
|
}
|
|
25
32
|
|
|
26
|
-
function getBeforeDates(firstDay, leftPadding) {
|
|
33
|
+
function getBeforeDates(firstDay: Date, leftPadding: number): Date[] {
|
|
27
34
|
let allDates = getDatesAfter(firstDay, 0, leftPadding, -1)
|
|
28
35
|
allDates = allDates.reverse()
|
|
29
36
|
return allDates
|
|
30
37
|
}
|
|
31
38
|
|
|
32
|
-
function getNextMonthDates(currentAndPreviousMonthDates) {
|
|
39
|
+
function getNextMonthDates(currentAndPreviousMonthDates: Date[]): Date[] {
|
|
33
40
|
const numberofDaysInCalendar =
|
|
34
41
|
currentAndPreviousMonthDates.length > 35 ? 42 : 35
|
|
35
42
|
let lengthOfDates = currentAndPreviousMonthDates.length
|
|
@@ -41,13 +48,13 @@ export function getCalendarDates(month, year) {
|
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
function getDatesAfter(
|
|
44
|
-
date,
|
|
45
|
-
startIndex,
|
|
46
|
-
counter,
|
|
51
|
+
date: Date,
|
|
52
|
+
startIndex: number,
|
|
53
|
+
counter: number,
|
|
47
54
|
stepper = 1,
|
|
48
55
|
getNextMonthDates = false,
|
|
49
|
-
) {
|
|
50
|
-
let allDates = []
|
|
56
|
+
): Date[] {
|
|
57
|
+
let allDates: Date[] = []
|
|
51
58
|
for (let index = startIndex; index < counter; index++) {
|
|
52
59
|
let tempDate = new Date(
|
|
53
60
|
date.getFullYear(),
|
|
@@ -59,43 +66,49 @@ export function getCalendarDates(month, year) {
|
|
|
59
66
|
return allDates
|
|
60
67
|
}
|
|
61
68
|
|
|
62
|
-
function isLeapYear(date) {
|
|
69
|
+
function isLeapYear(date: Date) {
|
|
63
70
|
let year = date.getFullYear()
|
|
64
71
|
return year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
74
|
|
|
68
|
-
export function groupBy(
|
|
75
|
+
export function groupBy<T>(
|
|
76
|
+
obj: T[],
|
|
77
|
+
fn: (value: T) => string | number,
|
|
78
|
+
): Record<string, T[]> {
|
|
69
79
|
if (typeof fn !== 'function') throw new Error(`${fn} should be a function`)
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
acc[group]
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
return obj.reduce(
|
|
81
|
+
(acc, value) => {
|
|
82
|
+
const group = String(fn(value))
|
|
83
|
+
if (!acc[group]) {
|
|
84
|
+
acc[group] = []
|
|
85
|
+
}
|
|
86
|
+
acc[group].push(value)
|
|
87
|
+
return acc
|
|
88
|
+
},
|
|
89
|
+
{} as Record<string, T[]>,
|
|
90
|
+
)
|
|
78
91
|
}
|
|
79
92
|
|
|
80
|
-
export function calculateMinutes(time) {
|
|
93
|
+
export function calculateMinutes(time: string): number {
|
|
81
94
|
let [hours, minutes] = time.split(':')
|
|
82
95
|
return parseInt(hours) * 60 + parseInt(minutes)
|
|
83
96
|
}
|
|
84
97
|
|
|
85
|
-
export function convertMinutesToHours(minutes) {
|
|
86
|
-
let hours = Math.floor(minutes / 60)
|
|
87
|
-
let remainingMinutes = minutes % 60
|
|
98
|
+
export function convertMinutesToHours(minutes: number): string {
|
|
99
|
+
let hours: number | string = Math.floor(minutes / 60)
|
|
100
|
+
let remainingMinutes: number | string = minutes % 60
|
|
88
101
|
if (hours < 10) hours = `0${hours}`
|
|
89
102
|
if (remainingMinutes < 10) remainingMinutes = `0${remainingMinutes}`
|
|
90
103
|
return `${hours}:${remainingMinutes}:00`
|
|
91
104
|
}
|
|
92
105
|
|
|
93
|
-
export function parseDate(date) {
|
|
106
|
+
export function parseDate(date: Date | string): string {
|
|
94
107
|
if (typeof date === 'string') {
|
|
95
108
|
date = new Date(date)
|
|
96
109
|
}
|
|
97
|
-
let dd = date.getDate()
|
|
98
|
-
let mm = date.getMonth() + 1
|
|
110
|
+
let dd: number | string = date.getDate()
|
|
111
|
+
let mm: number | string = date.getMonth() + 1
|
|
99
112
|
let yyyy = date.getFullYear()
|
|
100
113
|
|
|
101
114
|
if (dd < 10) dd = '0' + dd
|
|
@@ -105,12 +118,12 @@ export function parseDate(date) {
|
|
|
105
118
|
}
|
|
106
119
|
|
|
107
120
|
export function parseDateEventPopupFormat(
|
|
108
|
-
date,
|
|
121
|
+
date: Date,
|
|
109
122
|
showDay = true,
|
|
110
123
|
showMonth = true,
|
|
111
|
-
weekDay = 'short',
|
|
112
|
-
) {
|
|
113
|
-
const options = {
|
|
124
|
+
weekDay: 'short' | 'long' | 'narrow' = 'short',
|
|
125
|
+
): string {
|
|
126
|
+
const options: Intl.DateTimeFormatOptions = {
|
|
114
127
|
day: 'numeric',
|
|
115
128
|
}
|
|
116
129
|
if (showMonth) {
|
|
@@ -123,36 +136,38 @@ export function parseDateEventPopupFormat(
|
|
|
123
136
|
return date.toLocaleDateString('en-US', options)
|
|
124
137
|
}
|
|
125
138
|
|
|
126
|
-
export function parseDateWithComma(date, showDay = false) {
|
|
139
|
+
export function parseDateWithComma(date: Date, showDay = false): string {
|
|
127
140
|
return parseDateEventPopupFormat(date, showDay).split(' ').join(', ')
|
|
128
141
|
}
|
|
129
142
|
|
|
130
|
-
export function parseDateWithDay(date, fullDay = false) {
|
|
143
|
+
export function parseDateWithDay(date: Date, fullDay = false): string {
|
|
131
144
|
return fullDay
|
|
132
145
|
? daysListFull[date.getDay()] + ', ' + date.getDate()
|
|
133
146
|
: daysList[date.getDay()] + ' ' + date.getDate()
|
|
134
147
|
}
|
|
135
148
|
|
|
136
|
-
export function calculateDiff(from, to) {
|
|
149
|
+
export function calculateDiff(from: string, to: string): number {
|
|
137
150
|
let fromMinutes = calculateMinutes(from)
|
|
138
151
|
let toMinutes = calculateMinutes(to)
|
|
139
152
|
return toMinutes - fromMinutes
|
|
140
153
|
}
|
|
141
154
|
|
|
142
|
-
export function handleSeconds(time) {
|
|
155
|
+
export function handleSeconds(time: string): string {
|
|
143
156
|
return time.split(':').slice(0, 2).join(':') + ':00'
|
|
144
157
|
}
|
|
145
158
|
|
|
146
|
-
export function findOverlappingEventsCount(
|
|
159
|
+
export function findOverlappingEventsCount(
|
|
160
|
+
events: CalendarEvent[],
|
|
161
|
+
): CalendarEvent[] {
|
|
147
162
|
// Sort events based on start time
|
|
148
|
-
events = events.sort((a, b) => a.startTime - b.startTime)
|
|
163
|
+
events = events.sort((a, b) => (a.startTime || 0) - (b.startTime || 0))
|
|
149
164
|
|
|
150
165
|
let hallNumber = 0
|
|
151
|
-
const result = []
|
|
166
|
+
const result: CalendarEvent[][] = []
|
|
152
167
|
|
|
153
168
|
for (const event of events) {
|
|
154
169
|
const availableHall = result.find(
|
|
155
|
-
(hall) => hall[hall.length - 1].endTime <= event.startTime,
|
|
170
|
+
(hall) => (hall[hall.length - 1].endTime || 0) <= (event.startTime || 0),
|
|
156
171
|
)
|
|
157
172
|
|
|
158
173
|
if (availableHall) {
|
|
@@ -255,7 +270,11 @@ export const twentyFourHoursFormat = [
|
|
|
255
270
|
'23:00',
|
|
256
271
|
]
|
|
257
272
|
|
|
258
|
-
export function formattedDuration(
|
|
273
|
+
export function formattedDuration(
|
|
274
|
+
fromTime: string,
|
|
275
|
+
toTime: string,
|
|
276
|
+
timeFormat: CalendarTimeFormat,
|
|
277
|
+
): string {
|
|
259
278
|
fromTime = formatTime(fromTime, timeFormat)
|
|
260
279
|
toTime = formatTime(toTime, timeFormat)
|
|
261
280
|
|
|
@@ -266,10 +285,10 @@ export function formattedDuration(fromTime, toTime, timeFormat) {
|
|
|
266
285
|
return fromTime + ' - ' + toTime
|
|
267
286
|
}
|
|
268
287
|
|
|
269
|
-
export function formatTime(time, format) {
|
|
288
|
+
export function formatTime(time: string, format: CalendarTimeFormat): string {
|
|
270
289
|
if (format === '12h') {
|
|
271
|
-
let [
|
|
272
|
-
hours = parseInt(
|
|
290
|
+
let [hoursValue, minutes] = time.split(':')
|
|
291
|
+
let hours: number | string = parseInt(hoursValue)
|
|
273
292
|
const ampm = hours >= 12 ? 'pm' : 'am'
|
|
274
293
|
hours = hours % 12
|
|
275
294
|
hours = hours ? hours : 12 // the hour '0' should be '12'
|
|
@@ -283,7 +302,7 @@ export function formatTime(time, format) {
|
|
|
283
302
|
return time
|
|
284
303
|
}
|
|
285
304
|
|
|
286
|
-
export const colorMap = {
|
|
305
|
+
export const colorMap: Record<string, CalendarColor> = {
|
|
287
306
|
amber: {
|
|
288
307
|
color: '#DB7706',
|
|
289
308
|
border: '#DB7706',
|
|
@@ -363,7 +382,7 @@ export const colorMap = {
|
|
|
363
382
|
},
|
|
364
383
|
}
|
|
365
384
|
|
|
366
|
-
export const colorMapDark = {
|
|
385
|
+
export const colorMapDark: Record<string, CalendarColor> = {
|
|
367
386
|
amber: {
|
|
368
387
|
color: '#DB7706',
|
|
369
388
|
border: '#C57411',
|
|
@@ -462,7 +481,9 @@ const _weekdayNameToIndex = {
|
|
|
462
481
|
saturday: 6,
|
|
463
482
|
}
|
|
464
483
|
|
|
465
|
-
export function getWeekendDays(
|
|
484
|
+
export function getWeekendDays(
|
|
485
|
+
config?: Partial<CalendarConfig> & { weekendDays?: Array<number | string> },
|
|
486
|
+
): number[] {
|
|
466
487
|
// Support both weekendDays (preferred) and weekends (legacy) keys
|
|
467
488
|
const raw = config?.weekendDays || config?.weekends
|
|
468
489
|
if (!raw || !Array.isArray(raw) || raw.length === 0) return [0]
|
|
@@ -471,28 +492,31 @@ export function getWeekendDays(config) {
|
|
|
471
492
|
if (typeof d === 'number') return d
|
|
472
493
|
if (typeof d === 'string') {
|
|
473
494
|
const key = d.trim().toLowerCase()
|
|
474
|
-
if (
|
|
475
|
-
return _weekdayNameToIndex[key]
|
|
495
|
+
if (Object.prototype.hasOwnProperty.call(_weekdayNameToIndex, key))
|
|
496
|
+
return _weekdayNameToIndex[key as keyof typeof _weekdayNameToIndex]
|
|
476
497
|
}
|
|
477
498
|
return null
|
|
478
499
|
})
|
|
479
|
-
.filter((v) => v !== null && v >= 0 && v <= 6)
|
|
500
|
+
.filter((v): v is number => v !== null && v >= 0 && v <= 6)
|
|
480
501
|
}
|
|
481
502
|
|
|
482
|
-
export function isWeekend(
|
|
503
|
+
export function isWeekend(
|
|
504
|
+
date: Date | string,
|
|
505
|
+
config?: CalendarConfig,
|
|
506
|
+
): boolean {
|
|
483
507
|
const day = new Date(date).getDay()
|
|
484
508
|
const weekendDays = getWeekendDays(config)
|
|
485
509
|
return weekendDays.includes(day)
|
|
486
510
|
}
|
|
487
511
|
|
|
488
512
|
// Format single month & year (e.g., "August, 2025")
|
|
489
|
-
export function formatMonthYear(month, year) {
|
|
513
|
+
export function formatMonthYear(month: number, year: number): string {
|
|
490
514
|
return `${monthList[month]} ${year}`
|
|
491
515
|
}
|
|
492
516
|
|
|
493
517
|
// Extract ordered unique {month, year} pairs from a week of dates
|
|
494
|
-
export function getWeekMonthParts(weekDates) {
|
|
495
|
-
const parts = []
|
|
518
|
+
export function getWeekMonthParts(weekDates?: Date[]) {
|
|
519
|
+
const parts: Array<{ key: string; month: number; year: number }> = []
|
|
496
520
|
for (const d of weekDates || []) {
|
|
497
521
|
const dt = new Date(d)
|
|
498
522
|
const m = dt.getMonth()
|
|
@@ -4,13 +4,21 @@ import {
|
|
|
4
4
|
calculateMinutes,
|
|
5
5
|
findOverlappingEventsCount,
|
|
6
6
|
} from '../calendarUtils'
|
|
7
|
+
import type {
|
|
8
|
+
CalendarEvent,
|
|
9
|
+
CalendarMode,
|
|
10
|
+
GroupedCalendarEvents,
|
|
11
|
+
} from '../types'
|
|
7
12
|
|
|
8
|
-
export const activeEvent = ref('')
|
|
13
|
+
export const activeEvent = ref<string | number>('')
|
|
9
14
|
|
|
10
|
-
export default function useCalendarData(
|
|
15
|
+
export default function useCalendarData(
|
|
16
|
+
events: CalendarEvent[] = [],
|
|
17
|
+
view: CalendarMode | '' = '',
|
|
18
|
+
) {
|
|
11
19
|
const timedEvents = computed(() => {
|
|
12
|
-
let groupByDate = groupBy(events, (row) => row.date)
|
|
13
|
-
let sortedArray = {}
|
|
20
|
+
let groupByDate = groupBy(events, (row) => row.date || '')
|
|
21
|
+
let sortedArray: GroupedCalendarEvents = {}
|
|
14
22
|
if (view === 'Month') {
|
|
15
23
|
for (const [key, value] of Object.entries(groupByDate)) {
|
|
16
24
|
sortedArray[key] = sortMonthlyEvents(value)
|
|
@@ -19,10 +27,12 @@ export default function useCalendarData(events, view = '') {
|
|
|
19
27
|
for (let [key, value] of Object.entries(groupByDate)) {
|
|
20
28
|
value = value.filter((event) => !event.isFullDay)
|
|
21
29
|
value.forEach((task) => {
|
|
22
|
-
task.startTime = calculateMinutes(task.fromTime)
|
|
23
|
-
task.endTime = calculateMinutes(task.toTime)
|
|
30
|
+
task.startTime = calculateMinutes(task.fromTime || '00:00')
|
|
31
|
+
task.endTime = calculateMinutes(task.toTime || '00:00')
|
|
24
32
|
})
|
|
25
|
-
let sortedEvents = value.sort(
|
|
33
|
+
let sortedEvents = value.sort(
|
|
34
|
+
(a, b) => (a.startTime || 0) - (b.startTime || 0),
|
|
35
|
+
)
|
|
26
36
|
sortedArray[key] = findOverlappingEventsCount(sortedEvents)
|
|
27
37
|
}
|
|
28
38
|
}
|
|
@@ -31,23 +41,25 @@ export default function useCalendarData(events, view = '') {
|
|
|
31
41
|
|
|
32
42
|
const fullDayEvents = computed(() => {
|
|
33
43
|
let fullDay = events.filter((event) => event.isFullDay)
|
|
34
|
-
let dateGroup = groupBy(fullDay, (row) => row.date)
|
|
44
|
+
let dateGroup = groupBy(fullDay, (row) => row.date || '')
|
|
35
45
|
return dateGroup
|
|
36
46
|
})
|
|
37
47
|
|
|
38
48
|
return { timedEvents, fullDayEvents }
|
|
39
49
|
}
|
|
40
50
|
|
|
41
|
-
function sortMonthlyEvents(events) {
|
|
51
|
+
function sortMonthlyEvents(events: CalendarEvent[]): CalendarEvent[] {
|
|
42
52
|
let fullDayEvents = events.filter((event) => event.isFullDay)
|
|
43
53
|
let timedEvents = events
|
|
44
54
|
.filter((event) => !event.isFullDay)
|
|
45
55
|
.sort((a, b) =>
|
|
46
56
|
a.fromTime !== b.fromTime
|
|
47
|
-
? calculateMinutes(a.fromTime) >
|
|
57
|
+
? calculateMinutes(a.fromTime || '00:00') >
|
|
58
|
+
calculateMinutes(b.fromTime || '00:00')
|
|
48
59
|
? 1
|
|
49
60
|
: -1
|
|
50
|
-
: calculateMinutes(a.toTime) >
|
|
61
|
+
: calculateMinutes(a.toTime || '00:00') >
|
|
62
|
+
calculateMinutes(b.toTime || '00:00')
|
|
51
63
|
? 1
|
|
52
64
|
: -1,
|
|
53
65
|
)
|
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
convertMinutesToHours,
|
|
5
5
|
calculateMinutes,
|
|
6
6
|
} from '../calendarUtils'
|
|
7
|
+
import type { CalendarEvent, CalendarMode } from '../types'
|
|
7
8
|
|
|
8
9
|
export default function useEventModal() {
|
|
9
10
|
const showEventModal = ref(false)
|
|
10
|
-
const newEvent = reactive({
|
|
11
|
+
const newEvent = reactive<CalendarEvent>({
|
|
11
12
|
date: '',
|
|
12
13
|
participant: '',
|
|
13
14
|
fromDate: '',
|
|
@@ -19,21 +20,19 @@ export default function useEventModal() {
|
|
|
19
20
|
isFullDay: false,
|
|
20
21
|
})
|
|
21
22
|
function openNewEventModal(
|
|
22
|
-
e,
|
|
23
|
-
view,
|
|
24
|
-
date,
|
|
25
|
-
isEditMode,
|
|
23
|
+
e: MouseEvent,
|
|
24
|
+
view: CalendarMode,
|
|
25
|
+
date: Date | string,
|
|
26
|
+
isEditMode: boolean,
|
|
26
27
|
fromTime = '',
|
|
27
28
|
isFullDay = false,
|
|
28
29
|
) {
|
|
29
30
|
if (!isEditMode) return
|
|
30
|
-
date =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
newEvent.
|
|
35
|
-
newEvent.fromDate = date
|
|
36
|
-
newEvent.toDate = date
|
|
31
|
+
date = view === 'Week' ? getDateFromWeeklyCell(e) || date : date
|
|
32
|
+
const formattedDate = parseDate(new Date(date))
|
|
33
|
+
newEvent.date = formattedDate
|
|
34
|
+
newEvent.fromDate = formattedDate
|
|
35
|
+
newEvent.toDate = formattedDate
|
|
37
36
|
newEvent.isFullDay = isFullDay
|
|
38
37
|
|
|
39
38
|
if (view === 'Month') {
|
|
@@ -53,3 +52,8 @@ export default function useEventModal() {
|
|
|
53
52
|
|
|
54
53
|
return { showEventModal, newEvent, openNewEventModal }
|
|
55
54
|
}
|
|
55
|
+
|
|
56
|
+
function getDateFromWeeklyCell(e: MouseEvent) {
|
|
57
|
+
const target = e.target as HTMLElement | null
|
|
58
|
+
return target?.parentElement?.parentElement?.getAttribute('data-date-attr')
|
|
59
|
+
}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
export { default as Calendar } from './Calendar.vue'
|
|
2
|
-
export { colorMap as CalendarColorMap } from './calendarUtils
|
|
3
|
-
export { activeEvent as CalendarActiveEvent } from './composables/useCalendarData
|
|
2
|
+
export { colorMap as CalendarColorMap } from './calendarUtils'
|
|
3
|
+
export { activeEvent as CalendarActiveEvent } from './composables/useCalendarData'
|
|
4
|
+
export type {
|
|
5
|
+
CalendarActions,
|
|
6
|
+
CalendarCellClickData,
|
|
7
|
+
CalendarConfig,
|
|
8
|
+
CalendarEvent,
|
|
9
|
+
CalendarMode,
|
|
10
|
+
CalendarPublicProps,
|
|
11
|
+
CalendarTimeFormat,
|
|
12
|
+
GroupedCalendarEvents,
|
|
13
|
+
} from './types'
|
|
@@ -111,7 +111,7 @@ const events = ref([
|
|
|
111
111
|
<template #target="{ togglePopover }">
|
|
112
112
|
<Button
|
|
113
113
|
variant="ghost"
|
|
114
|
-
class="text-lg
|
|
114
|
+
class="text-lg-medium text-ink-gray-7"
|
|
115
115
|
:label="headerProps.currentMonthYear"
|
|
116
116
|
iconRight="lucide-chevron-down"
|
|
117
117
|
@click="togglePopover"
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Component, InjectionKey, Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
export type CalendarMode = 'Day' | 'Week' | 'Month'
|
|
4
|
+
export type CalendarTimeFormat = '12h' | '24h'
|
|
5
|
+
|
|
6
|
+
export interface CalendarColor {
|
|
7
|
+
color: string
|
|
8
|
+
border: string
|
|
9
|
+
borderActive: string
|
|
10
|
+
text: string
|
|
11
|
+
textActive?: string
|
|
12
|
+
subtext: string
|
|
13
|
+
subtextActive: string
|
|
14
|
+
bg: string
|
|
15
|
+
bgHover: string
|
|
16
|
+
bgActive: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CalendarEvent {
|
|
20
|
+
id?: string | number
|
|
21
|
+
name?: string | number
|
|
22
|
+
title?: string
|
|
23
|
+
date?: string
|
|
24
|
+
fromDate?: string
|
|
25
|
+
toDate?: string
|
|
26
|
+
fromTime?: string
|
|
27
|
+
toTime?: string
|
|
28
|
+
fromDateTime?: string
|
|
29
|
+
toDateTime?: string
|
|
30
|
+
participant?: string
|
|
31
|
+
venue?: string
|
|
32
|
+
color?: string
|
|
33
|
+
type?: string
|
|
34
|
+
isFullDay?: boolean
|
|
35
|
+
startTime?: number
|
|
36
|
+
endTime?: number
|
|
37
|
+
hallNumber?: number
|
|
38
|
+
idx?: number
|
|
39
|
+
[key: string]: unknown
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CalendarConfig {
|
|
43
|
+
scrollToHour: number
|
|
44
|
+
disableModes: CalendarMode[]
|
|
45
|
+
defaultMode: CalendarMode
|
|
46
|
+
isEditMode: boolean
|
|
47
|
+
eventIcons: Record<string, Component>
|
|
48
|
+
hourHeight: number
|
|
49
|
+
enableShortcuts: boolean
|
|
50
|
+
showIcon: boolean
|
|
51
|
+
timeFormat: CalendarTimeFormat
|
|
52
|
+
weekends: string[]
|
|
53
|
+
noBorder?: boolean
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface CalendarCellClickData {
|
|
57
|
+
e: MouseEvent
|
|
58
|
+
view: CalendarMode
|
|
59
|
+
date: Date | string
|
|
60
|
+
time: string
|
|
61
|
+
isFullDay: boolean
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface CalendarPublicProps {
|
|
65
|
+
events: CalendarEvent[]
|
|
66
|
+
config?: Partial<CalendarConfig>
|
|
67
|
+
onClick?: (data: { e: MouseEvent; calendarEvent: CalendarEvent }) => void
|
|
68
|
+
onDblClick?: (data: {
|
|
69
|
+
e: MouseEvent | null
|
|
70
|
+
calendarEvent: CalendarEvent
|
|
71
|
+
}) => void
|
|
72
|
+
onCellClick?: (data: CalendarCellClickData) => void
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface CalendarActions {
|
|
76
|
+
createNewEvent: (event: CalendarEvent) => void
|
|
77
|
+
updateEventState: (event: CalendarEvent) => void
|
|
78
|
+
deleteEvent: (eventID: CalendarEvent['id']) => void
|
|
79
|
+
handleCellClick: (
|
|
80
|
+
e: MouseEvent,
|
|
81
|
+
date: Date | string,
|
|
82
|
+
time?: string,
|
|
83
|
+
isFullDay?: boolean,
|
|
84
|
+
) => void
|
|
85
|
+
updateActiveView: (
|
|
86
|
+
value: CalendarMode,
|
|
87
|
+
date?: Date,
|
|
88
|
+
isPreviousMonth?: boolean,
|
|
89
|
+
isNextMonth?: boolean,
|
|
90
|
+
) => void
|
|
91
|
+
props: CalendarPublicProps
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type GroupedCalendarEvents = Record<string, CalendarEvent[]>
|
|
95
|
+
|
|
96
|
+
export const ACTIVE_VIEW_KEY = Symbol(
|
|
97
|
+
'frappe-ui.calendar.active-view',
|
|
98
|
+
) as InjectionKey<Ref<CalendarMode>>
|
|
99
|
+
|
|
100
|
+
export const CALENDAR_CONFIG_KEY = Symbol(
|
|
101
|
+
'frappe-ui.calendar.config',
|
|
102
|
+
) as InjectionKey<CalendarConfig>
|
|
103
|
+
|
|
104
|
+
export const CALENDAR_ACTIONS_KEY = Symbol(
|
|
105
|
+
'frappe-ui.calendar.actions',
|
|
106
|
+
) as InjectionKey<CalendarActions>
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { ref, inject, computed, watch, reactive } from 'vue'
|
|
2
|
-
import { activeEvent } from './composables/useCalendarData
|
|
2
|
+
import { activeEvent } from './composables/useCalendarData'
|
|
3
3
|
import { colorMap, colorMapDark } from './calendarUtils'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
date: {
|
|
11
|
-
type: Date,
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
}
|
|
4
|
+
import {
|
|
5
|
+
CALENDAR_ACTIONS_KEY,
|
|
6
|
+
CALENDAR_CONFIG_KEY,
|
|
7
|
+
type CalendarColor,
|
|
8
|
+
type CalendarEvent,
|
|
9
|
+
} from './types'
|
|
15
10
|
|
|
16
11
|
export const isAnyPopoverOpen = ref(false)
|
|
17
12
|
|
|
18
|
-
export function useEventBase(props) {
|
|
19
|
-
const config = inject(
|
|
20
|
-
const calendarActions = inject(
|
|
13
|
+
export function useEventBase(props: { event: CalendarEvent; date: Date }) {
|
|
14
|
+
const config = inject(CALENDAR_CONFIG_KEY)!
|
|
15
|
+
const calendarActions = inject(CALENDAR_ACTIONS_KEY)!
|
|
16
|
+
|
|
17
|
+
if (!config || !calendarActions) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
'Calendar event components must be rendered inside Calendar.',
|
|
20
|
+
)
|
|
21
|
+
}
|
|
21
22
|
|
|
22
23
|
const calendarEvent = ref(props.event)
|
|
23
24
|
const updatedEvent = reactive({ ...props.event })
|
|
@@ -41,16 +42,19 @@ export function useEventBase(props) {
|
|
|
41
42
|
const getTheme = () => {
|
|
42
43
|
const theme = document.documentElement.getAttribute('data-theme')
|
|
43
44
|
if (theme) return theme
|
|
44
|
-
return document.documentElement.classList.contains('htw-dark')
|
|
45
|
+
return document.documentElement.classList.contains('htw-dark')
|
|
46
|
+
? 'dark'
|
|
47
|
+
: 'light'
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
function color(colorValue) {
|
|
50
|
+
function color(colorValue?: string): CalendarColor {
|
|
48
51
|
const map = getTheme() === 'dark' ? colorMapDark : colorMap
|
|
49
|
-
if (!colorValue?.startsWith('#'))
|
|
52
|
+
if (!colorValue?.startsWith('#'))
|
|
53
|
+
return map[colorValue || 'green'] || map['green']!
|
|
50
54
|
for (const value of Object.values(map)) {
|
|
51
55
|
if (value.color === colorValue) return value
|
|
52
56
|
}
|
|
53
|
-
return map['green']
|
|
57
|
+
return map['green']!
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
const eventBgStyle = computed(() => {
|
|
@@ -82,7 +86,7 @@ export function useEventBase(props) {
|
|
|
82
86
|
document.removeEventListener('keydown', handleDeleteShortcut)
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
function handleDeleteShortcut(e) {
|
|
89
|
+
function handleDeleteShortcut(e: KeyboardEvent) {
|
|
86
90
|
if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
87
91
|
e.preventDefault()
|
|
88
92
|
handleEventDelete()
|
|
@@ -92,9 +96,13 @@ export function useEventBase(props) {
|
|
|
92
96
|
// ── Click / edit / delete ────────────────────────────────────────────────
|
|
93
97
|
|
|
94
98
|
const preventClick = ref(false)
|
|
95
|
-
let clickTimer = null
|
|
99
|
+
let clickTimer: ReturnType<typeof setTimeout> | null = null
|
|
96
100
|
|
|
97
|
-
function handleEventClick(
|
|
101
|
+
function handleEventClick(
|
|
102
|
+
e: MouseEvent,
|
|
103
|
+
togglePopover: () => void,
|
|
104
|
+
isPopoverOpen?: boolean,
|
|
105
|
+
) {
|
|
98
106
|
isAnyPopoverOpen.value = false
|
|
99
107
|
if (preventClick.value) {
|
|
100
108
|
preventClick.value = false
|
|
@@ -103,7 +111,10 @@ export function useEventBase(props) {
|
|
|
103
111
|
if (e.detail === 1) {
|
|
104
112
|
clickTimer = setTimeout(() => {
|
|
105
113
|
if (calendarActions.props.onClick)
|
|
106
|
-
calendarActions.props.onClick({
|
|
114
|
+
calendarActions.props.onClick({
|
|
115
|
+
e,
|
|
116
|
+
calendarEvent: calendarEvent.value,
|
|
117
|
+
})
|
|
107
118
|
else {
|
|
108
119
|
togglePopover()
|
|
109
120
|
isAnyPopoverOpen.value = !isPopoverOpen
|
|
@@ -114,11 +125,14 @@ export function useEventBase(props) {
|
|
|
114
125
|
|
|
115
126
|
const showEventModal = ref(false)
|
|
116
127
|
|
|
117
|
-
function handleEventEdit(e = null) {
|
|
128
|
+
function handleEventEdit(e: MouseEvent | null = null) {
|
|
118
129
|
e && (e.cancelBubble = true)
|
|
119
|
-
clearTimeout(clickTimer)
|
|
130
|
+
if (clickTimer) clearTimeout(clickTimer)
|
|
120
131
|
if (calendarActions.props.onDblClick) {
|
|
121
|
-
calendarActions.props.onDblClick({
|
|
132
|
+
calendarActions.props.onDblClick({
|
|
133
|
+
e,
|
|
134
|
+
calendarEvent: calendarEvent.value,
|
|
135
|
+
})
|
|
122
136
|
return
|
|
123
137
|
}
|
|
124
138
|
if (!config.isEditMode) return
|
package/src/components/Card.vue
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="flex flex-col rounded-lg border bg-white px-6 py-5
|
|
2
|
+
<div class="flex flex-col rounded-lg border bg-white px-6 py-5">
|
|
3
3
|
<div class="flex items-baseline justify-between">
|
|
4
4
|
<div class="flex items-baseline space-x-2">
|
|
5
5
|
<div class="flex items-center space-x-2" v-if="$slots['actions-left']">
|
|
6
6
|
<slot name="actions-left"></slot>
|
|
7
7
|
</div>
|
|
8
|
-
<h2 class="text-
|
|
8
|
+
<h2 class="text-2xl-semibold">{{ title }}</h2>
|
|
9
9
|
</div>
|
|
10
10
|
<div class="flex items-center space-x-2" v-if="$slots['actions']">
|
|
11
11
|
<slot name="actions"></slot>
|
|
@@ -59,7 +59,7 @@ watch(
|
|
|
59
59
|
<div ref="chartDiv" v-show="!error" dir="ltr" :class="chartClass"></div>
|
|
60
60
|
<div
|
|
61
61
|
v-show="error"
|
|
62
|
-
class="flex h-full w-full items-center justify-center text-center text-ink-red-
|
|
62
|
+
class="flex h-full w-full items-center justify-center text-center text-ink-red-6"
|
|
63
63
|
>
|
|
64
64
|
Error: {{ error }}
|
|
65
65
|
</div>
|