@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.
Files changed (111) hide show
  1. package/dist/API.md +1058 -18
  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/MCreditCardInput.vue.d.ts +75 -0
  29. package/dist/components/MMortgageCalculator.vue.d.ts +83 -0
  30. package/dist/components/MOdontogram.vue.d.ts +86 -0
  31. package/dist/components/MOrderBook.vue.d.ts +89 -0
  32. package/dist/components/MOrderTicket.vue.d.ts +91 -0
  33. package/dist/components/MPosKeypad.vue.d.ts +84 -0
  34. package/dist/components/MProductConfigurator.vue.d.ts +136 -0
  35. package/dist/components/MQuiz.vue.d.ts +102 -0
  36. package/dist/components/MReceipt.vue.d.ts +93 -0
  37. package/dist/components/MSeatMap.vue.d.ts +131 -0
  38. package/dist/components/MSeekBar.vue.d.ts +1 -1
  39. package/dist/components/MTicket.vue.d.ts +83 -0
  40. package/dist/components/MVideoPlayer.vue.d.ts +1 -1
  41. package/dist/components/MVitalsChart.vue.d.ts +73 -0
  42. package/dist/composables/_printElement.d.ts +9 -0
  43. package/dist/composables/cardBrand.d.ts +25 -0
  44. package/dist/composables/mortgage.d.ts +37 -0
  45. package/dist/composables/useLocale.d.ts +131 -0
  46. package/dist/draw.js +2 -2
  47. package/dist/flow.js +1 -1
  48. package/dist/gantt.js +1 -1
  49. package/dist/index.d.ts +35 -0
  50. package/dist/locales/index.js +924 -7
  51. package/dist/locales/index.js.map +1 -1
  52. package/dist/m3ui-vue.css +1 -1
  53. package/dist/m3ui.js +8264 -3553
  54. package/dist/m3ui.js.map +1 -1
  55. package/dist/map.js +5 -5
  56. package/dist/media.js +4 -4
  57. package/dist/pdf.js +4 -4
  58. package/dist/rich-text-editor.js +4 -4
  59. package/dist/styles.css +1 -1
  60. package/dist/{useLocale-D2ucaY-l.js → useLocale-DLKJIRFi.js} +133 -2
  61. package/dist/useLocale-DLKJIRFi.js.map +1 -0
  62. package/package.json +1 -1
  63. package/src/__tests__/MAvailabilityCalendar.test.ts +85 -0
  64. package/src/__tests__/MBeforeAfter.test.ts +79 -0
  65. package/src/__tests__/MBodyMap.test.ts +60 -0
  66. package/src/__tests__/MCandlestickChart.test.ts +66 -0
  67. package/src/__tests__/MCertificate.test.ts +32 -0
  68. package/src/__tests__/MCreditCardInput.test.ts +122 -0
  69. package/src/__tests__/MMortgageCalculator.test.ts +49 -0
  70. package/src/__tests__/MOdontogram.test.ts +93 -0
  71. package/src/__tests__/MOrderBook.test.ts +66 -0
  72. package/src/__tests__/MOrderTicket.test.ts +68 -0
  73. package/src/__tests__/MPosKeypad.test.ts +116 -0
  74. package/src/__tests__/MProductConfigurator.test.ts +73 -0
  75. package/src/__tests__/MQuiz.test.ts +104 -0
  76. package/src/__tests__/MReceipt.test.ts +52 -0
  77. package/src/__tests__/MSeatMap.test.ts +76 -0
  78. package/src/__tests__/MTicket.test.ts +38 -0
  79. package/src/__tests__/MVitalsChart.test.ts +49 -0
  80. package/src/__tests__/mortgage.test.ts +25 -0
  81. package/src/__tests__/ssr.test.ts +11 -0
  82. package/src/components/MAvailabilityCalendar.vue +460 -0
  83. package/src/components/MBeforeAfter.vue +248 -0
  84. package/src/components/MBodyMap.vue +266 -0
  85. package/src/components/MCandlestickChart.vue +479 -0
  86. package/src/components/MCertificate.vue +351 -0
  87. package/src/components/MCreditCardInput.vue +351 -0
  88. package/src/components/MMortgageCalculator.vue +258 -0
  89. package/src/components/MOdontogram.vue +462 -0
  90. package/src/components/MOrderBook.vue +287 -0
  91. package/src/components/MOrderTicket.vue +217 -0
  92. package/src/components/MPosKeypad.vue +406 -0
  93. package/src/components/MProductConfigurator.vue +412 -0
  94. package/src/components/MQuiz.vue +531 -0
  95. package/src/components/MReceipt.vue +249 -0
  96. package/src/components/MSeatMap.vue +431 -0
  97. package/src/components/MTicket.vue +209 -0
  98. package/src/components/MVitalsChart.vue +303 -0
  99. package/src/composables/_printElement.ts +36 -0
  100. package/src/composables/cardBrand.ts +104 -0
  101. package/src/composables/mortgage.ts +70 -0
  102. package/src/composables/useLocale.ts +277 -0
  103. package/src/index.ts +35 -0
  104. package/src/locales/de.ts +131 -0
  105. package/src/locales/es.ts +131 -0
  106. package/src/locales/fr.ts +131 -0
  107. package/src/locales/ja.ts +131 -0
  108. package/src/locales/ko.ts +131 -0
  109. package/src/locales/pt.ts +131 -0
  110. package/src/locales/zh.ts +131 -0
  111. package/dist/useLocale-D2ucaY-l.js.map +0 -1
