@m3ui-vue/m3ui-vue 1.3.8 → 1.4.1

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.
Files changed (117) hide show
  1. package/dist/API.md +1102 -20
  2. package/dist/{MButton-D5eJiDza.js → MButton-DQMTIlaV.js} +2 -2
  3. package/dist/{MButton-D5eJiDza.js.map → MButton-DQMTIlaV.js.map} +1 -1
  4. package/dist/{MDialog-WqB0jewp.js → MDialog-cdgapGfZ.js} +2 -2
  5. package/dist/{MDialog-WqB0jewp.js.map → MDialog-cdgapGfZ.js.map} +1 -1
  6. package/dist/{MListItem-Cf-C2Ru-.js → MListItem-ZkSGIIrb.js} +2 -2
  7. package/dist/{MListItem-Cf-C2Ru-.js.map → MListItem-ZkSGIIrb.js.map} +1 -1
  8. package/dist/{MLoadingIndicator-D4GzEZoH.js → MLoadingIndicator-U6_oGx8z.js} +2 -2
  9. package/dist/{MLoadingIndicator-D4GzEZoH.js.map → MLoadingIndicator-U6_oGx8z.js.map} +1 -1
  10. package/dist/{MSeekBar-B19xoWE3.js → MSeekBar-DTZVizZg.js} +2 -2
  11. package/dist/{MSeekBar-B19xoWE3.js.map → MSeekBar-DTZVizZg.js.map} +1 -1
  12. package/dist/{MSlider-9RoiuebS.js → MSlider-CqJkEYRZ.js} +2 -2
  13. package/dist/{MSlider-9RoiuebS.js.map → MSlider-CqJkEYRZ.js.map} +1 -1
  14. package/dist/{MSpinner-BNF8MN-L.js → MSpinner-Btgc-0nb.js} +2 -2
  15. package/dist/{MSpinner-BNF8MN-L.js.map → MSpinner-Btgc-0nb.js.map} +1 -1
  16. package/dist/{MTextField-CuG0T3qh.js → MTextField-B6M0gJEO.js} +2 -2
  17. package/dist/{MTextField-CuG0T3qh.js.map → MTextField-B6M0gJEO.js.map} +1 -1
  18. package/dist/{MTooltip-Bv7yxngk.js → MTooltip-Dspji4XG.js} +4 -4
  19. package/dist/{MTooltip-Bv7yxngk.js.map → MTooltip-Dspji4XG.js.map} +1 -1
  20. package/dist/api.json +1 -1
  21. package/dist/code-editor.js +1 -1
  22. package/dist/components/MAudioPlayer.vue.d.ts +2 -2
  23. package/dist/components/MAvailabilityCalendar.vue.d.ts +83 -0
  24. package/dist/components/MBeforeAfter.vue.d.ts +61 -0
  25. package/dist/components/MBodyMap.vue.d.ts +70 -0
  26. package/dist/components/MCandlestickChart.vue.d.ts +82 -0
  27. package/dist/components/MCertificate.vue.d.ts +76 -0
  28. package/dist/components/MCountdown.vue.d.ts +80 -0
  29. package/dist/components/MCreditCardInput.vue.d.ts +75 -0
  30. package/dist/components/MMortgageCalculator.vue.d.ts +83 -0
  31. package/dist/components/MOdontogram.vue.d.ts +86 -0
  32. package/dist/components/MOrderBook.vue.d.ts +89 -0
  33. package/dist/components/MOrderTicket.vue.d.ts +91 -0
  34. package/dist/components/MPosKeypad.vue.d.ts +84 -0
  35. package/dist/components/MProductConfigurator.vue.d.ts +136 -0
  36. package/dist/components/MQuiz.vue.d.ts +102 -0
  37. package/dist/components/MReceipt.vue.d.ts +93 -0
  38. package/dist/components/MSeatMap.vue.d.ts +131 -0
  39. package/dist/components/MSeekBar.vue.d.ts +1 -1
  40. package/dist/components/MTicket.vue.d.ts +83 -0
  41. package/dist/components/MVideoPlayer.vue.d.ts +1 -1
  42. package/dist/components/MVitalsChart.vue.d.ts +73 -0
  43. package/dist/composables/_printElement.d.ts +9 -0
  44. package/dist/composables/cardBrand.d.ts +25 -0
  45. package/dist/composables/mortgage.d.ts +37 -0
  46. package/dist/composables/useLocale.d.ts +131 -0
  47. package/dist/draw.js +2 -2
  48. package/dist/flow.js +1 -1
  49. package/dist/gantt.js +1 -1
  50. package/dist/index.d.ts +37 -0
  51. package/dist/locales/index.js +924 -7
  52. package/dist/locales/index.js.map +1 -1
  53. package/dist/m3ui-vue.css +1 -1
  54. package/dist/m3ui.js +10125 -5263
  55. package/dist/m3ui.js.map +1 -1
  56. package/dist/map.js +5 -5
  57. package/dist/media.js +4 -4
  58. package/dist/pdf.js +4 -4
  59. package/dist/rich-text-editor.js +4 -4
  60. package/dist/styles.css +1 -1
  61. package/dist/{useLocale-D2ucaY-l.js → useLocale-DLKJIRFi.js} +133 -2
  62. package/dist/useLocale-DLKJIRFi.js.map +1 -0
  63. package/package.json +1 -1
  64. package/src/__tests__/MAvailabilityCalendar.test.ts +85 -0
  65. package/src/__tests__/MBeforeAfter.test.ts +79 -0
  66. package/src/__tests__/MBodyMap.test.ts +60 -0
  67. package/src/__tests__/MCandlestickChart.test.ts +66 -0
  68. package/src/__tests__/MCertificate.test.ts +32 -0
  69. package/src/__tests__/MCountdown.test.ts +75 -0
  70. package/src/__tests__/MCreditCardInput.test.ts +122 -0
  71. package/src/__tests__/MMortgageCalculator.test.ts +49 -0
  72. package/src/__tests__/MOdontogram.test.ts +93 -0
  73. package/src/__tests__/MOrderBook.test.ts +66 -0
  74. package/src/__tests__/MOrderTicket.test.ts +68 -0
  75. package/src/__tests__/MPosKeypad.test.ts +116 -0
  76. package/src/__tests__/MProductConfigurator.test.ts +73 -0
  77. package/src/__tests__/MQuiz.test.ts +104 -0
  78. package/src/__tests__/MReceipt.test.ts +52 -0
  79. package/src/__tests__/MSeatMap.test.ts +76 -0
  80. package/src/__tests__/MTicket.test.ts +38 -0
  81. package/src/__tests__/MVitalsChart.test.ts +49 -0
  82. package/src/__tests__/clearToNull.test.ts +30 -0
  83. package/src/__tests__/mortgage.test.ts +25 -0
  84. package/src/__tests__/ssr.test.ts +11 -0
  85. package/src/components/MAutocomplete.vue +2 -2
  86. package/src/components/MAvailabilityCalendar.vue +460 -0
  87. package/src/components/MBeforeAfter.vue +248 -0
  88. package/src/components/MBodyMap.vue +266 -0
  89. package/src/components/MCandlestickChart.vue +479 -0
  90. package/src/components/MCertificate.vue +351 -0
  91. package/src/components/MCountdown.vue +200 -0
  92. package/src/components/MCreditCardInput.vue +351 -0
  93. package/src/components/MMortgageCalculator.vue +258 -0
  94. package/src/components/MOdontogram.vue +462 -0
  95. package/src/components/MOrderBook.vue +287 -0
  96. package/src/components/MOrderTicket.vue +217 -0
  97. package/src/components/MPosKeypad.vue +406 -0
  98. package/src/components/MProductConfigurator.vue +412 -0
  99. package/src/components/MQuiz.vue +531 -0
  100. package/src/components/MReceipt.vue +249 -0
  101. package/src/components/MSeatMap.vue +431 -0
  102. package/src/components/MSelect.vue +2 -2
  103. package/src/components/MTicket.vue +209 -0
  104. package/src/components/MVitalsChart.vue +303 -0
  105. package/src/composables/_printElement.ts +36 -0
  106. package/src/composables/cardBrand.ts +104 -0
  107. package/src/composables/mortgage.ts +70 -0
  108. package/src/composables/useLocale.ts +277 -0
  109. package/src/index.ts +37 -0
  110. package/src/locales/de.ts +131 -0
  111. package/src/locales/es.ts +131 -0
  112. package/src/locales/fr.ts +131 -0
  113. package/src/locales/ja.ts +131 -0
  114. package/src/locales/ko.ts +131 -0
  115. package/src/locales/pt.ts +131 -0
  116. package/src/locales/zh.ts +131 -0
  117. package/dist/useLocale-D2ucaY-l.js.map +0 -1
