@m3ui-vue/m3ui-vue 1.3.7 → 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 (130) hide show
  1. package/dist/API.md +1097 -26
  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/MBadge.vue.d.ts +1 -1
  25. package/dist/components/MBeforeAfter.vue.d.ts +61 -0
  26. package/dist/components/MBodyMap.vue.d.ts +70 -0
  27. package/dist/components/MCandlestickChart.vue.d.ts +82 -0
  28. package/dist/components/MCertificate.vue.d.ts +76 -0
  29. package/dist/components/MCreditCardInput.vue.d.ts +75 -0
  30. package/dist/components/MFlow.vue.d.ts +13 -0
  31. package/dist/components/MMortgageCalculator.vue.d.ts +83 -0
  32. package/dist/components/MOdontogram.vue.d.ts +86 -0
  33. package/dist/components/MOrderBook.vue.d.ts +89 -0
  34. package/dist/components/MOrderTicket.vue.d.ts +91 -0
  35. package/dist/components/MPosKeypad.vue.d.ts +84 -0
  36. package/dist/components/MProductConfigurator.vue.d.ts +136 -0
  37. package/dist/components/MQuiz.vue.d.ts +102 -0
  38. package/dist/components/MReceipt.vue.d.ts +93 -0
  39. package/dist/components/MSeatMap.vue.d.ts +131 -0
  40. package/dist/components/MSeekBar.vue.d.ts +1 -1
  41. package/dist/components/MSlider.vue.d.ts +2 -2
  42. package/dist/components/MSplitter.vue.d.ts +1 -1
  43. package/dist/components/MTicket.vue.d.ts +83 -0
  44. package/dist/components/MTour.vue.d.ts +52 -2
  45. package/dist/components/MVideoPlayer.vue.d.ts +1 -1
  46. package/dist/components/MVitalsChart.vue.d.ts +73 -0
  47. package/dist/composables/_printElement.d.ts +9 -0
  48. package/dist/composables/cardBrand.d.ts +25 -0
  49. package/dist/composables/flowPaths.d.ts +11 -3
  50. package/dist/composables/mortgage.d.ts +37 -0
  51. package/dist/composables/useFlow.d.ts +4 -0
  52. package/dist/composables/useLocale.d.ts +131 -0
  53. package/dist/draw.js +2 -2
  54. package/dist/flow.d.ts +1 -1
  55. package/dist/flow.js +526 -434
  56. package/dist/flow.js.map +1 -1
  57. package/dist/{flowPaths-DzW-aiET.js → flowPaths-CcWOKY4Z.js} +5 -5
  58. package/dist/flowPaths-CcWOKY4Z.js.map +1 -0
  59. package/dist/gantt.js +2 -2
  60. package/dist/index.d.ts +35 -0
  61. package/dist/locales/index.js +924 -7
  62. package/dist/locales/index.js.map +1 -1
  63. package/dist/m3ui-vue.css +1 -1
  64. package/dist/m3ui.js +8393 -3613
  65. package/dist/m3ui.js.map +1 -1
  66. package/dist/map.js +5 -5
  67. package/dist/media.js +4 -4
  68. package/dist/pdf.js +4 -4
  69. package/dist/rich-text-editor.js +4 -4
  70. package/dist/styles.css +1 -1
  71. package/dist/{useLocale-D2ucaY-l.js → useLocale-DLKJIRFi.js} +133 -2
  72. package/dist/useLocale-DLKJIRFi.js.map +1 -0
  73. package/package.json +1 -1
  74. package/src/__tests__/MAvailabilityCalendar.test.ts +85 -0
  75. package/src/__tests__/MBeforeAfter.test.ts +79 -0
  76. package/src/__tests__/MBodyMap.test.ts +60 -0
  77. package/src/__tests__/MCandlestickChart.test.ts +66 -0
  78. package/src/__tests__/MCertificate.test.ts +32 -0
  79. package/src/__tests__/MCreditCardInput.test.ts +122 -0
  80. package/src/__tests__/MFlow.test.ts +69 -0
  81. package/src/__tests__/MMortgageCalculator.test.ts +49 -0
  82. package/src/__tests__/MOdontogram.test.ts +93 -0
  83. package/src/__tests__/MOrderBook.test.ts +66 -0
  84. package/src/__tests__/MOrderTicket.test.ts +68 -0
  85. package/src/__tests__/MPosKeypad.test.ts +116 -0
  86. package/src/__tests__/MProductConfigurator.test.ts +73 -0
  87. package/src/__tests__/MQuiz.test.ts +104 -0
  88. package/src/__tests__/MReceipt.test.ts +52 -0
  89. package/src/__tests__/MSeatMap.test.ts +76 -0
  90. package/src/__tests__/MTicket.test.ts +38 -0
  91. package/src/__tests__/MTour.test.ts +102 -0
  92. package/src/__tests__/MVitalsChart.test.ts +49 -0
  93. package/src/__tests__/mortgage.test.ts +25 -0
  94. package/src/__tests__/ssr.test.ts +11 -0
  95. package/src/components/MAvailabilityCalendar.vue +460 -0
  96. package/src/components/MBeforeAfter.vue +248 -0
  97. package/src/components/MBodyMap.vue +266 -0
  98. package/src/components/MCandlestickChart.vue +479 -0
  99. package/src/components/MCertificate.vue +351 -0
  100. package/src/components/MCreditCardInput.vue +351 -0
  101. package/src/components/MFlow.vue +117 -17
  102. package/src/components/MMortgageCalculator.vue +258 -0
  103. package/src/components/MOdontogram.vue +462 -0
  104. package/src/components/MOrderBook.vue +287 -0
  105. package/src/components/MOrderTicket.vue +217 -0
  106. package/src/components/MPosKeypad.vue +406 -0
  107. package/src/components/MProductConfigurator.vue +412 -0
  108. package/src/components/MQuiz.vue +531 -0
  109. package/src/components/MReceipt.vue +249 -0
  110. package/src/components/MSeatMap.vue +431 -0
  111. package/src/components/MTicket.vue +209 -0
  112. package/src/components/MTour.vue +145 -27
  113. package/src/components/MVitalsChart.vue +303 -0
  114. package/src/composables/_printElement.ts +36 -0
  115. package/src/composables/cardBrand.ts +104 -0
  116. package/src/composables/flowPaths.ts +16 -7
  117. package/src/composables/mortgage.ts +70 -0
  118. package/src/composables/useFlow.ts +4 -0
  119. package/src/composables/useLocale.ts +277 -0
  120. package/src/flow.ts +1 -1
  121. package/src/index.ts +35 -0
  122. package/src/locales/de.ts +131 -0
  123. package/src/locales/es.ts +131 -0
  124. package/src/locales/fr.ts +131 -0
  125. package/src/locales/ja.ts +131 -0
  126. package/src/locales/ko.ts +131 -0
  127. package/src/locales/pt.ts +131 -0
  128. package/src/locales/zh.ts +131 -0
  129. package/dist/flowPaths-DzW-aiET.js.map +0 -1
  130. package/dist/useLocale-D2ucaY-l.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MTicket from '../components/MTicket.vue'
