@m3ui-vue/m3ui-vue 1.3.8 → 1.4.0
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/dist/API.md +1058 -18
- package/dist/{MButton-D5eJiDza.js → MButton-DQMTIlaV.js} +2 -2
- package/dist/{MButton-D5eJiDza.js.map → MButton-DQMTIlaV.js.map} +1 -1
- package/dist/{MDialog-WqB0jewp.js → MDialog-cdgapGfZ.js} +2 -2
- package/dist/{MDialog-WqB0jewp.js.map → MDialog-cdgapGfZ.js.map} +1 -1
- package/dist/{MListItem-Cf-C2Ru-.js → MListItem-ZkSGIIrb.js} +2 -2
- package/dist/{MListItem-Cf-C2Ru-.js.map → MListItem-ZkSGIIrb.js.map} +1 -1
- package/dist/{MLoadingIndicator-D4GzEZoH.js → MLoadingIndicator-U6_oGx8z.js} +2 -2
- package/dist/{MLoadingIndicator-D4GzEZoH.js.map → MLoadingIndicator-U6_oGx8z.js.map} +1 -1
- package/dist/{MSeekBar-B19xoWE3.js → MSeekBar-DTZVizZg.js} +2 -2
- package/dist/{MSeekBar-B19xoWE3.js.map → MSeekBar-DTZVizZg.js.map} +1 -1
- package/dist/{MSlider-9RoiuebS.js → MSlider-CqJkEYRZ.js} +2 -2
- package/dist/{MSlider-9RoiuebS.js.map → MSlider-CqJkEYRZ.js.map} +1 -1
- package/dist/{MSpinner-BNF8MN-L.js → MSpinner-Btgc-0nb.js} +2 -2
- package/dist/{MSpinner-BNF8MN-L.js.map → MSpinner-Btgc-0nb.js.map} +1 -1
- package/dist/{MTextField-CuG0T3qh.js → MTextField-B6M0gJEO.js} +2 -2
- package/dist/{MTextField-CuG0T3qh.js.map → MTextField-B6M0gJEO.js.map} +1 -1
- package/dist/{MTooltip-Bv7yxngk.js → MTooltip-Dspji4XG.js} +4 -4
- package/dist/{MTooltip-Bv7yxngk.js.map → MTooltip-Dspji4XG.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MAudioPlayer.vue.d.ts +2 -2
- package/dist/components/MAvailabilityCalendar.vue.d.ts +83 -0
- package/dist/components/MBeforeAfter.vue.d.ts +61 -0
- package/dist/components/MBodyMap.vue.d.ts +70 -0
- package/dist/components/MCandlestickChart.vue.d.ts +82 -0
- package/dist/components/MCertificate.vue.d.ts +76 -0
- package/dist/components/MCreditCardInput.vue.d.ts +75 -0
- package/dist/components/MMortgageCalculator.vue.d.ts +83 -0
- package/dist/components/MOdontogram.vue.d.ts +86 -0
- package/dist/components/MOrderBook.vue.d.ts +89 -0
- package/dist/components/MOrderTicket.vue.d.ts +91 -0
- package/dist/components/MPosKeypad.vue.d.ts +84 -0
- package/dist/components/MProductConfigurator.vue.d.ts +136 -0
- package/dist/components/MQuiz.vue.d.ts +102 -0
- package/dist/components/MReceipt.vue.d.ts +93 -0
- package/dist/components/MSeatMap.vue.d.ts +131 -0
- package/dist/components/MSeekBar.vue.d.ts +1 -1
- package/dist/components/MTicket.vue.d.ts +83 -0
- package/dist/components/MVideoPlayer.vue.d.ts +1 -1
- package/dist/components/MVitalsChart.vue.d.ts +73 -0
- package/dist/composables/_printElement.d.ts +9 -0
- package/dist/composables/cardBrand.d.ts +25 -0
- package/dist/composables/mortgage.d.ts +37 -0
- package/dist/composables/useLocale.d.ts +131 -0
- package/dist/draw.js +2 -2
- package/dist/flow.js +1 -1
- package/dist/gantt.js +1 -1
- package/dist/index.d.ts +35 -0
- package/dist/locales/index.js +924 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +8264 -3553
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +5 -5
- package/dist/media.js +4 -4
- package/dist/pdf.js +4 -4
- package/dist/rich-text-editor.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/{useLocale-D2ucaY-l.js → useLocale-DLKJIRFi.js} +133 -2
- package/dist/useLocale-DLKJIRFi.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MAvailabilityCalendar.test.ts +85 -0
- package/src/__tests__/MBeforeAfter.test.ts +79 -0
- package/src/__tests__/MBodyMap.test.ts +60 -0
- package/src/__tests__/MCandlestickChart.test.ts +66 -0
- package/src/__tests__/MCertificate.test.ts +32 -0
- package/src/__tests__/MCreditCardInput.test.ts +122 -0
- package/src/__tests__/MMortgageCalculator.test.ts +49 -0
- package/src/__tests__/MOdontogram.test.ts +93 -0
- package/src/__tests__/MOrderBook.test.ts +66 -0
- package/src/__tests__/MOrderTicket.test.ts +68 -0
- package/src/__tests__/MPosKeypad.test.ts +116 -0
- package/src/__tests__/MProductConfigurator.test.ts +73 -0
- package/src/__tests__/MQuiz.test.ts +104 -0
- package/src/__tests__/MReceipt.test.ts +52 -0
- package/src/__tests__/MSeatMap.test.ts +76 -0
- package/src/__tests__/MTicket.test.ts +38 -0
- package/src/__tests__/MVitalsChart.test.ts +49 -0
- package/src/__tests__/mortgage.test.ts +25 -0
- package/src/__tests__/ssr.test.ts +11 -0
- package/src/components/MAvailabilityCalendar.vue +460 -0
- package/src/components/MBeforeAfter.vue +248 -0
- package/src/components/MBodyMap.vue +266 -0
- package/src/components/MCandlestickChart.vue +479 -0
- package/src/components/MCertificate.vue +351 -0
- package/src/components/MCreditCardInput.vue +351 -0
- package/src/components/MMortgageCalculator.vue +258 -0
- package/src/components/MOdontogram.vue +462 -0
- package/src/components/MOrderBook.vue +287 -0
- package/src/components/MOrderTicket.vue +217 -0
- package/src/components/MPosKeypad.vue +406 -0
- package/src/components/MProductConfigurator.vue +412 -0
- package/src/components/MQuiz.vue +531 -0
- package/src/components/MReceipt.vue +249 -0
- package/src/components/MSeatMap.vue +431 -0
- package/src/components/MTicket.vue +209 -0
- package/src/components/MVitalsChart.vue +303 -0
- package/src/composables/_printElement.ts +36 -0
- package/src/composables/cardBrand.ts +104 -0
- package/src/composables/mortgage.ts +70 -0
- package/src/composables/useLocale.ts +277 -0
- package/src/index.ts +35 -0
- package/src/locales/de.ts +131 -0
- package/src/locales/es.ts +131 -0
- package/src/locales/fr.ts +131 -0
- package/src/locales/ja.ts +131 -0
- package/src/locales/ko.ts +131 -0
- package/src/locales/pt.ts +131 -0
- package/src/locales/zh.ts +131 -0
- package/dist/useLocale-D2ucaY-l.js.map +0 -1
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export type ToothSurface = 'mesial' | 'distal' | 'buccal' | 'lingual' | 'occlusal'
|
|
3
|
+
|
|
4
|
+
/** The chart of one tooth: a condition per surface, and conditions of the whole tooth. */
|
|
5
|
+
export interface ToothState {
|
|
6
|
+
surfaces?: Partial<Record<ToothSurface, string>>
|
|
7
|
+
conditions?: string[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Teeth by number (in the chosen numbering) → their state. */
|
|
11
|
+
export type OdontogramValue = Record<string, ToothState>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Something to chart. `surface` conditions paint one face (caries, a filling); `tooth` conditions mark the whole
|
|
15
|
+
* tooth. The built-in tooth keys `missing`, `extraction`, `crown`, `rootCanal` and `implant` get their own drawing;
|
|
16
|
+
* any other tooth key outlines the tooth in its color.
|
|
17
|
+
*/
|
|
18
|
+
export interface OdontogramCondition {
|
|
19
|
+
key: string
|
|
20
|
+
label: string
|
|
21
|
+
color: string
|
|
22
|
+
scope: 'surface' | 'tooth'
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
/**
|
|
28
|
+
* A dental chart: every tooth with its five surfaces (mesial, distal, buccal, lingual, occlusal) and whole-tooth
|
|
29
|
+
* conditions (missing, to extract, crown, root canal, implant). Pick a condition in the toolbar, then tap a surface
|
|
30
|
+
* or a tooth number to chart it; tapping again removes it. FDI or Universal numbering, permanent or primary teeth.
|
|
31
|
+
*
|
|
32
|
+
* Keyboard: each tooth is one tab stop; arrows move between teeth, M / D / B / L / O chart that surface with a
|
|
33
|
+
* surface condition, Enter charts a tooth condition, Delete clears the tooth.
|
|
34
|
+
*
|
|
35
|
+
* @slot toolbar Replaces the condition picker. Slot props: `{ conditions, tool, setTool }`
|
|
36
|
+
* @event update:modelValue The chart — powers v-model
|
|
37
|
+
* @event update:tool The condition picked — powers v-model:tool
|
|
38
|
+
* @event change A tooth changed: `{ tooth, surface?, condition }` (condition null = cleared)
|
|
39
|
+
*/
|
|
40
|
+
import { computed, nextTick, ref } from 'vue'
|
|
41
|
+
import MIcon from './MIcon.vue'
|
|
42
|
+
import { useLocale } from '../composables/useLocale'
|
|
43
|
+
import { vRipple } from '../directives/vRipple'
|
|
44
|
+
|
|
45
|
+
const locale = useLocale()
|
|
46
|
+
|
|
47
|
+
const props = withDefaults(
|
|
48
|
+
defineProps<{
|
|
49
|
+
/** The chart (v-model) */
|
|
50
|
+
modelValue?: OdontogramValue
|
|
51
|
+
/** Condition picked in the toolbar, or "eraser" (v-model:tool) */
|
|
52
|
+
tool?: string
|
|
53
|
+
/** Conditions offered. Defaults to caries, filling, sealant, crown, root canal, implant, missing and to extract */
|
|
54
|
+
conditions?: OdontogramCondition[]
|
|
55
|
+
/** Tooth numbering: FDI two-digit (11–48) or Universal (1–32, A–T for primary teeth) */
|
|
56
|
+
numbering?: 'fdi' | 'universal'
|
|
57
|
+
/** Adult (32) or primary (20) teeth */
|
|
58
|
+
dentition?: 'permanent' | 'primary'
|
|
59
|
+
/** Hides the condition picker (e.g. when the app draws its own) */
|
|
60
|
+
hideToolbar?: boolean
|
|
61
|
+
/** Shows the chart but doesn't change it */
|
|
62
|
+
readonly?: boolean
|
|
63
|
+
}>(),
|
|
64
|
+
{
|
|
65
|
+
modelValue: () => ({}),
|
|
66
|
+
tool: undefined,
|
|
67
|
+
numbering: 'fdi',
|
|
68
|
+
dentition: 'permanent',
|
|
69
|
+
hideToolbar: false,
|
|
70
|
+
readonly: false,
|
|
71
|
+
},
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const emit = defineEmits<{
|
|
75
|
+
'update:modelValue': [OdontogramValue]
|
|
76
|
+
'update:tool': [string]
|
|
77
|
+
change: [{ tooth: string; surface?: ToothSurface; condition: string | null }]
|
|
78
|
+
}>()
|
|
79
|
+
|
|
80
|
+
const defaultConditions = computed<OdontogramCondition[]>(() => [
|
|
81
|
+
{ key: 'caries', label: locale.odontoCaries, color: 'var(--color-error)', scope: 'surface' },
|
|
82
|
+
{ key: 'filling', label: locale.odontoFilling, color: 'var(--color-primary)', scope: 'surface' },
|
|
83
|
+
{ key: 'sealant', label: locale.odontoSealant, color: 'var(--color-tertiary)', scope: 'surface' },
|
|
84
|
+
{ key: 'crown', label: locale.odontoCrown, color: 'var(--color-primary)', scope: 'tooth' },
|
|
85
|
+
{ key: 'rootCanal', label: locale.odontoRootCanal, color: 'var(--color-secondary)', scope: 'tooth' },
|
|
86
|
+
{ key: 'implant', label: locale.odontoImplant, color: 'var(--color-tertiary)', scope: 'tooth' },
|
|
87
|
+
{ key: 'missing', label: locale.odontoMissing, color: 'var(--color-on-surface-variant)', scope: 'tooth' },
|
|
88
|
+
{ key: 'extraction', label: locale.odontoExtraction, color: 'var(--color-error)', scope: 'tooth' },
|
|
89
|
+
])
|
|
90
|
+
const conds = computed(() => props.conditions ?? defaultConditions.value)
|
|
91
|
+
const condMap = computed(() => new Map(conds.value.map((c) => [c.key, c])))
|
|
92
|
+
|
|
93
|
+
const innerTool = ref(props.tool ?? conds.value[0]?.key ?? 'eraser')
|
|
94
|
+
const tool = computed(() => props.tool ?? innerTool.value)
|
|
95
|
+
function setTool(k: string) {
|
|
96
|
+
innerTool.value = k
|
|
97
|
+
emit('update:tool', k)
|
|
98
|
+
}
|
|
99
|
+
const toolCond = computed(() => condMap.value.get(tool.value))
|
|
100
|
+
|
|
101
|
+
// ── teeth, in chart order (viewer's left to right) ──
|
|
102
|
+
interface Tooth { fdi: number; label: string; upper: boolean; /** patient's right = viewer's left */ right: boolean }
|
|
103
|
+
|
|
104
|
+
const UNIVERSAL_PRIMARY = 'ABCDEFGHIJKLMNOPQRST'
|
|
105
|
+
|
|
106
|
+
function universal(fdi: number) {
|
|
107
|
+
const q = Math.floor(fdi / 10)
|
|
108
|
+
const n = fdi % 10
|
|
109
|
+
if (q <= 4) {
|
|
110
|
+
// 1 = upper right third molar … 16 = upper left; 17 = lower left third molar … 32 = lower right
|
|
111
|
+
if (q === 1) return String(9 - n)
|
|
112
|
+
if (q === 2) return String(8 + n)
|
|
113
|
+
if (q === 3) return String(25 - n)
|
|
114
|
+
return String(24 + n)
|
|
115
|
+
}
|
|
116
|
+
if (q === 5) return UNIVERSAL_PRIMARY[5 - n]!
|
|
117
|
+
if (q === 6) return UNIVERSAL_PRIMARY[4 + n]!
|
|
118
|
+
if (q === 7) return UNIVERSAL_PRIMARY[15 - n]!
|
|
119
|
+
return UNIVERSAL_PRIMARY[14 + n]!
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const rows = computed(() => {
|
|
123
|
+
const count = props.dentition === 'primary' ? 5 : 8
|
|
124
|
+
const [qUR, qUL, qLL, qLR] = props.dentition === 'primary' ? [5, 6, 7, 8] : [1, 2, 3, 4]
|
|
125
|
+
const make = (q: number, n: number, upper: boolean, right: boolean): Tooth => {
|
|
126
|
+
const fdi = q * 10 + n
|
|
127
|
+
return { fdi, label: props.numbering === 'fdi' ? String(fdi) : universal(fdi), upper, right }
|
|
128
|
+
}
|
|
129
|
+
const seq = (from: number) => Array.from({ length: count }, (_, i) => from - i)
|
|
130
|
+
const upper = [
|
|
131
|
+
...seq(count).map((n) => make(qUR!, n, true, true)),
|
|
132
|
+
...seq(count).reverse().map((n) => make(qUL!, n, true, false)),
|
|
133
|
+
]
|
|
134
|
+
const lower = [
|
|
135
|
+
...seq(count).map((n) => make(qLR!, n, false, true)),
|
|
136
|
+
...seq(count).reverse().map((n) => make(qLL!, n, false, false)),
|
|
137
|
+
]
|
|
138
|
+
return [upper, lower]
|
|
139
|
+
})
|
|
140
|
+
const allTeeth = computed(() => rows.value.flat())
|
|
141
|
+
|
|
142
|
+
// ── geometry: a 40×40 box per tooth, 4 trapezoids around a center square ──
|
|
143
|
+
const BOX = 40
|
|
144
|
+
const GAP = 6
|
|
145
|
+
const MID = 14
|
|
146
|
+
const ROOT = 16
|
|
147
|
+
const LABEL = 16
|
|
148
|
+
type Side = 'top' | 'bottom' | 'left' | 'right' | 'center'
|
|
149
|
+
const POLY: Record<Exclude<Side, 'center'>, string> = {
|
|
150
|
+
top: '0,0 40,0 28,12 12,12',
|
|
151
|
+
bottom: '0,40 40,40 28,28 12,28',
|
|
152
|
+
left: '0,0 12,12 12,28 0,40',
|
|
153
|
+
right: '40,0 28,12 28,28 40,40',
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Which surface each side of the box is, for this tooth */
|
|
157
|
+
function surfaceAt(t: Tooth, side: Side): ToothSurface {
|
|
158
|
+
if (side === 'center') return 'occlusal'
|
|
159
|
+
if (side === 'top') return t.upper ? 'buccal' : 'lingual'
|
|
160
|
+
if (side === 'bottom') return t.upper ? 'lingual' : 'buccal'
|
|
161
|
+
// Mesial faces the midline
|
|
162
|
+
const towardMid = t.right ? 'right' : 'left'
|
|
163
|
+
return side === towardMid ? 'mesial' : 'distal'
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const perRow = computed(() => rows.value[0]!.length)
|
|
167
|
+
const width = computed(() => perRow.value * (BOX + GAP) - GAP + MID)
|
|
168
|
+
const rowH = BOX + ROOT + LABEL
|
|
169
|
+
const height = rowH * 2 + 20
|
|
170
|
+
|
|
171
|
+
function xOf(i: number) {
|
|
172
|
+
return i * (BOX + GAP) + (i >= perRow.value / 2 ? MID : 0)
|
|
173
|
+
}
|
|
174
|
+
/** Box top for a row: upper roots go up (above the box), lower roots go down */
|
|
175
|
+
function yOf(upper: boolean) {
|
|
176
|
+
return upper ? ROOT + LABEL : rowH + 20
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const surfaceLabels = computed<Record<ToothSurface, string>>(() => ({
|
|
180
|
+
mesial: locale.odontoMesial,
|
|
181
|
+
distal: locale.odontoDistal,
|
|
182
|
+
buccal: locale.odontoBuccal,
|
|
183
|
+
lingual: locale.odontoLingual,
|
|
184
|
+
occlusal: locale.odontoOcclusal,
|
|
185
|
+
}))
|
|
186
|
+
|
|
187
|
+
// ── state ──
|
|
188
|
+
function state(t: Tooth): ToothState {
|
|
189
|
+
return props.modelValue[t.label] ?? {}
|
|
190
|
+
}
|
|
191
|
+
function surfaceColor(t: Tooth, s: ToothSurface) {
|
|
192
|
+
const k = state(t).surfaces?.[s]
|
|
193
|
+
return k ? condMap.value.get(k)?.color : undefined
|
|
194
|
+
}
|
|
195
|
+
function has(t: Tooth, k: string) {
|
|
196
|
+
return state(t).conditions?.includes(k) ?? false
|
|
197
|
+
}
|
|
198
|
+
const customToothConds = (t: Tooth) =>
|
|
199
|
+
(state(t).conditions ?? []).filter((k) => !['missing', 'extraction', 'crown', 'rootCanal', 'implant'].includes(k))
|
|
200
|
+
|
|
201
|
+
function commit(t: Tooth, next: ToothState) {
|
|
202
|
+
const v = { ...props.modelValue }
|
|
203
|
+
const clean: ToothState = {}
|
|
204
|
+
if (next.surfaces && Object.keys(next.surfaces).length) clean.surfaces = next.surfaces
|
|
205
|
+
if (next.conditions?.length) clean.conditions = next.conditions
|
|
206
|
+
if (clean.surfaces || clean.conditions) v[t.label] = clean
|
|
207
|
+
else delete v[t.label]
|
|
208
|
+
emit('update:modelValue', v)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function applySurface(t: Tooth, s: ToothSurface) {
|
|
212
|
+
if (props.readonly) return
|
|
213
|
+
const cur = state(t)
|
|
214
|
+
const surfaces = { ...cur.surfaces }
|
|
215
|
+
let condition: string | null
|
|
216
|
+
if (tool.value === 'eraser' || surfaces[s] === tool.value) {
|
|
217
|
+
delete surfaces[s]
|
|
218
|
+
condition = null
|
|
219
|
+
} else if (toolCond.value?.scope === 'surface') {
|
|
220
|
+
surfaces[s] = tool.value
|
|
221
|
+
condition = tool.value
|
|
222
|
+
} else {
|
|
223
|
+
// A whole-tooth tool clicked on a surface charts the tooth
|
|
224
|
+
return applyTooth(t)
|
|
225
|
+
}
|
|
226
|
+
commit(t, { ...cur, surfaces })
|
|
227
|
+
emit('change', { tooth: t.label, surface: s, condition })
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function applyTooth(t: Tooth) {
|
|
231
|
+
if (props.readonly) return
|
|
232
|
+
const cur = state(t)
|
|
233
|
+
if (tool.value === 'eraser') {
|
|
234
|
+
commit(t, {})
|
|
235
|
+
emit('change', { tooth: t.label, condition: null })
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
if (toolCond.value?.scope !== 'tooth') return
|
|
239
|
+
const list = cur.conditions ?? []
|
|
240
|
+
const on = list.includes(tool.value)
|
|
241
|
+
commit(t, { ...cur, conditions: on ? list.filter((k) => k !== tool.value) : [...list, tool.value] })
|
|
242
|
+
emit('change', { tooth: t.label, condition: on ? null : tool.value })
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// ── keyboard ──
|
|
246
|
+
const focusIdx = ref(0)
|
|
247
|
+
const rootEl = ref<HTMLElement | null>(null)
|
|
248
|
+
const KEY_SURFACE: Record<string, ToothSurface> = { m: 'mesial', d: 'distal', b: 'buccal', v: 'buccal', l: 'lingual', p: 'lingual', o: 'occlusal', i: 'occlusal' }
|
|
249
|
+
|
|
250
|
+
async function onKeydown(e: KeyboardEvent, idx: number) {
|
|
251
|
+
const t = allTeeth.value[idx]!
|
|
252
|
+
const n = perRow.value
|
|
253
|
+
let next: number | null = null
|
|
254
|
+
if (e.key === 'ArrowRight') next = Math.min(allTeeth.value.length - 1, idx + 1)
|
|
255
|
+
else if (e.key === 'ArrowLeft') next = Math.max(0, idx - 1)
|
|
256
|
+
else if (e.key === 'ArrowDown') next = idx < n ? idx + n : idx
|
|
257
|
+
else if (e.key === 'ArrowUp') next = idx >= n ? idx - n : idx
|
|
258
|
+
else if (e.key === 'Enter' || e.key === ' ') {
|
|
259
|
+
e.preventDefault()
|
|
260
|
+
applyTooth(t)
|
|
261
|
+
return
|
|
262
|
+
} else if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
263
|
+
e.preventDefault()
|
|
264
|
+
if (!props.readonly) {
|
|
265
|
+
commit(t, {})
|
|
266
|
+
emit('change', { tooth: t.label, condition: null })
|
|
267
|
+
}
|
|
268
|
+
return
|
|
269
|
+
} else if (KEY_SURFACE[e.key.toLowerCase()] && !e.ctrlKey && !e.metaKey) {
|
|
270
|
+
e.preventDefault()
|
|
271
|
+
applySurface(t, KEY_SURFACE[e.key.toLowerCase()]!)
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
if (next === null) return
|
|
275
|
+
e.preventDefault()
|
|
276
|
+
focusIdx.value = next
|
|
277
|
+
await nextTick()
|
|
278
|
+
rootEl.value?.querySelector<SVGElement>(`[data-tooth-index="${next}"]`)?.focus()
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function toothLabel(t: Tooth) {
|
|
282
|
+
const st = state(t)
|
|
283
|
+
const parts = [locale.odontoTooth.replace('{n}', t.label)]
|
|
284
|
+
for (const k of st.conditions ?? []) parts.push(condMap.value.get(k)?.label ?? k)
|
|
285
|
+
for (const [s, k] of Object.entries(st.surfaces ?? {})) parts.push(`${surfaceLabels.value[s as ToothSurface]}: ${condMap.value.get(k!)?.label ?? k}`)
|
|
286
|
+
return parts.join(', ')
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const SIDES: Exclude<Side, 'center'>[] = ['top', 'bottom', 'left', 'right']
|
|
290
|
+
</script>
|
|
291
|
+
|
|
292
|
+
<template>
|
|
293
|
+
<div ref="rootEl" class="m3-odontogram flex flex-col gap-3 text-on-surface">
|
|
294
|
+
<div v-if="!hideToolbar" class="flex flex-wrap gap-2" role="radiogroup" data-toolbar>
|
|
295
|
+
<slot name="toolbar" :conditions="conds" :tool="tool" :set-tool="setTool">
|
|
296
|
+
<button
|
|
297
|
+
v-for="c in conds"
|
|
298
|
+
:key="c.key"
|
|
299
|
+
v-ripple
|
|
300
|
+
type="button"
|
|
301
|
+
role="radio"
|
|
302
|
+
:aria-checked="tool === c.key"
|
|
303
|
+
class="relative flex h-8 items-center gap-2 overflow-hidden rounded-sm border px-3 text-label-large transition-colors"
|
|
304
|
+
:class="tool === c.key ? 'border-transparent bg-secondary-container text-on-secondary-container' : 'border-outline-variant text-on-surface-variant'"
|
|
305
|
+
:disabled="readonly"
|
|
306
|
+
:data-tool="c.key"
|
|
307
|
+
@click="setTool(c.key)"
|
|
308
|
+
>
|
|
309
|
+
<span class="h-3 w-3 shrink-0" :class="c.scope === 'surface' ? 'rounded-[2px]' : 'rounded-full border-2 bg-transparent'" :style="c.scope === 'surface' ? { background: c.color } : { borderColor: c.color }" />
|
|
310
|
+
{{ c.label }}
|
|
311
|
+
</button>
|
|
312
|
+
<button
|
|
313
|
+
v-ripple
|
|
314
|
+
type="button"
|
|
315
|
+
role="radio"
|
|
316
|
+
:aria-checked="tool === 'eraser'"
|
|
317
|
+
class="relative flex h-8 items-center gap-1 overflow-hidden rounded-sm border px-3 text-label-large transition-colors"
|
|
318
|
+
:class="tool === 'eraser' ? 'border-transparent bg-secondary-container text-on-secondary-container' : 'border-outline-variant text-on-surface-variant'"
|
|
319
|
+
:disabled="readonly"
|
|
320
|
+
data-tool="eraser"
|
|
321
|
+
@click="setTool('eraser')"
|
|
322
|
+
>
|
|
323
|
+
<MIcon name="ink_eraser" :size="18" />{{ locale.odontoEraser }}
|
|
324
|
+
</button>
|
|
325
|
+
</slot>
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
<div class="overflow-x-auto">
|
|
329
|
+
<svg :viewBox="`-2 0 ${width + 4} ${height}`" class="block w-full min-w-[34rem]" role="grid">
|
|
330
|
+
<line :x1="width / 2" :x2="width / 2" y1="0" :y2="height" class="stroke-outline-variant" stroke-dasharray="4 4" />
|
|
331
|
+
<line x1="0" :x2="width" :y1="rowH + 10" :y2="rowH + 10" class="stroke-outline-variant" stroke-dasharray="4 4" />
|
|
332
|
+
|
|
333
|
+
<g v-for="(row, ri) in rows" :key="ri" role="row" :aria-label="ri === 0 ? locale.odontoUpper : locale.odontoLower">
|
|
334
|
+
<g
|
|
335
|
+
v-for="(t, ti) in row"
|
|
336
|
+
:key="t.fdi"
|
|
337
|
+
role="gridcell"
|
|
338
|
+
class="m3-odontogram__tooth"
|
|
339
|
+
:class="{ 'is-missing': has(t, 'missing') }"
|
|
340
|
+
:transform="`translate(${xOf(ti)} ${yOf(t.upper)})`"
|
|
341
|
+
:tabindex="ri * row.length + ti === focusIdx ? 0 : -1"
|
|
342
|
+
:aria-label="toothLabel(t)"
|
|
343
|
+
:data-tooth="t.label"
|
|
344
|
+
:data-tooth-index="ri * row.length + ti"
|
|
345
|
+
@focus="focusIdx = ri * row.length + ti"
|
|
346
|
+
@keydown="onKeydown($event, ri * row.length + ti)"
|
|
347
|
+
>
|
|
348
|
+
<!-- root: drawn when a root condition is charted -->
|
|
349
|
+
<g :transform="t.upper ? `translate(0 ${-ROOT})` : `translate(0 ${BOX})`">
|
|
350
|
+
<path
|
|
351
|
+
v-if="has(t, 'implant')"
|
|
352
|
+
:d="t.upper ? 'M14 16 L16 2 H24 L26 16 Z' : 'M14 0 L16 14 H24 L26 0 Z'"
|
|
353
|
+
:fill="condMap.get('implant')?.color"
|
|
354
|
+
data-mark="implant"
|
|
355
|
+
/>
|
|
356
|
+
<g v-if="has(t, 'implant')" class="stroke-surface" stroke-width="1.5">
|
|
357
|
+
<line x1="15" x2="25" :y1="t.upper ? 6 : 4" :y2="t.upper ? 6 : 4" />
|
|
358
|
+
<line x1="15" x2="25" :y1="t.upper ? 10 : 8" :y2="t.upper ? 10 : 8" />
|
|
359
|
+
<line x1="15" x2="25" :y1="t.upper ? 14 : 12" :y2="t.upper ? 14 : 12" />
|
|
360
|
+
</g>
|
|
361
|
+
<line
|
|
362
|
+
v-if="has(t, 'rootCanal')"
|
|
363
|
+
x1="20"
|
|
364
|
+
x2="20"
|
|
365
|
+
:y1="t.upper ? 1 : 0"
|
|
366
|
+
:y2="t.upper ? 16 : 15"
|
|
367
|
+
:stroke="condMap.get('rootCanal')?.color"
|
|
368
|
+
stroke-width="4"
|
|
369
|
+
stroke-linecap="round"
|
|
370
|
+
data-mark="rootCanal"
|
|
371
|
+
/>
|
|
372
|
+
</g>
|
|
373
|
+
|
|
374
|
+
<polygon
|
|
375
|
+
v-for="s in SIDES"
|
|
376
|
+
:key="s"
|
|
377
|
+
:points="POLY[s]"
|
|
378
|
+
class="m3-odontogram__surface"
|
|
379
|
+
:style="surfaceColor(t, surfaceAt(t, s)) ? { fill: surfaceColor(t, surfaceAt(t, s)) } : undefined"
|
|
380
|
+
:data-surface="surfaceAt(t, s)"
|
|
381
|
+
@click="applySurface(t, surfaceAt(t, s))"
|
|
382
|
+
>
|
|
383
|
+
<title>{{ locale.odontoTooth.replace('{n}', t.label) }} · {{ surfaceLabels[surfaceAt(t, s)] }}</title>
|
|
384
|
+
</polygon>
|
|
385
|
+
<rect
|
|
386
|
+
x="12"
|
|
387
|
+
y="12"
|
|
388
|
+
width="16"
|
|
389
|
+
height="16"
|
|
390
|
+
class="m3-odontogram__surface"
|
|
391
|
+
:style="surfaceColor(t, 'occlusal') ? { fill: surfaceColor(t, 'occlusal') } : undefined"
|
|
392
|
+
data-surface="occlusal"
|
|
393
|
+
@click="applySurface(t, 'occlusal')"
|
|
394
|
+
>
|
|
395
|
+
<title>{{ locale.odontoTooth.replace('{n}', t.label) }} · {{ surfaceLabels.occlusal }}</title>
|
|
396
|
+
</rect>
|
|
397
|
+
|
|
398
|
+
<circle v-if="has(t, 'crown')" cx="20" cy="20" r="23" fill="none" :stroke="condMap.get('crown')?.color" stroke-width="2.5" pointer-events="none" data-mark="crown" />
|
|
399
|
+
<rect
|
|
400
|
+
v-for="(k, ki) in customToothConds(t)"
|
|
401
|
+
:key="k"
|
|
402
|
+
:x="-2 - ki * 3"
|
|
403
|
+
:y="-2 - ki * 3"
|
|
404
|
+
:width="44 + ki * 6"
|
|
405
|
+
:height="44 + ki * 6"
|
|
406
|
+
rx="3"
|
|
407
|
+
fill="none"
|
|
408
|
+
:stroke="condMap.get(k)?.color"
|
|
409
|
+
stroke-width="2"
|
|
410
|
+
pointer-events="none"
|
|
411
|
+
/>
|
|
412
|
+
<g v-if="has(t, 'missing') || has(t, 'extraction')" pointer-events="none" stroke-width="3" stroke-linecap="round" :data-mark="has(t, 'extraction') ? 'extraction' : 'missing'">
|
|
413
|
+
<line x1="2" y1="2" x2="38" y2="38" :stroke="condMap.get(has(t, 'extraction') ? 'extraction' : 'missing')?.color" />
|
|
414
|
+
<line x1="38" y1="2" x2="2" y2="38" :stroke="condMap.get(has(t, 'extraction') ? 'extraction' : 'missing')?.color" />
|
|
415
|
+
</g>
|
|
416
|
+
|
|
417
|
+
<!-- number: a button for whole-tooth conditions -->
|
|
418
|
+
<g
|
|
419
|
+
class="m3-odontogram__number cursor-pointer"
|
|
420
|
+
:transform="t.upper ? `translate(0 ${-ROOT - LABEL})` : `translate(0 ${BOX + ROOT})`"
|
|
421
|
+
data-number
|
|
422
|
+
@click="applyTooth(t)"
|
|
423
|
+
>
|
|
424
|
+
<rect x="4" y="1" width="32" height="14" rx="7" class="m3-odontogram__number-bg" />
|
|
425
|
+
<text x="20" y="12" text-anchor="middle" class="fill-on-surface-variant text-[10px] font-medium">{{ t.label }}</text>
|
|
426
|
+
</g>
|
|
427
|
+
</g>
|
|
428
|
+
</g>
|
|
429
|
+
</svg>
|
|
430
|
+
</div>
|
|
431
|
+
</div>
|
|
432
|
+
</template>
|
|
433
|
+
|
|
434
|
+
<style>
|
|
435
|
+
.m3-odontogram__surface {
|
|
436
|
+
fill: var(--color-surface-container-lowest);
|
|
437
|
+
stroke: var(--color-outline);
|
|
438
|
+
stroke-width: 1;
|
|
439
|
+
cursor: pointer;
|
|
440
|
+
transition: fill 120ms ease;
|
|
441
|
+
}
|
|
442
|
+
.m3-odontogram__surface:hover {
|
|
443
|
+
fill: color-mix(in srgb, var(--color-on-surface) 10%, var(--color-surface-container-lowest));
|
|
444
|
+
}
|
|
445
|
+
.m3-odontogram__tooth {
|
|
446
|
+
outline: none;
|
|
447
|
+
}
|
|
448
|
+
.m3-odontogram__tooth.is-missing .m3-odontogram__surface {
|
|
449
|
+
opacity: 0.35;
|
|
450
|
+
}
|
|
451
|
+
.m3-odontogram__tooth:focus-visible .m3-odontogram__number-bg {
|
|
452
|
+
fill: var(--color-secondary-container);
|
|
453
|
+
stroke: var(--color-secondary);
|
|
454
|
+
stroke-width: 2;
|
|
455
|
+
}
|
|
456
|
+
.m3-odontogram__number-bg {
|
|
457
|
+
fill: transparent;
|
|
458
|
+
}
|
|
459
|
+
.m3-odontogram__number:hover .m3-odontogram__number-bg {
|
|
460
|
+
fill: color-mix(in srgb, var(--color-on-surface) 8%, transparent);
|
|
461
|
+
}
|
|
462
|
+
</style>
|