@flux-ui/components 3.0.0-next.58 → 3.0.0-next.59
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/dist/component/FluxButtonStack.vue.d.ts +1 -1
- package/dist/component/FluxCalendar.vue.d.ts +63 -2
- package/dist/component/{FluxCalendarEvent.vue.d.ts → FluxCalendarItem.vue.d.ts} +9 -7
- package/dist/component/FluxClickablePane.vue.d.ts +1 -1
- package/dist/component/FluxDivider.vue.d.ts +1 -1
- package/dist/component/FluxFilter.vue.d.ts +1 -1
- package/dist/component/FluxFilterBar.vue.d.ts +1 -1
- package/dist/component/FluxFormInput.vue.d.ts +2 -2
- package/dist/component/FluxFormInputAddition.vue.d.ts +1 -1
- package/dist/component/FluxFormTreeViewSelect.vue.d.ts +3 -3
- package/dist/component/FluxGallery.vue.d.ts +1 -1
- package/dist/component/FluxInfo.vue.d.ts +1 -1
- package/dist/component/FluxKanbanColumn.vue.d.ts +2 -2
- package/dist/component/{FluxKanbanCard.vue.d.ts → FluxKanbanItem.vue.d.ts} +1 -1
- package/dist/component/FluxMenuItem.vue.d.ts +1 -1
- package/dist/component/FluxNotice.vue.d.ts +1 -1
- package/dist/component/FluxPaneHeader.vue.d.ts +1 -1
- package/dist/component/FluxPressable.vue.d.ts +1 -1
- package/dist/component/FluxPrompt.vue.d.ts +3 -3
- package/dist/component/FluxSplitButton.vue.d.ts +1 -1
- package/dist/component/FluxStack.vue.d.ts +1 -1
- package/dist/component/FluxTab.vue.d.ts +1 -1
- package/dist/component/FluxTabBar.vue.d.ts +4 -1
- package/dist/component/FluxTabs.vue.d.ts +4 -1
- package/dist/component/FluxTimelineItem.vue.d.ts +1 -1
- package/dist/component/calendar/FluxCalendarItemDisplay.vue.d.ts +9 -0
- package/dist/component/calendar/FluxCalendarMonthView.vue.d.ts +19 -0
- package/dist/component/calendar/FluxCalendarTimeGridView.vue.d.ts +36 -0
- package/dist/component/calendar/index.d.ts +3 -0
- package/dist/component/index.d.ts +2 -2
- package/dist/component/primitive/DialogLayout.vue.d.ts +1 -1
- package/dist/component/primitive/SelectBase.vue.d.ts +3 -3
- package/dist/composable/index.d.ts +3 -0
- package/dist/composable/private/index.d.ts +5 -8
- package/dist/composable/private/useKanban.d.ts +2 -2
- package/dist/composable/private/useKanbanAutoScroll.d.ts +13 -0
- package/dist/composable/useCalendarInjection.d.ts +2 -0
- package/dist/composable/useKanbanInjection.d.ts +2 -0
- package/dist/composable/useTabBarInjection.d.ts +2 -0
- package/dist/data/di.d.ts +54 -12
- package/dist/data/i18n.d.ts +4 -0
- package/dist/index.css +1500 -1221
- package/dist/index.js +9339 -8216
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/component/FluxAction.vue +1 -1
- package/src/component/FluxActionBar.vue +2 -2
- package/src/component/FluxActionPane.vue +1 -1
- package/src/component/FluxAdaptiveGroup.vue +2 -2
- package/src/component/FluxAdaptiveSlot.vue +2 -2
- package/src/component/FluxAlert.vue +1 -1
- package/src/component/FluxAnimatedColors.vue +1 -1
- package/src/component/FluxAspectRatio.vue +1 -1
- package/src/component/FluxAvatar.vue +2 -2
- package/src/component/FluxBadge.vue +2 -2
- package/src/component/FluxBorderShine.vue +1 -1
- package/src/component/FluxBoxedIcon.vue +1 -1
- package/src/component/FluxButton.vue +2 -2
- package/src/component/FluxButtonGroup.vue +1 -1
- package/src/component/FluxButtonStack.vue +1 -1
- package/src/component/FluxCalendar.vue +588 -179
- package/src/component/FluxCalendarItem.vue +79 -0
- package/src/component/FluxCheckbox.vue +2 -2
- package/src/component/FluxChip.vue +2 -2
- package/src/component/FluxClickablePane.vue +2 -2
- package/src/component/FluxColorPicker.vue +2 -2
- package/src/component/FluxColorSelect.vue +3 -3
- package/src/component/FluxColumn.vue +1 -1
- package/src/component/FluxCommandPalette.vue +4 -4
- package/src/component/FluxCommandPaletteGroup.vue +1 -1
- package/src/component/FluxCommandPaletteItem.vue +1 -1
- package/src/component/FluxComment.vue +2 -2
- package/src/component/FluxConfirm.vue +1 -1
- package/src/component/FluxContainer.vue +1 -1
- package/src/component/FluxDataTable.vue +1 -2
- package/src/component/FluxDatePicker.vue +3 -3
- package/src/component/FluxDestructiveButton.vue +1 -1
- package/src/component/FluxDisabled.vue +1 -1
- package/src/component/FluxDivider.vue +2 -2
- package/src/component/FluxDotPattern.vue +1 -1
- package/src/component/FluxDropZone.vue +4 -4
- package/src/component/FluxExpandable.vue +3 -3
- package/src/component/FluxExpandableGroup.vue +2 -2
- package/src/component/FluxFader.vue +1 -1
- package/src/component/FluxFaderItem.vue +1 -1
- package/src/component/FluxFilter.vue +2 -2
- package/src/component/FluxFilterBar.vue +5 -6
- package/src/component/FluxFilterBase.vue +2 -2
- package/src/component/FluxFilterDate.vue +2 -2
- package/src/component/FluxFilterDateRange.vue +2 -2
- package/src/component/FluxFilterOption.vue +2 -2
- package/src/component/FluxFilterOptionAsync.vue +1 -1
- package/src/component/FluxFilterOptions.vue +2 -2
- package/src/component/FluxFilterOptionsAsync.vue +1 -1
- package/src/component/FluxFilterRange.vue +2 -2
- package/src/component/FluxFilterWindow.vue +3 -3
- package/src/component/FluxFlickeringGrid.vue +1 -1
- package/src/component/FluxFlyout.vue +2 -2
- package/src/component/FluxFocalPointEditor.vue +3 -3
- package/src/component/FluxFocalPointImage.vue +1 -1
- package/src/component/FluxForm.vue +1 -1
- package/src/component/FluxFormColumn.vue +1 -1
- package/src/component/FluxFormDateInput.vue +3 -3
- package/src/component/FluxFormDateRangeInput.vue +4 -4
- package/src/component/FluxFormDateTimeInput.vue +3 -3
- package/src/component/FluxFormField.vue +3 -3
- package/src/component/FluxFormFieldAddition.vue +1 -1
- package/src/component/FluxFormGrid.vue +1 -1
- package/src/component/FluxFormInput.vue +3 -3
- package/src/component/FluxFormInputAddition.vue +2 -2
- package/src/component/FluxFormInputGroup.vue +2 -2
- package/src/component/FluxFormPinInput.vue +3 -3
- package/src/component/FluxFormRangeSlider.vue +3 -3
- package/src/component/FluxFormRow.vue +1 -1
- package/src/component/FluxFormSection.vue +1 -1
- package/src/component/FluxFormSelect.vue +4 -4
- package/src/component/FluxFormSelectAsync.vue +6 -6
- package/src/component/FluxFormSlider.vue +2 -2
- package/src/component/FluxFormTextArea.vue +2 -2
- package/src/component/FluxFormTimeZonePicker.vue +4 -4
- package/src/component/FluxFormTreeViewSelect.vue +9 -12
- package/src/component/FluxGallery.vue +3 -3
- package/src/component/FluxGalleryItem.vue +1 -1
- package/src/component/FluxGrid.vue +1 -1
- package/src/component/FluxGridColumn.vue +1 -1
- package/src/component/FluxGridPattern.vue +1 -1
- package/src/component/FluxIcon.vue +2 -2
- package/src/component/FluxInfo.vue +2 -2
- package/src/component/FluxItem.vue +1 -1
- package/src/component/FluxItemActions.vue +1 -1
- package/src/component/FluxItemContent.vue +1 -1
- package/src/component/FluxItemMedia.vue +1 -1
- package/src/component/FluxItemStack.vue +1 -1
- package/src/component/FluxKanban.vue +6 -13
- package/src/component/FluxKanbanColumn.vue +42 -36
- package/src/component/FluxKanbanItem.vue +162 -0
- package/src/component/FluxLayerPane.vue +1 -1
- package/src/component/FluxLayerPaneSecondary.vue +1 -1
- package/src/component/FluxLegend.vue +1 -1
- package/src/component/FluxLink.vue +1 -1
- package/src/component/FluxMenu.vue +1 -1
- package/src/component/FluxMenuCollapsible.vue +3 -3
- package/src/component/FluxMenuGroup.vue +1 -1
- package/src/component/FluxMenuItem.vue +2 -2
- package/src/component/FluxMenuSubHeader.vue +1 -1
- package/src/component/FluxMenuTitle.vue +1 -1
- package/src/component/FluxNotice.vue +3 -3
- package/src/component/FluxOverflowBar.vue +1 -1
- package/src/component/FluxOverlay.vue +3 -3
- package/src/component/FluxOverlayProvider.vue +2 -2
- package/src/component/FluxPagination.vue +3 -3
- package/src/component/FluxPaginationBar.vue +2 -2
- package/src/component/FluxPaginationButton.vue +1 -1
- package/src/component/FluxPane.vue +1 -1
- package/src/component/FluxPaneBody.vue +1 -1
- package/src/component/FluxPaneFooter.vue +1 -1
- package/src/component/FluxPaneGroup.vue +1 -1
- package/src/component/FluxPaneHeader.vue +2 -2
- package/src/component/FluxPaneIllustration.vue +1 -1
- package/src/component/FluxPaneMedia.vue +1 -1
- package/src/component/FluxPercentageBar.vue +1 -1
- package/src/component/FluxPersona.vue +1 -1
- package/src/component/FluxPlaceholder.vue +1 -1
- package/src/component/FluxPressable.vue +1 -1
- package/src/component/FluxPrimaryButton.vue +1 -1
- package/src/component/FluxPrimaryLinkButton.vue +1 -1
- package/src/component/FluxProgressBar.vue +2 -2
- package/src/component/FluxPrompt.vue +1 -1
- package/src/component/FluxPublishButton.vue +1 -1
- package/src/component/FluxQuantitySelector.vue +2 -2
- package/src/component/FluxRemove.vue +2 -2
- package/src/component/FluxRoot.vue +2 -2
- package/src/component/FluxRow.vue +1 -1
- package/src/component/FluxSecondaryButton.vue +1 -1
- package/src/component/FluxSecondaryLinkButton.vue +1 -1
- package/src/component/FluxSegmentedControl.vue +1 -1
- package/src/component/FluxSeparator.vue +1 -1
- package/src/component/FluxSlideOver.vue +3 -3
- package/src/component/FluxSnackbar.vue +2 -2
- package/src/component/FluxSnackbarProvider.vue +2 -2
- package/src/component/FluxSpacer.vue +1 -1
- package/src/component/FluxSpinner.vue +1 -1
- package/src/component/FluxSplitButton.vue +2 -2
- package/src/component/FluxStack.vue +2 -2
- package/src/component/FluxStatistic.vue +2 -2
- package/src/component/FluxStepper.vue +1 -1
- package/src/component/FluxStepperStep.vue +1 -1
- package/src/component/FluxStepperSteps.vue +2 -2
- package/src/component/FluxTab.vue +2 -2
- package/src/component/FluxTabBar.vue +75 -7
- package/src/component/FluxTabBarItem.vue +35 -4
- package/src/component/FluxTable.vue +3 -4
- package/src/component/FluxTableActions.vue +1 -1
- package/src/component/FluxTableBar.vue +3 -3
- package/src/component/FluxTableCell.vue +3 -3
- package/src/component/FluxTableHeader.vue +3 -3
- package/src/component/FluxTableRow.vue +1 -1
- package/src/component/FluxTabs.vue +10 -4
- package/src/component/FluxTag.vue +2 -2
- package/src/component/FluxTicks.vue +1 -1
- package/src/component/FluxTimeline.vue +1 -1
- package/src/component/FluxTimelineItem.vue +2 -2
- package/src/component/FluxToggle.vue +2 -2
- package/src/component/FluxToolbar.vue +2 -2
- package/src/component/FluxTooltip.vue +1 -1
- package/src/component/FluxTooltipProvider.vue +3 -3
- package/src/component/FluxTreeView.vue +3 -4
- package/src/component/FluxWindow.vue +1 -1
- package/src/component/calendar/FluxCalendarItemDisplay.vue +117 -0
- package/src/component/calendar/FluxCalendarMonthView.vue +134 -0
- package/src/component/calendar/FluxCalendarTimeGridView.vue +550 -0
- package/src/component/calendar/index.ts +3 -0
- package/src/component/index.ts +2 -2
- package/src/component/primitive/CoordinatePicker.vue +2 -2
- package/src/component/primitive/CoordinatePickerThumb.vue +2 -2
- package/src/component/primitive/DialogLayout.vue +1 -1
- package/src/component/primitive/FilterBadge.vue +2 -2
- package/src/component/primitive/FilterItem.vue +1 -1
- package/src/component/primitive/FilterMenuRenderer.ts +2 -2
- package/src/component/primitive/FilterOptionBase.vue +6 -6
- package/src/component/primitive/SelectBase.vue +13 -13
- package/src/component/primitive/SliderBase.vue +3 -3
- package/src/component/primitive/SliderThumb.vue +2 -2
- package/src/component/primitive/SliderTrack.vue +1 -1
- package/src/component/primitive/TreeNodeRenderer.vue +3 -4
- package/src/component/primitive/VNodeRenderer.ts +1 -2
- package/src/composable/index.ts +3 -0
- package/src/composable/private/index.ts +5 -8
- package/src/composable/private/useAsyncFilterOptions.ts +2 -2
- package/src/composable/private/useCommandPalette.ts +2 -2
- package/src/composable/private/useDateFlyout.ts +1 -1
- package/src/composable/private/useDropdownPopup.ts +1 -1
- package/src/composable/private/useFilterOption.ts +2 -2
- package/src/composable/private/useFormSelect.ts +2 -3
- package/src/composable/private/useKanban.ts +167 -244
- package/src/composable/private/useKanbanAutoScroll.ts +95 -0
- package/src/composable/private/useTranslate.ts +1 -2
- package/src/composable/private/useTreeView.ts +1 -1
- package/src/composable/useAdaptiveGroupInjection.ts +1 -1
- package/src/composable/useBreakpoints.ts +1 -2
- package/src/composable/useCalendarInjection.ts +6 -0
- package/src/composable/useDisabled.ts +1 -2
- package/src/composable/useDisabledInjection.ts +1 -1
- package/src/composable/useExpandableGroupInjection.ts +1 -1
- package/src/composable/useFilterInjection.ts +1 -1
- package/src/composable/useFlyoutInjection.ts +1 -1
- package/src/composable/useFormFieldInjection.ts +1 -1
- package/src/composable/useKanbanInjection.ts +12 -0
- package/src/composable/useTabBarInjection.ts +10 -0
- package/src/composable/useTableInjection.ts +1 -1
- package/src/composable/useTooltipInjection.ts +1 -1
- package/src/css/component/Action.module.scss +1 -1
- package/src/css/component/AdaptiveSlot.module.scss +5 -7
- package/src/css/component/Avatar.module.scss +1 -1
- package/src/css/component/Badge.module.scss +1 -1
- package/src/css/component/Button.module.scss +1 -1
- package/src/css/component/Calendar.module.scss +274 -44
- package/src/css/component/Chip.module.scss +1 -1
- package/src/css/component/Color.module.scss +1 -1
- package/src/css/component/CommandPalette.module.scss +1 -1
- package/src/css/component/DatePicker.module.scss +1 -1
- package/src/css/component/Expandable.module.scss +1 -1
- package/src/css/component/Form.module.scss +1 -1
- package/src/css/component/Gallery.module.scss +1 -1
- package/src/css/component/Grid.module.scss +1 -1
- package/src/css/component/Item.module.scss +1 -1
- package/src/css/component/{FluxKanban.module.scss → Kanban.module.scss} +56 -79
- package/src/css/component/Layout.module.scss +1 -1
- package/src/css/component/Menu.module.scss +1 -1
- package/src/css/component/Notice.module.scss +1 -1
- package/src/css/component/Overlay.module.scss +4 -4
- package/src/css/component/Pagination.module.scss +1 -1
- package/src/css/component/Pane.module.scss +2 -1
- package/src/css/component/Placeholder.module.scss +1 -1
- package/src/css/component/Remove.module.scss +1 -1
- package/src/css/component/SegmentedControl.module.scss +1 -1
- package/src/css/component/Snackbar.module.scss +1 -1
- package/src/css/component/Tab.module.scss +138 -34
- package/src/css/component/Table.module.scss +1 -1
- package/src/css/component/TreeView.module.scss +1 -1
- package/src/css/component/TreeViewSelect.module.scss +1 -1
- package/src/css/component/base/Button.module.scss +1 -1
- package/src/css/component/primitive/Slider.module.scss +1 -1
- package/src/css/component/primitive/TreeNode.module.scss +1 -1
- package/src/css/variables.scss +2 -2
- package/src/data/di.ts +64 -11
- package/src/data/filter.ts +3 -3
- package/src/data/i18n.ts +4 -0
- package/src/data/store.ts +1 -2
- package/src/transition/FluxBreakthroughTransition.vue +1 -1
- package/src/transition/FluxFadeTransition.vue +1 -1
- package/src/transition/FluxOverlayTransition.vue +1 -1
- package/src/transition/FluxRouteTransition.vue +1 -1
- package/src/transition/FluxSlideOverTransition.vue +1 -1
- package/src/transition/FluxTooltipTransition.vue +1 -1
- package/src/transition/FluxVerticalWindowTransition.vue +1 -1
- package/src/transition/FluxWindowTransition.vue +1 -1
- package/src/util/createDialogRenderer.ts +3 -4
- package/src/util/createLabelForDateRange.ts +1 -1
- package/src/component/FluxCalendarEvent.vue +0 -42
- package/src/component/FluxKanbanCard.vue +0 -199
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script
|
|
2
|
+
lang="ts"
|
|
3
|
+
setup>
|
|
4
|
+
import { useKeyboardGrab } from '@flux-ui/internals';
|
|
5
|
+
import { clsx } from 'clsx';
|
|
6
|
+
import { computed, defineComponent, onBeforeUnmount, onMounted, ref, toRef, watch } from 'vue';
|
|
7
|
+
import { useCalendarInjection } from '~flux/components/composable';
|
|
8
|
+
import type { FluxCalendarItemData } from '~flux/components/data';
|
|
9
|
+
import $style from '~flux/components/css/component/Calendar.module.scss';
|
|
10
|
+
|
|
11
|
+
const {data} = defineProps<{
|
|
12
|
+
readonly data: FluxCalendarItemData;
|
|
13
|
+
}>();
|
|
14
|
+
|
|
15
|
+
const dragContext = useCalendarInjection();
|
|
16
|
+
const root = ref<HTMLButtonElement | null>(null);
|
|
17
|
+
|
|
18
|
+
const canDrag = computed(() => dragContext?.isDraggable.value === true);
|
|
19
|
+
|
|
20
|
+
const RenderItemContent = defineComponent({
|
|
21
|
+
props: {
|
|
22
|
+
render: {
|
|
23
|
+
type: Function,
|
|
24
|
+
required: true
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
setup: (props) => () => (props.render as () => unknown)()
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
isGrabbed,
|
|
32
|
+
handleKeyDown,
|
|
33
|
+
release: releaseKeyboardGrab
|
|
34
|
+
} = useKeyboardGrab({
|
|
35
|
+
isDraggable: canDrag,
|
|
36
|
+
itemId: toRef(() => data.id),
|
|
37
|
+
grabbedId: dragContext?.grabbedId ?? ref<string | number | null>(null),
|
|
38
|
+
onGrab() {
|
|
39
|
+
dragContext?.onItemKeyboardGrab(data.id, data.date);
|
|
40
|
+
return data.date;
|
|
41
|
+
},
|
|
42
|
+
onMove(direction) {
|
|
43
|
+
dragContext?.onItemKeyboardMove(direction);
|
|
44
|
+
},
|
|
45
|
+
onCommit() {
|
|
46
|
+
dragContext?.onItemKeyboardCommit();
|
|
47
|
+
},
|
|
48
|
+
onCancel() {
|
|
49
|
+
dragContext?.onItemKeyboardCancel();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const itemClasses = computed(() => clsx(
|
|
54
|
+
$style.calendarItem,
|
|
55
|
+
data.isClickable && $style.isClickable,
|
|
56
|
+
canDrag.value && $style.isDraggable,
|
|
57
|
+
isGrabbed.value && $style.isGrabbed,
|
|
58
|
+
data.allDay && $style.isAllDay
|
|
59
|
+
));
|
|
60
|
+
|
|
61
|
+
function onClick(evt: MouseEvent): void {
|
|
62
|
+
data.handleClick(evt);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function onDragStart(evt: DragEvent): void {
|
|
66
|
+
if (!canDrag.value || !dragContext) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (isGrabbed.value) {
|
|
71
|
+
dragContext.onItemKeyboardCancel();
|
|
72
|
+
releaseKeyboardGrab();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
dragContext.onItemDragStart(data.id, data.date, evt);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function onDragEnd(): void {
|
|
79
|
+
dragContext?.onItemDragEnd(data.id);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onMounted(() => {
|
|
83
|
+
if (root.value) {
|
|
84
|
+
dragContext?.registerItemElement(root.value, data.id);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
onBeforeUnmount(() => {
|
|
89
|
+
if (root.value) {
|
|
90
|
+
dragContext?.unregisterItemElement(root.value);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
watch(() => data.id, (_newId, _oldId) => {
|
|
95
|
+
if (!root.value) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
dragContext?.unregisterItemElement(root.value);
|
|
100
|
+
dragContext?.registerItemElement(root.value, data.id);
|
|
101
|
+
});
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<template>
|
|
105
|
+
<button
|
|
106
|
+
ref="root"
|
|
107
|
+
:class="itemClasses"
|
|
108
|
+
:draggable="canDrag"
|
|
109
|
+
:tabindex="canDrag ? 0 : undefined"
|
|
110
|
+
type="button"
|
|
111
|
+
@click="onClick"
|
|
112
|
+
@dragstart="onDragStart"
|
|
113
|
+
@dragend="onDragEnd"
|
|
114
|
+
@keydown="handleKeyDown">
|
|
115
|
+
<RenderItemContent :render="data.renderContent"/>
|
|
116
|
+
</button>
|
|
117
|
+
</template>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FluxWindowTransition :is-back="isTransitioningToPast">
|
|
3
|
+
<div
|
|
4
|
+
:key="viewDate.month"
|
|
5
|
+
:class="$style.calendarCells"
|
|
6
|
+
role="grid">
|
|
7
|
+
<template v-for="day of days">
|
|
8
|
+
<div :class="$style.calendarDay">
|
|
9
|
+
{{ day }}
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<template v-for="date of dates">
|
|
14
|
+
<div
|
|
15
|
+
:class="clsx(
|
|
16
|
+
$style.calendarEntry,
|
|
17
|
+
viewDate.month !== date.month && $style.isDisabled,
|
|
18
|
+
isToday(date) && $style.isToday,
|
|
19
|
+
focusedDate && date.toSQLDate() === focusedDate.toSQLDate() && $style.isFocused,
|
|
20
|
+
draggable && dropTargetDate === date.toSQLDate() && $style.isDropTarget
|
|
21
|
+
)"
|
|
22
|
+
role="gridcell"
|
|
23
|
+
@dragover="draggable ? onCellDragOver(date, $event) : undefined"
|
|
24
|
+
@dragleave="draggable ? onCellDragLeave(date) : undefined"
|
|
25
|
+
@drop="draggable ? onCellDrop(date, $event) : undefined">
|
|
26
|
+
<div :class="$style.calendarEvents">
|
|
27
|
+
<FluxCalendarItemDisplay
|
|
28
|
+
v-for="item of getItemsForDate(date)"
|
|
29
|
+
:key="item.id"
|
|
30
|
+
:data="item"/>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<span :class="$style.calendarEntryDate">
|
|
34
|
+
{{ date.toLocaleString({day: 'numeric'}) }}
|
|
35
|
+
</span>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
</div>
|
|
39
|
+
</FluxWindowTransition>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script
|
|
43
|
+
lang="ts"
|
|
44
|
+
setup>
|
|
45
|
+
import { clsx } from 'clsx';
|
|
46
|
+
import { DateTime } from 'luxon';
|
|
47
|
+
import { computed, ref, unref } from 'vue';
|
|
48
|
+
import type { FluxCalendarItemData } from '~flux/components/data';
|
|
49
|
+
import { FluxWindowTransition } from '~flux/components/transition';
|
|
50
|
+
import FluxCalendarItemDisplay from './FluxCalendarItemDisplay.vue';
|
|
51
|
+
import $style from '~flux/components/css/component/Calendar.module.scss';
|
|
52
|
+
|
|
53
|
+
const emit = defineEmits<{
|
|
54
|
+
cellDrop: [DateTime];
|
|
55
|
+
}>();
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
dates,
|
|
59
|
+
days,
|
|
60
|
+
viewDate,
|
|
61
|
+
draggable,
|
|
62
|
+
items,
|
|
63
|
+
hasActiveDrag,
|
|
64
|
+
focusedDate
|
|
65
|
+
} = defineProps<{
|
|
66
|
+
readonly dates: DateTime[];
|
|
67
|
+
readonly days: string[];
|
|
68
|
+
readonly viewDate: DateTime;
|
|
69
|
+
readonly isTransitioningToPast: boolean;
|
|
70
|
+
readonly draggable: boolean;
|
|
71
|
+
readonly items: FluxCalendarItemData[];
|
|
72
|
+
readonly hasActiveDrag: boolean;
|
|
73
|
+
readonly focusedDate?: DateTime | null;
|
|
74
|
+
}>();
|
|
75
|
+
|
|
76
|
+
const dropTargetDate = ref<string | null>(null);
|
|
77
|
+
|
|
78
|
+
function isToday(date: DateTime): boolean {
|
|
79
|
+
return date.hasSame(DateTime.now(), 'day');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const itemsByDate = computed(() => {
|
|
83
|
+
const map = new Map<string, FluxCalendarItemData[]>();
|
|
84
|
+
|
|
85
|
+
items.forEach(item => {
|
|
86
|
+
const dateKey = item.date.toSQLDate();
|
|
87
|
+
|
|
88
|
+
if (!dateKey) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const list = map.get(dateKey);
|
|
93
|
+
|
|
94
|
+
if (list) {
|
|
95
|
+
list.push(item);
|
|
96
|
+
} else {
|
|
97
|
+
map.set(dateKey, [item]);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return map;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
function getItemsForDate(forDate: DateTime): FluxCalendarItemData[] {
|
|
105
|
+
const key = forDate.toSQLDate();
|
|
106
|
+
return key ? unref(itemsByDate).get(key) ?? [] : [];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function onCellDragOver(date: DateTime, evt: DragEvent): void {
|
|
110
|
+
if (!hasActiveDrag) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
evt.preventDefault();
|
|
115
|
+
|
|
116
|
+
if (evt.dataTransfer) {
|
|
117
|
+
evt.dataTransfer.dropEffect = 'move';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
dropTargetDate.value = date.toSQLDate();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function onCellDragLeave(date: DateTime): void {
|
|
124
|
+
if (unref(dropTargetDate) === date.toSQLDate()) {
|
|
125
|
+
dropTargetDate.value = null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function onCellDrop(date: DateTime, evt: DragEvent): void {
|
|
130
|
+
evt.preventDefault();
|
|
131
|
+
emit('cellDrop', date.startOf('day'));
|
|
132
|
+
dropTargetDate.value = null;
|
|
133
|
+
}
|
|
134
|
+
</script>
|