@operato/board 10.29.87 → 10.29.90
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/src/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './board-provider.js';
|
|
|
7
7
|
export * from './resolved-scene.js';
|
|
8
8
|
export * from './figure-provider.js';
|
|
9
9
|
export * from './board-placement-palette.js';
|
|
10
|
+
export * from './scene-presenters.js';
|
|
10
11
|
export * from './ox-board-viewer.js';
|
|
11
12
|
export * from './ox-board-preview.js';
|
|
12
13
|
export * from './ox-board-player.js';
|
|
@@ -14,3 +15,4 @@ export * from './ox-board-modeller.js';
|
|
|
14
15
|
export * from './ox-board-list.js';
|
|
15
16
|
export * from './ox-board-template-viewer.js';
|
|
16
17
|
export declare const uninstallFigureResolver: () => void;
|
|
18
|
+
export declare const uninstallScenePresenters: () => void;
|
package/dist/src/index.js
CHANGED
|
@@ -10,6 +10,8 @@ export * from './resolved-scene.js';
|
|
|
10
10
|
export * from './figure-provider.js';
|
|
11
11
|
/* The modeller tray asks a host app what it has to place; this is where the host registers. */
|
|
12
12
|
export * from './board-placement-palette.js';
|
|
13
|
+
/* How a scene asks before an action and shows its actions menu (ADR-0209) — the package takes those seats on load. */
|
|
14
|
+
export * from './scene-presenters.js';
|
|
13
15
|
export * from './ox-board-viewer.js';
|
|
14
16
|
export * from './ox-board-preview.js';
|
|
15
17
|
export * from './ox-board-player.js';
|
|
@@ -22,4 +24,10 @@ import { installFigureResolver } from './figure-provider.js';
|
|
|
22
24
|
figure door takes the seat back with the returned function (ADR-0063 결정 2 — 앱이 채우지 않는다).
|
|
23
25
|
*/
|
|
24
26
|
export const uninstallFigureResolver = installFigureResolver();
|
|
27
|
+
import { installScenePresenters } from './scene-presenters.js';
|
|
28
|
+
/*
|
|
29
|
+
The same declaration for how a scene asks and lists actions: the framework's prompt and popup menu instead of the
|
|
30
|
+
browser's confirm and the scene's plain list.
|
|
31
|
+
*/
|
|
32
|
+
export const uninstallScenePresenters = installScenePresenters();
|
|
25
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
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
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type SceneActionConfirm, type SceneMenuPresenter } from '@hatiolab/things-scene';
|
|
2
|
+
/**
|
|
3
|
+
* A scene's actions menu (ADR-0209 amendment 1, decision 8): the actions a component's capabilities list, at the point
|
|
4
|
+
* pressed, in the user's language. It is drawn as the scene's own popups are (`ox-scene-action-menu`, the summary's dark
|
|
5
|
+
* card) -- the application's drop-down looked foreign over a board. Picking one runs it; its confirm asks first.
|
|
6
|
+
*/
|
|
7
|
+
export declare const popupMenuPresenter: SceneMenuPresenter;
|
|
8
|
+
/**
|
|
9
|
+
* The question an action that cannot be undone asks before it runs (ADR-0209 decision 3), as the framework's prompt
|
|
10
|
+
* rather than the browser's confirm. Its words are the action's own; yes runs it.
|
|
11
|
+
*/
|
|
12
|
+
export declare const promptConfirm: SceneActionConfirm;
|
|
13
|
+
/**
|
|
14
|
+
* Takes the scene's seats for asking and for the actions menu. Having this package is the declaration, as for the
|
|
15
|
+
* figure resolver; the returned function gives both seats back.
|
|
16
|
+
*/
|
|
17
|
+
export declare function installScenePresenters(): () => void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { sceneText, setSceneActionConfirm, setSceneMenuPresenter } from '@hatiolab/things-scene';
|
|
2
|
+
import { i18next } from '@operato/i18n';
|
|
3
|
+
import { OxPrompt } from '@operato/popup';
|
|
4
|
+
import { OxSceneActionMenu } from './ox-scene-action-menu.js';
|
|
5
|
+
/**
|
|
6
|
+
* A scene's actions menu (ADR-0209 amendment 1, decision 8): the actions a component's capabilities list, at the point
|
|
7
|
+
* pressed, in the user's language. It is drawn as the scene's own popups are (`ox-scene-action-menu`, the summary's dark
|
|
8
|
+
* card) -- the application's drop-down looked foreign over a board. Picking one runs it; its confirm asks first.
|
|
9
|
+
*/
|
|
10
|
+
export const popupMenuPresenter = (items, { x, y }) => {
|
|
11
|
+
if (!items.length)
|
|
12
|
+
return;
|
|
13
|
+
const lang = i18next.language;
|
|
14
|
+
OxSceneActionMenu.open(items.map(item => ({ text: sceneText(item.label, lang) || item.text, action: item.action, run: () => item.run() })), x, y);
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The question an action that cannot be undone asks before it runs (ADR-0209 decision 3), as the framework's prompt
|
|
18
|
+
* rather than the browser's confirm. Its words are the action's own; yes runs it.
|
|
19
|
+
*/
|
|
20
|
+
export const promptConfirm = async (message) => !!(await OxPrompt.open({
|
|
21
|
+
type: 'warning',
|
|
22
|
+
title: message,
|
|
23
|
+
confirmButton: { text: i18next.t('button.confirm', { defaultValue: 'confirm' }) },
|
|
24
|
+
cancelButton: { text: i18next.t('button.cancel', { defaultValue: 'cancel' }) }
|
|
25
|
+
}));
|
|
26
|
+
/**
|
|
27
|
+
* Takes the scene's seats for asking and for the actions menu. Having this package is the declaration, as for the
|
|
28
|
+
* figure resolver; the returned function gives both seats back.
|
|
29
|
+
*/
|
|
30
|
+
export function installScenePresenters() {
|
|
31
|
+
const beforeMenu = setSceneMenuPresenter(popupMenuPresenter);
|
|
32
|
+
const beforeConfirm = setSceneActionConfirm(promptConfirm);
|
|
33
|
+
return () => {
|
|
34
|
+
setSceneMenuPresenter(beforeMenu);
|
|
35
|
+
setSceneActionConfirm(beforeConfirm);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=scene-presenters.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/board",
|
|
3
|
-
"version": "10.29.
|
|
3
|
+
"version": "10.29.90",
|
|
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.
|
|
146
|
-
"@operato/data-grist": "^10.29.
|
|
147
|
-
"@operato/font": "^10.29.
|
|
145
|
+
"@operato/app": "^10.29.90",
|
|
146
|
+
"@operato/data-grist": "^10.29.90",
|
|
147
|
+
"@operato/font": "^10.29.90",
|
|
148
148
|
"@operato/graphql": "^10.29.85",
|
|
149
149
|
"@operato/i18n": "^10.29.85",
|
|
150
|
-
"@operato/input": "^10.29.
|
|
151
|
-
"@operato/layout": "^10.29.
|
|
150
|
+
"@operato/input": "^10.29.90",
|
|
151
|
+
"@operato/layout": "^10.29.90",
|
|
152
152
|
"@operato/markdown": "^10.29.83",
|
|
153
153
|
"@operato/popup": "^10.29.85",
|
|
154
|
-
"@operato/property-editor": "^10.29.
|
|
155
|
-
"@operato/property-panel": "^10.29.
|
|
154
|
+
"@operato/property-editor": "^10.29.90",
|
|
155
|
+
"@operato/property-panel": "^10.29.90",
|
|
156
156
|
"@operato/styles": "^10.29.83",
|
|
157
157
|
"@operato/utils": "^10.29.85",
|
|
158
158
|
"@types/file-saver": "^2.0.4",
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
"devDependencies": {
|
|
167
167
|
"@custom-elements-manifest/analyzer": "^0.10.0",
|
|
168
168
|
"@hatiolab/prettier-config": "^1.0.0",
|
|
169
|
-
"@hatiolab/things-scene": "^10.1.
|
|
169
|
+
"@hatiolab/things-scene": "^10.1.123",
|
|
170
170
|
"@open-wc/eslint-config": "^12.0.3",
|
|
171
171
|
"@open-wc/testing": "^4.0.0",
|
|
172
172
|
"@rollup/plugin-image": "^3.0.3",
|
|
@@ -202,5 +202,5 @@
|
|
|
202
202
|
"prettier --write"
|
|
203
203
|
]
|
|
204
204
|
},
|
|
205
|
-
"gitHead": "
|
|
205
|
+
"gitHead": "354953417c0c6fefa2ed68da4fcfd276d95ba605"
|
|
206
206
|
}
|