@things-factory/figure-ui 10.1.248 → 10.1.253

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.
@@ -5,8 +5,10 @@ import { customElement, property, state } from 'lit/decorators.js';
5
5
  import { i18next, localize } from '@operato/i18n';
6
6
  import { unitWord } from './unit-words.js';
7
7
  import { FIGURE_UNITS, figureDataExample, inferFigureDataSchema } from '@hatiolab/figure-model';
8
- import { accessorOfRow, behaviorKeyOf, behaviorsOf, bindingDraftOf, domainOf, endlessJointsOf, fieldAt, fieldOfKind, fitsField, freeCodeOf, legendRoleOf, methodOf, methodsOf, partsOf, rotationStepsOf, sampleOf, schemaRowsOf, schemaWithField, schemaWithFieldReplaced, schemaWithoutField, schemaFollowingCodes, stateInputsOf, tableColumnsOf, tableDraftOf, tableWithKeys, tableWithLook, tableWithTargets } from './data-interface.js';
8
+ import { accessorOfRow, behaviorsOf, bindingDraftOf, domainOf, endlessJointsOf, fieldAt, fieldOfKind, fitsField, freeCodeOf, legendRoleOf, methodOf, methodsOf, partsOf, rotationStepsOf, sampleOf, schemaRowsOf, schemaWithField, schemaWithFieldReplaced, schemaWithoutField, schemaFollowingCodes, stateInputsOf, tableColumnsOf, tableDraftOf, tableWithKeys, tableWithLook, tableWithTargets } from './data-interface.js';
9
9
  import { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js';
10
+ import { dataMoveOf } from '@things-factory/figure-viewer/dist-client/data-connection.js';
11
+ import { kindWords, moveWords } from '@things-factory/figure-viewer/dist-client/data-words.js';
10
12
  import { figureBindingsTakenOver, figureCapabilityDescriptorOf } from '@hatiolab/things-scene';
11
13
  import { consumerDescriptors } from './consumer-capabilities.js';
12
14
  import { HelpToggles } from './help.js';
@@ -263,17 +265,9 @@ let FigureDataPanel = class FigureDataPanel extends localize(i18next)(LitElement
263
265
  ${this.renderAddField(schema, '')} ${this.renderFromSample(schema)}
264
266
  </section>`;
265
267
  }
268
+ /** A field's kind in the words every screen says it in (figure-viewer kindWords). */
266
269
  kindWord(node) {
267
- const kind = i18next.t('figure.label.data-kind-' + node.kind);
268
- if (node.kind === 'number') {
269
- const range = node.min !== undefined || node.max !== undefined ? ` ${node.min ?? ''}~${node.max ?? ''}` : '';
270
- return `${kind}${node.unit ? ` ${unitWord(node.unit)}` : ''}${range}`;
271
- }
272
- if (node.kind === 'text' && node.values)
273
- return `${kind} (${node.values.join(', ')})`;
274
- if (node.kind === 'list')
275
- return `${kind} · ${i18next.t('figure.label.data-kind-' + node.item.kind)}`;
276
- return kind;
270
+ return kindWords(node);
277
271
  }
278
272
  /** The chosen field's own settings, and a field added under it when it holds fields. */
279
273
  renderField(asset, schema, row) {
@@ -433,21 +427,9 @@ let FigureDataPanel = class FigureDataPanel extends localize(i18next)(LitElement
433
427
  </details>`;
434
428
  }
435
429
  /* ---------------------------------------------------------------- the bindings */
436
- behaviorName(asset, choices, b) {
437
- const key = behaviorKeyOf(b);
438
- const choice = choices.find(c => c.key === key);
439
- const name = b.kind === 'pose' ? i18next.t('figure.label.data-axis-' + b.axis) : (choice?.name ?? key.slice(key.indexOf(':') + 1));
440
- return i18next.t('figure.label.data-behavior-' + b.kind, { name });
441
- }
442
- /** What a table shows on, as one line: its parts, the controls it sets, its motion group. */
443
- targetsName(asset, b) {
444
- const inputs = stateInputsOf(asset);
445
- const group = (asset.motionGroups ?? []).find(g => g.id === b.targets.group);
446
- return [
447
- ...(b.targets.parts ?? []),
448
- ...(b.targets.inputs ?? []).map(id => inputs.find(i => i.id === id)?.label ?? id),
449
- ...(group ? [group.label] : [])
450
- ].join(', ');
430
+ /** What a behavior moves, in the words every screen says it in (figure-viewer dataMoveOf · moveWords). */
431
+ behaviorName(asset, b) {
432
+ return moveWords(dataMoveOf(asset, b));
451
433
  }
452
434
  renderBindings(asset, rows) {
453
435
  const bindings = asset.dataInterface?.bindings ?? [];
@@ -464,7 +446,7 @@ let FigureDataPanel = class FigureDataPanel extends localize(i18next)(LitElement
464
446
  renderBinding(asset, choices, b, resting) {
465
447
  const open = this.opened === b.id;
466
448
  const set = (next) => this.edit({ kind: 'set-data-binding', binding: next });
467
- const what = b.rule === 'table' ? this.targetsName(asset, b) : this.behaviorName(asset, choices, b.behavior);
449
+ const what = moveWords(dataMoveOf(asset, b.rule === 'table' ? { kind: 'table', targets: b.targets } : b.behavior));
468
450
  const rests = resting.some(r => r.id === b.id);
469
451
  return html `<section item>
470
452
  <div head>
@@ -837,7 +819,7 @@ let FigureDataPanel = class FigureDataPanel extends localize(i18next)(LitElement
837
819
  ${!table && fitting.length
838
820
  ? html `<span>${i18next.t('figure.label.data-behavior')}</span>
839
821
  <select @change=${(e) => set({ behavior: typed(e) })}>
840
- ${fitting.map(c => html `<option value=${c.key} ?selected=${c === choice}>${this.behaviorName(asset, choices, c.behavior)}</option>`)}
822
+ ${fitting.map(c => html `<option value=${c.key} ?selected=${c === choice}>${this.behaviorName(asset, c.behavior)}</option>`)}
841
823
  </select>`
842
824
  : nothing}
843
825
  </div>