@operato/board 10.29.109 → 10.29.111

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.
@@ -21,7 +21,7 @@ export declare class ComponentMenu extends ComponentMenu_base {
21
21
  updated(changes: PropertyValues<this>): void;
22
22
  findTemplate(type: string | null | undefined): void;
23
23
  onHoverComponent(e: MouseEvent): void;
24
- onClickTemplate(e: MouseEvent): void;
24
+ onClickTemplate(e: MouseEvent): Promise<void>;
25
25
  templateIcon(template: PalletItem): HTMLImageElement;
26
26
  }
27
27
  export {};
@@ -4,6 +4,7 @@
4
4
  import { __decorate } from "tslib";
5
5
  import { css, html, LitElement, nothing } from 'lit';
6
6
  import { property, query, state } from 'lit/decorators.js';
7
+ import { resolveUnknownTypes } from '@hatiolab/things-scene';
7
8
  import { ScopedElementsMixin } from '@open-wc/scoped-elements';
8
9
  import { ScrollbarStyles } from '@operato/styles';
9
10
  import { i18next } from '@operato/i18n';
@@ -95,8 +96,8 @@ export class ComponentMenu extends ScopedElementsMixin(LitElement) {
95
96
  const button = e.target;
96
97
  this.findTemplate((_a = button.closest('[data-type]')) === null || _a === void 0 ? void 0 : _a.getAttribute('data-type'));
97
98
  }
