@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,126 +1,534 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* An emoji picker in the style of Android's and Gboard's: the full Unicode set (Emoji 15.0) by category,
|
|
4
|
+
* recently used ones first, skin tones, and search by name in the app's language. The names come from Unicode's
|
|
5
|
+
* CLDR and load only when the picker is used, one language at a time.
|
|
6
|
+
*
|
|
7
|
+
* @event select An emoji was picked, with the skin tone applied
|
|
8
|
+
*/
|
|
9
|
+
/*
|
|
10
|
+
* Emoji picker. M3 has no emoji component; the reference is Google's own androidx
|
|
11
|
+
* EmojiPickerView (a category bar with Recent first, a grid with headers, skin-tone variants on
|
|
12
|
+
* long press) plus Gboard's search.
|
|
13
|
+
*
|
|
14
|
+
* Data: src/data/emojis.ts (Unicode emoji-test, generated) ships with the component; names and
|
|
15
|
+
* keywords (CLDR, one file per language in src/data/emoji-names/) load on demand, for the app's
|
|
16
|
+
* language plus English while searching.
|
|
17
|
+
*/
|
|
18
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
|
|
3
19
|
import MIcon from './MIcon.vue'
|
|
4
|
-
import
|
|
5
|
-
import { emojiCategories, type EmojiCategory } from '../data/emojis'
|
|
20
|
+
import { useLocale, type M3Locale } from '../composables/useLocale'
|
|
21
|
+
import { emojiCategories, toneableEmojis, withSkinTone, type EmojiCategory } from '../data/emojis'
|
|
6
22
|
|
|
7
23
|
const props = withDefaults(
|
|
8
24
|
defineProps<{
|
|
9
25
|
/** Which categories to show (ids). All if empty. */
|
|
10
26
|
categories?: string[]
|
|
11
|
-
/** Show search
|
|
27
|
+
/** Show the search field. */
|
|
12
28
|
search?: boolean
|
|
13
|
-
/**
|
|
29
|
+
/** Fixed number of columns. By default as many as fit. */
|
|
14
30
|
columns?: number
|
|
15
|
-
/** Emoji
|
|
31
|
+
/** Emoji size in px. */
|
|
16
32
|
emojiSize?: number
|
|
33
|
+
/** Remember picked emoji and show them first (stored in localStorage). */
|
|
34
|
+
recent?: boolean
|
|
35
|
+
/** How many recent emoji to keep. */
|
|
36
|
+
recentLimit?: number
|
|
37
|
+
/** Offer skin tones (long press, right click or Shift+Enter on an emoji, or the footer button). */
|
|
38
|
+
skinTones?: boolean
|
|
39
|
+
/** Show the hovered or focused emoji with its name at the bottom. */
|
|
40
|
+
preview?: boolean
|
|
41
|
+
/** Height of the scrolling grid. */
|
|
42
|
+
height?: string
|
|
17
43
|
}>(),
|
|
18
|
-
{ search: true,
|
|
44
|
+
{ search: true, emojiSize: 28, recent: true, recentLimit: 24, skinTones: true, preview: true, height: '320px' },
|
|
19
45
|
)
|
|
20
46
|
|
|
21
47
|
const emit = defineEmits<{
|
|
22
48
|
select: [emoji: string]
|
|
23
49
|
}>()
|
|
24
50
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
51
|
+
const t = useLocale()
|
|
52
|
+
|
|
53
|
+
// ── Names (lazy, per language) ────────────────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
type Names = Record<string, string>
|
|
56
|
+
const loaders: Record<string, () => Promise<{ default: Names }>> = {
|
|
57
|
+
en: () => import('../data/emoji-names/emoji-names-en'),
|
|
58
|
+
es: () => import('../data/emoji-names/emoji-names-es'),
|
|
59
|
+
fr: () => import('../data/emoji-names/emoji-names-fr'),
|
|
60
|
+
pt: () => import('../data/emoji-names/emoji-names-pt'),
|
|
61
|
+
de: () => import('../data/emoji-names/emoji-names-de'),
|
|
62
|
+
ja: () => import('../data/emoji-names/emoji-names-ja'),
|
|
63
|
+
zh: () => import('../data/emoji-names/emoji-names-zh'),
|
|
64
|
+
ko: () => import('../data/emoji-names/emoji-names-ko'),
|
|
65
|
+
}
|
|
66
|
+
const lang = computed(() => {
|
|
67
|
+
const code = (t.lang || 'en').slice(0, 2).toLowerCase()
|
|
68
|
+
return code in loaders ? code : 'en'
|
|
69
|
+
})
|
|
70
|
+
const names = shallowRef<Names | null>(null)
|
|
71
|
+
const englishNames = shallowRef<Names | null>(null)
|
|
72
|
+
|
|
73
|
+
async function load(code: string) {
|
|
74
|
+
return (await loaders[code]!()).default
|
|
75
|
+
}
|
|
76
|
+
watch(lang, async (code) => {
|
|
77
|
+
names.value = await load(code)
|
|
78
|
+
if (code === 'en') englishNames.value = names.value
|
|
79
|
+
}, { immediate: true })
|
|
80
|
+
|
|
81
|
+
/** The emoji's name in the app's language (its first entry). */
|
|
82
|
+
function nameOf(emoji: string) {
|
|
83
|
+
const entry = names.value?.[emoji]
|
|
84
|
+
if (!entry) return ''
|
|
85
|
+
const name = entry.slice(0, entry.indexOf('|') === -1 ? undefined : entry.indexOf('|'))
|
|
86
|
+
return name.charAt(0).toUpperCase() + name.slice(1)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ── Recent and skin tone (per viewer, localStorage) ───────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
const RECENT_KEY = 'm3-emoji-recent'
|
|
92
|
+
const TONE_KEY = 'm3-emoji-tone'
|
|
93
|
+
function read<T>(key: string, fallback: T): T {
|
|
94
|
+
try {
|
|
95
|
+
const v = localStorage.getItem(key)
|
|
96
|
+
return v === null ? fallback : (JSON.parse(v) as T)
|
|
97
|
+
} catch {
|
|
98
|
+
return fallback
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function store(key: string, value: unknown) {
|
|
102
|
+
try { localStorage.setItem(key, JSON.stringify(value)) } catch { /* storage blocked */ }
|
|
103
|
+
}
|
|
104
|
+
const recents = ref<string[]>(read<string[]>(RECENT_KEY, []))
|
|
105
|
+
const tone = ref<number>(read<number>(TONE_KEY, 0))
|
|
29
106
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
107
|
+
const show = (emoji: string) => (props.skinTones ? withSkinTone(emoji, tone.value) : emoji)
|
|
108
|
+
/** Toned variant → its base emoji, for names and the tone row (recent emoji are stored toned). */
|
|
109
|
+
const toneBase = new Map<string, string>()
|
|
110
|
+
for (const e of toneableEmojis) for (let i = 1; i <= 5; i++) toneBase.set(withSkinTone(e, i), e)
|
|
111
|
+
const baseOf = (emoji: string) => toneBase.get(emoji) ?? emoji
|
|
112
|
+
|
|
113
|
+
function pick(emoji: string) {
|
|
114
|
+
emit('select', emoji)
|
|
115
|
+
if (props.recent) {
|
|
116
|
+
recents.value = [emoji, ...recents.value.filter((e) => e !== emoji)].slice(0, props.recentLimit)
|
|
117
|
+
store(RECENT_KEY, recents.value)
|
|
33
118
|
}
|
|
34
|
-
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ── Sections ──────────────────────────────────────────────────────────────────────────────────
|
|
122
|
+
|
|
123
|
+
const categoryLabel: Record<string, keyof M3Locale> = {
|
|
124
|
+
smileys: 'emojiCategorySmileys', gestures: 'emojiCategoryGestures', people: 'emojiCategoryPeople',
|
|
125
|
+
animals: 'emojiCategoryAnimals', nature: 'emojiCategoryNature', food: 'emojiCategoryFood',
|
|
126
|
+
activities: 'emojiCategoryActivities', travel: 'emojiCategoryTravel', objects: 'emojiCategoryObjects',
|
|
127
|
+
symbols: 'emojiCategorySymbols', flags: 'emojiCategoryFlags',
|
|
128
|
+
}
|
|
129
|
+
const labelOf = (c: EmojiCategory) => (categoryLabel[c.id] ? String(t[categoryLabel[c.id]!]) : c.label)
|
|
130
|
+
|
|
131
|
+
const visibleCategories = computed<EmojiCategory[]>(() =>
|
|
132
|
+
props.categories?.length ? emojiCategories.filter((c) => props.categories!.includes(c.id)) : emojiCategories,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
interface Section { id: string; label: string; icon: string; emojis: string[] }
|
|
136
|
+
|
|
137
|
+
const query = ref('')
|
|
138
|
+
const normalize = (s: string) => s.toLowerCase().normalize('NFD').replace(/[̀-ͯ]/g, '')
|
|
139
|
+
|
|
140
|
+
watch(query, (q) => {
|
|
141
|
+
// Searching also matches English names, which people often type regardless of the UI language.
|
|
142
|
+
if (q && !englishNames.value) load('en').then((n) => (englishNames.value = n))
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
const searchIndex = computed(() => {
|
|
146
|
+
const local = names.value
|
|
147
|
+
const english = englishNames.value
|
|
148
|
+
if (!local && !english) return []
|
|
149
|
+
return visibleCategories.value.flatMap((c) =>
|
|
150
|
+
c.emojis.map((emoji) => ({
|
|
151
|
+
emoji,
|
|
152
|
+
name: normalize((local?.[emoji] ?? '').split('|')[0] ?? ''),
|
|
153
|
+
text: normalize(`${local?.[emoji] ?? ''}|${english && english !== local ? english[emoji] ?? '' : ''}`),
|
|
154
|
+
})),
|
|
155
|
+
)
|
|
35
156
|
})
|
|
36
157
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
158
|
+
const results = computed(() => {
|
|
159
|
+
const q = normalize(query.value.trim())
|
|
160
|
+
if (!q) return []
|
|
161
|
+
const tokens = q.split(/\s+/)
|
|
162
|
+
return searchIndex.value
|
|
163
|
+
.filter((it) => tokens.every((tok) => it.text.includes(tok)))
|
|
164
|
+
.map((it) => ({ emoji: it.emoji, rank: it.name.startsWith(q) ? 0 : it.text.split('|').some((w) => w.startsWith(tokens[0]!)) ? 1 : 2 }))
|
|
165
|
+
.sort((a, b) => a.rank - b.rank)
|
|
166
|
+
.map((it) => it.emoji)
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
const sections = computed<Section[]>(() => {
|
|
170
|
+
if (query.value.trim()) return [{ id: 'results', label: t.emojiSearch, icon: 'search', emojis: results.value }]
|
|
171
|
+
const list: Section[] = visibleCategories.value.map((c) => ({ id: c.id, label: labelOf(c), icon: c.icon, emojis: c.emojis }))
|
|
172
|
+
if (props.recent && recents.value.length) list.unshift({ id: 'recent', label: t.emojiRecent, icon: 'schedule', emojis: recents.value })
|
|
173
|
+
return list
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
// ── Scrolling and the category bar ────────────────────────────────────────────────────────────
|
|
177
|
+
|
|
178
|
+
const gridEl = ref<HTMLElement | null>(null)
|
|
179
|
+
const activeSection = ref<string | null>(null)
|
|
180
|
+
let scrollFrame = 0
|
|
181
|
+
|
|
182
|
+
function onScroll() {
|
|
183
|
+
if (scrollFrame) return
|
|
184
|
+
scrollFrame = requestAnimationFrame(() => {
|
|
185
|
+
scrollFrame = 0
|
|
186
|
+
const grid = gridEl.value
|
|
187
|
+
if (!grid) return
|
|
188
|
+
let current = sections.value[0]?.id ?? null
|
|
189
|
+
for (const el of grid.querySelectorAll<HTMLElement>('[data-emoji-section]')) {
|
|
190
|
+
if (el.offsetTop - grid.scrollTop <= 8) current = el.dataset.emojiSection!
|
|
191
|
+
}
|
|
192
|
+
activeSection.value = current
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function scrollToSection(id: string) {
|
|
197
|
+
const grid = gridEl.value
|
|
198
|
+
const el = grid?.querySelector<HTMLElement>(`[data-emoji-section="${id}"]`)
|
|
199
|
+
if (!grid || !el) return
|
|
200
|
+
activeSection.value = id
|
|
201
|
+
// scrollTo on the grid only: scrollIntoView() would scroll the page around it too.
|
|
202
|
+
grid.scrollTo({ top: el.offsetTop, behavior: 'smooth' })
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
watch(sections, () => nextTick(onScroll))
|
|
206
|
+
|
|
207
|
+
const gridColumns = computed(() =>
|
|
208
|
+
props.columns
|
|
209
|
+
? `repeat(${props.columns}, minmax(0, 1fr))`
|
|
210
|
+
: `repeat(auto-fill, minmax(${props.emojiSize + 12}px, 1fr))`,
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
// ── Preview ───────────────────────────────────────────────────────────────────────────────────
|
|
214
|
+
|
|
215
|
+
const previewed = ref<string | null>(null)
|
|
216
|
+
|
|
217
|
+
// ── Keyboard (roving focus over the grid) ─────────────────────────────────────────────────────
|
|
218
|
+
|
|
219
|
+
const focusKey = ref<string | null>(null)
|
|
220
|
+
const keyOf = (section: string, emoji: string) => `${section}:${emoji}`
|
|
221
|
+
const firstKey = computed(() => {
|
|
222
|
+
const s = sections.value.find((x) => x.emojis.length)
|
|
223
|
+
return s ? keyOf(s.id, s.emojis[0]!) : null
|
|
48
224
|
})
|
|
225
|
+
const rovingKey = computed(() => focusKey.value ?? firstKey.value)
|
|
226
|
+
watch(sections, () => (focusKey.value = null))
|
|
227
|
+
|
|
228
|
+
function buttons() {
|
|
229
|
+
return Array.from(gridEl.value?.querySelectorAll<HTMLElement>('[data-emoji]') ?? [])
|
|
230
|
+
}
|
|
49
231
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
|
|
232
|
+
/** Keeps a focused emoji in view below the sticky header, scrolling the grid only. */
|
|
233
|
+
function keepVisible(el: HTMLElement) {
|
|
234
|
+
const grid = gridEl.value
|
|
235
|
+
if (!grid) return
|
|
236
|
+
const g = grid.getBoundingClientRect()
|
|
237
|
+
const r = el.getBoundingClientRect()
|
|
238
|
+
const header = 32
|
|
239
|
+
if (r.top < g.top + header) grid.scrollTop -= g.top + header - r.top
|
|
240
|
+
else if (r.bottom > g.bottom) grid.scrollTop += r.bottom - g.bottom
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function focusButton(el: HTMLElement | undefined) {
|
|
244
|
+
if (!el) return
|
|
245
|
+
focusKey.value = el.dataset.key!
|
|
246
|
+
el.focus({ preventScroll: true })
|
|
247
|
+
keepVisible(el)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function onGridKeydown(e: KeyboardEvent) {
|
|
251
|
+
const list = buttons()
|
|
252
|
+
const i = list.indexOf(document.activeElement as HTMLElement)
|
|
253
|
+
if (i === -1) return
|
|
254
|
+
const cur = list[i]!
|
|
255
|
+
const rect = cur.getBoundingClientRect()
|
|
256
|
+
const sameColumnIn = (rows: HTMLElement[]) =>
|
|
257
|
+
rows.reduce<HTMLElement | undefined>((best, el) => {
|
|
258
|
+
const d = Math.abs(el.getBoundingClientRect().left - rect.left)
|
|
259
|
+
return !best || d < Math.abs(best.getBoundingClientRect().left - rect.left) ? el : best
|
|
260
|
+
}, undefined)
|
|
261
|
+
const rowOf = (from: HTMLElement[], top: number) => from.filter((el) => Math.abs(el.getBoundingClientRect().top - top) < 2)
|
|
262
|
+
|
|
263
|
+
if (e.key === 'ArrowRight') focusButton(list[i + 1])
|
|
264
|
+
else if (e.key === 'ArrowLeft') focusButton(list[i - 1])
|
|
265
|
+
else if (e.key === 'ArrowDown') {
|
|
266
|
+
const next = list.slice(i + 1).find((el) => el.getBoundingClientRect().top > rect.top + 2)
|
|
267
|
+
if (next) focusButton(sameColumnIn(rowOf(list.slice(i + 1), next.getBoundingClientRect().top)))
|
|
268
|
+
} else if (e.key === 'ArrowUp') {
|
|
269
|
+
const prev = [...list.slice(0, i)].reverse().find((el) => el.getBoundingClientRect().top < rect.top - 2)
|
|
270
|
+
if (prev) focusButton(sameColumnIn(rowOf(list.slice(0, i), prev.getBoundingClientRect().top)))
|
|
271
|
+
else searchEl.value?.focus()
|
|
272
|
+
} else if (e.key === 'Home') focusButton(list[0])
|
|
273
|
+
else if (e.key === 'End') focusButton(list[list.length - 1])
|
|
274
|
+
else if ((e.key === 'Enter' && e.shiftKey) || e.key === 'ContextMenu') {
|
|
275
|
+
const emoji = cur.dataset.emoji!
|
|
276
|
+
if (props.skinTones && toneableEmojis.has(baseOf(emoji))) openTones(baseOf(emoji), cur)
|
|
277
|
+
} else return
|
|
278
|
+
e.preventDefault()
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const searchEl = ref<HTMLInputElement | null>(null)
|
|
282
|
+
function onSearchKeydown(e: KeyboardEvent) {
|
|
283
|
+
if (e.key === 'ArrowDown') {
|
|
284
|
+
e.preventDefault()
|
|
285
|
+
focusButton(buttons()[0])
|
|
286
|
+
} else if (e.key === 'Enter') {
|
|
287
|
+
const first = results.value[0]
|
|
288
|
+
if (first) pick(show(first))
|
|
289
|
+
} else if (e.key === 'Escape' && query.value) {
|
|
290
|
+
e.stopPropagation()
|
|
291
|
+
query.value = ''
|
|
55
292
|
}
|
|
56
293
|
}
|
|
57
294
|
|
|
58
|
-
|
|
59
|
-
|
|
295
|
+
// ── Skin tones ────────────────────────────────────────────────────────────────────────────────
|
|
296
|
+
|
|
297
|
+
const rootEl = ref<HTMLElement | null>(null)
|
|
298
|
+
const tonePicker = ref<{ emoji: string | null; x: number; y: number; below: boolean } | null>(null)
|
|
299
|
+
const toneLabels = computed(() => t.emojiSkinTones.split('|'))
|
|
300
|
+
|
|
301
|
+
/** Opens the tone row above `anchor`, for `emoji` (null: the default tone for every emoji). */
|
|
302
|
+
function openTones(emoji: string | null, anchor: HTMLElement) {
|
|
303
|
+
const root = rootEl.value
|
|
304
|
+
if (!root) return
|
|
305
|
+
const r = root.getBoundingClientRect()
|
|
306
|
+
const a = anchor.getBoundingClientRect()
|
|
307
|
+
const below = a.top - r.top < 56
|
|
308
|
+
tonePicker.value = { emoji, x: a.left - r.left + a.width / 2, y: below ? a.bottom - r.top + 4 : a.top - r.top - 4, below }
|
|
309
|
+
nextTick(() => rootEl.value?.querySelector<HTMLElement>('[data-tone-option][aria-checked="true"]')?.focus())
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function chooseTone(i: number) {
|
|
313
|
+
const picker = tonePicker.value
|
|
314
|
+
tone.value = i
|
|
315
|
+
store(TONE_KEY, i)
|
|
316
|
+
tonePicker.value = null
|
|
317
|
+
if (picker?.emoji) pick(withSkinTone(picker.emoji, i))
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function onToneKeydown(e: KeyboardEvent) {
|
|
321
|
+
const opts = Array.from(rootEl.value?.querySelectorAll<HTMLElement>('[data-tone-option]') ?? [])
|
|
322
|
+
const i = opts.indexOf(document.activeElement as HTMLElement)
|
|
323
|
+
if (e.key === 'ArrowRight') opts[Math.min(i + 1, opts.length - 1)]?.focus()
|
|
324
|
+
else if (e.key === 'ArrowLeft') opts[Math.max(i - 1, 0)]?.focus()
|
|
325
|
+
else if (e.key === 'Escape') {
|
|
326
|
+
e.stopPropagation()
|
|
327
|
+
tonePicker.value = null
|
|
328
|
+
} else return
|
|
329
|
+
e.preventDefault()
|
|
60
330
|
}
|
|
61
331
|
|
|
62
|
-
function
|
|
63
|
-
if (
|
|
332
|
+
function onDocPointerDown(e: PointerEvent) {
|
|
333
|
+
if (tonePicker.value && !(e.target as Element).closest('[data-tone-picker]')) tonePicker.value = null
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Long press (touch) opens the tones; the click that ends it doesn't also pick the emoji.
|
|
337
|
+
let pressTimer: ReturnType<typeof setTimeout> | null = null
|
|
338
|
+
let pressStart = { x: 0, y: 0 }
|
|
339
|
+
let suppressClick = false
|
|
340
|
+
|
|
341
|
+
function onEmojiPointerDown(e: PointerEvent, base: string) {
|
|
342
|
+
if (!props.skinTones || !toneableEmojis.has(base) || e.pointerType === 'mouse') return
|
|
343
|
+
const target = e.currentTarget as HTMLElement
|
|
344
|
+
pressStart = { x: e.clientX, y: e.clientY }
|
|
345
|
+
pressTimer = setTimeout(() => {
|
|
346
|
+
pressTimer = null
|
|
347
|
+
suppressClick = true
|
|
348
|
+
openTones(base, target)
|
|
349
|
+
}, 450)
|
|
350
|
+
}
|
|
351
|
+
function onEmojiPointerMove(e: PointerEvent) {
|
|
352
|
+
if (pressTimer && Math.hypot(e.clientX - pressStart.x, e.clientY - pressStart.y) > 8) cancelPress()
|
|
353
|
+
}
|
|
354
|
+
function cancelPress() {
|
|
355
|
+
if (pressTimer) clearTimeout(pressTimer)
|
|
356
|
+
pressTimer = null
|
|
64
357
|
}
|
|
358
|
+
function onEmojiClick(emoji: string) {
|
|
359
|
+
if (suppressClick) {
|
|
360
|
+
suppressClick = false
|
|
361
|
+
return
|
|
362
|
+
}
|
|
363
|
+
pick(emoji)
|
|
364
|
+
}
|
|
365
|
+
function onEmojiContextMenu(e: MouseEvent, base: string) {
|
|
366
|
+
if (!props.skinTones || !toneableEmojis.has(base)) return
|
|
367
|
+
e.preventDefault()
|
|
368
|
+
openTones(base, e.currentTarget as HTMLElement)
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
onMounted(() => {
|
|
372
|
+
document.addEventListener('pointerdown', onDocPointerDown)
|
|
373
|
+
onScroll()
|
|
374
|
+
})
|
|
375
|
+
onBeforeUnmount(() => {
|
|
376
|
+
document.removeEventListener('pointerdown', onDocPointerDown)
|
|
377
|
+
cancelPress()
|
|
378
|
+
if (scrollFrame) cancelAnimationFrame(scrollFrame)
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
defineExpose({ focus: () => (searchEl.value ?? buttons()[0])?.focus() })
|
|
65
382
|
</script>
|
|
66
383
|
|
|
67
384
|
<template>
|
|
68
|
-
<div class="flex w-full flex-col overflow-hidden rounded-xl
|
|
385
|
+
<div ref="rootEl" class="relative flex w-full flex-col overflow-hidden rounded-xl bg-surface-container-high">
|
|
69
386
|
<!-- Search -->
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
387
|
+
<!-- Its own bottom space: while searching the category bar is gone, and the results' sticky
|
|
388
|
+
header would otherwise cover the field's focus outline -->
|
|
389
|
+
<div v-if="search" class="px-3 pt-3 pb-1.5">
|
|
390
|
+
<label class="flex h-12 items-center gap-2 rounded-full bg-surface-container-highest px-4 focus-within:outline-2 focus-within:outline-secondary">
|
|
391
|
+
<MIcon name="search" :size="20" class="shrink-0 text-on-surface-variant" />
|
|
392
|
+
<input
|
|
393
|
+
ref="searchEl"
|
|
394
|
+
v-model="query"
|
|
395
|
+
type="text"
|
|
396
|
+
:placeholder="t.emojiSearch"
|
|
397
|
+
:aria-label="t.emojiSearch"
|
|
398
|
+
class="min-w-0 flex-1 bg-transparent text-body-large text-on-surface outline-none placeholder:text-on-surface-variant"
|
|
399
|
+
@keydown="onSearchKeydown"
|
|
400
|
+
/>
|
|
401
|
+
<button
|
|
402
|
+
v-if="query"
|
|
403
|
+
type="button"
|
|
404
|
+
class="flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-on-surface-variant hover:bg-on-surface/8"
|
|
405
|
+
:aria-label="t.clearSearch"
|
|
406
|
+
@click="query = ''; searchEl?.focus()"
|
|
407
|
+
>
|
|
408
|
+
<MIcon name="close" :size="18" />
|
|
409
|
+
</button>
|
|
410
|
+
</label>
|
|
77
411
|
</div>
|
|
78
412
|
|
|
79
|
-
<!-- Category
|
|
80
|
-
<div class="flex gap-0.5 overflow-x-auto
|
|
413
|
+
<!-- Category bar -->
|
|
414
|
+
<div v-if="!query.trim()" class="flex gap-0.5 overflow-x-auto px-2 pb-1" :class="search ? 'pt-0.5' : 'pt-2'" style="scrollbar-width: none" role="tablist">
|
|
81
415
|
<button
|
|
82
|
-
v-for="
|
|
83
|
-
:key="
|
|
416
|
+
v-for="s in sections"
|
|
417
|
+
:key="s.id"
|
|
84
418
|
type="button"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
419
|
+
role="tab"
|
|
420
|
+
:aria-selected="activeSection === s.id"
|
|
421
|
+
:aria-label="s.label"
|
|
422
|
+
:title="s.label"
|
|
423
|
+
class="flex h-9 min-w-9 flex-1 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150"
|
|
424
|
+
:class="activeSection === s.id ? 'bg-secondary-container text-on-secondary-container' : 'text-on-surface-variant hover:bg-on-surface/8'"
|
|
425
|
+
@click="scrollToSection(s.id)"
|
|
91
426
|
>
|
|
92
|
-
<MIcon :name="
|
|
427
|
+
<MIcon :name="s.icon" :size="20" />
|
|
93
428
|
</button>
|
|
94
429
|
</div>
|
|
95
430
|
|
|
96
|
-
<!--
|
|
97
|
-
<div
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
431
|
+
<!-- Grid -->
|
|
432
|
+
<div
|
|
433
|
+
ref="gridEl"
|
|
434
|
+
class="relative overflow-x-hidden overflow-y-auto px-2 pb-2"
|
|
435
|
+
:style="{ height }"
|
|
436
|
+
@scroll.passive="onScroll"
|
|
437
|
+
@keydown="onGridKeydown"
|
|
438
|
+
>
|
|
439
|
+
<section
|
|
440
|
+
v-for="s in sections"
|
|
441
|
+
:key="s.id"
|
|
442
|
+
:data-emoji-section="s.id"
|
|
443
|
+
role="group"
|
|
444
|
+
:aria-label="s.label"
|
|
445
|
+
>
|
|
446
|
+
<h3 class="sticky top-0 z-10 -mx-2 bg-surface-container-high px-3 py-1.5 text-label-medium text-on-surface-variant">{{ s.label }}</h3>
|
|
447
|
+
<div class="grid gap-0.5" :style="{ gridTemplateColumns: gridColumns }">
|
|
448
|
+
<button
|
|
449
|
+
v-for="emoji in s.emojis"
|
|
450
|
+
:key="emoji"
|
|
451
|
+
type="button"
|
|
452
|
+
:data-emoji="show(emoji)"
|
|
453
|
+
:data-key="keyOf(s.id, emoji)"
|
|
454
|
+
:tabindex="rovingKey === keyOf(s.id, emoji) ? 0 : -1"
|
|
455
|
+
:aria-label="nameOf(baseOf(emoji)) || emoji"
|
|
456
|
+
class="relative flex cursor-pointer items-center justify-center rounded-lg leading-none transition-transform duration-75 select-none hover:bg-on-surface/8 focus-visible:outline-2 focus-visible:outline-secondary active:scale-90"
|
|
457
|
+
:style="{ fontSize: `${emojiSize}px`, height: `${emojiSize + 12}px` }"
|
|
458
|
+
@click="onEmojiClick(show(emoji))"
|
|
459
|
+
@contextmenu="onEmojiContextMenu($event, baseOf(emoji))"
|
|
460
|
+
@pointerdown="onEmojiPointerDown($event, baseOf(emoji))"
|
|
461
|
+
@pointermove="onEmojiPointerMove"
|
|
462
|
+
@pointerup="cancelPress"
|
|
463
|
+
@pointercancel="cancelPress"
|
|
464
|
+
@pointerleave="cancelPress"
|
|
465
|
+
@mouseenter="previewed = show(emoji)"
|
|
466
|
+
@focus="previewed = show(emoji)"
|
|
467
|
+
>
|
|
468
|
+
{{ s.id === 'recent' ? emoji : show(emoji) }}
|
|
469
|
+
<!-- Takes a skin tone: a small corner mark, like Android's picker -->
|
|
470
|
+
<span
|
|
471
|
+
v-if="skinTones && s.id !== 'recent' && toneableEmojis.has(emoji)"
|
|
472
|
+
aria-hidden="true"
|
|
473
|
+
class="absolute right-1 bottom-1 h-1.5 w-1.5 bg-on-surface-variant/50 [clip-path:polygon(100%_0,100%_100%,0_100%)]"
|
|
474
|
+
/>
|
|
475
|
+
</button>
|
|
115
476
|
</div>
|
|
477
|
+
</section>
|
|
478
|
+
|
|
479
|
+
<p v-if="query.trim() && !results.length" class="py-10 text-center text-body-medium text-on-surface-variant">
|
|
480
|
+
{{ names || englishNames ? t.emojiNoResults : '…' }}
|
|
481
|
+
</p>
|
|
482
|
+
</div>
|
|
483
|
+
|
|
484
|
+
<!-- Preview and default skin tone -->
|
|
485
|
+
<div v-if="preview || skinTones" class="flex h-14 items-center gap-3 border-t border-outline-variant/60 px-4">
|
|
486
|
+
<template v-if="preview && previewed">
|
|
487
|
+
<span class="text-[32px] leading-none" aria-hidden="true">{{ previewed }}</span>
|
|
488
|
+
<span class="min-w-0 flex-1 truncate text-body-medium text-on-surface">{{ nameOf(baseOf(previewed)) }}</span>
|
|
116
489
|
</template>
|
|
490
|
+
<span v-else class="flex-1" />
|
|
491
|
+
<button
|
|
492
|
+
v-if="skinTones"
|
|
493
|
+
type="button"
|
|
494
|
+
class="flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-full text-[22px] leading-none hover:bg-on-surface/8"
|
|
495
|
+
:aria-label="`${t.emojiSkinTone}: ${toneLabels[tone] ?? ''}`"
|
|
496
|
+
:title="t.emojiSkinTone"
|
|
497
|
+
@click="openTones(null, $event.currentTarget as HTMLElement)"
|
|
498
|
+
>
|
|
499
|
+
{{ withSkinTone('✋', tone) }}
|
|
500
|
+
</button>
|
|
501
|
+
</div>
|
|
117
502
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
503
|
+
<!-- Skin tone row -->
|
|
504
|
+
<div
|
|
505
|
+
v-if="tonePicker"
|
|
506
|
+
data-tone-picker
|
|
507
|
+
role="radiogroup"
|
|
508
|
+
:aria-label="t.emojiSkinTone"
|
|
509
|
+
class="absolute z-30 flex gap-0.5 rounded-full bg-surface-container-highest p-1 shadow-elevation-2"
|
|
510
|
+
:style="{
|
|
511
|
+
left: `clamp(4px, ${tonePicker.x}px - ${(emojiSize + 12) * 3}px, calc(100% - ${(emojiSize + 12) * 6 + 12}px))`,
|
|
512
|
+
top: `${tonePicker.y}px`,
|
|
513
|
+
transform: tonePicker.below ? undefined : 'translateY(-100%)',
|
|
514
|
+
}"
|
|
515
|
+
@keydown="onToneKeydown"
|
|
516
|
+
>
|
|
517
|
+
<button
|
|
518
|
+
v-for="(label, i) in toneLabels"
|
|
519
|
+
:key="i"
|
|
520
|
+
type="button"
|
|
521
|
+
role="radio"
|
|
522
|
+
data-tone-option
|
|
523
|
+
:aria-checked="tone === i"
|
|
524
|
+
:aria-label="label"
|
|
525
|
+
class="flex cursor-pointer items-center justify-center rounded-full leading-none hover:bg-on-surface/8 focus-visible:outline-2 focus-visible:outline-secondary"
|
|
526
|
+
:class="tone === i ? 'bg-secondary-container' : ''"
|
|
527
|
+
:style="{ fontSize: `${emojiSize}px`, width: `${emojiSize + 12}px`, height: `${emojiSize + 12}px` }"
|
|
528
|
+
@click="chooseTone(i)"
|
|
121
529
|
>
|
|
122
|
-
|
|
123
|
-
</
|
|
530
|
+
{{ withSkinTone(tonePicker.emoji ?? '✋', i) }}
|
|
531
|
+
</button>
|
|
124
532
|
</div>
|
|
125
533
|
</div>
|
|
126
534
|
</template>
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A placeholder for empty views — icon, title, description, and optional action buttons.
|
|
4
|
+
*
|
|
5
|
+
* @slot actions Action buttons rendered below the description
|
|
6
|
+
*/
|
|
2
7
|
import MIcon from './MIcon.vue'
|
|
3
8
|
|
|
4
9
|
withDefaults(defineProps<{
|
|
10
|
+
/** Material Symbol icon */
|
|
5
11
|
icon?: string
|
|
12
|
+
/** Title text — required */
|
|
6
13
|
title: string
|
|
14
|
+
/** Supporting description */
|
|
7
15
|
description?: string
|
|
16
|
+
/** Smaller variant (24px icon in a 48px circle, less padding) */
|
|
8
17
|
compact?: boolean
|
|
9
18
|
}>(), { icon: 'inbox' })
|
|
10
19
|
</script>
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A collapsible section with a smooth height animation. Works controlled via v-model, or uncontrolled by simply
|
|
4
|
+
* omitting modelValue.
|
|
5
|
+
*
|
|
6
|
+
* @slot default Panel body content, revealed with a height animation when open
|
|
7
|
+
* @event update:modelValue Emitted when the panel is toggled — only meaningful when modelValue is passed
|
|
8
|
+
* (controlled usage); powers v-model
|
|
9
|
+
*/
|
|
2
10
|
import { computed, ref } from 'vue'
|
|
3
11
|
import MIcon from './MIcon.vue'
|
|
4
12
|
|
|
5
13
|
const props = withDefaults(defineProps<{
|
|
14
|
+
/** Panel header text */
|
|
6
15
|
title: string
|
|
16
|
+
/** Secondary text in the header, below the title */
|
|
7
17
|
subtitle?: string
|
|
18
|
+
/** Leading Material Symbol icon in the header */
|
|
8
19
|
icon?: string
|
|
20
|
+
/**
|
|
21
|
+
* Open/closed state (v-model). Omit it entirely to let the panel manage its own open state internally
|
|
22
|
+
* (uncontrolled).
|
|
23
|
+
*/
|
|
9
24
|
modelValue?: boolean
|
|
25
|
+
/** Disables toggling */
|
|
10
26
|
disabled?: boolean
|
|
27
|
+
/** Visual style of the panel container */
|
|
11
28
|
variant?: 'outlined' | 'filled' | 'elevated'
|
|
12
29
|
}>(), { modelValue: undefined, disabled: false, variant: 'outlined' })
|
|
13
30
|
|