@things-factory/figure-ui 10.1.223 → 10.1.224

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.
Files changed (59) hide show
  1. package/client/modeller/canvas.ts +2 -2
  2. package/client/modeller/consumer-capabilities.ts +66 -0
  3. package/client/modeller/data-interface.ts +230 -80
  4. package/client/modeller/editor.ts +14 -7
  5. package/client/modeller/figure-capability-panel.ts +145 -1
  6. package/client/modeller/figure-data-panel.ts +495 -188
  7. package/client/modeller/figure-links.ts +130 -12
  8. package/client/modeller/figure-preview.ts +19 -2
  9. package/client/modeller/figure-slot-layout-panel.ts +7 -3
  10. package/client/modeller/links.ts +58 -0
  11. package/client/modeller/refusals.ts +12 -4
  12. package/client/modeller/slot-layout-host.ts +76 -5
  13. package/dist-client/modeller/canvas.js +2 -2
  14. package/dist-client/modeller/canvas.js.map +1 -1
  15. package/dist-client/modeller/consumer-capabilities.d.ts +29 -0
  16. package/dist-client/modeller/consumer-capabilities.js +60 -0
  17. package/dist-client/modeller/consumer-capabilities.js.map +1 -0
  18. package/dist-client/modeller/data-interface.d.ts +83 -17
  19. package/dist-client/modeller/data-interface.js +194 -82
  20. package/dist-client/modeller/data-interface.js.map +1 -1
  21. package/dist-client/modeller/editor.d.ts +5 -2
  22. package/dist-client/modeller/editor.js +16 -5
  23. package/dist-client/modeller/editor.js.map +1 -1
  24. package/dist-client/modeller/figure-capability-panel.d.ts +12 -0
  25. package/dist-client/modeller/figure-capability-panel.js +123 -1
  26. package/dist-client/modeller/figure-capability-panel.js.map +1 -1
  27. package/dist-client/modeller/figure-data-panel.d.ts +57 -13
  28. package/dist-client/modeller/figure-data-panel.js +461 -180
  29. package/dist-client/modeller/figure-data-panel.js.map +1 -1
  30. package/dist-client/modeller/figure-links.d.ts +11 -0
  31. package/dist-client/modeller/figure-links.js +137 -16
  32. package/dist-client/modeller/figure-links.js.map +1 -1
  33. package/dist-client/modeller/figure-preview.d.ts +4 -0
  34. package/dist-client/modeller/figure-preview.js +19 -1
  35. package/dist-client/modeller/figure-preview.js.map +1 -1
  36. package/dist-client/modeller/figure-slot-layout-panel.js +6 -4
  37. package/dist-client/modeller/figure-slot-layout-panel.js.map +1 -1
  38. package/dist-client/modeller/links.d.ts +22 -0
  39. package/dist-client/modeller/links.js +48 -0
  40. package/dist-client/modeller/links.js.map +1 -1
  41. package/dist-client/modeller/refusals.js +14 -6
  42. package/dist-client/modeller/refusals.js.map +1 -1
  43. package/dist-client/modeller/slot-layout-host.d.ts +28 -3
  44. package/dist-client/modeller/slot-layout-host.js +68 -6
  45. package/dist-client/modeller/slot-layout-host.js.map +1 -1
  46. package/dist-client/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +7 -7
  48. package/test/browser/data-table-page.js +9 -0
  49. package/test/browser/links.check.mjs +25 -3
  50. package/test/consumer-capabilities.test.ts +116 -0
  51. package/test/data-motion.test.ts +94 -27
  52. package/test/links.test.ts +15 -0
  53. package/test/slot-layout-host.test.ts +63 -5
  54. package/translations/en.json +81 -23
  55. package/translations/es.json +81 -23
  56. package/translations/ja.json +81 -23
  57. package/translations/ko.json +81 -23
  58. package/translations/ms.json +81 -23
  59. package/translations/zh.json +81 -23
@@ -7,14 +7,26 @@ declare const FigureCapabilityPanel_base: (new (...args: any[]) => LitElement) &
7
7
  * so the list is the only way to find one; choosing a row selects its part, where the place is edited. Whether the
8
8
  * figure is the look of an item a holder carries is said here too (ADR-0155 amendment 2): a tag, apart from the ladder,
9
9
  * since an item may hold things as well.
10
+ *
11
+ * Below the ladder, the products' capabilities this modeller has descriptors for (ADR-0167 9, 12): each put on or off,
12
+ * what it still needs, and its settings as its descriptor draws them -- parts picked (the part chosen here by one
13
+ * button), an input and a value per fixed key, never a row added or taken away -- with what its check says.
10
14
  */
