@formicoidea/labre-core 0.47.1 → 0.49.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/dist/_pkgs/affine-block-data-view/configs/slash-menu.js +3 -1
- package/dist/_pkgs/affine-block-data-view/view.d.ts +17 -1
- package/dist/_pkgs/affine-block-data-view/view.js +21 -2
- package/dist/_pkgs/affine-block-database/commands.d.ts +2 -2
- package/dist/_pkgs/affine-block-database/commands.js +3 -3
- package/dist/_pkgs/affine-block-database/components/values-banner.d.ts +28 -0
- package/dist/_pkgs/affine-block-database/components/values-banner.js +199 -0
- package/dist/_pkgs/affine-block-database/configs/slash-menu.d.ts +6 -1
- package/dist/_pkgs/affine-block-database/configs/slash-menu.js +57 -70
- package/dist/_pkgs/affine-block-database/data-source.d.ts +9 -5
- package/dist/_pkgs/affine-block-database/data-source.js +11 -7
- package/dist/_pkgs/affine-block-database/database-block-styles.d.ts +2 -0
- package/dist/_pkgs/affine-block-database/database-block-styles.js +15 -0
- package/dist/_pkgs/affine-block-database/database-block.d.ts +23 -0
- package/dist/_pkgs/affine-block-database/database-block.js +141 -19
- package/dist/_pkgs/affine-block-database/effects.js +2 -0
- package/dist/_pkgs/affine-block-database/external-data-source.d.ts +69 -2
- package/dist/_pkgs/affine-block-database/external-data-source.js +88 -16
- package/dist/_pkgs/affine-block-database/index.d.ts +2 -0
- package/dist/_pkgs/affine-block-database/index.js +2 -0
- package/dist/_pkgs/affine-block-database/linked-view.d.ts +38 -0
- package/dist/_pkgs/affine-block-database/linked-view.js +109 -0
- package/dist/_pkgs/affine-block-database/properties/index.d.ts +2 -0
- package/dist/_pkgs/affine-block-database/properties/index.js +2 -0
- package/dist/_pkgs/affine-block-database/properties/text/hosted.d.ts +15 -0
- package/dist/_pkgs/affine-block-database/properties/text/hosted.js +24 -0
- package/dist/_pkgs/affine-block-database/properties/title/hosted.d.ts +16 -0
- package/dist/_pkgs/affine-block-database/properties/title/hosted.js +42 -0
- package/dist/_pkgs/affine-block-database/service/index.d.ts +3 -0
- package/dist/_pkgs/affine-block-database/service/index.js +3 -0
- package/dist/_pkgs/affine-block-database/service/new-row-menu.d.ts +49 -0
- package/dist/_pkgs/affine-block-database/service/new-row-menu.js +21 -0
- package/dist/_pkgs/affine-block-database/service/open-row.d.ts +77 -0
- package/dist/_pkgs/affine-block-database/service/open-row.js +62 -0
- package/dist/_pkgs/affine-block-database/service/properties-panel.d.ts +23 -0
- package/dist/_pkgs/affine-block-database/service/properties-panel.js +33 -0
- package/dist/_pkgs/affine-block-database/translations.d.ts +10 -0
- package/dist/_pkgs/affine-block-database/translations.js +35 -0
- package/dist/_pkgs/affine-block-database/view-creation.d.ts +10 -0
- package/dist/_pkgs/affine-block-database/view-creation.js +14 -0
- package/dist/_pkgs/affine-block-database/view.d.ts +31 -1
- package/dist/_pkgs/affine-block-database/view.js +48 -4
- package/dist/_pkgs/affine-block-database/views/index.d.ts +30 -3
- package/dist/_pkgs/affine-block-database/views/index.js +44 -3
- package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/configs/new-doc.d.ts +25 -0
- package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/configs/new-doc.js +71 -0
- package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/configs/slash-menu.js +3 -11
- package/dist/_pkgs/affine-components/date-picker/date-picker.d.ts +20 -0
- package/dist/_pkgs/affine-components/date-picker/date-picker.js +60 -26
- package/dist/_pkgs/affine-components/date-picker/style.js +1 -0
- package/dist/_pkgs/affine-components/translations.d.ts +4 -0
- package/dist/_pkgs/affine-components/translations.js +26 -0
- package/dist/_pkgs/affine-fragment-doc-title/doc-title.d.ts +18 -0
- package/dist/_pkgs/affine-fragment-doc-title/doc-title.js +41 -2
- package/dist/_pkgs/affine-fragment-doc-title/index.d.ts +1 -1
- package/dist/_pkgs/affine-fragment-doc-title/index.js +1 -1
- package/dist/_pkgs/affine-fragment-doc-title/title-band/band-cell.d.ts +30 -0
- package/dist/_pkgs/affine-fragment-doc-title/title-band/band-cell.js +137 -0
- package/dist/_pkgs/affine-fragment-doc-title/title-band/format.d.ts +7 -19
- package/dist/_pkgs/affine-fragment-doc-title/title-band/format.js +0 -38
- package/dist/_pkgs/affine-fragment-doc-title/title-band/show-here.d.ts +19 -0
- package/dist/_pkgs/affine-fragment-doc-title/title-band/show-here.js +61 -0
- package/dist/_pkgs/affine-fragment-doc-title/title-band/title-band.d.ts +33 -18
- package/dist/_pkgs/affine-fragment-doc-title/title-band/title-band.js +263 -205
- package/dist/_pkgs/affine-fragment-doc-title/translations.d.ts +7 -4
- package/dist/_pkgs/affine-fragment-doc-title/translations.js +12 -9
- package/dist/_pkgs/affine-model/blocks/database/types.d.ts +16 -0
- package/dist/_pkgs/affine-model/blocks/database/types.js +5 -1
- package/dist/_pkgs/affine-shared/services/data-source-picker-service.d.ts +139 -0
- package/dist/_pkgs/affine-shared/services/data-source-picker-service.js +22 -0
- package/dist/_pkgs/affine-shared/services/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/services/index.js +1 -0
- package/dist/_pkgs/affine-shared/services/linked-doc-creation-service.d.ts +15 -6
- package/dist/_pkgs/affine-shared/services/telemetry-service/database.d.ts +59 -0
- package/dist/_pkgs/affine-shared/services/title-band-service.d.ts +34 -7
- package/dist/_pkgs/affine-shared/utils/model/doc.d.ts +10 -2
- package/dist/_pkgs/affine-shared/utils/model/doc.js +17 -7
- package/dist/_pkgs/data-view/core/component/cell-status/cell-status-css.d.ts +2 -0
- package/dist/_pkgs/data-view/core/component/cell-status/cell-status-css.js +16 -0
- package/dist/_pkgs/data-view/core/component/cell-status/cell-status.d.ts +10 -0
- package/dist/_pkgs/data-view/core/component/cell-status/cell-status.js +23 -0
- package/dist/_pkgs/data-view/core/component/index.d.ts +1 -0
- package/dist/_pkgs/data-view/core/component/index.js +1 -0
- package/dist/_pkgs/data-view/core/component/overflow/fit.d.ts +26 -0
- package/dist/_pkgs/data-view/core/component/overflow/fit.js +48 -0
- package/dist/_pkgs/data-view/core/component/overflow/overflow.d.ts +26 -3
- package/dist/_pkgs/data-view/core/component/overflow/overflow.js +84 -31
- package/dist/_pkgs/data-view/core/component/tags/colors.d.ts +7 -0
- package/dist/_pkgs/data-view/core/component/tags/colors.js +22 -10
- package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.d.ts +25 -2
- package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.js +81 -32
- package/dist/_pkgs/data-view/core/data-source/base.d.ts +5 -1
- package/dist/_pkgs/data-view/core/data-source/base.js +7 -1
- package/dist/_pkgs/data-view/core/data-source/hydration.d.ts +44 -0
- package/dist/_pkgs/data-view/core/data-source/hydration.js +31 -0
- package/dist/_pkgs/data-view/core/data-source/index.d.ts +1 -0
- package/dist/_pkgs/data-view/core/data-source/index.js +1 -0
- package/dist/_pkgs/data-view/core/data-view.d.ts +22 -2
- package/dist/_pkgs/data-view/core/data-view.js +14 -0
- package/dist/_pkgs/data-view/core/effect.js +4 -0
- package/dist/_pkgs/data-view/core/group-by/collapsed-state.d.ts +3 -0
- package/dist/_pkgs/data-view/core/group-by/collapsed-state.js +59 -0
- package/dist/_pkgs/data-view/core/group-by/group-properties.d.ts +21 -0
- package/dist/_pkgs/data-view/core/group-by/group-properties.js +38 -0
- package/dist/_pkgs/data-view/core/group-by/group-title.js +4 -0
- package/dist/_pkgs/data-view/core/group-by/group-visibility.d.ts +40 -0
- package/dist/_pkgs/data-view/core/group-by/group-visibility.js +291 -0
- package/dist/_pkgs/data-view/core/group-by/setting.d.ts +11 -3
- package/dist/_pkgs/data-view/core/group-by/setting.js +81 -8
- package/dist/_pkgs/data-view/core/group-by/trait.d.ts +22 -0
- package/dist/_pkgs/data-view/core/group-by/trait.js +62 -1
- package/dist/_pkgs/data-view/core/index.d.ts +3 -0
- package/dist/_pkgs/data-view/core/index.js +3 -0
- package/dist/_pkgs/data-view/core/property/base-cell.d.ts +15 -1
- package/dist/_pkgs/data-view/core/property/base-cell.js +28 -3
- package/dist/_pkgs/data-view/core/property/index.d.ts +1 -0
- package/dist/_pkgs/data-view/core/property/index.js +1 -0
- package/dist/_pkgs/data-view/core/property/standalone-cell.d.ts +109 -0
- package/dist/_pkgs/data-view/core/property/standalone-cell.js +324 -0
- package/dist/_pkgs/data-view/core/telemetry.d.ts +16 -0
- package/dist/_pkgs/data-view/core/telemetry.js +22 -0
- package/dist/_pkgs/data-view/core/utils/new-tab-click.d.ts +2 -0
- package/dist/_pkgs/data-view/core/utils/new-tab-click.js +4 -0
- package/dist/_pkgs/data-view/core/utils/wording.d.ts +11 -0
- package/dist/_pkgs/data-view/core/utils/wording.js +9 -0
- package/dist/_pkgs/data-view/core/view/data-view.d.ts +7 -0
- package/dist/_pkgs/data-view/core/view/default-name.d.ts +10 -0
- package/dist/_pkgs/data-view/core/view/default-name.js +14 -0
- package/dist/_pkgs/data-view/core/view/index.d.ts +2 -0
- package/dist/_pkgs/data-view/core/view/index.js +2 -0
- package/dist/_pkgs/data-view/core/view/open-in.d.ts +27 -0
- package/dist/_pkgs/data-view/core/view/open-in.js +39 -0
- package/dist/_pkgs/data-view/core/view-manager/cell.d.ts +5 -0
- package/dist/_pkgs/data-view/core/view-manager/cell.js +11 -0
- package/dist/_pkgs/data-view/core/view-manager/index.d.ts +3 -0
- package/dist/_pkgs/data-view/core/view-manager/index.js +3 -0
- package/dist/_pkgs/data-view/core/view-manager/new-row-menu-opener.d.ts +18 -0
- package/dist/_pkgs/data-view/core/view-manager/new-row-menu-opener.js +2 -0
- package/dist/_pkgs/data-view/core/view-manager/properties-panel-opener.d.ts +8 -0
- package/dist/_pkgs/data-view/core/view-manager/properties-panel-opener.js +9 -0
- package/dist/_pkgs/data-view/core/view-manager/property.d.ts +14 -0
- package/dist/_pkgs/data-view/core/view-manager/single-view.d.ts +28 -1
- package/dist/_pkgs/data-view/core/view-manager/single-view.js +45 -1
- package/dist/_pkgs/data-view/core/view-manager/view-creation.d.ts +49 -0
- package/dist/_pkgs/data-view/core/view-manager/view-creation.js +40 -0
- package/dist/_pkgs/data-view/core/view-manager/view-manager.d.ts +6 -2
- package/dist/_pkgs/data-view/core/view-manager/view-manager.js +2 -2
- package/dist/_pkgs/data-view/property-presets/date/cell-renderer.d.ts +2 -0
- package/dist/_pkgs/data-view/property-presets/date/cell-renderer.js +11 -2
- package/dist/_pkgs/data-view/property-presets/multi-select/cell-renderer.js +3 -1
- package/dist/_pkgs/data-view/property-presets/select/cell-renderer.js +3 -1
- package/dist/_pkgs/data-view/property-presets/text/cell-renderer.js +3 -1
- package/dist/_pkgs/data-view/translations.d.ts +55 -0
- package/dist/_pkgs/data-view/translations.js +181 -0
- package/dist/_pkgs/data-view/view-presets/calendar/define.js +3 -1
- package/dist/_pkgs/data-view/view-presets/convert.js +2 -0
- package/dist/_pkgs/data-view/view-presets/effect.js +4 -0
- package/dist/_pkgs/data-view/view-presets/flat/flat-converts.d.ts +2 -0
- package/dist/_pkgs/data-view/view-presets/flat/flat-converts.js +35 -0
- package/dist/_pkgs/data-view/view-presets/flat/flat-view-manager.d.ts +79 -0
- package/dist/_pkgs/data-view/view-presets/flat/flat-view-manager.js +194 -0
- package/dist/_pkgs/data-view/view-presets/flat/flat-view-ui.d.ts +56 -0
- package/dist/_pkgs/data-view/view-presets/flat/flat-view-ui.js +266 -0
- package/dist/_pkgs/data-view/view-presets/gallery/define.d.ts +14 -0
- package/dist/_pkgs/data-view/view-presets/gallery/define.js +15 -0
- package/dist/_pkgs/data-view/view-presets/gallery/effect.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/gallery/effect.js +4 -0
- package/dist/_pkgs/data-view/view-presets/gallery/gallery-view.d.ts +27 -0
- package/dist/_pkgs/data-view/view-presets/gallery/gallery-view.js +179 -0
- package/dist/_pkgs/data-view/view-presets/gallery/index.d.ts +2 -0
- package/dist/_pkgs/data-view/view-presets/gallery/index.js +2 -0
- package/dist/_pkgs/data-view/view-presets/gallery/renderer.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/gallery/renderer.js +11 -0
- package/dist/_pkgs/data-view/view-presets/index.d.ts +5 -0
- package/dist/_pkgs/data-view/view-presets/index.js +7 -0
- package/dist/_pkgs/data-view/view-presets/kanban/define.js +3 -1
- package/dist/_pkgs/data-view/view-presets/kanban/kanban-view-manager.js +5 -53
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/card.js +8 -1
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/cell.js +6 -1
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/group.d.ts +4 -2
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/group.js +52 -6
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/kanban-view-ui-logic.js +5 -1
- package/dist/_pkgs/data-view/view-presets/kanban/pc/card.js +2 -0
- package/dist/_pkgs/data-view/view-presets/kanban/pc/cell.js +4 -0
- package/dist/_pkgs/data-view/view-presets/kanban/pc/group.d.ts +4 -2
- package/dist/_pkgs/data-view/view-presets/kanban/pc/group.js +51 -6
- package/dist/_pkgs/data-view/view-presets/kanban/pc/kanban-view-ui-logic.js +5 -1
- package/dist/_pkgs/data-view/view-presets/list/define.d.ts +14 -0
- package/dist/_pkgs/data-view/view-presets/list/define.js +15 -0
- package/dist/_pkgs/data-view/view-presets/list/effect.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/list/effect.js +4 -0
- package/dist/_pkgs/data-view/view-presets/list/index.d.ts +2 -0
- package/dist/_pkgs/data-view/view-presets/list/index.js +2 -0
- package/dist/_pkgs/data-view/view-presets/list/list-view.d.ts +24 -0
- package/dist/_pkgs/data-view/view-presets/list/list-view.js +194 -0
- package/dist/_pkgs/data-view/view-presets/list/renderer.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/list/renderer.js +11 -0
- package/dist/_pkgs/data-view/view-presets/table/collapsed-state.d.ts +3 -14
- package/dist/_pkgs/data-view/view-presets/table/collapsed-state.js +6 -30
- package/dist/_pkgs/data-view/view-presets/table/consts.d.ts +2 -0
- package/dist/_pkgs/data-view/view-presets/table/consts.js +2 -0
- package/dist/_pkgs/data-view/view-presets/table/define.js +3 -1
- package/dist/_pkgs/data-view/view-presets/table/mobile/cell.js +4 -1
- package/dist/_pkgs/data-view/view-presets/table/mobile/column-header.js +2 -2
- package/dist/_pkgs/data-view/view-presets/table/mobile/group.d.ts +3 -1
- package/dist/_pkgs/data-view/view-presets/table/mobile/group.js +20 -5
- package/dist/_pkgs/data-view/view-presets/table/mobile/row.js +10 -2
- package/dist/_pkgs/data-view/view-presets/table/mobile/table-view-ui-logic.js +4 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/cell.js +4 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/controller/hotkeys.js +1 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/group.d.ts +3 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/group.js +20 -5
- package/dist/_pkgs/data-view/view-presets/table/pc/menu.d.ts +1 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/menu.js +2 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/row/row.js +3 -2
- package/dist/_pkgs/data-view/view-presets/table/pc/table-view-ui-logic.js +4 -1
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/hotkeys.js +1 -1
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/bottom/stats/column-stats-column.js +5 -1
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/group-title.js +22 -19
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/cell.js +4 -1
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/table-view-ui-logic.js +7 -2
- package/dist/_pkgs/data-view/view-presets/table/stats/column-stats-column.js +5 -1
- package/dist/_pkgs/data-view/view-presets/table/table-view-manager.js +5 -53
- package/dist/_pkgs/data-view/widget-presets/tools/presets/table-add-row/add-row.d.ts +1 -0
- package/dist/_pkgs/data-view/widget-presets/tools/presets/table-add-row/add-row.js +60 -2
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-options.d.ts +18 -1
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-options.js +121 -124
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-settings.d.ts +43 -0
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-settings.js +187 -0
- package/dist/_pkgs/data-view/widget-presets/views-bar/views-view.d.ts +36 -3
- package/dist/_pkgs/data-view/widget-presets/views-bar/views-view.js +187 -59
- package/dist/extensions/view.d.ts +2 -2
- package/dist/extensions/view.js +10 -3
- package/dist/flags.d.ts +8 -4
- package/dist/flags.js +8 -4
- package/dist/frameworks.d.ts +27 -0
- package/dist/frameworks.js +28 -0
- package/dist/translations.js +13 -1
- package/package.json +5 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { calendarEffects } from './calendar/effect.js';
|
|
2
|
+
import { galleryEffects } from './gallery/effect.js';
|
|
2
3
|
import { kanbanEffects } from './kanban/effect.js';
|
|
4
|
+
import { listEffects } from './list/effect.js';
|
|
3
5
|
import { tableEffects } from './table/effect.js';
|
|
4
6
|
export function viewPresetsEffects() {
|
|
5
7
|
calendarEffects();
|
|
8
|
+
galleryEffects();
|
|
6
9
|
kanbanEffects();
|
|
10
|
+
listEffects();
|
|
7
11
|
tableEffects();
|
|
8
12
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { calendarViewModel } from '../calendar/define.js';
|
|
2
|
+
import { galleryViewModel } from '../gallery/define.js';
|
|
3
|
+
import { kanbanViewModel } from '../kanban/define.js';
|
|
4
|
+
import { listViewModel } from '../list/define.js';
|
|
5
|
+
import { tableViewModel } from '../table/define.js';
|
|
6
|
+
/**
|
|
7
|
+
* A layout switch into or out of a gallery or a list keeps the filter, the
|
|
8
|
+
* sort and the grouping (B8: every layout groups, as table and kanban already
|
|
9
|
+
* kept `groupBy` between them); the properties shown are the target layout's
|
|
10
|
+
* own default, as when Notion switches a view's layout. A source with no
|
|
11
|
+
* grouping leaves the target's default: a kanban still gets its own. Calendar
|
|
12
|
+
* is a source only: nothing converts into it (ADR 0035 §6).
|
|
13
|
+
*/
|
|
14
|
+
const keepFilterSortAndGroup = (data) => {
|
|
15
|
+
const { filter, sort, groupBy } = data;
|
|
16
|
+
// View data is an open record per mode: the target model types the rest.
|
|
17
|
+
return {
|
|
18
|
+
...(filter ? { filter } : {}),
|
|
19
|
+
...(sort ? { sort } : {}),
|
|
20
|
+
...(groupBy ? { groupBy } : {}),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const flatModels = [galleryViewModel, listViewModel];
|
|
24
|
+
const convert = (from, to) => ({
|
|
25
|
+
from,
|
|
26
|
+
to,
|
|
27
|
+
convert: keepFilterSortAndGroup,
|
|
28
|
+
});
|
|
29
|
+
export const flatViewConverts = [
|
|
30
|
+
...[tableViewModel, kanbanViewModel, calendarViewModel, ...flatModels]
|
|
31
|
+
.flatMap(from => flatModels.map(to => [from.type, to.type]))
|
|
32
|
+
.filter(([from, to]) => from !== to)
|
|
33
|
+
.map(([from, to]) => convert(from, to)),
|
|
34
|
+
...flatModels.flatMap(from => [tableViewModel, kanbanViewModel].map(to => convert(from.type, to.type))),
|
|
35
|
+
];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type InsertToPosition } from '../../../affine-shared/utils/index.js';
|
|
2
|
+
import type { GroupBy, GroupProperty } from '../../core/common/types.js';
|
|
3
|
+
import { FilterTrait } from '../../core/filter/trait.js';
|
|
4
|
+
import type { FilterGroup } from '../../core/filter/types.js';
|
|
5
|
+
import { GroupTrait } from '../../core/group-by/trait.js';
|
|
6
|
+
import type { Sort } from '../../core/sort/types.js';
|
|
7
|
+
import type { BasicViewDataType } from '../../core/view/data-view.js';
|
|
8
|
+
import { PropertyBase } from '../../core/view-manager/property.js';
|
|
9
|
+
import type { Row } from '../../core/view-manager/row.js';
|
|
10
|
+
import { SingleViewBase } from '../../core/view-manager/single-view.js';
|
|
11
|
+
import type { ViewManager } from '../../core/view-manager/view-manager.js';
|
|
12
|
+
/**
|
|
13
|
+
* A property's place in a gallery or list view: the shape table and kanban
|
|
14
|
+
* already store, `columns[].hide` (ADR 0035 §8), so per-view visibility reads
|
|
15
|
+
* and writes the same way in every preset.
|
|
16
|
+
*/
|
|
17
|
+
export type FlatViewColumn = {
|
|
18
|
+
id: string;
|
|
19
|
+
hide?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type FlatViewDataType<Mode extends string = string> = BasicViewDataType<Mode, {
|
|
22
|
+
columns: FlatViewColumn[];
|
|
23
|
+
filter: FilterGroup;
|
|
24
|
+
sort?: Sort;
|
|
25
|
+
groupBy?: GroupBy;
|
|
26
|
+
groupProperties?: GroupProperty[];
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* What a new gallery or list view stores: its title shown, every other
|
|
30
|
+
* property hidden until the user shows it, as Notion does for these two
|
|
31
|
+
* layouts. Written once, by the gesture that creates the view; a stored view
|
|
32
|
+
* is never rewritten on load.
|
|
33
|
+
*/
|
|
34
|
+
export declare const flatViewDefaultData: (viewManager: ViewManager) => {
|
|
35
|
+
columns: FlatViewColumn[];
|
|
36
|
+
filter: FilterGroup;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The manager both ungrouped presets share, gallery and list (ADR 0035 §1,
|
|
40
|
+
* B6 and B7): the table's per-view property order and visibility, filter and
|
|
41
|
+
* sort, and its row creation from the filter's default values, without the
|
|
42
|
+
* table's widths and statistics. Grouping (B8) is the table's too: the same
|
|
43
|
+
* stored `groupBy` and `groupProperties`, the same trait and ops.
|
|
44
|
+
*/
|
|
45
|
+
export declare abstract class FlatSingleView<ViewData extends FlatViewDataType = FlatViewDataType> extends SingleViewBase<ViewData> {
|
|
46
|
+
propertiesRaw$: import("@preact/signals-core").ReadonlySignal<FlatProperty[]>;
|
|
47
|
+
properties$: import("@preact/signals-core").ReadonlySignal<FlatProperty[]>;
|
|
48
|
+
detailProperties$: import("@preact/signals-core").ReadonlySignal<FlatProperty[]>;
|
|
49
|
+
/** The title, drawn first on a card or a row whatever the columns say. */
|
|
50
|
+
titleProperty$: import("@preact/signals-core").ReadonlySignal<FlatProperty | undefined>;
|
|
51
|
+
/** The visible properties drawn after the title. */
|
|
52
|
+
bodyProperties$: import("@preact/signals-core").ReadonlySignal<FlatProperty[]>;
|
|
53
|
+
mainProperties$: import("@preact/signals-core").ReadonlySignal<{
|
|
54
|
+
titleColumn: string | undefined;
|
|
55
|
+
iconColumn: string;
|
|
56
|
+
}>;
|
|
57
|
+
readonly$: import("@preact/signals-core").ReadonlySignal<boolean>;
|
|
58
|
+
private readonly filter$;
|
|
59
|
+
private readonly sortList$;
|
|
60
|
+
filterTrait: FilterTrait;
|
|
61
|
+
private readonly sortManager;
|
|
62
|
+
private readonly groupBy$;
|
|
63
|
+
groupTrait: GroupTrait;
|
|
64
|
+
/** Every property's column entry, so a first hide stores the full order. */
|
|
65
|
+
readonly columnsData$: import("@preact/signals-core").ReadonlySignal<FlatViewColumn[]>;
|
|
66
|
+
isShow(rowId: string): boolean;
|
|
67
|
+
propertyGetOrCreate(propertyId: string): FlatProperty;
|
|
68
|
+
/** A row added from a group's "New page" takes that group's value. */
|
|
69
|
+
rowAdd(insertPosition: InsertToPosition | number, groupKey?: string): string;
|
|
70
|
+
protected rowsMapping(rows: Row[]): Row[];
|
|
71
|
+
}
|
|
72
|
+
export declare class FlatProperty extends PropertyBase {
|
|
73
|
+
private readonly flatView;
|
|
74
|
+
hide$: import("@preact/signals-core").ReadonlySignal<boolean>;
|
|
75
|
+
viewData$: import("@preact/signals-core").ReadonlySignal<FlatViewColumn | undefined>;
|
|
76
|
+
constructor(flatView: FlatSingleView, propertyId: string);
|
|
77
|
+
hideSet(hide: boolean): void;
|
|
78
|
+
move(position: InsertToPosition): void;
|
|
79
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { insertPositionToIndex, } from '../../../affine-shared/utils/index.js';
|
|
2
|
+
import { computed } from '@preact/signals-core';
|
|
3
|
+
import { evalFilter } from '../../core/filter/eval.js';
|
|
4
|
+
import { generateDefaultValues } from '../../core/filter/generate-default-values.js';
|
|
5
|
+
import { FilterTrait, filterTraitKey } from '../../core/filter/trait.js';
|
|
6
|
+
import { emptyFilterGroup } from '../../core/filter/utils.js';
|
|
7
|
+
import { groupPropertiesOps } from '../../core/group-by/group-properties.js';
|
|
8
|
+
import { GroupTrait, groupTraitKey } from '../../core/group-by/trait.js';
|
|
9
|
+
import { fromJson } from '../../core/property/utils.js';
|
|
10
|
+
import { SortManager, sortTraitKey } from '../../core/sort/manager.js';
|
|
11
|
+
import { PropertyBase } from '../../core/view-manager/property.js';
|
|
12
|
+
import { SingleViewBase } from '../../core/view-manager/single-view.js';
|
|
13
|
+
/**
|
|
14
|
+
* What a new gallery or list view stores: its title shown, every other
|
|
15
|
+
* property hidden until the user shows it, as Notion does for these two
|
|
16
|
+
* layouts. Written once, by the gesture that creates the view; a stored view
|
|
17
|
+
* is never rewritten on load.
|
|
18
|
+
*/
|
|
19
|
+
export const flatViewDefaultData = (viewManager) => {
|
|
20
|
+
const dataSource = viewManager.dataSource;
|
|
21
|
+
return {
|
|
22
|
+
columns: dataSource.properties$.value.map(id => ({
|
|
23
|
+
id,
|
|
24
|
+
hide: dataSource.propertyTypeGet(id) !== 'title',
|
|
25
|
+
})),
|
|
26
|
+
filter: { type: 'group', op: 'and', conditions: [] },
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The manager both ungrouped presets share, gallery and list (ADR 0035 §1,
|
|
31
|
+
* B6 and B7): the table's per-view property order and visibility, filter and
|
|
32
|
+
* sort, and its row creation from the filter's default values, without the
|
|
33
|
+
* table's widths and statistics. Grouping (B8) is the table's too: the same
|
|
34
|
+
* stored `groupBy` and `groupProperties`, the same trait and ops.
|
|
35
|
+
*/
|
|
36
|
+
export class FlatSingleView extends SingleViewBase {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this.propertiesRaw$ = computed(() => {
|
|
40
|
+
const needShow = new Set(this.dataSource.properties$.value);
|
|
41
|
+
const result = [];
|
|
42
|
+
this.data$.value?.columns.forEach(v => {
|
|
43
|
+
if (needShow.has(v.id)) {
|
|
44
|
+
result.push(v.id);
|
|
45
|
+
needShow.delete(v.id);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
result.push(...needShow);
|
|
49
|
+
return result.map(id => this.propertyGetOrCreate(id));
|
|
50
|
+
});
|
|
51
|
+
this.properties$ = computed(() => {
|
|
52
|
+
return this.propertiesRaw$.value.filter(property => !property.hide$.value);
|
|
53
|
+
});
|
|
54
|
+
this.detailProperties$ = computed(() => {
|
|
55
|
+
return this.propertiesRaw$.value.filter(property => property.type$.value !== 'title');
|
|
56
|
+
});
|
|
57
|
+
/** The title, drawn first on a card or a row whatever the columns say. */
|
|
58
|
+
this.titleProperty$ = computed(() => {
|
|
59
|
+
return this.properties$.value.find(property => property.type$.value === 'title');
|
|
60
|
+
});
|
|
61
|
+
/** The visible properties drawn after the title. */
|
|
62
|
+
this.bodyProperties$ = computed(() => {
|
|
63
|
+
return this.properties$.value.filter(property => property.type$.value !== 'title');
|
|
64
|
+
});
|
|
65
|
+
this.mainProperties$ = computed(() => ({
|
|
66
|
+
titleColumn: this.propertiesRaw$.value.find(property => property.type$.value === 'title')?.id,
|
|
67
|
+
iconColumn: 'type',
|
|
68
|
+
}));
|
|
69
|
+
this.readonly$ = computed(() => {
|
|
70
|
+
return this.manager.readonly$.value;
|
|
71
|
+
});
|
|
72
|
+
this.filter$ = computed(() => {
|
|
73
|
+
return this.data$.value?.filter ?? emptyFilterGroup;
|
|
74
|
+
});
|
|
75
|
+
this.sortList$ = computed(() => {
|
|
76
|
+
return this.data$.value?.sort;
|
|
77
|
+
});
|
|
78
|
+
this.filterTrait = this.traitSet(filterTraitKey, new FilterTrait(this.filter$, this, {
|
|
79
|
+
filterSet: (filter) => {
|
|
80
|
+
this.dataUpdate(() => ({ filter }));
|
|
81
|
+
},
|
|
82
|
+
}));
|
|
83
|
+
this.sortManager = this.traitSet(sortTraitKey, new SortManager(this.sortList$, this, {
|
|
84
|
+
setSortList: sortList => {
|
|
85
|
+
this.dataUpdate(data => ({
|
|
86
|
+
sort: {
|
|
87
|
+
...data.sort,
|
|
88
|
+
...sortList,
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
},
|
|
92
|
+
}));
|
|
93
|
+
this.groupBy$ = computed(() => {
|
|
94
|
+
return this.data$.value?.groupBy;
|
|
95
|
+
});
|
|
96
|
+
this.groupTrait = this.traitSet(groupTraitKey, new GroupTrait(this.groupBy$, this, {
|
|
97
|
+
groupBySet: groupBy => {
|
|
98
|
+
this.dataUpdate(() => ({ groupBy }));
|
|
99
|
+
},
|
|
100
|
+
...groupPropertiesOps(() => this.data$.value?.groupProperties ?? [], groupProperties => {
|
|
101
|
+
this.dataUpdate(() => ({ groupProperties }));
|
|
102
|
+
}),
|
|
103
|
+
}));
|
|
104
|
+
/** Every property's column entry, so a first hide stores the full order. */
|
|
105
|
+
this.columnsData$ = computed(() => {
|
|
106
|
+
return this.propertiesRaw$.value.map(property => ({
|
|
107
|
+
id: property.id,
|
|
108
|
+
hide: property.hide$.value,
|
|
109
|
+
}));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
isShow(rowId) {
|
|
113
|
+
const filter = this.filter$.value;
|
|
114
|
+
if (!filter.conditions.length)
|
|
115
|
+
return true;
|
|
116
|
+
// Hidden properties included, as in the table: hiding a property must not
|
|
117
|
+
// silently drop the condition on it.
|
|
118
|
+
const rowMap = Object.fromEntries(this.propertiesRaw$.value.map(property => [
|
|
119
|
+
property.id,
|
|
120
|
+
property.cellGetOrCreate(rowId).jsonValue$.value,
|
|
121
|
+
]));
|
|
122
|
+
return evalFilter(filter, rowMap);
|
|
123
|
+
}
|
|
124
|
+
propertyGetOrCreate(propertyId) {
|
|
125
|
+
return new FlatProperty(this, propertyId);
|
|
126
|
+
}
|
|
127
|
+
/** A row added from a group's "New page" takes that group's value. */
|
|
128
|
+
rowAdd(insertPosition, groupKey) {
|
|
129
|
+
const id = super.rowAdd(insertPosition);
|
|
130
|
+
if (!id)
|
|
131
|
+
return id;
|
|
132
|
+
const filter = this.filter$.value;
|
|
133
|
+
const defaultValues = filter.conditions.length
|
|
134
|
+
? generateDefaultValues(filter, this.vars$.value)
|
|
135
|
+
: {};
|
|
136
|
+
Object.entries(defaultValues).forEach(([propertyId, jsonValue]) => {
|
|
137
|
+
const property = this.propertyGetOrCreate(propertyId);
|
|
138
|
+
const propertyMeta = property.meta$.value;
|
|
139
|
+
if (!propertyMeta)
|
|
140
|
+
return;
|
|
141
|
+
const value = fromJson(propertyMeta.config, {
|
|
142
|
+
value: jsonValue,
|
|
143
|
+
data: property.data$.value,
|
|
144
|
+
dataSource: this.dataSource,
|
|
145
|
+
});
|
|
146
|
+
this.cellGetOrCreate(id, propertyId).valueSet(value);
|
|
147
|
+
});
|
|
148
|
+
// After the filter's defaults, as in the table: the group clicked wins.
|
|
149
|
+
if (groupKey != null)
|
|
150
|
+
this.groupTrait.addToGroup(id, groupKey);
|
|
151
|
+
return id;
|
|
152
|
+
}
|
|
153
|
+
rowsMapping(rows) {
|
|
154
|
+
return this.sortManager.sort(super.rowsMapping(rows));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export class FlatProperty extends PropertyBase {
|
|
158
|
+
constructor(flatView, propertyId) {
|
|
159
|
+
super(flatView, propertyId);
|
|
160
|
+
this.flatView = flatView;
|
|
161
|
+
this.hide$ = computed(() => {
|
|
162
|
+
const hideFromViewData = this.viewData$.value?.hide;
|
|
163
|
+
if (hideFromViewData != null) {
|
|
164
|
+
return hideFromViewData;
|
|
165
|
+
}
|
|
166
|
+
const defaultShow = this.meta$.value?.config.fixed?.defaultShow;
|
|
167
|
+
if (defaultShow != null) {
|
|
168
|
+
return !defaultShow;
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
});
|
|
172
|
+
this.viewData$ = computed(() => {
|
|
173
|
+
return this.flatView.data$.value?.columns.find(v => v.id === this.id);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
hideSet(hide) {
|
|
177
|
+
this.flatView.dataUpdate(() => ({
|
|
178
|
+
columns: this.flatView.columnsData$.value.map(v => v.id === this.id ? { ...v, hide } : v),
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
move(position) {
|
|
182
|
+
this.flatView.dataUpdate(() => {
|
|
183
|
+
const columns = [...this.flatView.columnsData$.value];
|
|
184
|
+
const index = columns.findIndex(v => v.id === this.id);
|
|
185
|
+
if (index < 0)
|
|
186
|
+
return {};
|
|
187
|
+
const [column] = columns.splice(index, 1);
|
|
188
|
+
if (!column)
|
|
189
|
+
return {};
|
|
190
|
+
columns.splice(insertPositionToIndex(position, columns), 0, column);
|
|
191
|
+
return { columns };
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ChromeWording } from '../../../affine-shared/services/index.js';
|
|
2
|
+
import type { UniComponent } from '../../../affine-shared/types/index.js';
|
|
3
|
+
import type { InsertToPosition } from '../../../affine-shared/utils/index.js';
|
|
4
|
+
import type { BlockStdScope } from '../../../std/index.js';
|
|
5
|
+
import { nothing } from 'lit';
|
|
6
|
+
import type { Group } from '../../core/group-by/trait.js';
|
|
7
|
+
import { DataViewUIBase, DataViewUILogicBase } from '../../core/view/data-view-base.js';
|
|
8
|
+
import type { Property } from '../../core/view-manager/property.js';
|
|
9
|
+
import type { Row } from '../../core/view-manager/row.js';
|
|
10
|
+
import type { FlatSingleView } from './flat-view-manager.js';
|
|
11
|
+
/**
|
|
12
|
+
* The UI logic both ungrouped presets share. Neither has a selection model of
|
|
13
|
+
* its own: a cell edits through the cell host (`dv-standalone-cell`), with the
|
|
14
|
+
* very renderer and popups a table cell mounts, and a click anywhere else on
|
|
15
|
+
* a card or a row opens the row through the root's detail panel, the path
|
|
16
|
+
* the table's and the kanban's open buttons take. Grouped (B8), each group
|
|
17
|
+
* draws under the table's group header; drag and drop of rows between groups
|
|
18
|
+
* is not offered: a row changes group by editing its value.
|
|
19
|
+
*/
|
|
20
|
+
export declare abstract class FlatViewUILogic<View extends FlatSingleView = FlatSingleView> extends DataViewUILogicBase<View> {
|
|
21
|
+
clearSelection: () => void;
|
|
22
|
+
focusFirstCell: () => void;
|
|
23
|
+
showIndicator: (_evt: MouseEvent) => boolean;
|
|
24
|
+
hideIndicator: () => void;
|
|
25
|
+
moveTo: (_id: string, _evt: MouseEvent) => void;
|
|
26
|
+
addRow: (position: InsertToPosition, groupKey?: string) => string | undefined;
|
|
27
|
+
abstract renderer: UniComponent<unknown>;
|
|
28
|
+
/** A Ctrl/Cmd click asks the host for a new tab (ADR 0035 §9a). */
|
|
29
|
+
openRow: (rowId: string, newTab?: boolean) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare abstract class FlatViewUI<Logic extends FlatViewUILogic = FlatViewUILogic> extends DataViewUIBase<Logic> {
|
|
32
|
+
/** Absent outside an editor (a unit test): the wordings read English. */
|
|
33
|
+
accessor std: BlockStdScope;
|
|
34
|
+
protected wording([key, fallback]: ChromeWording): string;
|
|
35
|
+
protected get view(): FlatSingleView<import("./flat-view-manager.js").FlatViewDataType<string>>;
|
|
36
|
+
/**
|
|
37
|
+
* One property's value, drawn and edited by the cell renderer a table cell
|
|
38
|
+
* mounts. `readonly` draws the value only and lets a click through to the
|
|
39
|
+
* card or row, which is how the title opens its row.
|
|
40
|
+
*/
|
|
41
|
+
protected renderCell(property: Property, rowId: string, readonly?: boolean): import("lit-html").TemplateResult<1>;
|
|
42
|
+
protected renderOpenButton(rowId: string): import("lit-html").TemplateResult<1>;
|
|
43
|
+
protected renderHeaderWidget(): import("lit-html").TemplateResult | typeof nothing;
|
|
44
|
+
/**
|
|
45
|
+
* The view's rows through `renderBody`: once, or once per visible group
|
|
46
|
+
* under its header, then the hidden groups (B8, PRD REQ-DB-13 and 16). A
|
|
47
|
+
* folded group keeps its header only.
|
|
48
|
+
*/
|
|
49
|
+
protected renderGrouped(renderBody: (rows: Row[], group?: Group) => unknown): unknown;
|
|
50
|
+
private renderGroup;
|
|
51
|
+
protected readonly onRowClick: (event: MouseEvent) => void;
|
|
52
|
+
}
|
|
53
|
+
/** The group header both presets draw, the table's title and count. */
|
|
54
|
+
export declare const flatGroupStyles: import("lit").CSSResult;
|
|
55
|
+
/** The open button both presets draw, shown on hover or keyboard focus. */
|
|
56
|
+
export declare const flatOpenButtonStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { popFilterableSimpleMenu, popupTargetFromElement, } from '../../../affine-components/context-menu/index.js';
|
|
36
|
+
import { translateKey } from '../../../affine-shared/services/index.js';
|
|
37
|
+
import { OPEN_LABEL } from '../../../affine-components/translations.js';
|
|
38
|
+
import { CenterPeekIcon } from '@blocksuite/icons/lit';
|
|
39
|
+
import { stdContext } from '../../../std/index.js';
|
|
40
|
+
import { consume } from '@lit/context';
|
|
41
|
+
import { cssVarV2 } from '@toeverything/theme/v2';
|
|
42
|
+
import { css, html, nothing, unsafeCSS } from 'lit';
|
|
43
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
44
|
+
import { renderCellStatus } from '../../core/component/cell-status/cell-status.js';
|
|
45
|
+
import { GroupTitle } from '../../core/group-by/group-title.js';
|
|
46
|
+
import { hideGroupAction, renderGroupToggle, } from '../../core/group-by/group-visibility.js';
|
|
47
|
+
import { isNewTabClick } from '../../core/utils/new-tab-click.js';
|
|
48
|
+
import { renderUniLit } from '../../core/utils/uni-component/uni-component.js';
|
|
49
|
+
import { DataViewUIBase, DataViewUILogicBase, } from '../../core/view/data-view-base.js';
|
|
50
|
+
/**
|
|
51
|
+
* The UI logic both ungrouped presets share. Neither has a selection model of
|
|
52
|
+
* its own: a cell edits through the cell host (`dv-standalone-cell`), with the
|
|
53
|
+
* very renderer and popups a table cell mounts, and a click anywhere else on
|
|
54
|
+
* a card or a row opens the row through the root's detail panel, the path
|
|
55
|
+
* the table's and the kanban's open buttons take. Grouped (B8), each group
|
|
56
|
+
* draws under the table's group header; drag and drop of rows between groups
|
|
57
|
+
* is not offered: a row changes group by editing its value.
|
|
58
|
+
*/
|
|
59
|
+
export class FlatViewUILogic extends DataViewUILogicBase {
|
|
60
|
+
constructor() {
|
|
61
|
+
super(...arguments);
|
|
62
|
+
this.clearSelection = () => { };
|
|
63
|
+
this.focusFirstCell = () => { };
|
|
64
|
+
this.showIndicator = (_evt) => false;
|
|
65
|
+
this.hideIndicator = () => { };
|
|
66
|
+
this.moveTo = (_id, _evt) => { };
|
|
67
|
+
this.addRow = (position, groupKey) => {
|
|
68
|
+
if (this.view.readonly$.value)
|
|
69
|
+
return;
|
|
70
|
+
const rowId = this.view.rowAdd(position, groupKey);
|
|
71
|
+
if (rowId)
|
|
72
|
+
this.openRow(rowId);
|
|
73
|
+
return rowId;
|
|
74
|
+
};
|
|
75
|
+
/** A Ctrl/Cmd click asks the host for a new tab (ADR 0035 §9a). */
|
|
76
|
+
this.openRow = (rowId, newTab = false) => {
|
|
77
|
+
this.root.openDetailPanel({ view: this.view, rowId, newTab });
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let FlatViewUI = (() => {
|
|
82
|
+
let _classSuper = DataViewUIBase;
|
|
83
|
+
let _std_decorators;
|
|
84
|
+
let _std_initializers = [];
|
|
85
|
+
let _std_extraInitializers = [];
|
|
86
|
+
return class FlatViewUI extends _classSuper {
|
|
87
|
+
constructor() {
|
|
88
|
+
super(...arguments);
|
|
89
|
+
this.#std_accessor_storage = __runInitializers(this, _std_initializers, void 0);
|
|
90
|
+
this.onRowClick = (__runInitializers(this, _std_extraInitializers), (event) => {
|
|
91
|
+
const rowId = event.currentTarget.dataset.rowId;
|
|
92
|
+
if (rowId)
|
|
93
|
+
this.logic.openRow(rowId, isNewTabClick(event));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
static {
|
|
97
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
98
|
+
_std_decorators = [consume({ context: stdContext })];
|
|
99
|
+
__esDecorate(this, null, _std_decorators, { kind: "accessor", name: "std", static: false, private: false, access: { has: obj => "std" in obj, get: obj => obj.std, set: (obj, value) => { obj.std = value; } }, metadata: _metadata }, _std_initializers, _std_extraInitializers);
|
|
100
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
101
|
+
}
|
|
102
|
+
#std_accessor_storage;
|
|
103
|
+
/** Absent outside an editor (a unit test): the wordings read English. */
|
|
104
|
+
get std() { return this.#std_accessor_storage; }
|
|
105
|
+
set std(value) { this.#std_accessor_storage = value; }
|
|
106
|
+
wording([key, fallback]) {
|
|
107
|
+
return this.std ? translateKey(this.std, key, fallback) : fallback;
|
|
108
|
+
}
|
|
109
|
+
get view() {
|
|
110
|
+
return this.logic.view;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* One property's value, drawn and edited by the cell renderer a table cell
|
|
114
|
+
* mounts. `readonly` draws the value only and lets a click through to the
|
|
115
|
+
* card or row, which is how the title opens its row.
|
|
116
|
+
*/
|
|
117
|
+
renderCell(property, rowId, readonly = false) {
|
|
118
|
+
const view = this.view;
|
|
119
|
+
const cell = property.cellGetOrCreate(rowId);
|
|
120
|
+
// As a table cell: a value not yet hydrated mounts no renderer, so nothing
|
|
121
|
+
// can be edited over it (ADR 0035 §9e).
|
|
122
|
+
const status = renderCellStatus(cell);
|
|
123
|
+
if (status) {
|
|
124
|
+
return html `<span data-property-id="${property.id}">${status}</span>`;
|
|
125
|
+
}
|
|
126
|
+
return html `<dv-standalone-cell
|
|
127
|
+
data-property-id="${property.id}"
|
|
128
|
+
.cell="${cell}"
|
|
129
|
+
.readonly="${readonly ||
|
|
130
|
+
view.readonly$.value ||
|
|
131
|
+
property.readonly$.value}"
|
|
132
|
+
.onEditingChange="${(editing) => view.lockRows(editing)}"
|
|
133
|
+
></dv-standalone-cell>`;
|
|
134
|
+
}
|
|
135
|
+
renderOpenButton(rowId) {
|
|
136
|
+
const label = this.wording(OPEN_LABEL);
|
|
137
|
+
return html `<button
|
|
138
|
+
class="dv-flat-open"
|
|
139
|
+
data-testid="dv-flat-open"
|
|
140
|
+
aria-label="${label}"
|
|
141
|
+
title="${label}"
|
|
142
|
+
@click="${(event) => {
|
|
143
|
+
event.stopPropagation();
|
|
144
|
+
this.logic.openRow(rowId, isNewTabClick(event));
|
|
145
|
+
}}"
|
|
146
|
+
>
|
|
147
|
+
${CenterPeekIcon()}
|
|
148
|
+
</button>`;
|
|
149
|
+
}
|
|
150
|
+
renderHeaderWidget() {
|
|
151
|
+
const headerWidget = this.logic.headerWidget;
|
|
152
|
+
if (!headerWidget)
|
|
153
|
+
return nothing;
|
|
154
|
+
return renderUniLit(headerWidget, { dataViewLogic: this.logic });
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The view's rows through `renderBody`: once, or once per visible group
|
|
158
|
+
* under its header, then the hidden groups (B8, PRD REQ-DB-13 and 16). A
|
|
159
|
+
* folded group keeps its header only.
|
|
160
|
+
*/
|
|
161
|
+
renderGrouped(renderBody) {
|
|
162
|
+
const trait = this.view.groupTrait;
|
|
163
|
+
const groups = trait.visibleGroups$.value;
|
|
164
|
+
if (!groups)
|
|
165
|
+
return renderBody(this.view.rows$.value);
|
|
166
|
+
return html `${repeat(groups, group => group.key, group => this.renderGroup(group, renderBody))} <dv-hidden-groups .groupTrait="${trait}"></dv-hidden-groups>`;
|
|
167
|
+
}
|
|
168
|
+
renderGroup(group, renderBody) {
|
|
169
|
+
const collapsed = group.manager.collapsed$(group.key).value;
|
|
170
|
+
const wording = (pair) => this.wording(pair);
|
|
171
|
+
return html `<section
|
|
172
|
+
class="dv-flat-group"
|
|
173
|
+
data-testid="dv-flat-group"
|
|
174
|
+
data-group-key="${group.key}"
|
|
175
|
+
>
|
|
176
|
+
<div class="dv-flat-group-header">
|
|
177
|
+
${renderGroupToggle(group, wording)}
|
|
178
|
+
<div class="dv-flat-group-title">
|
|
179
|
+
${GroupTitle(group, {
|
|
180
|
+
readonly: this.view.readonly$.value,
|
|
181
|
+
clickAdd: () => this.logic.addRow('start', group.key),
|
|
182
|
+
clickOps: (event) => {
|
|
183
|
+
popFilterableSimpleMenu(popupTargetFromElement(event.currentTarget), [hideGroupAction(group, wording)]);
|
|
184
|
+
},
|
|
185
|
+
})}
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
${collapsed ? nothing : renderBody(group.rows, group)}
|
|
189
|
+
</section>`;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
})();
|
|
193
|
+
export { FlatViewUI };
|
|
194
|
+
/** The group header both presets draw, the table's title and count. */
|
|
195
|
+
export const flatGroupStyles = css `
|
|
196
|
+
.dv-flat-group {
|
|
197
|
+
display: flex;
|
|
198
|
+
flex-direction: column;
|
|
199
|
+
padding-top: 8px;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.dv-flat-group-header {
|
|
203
|
+
display: flex;
|
|
204
|
+
align-items: center;
|
|
205
|
+
gap: 4px;
|
|
206
|
+
min-height: 32px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.dv-flat-group-title {
|
|
210
|
+
display: flex;
|
|
211
|
+
flex: 1 1 auto;
|
|
212
|
+
align-items: center;
|
|
213
|
+
gap: 8px;
|
|
214
|
+
min-width: 0;
|
|
215
|
+
overflow: hidden;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.dv-flat-group-header:hover .group-header-op,
|
|
219
|
+
.dv-flat-group-header:focus-within .group-header-op {
|
|
220
|
+
visibility: visible;
|
|
221
|
+
opacity: 1;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@media (pointer: coarse) {
|
|
225
|
+
.dv-flat-group-header {
|
|
226
|
+
min-height: 44px;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
`;
|
|
230
|
+
/** The open button both presets draw, shown on hover or keyboard focus. */
|
|
231
|
+
export const flatOpenButtonStyles = css `
|
|
232
|
+
.dv-flat-open {
|
|
233
|
+
position: absolute;
|
|
234
|
+
top: 6px;
|
|
235
|
+
right: 6px;
|
|
236
|
+
display: flex;
|
|
237
|
+
align-items: center;
|
|
238
|
+
justify-content: center;
|
|
239
|
+
width: 24px;
|
|
240
|
+
height: 24px;
|
|
241
|
+
padding: 0;
|
|
242
|
+
border: 1px solid ${unsafeCSS(cssVarV2.layer.insideBorder.border)};
|
|
243
|
+
border-radius: 4px;
|
|
244
|
+
background-color: var(--affine-background-primary-color);
|
|
245
|
+
color: var(--affine-icon-color);
|
|
246
|
+
cursor: pointer;
|
|
247
|
+
visibility: hidden;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.dv-flat-open svg {
|
|
251
|
+
width: 16px;
|
|
252
|
+
height: 16px;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.dv-flat-open:focus-visible {
|
|
256
|
+
visibility: visible;
|
|
257
|
+
outline: 2px solid var(--affine-primary-color);
|
|
258
|
+
outline-offset: 1px;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@media (hover: hover) {
|
|
262
|
+
.dv-flat-open:hover {
|
|
263
|
+
background-color: var(--affine-hover-color);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FlatSingleView, type FlatViewDataType } from '../flat/flat-view-manager.js';
|
|
2
|
+
export declare const galleryViewType: {
|
|
3
|
+
type: "gallery";
|
|
4
|
+
createModel: <Data extends import("../../index.js").DataViewDataType>(model: import("../../index.js").DataViewModelConfig<Data>) => import("../../index.js").DataViewModel<"gallery", Data> & {
|
|
5
|
+
createMeta: (renderer: import("../../index.js").DataViewRendererConfig) => import("../../index.js").ViewMeta<"gallery", Data>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export type GalleryViewData = FlatViewDataType<typeof galleryViewType.type>;
|
|
9
|
+
export declare class GallerySingleView extends FlatSingleView<GalleryViewData> {
|
|
10
|
+
get type(): string;
|
|
11
|
+
}
|
|
12
|
+
export declare const galleryViewModel: import("../../index.js").DataViewModel<"gallery", GalleryViewData> & {
|
|
13
|
+
createMeta: (renderer: import("../../index.js").DataViewRendererConfig) => import("../../index.js").ViewMeta<"gallery", GalleryViewData>;
|
|
14
|
+
};
|