@things-factory/figure-ui 10.1.221 → 10.1.223

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.
@@ -1969,6 +1969,7 @@ export class FigureEditor extends LitElement {
1969
1969
  ?locked=${unavailable}
1970
1970
  @select-part=${(e: CustomEvent) => this.choose(e.detail.id)}
1971
1971
  @part-edit=${(e: CustomEvent) => this.run(() => this.session!.edit(e.detail.edit))}
1972
+ @command=${(e: CustomEvent) => this.linkCommand(e.detail.action)}
1972
1973
  ></figure-capability-panel>
1973
1974
  </div>
1974
1975
  <div panel ?off=${tab !== 'data'}>
@@ -12,7 +12,9 @@ import { placeTerms } from '@things-factory/figure-viewer/dist-client/detail-fac
12
12
  /**
13
13
  * 자리·능력 — what the figure does on a board: the ladder from drawing only, to
14
14
  * holding things, to passing them on, and every place things are held, whatever part it is on. A place is not drawn,
15
- * so the list is the only way to find one; choosing a row selects its part, where the place is edited.
15
+ * so the list is the only way to find one; choosing a row selects its part, where the place is edited. Whether the
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,
17
+ * since an item may hold things as well.
16
18
  */
17
19
  @customElement('figure-capability-panel')
18
20
  export class FigureCapabilityPanel extends localize(i18next)(LitElement) {
@@ -20,7 +22,8 @@ export class FigureCapabilityPanel extends localize(i18next)(LitElement) {
20
22
  :host {
21
23
  display: block;
22
24
  }
23
- label[rung] {
25
+ label[rung],
26
+ label[item] {
24
27
  display: flex;
25
28
  gap: 8px;
26
29
  align-items: flex-start;
@@ -29,16 +32,19 @@ export class FigureCapabilityPanel extends localize(i18next)(LitElement) {
29
32
  border-radius: 8px;
30
33
  cursor: pointer;
31
34
  }
32
- label[rung][on] {
35
+ label[rung][on],
36
+ label[item][on] {
33
37
  border-color: var(--md-sys-color-primary);
34
38
  background: var(--md-sys-color-secondary-container);
35
39
  color: var(--md-sys-color-on-secondary-container);
36
40
  }
37
- label[rung] span {
41
+ label[rung] span,
42
+ label[item] span {
38
43
  display: grid;
39
44
  gap: 2px;
40
45
  }
41
46
  label[rung] em,
47
+ label[item] em,
42
48
  p[hint],
43
49
  small {
44
50
  font-style: normal;
@@ -106,6 +112,16 @@ export class FigureCapabilityPanel extends localize(i18next)(LitElement) {
106
112
  : html`<p hint>${i18next.t('figure.text.no-places')}</p>`}
107
113
  ${places.length && rung === 'none' ? html`<p hint>${i18next.t('figure.text.place-needs-holding')}</p>` : nothing}
108
114
  </section>
115
+ <section>
116
+ <h3>${i18next.t('figure.label.item')}</h3>
117
+ <label item ?on=${!!asset.item}>
118
+ <input type="checkbox" .checked=${live(!!asset.item)} ?disabled=${this.locked} @change=${(e: Event) => this.setItem((e.target as HTMLInputElement).checked)} />
119
+ <span>
120
+ <strong>${i18next.t('figure.label.is-item')}</strong>
121
+ <em>${i18next.t('figure.text.is-item-note')}</em>
122
+ </span>
123
+ </label>
124
+ </section>
109
125
  `
110
126
  }
111
127
 
@@ -113,6 +129,10 @@ export class FigureCapabilityPanel extends localize(i18next)(LitElement) {
113
129
  this.dispatchEvent(new CustomEvent('part-edit', { detail: { edit: { kind: 'set-capabilities', names: [...RUNGS[which]] } }, bubbles: true, composed: true }))
114
130
  }
115
131
 
132
+ private setItem(item: boolean) {
133
+ this.dispatchEvent(new CustomEvent('command', { detail: { action: { kind: 'set-item', item } }, bubbles: true, composed: true }))
134
+ }
135
+
116
136
  private pick(part: string) {
117
137
  this.dispatchEvent(new CustomEvent('select-part', { detail: { id: part }, bubbles: true, composed: true }))
118
138
  }
@@ -9,7 +9,6 @@
9
9
  * Kept free of Lit, i18n and the editor's element so node tests read it directly.
10
10
  */
11
11
  import {
12
- figureShapeBoundsOf,
13
12
  figureSlotLayoutOf,
14
13
  figureSlotLayoutIssues,
15
14
  slotLayoutPreset,
@@ -40,8 +39,6 @@ export interface SlotEditorIssue {
40
39
  params?: Record<string, string | number>
41
40
  }
42
41
 
43
- type Body = { id: string; shape?: Parameters<typeof figureShapeBoundsOf>[0] }
44
-
45
42
  /** The figure's layout as the form and the layout, or a form to start one from on the selected part's top. */
46
43
  export function slotLayoutFormOf(asset: FigureAsset, part: string): { form: SlotLayoutForm; layout?: SlotLayout } {
47
44
  const had = figureSlotLayoutOf(asset as never)
@@ -49,17 +46,8 @@ export function slotLayoutFormOf(asset: FigureAsset, part: string): { form: Slot
49
46
  return { form: { label: '', role: 'seat', anchors: part ? [{ id: part, part, face: 'top' }] : [] } }
50
47
  }
51
48
 
52
- /** How big each anchor's face is, along the part's own X (width) and Z (depth): what the editor checks slots against. */
53
- export function anchorFacesOf(anchors: readonly SlotAnchor[], geometry: readonly Body[]): Record<string, { width: number; depth: number }> {
54
- const out: Record<string, { width: number; depth: number }> = {}
55
- for (const a of anchors) {
56
- const body = geometry.find(g => g.id === a.part)
57
- if (!body?.shape) continue
58
- const b = figureShapeBoundsOf(body.shape)
59
- out[a.id] = { width: b.x.max - b.x.min, depth: b.z.max - b.z.min }
60
- }
61
- return out
62
- }
49
+ /** How big each anchor's face is: things-scene's, the one a board's placed figure is measured with too. */
50
+ export { figureAnchorFacesOf as anchorFacesOf } from '@hatiolab/things-scene'
63
51
 
64
52
  /**
65
53
  * Where an author starts: the equipment presets (figure-model, ADR-0118 decision 8), laid out on this figure's anchors --
@@ -1996,6 +1996,7 @@ let FigureEditor = class FigureEditor extends LitElement {
1996
1996
  ?locked=${unavailable}
1997
1997
  @select-part=${(e) => this.choose(e.detail.id)}
1998
1998
  @part-edit=${(e) => this.run(() => this.session.edit(e.detail.edit))}
1999
+ @command=${(e) => this.linkCommand(e.detail.action)}
1999
2000
  ></figure-capability-panel>
2000
2001
  </div>
2001
2002
  <div panel ?off=${tab !== 'data'}>