@m3ui-vue/m3ui-vue 0.8.8 → 0.9.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.
- package/README.md +25 -5
- package/dist/API.md +3661 -0
- package/dist/MIcon-CaEooCmZ.js.map +1 -1
- package/dist/{MMenuItem-5xojJYAL.js → MTextField-pJU1vFaR.js} +374 -364
- package/dist/MTextField-pJU1vFaR.js.map +1 -0
- package/dist/api.json +1 -0
- package/dist/barcode.js +9 -11
- package/dist/barcode.js.map +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/code-editor.js +2 -2
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MAbsolute.vue.d.ts +12 -0
- package/dist/components/MAlert.vue.d.ts +4 -0
- package/dist/components/MAppBar.vue.d.ts +12 -0
- package/dist/components/MAppLayout.vue.d.ts +2 -0
- package/dist/components/MAspectRatio.vue.d.ts +1 -0
- package/dist/components/MAutocomplete.vue.d.ts +18 -0
- package/dist/components/MAvatar.vue.d.ts +3 -0
- package/dist/components/MBadge.vue.d.ts +6 -0
- package/dist/components/MBar.vue.d.ts +5 -0
- package/dist/components/MBarcode.vue.d.ts +9 -0
- package/dist/components/MBottomSheet.vue.d.ts +3 -0
- package/dist/components/MBox.vue.d.ts +6 -0
- package/dist/components/MBreadcrumbs.vue.d.ts +2 -0
- package/dist/components/MButton.vue.d.ts +14 -4
- package/dist/components/MButtonGroup.vue.d.ts +7 -0
- package/dist/components/MCalendar.vue.d.ts +8 -0
- package/dist/components/MCard.vue.d.ts +17 -0
- package/dist/components/MCarousel.vue.d.ts +61 -36
- package/dist/components/MCenter.vue.d.ts +1 -0
- package/dist/components/MChart.vue.d.ts +7 -0
- package/dist/components/MChatBubble.vue.d.ts +10 -0
- package/dist/components/MCheckbox.vue.d.ts +5 -0
- package/dist/components/MChip.vue.d.ts +9 -0
- package/dist/components/MCircleProgressBar.vue.d.ts +7 -0
- package/dist/components/MCodeEditor.vue.d.ts +9 -0
- package/dist/components/MColorPicker.vue.d.ts +8 -0
- package/dist/components/MColorPickerModal.vue.d.ts +4 -0
- package/dist/components/MCommandPalette.vue.d.ts +8 -0
- package/dist/components/MConfirmDialog.vue.d.ts +7 -0
- package/dist/components/MContainer.vue.d.ts +4 -0
- package/dist/components/MContextMenu.vue.d.ts +3 -6
- package/dist/components/MCopyButton.vue.d.ts +10 -0
- package/dist/components/MDataTable.vue.d.ts +33 -12
- package/dist/components/MDatePicker.vue.d.ts +16 -0
- package/dist/components/MDatePickerModal.vue.d.ts +9 -0
- package/dist/components/MDateRangePicker.vue.d.ts +18 -0
- package/dist/components/MDateRangePickerModal.vue.d.ts +9 -0
- package/dist/components/MDialog.vue.d.ts +10 -6
- package/dist/components/MDivider.vue.d.ts +6 -0
- package/dist/components/MDragDropList.vue.d.ts +6 -0
- package/dist/components/MEmoji.vue.d.ts +6 -0
- package/dist/components/MEmojiButton.vue.d.ts +5 -0
- package/dist/components/MEmojiSelector.vue.d.ts +21 -5
- package/dist/components/MEmptyState.vue.d.ts +4 -0
- package/dist/components/MExpansionPanel.vue.d.ts +9 -0
- package/dist/components/MExportButton.vue.d.ts +8 -0
- package/dist/components/MFab.vue.d.ts +9 -0
- package/dist/components/MFabMenu.vue.d.ts +15 -1
- package/dist/components/MFileUpload.vue.d.ts +8 -0
- package/dist/components/MFixed.vue.d.ts +10 -0
- package/dist/components/MFlex.vue.d.ts +7 -1
- package/dist/components/MFooter.vue.d.ts +11 -0
- package/dist/components/MFullscreen.vue.d.ts +2 -0
- package/dist/components/MGrid.vue.d.ts +7 -0
- package/dist/components/MHotkeys.vue.d.ts +4 -0
- package/dist/components/MIcon.vue.d.ts +2 -0
- package/dist/components/MIconButton.vue.d.ts +10 -0
- package/dist/components/MInfiniteScroll.vue.d.ts +6 -0
- package/dist/components/MJsonEditor.vue.d.ts +8 -0
- package/dist/components/MJsonViewer.vue.d.ts +4 -0
- package/dist/components/MKanban.vue.d.ts +2 -0
- package/dist/components/MKbd.vue.d.ts +2 -0
- package/dist/components/MLightbox.vue.d.ts +19 -5
- package/dist/components/MList.vue.d.ts +7 -0
- package/dist/components/MListItem.vue.d.ts +24 -0
- package/dist/components/MListSubheader.vue.d.ts +6 -0
- package/dist/components/MLoadingIndicator.vue.d.ts +10 -0
- package/dist/components/MLoadingOverlay.vue.d.ts +5 -0
- package/dist/components/MMarkdown.vue.d.ts +3 -0
- package/dist/components/MMaskField.vue.d.ts +15 -0
- package/dist/components/MMasonry.vue.d.ts +5 -0
- package/dist/components/MMenu.vue.d.ts +3 -6
- package/dist/components/MMenuDivider.vue.d.ts +4 -0
- package/dist/components/MMenuItem.vue.d.ts +5 -0
- package/dist/components/MMultiAutocomplete.vue.d.ts +20 -0
- package/dist/components/MMultiSelect.vue.d.ts +21 -0
- package/dist/components/MNavigationBar.vue.d.ts +2 -0
- package/dist/components/MNavigationDrawer.vue.d.ts +11 -0
- package/dist/components/MNavigationRail.vue.d.ts +9 -6
- package/dist/components/MNavigationSuite.vue.d.ts +5 -3
- package/dist/components/MNumberField.vue.d.ts +17 -0
- package/dist/components/MOverlay.vue.d.ts +3 -0
- package/dist/components/MPageProgress.vue.d.ts +3 -0
- package/dist/components/MPagination.vue.d.ts +3 -0
- package/dist/components/MPasswordMeter.vue.d.ts +1 -0
- package/dist/components/MPinInput.vue.d.ts +11 -0
- package/dist/components/MProgressBar.vue.d.ts +6 -0
- package/dist/components/MPullToRefresh.vue.d.ts +8 -0
- package/dist/components/MQRCode.vue.d.ts +6 -0
- package/dist/components/MRadio.vue.d.ts +5 -0
- package/dist/components/MRadioGroup.vue.d.ts +6 -0
- package/dist/components/MRating.vue.d.ts +11 -0
- package/dist/components/MRelativeTime.vue.d.ts +1 -0
- package/dist/components/MResponsive.vue.d.ts +3 -0
- package/dist/components/MResult.vue.d.ts +6 -0
- package/dist/components/MRichTextEditor.vue.d.ts +8 -0
- package/dist/components/MScheduler.vue.d.ts +48 -1
- package/dist/components/MScrollable.vue.d.ts +3 -0
- package/dist/components/MSearchBar.vue.d.ts +6 -0
- package/dist/components/MSection.vue.d.ts +5 -0
- package/dist/components/MSegmentedButton.vue.d.ts +5 -0
- package/dist/components/MSelect.vue.d.ts +17 -0
- package/dist/components/MShader.vue.d.ts +1 -0
- package/dist/components/MShape.vue.d.ts +1 -1
- package/dist/components/MShortNavigationBar.vue.d.ts +8 -9
- package/dist/components/MSideSheet.vue.d.ts +3 -0
- package/dist/components/MSignaturePad.vue.d.ts +7 -0
- package/dist/components/MSimpleCarousel.vue.d.ts +12 -2
- package/dist/components/MSkeleton.vue.d.ts +8 -0
- package/dist/components/MSlider.vue.d.ts +15 -1
- package/dist/components/MSnackbar.vue.d.ts +1 -0
- package/dist/components/MSpinner.vue.d.ts +6 -0
- package/dist/components/MSplitButton.vue.d.ts +7 -0
- package/dist/components/MSplitter.vue.d.ts +4 -0
- package/dist/components/MSpotlightSearch.vue.d.ts +18 -0
- package/dist/components/MStack.vue.d.ts +8 -1
- package/dist/components/MStatCard.vue.d.ts +7 -0
- package/dist/components/MStepper.vue.d.ts +7 -0
- package/dist/components/MSticky.vue.d.ts +2 -0
- package/dist/components/MSubtitle.vue.d.ts +4 -0
- package/dist/components/MSwitch.vue.d.ts +5 -6
- package/dist/components/MTable.vue.d.ts +17 -4
- package/dist/components/MTabs.vue.d.ts +6 -0
- package/dist/components/MTagInput.vue.d.ts +17 -0
- package/dist/components/MTerminal.vue.d.ts +4 -0
- package/dist/components/MText.vue.d.ts +10 -0
- package/dist/components/MTextField.vue.d.ts +18 -0
- package/dist/components/MTimePicker.vue.d.ts +10 -0
- package/dist/components/MTimePickerModal.vue.d.ts +5 -0
- package/dist/components/MTimeline.vue.d.ts +3 -0
- package/dist/components/MTitle.vue.d.ts +4 -0
- package/dist/components/MToggleButton.vue.d.ts +4 -0
- package/dist/components/MToolbar.vue.d.ts +6 -1
- package/dist/components/MTooltip.vue.d.ts +7 -0
- package/dist/components/MTopAppBar.vue.d.ts +8 -0
- package/dist/components/MTour.vue.d.ts +5 -0
- package/dist/components/MTransferList.vue.d.ts +11 -0
- package/dist/components/MTree.vue.d.ts +11 -0
- package/dist/components/MTreeTable.vue.d.ts +7 -0
- package/dist/components/MVirtualTable.vue.d.ts +6 -0
- package/dist/components/MWindow.vue.d.ts +33 -1
- package/dist/composables/_carouselStrategy.d.ts +101 -0
- package/dist/composables/useLocale.d.ts +21 -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 +140 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +6642 -5160
- package/dist/m3ui.js.map +1 -1
- package/dist/markdown.js +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/plugin.d.ts +6 -0
- package/dist/qrcode.js.map +1 -1
- package/dist/rich-text-editor.js +10 -10
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/terminal.js +34 -27
- package/dist/terminal.js.map +1 -1
- package/dist/{useLocale-D3ZWZ8jY.js → useLocale-Drihe5G2.js} +33 -11
- package/dist/useLocale-Drihe5G2.js.map +1 -0
- package/package.json +4 -2
- 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__/MHotkeys.test.ts +57 -0
- package/src/__tests__/MLightbox.test.ts +313 -5
- 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__/hostLocale.test.ts +57 -0
- package/src/__tests__/plugin.test.ts +28 -1
- package/src/components/MAbsolute.vue +18 -0
- package/src/components/MAlert.vue +12 -0
- package/src/components/MAppBar.vue +12 -0
- package/src/components/MAppLayout.vue +11 -0
- package/src/components/MAspectRatio.vue +6 -0
- package/src/components/MAutocomplete.vue +24 -0
- package/src/components/MAvatar.vue +12 -1
- package/src/components/MBadge.vue +11 -0
- package/src/components/MBar.vue +19 -0
- package/src/components/MBarcode.vue +18 -2
- package/src/components/MBottomSheet.vue +13 -1
- package/src/components/MBox.vue +12 -0
- package/src/components/MBreadcrumbs.vue +7 -0
- package/src/components/MButton.vue +22 -4
- package/src/components/MButtonGroup.vue +13 -0
- package/src/components/MCalendar.vue +14 -0
- package/src/components/MCard.vue +26 -0
- package/src/components/MCarousel.vue +542 -200
- package/src/components/MCenter.vue +6 -0
- package/src/components/MChart.vue +12 -0
- package/src/components/MChatBubble.vue +17 -0
- package/src/components/MCheckbox.vue +11 -0
- package/src/components/MChip.vue +17 -0
- package/src/components/MCircleProgressBar.vue +13 -0
- package/src/components/MCodeEditor.vue +18 -2
- package/src/components/MColorPicker.vue +13 -0
- package/src/components/MColorPickerModal.vue +12 -0
- package/src/components/MCommandPalette.vue +17 -1
- package/src/components/MConfirmDialog.vue +15 -0
- package/src/components/MContainer.vue +9 -0
- package/src/components/MContextMenu.vue +20 -7
- package/src/components/MCopyButton.vue +16 -0
- package/src/components/MDataTable.vue +58 -12
- package/src/components/MDatePicker.vue +21 -0
- package/src/components/MDatePickerModal.vue +17 -1
- package/src/components/MDateRangePicker.vue +23 -0
- package/src/components/MDateRangePickerModal.vue +17 -1
- package/src/components/MDialog.vue +43 -10
- package/src/components/MDivider.vue +6 -0
- package/src/components/MDragDropList.vue +18 -0
- package/src/components/MEmoji.vue +6 -0
- package/src/components/MEmojiButton.vue +11 -0
- package/src/components/MEmojiSelector.vue +486 -78
- package/src/components/MEmptyState.vue +9 -0
- package/src/components/MExpansionPanel.vue +17 -0
- package/src/components/MExportButton.vue +15 -0
- package/src/components/MFab.vue +20 -1
- package/src/components/MFabMenu.vue +20 -0
- package/src/components/MFileUpload.vue +19 -0
- package/src/components/MFixed.vue +16 -0
- package/src/components/MFlex.vue +11 -0
- package/src/components/MFooter.vue +11 -0
- package/src/components/MFullscreen.vue +8 -0
- package/src/components/MGrid.vue +12 -0
- package/src/components/MHotkeys.vue +20 -13
- package/src/components/MIcon.vue +10 -1
- package/src/components/MIconButton.vue +13 -0
- package/src/components/MInfiniteScroll.vue +16 -0
- package/src/components/MJsonEditor.vue +13 -0
- package/src/components/MJsonViewer.vue +7 -0
- package/src/components/MKanban.vue +18 -0
- package/src/components/MKbd.vue +6 -0
- package/src/components/MLightbox.vue +766 -268
- package/src/components/MList.vue +15 -0
- package/src/components/MListDetail.vue +11 -0
- package/src/components/MListItem.vue +37 -0
- package/src/components/MListSubheader.vue +6 -0
- package/src/components/MLoadingIndicator.vue +15 -0
- package/src/components/MLoadingOverlay.vue +18 -1
- package/src/components/MMarkdown.vue +7 -0
- package/src/components/MMaskField.vue +21 -0
- package/src/components/MMasonry.vue +11 -0
- package/src/components/MMenu.vue +19 -7
- package/src/components/MMenuDivider.vue +4 -0
- package/src/components/MMenuItem.vue +16 -0
- package/src/components/MMultiAutocomplete.vue +26 -0
- package/src/components/MMultiSelect.vue +27 -0
- package/src/components/MNavigationBar.vue +7 -0
- package/src/components/MNavigationDrawer.vue +30 -1
- package/src/components/MNavigationRail.vue +27 -6
- package/src/components/MNavigationSuite.vue +20 -3
- package/src/components/MNotificationHost.vue +3 -0
- package/src/components/MNumberField.vue +24 -0
- package/src/components/MOverlay.vue +11 -0
- package/src/components/MPageProgress.vue +7 -0
- package/src/components/MPagination.vue +15 -1
- package/src/components/MPasswordMeter.vue +7 -0
- package/src/components/MPinInput.vue +19 -0
- package/src/components/MProgressBar.vue +9 -0
- package/src/components/MPullToRefresh.vue +17 -0
- package/src/components/MQRCode.vue +12 -0
- package/src/components/MRadio.vue +11 -0
- package/src/components/MRadioGroup.vue +11 -0
- package/src/components/MRating.vue +19 -0
- package/src/components/MRelative.vue +8 -0
- package/src/components/MRelativeTime.vue +6 -0
- package/src/components/MResponsive.vue +9 -0
- package/src/components/MResult.vue +14 -0
- package/src/components/MRichTextEditor.vue +14 -0
- package/src/components/MScheduler.vue +303 -115
- package/src/components/MScrollable.vue +8 -0
- package/src/components/MSearchBar.vue +17 -0
- package/src/components/MSection.vue +13 -0
- package/src/components/MSegmentedButton.vue +10 -0
- package/src/components/MSelect.vue +22 -0
- package/src/components/MShader.vue +13 -0
- package/src/components/MShape.vue +6 -0
- package/src/components/MShortNavigationBar.vue +23 -9
- package/src/components/MSideSheet.vue +14 -1
- package/src/components/MSignaturePad.vue +15 -0
- package/src/components/MSimpleCarousel.vue +18 -0
- package/src/components/MSkeleton.vue +8 -0
- package/src/components/MSlider.vue +21 -0
- package/src/components/MSnackbar.vue +5 -0
- package/src/components/MSpacer.vue +6 -0
- package/src/components/MSpinner.vue +10 -0
- package/src/components/MSplitButton.vue +17 -1
- package/src/components/MSplitter.vue +10 -0
- package/src/components/MSpotlightSearch.vue +28 -1
- package/src/components/MStack.vue +12 -0
- package/src/components/MStatCard.vue +13 -0
- package/src/components/MStepper.vue +12 -0
- package/src/components/MSticky.vue +7 -0
- package/src/components/MSubtitle.vue +9 -0
- package/src/components/MSupportingPane.vue +10 -0
- package/src/components/MSwitch.vue +14 -6
- package/src/components/MTable.vue +33 -4
- package/src/components/MTabs.vue +12 -0
- package/src/components/MTagInput.vue +23 -0
- package/src/components/MTerminal.vue +33 -10
- package/src/components/MText.vue +15 -0
- package/src/components/MTextField.vue +26 -0
- package/src/components/MTimePicker.vue +15 -0
- package/src/components/MTimePickerModal.vue +13 -1
- package/src/components/MTimeline.vue +7 -0
- package/src/components/MTitle.vue +9 -0
- package/src/components/MToggleButton.vue +12 -0
- package/src/components/MToolbar.vue +12 -0
- package/src/components/MTooltip.vue +18 -0
- package/src/components/MTopAppBar.vue +18 -0
- package/src/components/MTour.vue +15 -2
- package/src/components/MTransferList.vue +24 -0
- package/src/components/MTree.vue +11 -0
- package/src/components/MTreeTable.vue +15 -0
- package/src/components/MVirtualTable.vue +12 -0
- package/src/components/MWindow.vue +34 -0
- package/src/composables/_carouselStrategy.ts +712 -0
- package/src/composables/useLocale.ts +54 -3
- 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 +19 -0
- package/src/locales/es.ts +19 -0
- package/src/locales/fr.ts +19 -0
- package/src/locales/ja.ts +19 -0
- package/src/locales/ko.ts +19 -0
- package/src/locales/pt.ts +19 -0
- package/src/locales/zh.ts +19 -0
- package/src/plugin.ts +14 -2
- package/dist/MMenuItem-5xojJYAL.js.map +0 -1
- package/dist/useLocale-D3ZWZ8jY.js.map +0 -1
|
@@ -1,33 +1,195 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { mount } from '@vue/test-utils'
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
2
|
+
import { mount, type VueWrapper } from '@vue/test-utils'
|
|
3
|
+
import { nextTick } from 'vue'
|
|
3
4
|
import MCarousel from '../components/MCarousel.vue'
|
|
5
|
+
import {
|
|
6
|
+
Strategy,
|
|
7
|
+
heroKeylineList,
|
|
8
|
+
maxScrollOffset,
|
|
9
|
+
multiBrowseKeylineList,
|
|
10
|
+
placeItem,
|
|
11
|
+
snapScrollOffset,
|
|
12
|
+
uncontainedKeylineList,
|
|
13
|
+
} from '../composables/_carouselStrategy'
|
|
4
14
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
const sizes = (s: Strategy) => s.defaultKeylines.keylines.map((k) => Math.round(k.size))
|
|
16
|
+
|
|
17
|
+
describe('carousel strategy (Compose port)', () => {
|
|
18
|
+
it('multi-browse arranges large, medium and small items between two anchors', () => {
|
|
19
|
+
const s = new Strategy(multiBrowseKeylineList(380, 186, 8, 6), 380, 8, 0, 0)
|
|
20
|
+
expect(sizes(s)).toEqual([10, 186, 122, 56, 10])
|
|
21
|
+
expect(s.itemMainAxisSize).toBe(186)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('multi-browse drops small items when there are fewer items than keylines', () => {
|
|
25
|
+
// Upstream removes small items first and never removes large ones (they're fully unmasked).
|
|
26
|
+
const s = new Strategy(multiBrowseKeylineList(380, 186, 8, 2), 380, 8, 0, 0)
|
|
27
|
+
expect(s.defaultKeylines.keylines.filter((k) => !k.isAnchor && k.size <= 56)).toHaveLength(0)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('centered hero puts the large item between two small ones', () => {
|
|
31
|
+
const s = new Strategy(heroKeylineList(380, null, 8, 6, true), 380, 8, 0, 0)
|
|
32
|
+
expect(sizes(s)).toEqual([10, 40, 284, 40, 10])
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('uncontained keeps items at their size and cuts off the last visible one', () => {
|
|
36
|
+
const s = new Strategy(uncontainedKeylineList(380, 186, 8), 380, 8, 0, 0)
|
|
37
|
+
expect(s.itemMainAxisSize).toBe(194)
|
|
38
|
+
expect(s.defaultKeylines.keylines.filter((k) => !k.isAnchor).map((k) => k.size)).toEqual([194, 194])
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it.each([
|
|
42
|
+
['multi-browse', multiBrowseKeylineList(412, 186, 8, 7), 7, 16],
|
|
43
|
+
['hero', heroKeylineList(412, null, 8, 7, true), 7, 0],
|
|
44
|
+
['uncontained', uncontainedKeylineList(412, 186, 8), 7, 0],
|
|
45
|
+
] as const)('%s: masked items touch with exactly the item spacing at any scroll', (_name, keylines, count, padding) => {
|
|
46
|
+
const s = new Strategy(keylines, 412, 8, padding, padding)
|
|
47
|
+
const max = maxScrollOffset(s, count)
|
|
48
|
+
for (let scroll = 0; scroll <= max; scroll += max / 23) {
|
|
49
|
+
const spans = Array.from({ length: count }, (_, i) => {
|
|
50
|
+
const p = placeItem(s, i, scroll, max)
|
|
51
|
+
return [p.offset + p.maskStart, p.offset + p.maskStart + p.maskSize] as const
|
|
52
|
+
}).filter(([a, b]) => b > 0 && a < 412)
|
|
53
|
+
for (let i = 1; i < spans.length; i++) {
|
|
54
|
+
expect(spans[i]![0] - spans[i - 1]![1]).toBeCloseTo(8, 3)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('snaps every item, the last one flush with the end padding', () => {
|
|
60
|
+
const s = new Strategy(multiBrowseKeylineList(412, 186, 8, 6), 412, 8, 16, 16)
|
|
61
|
+
const max = maxScrollOffset(s, 6)
|
|
62
|
+
expect(snapScrollOffset(s, 0, 6)).toBe(0)
|
|
63
|
+
expect(snapScrollOffset(s, 5, 6)).toBe(max)
|
|
64
|
+
const last = placeItem(s, 5, max, max)
|
|
65
|
+
expect(last.offset + last.maskStart + last.maskSize).toBeCloseTo(412 - 16, 3)
|
|
66
|
+
const first = placeItem(s, 0, 0, max)
|
|
67
|
+
expect(first.offset + first.maskStart).toBeCloseTo(16, 3)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const items = Array.from({ length: 6 }, (_, i) => ({ src: `${i}.jpg`, label: `Item ${i}` }))
|
|
72
|
+
|
|
73
|
+
function translateOf(el: Element) {
|
|
74
|
+
const m = /translate3d\((-?[\d.]+)px/.exec((el as HTMLElement).style.transform)
|
|
75
|
+
return m ? Number(m[1]) : NaN
|
|
76
|
+
}
|
|
10
77
|
|
|
11
78
|
describe('MCarousel', () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
79
|
+
let wrapper: VueWrapper | null = null
|
|
80
|
+
let rafTime = 0
|
|
81
|
+
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'requestAnimationFrame', 'cancelAnimationFrame', 'performance'] })
|
|
84
|
+
rafTime = 0
|
|
85
|
+
Object.defineProperty(HTMLElement.prototype, 'clientWidth', { configurable: true, get() { return this.classList?.contains('m3-carousel') ? 380 : 0 } })
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
afterEach(() => {
|
|
89
|
+
wrapper?.unmount()
|
|
90
|
+
wrapper = null
|
|
91
|
+
vi.useRealTimers()
|
|
92
|
+
// @ts-expect-error restore happy-dom's own getter
|
|
93
|
+
delete HTMLElement.prototype.clientWidth
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
async function mountCarousel(props: Record<string, unknown> = {}) {
|
|
97
|
+
wrapper = mount(MCarousel, {
|
|
98
|
+
props: { items, ...props, 'onUpdate:modelValue': (v: number) => wrapper!.setProps({ modelValue: v }) },
|
|
99
|
+
attachTo: document.body,
|
|
100
|
+
})
|
|
101
|
+
await nextTick()
|
|
102
|
+
await nextTick()
|
|
103
|
+
return wrapper
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function settle() {
|
|
107
|
+
for (let i = 0; i < 200; i++) {
|
|
108
|
+
rafTime += 16
|
|
109
|
+
vi.advanceTimersByTime(16)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const itemEls = () => wrapper!.findAll('[data-carousel-item]').map((w) => w.element as HTMLElement)
|
|
114
|
+
|
|
115
|
+
it('renders every item as a labelled group inside a carousel region', async () => {
|
|
116
|
+
await mountCarousel({ label: 'Photos' })
|
|
117
|
+
const root = wrapper!.get('.m3-carousel')
|
|
118
|
+
expect(root.attributes('role')).toBe('region')
|
|
119
|
+
expect(root.attributes('aria-roledescription')).toBe('Carousel')
|
|
120
|
+
expect(root.attributes('aria-label')).toBe('Photos')
|
|
121
|
+
expect(itemEls()).toHaveLength(6)
|
|
122
|
+
expect(itemEls()[1]!.getAttribute('aria-label')).toBe('2 of 6')
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('lays items out at the focal size and masks the ones after it', async () => {
|
|
126
|
+
await mountCarousel()
|
|
127
|
+
const [first, second] = itemEls()
|
|
128
|
+
expect(first!.style.width).toBe('186px')
|
|
129
|
+
expect(translateOf(first!)).toBe(0)
|
|
130
|
+
expect(first!.style.clipPath).toBe('inset(0 0px 0 0px round var(--radius-xl))')
|
|
131
|
+
// The medium item (122px) is masked from both sides of its 186px box.
|
|
132
|
+
expect(second!.style.clipPath).toBe('inset(0 32px 0 32px round var(--radius-xl))')
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('ArrowRight moves to the next item and updates v-model', async () => {
|
|
136
|
+
await mountCarousel({ modelValue: 0 })
|
|
137
|
+
await wrapper!.get('.m3-carousel').trigger('keydown', { key: 'ArrowRight' })
|
|
138
|
+
settle()
|
|
139
|
+
expect(wrapper!.emitted('update:modelValue')?.at(-1)).toEqual([1])
|
|
140
|
+
expect(translateOf(itemEls()[1]!)).toBeCloseTo(0, 0)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('setting v-model scrolls to that item', async () => {
|
|
144
|
+
await mountCarousel({ modelValue: 0 })
|
|
145
|
+
await wrapper!.setProps({ modelValue: 3 })
|
|
146
|
+
settle()
|
|
147
|
+
expect(translateOf(itemEls()[3]!)).toBeCloseTo(0, 0)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it('a fast drag advances exactly one item (single-advance fling)', async () => {
|
|
151
|
+
await mountCarousel({ modelValue: 0 })
|
|
152
|
+
const item = itemEls()[0]!
|
|
153
|
+
item.dispatchEvent(new PointerEvent('pointerdown', { pointerId: 1, button: 0, clientX: 300, clientY: 100, bubbles: true }))
|
|
154
|
+
for (let x = 290; x >= 100; x -= 30) {
|
|
155
|
+
rafTime += 10
|
|
156
|
+
vi.advanceTimersByTime(10)
|
|
157
|
+
window.dispatchEvent(new PointerEvent('pointermove', { pointerId: 1, clientX: x, clientY: 100 }))
|
|
158
|
+
}
|
|
159
|
+
window.dispatchEvent(new PointerEvent('pointerup', { pointerId: 1, clientX: 100, clientY: 100 }))
|
|
160
|
+
settle()
|
|
161
|
+
await nextTick()
|
|
162
|
+
expect(wrapper!.props('modelValue')).toBe(1)
|
|
163
|
+
expect(translateOf(itemEls()[1]!)).toBeCloseTo(0, 0)
|
|
15
164
|
})
|
|
16
165
|
|
|
17
|
-
it('
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
166
|
+
it('a drag does not count as a click on the item', async () => {
|
|
167
|
+
await mountCarousel()
|
|
168
|
+
const item = itemEls()[0]!
|
|
169
|
+
item.dispatchEvent(new PointerEvent('pointerdown', { pointerId: 1, button: 0, clientX: 300, clientY: 100, bubbles: true }))
|
|
170
|
+
window.dispatchEvent(new PointerEvent('pointermove', { pointerId: 1, clientX: 250, clientY: 100 }))
|
|
171
|
+
window.dispatchEvent(new PointerEvent('pointerup', { pointerId: 1, clientX: 250, clientY: 100 }))
|
|
172
|
+
item.click()
|
|
173
|
+
expect(wrapper!.emitted('itemClick')).toBeUndefined()
|
|
21
174
|
})
|
|
22
175
|
|
|
23
|
-
it('
|
|
24
|
-
|
|
25
|
-
|
|
176
|
+
it('clicking a partly visible item emits itemClick and brings it into focus', async () => {
|
|
177
|
+
await mountCarousel({ modelValue: 0 })
|
|
178
|
+
itemEls()[1]!.click()
|
|
179
|
+
settle()
|
|
180
|
+
await nextTick()
|
|
181
|
+
expect(wrapper!.emitted('itemClick')?.[0]).toEqual([items[1], 1])
|
|
182
|
+
expect(wrapper!.props('modelValue')).toBe(1)
|
|
26
183
|
})
|
|
27
184
|
|
|
28
|
-
it('
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
185
|
+
it('renders a custom #item slot', async () => {
|
|
186
|
+
wrapper = mount(MCarousel, {
|
|
187
|
+
props: { items },
|
|
188
|
+
slots: { item: `<template #item="{ item, index }"><p class="custom">{{ index }}-{{ item.label }}</p></template>` },
|
|
189
|
+
attachTo: document.body,
|
|
190
|
+
})
|
|
191
|
+
await nextTick()
|
|
192
|
+
expect(wrapper.findAll('.custom').map((w) => w.text())[2]).toBe('2-Item 2')
|
|
193
|
+
expect(wrapper.find('img').exists()).toBe(false)
|
|
32
194
|
})
|
|
33
195
|
})
|
|
@@ -55,4 +55,22 @@ describe('MDialog', () => {
|
|
|
55
55
|
})
|
|
56
56
|
expect(document.body.textContent).toContain('OK')
|
|
57
57
|
})
|
|
58
|
+
|
|
59
|
+
it.each([
|
|
60
|
+
['a Tailwind class', 'max-w-sm', 'max-w-sm', ''],
|
|
61
|
+
['a length', '420px', '', '420px'],
|
|
62
|
+
['a CSS function', 'min(90vw, 40rem)', '', 'min(90vw, 40rem)'],
|
|
63
|
+
])('maxWidth accepts %s', (_name, maxWidth, cls, style) => {
|
|
64
|
+
mount(MDialog, { props: { modelValue: true, maxWidth }, attachTo: document.body })
|
|
65
|
+
const box = document.body.querySelector('.dialog-box') as HTMLElement
|
|
66
|
+
if (cls) expect(box.classList.contains(cls)).toBe(true)
|
|
67
|
+
expect(box.style.maxWidth).toBe(style)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('maxHeight accepts a CSS value alongside a class maxWidth', () => {
|
|
71
|
+
mount(MDialog, { props: { modelValue: true, maxWidth: 'max-w-md', maxHeight: '600px' }, attachTo: document.body })
|
|
72
|
+
const box = document.body.querySelector('.dialog-box') as HTMLElement
|
|
73
|
+
expect(box.classList.contains('max-w-md')).toBe(true)
|
|
74
|
+
expect(box.style.maxHeight).toBe('600px')
|
|
75
|
+
})
|
|
58
76
|
})
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
2
|
+
import { mount, flushPromises, enableAutoUnmount } from '@vue/test-utils'
|
|
3
|
+
import { nextTick } from 'vue'
|
|
4
|
+
import MEmojiSelector from '../components/MEmojiSelector.vue'
|
|
5
|
+
import { M3_LOCALE_KEY } from '../composables/useLocale'
|
|
6
|
+
import { esLocale } from '../locales'
|
|
7
|
+
import { withSkinTone } from '../data/emojis'
|
|
8
|
+
|
|
9
|
+
enableAutoUnmount(afterEach)
|
|
10
|
+
|
|
11
|
+
function mountSelector(props: Record<string, unknown> = {}, locale?: object) {
|
|
12
|
+
return mount(MEmojiSelector, {
|
|
13
|
+
props,
|
|
14
|
+
attachTo: document.body,
|
|
15
|
+
global: locale ? { provide: { [M3_LOCALE_KEY as symbol]: locale } } : undefined,
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Names load with a dynamic import; wait until the buttons carry them. */
|
|
20
|
+
async function namesLoaded(wrapper: ReturnType<typeof mountSelector>) {
|
|
21
|
+
await vi.waitFor(() => {
|
|
22
|
+
expect(wrapper.find('[data-emoji="😀"]').attributes('aria-label')).not.toBe('😀')
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const search = async (wrapper: ReturnType<typeof mountSelector>, text: string) => {
|
|
27
|
+
await wrapper.find('input').setValue(text)
|
|
28
|
+
await flushPromises()
|
|
29
|
+
}
|
|
30
|
+
const shown = (wrapper: ReturnType<typeof mountSelector>) => wrapper.findAll('[data-emoji]').map((b) => b.attributes('data-emoji'))
|
|
31
|
+
|
|
32
|
+
describe('MEmojiSelector', () => {
|
|
33
|
+
beforeEach(() => localStorage.clear())
|
|
34
|
+
|
|
35
|
+
it('groups emoji under localized category headers with a tab each', () => {
|
|
36
|
+
const wrapper = mountSelector()
|
|
37
|
+
expect(wrapper.findAll('[role="tab"]')).toHaveLength(11)
|
|
38
|
+
expect(wrapper.findAll('section h3').map((h) => h.text())[0]).toBe('Smileys')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('labels each emoji with its name', async () => {
|
|
42
|
+
const wrapper = mountSelector()
|
|
43
|
+
await namesLoaded(wrapper)
|
|
44
|
+
expect(wrapper.find('[data-emoji="😀"]').attributes('aria-label')).toBe('Grinning face')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('searches by name and keyword', async () => {
|
|
48
|
+
const wrapper = mountSelector()
|
|
49
|
+
await namesLoaded(wrapper)
|
|
50
|
+
await search(wrapper, 'heart')
|
|
51
|
+
expect(shown(wrapper)).toContain('❤️')
|
|
52
|
+
await search(wrapper, 'pizza')
|
|
53
|
+
expect(shown(wrapper)[0]).toBe('🍕')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('searches in the app language, ignoring accents, and in English too', async () => {
|
|
57
|
+
const wrapper = mountSelector({}, esLocale)
|
|
58
|
+
await namesLoaded(wrapper)
|
|
59
|
+
expect(wrapper.find('[data-emoji="😀"]').attributes('aria-label')).toBe('Cara sonriendo')
|
|
60
|
+
await search(wrapper, 'corazon')
|
|
61
|
+
expect(shown(wrapper)).toContain('❤️')
|
|
62
|
+
await search(wrapper, 'pizza')
|
|
63
|
+
expect(shown(wrapper)).toContain('🍕')
|
|
64
|
+
await search(wrapper, 'grinning')
|
|
65
|
+
await vi.waitFor(() => expect(shown(wrapper)).toContain('😀'))
|
|
66
|
+
expect(wrapper.findAll('section h3').map((h) => h.text())[0]).toBe('Buscar emoji')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('says so when nothing matches', async () => {
|
|
70
|
+
const wrapper = mountSelector()
|
|
71
|
+
await namesLoaded(wrapper)
|
|
72
|
+
await search(wrapper, 'zzzzqqq')
|
|
73
|
+
expect(wrapper.text()).toContain('No emoji found')
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('emits the emoji and shows it first under Recently used', async () => {
|
|
77
|
+
const wrapper = mountSelector()
|
|
78
|
+
await wrapper.find('[data-emoji="🍕"]').trigger('click')
|
|
79
|
+
expect(wrapper.emitted('select')?.[0]).toEqual(['🍕'])
|
|
80
|
+
await nextTick()
|
|
81
|
+
expect(wrapper.findAll('section h3')[0]!.text()).toBe('Recently used')
|
|
82
|
+
expect(shown(wrapper)[0]).toBe('🍕')
|
|
83
|
+
expect(JSON.parse(localStorage.getItem('m3-emoji-recent')!)).toEqual(['🍕'])
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('recent can be turned off', async () => {
|
|
87
|
+
const wrapper = mountSelector({ recent: false })
|
|
88
|
+
await wrapper.find('[data-emoji="🍕"]').trigger('click')
|
|
89
|
+
await nextTick()
|
|
90
|
+
expect(wrapper.findAll('section h3')[0]!.text()).toBe('Smileys')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('a right click on an emoji that takes skin tones offers them, and the choice sticks', async () => {
|
|
94
|
+
const wrapper = mountSelector({ recent: false })
|
|
95
|
+
await wrapper.find('[data-emoji="👍"]').trigger('contextmenu')
|
|
96
|
+
const options = wrapper.findAll('[data-tone-option]')
|
|
97
|
+
expect(options.map((o) => o.text())).toEqual(['👍', '👍🏻', '👍🏼', '👍🏽', '👍🏾', '👍🏿'])
|
|
98
|
+
await options[3]!.trigger('click')
|
|
99
|
+
expect(wrapper.emitted('select')?.[0]).toEqual(['👍🏽'])
|
|
100
|
+
// Every emoji that takes a tone now shows the chosen one.
|
|
101
|
+
expect(wrapper.find(`[data-emoji="${withSkinTone('👋', 3)}"]`).exists()).toBe(true)
|
|
102
|
+
expect(localStorage.getItem('m3-emoji-tone')).toBe('3')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('emoji without skin tones open nothing on right click', async () => {
|
|
106
|
+
const wrapper = mountSelector()
|
|
107
|
+
await wrapper.find('[data-emoji="🍕"]').trigger('contextmenu')
|
|
108
|
+
expect(wrapper.find('[data-tone-picker]').exists()).toBe(false)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('handles the emoji with a variation selector (☝️ → ☝🏽)', () => {
|
|
112
|
+
expect(withSkinTone('☝️', 3)).toBe('☝🏽')
|
|
113
|
+
expect(withSkinTone('🕵️♀️', 1)).toBe('🕵🏻♀️')
|
|
114
|
+
expect(withSkinTone('🍕', 3)).toBe('🍕')
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('arrow keys move through the grid and Enter picks', async () => {
|
|
118
|
+
const wrapper = mountSelector({ recent: false })
|
|
119
|
+
const first = wrapper.find('[data-emoji="😀"]').element as HTMLElement
|
|
120
|
+
expect(first.tabIndex).toBe(0)
|
|
121
|
+
first.focus()
|
|
122
|
+
await wrapper.find('[data-emoji="😀"]').trigger('keydown', { key: 'ArrowRight' })
|
|
123
|
+
expect(document.activeElement?.getAttribute('data-emoji')).toBe('😃')
|
|
124
|
+
;(document.activeElement as HTMLElement).click()
|
|
125
|
+
expect(wrapper.emitted('select')?.[0]).toEqual(['😃'])
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('ArrowDown from the search field goes to the first emoji', async () => {
|
|
129
|
+
const wrapper = mountSelector({ recent: false })
|
|
130
|
+
await wrapper.find('input').trigger('keydown', { key: 'ArrowDown' })
|
|
131
|
+
expect(document.activeElement?.getAttribute('data-emoji')).toBe('😀')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('shows only the requested categories', () => {
|
|
135
|
+
const wrapper = mountSelector({ categories: ['food', 'flags'] })
|
|
136
|
+
expect(wrapper.findAll('section h3').map((h) => h.text())).toEqual(['Food & drink', 'Flags'])
|
|
137
|
+
})
|
|
138
|
+
})
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from 'vitest'
|
|
2
|
+
import { mount, type VueWrapper } from '@vue/test-utils'
|
|
3
|
+
import MHotkeys from '../components/MHotkeys.vue'
|
|
4
|
+
|
|
5
|
+
let wrapper: VueWrapper | null = null
|
|
6
|
+
afterEach(() => { wrapper?.unmount(); wrapper = null })
|
|
7
|
+
|
|
8
|
+
function press(key: string, mods: Partial<KeyboardEventInit> = {}) {
|
|
9
|
+
document.dispatchEvent(new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true, ...mods }))
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('MHotkeys', () => {
|
|
13
|
+
it('fires a mod binding with Ctrl (not on a Mac)', () => {
|
|
14
|
+
const handler = vi.fn()
|
|
15
|
+
wrapper = mount(MHotkeys, { props: { bindings: [{ keys: 'mod+z', label: 'Undo', handler }] } })
|
|
16
|
+
press('z', { ctrlKey: true })
|
|
17
|
+
expect(handler).toHaveBeenCalledTimes(1)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('fires mod+shift combos and not plain mod ones for them', () => {
|
|
21
|
+
const undo = vi.fn()
|
|
22
|
+
const redo = vi.fn()
|
|
23
|
+
wrapper = mount(MHotkeys, {
|
|
24
|
+
props: { bindings: [{ keys: 'mod+z', label: 'Undo', handler: undo }, { keys: 'mod+shift+z', label: 'Redo', handler: redo }] },
|
|
25
|
+
})
|
|
26
|
+
press('Z', { ctrlKey: true, shiftKey: true })
|
|
27
|
+
expect(redo).toHaveBeenCalledTimes(1)
|
|
28
|
+
expect(undo).not.toHaveBeenCalled()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('fires an explicit ctrl binding', () => {
|
|
32
|
+
const handler = vi.fn()
|
|
33
|
+
wrapper = mount(MHotkeys, { props: { bindings: [{ keys: 'ctrl+k', label: 'Search', handler }] } })
|
|
34
|
+
press('k', { ctrlKey: true })
|
|
35
|
+
expect(handler).toHaveBeenCalledTimes(1)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('does not fire when an extra modifier is held', () => {
|
|
39
|
+
const handler = vi.fn()
|
|
40
|
+
wrapper = mount(MHotkeys, { props: { bindings: [{ keys: 'mod+z', label: 'Undo', handler }] } })
|
|
41
|
+
press('z', { ctrlKey: true, altKey: true })
|
|
42
|
+
press('z')
|
|
43
|
+
expect(handler).not.toHaveBeenCalled()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('fires single keys, but not while typing', () => {
|
|
47
|
+
const handler = vi.fn()
|
|
48
|
+
wrapper = mount(MHotkeys, { props: { bindings: [{ keys: 'b', label: 'Brush', handler }] } })
|
|
49
|
+
press('b')
|
|
50
|
+
expect(handler).toHaveBeenCalledTimes(1)
|
|
51
|
+
const input = document.createElement('input')
|
|
52
|
+
document.body.appendChild(input)
|
|
53
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'b', bubbles: true }))
|
|
54
|
+
expect(handler).toHaveBeenCalledTimes(1)
|
|
55
|
+
input.remove()
|
|
56
|
+
})
|
|
57
|
+
})
|