@things-factory/figure-ui 10.1.181 → 10.1.183

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 (54) hide show
  1. package/client/modeller/editor-styles.ts +28 -9
  2. package/client/modeller/editor.ts +105 -12
  3. package/client/modeller/fasten-form.ts +207 -0
  4. package/client/modeller/fasten-geometry.ts +5 -1
  5. package/client/modeller/figure-fasten-dialog.ts +442 -0
  6. package/client/modeller/figure-fasten-drawing.ts +32 -11
  7. package/client/modeller/figure-links.ts +56 -300
  8. package/client/modeller/modeller-keys.ts +4 -4
  9. package/dist-client/modeller/editor-styles.js +28 -9
  10. package/dist-client/modeller/editor-styles.js.map +1 -1
  11. package/dist-client/modeller/editor.d.ts +23 -2
  12. package/dist-client/modeller/editor.js +121 -12
  13. package/dist-client/modeller/editor.js.map +1 -1
  14. package/dist-client/modeller/fasten-form.d.ts +69 -0
  15. package/dist-client/modeller/fasten-form.js +131 -0
  16. package/dist-client/modeller/fasten-form.js.map +1 -0
  17. package/dist-client/modeller/fasten-geometry.d.ts +3 -1
  18. package/dist-client/modeller/fasten-geometry.js +6 -1
  19. package/dist-client/modeller/fasten-geometry.js.map +1 -1
  20. package/dist-client/modeller/figure-fasten-dialog.d.ts +64 -0
  21. package/dist-client/modeller/figure-fasten-dialog.js +418 -0
  22. package/dist-client/modeller/figure-fasten-dialog.js.map +1 -0
  23. package/dist-client/modeller/figure-fasten-drawing.d.ts +6 -3
  24. package/dist-client/modeller/figure-fasten-drawing.js +36 -10
  25. package/dist-client/modeller/figure-fasten-drawing.js.map +1 -1
  26. package/dist-client/modeller/figure-links.d.ts +15 -39
  27. package/dist-client/modeller/figure-links.js +58 -301
  28. package/dist-client/modeller/figure-links.js.map +1 -1
  29. package/dist-client/modeller/modeller-keys.js +4 -4
  30. package/dist-client/modeller/modeller-keys.js.map +1 -1
  31. package/dist-client/route.d.ts +1 -1
  32. package/dist-client/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +5 -5
  34. package/test/browser/links-page.js +4 -4
  35. package/test/browser/links.check.mjs +184 -46
  36. package/test/browser/modeller-page.js +23 -0
  37. package/test/browser/modeller.check.mjs +19 -20
  38. package/test/browser/namespace-page.js +2 -29
  39. package/test/browser/popup-stand-in.js +48 -0
  40. package/test/browser/product-page.check.mjs +4 -3
  41. package/test/browser/product-page.js +19 -32
  42. package/test/browser/props.check.mjs +28 -7
  43. package/test/browser/screen.check.mjs +28 -23
  44. package/test/browser/section-page.js +13 -41
  45. package/test/browser/section.check.mjs +39 -30
  46. package/test/fasten-form.test.ts +77 -0
  47. package/test/fasten-geometry.test.ts +2 -0
  48. package/test/first-minute.test.ts +7 -4
  49. package/translations/en.json +4 -3
  50. package/translations/es.json +4 -3
  51. package/translations/ja.json +4 -3
  52. package/translations/ko.json +4 -3
  53. package/translations/ms.json +4 -3
  54. package/translations/zh.json +4 -3
