@formicoidea/labre-core-database 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -90,10 +90,25 @@ export class DatabasePageRoot extends BlockComponent {
90
90
  affine-database-page-root:has(dv-table-view-ui[data-page-layout]) {
91
91
  width: max-content;
92
92
  min-width: 100%;
93
+ /* Widened, the root is no longer centred by its auto margins: it
94
+ pads its left side by what centring gave the page heading (whose
95
+ container in doc-title is the same max-width, centred in the
96
+ viewport), so the heading, the view bar and the rows share one left
97
+ edge and the table grows to the right (labre recette of 1.1). The
98
+ block's sticky view bar reads the same inset. */
99
+ --affine-database-page-inset: max(
100
+ 0px,
101
+ calc((100cqw - var(--affine-editor-width, 100cqw)) / 2)
102
+ );
103
+ padding-left: calc(
104
+ var(--affine-database-page-inset) +
105
+ var(--affine-editor-side-padding, 24px)
106
+ );
93
107
  }
94
108
  /* A phone keeps the page root's narrow padding (page-root-block.ts). */
95
109
  @container viewport (width <= 640px) {
96
- affine-database-page-root {
110
+ affine-database-page-root,
111
+ affine-database-page-root:has(dv-table-view-ui[data-page-layout]) {
97
112
  padding-left: 24px;
98
113
  padding-right: 24px;
99
114
  }
@@ -53,10 +53,7 @@ export function changeViewSource(dataSource, viewId, sourceId, added) {
53
53
  ? schemaProperties(fromSchema)
54
54
  : sourceProperties(dataSource);
55
55
  const to = schemaProperties(target.schema);
56
- // A stored view is the block's reactive proxy, which `structuredClone`
57
- // (inside `remapView`) refuses; its plain JSON is what the view stores.
58
- const plain = JSON.parse(JSON.stringify(view));
59
- const { data } = remapView(plain, from, to, defaultMapping(from, to));
56
+ const { data } = remapView(view, from, to, defaultMapping(from, to));
60
57
  // The block's `updateView` merges over the stored view: a key the remap
61
58
  // removed (a grouping by a property the target lacks) is cleared with an
62
59
  // own `undefined`, as the group trait's `groupBySet(undefined)` clears it.
@@ -1,3 +1,13 @@
1
+ /**
2
+ * A plain, JSON-safe copy of a stored view. A host may hand the store's
3
+ * live view (a reactive `Proxy` over the block's props), which
4
+ * `structuredClone` refuses with a `DataCloneError` (labre hit it on
5
+ * import); view data is JSON by construction (ADR 0035 §8), so a JSON
6
+ * round-trip copies every key a view can hold, whatever the input.
7
+ */
8
+ function plainCopy(view) {
9
+ return JSON.parse(JSON.stringify(view));
10
+ }
1
11
  const OPTION_TYPES = new Set(['select', 'multi-select']);
2
12
  /** The `header` keys of the presets that name a property. */
3
13
  const HEADER_KEYS = ['titleColumn', 'iconColumn', 'imageColumn', 'coverColumn'];
@@ -32,7 +42,7 @@ function isRecord(value) {
32
42
  * A mapping onto a property that `to` does not have counts as ignored.
33
43
  */
34
44
  export function remapView(view, from, to, mapping) {
35
- const data = structuredClone(view);
45
+ const data = plainCopy(view);
36
46
  delete data.id;
37
47
  delete data.name;
38
48
  delete data.sourceId;
@@ -239,7 +249,7 @@ export function defaultMapping(from, to) {
239
249
  * REQ-DB-4 names them part of a template.
240
250
  */
241
251
  export function viewTemplateData(view) {
242
- const data = structuredClone(view);
252
+ const data = plainCopy(view);
243
253
  delete data.id;
244
254
  delete data.sourceId;
245
255
  delete data.sort;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-core-database",
3
3
  "description": "Labre core-database editing chrome for @formicoidea/labre-core.",
4
- "version": "1.1.0",
4
+ "version": "2.0.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -27,7 +27,7 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@formicoidea/labre-core": "1.1.0",
30
+ "@formicoidea/labre-core": "2.0.0",
31
31
  "@blocksuite/icons": "^2.2.12",
32
32
  "@preact/signals-core": "^1.8.0",
33
33
  "lit": "^3.2.0"