@m3ui-vue/m3ui-vue 1.10.2 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -4
- package/dist/API.md +195 -56
- package/dist/MButton-gWoOzFWf.js +284 -0
- package/dist/MButton-gWoOzFWf.js.map +1 -0
- package/dist/MColorPickerModal-CJYMvlgK.js +466 -0
- package/dist/MColorPickerModal-CJYMvlgK.js.map +1 -0
- package/dist/MDialog-CU8EYgCC.js +226 -0
- package/dist/MDialog-CU8EYgCC.js.map +1 -0
- package/dist/{MIcon-BSsJZhK7.js → MIcon-CkUc9kuQ.js} +10 -4
- package/dist/MIcon-CkUc9kuQ.js.map +1 -0
- package/dist/MIconButton-DTFOfsTy.js +317 -0
- package/dist/MIconButton-DTFOfsTy.js.map +1 -0
- package/dist/MListItem-Cdw2FqCT.js +1306 -0
- package/dist/MListItem-Cdw2FqCT.js.map +1 -0
- package/dist/MLoadingIndicator-BxAy2x7P.js +115 -0
- package/dist/MLoadingIndicator-BxAy2x7P.js.map +1 -0
- package/dist/{MMenuItem-US0Zbglq.js → MMenuItem-CEIKYvaX.js} +216 -214
- package/dist/MMenuItem-CEIKYvaX.js.map +1 -0
- package/dist/{MPdfViewer-DL9mRsd2.js → MPdfViewer-CEfyXGq2.js} +674 -671
- package/dist/MPdfViewer-CEfyXGq2.js.map +1 -0
- package/dist/MProgressBar-BzZMxq7M.js.map +1 -1
- package/dist/MSeekBar-B3_D-PwH.js +435 -0
- package/dist/MSeekBar-B3_D-PwH.js.map +1 -0
- package/dist/{MSegmentedButton-DMou-8sG.js → MSegmentedButton-Dg07j-4r.js} +4 -4
- package/dist/{MSegmentedButton-DMou-8sG.js.map → MSegmentedButton-Dg07j-4r.js.map} +1 -1
- package/dist/{MSignaturePad-WuvE_Cyl.js → MSignaturePad-3nddtLKI.js} +2 -2
- package/dist/{MSignaturePad-WuvE_Cyl.js.map → MSignaturePad-3nddtLKI.js.map} +1 -1
- package/dist/{MSlider-7TzhFHKS.js → MSlider-BrpLbqwt.js} +4 -4
- package/dist/{MSlider-7TzhFHKS.js.map → MSlider-BrpLbqwt.js.map} +1 -1
- package/dist/{MSpinner-CkIVBuGE.js → MSpinner-CLwzDH33.js} +2 -2
- package/dist/{MSpinner-CkIVBuGE.js.map → MSpinner-CLwzDH33.js.map} +1 -1
- package/dist/{MTextField-B6_iOczK.js → MTextField-CZRizAwA.js} +136 -134
- package/dist/MTextField-CZRizAwA.js.map +1 -0
- package/dist/{_useFieldValidation-COBJ1tWr.js → _useFieldValidation-DVcqyy9g.js} +2 -2
- package/dist/{_useFieldValidation-COBJ1tWr.js.map → _useFieldValidation-DVcqyy9g.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/chart.js +1 -1
- package/dist/code-editor.js +3 -3
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MAlert.vue.d.ts +1 -1
- package/dist/components/MAudioPlayer.vue.d.ts +3 -3
- package/dist/components/MAvatar.vue.d.ts +19 -1
- package/dist/components/MButton.vue.d.ts +2 -1
- package/dist/components/MChatBubble.vue.d.ts +2 -0
- package/dist/components/MCheckbox.vue.d.ts +2 -0
- package/dist/components/MDataTable.vue.d.ts +31 -3
- package/dist/components/MFlow.vue.d.ts +1 -1
- package/dist/components/MHotkeys.vue.d.ts +1 -0
- package/dist/components/MIcon.vue.d.ts +6 -0
- package/dist/components/MIconButton.vue.d.ts +5 -0
- package/dist/components/MKanban.vue.d.ts +1 -1
- package/dist/components/MLink.vue.d.ts +59 -0
- package/dist/components/MListItem.vue.d.ts +3 -1
- package/dist/components/MMapControl.vue.d.ts +1 -1
- package/dist/components/MNotificationCenter.vue.d.ts +1 -1
- package/dist/components/MNumberField.vue.d.ts +1 -1
- package/dist/components/MPagination.vue.d.ts +14 -1
- package/dist/components/MPdfSigner.vue.d.ts +2 -2
- package/dist/components/MRadio.vue.d.ts +2 -0
- package/dist/components/MRadioGroup.vue.d.ts +2 -0
- package/dist/components/MStatCard.vue.d.ts +2 -2
- package/dist/components/MSwitch.vue.d.ts +2 -0
- package/dist/components/MText.vue.d.ts +4 -2
- package/dist/components/MTextField.vue.d.ts +2 -0
- package/dist/components/_MDrawerItemList.vue.d.ts +6 -0
- package/dist/composables/_menuGroups.d.ts +10 -1
- package/dist/composables/_splitAttrs.d.ts +6 -0
- package/dist/composables/_springAnimation.d.ts +2 -2
- package/dist/composables/_useFocusTrap.d.ts +15 -0
- package/dist/composables/_usePaneResize.d.ts +1 -1
- package/dist/composables/_useSpring.d.ts +4 -4
- package/dist/composables/dynamicColor.d.ts +9 -1
- package/dist/composables/motion.d.ts +63 -0
- package/dist/composables/useConfirm.d.ts +28 -0
- package/dist/composables/useDevice.d.ts +8 -1
- package/dist/composables/useLocale.d.ts +14 -0
- package/dist/composables/useScrollReveal.d.ts +1 -1
- package/dist/composables/useTheme.d.ts +1 -0
- package/dist/composables/useToast.d.ts +7 -0
- package/dist/draw.js +556 -556
- package/dist/draw.js.map +1 -1
- package/dist/flow.js +854 -851
- package/dist/flow.js.map +1 -1
- package/dist/gantt.js +1118 -1096
- package/dist/gantt.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/locales/index.d.ts +1 -0
- package/dist/locales/index.js +833 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/locales/pl.d.ts +2 -0
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +10327 -9796
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +860 -860
- package/dist/map.js.map +1 -1
- package/dist/{material-color-utilities-CEFytLsr.js → material-color-utilities-BZsBNIhi.js} +276 -217
- package/dist/material-color-utilities-BZsBNIhi.js.map +1 -0
- package/dist/media.js +7 -7
- package/dist/{motion-BcejVTeX.js → motion-BqYcqcim.js} +15 -5
- package/dist/motion-BqYcqcim.js.map +1 -0
- package/dist/pdf-sign.js +140 -137
- package/dist/pdf-sign.js.map +1 -1
- package/dist/pdf.js +1 -1
- package/dist/plugin.d.ts +11 -0
- package/dist/rich-text-editor.js +7 -7
- package/dist/styles/theme.css +40 -0
- package/dist/styles.css +1 -1
- package/dist/terminal.js +1 -1
- package/dist/{useLocale-YRaOT12S.js → useLocale-BjcYauXr.js} +60 -4
- package/dist/useLocale-BjcYauXr.js.map +1 -0
- package/dist/{useThemeTokens-DyAdPQB0.js → useThemeTokens-D5nr5KHf.js} +28 -27
- package/dist/useThemeTokens-D5nr5KHf.js.map +1 -0
- package/package.json +17 -2
- package/src/__tests__/MAvatarImage.test.ts +37 -0
- package/src/__tests__/MDataTableControlled.test.ts +68 -0
- package/src/__tests__/MHotkeysSequence.test.ts +53 -0
- package/src/__tests__/MIconAxes.test.ts +16 -0
- package/src/__tests__/MIconButtonWidth.test.ts +22 -0
- package/src/__tests__/MLink.test.ts +46 -0
- package/src/__tests__/MPaginationPages.test.ts +43 -0
- package/src/__tests__/MTextEmphasized.test.ts +14 -0
- package/src/__tests__/controlDescription.test.ts +34 -0
- package/src/__tests__/customColor.test.ts +27 -0
- package/src/__tests__/dynamicColor.test.ts +3 -2
- package/src/__tests__/focusTrap.test.ts +124 -0
- package/src/__tests__/formatMessage.test.ts +20 -0
- package/src/__tests__/inputAttrs.test.ts +103 -0
- package/src/__tests__/localePresets.test.ts +2 -0
- package/src/__tests__/menuGroupsRemount.test.ts +40 -0
- package/src/__tests__/menuHydration.test.ts +41 -0
- package/src/__tests__/motionPrefs.test.ts +28 -0
- package/src/__tests__/ssr.test.ts +11 -0
- package/src/__tests__/ssrToast.test.ts +20 -0
- package/src/__tests__/toastDetails.test.ts +39 -0
- package/src/__tests__/useConfirm.test.ts +47 -0
- package/src/__tests__/useTheme.test.ts +14 -0
- package/src/__tests__/warningRole.test.ts +22 -0
- package/src/components/MAlert.vue +2 -2
- package/src/components/MAnimatedNumber.vue +9 -3
- package/src/components/MAutocomplete.vue +16 -4
- package/src/components/MAvailabilityCalendar.vue +3 -3
- package/src/components/MAvatar.vue +32 -5
- package/src/components/MAvatarGroup.vue +7 -2
- package/src/components/MBottomSheet.vue +18 -2
- package/src/components/MButton.vue +18 -5
- package/src/components/MCarousel.vue +3 -3
- package/src/components/MChatBubble.vue +14 -1
- package/src/components/MCheckbox.vue +21 -4
- package/src/components/MChip.vue +4 -2
- package/src/components/MCollapse.vue +7 -1
- package/src/components/MCommandPalette.vue +6 -2
- package/src/components/MContextMenu.vue +4 -4
- package/src/components/MCreditCardInput.vue +5 -0
- package/src/components/MDashboardGrid.vue +2 -1
- package/src/components/MDataTable.vue +63 -16
- package/src/components/MDialog.vue +21 -3
- package/src/components/MDiffViewer.vue +3 -3
- package/src/components/MDrawLayers.vue +3 -3
- package/src/components/MFabMenu.vue +7 -0
- package/src/components/MFloorPlan.vue +3 -3
- package/src/components/MFloorPlanInspector.vue +3 -3
- package/src/components/MFlow.vue +9 -5
- package/src/components/MFlowControls.vue +6 -0
- package/src/components/MFormBuilder.vue +1 -1
- package/src/components/MGantt.vue +10 -10
- package/src/components/MHotkeys.vue +61 -16
- package/src/components/MIcon.vue +17 -1
- package/src/components/MIconButton.vue +29 -6
- package/src/components/MImageCropper.vue +1 -1
- package/src/components/MKanban.vue +2 -1
- package/src/components/MLightbox.vue +5 -4
- package/src/components/MLink.vue +136 -0
- package/src/components/MListDetail.vue +7 -0
- package/src/components/MListItem.vue +7 -4
- package/src/components/MLoadingIndicator.vue +2 -1
- package/src/components/MMap.vue +3 -0
- package/src/components/MMapCluster.vue +2 -2
- package/src/components/MMapControl.vue +2 -2
- package/src/components/MMapMeasure.vue +1 -1
- package/src/components/MMaskField.vue +16 -3
- package/src/components/MMenu.vue +4 -4
- package/src/components/MMenuItem.vue +2 -2
- package/src/components/MMeterGroup.vue +3 -2
- package/src/components/MMortgageCalculator.vue +3 -3
- package/src/components/MMultiAutocomplete.vue +19 -7
- package/src/components/MMultiSelect.vue +19 -7
- package/src/components/MNavigationDrawer.vue +10 -3
- package/src/components/MNavigationRail.vue +5 -1
- package/src/components/MNotificationCenter.vue +2 -1
- package/src/components/MNotificationHost.vue +3 -3
- package/src/components/MNumberField.vue +23 -6
- package/src/components/MOdontogram.vue +4 -4
- package/src/components/MOrderBook.vue +4 -0
- package/src/components/MPagination.vue +91 -12
- package/src/components/MPdfSigner.vue +3 -3
- package/src/components/MPdfViewer.vue +7 -7
- package/src/components/MPhoneInput.vue +17 -4
- package/src/components/MProductConfigurator.vue +4 -4
- package/src/components/MProgressBar.vue +5 -0
- package/src/components/MQuiz.vue +8 -5
- package/src/components/MRadio.vue +24 -5
- package/src/components/MRadioGroup.vue +3 -0
- package/src/components/MReactions.vue +2 -2
- package/src/components/MResourceTimeline.vue +3 -3
- package/src/components/MResult.vue +1 -1
- package/src/components/MScrollField.vue +1 -1
- package/src/components/MSearchField.vue +6 -5
- package/src/components/MSeatMap.vue +5 -0
- package/src/components/MSeekBar.vue +3 -2
- package/src/components/MSelect.vue +16 -4
- package/src/components/MSideSheet.vue +25 -3
- package/src/components/MSimpleCarousel.vue +2 -2
- package/src/components/MSnackbar.vue +16 -13
- package/src/components/MSparkline.vue +2 -1
- package/src/components/MSpinner.vue +8 -0
- package/src/components/MSplitter.vue +1 -1
- package/src/components/MSpotlightSearch.vue +6 -2
- package/src/components/MSpreadsheet.vue +1 -1
- package/src/components/MStatCard.vue +2 -1
- package/src/components/MSwitch.vue +21 -4
- package/src/components/MTabs.vue +2 -1
- package/src/components/MTagInput.vue +19 -6
- package/src/components/MText.vue +23 -4
- package/src/components/MTextField.vue +25 -6
- package/src/components/MTimeline.vue +5 -5
- package/src/components/MToolbar.vue +2 -2
- package/src/components/MTour.vue +3 -0
- package/src/components/MTrackingTimeline.vue +6 -0
- package/src/components/MTypewriter.vue +7 -1
- package/src/components/MWindow.vue +10 -1
- package/src/components/_MColorPanel.vue +4 -4
- package/src/components/_MComment.vue +3 -2
- package/src/components/_MFlowNodeShell.vue +1 -1
- package/src/components/_MPdfPage.vue +1 -1
- package/src/components/_MTransferPane.vue +10 -0
- package/src/composables/_effectCanvas.ts +2 -1
- package/src/composables/_menuGroups.ts +10 -1
- package/src/composables/_splitAttrs.ts +29 -0
- package/src/composables/_springAnimation.ts +3 -3
- package/src/composables/_themeTransition.ts +3 -2
- package/src/composables/_useFocusTrap.ts +142 -0
- package/src/composables/_useMenuNav.ts +3 -3
- package/src/composables/_usePaneResize.ts +2 -1
- package/src/composables/_useSheetMotion.ts +3 -4
- package/src/composables/_useSpring.ts +16 -10
- package/src/composables/cron.ts +7 -6
- package/src/composables/dynamicColor.ts +21 -2
- package/src/composables/motion.ts +27 -0
- package/src/composables/useConfirm.ts +116 -0
- package/src/composables/useDevice.ts +23 -3
- package/src/composables/useFieldBg.ts +4 -0
- package/src/composables/useLocale.ts +74 -0
- package/src/composables/useNotification.ts +3 -0
- package/src/composables/useScrollReveal.ts +3 -3
- package/src/composables/useTheme.ts +8 -2
- package/src/composables/useToast.ts +27 -4
- package/src/directives/vSparkle.ts +2 -1
- package/src/index.ts +8 -5
- package/src/locales/ar.ts +7 -0
- package/src/locales/de.ts +7 -0
- package/src/locales/es.ts +7 -0
- package/src/locales/fr.ts +7 -0
- package/src/locales/index.ts +1 -0
- package/src/locales/ja.ts +7 -0
- package/src/locales/ko.ts +7 -0
- package/src/locales/pl.ts +807 -0
- package/src/locales/pt.ts +7 -0
- package/src/locales/zh.ts +7 -0
- package/src/plugin.ts +16 -0
- package/src/styles/theme.css +40 -0
- package/dist/MButton-B9RCM06i.js +0 -171
- package/dist/MButton-B9RCM06i.js.map +0 -1
- package/dist/MColorPickerModal-ChRtcZOo.js +0 -577
- package/dist/MColorPickerModal-ChRtcZOo.js.map +0 -1
- package/dist/MDialog-dk07tify.js +0 -167
- package/dist/MDialog-dk07tify.js.map +0 -1
- package/dist/MIcon-BSsJZhK7.js.map +0 -1
- package/dist/MIconButton-CrBPZidd.js +0 -288
- package/dist/MIconButton-CrBPZidd.js.map +0 -1
- package/dist/MListItem-h9H223vx.js +0 -1239
- package/dist/MListItem-h9H223vx.js.map +0 -1
- package/dist/MLoadingIndicator-YTV1Ov5w.js +0 -114
- package/dist/MLoadingIndicator-YTV1Ov5w.js.map +0 -1
- package/dist/MMenuItem-US0Zbglq.js.map +0 -1
- package/dist/MPdfViewer-DL9mRsd2.js.map +0 -1
- package/dist/MSeekBar-JFZcoJ8y.js +0 -434
- package/dist/MSeekBar-JFZcoJ8y.js.map +0 -1
- package/dist/MTextField-B6_iOczK.js.map +0 -1
- package/dist/material-color-utilities-CEFytLsr.js.map +0 -1
- package/dist/motion-BcejVTeX.js.map +0 -1
- package/dist/useLocale-YRaOT12S.js.map +0 -1
- package/dist/useThemeTokens-DyAdPQB0.js.map +0 -1
|
@@ -27,7 +27,10 @@ export interface GeneratedScheme {
|
|
|
27
27
|
dark: Record<string, string>
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* The `--color-*` roles a generated scheme sets from M3's dynamic colors. The library's status extensions
|
|
32
|
+
* (`success*`, `warning*`) are added on top, harmonized with the seed (see `statusColors`).
|
|
33
|
+
*/
|
|
31
34
|
export const schemeRoles = [
|
|
32
35
|
'primary', 'on-primary', 'primary-container', 'on-primary-container',
|
|
33
36
|
'secondary', 'on-secondary', 'secondary-container', 'on-secondary-container',
|
|
@@ -74,9 +77,25 @@ export async function generateScheme(seed: string, options: SeedOptions = {}): P
|
|
|
74
77
|
}
|
|
75
78
|
return out
|
|
76
79
|
}
|
|
77
|
-
|
|
80
|
+
const light = build(false)
|
|
81
|
+
const dark = build(true)
|
|
82
|
+
// Status colors as M3 custom colors: the fixed green and amber nudged toward the seed's hue (Blend.harmonize,
|
|
83
|
+
// what Android does with custom colors), so they sit with the palette instead of against it
|
|
84
|
+
for (const [name, value] of Object.entries(statusColors)) {
|
|
85
|
+
const c = mcu.customColor(source.toInt(), { name, value: mcu.argbFromHex(value), blend: true })
|
|
86
|
+
for (const [out, group] of [[light, c.light], [dark, c.dark]] as const) {
|
|
87
|
+
out[name] = mcu.hexFromArgb(group.color)
|
|
88
|
+
out[`on-${name}`] = mcu.hexFromArgb(group.onColor)
|
|
89
|
+
out[`${name}-container`] = mcu.hexFromArgb(group.colorContainer)
|
|
90
|
+
out[`on-${name}-container`] = mcu.hexFromArgb(group.onColorContainer)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { light, dark }
|
|
78
94
|
}
|
|
79
95
|
|
|
96
|
+
/** The base colors of the status extensions, before a seed harmonizes them */
|
|
97
|
+
export const statusColors = { success: '#2e7d32', warning: '#ffb300' } as const
|
|
98
|
+
|
|
80
99
|
/** CSS for a scheme under `[data-palette='<id>']` (light) and `[data-palette='<id>'].dark`, like palettes.css. */
|
|
81
100
|
export function schemeToCss(scheme: GeneratedScheme, id: string): string {
|
|
82
101
|
const block = (tokens: Record<string, string>) =>
|
|
@@ -30,6 +30,33 @@ export const motionSprings = {
|
|
|
30
30
|
},
|
|
31
31
|
} as const satisfies Record<'standard' | 'expressive', Record<string, SpringSpec>>
|
|
32
32
|
|
|
33
|
+
export type MotionScheme = 'standard' | 'expressive'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The app's motion scheme, from `createM3UI({ motionScheme })` (or `data-m3-motion-scheme` on `<html>`, which a
|
|
37
|
+
* server-rendered page can set itself). Components that follow the scheme read it when an animation starts.
|
|
38
|
+
*/
|
|
39
|
+
export function getMotionScheme(): MotionScheme {
|
|
40
|
+
return typeof document !== 'undefined' && document.documentElement.dataset.m3MotionScheme === 'expressive'
|
|
41
|
+
? 'expressive'
|
|
42
|
+
: 'standard'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The springs of the app's motion scheme: `motionSprings[getMotionScheme()]` */
|
|
46
|
+
export function appSprings() {
|
|
47
|
+
return motionSprings[getMotionScheme()]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Whether to cut animations down: the user's "reduce motion" setting, or `createM3UI({ reducedMotion: 'always' })`
|
|
52
|
+
* (`data-m3-motion="reduce"` on `<html>`). Ask it when an animation starts, as the library's own components do.
|
|
53
|
+
*/
|
|
54
|
+
export function shouldReduceMotion(): boolean {
|
|
55
|
+
if (typeof window === 'undefined') return false
|
|
56
|
+
if (document.documentElement.dataset.m3Motion === 'reduce') return true
|
|
57
|
+
return !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
|
|
58
|
+
}
|
|
59
|
+
|
|
33
60
|
/** Easing curves as cubic-bezier control points [x1, y1, x2, y2] (theme.css has them as `--ease-*`) */
|
|
34
61
|
export const motionEasings = {
|
|
35
62
|
emphasized: [0.2, 0, 0, 1],
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createApp, defineComponent, h, ref } from 'vue'
|
|
2
|
+
import MConfirmDialog from '../components/MConfirmDialog.vue'
|
|
3
|
+
|
|
4
|
+
export interface ConfirmOptions {
|
|
5
|
+
/** Dialog title */
|
|
6
|
+
title: string
|
|
7
|
+
/** The question or what will happen */
|
|
8
|
+
message: string
|
|
9
|
+
/** Confirm button label; the locale's `confirm` when omitted */
|
|
10
|
+
confirmLabel?: string
|
|
11
|
+
/** Cancel button label; the locale's `cancel` when omitted */
|
|
12
|
+
cancelLabel?: string
|
|
13
|
+
/** Error color on the confirm button, for destructive actions */
|
|
14
|
+
danger?: boolean
|
|
15
|
+
/**
|
|
16
|
+
* Work to do on confirm, with the dialog still open: the button shows a spinner until it settles, then the promise
|
|
17
|
+
* resolves `true`. If it throws, the dialog stays open so the user can retry or cancel; the error isn't passed on,
|
|
18
|
+
* so report it from inside `onConfirm` (a toast, say)
|
|
19
|
+
*/
|
|
20
|
+
onConfirm?: () => unknown
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Request {
|
|
24
|
+
id: number
|
|
25
|
+
options: ConfirmOptions
|
|
26
|
+
resolve: (ok: boolean) => void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Module-level, like useToast: one host for the whole app, mounted on first use
|
|
30
|
+
const queue: Request[] = []
|
|
31
|
+
const current = ref<Request | null>(null)
|
|
32
|
+
const open = ref(false)
|
|
33
|
+
const busy = ref(false)
|
|
34
|
+
let nextId = 1
|
|
35
|
+
let mounted = false
|
|
36
|
+
// MDialog's leave transition (150ms) plays out before the next queued dialog takes the host
|
|
37
|
+
const SWAP_DELAY = 180
|
|
38
|
+
|
|
39
|
+
const ConfirmHost = defineComponent({
|
|
40
|
+
name: 'MConfirmHost',
|
|
41
|
+
setup() {
|
|
42
|
+
return () => {
|
|
43
|
+
const req = current.value
|
|
44
|
+
if (!req) return null
|
|
45
|
+
const o = req.options
|
|
46
|
+
return h(MConfirmDialog, {
|
|
47
|
+
key: req.id,
|
|
48
|
+
modelValue: open.value,
|
|
49
|
+
title: o.title,
|
|
50
|
+
message: o.message,
|
|
51
|
+
confirmLabel: o.confirmLabel,
|
|
52
|
+
cancelLabel: o.cancelLabel,
|
|
53
|
+
danger: o.danger,
|
|
54
|
+
loading: busy.value,
|
|
55
|
+
'onUpdate:modelValue': (v: boolean) => { if (!v && !busy.value) settle(false) },
|
|
56
|
+
onConfirm: () => accept(),
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
function ensureMounted() {
|
|
63
|
+
if (mounted || typeof document === 'undefined') return
|
|
64
|
+
mounted = true
|
|
65
|
+
const container = document.createElement('div')
|
|
66
|
+
container.id = 'm3-confirm-host'
|
|
67
|
+
document.body.appendChild(container)
|
|
68
|
+
createApp({ render: () => h(ConfirmHost) }).mount(container)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function showNext() {
|
|
72
|
+
const next = queue.shift()
|
|
73
|
+
current.value = next ?? null
|
|
74
|
+
open.value = !!next
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function settle(ok: boolean) {
|
|
78
|
+
const req = current.value
|
|
79
|
+
if (!req || !open.value) return
|
|
80
|
+
open.value = false
|
|
81
|
+
busy.value = false
|
|
82
|
+
req.resolve(ok)
|
|
83
|
+
setTimeout(() => { if (!open.value) showNext() }, SWAP_DELAY)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function accept() {
|
|
87
|
+
const req = current.value
|
|
88
|
+
if (!req || busy.value) return
|
|
89
|
+
if (!req.options.onConfirm) return settle(true)
|
|
90
|
+
busy.value = true
|
|
91
|
+
try {
|
|
92
|
+
await req.options.onConfirm()
|
|
93
|
+
} catch {
|
|
94
|
+
busy.value = false
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
settle(true)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Asks with an `MConfirmDialog` and resolves `true` (confirmed) or `false` (cancelled, Escape, the close button or
|
|
102
|
+
* the scrim). Calls made while one is open wait their turn. On the server it resolves `false` at once.
|
|
103
|
+
*/
|
|
104
|
+
function confirm(options: ConfirmOptions): Promise<boolean> {
|
|
105
|
+
if (typeof document === 'undefined') return Promise.resolve(false)
|
|
106
|
+
ensureMounted()
|
|
107
|
+
return new Promise<boolean>((resolve) => {
|
|
108
|
+
queue.push({ id: nextId++, options, resolve })
|
|
109
|
+
if (!current.value) showNext()
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Promise-based confirmation dialogs, without placing a dialog or wiring a v-model: `if (await confirm({…})) …` */
|
|
114
|
+
export function useConfirm() {
|
|
115
|
+
return { confirm }
|
|
116
|
+
}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
import { ref, onMounted, onUnmounted } from 'vue'
|
|
1
|
+
import { computed, ref, onMounted, onUnmounted, type Ref } from 'vue'
|
|
2
|
+
import { isHydrating } from './_hydration'
|
|
3
|
+
import { initialState } from './_ssrState'
|
|
2
4
|
|
|
3
5
|
const MOBILE_BREAKPOINT = 768
|
|
4
6
|
|
|
5
|
-
const isMobile = ref(
|
|
7
|
+
const isMobile = ref(typeof window !== 'undefined' && window.innerWidth < MOBILE_BREAKPOINT)
|
|
6
8
|
let listeners = 0
|
|
7
9
|
|
|
8
10
|
function update() {
|
|
9
11
|
isMobile.value = window.innerWidth < MOBILE_BREAKPOINT
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
/**
|
|
15
|
+
* `isMobile`: whether the window is narrower than 768px, kept up to date on resize. In the browser it's right from
|
|
16
|
+
* the first render. Server-side rendering with `createM3UI({ initialState: { viewport } })` (the viewport cookie the
|
|
17
|
+
* Nuxt module keeps) renders and hydrates with the size the server was given, then follows the window; without a
|
|
18
|
+
* viewport the server renders the desktop markup (`false`).
|
|
19
|
+
*/
|
|
20
|
+
export function useDevice(): { isMobile: Readonly<Ref<boolean>> } {
|
|
21
|
+
const server = typeof window === 'undefined'
|
|
22
|
+
const hydrating = !server && isHydrating()
|
|
23
|
+
const start = server || hydrating ? initialState()?.viewport : undefined
|
|
24
|
+
const startMobile = start ? start.width < MOBILE_BREAKPOINT : false
|
|
25
|
+
|
|
13
26
|
onMounted(() => {
|
|
14
27
|
if (listeners === 0) {
|
|
15
28
|
update()
|
|
@@ -25,5 +38,12 @@ export function useDevice() {
|
|
|
25
38
|
}
|
|
26
39
|
})
|
|
27
40
|
|
|
41
|
+
if (server) return { isMobile: computed(() => startMobile) }
|
|
42
|
+
if (hydrating) {
|
|
43
|
+
// The server's answer until mounted, so the hydrated markup matches, then the window's
|
|
44
|
+
const mounted = ref(false)
|
|
45
|
+
onMounted(() => { mounted.value = true })
|
|
46
|
+
return { isMobile: computed(() => (mounted.value ? isMobile.value : startMobile)) }
|
|
47
|
+
}
|
|
28
48
|
return { isMobile }
|
|
29
49
|
}
|
|
@@ -16,6 +16,8 @@ const M3_BG_CLASSES = [
|
|
|
16
16
|
'bg-secondary-container',
|
|
17
17
|
'bg-tertiary-container',
|
|
18
18
|
'bg-error-container',
|
|
19
|
+
'bg-success-container',
|
|
20
|
+
'bg-warning-container',
|
|
19
21
|
'bg-primary-fixed',
|
|
20
22
|
'bg-primary-fixed-dim',
|
|
21
23
|
'bg-secondary-fixed',
|
|
@@ -26,6 +28,8 @@ const M3_BG_CLASSES = [
|
|
|
26
28
|
'bg-secondary',
|
|
27
29
|
'bg-tertiary',
|
|
28
30
|
'bg-error',
|
|
31
|
+
'bg-success',
|
|
32
|
+
'bg-warning',
|
|
29
33
|
] as const
|
|
30
34
|
|
|
31
35
|
function findM3BgVar(el: HTMLElement): string | null {
|
|
@@ -27,6 +27,8 @@ export interface M3Locale {
|
|
|
27
27
|
collapse: string
|
|
28
28
|
/** Clears a field's value (the × at its end) */
|
|
29
29
|
clear: string
|
|
30
|
+
increase: string
|
|
31
|
+
decrease: string
|
|
30
32
|
columns: string
|
|
31
33
|
exportCsv: string
|
|
32
34
|
noGroup: string
|
|
@@ -215,6 +217,11 @@ export interface M3Locale {
|
|
|
215
217
|
paginationPage: string
|
|
216
218
|
previousPage: string
|
|
217
219
|
nextPage: string
|
|
220
|
+
firstPage: string
|
|
221
|
+
lastPage: string
|
|
222
|
+
goToPage: string
|
|
223
|
+
pagination: string
|
|
224
|
+
opensInNewTab: string
|
|
218
225
|
carousel: string
|
|
219
226
|
carouselItem: string
|
|
220
227
|
/** MSparkline's summary for screen readers: {first}, {last}, {min}, {max} */
|
|
@@ -956,6 +963,8 @@ export const defaultLocale: M3Locale = {
|
|
|
956
963
|
expand: 'Expand',
|
|
957
964
|
collapse: 'Collapse',
|
|
958
965
|
clear: 'Clear',
|
|
966
|
+
increase: 'Increase',
|
|
967
|
+
decrease: 'Decrease',
|
|
959
968
|
columns: 'Columns',
|
|
960
969
|
exportCsv: 'Export CSV',
|
|
961
970
|
noGroup: 'No group',
|
|
@@ -1122,6 +1131,11 @@ export const defaultLocale: M3Locale = {
|
|
|
1122
1131
|
paginationPage: 'Page {page} of {pages}',
|
|
1123
1132
|
previousPage: 'Previous page',
|
|
1124
1133
|
nextPage: 'Next page',
|
|
1134
|
+
firstPage: 'First page',
|
|
1135
|
+
lastPage: 'Last page',
|
|
1136
|
+
goToPage: 'Page {page}',
|
|
1137
|
+
pagination: 'Pagination',
|
|
1138
|
+
opensInNewTab: 'opens in a new tab',
|
|
1125
1139
|
carousel: 'Carousel',
|
|
1126
1140
|
carouselItem: '{index} of {count}',
|
|
1127
1141
|
sparklineSummary: 'From {first} to {last}, low {min}, high {max}',
|
|
@@ -1742,6 +1756,66 @@ export const M3_LOCALE_KEY: InjectionKey<MaybeRef<Partial<M3Locale>>> = Symbol('
|
|
|
1742
1756
|
const appLocale = shallowRef<{ locale: MaybeRef<Partial<M3Locale>> } | null>(null)
|
|
1743
1757
|
|
|
1744
1758
|
/** @internal Called by `createM3UI()`; not exported from the package. */
|
|
1759
|
+
/**
|
|
1760
|
+
* Fills a locale string's placeholders: `{name}` takes `vars.name`, and a plural block
|
|
1761
|
+
* `{count, plural, one {# file} few {# files} other {# files}}` picks the form `Intl.PluralRules` gives for `lang`
|
|
1762
|
+
* (`zero`, `one`, `two`, `few`, `many`, `other`, or an exact `=0`), with `#` standing for the number. Strings without
|
|
1763
|
+
* a plural block work as before, so a locale only needs them where its grammar does (Polish, Arabic…).
|
|
1764
|
+
*/
|
|
1765
|
+
export function formatMessage(template: string, vars: Record<string, string | number> = {}, lang = 'en'): string {
|
|
1766
|
+
let out = ''
|
|
1767
|
+
let i = 0
|
|
1768
|
+
while (i < template.length) {
|
|
1769
|
+
const open = template.indexOf('{', i)
|
|
1770
|
+
if (open < 0) { out += template.slice(i); break }
|
|
1771
|
+
out += template.slice(i, open)
|
|
1772
|
+
const close = matchingBrace(template, open)
|
|
1773
|
+
if (close < 0) { out += template.slice(open); break }
|
|
1774
|
+
const inner = template.slice(open + 1, close)
|
|
1775
|
+
const plural = /^\s*(\w+)\s*,\s*plural\s*,(.*)$/s.exec(inner)
|
|
1776
|
+
if (plural) out += pluralForm(plural[1]!, plural[2]!, vars, lang)
|
|
1777
|
+
else {
|
|
1778
|
+
const name = inner.trim()
|
|
1779
|
+
out += name in vars ? String(vars[name]) : template.slice(open, close + 1)
|
|
1780
|
+
}
|
|
1781
|
+
i = close + 1
|
|
1782
|
+
}
|
|
1783
|
+
return out
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
function matchingBrace(s: string, open: number) {
|
|
1787
|
+
let depth = 0
|
|
1788
|
+
for (let k = open; k < s.length; k++) {
|
|
1789
|
+
if (s[k] === '{') depth++
|
|
1790
|
+
else if (s[k] === '}' && --depth === 0) return k
|
|
1791
|
+
}
|
|
1792
|
+
return -1
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
const pluralRules = new Map<string, Intl.PluralRules>()
|
|
1796
|
+
function pluralForm(name: string, body: string, vars: Record<string, string | number>, lang: string) {
|
|
1797
|
+
const raw = vars[name]
|
|
1798
|
+
const n = typeof raw === 'number' ? raw : Number(raw)
|
|
1799
|
+
const forms = new Map<string, string>()
|
|
1800
|
+
const re = /\s*(=\d+|\w+)\s*\{/g
|
|
1801
|
+
let m: RegExpExecArray | null
|
|
1802
|
+
while ((m = re.exec(body))) {
|
|
1803
|
+
const start = m.index + m[0].length - 1
|
|
1804
|
+
const end = matchingBrace(body, start)
|
|
1805
|
+
if (end < 0) break
|
|
1806
|
+
forms.set(m[1]!, body.slice(start + 1, end))
|
|
1807
|
+
re.lastIndex = end + 1
|
|
1808
|
+
}
|
|
1809
|
+
let rules = pluralRules.get(lang)
|
|
1810
|
+
if (!rules) {
|
|
1811
|
+
try { rules = new Intl.PluralRules(lang) } catch { rules = new Intl.PluralRules('en') }
|
|
1812
|
+
pluralRules.set(lang, rules)
|
|
1813
|
+
}
|
|
1814
|
+
const text = forms.get(`=${n}`) ?? forms.get(Number.isNaN(n) ? 'other' : rules.select(n)) ?? forms.get('other') ?? ''
|
|
1815
|
+
// Inner placeholders ({name} inside a form) are filled too; # is the number as given
|
|
1816
|
+
return formatMessage(text.replace(/#/g, String(raw ?? '')), vars, lang)
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1745
1819
|
export function __setAppLocale(locale: MaybeRef<Partial<M3Locale>> | null) {
|
|
1746
1820
|
appLocale.value = locale ? { locale } : null
|
|
1747
1821
|
}
|
|
@@ -55,6 +55,9 @@ function show(
|
|
|
55
55
|
variant: NotificationVariant = 'info',
|
|
56
56
|
options: NotificationOptions = {},
|
|
57
57
|
) {
|
|
58
|
+
// On the server there's no host to show it, and the list is module state shared by every request: a toast
|
|
59
|
+
// queued there would leak into other users' pages. Toasts are a client thing; -1 is an id nothing matches.
|
|
60
|
+
if (typeof document === 'undefined') return -1
|
|
58
61
|
ensureMounted()
|
|
59
62
|
const isLoading = options.loading ?? false
|
|
60
63
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getCurrentInstance, onBeforeUnmount, toValue, watch, type MaybeRefOrGetter } from 'vue'
|
|
2
|
-
import { motionSprings } from './motion'
|
|
2
|
+
import { getMotionScheme, motionSprings } from './motion'
|
|
3
3
|
import { playSamples, prefersReducedMotion, sampleSpring } from './_springAnimation'
|
|
4
4
|
|
|
5
5
|
/** How an element enters: from below, from a side, growing, or only fading. */
|
|
@@ -20,7 +20,7 @@ export interface ScrollRevealOptions {
|
|
|
20
20
|
threshold?: number
|
|
21
21
|
/** Grows or shrinks the area that counts as visible, like IntersectionObserver's `rootMargin` (default `'0px'`) */
|
|
22
22
|
rootMargin?: string
|
|
23
|
-
/** Motion scheme of the springs: `'standard'`
|
|
23
|
+
/** Motion scheme of the springs: `'standard'` or `'expressive'` (a little bounce). Defaults to the app's (createM3UI's `motionScheme`) */
|
|
24
24
|
scheme?: 'standard' | 'expressive'
|
|
25
25
|
/** Pace: M3's fast, default or slow springs (default `'default'`); slow suits large, calm entrances */
|
|
26
26
|
speed?: 'fast' | 'default' | 'slow'
|
|
@@ -43,7 +43,7 @@ const hiddenStyle = (o: ReturnType<(typeof OFFSET)[RevealEffect]>) =>
|
|
|
43
43
|
* entering together cascade by `stagger`.
|
|
44
44
|
*/
|
|
45
45
|
export function createReveal(options: ScrollRevealOptions = {}) {
|
|
46
|
-
const { effect = 'fade-up', distance = 24, delay = 0, stagger = 60, once = true, threshold = 0.15, rootMargin = '0px', scheme =
|
|
46
|
+
const { effect = 'fade-up', distance = 24, delay = 0, stagger = 60, once = true, threshold = 0.15, rootMargin = '0px', scheme = getMotionScheme(), speed = 'default' } = options
|
|
47
47
|
const offset = OFFSET[effect](distance)
|
|
48
48
|
const springs = motionSprings[scheme]
|
|
49
49
|
const shown = new WeakSet<Element>()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, watchEffect, onMounted, onUnmounted } from 'vue'
|
|
1
|
+
import { computed, ref, watchEffect, onMounted, onUnmounted } from 'vue'
|
|
2
2
|
import { themeTransition } from './_themeTransition'
|
|
3
3
|
import { initialState, readCookie, ssrValue, writeCookie } from './_ssrState'
|
|
4
4
|
import { THEME_KEY, onStoragePrefix, storageKey } from './_storageKeys'
|
|
@@ -22,6 +22,8 @@ function readStored(): Theme {
|
|
|
22
22
|
const theme = ref<Theme>(readStored())
|
|
23
23
|
|
|
24
24
|
let _appliedDark: boolean | null = null
|
|
25
|
+
// The scheme actually showing: `theme` resolved against the system preference when it's 'system'
|
|
26
|
+
const dark = ref(false)
|
|
25
27
|
|
|
26
28
|
function applyTheme(t: Theme) {
|
|
27
29
|
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
@@ -33,6 +35,7 @@ function applyTheme(t: Theme) {
|
|
|
33
35
|
else apply()
|
|
34
36
|
|
|
35
37
|
_appliedDark = isDark
|
|
38
|
+
dark.value = isDark
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
// Apply immediately on module load (before any component mounts) — no animation
|
|
@@ -71,5 +74,8 @@ export function useTheme() {
|
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
// Server-side rendering with `createM3UI({ initialState })`: the user's theme as the server knows it
|
|
74
|
-
|
|
77
|
+
const serverTheme = initialState()?.theme
|
|
78
|
+
// On the server only an explicit 'dark' is known to be dark: 'system' depends on the device, so it renders light
|
|
79
|
+
const isDark = computed(() => (inBrowser ? dark.value : serverTheme === 'dark'))
|
|
80
|
+
return { theme: ssrValue(theme, serverTheme), isDark, cycle }
|
|
75
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, createApp, h } from 'vue'
|
|
1
|
+
import { ref, createApp, h, watch } from 'vue'
|
|
2
2
|
import MSnackbar from '../components/MSnackbar.vue'
|
|
3
3
|
|
|
4
4
|
export type ToastVariant = 'info' | 'success' | 'warning' | 'error'
|
|
@@ -11,6 +11,8 @@ export interface ToastAction { label: string; onClick: () => void }
|
|
|
11
11
|
export interface Toast {
|
|
12
12
|
id: number
|
|
13
13
|
message: string
|
|
14
|
+
/** Second line under the message, in a smaller, quieter style (the message then reads as a title) */
|
|
15
|
+
description?: string
|
|
14
16
|
variant: ToastVariant
|
|
15
17
|
duration: number
|
|
16
18
|
loading?: boolean
|
|
@@ -26,6 +28,8 @@ const timers = new Map<number, ReturnType<typeof setTimeout>>()
|
|
|
26
28
|
|
|
27
29
|
const toasts = ref<Toast[]>([])
|
|
28
30
|
const position = ref<ToastPosition>('bottom-center')
|
|
31
|
+
// Most toasts on screen at once (0 = no limit): showing one more dismisses the oldest that isn't loading
|
|
32
|
+
const max = ref(0)
|
|
29
33
|
|
|
30
34
|
function ensureMounted() {
|
|
31
35
|
if (mounted || typeof document === 'undefined') return
|
|
@@ -43,6 +47,8 @@ function dismiss(id: number) {
|
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
export interface ToastOptions {
|
|
50
|
+
/** Second line under the message (the message then reads as a title) */
|
|
51
|
+
description?: string
|
|
46
52
|
duration?: number
|
|
47
53
|
loading?: boolean
|
|
48
54
|
action?: ToastAction
|
|
@@ -55,6 +61,9 @@ function show(
|
|
|
55
61
|
variant: ToastVariant = 'info',
|
|
56
62
|
options: number | ToastOptions = {},
|
|
57
63
|
) {
|
|
64
|
+
// On the server there's no host to show it, and the list is module state shared by every request: a toast
|
|
65
|
+
// queued there would leak into other users' pages. Toasts are a client thing; -1 is an id nothing matches.
|
|
66
|
+
if (typeof document === 'undefined') return -1
|
|
58
67
|
ensureMounted()
|
|
59
68
|
const opts = typeof options === 'number' ? { duration: options } : options
|
|
60
69
|
const isLoading = opts.loading ?? false
|
|
@@ -62,7 +71,7 @@ function show(
|
|
|
62
71
|
// Dedup: identical non-loading, non-action toasts increment count instead of stacking
|
|
63
72
|
if (!isLoading && !opts.action) {
|
|
64
73
|
const existing = toasts.value.find(
|
|
65
|
-
t => t.message === message && t.variant === variant && !t.loading && !t.action,
|
|
74
|
+
t => t.message === message && t.description === opts.description && t.variant === variant && !t.loading && !t.action,
|
|
66
75
|
)
|
|
67
76
|
if (existing) {
|
|
68
77
|
existing.count++
|
|
@@ -76,11 +85,25 @@ function show(
|
|
|
76
85
|
|
|
77
86
|
const id = nextId++
|
|
78
87
|
const duration = isLoading ? 0 : (opts.duration ?? (variant === 'error' ? 6000 : 4000))
|
|
79
|
-
toasts.value.push({ id, message, variant, duration, loading: isLoading, action: opts.action, icon: opts.icon, color: opts.color, count: 1 })
|
|
88
|
+
toasts.value.push({ id, message, description: opts.description, variant, duration, loading: isLoading, action: opts.action, icon: opts.icon, color: opts.color, count: 1 })
|
|
80
89
|
if (duration > 0) timers.set(id, setTimeout(() => dismiss(id), duration))
|
|
90
|
+
enforceMax()
|
|
81
91
|
return id
|
|
82
92
|
}
|
|
83
93
|
|
|
94
|
+
function enforceMax() {
|
|
95
|
+
if (max.value <= 0) return
|
|
96
|
+
// Loading toasts stand for work in progress, so they're never pushed out; the oldest of the rest go first
|
|
97
|
+
while (toasts.value.length > max.value) {
|
|
98
|
+
const oldest = toasts.value.find((t) => !t.loading)
|
|
99
|
+
if (!oldest) break
|
|
100
|
+
dismiss(oldest.id)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Lowering the limit with toasts on screen trims them right away
|
|
105
|
+
watch(max, () => enforceMax())
|
|
106
|
+
|
|
84
107
|
function update(id: number, patch: Partial<Omit<Toast, 'id'>>) {
|
|
85
108
|
const t = toasts.value.find((t) => t.id === id)
|
|
86
109
|
if (!t) return
|
|
@@ -106,5 +129,5 @@ const warning = (msg: string, opts?: ToastOptions) => show(msg, 'warning', opts
|
|
|
106
129
|
const info = (msg: string, opts?: ToastOptions) => show(msg, 'info', opts ?? {})
|
|
107
130
|
|
|
108
131
|
export function useToast() {
|
|
109
|
-
return { toasts, position, show, success, error, warning, info, loading, update, dismiss }
|
|
132
|
+
return { toasts, position, max, show, success, error, warning, info, loading, update, dismiss }
|
|
110
133
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Directive } from 'vue'
|
|
2
|
+
import { shouldReduceMotion } from '../composables/motion'
|
|
2
3
|
import { getShape, toSvgPath, type ShapeName } from 'shape-morph'
|
|
3
4
|
|
|
4
5
|
/** Options for `v-sparkle`. */
|
|
@@ -93,7 +94,7 @@ function spawn(el: HTMLElement, state: SparkleState) {
|
|
|
93
94
|
function active(state: SparkleState) {
|
|
94
95
|
const { options } = state
|
|
95
96
|
if (options.disabled || !state.visible) return false
|
|
96
|
-
if (
|
|
97
|
+
if (shouldReduceMotion()) return false
|
|
97
98
|
return options.trigger === 'hover' ? state.hovering : true
|
|
98
99
|
}
|
|
99
100
|
|
package/src/index.ts
CHANGED
|
@@ -25,10 +25,12 @@ export { generateScheme, schemeToCss, schemeRoles, seedFromImage, seedFromPixels
|
|
|
25
25
|
export type { SchemeVariant, SeedOptions, GeneratedScheme } from './composables/dynamicColor'
|
|
26
26
|
export { useToast } from './composables/useToast'
|
|
27
27
|
export type { Toast, ToastVariant, ToastPosition, ToastAction, ToastOptions } from './composables/useToast'
|
|
28
|
+
export { useConfirm } from './composables/useConfirm'
|
|
29
|
+
export type { ConfirmOptions } from './composables/useConfirm'
|
|
28
30
|
export { useUndo } from './composables/useUndo'
|
|
29
31
|
export type { UndoableAction, UseUndoOptions } from './composables/useUndo'
|
|
30
32
|
export { useFieldBg } from './composables/useFieldBg'
|
|
31
|
-
export { useLocale, defaultLocale } from './composables/useLocale'
|
|
33
|
+
export { useLocale, defaultLocale, formatMessage } from './composables/useLocale'
|
|
32
34
|
export type { M3Locale } from './composables/useLocale'
|
|
33
35
|
export { useDevice } from './composables/useDevice'
|
|
34
36
|
export { useAutoGrow } from './composables/useAutoGrow'
|
|
@@ -48,8 +50,8 @@ export { evaluateFormula, createSheetEvaluator, shiftFormula, columnName, column
|
|
|
48
50
|
export type { SpreadsheetCell, SpreadsheetValue, SpreadsheetFunction, FormulaContext } from './composables/spreadsheetFormula'
|
|
49
51
|
export { usePageProgress } from './composables/usePageProgress'
|
|
50
52
|
export { useSpring } from './composables/_useSpring'
|
|
51
|
-
export { motionSprings, motionEasings, motionDurations, cubicBezier } from './composables/motion'
|
|
52
|
-
export type { SpringSpec } from './composables/motion'
|
|
53
|
+
export { motionSprings, motionEasings, motionDurations, cubicBezier, getMotionScheme, shouldReduceMotion } from './composables/motion'
|
|
54
|
+
export type { SpringSpec, MotionScheme } from './composables/motion'
|
|
53
55
|
|
|
54
56
|
// Directives
|
|
55
57
|
export { vRipple } from './directives/vRipple'
|
|
@@ -168,6 +170,7 @@ export { default as MKanban } from './components/MKanban.vue'
|
|
|
168
170
|
export { default as MKbd } from './components/MKbd.vue'
|
|
169
171
|
export { default as MLightbox } from './components/MLightbox.vue'
|
|
170
172
|
export type { LightboxItem } from './components/MLightbox.vue'
|
|
173
|
+
export { default as MLink } from './components/MLink.vue'
|
|
171
174
|
export { default as MList } from './components/MList.vue'
|
|
172
175
|
export { default as MListItem } from './components/MListItem.vue'
|
|
173
176
|
export { default as MListSubheader } from './components/MListSubheader.vue'
|
|
@@ -348,7 +351,7 @@ export { emojiCategories, allEmojis, randomEmoji, withSkinTone, toneableEmojis,
|
|
|
348
351
|
export type { Placement } from './components/MAbsolute.vue'
|
|
349
352
|
export type { BadgePosition, BadgeOverlap } from './components/MBadge.vue'
|
|
350
353
|
export type { CalendarEvent } from './components/MCalendar.vue'
|
|
351
|
-
export type { DataTableColumn, DataTableFetchParams } from './components/MDataTable.vue'
|
|
354
|
+
export type { DataTableColumn, DataTableFetchParams, DataTableSort } from './components/MDataTable.vue'
|
|
352
355
|
export { default as MFilterBuilder } from './components/MFilterBuilder.vue'
|
|
353
356
|
export { filterRows, matchesFilter, createFilter, createRule, createGroup, operatorsFor, countRules, isComplete, FILTER_OPERATORS } from './composables/filterBuilder'
|
|
354
357
|
export type { FilterField, FilterFieldType, FilterOperator, FilterRule, FilterGroup } from './composables/filterBuilder'
|
|
@@ -369,7 +372,7 @@ export type { SegmentedOption } from './components/MSegmentedButton.vue'
|
|
|
369
372
|
export type { SpotlightResult } from './components/MSpotlightSearch.vue'
|
|
370
373
|
export type { StepItem } from './components/MStepper.vue'
|
|
371
374
|
export type { CommandItem } from './components/MCommandPalette.vue'
|
|
372
|
-
export type { TableFetchParams } from './components/MTable.vue'
|
|
375
|
+
export type { TableColumn, TableFetchParams } from './components/MTable.vue'
|
|
373
376
|
export type { TimelineItem, TimelineStatus } from './components/MTimeline.vue'
|
|
374
377
|
export type { TrackingStep, TrackingStatus } from './components/MTrackingTimeline.vue'
|
|
375
378
|
export type { TourStep } from './components/MTour.vue'
|
package/src/locales/ar.ts
CHANGED
|
@@ -28,6 +28,8 @@ export const arLocale: M3Locale = {
|
|
|
28
28
|
expand: 'توسيع',
|
|
29
29
|
collapse: 'طي',
|
|
30
30
|
clear: 'مسح',
|
|
31
|
+
increase: 'زيادة',
|
|
32
|
+
decrease: 'إنقاص',
|
|
31
33
|
columns: 'الأعمدة',
|
|
32
34
|
exportCsv: 'تصدير CSV',
|
|
33
35
|
noGroup: 'بلا مجموعة',
|
|
@@ -204,6 +206,11 @@ export const arLocale: M3Locale = {
|
|
|
204
206
|
paginationPage: 'الصفحة {page} من {pages}',
|
|
205
207
|
previousPage: 'الصفحة السابقة',
|
|
206
208
|
nextPage: 'الصفحة التالية',
|
|
209
|
+
firstPage: 'الصفحة الأولى',
|
|
210
|
+
lastPage: 'الصفحة الأخيرة',
|
|
211
|
+
goToPage: 'الصفحة {page}',
|
|
212
|
+
pagination: 'ترقيم الصفحات',
|
|
213
|
+
opensInNewTab: 'يفتح في علامة تبويب جديدة',
|
|
207
214
|
carousel: 'عرض دوّار',
|
|
208
215
|
carouselItem: '{index} من {count}',
|
|
209
216
|
sparklineSummary: 'من {first} إلى {last}، الأدنى {min}، الأعلى {max}',
|
package/src/locales/de.ts
CHANGED
|
@@ -24,6 +24,8 @@ export const deLocale: M3Locale = {
|
|
|
24
24
|
expand: 'Erweitern',
|
|
25
25
|
collapse: 'Einklappen',
|
|
26
26
|
clear: 'Löschen',
|
|
27
|
+
increase: 'Erhöhen',
|
|
28
|
+
decrease: 'Verringern',
|
|
27
29
|
columns: 'Spalten',
|
|
28
30
|
exportCsv: 'CSV exportieren',
|
|
29
31
|
noGroup: 'Keine Gruppe',
|
|
@@ -200,6 +202,11 @@ export const deLocale: M3Locale = {
|
|
|
200
202
|
paginationPage: 'Seite {page} von {pages}',
|
|
201
203
|
previousPage: 'Vorherige Seite',
|
|
202
204
|
nextPage: 'Nächste Seite',
|
|
205
|
+
firstPage: 'Erste Seite',
|
|
206
|
+
lastPage: 'Letzte Seite',
|
|
207
|
+
goToPage: 'Seite {page}',
|
|
208
|
+
pagination: 'Seitennavigation',
|
|
209
|
+
opensInNewTab: 'öffnet in einem neuen Tab',
|
|
203
210
|
carousel: 'Karussell',
|
|
204
211
|
carouselItem: '{index} von {count}', // MMap (maplibre controls)
|
|
205
212
|
sparklineSummary: 'Von {first} bis {last}, Minimum {min}, Maximum {max}',
|
package/src/locales/es.ts
CHANGED
|
@@ -24,6 +24,8 @@ export const esLocale: M3Locale = {
|
|
|
24
24
|
expand: 'Expandir',
|
|
25
25
|
collapse: 'Contraer',
|
|
26
26
|
clear: 'Borrar',
|
|
27
|
+
increase: 'Aumentar',
|
|
28
|
+
decrease: 'Disminuir',
|
|
27
29
|
columns: 'Columnas',
|
|
28
30
|
exportCsv: 'Exportar CSV',
|
|
29
31
|
noGroup: 'Sin grupo',
|
|
@@ -200,6 +202,11 @@ export const esLocale: M3Locale = {
|
|
|
200
202
|
paginationPage: 'Página {page} de {pages}',
|
|
201
203
|
previousPage: 'Página anterior',
|
|
202
204
|
nextPage: 'Página siguiente',
|
|
205
|
+
firstPage: 'Primera página',
|
|
206
|
+
lastPage: 'Última página',
|
|
207
|
+
goToPage: 'Página {page}',
|
|
208
|
+
pagination: 'Paginación',
|
|
209
|
+
opensInNewTab: 'se abre en una pestaña nueva',
|
|
203
210
|
carousel: 'Carrusel',
|
|
204
211
|
carouselItem: '{index} de {count}', // MMap (maplibre controls)
|
|
205
212
|
sparklineSummary: 'De {first} a {last}, mínimo {min}, máximo {max}',
|
package/src/locales/fr.ts
CHANGED
|
@@ -24,6 +24,8 @@ export const frLocale: M3Locale = {
|
|
|
24
24
|
expand: 'Développer',
|
|
25
25
|
collapse: 'Réduire',
|
|
26
26
|
clear: 'Effacer',
|
|
27
|
+
increase: 'Augmenter',
|
|
28
|
+
decrease: 'Diminuer',
|
|
27
29
|
columns: 'Colonnes',
|
|
28
30
|
exportCsv: 'Exporter CSV',
|
|
29
31
|
noGroup: 'Sans groupe',
|
|
@@ -200,6 +202,11 @@ export const frLocale: M3Locale = {
|
|
|
200
202
|
paginationPage: 'Page {page} sur {pages}',
|
|
201
203
|
previousPage: 'Page précédente',
|
|
202
204
|
nextPage: 'Page suivante',
|
|
205
|
+
firstPage: 'Première page',
|
|
206
|
+
lastPage: 'Dernière page',
|
|
207
|
+
goToPage: 'Page {page}',
|
|
208
|
+
pagination: 'Pagination',
|
|
209
|
+
opensInNewTab: 's’ouvre dans un nouvel onglet',
|
|
203
210
|
carousel: 'Carrousel',
|
|
204
211
|
carouselItem: '{index} sur {count}', // MMap (maplibre controls)
|
|
205
212
|
sparklineSummary: 'De {first} à {last}, minimum {min}, maximum {max}',
|