@@ -0,0 +1,406 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * A large touch keypad for a point of sale, a kiosk or a cash drawer: amounts, quantities, a waiter's PIN. It
4
+ * shows the value formatted (with a currency when one is given), can enter amounts cash-register style (digits
5
+ * shift in from the right, `1` `2` `5` `0` → 12.50), offers quick-amount chips and, given the amount due, shows
6
+ * what's left to pay or the change to give back.
7
+ *
8
+ * Holding delete clears everything. With the keypad focused (or `keyboard="global"`), the physical keyboard works
9
+ * too: digits, `.`/`,`, Backspace, Escape to clear and Enter to submit.
10
+ *
11
+ * The value (v-model) is a plain decimal string ("12.50", or the digits of a PIN) so leading zeros survive.
12
+ *
13
+ * @slot display Replaces the value display. Slot props: `{ value, formatted, amount }`
14
+ * @slot action Replaces the submit button. Slot props: `{ value, amount, submit }`
15
+ * @event update:modelValue Emitted on every key — powers v-model
16
+ * @event submit Emitted by the action button or Enter, with the value
17
+ * @event key Emitted on every key press, with the key (`'0'`–`'9'`, `'00'`, `'.'`, `'backspace'`, `'clear'`)
18
+ */
19
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
20
+ import MIcon from './MIcon.vue'
21
+ import MButton from './MButton.vue'
22
+ import { vRipple } from '../directives/vRipple'
23
+ import { useLocale } from '../composables/useLocale'
24
+
25
+ const locale = useLocale()
26
+
27
+ const props = withDefaults(
28
+ defineProps<{
29
+ /** Value (v-model): a decimal string like "12.50", or a digit string in `pin` mode */
30
+ modelValue: string
31
+ /**
32
+ * What is typed: `amount` (decimals, currency formatting), `integer` (quantities, no decimals) or `pin`
33
+ * (digits shown as dots, leading zeros kept)
34
+ */
35
+ mode?: 'amount' | 'integer' | 'pin'
36
+ /** Decimal places of an amount */
37
+ decimals?: number
38
+ /**
39
+ * How an amount is entered: `free` (a decimal-point key) or `shift` (cash register: digits shift in from the
40
+ * right, with a `00` key instead of the point)
41
+ */
42
+ entry?: 'free' | 'shift'
43
+ /** ISO 4217 code (e.g. "USD", "ARS") to format the amount as money. Unset shows a plain number */
44
+ currency?: string
45
+ /** Largest amount accepted; keys that would pass it are ignored */
46
+ max?: number
47
+ /** Most digits accepted (a PIN's length, for one). With `pin` mode, filling it emits `submit` on its own */
48
+ maxLength?: number
49
+ /** Chips above the keys with preset amounts */
50
+ quickAmounts?: number[]
51
+ /** Whether a quick amount replaces the value or adds to it */
52
+ quickMode?: 'set' | 'add'
53
+ /** Amount due: shows the remaining amount under the value, or the change once it's covered */
54
+ due?: number
55
+ /** Label of the submit button. Without it (and without the `action` slot) there is no button */
56
+ actionLabel?: string
57
+ /** Material Symbol on the submit button */
58
+ actionIcon?: string
59
+ /** Disables the submit button. By default it's disabled while the value is empty or doesn't cover `due` */
60
+ actionDisabled?: boolean
61
+ /** Hides the value display (e.g. the value is shown elsewhere) */
62
+ hideDisplay?: boolean
63
+ /** Physical keyboard: while the keypad is focused, always (`global`), or never */
64
+ keyboard?: 'focus' | 'global' | 'none'
65
+ /** A short vibration on every key, on devices that support it */
66
+ haptics?: boolean
67
+ /** Disables every key */
68
+ disabled?: boolean
69
+ }>(),
70
+ {
71
+ mode: 'amount',
72
+ decimals: 2,
73
+ entry: 'free',
74
+ quickMode: 'set',
75
+ actionDisabled: undefined,
76
+ hideDisplay: false,
77
+ keyboard: 'focus',
78
+ haptics: false,
79
+ disabled: false,
80
+ },
81
+ )
82
+
83
+ const emit = defineEmits<{
84
+ 'update:modelValue': [string]
85
+ submit: [string]
86
+ key: [string]
87
+ }>()
88
+
89
+ const decimals = computed(() => (props.mode === 'amount' ? Math.max(0, props.decimals) : 0))
90
+ const shift = computed(() => props.mode === 'amount' && props.entry === 'shift' && decimals.value > 0)
91
+
92
+ /** The value as a number (NaN-safe) */
93
+ const amount = computed(() => {
94
+ const n = Number(props.modelValue)
95
+ return Number.isFinite(n) ? n : 0
96
+ })
97
+
98
+ type Key = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '00' | '.' | 'backspace' | 'clear'
99
+
100
+ const bottomLeft = computed<Key>(() => {
101
+ if (shift.value) return '00'
102
+ if (props.mode === 'amount' && decimals.value > 0) return '.'
103
+ return 'clear'
104
+ })
105
+
106
+ const keys = computed<Key[]>(() => ['1', '2', '3', '4', '5', '6', '7', '8', '9', bottomLeft.value, '0', 'backspace'])
107
+
108
+ function digitCount(v: string) {
109
+ return v.replace(/\D/g, '').length
110
+ }
111
+
112
+ function withinLimits(next: string) {
113
+ if (props.maxLength !== undefined && digitCount(next) > props.maxLength) return false
114
+ if (props.max !== undefined && props.mode !== 'pin' && Number(next) > props.max) return false
115
+ return true
116
+ }
117
+
118
+ // Cash-register entry: the value is its digits divided by 10^decimals
119
+ function shiftValue(digits: string) {
120
+ const trimmed = digits.replace(/^0+/, '')
121
+ if (!trimmed) return ''
122
+ return (Number(trimmed) / 10 ** decimals.value).toFixed(decimals.value)
123
+ }
124
+
125
+ function apply(key: Key): string {
126
+ const v = props.modelValue ?? ''
127
+ if (key === 'clear') return ''
128
+ if (shift.value) {
129
+ const digits = v.replace(/\D/g, '').replace(/^0+/, '')
130
+ if (key === 'backspace') return shiftValue(digits.slice(0, -1))
131
+ if (key === '.') return v
132
+ return shiftValue(digits + key)
133
+ }
134
+ if (key === 'backspace') {
135
+ const next = v.slice(0, -1)
136
+ return next === '0' && props.mode !== 'pin' ? '' : next
137
+ }
138
+ if (key === '.') {
139
+ if (decimals.value === 0 || v.includes('.')) return v
140
+ return (v || '0') + '.'
141
+ }
142
+ const digits = key
143
+ if (props.mode !== 'pin') {
144
+ // No leading zeros on a number
145
+ if (v === '0') return digits === '00' ? v : digits.replace(/^0+(?=\d)/, '')
146
+ if (!v && digits === '00') return '0'
147
+ const dot = v.indexOf('.')
148
+ if (dot >= 0) {
149
+ const room = decimals.value - (v.length - dot - 1)
150
+ if (room <= 0) return v
151
+ return v + digits.slice(0, room)
152
+ }
153
+ }
154
+ return v + digits
155
+ }
156
+
157
+ function press(key: Key) {
158
+ if (props.disabled) return
159
+ emit('key', key)
160
+ if (props.haptics) navigator.vibrate?.(8)
161
+ const next = apply(key)
162
+ if (next === props.modelValue) return
163
+ if (key !== 'backspace' && key !== 'clear' && !withinLimits(next)) return
164
+ emit('update:modelValue', next)
165
+ if (props.mode === 'pin' && props.maxLength !== undefined && next.length === props.maxLength) emit('submit', next)
166
+ }
167
+
168
+ // ── Display ─────────────────────────────────────────────────────────────
169
+
170
+ function formatAmount(value: string, fractionDigits?: number) {
171
+ const hasDot = value.includes('.')
172
+ const frac = hasDot ? value.split('.')[1] ?? '' : ''
173
+ const minFrac = fractionDigits ?? (shift.value ? decimals.value : frac.length)
174
+ const opts: Intl.NumberFormatOptions = {
175
+ minimumFractionDigits: minFrac,
176
+ maximumFractionDigits: Math.max(minFrac, fractionDigits ?? 0),
177
+ }
178
+ if (props.currency) Object.assign(opts, { style: 'currency', currency: props.currency })
179
+ let parts: Intl.NumberFormatPart[]
180
+ try {
181
+ parts = new Intl.NumberFormat(locale.lang, opts).formatToParts(Number(value || 0))
182
+ } catch {
183
+ return value || '0'
184
+ }
185
+ // "12." while typing: Intl drops a point with no digits after it, so put it back
186
+ if (hasDot && minFrac === 0 && fractionDigits === undefined) {
187
+ const sep = new Intl.NumberFormat(locale.lang).formatToParts(1.1).find((p) => p.type === 'decimal')?.value ?? '.'
188
+ const lastInt = parts.map((p) => p.type).lastIndexOf('integer')
189
+ parts.splice(lastInt + 1, 0, { type: 'decimal', value: sep })
190
+ }
191
+ return parts.map((p) => p.value).join('')
192
+ }
193
+
194
+ const formatted = computed(() => {
195
+ if (props.mode === 'pin') return props.modelValue
196
+ return formatAmount(props.modelValue ?? '')
197
+ })
198
+
199
+ const pinSlots = computed(() => {
200
+ const len = props.maxLength ?? Math.max(4, props.modelValue.length)
201
+ return Array.from({ length: len }, (_, i) => i < props.modelValue.length)
202
+ })
203
+
204
+ const balance = computed(() => {
205
+ if (props.due === undefined || props.mode === 'pin') return null
206
+ const diff = amount.value - props.due
207
+ const value = formatAmount(String(Math.abs(Math.round(diff * 10 ** decimals.value) / 10 ** decimals.value)), decimals.value)
208
+ return diff >= 0
209
+ ? { label: locale.keypadChange, value, covered: true }
210
+ : { label: locale.keypadRemaining, value, covered: false }
211
+ })
212
+
213
+ const actionIsDisabled = computed(() => {
214
+ if (props.disabled) return true
215
+ if (props.actionDisabled !== undefined) return props.actionDisabled
216
+ if (!props.modelValue) return true
217
+ return props.due !== undefined && amount.value < props.due
218
+ })
219
+
220
+ function submit() {
221
+ if (actionIsDisabled.value && (props.actionLabel || props.actionDisabled !== undefined)) return
222
+ emit('submit', props.modelValue)
223
+ }
224
+
225
+ function quick(n: number) {
226
+ if (props.disabled) return
227
+ const next = props.quickMode === 'add' ? amount.value + n : n
228
+ const capped = props.max !== undefined ? Math.min(props.max, next) : next
229
+ const v = decimals.value > 0 && (shift.value || !Number.isInteger(capped)) ? capped.toFixed(decimals.value) : String(capped)
230
+ emit('update:modelValue', v)
231
+ }
232
+
233
+ // ── Long press on delete clears ─────────────────────────────────────────
234
+
235
+ let holdTimer: ReturnType<typeof setTimeout> | null = null
236
+ let held = false
237
+
238
+ function onDeleteDown(e: PointerEvent) {
239
+ if (e.button > 0 || props.disabled) return
240
+ held = false
241
+ holdTimer = setTimeout(() => {
242
+ held = true
243
+ press('clear')
244
+ }, 500)
245
+ }
246
+ function cancelHold() {
247
+ if (holdTimer) clearTimeout(holdTimer)
248
+ holdTimer = null
249
+ }
250
+ function onKeyClick(key: Key) {
251
+ if (key === 'backspace' && held) {
252
+ held = false
253
+ return
254
+ }
255
+ press(key)
256
+ }
257
+
258
+ // ── Physical keyboard ───────────────────────────────────────────────────
259
+
260
+ const rootEl = ref<HTMLElement | null>(null)
261
+
262
+ function onKeydown(e: KeyboardEvent) {
263
+ if (props.disabled || e.ctrlKey || e.metaKey || e.altKey) return
264
+ let key: Key | 'enter' | null = null
265
+ if (/^[0-9]$/.test(e.key)) key = e.key as Key
266
+ else if (e.key === '.' || e.key === ',') key = '.'
267
+ else if (e.key === 'Backspace') key = 'backspace'
268
+ else if (e.key === 'Escape' || e.key === 'Delete') key = 'clear'
269
+ else if (e.key === 'Enter') key = 'enter'
270
+ if (!key) return
271
+ // Let a focused key button handle its own Enter/Space click
272
+ if (key === 'enter' && (e.target as HTMLElement)?.closest?.('button')) return
273
+ e.preventDefault()
274
+ if (key === 'enter') submit()
275
+ else press(key)
276
+ }
277
+
278
+ function onGlobalKeydown(e: KeyboardEvent) {
279
+ const t = e.target as HTMLElement | null
280
+ // Never steal typing from a real field
281
+ if (t?.closest?.('input, textarea, select, [contenteditable]')) return
282
+ if (rootEl.value?.contains(t)) return // handled by the root listener
283
+ onKeydown(e)
284
+ }
285
+
286
+ function bindGlobal(on: boolean) {
287
+ if (typeof window === 'undefined') return
288
+ if (on) window.addEventListener('keydown', onGlobalKeydown)
289
+ else window.removeEventListener('keydown', onGlobalKeydown)
290
+ }
291
+ onMounted(() => bindGlobal(props.keyboard === 'global'))
292
+ watch(() => props.keyboard, (k, old) => {
293
+ if (old === 'global') bindGlobal(false)
294
+ if (k === 'global') bindGlobal(true)
295
+ })
296
+ onBeforeUnmount(() => {
297
+ bindGlobal(false)
298
+ cancelHold()
299
+ })
300
+
301
+ function keyLabel(key: Key) {
302
+ if (key === '.') {
303
+ return new Intl.NumberFormat(locale.lang).formatToParts(1.1).find((p) => p.type === 'decimal')?.value ?? '.'
304
+ }
305
+ return key
306
+ }
307
+ </script>
308
+
309
+ <template>
310
+ <div
311
+ ref="rootEl"
312
+ class="m3-pos-keypad flex flex-col gap-3 outline-none"
313
+ :tabindex="keyboard === 'none' || disabled ? undefined : 0"
314
+ @keydown="keyboard !== 'none' && onKeydown($event)"
315
+ >
316
+ <div v-if="!hideDisplay" class="flex flex-col items-end gap-1 px-2" aria-live="polite">
317
+ <slot name="display" :value="modelValue" :formatted="formatted" :amount="amount">
318
+ <div v-if="mode === 'pin'" class="flex h-14 w-full items-center justify-center gap-3" :aria-label="`${modelValue.length}/${pinSlots.length}`">
319
+ <span
320
+ v-for="(filled, i) in pinSlots"
321
+ :key="i"
322
+ class="h-4 w-4 rounded-full transition-[background-color,transform] duration-150"
323
+ :class="filled ? 'scale-110 bg-primary' : 'bg-outline-variant'"
324
+ />
325
+ </div>
326
+ <div
327
+ v-else
328
+ class="max-w-full truncate text-display-medium tabular-nums"
329
+ :class="[modelValue ? 'text-on-surface' : 'text-on-surface-variant', disabled ? 'opacity-38' : '']"
330
+ >{{ formatted }}</div>
331
+ </slot>
332
+ <div v-if="balance" class="text-title-medium tabular-nums" :class="balance.covered ? 'text-primary' : 'text-on-surface-variant'">
333
+ {{ balance.label }}: {{ balance.value }}
334
+ </div>
335
+ </div>
336
+
337
+ <div v-if="quickAmounts?.length && mode !== 'pin'" class="flex flex-wrap justify-center gap-2">
338
+ <button
339
+ v-for="q in quickAmounts"
340
+ :key="q"
341
+ v-ripple="{ disabled }"
342
+ type="button"
343
+ :disabled="disabled"
344
+ class="relative h-8 cursor-pointer overflow-hidden rounded-sm border border-outline-variant px-4 text-label-large text-on-surface-variant transition-colors hover:bg-on-surface-variant/8 disabled:cursor-not-allowed disabled:opacity-38"
345
+ @click="quick(q)"
346
+ >{{ quickMode === 'add' ? '+' : '' }}{{ formatAmount(String(q), Number.isInteger(q) ? 0 : decimals) }}</button>
347
+ </div>
348
+
349
+ <div class="grid grid-cols-3 gap-2" role="group">
350
+ <button
351
+ v-for="key in keys"
352
+ :key="key"
353
+ v-ripple="{ disabled }"
354
+ type="button"
355
+ tabindex="-1"
356
+ :disabled="disabled"
357
+ :aria-label="key === 'backspace' ? locale.keypadDelete : key === 'clear' ? locale.keypadClear : undefined"
358
+ :title="key === 'backspace' ? locale.keypadDelete : undefined"
359
+ :data-key="key"
360
+ class="m3-pos-key relative flex h-16 cursor-pointer items-center justify-center overflow-hidden text-headline-small tabular-nums transition-[border-radius,background-color] duration-150 disabled:cursor-not-allowed disabled:opacity-38"
361
+ :class="key === 'backspace' || key === 'clear'
362
+ ? 'bg-secondary-container text-on-secondary-container'
363
+ : 'bg-surface-container-highest text-on-surface'"
364
+ @click="onKeyClick(key)"
365
+ @pointerdown="key === 'backspace' && onDeleteDown($event)"
366
+ @pointerup="cancelHold"
367
+ @pointerleave="cancelHold"
368
+ @pointercancel="cancelHold"
369
+ @contextmenu.prevent
370
+ >
371
+ <MIcon v-if="key === 'backspace'" name="backspace" :size="28" />
372
+ <span v-else-if="key === 'clear'" class="text-title-large">C</span>
373
+ <span v-else>{{ keyLabel(key) }}</span>
374
+ </button>
375
+ </div>
376
+
377
+ <slot name="action" :value="modelValue" :amount="amount" :submit="submit">
378
+ <MButton
379
+ v-if="actionLabel"
380
+ size="md"
381
+ class="w-full"
382
+ :icon="actionIcon"
383
+ :disabled="actionIsDisabled"
384
+ @click="submit"
385
+ >{{ actionLabel }}</MButton>
386
+ </slot>
387
+ </div>
388
+ </template>
389
+
390
+ <style>
391
+ .m3-pos-key {
392
+ border-radius: var(--radius-xl, 1.75rem);
393
+ }
394
+ .m3-pos-key:not(:disabled):hover {
395
+ background-image: linear-gradient(color-mix(in srgb, currentColor 8%, transparent), color-mix(in srgb, currentColor 8%, transparent));
396
+ }
397
+ .m3-pos-key:not(:disabled):active {
398
+ border-radius: var(--radius-md, 0.75rem);
399
+ background-image: linear-gradient(color-mix(in srgb, currentColor 10%, transparent), color-mix(in srgb, currentColor 10%, transparent));
400
+ }
401
+ .m3-pos-keypad:focus-visible {
402
+ outline: 3px solid var(--color-secondary);
403
+ outline-offset: 4px;
404
+ border-radius: var(--radius-md, 0.75rem);
405
+ }
406
+ </style>