@operato/property-panel 10.29.79 → 10.29.80

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/property-panel",
3
3
  "description": "Webcomponent property-panel following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "10.29.79",
5
+ "version": "10.29.80",
6
6
  "type": "module",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
@@ -28,7 +28,8 @@
28
28
  "./shapes.js": "./dist/src/property-panel/shapes/shapes.js",
29
29
  "./specifics.js": "./dist/src/property-panel/specifics/specifics.js",
30
30
  "./styles.js": "./dist/src/property-panel/styles/styles.js",
31
- "./threed.js": "./dist/src/property-panel/threed/threed.js"
31
+ "./threed.js": "./dist/src/property-panel/threed/threed.js",
32
+ "./size-limits.js": "./dist/src/property-panel/size-limits.js"
32
33
  },
33
34
  "typesVersions": {
34
35
  "*": {
@@ -55,6 +56,9 @@
55
56
  ],
56
57
  "./threed.js": [
57
58
  "./dist/src/property-panel/threed/threed.d.ts"
59
+ ],
60
+ "./size-limits.js": [
61
+ "./dist/src/property-panel/size-limits.d.ts"
58
62
  ]
59
63
  }
60
64
  },
@@ -68,11 +72,11 @@
68
72
  },
69
73
  "dependencies": {
70
74
  "@material/web": "^2.0.0",
71
- "@operato/app": "^10.29.79",
72
- "@operato/attachment": "^10.29.79",
75
+ "@operato/app": "^10.29.80",
76
+ "@operato/attachment": "^10.29.80",
73
77
  "@operato/i18n": "^10.29.27",
74
- "@operato/input": "^10.29.79",
75
- "@operato/styles": "^10.29.79",
78
+ "@operato/input": "^10.29.80",
79
+ "@operato/styles": "^10.29.80",
76
80
  "@operato/utils": "^10.29.76",
77
81
  "lit": "^3.1.2"
78
82
  },
@@ -109,5 +113,5 @@
109
113
  "prettier --write"
110
114
  ]
111
115
  },
112
- "gitHead": "f86fbc40c2d343d7996573fe49f82829c1ac1ea4"
116
+ "gitHead": "15c5b5a647b07ba7589cda2ca05028d76ad82a93"
113
117
  }
