@things-factory/figure-ui 10.1.166 → 10.1.168
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/figure-assistant.ts +5 -0
- package/client/modeller/ai-proposal.ts +20 -2
- package/client/modeller/figure-properties.ts +1 -3
- package/client/modeller/product-session.ts +9 -4
- package/client/pages/figure-modeller-page.ts +7 -6
- package/dist-client/figure-assistant.js +5 -0
- package/dist-client/figure-assistant.js.map +1 -1
- package/dist-client/modeller/ai-proposal.d.ts +8 -0
- package/dist-client/modeller/ai-proposal.js +16 -3
- package/dist-client/modeller/ai-proposal.js.map +1 -1
- package/dist-client/modeller/figure-properties.d.ts +1 -2
- package/dist-client/modeller/figure-properties.js +1 -3
- package/dist-client/modeller/figure-properties.js.map +1 -1
- package/dist-client/modeller/product-session.d.ts +14 -3
- package/dist-client/modeller/product-session.js +9 -4
- package/dist-client/modeller/product-session.js.map +1 -1
- package/dist-client/pages/figure-modeller-page.js +7 -6
- package/dist-client/pages/figure-modeller-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/test/ai-proposal.test.ts +73 -2
- package/test/browser/acceptance-page.js +3 -1
- package/test/browser/product-page.check.mjs +63 -3
- package/test/browser/product-page.js +7 -2
- package/test/figure-assistant-surface.test.ts +27 -1
- package/test/links.test.ts +1 -1
- package/test/proposal-record.test.ts +18 -6
- package/test/refusals.test.ts +1 -1
- package/translations/en.json +0 -12
- package/translations/es.json +0 -12
- package/translations/ja.json +0 -12
- package/translations/ko.json +35 -47
- package/translations/ms.json +0 -12
- package/translations/zh.json +0 -12
- package/client/modeller/carrier-declaration.ts +0 -63
- package/client/modeller/figure-carrier.ts +0 -117
- package/dist-client/modeller/carrier-declaration.d.ts +0 -31
- package/dist-client/modeller/carrier-declaration.js +0 -53
- package/dist-client/modeller/carrier-declaration.js.map +0 -1
- package/dist-client/modeller/figure-carrier.d.ts +0 -26
- package/dist-client/modeller/figure-carrier.js +0 -123
- package/dist-client/modeller/figure-carrier.js.map +0 -1
- package/test/carrier-declaration.test.ts +0 -69
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { css, html, LitElement, nothing } from 'lit';
|
|
3
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
|
-
import { live } from 'lit/directives/live.js';
|
|
5
|
-
import { i18next, localize } from '@operato/i18n';
|
|
6
|
-
import { CARRIER_AXES, carrierCommandOf, carrierDraftOf, draftIsDeclared } from './carrier-declaration.js';
|
|
7
|
-
import { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js';
|
|
8
|
-
const AXIS_LETTER = { width: 'W', length: 'L', height: 'H' };
|
|
9
|
-
/**
|
|
10
|
-
* 캐리어 — the CARRIERTYPE code and physical size a carrier figure declares (ADR-0123), in the properties tab.
|
|
11
|
-
*
|
|
12
|
-
* Declaring and clearing are `set-carrier` commands, sent up as `command` like the tab's others, so the page runs them as
|
|
13
|
-
* steps of the session's history: undo takes them back and they are saved with the figure. A value the kernel refuses
|
|
14
|
-
* is said here and sends nothing.
|
|
15
|
-
*/
|
|
16
|
-
let FigureCarrier = class FigureCarrier extends localize(i18next)(LitElement) {
|
|
17
|
-
constructor() {
|
|
18
|
-
super(...arguments);
|
|
19
|
-
this.draft = carrierDraftOf();
|
|
20
|
-
this.refusal = '';
|
|
21
|
-
this.enter = (event) => {
|
|
22
|
-
if (event.key === 'Enter' && !draftIsDeclared(this.draft, this.carrier))
|
|
23
|
-
this.declare();
|
|
24
|
-
};
|
|
25
|
-
this.declare = () => {
|
|
26
|
-
const made = carrierCommandOf(this.draft, (key, params) => i18next.t(key, params));
|
|
27
|
-
if ('refusal' in made)
|
|
28
|
-
this.refusal = made.refusal;
|
|
29
|
-
else
|
|
30
|
-
this.command(made.action);
|
|
31
|
-
};
|
|
32
|
-
this.clear = () => this.command({ kind: 'set-carrier', carrier: null });
|
|
33
|
-
}
|
|
34
|
-
static { this.styles = [SidePanelStyles, css `
|
|
35
|
-
div[row] {
|
|
36
|
-
display: flex;
|
|
37
|
-
gap: 6px;
|
|
38
|
-
}
|
|
39
|
-
div[row] > button[act] {
|
|
40
|
-
flex: 1;
|
|
41
|
-
margin-top: 0;
|
|
42
|
-
}
|
|
43
|
-
small[role='alert'] {
|
|
44
|
-
color: var(--md-sys-color-error);
|
|
45
|
-
}
|
|
46
|
-
`]; }
|
|
47
|
-
willUpdate(changed) {
|
|
48
|
-
if (!changed.has('carrier'))
|
|
49
|
-
return;
|
|
50
|
-
const declared = JSON.stringify(this.carrier ?? null);
|
|
51
|
-
if (declared === this.filledFrom)
|
|
52
|
-
return;
|
|
53
|
-
this.filledFrom = declared;
|
|
54
|
-
this.draft = carrierDraftOf(this.carrier);
|
|
55
|
-
this.refusal = '';
|
|
56
|
-
}
|
|
57
|
-
render() {
|
|
58
|
-
const pending = !draftIsDeclared(this.draft, this.carrier);
|
|
59
|
-
return html `<section>
|
|
60
|
-
<h3>${i18next.t('figure.label.group-carrier')}</h3>
|
|
61
|
-
<div field>
|
|
62
|
-
<label for="carrier-type">${i18next.t('figure.label.carrier-type')}</label>
|
|
63
|
-
<input
|
|
64
|
-
id="carrier-type"
|
|
65
|
-
.value=${live(this.draft.type)}
|
|
66
|
-
placeholder=${i18next.t('figure.text.carrier-type-placeholder')}
|
|
67
|
-
@input=${(e) => this.type('type', e)}
|
|
68
|
-
@keydown=${this.enter}
|
|
69
|
-
/>
|
|
70
|
-
</div>
|
|
71
|
-
<div vector-row>
|
|
72
|
-
<label>${i18next.t('figure.label.carrier-size')} <span unit>mm</span></label>
|
|
73
|
-
<div triple>
|
|
74
|
-
${CARRIER_AXES.map(axis => html `<div cell>
|
|
75
|
-
<span axis>${AXIS_LETTER[axis]}</span>
|
|
76
|
-
<input
|
|
77
|
-
type="number"
|
|
78
|
-
min="0"
|
|
79
|
-
step="any"
|
|
80
|
-
aria-label=${i18next.t(`figure.label.carrier-${axis}`)}
|
|
81
|
-
.value=${live(this.draft[axis])}
|
|
82
|
-
@input=${(e) => this.type(axis, e)}
|
|
83
|
-
@keydown=${this.enter}
|
|
84
|
-
/>
|
|
85
|
-
</div>`)}
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
${this.refusal ? html `<small role="alert">${this.refusal}</small>` : nothing}
|
|
89
|
-
<div row>
|
|
90
|
-
<button act ?disabled=${!pending} @click=${this.declare}>
|
|
91
|
-
<md-icon>check</md-icon>${i18next.t('figure.button.declare-carrier')}
|
|
92
|
-
</button>
|
|
93
|
-
<button act ?disabled=${!this.carrier} @click=${this.clear}>
|
|
94
|
-
<md-icon>close</md-icon>${i18next.t('figure.button.clear-carrier')}
|
|
95
|
-
</button>
|
|
96
|
-
</div>
|
|
97
|
-
</section>`;
|
|
98
|
-
}
|
|
99
|
-
type(key, event) {
|
|
100
|
-
this.draft = { ...this.draft, [key]: event.target.value };
|
|
101
|
-
this.refusal = '';
|
|
102
|
-
}
|
|
103
|
-
command(action) {
|
|
104
|
-
this.dispatchEvent(new CustomEvent('command', { detail: { action }, bubbles: true, composed: true }));
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
__decorate([
|
|
108
|
-
property({ attribute: false }),
|
|
109
|
-
__metadata("design:type", Object)
|
|
110
|
-
], FigureCarrier.prototype, "carrier", void 0);
|
|
111
|
-
__decorate([
|
|
112
|
-
state(),
|
|
113
|
-
__metadata("design:type", Object)
|
|
114
|
-
], FigureCarrier.prototype, "draft", void 0);
|
|
115
|
-
__decorate([
|
|
116
|
-
state(),
|
|
117
|
-
__metadata("design:type", Object)
|
|
118
|
-
], FigureCarrier.prototype, "refusal", void 0);
|
|
119
|
-
FigureCarrier = __decorate([
|
|
120
|
-
customElement('figure-carrier')
|
|
121
|
-
], FigureCarrier);
|
|
122
|
-
export { FigureCarrier };
|
|
123
|
-
//# sourceMappingURL=figure-carrier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,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,EAAE;;4CAA+C;AACtC;IAAhB,KAAK,EAAE;;8CAAqB;AAlBlB,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAgGzB","sourcesContent":["import { css, html, LitElement, nothing, type PropertyValues } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport type { FigureAsset, FigureAuthoringAction } from '@hatiolab/figure-model'\n\nimport { CARRIER_AXES, carrierCommandOf, carrierDraftOf, draftIsDeclared, type CarrierAxis, type CarrierDraft } from './carrier-declaration.js'\nimport { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js'\n\nconst AXIS_LETTER: Record<CarrierAxis, string> = { width: 'W', length: 'L', height: 'H' }\n\n/**\n * 캐리어 — the CARRIERTYPE code and physical size a carrier figure declares (ADR-0123), in the properties tab.\n *\n * Declaring and clearing are `set-carrier` commands, sent up as `command` like the tab's others, so the page runs them as\n * steps of the session's history: undo takes them back and they are saved with the figure. A value the kernel refuses\n * is said here and sends nothing.\n */\n@customElement('figure-carrier')\nexport class FigureCarrier extends localize(i18next)(LitElement) {\n static styles = [SidePanelStyles, css`\n div[row] {\n display: flex;\n gap: 6px;\n }\n div[row] > button[act] {\n flex: 1;\n margin-top: 0;\n }\n small[role='alert'] {\n color: var(--md-sys-color-error);\n }\n `]\n\n /** What the figure on screen declares; absent when it is not a carrier type. */\n @property({ attribute: false }) carrier?: FigureAsset['carrier']\n @state() private draft: CarrierDraft = carrierDraftOf()\n @state() private refusal = ''\n /* The declaration the field was last filled from: other edits draw the tab again and must not wipe what is being typed. */\n private filledFrom?: string\n\n willUpdate(changed: PropertyValues<this>) {\n if (!changed.has('carrier')) return\n const declared = JSON.stringify(this.carrier ?? null)\n if (declared === this.filledFrom) return\n this.filledFrom = declared\n this.draft = carrierDraftOf(this.carrier)\n this.refusal = ''\n }\n\n render() {\n const pending = !draftIsDeclared(this.draft, this.carrier)\n return html`<section>\n <h3>${i18next.t('figure.label.group-carrier')}</h3>\n <div field>\n <label for=\"carrier-type\">${i18next.t('figure.label.carrier-type')}</label>\n <input\n id=\"carrier-type\"\n .value=${live(this.draft.type)}\n placeholder=${i18next.t('figure.text.carrier-type-placeholder')}\n @input=${(e: Event) => this.type('type', e)}\n @keydown=${this.enter}\n />\n </div>\n <div vector-row>\n <label>${i18next.t('figure.label.carrier-size')} <span unit>mm</span></label>\n <div triple>\n ${CARRIER_AXES.map(\n axis => html`<div cell>\n <span axis>${AXIS_LETTER[axis]}</span>\n <input\n type=\"number\"\n min=\"0\"\n step=\"any\"\n aria-label=${i18next.t(`figure.label.carrier-${axis}`)}\n .value=${live(this.draft[axis])}\n @input=${(e: Event) => this.type(axis, e)}\n @keydown=${this.enter}\n />\n </div>`\n )}\n </div>\n </div>\n ${this.refusal ? html`<small role=\"alert\">${this.refusal}</small>` : nothing}\n <div row>\n <button act ?disabled=${!pending} @click=${this.declare}>\n <md-icon>check</md-icon>${i18next.t('figure.button.declare-carrier')}\n </button>\n <button act ?disabled=${!this.carrier} @click=${this.clear}>\n <md-icon>close</md-icon>${i18next.t('figure.button.clear-carrier')}\n </button>\n </div>\n </section>`\n }\n\n private type(key: keyof CarrierDraft, event: Event) {\n this.draft = { ...this.draft, [key]: (event.target as HTMLInputElement).value }\n this.refusal = ''\n }\n\n private enter = (event: KeyboardEvent) => {\n if (event.key === 'Enter' && !draftIsDeclared(this.draft, this.carrier)) this.declare()\n }\n\n private declare = () => {\n const made = carrierCommandOf(this.draft, (key, params) => i18next.t(key, params))\n if ('refusal' in made) this.refusal = made.refusal\n else this.command(made.action)\n }\n\n private clear = () => this.command({ kind: 'set-carrier', carrier: null })\n\n private command(action: FigureAuthoringAction) {\n this.dispatchEvent(new CustomEvent('command', { detail: { action }, bubbles: true, composed: true }))\n }\n}\n"]}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The properties tab's carrier field (ADR-0123): what it sends as `set-carrier`, what it says when the kernel would
|
|
3
|
-
* refuse, and that the declaration is a step of the session's history -- undo takes it back, the save carries it.
|
|
4
|
-
*/
|
|
5
|
-
import { test } from 'node:test'
|
|
6
|
-
import assert from 'node:assert/strict'
|
|
7
|
-
import { addFigureBox, createFigureAsset, parseFigureAsset, serializeFigureAsset } from '@hatiolab/figure-model'
|
|
8
|
-
|
|
9
|
-
import { carrierCommandOf, carrierDraftOf, draftIsDeclared, type CarrierDraft } from '../client/modeller/carrier-declaration.ts'
|
|
10
|
-
import { createFigureProductSession } from '../client/modeller/product-session.ts'
|
|
11
|
-
|
|
12
|
-
const say = (key: string, params: Record<string, string>) => `${key}${Object.keys(params).length ? ' ' + JSON.stringify(params) : ''}`
|
|
13
|
-
const draft = (type: string, width = '1000', length = '600', height = '200'): CarrierDraft => ({ type, width, length, height })
|
|
14
|
-
|
|
15
|
-
const source = serializeFigureAsset(addFigureBox(createFigureAsset('roll'), { id: 'body', size: { x: 100, y: 100, z: 100 }, position: { x: 0, y: 50, z: 0 } }))
|
|
16
|
-
const store = {
|
|
17
|
-
load: async (id: string) => ({ id, source }),
|
|
18
|
-
save: async (q: { id?: string; source: string }) => ({ id: q.id ?? 'saved', source: q.source })
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
test('the field sends the code as the kernel stores it and the three lengths as numbers', () => {
|
|
22
|
-
assert.deepEqual(carrierCommandOf(draft(' foup '), say), {
|
|
23
|
-
action: { kind: 'set-carrier', carrier: { type: 'FOUP', dimensions: { width: 1000, length: 600, height: 200 } } }
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test('a value the kernel refuses is said from its code and path, and nothing is sent', () => {
|
|
28
|
-
assert.deepEqual(carrierCommandOf(draft(' '), say), { refusal: 'figure.text.carrier-type-required' })
|
|
29
|
-
assert.deepEqual(carrierCommandOf(draft('X'.repeat(65)), say), { refusal: 'figure.text.carrier-type-too-long {"max":"64"}' })
|
|
30
|
-
assert.deepEqual(carrierCommandOf(draft('FOUP', '1000', ''), say), {
|
|
31
|
-
refusal: 'figure.text.carrier-length-positive {"axis":"figure.label.carrier-length"}'
|
|
32
|
-
})
|
|
33
|
-
assert.deepEqual(carrierCommandOf(draft('FOUP', '1000', '600', '-5'), say), {
|
|
34
|
-
refusal: 'figure.text.carrier-length-positive {"axis":"figure.label.carrier-height"}'
|
|
35
|
-
})
|
|
36
|
-
assert.deepEqual(carrierCommandOf(draft('FOUP', '0'), say), {
|
|
37
|
-
refusal: 'figure.text.carrier-length-positive {"axis":"figure.label.carrier-width"}'
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test('the field reads a declaration back, and what is declared already has nothing to send', () => {
|
|
42
|
-
const declared = { type: 'FOUP', dimensions: { width: 1000, length: 600, height: 200 } }
|
|
43
|
-
assert.deepEqual(carrierDraftOf(declared), draft('FOUP'))
|
|
44
|
-
assert.deepEqual(carrierDraftOf(), draft('', '', '', ''))
|
|
45
|
-
assert.equal(draftIsDeclared(draft('foup ', '1000.0'), declared), true)
|
|
46
|
-
assert.equal(draftIsDeclared(draft('FOUP', '1001'), declared), false)
|
|
47
|
-
assert.equal(draftIsDeclared(draft('', '', '', ''), undefined), true)
|
|
48
|
-
assert.equal(draftIsDeclared(draft('FOUP'), undefined), false)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test('declaring and clearing are steps of the history: undo takes each back and the save carries the declaration', async () => {
|
|
52
|
-
const session = createFigureProductSession(store)
|
|
53
|
-
await session.open('A')
|
|
54
|
-
const made = carrierCommandOf(draft('foup'), say)
|
|
55
|
-
assert.ok('action' in made)
|
|
56
|
-
|
|
57
|
-
session.command(made.action)
|
|
58
|
-
const declared = { type: 'FOUP', dimensions: { width: 1000, length: 600, height: 200 } }
|
|
59
|
-
assert.deepEqual(session.revisionNow()?.asset.carrier, declared)
|
|
60
|
-
assert.deepEqual(parseFigureAsset(session.source()).carrier, declared)
|
|
61
|
-
|
|
62
|
-
session.command({ kind: 'set-carrier', carrier: null })
|
|
63
|
-
assert.equal(session.revisionNow()?.asset.carrier, undefined)
|
|
64
|
-
|
|
65
|
-
session.undo()
|
|
66
|
-
assert.deepEqual(session.revisionNow()?.asset.carrier, declared, 'undoing the clear brings the declaration back')
|
|
67
|
-
session.undo()
|
|
68
|
-
assert.equal(session.revisionNow()?.asset.carrier, undefined, 'undoing the declaration leaves the figure no carrier')
|
|
69
|
-
})
|