@@ -0,0 +1,85 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MAvailabilityCalendar from '../components/MAvailabilityCalendar.vue'
4
+
5
+ type Range = [string | null, string | null]
6
+
7
+ const base = {
8
+ min: '2026-12-01',
9
+ months: 1,
10
+ firstDayOfWeek: 1,
11
+ prices: (d: string) => (d.endsWith('-05') ? 200 : 100),
12
+ unavailable: ['2026-12-10', '2026-12-11'],
13
+ }
14
+
15
+ function setup(extra: Record<string, unknown> = {}) {
16
+ const w = mount(MAvailabilityCalendar, {
17
+ props: {
18
+ ...base,
19
+ modelValue: [null, null] as Range,
20
+ 'onUpdate:modelValue': (v: Range) => w.setProps({ modelValue: v }),
21
+ ...extra,
22
+ },
23
+ })
24
+ return w
25
+ }
26
+ const day = (w: ReturnType<typeof setup>, d: string) => w.find(`[data-date="2026-12-${d}"]`)
27
+ const state = (w: ReturnType<typeof setup>, d: string) => day(w, d).element.parentElement!.dataset.state
28
+
29
+ describe('MAvailabilityCalendar', () => {
30
+ it('lays out the month from the first day of the week', () => {
31
+ const w = setup()
32
+ // Dec 1 2026 is a Tuesday: one blank before it with Monday first
33
+ const cells = w.findAll('[role="gridcell"]')
34
+ expect(cells[0]!.find('button').exists()).toBe(false)
35
+ expect(cells[1]!.find('button').attributes('data-date')).toBe('2026-12-01')
36
+ })
37
+
38
+ it('picks a stay and sums the nights', async () => {
39
+ const w = setup()
40
+ await day(w, '04').trigger('click')
41
+ expect(w.props('modelValue')).toEqual(['2026-12-04', null])
42
+ await day(w, '07').trigger('click')
43
+ expect(w.props('modelValue')).toEqual(['2026-12-04', '2026-12-07'])
44
+ expect(w.emitted('change')![0]![0]).toEqual({ start: '2026-12-04', end: '2026-12-07', nights: 3, total: 400 })
45
+ expect(state(w, '05')).toBe('range')
46
+ expect(w.find('[data-summary]').text()).toContain('3 nights')
47
+ })
48
+
49
+ it('lets a stay end on the morning a booked night starts, not run over it', async () => {
50
+ const w = setup()
51
+ await day(w, '08').trigger('click')
52
+ expect(state(w, '10')).toBe('checkout-only')
53
+ expect(state(w, '11')).toBe('booked')
54
+ expect(state(w, '13')).toBe('disabled')
55
+ await day(w, '13').trigger('click')
56
+ expect(w.props('modelValue')).toEqual(['2026-12-08', null])
57
+ await day(w, '10').trigger('click')
58
+ expect(w.props('modelValue')).toEqual(['2026-12-08', '2026-12-10'])
59
+ })
60
+
61
+ it('blocks booked nights and check-ins that cannot fit the minimum stay', async () => {
62
+ const w = setup({ minNights: 3 })
63
+ expect(state(w, '10')).toBe('booked')
64
+ expect(state(w, '08')).toBe('disabled')
65
+ expect(state(w, '07')).toBe('available')
66
+ await day(w, '07').trigger('click')
67
+ expect(state(w, '08')).toBe('disabled')
68
+ expect(state(w, '10')).toBe('checkout-only')
69
+ expect(w.text()).toContain('Minimum stay: 3 nights')
70
+ })
71
+
72
+ it('picking an earlier day restarts the stay', async () => {
73
+ const w = setup()
74
+ await day(w, '06').trigger('click')
75
+ await day(w, '03').trigger('click')
76
+ expect(w.props('modelValue')).toEqual(['2026-12-03', null])
77
+ })
78
+
79
+ it('moves focus with the arrow keys across months', async () => {
80
+ const w = setup({ modelValue: ['2026-12-31', null] as Range })
81
+ await day(w, '31').trigger('keydown', { key: 'ArrowRight' })
82
+ expect(w.find('[data-date="2027-01-01"]').exists()).toBe(true)
83
+ expect(w.find('h3').text()).toMatch(/january 2027/i)
84
+ })
85
+ })
@@ -0,0 +1,79 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MBeforeAfter from '../components/MBeforeAfter.vue'
4
+
5
+ function mockRect(el: Element, width = 200, height = 100) {
6
+ el.getBoundingClientRect = () =>
7
+ ({ left: 0, top: 0, right: width, bottom: height, width, height, x: 0, y: 0 }) as DOMRect
8
+ }
9
+
10
+ function pointer(type: string, init: Partial<PointerEventInit>) {
11
+ return new PointerEvent(type, { bubbles: true, pointerId: 1, button: 0, pointerType: 'mouse', ...init })
12
+ }
13
+
14
+ describe('MBeforeAfter', () => {
15
+ it('clips the before layer at the position', () => {
16
+ const w = mount(MBeforeAfter, { props: { modelValue: 30, before: 'a.jpg', after: 'b.jpg' } })
17
+ const clipped = w.findAll('div').find((d) => d.attributes('style')?.includes('clip-path'))
18
+ expect(clipped?.attributes('style')).toContain('inset(0 70% 0 0)')
19
+ })
20
+
21
+ it('moves the split to the pointer and follows the drag', async () => {
22
+ const w = mount(MBeforeAfter, { props: { before: 'a.jpg', after: 'b.jpg' } })
23
+ mockRect(w.element)
24
+ w.element.dispatchEvent(pointer('pointerdown', { clientX: 50 }))
25
+ w.element.dispatchEvent(pointer('pointermove', { clientX: 150 }))
26
+ w.element.dispatchEvent(pointer('pointerup', { clientX: 150 }))
27
+ expect(w.emitted('update:modelValue')).toEqual([[25], [75]])
28
+ expect(w.emitted('change')).toEqual([[75]])
29
+ })
30
+
31
+ it('uses the vertical axis', async () => {
32
+ const w = mount(MBeforeAfter, { props: { orientation: 'vertical' } })
33
+ mockRect(w.element)
34
+ w.element.dispatchEvent(pointer('pointerdown', { clientY: 20 }))
35
+ expect(w.emitted('update:modelValue')?.[0]).toEqual([20])
36
+ })
37
+
38
+ it('follows a hovering mouse only with hover', async () => {
39
+ const w = mount(MBeforeAfter)
40
+ mockRect(w.element)
41
+ w.element.dispatchEvent(pointer('pointermove', { clientX: 40 }))
42
+ expect(w.emitted('update:modelValue')).toBeUndefined()
43
+ await w.setProps({ hover: true })
44
+ w.element.dispatchEvent(pointer('pointermove', { clientX: 40 }))
45
+ expect(w.emitted('update:modelValue')?.[0]).toEqual([20])
46
+ })
47
+
48
+ it('steps with the keyboard and clamps', async () => {
49
+ const w = mount(MBeforeAfter, { props: { modelValue: 50 } })
50
+ const slider = w.find('[role="slider"]')
51
+ await slider.trigger('keydown', { key: 'ArrowRight' })
52
+ await w.setProps({ modelValue: 51 })
53
+ await slider.trigger('keydown', { key: 'PageDown' })
54
+ await w.setProps({ modelValue: 41 })
55
+ await slider.trigger('keydown', { key: 'End' })
56
+ expect(w.emitted('update:modelValue')).toEqual([[51], [41], [100]])
57
+ expect(slider.attributes('aria-valuenow')).toBe('100')
58
+ })
59
+
60
+ it('ignores input when disabled', async () => {
61
+ const w = mount(MBeforeAfter, { props: { disabled: true } })
62
+ mockRect(w.element)
63
+ w.element.dispatchEvent(pointer('pointerdown', { clientX: 10 }))
64
+ await w.find('[role="slider"]').trigger('keydown', { key: 'Home' })
65
+ expect(w.emitted('update:modelValue')).toBeUndefined()
66
+ })
67
+
68
+ it('hides a label given as an empty string', () => {
69
+ const w = mount(MBeforeAfter, { props: { beforeLabel: '', afterLabel: 'Now' } })
70
+ expect(w.text()).not.toContain('Before')
71
+ expect(w.text()).toContain('Now')
72
+ })
73
+
74
+ it('has no position utility on its root', () => {
75
+ const w = mount(MBeforeAfter)
76
+ expect(w.classes()).not.toContain('relative')
77
+ expect(w.classes()).toContain('m3-before-after')
78
+ })
79
+ })
@@ -0,0 +1,60 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MBodyMap from '../components/MBodyMap.vue'
4
+ import type { BodyMapValue } from '../components/MBodyMap.vue'
5
+
6
+ function setup(extra: Record<string, unknown> = {}) {
7
+ const w = mount(MBodyMap, {
8
+ props: { modelValue: {} as BodyMapValue, 'onUpdate:modelValue': (v: BodyMapValue) => w.setProps({ modelValue: v }), ...extra },
9
+ })
10
+ return w
11
+ }
12
+
13
+ describe('MBodyMap', () => {
14
+ it('draws front and back with the patient’s sides', () => {
15
+ const w = setup()
16
+ expect(w.findAll('[data-view="front"] [data-region]')).toHaveLength(22)
17
+ expect(w.findAll('[data-view="back"] [data-region]')).toHaveLength(23)
18
+ // On the front view, the patient's right shoulder is on the viewer's left
19
+ const right = w.find('[data-region="shoulder-right"]')
20
+ expect(Number(right.attributes('cx'))).toBeLessThan(100)
21
+ expect(right.attributes('aria-label')).toBe('Shoulder, right')
22
+ // On the back view it is on the viewer's right
23
+ expect(Number(w.find('[data-region="back-shoulder-right"]').attributes('cx'))).toBeGreaterThan(100)
24
+ expect(w.find('[data-region="back-shoulder-right"]').attributes('aria-label')).toBe('Shoulder, right (back)')
25
+ expect(w.find('[data-region="back-lower-back"]').attributes('aria-label')).toBe('Lower back')
26
+ })
27
+
28
+ it('toggles a region with one level', async () => {
29
+ const w = setup()
30
+ await w.find('[data-region="knee-left"]').trigger('click')
31
+ expect(w.props('modelValue')).toEqual({ 'knee-left': 1 })
32
+ expect(w.emitted('select')![0]![0]).toMatchObject({ id: 'knee-left', level: 1, view: 'front' })
33
+ await w.find('[data-region="knee-left"]').trigger('click')
34
+ expect(w.props('modelValue')).toEqual({})
35
+ })
36
+
37
+ it('cycles through levels and sets one with the number keys', async () => {
38
+ const w = setup({ levels: 3, levelLabels: ['Mild', 'Moderate', 'Severe'] })
39
+ const head = () => w.find('[data-region="head"]')
40
+ await head().trigger('click')
41
+ await head().trigger('click')
42
+ expect(w.props('modelValue')).toEqual({ head: 2 })
43
+ expect(head().attributes('aria-label')).toBe('Head: Moderate')
44
+ await head().trigger('keydown', { key: '3' })
45
+ expect(w.props('modelValue')).toEqual({ head: 3 })
46
+ await head().trigger('click')
47
+ expect(w.props('modelValue')).toEqual({})
48
+ expect(w.find('[data-legend]').text()).toContain('Severe')
49
+ })
50
+
51
+ it('respects readonly, disabled regions and a single view', async () => {
52
+ const w = setup({ view: 'back', disabledRegions: ['back-head'] })
53
+ expect(w.find('[data-view="front"]').exists()).toBe(false)
54
+ await w.find('[data-region="back-head"]').trigger('click')
55
+ expect(w.emitted('update:modelValue')).toBeUndefined()
56
+ await w.setProps({ readonly: true })
57
+ await w.find('[data-region="back-neck"]').trigger('click')
58
+ expect(w.emitted('update:modelValue')).toBeUndefined()
59
+ })
60
+ })
@@ -0,0 +1,66 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MCandlestickChart from '../components/MCandlestickChart.vue'
4
+
5
+ function series(n: number) {
6
+ return Array.from({ length: n }, (_, i) => {
7
+ const open = 100 + i
8
+ const close = i % 2 ? open - 2 : open + 3
9
+ return { time: Date.UTC(2026, 0, 1 + i), open, high: Math.max(open, close) + 1, low: Math.min(open, close) - 1, close, volume: 1000 + i }
10
+ })
11
+ }
12
+
13
+ function rect(w: ReturnType<typeof mount>) {
14
+ ;(w.element as HTMLElement).getBoundingClientRect = () => ({ left: 0, top: 0, right: 664, bottom: 320, width: 664, height: 320, x: 0, y: 0, toJSON() {} })
15
+ }
16
+
17
+ describe('MCandlestickChart', () => {
18
+ it('draws rising and falling candles in separate paths', () => {
19
+ const w = mount(MCandlestickChart, { props: { data: series(10) } })
20
+ expect(w.find('[data-candles="up"]').attributes('d')).toMatch(/^M/)
21
+ expect(w.find('[data-candles="down"]').attributes('d')).toMatch(/^M/)
22
+ // 5 up candles: a wick and a body each
23
+ expect((w.find('[data-candles="up"]').attributes('d')!.match(/V/g) ?? []).length).toBe(5)
24
+ })
25
+
26
+ it('shows the last candle in the legend and the last price', () => {
27
+ const w = mount(MCandlestickChart, { props: { data: series(3) } })
28
+ // last candle: open 102, close 105
29
+ expect(w.find('[data-legend]').text()).toContain('Close 105.00')
30
+ expect(w.find('[data-last-price]').text()).toBe('105.00')
31
+ })
32
+
33
+ it('draws moving averages once there are enough candles', () => {
34
+ const w = mount(MCandlestickChart, { props: { data: series(30), movingAverages: [5, 50] } })
35
+ expect(w.find('[data-ma="5"]').attributes('d')).toMatch(/^M/)
36
+ expect(w.find('[data-ma="50"]').attributes('d')).toBe('')
37
+ })
38
+
39
+ it('moves the crosshair with the keyboard and emits hover', async () => {
40
+ const data = series(10)
41
+ const w = mount(MCandlestickChart, { props: { data } })
42
+ await w.trigger('keydown', { key: 'ArrowLeft' })
43
+ expect(w.emitted('hover')![0]![0]).toEqual(data[8])
44
+ expect(w.find('[data-legend]').text()).toContain('Close 111.00')
45
+ await w.trigger('keydown', { key: 'Escape' })
46
+ expect(w.emitted('hover')!.at(-1)![0]).toBeNull()
47
+ })
48
+
49
+ it('pans with a drag', async () => {
50
+ const w = mount(MCandlestickChart, { props: { data: series(200), visible: 20 }, attachTo: document.body })
51
+ rect(w)
52
+ const before = w.find('[data-candles="up"]').attributes('d')
53
+ await w.trigger('pointerdown', { pointerId: 1, clientX: 300, clientY: 100, button: 0, pointerType: 'mouse' })
54
+ await w.trigger('pointermove', { pointerId: 1, clientX: 500, clientY: 100, pointerType: 'mouse' })
55
+ await w.trigger('pointerup', { pointerId: 1, pointerType: 'mouse' })
56
+ expect(w.find('[data-candles="up"]').attributes('d')).not.toBe(before)
57
+ w.unmount()
58
+ })
59
+
60
+ it('follows new candles while the latest is in view', async () => {
61
+ const w = mount(MCandlestickChart, { props: { data: series(10) } })
62
+ await w.setProps({ data: series(11) })
63
+ expect(w.find('[data-last-price]').text()).toBe('113.00')
64
+ expect(w.find('[data-legend]').text()).toContain('Close 113.00')
65
+ })
66
+ })
@@ -0,0 +1,32 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MCertificate from '../components/MCertificate.vue'
4
+
5
+ describe('MCertificate', () => {
6
+ it('renders the recipient with locale defaults', () => {
7
+ const w = mount(MCertificate, { props: { recipient: 'Ana Gómez', description: 'has completed Vue 3 Fundamentals', date: new Date(2026, 10, 17), code: 'M3-2026-0042' } })
8
+ expect(w.find('[data-title]').text()).toBe('Certificate of completion')
9
+ expect(w.text()).toContain('This certifies that')
10
+ expect(w.find('[data-recipient]').text()).toBe('Ana Gómez')
11
+ expect(w.text()).toContain('November 17, 2026')
12
+ expect(w.find('[data-code]').text()).toBe('Certificate ID: M3-2026-0042')
13
+ })
14
+
15
+ it('draws signatures, with an image when given', () => {
16
+ const w = mount(MCertificate, {
17
+ props: { recipient: 'A', signatures: [{ name: 'Leo Paz', role: 'Director', image: 'data:image/png;base64,x' }, { name: 'Mía Ruiz' }] },
18
+ })
19
+ const sigs = w.findAll('[data-signature]')
20
+ expect(sigs).toHaveLength(2)
21
+ expect(sigs[0]!.find('img').attributes('src')).toBe('data:image/png;base64,x')
22
+ expect(sigs[0]!.text()).toContain('Director')
23
+ })
24
+
25
+ it('switches variant, orientation, color and seal', async () => {
26
+ const w = mount(MCertificate, { props: { recipient: 'A', variant: 'modern', orientation: 'portrait', color: 'tertiary', seal: false } })
27
+ expect(w.attributes('data-variant')).toBe('modern')
28
+ expect(w.attributes('style')).toContain('210 / 297')
29
+ expect(w.attributes('style')).toContain('var(--color-tertiary)')
30
+ expect(w.find('.m3-certificate__seal').exists()).toBe(false)
31
+ })
32
+ })
@@ -0,0 +1,122 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MCreditCardInput from '../components/MCreditCardInput.vue'
4
+ import { detectCardBrand, formatCardNumber, isValidCardNumber, isValidExpiry, luhnCheck } from '../composables/cardBrand'
5
+
6
+ const empty = { number: '', expiry: '', cvc: '' }
7
+
8
+ describe('card helpers', () => {
9
+ it('detects networks', () => {
10
+ expect(detectCardBrand('4242').brand).toBe('visa')
11
+ expect(detectCardBrand('5555 5555').brand).toBe('mastercard')
12
+ expect(detectCardBrand('2223').brand).toBe('mastercard')
13
+ expect(detectCardBrand('3782').brand).toBe('amex')
14
+ expect(detectCardBrand('6011').brand).toBe('discover')
15
+ expect(detectCardBrand('3530').brand).toBe('jcb')
16
+ expect(detectCardBrand('589562').brand).toBe('naranja')
17
+ expect(detectCardBrand('9999').brand).toBe('unknown')
18
+ })
19
+
20
+ it('checks Luhn and lengths', () => {
21
+ expect(luhnCheck('4242424242424242')).toBe(true)
22
+ expect(luhnCheck('4242424242424241')).toBe(false)
23
+ expect(isValidCardNumber('4242 4242 4242 4242')).toBe(true)
24
+ expect(isValidCardNumber('424242424242')).toBe(false)
25
+ expect(isValidCardNumber('378282246310005')).toBe(true)
26
+ })
27
+
28
+ it('groups numbers the way the network prints them', () => {
29
+ expect(formatCardNumber('4242424242424242')).toBe('4242 4242 4242 4242')
30
+ expect(formatCardNumber('378282246310005')).toBe('3782 822463 10005')
31
+ })
32
+
33
+ it('accepts only future expiries', () => {
34
+ const now = new Date(2026, 10, 17)
35
+ expect(isValidExpiry('11/26', now)).toBe(true)
36
+ expect(isValidExpiry('10/26', now)).toBe(false)
37
+ expect(isValidExpiry('13/27', now)).toBe(false)
38
+ expect(isValidExpiry('1/27', now)).toBe(false)
39
+ })
40
+ })
41
+
42
+ describe('MCreditCardInput', () => {
43
+ function inputs(w: ReturnType<typeof mount>) {
44
+ return w.findAll('input')
45
+ }
46
+
47
+ it('keeps digits only in the value and shows them grouped', async () => {
48
+ const w = mount(MCreditCardInput, { props: { modelValue: empty } })
49
+ await inputs(w)[0]!.setValue('4242-4242 4242a4242')
50
+ const v = w.emitted('update:modelValue')!.at(-1)![0] as typeof empty
51
+ expect(v.number).toBe('4242424242424242')
52
+ await w.setProps({ modelValue: v })
53
+ expect((inputs(w)[0]!.element as HTMLInputElement).value).toBe('4242 4242 4242 4242')
54
+ })
55
+
56
+ it('caps the number at the network length', async () => {
57
+ const w = mount(MCreditCardInput, { props: { modelValue: empty } })
58
+ await inputs(w)[0]!.setValue('37828224631000599')
59
+ expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).number).toBe('378282246310005')
60
+ })
61
+
62
+ it('stops a Visa or an unknown network at 16 digits', async () => {
63
+ const w = mount(MCreditCardInput, { props: { modelValue: empty } })
64
+ await inputs(w)[0]!.setValue('4242424242424242123')
65
+ expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).number).toBe('4242424242424242')
66
+ await inputs(w)[0]!.setValue('9999999999999999123')
67
+ expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).number).toBe('9999999999999999')
68
+ })
69
+
70
+ it('formats the expiry and pads a single-digit month', async () => {
71
+ const w = mount(MCreditCardInput, { props: { modelValue: empty } })
72
+ await inputs(w)[1]!.setValue('4')
73
+ expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).expiry).toBe('04')
74
+ await inputs(w)[1]!.setValue('1229')
75
+ expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).expiry).toBe('12/29')
76
+ })
77
+
78
+ it('limits the security code to the network length', async () => {
79
+ const w = mount(MCreditCardInput, { props: { modelValue: { ...empty, number: '4242' } } })
80
+ await inputs(w)[2]!.setValue('12345')
81
+ expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).cvc).toBe('123')
82
+ await w.setProps({ modelValue: { ...empty, number: '3782' } })
83
+ await inputs(w)[2]!.setValue('12345')
84
+ expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).cvc).toBe('1234')
85
+ })
86
+
87
+ it('shows an error only after a field is left', async () => {
88
+ const w = mount(MCreditCardInput, { props: { modelValue: { ...empty, number: '4242424242424241' } } })
89
+ expect(w.text()).not.toContain('Invalid card number')
90
+ await inputs(w)[0]!.trigger('focusout')
91
+ expect(w.text()).toContain('Invalid card number')
92
+ })
93
+
94
+ it('validate() marks every field and reports validity', async () => {
95
+ const w = mount(MCreditCardInput, { props: { modelValue: empty } })
96
+ expect((w.vm as any).validate()).toBe(false)
97
+ await w.vm.$nextTick()
98
+ expect(w.text()).toContain('Invalid or expired date')
99
+ await w.setProps({ modelValue: { number: '4242424242424242', expiry: '12/40', cvc: '123' } })
100
+ expect((w.vm as any).validate()).toBe(true)
101
+ })
102
+
103
+ it('emits complete once every field is valid', async () => {
104
+ const w = mount(MCreditCardInput, { props: { modelValue: empty } })
105
+ await w.setProps({ modelValue: { number: '4242424242424242', expiry: '12/40', cvc: '123' } })
106
+ expect(w.emitted('complete')).toHaveLength(1)
107
+ expect(w.emitted('brand')?.[0]).toEqual(['visa'])
108
+ })
109
+
110
+ it('shows external errors', () => {
111
+ const w = mount(MCreditCardInput, { props: { modelValue: empty, errors: { number: 'Card declined' } } })
112
+ expect(w.text()).toContain('Card declined')
113
+ })
114
+
115
+ it('flips the preview while the security code is focused', async () => {
116
+ const w = mount(MCreditCardInput, { props: { modelValue: empty } })
117
+ await inputs(w)[2]!.trigger('focusin')
118
+ expect(w.find('.m3-cc-preview__inner').classes()).toContain('is-flipped')
119
+ await inputs(w)[2]!.trigger('focusout')
120
+ expect(w.find('.m3-cc-preview__inner').classes()).not.toContain('is-flipped')
121
+ })
122
+ })
@@ -0,0 +1,49 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MMortgageCalculator from '../components/MMortgageCalculator.vue'
4
+ import type { MortgageInput } from '../components/MMortgageCalculator.vue'
5
+
6
+ const input: MortgageInput = { price: 250_000, down: 50_000, rate: 6, years: 30 }
7
+
8
+ function setup(extra: Record<string, unknown> = {}) {
9
+ const w = mount(MMortgageCalculator, {
10
+ props: { modelValue: input, currency: 'USD', 'onUpdate:modelValue': (v: MortgageInput) => w.setProps({ modelValue: v }), ...extra },
11
+ })
12
+ return w
13
+ }
14
+
15
+ describe('MMortgageCalculator', () => {
16
+ it('shows the monthly payment of the loan', () => {
17
+ const w = setup()
18
+ expect(w.find('[data-loan]').text()).toBe('$200,000')
19
+ expect(w.find('[data-monthly]').text()).toBe('$1,199.10')
20
+ })
21
+
22
+ it('changes the term from the chips', async () => {
23
+ const w = setup()
24
+ await w.find('[data-term="15"]').trigger('click')
25
+ expect(w.props('modelValue').years).toBe(15)
26
+ expect(w.find('[data-monthly]').text()).toBe('$1,687.71')
27
+ })
28
+
29
+ it('adds monthly extras and shows the falling payments of the german system', () => {
30
+ const w = setup({ system: 'german', extras: [{ label: 'Insurance', amount: 50 }] })
31
+ // 200000 / 360 = 555.56 principal + 1000 interest + 50
32
+ expect(w.find('[data-monthly]').text()).toBe('$1,605.56')
33
+ expect(w.text()).toContain('Last payment')
34
+ })
35
+
36
+ it('folds the schedule by year', async () => {
37
+ const w = setup()
38
+ expect(w.find('[data-schedule]').exists()).toBe(false)
39
+ await w.find('[data-toggle-schedule]').trigger('click')
40
+ expect(w.findAll('[data-schedule] tbody tr')).toHaveLength(30)
41
+ expect(w.findAll('[data-schedule] tbody tr').at(-1)!.text()).toContain('$0')
42
+ })
43
+
44
+ it('keeps the down payment within the price', async () => {
45
+ const w = setup()
46
+ await w.find('[data-field="price"] input').setValue('40000')
47
+ expect(w.props('modelValue')).toMatchObject({ price: 40_000, down: 40_000 })
48
+ })
49
+ })
@@ -0,0 +1,93 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MOdontogram from '../components/MOdontogram.vue'
4
+ import type { OdontogramValue } from '../components/MOdontogram.vue'
5
+
6
+ function setup(extra: Record<string, unknown> = {}) {
7
+ const w = mount(MOdontogram, {
8
+ props: {
9
+ modelValue: {} as OdontogramValue,
10
+ 'onUpdate:modelValue': (v: OdontogramValue) => w.setProps({ modelValue: v }),
11
+ 'onUpdate:tool': (t: string) => w.setProps({ tool: t }),
12
+ ...extra,
13
+ },
14
+ })
15
+ return w
16
+ }
17
+ const teeth = (w: ReturnType<typeof setup>) => w.findAll('[data-tooth]').map((t) => t.attributes('data-tooth'))
18
+ const surface = (w: ReturnType<typeof setup>, tooth: string, s: string) => w.find(`[data-tooth="${tooth}"] [data-surface="${s}"]`)
19
+
20
+ describe('MOdontogram', () => {
21
+ it('lays out FDI teeth from the patient’s upper right', () => {
22
+ const w = setup()
23
+ const t = teeth(w)
24
+ expect(t).toHaveLength(32)
25
+ expect(t.slice(0, 3)).toEqual(['18', '17', '16'])
26
+ expect(t.slice(7, 9)).toEqual(['11', '21'])
27
+ expect(t.slice(16, 18)).toEqual(['48', '47'])
28
+ expect(t.at(-1)).toBe('38')
29
+ })
30
+
31
+ it('numbers Universal and primary teeth', async () => {
32
+ const w = setup({ numbering: 'universal' })
33
+ expect(teeth(w).slice(0, 2)).toEqual(['1', '2'])
34
+ expect(teeth(w)[16]).toBe('32')
35
+ expect(teeth(w).at(-1)).toBe('17')
36
+ await w.setProps({ dentition: 'primary' })
37
+ expect(teeth(w)).toHaveLength(20)
38
+ expect(teeth(w).slice(0, 2)).toEqual(['A', 'B'])
39
+ await w.setProps({ numbering: 'fdi' })
40
+ expect(teeth(w).slice(0, 5)).toEqual(['55', '54', '53', '52', '51'])
41
+ })
42
+
43
+ it('points mesial at the midline and buccal outward', () => {
44
+ const w = setup()
45
+ // Tooth 16 sits left of the midline: its mesial side is the box's right side
46
+ expect(surface(w, '16', 'mesial').attributes('points')).toBe('40,0 28,12 28,28 40,40')
47
+ expect(surface(w, '26', 'mesial').attributes('points')).toBe('0,0 12,12 12,28 0,40')
48
+ expect(surface(w, '16', 'buccal').attributes('points')).toBe('0,0 40,0 28,12 12,12')
49
+ expect(surface(w, '46', 'buccal').attributes('points')).toBe('0,40 40,40 28,28 12,28')
50
+ })
51
+
52
+ it('charts a surface with the picked condition and clears it on a second tap', async () => {
53
+ const w = setup()
54
+ await surface(w, '36', 'occlusal').trigger('click')
55
+ expect(w.props('modelValue')).toEqual({ 36: { surfaces: { occlusal: 'caries' } } })
56
+ expect(w.emitted('change')![0]![0]).toEqual({ tooth: '36', surface: 'occlusal', condition: 'caries' })
57
+ await w.find('[data-tool="filling"]').trigger('click')
58
+ await surface(w, '36', 'occlusal').trigger('click')
59
+ expect(w.props('modelValue')).toEqual({ 36: { surfaces: { occlusal: 'filling' } } })
60
+ await surface(w, '36', 'occlusal').trigger('click')
61
+ expect(w.props('modelValue')).toEqual({})
62
+ })
63
+
64
+ it('charts whole-tooth conditions from the number', async () => {
65
+ const w = setup({ tool: 'missing' })
66
+ await w.find('[data-tooth="18"] [data-number]').trigger('click')
67
+ expect(w.props('modelValue')).toEqual({ 18: { conditions: ['missing'] } })
68
+ expect(w.find('[data-tooth="18"] [data-mark="missing"]').exists()).toBe(true)
69
+ await w.setProps({ tool: 'rootCanal' })
70
+ await w.find('[data-tooth="11"] [data-surface="buccal"]').trigger('click')
71
+ expect(w.props('modelValue')['11']).toEqual({ conditions: ['rootCanal'] })
72
+ await w.setProps({ tool: 'eraser' })
73
+ await w.find('[data-tooth="18"] [data-number]').trigger('click')
74
+ expect(w.props('modelValue')['18']).toBeUndefined()
75
+ })
76
+
77
+ it('charts surfaces from the keyboard', async () => {
78
+ const w = setup()
79
+ const first = w.find('[data-tooth="18"]')
80
+ await first.trigger('keydown', { key: 'o' })
81
+ await first.trigger('keydown', { key: 'M' })
82
+ expect(w.props('modelValue')['18']).toEqual({ surfaces: { occlusal: 'caries', mesial: 'caries' } })
83
+ expect(first.attributes('aria-label')).toBe('Tooth 18, Occlusal: Caries, Mesial: Caries')
84
+ await first.trigger('keydown', { key: 'Delete' })
85
+ expect(w.props('modelValue')).toEqual({})
86
+ })
87
+
88
+ it('does nothing when readonly', async () => {
89
+ const w = setup({ readonly: true })
90
+ await surface(w, '36', 'occlusal').trigger('click')
91
+ expect(w.emitted('update:modelValue')).toBeUndefined()
92
+ })
93
+ })
@@ -0,0 +1,66 @@
1
+ import { describe, it, expect, vi, afterEach } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MOrderBook from '../components/MOrderBook.vue'
4
+ import type { OrderBookLevel } from '../components/MOrderBook.vue'
5
+
6
+ const bids: OrderBookLevel[] = [[99.5, 2], [100, 1], [99.75, 3]]
7
+ const asks: OrderBookLevel[] = [[100.5, 1], [100.25, 4], [101, 2]]
8
+
9
+ afterEach(() => vi.useRealTimers())
10
+
11
+ const prices = (w: ReturnType<typeof mount>, side: string) =>
12
+ w.findAll(`[data-side="${side}"]`).map((r) => r.findAll('span.relative')[0]!.text())
13
+
14
+ describe('MOrderBook', () => {
15
+ it('sorts asks above bids with the best of each by the middle', () => {
16
+ const w = mount(MOrderBook, { props: { bids, asks } })
17
+ expect(prices(w, 'ask')).toEqual(['101.00', '100.50', '100.25'])
18
+ expect(prices(w, 'bid')).toEqual(['100.00', '99.75', '99.50'])
19
+ })
20
+
21
+ it('accumulates totals and shows the spread', () => {
22
+ const w = mount(MOrderBook, { props: { bids, asks } })
23
+ const bidTotals = w.findAll('[data-side="bid"]').map((r) => r.findAll('span.relative')[2]!.text())
24
+ expect(bidTotals).toEqual(['1.0000', '4.0000', '6.0000'])
25
+ expect(w.find('[data-spread]').text()).toContain('0.25')
26
+ })
27
+
28
+ it('groups levels into price steps', () => {
29
+ const w = mount(MOrderBook, { props: { bids, asks, step: 1 } })
30
+ expect(prices(w, 'bid')).toEqual(['100', '99'])
31
+ expect(prices(w, 'ask')).toEqual(['101'])
32
+ const sizes = w.findAll('[data-side="bid"]').map((r) => r.findAll('span.relative')[1]!.text())
33
+ expect(sizes).toEqual(['1.0000', '5.0000'])
34
+ })
35
+
36
+ it('caps the levels per side', () => {
37
+ const w = mount(MOrderBook, { props: { bids, asks, levels: 2 } })
38
+ expect(prices(w, 'bid')).toEqual(['100.00', '99.75'])
39
+ expect(prices(w, 'ask')).toEqual(['100.50', '100.25'])
40
+ })
41
+
42
+ it('flashes a level whose size changed', async () => {
43
+ vi.useFakeTimers()
44
+ const w = mount(MOrderBook, { props: { bids, asks } })
45
+ expect(w.find('.m3-ob-flash').exists()).toBe(false)
46
+ await w.setProps({ bids: [[99.5, 2], [100, 1.5], [99.75, 3]] })
47
+ expect(w.findAll('.m3-ob-flash')).toHaveLength(1)
48
+ vi.advanceTimersByTime(800)
49
+ await w.vm.$nextTick()
50
+ expect(w.find('.m3-ob-flash').exists()).toBe(false)
51
+ })
52
+
53
+ it('points the last price arrow the way it moved', async () => {
54
+ const w = mount(MOrderBook, { props: { bids, asks, lastPrice: 100.1 } })
55
+ await w.setProps({ lastPrice: 100.2 })
56
+ expect(w.find('[data-middle]').text()).toContain('arrow_upward')
57
+ await w.setProps({ lastPrice: 100 })
58
+ expect(w.find('[data-middle]').text()).toContain('arrow_downward')
59
+ })
60
+
61
+ it('emits the clicked level', async () => {
62
+ const w = mount(MOrderBook, { props: { bids, asks, layout: 'split' } })
63
+ await w.find('[data-side="ask"]').trigger('click')
64
+ expect(w.emitted('select')![0]![0]).toEqual({ price: 100.25, size: 4, side: 'ask' })
65
+ })
66
+ })