11
15
  export declare class FigureCapabilityPanel extends FigureCapabilityPanel_base {
12
16
  static styles: import("lit").CSSResult[];
17
+ private unlisten?;
18
+ connectedCallback(): void;
19
+ disconnectedCallback(): void;
13
20
  asset?: FigureAsset;
14
21
  /** The selected part, whose places are marked. */
15
22
  selected: string;
16
23
  locked: boolean;
17
24
  render(): import("lit-html").TemplateResult<1> | typeof nothing;
25
+ /** The products' capabilities: those this modeller knows, each on or off with its settings, and those it does not know. */
26
+ private renderConsumers;
27
+ /** A capability's settings as its descriptor draws them, and what its check says of them. */
28
+ private renderSettings;
29
+ private setConsumer;
18
30
  private setRung;
19
31
  private setItem;
20
32
  private pick;
@@ -7,12 +7,18 @@ import { figureBindingsOf } from '@hatiolab/figure-model';
7
7
  import { RUNGS, rungOf } from '@things-factory/figure-viewer/dist-client/capability-rung.js';
8
8
  import { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js';
9
9
  import { placeTerms } from '@things-factory/figure-viewer/dist-client/detail-facts.js';
10
+ import { onFigureCapabilitiesChanged } from '@hatiolab/things-scene';
11
+ import { consumerDescriptors, inputTableAt, namesWith, needsMissing, partsAt, settingsIssues, settingsOf, unknownConsumerNames, withInputTable, withParts } from './consumer-capabilities.js';
10
12
  /**
11
13
  * 자리·능력 — what the figure does on a board: the ladder from drawing only, to
12
14
  * holding things, to passing them on, and every place things are held, whatever part it is on. A place is not drawn,
13
15
  * so the list is the only way to find one; choosing a row selects its part, where the place is edited. Whether the
14
16
  * figure is the look of an item a holder carries is said here too (ADR-0155 amendment 2): a tag, apart from the ladder,
15
17
  * since an item may hold things as well.
18
+ *
19
+ * Below the ladder, the products' capabilities this modeller has descriptors for (ADR-0167 9, 12): each put on or off,
20
+ * what it still needs, and its settings as its descriptor draws them -- parts picked (the part chosen here by one
21
+ * button), an input and a value per fixed key, never a row added or taken away -- with what its check says.
16
22
  */
17
23
  let FigureCapabilityPanel = class FigureCapabilityPanel extends localize(i18next)(LitElement) {
18
24
  constructor() {
@@ -73,7 +79,37 @@ let FigureCapabilityPanel = class FigureCapabilityPanel extends localize(i18next
73
79
  font-size: var(--ui-t-small, 11.5px);
74
80
  color: var(--md-sys-color-on-surface-variant);
75
81
  }
82
+ div[chips] {
83
+ display: flex;
84
+ flex-wrap: wrap;
85
+ gap: 4px 10px;
86
+ align-items: center;
87
+ }
88
+ div[chips] label {
89
+ display: inline-flex;
90
+ gap: 4px;
91
+ align-items: center;
92
+ }
93
+ div[table] {
94
+ display: grid;
95
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
96
+ gap: 4px 6px;
97
+ align-items: center;
98
+ }
99
+ p[warn] {
100
+ margin: 0;
101
+ color: var(--md-sys-color-error);
102
+ }
76
103
  `]; }
104
+ connectedCallback() {
105
+ super.connectedCallback();
106
+ /* A product's descriptors may be registered after the panel stands. */
107
+ this.unlisten = onFigureCapabilitiesChanged(() => this.requestUpdate());
108
+ }
109
+ disconnectedCallback() {
110
+ super.disconnectedCallback();
111
+ this.unlisten?.();
112
+ }
77
113
  render() {
78
114
  const asset = this.asset;
79
115
  if (!asset)
@@ -93,6 +129,7 @@ let FigureCapabilityPanel = class FigureCapabilityPanel extends localize(i18next
93
129
  ${rung === null ? html `<p hint>${i18next.t('figure.text.capability-hand-written')}</p>` : nothing}
94
130
  ${names.length ? html `<code>${names.join(' · ')}</code>` : nothing}
95
131
  </section>
132
+ ${this.renderConsumers(asset)}
96
133
  <section>
97
134
  <h3>${i18next.t('figure.label.places')}</h3>
98
135
  ${places.length
@@ -118,8 +155,93 @@ let FigureCapabilityPanel = class FigureCapabilityPanel extends localize(i18next
118
155
  </section>
119
156
  `;
120
157
  }
158
+ /** The products' capabilities: those this modeller knows, each on or off with its settings, and those it does not know. */
159
+ renderConsumers(asset) {
160
+ const known = consumerDescriptors();
161
+ const unknown = unknownConsumerNames(asset);
162
+ if (!known.length && !unknown.length)
163
+ return nothing;
164
+ const names = asset.document.capabilities.names ?? [];
165
+ return html `<section>
166
+ <h3>${i18next.t('figure.label.product-capabilities')}</h3>
167
+ ${known.map(d => {
168
+ const on = names.includes(d.name);
169
+ const missing = needsMissing(d, asset);
170
+ return html `<label rung ?on=${on}>
171
+ <input type="checkbox" .checked=${live(on)} ?disabled=${this.locked || (!on && missing.length > 0)} @change=${(e) => this.setConsumer(asset, d.name, e.target.checked)} />
172
+ <span>
173
+ <strong>${d.label}</strong>
174
+ <em>${d.note}</em>
175
+ <code>${d.name} · ${d.version}</code>
176
+ </span>
177
+ </label>
178
+ ${missing.length ? html `<p hint>${i18next.t('figure.text.product-capability-needs', { needs: missing.map(m => (m === 'item' ? i18next.t('figure.label.is-item') : m)).join(', ') })}</p>` : nothing}
179
+ ${on ? this.renderSettings(asset, d) : nothing}`;
180
+ })}
181
+ ${unknown.map(name => html `<p hint>
182
+ ${i18next.t('figure.text.product-capability-unknown', { name })}
183
+ <button quiet ?disabled=${this.locked} @click=${() => this.setConsumer(asset, name, false)}>${i18next.t('figure.button.product-capability-remove')}</button>
184
+ </p>`)}
185
+ </section>`;
186
+ }
187
+ /** A capability's settings as its descriptor draws them, and what its check says of them. */
188
+ renderSettings(asset, d) {
189
+ const settings = settingsOf(asset, d.name);
190
+ const write = (next) => this.dispatchEvent(new CustomEvent('part-edit', { detail: { edit: { kind: 'set-capability-settings', name: d.name, settings: Object.keys(next).length ? next : null } }, bubbles: true, composed: true }));
191
+ const parts = [...new Set(asset.appearance.map(a => a.target))];
192
+ const inputs = asset.document.model.inputs.filter(i => i.role === 'state');
193
+ const issues = settingsIssues(d, asset);
194
+ return html `<div form>
195
+ ${(d.settings ?? []).map((setting) => {
196
+ if (setting.kind === 'parts') {
197
+ const chosen = partsAt(settings, setting.key);
198
+ const toggle = (part, on) => write(withParts(settings, setting.key, on ? [...chosen, part] : chosen.filter(p => p !== part)));
199
+ return html `<span>${setting.label}</span>
200
+ <div chips>
201
+ ${parts.map(p => html `<label><input type="checkbox" .checked=${live(chosen.includes(p))} ?disabled=${this.locked} @change=${(e) => toggle(p, e.target.checked)} />${p}</label>`)}
202
+ ${this.selected && parts.includes(this.selected) && !chosen.includes(this.selected)
203
+ ? html `<button quiet ?disabled=${this.locked} @click=${() => toggle(this.selected, true)}>${i18next.t('figure.button.data-add-selected-part', { part: this.selected })}</button>`
204
+ : nothing}
205
+ </div>`;
206
+ }
207
+ const table = inputTableAt(settings, setting);
208
+ const input = inputs.find(i => i.id === table.input);
209
+ return html `<span>${setting.label}</span>
210
+ <select ?disabled=${this.locked} @change=${(e) => write(withInputTable(settings, setting, e.target.value || undefined, table.values))}>
211
+ <option value="" ?selected=${!table.input}>${i18next.t('figure.label.data-none')}</option>
212
+ ${inputs.map(i => html `<option value=${i.id} ?selected=${i.id === table.input}>${asset.stateInputs?.[i.id]?.label ?? i.id}${i.unit ? ` (${i.unit} ${i.min ?? ''}~${i.max ?? ''})` : ''}</option>`)}
213
+ </select>
214
+ ${table.input
215
+ ? html `<span></span>
216
+ <div table>
217
+ ${setting.keys.map(key => html `<span>${key}</span>
218
+ <input
219
+ type="number"
220
+ step="any"
221
+ min=${input?.min ?? ''}
222
+ max=${input?.max ?? ''}
223
+ .value=${String(table.values[key])}
224
+ ?disabled=${this.locked}
225
+ @change=${(e) => {
226
+ const n = e.target.valueAsNumber;
227
+ if (!Number.isFinite(n))
228
+ return this.requestUpdate();
229
+ write(withInputTable(settings, setting, table.input, { ...table.values, [key]: n }));
230
+ }}
231
+ />`)}
232
+ </div>`
233
+ : nothing}`;
234
+ })}
235
+ </div>
236
+ ${issues.map(reason => html `<p warn>${reason}</p>`)}`;
237
+ }
238
+ setConsumer(asset, name, on) {
239
+ this.dispatchEvent(new CustomEvent('part-edit', { detail: { edit: { kind: 'set-capabilities', names: namesWith(asset, name, on) } }, bubbles: true, composed: true }));
240
+ }
121
241
  setRung(which) {
122
- this.dispatchEvent(new CustomEvent('part-edit', { detail: { edit: { kind: 'set-capabilities', names: [...RUNGS[which]] } }, bubbles: true, composed: true }));
242
+ /* The ladder sets the shared names; a product's capabilities stay as they are. */
243
+ const consumers = (this.asset?.document.capabilities.names ?? []).filter(n => n.includes('.'));
244
+ this.dispatchEvent(new CustomEvent('part-edit', { detail: { edit: { kind: 'set-capabilities', names: [...RUNGS[which], ...consumers] } }, bubbles: true, composed: true }));
123
245
  }
124
246
  setItem(item) {
125
247
  this.dispatchEvent(new CustomEvent('command', { detail: { action: { kind: 'set-item', item } }, bubbles: true, composed: true }));
@@ -1 +1 @@
1
- {"version":3,"file":"figure-capability-panel.js","sourceRoot":"","sources":["../../client/modeller/figure-capability-panel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAa,MAAM,8DAA8D,CAAA;AACvG,OAAO,EAAE,eAAe,EAAE,MAAM,gEAAgE,CAAA;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,2DAA2D,CAAA;AAEtF;;;;;;GAMG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;IAAjE;;QAwDL,kDAAkD;QACtC,aAAQ,GAAG,EAAE,CAAA;QACI,WAAM,GAAG,KAAK,CAAA;IA6D7C,CAAC;aAtHQ,WAAM,GAAG,CAAC,eAAe,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDpC,CAAC,AApDW,CAoDX;IAOF,MAAM;QACJ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QACxB,IAAI,CAAC,KAAK;YAAE,OAAO,OAAO,CAAA;QAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE,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AAC,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACnI,CAAC;IAEO,IAAI,CAAC,IAAY;QACvB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC7G,CAAC;;AA/D+B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;oDAAoB;AAEvC;IAAX,QAAQ,EAAE;;uDAAc;AACI;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;qDAAe;AA1DhC,qBAAqB;IADjC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,qBAAqB,CAuHjC","sourcesContent":["import { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { figureBindingsOf } from '@hatiolab/figure-model'\nimport type { FigureAsset } from '@hatiolab/figure-model'\nimport { RUNGS, rungOf, type Rung } from '@things-factory/figure-viewer/dist-client/capability-rung.js'\nimport { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js'\nimport { placeTerms } from '@things-factory/figure-viewer/dist-client/detail-facts.js'\n\n/**\n * 자리·능력 — what the figure does on a board: the ladder from drawing only, to\n * holding things, to passing them on, and every place things are held, whatever part it is on. A place is not drawn,\n * so the list is the only way to find one; choosing a row selects its part, where the place is edited. Whether the\n * figure is the look of an item a holder carries is said here too (ADR-0155 amendment 2): a tag, apart from the ladder,\n * since an item may hold things as well.\n */\n@customElement('figure-capability-panel')\nexport class FigureCapabilityPanel extends localize(i18next)(LitElement) {\n static styles = [SidePanelStyles, css`\n :host {\n display: block;\n }\n label[rung],\n label[item] {\n display: flex;\n gap: 8px;\n align-items: flex-start;\n padding: 8px;\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n cursor: pointer;\n }\n label[rung][on],\n label[item][on] {\n border-color: var(--md-sys-color-primary);\n background: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n }\n label[rung] span,\n label[item] span {\n display: grid;\n gap: 2px;\n }\n label[rung] em,\n label[item] em,\n p[hint],\n small {\n font-style: normal;\n margin: 0;\n color: var(--md-sys-color-on-surface-variant);\n }\n button[place] {\n display: grid;\n gap: 2px;\n text-align: left;\n padding: 6px 8px;\n font: inherit;\n color: inherit;\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n background: none;\n cursor: pointer;\n }\n button[place][on] {\n border-color: var(--md-sys-color-primary);\n }\n code {\n font-size: var(--ui-t-small, 11.5px);\n color: var(--md-sys-color-on-surface-variant);\n }\n `]\n\n @property({ attribute: false }) asset?: FigureAsset\n /** The selected part, whose places are marked. */\n @property() selected = ''\n @property({ type: Boolean }) locked = false\n\n render() {\n const asset = this.asset\n if (!asset) return nothing\n const names = asset.document.capabilities.names ?? []\n const rung = rungOf(names)\n const places = figureBindingsOf(asset)\n return html`<section>\n <h3>${i18next.t('figure.label.what-this-does')}</h3>\n ${(['none', 'hold', 'flow'] as const).map(\n which => html`<label rung ?on=${rung === which}>\n <input type=\"radio\" name=\"rung\" .checked=${live(rung === which)} ?disabled=${this.locked} @change=${() => this.setRung(which)} />\n <span>\n <strong>${i18next.t(`figure.label.rung-${which}`)}</strong>\n <em>${i18next.t(`figure.text.rung-${which}-note`)}</em>\n </span>\n </label>`\n )}\n ${rung === null ? html`<p hint>${i18next.t('figure.text.capability-hand-written')}</p>` : nothing}\n ${names.length ? html`<code>${names.join(' · ')}</code>` : nothing}\n </section>\n <section>\n <h3>${i18next.t('figure.label.places')}</h3>\n ${places.length\n ? places.map(\n one => html`<button place ?on=${one.part === this.selected} @click=${() => one.part && this.pick(one.part)}>\n <strong>${one.label}</strong>\n <small>\n ${one.part ?? '?'}${one.face ? ' · ' + i18next.t('figure.label.face-' + one.face) : ''} ·\n ${placeTerms(one, (key, params) => i18next.t(key, params))}\n </small>\n </button>`\n )\n : html`<p hint>${i18next.t('figure.text.no-places')}</p>`}\n ${places.length && rung === 'none' ? html`<p hint>${i18next.t('figure.text.place-needs-holding')}</p>` : nothing}\n </section>\n <section>\n <h3>${i18next.t('figure.label.item')}</h3>\n <label item ?on=${!!asset.item}>\n <input type=\"checkbox\" .checked=${live(!!asset.item)} ?disabled=${this.locked} @change=${(e: Event) => this.setItem((e.target as HTMLInputElement).checked)} />\n <span>\n <strong>${i18next.t('figure.label.is-item')}</strong>\n <em>${i18next.t('figure.text.is-item-note')}</em>\n </span>\n </label>\n </section>\n `\n }\n\n private setRung(which: Rung) {\n this.dispatchEvent(new CustomEvent('part-edit', { detail: { edit: { kind: 'set-capabilities', names: [...RUNGS[which]] } }, bubbles: true, composed: true }))\n }\n\n private setItem(item: boolean) {\n this.dispatchEvent(new CustomEvent('command', { detail: { action: { kind: 'set-item', item } }, bubbles: true, composed: true }))\n }\n\n private pick(part: string) {\n this.dispatchEvent(new CustomEvent('select-part', { detail: { id: part }, bubbles: true, composed: true }))\n }\n}\n"]}
1
+ {"version":3,"file":"figure-capability-panel.js","sourceRoot":"","sources":["../../client/modeller/figure-capability-panel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,g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AAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC7K,CAAC;IAEO,OAAO,CAAC,IAAa;QAC3B,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACnI,CAAC;IAEO,IAAI,CAAC,IAAY;QACvB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC7G,CAAC;;AA3J+B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;oDAAoB;AAEvC;IAAX,QAAQ,EAAE;;uDAAc;AACI;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;qDAAe;AA5FhC,qBAAqB;IADjC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,qBAAqB,CAqPjC","sourcesContent":["import { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { figureBindingsOf } from '@hatiolab/figure-model'\nimport type { FigureAsset } from '@hatiolab/figure-model'\nimport { RUNGS, rungOf, type Rung } from '@things-factory/figure-viewer/dist-client/capability-rung.js'\nimport { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js'\nimport { placeTerms } from '@things-factory/figure-viewer/dist-client/detail-facts.js'\nimport { onFigureCapabilitiesChanged, type FigureCapabilityDescriptor, type FigureCapabilitySetting } from '@hatiolab/things-scene'\n\nimport {\n consumerDescriptors,\n inputTableAt,\n namesWith,\n needsMissing,\n partsAt,\n settingsIssues,\n settingsOf,\n unknownConsumerNames,\n withInputTable,\n withParts\n} from './consumer-capabilities.js'\n\n/**\n * 자리·능력 — what the figure does on a board: the ladder from drawing only, to\n * holding things, to passing them on, and every place things are held, whatever part it is on. A place is not drawn,\n * so the list is the only way to find one; choosing a row selects its part, where the place is edited. Whether the\n * figure is the look of an item a holder carries is said here too (ADR-0155 amendment 2): a tag, apart from the ladder,\n * since an item may hold things as well.\n *\n * Below the ladder, the products' capabilities this modeller has descriptors for (ADR-0167 9, 12): each put on or off,\n * what it still needs, and its settings as its descriptor draws them -- parts picked (the part chosen here by one\n * button), an input and a value per fixed key, never a row added or taken away -- with what its check says.\n */\n@customElement('figure-capability-panel')\nexport class FigureCapabilityPanel extends localize(i18next)(LitElement) {\n static styles = [SidePanelStyles, css`\n :host {\n display: block;\n }\n label[rung],\n label[item] {\n display: flex;\n gap: 8px;\n align-items: flex-start;\n padding: 8px;\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n cursor: pointer;\n }\n label[rung][on],\n label[item][on] {\n border-color: var(--md-sys-color-primary);\n background: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n }\n label[rung] span,\n label[item] span {\n display: grid;\n gap: 2px;\n }\n label[rung] em,\n label[item] em,\n p[hint],\n small {\n font-style: normal;\n margin: 0;\n color: var(--md-sys-color-on-surface-variant);\n }\n button[place] {\n display: grid;\n gap: 2px;\n text-align: left;\n padding: 6px 8px;\n font: inherit;\n color: inherit;\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n background: none;\n cursor: pointer;\n }\n button[place][on] {\n border-color: var(--md-sys-color-primary);\n }\n code {\n font-size: var(--ui-t-small, 11.5px);\n color: var(--md-sys-color-on-surface-variant);\n }\n div[chips] {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 10px;\n align-items: center;\n }\n div[chips] label {\n display: inline-flex;\n gap: 4px;\n align-items: center;\n }\n div[table] {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: 4px 6px;\n align-items: center;\n }\n p[warn] {\n margin: 0;\n color: var(--md-sys-color-error);\n }\n `]\n\n private unlisten?: () => void\n\n connectedCallback() {\n super.connectedCallback()\n /* A product's descriptors may be registered after the panel stands. */\n this.unlisten = onFigureCapabilitiesChanged(() => this.requestUpdate())\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this.unlisten?.()\n }\n\n @property({ attribute: false }) asset?: FigureAsset\n /** The selected part, whose places are marked. */\n @property() selected = ''\n @property({ type: Boolean }) locked = false\n\n render() {\n const asset = this.asset\n if (!asset) return nothing\n const names = asset.document.capabilities.names ?? []\n const rung = rungOf(names)\n const places = figureBindingsOf(asset)\n return html`<section>\n <h3>${i18next.t('figure.label.what-this-does')}</h3>\n ${(['none', 'hold', 'flow'] as const).map(\n which => html`<label rung ?on=${rung === which}>\n <input type=\"radio\" name=\"rung\" .checked=${live(rung === which)} ?disabled=${this.locked} @change=${() => this.setRung(which)} />\n <span>\n <strong>${i18next.t(`figure.label.rung-${which}`)}</strong>\n <em>${i18next.t(`figure.text.rung-${which}-note`)}</em>\n </span>\n </label>`\n )}\n ${rung === null ? html`<p hint>${i18next.t('figure.text.capability-hand-written')}</p>` : nothing}\n ${names.length ? html`<code>${names.join(' · ')}</code>` : nothing}\n </section>\n ${this.renderConsumers(asset)}\n <section>\n <h3>${i18next.t('figure.label.places')}</h3>\n ${places.length\n ? places.map(\n one => html`<button place ?on=${one.part === this.selected} @click=${() => one.part && this.pick(one.part)}>\n <strong>${one.label}</strong>\n <small>\n ${one.part ?? '?'}${one.face ? ' · ' + i18next.t('figure.label.face-' + one.face) : ''} ·\n ${placeTerms(one, (key, params) => i18next.t(key, params))}\n </small>\n </button>`\n )\n : html`<p hint>${i18next.t('figure.text.no-places')}</p>`}\n ${places.length && rung === 'none' ? html`<p hint>${i18next.t('figure.text.place-needs-holding')}</p>` : nothing}\n </section>\n <section>\n <h3>${i18next.t('figure.label.item')}</h3>\n <label item ?on=${!!asset.item}>\n <input type=\"checkbox\" .checked=${live(!!asset.item)} ?disabled=${this.locked} @change=${(e: Event) => this.setItem((e.target as HTMLInputElement).checked)} />\n <span>\n <strong>${i18next.t('figure.label.is-item')}</strong>\n <em>${i18next.t('figure.text.is-item-note')}</em>\n </span>\n </label>\n </section>\n `\n }\n\n /** The products' capabilities: those this modeller knows, each on or off with its settings, and those it does not know. */\n private renderConsumers(asset: FigureAsset) {\n const known = consumerDescriptors()\n const unknown = unknownConsumerNames(asset)\n if (!known.length && !unknown.length) return nothing\n const names = asset.document.capabilities.names ?? []\n return html`<section>\n <h3>${i18next.t('figure.label.product-capabilities')}</h3>\n ${known.map(d => {\n const on = names.includes(d.name)\n const missing = needsMissing(d, asset)\n return html`<label rung ?on=${on}>\n <input type=\"checkbox\" .checked=${live(on)} ?disabled=${this.locked || (!on && missing.length > 0)} @change=${(e: Event) => this.setConsumer(asset, d.name, (e.target as HTMLInputElement).checked)} />\n <span>\n <strong>${d.label}</strong>\n <em>${d.note}</em>\n <code>${d.name} · ${d.version}</code>\n </span>\n </label>\n ${missing.length ? html`<p hint>${i18next.t('figure.text.product-capability-needs', { needs: missing.map(m => (m === 'item' ? i18next.t('figure.label.is-item') : m)).join(', ') })}</p>` : nothing}\n ${on ? this.renderSettings(asset, d) : nothing}`\n })}\n ${unknown.map(\n name => html`<p hint>\n ${i18next.t('figure.text.product-capability-unknown', { name })}\n <button quiet ?disabled=${this.locked} @click=${() => this.setConsumer(asset, name, false)}>${i18next.t('figure.button.product-capability-remove')}</button>\n </p>`\n )}\n </section>`\n }\n\n /** A capability's settings as its descriptor draws them, and what its check says of them. */\n private renderSettings(asset: FigureAsset, d: FigureCapabilityDescriptor) {\n const settings = settingsOf(asset, d.name)\n const write = (next: Record<string, unknown>) =>\n this.dispatchEvent(new CustomEvent('part-edit', { detail: { edit: { kind: 'set-capability-settings', name: d.name, settings: Object.keys(next).length ? next : null } }, bubbles: true, composed: true }))\n const parts = [...new Set(asset.appearance.map(a => a.target))]\n const inputs = asset.document.model.inputs.filter(i => i.role === 'state')\n const issues = settingsIssues(d, asset)\n return html`<div form>\n ${(d.settings ?? []).map((setting: FigureCapabilitySetting) => {\n if (setting.kind === 'parts') {\n const chosen = partsAt(settings, setting.key)\n const toggle = (part: string, on: boolean) => write(withParts(settings, setting.key, on ? [...chosen, part] : chosen.filter(p => p !== part)))\n return html`<span>${setting.label}</span>\n <div chips>\n ${parts.map(p => html`<label><input type=\"checkbox\" .checked=${live(chosen.includes(p))} ?disabled=${this.locked} @change=${(e: Event) => toggle(p, (e.target as HTMLInputElement).checked)} />${p}</label>`)}\n ${this.selected && parts.includes(this.selected) && !chosen.includes(this.selected)\n ? html`<button quiet ?disabled=${this.locked} @click=${() => toggle(this.selected, true)}>${i18next.t('figure.button.data-add-selected-part', { part: this.selected })}</button>`\n : nothing}\n </div>`\n }\n const table = inputTableAt(settings, setting)\n const input = inputs.find(i => i.id === table.input)\n return html`<span>${setting.label}</span>\n <select ?disabled=${this.locked} @change=${(e: Event) => write(withInputTable(settings, setting, (e.target as HTMLSelectElement).value || undefined, table.values))}>\n <option value=\"\" ?selected=${!table.input}>${i18next.t('figure.label.data-none')}</option>\n ${inputs.map(i => html`<option value=${i.id} ?selected=${i.id === table.input}>${asset.stateInputs?.[i.id]?.label ?? i.id}${i.unit ? ` (${i.unit} ${i.min ?? ''}~${i.max ?? ''})` : ''}</option>`)}\n </select>\n ${table.input\n ? html`<span></span>\n <div table>\n ${setting.keys.map(\n key => html`<span>${key}</span>\n <input\n type=\"number\"\n step=\"any\"\n min=${input?.min ?? ''}\n max=${input?.max ?? ''}\n .value=${String(table.values[key])}\n ?disabled=${this.locked}\n @change=${(e: Event) => {\n const n = (e.target as HTMLInputElement).valueAsNumber\n if (!Number.isFinite(n)) return this.requestUpdate()\n write(withInputTable(settings, setting, table.input, { ...table.values, [key]: n }))\n }}\n />`\n )}\n </div>`\n : nothing}`\n })}\n </div>\n ${issues.map(reason => html`<p warn>${reason}</p>`)}`\n }\n\n private setConsumer(asset: FigureAsset, name: string, on: boolean) {\n this.dispatchEvent(new CustomEvent('part-edit', { detail: { edit: { kind: 'set-capabilities', names: namesWith(asset, name, on) } }, bubbles: true, composed: true }))\n }\n\n private setRung(which: Rung) {\n /* The ladder sets the shared names; a product's capabilities stay as they are. */\n const consumers = (this.asset?.document.capabilities.names ?? []).filter(n => n.includes('.'))\n this.dispatchEvent(new CustomEvent('part-edit', { detail: { edit: { kind: 'set-capabilities', names: [...RUNGS[which], ...consumers] } }, bubbles: true, composed: true }))\n }\n\n private setItem(item: boolean) {\n this.dispatchEvent(new CustomEvent('command', { detail: { action: { kind: 'set-item', item } }, bubbles: true, composed: true }))\n }\n\n private pick(part: string) {\n this.dispatchEvent(new CustomEvent('select-part', { detail: { id: part }, bubbles: true, composed: true }))\n }\n}\n"]}
@@ -5,33 +5,41 @@ declare const FigureDataPanel_base: (new (...args: any[]) => LitElement) & typeo
5
5
  /**
6
6
  * 데이터 -- the data a site sends this figure, in its own names, and what each value moves (ADR-0051 §8, data binding
7
7
  * design decision 4). The schema is free: fields the author names, a tree of objects and lists. A binding reads one place
8
- * of it and moves one thing the figure can do -- a control, a colour, a motion group's clip, speed or pause, a status
9
- * port, its position, the items in its places -- by the board's rules (value, map, range, scale). Every change is one
10
- * part edit, and whether it holds is the kernel's check.
8
+ * of it and shows it in the figure (ADR-0166): as it is or scaled, it moves one thing -- a control, a colour, a motion
9
+ * group's clip, speed or pause, its position, the items in its places; by a code table or a range table, each value's
10
+ * look goes to several targets at once -- parts' colour and effect, controls' values, a motion group. The field's kind
11
+ * says which methods there are. Every change is one part edit, and whether it holds is the kernel's check.
11
12
  *
12
13
  * The sample is not saved: data tried here, read the one way a placed figure reads it, and -- in the preview -- the figure
13
- * running on it (`data-sample`).
14
+ * running on it (`data-sample`); a sample legend pasted for a table's role shows it as a board's legend would
15
+ * (`legend-sample`).
14
16
  */
15
17
  export declare class FigureDataPanel extends FigureDataPanel_base {
16
18
  private readonly help;
17
19
  static styles: import("lit").CSSResult[];
18
20
  asset?: FigureAsset;
19
21
  locked: boolean;
22
+ /** The part chosen in the modeller, put among a table's parts by one button. */
23
+ selected: string;
20
24
  /** The schema row chosen, by its path; its field is edited under it. */
21
25
  private chosen;
22
26
  private adding;
23
27
  /** A site's data pasted to start the schema from; nothing is kept until the author says so. */
24
28
  private pasted;
29
+ /** A binding as it is being added: the field (or a new field's name), the method, the behavior or the table's targets. */
25
30
  private connecting;
26
31
  /** The binding opened to edit its rule, by id. */
27
32
  private opened;
28
- private porting;
33
+ /** Sample legends by role, as JSON typed; not saved. */
34
+ private legendSample;
29
35
  /** The rotation card as filled in: the joint, and the fields for on, speed (and its most rpm) and direction. */
30
36
  private rotating;
31
37
  /** The sample as typed, JSON; empty until edited, the schema's example shown until then. */
32
38
  private sample;
33
39
  private sampling;
34
40
  render(): import("lit-html").TemplateResult<1> | typeof nothing;
41
+ /** The data a product's capability the figure wears reads itself (ADR-0167 14): said, read only. */
42
+ private renderCapabilityData;
35
43
  private renderSchema;
36
44
  private kindWord;
37
45
  /** The chosen field's own settings, and a field added under it when it holds fields. */
@@ -40,26 +48,62 @@ export declare class FigureDataPanel extends FigureDataPanel_base {
40
48
  /** A site's data pasted: the schema guessed from it, kept only when the author says so -- units, ranges and closed values are theirs to set. */
41
49
  private renderFromSample;
42
50
  private behaviorName;
51
+ /** What a table shows on, as one line: its parts, the controls it sets, its motion group. */
52
+ private targetsName;
43
53
  private renderBindings;
44
54
  private renderBinding;
45
- private renderBindingDetail;
46
- /** A result editor fitting what the behavior takes: a colour, a clip of the group, true or false, a code, a number. */
47
- private renderResult;
48
- /** A result per value of a closed field, and one for every other value. */
49
- private renderCases;
50
- /** Intervals of a number, each from (inclusive) to (exclusive), either end left open, and one result for the rest. */
51
- private renderRanges;
55
+ /**
56
+ * A binding a product's capability takes over where the product registers it (ADR-0167 17): there it rests, whole or for
57
+ * the targets named; elsewhere (a board without the product) it works.
58
+ */
59
+ private renderResting;
60
+ private renderValueDetail;
61
+ /**
62
+ * A table (ADR-0166 10): what it shows on -- parts, controls, a motion group -- its rows, a code or an interval each
63
+ * with a cell per column, the look of every other value, and whether a board may swap it for a legend.
64
+ */
65
+ private renderTable;
66
+ /** Which parts, controls and motion group a table shows on: chips to tick, and the part chosen in the modeller by one button. */
67
+ private renderTargets;
68
+ /** The column heads of a table's rows, after the key's own one or two. */
69
+ private columnHeads;
70
+ /** One look's cells, a column each: a colour, an effect, a control's value, a clip, a speed, a pause -- empty leaves the target as it is. */
71
+ private lookCells;
72
+ /** The look of every other value: a row like the others, added or taken away; kept when a closed field's values are not all rows. */
73
+ private renderOtherwise;
74
+ /**
75
+ * A code table's rows: a code each, typed, with its look. A closed text's values follow the codes (ADR-0166 risk 3):
76
+ * a code added, renamed or taken away is the field's value too; true and false are both rows.
77
+ */
78
+ private renderCodeRows;
79
+ /**
80
+ * A range table's rows: from (inclusive) and to (exclusive), either end open, with a look each. Giving the last row,
81
+ * open above, an end starts the next row there; a row open above is the last there can be.
82
+ */
83
+ private renderRangeRows;
52
84
  /** Which field of each element is its id, its type, its place, its height in the stack, its status. */
53
85
  private renderItemFields;
86
+ /**
87
+ * 「연결 추가」 (ADR-0166 10): a field there or a new name, then a method the field's kind allows. As it is or scaled,
88
+ * the one thing it moves; a table, the parts, controls and motion group it shows on -- a new name makes the field.
89
+ */
54
90
  private renderAddBinding;
55
91
  /**
56
92
  * 「+ 회전」: a joint that turns without end, turned by the data -- on, speed in rpm, direction -- in one step. The
57
93
  * clips, the group and the bindings it writes are ordinary ones, edited one by one afterwards.
58
94
  */
59
95
  private renderRotation;
60
- private renderPorts;
61
96
  /** Data to try, read the way a placed figure reads it: what it moves, or why it is refused; in the preview, the figure running on it. */
62
97
  private renderSample;
98
+ /** Which row of a table the sample's value matched, and from which table: the figure's own or the sample legend of its role. */
99
+ private renderTableUse;
100
+ /** The sample legends as read: by role, those that are JSON. */
101
+ private sampleLegends;
102
+ /**
103
+ * A legend pasted for each table role, to see the figure as a board's legend of that role would show it -- not saved.
104
+ * The preview shows it too, as a scene's legend named as the role.
105
+ */
106
+ private renderSampleLegends;
63
107
  private try;
64
108
  /** The sample to the preview while it is asked for; null lets the preview's figure go back to its own values. */
65
109
  private tell;