@formicoidea/labre-core 1.1.0 → 2.0.0
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/architecture/code.c4 +37 -34
- package/architecture/likec4.config.json +3 -3
- package/dist/_pkgs/affine-block-surface/extensions/reading-toolbar.js +12 -12
- package/dist/_pkgs/affine-components/context-menu/menu-renderer.d.ts +3 -1
- package/dist/_pkgs/affine-components/context-menu/menu-renderer.js +9 -1
- package/dist/_pkgs/affine-components/context-menu/menu.d.ts +7 -0
- package/dist/_pkgs/affine-components/context-menu/menu.js +5 -0
- package/dist/_pkgs/affine-components/context-menu/sub-menu.d.ts +16 -1
- package/dist/_pkgs/affine-components/context-menu/sub-menu.js +32 -5
- package/dist/_pkgs/affine-components/highlight-dropdown-menu/highlight-duotone-icon.js +8 -8
- package/dist/_pkgs/affine-components/highlight-dropdown-menu/text-duotone-icon.js +11 -11
- package/dist/_pkgs/affine-database-block/configs/slash-menu.js +14 -6
- package/dist/_pkgs/affine-database-block/database-block-styles.js +4 -3
- package/dist/_pkgs/affine-database-block/database-block.js +6 -18
- package/dist/_pkgs/affine-database-block/database-dnd-preview-block.js +5 -1
- package/dist/_pkgs/affine-database-block/detail-panel/block-renderer.js +5 -2
- package/dist/_pkgs/affine-database-block/detail-panel/note-renderer.js +3 -2
- package/dist/_pkgs/affine-database-block/external-data-source.d.ts +10 -0
- package/dist/_pkgs/affine-database-block/external-data-source.js +24 -0
- package/dist/_pkgs/affine-database-block/properties/created-time/define.js +3 -1
- package/dist/_pkgs/affine-database-block/properties/link/cell-renderer.js +3 -2
- package/dist/_pkgs/affine-database-block/properties/link/define.js +3 -1
- package/dist/_pkgs/affine-database-block/properties/rich-text/define.js +3 -1
- package/dist/_pkgs/affine-database-block/properties/text/hosted.js +1 -0
- package/dist/_pkgs/affine-database-block/properties/title/define.js +3 -1
- package/dist/_pkgs/affine-database-block/properties/title/hosted.js +1 -0
- package/dist/_pkgs/affine-database-block/service/new-row-menu.d.ts +1 -1
- package/dist/_pkgs/affine-database-block/service/new-row-menu.js +1 -1
- package/dist/_pkgs/affine-database-block/translations.d.ts +11 -0
- package/dist/_pkgs/affine-database-block/translations.js +57 -0
- package/dist/_pkgs/affine-database-block/views/index.d.ts +7 -9
- package/dist/_pkgs/affine-database-block/views/index.js +7 -10
- package/dist/_pkgs/affine-database-engine/core/common/properties.js +7 -7
- package/dist/_pkgs/affine-database-engine/core/common/property-menu.d.ts +18 -2
- package/dist/_pkgs/affine-database-engine/core/common/property-menu.js +78 -27
- package/dist/_pkgs/affine-database-engine/core/data-source/base.d.ts +11 -0
- package/dist/_pkgs/affine-database-engine/core/data-source/base.js +3 -0
- package/dist/_pkgs/affine-database-engine/core/detail/detail.js +8 -5
- package/dist/_pkgs/affine-database-engine/core/detail/field.js +14 -7
- package/dist/_pkgs/affine-database-engine/core/filter/add-filter.js +4 -2
- package/dist/_pkgs/affine-database-engine/core/filter/filter-fn/boolean.js +7 -4
- package/dist/_pkgs/affine-database-engine/core/filter/filter-fn/create.d.ts +9 -1
- package/dist/_pkgs/affine-database-engine/core/filter/filter-fn/create.js +2 -0
- package/dist/_pkgs/affine-database-engine/core/filter/filter-fn/date.js +7 -4
- package/dist/_pkgs/affine-database-engine/core/filter/filter-fn/multi-tag.js +17 -8
- package/dist/_pkgs/affine-database-engine/core/filter/filter-fn/number.js +6 -6
- package/dist/_pkgs/affine-database-engine/core/filter/filter-fn/string.js +19 -12
- package/dist/_pkgs/affine-database-engine/core/filter/filter-fn/tag.js +9 -4
- package/dist/_pkgs/affine-database-engine/core/filter/filter-fn/unknown.js +7 -4
- package/dist/_pkgs/affine-database-engine/core/filter/literal/define.js +6 -4
- package/dist/_pkgs/affine-database-engine/core/filter/literal/matcher.d.ts +2 -1
- package/dist/_pkgs/affine-database-engine/core/filter/literal/matcher.js +3 -2
- package/dist/_pkgs/affine-database-engine/core/filter/literal/types.d.ts +4 -1
- package/dist/_pkgs/affine-database-engine/core/filter/literal/types.js +1 -1
- package/dist/_pkgs/affine-database-engine/core/group-by/define.js +11 -9
- package/dist/_pkgs/affine-database-engine/core/group-by/group-title.js +16 -6
- package/dist/_pkgs/affine-database-engine/core/group-by/locate-row.d.ts +16 -0
- package/dist/_pkgs/affine-database-engine/core/group-by/locate-row.js +32 -0
- package/dist/_pkgs/affine-database-engine/core/group-by/renderer/date-group.js +10 -3
- package/dist/_pkgs/affine-database-engine/core/group-by/setting.d.ts +2 -0
- package/dist/_pkgs/affine-database-engine/core/group-by/setting.js +40 -28
- package/dist/_pkgs/affine-database-engine/core/group-by/trait.d.ts +3 -0
- package/dist/_pkgs/affine-database-engine/core/group-by/trait.js +8 -0
- package/dist/_pkgs/affine-database-engine/core/group-by/types.d.ts +3 -1
- package/dist/_pkgs/affine-database-engine/core/group-by/types.js +1 -1
- package/dist/_pkgs/affine-database-engine/core/property/types.d.ts +7 -0
- package/dist/_pkgs/affine-database-engine/core/property/types.js +1 -1
- package/dist/_pkgs/affine-database-engine/core/sort/add-sort.js +3 -1
- package/dist/_pkgs/affine-database-engine/core/statistics/any.js +43 -21
- package/dist/_pkgs/affine-database-engine/core/statistics/checkbox.js +29 -14
- package/dist/_pkgs/affine-database-engine/core/statistics/number.js +54 -31
- package/dist/_pkgs/affine-database-engine/core/statistics/types.d.ts +8 -0
- package/dist/_pkgs/affine-database-engine/core/statistics/types.js +2 -1
- package/dist/_pkgs/affine-database-engine/core/utils/wording.d.ts +20 -1
- package/dist/_pkgs/affine-database-engine/core/utils/wording.js +24 -0
- package/dist/_pkgs/affine-database-engine/core/view-manager/property.d.ts +7 -0
- package/dist/_pkgs/affine-database-engine/core/view-manager/property.js +29 -5
- package/dist/_pkgs/affine-database-engine/core/view-manager/single-view.d.ts +14 -0
- package/dist/_pkgs/affine-database-engine/core/view-manager/single-view.js +11 -0
- package/dist/_pkgs/affine-database-engine/property-presets/checkbox/define.js +3 -1
- package/dist/_pkgs/affine-database-engine/property-presets/date/define.js +3 -1
- package/dist/_pkgs/affine-database-engine/property-presets/multi-select/define.js +3 -1
- package/dist/_pkgs/affine-database-engine/property-presets/number/define.js +3 -1
- package/dist/_pkgs/affine-database-engine/property-presets/number/utils/formats.d.ts +3 -0
- package/dist/_pkgs/affine-database-engine/property-presets/number/utils/formats.js +56 -9
- package/dist/_pkgs/affine-database-engine/property-presets/progress/define.js +3 -1
- package/dist/_pkgs/affine-database-engine/property-presets/select/define.js +3 -1
- package/dist/_pkgs/affine-database-engine/property-presets/text/define.js +3 -1
- package/dist/_pkgs/affine-database-engine/translations.d.ts +133 -5
- package/dist/_pkgs/affine-database-engine/translations.js +625 -9
- package/dist/_pkgs/affine-database-engine/view-presets/convert.js +0 -28
- package/dist/_pkgs/affine-database-engine/view-presets/effect.js +0 -2
- package/dist/_pkgs/affine-database-engine/view-presets/flat/flat-converts.js +2 -4
- package/dist/_pkgs/affine-database-engine/view-presets/flat/flat-view-ui.d.ts +57 -0
- package/dist/_pkgs/affine-database-engine/view-presets/flat/flat-view-ui.js +113 -4
- package/dist/_pkgs/affine-database-engine/view-presets/gallery/gallery-view.js +2 -1
- package/dist/_pkgs/affine-database-engine/view-presets/index.d.ts +0 -2
- package/dist/_pkgs/affine-database-engine/view-presets/index.js +0 -3
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/kanban-view-manager.js +2 -0
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/mobile/group.js +7 -5
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/mobile/kanban-view-ui-logic.d.ts +5 -0
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/mobile/kanban-view-ui-logic.js +25 -3
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/mobile/menu.js +12 -6
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/pc/controller/selection.d.ts +8 -0
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/pc/controller/selection.js +35 -12
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/pc/group.js +7 -5
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/pc/header.js +5 -1
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/pc/kanban-view-ui-logic.d.ts +5 -0
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/pc/kanban-view-ui-logic.js +8 -4
- package/dist/_pkgs/affine-database-engine/view-presets/kanban/pc/menu.js +12 -6
- package/dist/_pkgs/affine-database-engine/view-presets/list/list-view.js +2 -1
- package/dist/_pkgs/affine-database-engine/view-presets/table/mobile/column-header.js +6 -4
- package/dist/_pkgs/affine-database-engine/view-presets/table/mobile/group.js +6 -5
- package/dist/_pkgs/affine-database-engine/view-presets/table/mobile/header.js +2 -2
- package/dist/_pkgs/affine-database-engine/view-presets/table/mobile/table-view-ui-logic.d.ts +4 -3
- package/dist/_pkgs/affine-database-engine/view-presets/table/mobile/table-view-ui-logic.js +29 -5
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc/controller/clipboard.js +6 -2
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc/controller/selection.js +2 -0
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc/group.js +6 -5
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc/header/column-header.js +11 -7
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc/header/database-header-column.js +16 -12
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc/header/number-format-bar.js +4 -2
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc/menu.js +9 -6
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc/table-view-ui-logic.d.ts +8 -1
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc/table-view-ui-logic.js +29 -7
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/controller/clipboard.js +6 -2
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/controller/selection.js +2 -0
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/group/bottom/group-footer.js +5 -2
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/group/bottom/stats/column-stats-column.d.ts +1 -1
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/group/bottom/stats/column-stats-column.js +14 -6
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/group/top/group-header.js +5 -2
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/group/top/group-title.js +5 -3
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/group/top/header/column-header.js +17 -10
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/group/top/header/number-format-bar.js +4 -2
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/group/top/header/single-column-header.js +20 -14
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/row/menu.js +9 -6
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/table-view-ui-logic.d.ts +6 -1
- package/dist/_pkgs/affine-database-engine/view-presets/table/pc-virtual/table-view-ui-logic.js +30 -3
- package/dist/_pkgs/affine-database-engine/view-presets/table/stats/column-stats-column.d.ts +1 -1
- package/dist/_pkgs/affine-database-engine/view-presets/table/stats/column-stats-column.js +14 -6
- package/dist/_pkgs/affine-database-engine/view-presets/table/table-view-manager.js +2 -0
- package/dist/_pkgs/affine-database-engine/widget-presets/quick-setting-bar/filter/condition-view.d.ts +2 -0
- package/dist/_pkgs/affine-database-engine/widget-presets/quick-setting-bar/filter/condition-view.js +13 -6
- package/dist/_pkgs/affine-database-engine/widget-presets/quick-setting-bar/filter/group-panel-view.js +20 -13
- package/dist/_pkgs/affine-database-engine/widget-presets/quick-setting-bar/filter/root-panel-view.js +10 -5
- package/dist/_pkgs/affine-database-engine/widget-presets/quick-setting-bar/sort/root-panel.js +8 -5
- package/dist/_pkgs/affine-database-engine/widget-presets/tools/presets/search/search.js +2 -2
- package/dist/_pkgs/affine-database-engine/widget-presets/tools/presets/table-add-row/add-row.d.ts +6 -0
- package/dist/_pkgs/affine-database-engine/widget-presets/tools/presets/table-add-row/add-row.js +49 -4
- package/dist/_pkgs/affine-database-engine/widget-presets/tools/presets/view-options/view-settings.d.ts +3 -3
- package/dist/_pkgs/affine-database-engine/widget-presets/tools/presets/view-options/view-settings.js +3 -3
- package/dist/_pkgs/affine-database-engine/widget-presets/views-bar/views-view.js +5 -0
- package/dist/_pkgs/affine-database-view-block/configs/slash-menu.js +6 -3
- package/dist/_pkgs/affine-database-view-block/data-view-block.js +5 -4
- package/dist/_pkgs/affine-fragment-doc-title/doc-title.d.ts +3 -2
- package/dist/_pkgs/affine-fragment-doc-title/doc-title.js +3 -2
- package/dist/_pkgs/affine-shared/services/data-source-picker-service.d.ts +31 -0
- package/dist/_pkgs/affine-widget-edgeless-zoom-toolbar/index.js +26 -26
- package/dist/_pkgs/affine-widget-keyboard-toolbar/icons.js +98 -98
- package/dist/_pkgs/affine-widget-page-dragging-area/index.js +10 -10
- package/dist/_pkgs/affine-widget-viewport-overlay/index.js +13 -13
- package/package.json +1 -1
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/calendar-view-manager.d.ts +0 -70
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/calendar-view-manager.js +0 -449
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/define.d.ts +0 -10
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/define.js +0 -29
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/effect.d.ts +0 -1
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/effect.js +0 -4
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/index.d.ts +0 -6
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/index.js +0 -6
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/layout.d.ts +0 -37
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/layout.js +0 -138
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/actions.d.ts +0 -7
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/actions.js +0 -64
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/dnd.d.ts +0 -32
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/dnd.js +0 -159
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/effect.d.ts +0 -1
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/effect.js +0 -7
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/hit-test.d.ts +0 -1
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/hit-test.js +0 -28
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/styles.d.ts +0 -1
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/styles.js +0 -707
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/view.d.ts +0 -89
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/pc/view.js +0 -849
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/renderer.d.ts +0 -2
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/renderer.js +0 -8
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/source.d.ts +0 -8
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/source.js +0 -3
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/types.d.ts +0 -79
- package/dist/_pkgs/affine-database-engine/view-presets/calendar/types.js +0 -1
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { DataViewRootUILogic } from '../../../core/data-view.js';
|
|
2
|
-
import type { CalendarSingleView } from '../calendar-view-manager.js';
|
|
3
|
-
import type { CalendarEntry } from '../types.js';
|
|
4
|
-
export declare const formatEntryTime: (entry: CalendarEntry) => string;
|
|
5
|
-
export declare const openCalendarEntry: (root: DataViewRootUILogic, view: CalendarSingleView, entry: CalendarEntry, target: HTMLElement, options?: {
|
|
6
|
-
selectEntry?: (entryId: string | undefined) => void;
|
|
7
|
-
}) => void;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { popMenu, popupTargetFromElement, } from '../../../../affine-components/context-menu/index.js';
|
|
2
|
-
import { CalendarPanelIcon, DateTimeIcon, PinIcon, TextIcon, } from '@blocksuite/icons/lit';
|
|
3
|
-
import { html } from 'lit';
|
|
4
|
-
const dateTimeFormatter = new Intl.DateTimeFormat(undefined, {
|
|
5
|
-
dateStyle: 'medium',
|
|
6
|
-
timeStyle: 'short',
|
|
7
|
-
});
|
|
8
|
-
const dateFormatter = new Intl.DateTimeFormat(undefined, {
|
|
9
|
-
dateStyle: 'medium',
|
|
10
|
-
});
|
|
11
|
-
export const formatEntryTime = (entry) => {
|
|
12
|
-
const formatter = entry.allDay ? dateFormatter : dateTimeFormatter;
|
|
13
|
-
const start = formatter.format(new Date(entry.startAt));
|
|
14
|
-
if (!entry.endAt) {
|
|
15
|
-
return start;
|
|
16
|
-
}
|
|
17
|
-
return `${start} - ${formatter.format(new Date(entry.endAt))}`;
|
|
18
|
-
};
|
|
19
|
-
export const openCalendarEntry = (root, view, entry, target, options) => {
|
|
20
|
-
if (entry.kind === 'row') {
|
|
21
|
-
options?.selectEntry?.(entry.id);
|
|
22
|
-
root.openDetailPanel({
|
|
23
|
-
view,
|
|
24
|
-
rowId: entry.rowId,
|
|
25
|
-
onClose: () => options?.selectEntry?.(undefined),
|
|
26
|
-
});
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
popMenu(popupTargetFromElement(target), {
|
|
30
|
-
options: {
|
|
31
|
-
items: [
|
|
32
|
-
() => html `
|
|
33
|
-
<div class="calendar-event-popover">
|
|
34
|
-
<div class="calendar-event-popover-title">${entry.title}</div>
|
|
35
|
-
<div class="calendar-event-popover-row">
|
|
36
|
-
<span class="calendar-event-popover-icon"
|
|
37
|
-
>${CalendarPanelIcon()}</span
|
|
38
|
-
>
|
|
39
|
-
<span>${entry.calendarName ?? 'Calendar event'}</span>
|
|
40
|
-
</div>
|
|
41
|
-
<div class="calendar-event-popover-row">
|
|
42
|
-
<span class="calendar-event-popover-icon">${DateTimeIcon()}</span>
|
|
43
|
-
<span>${formatEntryTime(entry)}</span>
|
|
44
|
-
</div>
|
|
45
|
-
${entry.location
|
|
46
|
-
? html `<div class="calendar-event-popover-row">
|
|
47
|
-
<span class="calendar-event-popover-icon">${PinIcon()}</span>
|
|
48
|
-
<span>${entry.location}</span>
|
|
49
|
-
</div>`
|
|
50
|
-
: ''}
|
|
51
|
-
${entry.description
|
|
52
|
-
? html `<div class="calendar-event-popover-row">
|
|
53
|
-
<span class="calendar-event-popover-icon">${TextIcon()}</span>
|
|
54
|
-
<span class="calendar-event-popover-description"
|
|
55
|
-
>${entry.description}</span
|
|
56
|
-
>
|
|
57
|
-
</div>`
|
|
58
|
-
: ''}
|
|
59
|
-
</div>
|
|
60
|
-
`,
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { DndController } from '../../../../std/index.js';
|
|
2
|
-
import type { CalendarEntry, CalendarRowEntry } from '../types.js';
|
|
3
|
-
export type CalendarDndEntity = {
|
|
4
|
-
type: 'calendar-entry';
|
|
5
|
-
entryId: string;
|
|
6
|
-
} | {
|
|
7
|
-
type: 'doc';
|
|
8
|
-
docId: string;
|
|
9
|
-
};
|
|
10
|
-
export declare const getCalendarDndEntity: (data: unknown) => CalendarDndEntity | undefined;
|
|
11
|
-
export type CalendarDndCallbacks = {
|
|
12
|
-
getEntry: (entryId: string) => CalendarEntry | undefined;
|
|
13
|
-
canDragEntry: () => boolean;
|
|
14
|
-
canDrop: (entity: CalendarDndEntity) => boolean;
|
|
15
|
-
onEntryDragStart: (entry: CalendarRowEntry) => void;
|
|
16
|
-
onEntryDragEnd: () => void;
|
|
17
|
-
onDropTargetChange: (date: number | undefined, entity?: CalendarDndEntity) => void;
|
|
18
|
-
onDrop: (entity: CalendarDndEntity, date: number) => void;
|
|
19
|
-
};
|
|
20
|
-
export declare class CalendarDnd {
|
|
21
|
-
private readonly dnd;
|
|
22
|
-
private readonly callbacks;
|
|
23
|
-
private readonly entryCleanups;
|
|
24
|
-
private rootCleanup?;
|
|
25
|
-
constructor(dnd: DndController | undefined, callbacks: CalendarDndCallbacks);
|
|
26
|
-
bindRoot(element?: Element): void;
|
|
27
|
-
bindEntry(key: string, entry: CalendarEntry, element?: Element, disabled?: boolean): void;
|
|
28
|
-
cleanup(): void;
|
|
29
|
-
private cleanupEntry;
|
|
30
|
-
private cleanupRoot;
|
|
31
|
-
private updateDropTarget;
|
|
32
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { getCalendarDateFromPoint } from './hit-test.js';
|
|
2
|
-
const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
3
|
-
export const getCalendarDndEntity = (data) => {
|
|
4
|
-
if (!isRecord(data)) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
const bsEntity = data.bsEntity;
|
|
8
|
-
if (isRecord(bsEntity)) {
|
|
9
|
-
if (bsEntity.type === 'calendar-entry' &&
|
|
10
|
-
typeof bsEntity.entryId === 'string') {
|
|
11
|
-
return {
|
|
12
|
-
type: 'calendar-entry',
|
|
13
|
-
entryId: bsEntity.entryId,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
if (bsEntity.type === 'doc' && typeof bsEntity.docId === 'string') {
|
|
17
|
-
return {
|
|
18
|
-
type: 'doc',
|
|
19
|
-
docId: bsEntity.docId,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const entity = data.entity;
|
|
24
|
-
if (isRecord(entity) &&
|
|
25
|
-
entity.type === 'doc' &&
|
|
26
|
-
typeof entity.id === 'string') {
|
|
27
|
-
return {
|
|
28
|
-
type: 'doc',
|
|
29
|
-
docId: entity.id,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return;
|
|
33
|
-
};
|
|
34
|
-
export class CalendarDnd {
|
|
35
|
-
constructor(dnd, callbacks) {
|
|
36
|
-
this.dnd = dnd;
|
|
37
|
-
this.callbacks = callbacks;
|
|
38
|
-
this.entryCleanups = new Map();
|
|
39
|
-
}
|
|
40
|
-
bindRoot(element) {
|
|
41
|
-
if (!this.dnd || !(element instanceof HTMLElement)) {
|
|
42
|
-
this.cleanupRoot();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (this.rootCleanup?.element === element) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
this.cleanupRoot();
|
|
49
|
-
const cleanup = this.dnd.dropTarget({
|
|
50
|
-
element,
|
|
51
|
-
getIsSticky: () => true,
|
|
52
|
-
setDropData: ({ input }) => ({
|
|
53
|
-
date: getCalendarDateFromPoint(element, input.clientX, input.clientY),
|
|
54
|
-
}),
|
|
55
|
-
canDrop: ({ source, input }) => {
|
|
56
|
-
const entity = getCalendarDndEntity(source.data);
|
|
57
|
-
const date = getCalendarDateFromPoint(element, input.clientX, input.clientY);
|
|
58
|
-
return entity && date !== undefined
|
|
59
|
-
? this.callbacks.canDrop(entity)
|
|
60
|
-
: false;
|
|
61
|
-
},
|
|
62
|
-
onDrag: ({ source, location }) => {
|
|
63
|
-
this.updateDropTarget(element, source.data, location.current.input);
|
|
64
|
-
},
|
|
65
|
-
onDragEnter: ({ source, location }) => {
|
|
66
|
-
this.updateDropTarget(element, source.data, location.current.input);
|
|
67
|
-
},
|
|
68
|
-
onDragLeave: () => {
|
|
69
|
-
this.callbacks.onDropTargetChange(undefined);
|
|
70
|
-
},
|
|
71
|
-
onDrop: ({ source, location }) => {
|
|
72
|
-
const entity = getCalendarDndEntity(source.data);
|
|
73
|
-
const date = getCalendarDateFromPoint(element, location.current.input.clientX, location.current.input.clientY);
|
|
74
|
-
if (entity && date !== undefined && this.callbacks.canDrop(entity)) {
|
|
75
|
-
this.callbacks.onDrop(entity, date);
|
|
76
|
-
}
|
|
77
|
-
this.callbacks.onDropTargetChange(undefined);
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
this.rootCleanup = { element, cleanup };
|
|
81
|
-
}
|
|
82
|
-
bindEntry(key, entry, element, disabled = false) {
|
|
83
|
-
if (!this.dnd ||
|
|
84
|
-
!(element instanceof HTMLElement) ||
|
|
85
|
-
entry.kind !== 'row' ||
|
|
86
|
-
disabled) {
|
|
87
|
-
this.cleanupEntry(key);
|
|
88
|
-
if (element instanceof HTMLElement) {
|
|
89
|
-
element.setAttribute('draggable', 'false');
|
|
90
|
-
}
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const current = this.entryCleanups.get(key);
|
|
94
|
-
if (current?.element === element) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
this.cleanupEntry(key);
|
|
98
|
-
const cleanup = this.dnd.draggable({
|
|
99
|
-
element,
|
|
100
|
-
canDrag: () => {
|
|
101
|
-
const currentEntry = this.callbacks.getEntry(entry.id);
|
|
102
|
-
return currentEntry?.kind === 'row'
|
|
103
|
-
? this.callbacks.canDragEntry()
|
|
104
|
-
: false;
|
|
105
|
-
},
|
|
106
|
-
setDragData: () => ({
|
|
107
|
-
type: 'calendar-entry',
|
|
108
|
-
entryId: entry.id,
|
|
109
|
-
}),
|
|
110
|
-
setDragPreview: ({ container, setOffset }) => {
|
|
111
|
-
const currentEntry = this.callbacks.getEntry(entry.id);
|
|
112
|
-
const preview = document.createElement('div');
|
|
113
|
-
preview.textContent = currentEntry?.title || 'Untitled';
|
|
114
|
-
preview.style.cssText =
|
|
115
|
-
'padding:0 6px;height:22px;line-height:22px;border-radius:4px;' +
|
|
116
|
-
'font-size:12px;white-space:nowrap;overflow:hidden;' +
|
|
117
|
-
'background:var(--affine-hover-color,#f5f5f5);' +
|
|
118
|
-
'color:var(--affine-text-primary-color,#333);' +
|
|
119
|
-
'max-width:140px;text-overflow:ellipsis;pointer-events:none;';
|
|
120
|
-
container.append(preview);
|
|
121
|
-
setOffset({ x: 10, y: 11 });
|
|
122
|
-
},
|
|
123
|
-
onDragStart: () => {
|
|
124
|
-
const currentEntry = this.callbacks.getEntry(entry.id);
|
|
125
|
-
if (currentEntry?.kind === 'row') {
|
|
126
|
-
this.callbacks.onEntryDragStart(currentEntry);
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
onDrop: () => {
|
|
130
|
-
this.callbacks.onEntryDragEnd();
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
this.entryCleanups.set(key, { element, cleanup });
|
|
134
|
-
}
|
|
135
|
-
cleanup() {
|
|
136
|
-
this.cleanupRoot();
|
|
137
|
-
for (const key of this.entryCleanups.keys()) {
|
|
138
|
-
this.cleanupEntry(key);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
cleanupEntry(key) {
|
|
142
|
-
this.entryCleanups.get(key)?.cleanup();
|
|
143
|
-
this.entryCleanups.delete(key);
|
|
144
|
-
}
|
|
145
|
-
cleanupRoot() {
|
|
146
|
-
this.rootCleanup?.cleanup();
|
|
147
|
-
this.rootCleanup = undefined;
|
|
148
|
-
}
|
|
149
|
-
updateDropTarget(root, data, input) {
|
|
150
|
-
const entity = getCalendarDndEntity(data);
|
|
151
|
-
const date = getCalendarDateFromPoint(root, input.clientX, input.clientY);
|
|
152
|
-
if (entity && date !== undefined && this.callbacks.canDrop(entity)) {
|
|
153
|
-
this.callbacks.onDropTargetChange(date, entity);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
this.callbacks.onDropTargetChange(undefined);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function pcEffects(): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getCalendarDateFromPoint: (root: HTMLElement, clientX: number, clientY: number) => number | undefined;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const getCalendarDateFromPoint = (root, clientX, clientY) => {
|
|
2
|
-
const doc = root.ownerDocument;
|
|
3
|
-
const hitStack = doc.elementsFromPoint(clientX, clientY);
|
|
4
|
-
for (const element of hitStack) {
|
|
5
|
-
const day = element.closest('.calendar-day[data-date]');
|
|
6
|
-
if (day && root.contains(day)) {
|
|
7
|
-
return Number(day.dataset['date']);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
for (const element of hitStack) {
|
|
11
|
-
const week = element.closest('.calendar-week') ??
|
|
12
|
-
element.closest('.calendar-segments')?.parentElement;
|
|
13
|
-
if (week && root.contains(week)) {
|
|
14
|
-
const days = week.querySelectorAll('.calendar-day');
|
|
15
|
-
for (const day of days) {
|
|
16
|
-
const rect = day.getBoundingClientRect();
|
|
17
|
-
if (clientX >= rect.left &&
|
|
18
|
-
clientX < rect.right &&
|
|
19
|
-
clientY >= rect.top &&
|
|
20
|
-
clientY < rect.bottom &&
|
|
21
|
-
day.dataset['date']) {
|
|
22
|
-
return Number(day.dataset['date']);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return;
|
|
28
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const calendarViewStyles: import("lit").CSSResult;
|