@m3ui-vue/m3ui-vue 0.9.0 → 0.9.2
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 +53 -2
- package/dist/API.md +3806 -0
- package/dist/MIcon-CaEooCmZ.js.map +1 -1
- package/dist/{MTextField-B0wGv1Mx.js → MTextField-Ck0oWDMk.js} +9 -3
- package/dist/MTextField-Ck0oWDMk.js.map +1 -0
- package/dist/api.json +1 -0
- 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 +8 -2
- 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 +7 -1
- 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 +20 -0
- package/dist/components/MColorPickerModal.vue.d.ts +16 -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 +9 -7
- package/dist/components/MDivider.vue.d.ts +6 -0
- package/dist/components/MDragDropList.vue.d.ts +6 -0
- package/dist/components/MDragHandle.vue.d.ts +12 -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 +1 -1
- 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 +10 -1
- 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 +6 -0
- 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 +4 -0
- package/dist/components/MList.vue.d.ts +7 -0
- package/dist/components/MListItem.vue.d.ts +29 -5
- 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 +4 -1
- 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 +10 -0
- package/dist/components/MScrollField.vue.d.ts +40 -0
- package/dist/components/MScrollable.vue.d.ts +12 -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/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 +10 -0
- package/dist/components/MSkeleton.vue.d.ts +8 -0
- package/dist/components/MSlider.vue.d.ts +14 -0
- 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 +6 -2
- package/dist/components/MSpotlightSearch.vue.d.ts +18 -0
- package/dist/components/MStack.vue.d.ts +7 -0
- 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/MSwipeToDismiss.vue.d.ts +49 -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 +5 -0
- 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/MTransition.vue.d.ts +34 -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/components/_MColorPanel.vue.d.ts +18 -0
- package/dist/composables/_colorUtils.d.ts +34 -0
- package/dist/composables/_themeColor.d.ts +1 -0
- package/dist/composables/_useSpring.d.ts +15 -0
- package/dist/composables/dynamicColor.d.ts +18 -0
- package/dist/composables/useColorPalette.d.ts +27 -0
- package/dist/composables/useLocale.d.ts +12 -0
- package/dist/index.d.ts +9 -1
- package/dist/locales/index.js +70 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +6456 -5273
- package/dist/m3ui.js.map +1 -1
- package/dist/markdown.js +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/material-color-utilities-Cktu8DBU.js +3160 -0
- package/dist/material-color-utilities-Cktu8DBU.js.map +1 -0
- package/dist/plugin.d.ts +18 -0
- package/dist/qrcode.js.map +1 -1
- package/dist/rich-text-editor.js +3 -3
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles/palettes.css +546 -0
- package/dist/styles/theme.css +77 -0
- package/dist/styles.css +1 -1
- package/dist/terminal.js.map +1 -1
- package/dist/{useLocale-CmI675Ab.js → useLocale-CFW8cIzL.js} +23 -10
- package/dist/useLocale-CFW8cIzL.js.map +1 -0
- package/package.json +5 -2
- package/src/__tests__/MButtonGroup.test.ts +51 -0
- package/src/__tests__/MColorPicker.test.ts +141 -0
- package/src/__tests__/MDragHandle.test.ts +57 -0
- package/src/__tests__/MHotkeys.test.ts +57 -0
- package/src/__tests__/MListItemShape.test.ts +76 -0
- package/src/__tests__/MScrollField.test.ts +41 -0
- package/src/__tests__/MScrollable.test.ts +42 -0
- package/src/__tests__/MSwipeToDismiss.test.ts +104 -0
- package/src/__tests__/MTransition.test.ts +27 -0
- package/src/__tests__/dynamicColor.test.ts +191 -0
- package/src/__tests__/hostLocale.test.ts +57 -0
- 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 +14 -0
- package/src/components/MBottomSheet.vue +12 -0
- package/src/components/MBox.vue +15 -1
- package/src/components/MBreadcrumbs.vue +7 -0
- package/src/components/MButton.vue +22 -4
- package/src/components/MButtonGroup.vue +129 -35
- package/src/components/MCalendar.vue +14 -0
- package/src/components/MCard.vue +26 -0
- package/src/components/MCarousel.vue +17 -1
- 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 +15 -0
- package/src/components/MColorPicker.vue +124 -207
- package/src/components/MColorPickerModal.vue +58 -247
- package/src/components/MCommandPalette.vue +16 -0
- package/src/components/MConfirmDialog.vue +15 -0
- package/src/components/MContainer.vue +9 -0
- package/src/components/MContextMenu.vue +17 -6
- 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 +16 -0
- package/src/components/MDateRangePicker.vue +23 -0
- package/src/components/MDateRangePickerModal.vue +16 -0
- package/src/components/MDialog.vue +27 -7
- package/src/components/MDivider.vue +6 -0
- package/src/components/MDragDropList.vue +18 -0
- package/src/components/MDragHandle.vue +54 -0
- package/src/components/MEmoji.vue +6 -0
- package/src/components/MEmojiButton.vue +11 -0
- package/src/components/MEmojiSelector.vue +7 -0
- 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 +17 -0
- 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 +16 -0
- package/src/components/MList.vue +48 -3
- package/src/components/MListDetail.vue +11 -0
- package/src/components/MListItem.vue +112 -5
- package/src/components/MListSubheader.vue +6 -0
- package/src/components/MLoadingIndicator.vue +15 -0
- package/src/components/MLoadingOverlay.vue +12 -0
- 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 +16 -6
- 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 +25 -0
- package/src/components/MNavigationRail.vue +24 -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 +10 -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 +21 -0
- package/src/components/MScrollField.vue +302 -0
- package/src/components/MScrollable.vue +167 -4
- 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 +13 -0
- 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 +14 -0
- package/src/components/MSplitter.vue +42 -9
- package/src/components/MSpotlightSearch.vue +27 -0
- 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/MSwipeToDismiss.vue +247 -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 +11 -0
- 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 +12 -0
- 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 +15 -0
- package/src/components/MTopAppBar.vue +18 -0
- package/src/components/MTour.vue +13 -0
- package/src/components/MTransferList.vue +24 -0
- package/src/components/MTransition.vue +149 -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/components/_MColorPanel.vue +478 -0
- package/src/composables/_colorUtils.ts +107 -0
- package/src/composables/_themeColor.ts +33 -0
- package/src/composables/_useSpring.ts +89 -0
- package/src/composables/dynamicColor.ts +85 -0
- package/src/composables/useColorPalette.ts +171 -25
- package/src/composables/useFieldBg.ts +6 -0
- package/src/composables/useLocale.ts +38 -3
- package/src/index.ts +9 -1
- package/src/locales/de.ts +10 -0
- package/src/locales/es.ts +10 -0
- package/src/locales/fr.ts +10 -0
- package/src/locales/ja.ts +10 -0
- package/src/locales/ko.ts +10 -0
- package/src/locales/pt.ts +10 -0
- package/src/locales/zh.ts +10 -0
- package/src/plugin.ts +30 -8
- package/src/styles/palettes.css +546 -0
- package/src/styles/theme.css +77 -0
- package/dist/MTextField-B0wGv1Mx.js.map +0 -1
- package/dist/useLocale-CmI675Ab.js.map +0 -1
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Registers global keyboard shortcuts for as long as it's mounted, with an optional on-screen overlay listing
|
|
4
|
+
* them grouped by category.
|
|
5
|
+
*/
|
|
2
6
|
import { onMounted, onBeforeUnmount } from 'vue'
|
|
3
7
|
|
|
4
8
|
export interface HotkeyBinding {
|
|
@@ -11,7 +15,11 @@ export interface HotkeyBinding {
|
|
|
11
15
|
|
|
12
16
|
const props = withDefaults(
|
|
13
17
|
defineProps<{
|
|
18
|
+
/** Array of key combos to register globally; see `HotkeyBinding` */
|
|
14
19
|
bindings: HotkeyBinding[]
|
|
20
|
+
/**
|
|
21
|
+
* Render a visible list of the registered shortcuts (otherwise the component is invisible and only listens)
|
|
22
|
+
*/
|
|
15
23
|
showOverlay?: boolean
|
|
16
24
|
}>(),
|
|
17
25
|
{ showOverlay: false },
|
|
@@ -41,22 +49,21 @@ function parseCombo(keys: string) {
|
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
function matchesEvent(combo: string[], e: KeyboardEvent): boolean {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
// `mod` is resolved to the platform's physical key first: comparing it as a fifth modifier
|
|
53
|
+
// made Ctrl count as both `ctrl` and `mod`, so neither `mod+z` nor `ctrl+z` ever matched.
|
|
54
|
+
const wanted = { ctrl: false, alt: false, shift: false, meta: false }
|
|
55
|
+
let key = ''
|
|
47
56
|
for (const part of combo) {
|
|
48
|
-
if (part
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return false
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
for (const [mod, active] of Object.entries(modifiers)) {
|
|
56
|
-
if (active && !combo.includes(mod)) return false
|
|
57
|
+
if (part === 'mod') wanted[isMac ? 'meta' : 'ctrl'] = true
|
|
58
|
+
else if (part in wanted) wanted[part as keyof typeof wanted] = true
|
|
59
|
+
else key = part
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
return
|
|
62
|
+
return e.ctrlKey === wanted.ctrl
|
|
63
|
+
&& e.altKey === wanted.alt
|
|
64
|
+
&& e.shiftKey === wanted.shift
|
|
65
|
+
&& e.metaKey === wanted.meta
|
|
66
|
+
&& e.key.toLowerCase() === key
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
function onKeydown(e: KeyboardEvent) {
|
package/src/components/MIcon.vue
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Renders a Material Symbols Outlined glyph by name. Color follows the surrounding text color (set it with a
|
|
4
|
+
* Tailwind text-* class).
|
|
5
|
+
*/
|
|
6
|
+
withDefaults(defineProps<{
|
|
7
|
+
/** Material Symbol name (e.g. "settings", "favorite") */
|
|
8
|
+
name: string
|
|
9
|
+
/** Icon size in px */
|
|
10
|
+
size?: number
|
|
11
|
+
}>(), { size: 24 })
|
|
3
12
|
</script>
|
|
4
13
|
|
|
5
14
|
<template>
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A button that shows only an icon — four visual styles, the same 5-tier expressive sizing as MButton.
|
|
4
|
+
*/
|
|
2
5
|
import { computed } from 'vue'
|
|
3
6
|
import MIcon from './MIcon.vue'
|
|
4
7
|
|
|
5
8
|
const props = withDefaults(
|
|
6
9
|
defineProps<{
|
|
10
|
+
/** Material Symbol icon name */
|
|
7
11
|
icon: string
|
|
12
|
+
/** Accessible label (aria-label and title) */
|
|
8
13
|
label?: string
|
|
14
|
+
/** Visual style */
|
|
9
15
|
variant?: 'standard' | 'filled' | 'tonal' | 'outlined'
|
|
16
|
+
/**
|
|
17
|
+
* Button shape — rounded (pill, always) or squared (corner radius scales with size: 12px xs/sm, 16px md,
|
|
18
|
+
* 28px lg/xl)
|
|
19
|
+
*/
|
|
10
20
|
shape?: 'rounded' | 'squared'
|
|
21
|
+
/** M3's 5-tier icon button sizing (xs:32, sm:40, md:56, lg:96, xl:136), or a custom pixel value */
|
|
11
22
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number
|
|
23
|
+
/** Disables interaction */
|
|
12
24
|
disabled?: boolean
|
|
25
|
+
/** Vue Router destination — renders as RouterLink instead of button */
|
|
13
26
|
to?: string | Record<string, any>
|
|
14
27
|
}>(),
|
|
15
28
|
{
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a scrollable list and emits load when an IntersectionObserver sentinel at the bottom becomes visible —
|
|
4
|
+
* hand it your own fetch-more logic.
|
|
5
|
+
*
|
|
6
|
+
* @slot default The content list itself
|
|
7
|
+
* @slot loading Custom loading indicator, shown when loading is true
|
|
8
|
+
* @slot end Custom end-of-list content, shown when ended is true
|
|
9
|
+
* @slot idle Content shown when neither loading nor ended (empty by default)
|
|
10
|
+
* @event load Emitted when the sentinel scrolls into view and more items should be fetched
|
|
11
|
+
*/
|
|
2
12
|
import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
|
|
3
13
|
import MSpinner from './MSpinner.vue'
|
|
4
14
|
import { useLocale } from '../composables/useLocale'
|
|
@@ -7,11 +17,17 @@ const locale = useLocale()
|
|
|
7
17
|
|
|
8
18
|
const props = withDefaults(
|
|
9
19
|
defineProps<{
|
|
20
|
+
/** Currently loading more items — shows the loading slot */
|
|
10
21
|
loading?: boolean
|
|
22
|
+
/** Disable the load trigger entirely (no observer attached) */
|
|
11
23
|
disabled?: boolean
|
|
24
|
+
/** Distance in px from the sentinel before it triggers load */
|
|
12
25
|
threshold?: number
|
|
26
|
+
/** Text shown while loading (defaults to the locale string, 'Loading...') */
|
|
13
27
|
loadingText?: string
|
|
28
|
+
/** Text shown when ended (defaults to the locale string, 'No more items') */
|
|
14
29
|
endText?: string
|
|
30
|
+
/** No more items to load — shows the end slot and stops observing */
|
|
15
31
|
ended?: boolean
|
|
16
32
|
}>(),
|
|
17
33
|
{
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A JSON-aware editor built on top of MCodeEditor — validates as you type and adds format/minify shortcuts.
|
|
4
|
+
*
|
|
5
|
+
* @event update:modelValue Emitted with the parsed value whenever the text is valid JSON — powers v-model
|
|
6
|
+
*/
|
|
2
7
|
import { ref, computed, watch } from 'vue'
|
|
3
8
|
import MCodeEditor from './MCodeEditor.vue'
|
|
4
9
|
import MIcon from './MIcon.vue'
|
|
@@ -15,10 +20,18 @@ const locale = useLocale()
|
|
|
15
20
|
|
|
16
21
|
const props = withDefaults(
|
|
17
22
|
defineProps<{
|
|
23
|
+
/** JSON data (v-model, any valid JSON) */
|
|
18
24
|
modelValue: unknown
|
|
25
|
+
/** Read-only mode */
|
|
19
26
|
readonly?: boolean
|
|
27
|
+
/** Min height */
|
|
20
28
|
minHeight?: string
|
|
29
|
+
/** Max height */
|
|
21
30
|
maxHeight?: string
|
|
31
|
+
/**
|
|
32
|
+
* Overrides for the valid/invalid badge and format/minify button text (see `JsonEditorLabels`) — defaults come
|
|
33
|
+
* from useLocale()
|
|
34
|
+
*/
|
|
22
35
|
labels?: JsonEditorLabels
|
|
23
36
|
}>(),
|
|
24
37
|
{
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A read-only, recursively expandable tree view for inspecting JSON-compatible data.
|
|
4
|
+
*/
|
|
2
5
|
import { ref, computed } from 'vue'
|
|
3
6
|
import MIcon from './MIcon.vue'
|
|
4
7
|
import { useLocale } from '../composables/useLocale'
|
|
@@ -12,9 +15,13 @@ const locale = useLocale()
|
|
|
12
15
|
|
|
13
16
|
const props = withDefaults(
|
|
14
17
|
defineProps<{
|
|
18
|
+
/** Data to display (any JSON-compatible value) */
|
|
15
19
|
data: unknown
|
|
20
|
+
/** Name for the root node */
|
|
16
21
|
rootName?: string
|
|
22
|
+
/** Levels to expand by default */
|
|
17
23
|
expandDepth?: number
|
|
24
|
+
/** Overrides for the collapsed-node summary text (see `JsonViewerLabels`) — defaults come from useLocale() */
|
|
18
25
|
labels?: JsonViewerLabels
|
|
19
26
|
/** @internal — used by recursive instances */
|
|
20
27
|
_depth?: number
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A drag-and-drop board. Cards lift and follow the pointer, the others make room, and a dashed slot shows where
|
|
4
|
+
* the card will land. Works with a mouse, a finger (long-press a card) and the keyboard; the board scrolls
|
|
5
|
+
* sideways on its own when you drag near its edges.
|
|
6
|
+
*
|
|
7
|
+
* @slot card Content of each card. column is the full KanbanColumn; dragging is true while the card is lifted.
|
|
8
|
+
* Buttons, links and inputs inside keep working: they never start a drag or fire cardClick. Add
|
|
9
|
+
* data-kanban-action to any other element (a badge, a span) to give it the same treatment, so a click there
|
|
10
|
+
* can do something else instead of opening the card
|
|
11
|
+
* @slot column-header Replaces the default header (color dot, title and count)
|
|
12
|
+
* @slot column-footer Content below each column's cards, e.g. an "Add card" button
|
|
13
|
+
* @event update:modelValue Emitted after a card moves, by pointer or keyboard (v-model)
|
|
14
|
+
* @event cardMove Emitted alongside update:modelValue with where the card went. Not emitted when a card is
|
|
15
|
+
* dropped back where it was
|
|
16
|
+
* @event cardClick Emitted when a card is clicked or Enter is pressed on it. Not emitted at the end of a drag
|
|
17
|
+
*/
|
|
2
18
|
import { ref, onBeforeUpdate, onUpdated, onMounted, onBeforeUnmount } from 'vue'
|
|
3
19
|
import MIcon from './MIcon.vue'
|
|
4
20
|
import { useLocale } from '../composables/useLocale'
|
|
@@ -18,7 +34,9 @@ export interface KanbanColumn {
|
|
|
18
34
|
}
|
|
19
35
|
|
|
20
36
|
const props = defineProps<{
|
|
37
|
+
/** Columns with their cards (v-model). Required */
|
|
21
38
|
modelValue: KanbanColumn[]
|
|
39
|
+
/** Text shown in a column with no cards (defaults to the locale string) */
|
|
22
40
|
emptyText?: string
|
|
23
41
|
}>()
|
|
24
42
|
|
package/src/components/MKbd.vue
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Displays a keyboard shortcut as styled key chips. Purely presentational — pairs well with MHotkeys or
|
|
4
|
+
* MCommandPalette to show the shortcut that triggers an action.
|
|
5
|
+
*/
|
|
2
6
|
import { computed } from 'vue'
|
|
3
7
|
|
|
4
8
|
const props = withDefaults(
|
|
5
9
|
defineProps<{
|
|
6
10
|
/** A '+'-delimited string ("Ctrl+Shift+K") or an array of keys (['Ctrl', 'Shift', 'K']). */
|
|
7
11
|
keys: string | string[]
|
|
12
|
+
/** Key chip size */
|
|
8
13
|
size?: 'sm' | 'md' | 'lg'
|
|
14
|
+
/** Separator rendered between keys */
|
|
9
15
|
separator?: string
|
|
10
16
|
}>(),
|
|
11
17
|
{
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A full-screen image viewer in the style of Google Photos. Images grow out of the picture you tapped and
|
|
4
|
+
* shrink back into it, you swipe between them with the next one already in view, zoom with a double tap or a
|
|
5
|
+
* pinch, and drag one down to close. Tapping the image hides the bars. Wrap your content and it finds the `<img>`
|
|
6
|
+
* elements by itself, or pass items.
|
|
7
|
+
*
|
|
8
|
+
* @slot default Content to scan for `<img>` elements when items is not given
|
|
9
|
+
* @slot actions Extra buttons in the top bar, for the image being shown (download, share, info…)
|
|
10
|
+
* @event update:modelValue Fires when the lightbox opens or closes
|
|
11
|
+
* @event update:index Fires whenever the current index changes (next/prev/goTo/auto-detected image click)
|
|
12
|
+
* @event change Fires alongside update:index with the new index
|
|
13
|
+
*/
|
|
2
14
|
/*
|
|
3
15
|
* Full-screen image viewer. M3 has no lightbox component; the reference is Google Photos' viewer:
|
|
4
16
|
* a black stage, a top bar (close, position, actions) and a bottom area (caption, thumbnails) that
|
|
@@ -29,11 +41,15 @@ defineOptions({ inheritAttrs: false })
|
|
|
29
41
|
|
|
30
42
|
const props = withDefaults(
|
|
31
43
|
defineProps<{
|
|
44
|
+
/** v-model — open/closed state */
|
|
32
45
|
modelValue?: boolean
|
|
33
46
|
/** Explicit gallery. Omit it to auto-detect `<img>` elements rendered in the default slot instead. */
|
|
34
47
|
items?: LightboxItem[]
|
|
48
|
+
/** v-model:index — current image index */
|
|
35
49
|
index?: number
|
|
50
|
+
/** Wrap around when navigating past the first/last image */
|
|
36
51
|
loop?: boolean
|
|
52
|
+
/** Overrides the close button aria-label (defaults to the active locale) */
|
|
37
53
|
closeLabel?: string
|
|
38
54
|
/** Show a row of clickable thumbnails at the bottom for jumping directly to an image. */
|
|
39
55
|
showThumbnails?: boolean
|
package/src/components/MList.vue
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* A vertical list container (MList) with rich, flexible rows (MListItem) and optional section headers
|
|
4
|
+
* (MListSubheader) — one-line to three-line items, leading/trailing elements, selection, navigation, segmented,
|
|
5
|
+
* and expandable variants.
|
|
6
|
+
*
|
|
7
|
+
* @slot default MListItem / MListSubheader children
|
|
8
|
+
* @event update:selected Fires when a selectable item is clicked (via v-model:selected)
|
|
9
|
+
*/
|
|
10
|
+
import { computed, onMounted, onUnmounted, provide, ref, shallowRef } from 'vue'
|
|
3
11
|
|
|
4
12
|
const props = withDefaults(
|
|
5
13
|
defineProps<{
|
|
14
|
+
/** Compact vertical padding on child items */
|
|
6
15
|
dense?: boolean
|
|
16
|
+
/** Show separators between items — 'inset' aligns the line past a leading icon/avatar */
|
|
7
17
|
dividers?: boolean | 'inset'
|
|
18
|
+
/** Navigation variant with rounded (pill) active items, ideal for drawers */
|
|
8
19
|
nav?: boolean
|
|
20
|
+
/** Segmented style — items each get an individual rounded background instead of a flat list */
|
|
9
21
|
segmented?: boolean
|
|
22
|
+
/** Enable single-item selection — items compare their value prop against selected */
|
|
10
23
|
selectable?: boolean
|
|
24
|
+
/** Currently selected item value (v-model:selected) */
|
|
11
25
|
selected?: string | number | null
|
|
26
|
+
/** Default line count for child items that don't set their own lines prop */
|
|
12
27
|
lines?: 1 | 2 | 3
|
|
13
28
|
}>(),
|
|
14
29
|
{ dense: false, dividers: false, nav: false, segmented: false, selectable: false },
|
|
@@ -18,7 +33,36 @@ const emit = defineEmits<{
|
|
|
18
33
|
'update:selected': [value: string | number | null]
|
|
19
34
|
}>()
|
|
20
35
|
|
|
36
|
+
// Segmented items need to know whether they open or close their run of items (SegmentedListItem's
|
|
37
|
+
// segmentedShapes(index, count)). A subheader or any other non-item child starts a new run.
|
|
38
|
+
const listEl = ref<HTMLElement>()
|
|
39
|
+
const positions = shallowRef(new Map<Element, 'single' | 'first' | 'middle' | 'last'>())
|
|
40
|
+
function measure() {
|
|
41
|
+
const map = new Map<Element, 'single' | 'first' | 'middle' | 'last'>()
|
|
42
|
+
let run: Element[] = []
|
|
43
|
+
const flush = () => {
|
|
44
|
+
run.forEach((el, i) => map.set(el, run.length === 1 ? 'single' : i === 0 ? 'first' : i === run.length - 1 ? 'last' : 'middle'))
|
|
45
|
+
run = []
|
|
46
|
+
}
|
|
47
|
+
for (const child of listEl.value?.children ?? []) {
|
|
48
|
+
if (child.getAttribute('role') === 'listitem') run.push(child)
|
|
49
|
+
else flush()
|
|
50
|
+
}
|
|
51
|
+
flush()
|
|
52
|
+
positions.value = map
|
|
53
|
+
}
|
|
54
|
+
let observer: MutationObserver | undefined
|
|
55
|
+
onMounted(() => {
|
|
56
|
+
measure()
|
|
57
|
+
if (listEl.value) {
|
|
58
|
+
observer = new MutationObserver(measure)
|
|
59
|
+
observer.observe(listEl.value, { childList: true })
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
onUnmounted(() => observer?.disconnect())
|
|
63
|
+
|
|
21
64
|
provide('m-list', {
|
|
65
|
+
segmentPosition: (el: Element | null | undefined) => (el ? positions.value.get(el) : undefined),
|
|
22
66
|
dense: computed(() => props.dense),
|
|
23
67
|
nav: computed(() => props.nav),
|
|
24
68
|
segmented: computed(() => props.segmented),
|
|
@@ -31,13 +75,14 @@ provide('m-list', {
|
|
|
31
75
|
|
|
32
76
|
const classes = computed(() => [
|
|
33
77
|
'flex flex-col',
|
|
34
|
-
|
|
78
|
+
// ListTokens.SegmentedGap = 2dp
|
|
79
|
+
props.segmented ? 'gap-0.5 p-2' : 'py-2',
|
|
35
80
|
props.nav && !props.segmented && 'gap-0.5 px-3',
|
|
36
81
|
])
|
|
37
82
|
</script>
|
|
38
83
|
|
|
39
84
|
<template>
|
|
40
|
-
<ul role="list" :class="classes">
|
|
85
|
+
<ul ref="listEl" role="list" :class="classes">
|
|
41
86
|
<slot />
|
|
42
87
|
</ul>
|
|
43
88
|
</template>
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Material 3's list-detail layout: a list of items and the details of the selected one. When there's room
|
|
4
|
+
* (840px and up, the expanded width class) both panes sit side by side; on smaller screens only one shows, the
|
|
5
|
+
* detail sliding in over the list when you open an item and back out on `back()`. It measures its own width, so
|
|
6
|
+
* it adapts inside a column or a dialog too. Both panes stay mounted, so the list keeps its scroll position. It
|
|
7
|
+
* has no default size: give it a height so each pane scrolls on its own.
|
|
8
|
+
*
|
|
9
|
+
* @slot list The list pane. Scrolls on its own and keeps its scroll position while the detail is open
|
|
10
|
+
* @slot detail The detail pane. back() returns to the list; show a back button only when !twoPane
|
|
11
|
+
* @event update:showDetail Emitted with false when the detail slot calls back()
|
|
12
|
+
*/
|
|
2
13
|
import { computed, ref } from 'vue'
|
|
3
14
|
import { useWindowSizeClass } from '../composables/useWindowSizeClass'
|
|
4
15
|
|
|
@@ -1,37 +1,76 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A row of an MList: headline with optional overline, supporting text, a leading icon, avatar or image, and
|
|
4
|
+
* trailing text, icon, checkbox or switch. It can be a link, be clickable or expand to show nested items.
|
|
5
|
+
*
|
|
6
|
+
* @slot leading Custom leading element, replacing the icon/avatar/image/icon-container
|
|
7
|
+
* @slot overline Custom overline content, replacing the overline prop
|
|
8
|
+
* @slot default Custom content replacing the title/subtitle/description text block
|
|
9
|
+
* @slot children Nested content revealed when expandable is set and the item is expanded
|
|
10
|
+
* @slot trailing Custom trailing element, replacing the icon/text/switch/checkbox
|
|
11
|
+
* @event click Fires on any click, including on an expandable item (right before it toggles)
|
|
12
|
+
* @event update:trailingValue Fires when a trailing switch/checkbox is toggled (trailing='switch' | 'checkbox')
|
|
13
|
+
* @event update:expanded Fires when an expandable item is toggled open/closed
|
|
14
|
+
*/
|
|
2
15
|
import { computed, inject, ref, useAttrs, watch } from 'vue'
|
|
16
|
+
import type { ComponentPublicInstance } from 'vue'
|
|
3
17
|
import type { ComputedRef } from 'vue'
|
|
4
18
|
import MIcon from './MIcon.vue'
|
|
5
19
|
import MAvatar from './MAvatar.vue'
|
|
6
20
|
import MCheckbox from './MCheckbox.vue'
|
|
7
21
|
import MSwitch from './MSwitch.vue'
|
|
22
|
+
import { useSpring } from '../composables/_useSpring'
|
|
8
23
|
|
|
9
24
|
export type ListItemLeading = 'icon' | 'avatar' | 'checkbox' | 'radio' | 'image' | 'icon-container'
|
|
10
25
|
export type ListItemTrailing = 'icon' | 'text' | 'switch' | 'checkbox'
|
|
11
26
|
|
|
12
27
|
const props = withDefaults(
|
|
13
28
|
defineProps<{
|
|
29
|
+
/** Primary text (headline) */
|
|
14
30
|
title?: string
|
|
31
|
+
/** Small label above the title */
|
|
15
32
|
overline?: string
|
|
33
|
+
/** Secondary text (line 2) */
|
|
16
34
|
subtitle?: string
|
|
35
|
+
/** Tertiary text (line 3) */
|
|
17
36
|
description?: string
|
|
37
|
+
/** Number of text lines — auto-detected from which text props/parent MList lines are set when omitted */
|
|
18
38
|
lines?: 1 | 2 | 3
|
|
39
|
+
/** Leading Material Symbol icon */
|
|
19
40
|
icon?: string
|
|
41
|
+
/**
|
|
42
|
+
* Leading element type — auto-resolves to 'icon'/'avatar'/'image' from icon/avatarName/image when omitted
|
|
43
|
+
*/
|
|
20
44
|
leading?: ListItemLeading
|
|
45
|
+
/** Name for the avatar (when leading='avatar') */
|
|
21
46
|
avatarName?: string
|
|
47
|
+
/** Image URL (when leading='image') */
|
|
22
48
|
image?: string
|
|
49
|
+
/** Icon container background color (when leading='icon-container') */
|
|
23
50
|
iconContainerColor?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'success'
|
|
51
|
+
/** Trailing icon name */
|
|
24
52
|
trailingIcon?: string
|
|
53
|
+
/** Trailing text label */
|
|
25
54
|
trailingText?: string
|
|
55
|
+
/** Trailing element type — auto-resolves from trailingIcon/trailingText when omitted */
|
|
26
56
|
trailing?: ListItemTrailing
|
|
57
|
+
/** Value for a trailing switch/checkbox (v-model:trailingValue) */
|
|
27
58
|
trailingValue?: boolean
|
|
59
|
+
/** Selection value — compared against the parent MList selected prop */
|
|
28
60
|
value?: string | number
|
|
61
|
+
/** Force the active/highlighted state regardless of parent list selection */
|
|
29
62
|
active?: boolean
|
|
63
|
+
/** Disabled state (38% opacity, blocks interaction) */
|
|
30
64
|
disabled?: boolean
|
|
65
|
+
/** Force interactive styling/behavior (auto-true when href, to, @click, selectable, or expandable apply) */
|
|
31
66
|
clickable?: boolean
|
|
67
|
+
/** Link URL — renders the item as an `<a>` */
|
|
32
68
|
href?: string
|
|
69
|
+
/** Vue Router destination — renders the item as a router-link */
|
|
33
70
|
to?: string | object
|
|
71
|
+
/** Show an expand/collapse chevron revealing the #children slot */
|
|
34
72
|
expandable?: boolean
|
|
73
|
+
/** Control the expanded state (v-model:expanded) — otherwise managed internally */
|
|
35
74
|
expanded?: boolean
|
|
36
75
|
}>(),
|
|
37
76
|
{ active: false, disabled: false, expandable: false },
|
|
@@ -50,6 +89,7 @@ watch(() => props.expanded, (v) => { if (v !== undefined) internalExpanded.value
|
|
|
50
89
|
const isExpanded = computed(() => internalExpanded.value)
|
|
51
90
|
|
|
52
91
|
const list = inject<{
|
|
92
|
+
segmentPosition: (el: Element | null | undefined) => 'single' | 'first' | 'middle' | 'last' | undefined
|
|
53
93
|
dense: ComputedRef<boolean>
|
|
54
94
|
nav: ComputedRef<boolean>
|
|
55
95
|
segmented: ComputedRef<boolean>
|
|
@@ -120,9 +160,8 @@ const minHeightClass = computed(() => {
|
|
|
120
160
|
|
|
121
161
|
const containerClasses = computed(() => [
|
|
122
162
|
'mli-row relative flex w-full items-center gap-4 text-left',
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
: isNav.value ? 'rounded-full px-4' : 'px-4',
|
|
163
|
+
// Corner radius: a pill in nav lists, otherwise sprung by expressiveRadii below
|
|
164
|
+
isSegmented.value ? 'bg-surface-container px-4' : isNav.value ? 'rounded-full px-4' : 'px-4',
|
|
126
165
|
isDense.value
|
|
127
166
|
? 'py-1'
|
|
128
167
|
: resolvedLines.value === 3 ? 'py-3' : 'py-2',
|
|
@@ -134,6 +173,57 @@ const containerClasses = computed(() => [
|
|
|
134
173
|
props.disabled && 'opacity-[0.38] pointer-events-none',
|
|
135
174
|
])
|
|
136
175
|
|
|
176
|
+
// ── Expressive shape morph ──────────────────────────────────────────────────────────────────
|
|
177
|
+
// The current (non-deprecated) ListItem overloads morph the container's corners by interaction, with
|
|
178
|
+
// ListItemDefaults.shapes(): ListTokens.ItemContainerExpressiveShape CornerExtraSmall (4dp) at rest,
|
|
179
|
+
// ItemHovered… CornerMedium (8dp), ItemPressed/Focused/Selected… CornerLarge (16dp), priority
|
|
180
|
+
// pressed > selected > focused > hovered (shapeForInteraction). SegmentedListItem's segmentedShapes() swaps
|
|
181
|
+
// only the resting shape's outer corners for ListTokens.ContainerShape (CornerLarge) on the first and last
|
|
182
|
+
// item of a run; the interaction shapes stay the same. Animated with MotionSchemeKeyTokens.FastSpatial.
|
|
183
|
+
// Nav lists keep their pill (that's NavigationDrawerItem's shape, which doesn't morph).
|
|
184
|
+
const rootEl = ref<Element | ComponentPublicInstance | null>(null)
|
|
185
|
+
const shapeEl = ref<HTMLElement | null>(null)
|
|
186
|
+
const el = (r: Element | ComponentPublicInstance | null) => (r && '$el' in r ? (r.$el as Element) : r)
|
|
187
|
+
const hovered = ref(false)
|
|
188
|
+
const pressed = ref(false)
|
|
189
|
+
const focused = ref(false)
|
|
190
|
+
|
|
191
|
+
const REST = 4
|
|
192
|
+
const HOVERED = 8
|
|
193
|
+
const LARGE = 16
|
|
194
|
+
|
|
195
|
+
const segmentPosition = computed(() => (isSegmented.value ? list?.segmentPosition(el(rootEl.value)) : undefined))
|
|
196
|
+
|
|
197
|
+
const expressiveRadii = computed<number[]>(() => {
|
|
198
|
+
if (isNav.value) return []
|
|
199
|
+
const interactive = isClickable.value && !props.disabled
|
|
200
|
+
const r = interactive && pressed.value ? LARGE
|
|
201
|
+
: isActive.value ? LARGE
|
|
202
|
+
: interactive && focused.value ? LARGE
|
|
203
|
+
: interactive && hovered.value ? HOVERED
|
|
204
|
+
: null
|
|
205
|
+
if (r !== null) return [r, r, r, r]
|
|
206
|
+
const pos = segmentPosition.value
|
|
207
|
+
const top = pos === 'first' || pos === 'single' ? LARGE : REST
|
|
208
|
+
const bottom = pos === 'last' || pos === 'single' ? LARGE : REST
|
|
209
|
+
return [top, top, bottom, bottom]
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
const { snap } = useSpring(() => expressiveRadii.value, (v) => {
|
|
213
|
+
const target = shapeEl.value ?? (el(rootEl.value) as HTMLElement | null)
|
|
214
|
+
if (!target) return
|
|
215
|
+
target.style.borderRadius = v.length ? v.map((n) => `${n}px`).join(' ') : ''
|
|
216
|
+
})
|
|
217
|
+
// A change of place in the list (or of list style) isn't an interaction: jump there
|
|
218
|
+
watch([segmentPosition, isNav], () => snap())
|
|
219
|
+
|
|
220
|
+
function onPointerEnter(e: PointerEvent) { if (e.pointerType !== 'touch') hovered.value = true }
|
|
221
|
+
function onPointerLeave() { hovered.value = false; pressed.value = false }
|
|
222
|
+
function onPointerDown(e: PointerEvent) { if (e.button === 0) pressed.value = true }
|
|
223
|
+
function onPointerUp() { pressed.value = false }
|
|
224
|
+
function onFocus(e: FocusEvent) { focused.value = (e.currentTarget as Element).matches(':focus-visible') }
|
|
225
|
+
function onBlur() { focused.value = false }
|
|
226
|
+
|
|
137
227
|
const tag = computed(() => {
|
|
138
228
|
if (props.href) return 'a'
|
|
139
229
|
if (props.to) return 'router-link'
|
|
@@ -172,8 +262,17 @@ function handleTrailingToggle() {
|
|
|
172
262
|
</script>
|
|
173
263
|
|
|
174
264
|
<template>
|
|
175
|
-
<li v-if="expandable" role="listitem">
|
|
176
|
-
<div
|
|
265
|
+
<li v-if="expandable" ref="rootEl" role="listitem">
|
|
266
|
+
<div
|
|
267
|
+
ref="shapeEl"
|
|
268
|
+
:class="containerClasses"
|
|
269
|
+
@click="handleClick"
|
|
270
|
+
@pointerenter="onPointerEnter"
|
|
271
|
+
@pointerleave="onPointerLeave"
|
|
272
|
+
@pointerdown="onPointerDown"
|
|
273
|
+
@pointerup="onPointerUp"
|
|
274
|
+
@pointercancel="onPointerUp"
|
|
275
|
+
>
|
|
177
276
|
<!-- Leading -->
|
|
178
277
|
<slot name="leading">
|
|
179
278
|
<MIcon v-if="resolvedLeading === 'icon'" :name="icon!" :size="24" class="shrink-0" :class="activeIconClass" />
|
|
@@ -215,9 +314,17 @@ function handleTrailingToggle() {
|
|
|
215
314
|
v-else
|
|
216
315
|
:is="tag"
|
|
217
316
|
:class="containerClasses"
|
|
317
|
+
ref="rootEl"
|
|
218
318
|
v-bind="linkProps"
|
|
219
319
|
role="listitem"
|
|
220
320
|
@click="handleClick"
|
|
321
|
+
@pointerenter="onPointerEnter"
|
|
322
|
+
@pointerleave="onPointerLeave"
|
|
323
|
+
@pointerdown="onPointerDown"
|
|
324
|
+
@pointerup="onPointerUp"
|
|
325
|
+
@pointercancel="onPointerUp"
|
|
326
|
+
@focus="onFocus"
|
|
327
|
+
@blur="onBlur"
|
|
221
328
|
>
|
|
222
329
|
<!-- Divider -->
|
|
223
330
|
<div
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A small heading that labels a group of items inside an MList.
|
|
4
|
+
*
|
|
5
|
+
* @slot default Subheader text/content
|
|
6
|
+
*/
|
|
2
7
|
withDefaults(
|
|
3
8
|
defineProps<{
|
|
9
|
+
/** Align with items that have a leading icon (adds left padding) */
|
|
4
10
|
inset?: boolean
|
|
5
11
|
}>(),
|
|
6
12
|
{ inset: false },
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The M3 Expressive loading indicator — continuously morphs between rounded shapes (soft burst, cookie,
|
|
4
|
+
* pentagon, pill, sunny, oval) via an underdamped spring while slowly rotating. Comes in a plain and a
|
|
5
|
+
* contained (circle-backed) variant.
|
|
6
|
+
*/
|
|
2
7
|
import { computed, onMounted, onUnmounted, ref } from "vue";
|
|
3
8
|
import { useLocale } from '../composables/useLocale';
|
|
4
9
|
|
|
5
10
|
const props = withDefaults(
|
|
6
11
|
defineProps<{
|
|
12
|
+
/**
|
|
13
|
+
* Overall footprint in px. The active shape sits inset within it (38/48 ratio) unless contained, where it
|
|
14
|
+
* scales to 55% of size.
|
|
15
|
+
*/
|
|
7
16
|
size?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Wraps the shape in a filled container circle, and recolors the shape to the OnXContainer role instead of
|
|
19
|
+
* the bare X role
|
|
20
|
+
*/
|
|
8
21
|
contained?: boolean;
|
|
22
|
+
/** Active shape (and container, when contained) color */
|
|
9
23
|
color?: "primary" | "secondary" | "tertiary" | "error";
|
|
24
|
+
/** Aria label for the indicator's status role — falls back to the locale string ('Loading') when omitted */
|
|
10
25
|
label?: string;
|
|
11
26
|
}>(),
|
|
12
27
|
{ size: 48, contained: false, color: "primary" },
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A spinner-and-text overlay, either layered on top of a piece of content via the `#content` slot, or covering
|
|
4
|
+
* the whole viewport with `fullscreen`.
|
|
5
|
+
*
|
|
6
|
+
* @slot default Extra content shown below the spinner/text, in either mode
|
|
7
|
+
* @slot content The content the overlay is layered on top of (only used when fullscreen is false)
|
|
8
|
+
*/
|
|
2
9
|
import MSpinner from './MSpinner.vue'
|
|
3
10
|
|
|
4
11
|
defineOptions({ inheritAttrs: false })
|
|
5
12
|
|
|
6
13
|
withDefaults(defineProps<{
|
|
14
|
+
/** Show/hide the overlay */
|
|
7
15
|
visible: boolean
|
|
16
|
+
/** Loading text message shown below the spinner */
|
|
8
17
|
text?: string
|
|
18
|
+
/** Cover the entire viewport via Teleport, instead of overlaying just the #content slot */
|
|
9
19
|
fullscreen?: boolean
|
|
20
|
+
/** Solid surface background instead of a translucent, blurred one */
|
|
10
21
|
opaque?: boolean
|
|
22
|
+
/** Spinner size in px */
|
|
11
23
|
spinnerSize?: number
|
|
12
24
|
}>(), { fullscreen: false, opaque: false, spinnerSize: 40 })
|
|
13
25
|
</script>
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Renders markdown source as styled HTML — headings, lists, tables, blockquotes, links, and fenced code blocks
|
|
4
|
+
* with optional syntax highlighting, line highlighting, and a copy button.
|
|
5
|
+
*/
|
|
2
6
|
import { computed, ref, onMounted } from 'vue'
|
|
3
7
|
|
|
4
8
|
const props = withDefaults(
|
|
5
9
|
defineProps<{
|
|
10
|
+
/** Markdown source text */
|
|
6
11
|
source: string
|
|
12
|
+
/** Convert single newlines to `<br>` */
|
|
7
13
|
breaks?: boolean
|
|
14
|
+
/** Auto-detect bare URLs and turn them into links */
|
|
8
15
|
linkify?: boolean
|
|
9
16
|
}>(),
|
|
10
17
|
{ breaks: true, linkify: true },
|