@things-factory/figure-viewer 0.0.0-stage → 10.1.163
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/capability-rung.ts +22 -0
- package/client/controls.ts +54 -0
- package/client/detail-facts.ts +87 -0
- package/client/detail-motion.ts +11 -0
- package/client/figure-asset-viewer.ts +284 -0
- package/client/figure-facts-list.ts +59 -0
- package/client/figure-thumb-mark.ts +34 -0
- package/client/figure-view.ts +151 -0
- package/client/index.ts +14 -0
- package/client/preview-model.ts +89 -0
- package/client/side-panel-styles.ts +374 -0
- package/client/tsconfig.json +19 -0
- package/dist-client/capability-rung.d.ts +5 -0
- package/dist-client/capability-rung.js +16 -0
- package/dist-client/capability-rung.js.map +1 -0
- package/dist-client/controls.d.ts +28 -0
- package/dist-client/controls.js +28 -0
- package/dist-client/controls.js.map +1 -0
- package/dist-client/detail-facts.d.ts +37 -0
- package/dist-client/detail-facts.js +58 -0
- package/dist-client/detail-facts.js.map +1 -0
- package/dist-client/detail-motion.d.ts +6 -0
- package/dist-client/detail-motion.js +9 -0
- package/dist-client/detail-motion.js.map +1 -0
- package/dist-client/figure-asset-viewer.d.ts +51 -0
- package/dist-client/figure-asset-viewer.js +313 -0
- package/dist-client/figure-asset-viewer.js.map +1 -0
- package/dist-client/figure-facts-list.d.ts +17 -0
- package/dist-client/figure-facts-list.js +63 -0
- package/dist-client/figure-facts-list.js.map +1 -0
- package/dist-client/figure-thumb-mark.d.ts +12 -0
- package/dist-client/figure-thumb-mark.js +42 -0
- package/dist-client/figure-thumb-mark.js.map +1 -0
- package/dist-client/figure-view.d.ts +117 -0
- package/dist-client/figure-view.js +78 -0
- package/dist-client/figure-view.js.map +1 -0
- package/dist-client/index.d.ts +10 -0
- package/dist-client/index.js +15 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/preview-model.d.ts +54 -0
- package/dist-client/preview-model.js +79 -0
- package/dist-client/preview-model.js.map +1 -0
- package/dist-client/side-panel-styles.d.ts +27 -0
- package/dist-client/side-panel-styles.js +374 -0
- package/dist-client/side-panel-styles.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/index.d.ts +1 -0
- package/dist-server/index.js +3 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +35 -4
- package/server/index.ts +4 -0
- package/server/tsconfig.json +10 -0
- package/test/controls.test.ts +51 -0
- package/test/detail-facts.test.ts +79 -0
- package/test/detail-motion.test.ts +26 -0
- package/test/joints.ts +35 -0
- package/test/preview.test.ts +53 -0
- package/test/resolve-ts-siblings.mjs +85 -0
- package/test/view.test.ts +13 -0
- package/things-factory.config.js +5 -0
- package/translations/en.json +37 -0
- package/translations/es.json +37 -0
- package/translations/ja.json +37 -0
- package/translations/ko.json +37 -0
- package/translations/ms.json +37 -0
- package/translations/zh.json +37 -0
- package/README.md +0 -3
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 저작 화면의 **보기 설정**.
|
|
3
|
+
*
|
|
4
|
+
* ## 저장되지 않는다
|
|
5
|
+
*
|
|
6
|
+
* 이것은 자산이 아니라 **작업대**다. 조명을 밝게 하고 바닥을 켠 것은 그 사람이 지금
|
|
7
|
+
* 보기 편한 상태일 뿐, 그 자산의 성질이 아니다. 그래서 자산에 안 들어가고, 보는 사람의
|
|
8
|
+
* 브라우저에 남는다.
|
|
9
|
+
*
|
|
10
|
+
* 다른 사람이 같은 자산을 열면 자기 설정으로 본다. 그것이 맞다.
|
|
11
|
+
*
|
|
12
|
+
* ## 씬이 아는 이름을 그대로 쓴다
|
|
13
|
+
*
|
|
14
|
+
* 여기 이름은 전부 `model-layer` 의 상태 이름이다. 옮겨 적는 표를 두지 않는다 — 표를
|
|
15
|
+
* 두면 씬이 새 설정을 받아도 이쪽이 모른다.
|
|
16
|
+
*
|
|
17
|
+
* 값이 바뀌면 씬이 스스로 반영한다(`three-capability` 의 `onchange`). 다만 `grid` 는
|
|
18
|
+
* 한동안 3D 를 세울 때만 읽혔다 — things-scene 10.1.5 에서 고쳤다.
|
|
19
|
+
*/
|
|
20
|
+
export interface ViewSettings {
|
|
21
|
+
/**
|
|
22
|
+
* 어떤 도면에 놓인 것으로 보나 — 씬 전체의 좌표 모드.
|
|
23
|
+
*
|
|
24
|
+
* **도형의 `placement` 와 다른 것이다.** 도형의 것은 「이 종류는 바닥에 서나, 천장에
|
|
25
|
+
* 매달리나」이고, 이것은 「지금 보고 있는 도면이 어느 쪽을 기준으로 재나」다. 바닥
|
|
26
|
+
* 기준 도면에 천정 기반 OHT 를 놓으면 도면은 안 뒤집히고 OHT 가 천장 높이에 매달린다.
|
|
27
|
+
*
|
|
28
|
+
* 한동안 도형의 `placement` 를 이 자리에 흘려 넣었다. 모델러에 도형이 하나뿐이라
|
|
29
|
+
* 그럴듯해 보였지만, 그러면 도형의 성질이 씬 전체를 뒤집는다 — 도면에서는 성립할 수가
|
|
30
|
+
* 없고(도면에는 도형이 여럿이다), 저작 중에는 배치를 고를 때마다 저작자가 적어 둔
|
|
31
|
+
* 높이가 전부 다른 숫자로 보였다.
|
|
32
|
+
*
|
|
33
|
+
* 씬의 낱말 그대로다: `floor` 바닥 기준 · `space` 중심 기준(바닥 없음) · `inverted`
|
|
34
|
+
* 천장 기준. **미리보기에만 먹인다** — 편집 캔버스의 `zPos` 는 저작자가 직접 적는
|
|
35
|
+
* 숫자라 그 뜻이 보기 설정에 따라 바뀌면 안 된다.
|
|
36
|
+
*/
|
|
37
|
+
placement: 'floor' | 'space' | 'inverted'
|
|
38
|
+
/**
|
|
39
|
+
* 천장 높이 (mm). 천정 기반 도형을 미리보기에서 어디에 매달 것인가.
|
|
40
|
+
*
|
|
41
|
+
* 도형은 제가 놓일 방의 높이를 모른다. 도면은 알지만 미리보기에는 도면이 없으므로,
|
|
42
|
+
* 저작자가 가정할 값을 여기서 정한다.
|
|
43
|
+
*/
|
|
44
|
+
ceilingHeight: number
|
|
45
|
+
/** 좌표 바탕(축 가이드). 원점과 눈금을 보인다. */
|
|
46
|
+
grid: boolean
|
|
47
|
+
/** 축 이름표(X · Y · Z). 눈금만 두고 글자를 끌 수 있다. */
|
|
48
|
+
gridLabels: boolean
|
|
49
|
+
/** 판의 바닥면. 좌표 바탕과 겹치므로 기본은 끈다. */
|
|
50
|
+
floor: boolean
|
|
51
|
+
/** Environment — 반사(IBL). 금속 재질이 무엇을 비출지 정한다. */
|
|
52
|
+
environment: EnvironmentName
|
|
53
|
+
/** Sky Color — 배경색. */
|
|
54
|
+
skyColor: string
|
|
55
|
+
/** Key Light Intensity. */
|
|
56
|
+
dirLightIntensity: number
|
|
57
|
+
/** Key Light — Follow Camera. 끄면 그림자 방향이 고정된다. */
|
|
58
|
+
dirLightFollowCamera: boolean
|
|
59
|
+
/** Key Light — Cast Shadow. */
|
|
60
|
+
dirShadowEnabled: boolean
|
|
61
|
+
/** Hemisphere Light Intensity — 그늘진 면을 들어올린다. */
|
|
62
|
+
hemiIntensity: number
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 환경 프리셋 — **`scene-manager` 의 `SkyPreset` 과 같은 여덟이다.**
|
|
67
|
+
*
|
|
68
|
+
* 한동안 다섯만 적었다. 씬은 여덟을 다 받는데 이쪽이 셋을 몰라서 고를 수 없었다.
|
|
69
|
+
* operato-board 의 3D 씬 속성 패널도 같은 여덟을 보인다.
|
|
70
|
+
*/
|
|
71
|
+
export const ENVIRONMENTS = [
|
|
72
|
+
'studio',
|
|
73
|
+
'warehouse',
|
|
74
|
+
'factory',
|
|
75
|
+
'office',
|
|
76
|
+
'home',
|
|
77
|
+
'sunny',
|
|
78
|
+
'cloudy',
|
|
79
|
+
'rainy'
|
|
80
|
+
] as const
|
|
81
|
+
export type EnvironmentName = (typeof ENVIRONMENTS)[number]
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 씬에 그대로 넣는 보기 설정 — **좌표 기준과 천장 높이는 빼고.**
|
|
85
|
+
*
|
|
86
|
+
* 나머지는 전부 `model-layer` 의 상태 이름이라 그대로 넣으면 씬이 알아서 반응한다.
|
|
87
|
+
* 그런데 `placement` 는 편집 캔버스에 들어가면 안 되고(거기는 늘 상자 기준이다),
|
|
88
|
+
* `ceilingHeight` 는 씬이 모르는 이름이다.
|
|
89
|
+
*
|
|
90
|
+
* **rest spread 로 넘기지 않으려고 이 함수가 있다.** 캔버스가 한동안
|
|
91
|
+
* `const { grid, ..., ...light } = view` 로 나머지를 통째로 넘겼는데, 그러면 설정을
|
|
92
|
+
* 하나 더할 때마다 그것이 두 화면에 **말없이** 실린다. 새로 더한 좌표 기준이 바로
|
|
93
|
+
* 그 길로 캔버스에 들어갈 뻔했다.
|
|
94
|
+
*/
|
|
95
|
+
export function sceneLook(view: ViewSettings): Record<string, unknown> {
|
|
96
|
+
const { placement, ceilingHeight, ...look } = view
|
|
97
|
+
return look
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 씬의 좌표 기준 — **씬의 낱말 그대로 셋이다.**
|
|
102
|
+
*
|
|
103
|
+
* 형식의 `floor` · `center` · `ceiling` 과 짝이 맞지만 철자가 다르다. 옮겨 적는 표를 두지
|
|
104
|
+
* 않는 것이 이 파일의 규칙이므로 씬 쪽을 쓴다. 화면에는 둘 다 보인다 — 「천장 기준
|
|
105
|
+
* (inverted)」.
|
|
106
|
+
*/
|
|
107
|
+
export const SCENE_REFERENCES = ['floor', 'space', 'inverted'] as const
|
|
108
|
+
|
|
109
|
+
/** 배경색 기본값. 회색이라 부품 색이 제 색으로 보인다. */
|
|
110
|
+
export const WORKBENCH = '#7c7c7c'
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 처음 값.
|
|
114
|
+
*
|
|
115
|
+
* **지금 저작 화면이 실제로 쓰던 값 그대로다.** 설정을 만들면서 화면이 달라지면
|
|
116
|
+
* 무엇이 설정 때문이고 무엇이 원래 그랬는지 갈리지 않는다.
|
|
117
|
+
*/
|
|
118
|
+
export const DEFAULT_VIEW: ViewSettings = {
|
|
119
|
+
placement: 'floor',
|
|
120
|
+
/* 공장 천장의 흔한 높이. 반도체 fab 의 OHT 레일이 대체로 이 언저리다. */
|
|
121
|
+
ceilingHeight: 4000,
|
|
122
|
+
grid: true,
|
|
123
|
+
gridLabels: true,
|
|
124
|
+
floor: false,
|
|
125
|
+
environment: 'studio',
|
|
126
|
+
skyColor: WORKBENCH,
|
|
127
|
+
dirLightIntensity: 2.0,
|
|
128
|
+
dirLightFollowCamera: true,
|
|
129
|
+
dirShadowEnabled: true,
|
|
130
|
+
hemiIntensity: 4.0
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* How tall the preview board is: enough room for the tallest instance where the figure actually stands.
|
|
135
|
+
*
|
|
136
|
+
* A floor or center figure stands on the floor, so the tallest instance is the whole height. Only a
|
|
137
|
+
* ceiling figure needs the room up to the ceiling. The board used to reach the ceiling for every figure,
|
|
138
|
+
* which made a 920 tall AGV preview 4400 tall.
|
|
139
|
+
*
|
|
140
|
+
* This is an envelope, not a placement rule: where each instance goes is still the scene's
|
|
141
|
+
* (`FigureRealObject.effectiveZPos`), and the camera fits what the scene drew.
|
|
142
|
+
*/
|
|
143
|
+
export function previewBoardDepth(
|
|
144
|
+
figure: { placement?: 'floor' | 'ceiling' | 'center' | 'wall'; base: { y: number } },
|
|
145
|
+
ceilingHeight: number,
|
|
146
|
+
factor: number
|
|
147
|
+
): number {
|
|
148
|
+
const tallest = figure.base.y * factor
|
|
149
|
+
const reach = figure.placement === 'ceiling' ? Math.max(ceilingHeight, tallest) : tallest
|
|
150
|
+
return Math.round(reach * 1.1)
|
|
151
|
+
}
|
package/client/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A released figure on a live canvas, shared by figure-ui (the authoring catalogue) and figure-library (a board
|
|
3
|
+
* server's library). Importers use the files by path (`@things-factory/figure-viewer/dist-client/<file>.js`).
|
|
4
|
+
*/
|
|
5
|
+
export * from './capability-rung.js'
|
|
6
|
+
export * from './controls.js'
|
|
7
|
+
export * from './detail-facts.js'
|
|
8
|
+
export * from './detail-motion.js'
|
|
9
|
+
export * from './figure-asset-viewer.js'
|
|
10
|
+
export * from './figure-facts-list.js'
|
|
11
|
+
export * from './figure-thumb-mark.js'
|
|
12
|
+
export * from './figure-view.js'
|
|
13
|
+
export * from './preview-model.js'
|
|
14
|
+
export * from './side-panel-styles.js'
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { compileFigureAsset, figureOccupiedBoxesOf, figureWritersOf, FIGURE_INSTANCE_SIZE_INPUTS } from '@hatiolab/figure-model'
|
|
2
|
+
import type { FigureAsset } from '@hatiolab/figure-model'
|
|
3
|
+
|
|
4
|
+
/* The preview's arithmetic, apart from the element so it is tested without a browser (see figure-preview.ts). */
|
|
5
|
+
|
|
6
|
+
export const PREVIEW_FACTOR = 2
|
|
7
|
+
|
|
8
|
+
/** The type the preview registers the figure under: this figure's own, never a real type a board uses. */
|
|
9
|
+
export function previewTypeOf(context: string): string {
|
|
10
|
+
return `figure-preview-${context || 'new'}`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const PREVIEW_WAYS: readonly { name: string; axes: readonly ('x' | 'y' | 'z')[] }[] = [
|
|
14
|
+
{ name: 'base', axes: [] },
|
|
15
|
+
{ name: 'x', axes: ['x'] },
|
|
16
|
+
{ name: 'y', axes: ['y'] },
|
|
17
|
+
{ name: 'z', axes: ['z'] },
|
|
18
|
+
{ name: 'x·y', axes: ['x', 'y'] },
|
|
19
|
+
{ name: 'x·z', axes: ['x', 'z'] },
|
|
20
|
+
{ name: 'y·z', axes: ['y', 'z'] },
|
|
21
|
+
{ name: 'x·y·z', axes: ['x', 'y', 'z'] }
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
/** The size the figure was made at: its instance size when it declares one, else the room its bodies take. */
|
|
25
|
+
export function authoredSizeOf(asset: FigureAsset): { x: number; y: number; z: number } {
|
|
26
|
+
const d = asset.designInputs
|
|
27
|
+
const declared = (['x', 'y', 'z'] as const).map(axis => d[FIGURE_INSTANCE_SIZE_INPUTS[axis]])
|
|
28
|
+
if (declared.every(v => typeof v === 'number' && v > 0)) return { x: declared[0]!, y: declared[1]!, z: declared[2]! }
|
|
29
|
+
/* No declared size: the room its bodies take up, so the instance is placed at the size it draws. */
|
|
30
|
+
const boxes = figureOccupiedBoxesOf(compileFigureAsset(asset).evaluate().geometry, figureWritersOf(asset))
|
|
31
|
+
const span = (axis: 'x' | 'y' | 'z') =>
|
|
32
|
+
boxes.length ? Math.max(...boxes.map(b => b.centre[axis] + b.extent[axis] / 2)) - Math.min(...boxes.map(b => b.centre[axis] - b.extent[axis] / 2)) : 0
|
|
33
|
+
return { x: Math.max(1, Math.round(span('x'))), y: Math.max(1, Math.round(span('y'))), z: Math.max(1, Math.round(span('z'))) }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The eight instances: where each stands on the board and how large, in the scene's words. */
|
|
37
|
+
export function previewInstances(type: string, size: { x: number; y: number; z: number }) {
|
|
38
|
+
const COLUMNS = 4
|
|
39
|
+
const cell = { x: size.x * PREVIEW_FACTOR * 1.25, z: size.z * PREVIEW_FACTOR * 1.25 }
|
|
40
|
+
const components = PREVIEW_WAYS.map((way, at) => {
|
|
41
|
+
const grow = (axis: 'x' | 'y' | 'z') => (way.axes.includes(axis) ? PREVIEW_FACTOR : 1)
|
|
42
|
+
const width = Math.round(size.x * grow('x'))
|
|
43
|
+
const height = Math.round(size.z * grow('z'))
|
|
44
|
+
const column = at % COLUMNS
|
|
45
|
+
const row = Math.floor(at / COLUMNS)
|
|
46
|
+
return {
|
|
47
|
+
type,
|
|
48
|
+
id: `at-${way.name}`,
|
|
49
|
+
left: Math.round(column * cell.x + (cell.x - width) / 2),
|
|
50
|
+
top: Math.round(row * cell.z + (cell.z - height) / 2),
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
/* Always written: without it the height is taken as the plan's mean and "grow y only" would not grow it. */
|
|
54
|
+
depth: Math.round(size.y * grow('y'))
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
return { components, board: { width: Math.round(cell.x * COLUMNS), height: Math.round(cell.z * Math.ceil(PREVIEW_WAYS.length / COLUMNS)) } }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Where a variant asks a size the figure does not declare, the size it is drawn at instead -- as the board draws it
|
|
63
|
+
* (things-scene clamps each axis to the declared range; chief architect's ruling 2026-09-25). Per variant, empty when
|
|
64
|
+
* it is drawn as asked. A figure that follows its height only is drawn at its one width in the wider variants, and
|
|
65
|
+
* the preview says so rather than drawing them as though they grew.
|
|
66
|
+
*/
|
|
67
|
+
export function previewClampsOf(asset: FigureAsset, size: { x: number; y: number; z: number }): Record<string, Array<{ axis: 'x' | 'y' | 'z'; asked: number; used: number }>> {
|
|
68
|
+
const inputs = asset.document.model.inputs
|
|
69
|
+
return Object.fromEntries(
|
|
70
|
+
PREVIEW_WAYS.map(way => [
|
|
71
|
+
way.name,
|
|
72
|
+
(['x', 'y', 'z'] as const).flatMap(axis => {
|
|
73
|
+
const input = inputs.find(i => i.id === FIGURE_INSTANCE_SIZE_INPUTS[axis])
|
|
74
|
+
if (!input) return []
|
|
75
|
+
const asked = Math.round(size[axis] * (way.axes.includes(axis) ? PREVIEW_FACTOR : 1))
|
|
76
|
+
const used = Math.round(Math.min(Math.max(asked, input.min ?? -Infinity), input.max ?? Infinity))
|
|
77
|
+
return used === asked ? [] : [{ axis, asked, used }]
|
|
78
|
+
})
|
|
79
|
+
])
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The part the preview's size help speaks of: the one picked in the help, else the one chosen in the editor, else the
|
|
85
|
+
* first that has a size rule. A choice that is not among the parts (removed, or a part with no rule) is passed over.
|
|
86
|
+
*/
|
|
87
|
+
export function setupPartOf(picked: string, chosen: string, targets: string[]): string {
|
|
88
|
+
return [picked, chosen].find(id => !!id && targets.includes(id)) ?? targets[0] ?? ''
|
|
89
|
+
}
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { css } from 'lit'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The side panel's one look, for every element that draws in the modeller's side.
|
|
5
|
+
*
|
|
6
|
+
* The side is drawn by several elements (the type field, the figure's properties, a part's values, fastening, places,
|
|
7
|
+
* motion, material, controls, clips, the environment) and each had styled its own fields: three label styles and
|
|
8
|
+
* three field heights in one column (user, 2026-09-24: "why are the styles and layout all different?"). They share
|
|
9
|
+
* this sheet now and keep only what is theirs.
|
|
10
|
+
*
|
|
11
|
+
* The vocabulary:
|
|
12
|
+
* section one titled group; the side is a stack of them
|
|
13
|
+
* h3 a group's title
|
|
14
|
+
*
|
|
15
|
+
* Three sizes and two weights (user 2026-10-01, the panel checked for balance: eight sizes, and titles smaller than
|
|
16
|
+
* what they titled): a title at the body token and semibold, everything else at the small token, and a hint at the
|
|
17
|
+
* micro one. Sections are 16 px above their title and 12 px below their last line.
|
|
18
|
+
* div[inline-field] a short label and its one field on one line
|
|
19
|
+
* div[field] a label above a full-width field
|
|
20
|
+
* div[form] short labels beside their fields, the fields starting on one line
|
|
21
|
+
* div[vector-row] a title, then X · Y · Z in one row of cells with the axis inside (`div[triple]` of
|
|
22
|
+
* `div[cell]`) -- three values read together, as vector tools lay them out
|
|
23
|
+
* div[pair] two controls side by side
|
|
24
|
+
* label[toggle] a checkbox and its words
|
|
25
|
+
* p[hint] · small the quiet line under a field
|
|
26
|
+
* button[act] an action under the fields it acts on
|
|
27
|
+
* [scrub] a label dragged sideways to scrub its field
|
|
28
|
+
*/
|
|
29
|
+
export const SidePanelStyles = css`
|
|
30
|
+
:host {
|
|
31
|
+
--figure-control-height: 30px;
|
|
32
|
+
font-size: var(--ui-t-small, 11.5px);
|
|
33
|
+
color: var(--md-sys-color-on-surface);
|
|
34
|
+
}
|
|
35
|
+
/* The side is a stack of sections, each a titled group. */
|
|
36
|
+
section {
|
|
37
|
+
display: grid;
|
|
38
|
+
gap: 8px;
|
|
39
|
+
padding: 16px 12px 12px;
|
|
40
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
41
|
+
}
|
|
42
|
+
section > h3 {
|
|
43
|
+
margin: 0;
|
|
44
|
+
}
|
|
45
|
+
section div[field] + div[field],
|
|
46
|
+
section div[inline-field] + div[inline-field],
|
|
47
|
+
section div[vector-row] + div[vector-row] {
|
|
48
|
+
margin-top: 0;
|
|
49
|
+
}
|
|
50
|
+
h3 {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
gap: 4px;
|
|
54
|
+
margin: 14px 0 6px;
|
|
55
|
+
font-size: var(--ui-t-body, 13px);
|
|
56
|
+
font-weight: 600;
|
|
57
|
+
color: var(--md-sys-color-on-surface);
|
|
58
|
+
}
|
|
59
|
+
h3:first-child {
|
|
60
|
+
margin-top: 0;
|
|
61
|
+
}
|
|
62
|
+
/* Two weights only: a bold word in a line is the title's weight, not the browser's heavier one. */
|
|
63
|
+
b,
|
|
64
|
+
strong {
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
}
|
|
67
|
+
label,
|
|
68
|
+
div[form] > span {
|
|
69
|
+
font-size: inherit;
|
|
70
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
71
|
+
}
|
|
72
|
+
div[field] {
|
|
73
|
+
display: grid;
|
|
74
|
+
gap: 2px;
|
|
75
|
+
}
|
|
76
|
+
div[field] + div[field],
|
|
77
|
+
div[field] + div[form],
|
|
78
|
+
div[form] + div[field],
|
|
79
|
+
div[vector-row] + div[vector-row],
|
|
80
|
+
div[vector-row] + div[field],
|
|
81
|
+
div[field] + div[vector-row] {
|
|
82
|
+
margin-top: 5px;
|
|
83
|
+
}
|
|
84
|
+
div[form],
|
|
85
|
+
div[inline-field],
|
|
86
|
+
div[vector-row] {
|
|
87
|
+
display: grid;
|
|
88
|
+
grid-template-columns: 64px minmax(0, 1fr);
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: 5px 7px;
|
|
91
|
+
}
|
|
92
|
+
div[form] > span,
|
|
93
|
+
div[inline-field] > label,
|
|
94
|
+
div[vector-row] > label {
|
|
95
|
+
overflow-wrap: anywhere;
|
|
96
|
+
white-space: normal;
|
|
97
|
+
}
|
|
98
|
+
/* A value read, not edited, beside its label: the field's size and colour, not the page's. */
|
|
99
|
+
div[inline-field] > span[value] {
|
|
100
|
+
font-size: inherit;
|
|
101
|
+
color: var(--md-sys-color-on-surface);
|
|
102
|
+
}
|
|
103
|
+
label span[unit] {
|
|
104
|
+
color: var(--md-sys-color-outline);
|
|
105
|
+
}
|
|
106
|
+
div[inline-field] + div[inline-field],
|
|
107
|
+
div[inline-field] + div[vector-row],
|
|
108
|
+
div[vector-row] + div[inline-field] {
|
|
109
|
+
margin-top: 5px;
|
|
110
|
+
}
|
|
111
|
+
/* A row of worded tools (align, snap; mirror copies). */
|
|
112
|
+
div[tools] {
|
|
113
|
+
display: flex;
|
|
114
|
+
flex-wrap: wrap;
|
|
115
|
+
gap: 4px;
|
|
116
|
+
}
|
|
117
|
+
div[tools] button {
|
|
118
|
+
height: var(--figure-control-height);
|
|
119
|
+
padding: 0 10px;
|
|
120
|
+
font: inherit;
|
|
121
|
+
color: var(--md-sys-color-on-surface);
|
|
122
|
+
background: var(--md-sys-color-surface-container-lowest);
|
|
123
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
124
|
+
border-radius: 6px;
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
}
|
|
127
|
+
div[tools] button:hover:not(:disabled) {
|
|
128
|
+
background: var(--md-sys-color-surface-container);
|
|
129
|
+
}
|
|
130
|
+
div[tools] button:disabled {
|
|
131
|
+
opacity: 0.45;
|
|
132
|
+
cursor: default;
|
|
133
|
+
}
|
|
134
|
+
div[pair] {
|
|
135
|
+
display: flex;
|
|
136
|
+
gap: 4px;
|
|
137
|
+
}
|
|
138
|
+
div[pair] > * {
|
|
139
|
+
flex: 1;
|
|
140
|
+
min-width: 0;
|
|
141
|
+
}
|
|
142
|
+
div[triple] {
|
|
143
|
+
display: grid;
|
|
144
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
145
|
+
gap: 4px;
|
|
146
|
+
}
|
|
147
|
+
input,
|
|
148
|
+
select {
|
|
149
|
+
width: 100%;
|
|
150
|
+
min-width: 0;
|
|
151
|
+
min-height: var(--figure-control-height);
|
|
152
|
+
box-sizing: border-box;
|
|
153
|
+
padding: 4px 7px;
|
|
154
|
+
font: inherit;
|
|
155
|
+
color: var(--md-sys-color-on-surface);
|
|
156
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
157
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
158
|
+
border-radius: 6px;
|
|
159
|
+
}
|
|
160
|
+
/* The browser's own box and dot, in the panel's colour. */
|
|
161
|
+
input[type='checkbox'],
|
|
162
|
+
input[type='radio'] {
|
|
163
|
+
width: auto;
|
|
164
|
+
min-height: 0;
|
|
165
|
+
margin: 0;
|
|
166
|
+
accent-color: var(--md-sys-color-primary);
|
|
167
|
+
}
|
|
168
|
+
/* A fold: the panel's chevron, not the browser's triangle. */
|
|
169
|
+
summary {
|
|
170
|
+
display: flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
gap: 6px;
|
|
173
|
+
padding: 6px 0;
|
|
174
|
+
list-style: none;
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
177
|
+
}
|
|
178
|
+
summary::-webkit-details-marker {
|
|
179
|
+
display: none;
|
|
180
|
+
}
|
|
181
|
+
summary::before {
|
|
182
|
+
content: '';
|
|
183
|
+
flex: none;
|
|
184
|
+
width: 6px;
|
|
185
|
+
height: 6px;
|
|
186
|
+
margin: 0 2px;
|
|
187
|
+
border-right: 1.5px solid currentColor;
|
|
188
|
+
border-bottom: 1.5px solid currentColor;
|
|
189
|
+
transform: rotate(-45deg);
|
|
190
|
+
transition: transform 0.15s;
|
|
191
|
+
}
|
|
192
|
+
details[open] > summary::before {
|
|
193
|
+
transform: rotate(45deg);
|
|
194
|
+
}
|
|
195
|
+
/* A thin track and a small thumb: a slider is a line to drag along, not a block (user, 2026-09-24). */
|
|
196
|
+
input[type='range'] {
|
|
197
|
+
-webkit-appearance: none;
|
|
198
|
+
appearance: none;
|
|
199
|
+
min-height: 16px;
|
|
200
|
+
height: 16px;
|
|
201
|
+
padding: 0;
|
|
202
|
+
border: none;
|
|
203
|
+
background: transparent;
|
|
204
|
+
cursor: pointer;
|
|
205
|
+
}
|
|
206
|
+
input[type='range']::-webkit-slider-runnable-track {
|
|
207
|
+
height: 3px;
|
|
208
|
+
border-radius: 2px;
|
|
209
|
+
background: var(--md-sys-color-outline-variant);
|
|
210
|
+
}
|
|
211
|
+
input[type='range']::-webkit-slider-thumb {
|
|
212
|
+
-webkit-appearance: none;
|
|
213
|
+
width: 12px;
|
|
214
|
+
height: 12px;
|
|
215
|
+
margin-top: -4.5px;
|
|
216
|
+
border: none;
|
|
217
|
+
border-radius: 50%;
|
|
218
|
+
background: var(--md-sys-color-primary);
|
|
219
|
+
}
|
|
220
|
+
input[type='range']::-moz-range-track {
|
|
221
|
+
height: 3px;
|
|
222
|
+
border-radius: 2px;
|
|
223
|
+
background: var(--md-sys-color-outline-variant);
|
|
224
|
+
}
|
|
225
|
+
input[type='range']::-moz-range-thumb {
|
|
226
|
+
width: 12px;
|
|
227
|
+
height: 12px;
|
|
228
|
+
border: none;
|
|
229
|
+
border-radius: 50%;
|
|
230
|
+
background: var(--md-sys-color-primary);
|
|
231
|
+
}
|
|
232
|
+
input[type='range']:focus {
|
|
233
|
+
outline: none;
|
|
234
|
+
}
|
|
235
|
+
input[type='range']:focus-visible::-webkit-slider-thumb {
|
|
236
|
+
outline: 2px solid var(--md-sys-color-primary);
|
|
237
|
+
outline-offset: 2px;
|
|
238
|
+
}
|
|
239
|
+
input[type='color'] {
|
|
240
|
+
padding: 2px;
|
|
241
|
+
width: 40px;
|
|
242
|
+
}
|
|
243
|
+
input:focus,
|
|
244
|
+
select:focus {
|
|
245
|
+
outline: 2px solid var(--md-sys-color-primary);
|
|
246
|
+
outline-offset: -1px;
|
|
247
|
+
}
|
|
248
|
+
input:disabled,
|
|
249
|
+
select:disabled {
|
|
250
|
+
opacity: 0.6;
|
|
251
|
+
}
|
|
252
|
+
/* A number with its axis inside the cell, on the left. */
|
|
253
|
+
div[cell] {
|
|
254
|
+
display: flex;
|
|
255
|
+
box-sizing: border-box;
|
|
256
|
+
height: var(--figure-control-height);
|
|
257
|
+
align-items: center;
|
|
258
|
+
gap: 2px;
|
|
259
|
+
padding-left: 6px;
|
|
260
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
261
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
262
|
+
border-radius: 6px;
|
|
263
|
+
}
|
|
264
|
+
div[cell]:focus-within {
|
|
265
|
+
outline: 2px solid var(--md-sys-color-primary);
|
|
266
|
+
outline-offset: -1px;
|
|
267
|
+
border-color: transparent;
|
|
268
|
+
}
|
|
269
|
+
/* A label that scrubs its field when dragged sideways (vector tools' way). */
|
|
270
|
+
[scrub] {
|
|
271
|
+
cursor: ew-resize;
|
|
272
|
+
user-select: none;
|
|
273
|
+
touch-action: none;
|
|
274
|
+
}
|
|
275
|
+
div[cell] span[axis] {
|
|
276
|
+
flex: none;
|
|
277
|
+
font-size: var(--ui-t-micro, 11px);
|
|
278
|
+
letter-spacing: 0.02em;
|
|
279
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
280
|
+
}
|
|
281
|
+
div[cell] input {
|
|
282
|
+
min-height: 0;
|
|
283
|
+
height: calc(var(--figure-control-height) - 2px);
|
|
284
|
+
padding: 4px 6px 4px 2px;
|
|
285
|
+
font-family: var(--mono-font, monospace);
|
|
286
|
+
text-align: right;
|
|
287
|
+
background: none;
|
|
288
|
+
border: none;
|
|
289
|
+
border-radius: 0;
|
|
290
|
+
}
|
|
291
|
+
div[cell] input:focus {
|
|
292
|
+
outline: none;
|
|
293
|
+
}
|
|
294
|
+
/* An axis a rule sets: its number, read-only, on a quieter ground (ADR-0097). */
|
|
295
|
+
div[cell][held] {
|
|
296
|
+
background-color: var(--md-sys-color-surface-container);
|
|
297
|
+
border-style: dashed;
|
|
298
|
+
}
|
|
299
|
+
div[cell][held] input {
|
|
300
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
301
|
+
font-style: italic;
|
|
302
|
+
}
|
|
303
|
+
p[held-axes] {
|
|
304
|
+
margin: 2px 0 6px;
|
|
305
|
+
}
|
|
306
|
+
label[toggle] {
|
|
307
|
+
display: flex;
|
|
308
|
+
align-items: center;
|
|
309
|
+
gap: 6px;
|
|
310
|
+
color: var(--md-sys-color-on-surface);
|
|
311
|
+
}
|
|
312
|
+
/* The 「?」 beside a title: no border, it says there is more rather than asking to be pressed. */
|
|
313
|
+
button[help] {
|
|
314
|
+
display: inline-flex;
|
|
315
|
+
align-items: center;
|
|
316
|
+
padding: 0;
|
|
317
|
+
margin: 0;
|
|
318
|
+
color: var(--md-sys-color-outline);
|
|
319
|
+
background: none;
|
|
320
|
+
border: none;
|
|
321
|
+
cursor: pointer;
|
|
322
|
+
}
|
|
323
|
+
button[help] md-icon {
|
|
324
|
+
font-size: 13px;
|
|
325
|
+
width: 13px;
|
|
326
|
+
height: 13px;
|
|
327
|
+
}
|
|
328
|
+
button[help]:hover,
|
|
329
|
+
button[help][aria-expanded='true'] {
|
|
330
|
+
color: var(--md-sys-color-primary);
|
|
331
|
+
}
|
|
332
|
+
p[hint],
|
|
333
|
+
small {
|
|
334
|
+
display: block;
|
|
335
|
+
margin: 2px 0 4px;
|
|
336
|
+
font-size: var(--ui-t-micro, 11px);
|
|
337
|
+
line-height: 1.5;
|
|
338
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
339
|
+
}
|
|
340
|
+
/*
|
|
341
|
+
* An action under its fields: as wide as its words, not a band across the panel -- four full-width grey bars read as
|
|
342
|
+
* four walls and none of them as the one to press (user 2026-10-01). Every one carries its icon.
|
|
343
|
+
*/
|
|
344
|
+
button[act] {
|
|
345
|
+
display: inline-flex;
|
|
346
|
+
align-items: center;
|
|
347
|
+
justify-content: center;
|
|
348
|
+
justify-self: start;
|
|
349
|
+
gap: 6px;
|
|
350
|
+
width: auto;
|
|
351
|
+
max-width: 100%;
|
|
352
|
+
margin-top: 4px;
|
|
353
|
+
padding: 0 12px;
|
|
354
|
+
min-height: var(--figure-control-height);
|
|
355
|
+
font: inherit;
|
|
356
|
+
color: var(--md-sys-color-primary);
|
|
357
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
358
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
359
|
+
border-radius: 6px;
|
|
360
|
+
cursor: pointer;
|
|
361
|
+
}
|
|
362
|
+
button[act]:hover:not(:disabled) {
|
|
363
|
+
background-color: var(--md-sys-color-primary-container);
|
|
364
|
+
}
|
|
365
|
+
button[act]:disabled {
|
|
366
|
+
opacity: 0.5;
|
|
367
|
+
cursor: default;
|
|
368
|
+
}
|
|
369
|
+
button[act] md-icon {
|
|
370
|
+
font-size: 16px;
|
|
371
|
+
width: 16px;
|
|
372
|
+
height: 16px;
|
|
373
|
+
}
|
|
374
|
+
`
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig-base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"experimentalDecorators": true,
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"baseUrl": "./",
|
|
9
|
+
"module": "esnext",
|
|
10
|
+
"outDir": "../dist-client"
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"./**/*"
|
|
14
|
+
],
|
|
15
|
+
"exclude": [
|
|
16
|
+
"**/*.test.ts",
|
|
17
|
+
"**/*.spec.ts"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FigureCapability } from '@hatiolab/figure-model';
|
|
2
|
+
export type Rung = 'none' | 'hold' | 'flow';
|
|
3
|
+
export declare const RUNGS: Readonly<Record<Rung, readonly FigureCapability[]>>;
|
|
4
|
+
/** Which rung a set of names is, or null when it is none of them -- not invented. */
|
|
5
|
+
export declare function rungOf(names: readonly string[] | undefined): Rung | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const RUNGS = Object.freeze({
|
|
2
|
+
none: [],
|
|
3
|
+
hold: ['Capacity', 'Holdable'],
|
|
4
|
+
flow: ['FlowNode']
|
|
5
|
+
});
|
|
6
|
+
/** Which rung a set of names is, or null when it is none of them -- not invented. */
|
|
7
|
+
export function rungOf(names) {
|
|
8
|
+
const has = new Set(names ?? []);
|
|
9
|
+
if (has.size === 0)
|
|
10
|
+
return 'none';
|
|
11
|
+
for (const [rung, wanted] of Object.entries(RUNGS))
|
|
12
|
+
if (wanted.length === has.size && wanted.every(name => has.has(name)))
|
|
13
|
+
return rung;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=capability-rung.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-rung.js","sourceRoot":"","sources":["../client/capability-rung.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,KAAK,GAAwD,MAAM,CAAC,MAAM,CAAC;IACtF,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;IAC9B,IAAI,EAAE,CAAC,UAAU,CAAC;CACnB,CAAC,CAAA;AAEF,qFAAqF;AACrF,MAAM,UAAU,MAAM,CAAC,KAAoC;IACzD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IAChC,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,MAAM,CAAA;IACjC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAA0C;QACzF,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAA;IACpF,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { FigureCapability } from '@hatiolab/figure-model'\n\n/*\n One rung per set of the format's capability names. Typed as the format's names, so a misspelt rung does not pass\n (ADR-0051 ④).\n*/\nexport type Rung = 'none' | 'hold' | 'flow'\nexport const RUNGS: Readonly<Record<Rung, readonly FigureCapability[]>> = Object.freeze({\n none: [],\n hold: ['Capacity', 'Holdable'],\n flow: ['FlowNode']\n})\n\n/** Which rung a set of names is, or null when it is none of them -- not invented. */\nexport function rungOf(names: readonly string[] | undefined): Rung | null {\n const has = new Set(names ?? [])\n if (has.size === 0) return 'none'\n for (const [rung, wanted] of Object.entries(RUNGS) as [Rung, readonly FigureCapability[]][])\n if (wanted.length === has.size && wanted.every(name => has.has(name))) return rung\n return null\n}\n\n"]}
|