@@ -0,0 +1,115 @@
1
+ /*
2
+ * A size field on a placed figure says what the figure takes, beside the field, and refuses a typed size past it,
3
+ * naming the field and the bound; an unwritten depth shows the height the figure stands at (ADR-0087 amendment
4
+ * 2026-11-11). The figure is what things-scene's FigureInstance says of its sizes.
5
+ */
6
+ import { html } from 'lit'
7
+ import { fixture, expect, oneEvent } from '@open-wc/testing'
8
+ import { i18next } from '@operato/i18n'
9
+
10
+ import { shownSize, sizeLimitOf, sizeRefusalOf } from '../src/property-panel/size-limits.js'
11
+ import { Property3D } from '../src/property-panel/threed/threed.js'
12
+ import { PropertyShapes } from '../src/property-panel/shapes/shapes.js'
13
+
14
+ customElements.define('size-3d-under-test', class extends Property3D {})
15
+ customElements.define('size-shapes-under-test', class extends PropertyShapes {})
16
+
17
+ /** An OHT as things-scene places it at 50 mm a coordinate: depth open above, plan open. */
18
+ const oht = {
19
+ sizeRanges: { width: { min: 12.001, max: Infinity }, height: { min: 0, max: Infinity }, depth: { min: 20.515, max: Infinity } },
20
+ heldSizeAxes: { x: false, y: false, z: false },
21
+ standingSize: { width: 40, height: 18, depth: 35.5 },
22
+ isRootModel: () => false,
23
+ isLayer: () => false,
24
+ isLine: () => false,
25
+ isIdentifiable: () => true
26
+ }
27
+ /** A roller conveyor: depth held. */
28
+ const conveyor = {
29
+ ...oht,
30
+ sizeRanges: { width: { min: 26, max: 126 }, height: { min: 11.2, max: Infinity }, depth: { min: 17.6, max: 17.6 } },
31
+ heldSizeAxes: { x: false, y: true, z: false },
32
+ standingSize: { width: 46, height: 12, depth: 17.6 }
33
+ }
34
+
35
+ const panel3d = (selected: object, value = {}) =>
36
+ fixture<Property3D>(html`<size-3d-under-test .value=${value} .bounds=${{ left: 0, top: 0, width: 40, height: 18 }} .selected=${[selected]}></size-3d-under-test>`)
37
+ const input = (el: Element, key: string) => el.shadowRoot!.querySelector(`input[value-key="${key}"]`) as HTMLInputElement
38
+ const limits = (el: Element) => Array.from(el.shadowRoot!.querySelectorAll('.size-limit')).map(e => e.textContent!.trim())
39
+ const type = (field: HTMLInputElement, value: string) => {
40
+ field.value = value
41
+ field.dispatchEvent(new Event('change', { bubbles: true, composed: true }))
42
+ }
43
+
44
+ describe('size limits (ADR-0087 2026-11-11)', () => {
45
+ it('words a range: held, at least, at most, between; nothing for any size', () => {
46
+ expect(sizeLimitOf({ min: 35.5, max: 35.5 }, true)).to.deep.equal({ key: 'text.size-held', params: {} })
47
+ expect(sizeLimitOf({ min: 6.10000122, max: Infinity })).to.deep.equal({ key: 'text.size-at-least', params: { min: '6.1' } })
48
+ expect(sizeLimitOf({ min: 0.001, max: Infinity })).to.equal(undefined)
49
+ expect(sizeLimitOf({ min: 0, max: 80 })).to.deep.equal({ key: 'text.size-at-most', params: { max: '80' } })
50
+ expect(sizeLimitOf({ min: 20.515, max: 120.4567 })).to.deep.equal({ key: 'text.size-between', params: { min: '20.52', max: '120.46' } })
51
+ expect(sizeLimitOf({ min: 0, max: Infinity })).to.equal(undefined)
52
+ })
53
+
54
+ it('takes the bound as shown, refuses past it naming the bound, never a cleared field', () => {
55
+ expect(sizeRefusalOf(6.1, { min: 6.10000122, max: Infinity })).to.equal(undefined)
56
+ expect(sizeRefusalOf(3, { min: 6.10000122, max: Infinity })).to.deep.equal({ key: 'text.size-below-min', params: { min: '6.1' } })
57
+ expect(sizeRefusalOf(20.51, { min: 20.515, max: 120.4567 })).to.equal(undefined)
58
+ expect(sizeRefusalOf(120.47, { min: 20.515, max: 120.4567 })).to.deep.equal({ key: 'text.size-above-max', params: { max: '120.46' } })
59
+ expect(sizeRefusalOf(undefined, { min: 6, max: 9 })).to.equal(undefined)
60
+ expect(shownSize(61.82018434433779)).to.equal('61.82')
61
+ })
62
+
63
+ it('the 3D tab shows a limit under each size, and the height a figure stands at for an unwritten depth', async () => {
64
+ const el = await panel3d(oht)
65
+ expect(limits(el).length).to.equal(3)
66
+ expect(limits(el)[1]).to.equal('')
67
+ expect(input(el, 'depth').value).to.equal('')
68
+ expect(input(el, 'depth').placeholder).to.equal('35.5')
69
+ })
70
+
71
+ it('a held size is read-only', async () => {
72
+ const el = await panel3d(conveyor, { depth: 17.6 })
73
+ expect(input(el, 'depth').readOnly).to.equal(true)
74
+ expect(input(el, 'bounds.width').readOnly).to.equal(false)
75
+ })
76
+
77
+ it('a typed depth past the limit is refused with a notice naming the field and the limit, and nothing is written', async () => {
78
+ const el = await panel3d(oht)
79
+ let written = false
80
+ el.addEventListener('property-change', () => (written = true))
81
+ setTimeout(() => type(input(el, 'depth'), '5'))
82
+ const { detail } = (await oneEvent(document, 'notify')) as CustomEvent
83
+ expect(detail.level).to.equal('warn')
84
+ expect(detail.message).to.equal(i18next.t('text.size-below-min', { field: i18next.t('label.depth'), min: '20.52' }))
85
+ expect(written).to.equal(false)
86
+ expect(input(el, 'depth').value).to.equal('')
87
+ })
88
+
89
+ it('a typed depth the figure takes is written', async () => {
90
+ const el = await panel3d(oht)
91
+ setTimeout(() => type(input(el, 'depth'), '30'))
92
+ const { detail } = (await oneEvent(el, 'property-change')) as CustomEvent
93
+ expect(detail).to.deep.equal({ depth: 30 })
94
+ })
95
+
96
+ it('a component that is not a figure shows no limits, as before', async () => {
97
+ const el = await panel3d({ isRootModel: () => false, isLayer: () => false, isLine: () => false, isIdentifiable: () => true }, { depth: 7 })
98
+ expect(limits(el)).to.deep.equal([])
99
+ expect(input(el, 'depth').value).to.equal('7')
100
+ })
101
+
102
+ it('the shapes tab refuses a width past the limit too', async () => {
103
+ const el = await fixture<PropertyShapes>(
104
+ html`<size-shapes-under-test .value=${{}} .bounds=${{ left: 0, top: 0, width: 46, height: 12 }} .selected=${[conveyor]}></size-shapes-under-test>`
105
+ )
106
+ expect(limits(el)).to.deep.equal([
107
+ i18next.t('text.size-between', { min: '26', max: '126' }),
108
+ i18next.t('text.size-at-least', { min: '11.2' })
109
+ ])
110
+ setTimeout(() => type(input(el, 'bounds.width'), '200'))
111
+ const { detail } = (await oneEvent(document, 'notify')) as CustomEvent
112
+ expect(detail.message).to.equal(i18next.t('text.size-above-max', { field: i18next.t('label.width'), max: '126' }))
113
+ expect(input(el, 'bounds.width').value).to.equal('46')
114
+ })
115
+ })
@@ -715,6 +715,12 @@
715
715
  "text.select_file": "Select File",
