@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
|
@@ -0,0 +1,324 @@
|
|
|
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 { createIdentifier, } from '../../../global/di/index.js';
|
|
36
|
+
import { SignalWatcher, WithDisposable } from '../../../global/lit/index.js';
|
|
37
|
+
import { ShadowlessElement } from '../../../std/index.js';
|
|
38
|
+
import { computed, signal } from '@preact/signals-core';
|
|
39
|
+
import { css, html, nothing, unsafeCSS } from 'lit';
|
|
40
|
+
import { property } from 'lit/decorators.js';
|
|
41
|
+
import { dataViewCssVariable } from '../common/css-variable.js';
|
|
42
|
+
import { renderUniLit } from '../utils/uni-component/uni-component.js';
|
|
43
|
+
const NO_FLAGS = signal({
|
|
44
|
+
enable_number_formatting: false,
|
|
45
|
+
enable_table_virtual_scroll: false,
|
|
46
|
+
});
|
|
47
|
+
function isEmptyValue(value) {
|
|
48
|
+
if (value == null)
|
|
49
|
+
return true;
|
|
50
|
+
if (typeof value === 'string')
|
|
51
|
+
return value.trim() === '';
|
|
52
|
+
if (Array.isArray(value))
|
|
53
|
+
return value.length === 0;
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
class StandaloneCell {
|
|
57
|
+
get propertyId() {
|
|
58
|
+
return this._source.propertyId;
|
|
59
|
+
}
|
|
60
|
+
get rowId() {
|
|
61
|
+
return this._source.propertyId;
|
|
62
|
+
}
|
|
63
|
+
get row() {
|
|
64
|
+
throw new Error('A standalone cell has no row.');
|
|
65
|
+
}
|
|
66
|
+
constructor(meta, _source) {
|
|
67
|
+
this._source = _source;
|
|
68
|
+
const source = _source;
|
|
69
|
+
const view = {
|
|
70
|
+
readonly$: source.readonly$,
|
|
71
|
+
featureFlags$: source.featureFlags$ ?? NO_FLAGS,
|
|
72
|
+
serviceGet: (key) => source.serviceGet?.(key) ?? null,
|
|
73
|
+
};
|
|
74
|
+
// The whole seam is these three members, held by the spec named above.
|
|
75
|
+
this.view = view;
|
|
76
|
+
const type$ = signal(meta.type);
|
|
77
|
+
const property = {
|
|
78
|
+
id: source.propertyId,
|
|
79
|
+
name$: source.name$,
|
|
80
|
+
data$: source.data$,
|
|
81
|
+
type$,
|
|
82
|
+
readonly$: source.readonly$,
|
|
83
|
+
meta$: signal(meta),
|
|
84
|
+
renderer$: signal(meta.renderer.cellRenderer),
|
|
85
|
+
dataCanSet: !!source.dataSet,
|
|
86
|
+
optionEdits: source.optionEdits,
|
|
87
|
+
dataUpdate: (updater) => {
|
|
88
|
+
if (!source.dataSet)
|
|
89
|
+
return;
|
|
90
|
+
const data = source.data$.peek();
|
|
91
|
+
source.dataSet({ ...data, ...updater(data) });
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
this.property = property;
|
|
95
|
+
this.value$ = source.value$;
|
|
96
|
+
this.jsonValue$ = source.value$;
|
|
97
|
+
this.isEmpty$ = computed(() => isEmptyValue(source.value$.value));
|
|
98
|
+
this.stringValue$ = computed(() => {
|
|
99
|
+
const value = source.value$.value;
|
|
100
|
+
if (value === undefined)
|
|
101
|
+
return undefined;
|
|
102
|
+
const toString = meta.config.rawValue.toString;
|
|
103
|
+
return toString({ value, data: source.data$.value });
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
valueSet(value) {
|
|
107
|
+
this._source.valueSet(value);
|
|
108
|
+
}
|
|
109
|
+
jsonValueSet(value) {
|
|
110
|
+
this._source.valueSet(value);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** A `Cell` for one value outside any view, drawn with `meta`'s renderer. */
|
|
114
|
+
export function createStandaloneCell(meta, source) {
|
|
115
|
+
return new StandaloneCell(meta, source);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A property type a standalone cell can be drawn with, registered by the
|
|
119
|
+
* package that owns its renderer when that package sits above the host: the
|
|
120
|
+
* database block registers its `link` cell, which the title band (a fragment
|
|
121
|
+
* the database block depends on) cannot import. The presets of this package
|
|
122
|
+
* need no registration; a host imports them.
|
|
123
|
+
*/
|
|
124
|
+
export const StandaloneCellMetaProvider = createIdentifier('DataViewStandaloneCellMeta');
|
|
125
|
+
export function StandaloneCellMetaExtension(meta) {
|
|
126
|
+
// Erased the way a data source's property list erases its metas.
|
|
127
|
+
const erased = meta;
|
|
128
|
+
return {
|
|
129
|
+
setup: di => {
|
|
130
|
+
di.override(StandaloneCellMetaProvider(meta.type), () => erased);
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The element that hosts a standalone cell: it mounts the cell renderer the
|
|
136
|
+
* way a table cell container does and owns the same edit lifecycle
|
|
137
|
+
* (`beforeEnterEditMode`, `afterEnterEditingMode`, `beforeExitEditingMode`),
|
|
138
|
+
* so a click, Enter or Space starts the renderer's own editor: the checkbox
|
|
139
|
+
* toggles, a select pops its tag menu, the date its picker, a text its input.
|
|
140
|
+
*
|
|
141
|
+
* Leaving: a popup editor (select, date) closes itself on a click away and
|
|
142
|
+
* calls `selectCurrentCell(false)`, as in the table; an editor drawn in place
|
|
143
|
+
* (an input inside this element) leaves when the focus does, Escape included.
|
|
144
|
+
* Either way the renderer's exit hook commits, exactly once.
|
|
145
|
+
*/
|
|
146
|
+
let StandaloneCellHost = (() => {
|
|
147
|
+
let _classSuper = SignalWatcher(WithDisposable(ShadowlessElement));
|
|
148
|
+
let _cell_decorators;
|
|
149
|
+
let _cell_initializers = [];
|
|
150
|
+
let _cell_extraInitializers = [];
|
|
151
|
+
let _placeholder_decorators;
|
|
152
|
+
let _placeholder_initializers = [];
|
|
153
|
+
let _placeholder_extraInitializers = [];
|
|
154
|
+
let _readonly_decorators;
|
|
155
|
+
let _readonly_initializers = [];
|
|
156
|
+
let _readonly_extraInitializers = [];
|
|
157
|
+
let _onEditingChange_decorators;
|
|
158
|
+
let _onEditingChange_initializers = [];
|
|
159
|
+
let _onEditingChange_extraInitializers = [];
|
|
160
|
+
return class StandaloneCellHost extends _classSuper {
|
|
161
|
+
static {
|
|
162
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
163
|
+
_cell_decorators = [property({ attribute: false })];
|
|
164
|
+
_placeholder_decorators = [property({ attribute: false })];
|
|
165
|
+
_readonly_decorators = [property({ attribute: false })];
|
|
166
|
+
_onEditingChange_decorators = [property({ attribute: false })];
|
|
167
|
+
__esDecorate(this, null, _cell_decorators, { kind: "accessor", name: "cell", static: false, private: false, access: { has: obj => "cell" in obj, get: obj => obj.cell, set: (obj, value) => { obj.cell = value; } }, metadata: _metadata }, _cell_initializers, _cell_extraInitializers);
|
|
168
|
+
__esDecorate(this, null, _placeholder_decorators, { kind: "accessor", name: "placeholder", static: false, private: false, access: { has: obj => "placeholder" in obj, get: obj => obj.placeholder, set: (obj, value) => { obj.placeholder = value; } }, metadata: _metadata }, _placeholder_initializers, _placeholder_extraInitializers);
|
|
169
|
+
__esDecorate(this, null, _readonly_decorators, { kind: "accessor", name: "readonly", static: false, private: false, access: { has: obj => "readonly" in obj, get: obj => obj.readonly, set: (obj, value) => { obj.readonly = value; } }, metadata: _metadata }, _readonly_initializers, _readonly_extraInitializers);
|
|
170
|
+
__esDecorate(this, null, _onEditingChange_decorators, { kind: "accessor", name: "onEditingChange", static: false, private: false, access: { has: obj => "onEditingChange" in obj, get: obj => obj.onEditingChange, set: (obj, value) => { obj.onEditingChange = value; } }, metadata: _metadata }, _onEditingChange_initializers, _onEditingChange_extraInitializers);
|
|
171
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
172
|
+
}
|
|
173
|
+
static { this.styles = css `
|
|
174
|
+
dv-standalone-cell {
|
|
175
|
+
${unsafeCSS(dataViewCssVariable())}
|
|
176
|
+
display: inline-flex;
|
|
177
|
+
align-items: center;
|
|
178
|
+
gap: 4px;
|
|
179
|
+
min-width: 0;
|
|
180
|
+
max-width: 100%;
|
|
181
|
+
outline: none;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
dv-standalone-cell[data-editable='true'] {
|
|
185
|
+
cursor: pointer;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* The record detail's editing ring (detail/field.ts). */
|
|
189
|
+
dv-standalone-cell[data-editing='true'] {
|
|
190
|
+
border-radius: 4px;
|
|
191
|
+
box-shadow: 0px 0px 0px 2px
|
|
192
|
+
color-mix(in srgb, var(--affine-primary-color) 30%, transparent);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.dv-standalone-cell-placeholder {
|
|
196
|
+
color: var(--affine-placeholder-color);
|
|
197
|
+
white-space: nowrap;
|
|
198
|
+
}
|
|
199
|
+
`; }
|
|
200
|
+
/** Opens the renderer's editor; a checkbox toggles instead. */
|
|
201
|
+
edit() {
|
|
202
|
+
if (this.readonly || this.isEditing$.peek())
|
|
203
|
+
return;
|
|
204
|
+
const cell = this._cell$.peek();
|
|
205
|
+
if (!cell?.beforeEnterEditMode())
|
|
206
|
+
return;
|
|
207
|
+
this.isEditing$.value = true;
|
|
208
|
+
this.onEditingChange?.(true);
|
|
209
|
+
requestAnimationFrame(() => {
|
|
210
|
+
if (this.isEditing$.peek())
|
|
211
|
+
cell.afterEnterEditingMode();
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/** Closes the editor; the renderer's exit hook commits its value. */
|
|
215
|
+
exit() {
|
|
216
|
+
// An exit hook may close a popup whose own close asks to exit again.
|
|
217
|
+
if (!this.isEditing$.peek() || this._exiting)
|
|
218
|
+
return;
|
|
219
|
+
this._exiting = true;
|
|
220
|
+
try {
|
|
221
|
+
this._cell$.peek()?.beforeExitEditingMode();
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
this._exiting = false;
|
|
225
|
+
}
|
|
226
|
+
this.isEditing$.value = false;
|
|
227
|
+
this.onEditingChange?.(false);
|
|
228
|
+
}
|
|
229
|
+
connectedCallback() {
|
|
230
|
+
super.connectedCallback();
|
|
231
|
+
this._disposables.addFromEvent(this, 'click', event => {
|
|
232
|
+
if (this.readonly)
|
|
233
|
+
return;
|
|
234
|
+
event.stopPropagation();
|
|
235
|
+
this.edit();
|
|
236
|
+
});
|
|
237
|
+
this._disposables.addFromEvent(this, 'keydown', event => {
|
|
238
|
+
if (this.isEditing$.peek()) {
|
|
239
|
+
if (event.key === 'Escape')
|
|
240
|
+
this.exit();
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (event.target !== this)
|
|
244
|
+
return;
|
|
245
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
246
|
+
event.preventDefault();
|
|
247
|
+
this.edit();
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
this._disposables.addFromEvent(this, 'focusout', event => {
|
|
251
|
+
if (!this.isEditing$.peek())
|
|
252
|
+
return;
|
|
253
|
+
const { target, relatedTarget } = event;
|
|
254
|
+
if (!(target instanceof HTMLInputElement) &&
|
|
255
|
+
!(target instanceof HTMLTextAreaElement))
|
|
256
|
+
return;
|
|
257
|
+
if (relatedTarget instanceof Node && this.contains(relatedTarget))
|
|
258
|
+
return;
|
|
259
|
+
this.exit();
|
|
260
|
+
});
|
|
261
|
+
this._disposables.add(() => this.exit());
|
|
262
|
+
}
|
|
263
|
+
render() {
|
|
264
|
+
const view = this.cell.property.renderer$.value?.view;
|
|
265
|
+
if (!view)
|
|
266
|
+
return nothing;
|
|
267
|
+
this.dataset.editable = this.readonly ? 'false' : 'true';
|
|
268
|
+
this.dataset.editing = this.isEditing$.value ? 'true' : 'false';
|
|
269
|
+
if (this.readonly)
|
|
270
|
+
this.removeAttribute('tabindex');
|
|
271
|
+
else
|
|
272
|
+
this.tabIndex = 0;
|
|
273
|
+
const props = {
|
|
274
|
+
cell: this.cell,
|
|
275
|
+
isEditing$: this.isEditing$,
|
|
276
|
+
selectCurrentCell: this._selectCurrentCell,
|
|
277
|
+
};
|
|
278
|
+
const placeholder = this.placeholder && !this.isEditing$.value && this.cell.isEmpty$.value
|
|
279
|
+
? html `<span class="dv-standalone-cell-placeholder"
|
|
280
|
+
>${this.placeholder}</span
|
|
281
|
+
>`
|
|
282
|
+
: nothing;
|
|
283
|
+
return html `${renderUniLit(view, props, { ref: this._cell$, style: { display: 'contents' } })}${placeholder}`;
|
|
284
|
+
}
|
|
285
|
+
#cell_accessor_storage;
|
|
286
|
+
get cell() { return this.#cell_accessor_storage; }
|
|
287
|
+
set cell(value) { this.#cell_accessor_storage = value; }
|
|
288
|
+
#placeholder_accessor_storage;
|
|
289
|
+
/** Drawn while the value is empty and no editor is open. */
|
|
290
|
+
get placeholder() { return this.#placeholder_accessor_storage; }
|
|
291
|
+
set placeholder(value) { this.#placeholder_accessor_storage = value; }
|
|
292
|
+
#readonly_accessor_storage;
|
|
293
|
+
/** Draws the value and opens no editor. */
|
|
294
|
+
get readonly() { return this.#readonly_accessor_storage; }
|
|
295
|
+
set readonly(value) { this.#readonly_accessor_storage = value; }
|
|
296
|
+
#onEditingChange_accessor_storage;
|
|
297
|
+
/**
|
|
298
|
+
* Told when the editor opens and closes. The gallery and list presets host
|
|
299
|
+
* a view's own cells here and lock the view's rows while one edits, as a
|
|
300
|
+
* table or kanban cell does (`view.lockRows`), so a value that changes the
|
|
301
|
+
* sort or the filter does not move or drop the row under the editor.
|
|
302
|
+
*/
|
|
303
|
+
get onEditingChange() { return this.#onEditingChange_accessor_storage; }
|
|
304
|
+
set onEditingChange(value) { this.#onEditingChange_accessor_storage = value; }
|
|
305
|
+
constructor() {
|
|
306
|
+
super(...arguments);
|
|
307
|
+
this._cell$ = signal();
|
|
308
|
+
this._exiting = false;
|
|
309
|
+
this.isEditing$ = signal(false);
|
|
310
|
+
this._selectCurrentCell = (editing) => {
|
|
311
|
+
if (editing)
|
|
312
|
+
this.edit();
|
|
313
|
+
else
|
|
314
|
+
this.exit();
|
|
315
|
+
};
|
|
316
|
+
this.#cell_accessor_storage = __runInitializers(this, _cell_initializers, void 0);
|
|
317
|
+
this.#placeholder_accessor_storage = (__runInitializers(this, _cell_extraInitializers), __runInitializers(this, _placeholder_initializers, ''));
|
|
318
|
+
this.#readonly_accessor_storage = (__runInitializers(this, _placeholder_extraInitializers), __runInitializers(this, _readonly_initializers, false));
|
|
319
|
+
this.#onEditingChange_accessor_storage = (__runInitializers(this, _readonly_extraInitializers), __runInitializers(this, _onEditingChange_initializers, undefined));
|
|
320
|
+
__runInitializers(this, _onEditingChange_extraInitializers);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
})();
|
|
324
|
+
export { StandaloneCellHost };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DatabaseAllEvents, DatabaseAllViewEvents, EventTraceFn } from '../../affine-shared/services/index.js';
|
|
2
|
+
import type { SingleView } from './view-manager/single-view.js';
|
|
3
|
+
/**
|
|
4
|
+
* The tracer a database host gives its data source (`serviceSet`), the same
|
|
5
|
+
* function it passes the root as `config.eventTrace`. It exists for the
|
|
6
|
+
* gestures whose code holds a view or a trait but no UI logic (the group-by
|
|
7
|
+
* menus build from a `GroupTrait`): they report through the view's source.
|
|
8
|
+
* Absent, nothing is reported (a standalone data view, a test).
|
|
9
|
+
*/
|
|
10
|
+
export declare const DataViewEventTraceKey: import("../../global/di/types.js").ServiceIdentifier<EventTraceFn<DatabaseAllEvents>> & (<U extends EventTraceFn<DatabaseAllEvents> = EventTraceFn<DatabaseAllEvents>>(variant: import("../../global/di/types.js").ServiceVariant) => import("../../global/di/types.js").ServiceIdentifier<U>);
|
|
11
|
+
/**
|
|
12
|
+
* Report a view-level event from code that only holds the view, with the
|
|
13
|
+
* same `viewId` / `viewType` params `DataViewUILogicBase.eventTrace` adds.
|
|
14
|
+
* Ids only (telemetry README, "Databases").
|
|
15
|
+
*/
|
|
16
|
+
export declare function traceViewEvent<K extends keyof DatabaseAllViewEvents>(view: SingleView, key: K, params: DatabaseAllViewEvents[K]): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createIdentifier } from '../../global/di/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The tracer a database host gives its data source (`serviceSet`), the same
|
|
4
|
+
* function it passes the root as `config.eventTrace`. It exists for the
|
|
5
|
+
* gestures whose code holds a view or a trait but no UI logic (the group-by
|
|
6
|
+
* menus build from a `GroupTrait`): they report through the view's source.
|
|
7
|
+
* Absent, nothing is reported (a standalone data view, a test).
|
|
8
|
+
*/
|
|
9
|
+
export const DataViewEventTraceKey = createIdentifier('data-view-event-trace');
|
|
10
|
+
/**
|
|
11
|
+
* Report a view-level event from code that only holds the view, with the
|
|
12
|
+
* same `viewId` / `viewType` params `DataViewUILogicBase.eventTrace` adds.
|
|
13
|
+
* Ids only (telemetry README, "Databases").
|
|
14
|
+
*/
|
|
15
|
+
export function traceViewEvent(view, key, params) {
|
|
16
|
+
const trace = view.manager.dataSource.serviceGet(DataViewEventTraceKey);
|
|
17
|
+
trace?.(key, {
|
|
18
|
+
...params,
|
|
19
|
+
viewId: view.id,
|
|
20
|
+
viewType: view.type,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ChromeWording } from '../../../affine-shared/services/index.js';
|
|
2
|
+
import type { BlockStdScope } from '../../../std/index.js';
|
|
3
|
+
export type Wording = (wording: ChromeWording) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the data-view's wordings through the translation seam when an
|
|
6
|
+
* editor is there (`stdContext`), in English otherwise (a unit test, a
|
|
7
|
+
* standalone mount). A popup renders outside the host, so its opener
|
|
8
|
+
* resolves the words and hands this function down.
|
|
9
|
+
*/
|
|
10
|
+
export declare const wordingOf: (std: BlockStdScope | undefined) => Wording;
|
|
11
|
+
export declare const englishWording: Wording;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { translateKey, } from '../../../affine-shared/services/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the data-view's wordings through the translation seam when an
|
|
4
|
+
* editor is there (`stdContext`), in English otherwise (a unit test, a
|
|
5
|
+
* standalone mount). A popup renders outside the host, so its opener
|
|
6
|
+
* resolves the words and hands this function down.
|
|
7
|
+
*/
|
|
8
|
+
export const wordingOf = (std) => ([key, fallback]) => std ? translateKey(std, key, fallback) : fallback;
|
|
9
|
+
export const englishWording = ([, fallback]) => fallback;
|
|
@@ -14,7 +14,14 @@ export type DefaultViewDataType = BasicViewDataType & {
|
|
|
14
14
|
export type DataViewDataType = DefaultViewDataType;
|
|
15
15
|
export type DataViewMode = string;
|
|
16
16
|
export interface DataViewModelConfig<Data extends DataViewDataType = DataViewDataType> {
|
|
17
|
+
/**
|
|
18
|
+
* The English name a new view of this preset is given, and the fallback of
|
|
19
|
+
* {@link defaultNameKey}. A seed: never translated in place, the creation
|
|
20
|
+
* site writes the resolved name (`viewDefaultName`).
|
|
21
|
+
*/
|
|
17
22
|
defaultName: string;
|
|
23
|
+
/** The `com.labre.*` key of {@link defaultName}; absent, it is shown as is. */
|
|
24
|
+
defaultNameKey?: string;
|
|
18
25
|
dataViewManager: new (viewManager: ViewManager, viewId: string) => SingleView;
|
|
19
26
|
defaultData: (viewManager: ViewManager) => Omit<Data, 'id' | 'name' | 'mode'>;
|
|
20
27
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BlockStdScope } from '../../../std/index.js';
|
|
2
|
+
import type { DataViewModel } from './data-view.js';
|
|
3
|
+
/**
|
|
4
|
+
* The name a view created now is given: the preset's `defaultNameKey`
|
|
5
|
+
* resolved through the host's catalogue, its English `defaultName` without
|
|
6
|
+
* an editor (`std` absent) or without a key. A creation site writes what
|
|
7
|
+
* this returns, at the gesture, so the stored name is the one the author saw
|
|
8
|
+
* and the preset's seed never changes (ADR 0023). Never call it on load.
|
|
9
|
+
*/
|
|
10
|
+
export declare function viewDefaultName(meta: Pick<DataViewModel, 'model'>, std: BlockStdScope | undefined): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { translateKey } from '../../../affine-shared/services/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The name a view created now is given: the preset's `defaultNameKey`
|
|
4
|
+
* resolved through the host's catalogue, its English `defaultName` without
|
|
5
|
+
* an editor (`std` absent) or without a key. A creation site writes what
|
|
6
|
+
* this returns, at the gesture, so the stored name is the one the author saw
|
|
7
|
+
* and the preset's seed never changes (ADR 0023). Never call it on load.
|
|
8
|
+
*/
|
|
9
|
+
export function viewDefaultName(meta, std) {
|
|
10
|
+
const { defaultName, defaultNameKey } = meta.model;
|
|
11
|
+
if (!std || !defaultNameKey)
|
|
12
|
+
return defaultName;
|
|
13
|
+
return translateKey(std, defaultNameKey, defaultName);
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type DatabaseViewOpenIn } from '../../../affine-model/index.js';
|
|
2
|
+
import type { DataSource } from '../data-source/base.js';
|
|
3
|
+
import type { SingleView } from '../view-manager/single-view.js';
|
|
4
|
+
/**
|
|
5
|
+
* Where a view opens its rows' pages (ADR 0035 §8, B8; PRD REQ-DB-11): the
|
|
6
|
+
* stored `openIn` of the view, a setting every reader of the view shares.
|
|
7
|
+
* Absent, or a value this build does not know (the list is append-only),
|
|
8
|
+
* reads `side`. The row-open seam (§9a, B9) reads it; this file only reads
|
|
9
|
+
* and writes the setting.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_OPEN_IN: DatabaseViewOpenIn;
|
|
12
|
+
export declare function viewOpenIn(data: object | undefined): DatabaseViewOpenIn;
|
|
13
|
+
/**
|
|
14
|
+
* Record a choice of the view settings. Written on that gesture only, and not
|
|
15
|
+
* when it changes nothing: picking "Side peek" on a view that stores no
|
|
16
|
+
* `openIn` leaves the field absent. A read-only view and a fallback view
|
|
17
|
+
* (ADR 0035 §6) are never written. Returns whether it wrote.
|
|
18
|
+
*/
|
|
19
|
+
export declare function viewOpenInSet(view: SingleView, openIn: DatabaseViewOpenIn): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the source says its rows are pages (`rowsAreDocuments`, on the
|
|
22
|
+
* hosted source of `blocks/database`, ADR 0035 §9a). Only then does a row
|
|
23
|
+
* open where `openIn` says, so only then is the setting offered: a
|
|
24
|
+
* block-backed row keeps the detail panel whatever the view stores. Read
|
|
25
|
+
* structurally because the flag is declared above this package.
|
|
26
|
+
*/
|
|
27
|
+
export declare function rowsArePages(dataSource: DataSource): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DATABASE_VIEW_OPEN_IN, } from '../../../affine-model/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Where a view opens its rows' pages (ADR 0035 §8, B8; PRD REQ-DB-11): the
|
|
4
|
+
* stored `openIn` of the view, a setting every reader of the view shares.
|
|
5
|
+
* Absent, or a value this build does not know (the list is append-only),
|
|
6
|
+
* reads `side`. The row-open seam (§9a, B9) reads it; this file only reads
|
|
7
|
+
* and writes the setting.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_OPEN_IN = 'side';
|
|
10
|
+
export function viewOpenIn(data) {
|
|
11
|
+
const stored = data?.openIn;
|
|
12
|
+
return DATABASE_VIEW_OPEN_IN.find(mode => mode === stored) ?? DEFAULT_OPEN_IN;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Record a choice of the view settings. Written on that gesture only, and not
|
|
16
|
+
* when it changes nothing: picking "Side peek" on a view that stores no
|
|
17
|
+
* `openIn` leaves the field absent. A read-only view and a fallback view
|
|
18
|
+
* (ADR 0035 §6) are never written. Returns whether it wrote.
|
|
19
|
+
*/
|
|
20
|
+
export function viewOpenInSet(view, openIn) {
|
|
21
|
+
if (view.readonly$.peek() || view.shownAsFallback$.peek())
|
|
22
|
+
return false;
|
|
23
|
+
const dataSource = view.manager.dataSource;
|
|
24
|
+
if (viewOpenIn(dataSource.viewDataGet(view.id)) === openIn)
|
|
25
|
+
return false;
|
|
26
|
+
dataSource.viewDataUpdate(view.id, () => ({ openIn }));
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether the source says its rows are pages (`rowsAreDocuments`, on the
|
|
31
|
+
* hosted source of `blocks/database`, ADR 0035 §9a). Only then does a row
|
|
32
|
+
* open where `openIn` says, so only then is the setting offered: a
|
|
33
|
+
* block-backed row keeps the detail panel whatever the view stores. Read
|
|
34
|
+
* structurally because the flag is declared above this package.
|
|
35
|
+
*/
|
|
36
|
+
export function rowsArePages(dataSource) {
|
|
37
|
+
return (dataSource.rowsAreDocuments ===
|
|
38
|
+
true);
|
|
39
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReadonlySignal } from '@preact/signals-core';
|
|
2
|
+
import { type CellStatus } from '../data-source/hydration.js';
|
|
2
3
|
import type { Property } from './property.js';
|
|
3
4
|
import type { Row } from './row.js';
|
|
4
5
|
import type { SingleView } from './single-view.js';
|
|
@@ -12,6 +13,8 @@ export interface Cell<RawValue = unknown, JsonValue = unknown, Data extends Reco
|
|
|
12
13
|
readonly value$: ReadonlySignal<RawValue | undefined>;
|
|
13
14
|
readonly jsonValue$: ReadonlySignal<JsonValue | undefined>;
|
|
14
15
|
readonly stringValue$: ReadonlySignal<string | undefined>;
|
|
16
|
+
/** Whether the value is the source's real one yet (ADR 0035 §9e). */
|
|
17
|
+
readonly status$?: ReadonlySignal<CellStatus>;
|
|
15
18
|
valueSet(value: RawValue | undefined): void;
|
|
16
19
|
jsonValueSet(value: JsonValue | undefined): void;
|
|
17
20
|
}
|
|
@@ -21,6 +24,7 @@ export declare class CellBase<RawValue = unknown, JsonValue = unknown, Data exte
|
|
|
21
24
|
rowId: string;
|
|
22
25
|
get dataSource(): import("../index.js").DataSource;
|
|
23
26
|
meta$: ReadonlySignal<import("../index.js").PropertyMetaConfig | undefined>;
|
|
27
|
+
status$: ReadonlySignal<CellStatus>;
|
|
24
28
|
value$: ReadonlySignal<RawValue>;
|
|
25
29
|
isEmpty$: ReadonlySignal<boolean>;
|
|
26
30
|
jsonValue$: ReadonlySignal<JsonValue | undefined>;
|
|
@@ -29,6 +33,7 @@ export declare class CellBase<RawValue = unknown, JsonValue = unknown, Data exte
|
|
|
29
33
|
get property(): Property<RawValue, JsonValue, Data>;
|
|
30
34
|
get row(): Row;
|
|
31
35
|
constructor(view: SingleView, propertyId: string, rowId: string);
|
|
36
|
+
private get _writable();
|
|
32
37
|
valueSet(value: RawValue | undefined): void;
|
|
33
38
|
jsonValueSet(value: JsonValue | undefined): void;
|
|
34
39
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { computed } from '@preact/signals-core';
|
|
2
|
+
import { cellStatusOf } from '../data-source/hydration.js';
|
|
2
3
|
import { fromJson } from '../property/utils.js';
|
|
3
4
|
export class CellBase {
|
|
4
5
|
get dataSource() {
|
|
@@ -17,6 +18,7 @@ export class CellBase {
|
|
|
17
18
|
this.meta$ = computed(() => {
|
|
18
19
|
return this.dataSource.propertyMetaGet(this.property.type$.value);
|
|
19
20
|
});
|
|
21
|
+
this.status$ = computed(() => cellStatusOf(this.dataSource, this.rowId, this.propertyId));
|
|
20
22
|
this.value$ = computed(() => {
|
|
21
23
|
return this.view.manager.dataSource.cellValueGet(this.rowId, this.propertyId);
|
|
22
24
|
});
|
|
@@ -51,10 +53,19 @@ export class CellBase {
|
|
|
51
53
|
});
|
|
52
54
|
});
|
|
53
55
|
}
|
|
56
|
+
// A value the source has not delivered (or failed to) is never written
|
|
57
|
+
// over: a paste, a fill or a kanban drop on such a cell does nothing.
|
|
58
|
+
get _writable() {
|
|
59
|
+
return this.status$.peek() === 'ready';
|
|
60
|
+
}
|
|
54
61
|
valueSet(value) {
|
|
62
|
+
if (!this._writable)
|
|
63
|
+
return;
|
|
55
64
|
this.view.manager.dataSource.cellValueChange(this.rowId, this.propertyId, value);
|
|
56
65
|
}
|
|
57
66
|
jsonValueSet(value) {
|
|
67
|
+
if (!this._writable)
|
|
68
|
+
return;
|
|
58
69
|
const meta = this.property.meta$.value;
|
|
59
70
|
if (!meta) {
|
|
60
71
|
return;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set on a data source (`serviceSet`) by the block that hosts its views when
|
|
3
|
+
* the host offers a menu beside "New" (templates and options, ADR 0035
|
|
4
|
+
* amendment of 2026-10-14). The header's "New" then draws a chevron that
|
|
5
|
+
* calls `open`; the main part still adds a row through `addRow`, as without
|
|
6
|
+
* it. Absent, "New" is the single button of 0.48, nothing else drawn.
|
|
7
|
+
*
|
|
8
|
+
* `label` is resolved by the block, which owns the wording and the
|
|
9
|
+
* translation seam, so data-view declares no key for a host's menu.
|
|
10
|
+
*/
|
|
11
|
+
export interface NewRowMenuOpener {
|
|
12
|
+
label(): string;
|
|
13
|
+
/** Asked at every render of "New"; `false` draws no chevron for this
|
|
14
|
+
* view. Absent, the chevron is drawn. */
|
|
15
|
+
canOpen?(viewId: string): boolean;
|
|
16
|
+
open(anchor: HTMLElement, viewId: string): void;
|
|
17
|
+
}
|
|
18
|
+
export declare const NewRowMenuOpenerKey: import("../../../global/di/types.js").ServiceIdentifier<NewRowMenuOpener> & (<U extends NewRowMenuOpener = NewRowMenuOpener>(variant: import("../../../global/di/types.js").ServiceVariant) => import("../../../global/di/types.js").ServiceIdentifier<U>);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set on a data source (`serviceSet`) by the block that hosts its views when
|
|
3
|
+
* the editor has a properties panel (ADR 0035 §9b, issue B10): the view
|
|
4
|
+
* options' "Properties" then opens that panel on the view instead of the
|
|
5
|
+
* popover. Absent, the popover, as in 0.48: the only way back to a hidden
|
|
6
|
+
* property must always exist, and here it is the panel or the popover.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PropertiesPanelOpenerKey: import("../../../global/di/types.js").ServiceIdentifier<(viewId: string) => void> & (<U extends (viewId: string) => void = (viewId: string) => void>(variant: import("../../../global/di/types.js").ServiceVariant) => import("../../../global/di/types.js").ServiceIdentifier<U>);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createIdentifier } from '../../../global/di/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Set on a data source (`serviceSet`) by the block that hosts its views when
|
|
4
|
+
* the editor has a properties panel (ADR 0035 §9b, issue B10): the view
|
|
5
|
+
* options' "Properties" then opens that panel on the view instead of the
|
|
6
|
+
* popover. Absent, the popover, as in 0.48: the only way back to a hidden
|
|
7
|
+
* property must always exist, and here it is the panel or the popover.
|
|
8
|
+
*/
|
|
9
|
+
export const PropertiesPanelOpenerKey = createIdentifier('data-view-properties-panel-opener');
|