@operato/property-panel 10.29.90 → 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.
@@ -25,6 +25,7 @@ export declare class EventHandlersMapper extends LitElement {
25
25
  handler: EventHandlerSpec;
26
26
  scene?: Scene;
27
27
  render(): import("lit-html").TemplateResult<1>;
28
+ private _renderGiven;
28
29
  private _renderScriptFields;
29
30
  private _renderActionFields;
30
31
  private _update;
@@ -11,7 +11,7 @@ import '@operato/input/ox-input-code.js';
11
11
  import '@operato/i18n/ox-i18n.js';
12
12
  import { css, html, LitElement } from 'lit';
13
13
  import { property } from 'lit/decorators.js';
14
- import { GESTURE_MEANINGS, meaningOfTrigger, sceneActionNames, triggerOfMeaning } from '@hatiolab/things-scene';
14
+ import { GESTURE_MEANINGS, capabilityText, figureCapabilityDescriptorOf, hasOwnHandlerOf, meaningOfTrigger, sceneActionNames, sceneInteractionsOf, triggerOfMeaning } from '@hatiolab/things-scene';
15
15
  import { i18next } from '@operato/i18n';
16
16
  /*
17
17
  A handler is put on a meaning, not a gesture (ADR-0209 decision 2): the four meanings of things-scene's table, then the
@@ -24,7 +24,16 @@ const actionsOf = (current) => {
24
24
  const names = ['', 'script', ...sceneActionNames().filter(n => n !== 'script').sort()];
25
25
  return current && !names.includes(current) ? [...names, current] : names;
26
26
  };
27
- const words = (text) => (String(i18next.language || '').startsWith('ko') ? text.ko : text.en);
27
+ /* Words in the user's language, by the one rule (figure-model `capabilityText`): the gesture table's and a capability's. */
28
+ const words = (text) => capabilityText(text, i18next.language);
29
+ /* An interaction a capability gives, in words: whose, what (its own words, else the action's name) and on which part. */
30
+ const interactionWords = (one) => {
31
+ var _a;
32
+ const whose = one.capability ? words((_a = figureCapabilityDescriptorOf(one.capability)) === null || _a === void 0 ? void 0 : _a.label) || one.capability : '';
33
+ const what = words(one.label) || one.action;
34
+ const part = one.part ? ` (${i18next.t('text.capability-interaction-part', { part: one.part })})` : '';
35
+ return `${whose ? whose + ' · ' : ''}${what}${part}`;
36
+ };
28
37
  export class EventHandlersMapper extends LitElement {
29
38
  constructor() {
30
39
  super(...arguments);
@@ -49,6 +58,8 @@ export class EventHandlersMapper extends LitElement {
49
58
  </select>
50
59
  </div>
51
60
 
61
+ ${this._renderGiven(h)}
62
+
52
63
  <div class="row">
53
64
  <label><ox-i18n msgid="label.action">Action</ox-i18n></label>
54
65
  <select
@@ -64,6 +75,30 @@ export class EventHandlersMapper extends LitElement {
64
75
  : (h.action ? this._renderActionFields(h) : null)}
65
76
  `;
66
77
  }
78
+ /*
79
+ What the selected component's capabilities already do on the handler's meaning (ADR-0209 decision 7), and that a
80
+ handler of that meaning runs in their place -- the scene's one rule, `hasOwnHandlerOf`, asked of this handler.
81
+ */
82
+ _renderGiven(h) {
83
+ var _a, _b;
84
+ const meaning = meaningOfTrigger(h.trigger || 'click');
85
+ const component = (_b = (_a = this.scene) === null || _a === void 0 ? void 0 : _a.selected) === null || _b === void 0 ? void 0 : _b[0];
86
+ if (!meaning || !component)
87
+ return null;
88
+ const given = sceneInteractionsOf(component).filter(one => one.meaning === meaning);
89
+ if (!given.length)
90
+ return null;
91
+ const replaces = hasOwnHandlerOf({ eventHandlers: [h] }, meaning);
92
+ return html `
93
+ <div class="row">
94
+ <label><ox-i18n msgid="label.capability-interactions">Capability actions</ox-i18n></label>
95
+ <div given>
96
+ ${given.map(one => html `<span>${interactionWords(one)}</span>`)}
97
+ <small>${i18next.t(replaces ? 'text.handler-replaces-capability' : 'text.disabled-handler-keeps-capability')}</small>
98
+ </div>
99
+ </div>
100
+ `;
101
+ }
67
102
  _renderScriptFields(h) {
68
103
  return html `
69
104
  <div class="row">
@@ -245,6 +280,25 @@ EventHandlersMapper.styles = [
245
280
  flex: 1;
246
281
  }
247
282
 
283
+ /* A list of several lines: its label stands at the first line, not in the middle. */
284
+ .row:has(> [given]) {
285
+ align-items: start;
286
+ }
287
+
288
+ [given] {
289
+ display: flex;
290
+ flex-direction: column;
291
+ gap: 2px;
292
+ min-width: 0;
293
+ font-size: 0.74rem;
294
+ color: var(--md-sys-color-on-surface);
295
+ }
296
+
297
+ [given] small {
298
+ color: var(--md-sys-color-on-surface-variant);
299
+ line-height: 1.35;
300
+ }
301
+
248
302
  label {
249
303
  font-size: 12px;
250
304
  color: var(--md-sys-color-on-surface-variant, #49454f);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/property-panel",
3
3
  "description": "Webcomponent property-panel following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "10.29.90",
5
+ "version": "10.29.94",
6
6
  "type": "module",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
@@ -87,10 +87,10 @@
87
87
  },
88
88
  "dependencies": {
89
89
  "@material/web": "^2.0.0",
90
- "@operato/app": "^10.29.90",
91
- "@operato/attachment": "^10.29.90",
90
+ "@operato/app": "^10.29.94",
91
+ "@operato/attachment": "^10.29.94",
92
92
  "@operato/i18n": "^10.29.85",
93
- "@operato/input": "^10.29.90",
93
+ "@operato/input": "^10.29.94",
94
94
  "@operato/styles": "^10.29.83",
95
95
  "@operato/utils": "^10.29.85",
96
96
  "lit": "^3.1.2"
@@ -128,5 +128,5 @@
128
128
  "prettier --write"
129
129
  ]
130
130
  },
131
- "gitHead": "354953417c0c6fefa2ed68da4fcfd276d95ba605"
131
+ "gitHead": "5172807a0136c6f14dda157d1589abfbe35f892e"
132
132
  }
@@ -791,5 +791,9 @@
791
791
  "button.calibrate-scale": "fit to a real length",
792
792
  "label.calibrate-width": "the real length of the drawing width {width}",
793
793
  "label.gesture-meaning": "meaning",
794
- "label.low-level-gestures": "low-level gestures"
794
+ "label.low-level-gestures": "low-level gestures",
795
+ "label.capability-interactions": "capability actions",
796
+ "text.capability-interaction-part": "part {part}",
797
+ "text.handler-replaces-capability": "With this handler, it runs instead of the actions above.",
798
+ "text.disabled-handler-keeps-capability": "This handler is off, so the actions above still run."
795
799
  }
@@ -791,5 +791,9 @@
791
791
  "button.calibrate-scale": "ajustar a una longitud real",
792
792
  "label.calibrate-width": "longitud real del ancho del plano {width}",
793
793
  "label.gesture-meaning": "significado",
794
- "label.low-level-gestures": "gestos de bajo nivel"
794
+ "label.low-level-gestures": "gestos de bajo nivel",
795
+ "label.capability-interactions": "acciones de la capacidad",
796
+ "text.capability-interaction-part": "pieza {part}",
797
+ "text.handler-replaces-capability": "Con este controlador, se ejecuta este en lugar de las acciones anteriores.",
798
+ "text.disabled-handler-keeps-capability": "Este controlador está desactivado, así que las acciones anteriores se siguen ejecutando."
795
799
  }
@@ -795,5 +795,9 @@
795
795
  "button.calibrate-scale": "実際の長さに合わせる",
796
796
  "label.calibrate-width": "図面の幅 {width} の実際の長さ",
797
797
  "label.gesture-meaning": "意味",
798
- "label.low-level-gestures": "低レベルのジェスチャー"
798
+ "label.low-level-gestures": "低レベルのジェスチャー",
799
+ "label.capability-interactions": "機能による操作",
800
+ "text.capability-interaction-part": "部品 {part}",
801
+ "text.handler-replaces-capability": "このハンドラーを置くと、上の操作の代わりにこのハンドラーが実行されます。",
802
+ "text.disabled-handler-keeps-capability": "このハンドラーはオフのため、上の操作がそのまま実行されます。"
799
803
  }
