@operato/board 10.29.92 → 10.29.94

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.
@@ -4,6 +4,7 @@ export interface FigureBlueprintsAnswer {
4
4
  type: string;
5
5
  ref: string;
6
6
  asset: unknown;
7
+ jointsChecked?: boolean;
7
8
  }[];
8
9
  refused: {
9
10
  type: string;
@@ -27,9 +28,13 @@ export declare const fetchFigureBlueprints: BlueprintsFetch;
27
28
  * `fetch` is a seam for tests — the default one talks to the server.
28
29
  */
29
30
  export declare function createFigureResolver(fetch?: BlueprintsFetch): (types: readonly string[]) => Promise<Refusals | undefined>;
30
- /** Registers one figure under the name the board asked. Anything but a figure asset is refused by name. */
31
+ /**
32
+ * Registers one figure under the name the board asked. Anything but a figure asset is refused by name. The server's word
33
+ * that its joints were checked goes with it, so the scene does not write them all again (figure-model ADR-0215).
34
+ */
31
35
  export declare function registerFigurePayload(type: string, payload: {
32
36
  asset?: unknown;
37
+ jointsChecked?: boolean;
33
38
  }): void;
34
39
  /**
35
40
  * Takes the seat. The package entry (`index.ts`) calls this, so an app that has `@operato/board`
@@ -55,12 +55,15 @@ export function createFigureResolver(fetch = fetchFigureBlueprints) {
55
55
  return { refused };
56
56
  };
57
57
  }
58
- /** Registers one figure under the name the board asked. Anything but a figure asset is refused by name. */
58
+ /**
59
+ * Registers one figure under the name the board asked. Anything but a figure asset is refused by name. The server's word
60
+ * that its joints were checked goes with it, so the scene does not write them all again (figure-model ADR-0215).
61
+ */
59
62
  export function registerFigurePayload(type, payload) {
60
63
  if (!(payload === null || payload === void 0 ? void 0 : payload.asset) || typeof payload.asset !== 'object') {
61
64
  throw new Error(`not a figure asset: ${type}`);
62
65
  }
63
- registerFigure(type, payload.asset);
66
+ registerFigure(type, payload.asset, { jointsChecked: payload.jointsChecked === true });
64
67
  }
65
68
  /**
66
69
  * Takes the seat. The package entry (`index.ts`) calls this, so an app that has `@operato/board`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/board",
3
- "version": "10.29.92",
3
+ "version": "10.29.94",
4
4
  "description": "Webcomponent for board following open-wc recommendations",
5
5
  "author": "heartyoh",
6
6
  "type": "module",
@@ -142,17 +142,17 @@
142
142
  "dependencies": {
143
143
  "@material/web": "^2.0.0",
144
144
  "@open-wc/scoped-elements": "^2.1.3",
145
- "@operato/app": "^10.29.90",
146
- "@operato/data-grist": "^10.29.90",
147
- "@operato/font": "^10.29.90",
145
+ "@operato/app": "^10.29.94",
146
+ "@operato/data-grist": "^10.29.94",
147
+ "@operato/font": "^10.29.94",
148
148
  "@operato/graphql": "^10.29.85",
149
149
  "@operato/i18n": "^10.29.85",
150
- "@operato/input": "^10.29.90",
151
- "@operato/layout": "^10.29.90",
150
+ "@operato/input": "^10.29.94",
151
+ "@operato/layout": "^10.29.94",
152
152
  "@operato/markdown": "^10.29.83",
153
- "@operato/popup": "^10.29.85",
154
- "@operato/property-editor": "^10.29.90",
155
- "@operato/property-panel": "^10.29.92",
153
+ "@operato/popup": "^10.29.94",
154
+ "@operato/property-editor": "^10.29.94",
155
+ "@operato/property-panel": "^10.29.94",
156
156
  "@operato/styles": "^10.29.83",
157
157
  "@operato/utils": "^10.29.85",
158
158
  "@types/file-saver": "^2.0.4",
@@ -165,6 +165,7 @@
165
165
  },
166
166
  "devDependencies": {
167
167
  "@custom-elements-manifest/analyzer": "^0.10.0",
168
+ "@hatiolab/figure-model": "^0.12.20",
168
169
  "@hatiolab/prettier-config": "^1.0.0",
169
170
  "@hatiolab/things-scene": "^10.1.123",
170
171
  "@open-wc/eslint-config": "^12.0.3",
@@ -202,5 +203,5 @@
202
203
  "prettier --write"
203
204
  ]
204
205
  },
205
- "gitHead": "70ab0f0b03aebb9e14c37e5216bd1116961786c8"
206
+ "gitHead": "5172807a0136c6f14dda157d1589abfbe35f892e"
206
207
  }
@@ -1,43 +0,0 @@
1
- import { LitElement } from 'lit';
2
- /**
3
- * A scene's actions menu (ADR-0209 amendment 1, decision 8), drawn as the scene draws its own popups -- the dark card of
4
- * the standard summary (`InfoWindow`) -- rather than as an application drop-down. It stands at the point pressed, kept
5
- * inside the window, and closes on a pick, Escape or a press outside.
6
- */
7
- export interface SceneActionMenuEntry {
8
- text: string;
9
- /** The action it runs: consecutive entries of one action make a group (a capability's commands) */
10
- action: string;
11
- run: () => void;
12
- }
13
- /**
14
- * Where the dividers go: between runs of one action, where either run has more than one entry -- so "Info · Open 360"
15
- * stay together and the commands stand apart, without a line under every single entry.
16
- */
17
- export declare function menuDividersBefore(entries: readonly {
18
- action: string;
19
- }[]): Set<number>;
20
- /** The menu's corner so that it stays inside the window: to the right and below the point, else flipped. */
21
- export declare function menuCorner(x: number, y: number, width: number, height: number, view: {
22
- width: number;
23
- height: number;
24
- }): {
25
- left: number;
26
- top: number;
27
- };
28
- export declare class OxSceneActionMenu extends LitElement {
29
- static styles: import("lit").CSSResult;
30
- entries: SceneActionMenuEntry[];
31
- private active;
32
- private dividers;
33
- private onOutside;
34
- render(): import("lit-html").TemplateResult<1>;
35
- connectedCallback(): void;
36
- disconnectedCallback(): void;
37
- firstUpdated(): void;
38
- pick(index: number): void;
39
- close: () => void;
40
- private onKey;
41
- /** Opens one menu at a point; an open one closes first. */
42
- static open(entries: SceneActionMenuEntry[], x: number, y: number): OxSceneActionMenu;
43
- }
@@ -1,163 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { css, html, LitElement } from 'lit';
3
- import { customElement, property, state } from 'lit/decorators.js';
4
- /**
5
- * Where the dividers go: between runs of one action, where either run has more than one entry -- so "Info · Open 360"
6
- * stay together and the commands stand apart, without a line under every single entry.
7
- */
8
- export function menuDividersBefore(entries) {
9
- const runs = [];
10
- entries.forEach((entry, i) => {
11
- const last = runs[runs.length - 1];
12
- if (last && entries[last.start].action === entry.action)
13
- last.length++;
14
- else
15
- runs.push({ start: i, length: 1 });
16
- });
17
- const out = new Set();
18
- for (let i = 1; i < runs.length; i++)
19
- if (runs[i].length > 1 || runs[i - 1].length > 1)
20
- out.add(runs[i].start);
21
- return out;
22
- }
23
- /** The menu's corner so that it stays inside the window: to the right and below the point, else flipped. */
24
- export function menuCorner(x, y, width, height, view) {
25
- const margin = 8;
26
- const left = x + width + margin > view.width ? Math.max(margin, x - width) : x;
27
- const top = y + height + margin > view.height ? Math.max(margin, y - height) : y;
28
- return { left, top };
29
- }
30
- let OxSceneActionMenu = class OxSceneActionMenu extends LitElement {
31
- constructor() {
32
- super(...arguments);
33
- this.entries = [];
34
- this.active = -1;
35
- this.dividers = new Set();
36
- this.onOutside = (e) => {
37
- if (!e.composedPath().includes(this))
38
- this.close();
39
- };
40
- this.close = () => {
41
- this.remove();
42
- };
43
- this.onKey = (e) => {
44
- const n = this.entries.length;
45
- if (e.key === 'Escape')
46
- this.close();
47
- else if (e.key === 'ArrowDown')
48
- this.active = (this.active + 1) % n;
49
- else if (e.key === 'ArrowUp')
50
- this.active = (this.active - 1 + n) % n;
51
- else if (e.key === 'Enter' && this.active >= 0)
52
- this.pick(this.active);
53
- else
54
- return;
55
- e.preventDefault();
56
- e.stopPropagation();
57
- };
58
- }
59
- render() {
60
- this.dividers = menuDividersBefore(this.entries);
61
- return html `${this.entries.map((entry, i) => html `${this.dividers.has(i) ? html `<div part="divider"></div>` : ''}
62
- <button part="entry" ?active=${i === this.active} @click=${() => this.pick(i)} @pointerenter=${() => (this.active = i)}>
63
- ${entry.text}
64
- </button>`)}`;
65
- }
66
- connectedCallback() {
67
- super.connectedCallback();
68
- this.tabIndex = -1;
69
- this.addEventListener('keydown', this.onKey);
70
- /* A press elsewhere closes it -- after this turn, so the press that opened it does not */
71
- setTimeout(() => {
72
- document.addEventListener('pointerdown', this.onOutside, true);
73
- window.addEventListener('blur', this.close);
74
- });
75
- }
76
- disconnectedCallback() {
77
- super.disconnectedCallback();
78
- document.removeEventListener('pointerdown', this.onOutside, true);
79
- window.removeEventListener('blur', this.close);
80
- }
81
- firstUpdated() {
82
- this.focus({ preventScroll: true });
83
- }
84
- pick(index) {
85
- const entry = this.entries[index];
86
- this.close();
87
- entry === null || entry === void 0 ? void 0 : entry.run();
88
- }
89
- /** Opens one menu at a point; an open one closes first. */
90
- static open(entries, x, y) {
91
- document.querySelectorAll('ox-scene-action-menu').forEach(m => m.close());
92
- const menu = document.createElement('ox-scene-action-menu');
93
- menu.entries = entries;
94
- menu.style.left = `${x}px`;
95
- menu.style.top = `${y}px`;
96
- document.body.appendChild(menu);
97
- /* Kept inside the window once its size is known */
98
- menu.updateComplete.then(() => {
99
- const { width, height } = menu.getBoundingClientRect();
100
- const { left, top } = menuCorner(x, y, width, height, { width: window.innerWidth, height: window.innerHeight });
101
- menu.style.left = `${left}px`;
102
- menu.style.top = `${top}px`;
103
- });
104
- return menu;
105
- }
106
- };
107
- OxSceneActionMenu.styles = css `
108
- :host {
109
- position: fixed;
110
- z-index: 1000;
111
- display: block;
112
- min-width: 148px;
113
- padding: 4px;
114
- border-radius: 7px;
115
- background-color: rgba(62, 66, 78, 0.96);
116
- color: #f2f3f5;
117
- font: normal 13px/1.4 helvetica, arial, sans-serif;
118
- box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
119
- animation: appear 120ms ease-out;
120
- outline: none;
121
- user-select: none;
122
- }
123
- @keyframes appear {
124
- from {
125
- opacity: 0;
126
- transform: translateY(-3px);
127
- }
128
- }
129
- [part='entry'] {
130
- display: block;
131
- width: 100%;
132
- box-sizing: border-box;
133
- padding: 6px 12px;
134
- border: 0;
135
- border-radius: 4px;
136
- background: transparent;
137
- color: inherit;
138
- font: inherit;
139
- text-align: left;
140
- white-space: nowrap;
141
- cursor: pointer;
142
- }
143
- [part='entry']:hover,
144
- [part='entry'][active] {
145
- background-color: rgba(255, 255, 255, 0.12);
146
- }
147
- [part='divider'] {
148
- height: 1px;
149
- margin: 4px 8px;
150
- background-color: rgba(255, 255, 255, 0.14);
151
- }
152
- `;
153
- __decorate([
154
- property({ attribute: false })
155
- ], OxSceneActionMenu.prototype, "entries", void 0);
156
- __decorate([
157
- state()
158
- ], OxSceneActionMenu.prototype, "active", void 0);
159
- OxSceneActionMenu = __decorate([
160
- customElement('ox-scene-action-menu')
161
- ], OxSceneActionMenu);
162
- export { OxSceneActionMenu };
163
- //# sourceMappingURL=ox-scene-action-menu.js.map