4
+
5
+ describe('MTicket', () => {
6
+ it('renders the route, fields and stub', () => {
7
+ const w = mount(MTicket, {
8
+ props: {
9
+ title: 'Aerolíneas',
10
+ from: { code: 'EZE', name: 'Buenos Aires', time: '08:40' },
11
+ to: { code: 'MDZ', name: 'Mendoza', time: '10:35' },
12
+ fields: [{ label: 'Gate', value: 'B12' }, { label: 'Seat', value: '14C', strong: true }],
13
+ },
14
+ slots: { stub: '<div data-test="qr">QR</div>' },
15
+ })
16
+ expect(w.find('[data-route]').text()).toContain('EZE')
17
+ expect(w.find('[data-route]').text()).toContain('MDZ')
18
+ expect(w.findAll('dt').map((d) => d.text())).toEqual(['Gate', 'Seat'])
19
+ expect(w.find('[data-test="qr"]').exists()).toBe(true)
20
+ expect(w.find('.m3-ticket__perforation').exists()).toBe(true)
21
+ })
22
+
23
+ it('has no stub or route when not given', () => {
24
+ const w = mount(MTicket, { props: { title: 'Coupon' }, slots: { default: '20% off' } })
25
+ expect(w.find('.m3-ticket__stub').exists()).toBe(false)
26
+ expect(w.find('[data-route]').exists()).toBe(false)
27
+ expect(w.text()).toContain('20% off')
28
+ })
29
+
30
+ it('colors the band with a role or a CSS color', async () => {
31
+ const w = mount(MTicket, { props: { title: 'T', color: 'tertiary' } })
32
+ const band = () => w.find('.m3-ticket__main > div').attributes('style')
33
+ expect(band()).toContain('var(--color-tertiary)')
34
+ await w.setProps({ color: 'secondary', orientation: 'vertical' })
35
+ expect(band()).toContain('var(--color-secondary)')
36
+ expect(w.attributes('data-orientation')).toBe('vertical')
37
+ })
38
+ })
@@ -0,0 +1,102 @@
1
+ import { describe, it, expect, afterEach } from 'vitest'
2
+ import { mount, type VueWrapper } from '@vue/test-utils'
3
+ import { h, nextTick } from 'vue'
4
+ import MTour, { type TourStep } from '../components/MTour.vue'
5
+
6
+ const frame = () => new Promise((r) => requestAnimationFrame(() => r(null)))
7
+ let wrapper: VueWrapper | null = null
8
+ const targets: HTMLElement[] = []
9
+
10
+ /** A laid-out element at a given place (happy-dom has no layout) */
11
+ function target(id: string, rect = { left: 100, top: 100, width: 80, height: 40 }) {
12
+ const el = document.createElement('button')
13
+ el.id = id
14
+ document.body.appendChild(el)
15
+ const at = { ...rect }
16
+ el.getBoundingClientRect = () => ({ ...at, right: at.left + at.width, bottom: at.top + at.height, x: at.left, y: at.top, toJSON() {} }) as DOMRect
17
+ el.getClientRects = () => [el.getBoundingClientRect()] as unknown as DOMRectList
18
+ targets.push(el)
19
+ return { el, at }
20
+ }
21
+ const tooltip = () => document.body.querySelector<HTMLElement>('.z-202')
22
+ const ring = () => document.body.querySelector<HTMLElement>('.m3-tour-ring')
23
+ const scrim = () => document.body.querySelector('.z-200')
24
+
25
+ afterEach(() => {
26
+ wrapper?.unmount()
27
+ wrapper = null
28
+ targets.splice(0).forEach((el) => el.remove())
29
+ })
30
+
31
+ describe('MTour', () => {
32
+ it('dims the page and lifts the target by default', async () => {
33
+ const { el } = target('a')
34
+ target('b')
35
+ const steps: TourStep[] = [{ target: '#a', title: 'One', content: 'First' }, { target: '#b', title: 'Two', content: 'Second' }]
36
+ wrapper = mount(MTour, { props: { modelValue: true, steps }, attachTo: document.body })
37
+ await nextTick()
38
+ await nextTick()
39
+ expect(scrim()).not.toBeNull()
40
+ expect(el.classList.contains('m3-tour-highlight')).toBe(true)
41
+ expect(tooltip()!.textContent).toContain('First')
42
+ })
43
+
44
+ it('follows v-model:step and reports Next through it', async () => {
45
+ target('a')
46
+ target('b')
47
+ const steps: TourStep[] = [{ target: '#a', title: 'One', content: 'First' }, { target: '#b', title: 'Two', content: 'Second' }]
48
+ wrapper = mount(MTour, { props: { modelValue: true, steps, step: 1 }, attachTo: document.body })
49
+ await nextTick()
50
+ expect(tooltip()!.textContent).toContain('Second')
51
+ await wrapper.setProps({ step: 0 })
52
+ expect(tooltip()!.textContent).toContain('First')
53
+ const next = [...tooltip()!.querySelectorAll('button')].find((b) => b.textContent?.includes('Next'))!
54
+ next.click()
55
+ expect(wrapper.emitted('update:step')).toEqual([[1]])
56
+ })
57
+
58
+ it('interactive: no scrim, the target left alone, a ring that follows it as it moves', async () => {
59
+ const { el, at } = target('a')
60
+ wrapper = mount(MTour, { props: { modelValue: true, interactive: true, steps: [{ target: () => document.getElementById('a'), title: 'One', content: 'First' }] }, attachTo: document.body })
61
+ await nextTick()
62
+ await frame()
63
+ await frame()
64
+ expect(scrim()).toBeNull()
65
+ expect(el.classList.contains('m3-tour-highlight')).toBe(false)
66
+ expect(ring()!.style.left).toBe('96px')
67
+ expect(ring()!.style.width).toBe('88px')
68
+ at.left = 300
69
+ await frame()
70
+ await frame()
71
+ expect(ring()!.style.left).toBe('296px')
72
+ // Clicking outside doesn't close it
73
+ document.body.click()
74
+ expect(wrapper.emitted('update:modelValue')).toBeUndefined()
75
+ })
76
+
77
+ it('without a target found, sits on its placement side of the viewport and draws no ring', async () => {
78
+ wrapper = mount(MTour, { props: { modelValue: true, interactive: true, steps: [{ target: '#missing', title: 'One', content: 'First', placement: 'bottom' }] }, attachTo: document.body })
79
+ await nextTick()
80
+ await frame()
81
+ await frame()
82
+ expect(tooltip()!.style.bottom).toBe('16px')
83
+ expect(ring()).toBeNull()
84
+ })
85
+
86
+ it('takes its text and buttons from slots', async () => {
87
+ target('a')
88
+ wrapper = mount(MTour, {
89
+ props: { modelValue: true, steps: [{ target: '#a', title: 'One', content: 'First' }] },
90
+ slots: {
91
+ content: ({ step, index }: { step: TourStep; index: number }) => h('p', { class: 'mine' }, `${index}:${step.title}`),
92
+ actions: ({ close }: { close: () => void }) => h('button', { class: 'leave', onClick: close }, 'Leave'),
93
+ },
94
+ attachTo: document.body,
95
+ })
96
+ await nextTick()
97
+ expect(tooltip()!.querySelector('.mine')!.textContent).toBe('0:One')
98
+ expect(tooltip()!.textContent).not.toContain('Finish')
99
+ tooltip()!.querySelector<HTMLElement>('.leave')!.click()
100
+ expect(wrapper.emitted('update:modelValue')).toEqual([[false]])
101
+ })
102
+ })
@@ -0,0 +1,49 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import MVitalsChart from '../components/MVitalsChart.vue'
4
+ import type { VitalSeries } from '../components/MVitalsChart.vue'
5
+
6
+ const h = (n: number) => Date.UTC(2026, 10, 17, n)
7
+ const series: VitalSeries[] = [
8
+ { key: 'hr', label: 'Heart rate', unit: 'bpm', normal: [60, 100], data: [{ time: h(8), value: 72 }, { time: h(12), value: 88 }, { time: h(16), value: 112 }] },
9
+ { key: 'bp', label: 'Blood pressure', unit: 'mmHg', normal: [[90, 120], [60, 80]], data: [{ time: h(8), value: [118, 76] }, { time: h(16), value: [124, 82] }] },
10
+ { key: 'temp', label: 'Temperature', unit: '°C', decimals: 1, normal: [36.1, 37.2], data: [{ time: h(12), value: 35.6 }] },
11
+ ]
12
+
13
+ describe('MVitalsChart', () => {
14
+ it('shows the latest reading of each vital with its status', () => {
15
+ const w = mount(MVitalsChart, { props: { series } })
16
+ const row = (k: string) => w.find(`[data-vital="${k}"]`)
17
+ expect(row('hr').find('[data-value]').text()).toBe('112')
18
+ expect(row('hr').find('[data-status]').text()).toBe('High')
19
+ expect(row('bp').find('[data-value]').text()).toBe('124/82')
20
+ expect(row('bp').find('[data-status]').text()).toBe('High')
21
+ expect(row('temp').find('[data-value]').text()).toBe('35.6')
22
+ expect(row('temp').find('[data-status]').text()).toBe('Low')
23
+ })
24
+
25
+ it('draws normal bands and flags readings outside them', () => {
26
+ const w = mount(MVitalsChart, { props: { series } })
27
+ expect(w.findAll('[data-vital="hr"] [data-band]')).toHaveLength(1)
28
+ expect(w.findAll('[data-vital="bp"] [data-band]')).toHaveLength(2)
29
+ expect(w.findAll('[data-vital="hr"] [data-out]')).toHaveLength(1)
30
+ })
31
+
32
+ it('moves a shared crosshair with the arrow keys', async () => {
33
+ const w = mount(MVitalsChart, { props: { series } })
34
+ await w.trigger('keydown', { key: 'ArrowLeft' })
35
+ expect(w.emitted('hover')![0]![0]).toBe(h(16))
36
+ await w.trigger('keydown', { key: 'ArrowLeft' })
37
+ expect(w.emitted('hover')![1]![0]).toBe(h(12))
38
+ // At 12:00 each row shows its latest reading so far
39
+ expect(w.find('[data-vital="hr"] [data-value]').text()).toBe('88')
40
+ expect(w.find('[data-vital="bp"] [data-value]').text()).toBe('118/76')
41
+ expect(w.find('[data-vital="bp"] [data-status]').exists()).toBe(false)
42
+ expect(w.find('[data-hover-time]').exists()).toBe(true)
43
+ })
44
+
45
+ it('says when there are no readings', () => {
46
+ const w = mount(MVitalsChart, { props: { series: [{ key: 'x', label: 'X', data: [] }] } })
47
+ expect(w.text()).toContain('No readings')
48
+ })
49
+ })
@@ -0,0 +1,25 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { amortize } from '../composables/mortgage'
3
+
4
+ describe('amortize', () => {
5
+ it('computes the fixed payment of a french loan', () => {
6
+ const a = amortize({ principal: 200_000, rate: 6, years: 30 })
7
+ expect(a.payments).toHaveLength(360)
8
+ expect(a.firstPayment).toBeCloseTo(1199.1, 1)
9
+ expect(a.payments.at(-1)!.balance).toBe(0)
10
+ expect(a.totalPaid).toBeCloseTo(a.totalInterest + 200_000, 1)
11
+ })
12
+
13
+ it('keeps the principal fixed in a german loan', () => {
14
+ const a = amortize({ principal: 120_000, rate: 12, years: 10, system: 'german' })
15
+ expect(a.payments[0]!.principal).toBe(1000)
16
+ expect(a.firstPayment).toBe(2200)
17
+ expect(a.lastPayment).toBeCloseTo(1010, 0)
18
+ expect(a.payments.at(-1)!.balance).toBe(0)
19
+ })
20
+
21
+ it('handles a zero rate and an empty loan', () => {
22
+ expect(amortize({ principal: 12_000, rate: 0, years: 1 }).firstPayment).toBe(1000)
23
+ expect(amortize({ principal: 0, rate: 5, years: 10 }).payments).toEqual([])
24
+ })
25
+ })
@@ -27,6 +27,17 @@ const props: Record<string, Record<string, unknown>> = {
27
27
  MTreeTable: { columns: [{ key: 'a', label: 'A' }], rows: [] },
28
28
  MTree: { nodes: [{ id: 1, label: 'a' }] },
29
29
  MKbd: { keys: 'Ctrl+K' },
30
+ MOrderTicket: { number: 1, createdAt: 0, items: [{ id: 1, name: 'Pizza' }] },
31
+ MSeatMap: { layout: ['ss_ss', 'ss_ss'], modelValue: ['A1'] },
32
+ MCreditCardInput: { modelValue: { number: '4242', expiry: '', cvc: '' } },
33
+ MReceipt: { items: [{ name: 'Coffee', price: 2 }] },
34
+ MProductConfigurator: { groups: [{ key: 's', label: 'Size', options: [{ value: 'm', label: 'M' }] }] },
35
+ MCandlestickChart: { data: [{ time: 0, open: 1, high: 2, low: 0.5, close: 1.5 }] },
36
+ MOrderBook: { bids: [[1, 1]], asks: [[2, 1]] },
37
+ MMortgageCalculator: { modelValue: { price: 100, down: 10, rate: 5, years: 10 } },
38
+ MVitalsChart: { series: [{ key: 'hr', label: 'HR', data: [{ time: 0, value: 70 }] }] },
39
+ MQuiz: { questions: [{ id: 1, prompt: 'Q', options: ['a', 'b'], answer: 0 }] },
40
+ MCertificate: { recipient: 'Ana' },
30
41
  MPasswordMeter: { value: 'abc' },
31
42
  MRelativeTime: { value: new Date(0) },
32
43
  MResult: { status: 'success', title: 't' },