@things-factory/figure-ui 10.1.69 → 10.1.71
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.
- package/client/graphql/index.ts +38 -6
- package/client/modeller/figure-v3-parts.ts +16 -136
- package/client/modeller/figure-v3-recipe-catalog.ts +348 -0
- package/client/modeller/v3-editor.ts +25 -5
- package/client/modeller/v3-fields.ts +21 -16
- package/client/modeller/v3-gizmo.ts +1 -1
- package/client/modeller/v3-links.ts +7 -66
- package/client/modeller/v3-palette.ts +3 -0
- package/client/modeller/v3-recipe-source.ts +15 -0
- package/client/modeller/v3-recipes.ts +53 -12
- package/client/pages/figure-v3-modeller-page.ts +16 -13
- package/dist-client/graphql/index.d.ts +12 -3
- package/dist-client/graphql/index.js +25 -6
- package/dist-client/graphql/index.js.map +1 -1
- package/dist-client/modeller/figure-v3-parts.d.ts +5 -12
- package/dist-client/modeller/figure-v3-parts.js +17 -147
- package/dist-client/modeller/figure-v3-parts.js.map +1 -1
- package/dist-client/modeller/figure-v3-recipe-catalog.d.ts +36 -0
- package/dist-client/modeller/figure-v3-recipe-catalog.js +382 -0
- package/dist-client/modeller/figure-v3-recipe-catalog.js.map +1 -0
- package/dist-client/modeller/v3-editor.d.ts +8 -3
- package/dist-client/modeller/v3-editor.js +35 -6
- package/dist-client/modeller/v3-editor.js.map +1 -1
- package/dist-client/modeller/v3-fields.d.ts +2 -2
- package/dist-client/modeller/v3-fields.js +20 -18
- package/dist-client/modeller/v3-fields.js.map +1 -1
- package/dist-client/modeller/v3-gizmo.js +1 -1
- package/dist-client/modeller/v3-gizmo.js.map +1 -1
- package/dist-client/modeller/v3-links.d.ts +8 -25
- package/dist-client/modeller/v3-links.js +4 -66
- package/dist-client/modeller/v3-links.js.map +1 -1
- package/dist-client/modeller/v3-palette.js +3 -0
- package/dist-client/modeller/v3-palette.js.map +1 -1
- package/dist-client/modeller/v3-recipe-source.d.ts +8 -0
- package/dist-client/modeller/v3-recipe-source.js +14 -0
- package/dist-client/modeller/v3-recipe-source.js.map +1 -0
- package/dist-client/modeller/v3-recipes.d.ts +25 -4
- package/dist-client/modeller/v3-recipes.js +43 -11
- package/dist-client/modeller/v3-recipes.js.map +1 -1
- package/dist-client/pages/figure-v3-modeller-page.d.ts +5 -3
- package/dist-client/pages/figure-v3-modeller-page.js +16 -13
- package/dist-client/pages/figure-v3-modeller-page.js.map +1 -1
- package/dist-client/tsconfig.fui.tsbuildinfo +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/scripts/template-thumbnails.mjs +53 -0
- package/test/browser/build.mjs +3 -3
- package/test/browser/modeller-page.js +25 -3
- package/test/browser/modeller.check.mjs +57 -47
- package/test/browser/thumbnail-page.js +14 -0
- package/test/v3-fields.test.ts +5 -1
- package/test/v3-links.test.ts +12 -0
- package/test/v3-recipes.test.ts +44 -11
- package/translations/en.json +38 -1
- package/translations/ja.json +38 -1
- package/translations/ko.json +38 -1
- package/translations/ms.json +38 -1
- package/translations/zh.json +38 -1
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import '@operato/markdown';
|
|
4
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
5
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
6
|
+
import { i18next, localize } from '@operato/i18n';
|
|
7
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
8
|
+
import { describeV3Recipe } from '@hatiolab/figure-model';
|
|
9
|
+
import { recipeFieldOf, recipeReady, recipeValueOf, recipeWord, recipeWorkings, recipesMatching } from './v3-recipes.js';
|
|
10
|
+
/**
|
|
11
|
+
* The recipe catalog (ADR-0095): the templates the product ships, by category, found by words, each told in full --
|
|
12
|
+
* what it puts in, how many parts, how they move, what each value does, and how to use it -- and put onto the chosen
|
|
13
|
+
* part in one step. The numbers and the ways of moving are worked out from the recipe (`describeV3Recipe`), so they say
|
|
14
|
+
* what it does; only the descriptions and the guide are written.
|
|
15
|
+
*/
|
|
16
|
+
let FigureV3RecipeCatalog = class FigureV3RecipeCatalog extends localize(i18next)(LitElement) {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.templates = [];
|
|
20
|
+
/** The part it would be put onto. */
|
|
21
|
+
this.selected = '';
|
|
22
|
+
this.locked = false;
|
|
23
|
+
/** Why the last one put in was refused, in the kernel's words. */
|
|
24
|
+
this.error = '';
|
|
25
|
+
this.category = '';
|
|
26
|
+
this.query = '';
|
|
27
|
+
this.chosen = '';
|
|
28
|
+
this.values = {};
|
|
29
|
+
this.guide = '';
|
|
30
|
+
}
|
|
31
|
+
static { this.styles = [
|
|
32
|
+
ScrollbarStyles,
|
|
33
|
+
css `
|
|
34
|
+
:host {
|
|
35
|
+
position: fixed;
|
|
36
|
+
inset: 0;
|
|
37
|
+
z-index: 20;
|
|
38
|
+
display: grid;
|
|
39
|
+
place-items: center;
|
|
40
|
+
background: color-mix(in srgb, var(--md-sys-color-scrim, #000) 32%, transparent);
|
|
41
|
+
font-size: 0.82rem;
|
|
42
|
+
color: var(--md-sys-color-on-surface);
|
|
43
|
+
}
|
|
44
|
+
div[panel] {
|
|
45
|
+
display: grid;
|
|
46
|
+
grid-template-rows: auto 1fr;
|
|
47
|
+
width: min(1100px, calc(100vw - 32px));
|
|
48
|
+
height: min(720px, calc(100vh - 32px));
|
|
49
|
+
background: var(--md-sys-color-surface);
|
|
50
|
+
border-radius: 12px;
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
|
|
53
|
+
}
|
|
54
|
+
header {
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: 8px;
|
|
58
|
+
padding: 8px 12px;
|
|
59
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
60
|
+
}
|
|
61
|
+
header h2 {
|
|
62
|
+
margin: 0;
|
|
63
|
+
font-size: var(--ui-t-title, 16px);
|
|
64
|
+
flex: 1;
|
|
65
|
+
}
|
|
66
|
+
header input {
|
|
67
|
+
width: 220px;
|
|
68
|
+
padding: 4px 8px;
|
|
69
|
+
font: inherit;
|
|
70
|
+
}
|
|
71
|
+
button[close] {
|
|
72
|
+
display: inline-grid;
|
|
73
|
+
place-items: center;
|
|
74
|
+
width: 32px;
|
|
75
|
+
height: 32px;
|
|
76
|
+
border: none;
|
|
77
|
+
border-radius: 8px;
|
|
78
|
+
background: none;
|
|
79
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
}
|
|
82
|
+
div[body] {
|
|
83
|
+
display: grid;
|
|
84
|
+
grid-template-columns: 170px minmax(0, 1fr) minmax(300px, 380px);
|
|
85
|
+
min-height: 0;
|
|
86
|
+
}
|
|
87
|
+
@media (max-width: 760px) {
|
|
88
|
+
div[body] {
|
|
89
|
+
grid-template-columns: 1fr;
|
|
90
|
+
overflow: auto;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
nav,
|
|
94
|
+
section[list],
|
|
95
|
+
section[detail] {
|
|
96
|
+
overflow: auto;
|
|
97
|
+
min-height: 0;
|
|
98
|
+
padding: 8px;
|
|
99
|
+
}
|
|
100
|
+
nav {
|
|
101
|
+
border-right: 1px solid var(--md-sys-color-outline-variant);
|
|
102
|
+
}
|
|
103
|
+
section[detail] {
|
|
104
|
+
border-left: 1px solid var(--md-sys-color-outline-variant);
|
|
105
|
+
display: grid;
|
|
106
|
+
gap: 10px;
|
|
107
|
+
align-content: start;
|
|
108
|
+
}
|
|
109
|
+
button[category] {
|
|
110
|
+
display: flex;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
width: 100%;
|
|
113
|
+
padding: 6px 8px;
|
|
114
|
+
font: inherit;
|
|
115
|
+
color: inherit;
|
|
116
|
+
background: none;
|
|
117
|
+
border: none;
|
|
118
|
+
border-radius: 6px;
|
|
119
|
+
text-align: left;
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
}
|
|
122
|
+
button[category][on],
|
|
123
|
+
button[card][on] {
|
|
124
|
+
background: var(--md-sys-color-secondary-container);
|
|
125
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
126
|
+
}
|
|
127
|
+
section[list] {
|
|
128
|
+
display: grid;
|
|
129
|
+
grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
|
|
130
|
+
gap: 8px;
|
|
131
|
+
align-content: start;
|
|
132
|
+
}
|
|
133
|
+
button[card] {
|
|
134
|
+
display: grid;
|
|
135
|
+
gap: 4px;
|
|
136
|
+
padding: 8px;
|
|
137
|
+
font: inherit;
|
|
138
|
+
color: inherit;
|
|
139
|
+
text-align: left;
|
|
140
|
+
background: none;
|
|
141
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
142
|
+
border-radius: 8px;
|
|
143
|
+
cursor: pointer;
|
|
144
|
+
}
|
|
145
|
+
button[card] img {
|
|
146
|
+
width: 100%;
|
|
147
|
+
aspect-ratio: 4 / 3;
|
|
148
|
+
object-fit: contain;
|
|
149
|
+
background: var(--md-sys-color-surface-container);
|
|
150
|
+
border-radius: 4px;
|
|
151
|
+
}
|
|
152
|
+
button[card] small,
|
|
153
|
+
p[muted] {
|
|
154
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
155
|
+
}
|
|
156
|
+
h3 {
|
|
157
|
+
margin: 0;
|
|
158
|
+
font-size: var(--ui-t-body, 14px);
|
|
159
|
+
}
|
|
160
|
+
p {
|
|
161
|
+
margin: 0;
|
|
162
|
+
line-height: 1.5;
|
|
163
|
+
}
|
|
164
|
+
ul {
|
|
165
|
+
margin: 0;
|
|
166
|
+
padding-left: 18px;
|
|
167
|
+
line-height: 1.6;
|
|
168
|
+
}
|
|
169
|
+
table {
|
|
170
|
+
border-collapse: collapse;
|
|
171
|
+
width: 100%;
|
|
172
|
+
}
|
|
173
|
+
th,
|
|
174
|
+
td {
|
|
175
|
+
text-align: left;
|
|
176
|
+
vertical-align: top;
|
|
177
|
+
padding: 3px 4px;
|
|
178
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
179
|
+
}
|
|
180
|
+
td small {
|
|
181
|
+
display: block;
|
|
182
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
183
|
+
}
|
|
184
|
+
div[form] {
|
|
185
|
+
display: grid;
|
|
186
|
+
gap: 6px;
|
|
187
|
+
padding: 8px;
|
|
188
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
189
|
+
border-radius: 8px;
|
|
190
|
+
}
|
|
191
|
+
div[form] label {
|
|
192
|
+
display: grid;
|
|
193
|
+
gap: 2px;
|
|
194
|
+
}
|
|
195
|
+
div[form] label[toggle] {
|
|
196
|
+
display: flex;
|
|
197
|
+
align-items: center;
|
|
198
|
+
gap: 6px;
|
|
199
|
+
}
|
|
200
|
+
div[form] input,
|
|
201
|
+
div[form] select {
|
|
202
|
+
font: inherit;
|
|
203
|
+
min-width: 0;
|
|
204
|
+
}
|
|
205
|
+
button[insert] {
|
|
206
|
+
justify-self: start;
|
|
207
|
+
display: inline-flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
gap: 4px;
|
|
210
|
+
padding: 6px 14px;
|
|
211
|
+
font: inherit;
|
|
212
|
+
white-space: nowrap;
|
|
213
|
+
color: var(--md-sys-color-on-primary);
|
|
214
|
+
background: var(--md-sys-color-primary);
|
|
215
|
+
border: none;
|
|
216
|
+
border-radius: 999em;
|
|
217
|
+
cursor: pointer;
|
|
218
|
+
}
|
|
219
|
+
button[insert]:disabled {
|
|
220
|
+
opacity: 0.38;
|
|
221
|
+
cursor: default;
|
|
222
|
+
}
|
|
223
|
+
p[role='alert'] {
|
|
224
|
+
padding: 6px;
|
|
225
|
+
white-space: pre-wrap;
|
|
226
|
+
color: var(--md-sys-color-on-error-container);
|
|
227
|
+
background: var(--md-sys-color-error-container);
|
|
228
|
+
border-radius: 6px;
|
|
229
|
+
}
|
|
230
|
+
ox-markdown {
|
|
231
|
+
display: block;
|
|
232
|
+
}
|
|
233
|
+
`
|
|
234
|
+
]; }
|
|
235
|
+
render() {
|
|
236
|
+
const language = i18next.language || 'en';
|
|
237
|
+
const categories = [...new Set(this.templates.map(t => t.category))].sort();
|
|
238
|
+
const shown = recipesMatching(this.templates, this.category, this.query);
|
|
239
|
+
const chosen = this.templates.find(t => t.name === this.chosen) ?? shown[0];
|
|
240
|
+
return html `<div panel role="dialog" aria-modal="true" aria-label=${i18next.t('figure.label.recipe-catalog')}>
|
|
241
|
+
<header>
|
|
242
|
+
<h2>${i18next.t('figure.label.recipe-catalog')}</h2>
|
|
243
|
+
<input search type="search" placeholder=${i18next.t('figure.text.recipe-search')} .value=${this.query} @input=${(e) => (this.query = e.target.value)} />
|
|
244
|
+
<button close aria-label=${i18next.t('figure.button.close')} @click=${() => this.dispatchEvent(new CustomEvent('close-catalog', { bubbles: true, composed: true }))}>
|
|
245
|
+
<md-icon>close</md-icon>
|
|
246
|
+
</button>
|
|
247
|
+
</header>
|
|
248
|
+
<div body>
|
|
249
|
+
<nav>
|
|
250
|
+
<button category ?on=${!this.category} @click=${() => (this.category = '')}>
|
|
251
|
+
<span>${i18next.t('figure.label.recipe-all')}</span><small>${this.templates.length}</small>
|
|
252
|
+
</button>
|
|
253
|
+
${categories.map(c => html `<button category=${c} ?on=${this.category === c} @click=${() => (this.category = c)}>
|
|
254
|
+
<span>${i18next.t('figure.label.recipe-category-' + c)}</span><small>${this.templates.filter(t => t.category === c).length}</small>
|
|
255
|
+
</button>`)}
|
|
256
|
+
</nav>
|
|
257
|
+
<section list>
|
|
258
|
+
${shown.map(t => html `<button card=${t.name} ?on=${t.name === chosen?.name} @click=${() => this.choose(t)}>
|
|
259
|
+
${t.hasThumbnail && this.thumbnailOf ? html `<img alt="" loading="lazy" src=${this.thumbnailOf(t.name)} />` : nothing}
|
|
260
|
+
<b>${t.title}</b>
|
|
261
|
+
<small>${t.description}</small>
|
|
262
|
+
</button>`)}
|
|
263
|
+
</section>
|
|
264
|
+
<section detail>${chosen ? this.renderDetail(chosen, language) : nothing}</section>
|
|
265
|
+
</div>
|
|
266
|
+
</div>`;
|
|
267
|
+
}
|
|
268
|
+
choose(t) {
|
|
269
|
+
if (this.chosen === t.name)
|
|
270
|
+
return;
|
|
271
|
+
this.chosen = t.name;
|
|
272
|
+
this.values = Object.fromEntries(t.recipe.params.map(p => [p.name, p.default]));
|
|
273
|
+
this.guide = '';
|
|
274
|
+
this.guideOf?.(t.name)
|
|
275
|
+
.then(text => this.chosen === t.name && (this.guide = text))
|
|
276
|
+
.catch(() => { });
|
|
277
|
+
}
|
|
278
|
+
willUpdate() {
|
|
279
|
+
/* The first card is chosen while nothing is, so the detail is never empty. */
|
|
280
|
+
const shown = recipesMatching(this.templates, this.category, this.query);
|
|
281
|
+
if (!this.templates.some(t => t.name === this.chosen) && shown[0])
|
|
282
|
+
this.choose(shown[0]);
|
|
283
|
+
}
|
|
284
|
+
renderDetail(t, language) {
|
|
285
|
+
const d = describeV3Recipe(t.recipe);
|
|
286
|
+
const count = d.parts.min === d.parts.max ? String(d.parts.min) : `${d.parts.min}–${d.parts.max}`;
|
|
287
|
+
const ready = recipeReady(t.recipe, this.selected);
|
|
288
|
+
return html `
|
|
289
|
+
<h3>${t.title}</h3>
|
|
290
|
+
<p>${t.description}</p>
|
|
291
|
+
<div>
|
|
292
|
+
<h3>${i18next.t('figure.label.recipe-adds')}</h3>
|
|
293
|
+
<ul>
|
|
294
|
+
<li parts=${count}>${i18next.t("figure.text.recipe-parts", { parts: count })}</li>
|
|
295
|
+
${recipeWorkings(t.recipe).map(line => html `<li>${i18next.t(line.key, line.words)}</li>`)}
|
|
296
|
+
<li>${i18next.t(t.recipe.target === 'part' ? 'figure.text.recipe-onto-chosen' : 'figure.text.recipe-onto-figure')}</li>
|
|
297
|
+
</ul>
|
|
298
|
+
</div>
|
|
299
|
+
${t.recipe.params.length ? this.renderForm(t.recipe, language) : nothing}
|
|
300
|
+
${this.error ? html `<p role="alert">${this.error}</p>` : nothing}
|
|
301
|
+
${ready ? nothing : html `<p muted>${i18next.t('figure.text.recipe-needs-a-part')}</p>`}
|
|
302
|
+
<button insert ?disabled=${this.locked || !ready} @click=${() => this.dispatchEvent(new CustomEvent('insert-recipe', { detail: { recipe: t.recipe, values: this.values }, bubbles: true, composed: true }))}>
|
|
303
|
+
<md-icon>add</md-icon>${this.selected && t.recipe.target === 'part' ? i18next.t('figure.button.insert-recipe-onto', { part: this.selected }) : i18next.t('figure.button.insert-recipe')}
|
|
304
|
+
</button>
|
|
305
|
+
${this.guide ? html `<ox-markdown .src=${this.guide}></ox-markdown>` : nothing}
|
|
306
|
+
`;
|
|
307
|
+
}
|
|
308
|
+
/** Each value: its name, what it does, and the field to set it -- a share typed as a percentage. */
|
|
309
|
+
renderForm(recipe, language) {
|
|
310
|
+
const set = (name, value) => (this.values = { ...this.values, [name]: value });
|
|
311
|
+
return html `<div form>
|
|
312
|
+
<h3>${i18next.t('figure.label.recipe-values')}</h3>
|
|
313
|
+
${recipe.params.map(param => {
|
|
314
|
+
const label = recipeWord(param.label, language) || param.name;
|
|
315
|
+
const hint = recipeWord(param.hint, language);
|
|
316
|
+
const value = this.values[param.name] ?? param.default;
|
|
317
|
+
const help = hint ? html `<small>${hint}</small>` : nothing;
|
|
318
|
+
if (param.kind === 'flag')
|
|
319
|
+
return html `<label toggle><input type="checkbox" param=${param.name} .checked=${value === true} @change=${(e) => set(param.name, e.target.checked)} />${label}</label>${help}`;
|
|
320
|
+
if (param.kind === 'choice' || param.kind === 'face')
|
|
321
|
+
return html `<label><span>${label}</span>
|
|
322
|
+
<select param=${param.name} @change=${(e) => set(param.name, recipeValueOf(param, e.target.value))}>
|
|
323
|
+
${(param.options ?? []).map(o => html `<option value=${String(o)} ?selected=${o === value}>${String(o)}</option>`)}
|
|
324
|
+
</select></label
|
|
325
|
+
>${help}`;
|
|
326
|
+
const range = param.kind === 'ratio' ? `${recipeFieldOf(param, param.min ?? 0)}–${recipeFieldOf(param, param.max ?? 1)} %` : `${param.min ?? ''}–${param.max ?? ''} mm`;
|
|
327
|
+
return html `<label><span>${label} (${range})</span>
|
|
328
|
+
<input type="number" step="any" param=${param.name} .value=${recipeFieldOf(param, value)} @change=${(e) => set(param.name, recipeValueOf(param, e.target.value))} /></label
|
|
329
|
+
>${help}`;
|
|
330
|
+
})}
|
|
331
|
+
</div>`;
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
__decorate([
|
|
335
|
+
property({ attribute: false }),
|
|
336
|
+
__metadata("design:type", Array)
|
|
337
|
+
], FigureV3RecipeCatalog.prototype, "templates", void 0);
|
|
338
|
+
__decorate([
|
|
339
|
+
property({ type: String }),
|
|
340
|
+
__metadata("design:type", Object)
|
|
341
|
+
], FigureV3RecipeCatalog.prototype, "selected", void 0);
|
|
342
|
+
__decorate([
|
|
343
|
+
property({ type: Boolean }),
|
|
344
|
+
__metadata("design:type", Object)
|
|
345
|
+
], FigureV3RecipeCatalog.prototype, "locked", void 0);
|
|
346
|
+
__decorate([
|
|
347
|
+
property({ type: String }),
|
|
348
|
+
__metadata("design:type", Object)
|
|
349
|
+
], FigureV3RecipeCatalog.prototype, "error", void 0);
|
|
350
|
+
__decorate([
|
|
351
|
+
property({ attribute: false }),
|
|
352
|
+
__metadata("design:type", Function)
|
|
353
|
+
], FigureV3RecipeCatalog.prototype, "guideOf", void 0);
|
|
354
|
+
__decorate([
|
|
355
|
+
property({ attribute: false }),
|
|
356
|
+
__metadata("design:type", Function)
|
|
357
|
+
], FigureV3RecipeCatalog.prototype, "thumbnailOf", void 0);
|
|
358
|
+
__decorate([
|
|
359
|
+
state(),
|
|
360
|
+
__metadata("design:type", Object)
|
|
361
|
+
], FigureV3RecipeCatalog.prototype, "category", void 0);
|
|
362
|
+
__decorate([
|
|
363
|
+
state(),
|
|
364
|
+
__metadata("design:type", Object)
|
|
365
|
+
], FigureV3RecipeCatalog.prototype, "query", void 0);
|
|
366
|
+
__decorate([
|
|
367
|
+
state(),
|
|
368
|
+
__metadata("design:type", Object)
|
|
369
|
+
], FigureV3RecipeCatalog.prototype, "chosen", void 0);
|
|
370
|
+
__decorate([
|
|
371
|
+
state(),
|
|
372
|
+
__metadata("design:type", Object)
|
|
373
|
+
], FigureV3RecipeCatalog.prototype, "values", void 0);
|
|
374
|
+
__decorate([
|
|
375
|
+
state(),
|
|
376
|
+
__metadata("design:type", Object)
|
|
377
|
+
], FigureV3RecipeCatalog.prototype, "guide", void 0);
|
|
378
|
+
FigureV3RecipeCatalog = __decorate([
|
|
379
|
+
customElement('figure-v3-recipe-catalog')
|
|
380
|
+
], FigureV3RecipeCatalog);
|
|
381
|
+
export { FigureV3RecipeCatalog };
|
|
382
|
+
//# sourceMappingURL=figure-v3-recipe-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure-v3-recipe-catalog.js","sourceRoot":"","sources":["../../client/modeller/figure-v3-recipe-catalog.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,mBAAmB,CAAA;AAE1B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAA;AAE7I;;;;;GAKG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;IAAjE;;QA8M2B,cAAS,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,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CAuUjC","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/markdown'\n\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { ScrollbarStyles } from '@operato/styles'\nimport { describeV3Recipe } from '@hatiolab/figure-model'\nimport type { V3Recipe, V3RecipeValue } from '@hatiolab/figure-model'\n\nimport { recipeFieldOf, recipeReady, recipeValueOf, recipeWord, recipeWorkings, recipesMatching, type RecipeTemplate } from './v3-recipes.js'\n\n/**\n * The recipe catalog (ADR-0095): the templates the product ships, by category, found by words, each told in full --\n * what it puts in, how many parts, how they move, what each value does, and how to use it -- and put onto the chosen\n * part in one step. The numbers and the ways of moving are worked out from the recipe (`describeV3Recipe`), so they say\n * what it does; only the descriptions and the guide are written.\n */\n@customElement('figure-v3-recipe-catalog')\nexport class FigureV3RecipeCatalog extends localize(i18next)(LitElement) {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n position: fixed;\n inset: 0;\n z-index: 20;\n display: grid;\n place-items: center;\n background: color-mix(in srgb, var(--md-sys-color-scrim, #000) 32%, transparent);\n font-size: 0.82rem;\n color: var(--md-sys-color-on-surface);\n }\n div[panel] {\n display: grid;\n grid-template-rows: auto 1fr;\n width: min(1100px, calc(100vw - 32px));\n height: min(720px, calc(100vh - 32px));\n background: var(--md-sys-color-surface);\n border-radius: 12px;\n overflow: hidden;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n }\n header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 12px;\n border-bottom: 1px solid var(--md-sys-color-outline-variant);\n }\n header h2 {\n margin: 0;\n font-size: var(--ui-t-title, 16px);\n flex: 1;\n }\n header input {\n width: 220px;\n padding: 4px 8px;\n font: inherit;\n }\n button[close] {\n display: inline-grid;\n place-items: center;\n width: 32px;\n height: 32px;\n border: none;\n border-radius: 8px;\n background: none;\n color: var(--md-sys-color-on-surface-variant);\n cursor: pointer;\n }\n div[body] {\n display: grid;\n grid-template-columns: 170px minmax(0, 1fr) minmax(300px, 380px);\n min-height: 0;\n }\n @media (max-width: 760px) {\n div[body] {\n grid-template-columns: 1fr;\n overflow: auto;\n }\n }\n nav,\n section[list],\n section[detail] {\n overflow: auto;\n min-height: 0;\n padding: 8px;\n }\n nav {\n border-right: 1px solid var(--md-sys-color-outline-variant);\n }\n section[detail] {\n border-left: 1px solid var(--md-sys-color-outline-variant);\n display: grid;\n gap: 10px;\n align-content: start;\n }\n button[category] {\n display: flex;\n justify-content: space-between;\n width: 100%;\n padding: 6px 8px;\n font: inherit;\n color: inherit;\n background: none;\n border: none;\n border-radius: 6px;\n text-align: left;\n cursor: pointer;\n }\n button[category][on],\n button[card][on] {\n background: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n }\n section[list] {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));\n gap: 8px;\n align-content: start;\n }\n button[card] {\n display: grid;\n gap: 4px;\n padding: 8px;\n font: inherit;\n color: inherit;\n text-align: left;\n background: none;\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n cursor: pointer;\n }\n button[card] img {\n width: 100%;\n aspect-ratio: 4 / 3;\n object-fit: contain;\n background: var(--md-sys-color-surface-container);\n border-radius: 4px;\n }\n button[card] small,\n p[muted] {\n color: var(--md-sys-color-on-surface-variant);\n }\n h3 {\n margin: 0;\n font-size: var(--ui-t-body, 14px);\n }\n p {\n margin: 0;\n line-height: 1.5;\n }\n ul {\n margin: 0;\n padding-left: 18px;\n line-height: 1.6;\n }\n table {\n border-collapse: collapse;\n width: 100%;\n }\n th,\n td {\n text-align: left;\n vertical-align: top;\n padding: 3px 4px;\n border-bottom: 1px solid var(--md-sys-color-outline-variant);\n }\n td small {\n display: block;\n color: var(--md-sys-color-on-surface-variant);\n }\n div[form] {\n display: grid;\n gap: 6px;\n padding: 8px;\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n }\n div[form] label {\n display: grid;\n gap: 2px;\n }\n div[form] label[toggle] {\n display: flex;\n align-items: center;\n gap: 6px;\n }\n div[form] input,\n div[form] select {\n font: inherit;\n min-width: 0;\n }\n button[insert] {\n justify-self: start;\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 14px;\n font: inherit;\n white-space: nowrap;\n color: var(--md-sys-color-on-primary);\n background: var(--md-sys-color-primary);\n border: none;\n border-radius: 999em;\n cursor: pointer;\n }\n button[insert]:disabled {\n opacity: 0.38;\n cursor: default;\n }\n p[role='alert'] {\n padding: 6px;\n white-space: pre-wrap;\n color: var(--md-sys-color-on-error-container);\n background: var(--md-sys-color-error-container);\n border-radius: 6px;\n }\n ox-markdown {\n display: block;\n }\n `\n ]\n\n @property({ attribute: false }) templates: RecipeTemplate[] = []\n /** The part it would be put onto. */\n @property({ type: String }) selected = ''\n @property({ type: Boolean }) locked = false\n /** Why the last one put in was refused, in the kernel's words. */\n @property({ type: String }) error = ''\n /** Reads a template's guide; absent, no guide is shown. */\n @property({ attribute: false }) guideOf?: (name: string) => Promise<string>\n /** Where a template's thumbnail is read from; absent, cards show no picture. */\n @property({ attribute: false }) thumbnailOf?: (name: string) => string\n\n @state() private category = ''\n @state() private query = ''\n @state() private chosen = ''\n @state() private values: Record<string, V3RecipeValue> = {}\n @state() private guide = ''\n\n render() {\n const language = i18next.language || 'en'\n const categories = [...new Set(this.templates.map(t => t.category))].sort()\n const shown = recipesMatching(this.templates, this.category, this.query)\n const chosen = this.templates.find(t => t.name === this.chosen) ?? shown[0]\n return html`<div panel role=\"dialog\" aria-modal=\"true\" aria-label=${i18next.t('figure.label.recipe-catalog')}>\n <header>\n <h2>${i18next.t('figure.label.recipe-catalog')}</h2>\n <input search type=\"search\" placeholder=${i18next.t('figure.text.recipe-search')} .value=${this.query} @input=${(e: Event) => (this.query = (e.target as HTMLInputElement).value)} />\n <button close aria-label=${i18next.t('figure.button.close')} @click=${() => this.dispatchEvent(new CustomEvent('close-catalog', { bubbles: true, composed: true }))}>\n <md-icon>close</md-icon>\n </button>\n </header>\n <div body>\n <nav>\n <button category ?on=${!this.category} @click=${() => (this.category = '')}>\n <span>${i18next.t('figure.label.recipe-all')}</span><small>${this.templates.length}</small>\n </button>\n ${categories.map(\n c => html`<button category=${c} ?on=${this.category === c} @click=${() => (this.category = c)}>\n <span>${i18next.t('figure.label.recipe-category-' + c)}</span><small>${this.templates.filter(t => t.category === c).length}</small>\n </button>`\n )}\n </nav>\n <section list>\n ${shown.map(\n t => html`<button card=${t.name} ?on=${t.name === chosen?.name} @click=${() => this.choose(t)}>\n ${t.hasThumbnail && this.thumbnailOf ? html`<img alt=\"\" loading=\"lazy\" src=${this.thumbnailOf(t.name)} />` : nothing}\n <b>${t.title}</b>\n <small>${t.description}</small>\n </button>`\n )}\n </section>\n <section detail>${chosen ? this.renderDetail(chosen, language) : nothing}</section>\n </div>\n </div>`\n }\n\n private choose(t: RecipeTemplate) {\n if (this.chosen === t.name) return\n this.chosen = t.name\n this.values = Object.fromEntries(t.recipe.params.map(p => [p.name, p.default]))\n this.guide = ''\n this.guideOf?.(t.name)\n .then(text => this.chosen === t.name && (this.guide = text))\n .catch(() => {})\n }\n\n protected willUpdate() {\n /* The first card is chosen while nothing is, so the detail is never empty. */\n const shown = recipesMatching(this.templates, this.category, this.query)\n if (!this.templates.some(t => t.name === this.chosen) && shown[0]) this.choose(shown[0])\n }\n\n private renderDetail(t: RecipeTemplate, language: string) {\n const d = describeV3Recipe(t.recipe)\n const count = d.parts.min === d.parts.max ? String(d.parts.min) : `${d.parts.min}–${d.parts.max}`\n const ready = recipeReady(t.recipe, this.selected)\n return html`\n <h3>${t.title}</h3>\n <p>${t.description}</p>\n <div>\n <h3>${i18next.t('figure.label.recipe-adds')}</h3>\n <ul>\n <li parts=${count}>${i18next.t(\"figure.text.recipe-parts\", { parts: count })}</li>\n ${recipeWorkings(t.recipe).map(line => html`<li>${i18next.t(line.key, line.words)}</li>`)}\n <li>${i18next.t(t.recipe.target === 'part' ? 'figure.text.recipe-onto-chosen' : 'figure.text.recipe-onto-figure')}</li>\n </ul>\n </div>\n ${t.recipe.params.length ? this.renderForm(t.recipe, language) : nothing}\n ${this.error ? html`<p role=\"alert\">${this.error}</p>` : nothing}\n ${ready ? nothing : html`<p muted>${i18next.t('figure.text.recipe-needs-a-part')}</p>`}\n <button insert ?disabled=${this.locked || !ready} @click=${() => this.dispatchEvent(new CustomEvent('insert-recipe', { detail: { recipe: t.recipe, values: this.values }, bubbles: true, composed: true }))}>\n <md-icon>add</md-icon>${this.selected && t.recipe.target === 'part' ? i18next.t('figure.button.insert-recipe-onto', { part: this.selected }) : i18next.t('figure.button.insert-recipe')}\n </button>\n ${this.guide ? html`<ox-markdown .src=${this.guide}></ox-markdown>` : nothing}\n `\n }\n\n /** Each value: its name, what it does, and the field to set it -- a share typed as a percentage. */\n private renderForm(recipe: V3Recipe, language: string) {\n const set = (name: string, value: V3RecipeValue) => (this.values = { ...this.values, [name]: value })\n return html`<div form>\n <h3>${i18next.t('figure.label.recipe-values')}</h3>\n ${recipe.params.map(param => {\n const label = recipeWord(param.label, language) || param.name\n const hint = recipeWord(param.hint, language)\n const value = this.values[param.name] ?? param.default\n const help = hint ? html`<small>${hint}</small>` : nothing\n if (param.kind === 'flag')\n return html`<label toggle><input type=\"checkbox\" param=${param.name} .checked=${value === true} @change=${(e: Event) => set(param.name, (e.target as HTMLInputElement).checked)} />${label}</label>${help}`\n if (param.kind === 'choice' || param.kind === 'face')\n return html`<label><span>${label}</span>\n <select param=${param.name} @change=${(e: Event) => set(param.name, recipeValueOf(param, (e.target as HTMLSelectElement).value))}>\n ${(param.options ?? []).map(o => html`<option value=${String(o)} ?selected=${o === value}>${String(o)}</option>`)}\n </select></label\n >${help}`\n const range = param.kind === 'ratio' ? `${recipeFieldOf(param, param.min ?? 0)}–${recipeFieldOf(param, param.max ?? 1)} %` : `${param.min ?? ''}–${param.max ?? ''} mm`\n return html`<label><span>${label} (${range})</span>\n <input type=\"number\" step=\"any\" param=${param.name} .value=${recipeFieldOf(param, value)} @change=${(e: Event) => set(param.name, recipeValueOf(param, (e.target as HTMLInputElement).value))} /></label\n >${help}`\n })}\n </div>`\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LitElement, type PropertyValues } from 'lit';
|
|
2
2
|
import '@operato/layout';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RecipeTemplate } from './v3-recipes.js';
|
|
4
|
+
import './figure-v3-recipe-catalog.js';
|
|
4
5
|
import type { V3ProductSession } from './v3-product-session.js';
|
|
5
6
|
import './v3-canvas.js';
|
|
6
7
|
import './figure-v3-parts.js';
|
|
@@ -17,8 +18,12 @@ import type { FirstSave } from './v3-first-save.js';
|
|
|
17
18
|
export declare class FigureV3Editor extends LitElement {
|
|
18
19
|
static styles: import("lit").CSSResult[];
|
|
19
20
|
session?: V3ProductSession;
|
|
20
|
-
/** The
|
|
21
|
-
|
|
21
|
+
/** The recipe templates (ADR-0095), read by the page from the server. */
|
|
22
|
+
templates: RecipeTemplate[];
|
|
23
|
+
/** Reads a template's guide; given by the page. */
|
|
24
|
+
guideOf?: (name: string) => Promise<string>;
|
|
25
|
+
thumbnailOf?: (name: string) => string;
|
|
26
|
+
private catalogOpen;
|
|
22
27
|
/** Why the last recipe was refused, in the kernel's words. */
|
|
23
28
|
private recipeError;
|
|
24
29
|
revision: number;
|
|
@@ -6,6 +6,7 @@ import '@operato/layout';
|
|
|
6
6
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
7
7
|
import { live } from 'lit/directives/live.js';
|
|
8
8
|
import { PART_LIMIT, parseV3Recipe, resolveV3Recipe, v3PartCountOf, v3RecipeIdFor } from '@hatiolab/figure-model';
|
|
9
|
+
import './figure-v3-recipe-catalog.js';
|
|
9
10
|
import { captureV3Thumbnail } from './v3-thumbnail.js';
|
|
10
11
|
import { drawableV3Parts } from './v3-renderer.js';
|
|
11
12
|
import './v3-canvas.js';
|
|
@@ -35,8 +36,9 @@ import { liveOverSession, NOTHING_LIVE, scrubbed, scrubStep } from './v3-live.js
|
|
|
35
36
|
let FigureV3Editor = class FigureV3Editor extends LitElement {
|
|
36
37
|
constructor() {
|
|
37
38
|
super(...arguments);
|
|
38
|
-
/** The
|
|
39
|
-
this.
|
|
39
|
+
/** The recipe templates (ADR-0095), read by the page from the server. */
|
|
40
|
+
this.templates = [];
|
|
41
|
+
this.catalogOpen = false;
|
|
40
42
|
/** Why the last recipe was refused, in the kernel's words. */
|
|
41
43
|
this.recipeError = '';
|
|
42
44
|
this.revision = 0;
|
|
@@ -529,6 +531,7 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
|
|
|
529
531
|
const steps = resolveV3Recipe(checked, { id, ...(checked.target === 'part' ? { target: this.selected } : {}), values });
|
|
530
532
|
this.session.applyRecipe(steps);
|
|
531
533
|
this.recipeError = '';
|
|
534
|
+
this.catalogOpen = false;
|
|
532
535
|
this.error = '';
|
|
533
536
|
this.changed();
|
|
534
537
|
}
|
|
@@ -1005,6 +1008,9 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
|
|
|
1005
1008
|
const repeat = repeatOf(this.selected, geometry);
|
|
1006
1009
|
if (!asset || !repeat || repeat.index)
|
|
1007
1010
|
return nothing;
|
|
1011
|
+
/* The row is set on its part; what hangs from that part is copied with it and has no row of its own. */
|
|
1012
|
+
if (!asset.document.model.nodes.some(n => n.id === `${this.selected}.repeat`))
|
|
1013
|
+
return nothing;
|
|
1008
1014
|
const model = asset.document.model;
|
|
1009
1015
|
const layout = model.nodes.find(n => n.id === `${this.selected}.layout`);
|
|
1010
1016
|
const axis = model.nodes.find(n => n.id === `${this.selected}.repeat`)?.params?.axis ?? '?';
|
|
@@ -1160,6 +1166,18 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
|
|
|
1160
1166
|
</div>`
|
|
1161
1167
|
: null}
|
|
1162
1168
|
${this.notice ? html `<div role="status" class="notice">${this.notice}</div>` : null}
|
|
1169
|
+
${this.catalogOpen
|
|
1170
|
+
? html `<figure-v3-recipe-catalog
|
|
1171
|
+
.templates=${this.templates}
|
|
1172
|
+
.selected=${this.selected}
|
|
1173
|
+
.error=${this.recipeError}
|
|
1174
|
+
.guideOf=${this.guideOf}
|
|
1175
|
+
.thumbnailOf=${this.thumbnailOf}
|
|
1176
|
+
?locked=${unavailable}
|
|
1177
|
+
@insert-recipe=${(e) => this.insertRecipe(e.detail.recipe, e.detail.values)}
|
|
1178
|
+
@close-catalog=${() => (this.catalogOpen = false)}
|
|
1179
|
+
></figure-v3-recipe-catalog>`
|
|
1180
|
+
: null}
|
|
1163
1181
|
<ox-three-pane>
|
|
1164
1182
|
<figure-v3-parts
|
|
1165
1183
|
slot="start"
|
|
@@ -1171,9 +1189,8 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
|
|
|
1171
1189
|
.selected=${this.selected}
|
|
1172
1190
|
?locked=${unavailable}
|
|
1173
1191
|
@add-part=${(e) => this.add(e.detail.kind)}
|
|
1174
|
-
.
|
|
1175
|
-
|
|
1176
|
-
@insert-recipe=${(e) => this.insertRecipe(e.detail.recipe, e.detail.values)}
|
|
1192
|
+
.recipeCount=${this.templates.length}
|
|
1193
|
+
@open-recipe-catalog=${() => ((this.catalogOpen = true), (this.recipeError = ''))}
|
|
1177
1194
|
@select-part=${(e) => this.choose(e.detail.id)}
|
|
1178
1195
|
@toggle-part-hidden=${(e) => this.toggleHiddenPart(e.detail.id)}
|
|
1179
1196
|
@set-all-parts-hidden=${(e) => (this.hiddenParts = e.detail.hidden ? new Set(view.geometry.map(g => ownerOf(g.id))) : new Set())}
|
|
@@ -1327,7 +1344,19 @@ __decorate([
|
|
|
1327
1344
|
__decorate([
|
|
1328
1345
|
property({ attribute: false }),
|
|
1329
1346
|
__metadata("design:type", Array)
|
|
1330
|
-
], FigureV3Editor.prototype, "
|
|
1347
|
+
], FigureV3Editor.prototype, "templates", void 0);
|
|
1348
|
+
__decorate([
|
|
1349
|
+
property({ attribute: false }),
|
|
1350
|
+
__metadata("design:type", Function)
|
|
1351
|
+
], FigureV3Editor.prototype, "guideOf", void 0);
|
|
1352
|
+
__decorate([
|
|
1353
|
+
property({ attribute: false }),
|
|
1354
|
+
__metadata("design:type", Function)
|
|
1355
|
+
], FigureV3Editor.prototype, "thumbnailOf", void 0);
|
|
1356
|
+
__decorate([
|
|
1357
|
+
state(),
|
|
1358
|
+
__metadata("design:type", Object)
|
|
1359
|
+
], FigureV3Editor.prototype, "catalogOpen", void 0);
|
|
1331
1360
|
__decorate([
|
|
1332
1361
|
state(),
|
|
1333
1362
|
__metadata("design:type", Object)
|