@m3ui-vue/m3ui-vue 0.8.7 → 0.9.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/README.md +13 -3
- package/dist/{MMenuItem-DmrsQrK7.js → MTextField-B0wGv1Mx.js} +374 -364
- package/dist/MTextField-B0wGv1Mx.js.map +1 -0
- package/dist/barcode.js +9 -11
- package/dist/barcode.js.map +1 -1
- package/dist/code-editor.js +2 -2
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MCarousel.vue.d.ts +55 -36
- package/dist/components/MDialog.vue.d.ts +4 -2
- package/dist/components/MEmojiSelector.vue.d.ts +21 -5
- package/dist/components/MFabMenu.vue.d.ts +1 -1
- package/dist/components/MFlex.vue.d.ts +1 -1
- package/dist/components/MLightbox.vue.d.ts +15 -5
- package/dist/components/MScheduler.vue.d.ts +38 -1
- package/dist/components/MShape.vue.d.ts +1 -1
- package/dist/components/MSimpleCarousel.vue.d.ts +2 -2
- package/dist/components/MSlider.vue.d.ts +1 -1
- package/dist/components/MStack.vue.d.ts +1 -1
- package/dist/components/MToolbar.vue.d.ts +1 -1
- package/dist/components/MWindow.vue.d.ts +1 -1
- package/dist/composables/_carouselStrategy.d.ts +101 -0
- package/dist/composables/useLocale.d.ts +23 -0
- package/dist/data/emoji-names/emoji-names-de.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-en.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-es.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-fr.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-ja.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-ko.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-pt.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-zh.d.ts +2 -0
- package/dist/data/emojis.d.ts +7 -1
- package/dist/emoji-names-de-BphO5XpV.js +1877 -0
- package/dist/emoji-names-de-BphO5XpV.js.map +1 -0
- package/dist/emoji-names-en-9ZvMRvzi.js +1877 -0
- package/dist/emoji-names-en-9ZvMRvzi.js.map +1 -0
- package/dist/emoji-names-es-DvfWU3Pj.js +1877 -0
- package/dist/emoji-names-es-DvfWU3Pj.js.map +1 -0
- package/dist/emoji-names-fr-B-jhUlsP.js +1877 -0
- package/dist/emoji-names-fr-B-jhUlsP.js.map +1 -0
- package/dist/emoji-names-ja-l8cMFJo1.js +1877 -0
- package/dist/emoji-names-ja-l8cMFJo1.js.map +1 -0
- package/dist/emoji-names-ko-YP-o9G0c.js +1877 -0
- package/dist/emoji-names-ko-YP-o9G0c.js.map +1 -0
- package/dist/emoji-names-pt-DGj_Js4M.js +1877 -0
- package/dist/emoji-names-pt-DGj_Js4M.js.map +1 -0
- package/dist/emoji-names-zh-Dzecwtw_.js +1877 -0
- package/dist/emoji-names-zh-Dzecwtw_.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/locales/index.js +168 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +3926 -2430
- package/dist/m3ui.js.map +1 -1
- package/dist/plugin.d.ts +6 -0
- package/dist/rich-text-editor.js +9 -9
- package/dist/styles.css +1 -1
- package/dist/terminal.js +34 -27
- package/dist/terminal.js.map +1 -1
- package/dist/{useLocale-Bircp823.js → useLocale-CmI675Ab.js} +25 -2
- package/dist/useLocale-CmI675Ab.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MCarousel.test.ts +183 -21
- package/src/__tests__/MDialog.test.ts +18 -0
- package/src/__tests__/MEmojiSelector.test.ts +138 -0
- package/src/__tests__/MLightbox.test.ts +313 -5
- package/src/__tests__/MPagination.test.ts +37 -0
- package/src/__tests__/MPullToRefresh.test.ts +39 -0
- package/src/__tests__/MScheduler.test.ts +122 -0
- package/src/__tests__/MTerminal.test.ts +63 -0
- package/src/__tests__/attrsFallthrough.test.ts +65 -0
- package/src/__tests__/plugin.test.ts +28 -1
- package/src/components/MBarcode.vue +4 -2
- package/src/components/MBottomSheet.vue +1 -1
- package/src/components/MCarousel.vue +526 -200
- package/src/components/MCodeEditor.vue +3 -2
- package/src/components/MCommandPalette.vue +1 -1
- package/src/components/MContextMenu.vue +3 -1
- package/src/components/MDatePickerModal.vue +1 -1
- package/src/components/MDateRangePickerModal.vue +1 -1
- package/src/components/MDialog.vue +19 -6
- package/src/components/MEmojiSelector.vue +479 -78
- package/src/components/MFab.vue +3 -1
- package/src/components/MLightbox.vue +750 -268
- package/src/components/MLoadingOverlay.vue +6 -1
- package/src/components/MMenu.vue +3 -1
- package/src/components/MNavigationDrawer.vue +5 -1
- package/src/components/MNavigationRail.vue +8 -2
- package/src/components/MOverlay.vue +1 -0
- package/src/components/MPagination.vue +8 -5
- package/src/components/MPullToRefresh.vue +13 -1
- package/src/components/MScheduler.vue +282 -115
- package/src/components/MSideSheet.vue +1 -1
- package/src/components/MSplitButton.vue +3 -1
- package/src/components/MSpotlightSearch.vue +1 -1
- package/src/components/MTerminal.vue +22 -10
- package/src/components/MTimePickerModal.vue +1 -1
- package/src/components/MTooltip.vue +3 -0
- package/src/components/MTour.vue +2 -2
- package/src/composables/_carouselStrategy.ts +712 -0
- package/src/composables/useLocale.ts +48 -0
- package/src/data/emoji-names/emoji-names-de.ts +1875 -0
- package/src/data/emoji-names/emoji-names-en.ts +1875 -0
- package/src/data/emoji-names/emoji-names-es.ts +1875 -0
- package/src/data/emoji-names/emoji-names-fr.ts +1875 -0
- package/src/data/emoji-names/emoji-names-ja.ts +1875 -0
- package/src/data/emoji-names/emoji-names-ko.ts +1875 -0
- package/src/data/emoji-names/emoji-names-pt.ts +1875 -0
- package/src/data/emoji-names/emoji-names-zh.ts +1875 -0
- package/src/data/emojis.ts +29 -198
- package/src/index.ts +2 -2
- package/src/locales/de.ts +24 -0
- package/src/locales/es.ts +24 -0
- package/src/locales/fr.ts +24 -0
- package/src/locales/ja.ts +24 -0
- package/src/locales/ko.ts +24 -0
- package/src/locales/pt.ts +24 -0
- package/src/locales/zh.ts +24 -0
- package/src/plugin.ts +12 -1
- package/dist/MMenuItem-DmrsQrK7.js.map +0 -1
- package/dist/useLocale-Bircp823.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest'
|
|
2
|
+
import { mount, type VueWrapper } from '@vue/test-utils'
|
|
3
|
+
import { nextTick, type Component } from 'vue'
|
|
4
|
+
import MMenu from '../components/MMenu.vue'
|
|
5
|
+
import MContextMenu from '../components/MContextMenu.vue'
|
|
6
|
+
import MTooltip from '../components/MTooltip.vue'
|
|
7
|
+
import MFab from '../components/MFab.vue'
|
|
8
|
+
import MSplitButton from '../components/MSplitButton.vue'
|
|
9
|
+
import MLightbox from '../components/MLightbox.vue'
|
|
10
|
+
import MBarcode from '../components/MBarcode.vue'
|
|
11
|
+
import MLoadingOverlay from '../components/MLoadingOverlay.vue'
|
|
12
|
+
import MNavigationDrawer from '../components/MNavigationDrawer.vue'
|
|
13
|
+
import MNavigationRail from '../components/MNavigationRail.vue'
|
|
14
|
+
import MSkeleton from '../components/MSkeleton.vue'
|
|
15
|
+
import MStepper from '../components/MStepper.vue'
|
|
16
|
+
import MTabs from '../components/MTabs.vue'
|
|
17
|
+
import MTransferList from '../components/MTransferList.vue'
|
|
18
|
+
|
|
19
|
+
// These components render more than one root node (an element plus a Teleport, a v-if/v-show
|
|
20
|
+
// pair, a comment before the root...), which makes Vue drop a consumer's class/attrs silently.
|
|
21
|
+
// Each case names the element that should receive them.
|
|
22
|
+
const cases: [name: string, component: Component, props: Record<string, unknown>, tag: string][] = [
|
|
23
|
+
['MMenu', MMenu, {}, 'DIV'],
|
|
24
|
+
['MContextMenu', MContextMenu, {}, 'DIV'],
|
|
25
|
+
['MTooltip', MTooltip, { text: 'Tip' }, 'SPAN'],
|
|
26
|
+
['MFab', MFab, { icon: 'add' }, 'DIV'],
|
|
27
|
+
['MSplitButton', MSplitButton, { label: 'Save' }, 'DIV'],
|
|
28
|
+
['MLightbox', MLightbox, { modelValue: false, items: [] }, 'DIV'],
|
|
29
|
+
['MBarcode', MBarcode, { value: '123456789012', displayValue: false }, 'svg'],
|
|
30
|
+
['MBarcode (error)', MBarcode, { value: 'abc', format: 'EAN13', displayValue: false }, 'DIV'],
|
|
31
|
+
['MLoadingOverlay', MLoadingOverlay, { visible: true }, 'DIV'],
|
|
32
|
+
['MLoadingOverlay (fullscreen)', MLoadingOverlay, { visible: true, fullscreen: true }, 'DIV'],
|
|
33
|
+
['MNavigationDrawer', MNavigationDrawer, { modelValue: true, sections: [] }, 'NAV'],
|
|
34
|
+
['MNavigationDrawer (modal)', MNavigationDrawer, { modelValue: true, sections: [], modal: true }, 'NAV'],
|
|
35
|
+
['MNavigationRail', MNavigationRail, { modelValue: 'a', items: [] }, 'NAV'],
|
|
36
|
+
['MNavigationRail (modal)', MNavigationRail, { modelValue: 'a', items: [], modal: true }, 'NAV'],
|
|
37
|
+
['MSkeleton', MSkeleton, {}, 'DIV'],
|
|
38
|
+
['MSkeleton (lines)', MSkeleton, { variant: 'text', lines: 3 }, 'DIV'],
|
|
39
|
+
['MStepper', MStepper, { steps: [{ label: 'One' }], modelValue: 0 }, 'DIV'],
|
|
40
|
+
['MStepper (vertical)', MStepper, { steps: [{ label: 'One' }], modelValue: 0, direction: 'vertical' }, 'DIV'],
|
|
41
|
+
['MTabs', MTabs, { modelValue: 'a', tabs: [{ value: 'a', label: 'A' }] }, 'DIV'],
|
|
42
|
+
['MTabs (secondary)', MTabs, { modelValue: 'a', tabs: [{ value: 'a', label: 'A' }], variant: 'secondary' }, 'DIV'],
|
|
43
|
+
['MTransferList', MTransferList, { modelValue: [], items: [] }, 'DIV'],
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
describe('consumer attrs reach multi-root components', () => {
|
|
47
|
+
let wrapper: VueWrapper | null = null
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
wrapper?.unmount()
|
|
50
|
+
wrapper = null
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it.each(cases)('%s', async (_name, component, props, tag) => {
|
|
54
|
+
wrapper = mount(component, {
|
|
55
|
+
props,
|
|
56
|
+
attrs: { class: 'consumer-class', 'data-consumer': 'yes' },
|
|
57
|
+
attachTo: document.body,
|
|
58
|
+
})
|
|
59
|
+
await nextTick()
|
|
60
|
+
const matches = document.body.querySelectorAll('[data-consumer="yes"]')
|
|
61
|
+
expect(matches).toHaveLength(1)
|
|
62
|
+
expect(matches[0].tagName).toBe(tag)
|
|
63
|
+
expect(matches[0].classList.contains('consumer-class')).toBe(true)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
2
2
|
import { createApp, defineComponent, h } from 'vue'
|
|
3
3
|
import { createM3UI } from '../plugin'
|
|
4
|
-
import { useColorPalette } from '../composables/useColorPalette'
|
|
4
|
+
import { useColorPalette, palettes } from '../composables/useColorPalette'
|
|
5
5
|
|
|
6
6
|
describe('createM3UI', () => {
|
|
7
7
|
beforeEach(() => {
|
|
@@ -52,4 +52,31 @@ describe('createM3UI', () => {
|
|
|
52
52
|
app.use(createM3UI({ palette: 'iron', persistPalette: false }))
|
|
53
53
|
expect(localStorage.getItem('m3-palette')).toBeNull()
|
|
54
54
|
})
|
|
55
|
+
|
|
56
|
+
describe('customPalettes', () => {
|
|
57
|
+
const builtIn = palettes.map((p) => ({ ...p }))
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
palettes.splice(0, palettes.length, ...builtIn)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('adds custom palettes to the list useColorPalette returns', () => {
|
|
63
|
+
const app = createApp(defineComponent({ render: () => h('div') }))
|
|
64
|
+
app.use(createM3UI({ customPalettes: [{ id: 'brand', label: 'Brand', seed: '#0b6e4f' }] }))
|
|
65
|
+
expect(useColorPalette().palettes).toHaveLength(builtIn.length + 1)
|
|
66
|
+
expect(useColorPalette().palettes.at(-1)).toEqual({ id: 'brand', label: 'Brand', seed: '#0b6e4f' })
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('replaces a built-in palette with the same id instead of duplicating it', () => {
|
|
70
|
+
const app = createApp(defineComponent({ render: () => h('div') }))
|
|
71
|
+
app.use(createM3UI({ customPalettes: [{ id: 'teal', label: 'Our teal', seed: '#008080' }] }))
|
|
72
|
+
expect(palettes).toHaveLength(builtIn.length)
|
|
73
|
+
expect(palettes.filter((p) => p.id === 'teal')).toEqual([{ id: 'teal', label: 'Our teal', seed: '#008080' }])
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('can be selected as the starting palette', () => {
|
|
77
|
+
const app = createApp(defineComponent({ render: () => h('div') }))
|
|
78
|
+
app.use(createM3UI({ palette: 'brand', customPalettes: [{ id: 'brand', label: 'Brand', seed: '#0b6e4f' }] }))
|
|
79
|
+
expect(document.documentElement.getAttribute('data-palette')).toBe('brand')
|
|
80
|
+
})
|
|
81
|
+
})
|
|
55
82
|
})
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { ref, watchEffect } from 'vue'
|
|
3
3
|
import JsBarcode from 'jsbarcode'
|
|
4
4
|
|
|
5
|
+
defineOptions({ inheritAttrs: false })
|
|
6
|
+
|
|
5
7
|
const props = withDefaults(
|
|
6
8
|
defineProps<{
|
|
7
9
|
value: string
|
|
@@ -54,8 +56,8 @@ watchEffect(() => {
|
|
|
54
56
|
</script>
|
|
55
57
|
|
|
56
58
|
<template>
|
|
57
|
-
<div v-if="error" class="flex items-center justify-center text-body-small text-error">
|
|
59
|
+
<div v-if="error" v-bind="$attrs" class="flex items-center justify-center text-body-small text-error">
|
|
58
60
|
<slot name="error">{{ error }}</slot>
|
|
59
61
|
</div>
|
|
60
|
-
<svg v-show="!error" ref="svgEl" role="img" :aria-label="label ?? value"></svg>
|
|
62
|
+
<svg v-show="!error" v-bind="error ? {} : $attrs" ref="svgEl" role="img" :aria-label="label ?? value"></svg>
|
|
61
63
|
</template>
|
|
@@ -17,7 +17,7 @@ const motion = useSheetMotion('y', close)
|
|
|
17
17
|
|
|
18
18
|
<template>
|
|
19
19
|
<Teleport to="body">
|
|
20
|
-
<Transition :css="false" @enter="motion.onEnter" @leave="motion.onLeave">
|
|
20
|
+
<Transition :css="false" @enter="motion.onEnter" @leave="motion.onLeave" appear>
|
|
21
21
|
<div v-if="modelValue" class="fixed inset-0 z-200 flex flex-col justify-end">
|
|
22
22
|
<!-- Scrim -->
|
|
23
23
|
<div data-sheet-scrim class="absolute inset-0 bg-scrim/32" @click="close" />
|