@@ -0,0 +1,442 @@
1
+ import '@material/web/button/filled-button.js'
2
+ import '@material/web/button/text-button.js'
3
+
4
+ import { css, html, LitElement, nothing } from 'lit'
5
+ import { customElement, property, state } from 'lit/decorators.js'
6
+
7
+ import { i18next, localize } from '@operato/i18n'
8
+ import '@operato/input/ox-input-select-buttons.js'
9
+ import '@operato/popup/ox-popup-actions.js'
10
+ import { CommonPopupStyles } from '@operato/styles'
11
+ import { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js'
12
+
13
+ import './figure-fasten-drawing.js'
14
+ import type { FastenChange } from './figure-fasten-drawing.js'
15
+ import { turnsInPlace, type FastenMode } from './fasten-geometry.js'
16
+ import {
17
+ aimFasten,
18
+ fastenChanged,
19
+ fastenDetailWordsOf,
20
+ fastenFormOf,
21
+ fastenPlanOf,
22
+ fastenSentenceOf,
23
+ fastenTargetsOf,
24
+ type FastenForm
25
+ } from './fasten-form.js'
26
+ import { fieldWordsOf, hasInstanceSize, heldBy, type Alignment, type Axis } from './links.js'
27
+ import type { FigureRevision } from './revision.js'
28
+
29
+ /** The target list's entry for the plane the figure stands by. */
30
+ const PLANE = '__plane'
31
+
32
+ /**
33
+ * 붙이기 창: what the selected part is fastened to, on which face, how -- chosen with room to see it, in the standard
34
+ * popup the editor opens (`openPopup`: its title, its close, moved by its head) (user 2026-10-17: 「속성에는 심플하고
35
+ * 직관적인 결과 위주로, 편집은 팝업에서 넓은 공간을 써서」; 2026-10-18: the standard popup, not a window of its own).
36
+ *
37
+ * Everything chosen here is tried, not done: the command it comes to is told to the editor as it changes
38
+ * (`preview-command`), and the canvas draws it. 「적용」 sends it once (`fasten-apply`), one step of the history;
39
+ * 「취소」 and Esc close it with nothing written (`fasten-cancel`). A row of the target list under the pointer or the
40
+ * arrows asks the canvas to light that part (`fasten-hover`). The window is the only one telling the preview while it
41
+ * is open; the editor keeps the panel quiet.
42
+ */
43
+ @customElement('figure-fasten-dialog')
44
+ export class FigureFastenDialog extends localize(i18next)(LitElement) {
45
+ static styles = [
46
+ SidePanelStyles,
47
+ CommonPopupStyles,
48
+ css`
49
+ :host {
50
+ display: grid;
51
+ gap: 16px;
52
+ padding: var(--popup-padding, 16px);
53
+ overflow: auto;
54
+ }
55
+ /* The result in one line, at the top: it changes with every choice below it. */
56
+ p[fasten-sentence] {
57
+ margin: 0;
58
+ font-size: var(--ui-t-body, 13px);
59
+ font-weight: 600;
60
+ }
61
+ div[question] {
62
+ display: grid;
63
+ align-content: start;
64
+ gap: 6px;
65
+ }
66
+ h4 {
67
+ margin: 0;
68
+ font-size: var(--ui-t-small, 11.5px);
69
+ font-weight: 600;
70
+ color: var(--md-sys-color-on-surface-variant);
71
+ }
72
+ p[loops] {
73
+ margin: 0;
74
+ }
75
+ details[fasten-detail] {
76
+ margin: 0;
77
+ }
78
+ details[fasten-detail] > div[form] {
79
+ margin-top: 8px;
80
+ max-width: 320px;
81
+ }
82
+ span[fasten-summary] {
83
+ opacity: 0.8;
84
+ }
85
+ ul[preview-words] {
86
+ margin: 0;
87
+ padding: 8px 12px 8px 26px;
88
+ border-radius: 6px;
89
+ background: var(--md-sys-color-surface-container, #8881);
90
+ display: grid;
91
+ gap: 4px;
92
+ }
93
+ p[preview-words] {
94
+ margin: 0;
95
+ padding: 8px 12px;
96
+ border-radius: 6px;
97
+ background: var(--md-sys-color-surface-container, #8881);
98
+ }
99
+ p[error] {
100
+ margin: 0;
101
+ color: var(--md-sys-color-error);
102
+ }
103
+ `
104
+ ]
105
+
106
+ /** The figure at the version on screen. */
107
+ @property({ attribute: false }) revision?: FigureRevision
108
+ /** The part being fastened. */
109
+ @property() partId = ''
110
+ @property({ type: Boolean }) locked = false
111
+ /** What the command would do, in words (the editor works it out: `command-preview.ts`). */
112
+ @property({ attribute: false }) previewWords: string[] = []
113
+ /** Why the last 「적용」 was refused, in the editor's words. */
114
+ @property() error = ''
115
+
116
+ @state() private form?: FastenForm
117
+ /** The command the part's own fastening comes to, as opened: tried unchanged, nothing new is said of it. */
118
+ private opened?: string
119
+ private told = ''
120
+ private loadedFor?: string
121
+ private hovered: string | null = null
122
+
123
+ willUpdate() {
124
+ /* Opened on what the part has now; another part is another window's. */
125
+ if (this.revision && this.partId && this.partId !== this.loadedFor) {
126
+ this.loadedFor = this.partId
127
+ this.form = fastenFormOf(this.revision, this.partId)
128
+ this.opened = JSON.stringify(fastenPlanOf(this.revision, this.partId, this.form).action ?? null)
129
+ }
130
+ }
131
+
132
+ async firstUpdated() {
133
+ /* Into the list, on what is chosen, so the arrows go from there. */
134
+ const list = this.renderRoot.querySelector<HTMLElement & { updateComplete?: Promise<unknown> }>(
135
+ 'ox-input-select-buttons'
136
+ )
137
+ await list?.updateComplete
138
+ const chips = list?.shadowRoot?.querySelectorAll<HTMLElement>('md-filter-chip')
139
+ ;([...(chips ?? [])].find(c => c.hasAttribute('selected')) ?? chips?.[0])?.focus()
140
+ }
141
+
142
+ updated() {
143
+ const plan = this.revision && this.form ? fastenPlanOf(this.revision, this.partId, this.form) : undefined
144
+ const candidate = plan?.action ? { action: plan.action, ...(plan.face ? { face: plan.face } : {}) } : null
145
+ const said = JSON.stringify(candidate)
146
+ if (said === this.told) return
147
+ this.told = said
148
+ this.dispatchEvent(new CustomEvent('preview-command', { detail: candidate, bubbles: true, composed: true }))
149
+ }
150
+
151
+ disconnectedCallback() {
152
+ super.disconnectedCallback()
153
+ /* Closed: what it showed goes with it. */
154
+ if (this.told && this.told !== 'null')
155
+ this.dispatchEvent(new CustomEvent('preview-command', { detail: null, bubbles: true, composed: true }))
156
+ this.told = ''
157
+ this.hover(null)
158
+ }
159
+
160
+ render() {
161
+ const revision = this.revision
162
+ const f = this.form
163
+ if (!revision || !f) return nothing
164
+ const asset = revision.asset
165
+ const held = !!heldBy(asset, this.partId)
166
+ const plan = fastenPlanOf(revision, this.partId, f)
167
+ const planeWord = i18next.t('figure.label.resize-place-' + (asset.placement ?? 'floor'))
168
+ const modes: FastenMode[] = f.toPlane
169
+ ? ['meet']
170
+ : ['meet', 'flush', ...(turnsInPlace(asset, this.partId) ? (['centre'] as FastenMode[]) : [])]
171
+ const detail = fastenDetailWordsOf(f, (key, params) => i18next.t(key, params))
172
+ const drawing = (show: 'face' | 'how') =>
173
+ html`<figure-fasten-drawing
174
+ show=${show}
175
+ .target=${f.toPlane ? '' : f.target}
176
+ .planeWord=${planeWord}
177
+ .faces=${plan.theirFaces}
178
+ .face=${plan.targetFace}
179
+ .modes=${modes}
180
+ .mode=${plan.mode}
181
+ .view=${plan.view}
182
+ .align=${f.align}
183
+ .alignMm=${f.alignMm}
184
+ .gap=${f.gap}
185
+ .partName=${this.partId}
186
+ ?locked=${this.locked}
187
+ @fasten-change=${(e: CustomEvent<FastenChange>) => (this.form = fastenChanged(revision, this.partId, this.form!, e.detail))}
188
+ ></figure-fasten-drawing>`
189
+ return html`
190
+ ${
191
+ plan.aim
192
+ ? html`<p fasten-sentence role="status">
193
+ ${fastenSentenceOf(this.partId, f, plan, planeWord, (key, params) => i18next.t(key, params))}
194
+ </p>`
195
+ : html`<p hint fasten-sentence>${i18next.t('figure.text.fasten-target-first')}</p>`
196
+ }
197
+ <div question="what">
198
+ <h4 id="what">${i18next.t('figure.label.fasten-what')}</h4>
199
+ ${this.renderTargets(revision, f, planeWord)}
200
+ </div>
201
+ ${
202
+ plan.aim
203
+ ? html`<div question="face">
204
+ <h4>
205
+ ${
206
+ /* The face asked is the target's, named: the part's own face follows from it. */ f.toPlane
207
+ ? i18next.t('figure.label.fasten-face-on-plane', { plane: planeWord })
208
+ : i18next.t('figure.label.fasten-face-on-part', { part: f.target })
209
+ }
210
+ </h4>
211
+ ${drawing('face')}
212
+ </div>
213
+ ${
214
+ modes.length > 1
215
+ ? html`<div question="how">
216
+ <h4>${i18next.t('figure.label.fasten-how')}</h4>
217
+ ${drawing('how')}
218
+ </div>`
219
+ : nothing
220
+ }
221
+ <div question="detail">
222
+ <details fasten-detail>
223
+ <summary>
224
+ ${i18next.t('figure.label.fasten-detail')}${detail.length ? html` · <span fasten-summary>${detail.join(' · ')}</span>` : nothing}
225
+ </summary>
226
+ ${plan.alignRows.length ? this.renderAlignment(plan.alignRows) : nothing}
227
+ <div form>
228
+ <span>${i18next.t('figure.label.gap')}</span>
229
+ <input
230
+ gap
231
+ type="number"
232
+ step="any"
233
+ .value=${f.gapKept !== undefined ? '' : String(f.gap)}
234
+ placeholder=${f.gapKept !== undefined ? i18next.t('figure.label.follows-expression') : ''}
235
+ @change=${(e: Event) => this.set({ gap: Number((e.target as HTMLInputElement).value) || 0, gapKept: undefined })}
236
+ />
237
+ <span>${i18next.t('figure.label.twist')}</span>
238
+ <input
239
+ twist
240
+ type="number"
241
+ step="any"
242
+ .value=${String(f.twist)}
243
+ @change=${(e: Event) => this.set({ twist: Number((e.target as HTMLInputElement).value) || 0 })}
244
+ />
245
+ </div>
246
+ </details>
247
+ </div>
248
+ ${/* The one it has, tried unchanged: that it stays where it is goes without saying. */ JSON.stringify(plan.action ?? null) === this.opened ? nothing : this.renderPreviewWords()}`
249
+ : nothing
250
+ }
251
+ ${this.error ? html`<p error role="alert">${this.error}</p>` : nothing}
252
+ <ox-popup-actions>
253
+ <md-text-button slot="cancel" cancel @click=${this.cancel}>${i18next.t('figure.button.cancel')}</md-text-button>
254
+ <md-filled-button slot="confirm" apply ?disabled=${this.locked || !plan.action} @click=${this.apply}>
255
+ ${i18next.t(held ? 'figure.button.apply' : 'figure.button.fasten')}
256
+ </md-filled-button>
257
+ </ox-popup-actions>
258
+ `
259
+ }
260
+
261
+ /**
262
+ * What to fasten to: the plane and the other parts, as the standard choice chips. The arrows move among them and
263
+ * the canvas lights the part under the focus or the pointer; a part hanging from this one is not offered, and why is
264
+ * said under them.
265
+ */
266
+ private renderTargets(revision: FigureRevision, f: FastenForm, planeWord: string) {
267
+ const chosen = f.toPlane ? PLANE : f.target
268
+ const targets = fastenTargetsOf(revision, this.partId)
269
+ const chipOf = (e: Event) =>
270
+ (e.composedPath().find(n => (n as Element).localName === 'md-filter-chip') as Element | undefined)?.getAttribute(
271
+ 'data-value'
272
+ ) ?? null
273
+ return html`<ox-input-select-buttons
274
+ targets
275
+ aria-labelledby="what"
276
+ .options=${[{ value: PLANE, display: planeWord }, ...targets.filter(t => !t.loops).map(t => ({ value: t.part, display: t.part }))]}
277
+ .value=${chosen || undefined}
278
+ ?disabled=${this.locked}
279
+ @change=${(e: CustomEvent) => {
280
+ /* A chip pressed again lets go of it; what to fasten to is always one thing once chosen. */
281
+ if (e.detail) this.aim(e.detail)
282
+ else (e.target as HTMLElement & { value?: string }).value = chosen || undefined
283
+ }}
284
+ @pointerover=${(e: Event) => this.hover(chipOf(e))}
285
+ @pointerleave=${() => this.hover(null)}
286
+ @focusin=${(e: Event) => this.hover(chipOf(e))}
287
+ @keyup=${(e: KeyboardEvent) => {
288
+ /* The arrows move the focus among the chips inside the list, which tells nothing outside it: read where it is. */
289
+ const at = (e.currentTarget as Element).shadowRoot?.activeElement
290
+ if (at?.localName === 'md-filter-chip') this.hover(at.getAttribute('data-value'))
291
+ }}
292
+ ></ox-input-select-buttons>
293
+ ${targets.filter(t => t.loops).map(t => html`<p hint loops target=${t.part}>${i18next.t('figure.text.target-would-loop', { part: t.part, mine: this.partId })}</p>`)}`
294
+ }
295
+
296
+ private aim(part: string) {
297
+ if (this.locked || !this.revision || !this.form) return
298
+ const chosen = this.form.toPlane ? PLANE : this.form.target
299
+ if (part === chosen) return
300
+ this.form = aimFasten(this.revision, this.partId, this.form, part === PLANE ? { plane: true } : { part })
301
+ }
302
+
303
+ /** The part under the pointer or the focus in the list, for the canvas to light; the plane lights nothing. */
304
+ private hover(part: string | null) {
305
+ const lit = part && part !== PLANE ? part : null
306
+ if (lit === this.hovered) return
307
+ this.hovered = lit
308
+ const face =
309
+ lit && this.revision && this.form
310
+ ? fastenPlanOf(this.revision, this.partId, aimFasten(this.revision, this.partId, this.form, { part: lit }))
311
+ .targetFace
312
+ : undefined
313
+ this.dispatchEvent(
314
+ new CustomEvent('fasten-hover', { detail: lit ? { part: lit, face } : null, bubbles: true, composed: true })
315
+ )
316
+ }
317
+
318
+ private set(change: Partial<FastenForm>) {
319
+ this.form = { ...this.form!, ...change }
320
+ }
321
+
322
+ /**
323
+ * Where on the target face the part sits, on the axes the drawing cannot set: centred, level with the target's edge on
324
+ * either side, a distance off centre, a share of the figure's size, or the position field it follows.
325
+ */
326
+ private renderAlignment(axes: { axis: Axis; edges: boolean }[]) {
327
+ const f = this.form!
328
+ const set = (axis: Axis, how: Alignment) => this.set({ align: { ...f.align, [axis]: how } })
329
+ const setMm = (axis: Axis, mm: number) => this.set({ alignMm: { ...f.alignMm, [axis]: mm } })
330
+ return html`<div form>
331
+ ${axes.map(({ axis, edges }) => {
332
+ const how =
333
+ f.align[axis] === 'min' || f.align[axis] === 'max'
334
+ ? edges
335
+ ? f.align[axis]!
336
+ : 'centre'
337
+ : (f.align[axis] ?? 'centre')
338
+ return html`<span>${i18next.t('figure.label.align-' + axis)}</span>
339
+ <select @change=${(e: Event) => set(axis, (e.target as HTMLSelectElement).value as Alignment)}>
340
+ <option value="centre" ?selected=${how === 'centre'}>${i18next.t('figure.label.align-centre')}</option>
341
+ ${
342
+ edges
343
+ ? html`<option value="min" ?selected=${how === 'min'}>
344
+ ${i18next.t(`figure.label.align-${axis}-min`)}
345
+ </option>
346
+ <option value="max" ?selected=${how === 'max'}>
347
+ ${i18next.t(`figure.label.align-${axis}-max`)}
348
+ </option>`
349
+ : nothing
350
+ }
351
+ ${
352
+ f.alignInput?.[axis]
353
+ ? html`<option value="input" ?selected=${how === 'input'}>
354
+ ${i18next.t('figure.label.align-input', { field: fieldWordsOf(f.alignInput[axis]!, key => i18next.t(key)) })}
355
+ </option>`
356
+ : nothing
357
+ }
358
+ <option value="mm" ?selected=${how === 'mm'}>${i18next.t('figure.label.align-mm')}</option>
359
+ ${
360
+ this.revision && hasInstanceSize(this.revision.asset, axis)
361
+ ? html`<option value="share" ?selected=${how === 'share'}>
362
+ ${i18next.t('figure.label.align-share')}
363
+ </option>`
364
+ : nothing
365
+ }
366
+ </select>
367
+ ${
368
+ how === 'mm' || how === 'share'
369
+ ? html`<span></span
370
+ ><input
371
+ type="number"
372
+ step="any"
373
+ aria-label=${i18next.t('figure.label.align-mm')}
374
+ .value=${String(f.alignMm[axis] ?? 0)}
375
+ @change=${(e: Event) => setMm(axis, Number((e.target as HTMLInputElement).value) || 0)}
376
+ />`
377
+ : nothing
378
+ }`
379
+ })}
380
+ </div>`
381
+ }
382
+
383
+ private renderPreviewWords() {
384
+ if (this.previewWords.length === 1) return html`<p preview-words role="status">${this.previewWords[0]}</p>`
385
+ return this.previewWords.length
386
+ ? html`<ul preview-words role="status">
387
+ ${this.previewWords.map(line => html`<li>${line}</li>`)}
388
+ </ul>`
389
+ : nothing
390
+ }
391
+
392
+ /** Enter applies what is chosen, Esc closes with nothing written; a key the window does not take goes on. */
393
+ connectedCallback() {
394
+ super.connectedCallback()
395
+ this.setAttribute('role', 'dialog')
396
+ this.setAttribute('aria-label', i18next.t('figure.label.fastening'))
397
+ this.addEventListener('keydown', this.onKey)
398
+ /* The popup's fitting width is the overlay's own setting; the window asks it for room for the face and the way side by side. */
399
+ this.closest<HTMLElement>('ox-floating-overlay')?.style.setProperty('--overlay-center-fit-width', '640px')
400
+ }
401
+
402
+ private onKey = async (e: KeyboardEvent) => {
403
+ if (e.key === 'Escape') {
404
+ e.stopPropagation()
405
+ e.preventDefault()
406
+ this.cancel()
407
+ return
408
+ }
409
+ if (e.key !== 'Enter' || e.isComposing) return
410
+ const path = e.composedPath() as Element[]
411
+ const target = path[0] as HTMLElement
412
+ /* On a chip of the list Enter applies, as it does anywhere in the window; a chip is chosen by Space or a press. */
413
+ const onChip = path.some(n => n.localName === 'ox-input-select-buttons')
414
+ /* A button, a fold or a list of options does what Enter does to it. */
415
+ if (
416
+ !onChip &&
417
+ (target.localName === 'button' ||
418
+ target.localName === 'summary' ||
419
+ target.localName === 'select' ||
420
+ /^md-.*button$/.test(target.localName))
421
+ )
422
+ return
423
+ e.preventDefault()
424
+ e.stopPropagation()
425
+ /* A number typed and Enter: the number first, as leaving the field would take it. */
426
+ if (target.localName === 'input') target.dispatchEvent(new Event('change', { bubbles: true, composed: true }))
427
+ await this.updateComplete
428
+ this.apply()
429
+ }
430
+
431
+ private apply = () => {
432
+ const plan = this.revision && this.form ? fastenPlanOf(this.revision, this.partId, this.form) : undefined
433
+ if (this.locked || !plan?.action) return
434
+ this.dispatchEvent(
435
+ new CustomEvent('fasten-apply', { detail: { action: plan.action }, bubbles: true, composed: true })
436
+ )
437
+ }
438
+
439
+ private cancel = () => {
440
+ this.dispatchEvent(new CustomEvent('fasten-cancel', { bubbles: true, composed: true }))
441
+ }
442
+ }
@@ -29,6 +29,9 @@ const HIDDEN: Array<[FigureFace, number, number]> = [
29
29
  ['back', 236, 14]
30
30
  ]
31
31
  const PANEL_W = 300
32
+ /* The face seen from above, beside the box in the fastening window: taller than the panel's was, for a long face's parts. */
33
+ const WHERE_W = 360
34
+ const WHERE_H = 200
32
35
 
33
36
 
34
37
  /**
@@ -41,7 +44,8 @@ const PANEL_W = 300
41
44
  * footprint on it: dragged, caught at the centre and at the edges from inside and outside, a guide drawn where it is
42
45
  * caught and a dimension where it is not, which is pressed to type the number. It may go past the edges: the part that
43
46
  * does is shaded, and a part off the face altogether is said so. Nothing is decided here: every change goes to the form
44
- * (`fasten-change`), and a press or a drag let go says so (`fasten-release`), for the form to apply a fastening it holds.
47
+ * (`fasten-change`), and a press or a drag let go says so (`fasten-release`). The window draws it twice, under its own
48
+ * questions: the face (`show="face"`: the box and the face seen from above, side by side) and the way (`show="how"`).
45
49
  */
46
50
  @customElement('figure-fasten-drawing')
47
51
  export class FigureFastenDrawing extends localize(i18next)(LitElement) {
@@ -62,31 +66,45 @@ export class FigureFastenDrawing extends localize(i18next)(LitElement) {
62
66
  }
63
67
  div[modes] {
64
68
  display: grid;
65
- grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
69
+ grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
66
70
  gap: 6px;
67
71
  }
68
72
  div[modes] svg {
69
- width: 64px;
70
- height: 44px;
73
+ width: 48px;
74
+ height: 33px;
71
75
  }
76
+ /* A choice drawn, not a box to press (the side's rule: no boxed buttons): the chosen one on the primary's ground. */
72
77
  div[modes] button {
73
78
  display: grid;
74
79
  justify-items: center;
75
80
  align-content: center;
76
81
  gap: 2px;
77
- padding: 2px 4px 4px;
82
+ padding: 4px 4px 6px;
78
83
  font: inherit;
79
84
  color: var(--md-sys-color-on-surface);
80
85
  background: none;
81
- border: 1px solid var(--md-sys-color-outline-variant);
82
- border-radius: 8px;
86
+ border: none;
87
+ border-radius: 6px;
83
88
  cursor: pointer;
84
89
  }
90
+ div[modes] button:hover:not([on]):not(:disabled) {
91
+ background: var(--md-sys-color-surface-container);
92
+ }
85
93
  div[modes] button[on] {
86
- border: 1.5px solid var(--md-sys-color-primary);
87
94
  background: var(--md-sys-color-primary-container);
88
95
  color: var(--md-sys-color-on-primary-container);
89
96
  }
97
+ /* The box and the face seen from above side by side, one under the other where the window is narrow. */
98
+ div[face-row] {
99
+ display: grid;
100
+ grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
101
+ gap: 12px;
102
+ align-items: start;
103
+ }
104
+ div[face-row] > div {
105
+ display: grid;
106
+ gap: 8px;
107
+ }
90
108
  div[where] {
91
109
  position: relative;
92
110
  }
@@ -120,6 +138,8 @@ export class FigureFastenDrawing extends localize(i18next)(LitElement) {
120
138
  @property({ type: Boolean }) locked = false
121
139
  /** The form already says how the fastening it has lies on the face: the drawing says it only while dragging. */
122
140
  @property({ type: Boolean }) said = false
141
+ /** Which of its questions it draws: the face, or the way. */
142
+ @property() show: 'face' | 'how' = 'face'
123
143
 
124
144
  /** Where the footprint is while dragging, and what it is caught by; undefined when nothing is dragged. */
125
145
  @state() private dragged?: { at: Record<Axis, number>; caught: Partial<Record<Axis, string>> }
@@ -135,7 +155,8 @@ export class FigureFastenDrawing extends localize(i18next)(LitElement) {
135
155
  }
136
156
 
137
157
  render() {
138
- return html`${this.renderTarget()}${this.renderModes()}${this.renderWhere()}`
158
+ if (this.show === 'how') return this.renderModes()
159
+ return html`<div face-row>${this.target ? html`<div>${this.renderTarget()}</div>` : nothing}<div>${this.renderWhere()}</div></div>`
139
160
  }
140
161
 
141
162
  /** The target box, its faces pressed; or the plane. */
@@ -248,8 +269,8 @@ export class FigureFastenDrawing extends localize(i18next)(LitElement) {
248
269
  const view = this.view
249
270
  if (!view) return nothing
250
271
  const { h, v, sign } = screenOf(view.axes)
251
- const W = PANEL_W,
252
- H = 180
272
+ const W = WHERE_W,
273
+ H = WHERE_H
253
274
  /* Room around the face for the part to go past its edges by about half itself; a plane with no size, three parts wide. */
254
275
  const span = (a: Axis) => (view.face[a] !== undefined ? view.face[a]! + view.part[a] : view.part[a] * 3)
255
276
  const k = Math.min((W - 40) / span(h), (H - 40) / span(v))