@formicoidea/labre-core 0.54.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/architecture/code.c4 +7547 -0
- package/architecture/likec4.config.json +3 -0
- package/architecture/model.c4 +128 -0
- package/dist/_pkgs/data-view/translations.d.ts +0 -2
- package/dist/_pkgs/data-view/translations.js +0 -6
- package/dist/_pkgs/data-view/view-presets/flat/flat-view-ui.d.ts +3 -1
- package/dist/_pkgs/data-view/view-presets/flat/flat-view-ui.js +5 -1
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/card.d.ts +6 -0
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/card.js +11 -0
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/cell.js +9 -10
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/kanban-view-ui-logic.js +3 -0
- package/dist/_pkgs/data-view/view-presets/table/mobile/cell.js +7 -4
- package/dist/_pkgs/data-view/view-presets/table/mobile/group.js +11 -8
- package/dist/_pkgs/data-view/view-presets/table/mobile/header.d.ts +8 -2
- package/dist/_pkgs/data-view/view-presets/table/mobile/header.js +47 -15
- package/dist/_pkgs/data-view/view-presets/table/mobile/menu.d.ts +3 -1
- package/dist/_pkgs/data-view/view-presets/table/mobile/menu.js +7 -3
- package/dist/_pkgs/data-view/view-presets/table/mobile/row.d.ts +23 -1
- package/dist/_pkgs/data-view/view-presets/table/mobile/row.js +131 -57
- package/dist/_pkgs/data-view/view-presets/table/mobile/table-view-ui-logic.d.ts +5 -1
- package/dist/_pkgs/data-view/view-presets/table/mobile/table-view-ui-logic.js +9 -2
- package/dist/_pkgs/data-view/view-presets/table/pc/row/row.js +5 -1
- package/dist/_pkgs/data-view/widget-presets/quick-setting-bar/filter/index.js +1 -2
- package/dist/_pkgs/data-view/widget-presets/quick-setting-bar/index.js +8 -8
- package/dist/_pkgs/data-view/widget-presets/tools/presets/filter/filter.d.ts +3 -0
- package/dist/_pkgs/data-view/widget-presets/tools/presets/filter/filter.js +125 -60
- package/dist/_pkgs/data-view/widget-presets/tools/presets/sort/sort.d.ts +3 -0
- package/dist/_pkgs/data-view/widget-presets/tools/presets/sort/sort.js +131 -66
- package/dist/_pkgs/data-view/widget-presets/tools/presets/table-add-row/add-row.js +49 -10
- package/dist/_pkgs/store/model/store/query.js +13 -1
- package/package.json +3 -2
|
@@ -1,14 +1,51 @@
|
|
|
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 { popupTargetFromElement } from '../../../../../affine-components/context-menu/index.js';
|
|
2
|
-
import { IS_MOBILE } from '../../../../../global/env/index.js';
|
|
3
36
|
import { SortIcon } from '@blocksuite/icons/lit';
|
|
4
37
|
import { computed } from '@preact/signals-core';
|
|
5
38
|
import { cssVarV2 } from '@toeverything/theme/v2';
|
|
39
|
+
import { stdContext } from '../../../../../std/index.js';
|
|
40
|
+
import { consume } from '@lit/context';
|
|
6
41
|
import { css, html, nothing } from 'lit';
|
|
7
42
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
8
43
|
import { popCreateSort } from '../../../../core/sort/add-sort.js';
|
|
9
44
|
import { sortTraitKey } from '../../../../core/sort/manager.js';
|
|
10
45
|
import { createSortUtils } from '../../../../core/sort/utils.js';
|
|
46
|
+
import { wordingOf } from '../../../../core/utils/wording.js';
|
|
11
47
|
import { WidgetBase } from '../../../../core/widget/widget-base.js';
|
|
48
|
+
import { DATA_VIEW_SORT } from '../../../../translations.js';
|
|
12
49
|
import { createDefaultShowQuickSettingBar, ShowQuickSettingBarKey, } from '../../../quick-setting-bar/context.js';
|
|
13
50
|
import { popSortRoot } from '../../../quick-setting-bar/sort/root-panel.js';
|
|
14
51
|
const styles = css `
|
|
@@ -28,80 +65,108 @@ const styles = css `
|
|
|
28
65
|
background-color: var(--affine-hover-color);
|
|
29
66
|
}
|
|
30
67
|
|
|
31
|
-
.
|
|
68
|
+
/* Shown on a phone too, its menus as sheets: 44px for a finger (P7). */
|
|
69
|
+
@media (pointer: coarse) {
|
|
70
|
+
.affine-database-sort-button {
|
|
71
|
+
min-width: 44px;
|
|
72
|
+
min-height: 44px;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
}
|
|
32
75
|
}
|
|
33
76
|
`;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
77
|
+
let DataViewHeaderToolsSort = (() => {
|
|
78
|
+
let _classSuper = WidgetBase;
|
|
79
|
+
let _std_decorators;
|
|
80
|
+
let _std_initializers = [];
|
|
81
|
+
let _std_extraInitializers = [];
|
|
82
|
+
return class DataViewHeaderToolsSort extends _classSuper {
|
|
83
|
+
static {
|
|
84
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
85
|
+
_std_decorators = [consume({ context: stdContext })];
|
|
86
|
+
__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);
|
|
87
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
88
|
+
}
|
|
89
|
+
static { this.styles = styles; }
|
|
90
|
+
get readonly() {
|
|
91
|
+
return this.view.readonly$.value;
|
|
92
|
+
}
|
|
93
|
+
clickSort(event) {
|
|
94
|
+
const sortUtils = this.sortUtils$.value;
|
|
95
|
+
if (!sortUtils) {
|
|
96
|
+
return;
|
|
41
97
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
98
|
+
if (this.hasSort.value) {
|
|
99
|
+
this.toggleShowQuickSettingBar();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
popCreateSort(popupTargetFromElement(event.currentTarget), {
|
|
103
|
+
sortUtils: {
|
|
104
|
+
...sortUtils,
|
|
105
|
+
add: sort => {
|
|
106
|
+
sortUtils.add(sort);
|
|
107
|
+
this.toggleShowQuickSettingBar(true);
|
|
108
|
+
requestAnimationFrame(() => {
|
|
109
|
+
const ele = this.closest('affine-data-view-renderer')?.querySelector('.data-view-sort-button');
|
|
110
|
+
if (ele) {
|
|
111
|
+
popSortRoot(popupTargetFromElement(ele), {
|
|
112
|
+
sortUtils: sortUtils,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
});
|
|
55
119
|
return;
|
|
56
120
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
121
|
+
#std_accessor_storage;
|
|
122
|
+
/** Absent outside an editor host: the wordings read English. */
|
|
123
|
+
get std() { return this.#std_accessor_storage; }
|
|
124
|
+
set std(value) { this.#std_accessor_storage = value; }
|
|
125
|
+
connectedCallback() {
|
|
126
|
+
super.connectedCallback();
|
|
127
|
+
this.style.display = 'flex';
|
|
60
128
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
popSortRoot(popupTargetFromElement(ele), {
|
|
71
|
-
sortUtils: sortUtils,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
connectedCallback() {
|
|
81
|
-
super.connectedCallback();
|
|
82
|
-
this.style.display = IS_MOBILE ? 'none' : 'flex';
|
|
83
|
-
}
|
|
84
|
-
render() {
|
|
85
|
-
if (this.readonly)
|
|
86
|
-
return nothing;
|
|
87
|
-
const style = styleMap({
|
|
88
|
-
color: this.hasSort.value
|
|
89
|
-
? cssVarV2('text/emphasis')
|
|
90
|
-
: cssVarV2('icon/primary'),
|
|
91
|
-
});
|
|
92
|
-
return html ` <div
|
|
129
|
+
render() {
|
|
130
|
+
if (this.readonly)
|
|
131
|
+
return nothing;
|
|
132
|
+
const style = styleMap({
|
|
133
|
+
color: this.hasSort.value
|
|
134
|
+
? cssVarV2('text/emphasis')
|
|
135
|
+
: cssVarV2('icon/primary'),
|
|
136
|
+
});
|
|
137
|
+
return html ` <div
|
|
93
138
|
@click="${this.clickSort}"
|
|
94
139
|
style="${style}"
|
|
95
140
|
class="affine-database-sort-button"
|
|
141
|
+
data-testid="dv-tools-sort"
|
|
142
|
+
role="button"
|
|
143
|
+
aria-label="${wordingOf(this.std)(DATA_VIEW_SORT)}"
|
|
96
144
|
>
|
|
97
145
|
${SortIcon()}
|
|
98
146
|
</div>`;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
147
|
+
}
|
|
148
|
+
toggleShowQuickSettingBar(show) {
|
|
149
|
+
const map = this.view.serviceGetOrCreate(ShowQuickSettingBarKey, createDefaultShowQuickSettingBar);
|
|
150
|
+
map.value = {
|
|
151
|
+
...map.value,
|
|
152
|
+
[this.view.id]: show ?? !map.value[this.view.id],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
constructor() {
|
|
156
|
+
super(...arguments);
|
|
157
|
+
this.sortUtils$ = computed(() => {
|
|
158
|
+
const sortTrait = this.view.traitGet(sortTraitKey);
|
|
159
|
+
if (sortTrait) {
|
|
160
|
+
return createSortUtils(sortTrait, this.dataViewLogic.eventTrace);
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
});
|
|
164
|
+
this.hasSort = computed(() => {
|
|
165
|
+
return (this.sortUtils$.value?.sortList$?.value?.length ?? 0) > 0;
|
|
166
|
+
});
|
|
167
|
+
this.#std_accessor_storage = __runInitializers(this, _std_initializers, void 0);
|
|
168
|
+
__runInitializers(this, _std_extraInitializers);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
})();
|
|
172
|
+
export { DataViewHeaderToolsSort };
|
|
@@ -41,7 +41,7 @@ import { css, html } from 'lit';
|
|
|
41
41
|
import { wordingOf } from '../../../../core/utils/wording.js';
|
|
42
42
|
import { NewRowMenuOpenerKey } from '../../../../core/view-manager/new-row-menu-opener.js';
|
|
43
43
|
import { WidgetBase } from '../../../../core/widget/widget-base.js';
|
|
44
|
-
import {
|
|
44
|
+
import { DATA_VIEW_NEW_PAGE, DATA_VIEW_NEW_RECORD, } from '../../../../translations.js';
|
|
45
45
|
const styles = css `
|
|
46
46
|
.new-record {
|
|
47
47
|
font-weight: 500;
|
|
@@ -54,6 +54,34 @@ const styles = css `
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/* On a phone, a blue "+" as Notion draws it: 32px drawn, 44px to touch. */
|
|
58
|
+
.new-record-phone {
|
|
59
|
+
position: relative;
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
width: 32px;
|
|
64
|
+
height: 32px;
|
|
65
|
+
margin: 6px;
|
|
66
|
+
padding: 0;
|
|
67
|
+
border: none;
|
|
68
|
+
border-radius: 8px;
|
|
69
|
+
background-color: ${unsafeCSSVarV2('button/primary')};
|
|
70
|
+
color: ${unsafeCSSVarV2('button/pureWhiteText')};
|
|
71
|
+
font-size: 20px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.new-record-phone::after {
|
|
76
|
+
content: '';
|
|
77
|
+
position: absolute;
|
|
78
|
+
inset: -6px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.new-record-phone svg {
|
|
82
|
+
color: inherit;
|
|
83
|
+
}
|
|
84
|
+
|
|
57
85
|
.new-record svg {
|
|
58
86
|
font-size: 20px;
|
|
59
87
|
color: ${unsafeCSSVarV2('icon/primary')};
|
|
@@ -114,15 +142,26 @@ let DataViewHeaderToolsAddRow = (() => {
|
|
|
114
142
|
if (this.readonly$.value) {
|
|
115
143
|
return;
|
|
116
144
|
}
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
145
|
+
const wording = wordingOf(this.std);
|
|
146
|
+
const button = IS_MOBILE
|
|
147
|
+
? html `<button
|
|
148
|
+
class="new-record-phone"
|
|
149
|
+
data-testid="dv-tools-new-row"
|
|
150
|
+
aria-label="${wording(DATA_VIEW_NEW_PAGE)}"
|
|
151
|
+
title="${wording(DATA_VIEW_NEW_PAGE)}"
|
|
152
|
+
@click="${this.onAddNewRecord}"
|
|
153
|
+
>
|
|
154
|
+
${PlusIcon()}
|
|
155
|
+
</button>`
|
|
156
|
+
: html ` <data-view-component-button
|
|
157
|
+
class="affine-database-toolbar-item new-record"
|
|
158
|
+
.onClick="${this.onAddNewRecord}"
|
|
159
|
+
.icon="${PlusIcon()}"
|
|
160
|
+
.text="${html `<span style="font-weight: 500"
|
|
161
|
+
>${wording(DATA_VIEW_NEW_RECORD)}</span
|
|
162
|
+
>`}"
|
|
163
|
+
>
|
|
164
|
+
</data-view-component-button>`;
|
|
126
165
|
const opener = this.view.serviceGet(NewRowMenuOpenerKey);
|
|
127
166
|
if (!opener || opener.canOpen?.(this.view.id) === false)
|
|
128
167
|
return button;
|
|
@@ -2,11 +2,23 @@ import isMatch from 'lodash.ismatch';
|
|
|
2
2
|
export function runQuery(query, block) {
|
|
3
3
|
const blockViewType = getBlockViewType(query, block);
|
|
4
4
|
block.blockViewType = blockViewType;
|
|
5
|
-
if (blockViewType !== 'hidden') {
|
|
5
|
+
if (blockViewType !== 'hidden' && canHideBlocks(query)) {
|
|
6
6
|
const queryMode = query.mode;
|
|
7
7
|
setAncestorsToDisplayIfHidden(queryMode, block);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* A loose query hides a block only through a `viewType: 'hidden'` entry, so
|
|
12
|
+
* without one no ancestor can be hidden and the walk below is a no-op. The
|
|
13
|
+
* walk costs one O(n) `getParent` per ancestor, which made opening a store
|
|
14
|
+
* with the default query quadratic in the block count (#507, guard
|
|
15
|
+
* `__tests__/query.unit.spec.ts`).
|
|
16
|
+
*/
|
|
17
|
+
function canHideBlocks(query) {
|
|
18
|
+
if (query.mode !== 'loose')
|
|
19
|
+
return true;
|
|
20
|
+
return query.match.some(entry => entry.viewType === 'hidden');
|
|
21
|
+
}
|
|
10
22
|
function getBlockViewType(query, block) {
|
|
11
23
|
const flavour = block.model.flavour;
|
|
12
24
|
const id = block.model.id;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formicoidea/labre-core",
|
|
3
3
|
"description": "Labre editor — the full BlockSuite-derived editor as one package.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.56.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "lajola",
|
|
@@ -904,7 +904,8 @@
|
|
|
904
904
|
}
|
|
905
905
|
},
|
|
906
906
|
"files": [
|
|
907
|
-
"dist"
|
|
907
|
+
"dist",
|
|
908
|
+
"architecture"
|
|
908
909
|
],
|
|
909
910
|
"dependencies": {
|
|
910
911
|
"@atlaskit/pragmatic-drag-and-drop": "^2.0.0",
|