@things-factory/figure-ui 10.1.210 → 10.1.211

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.
@@ -55,7 +55,7 @@ import { canFollow, followableAxes, endPlaceKeyOf, followOf, sizeFollowersOf, me
55
55
  import { jointFanOf } from './joint-fan.js';
56
56
  import { derivedOf } from './revision.js';
57
57
  import { jointDragOf } from './joint-drag.js';
58
- import { liveOverSession, NOTHING_LIVE, scrubbed, scrubStep } from './live.js';
58
+ import { liveOverSession, NOTHING_LIVE, scrubLabel } from './live.js';
59
59
  import { startingShapeKindOfBody } from './starting-shape.js';
60
60
  import { GroupMenuStyles } from './group-menu.js';
61
61
  /** The person's own fold of the properties' 「더 보기」, kept in their browser. */
@@ -832,7 +832,9 @@ let FigureEditor = class FigureEditor extends LitElement {
832
832
  ?locked=${unavailable}
833
833
  @command=${(e) => this.linkCommand(e.detail.action)}
834
834
  @size-recipe=${(e) => this.applySizeSteps(e.detail.steps)}
835
- @size-input=${(e) => this.run(() => this.session.apply(figureSizeEditOf(this.shown().asset, e.detail.part, [{ kind: 'set-design', input: e.detail.input, unit: 'mm', value: e.detail.value }], { keep: 'centre' }).changes))}
835
+ @size-input=${(e) => this.writeField({ id: e.detail.input, unit: 'mm' }, e.detail.value)}
836
+ @size-typing=${(e) => this.hold(this.heldOf({ id: e.detail.input, unit: 'mm' }, e.detail.value))}
837
+ @size-let-go=${() => (this.live = NOTHING_LIVE)}
836
838
  @fasten-open=${() => this.openFastening()}
837
839
  .previewWords=${this.commandPreview.words()}
838
840
  .detachWords=${this.commandPreview.detachWords(shown)}
@@ -1034,8 +1036,15 @@ let FigureEditor = class FigureEditor extends LitElement {
1034
1036
  }
1035
1037
  }
1036
1038
  changeField(field, event) {
1037
- const input = event.target, value = input.valueAsNumber;
1038
- /* A number typed keeps the part's middle, or its fastening -- figure-model's one size function (ADR-0140 4.1). */
1039
+ const input = event.target;
1040
+ // Rejected edits must also restore the displayed numeric value.
1041
+ input.value = String(this.writeField(field, input.valueAsNumber));
1042
+ }
1043
+ /**
1044
+ * A number written to an input, from a field, a scrub or the size editor's rows: a size keeps the part's middle, or its
1045
+ * fastening -- figure-model's one size function (ADR-0140 4.1). Gives the value the input holds after, refused or not.
1046
+ */
1047
+ writeField(field, value) {
1039
1048
  const part = this.selected;
1040
1049
  const change = { kind: field.role === 'state' ? 'set-state' : 'set-design', input: field.id, unit: field.unit, value };
1041
1050
  const asset = this.shown()?.asset;
@@ -1045,8 +1054,7 @@ let FigureEditor = class FigureEditor extends LitElement {
1045
1054
  const after = asset && part && field.role !== 'state' ? throughPlaneOf(this.shown().asset, drawableFigureParts(this.session.read().geometry ?? []), part) : 0;
1046
1055
  if (after > before + 0.5)
1047
1056
  this.tellThroughPlane(part, after);
1048
- // Rejected edits must also restore the displayed numeric value.
1049
- input.value = String(this.session.read().fields.find(i => i.id === field.id).value);
1057
+ return this.session.read().fields.find(i => i.id === field.id).value;
1050
1058
  }
1051
1059
  /** Typing or a held spinner: each number on the way is drawn; the field's change records it. */
1052
1060
  typing(field, event) {
@@ -1077,16 +1085,12 @@ let FigureEditor = class FigureEditor extends LitElement {
1077
1085
  * pointer, and the release records one step. The field's number follows too, so the value in hand is always read.
1078
1086
  */
1079
1087
  scrub(field, down, unavailable) {
1080
- if (unavailable || down.button !== 0)
1088
+ if (unavailable)
1081
1089
  return;
1082
1090
  const label = down.currentTarget;
1083
1091
  const input = (label.closest('div[cell]')?.querySelector('input') ?? label.nextElementSibling);
1084
1092
  if (!input)
1085
1093
  return;
1086
- down.preventDefault();
1087
- label.setPointerCapture(down.pointerId);
1088
- const start = field.value;
1089
- let value = start;
1090
1094
  /* Prepared once for the scrub: each move is a size through the same function its release writes with. */
1091
1095
  const asset = this.shown()?.asset;
1092
1096
  const sized = asset && this.selected && field.role !== 'state' ? (() => { try {
@@ -1095,29 +1099,17 @@ let FigureEditor = class FigureEditor extends LitElement {
1095
1099
  catch {
1096
1100
  return undefined;
1097
1101
  } })() : undefined;
1098
- const move = (e) => {
1099
- value = scrubbed(start, e.clientX - down.clientX, scrubStep(field.unit, start, e.shiftKey));
1100
- input.value = String(value);
1101
- this.hold(this.heldOf(field, value, sized));
1102
- };
1103
- const up = (e) => {
1104
- label.removeEventListener('pointermove', move);
1105
- label.removeEventListener('pointerup', up);
1106
- label.removeEventListener('pointercancel', up);
1107
- /* A drag the system took away is not the author's value: the field goes back to where it was. */
1108
- if (e.type === 'pointercancel')
1109
- value = start;
1110
- if (value === start) {
1111
- input.value = String(start);
1102
+ scrubLabel(down, field, {
1103
+ move: value => {
1104
+ input.value = String(value);
1105
+ this.hold(this.heldOf(field, value, sized));
1106
+ },
1107
+ release: value => (input.value = String(this.writeField(field, value))),
1108
+ cancel: () => {
1109
+ input.value = String(field.value);
1112
1110
  this.live = NOTHING_LIVE;
1113
- return;
1114
1111
  }
1115
- input.value = String(value);
1116
- this.changeField(field, { target: input });
1117
- };
1118
- label.addEventListener('pointermove', move);
1119
- label.addEventListener('pointerup', up);
1120
- label.addEventListener('pointercancel', up);
1112
+ });
1121
1113
  }
1122
1114
  /** The sizes a board may give the figure: the ends the author typed, and the rest as far as its parts allow. */
1123
1115
  renderInstanceRange(shown, unavailable) {