@@ -795,5 +795,9 @@
795
795
  "button.calibrate-scale": "실제 길이로 맞추기",
796
796
  "label.calibrate-width": "도면 너비 {width} 의 실제 길이",
797
797
  "label.gesture-meaning": "뜻",
798
- "label.low-level-gestures": "낮은 수준 제스처"
798
+ "label.low-level-gestures": "낮은 수준 제스처",
799
+ "label.capability-interactions": "능력이 주는 동작",
800
+ "text.capability-interaction-part": "{part} 부품",
801
+ "text.handler-replaces-capability": "이 핸들러를 두면 위 동작 대신 이 핸들러가 실행됩니다.",
802
+ "text.disabled-handler-keeps-capability": "이 핸들러는 꺼져 있으므로 위 동작이 그대로 실행됩니다."
799
803
  }
@@ -668,5 +668,9 @@
668
668
  "button.calibrate-scale": "padankan dengan panjang sebenar",
669
669
  "label.calibrate-width": "panjang sebenar lebar lukisan {width}",
670
670
  "label.gesture-meaning": "maksud",
671
- "label.low-level-gestures": "gerak isyarat aras rendah"
671
+ "label.low-level-gestures": "gerak isyarat aras rendah",
672
+ "label.capability-interactions": "tindakan keupayaan",
673
+ "text.capability-interaction-part": "bahagian {part}",
674
+ "text.handler-replaces-capability": "Dengan pengendali ini, pengendali ini dijalankan sebagai ganti tindakan di atas.",
675
+ "text.disabled-handler-keeps-capability": "Pengendali ini dimatikan, jadi tindakan di atas masih dijalankan."
672
676
  }
@@ -794,5 +794,9 @@
794
794
  "button.calibrate-scale": "按实际长度校准",
795
795
  "label.calibrate-width": "图纸宽度 {width} 的实际长度",
796
796
  "label.gesture-meaning": "含义",
797
- "label.low-level-gestures": "底层手势"
797
+ "label.low-level-gestures": "底层手势",
798
+ "label.capability-interactions": "功能提供的操作",
799
+ "text.capability-interaction-part": "部件 {part}",
800
+ "text.handler-replaces-capability": "设置此处理程序后,将执行此处理程序,而不执行上述操作。",
801
+ "text.disabled-handler-keeps-capability": "此处理程序已关闭,上述操作仍会执行。"
798
802
  }