98
- onClickTemplate(e) {
99
- var _a, _b, _c;
99
+ async onClickTemplate(e) {
100
+ var _a, _b, _c, _d;
100
101
  var item = e.target;
101
102
  var type = (_a = item.closest('[data-type]')) === null || _a === void 0 ? void 0 : _a.getAttribute('data-type');
102
103
  if (!type) {
@@ -109,9 +110,17 @@ export class ComponentMenu extends ScopedElementsMixin(LitElement) {
109
110
  if (this.scene) {
110
111
  (_c = this.scene.rootContainer) === null || _c === void 0 ? void 0 : _c.trigger('addstop'); // 새로운 컴포넌트 클릭시 이전 추가 모드 정지
111
112
  this.template = this.templates.find(template => template.type == type);
112
- this.template && this.scene.startAddMode(JSON.parse(JSON.stringify(this.template.model)));
113
113
  }
114
114
  this.group = null;
115
+ if (this.scene && this.template) {
116
+ const model = JSON.parse(JSON.stringify(this.template.model));
117
+ /*
118
+ A library figure is fetched when it is picked: the tray lists the figures without them, and a type nobody
119
+ registered is placed as the stand-in that cannot move. A type registered already asks nothing.
120
+ */
121
+ await resolveUnknownTypes({ components: [model] });
122
+ (_d = this.scene) === null || _d === void 0 ? void 0 : _d.startAddMode(model);
123
+ }
115
124
  }
116
125
  templateIcon(template) {
117
126
  return template.icon || noImage;
@@ -49,6 +49,12 @@ export declare class BoardViewer extends LitElement {
49
49
  _prev: HTMLElement;
50
50
  _next: HTMLElement;
51
51
  _fabExpanded: boolean;
52
+ _simulating: boolean;
53
+ _simulatedAt: string;
54
+ private _simulationClock?;
55
+ private get _vibeLayer();
56
+ private _onToggleDaySimulation;
57
+ private _stopDaySimulation;
52
58
  get _is3dMode(): boolean;
53
59
  _fullscreen: HTMLElement;
54
60
  _fabGroup: HTMLElement;
@@ -7,6 +7,7 @@ import { customElement, property, query, state } from 'lit/decorators.js';
7
7
  import * as XLSX from 'xlsx';
8
8
  import { LoadTracker, LoadingOverlay, SCENE_MODE } from '@hatiolab/things-scene';
9
9
  import { isIOS, togglefullscreen } from '@operato/utils';
10
+ import { i18next } from '@operato/i18n';
10
11
  import { ScrollbarStyles } from '@operato/styles';
11
12
  import { createResolvedScene } from './resolved-scene.js';
12
13
  import { BoardDataStorage } from './data-storage/data-storage.js';
@@ -52,10 +53,49 @@ let BoardViewer = class BoardViewer extends LitElement {
52
53
  this._backward = [];
53
54
  this.currentBoardId = (_a = this.board) === null || _a === void 0 ? void 0 : _a.id;
54
55
  this._fabExpanded = false;
56
+ /* A day played in a minute over the board's time and weather (ADR-0263), shown and not saved. */
57
+ this._simulating = false;
58
+ this._simulatedAt = '';
55
59
  this.resizeHandler = () => {
56
60
  this._scene && this._scene.fit();
57
61
  };
58
62
  }
63
+ get _vibeLayer() {
64
+ var _a, _b;
65
+ return (_b = (_a = this._scene) === null || _a === void 0 ? void 0 : _a.root) === null || _b === void 0 ? void 0 : _b.rootModel;
66
+ }
67
+ _onToggleDaySimulation() {
68
+ var _a;
69
+ const layer = this._vibeLayer;
70
+ if (!(layer === null || layer === void 0 ? void 0 : layer.previewVibe))
71
+ return;
72
+ if (this._simulating)
73
+ return this._stopDaySimulation();
74
+ const d = new Date();
75
+ const two = (n) => String(n).padStart(2, '0');
76
+ /* From 4:30 this morning in this computer's time zone, so dawn comes soon. */
77
+ const minutes = -d.getTimezoneOffset();
78
+ const offset = `${minutes >= 0 ? '+' : '-'}${two(Math.floor(Math.abs(minutes) / 60))}:${two(Math.abs(minutes) % 60)}`;
79
+ const { enabled, ...own } = (((_a = layer.state) === null || _a === void 0 ? void 0 : _a.vibe) && typeof layer.state.vibe === 'object' ? layer.state.vibe : {});
80
+ layer.previewVibe({ ...own, mode: 'cycle', cycleSeconds: 60, time: `${d.getFullYear()}-${two(d.getMonth() + 1)}-${two(d.getDate())}T04:30:00${offset}` });
81
+ this._simulating = true;
82
+ this._simulationClock = setInterval(() => {
83
+ var _a;
84
+ const t = (_a = this._vibeLayer) === null || _a === void 0 ? void 0 : _a.vibeShownTime;
85
+ if (!t)
86
+ return;
87
+ const at = new Date(t);
88
+ this._simulatedAt = `${at.getMonth() + 1}/${at.getDate()} ${two(at.getHours())}:${two(at.getMinutes())}`;
89
+ }, 250);
90
+ }
91
+ _stopDaySimulation() {
92
+ var _a, _b;
93
+ clearInterval(this._simulationClock);
94
+ this._simulationClock = undefined;
95
+ this._simulating = false;
96
+ this._simulatedAt = '';
97
+ (_b = (_a = this._vibeLayer) === null || _a === void 0 ? void 0 : _a.previewVibe) === null || _b === void 0 ? void 0 : _b.call(_a, undefined);
98
+ }
59
99
  get _is3dMode() {
60
100
  var _a, _b, _c;
61
101
  return !!((_c = (_b = (_a = this._scene) === null || _a === void 0 ? void 0 : _a.root) === null || _b === void 0 ? void 0 : _b.rootModel) === null || _c === void 0 ? void 0 : _c.is3dMode);
@@ -123,6 +163,14 @@ let BoardViewer = class BoardViewer extends LitElement {
123
163
  title=${this._is3dMode ? '2D mode' : '3D mode'}
124
164
  ><md-icon slot="icon">${this._is3dMode ? 'view_in_ar' : '3d_rotation'}</md-icon></md-fab>
125
165
 
166
+ ${this._is3dMode ? html `
167
+ <md-fab
168
+ class="sub-fab"
169
+ @click=${() => { this._fabExpanded = false; this._onToggleDaySimulation(); }}
170
+ title=${i18next.t(this._simulating ? 'button.vibe stop simulation' : 'button.vibe simulate day')}
171
+ ><md-icon slot="icon">${this._simulating ? 'stop' : 'wb_twilight'}</md-icon></md-fab>
172
+ ` : nothing}
173
+
126
174
  ${this.playbackEnabled ? html `
127
175
  <md-fab
128
176
  class="sub-fab"
@@ -133,6 +181,8 @@ let BoardViewer = class BoardViewer extends LitElement {
133
181
  </div>
134
182
  ` : html ``}
135
183
 
184
+ ${this._simulating ? html `<div simulation-clock>${this._simulatedAt}</div>` : nothing}
185
+
136
186
  ${this._playbackActive
137
187
  ? html `
138
188
  <ox-playback-controls
@@ -161,6 +211,8 @@ let BoardViewer = class BoardViewer extends LitElement {
161
211
  }, false);
162
212
  }
163
213
  disconnectedCallback() {
214
+ if (this._simulating)
215
+ this._stopDaySimulation();
164
216
  window.removeEventListener('resize', this.resizeHandler);
165
217
  window.removeEventListener('orientationchange', this.resizeHandler);
166
218
  super.disconnectedCallback();
@@ -802,6 +854,20 @@ BoardViewer.styles = [
802
854
  z-index: 1000;
803
855
  }
804
856
 
857
+ /* The simulated time, top left over the board while a day is simulated. */
858
+ [simulation-clock] {
859
+ position: absolute;
860
+ left: 12px;
861
+ top: 12px;
862
+ padding: 4px 10px;
863
+ border-radius: 12px;
864
+ background: rgba(0, 0, 0, 0.55);
865
+ color: #fff;
866
+ font-size: 13px;
867
+ font-variant-numeric: tabular-nums;
868
+ pointer-events: none;
869
+ }
870
+
805
871
  [fab-group] {
806
872
  position: absolute;
807
873
  bottom: 15px;
@@ -910,6 +976,12 @@ __decorate([
910
976
  __decorate([
911
977
  state()
912
978
  ], BoardViewer.prototype, "_fabExpanded", void 0);
979
+ __decorate([
980
+ state()
981
+ ], BoardViewer.prototype, "_simulating", void 0);
982
+ __decorate([
983
+ state()
984
+ ], BoardViewer.prototype, "_simulatedAt", void 0);
913
985
  __decorate([
914
986
  query('#fullscreen')
915
987
  ], BoardViewer.prototype, "_fullscreen", void 0);
@@ -25,4 +25,9 @@ export type ThemesProvider = () => Promise<Record<string, unknown> | readonly Do
25
25
  * figures' own. Null takes it back.
26
26
  */
27
27
  export declare function useThemes(provider: ThemesProvider | null): void;
28
+ /**
29
+ * The model with the figures its item types are drawn by (ADR-0155) added to what it names. Items come by data, so no
30
+ * model names their look; asked together with the model's own types, they are registered before the scene opens.
31
+ */
32
+ export declare function withItemTypeFigures(model: any, itemTypes: unknown): any;
28
33
  export declare function createResolvedScene(options: SceneCreateOptions, stillWanted?: StillWanted): Promise<ReturnType<typeof create> | null>;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
- import { create, resolveUnknownTypes, sceneLookSelection } from '@hatiolab/things-scene';
4
+ import { create, isItemTypeTable, readItemTypes, resolveUnknownTypes, sceneLookSelection } from '@hatiolab/things-scene';
5
5
  let itemTypesProvider = null;
6
6
  /**
7
7
  * An app that uses item types (ADR-0155) gives this package what answers its domain's table, once, from its bootstrap
@@ -22,6 +22,19 @@ let themesProvider = null;
22
22
  export function useThemes(provider) {
23
23
  themesProvider = provider;
24
24
  }
25
+ /**
26
+ * The model with the figures its item types are drawn by (ADR-0155) added to what it names. Items come by data, so no
27
+ * model names their look; asked together with the model's own types, they are registered before the scene opens.
28
+ */
29
+ export function withItemTypeFigures(model, itemTypes) {
30
+ if (itemTypes === undefined || itemTypes === null)
31
+ return model;
32
+ const table = isItemTypeTable(itemTypes) ? itemTypes : readItemTypes(itemTypes);
33
+ const figures = [...table.types.values()].map(type => type.figure).filter((figure) => !!figure);
34
+ if (!figures.length)
35
+ return model;
36
+ return { ...model, components: [...(Array.isArray(model === null || model === void 0 ? void 0 : model.components) ? model.components : []), ...figures.map(type => ({ type }))] };
37
+ }
25
38
  export async function createResolvedScene(options, stillWanted) {
26
39
  var _a;
27
40
  if (itemTypesProvider && options.itemTypes === undefined)
@@ -43,7 +56,7 @@ export async function createResolvedScene(options, stillWanted) {
43
56
  options = { ...options, style: themes };
44
57
  }
45
58
  }
46
- const resolution = await resolveUnknownTypes(options.model);
59
+ const resolution = await resolveUnknownTypes(withItemTypeFigures(options.model, options.itemTypes));
47
60
  const { unresolved, failed } = resolution;
48
61
  /* The reason a resolver gave for each type it refused (ADR-0114 A3); older scenes report none. */
49
62
  const refused = (_a = resolution.refused) !== null && _a !== void 0 ? _a : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/board",
3
- "version": "10.29.109",
3
+ "version": "10.29.111",
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.103",
146
- "@operato/data-grist": "^10.29.103",
147
- "@operato/font": "^10.29.103",
145
+ "@operato/app": "^10.29.110",
146
+ "@operato/data-grist": "^10.29.110",
147
+ "@operato/font": "^10.29.110",
148
148
  "@operato/graphql": "^10.29.85",
149
149
  "@operato/i18n": "^10.29.85",
150
- "@operato/input": "^10.29.96",
151
- "@operato/layout": "^10.29.103",
150
+ "@operato/input": "^10.29.110",
151
+ "@operato/layout": "^10.29.110",
152
152
  "@operato/markdown": "^10.29.83",
153
153
  "@operato/popup": "^10.29.96",
154
- "@operato/property-editor": "^10.29.103",
155
- "@operato/property-panel": "^10.29.109",
154
+ "@operato/property-editor": "^10.29.110",
155
+ "@operato/property-panel": "^10.29.110",
156
156
  "@operato/styles": "^10.29.83",
157
157
  "@operato/utils": "^10.29.85",
158
158
  "@types/file-saver": "^2.0.4",
@@ -167,7 +167,7 @@
167
167
  "@custom-elements-manifest/analyzer": "^0.10.0",
168
168
  "@hatiolab/figure-model": "^0.12.20",
169
169
  "@hatiolab/prettier-config": "^1.0.0",
170
- "@hatiolab/things-scene": "^10.1.143",
170
+ "@hatiolab/things-scene": "^10.1.145",
171
171
  "@open-wc/eslint-config": "^12.0.3",
172
172
  "@open-wc/testing": "^4.0.0",
173
173
  "@rollup/plugin-image": "^3.0.3",
@@ -203,5 +203,5 @@
203
203
  "prettier --write"
204
204
  ]
205
205
  },
206
- "gitHead": "874663836d54a024c61f9c81dfaf65ba146aba60"
206
+ "gitHead": "3688a300ee361aa6570605c95d69fba1bdd978f4"
207
207
  }
@@ -71,5 +71,7 @@
71
71
  "text.space tie needs id": "Give this space an id to tie its edges.",
72
72
  "text.space tie loop": "Tying to {to} would close a loop of placements. A loop cannot be saved.",
73
73
  "text.space narrow": "Narrower than its least width: {width} (least {min})",
74
- "text.aisle leaves components outside": "{space}: {count} out of the new boundary ({items})"
74
+ "text.aisle leaves components outside": "{space}: {count} out of the new boundary ({items})",
75
+ "button.vibe simulate day": "Simulate a day",
76
+ "button.vibe stop simulation": "Stop the simulation"
75
77
  }
@@ -71,5 +71,7 @@
71
71
  "text.space tie needs id": "경계를 연결하려면 이 공간에 ID를 지정하세요.",
72
72
  "text.space tie loop": "{to}에 연결하면 배치 조건이 순환합니다. 순환하는 배치 조건은 저장할 수 없습니다.",
73
73
  "text.space narrow": "최소 폭 미달: 폭 {width} (최소 {min})",
74
- "text.aisle leaves components outside": "{space}: 새 경계 밖으로 벗어나는 항목 {count}개 ({items})"
74
+ "text.aisle leaves components outside": "{space}: 새 경계 밖으로 벗어나는 항목 {count}개 ({items})",
75
+ "button.vibe simulate day": "하루 시뮬레이션",
76
+ "button.vibe stop simulation": "시뮬레이션 중지"
75
77
  }