716
716
  "text.server_unavailable": "text.Server Unavailable",
717
717
  "text.settings-already-done": "Settings are already done.",
718
+ "text.size-above-max": "{field} must be at most {max}.",
719
+ "text.size-at-least": "{min} or more",
720
+ "text.size-at-most": "{max} or less",
721
+ "text.size-below-min": "{field} must be at least {min}.",
722
+ "text.size-between": "{min}–{max}",
723
+ "text.size-held": "fixed",
718
724
  "text.stalled": "text.Stalled.",
719
725
  "text.sure-delete-domain": "Are you sure to delete it? (Every related data will be removed.)",
720
726
  "text.sure-delete-domain-final": "Every related data will be removed. Are you sure to DELETE it?",
@@ -715,6 +715,12 @@
715
715
  "text.select_file": "Seleccionar archivo",
716
716
  "text.server_unavailable": "Servidor no disponible",
717
717
  "text.settings-already-done": "La configuración ya está realizada.",
718
+ "text.size-above-max": "{field} debe ser como máximo {max}.",
719
+ "text.size-at-least": "{min} o más",
720
+ "text.size-at-most": "{max} o menos",
721
+ "text.size-below-min": "{field} debe ser al menos {min}.",
722
+ "text.size-between": "{min}–{max}",
723
+ "text.size-held": "fijo",
718
724
  "text.stalled": "Detenido.",
719
725
  "text.sure-delete-domain": "¿Está seguro de que desea eliminarlo? (Se eliminarán todos los datos relacionados.)",
720
726
  "text.sure-delete-domain-final": "Se eliminarán todos los datos relacionados. ¿Está seguro de que desea ELIMINARLO?",
@@ -719,6 +719,12 @@
719
719
  "text.select_file": "ファイルを選択してください",
720
720
  "text.server_unavailable": "利用できないサーバー",
721
721
  "text.setting-already-done": "セッティングが既に完了しています.",
