@formicoidea/labre-core 0.49.0 → 0.51.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-attachment/asset-picker.d.ts +24 -0
- package/dist/_pkgs/affine-block-attachment/asset-picker.js +87 -0
- package/dist/_pkgs/affine-block-attachment/configs/slash-menu.js +3 -20
- package/dist/_pkgs/affine-block-attachment/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-attachment/index.js +1 -0
- package/dist/_pkgs/affine-block-attachment/utils.d.ts +9 -1
- package/dist/_pkgs/affine-block-attachment/utils.js +9 -0
- package/dist/_pkgs/affine-block-bookmark/adapters/markdown/markdown.js +14 -1
- package/dist/_pkgs/affine-block-bookmark/adapters/notion-html.js +5 -1
- package/dist/_pkgs/affine-block-database/adapters/markdown.js +5 -3
- package/dist/_pkgs/affine-block-embed/common/adapters/html.js +5 -3
- package/dist/_pkgs/affine-block-embed/common/adapters/markdown.js +11 -0
- package/dist/_pkgs/affine-block-frame/frame-template.d.ts +58 -0
- package/dist/_pkgs/affine-block-frame/frame-template.js +207 -0
- package/dist/_pkgs/affine-block-frame/frame-toolbar.js +19 -3
- package/dist/_pkgs/affine-block-frame/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-frame/index.js +1 -0
- package/dist/_pkgs/affine-block-frame/translations.d.ts +7 -0
- package/dist/_pkgs/affine-block-frame/translations.js +16 -1
- package/dist/_pkgs/affine-block-frame/view.js +6 -0
- package/dist/_pkgs/affine-block-image/asset-picker.d.ts +63 -0
- package/dist/_pkgs/affine-block-image/asset-picker.js +183 -0
- package/dist/_pkgs/affine-block-image/commands/insert-images.d.ts +5 -0
- package/dist/_pkgs/affine-block-image/commands/insert-images.js +8 -8
- package/dist/_pkgs/affine-block-image/components/page-image-block.d.ts +11 -0
- package/dist/_pkgs/affine-block-image/components/page-image-block.js +81 -12
- package/dist/_pkgs/affine-block-image/configs/replace-action.d.ts +9 -0
- package/dist/_pkgs/affine-block-image/configs/replace-action.js +27 -0
- package/dist/_pkgs/affine-block-image/configs/toolbar.js +6 -0
- package/dist/_pkgs/affine-block-image/crop/crop-controller.d.ts +46 -0
- package/dist/_pkgs/affine-block-image/crop/crop-controller.js +104 -0
- package/dist/_pkgs/affine-block-image/crop/crop-math.d.ts +70 -0
- package/dist/_pkgs/affine-block-image/crop/crop-math.js +141 -0
- package/dist/_pkgs/affine-block-image/crop/crop-overlay.d.ts +57 -0
- package/dist/_pkgs/affine-block-image/crop/crop-overlay.js +343 -0
- package/dist/_pkgs/affine-block-image/crop/crop-toolbar.d.ts +12 -0
- package/dist/_pkgs/affine-block-image/crop/crop-toolbar.js +78 -0
- package/dist/_pkgs/affine-block-image/crop/write-crop.d.ts +16 -0
- package/dist/_pkgs/affine-block-image/crop/write-crop.js +57 -0
- package/dist/_pkgs/affine-block-image/edgeless-clipboard-config.js +4 -1
- package/dist/_pkgs/affine-block-image/effects.js +2 -0
- package/dist/_pkgs/affine-block-image/image-block.d.ts +2 -0
- package/dist/_pkgs/affine-block-image/image-block.js +2 -0
- package/dist/_pkgs/affine-block-image/image-edgeless-block.d.ts +2 -0
- package/dist/_pkgs/affine-block-image/image-edgeless-block.js +36 -8
- package/dist/_pkgs/affine-block-image/image-resize-manager.js +15 -0
- package/dist/_pkgs/affine-block-image/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-image/index.js +1 -0
- package/dist/_pkgs/affine-block-image/translations.d.ts +15 -0
- package/dist/_pkgs/affine-block-image/translations.js +43 -0
- package/dist/_pkgs/affine-block-image/utils.d.ts +13 -0
- package/dist/_pkgs/affine-block-image/utils.js +10 -1
- package/dist/_pkgs/affine-block-root/clipboard/page-clipboard.js +5 -0
- package/dist/_pkgs/affine-block-root/commands/page-export-commands.d.ts +2 -0
- package/dist/_pkgs/affine-block-root/commands/page-export-commands.js +71 -0
- package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-root/index.js +1 -0
- package/dist/_pkgs/affine-block-root/view.js +8 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/capability.d.ts +30 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/capability.js +44 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/colors.d.ts +26 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/colors.js +82 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/command.d.ts +18 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/command.js +91 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/index.d.ts +3 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/index.js +3 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/writer.d.ts +50 -0
- package/dist/_pkgs/affine-block-surface/extensions/drawio-export/writer.js +732 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/draw-image-block.d.ts +12 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/draw-image-block.js +15 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +7 -1
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +7 -1
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +60 -1
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +2 -2
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +2 -2
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/marker-version.d.ts +6 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/marker-version.js +8 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +28 -1
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +66 -6
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +2 -7
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +2 -6
- package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +2 -0
- package/dist/_pkgs/affine-block-surface/extensions/index.js +2 -0
- package/dist/_pkgs/affine-block-surface/extensions/interchange-export.d.ts +84 -0
- package/dist/_pkgs/affine-block-surface/extensions/interchange-export.js +150 -0
- package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +24 -2
- package/dist/_pkgs/affine-block-surface/extensions/interchange.d.ts +23 -2
- package/dist/_pkgs/affine-block-surface/extensions/interchange.js +4 -1
- package/dist/_pkgs/affine-block-surface/extensions/legend-role.d.ts +18 -0
- package/dist/_pkgs/affine-block-surface/extensions/legend-role.js +20 -0
- package/dist/_pkgs/affine-block-surface/extensions/legend.d.ts +2 -19
- package/dist/_pkgs/affine-block-surface/extensions/legend.js +2 -18
- package/dist/_pkgs/affine-block-surface/extensions/svg-sanitize.d.ts +67 -0
- package/dist/_pkgs/affine-block-surface/extensions/svg-sanitize.js +235 -0
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.d.ts +1 -0
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.js +9 -0
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +17 -13
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +52 -80
- package/dist/_pkgs/affine-block-surface/extensions/xml-element.d.ts +98 -0
- package/dist/_pkgs/affine-block-surface/extensions/xml-element.js +261 -0
- package/dist/_pkgs/affine-block-surface/extensions/xml-reader.d.ts +238 -0
- package/dist/_pkgs/affine-block-surface/extensions/xml-reader.js +570 -0
- package/dist/_pkgs/affine-block-surface/framework-background/def.js +1 -1
- package/dist/_pkgs/affine-block-surface/interchange-headless.d.ts +29 -0
- package/dist/_pkgs/affine-block-surface/interchange-headless.js +32 -0
- package/dist/_pkgs/affine-block-surface/view.js +22 -2
- package/dist/_pkgs/affine-block-table/adapters/utils.js +24 -1
- package/dist/_pkgs/affine-components/color-picker/color-panel.d.ts +11 -0
- package/dist/_pkgs/affine-components/color-picker/color-panel.js +87 -12
- package/dist/_pkgs/affine-components/color-picker/framework-palette.d.ts +8 -0
- package/dist/_pkgs/affine-components/color-picker/framework-palette.js +11 -3
- package/dist/_pkgs/affine-components/color-picker/icons.d.ts +9 -0
- package/dist/_pkgs/affine-components/color-picker/icons.js +12 -0
- package/dist/_pkgs/affine-gfx-note/toolbar/note-menu.js +5 -8
- package/dist/_pkgs/affine-gfx-template/contribute.d.ts +14 -4
- package/dist/_pkgs/affine-gfx-template/contribute.js +47 -6
- package/dist/_pkgs/affine-gfx-template/toolbar/builtin-templates.d.ts +7 -2
- package/dist/_pkgs/affine-gfx-template/toolbar/builtin-templates.js +14 -40
- package/dist/_pkgs/affine-gfx-template/toolbar/resolve-name.d.ts +1 -1
- package/dist/_pkgs/affine-gfx-template/toolbar/resolve-name.js +1 -1
- package/dist/_pkgs/affine-gfx-template/toolbar/template-panel.d.ts +4 -4
- package/dist/_pkgs/affine-gfx-template/toolbar/template-panel.js +9 -9
- package/dist/_pkgs/affine-gfx-template/toolbar/template-type.d.ts +2 -4
- package/dist/_pkgs/affine-gfx-template/translations.d.ts +5 -0
- package/dist/_pkgs/affine-gfx-template/translations.js +9 -0
- package/dist/_pkgs/affine-inline-footnote/adapters/markdown/inline-delta.js +6 -0
- package/dist/_pkgs/affine-inline-footnote/adapters/markdown/markdown-inline.js +7 -0
- package/dist/_pkgs/affine-inline-link/adapters/html/html-inline.js +4 -1
- package/dist/_pkgs/affine-inline-link/adapters/html/inline-delta.js +3 -1
- package/dist/_pkgs/affine-inline-link/adapters/markdown/inline-delta.js +4 -1
- package/dist/_pkgs/affine-inline-link/adapters/notion-html/html-inline.js +2 -1
- package/dist/_pkgs/affine-inline-link/link-node/affine-link.d.ts +7 -0
- package/dist/_pkgs/affine-inline-link/link-node/affine-link.js +37 -0
- package/dist/_pkgs/affine-inline-link/link-node/index.d.ts +1 -0
- package/dist/_pkgs/affine-inline-link/link-node/index.js +1 -0
- package/dist/_pkgs/affine-inline-link/link-node/propose-views.d.ts +22 -0
- package/dist/_pkgs/affine-inline-link/link-node/propose-views.js +59 -0
- package/dist/_pkgs/affine-model/blocks/database/types.d.ts +28 -0
- package/dist/_pkgs/affine-model/blocks/image/image-crop.d.ts +48 -0
- package/dist/_pkgs/affine-model/blocks/image/image-crop.js +78 -0
- package/dist/_pkgs/affine-model/blocks/image/image-model.d.ts +6 -0
- package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
- package/dist/_pkgs/affine-model/blocks/image/index.d.ts +1 -0
- package/dist/_pkgs/affine-model/blocks/image/index.js +1 -0
- package/dist/_pkgs/affine-model/consts/shape.d.ts +2 -0
- package/dist/_pkgs/affine-model/consts/shape.js +5 -0
- package/dist/_pkgs/affine-model/elements/bpmn/consts.d.ts +31 -0
- package/dist/_pkgs/affine-model/elements/bpmn/consts.js +31 -0
- package/dist/_pkgs/affine-model/elements/bpmn/index.d.ts +1 -0
- package/dist/_pkgs/affine-model/elements/bpmn/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/bpmn/pool.d.ts +0 -25
- package/dist/_pkgs/affine-model/elements/bpmn/pool.js +1 -25
- package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +0 -2
- package/dist/_pkgs/affine-model/elements/shape/shape.js +1 -2
- package/dist/_pkgs/affine-model/elements/uml/consts.d.ts +133 -0
- package/dist/_pkgs/affine-model/elements/uml/consts.js +107 -0
- package/dist/_pkgs/affine-model/elements/uml/diagram.d.ts +1 -79
- package/dist/_pkgs/affine-model/elements/uml/diagram.js +1 -53
- package/dist/_pkgs/affine-model/elements/uml/fragment.d.ts +0 -15
- package/dist/_pkgs/affine-model/elements/uml/fragment.js +1 -15
- package/dist/_pkgs/affine-model/elements/uml/index.d.ts +1 -0
- package/dist/_pkgs/affine-model/elements/uml/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/uml/partition.d.ts +0 -20
- package/dist/_pkgs/affine-model/elements/uml/partition.js +1 -20
- package/dist/_pkgs/affine-model/elements/uml/region.d.ts +0 -11
- package/dist/_pkgs/affine-model/elements/uml/region.js +1 -11
- package/dist/_pkgs/affine-model/headless.d.ts +19 -0
- package/dist/_pkgs/affine-model/headless.js +19 -0
- package/dist/_pkgs/affine-shared/headless.d.ts +10 -0
- package/dist/_pkgs/affine-shared/headless.js +10 -0
- package/dist/_pkgs/affine-shared/services/asset-picker-service.d.ts +63 -0
- package/dist/_pkgs/affine-shared/services/asset-picker-service.js +20 -0
- package/dist/_pkgs/affine-shared/services/data-source-picker-service.d.ts +6 -3
- package/dist/_pkgs/affine-shared/services/frame-template-service.d.ts +83 -0
- package/dist/_pkgs/affine-shared/services/frame-template-service.js +17 -0
- package/dist/_pkgs/affine-shared/services/index.d.ts +2 -0
- package/dist/_pkgs/affine-shared/services/index.js +2 -0
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +6 -0
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +10 -0
- package/dist/_pkgs/affine-widget-drag-handle/watchers/drag-event-watcher.js +8 -3
- package/dist/_pkgs/affine-widget-keyboard-toolbar/config.js +4 -16
- package/dist/_pkgs/affine-widget-linked-doc/transformers/html.d.ts +7 -0
- package/dist/_pkgs/affine-widget-linked-doc/transformers/html.js +25 -24
- package/dist/_pkgs/affine-widget-linked-doc/transformers/index.d.ts +1 -1
- package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.d.ts +7 -0
- package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.js +26 -25
- package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.d.ts +23 -0
- package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.js +14 -0
- package/dist/_pkgs/data-view/core/common/properties.d.ts +29 -0
- package/dist/_pkgs/data-view/core/common/properties.js +110 -8
- package/dist/_pkgs/data-view/core/common/property-menu.d.ts +44 -1
- package/dist/_pkgs/data-view/core/common/property-menu.js +100 -3
- package/dist/_pkgs/data-view/core/component/tags/color-carousel.d.ts +41 -0
- package/dist/_pkgs/data-view/core/component/tags/color-carousel.js +199 -0
- package/dist/_pkgs/data-view/core/component/tags/color-menu.d.ts +49 -0
- package/dist/_pkgs/data-view/core/component/tags/color-menu.js +123 -0
- package/dist/_pkgs/data-view/core/component/tags/index.d.ts +3 -0
- package/dist/_pkgs/data-view/core/component/tags/index.js +3 -0
- package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.d.ts +8 -1
- package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.js +21 -20
- package/dist/_pkgs/data-view/core/component/tags/softened-colors.d.ts +42 -0
- package/dist/_pkgs/data-view/core/component/tags/softened-colors.js +79 -0
- package/dist/_pkgs/data-view/core/data-view.d.ts +8 -1
- package/dist/_pkgs/data-view/core/data-view.js +18 -2
- package/dist/_pkgs/data-view/core/effect.js +2 -1
- package/dist/_pkgs/data-view/core/filter/eval.d.ts +6 -1
- package/dist/_pkgs/data-view/core/filter/eval.js +7 -2
- package/dist/_pkgs/data-view/core/group-by/renderer/select-group.d.ts +3 -0
- package/dist/_pkgs/data-view/core/group-by/renderer/select-group.js +119 -71
- package/dist/_pkgs/data-view/core/view/color-rules.d.ts +85 -0
- package/dist/_pkgs/data-view/core/view/color-rules.js +165 -0
- package/dist/_pkgs/data-view/core/view/index.d.ts +1 -0
- package/dist/_pkgs/data-view/core/view/index.js +1 -0
- package/dist/_pkgs/data-view/property-presets/multi-select/cell-renderer.js +1 -0
- package/dist/_pkgs/data-view/property-presets/select/cell-renderer.js +1 -0
- package/dist/_pkgs/data-view/translations.d.ts +34 -0
- package/dist/_pkgs/data-view/translations.js +80 -0
- package/dist/_pkgs/data-view/view-presets/gallery/gallery-view.js +7 -1
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/card.js +6 -1
- package/dist/_pkgs/data-view/view-presets/kanban/pc/card.js +6 -1
- package/dist/_pkgs/data-view/view-presets/list/list-view.js +4 -0
- package/dist/_pkgs/data-view/view-presets/table/mobile/row.js +3 -0
- package/dist/_pkgs/data-view/view-presets/table/pc/header/database-header-column.d.ts +3 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/header/database-header-column.js +149 -175
- package/dist/_pkgs/data-view/view-presets/table/pc/row/row.js +6 -0
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/color-rules-menu.d.ts +12 -0
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/color-rules-menu.js +206 -0
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-options.js +16 -2
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-settings.d.ts +4 -2
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-settings.js +11 -2
- package/dist/commands.js +5 -2
- package/dist/host-panels.d.ts +21 -1
- package/dist/host-panels.js +50 -10
- package/dist/interchange.d.ts +1 -0
- package/dist/interchange.js +1 -0
- package/dist/model/headless.d.ts +1 -0
- package/dist/model/headless.js +1 -0
- package/dist/shared/headless.d.ts +1 -0
- package/dist/shared/headless.js +1 -0
- package/dist/translations.js +8 -1
- package/package.json +13 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DatabaseAllEvents, EventTraceFn } from '../../affine-shared/services/index.js';
|
|
2
2
|
import type { DisposableMember } from '../../global/disposable/index.js';
|
|
3
|
-
import { type Clipboard, type DndController, type EventName, ShadowlessElement, type UIEventHandler } from '../../std/index.js';
|
|
3
|
+
import { type BlockStdScope, type Clipboard, type DndController, type EventName, ShadowlessElement, type UIEventHandler } from '../../std/index.js';
|
|
4
4
|
import { type ReadonlySignal } from '@preact/signals-core';
|
|
5
5
|
import { type TemplateResult } from 'lit';
|
|
6
6
|
import type { DataSource } from './data-source/index.js';
|
|
@@ -76,6 +76,13 @@ declare const DataViewRootUI_base: typeof ShadowlessElement & import("../../glob
|
|
|
76
76
|
export declare class DataViewRootUI extends DataViewRootUI_base {
|
|
77
77
|
static styles: import("lit").CSSResult;
|
|
78
78
|
accessor logic: DataViewRootUILogic;
|
|
79
|
+
/**
|
|
80
|
+
* The editor this view renders in, absent outside one. Read by the menus a
|
|
81
|
+
* view opens, which render outside it (the colour grid's framework pages,
|
|
82
|
+
* ADR 0036 amendment of 2026-10-14). Typed as the context provides it,
|
|
83
|
+
* like the cells' `chromeStd`; it is still absent outside an editor.
|
|
84
|
+
*/
|
|
85
|
+
accessor std: BlockStdScope;
|
|
79
86
|
accessor currentView: string | undefined;
|
|
80
87
|
focusFirstCell: () => void;
|
|
81
88
|
openDetailPanel: (ops: {
|
|
@@ -35,7 +35,8 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
35
35
|
import { IS_MOBILE } from '../../global/env/index.js';
|
|
36
36
|
import { BlockSuiteError } from '../../global/exceptions/index.js';
|
|
37
37
|
import { SignalWatcher, WithDisposable } from '../../global/lit/index.js';
|
|
38
|
-
import { ShadowlessElement, } from '../../std/index.js';
|
|
38
|
+
import { ShadowlessElement, stdContext, } from '../../std/index.js';
|
|
39
|
+
import { consume } from '@lit/context';
|
|
39
40
|
import { computed, signal } from '@preact/signals-core';
|
|
40
41
|
import { css, unsafeCSS } from 'lit';
|
|
41
42
|
import { property, state } from 'lit/decorators.js';
|
|
@@ -153,6 +154,9 @@ let DataViewRootUI = (() => {
|
|
|
153
154
|
let _logic_decorators;
|
|
154
155
|
let _logic_initializers = [];
|
|
155
156
|
let _logic_extraInitializers = [];
|
|
157
|
+
let _std_decorators;
|
|
158
|
+
let _std_initializers = [];
|
|
159
|
+
let _std_extraInitializers = [];
|
|
156
160
|
let _currentView_decorators;
|
|
157
161
|
let _currentView_initializers = [];
|
|
158
162
|
let _currentView_extraInitializers = [];
|
|
@@ -160,7 +164,8 @@ let DataViewRootUI = (() => {
|
|
|
160
164
|
constructor() {
|
|
161
165
|
super(...arguments);
|
|
162
166
|
this.#logic_accessor_storage = __runInitializers(this, _logic_initializers, void 0);
|
|
163
|
-
this.#
|
|
167
|
+
this.#std_accessor_storage = (__runInitializers(this, _logic_extraInitializers), __runInitializers(this, _std_initializers, void 0));
|
|
168
|
+
this.#currentView_accessor_storage = (__runInitializers(this, _std_extraInitializers), __runInitializers(this, _currentView_initializers, undefined));
|
|
164
169
|
this.focusFirstCell = (__runInitializers(this, _currentView_extraInitializers), () => {
|
|
165
170
|
this.logic.focusFirstCell();
|
|
166
171
|
});
|
|
@@ -171,8 +176,10 @@ let DataViewRootUI = (() => {
|
|
|
171
176
|
static {
|
|
172
177
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
173
178
|
_logic_decorators = [property({ attribute: false })];
|
|
179
|
+
_std_decorators = [consume({ context: stdContext })];
|
|
174
180
|
_currentView_decorators = [state()];
|
|
175
181
|
__esDecorate(this, null, _logic_decorators, { kind: "accessor", name: "logic", static: false, private: false, access: { has: obj => "logic" in obj, get: obj => obj.logic, set: (obj, value) => { obj.logic = value; } }, metadata: _metadata }, _logic_initializers, _logic_extraInitializers);
|
|
182
|
+
__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);
|
|
176
183
|
__esDecorate(this, null, _currentView_decorators, { kind: "accessor", name: "currentView", static: false, private: false, access: { has: obj => "currentView" in obj, get: obj => obj.currentView, set: (obj, value) => { obj.currentView = value; } }, metadata: _metadata }, _currentView_initializers, _currentView_extraInitializers);
|
|
177
184
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
178
185
|
}
|
|
@@ -186,6 +193,15 @@ let DataViewRootUI = (() => {
|
|
|
186
193
|
#logic_accessor_storage;
|
|
187
194
|
get logic() { return this.#logic_accessor_storage; }
|
|
188
195
|
set logic(value) { this.#logic_accessor_storage = value; }
|
|
196
|
+
#std_accessor_storage;
|
|
197
|
+
/**
|
|
198
|
+
* The editor this view renders in, absent outside one. Read by the menus a
|
|
199
|
+
* view opens, which render outside it (the colour grid's framework pages,
|
|
200
|
+
* ADR 0036 amendment of 2026-10-14). Typed as the context provides it,
|
|
201
|
+
* like the cells' `chromeStd`; it is still absent outside an editor.
|
|
202
|
+
*/
|
|
203
|
+
get std() { return this.#std_accessor_storage; }
|
|
204
|
+
set std(value) { this.#std_accessor_storage = value; }
|
|
189
205
|
#currentView_accessor_storage;
|
|
190
206
|
get currentView() { return this.#currentView_accessor_storage; }
|
|
191
207
|
set currentView(value) { this.#currentView_accessor_storage = value; }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DataViewPropertiesSettingView } from './common/properties.js';
|
|
2
2
|
import { Button } from './component/button/button.js';
|
|
3
3
|
import { Overflow } from './component/overflow/overflow.js';
|
|
4
|
-
import { MultiTagSelect, MultiTagView } from './component/tags/index.js';
|
|
4
|
+
import { DataViewColorCarousel, MultiTagSelect, MultiTagView, } from './component/tags/index.js';
|
|
5
5
|
import { DataViewRootUI } from './data-view.js';
|
|
6
6
|
import { RecordDetail } from './detail/detail.js';
|
|
7
7
|
import { RecordField } from './detail/field.js';
|
|
@@ -33,6 +33,7 @@ export function coreEffects() {
|
|
|
33
33
|
customElements.define('data-view-group-title-boolean-view', BooleanGroupView);
|
|
34
34
|
customElements.define('data-view-group-title-date-view', DateGroupView);
|
|
35
35
|
customElements.define('affine-multi-tag-view', MultiTagView);
|
|
36
|
+
customElements.define('dv-color-carousel', DataViewColorCarousel);
|
|
36
37
|
customElements.define('uni-lit', UniLit);
|
|
37
38
|
customElements.define('uni-any-render', UniAnyRender);
|
|
38
39
|
customElements.define('variable-ref-view', VariableRefView);
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { Filter } from './types.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* `undecided` is what a condition nothing can apply answers: `true` for a
|
|
4
|
+
* view filter (an unfinished condition hides no row), `false` for a colour
|
|
5
|
+
* rule (an unfinished condition colours no row, ADR 0036).
|
|
6
|
+
*/
|
|
7
|
+
export declare const evalFilter: (filterGroup: Filter, row: Record<string, unknown>, undecided?: boolean) => boolean;
|
|
@@ -32,7 +32,12 @@ const applyFilter = (func, value, filter) => {
|
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* `undecided` is what a condition nothing can apply answers: `true` for a
|
|
37
|
+
* view filter (an unfinished condition hides no row), `false` for a colour
|
|
38
|
+
* rule (an unfinished condition colours no row, ADR 0036).
|
|
39
|
+
*/
|
|
40
|
+
export const evalFilter = (filterGroup, row, undecided = true) => {
|
|
36
41
|
const evalF = (filter) => {
|
|
37
42
|
if (filter.type === 'filter') {
|
|
38
43
|
const value = evalRef(filter.left, row);
|
|
@@ -46,7 +51,7 @@ export const evalFilter = (filterGroup, row) => {
|
|
|
46
51
|
return result;
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
return
|
|
54
|
+
return undecided;
|
|
50
55
|
}
|
|
51
56
|
else if (filter.type === 'group') {
|
|
52
57
|
if (filter.op === 'and') {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BlockStdScope } from '../../../../std/index.js';
|
|
1
2
|
import type { SelectTag } from '../../logical/index.js';
|
|
2
3
|
import { BaseGroup } from './base.js';
|
|
3
4
|
export declare class SelectGroupView extends BaseGroup<string, {
|
|
@@ -5,6 +6,8 @@ export declare class SelectGroupView extends BaseGroup<string, {
|
|
|
5
6
|
}> {
|
|
6
7
|
static styles: import("lit").CSSResult;
|
|
7
8
|
private readonly _click;
|
|
9
|
+
/** Absent outside an editor host: the colour names read English. */
|
|
10
|
+
accessor std: BlockStdScope;
|
|
8
11
|
get tag(): {
|
|
9
12
|
id: string;
|
|
10
13
|
value: string;
|
|
@@ -1,48 +1,59 @@
|
|
|
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
|
+
};
|
|
1
35
|
import { menu, popMenu, popupTargetFromElement, } from '../../../../affine-components/context-menu/index.js';
|
|
36
|
+
import { stdContext } from '../../../../std/index.js';
|
|
37
|
+
import { consume } from '@lit/context';
|
|
2
38
|
import { css, html } from 'lit';
|
|
3
39
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
40
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
5
|
-
import {
|
|
41
|
+
import { selectOptionColorGrid } from '../../component/tags/color-menu.js';
|
|
42
|
+
import { wordingOf } from '../../utils/wording.js';
|
|
6
43
|
import { BaseGroup } from './base.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
onChange: text => {
|
|
21
|
-
this.updateTag({ value: text });
|
|
22
|
-
},
|
|
23
|
-
}),
|
|
24
|
-
...selectOptionColors.map(({ color, name }) => {
|
|
25
|
-
const styles = styleMap({
|
|
26
|
-
backgroundColor: color,
|
|
27
|
-
borderRadius: '50%',
|
|
28
|
-
width: '20px',
|
|
29
|
-
height: '20px',
|
|
30
|
-
});
|
|
31
|
-
return menu.action({
|
|
32
|
-
name: name,
|
|
33
|
-
isSelected: this.tag?.color === color,
|
|
34
|
-
prefix: html ` <div style=${styles}></div>`,
|
|
35
|
-
select: () => {
|
|
36
|
-
this.updateTag({ color });
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}),
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
static { this.styles = css `
|
|
44
|
+
let SelectGroupView = (() => {
|
|
45
|
+
let _classSuper = BaseGroup;
|
|
46
|
+
let _std_decorators;
|
|
47
|
+
let _std_initializers = [];
|
|
48
|
+
let _std_extraInitializers = [];
|
|
49
|
+
return class SelectGroupView extends _classSuper {
|
|
50
|
+
static {
|
|
51
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
52
|
+
_std_decorators = [consume({ context: stdContext })];
|
|
53
|
+
__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);
|
|
54
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
55
|
+
}
|
|
56
|
+
static { this.styles = css `
|
|
46
57
|
data-view-group-title-select-view {
|
|
47
58
|
overflow: hidden;
|
|
48
59
|
}
|
|
@@ -66,41 +77,78 @@ export class SelectGroupView extends BaseGroup {
|
|
|
66
77
|
white-space: nowrap;
|
|
67
78
|
}
|
|
68
79
|
`; }
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
#std_accessor_storage;
|
|
81
|
+
/** Absent outside an editor host: the colour names read English. */
|
|
82
|
+
get std() { return this.#std_accessor_storage; }
|
|
83
|
+
set std(value) { this.#std_accessor_storage = value; }
|
|
84
|
+
get tag() {
|
|
85
|
+
return this.data.options?.find(v => v.id === this.value);
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
const tag = this.tag;
|
|
89
|
+
if (!tag) {
|
|
90
|
+
return html ` <div
|
|
76
91
|
style="font-size: 14px;color: var(--affine-text-primary-color);line-height: 22px;"
|
|
77
92
|
>
|
|
78
93
|
Ungroups
|
|
79
94
|
</div>`;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
}
|
|
96
|
+
const style = styleMap({
|
|
97
|
+
backgroundColor: tag.color,
|
|
98
|
+
});
|
|
99
|
+
const classList = classMap({
|
|
100
|
+
'data-view-group-title-select-view': true,
|
|
101
|
+
readonly: this.readonly,
|
|
102
|
+
});
|
|
103
|
+
return html ` <div @click="${this._click}" class="${classList}">
|
|
89
104
|
<div class="tag" style="${style}">${tag.value}</div>
|
|
90
105
|
</div>`;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
106
|
+
}
|
|
107
|
+
updateTag(tag) {
|
|
108
|
+
this.updateData?.({
|
|
109
|
+
...this.data,
|
|
110
|
+
options: this.data.options.map(v => {
|
|
111
|
+
if (v.id === this.value) {
|
|
112
|
+
return {
|
|
113
|
+
...v,
|
|
114
|
+
...tag,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return v;
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
constructor() {
|
|
122
|
+
super(...arguments);
|
|
123
|
+
this._click = (e) => {
|
|
124
|
+
if (this.readonly) {
|
|
125
|
+
return;
|
|
101
126
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
127
|
+
e.stopPropagation();
|
|
128
|
+
popMenu(popupTargetFromElement(this), {
|
|
129
|
+
options: {
|
|
130
|
+
items: [
|
|
131
|
+
menu.input({
|
|
132
|
+
initialValue: this.tag?.value ?? '',
|
|
133
|
+
onChange: text => {
|
|
134
|
+
this.updateTag({ value: text });
|
|
135
|
+
},
|
|
136
|
+
}),
|
|
137
|
+
...selectOptionColorGrid({
|
|
138
|
+
current: this.tag?.color,
|
|
139
|
+
say: wordingOf(this.std),
|
|
140
|
+
std: this.std,
|
|
141
|
+
select: color => {
|
|
142
|
+
this.updateTag({ color });
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
this.#std_accessor_storage = __runInitializers(this, _std_initializers, void 0);
|
|
150
|
+
__runInitializers(this, _std_extraInitializers);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
})();
|
|
154
|
+
export { SelectGroupView };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Filter, FilterGroup } from '../filter/types.js';
|
|
2
|
+
import type { SingleView } from '../view-manager/single-view.js';
|
|
3
|
+
/**
|
|
4
|
+
* Conditional colours of a view (ADR 0036; labre PRD REQ-DB-4, REQ-DB-10):
|
|
5
|
+
* the stored `colorRules` of a view, read, evaluated and written here, in
|
|
6
|
+
* core, so every stored rule paints whatever bundle or flag the host has;
|
|
7
|
+
* the editor is a view setting like the filter (`color-rules-menu.ts`).
|
|
8
|
+
*
|
|
9
|
+
* A rule is `{ id, color, filter }`: `filter` is a view filter's own shape
|
|
10
|
+
* (`FilterGroup`, same functions, same editor), `color` a colour of the
|
|
11
|
+
* select options' palette, stored as an option stores it.
|
|
12
|
+
*/
|
|
13
|
+
export type ViewColorRule = {
|
|
14
|
+
id: string;
|
|
15
|
+
color: string;
|
|
16
|
+
filter: FilterGroup;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The custom property a coloured row or card carries; each layout's
|
|
20
|
+
* stylesheet reads it as its background in place of its own, and a
|
|
21
|
+
* selection or a hover still paints over it.
|
|
22
|
+
*
|
|
23
|
+
* ponytail: the virtual table (`enable_table_virtual_scroll`, off by
|
|
24
|
+
* default) paints no rule, its rows being grid cells; upgrade: paint each
|
|
25
|
+
* `DatabaseCellContainer` of `table/pc-virtual/row/cell.ts` from
|
|
26
|
+
* `viewRowColor`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ROW_COLOR_PROPERTY = "--data-view-row-color";
|
|
29
|
+
/**
|
|
30
|
+
* The stored rules of a view, in order, keeping only what reads as a rule
|
|
31
|
+
* (an id, a colour string, a filter group): a value a newer client wrote in
|
|
32
|
+
* another shape is skipped, never thrown on. Absent, no rule.
|
|
33
|
+
*/
|
|
34
|
+
export declare function viewColorRules(data: object | undefined): ViewColorRule[];
|
|
35
|
+
/**
|
|
36
|
+
* The palette colour a stored value names, or `undefined` for a value this
|
|
37
|
+
* build does not know. Only a palette colour is ever painted: a stored
|
|
38
|
+
* string is never put into a style as is, except a softened framework
|
|
39
|
+
* colour that passes the strict `isSoftenedChipColor` shape (ADR 0036
|
|
40
|
+
* amendment of 2026-10-14, "framework pages"). That check reads the string
|
|
41
|
+
* alone, never a flag or a registered palette, so a rule painted with a
|
|
42
|
+
* framework page paints whatever the host has switched off.
|
|
43
|
+
*/
|
|
44
|
+
export declare function colorRulePaint(color: string): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The colour of a row, given what `cellOf` reads for a property: the first
|
|
47
|
+
* rule whose filter matches wins. A rule with no condition matches no row,
|
|
48
|
+
* and a condition that cannot decide (a value not picked yet) does not
|
|
49
|
+
* match: a rule being written colours nothing until it says something. A
|
|
50
|
+
* matching rule whose colour this build does not know still wins, and
|
|
51
|
+
* paints nothing, as the newer client that wrote it would paint its own
|
|
52
|
+
* colour there and not a later rule's.
|
|
53
|
+
*/
|
|
54
|
+
export declare function colorRulesMatch(rules: readonly ViewColorRule[], cellOf: (propertyId: string) => unknown): string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The colour of `rowId` in `view`, read inside a render so the row repaints
|
|
57
|
+
* when a rule or a value it reads changes. A fallback view (ADR 0035 §6)
|
|
58
|
+
* trusts none of its stored settings, rules included.
|
|
59
|
+
*/
|
|
60
|
+
export declare function viewRowColor(view: SingleView, rowId: string): string | undefined;
|
|
61
|
+
/** Set or clear the colour a row or card element paints. */
|
|
62
|
+
export declare function paintRowColor(element: HTMLElement, color: string | undefined): void;
|
|
63
|
+
/** The same, for a template's `styleMap`. */
|
|
64
|
+
export declare function rowColorStyle(color: string | undefined): {
|
|
65
|
+
"--data-view-row-color": string;
|
|
66
|
+
} | {
|
|
67
|
+
"--data-view-row-color"?: undefined;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Write the rules of `view`. Written on a gesture alone, and not when it
|
|
71
|
+
* changes nothing; a read-only view and a fallback view are never written.
|
|
72
|
+
* Returns whether it wrote.
|
|
73
|
+
*/
|
|
74
|
+
export declare function viewColorRulesSet(view: SingleView, rules: readonly ViewColorRule[]): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Add a rule at the end, on `condition`, in the next palette colour no rule
|
|
77
|
+
* uses yet (the first one when every colour is taken). Its id, or `null`
|
|
78
|
+
* when nothing was written.
|
|
79
|
+
*/
|
|
80
|
+
export declare function colorRuleAdd(view: SingleView, condition: Filter): string | null;
|
|
81
|
+
/** Change a rule's colour or condition. */
|
|
82
|
+
export declare function colorRuleUpdate(view: SingleView, id: string, patch: Partial<Pick<ViewColorRule, 'color' | 'filter'>>): boolean;
|
|
83
|
+
export declare function colorRuleDelete(view: SingleView, id: string): boolean;
|
|
84
|
+
/** Move a rule one place earlier (`-1`) or later (`1`): order decides. */
|
|
85
|
+
export declare function colorRuleMove(view: SingleView, id: string, delta: -1 | 1): boolean;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { nanoid } from '../../../store/index.js';
|
|
2
|
+
import { selectOptionColors } from '../component/tags/colors.js';
|
|
3
|
+
import { isSoftenedChipColor } from '../component/tags/softened-colors.js';
|
|
4
|
+
import { evalFilter } from '../filter/eval.js';
|
|
5
|
+
/**
|
|
6
|
+
* The custom property a coloured row or card carries; each layout's
|
|
7
|
+
* stylesheet reads it as its background in place of its own, and a
|
|
8
|
+
* selection or a hover still paints over it.
|
|
9
|
+
*
|
|
10
|
+
* ponytail: the virtual table (`enable_table_virtual_scroll`, off by
|
|
11
|
+
* default) paints no rule, its rows being grid cells; upgrade: paint each
|
|
12
|
+
* `DatabaseCellContainer` of `table/pc-virtual/row/cell.ts` from
|
|
13
|
+
* `viewRowColor`.
|
|
14
|
+
*/
|
|
15
|
+
export const ROW_COLOR_PROPERTY = '--data-view-row-color';
|
|
16
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
17
|
+
/**
|
|
18
|
+
* The stored rules of a view, in order, keeping only what reads as a rule
|
|
19
|
+
* (an id, a colour string, a filter group): a value a newer client wrote in
|
|
20
|
+
* another shape is skipped, never thrown on. Absent, no rule.
|
|
21
|
+
*/
|
|
22
|
+
export function viewColorRules(data) {
|
|
23
|
+
const stored = data?.colorRules;
|
|
24
|
+
if (!Array.isArray(stored))
|
|
25
|
+
return [];
|
|
26
|
+
return stored.filter((rule) => isRecord(rule) &&
|
|
27
|
+
typeof rule.id === 'string' &&
|
|
28
|
+
typeof rule.color === 'string' &&
|
|
29
|
+
isRecord(rule.filter) &&
|
|
30
|
+
rule.filter.type === 'group' &&
|
|
31
|
+
Array.isArray(rule.filter.conditions));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The palette colour a stored value names, or `undefined` for a value this
|
|
35
|
+
* build does not know. Only a palette colour is ever painted: a stored
|
|
36
|
+
* string is never put into a style as is, except a softened framework
|
|
37
|
+
* colour that passes the strict `isSoftenedChipColor` shape (ADR 0036
|
|
38
|
+
* amendment of 2026-10-14, "framework pages"). That check reads the string
|
|
39
|
+
* alone, never a flag or a registered palette, so a rule painted with a
|
|
40
|
+
* framework page paints whatever the host has switched off.
|
|
41
|
+
*/
|
|
42
|
+
export function colorRulePaint(color) {
|
|
43
|
+
if (isSoftenedChipColor(color))
|
|
44
|
+
return color;
|
|
45
|
+
return selectOptionColors.find(item => item.color === color || item.oldColor === color)?.color;
|
|
46
|
+
}
|
|
47
|
+
/** The property ids a filter reads, nested groups included. */
|
|
48
|
+
function referencedProperties(filter, into) {
|
|
49
|
+
if (filter.type === 'filter')
|
|
50
|
+
into.add(filter.left.name);
|
|
51
|
+
else
|
|
52
|
+
filter.conditions.forEach(condition => referencedProperties(condition, into));
|
|
53
|
+
return into;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The colour of a row, given what `cellOf` reads for a property: the first
|
|
57
|
+
* rule whose filter matches wins. A rule with no condition matches no row,
|
|
58
|
+
* and a condition that cannot decide (a value not picked yet) does not
|
|
59
|
+
* match: a rule being written colours nothing until it says something. A
|
|
60
|
+
* matching rule whose colour this build does not know still wins, and
|
|
61
|
+
* paints nothing, as the newer client that wrote it would paint its own
|
|
62
|
+
* colour there and not a later rule's.
|
|
63
|
+
*/
|
|
64
|
+
export function colorRulesMatch(rules, cellOf) {
|
|
65
|
+
for (const rule of rules) {
|
|
66
|
+
if (!rule.filter.conditions.length)
|
|
67
|
+
continue;
|
|
68
|
+
const row = {};
|
|
69
|
+
referencedProperties(rule.filter, new Set()).forEach(id => {
|
|
70
|
+
row[id] = cellOf(id);
|
|
71
|
+
});
|
|
72
|
+
if (evalFilter(rule.filter, row, false))
|
|
73
|
+
return colorRulePaint(rule.color);
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The colour of `rowId` in `view`, read inside a render so the row repaints
|
|
79
|
+
* when a rule or a value it reads changes. A fallback view (ADR 0035 §6)
|
|
80
|
+
* trusts none of its stored settings, rules included.
|
|
81
|
+
*/
|
|
82
|
+
export function viewRowColor(view, rowId) {
|
|
83
|
+
if (view.shownAsFallback$.value)
|
|
84
|
+
return undefined;
|
|
85
|
+
const rules = viewColorRules(view.manager.dataSource.viewDataGet(view.id));
|
|
86
|
+
if (!rules.length)
|
|
87
|
+
return undefined;
|
|
88
|
+
const known = new Set(view.propertiesRaw$.value.map(property => property.id));
|
|
89
|
+
return colorRulesMatch(rules, id => known.has(id) ? view.cellGetOrCreate(rowId, id).jsonValue$.value : undefined);
|
|
90
|
+
}
|
|
91
|
+
/** Set or clear the colour a row or card element paints. */
|
|
92
|
+
export function paintRowColor(element, color) {
|
|
93
|
+
if (color)
|
|
94
|
+
element.style.setProperty(ROW_COLOR_PROPERTY, color);
|
|
95
|
+
else
|
|
96
|
+
element.style.removeProperty(ROW_COLOR_PROPERTY);
|
|
97
|
+
}
|
|
98
|
+
/** The same, for a template's `styleMap`. */
|
|
99
|
+
export function rowColorStyle(color) {
|
|
100
|
+
return color ? { [ROW_COLOR_PROPERTY]: color } : {};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Write the rules of `view`. Written on a gesture alone, and not when it
|
|
104
|
+
* changes nothing; a read-only view and a fallback view are never written.
|
|
105
|
+
* Returns whether it wrote.
|
|
106
|
+
*/
|
|
107
|
+
export function viewColorRulesSet(view, rules) {
|
|
108
|
+
if (view.readonly$.peek() || view.shownAsFallback$.peek())
|
|
109
|
+
return false;
|
|
110
|
+
const dataSource = view.manager.dataSource;
|
|
111
|
+
const current = viewColorRules(dataSource.viewDataGet(view.id));
|
|
112
|
+
if (JSON.stringify(current) === JSON.stringify(rules))
|
|
113
|
+
return false;
|
|
114
|
+
// The model's type, so the stored shape is the one ADR 0036 declares.
|
|
115
|
+
const colorRules = rules.map(rule => ({
|
|
116
|
+
id: rule.id,
|
|
117
|
+
color: rule.color,
|
|
118
|
+
filter: rule.filter,
|
|
119
|
+
}));
|
|
120
|
+
dataSource.viewDataUpdate(view.id, () => ({ colorRules }));
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
const rulesOf = (view) => viewColorRules(view.manager.dataSource.viewDataGet(view.id));
|
|
124
|
+
/**
|
|
125
|
+
* Add a rule at the end, on `condition`, in the next palette colour no rule
|
|
126
|
+
* uses yet (the first one when every colour is taken). Its id, or `null`
|
|
127
|
+
* when nothing was written.
|
|
128
|
+
*/
|
|
129
|
+
export function colorRuleAdd(view, condition) {
|
|
130
|
+
const rules = rulesOf(view);
|
|
131
|
+
const used = new Set(rules.map(rule => colorRulePaint(rule.color)));
|
|
132
|
+
const color = (selectOptionColors.find(item => !used.has(item.color)) ??
|
|
133
|
+
selectOptionColors[0])?.color;
|
|
134
|
+
if (!color)
|
|
135
|
+
return null;
|
|
136
|
+
const rule = {
|
|
137
|
+
id: nanoid(),
|
|
138
|
+
color,
|
|
139
|
+
filter: { type: 'group', op: 'and', conditions: [condition] },
|
|
140
|
+
};
|
|
141
|
+
return viewColorRulesSet(view, [...rules, rule]) ? rule.id : null;
|
|
142
|
+
}
|
|
143
|
+
/** Change a rule's colour or condition. */
|
|
144
|
+
export function colorRuleUpdate(view, id, patch) {
|
|
145
|
+
const rules = rulesOf(view);
|
|
146
|
+
if (!rules.some(rule => rule.id === id))
|
|
147
|
+
return false;
|
|
148
|
+
return viewColorRulesSet(view, rules.map(rule => (rule.id === id ? { ...rule, ...patch } : rule)));
|
|
149
|
+
}
|
|
150
|
+
export function colorRuleDelete(view, id) {
|
|
151
|
+
const rules = rulesOf(view);
|
|
152
|
+
return viewColorRulesSet(view, rules.filter(rule => rule.id !== id));
|
|
153
|
+
}
|
|
154
|
+
/** Move a rule one place earlier (`-1`) or later (`1`): order decides. */
|
|
155
|
+
export function colorRuleMove(view, id, delta) {
|
|
156
|
+
const rules = [...rulesOf(view)];
|
|
157
|
+
const from = rules.findIndex(rule => rule.id === id);
|
|
158
|
+
const to = from + delta;
|
|
159
|
+
const rule = rules[from];
|
|
160
|
+
if (from < 0 || !rule || to < 0 || to >= rules.length)
|
|
161
|
+
return false;
|
|
162
|
+
rules.splice(from, 1);
|
|
163
|
+
rules.splice(to, 0, rule);
|
|
164
|
+
return viewColorRulesSet(view, rules);
|
|
165
|
+
}
|