722
+ "text.size-above-max": "{field}は{max}以下にしてください。",
723
+ "text.size-at-least": "{min} 以上",
724
+ "text.size-at-most": "{max} 以下",
725
+ "text.size-below-min": "{field}は{min}以上にしてください。",
726
+ "text.size-between": "{min}–{max}",
727
+ "text.size-held": "固定",
722
728
  "text.stalled": "停滞中...",
723
729
  "text.sure-delete-domain": "該当ドメインを削除しますか? (関連する全てのデータが削除されます.)",
724
730
  "text.sure-delete-domain-final": "該当ドメインに含まれた全てのデータが削除されます. 削除しますか?",
@@ -601,7 +601,7 @@
601
601
  "label.waiting-time": "대기 시간",
602
602
  "label.warning": "경고",
603
603
  "label.wheel-size": "휠 크기",
604
- "label.width": "넓이",
604
+ "label.width": "너비",
605
605
  "label.will-get-return": "리턴값 반영",
606
606
  "label.wing": "날개",
607
607
  "label.with-credentials": "with credentials",
@@ -719,6 +719,12 @@
719
719
  "text.select_file": "파일을 선택하세요",
720
720
  "text.server_unavailable": "이용할 수 없는 서버",
721
721
  "text.setting-already-done": "세팅이 이미 완료되었습니다.",
722
+ "text.size-above-max": "{field}는 {max} 이하여야 합니다.",
723
+ "text.size-at-least": "{min} 이상",
724
+ "text.size-at-most": "{max} 이하",
725
+ "text.size-below-min": "{field}는 {min} 이상이어야 합니다.",
726
+ "text.size-between": "{min}–{max}",
727
+ "text.size-held": "고정",
722
728
  "text.stalled": "정체중...",
723
729
  "text.sure-delete-domain": "해당 도메인을 삭제하시겠습니까? (관련된 모든 데이터가 삭제됩니다.)",
724
730
  "text.sure-delete-domain-final": "해당 도메인에 포함된 모든 데이터가 삭제됩니다. 삭제하시겠습니까?",
@@ -232,6 +232,7 @@
232
232
  "label.delete-request-confirm": "Padam Permintaan",
233
233
  "label.delete-request-release": "Padam Permintaan",
234
234
  "label.demographics": "Demografi",
235
+ "label.depth": "kedalaman",
235
236
  "label.detail": "Butiran",
236
237
  "label.dialog-settings": "Tetapan Dialog",
237
238
  "label.disable": "Matikan",
@@ -587,6 +588,12 @@
587
588
  "text.saving": "Menyimpan...",
588
589
  "text.select_option": "Pilih satu pilihan",
589
590
  "text.server_error": "Ralat pelayan. Sila cuba lagi kemudian.",
591
+ "text.size-above-max": "{field} mesti tidak melebihi {max}.",
592
+ "text.size-at-least": "{min} atau lebih",
593
+ "text.size-at-most": "{max} atau kurang",
594
+ "text.size-below-min": "{field} mesti sekurang-kurangnya {min}.",
595
+ "text.size-between": "{min}–{max}",
596
+ "text.size-held": "tetap",
590
597
  "text.success": "Berjaya",
591
598
  "text.unable_to_load_data": "Tidak dapat memuatkan data",
592
599
  "text.unexpected_error": "Ralat tidak dijangka",
@@ -718,6 +718,12 @@
718
718
  "text.select_file": "选择文件",
719
719
  "text.server_unavailable": "服务器无法链接",
720
720
  "text.settings-already-done": "已有设置。",
721
+ "text.size-above-max": "{field}不能大于 {max}。",
722
+ "text.size-at-least": "{min} 以上",
723
+ "text.size-at-most": "{max} 以下",
724
+ "text.size-below-min": "{field}不能小于 {min}。",
725
+ "text.size-between": "{min}–{max}",
726
+ "text.size-held": "固定",
721
727
  "text.stalled": "停滞",
722
728
  "text.sure-delete-domain": "所有相关数据都会被删除,请确认是否删除?",
723
729
  "text.sure-delete-domain-final": "将会删除所有相关数据。是否继续进行删除?",