@m3ui-vue/m3ui-vue 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/API.md +34 -19
- package/dist/MButton-LiZRRP4h.js +171 -0
- package/dist/MButton-LiZRRP4h.js.map +1 -0
- package/dist/{MColorPickerModal-H8nuX0Wu.js → MColorPickerModal-IjciC8zh.js} +185 -184
- package/dist/MColorPickerModal-IjciC8zh.js.map +1 -0
- package/dist/MDialog-BLpfgIA3.js +167 -0
- package/dist/MDialog-BLpfgIA3.js.map +1 -0
- package/dist/MIcon-BSsJZhK7.js +116 -0
- package/dist/MIcon-BSsJZhK7.js.map +1 -0
- package/dist/{MIconButton-BBggVwBV.js → MIconButton-CNjN0xwW.js} +18 -18
- package/dist/{MIconButton-BBggVwBV.js.map → MIconButton-CNjN0xwW.js.map} +1 -1
- package/dist/{MListItem-DiOAxaN7.js → MListItem-BBQ-6i3v.js} +139 -139
- package/dist/MListItem-BBQ-6i3v.js.map +1 -0
- package/dist/{MLoadingIndicator-CuTZYFFj.js → MLoadingIndicator-dejdXpu8.js} +2 -2
- package/dist/{MLoadingIndicator-CuTZYFFj.js.map → MLoadingIndicator-dejdXpu8.js.map} +1 -1
- package/dist/MMenuItem-E31tMzOt.js +577 -0
- package/dist/MMenuItem-E31tMzOt.js.map +1 -0
- package/dist/MPdfViewer-B5Q9Xs9d.js +1866 -0
- package/dist/MPdfViewer-B5Q9Xs9d.js.map +1 -0
- package/dist/MProgressBar-CPrZhQbA.js +179 -0
- package/dist/MProgressBar-CPrZhQbA.js.map +1 -0
- package/dist/{MSeekBar-BCDQTx2t.js → MSeekBar-NwkuAzx-.js} +2 -2
- package/dist/{MSeekBar-BCDQTx2t.js.map → MSeekBar-NwkuAzx-.js.map} +1 -1
- package/dist/{MSegmentedButton-BXzRsg1S.js → MSegmentedButton-DZuZLBML.js} +4 -4
- package/dist/{MSegmentedButton-BXzRsg1S.js.map → MSegmentedButton-DZuZLBML.js.map} +1 -1
- package/dist/MSignaturePad-Bqr-1R9f.js +140 -0
- package/dist/MSignaturePad-Bqr-1R9f.js.map +1 -0
- package/dist/MSlider-B7dIcHVn.js +745 -0
- package/dist/MSlider-B7dIcHVn.js.map +1 -0
- package/dist/{MSpinner-UCdtSOHP.js → MSpinner-CXLY7lWw.js} +2 -2
- package/dist/{MSpinner-UCdtSOHP.js.map → MSpinner-CXLY7lWw.js.map} +1 -1
- package/dist/{MTextField-CYk9yFvi.js → MTextField-CryHMs8-.js} +18 -18
- package/dist/MTextField-CryHMs8-.js.map +1 -0
- package/dist/MTooltip-Cn_DYm9M.js +90 -0
- package/dist/MTooltip-Cn_DYm9M.js.map +1 -0
- package/dist/{_popupPosition-nL8SVKPK.js → _popupPosition-C_lxj9qU.js} +7 -7
- package/dist/_popupPosition-C_lxj9qU.js.map +1 -0
- package/dist/{_useFieldValidation-B0B44M_t.js → _useFieldValidation-CvZnZfl-.js} +2 -2
- package/dist/{_useFieldValidation-B0B44M_t.js.map → _useFieldValidation-CvZnZfl-.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/code-editor.js +129 -128
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MAddressField.vue.d.ts +1 -1
- package/dist/components/MAudioPlayer.vue.d.ts +1 -1
- package/dist/components/MAutocomplete.vue.d.ts +1 -1
- package/dist/components/MAvailabilityCalendar.vue.d.ts +3 -3
- package/dist/components/MBadge.vue.d.ts +2 -2
- package/dist/components/MBar.vue.d.ts +1 -1
- package/dist/components/MBeforeAfter.vue.d.ts +3 -3
- package/dist/components/MButton.vue.d.ts +1 -1
- package/dist/components/MCalendarHeatmap.vue.d.ts +1 -1
- package/dist/components/MChatBubble.vue.d.ts +1 -1
- package/dist/components/MCodeEditor.vue.d.ts +1 -1
- package/dist/components/MContainerTransform.vue.d.ts +1 -1
- package/dist/components/MCopyButton.vue.d.ts +2 -2
- package/dist/components/MCountrySelect.vue.d.ts +1 -1
- package/dist/components/MCreditCardInput.vue.d.ts +2 -2
- package/dist/components/MDiffViewer.vue.d.ts +1 -1
- package/dist/components/MDrawCanvas.vue.d.ts +2 -2
- package/dist/components/MExpansionPanel.vue.d.ts +1 -1
- package/dist/components/MExportButton.vue.d.ts +1 -1
- package/dist/components/MFab.vue.d.ts +1 -1
- package/dist/components/MFilterBuilder.vue.d.ts +1 -1
- package/dist/components/MFlex.vue.d.ts +2 -2
- package/dist/components/MFloorPlan.vue.d.ts +2 -2
- package/dist/components/MFlow.vue.d.ts +2 -2
- package/dist/components/MFormRenderer.vue.d.ts +2 -2
- package/dist/components/MGantt.vue.d.ts +2 -2
- package/dist/components/MGanttControls.vue.d.ts +1 -1
- package/dist/components/MGrid.vue.d.ts +1 -1
- package/dist/components/MIcon.vue.d.ts +3 -5
- package/dist/components/MIconButton.vue.d.ts +1 -1
- package/dist/components/MLightbox.vue.d.ts +2 -2
- package/dist/components/MMapMeasure.vue.d.ts +2 -2
- package/dist/components/MMenu.vue.d.ts +6 -3
- package/dist/components/MMortgageCalculator.vue.d.ts +2 -2
- package/dist/components/MMultiAutocomplete.vue.d.ts +1 -1
- package/dist/components/MMultiSelect.vue.d.ts +1 -1
- package/dist/components/MNavigationDrawer.vue.d.ts +5 -4
- package/dist/components/MNavigationRail.vue.d.ts +1 -1
- package/dist/components/MNumberField.vue.d.ts +1 -1
- package/dist/components/MOdontogram.vue.d.ts +2 -2
- package/dist/components/MPdfSigner.vue.d.ts +1 -1
- package/dist/components/MPhoneInput.vue.d.ts +2 -2
- package/dist/components/MPinInput.vue.d.ts +3 -3
- package/dist/components/MPosKeypad.vue.d.ts +1 -1
- package/dist/components/MProductConfigurator.vue.d.ts +1 -1
- package/dist/components/MResourceTimeline.vue.d.ts +2 -2
- package/dist/components/MRichTextEditor.vue.d.ts +1 -1
- package/dist/components/MScheme.vue.d.ts +1 -1
- package/dist/components/MSearchBar.vue.d.ts +2 -2
- package/dist/components/MSearchField.vue.d.ts +1 -1
- package/dist/components/MSeatMap.vue.d.ts +1 -1
- package/dist/components/MSeekBar.vue.d.ts +2 -2
- package/dist/components/MSelect.vue.d.ts +1 -1
- package/dist/components/MShortNavigationBar.vue.d.ts +1 -1
- package/dist/components/MSkeleton.vue.d.ts +1 -1
- package/dist/components/MSpreadsheet.vue.d.ts +2 -2
- package/dist/components/MStack.vue.d.ts +2 -2
- package/dist/components/MSubtitle.vue.d.ts +1 -1
- package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
- package/dist/components/MSwitch.vue.d.ts +1 -1
- package/dist/components/MTagInput.vue.d.ts +1 -1
- package/dist/components/MText.vue.d.ts +1 -1
- package/dist/components/MTextField.vue.d.ts +3 -3
- package/dist/components/MTimeScroll.vue.d.ts +1 -1
- package/dist/components/MTimezoneSelect.vue.d.ts +1 -1
- package/dist/components/MTitle.vue.d.ts +1 -1
- package/dist/components/MToolbar.vue.d.ts +1 -1
- package/dist/components/MTooltip.vue.d.ts +1 -1
- package/dist/components/MTopAppBar.vue.d.ts +2 -2
- package/dist/components/MVitalsChart.vue.d.ts +1 -1
- package/dist/components/MWindow.vue.d.ts +3 -3
- package/dist/components/_MDrawerItemList.vue.d.ts +8 -1
- package/dist/composables/_fieldLayout.d.ts +8 -8
- package/dist/composables/_popupPosition.d.ts +3 -2
- package/dist/composables/_rtl.d.ts +26 -0
- package/dist/composables/useColorPalette.d.ts +1 -1
- package/dist/composables/useLocale.d.ts +4 -0
- package/dist/draw.js +5 -5
- package/dist/flow.js +2 -2
- package/dist/gantt.js +3 -3
- package/dist/locales/ar.d.ts +6 -0
- package/dist/locales/index.d.ts +1 -0
- package/dist/locales/index.js +768 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +11962 -12039
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +1127 -1149
- package/dist/map.js.map +1 -1
- package/dist/markdown.js +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/media.js +7 -7
- package/dist/pdf-sign.d.ts +3 -0
- package/dist/pdf-sign.js +548 -0
- package/dist/pdf-sign.js.map +1 -0
- package/dist/pdf.d.ts +0 -3
- package/dist/pdf.js +1 -2400
- package/dist/plugin.d.ts +8 -0
- package/dist/rich-text-editor.js +79 -77
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles/theme.css +13 -0
- package/dist/styles.css +1 -1
- package/dist/terminal.js +5 -2
- package/dist/terminal.js.map +1 -1
- package/dist/{useLocale-DL96OFgr.js → useLocale-ybIju59R.js} +3 -1
- package/dist/useLocale-ybIju59R.js.map +1 -0
- package/dist/vTooltip-xESB2YOb.js +154 -0
- package/dist/vTooltip-xESB2YOb.js.map +1 -0
- package/package.json +5 -1
- package/src/__tests__/MAddressField.test.ts +1 -1
- package/src/__tests__/MChip.test.ts +3 -3
- package/src/__tests__/MFab.test.ts +6 -6
- package/src/__tests__/MListItemNestedControl.test.ts +2 -2
- package/src/__tests__/MScheduler.test.ts +1 -1
- package/src/__tests__/MTrackingTimeline.test.ts +1 -1
- package/src/__tests__/MWindow.test.ts +16 -0
- package/src/__tests__/fieldOverflow.test.ts +9 -9
- package/src/__tests__/hydration.test.ts +39 -0
- package/src/__tests__/localePresets.test.ts +2 -0
- package/src/__tests__/rtl.test.ts +167 -0
- package/src/__tests__/ssr.test.ts +6 -0
- package/src/components/MAlert.vue +1 -1
- package/src/components/MAutocomplete.vue +7 -7
- package/src/components/MAvailabilityCalendar.vue +5 -3
- package/src/components/MBadge.vue +12 -3
- package/src/components/MBar.vue +1 -1
- package/src/components/MBottomAppBar.vue +1 -1
- package/src/components/MCalendar.vue +3 -3
- package/src/components/MCalendarHeatmap.vue +3 -3
- package/src/components/MChatBubble.vue +3 -3
- package/src/components/MChip.vue +6 -6
- package/src/components/MCodeEditor.vue +7 -3
- package/src/components/MColorPicker.vue +1 -1
- package/src/components/MCommandPalette.vue +1 -1
- package/src/components/MContainerTransform.vue +1 -1
- package/src/components/MContextMenu.vue +1 -1
- package/src/components/MDataTable.vue +5 -5
- package/src/components/MDatePicker.vue +3 -2
- package/src/components/MDateRangePicker.vue +3 -2
- package/src/components/MDialog.vue +5 -5
- package/src/components/MDiffViewer.vue +1 -1
- package/src/components/MDivider.vue +1 -1
- package/src/components/MDragDropList.vue +1 -1
- package/src/components/MEmojiSelector.vue +11 -7
- package/src/components/MExpansionPanel.vue +1 -1
- package/src/components/MFab.vue +5 -5
- package/src/components/MFormBuilder.vue +3 -3
- package/src/components/MIcon.vue +14 -2
- package/src/components/MJsonEditor.vue +1 -3
- package/src/components/MJsonViewer.vue +1 -1
- package/src/components/MKanban.vue +2 -1
- package/src/components/MListDetail.vue +2 -2
- package/src/components/MListGroup.vue +1 -1
- package/src/components/MListItem.vue +5 -5
- package/src/components/MListSubheader.vue +1 -1
- package/src/components/MMapDraw.vue +3 -2
- package/src/components/MMapHover.vue +2 -1
- package/src/components/MMapMeasure.vue +2 -1
- package/src/components/MMapRoute.vue +2 -1
- package/src/components/MMarkdown.vue +9 -6
- package/src/components/MMaskField.vue +6 -6
- package/src/components/MMenu.vue +13 -6
- package/src/components/MMenuItem.vue +8 -6
- package/src/components/MMultiAutocomplete.vue +9 -8
- package/src/components/MMultiSelect.vue +9 -8
- package/src/components/MNavigationDrawer.vue +39 -27
- package/src/components/MNavigationRail.vue +28 -19
- package/src/components/MNavigationSuite.vue +1 -1
- package/src/components/MNotificationCenter.vue +1 -1
- package/src/components/MNotificationHost.vue +1 -1
- package/src/components/MNumberField.vue +6 -6
- package/src/components/MOrderTicket.vue +1 -1
- package/src/components/MPageProgress.vue +1 -1
- package/src/components/MPdfSigner.vue +1 -1
- package/src/components/MPhoneInput.vue +5 -4
- package/src/components/MPinInput.vue +3 -2
- package/src/components/MPosKeypad.vue +2 -1
- package/src/components/MProductConfigurator.vue +2 -1
- package/src/components/MProgressBar.vue +2 -2
- package/src/components/MRichTextEditor.vue +8 -4
- package/src/components/MScheduler.vue +14 -14
- package/src/components/MSearchField.vue +1 -1
- package/src/components/MSeatMap.vue +2 -1
- package/src/components/MSegmentedButton.vue +1 -1
- package/src/components/MSelect.vue +7 -7
- package/src/components/MSideSheet.vue +3 -2
- package/src/components/MSimpleCarousel.vue +20 -11
- package/src/components/MSlider.vue +15 -5
- package/src/components/MSnackbar.vue +2 -2
- package/src/components/MSplitButton.vue +3 -2
- package/src/components/MSplitter.vue +6 -3
- package/src/components/MSpotlightSearch.vue +1 -1
- package/src/components/MSwitch.vue +5 -5
- package/src/components/MTable.vue +3 -3
- package/src/components/MTabs.vue +4 -1
- package/src/components/MTagInput.vue +6 -6
- package/src/components/MTerminal.vue +1 -1
- package/src/components/MText.vue +1 -1
- package/src/components/MTextField.vue +7 -7
- package/src/components/MTimePicker.vue +3 -2
- package/src/components/MTimePickerModal.vue +2 -2
- package/src/components/MTimeScroll.vue +1 -1
- package/src/components/MTimeline.vue +12 -12
- package/src/components/MToolbar.vue +3 -3
- package/src/components/MTrackingTimeline.vue +3 -2
- package/src/components/MTransition.vue +8 -3
- package/src/components/MTreeTable.vue +1 -1
- package/src/components/MTypewriter.vue +1 -1
- package/src/components/MVirtualTable.vue +2 -2
- package/src/components/MWindow.vue +4 -3
- package/src/components/_MColorPanel.vue +5 -4
- package/src/components/_MDrawerItemList.vue +9 -5
- package/src/components/_MMapAttribution.vue +2 -1
- package/src/components/_MMonthYearButton.vue +1 -1
- package/src/components/_MTransferPane.vue +8 -1
- package/src/components/_MTreeNode.vue +3 -3
- package/src/components/_MYearGrid.vue +4 -2
- package/src/composables/_fieldLayout.ts +19 -19
- package/src/composables/_popupPosition.ts +5 -3
- package/src/composables/_rtl.ts +76 -0
- package/src/composables/_useMenuNav.ts +24 -17
- package/src/composables/_useSheetMotion.ts +10 -3
- package/src/composables/pdfSign.ts +2 -2
- package/src/composables/useLocale.ts +6 -0
- package/src/locales/ar.ts +798 -0
- package/src/locales/de.ts +2 -0
- package/src/locales/es.ts +2 -0
- package/src/locales/fr.ts +2 -0
- package/src/locales/index.ts +1 -0
- package/src/locales/ja.ts +2 -0
- package/src/locales/ko.ts +2 -0
- package/src/locales/pt.ts +2 -0
- package/src/locales/zh.ts +2 -0
- package/src/pdf-sign.ts +5 -0
- package/src/pdf.ts +0 -3
- package/src/plugin.ts +10 -0
- package/src/styles/theme.css +13 -0
- package/dist/MColorPickerModal-H8nuX0Wu.js.map +0 -1
- package/dist/MDialog-B42Mhn8W.js +0 -331
- package/dist/MDialog-B42Mhn8W.js.map +0 -1
- package/dist/MIcon-DpajuUTJ.js +0 -33
- package/dist/MIcon-DpajuUTJ.js.map +0 -1
- package/dist/MListItem-DiOAxaN7.js.map +0 -1
- package/dist/MMenuItem-BuxYoASE.js +0 -574
- package/dist/MMenuItem-BuxYoASE.js.map +0 -1
- package/dist/MSignaturePad-BTqGaPXA.js +0 -313
- package/dist/MSignaturePad-BTqGaPXA.js.map +0 -1
- package/dist/MSlider-D_O8J9YH.js +0 -739
- package/dist/MSlider-D_O8J9YH.js.map +0 -1
- package/dist/MTextField-CYk9yFvi.js.map +0 -1
- package/dist/MTooltip-CK39Zon4.js +0 -183
- package/dist/MTooltip-CK39Zon4.js.map +0 -1
- package/dist/_popupPosition-nL8SVKPK.js.map +0 -1
- package/dist/pdf.js.map +0 -1
- package/dist/useLocale-DL96OFgr.js.map +0 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
function e(e, t, n) {
|
|
2
|
+
let r = e.getBoundingClientRect(), i = t.getBoundingClientRect(), a = 0, o = 0;
|
|
3
|
+
switch (n) {
|
|
4
|
+
case "top":
|
|
5
|
+
a = r.top - i.height - 4, o = r.left + (r.width - i.width) / 2;
|
|
6
|
+
break;
|
|
7
|
+
case "bottom":
|
|
8
|
+
a = r.bottom + 4, o = r.left + (r.width - i.width) / 2;
|
|
9
|
+
break;
|
|
10
|
+
case "left":
|
|
11
|
+
a = r.top + (r.height - i.height) / 2, o = r.left - i.width - 4;
|
|
12
|
+
break;
|
|
13
|
+
case "right": a = r.top + (r.height - i.height) / 2, o = r.right + 4;
|
|
14
|
+
}
|
|
15
|
+
return a = Math.max(6, Math.min(a, window.innerHeight - i.height - 6)), o = Math.max(6, Math.min(o, window.innerWidth - i.width - 6)), {
|
|
16
|
+
top: a,
|
|
17
|
+
left: o
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function t(e, t) {
|
|
21
|
+
let n, r, i = null, a = !1, o = () => t.rich?.() ?? !1;
|
|
22
|
+
function s() {
|
|
23
|
+
clearTimeout(n), clearTimeout(r);
|
|
24
|
+
}
|
|
25
|
+
function c() {
|
|
26
|
+
s(), n = setTimeout(t.open, t.delay());
|
|
27
|
+
}
|
|
28
|
+
function l() {
|
|
29
|
+
s(), o() ? r = setTimeout(t.close, 120) : t.close();
|
|
30
|
+
}
|
|
31
|
+
function u() {
|
|
32
|
+
s(), t.close();
|
|
33
|
+
}
|
|
34
|
+
function d(e) {
|
|
35
|
+
e.pointerType === "mouse" && c();
|
|
36
|
+
}
|
|
37
|
+
function f(e) {
|
|
38
|
+
e.pointerType === "mouse" && l();
|
|
39
|
+
}
|
|
40
|
+
function p() {
|
|
41
|
+
i && clearTimeout(i.timer), i = null, window.removeEventListener("pointermove", h), window.removeEventListener("pointerup", g), window.removeEventListener("pointercancel", v);
|
|
42
|
+
}
|
|
43
|
+
function m(e) {
|
|
44
|
+
e.pointerType !== "mouse" && (p(), a = !1, i = {
|
|
45
|
+
id: e.pointerId,
|
|
46
|
+
x: e.clientX,
|
|
47
|
+
y: e.clientY,
|
|
48
|
+
timer: setTimeout(() => {
|
|
49
|
+
a = !0, s(), t.open();
|
|
50
|
+
}, 500)
|
|
51
|
+
}, window.addEventListener("pointermove", h), window.addEventListener("pointerup", g), window.addEventListener("pointercancel", v));
|
|
52
|
+
}
|
|
53
|
+
function h(e) {
|
|
54
|
+
i && e.pointerId === i.id && Math.hypot(e.clientX - i.x, e.clientY - i.y) > 10 && p();
|
|
55
|
+
}
|
|
56
|
+
function g(e) {
|
|
57
|
+
i && e.pointerId === i.id && (p(), a && (s(), o() ? document.addEventListener("pointerdown", _, !0) : r = setTimeout(t.close, 1500)));
|
|
58
|
+
}
|
|
59
|
+
function _(n) {
|
|
60
|
+
let r = n.target;
|
|
61
|
+
t.tip()?.contains(r) || e.contains(r) || (document.removeEventListener("pointerdown", _, !0), t.close());
|
|
62
|
+
}
|
|
63
|
+
function v(e) {
|
|
64
|
+
i && e.pointerId === i.id && (p(), a && l());
|
|
65
|
+
}
|
|
66
|
+
function y(e) {
|
|
67
|
+
a && (a = !1, e.preventDefault(), e.stopPropagation());
|
|
68
|
+
}
|
|
69
|
+
function b(e) {
|
|
70
|
+
(i || a) && e.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
function x(e) {
|
|
73
|
+
let t = !0;
|
|
74
|
+
try {
|
|
75
|
+
t = e.target.matches(":focus-visible");
|
|
76
|
+
} catch {}
|
|
77
|
+
t && c();
|
|
78
|
+
}
|
|
79
|
+
function S(e) {
|
|
80
|
+
e.key === "Escape" && t.visible() && (e.stopPropagation(), u());
|
|
81
|
+
}
|
|
82
|
+
function C() {
|
|
83
|
+
t.visible() && u();
|
|
84
|
+
}
|
|
85
|
+
return e.addEventListener("pointerenter", d), e.addEventListener("pointerleave", f), e.addEventListener("pointerdown", m), e.addEventListener("click", y, !0), e.addEventListener("contextmenu", b), e.addEventListener("focusin", x), e.addEventListener("focusout", l), e.addEventListener("keydown", S), window.addEventListener("scroll", C, !0), {
|
|
86
|
+
cancel: s,
|
|
87
|
+
closeNow: u,
|
|
88
|
+
destroy() {
|
|
89
|
+
s(), p(), document.removeEventListener("pointerdown", _, !0), e.removeEventListener("pointerenter", d), e.removeEventListener("pointerleave", f), e.removeEventListener("pointerdown", m), e.removeEventListener("click", y, !0), e.removeEventListener("contextmenu", b), e.removeEventListener("focusin", x), e.removeEventListener("focusout", l), e.removeEventListener("keydown", S), window.removeEventListener("scroll", C, !0);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// src/directives/vTooltip.ts
|
|
94
|
+
function n(e) {
|
|
95
|
+
return e == null ? {} : typeof e == "string" ? { text: e } : e;
|
|
96
|
+
}
|
|
97
|
+
var r = 0, i = /* @__PURE__ */ new WeakMap();
|
|
98
|
+
function a(t, n) {
|
|
99
|
+
let { text: r, disabled: i, placement: a = "top" } = n.options;
|
|
100
|
+
if (!r || i) return;
|
|
101
|
+
let o = n.tip;
|
|
102
|
+
o || (o = document.createElement("div"), o.className = "pointer-events-none fixed z-400 min-h-6 min-w-10 max-w-[200px] rounded bg-inverse-surface px-2 py-1 text-body-small text-inverse-on-surface", o.id = n.id, o.setAttribute("role", "tooltip"), document.body.appendChild(o), n.tip = o, o.animate?.([{ opacity: 0 }, { opacity: 1 }], { duration: 150 })), o.textContent = r;
|
|
103
|
+
let { top: c, left: l } = e(t, o, a);
|
|
104
|
+
o.style.top = `${c}px`, o.style.left = `${l}px`, s(t, n.id);
|
|
105
|
+
}
|
|
106
|
+
function o(e, t) {
|
|
107
|
+
let n = t.tip;
|
|
108
|
+
if (!n) return;
|
|
109
|
+
t.tip = null, c(e, t.id);
|
|
110
|
+
let r = n.animate?.([{ opacity: 1 }, { opacity: 0 }], {
|
|
111
|
+
duration: 100,
|
|
112
|
+
fill: "forwards"
|
|
113
|
+
});
|
|
114
|
+
if (!r) return n.remove();
|
|
115
|
+
t.leaving.add(n), r.onfinish = () => {
|
|
116
|
+
t.leaving.delete(n), n.remove();
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function s(e, t) {
|
|
120
|
+
let n = (e.getAttribute("aria-describedby") ?? "").split(/\s+/).filter(Boolean);
|
|
121
|
+
n.includes(t) || e.setAttribute("aria-describedby", [...n, t].join(" "));
|
|
122
|
+
}
|
|
123
|
+
function c(e, t) {
|
|
124
|
+
let n = (e.getAttribute("aria-describedby") ?? "").split(/\s+/).filter((e) => e && e !== t);
|
|
125
|
+
n.length ? e.setAttribute("aria-describedby", n.join(" ")) : e.removeAttribute("aria-describedby");
|
|
126
|
+
}
|
|
127
|
+
var l = {
|
|
128
|
+
mounted(e, s) {
|
|
129
|
+
let c = {
|
|
130
|
+
options: n(s.value),
|
|
131
|
+
tip: null,
|
|
132
|
+
leaving: /* @__PURE__ */ new Set(),
|
|
133
|
+
id: `m3-tooltip-${++r}`
|
|
134
|
+
};
|
|
135
|
+
c.trigger = t(e, {
|
|
136
|
+
delay: () => c.options.delay ?? 600,
|
|
137
|
+
visible: () => !!c.tip,
|
|
138
|
+
open: () => a(e, c),
|
|
139
|
+
close: () => o(e, c),
|
|
140
|
+
tip: () => c.tip
|
|
141
|
+
}), i.set(e, c);
|
|
142
|
+
},
|
|
143
|
+
updated(e, t) {
|
|
144
|
+
let r = i.get(e);
|
|
145
|
+
r && (r.options = n(t.value), r.tip && (!r.options.text || r.options.disabled ? r.trigger.closeNow() : a(e, r)));
|
|
146
|
+
},
|
|
147
|
+
beforeUnmount(e) {
|
|
148
|
+
let t = i.get(e);
|
|
149
|
+
t && (t.trigger.destroy(), t.tip?.remove(), t.leaving.forEach((e) => e.remove()), c(e, t.id), i.delete(e));
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
export { t as n, e as r, l as t };
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=vTooltip-xESB2YOb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vTooltip-xESB2YOb.js","names":["placeTooltip","tr","trigger","tt","tip","top","left","placement","createTooltipTrigger","showTimer","hideTimer","press","longPressed","rich","o","cancel","show","hide","closeNow","onPointerEnter","onPointerLeave","endPress","onPressMove","onPressUp","onPressCancel","onPointerDown","onOutsideTouch","t","e","el","onClickCapture","onContextMenu","onFocusIn","keyboard","onKeyDown","onScroll","normalize","value","nextId","states","open","state","text","disabled","addDescribedBy","close","removeDescribedBy","anim","ids","id","x","vTooltip","binding"],"sources":["../src/composables/_tooltipTrigger.ts","../src/directives/vTooltip.ts"],"sourcesContent":["/*\n * Internal (not exported from index.ts): what opens and closes a tooltip, shared by MTooltip and v-tooltip.\n *\n * Input as Compose's BasicTooltip: a mouse shows it on hover after `delay`; touch and pen on a long press, which\n * also swallows the click it would end in (a long-pressed button doesn't fire) and hides it TOUCH_DURATION after\n * the finger lifts (BasicTooltipDefaults.TooltipDuration); focus only from the keyboard. Escape hides it (and\n * stops there, so a dialog around it stays open), and so does any scroll. A rich tooltip closes a moment after\n * the pointer leaves (so it can move onto the tooltip), and after a long press stays until a touch outside it.\n */\n\nexport type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right'\n\nconst LONG_PRESS = 500\nconst TOUCH_DURATION = 1500\nconst RICH_HIDE_DELAY = 120\nconst GAP = 4\nconst MARGIN = 6\n\n/** Where `tip` goes next to `trigger`, kept 6px inside the window */\nexport function placeTooltip(trigger: HTMLElement, tip: HTMLElement, placement: TooltipPlacement) {\n const tr = trigger.getBoundingClientRect()\n const tt = tip.getBoundingClientRect()\n let top = 0\n let left = 0\n switch (placement) {\n case 'top': top = tr.top - tt.height - GAP; left = tr.left + (tr.width - tt.width) / 2; break\n case 'bottom': top = tr.bottom + GAP; left = tr.left + (tr.width - tt.width) / 2; break\n case 'left': top = tr.top + (tr.height - tt.height) / 2; left = tr.left - tt.width - GAP; break\n case 'right': top = tr.top + (tr.height - tt.height) / 2; left = tr.right + GAP; break\n }\n top = Math.max(MARGIN, Math.min(top, window.innerHeight - tt.height - MARGIN))\n left = Math.max(MARGIN, Math.min(left, window.innerWidth - tt.width - MARGIN))\n return { top, left }\n}\n\nexport interface TooltipTriggerOptions {\n delay: () => number\n rich?: () => boolean\n visible: () => boolean\n open: () => void\n close: () => void\n /** The tooltip's element while shown: a touch on it doesn't close a rich tooltip */\n tip: () => HTMLElement | null | undefined\n}\n\nexport function createTooltipTrigger(el: HTMLElement, o: TooltipTriggerOptions) {\n let showTimer: ReturnType<typeof setTimeout> | undefined\n let hideTimer: ReturnType<typeof setTimeout> | undefined\n let press: { id: number, x: number, y: number, timer: ReturnType<typeof setTimeout> } | null = null\n let longPressed = false\n const rich = () => o.rich?.() ?? false\n\n function cancel() {\n clearTimeout(showTimer)\n clearTimeout(hideTimer)\n }\n function show() {\n cancel()\n showTimer = setTimeout(o.open, o.delay())\n }\n function hide() {\n cancel()\n if (rich()) hideTimer = setTimeout(o.close, RICH_HIDE_DELAY)\n else o.close()\n }\n function closeNow() {\n cancel()\n o.close()\n }\n\n function onPointerEnter(e: PointerEvent) {\n if (e.pointerType === 'mouse') show()\n }\n function onPointerLeave(e: PointerEvent) {\n if (e.pointerType === 'mouse') hide()\n }\n\n function endPress() {\n if (press) clearTimeout(press.timer)\n press = null\n window.removeEventListener('pointermove', onPressMove)\n window.removeEventListener('pointerup', onPressUp)\n window.removeEventListener('pointercancel', onPressCancel)\n }\n function onPointerDown(e: PointerEvent) {\n if (e.pointerType === 'mouse') return\n endPress()\n longPressed = false\n press = {\n id: e.pointerId,\n x: e.clientX,\n y: e.clientY,\n timer: setTimeout(() => {\n longPressed = true\n cancel()\n o.open()\n }, LONG_PRESS),\n }\n window.addEventListener('pointermove', onPressMove)\n window.addEventListener('pointerup', onPressUp)\n window.addEventListener('pointercancel', onPressCancel)\n }\n function onPressMove(e: PointerEvent) {\n if (press && e.pointerId === press.id && Math.hypot(e.clientX - press.x, e.clientY - press.y) > 10) endPress()\n }\n function onPressUp(e: PointerEvent) {\n if (!press || e.pointerId !== press.id) return\n endPress()\n if (!longPressed) return\n cancel()\n // A rich tooltip may hold actions to tap: it stays until a touch outside it (Compose's persistent tooltips)\n if (rich()) document.addEventListener('pointerdown', onOutsideTouch, true)\n else hideTimer = setTimeout(o.close, TOUCH_DURATION)\n }\n function onOutsideTouch(e: PointerEvent) {\n const t = e.target as Node\n if (o.tip()?.contains(t) || el.contains(t)) return\n document.removeEventListener('pointerdown', onOutsideTouch, true)\n o.close()\n }\n // The browser took the touch (a scroll)\n function onPressCancel(e: PointerEvent) {\n if (!press || e.pointerId !== press.id) return\n endPress()\n if (longPressed) hide()\n }\n // The click a long press ends in, and the context menu it may open, belong to the tooltip\n function onClickCapture(e: MouseEvent) {\n if (!longPressed) return\n longPressed = false\n e.preventDefault()\n e.stopPropagation()\n }\n function onContextMenu(e: Event) {\n if (press || longPressed) e.preventDefault()\n }\n\n function onFocusIn(e: FocusEvent) {\n let keyboard = true\n try { keyboard = (e.target as Element).matches(':focus-visible') } catch { /* no :focus-visible: show */ }\n if (keyboard) show()\n }\n function onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Escape' && o.visible()) {\n // Hiding the tooltip uses the key: a dialog around it stays open\n e.stopPropagation()\n closeNow()\n }\n }\n function onScroll() {\n if (o.visible()) closeNow()\n }\n\n el.addEventListener('pointerenter', onPointerEnter)\n el.addEventListener('pointerleave', onPointerLeave)\n el.addEventListener('pointerdown', onPointerDown)\n el.addEventListener('click', onClickCapture, true)\n el.addEventListener('contextmenu', onContextMenu)\n el.addEventListener('focusin', onFocusIn)\n el.addEventListener('focusout', hide)\n el.addEventListener('keydown', onKeyDown)\n window.addEventListener('scroll', onScroll, true)\n\n return {\n /** Keeps it open (the pointer moved onto a rich tooltip) */\n cancel,\n /** Closes it at once */\n closeNow,\n destroy() {\n cancel()\n endPress()\n document.removeEventListener('pointerdown', onOutsideTouch, true)\n el.removeEventListener('pointerenter', onPointerEnter)\n el.removeEventListener('pointerleave', onPointerLeave)\n el.removeEventListener('pointerdown', onPointerDown)\n el.removeEventListener('click', onClickCapture, true)\n el.removeEventListener('contextmenu', onContextMenu)\n el.removeEventListener('focusin', onFocusIn)\n el.removeEventListener('focusout', hide)\n el.removeEventListener('keydown', onKeyDown)\n window.removeEventListener('scroll', onScroll, true)\n },\n }\n}\n","import type { Directive } from 'vue'\nimport { createTooltipTrigger, placeTooltip, type TooltipPlacement } from '../composables/_tooltipTrigger'\n\n/** Options for `v-tooltip`. */\nexport interface TooltipOptions {\n /** The tooltip's text; nothing shows while it's empty. */\n text?: string\n /** Side of the element it shows on (default `'top'`); it stays inside the window. */\n placement?: TooltipPlacement\n /** Delay before it shows on hover or keyboard focus, in ms (default 600, like MTooltip). */\n delay?: number\n /** Never shows while true. */\n disabled?: boolean\n}\n\n/** `v-tooltip` value: the text, or an options object. */\nexport type TooltipValue = string | TooltipOptions | null | undefined\n\nfunction normalize(value: TooltipValue): TooltipOptions {\n if (value == null) return {}\n return typeof value === 'string' ? { text: value } : value\n}\n\n// MTooltip's plain tooltip\nconst TIP_CLASS = 'pointer-events-none fixed z-400 min-h-6 min-w-10 max-w-[200px] rounded bg-inverse-surface px-2 py-1 text-body-small text-inverse-on-surface'\n\nlet nextId = 0\n\ninterface TooltipState {\n options: TooltipOptions\n tip: HTMLDivElement | null\n // Tooltips still fading out, removed at once if the element goes away first\n leaving: Set<HTMLDivElement>\n id: string\n trigger: ReturnType<typeof createTooltipTrigger>\n}\n\nconst states = new WeakMap<HTMLElement, TooltipState>()\n\nfunction open(el: HTMLElement, state: TooltipState) {\n const { text, disabled, placement = 'top' } = state.options\n if (!text || disabled) return\n let tip = state.tip\n if (!tip) {\n tip = document.createElement('div')\n tip.className = TIP_CLASS\n tip.id = state.id\n tip.setAttribute('role', 'tooltip')\n document.body.appendChild(tip)\n state.tip = tip\n tip.animate?.([{ opacity: 0 }, { opacity: 1 }], { duration: 150 })\n }\n tip.textContent = text\n const { top, left } = placeTooltip(el, tip, placement)\n tip.style.top = `${top}px`\n tip.style.left = `${left}px`\n addDescribedBy(el, state.id)\n}\n\nfunction close(el: HTMLElement, state: TooltipState) {\n const tip = state.tip\n if (!tip) return\n state.tip = null\n removeDescribedBy(el, state.id)\n const anim = tip.animate?.([{ opacity: 1 }, { opacity: 0 }], { duration: 100, fill: 'forwards' })\n if (!anim) return tip.remove()\n state.leaving.add(tip)\n anim.onfinish = () => {\n state.leaving.delete(tip)\n tip.remove()\n }\n}\n\n// While it shows, the element is described by it (aria-describedby), keeping any ids already there\nfunction addDescribedBy(el: HTMLElement, id: string) {\n const ids = (el.getAttribute('aria-describedby') ?? '').split(/\\s+/).filter(Boolean)\n if (!ids.includes(id)) el.setAttribute('aria-describedby', [...ids, id].join(' '))\n}\nfunction removeDescribedBy(el: HTMLElement, id: string) {\n const ids = (el.getAttribute('aria-describedby') ?? '').split(/\\s+/).filter((x) => x && x !== id)\n if (ids.length) el.setAttribute('aria-describedby', ids.join(' '))\n else el.removeAttribute('aria-describedby')\n}\n\n/**\n * MTooltip's plain tooltip on any element, without wrapping it: `v-tooltip=\"'Save'\"` or\n * `v-tooltip=\"{ text, placement, delay, disabled }\"`. Shows after a delay on mouse hover, on keyboard focus, and\n * on a long press on touch (swallowing that press's click, hiding 1.5s after the finger lifts); Escape and\n * scrolling hide it. Registered globally as `v-tooltip` by `createM3UI()`; import `vTooltip` to use it without\n * the plugin.\n */\nexport const vTooltip: Directive<HTMLElement, TooltipValue> = {\n mounted(el, binding) {\n const state = {\n options: normalize(binding.value),\n tip: null,\n leaving: new Set(),\n id: `m3-tooltip-${++nextId}`,\n } as unknown as TooltipState\n state.trigger = createTooltipTrigger(el, {\n delay: () => state.options.delay ?? 600,\n visible: () => !!state.tip,\n open: () => open(el, state),\n close: () => close(el, state),\n tip: () => state.tip,\n })\n states.set(el, state)\n },\n updated(el, binding) {\n const state = states.get(el)\n if (!state) return\n state.options = normalize(binding.value)\n // Showing: follow the new text, or hide when it went empty or disabled\n if (state.tip) {\n if (!state.options.text || state.options.disabled) state.trigger.closeNow()\n else open(el, state)\n }\n },\n beforeUnmount(el) {\n const state = states.get(el)\n if (!state) return\n state.trigger.destroy()\n state.tip?.remove()\n state.leaving.forEach((tip) => tip.remove())\n removeDescribedBy(el, state.id)\n states.delete(el)\n },\n}\n"],"mappings":"AAmBA,SAAgBA,EAAa,GAAsB,GAAkB,GAA6B;CAChG,IAAMC,IAAKC,EAAQ,sBAAsB,GACnCC,IAAKC,EAAI,sBAAsB,GACjCC,IAAM,GACNC,IAAO;CACX,QAAQC,GAAR;EACE,KAAK;GAAuC,AAAhC,IAAMN,EAAG,MAAME,EAAG,SAAS,GAAK,IAAOF,EAAG,QAAQA,EAAG,QAAQE,EAAG,SAAS;GAAG;EACxF,KAAK;GAAiC,AAAvB,I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EAAE,GAC9BF,EAAO,OAAOV,CAAE;CAClB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m3ui-vue/m3ui-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Material 3 component library for Vue 3 + Tailwind CSS v4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,6 +68,10 @@
|
|
|
68
68
|
"types": "./dist/pdf.d.ts",
|
|
69
69
|
"import": "./dist/pdf.js"
|
|
70
70
|
},
|
|
71
|
+
"./pdf-sign": {
|
|
72
|
+
"types": "./dist/pdf-sign.d.ts",
|
|
73
|
+
"import": "./dist/pdf-sign.js"
|
|
74
|
+
},
|
|
71
75
|
"./flow": {
|
|
72
76
|
"types": "./dist/flow.d.ts",
|
|
73
77
|
"import": "./dist/flow.js"
|
|
@@ -114,7 +114,7 @@ describe('MAddressField', () => {
|
|
|
114
114
|
|
|
115
115
|
it('keeps room for its clear button from the start, so long text never runs under it', async () => {
|
|
116
116
|
const { input } = await mountField()
|
|
117
|
-
expect(input.classes()).toContain('
|
|
117
|
+
expect(input.classes()).toContain('pe-12')
|
|
118
118
|
})
|
|
119
119
|
|
|
120
120
|
it('clears from its button', async () => {
|
|
@@ -22,14 +22,14 @@ describe('MChip', () => {
|
|
|
22
22
|
const w = chip({ type: 'assist', icon: 'event' })
|
|
23
23
|
expect(w.classes()).toEqual(expect.arrayContaining(['border', 'border-outline-variant', 'text-on-surface', 'rounded-sm']))
|
|
24
24
|
expect(w.find('.material-symbols-outlined').classes()).toContain('text-primary')
|
|
25
|
-
expect(w.find('button').classes()).toContain('
|
|
25
|
+
expect(w.find('button').classes()).toContain('ps-2')
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
it('draws an elevated suggestion chip without an outline', () => {
|
|
29
29
|
const w = chip({ type: 'suggestion', elevated: true })
|
|
30
30
|
expect(w.classes()).toEqual(expect.arrayContaining(['bg-surface-container-low', 'shadow-elevation-1', 'text-on-surface-variant']))
|
|
31
31
|
expect(w.classes()).not.toContain('border')
|
|
32
|
-
expect(w.find('button').classes()).toEqual(expect.arrayContaining(['
|
|
32
|
+
expect(w.find('button').classes()).toEqual(expect.arrayContaining(['ps-4', 'pe-4']))
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
it('toggles a filter chip with v-model:selected, filling it and morphing to a pill', async () => {
|
|
@@ -48,7 +48,7 @@ describe('MChip', () => {
|
|
|
48
48
|
const buttons = w.findAll('button')
|
|
49
49
|
expect(buttons).toHaveLength(2)
|
|
50
50
|
expect(buttons[0]!.find('img').exists()).toBe(true)
|
|
51
|
-
expect(buttons[0]!.classes()).toEqual(expect.arrayContaining(['
|
|
51
|
+
expect(buttons[0]!.classes()).toEqual(expect.arrayContaining(['ps-1', 'pe-2']))
|
|
52
52
|
await buttons[1]!.trigger('click')
|
|
53
53
|
expect(w.emitted('remove')).toHaveLength(1)
|
|
54
54
|
expect(w.emitted('click')).toBeUndefined()
|
|
@@ -9,14 +9,14 @@ const fab = (props: Record<string, unknown>) => mount(MFab, { props: { icon: 'ed
|
|
|
9
9
|
describe('MFab', () => {
|
|
10
10
|
it('keeps the baseline extended FAB for the regular size', () => {
|
|
11
11
|
const b = fab({ label: 'Compose' }).find('button')
|
|
12
|
-
expect(b.classes()).toEqual(expect.arrayContaining(['h-14', 'min-w-20', '
|
|
12
|
+
expect(b.classes()).toEqual(expect.arrayContaining(['h-14', 'min-w-20', 'ps-4', 'pe-5']))
|
|
13
13
|
expect(b.find('span.whitespace-nowrap').classes()).toContain('text-label-large')
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
it.each([
|
|
17
|
-
['small', 'h-14', 'text-title-medium', '
|
|
18
|
-
['medium', 'h-20', 'text-title-large', '
|
|
19
|
-
['large', 'h-24', 'text-headline-small', '
|
|
17
|
+
['small', 'h-14', 'text-title-medium', 'ps-2'],
|
|
18
|
+
['medium', 'h-20', 'text-title-large', 'ps-3'],
|
|
19
|
+
['large', 'h-24', 'text-headline-small', 'ps-4'],
|
|
20
20
|
])('sizes the %s extended FAB from ExtendedFab tokens', (size, height, text, gap) => {
|
|
21
21
|
const b = fab({ label: 'Compose', size }).find('button')
|
|
22
22
|
expect(b.classes()).toContain(height)
|
|
@@ -47,12 +47,12 @@ describe('MFab', () => {
|
|
|
47
47
|
await nextTick()
|
|
48
48
|
const b = w.find('button').element as HTMLElement
|
|
49
49
|
// An inline start padding only where the class's isn't the centered one
|
|
50
|
-
expect(b.style.
|
|
50
|
+
expect(b.style.paddingInlineStart).toBe(size === 'large' ? lead : '')
|
|
51
51
|
})
|
|
52
52
|
|
|
53
53
|
it('renders collapsed on the server too, before any script runs', async () => {
|
|
54
54
|
const large = await renderToString(createSSRApp({ render: () => h(MFab, { icon: 'edit', label: 'Compose', size: 'large', expanded: false }) }))
|
|
55
|
-
expect(large).toMatch(/<button[^>]*style="width:96px;min-width:0;padding-
|
|
55
|
+
expect(large).toMatch(/<button[^>]*style="width:96px;min-width:0;padding-inline-start:32px;"/)
|
|
56
56
|
const html = await renderToString(createSSRApp({ render: () => h(MFab, { icon: 'edit', label: 'Compose', expanded: false }) }))
|
|
57
57
|
expect(html).toMatch(/<button[^>]*style="width:56px;min-width:0;"/)
|
|
58
58
|
expect(html).toMatch(/<span[^>]*style="display:none;opacity:0;"[^>]*>Compose<\/span>/)
|
|
@@ -81,8 +81,8 @@ describe('MListItem with a control inside', () => {
|
|
|
81
81
|
slots: { children: () => h('p', 'child') },
|
|
82
82
|
})
|
|
83
83
|
await nextTick()
|
|
84
|
-
expect((wrapper.find('.mli-expand-body').element as HTMLElement).style.
|
|
84
|
+
expect((wrapper.find('.mli-expand-body').element as HTMLElement).style.paddingInlineStart).toBe('12px')
|
|
85
85
|
await wrapper.setProps({ indent: '0.5rem' })
|
|
86
|
-
expect((wrapper.find('.mli-expand-body').element as HTMLElement).style.
|
|
86
|
+
expect((wrapper.find('.mli-expand-body').element as HTMLElement).style.paddingInlineStart).toBe('0.5rem')
|
|
87
87
|
})
|
|
88
88
|
})
|
|
@@ -47,7 +47,7 @@ describe('MScheduler', () => {
|
|
|
47
47
|
{ id: 3, title: 'Gamma', start: '2026-10-14T14:00', end: '2026-10-14T15:00' },
|
|
48
48
|
])
|
|
49
49
|
expect(block('Alpha').attributes('style')).toContain('width: calc(50% - 4px)')
|
|
50
|
-
expect(block('Beta').attributes('style')).toContain('
|
|
50
|
+
expect(block('Beta').attributes('style')).toContain('inset-inline-start: calc(50% + 2px)')
|
|
51
51
|
expect(block('Gamma').attributes('style')).toContain('width: calc(100% - 4px)')
|
|
52
52
|
})
|
|
53
53
|
|
|
@@ -23,7 +23,7 @@ describe('MTrackingTimeline', () => {
|
|
|
23
23
|
it('titles the current stage, marks it, and fills the legs up to it', () => {
|
|
24
24
|
const w = mount(MTrackingTimeline, { props: { steps, current: 2, stepProgress: 0.4 } })
|
|
25
25
|
expect(w.find('h3').text()).toBe('On the way')
|
|
26
|
-
expect(w.find('[aria-current="step"]').
|
|
26
|
+
expect(w.find('[aria-current="step"] .sr-only').text()).toBe('On the way')
|
|
27
27
|
expect(legs(w)).toEqual(['100%', '100%', '40%'])
|
|
28
28
|
})
|
|
29
29
|
|
|
@@ -26,6 +26,22 @@ const pointer = (type: string, x: number, y: number, target: EventTarget = windo
|
|
|
26
26
|
target.dispatchEvent(new PointerEvent(type, { clientX: x, clientY: y, button: 0, bubbles: true }))
|
|
27
27
|
|
|
28
28
|
describe('MWindow', () => {
|
|
29
|
+
it("title bar buttons show the library's M3 tooltip, not the browser's native title", async () => {
|
|
30
|
+
vi.useFakeTimers()
|
|
31
|
+
try {
|
|
32
|
+
const { win } = setup()
|
|
33
|
+
await nextTick()
|
|
34
|
+
const close = win().find('button[aria-label="Close"]')
|
|
35
|
+
expect(close.attributes('title')).toBeUndefined()
|
|
36
|
+
close.element.dispatchEvent(new PointerEvent('pointerenter', { pointerType: 'mouse' }))
|
|
37
|
+
vi.advanceTimersByTime(600)
|
|
38
|
+
const tip = document.querySelector('[role="tooltip"]')
|
|
39
|
+
expect(tip?.textContent).toBe('Close')
|
|
40
|
+
expect(tip?.className).toContain('bg-inverse-surface')
|
|
41
|
+
}
|
|
42
|
+
finally { vi.useRealTimers() }
|
|
43
|
+
})
|
|
44
|
+
|
|
29
45
|
it('only the front window looks active; clicking another brings it forward', async () => {
|
|
30
46
|
const Two = defineComponent({
|
|
31
47
|
setup: () => () => [
|
|
@@ -32,13 +32,13 @@ describe('long content in narrow fields', () => {
|
|
|
32
32
|
|
|
33
33
|
it('MSelect reserves room for the clear button as well as the arrow', () => {
|
|
34
34
|
const plain = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options } })
|
|
35
|
-
expect(cls(plain.find('[role="combobox"]').element)).toContain('
|
|
35
|
+
expect(cls(plain.find('[role="combobox"]').element)).toContain('pe-10')
|
|
36
36
|
const clearable = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options, clearable: true } })
|
|
37
37
|
const trigger = clearable.find('[role="combobox"]')
|
|
38
|
-
expect(cls(trigger.element)).toContain('
|
|
39
|
-
expect(cls(trigger.element)).not.toContain('
|
|
38
|
+
expect(cls(trigger.element)).toContain('pe-16')
|
|
39
|
+
expect(cls(trigger.element)).not.toContain('pe-10')
|
|
40
40
|
// The floated label stops there too (filled: it sits in the same row as the clear button)
|
|
41
|
-
expect(cls(clearable.find('label').element)).toContain('
|
|
41
|
+
expect(cls(clearable.find('label').element)).toContain('end-16')
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
it('MSelect puts the whole value in a title only when it is cut', async () => {
|
|
@@ -55,13 +55,13 @@ describe('long content in narrow fields', () => {
|
|
|
55
55
|
|
|
56
56
|
it('MTextField: the label stops before a trailing button, and the outlined floated label before the corner', () => {
|
|
57
57
|
const w = mount(MTextField, { props: { modelValue: '', label: 'Etiqueta larga', clearable: true } })
|
|
58
|
-
expect(cls(w.find('label').element)).toContain('
|
|
59
|
-
expect(cls(w.find('input').element)).toContain('
|
|
58
|
+
expect(cls(w.find('label').element)).toContain('end-12')
|
|
59
|
+
expect(cls(w.find('input').element)).toContain('pe-12')
|
|
60
60
|
|
|
61
61
|
const icon = mount(MTextField, { props: { modelValue: '', label: 'Etiqueta', variant: 'outlined', leadingIcon: 'search' } })
|
|
62
62
|
const label = cls(icon.find('label').element)
|
|
63
|
-
expect(label).toContain('
|
|
64
|
-
//
|
|
63
|
+
expect(label).toContain('start-11')
|
|
64
|
+
// start-11 (44px) + 12px from the far corner
|
|
65
65
|
expect(label).toContain('peer-focus:max-w-[calc(100%-3.5rem)]')
|
|
66
66
|
expect(label).not.toContain('peer-focus:max-w-[calc(100%-1.5rem)]')
|
|
67
67
|
})
|
|
@@ -77,7 +77,7 @@ describe('long content in narrow fields', () => {
|
|
|
77
77
|
|
|
78
78
|
it('MAutocomplete reserves room for the clear button', () => {
|
|
79
79
|
const w = mount(MAutocomplete, { props: { modelValue: 'x', label: 'Estado', options, clearable: true } })
|
|
80
|
-
expect(cls(w.find('input').element)).toContain('
|
|
80
|
+
expect(cls(w.find('input').element)).toContain('pe-16')
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
it('chip fields cut a long chip instead of overflowing the field', () => {
|
|
@@ -142,3 +142,42 @@ describe('hydrating MContainerTransform', () => {
|
|
|
142
142
|
expect(document.body.querySelector('[role=dialog]')?.textContent).toBe('Detail')
|
|
143
143
|
})
|
|
144
144
|
})
|
|
145
|
+
|
|
146
|
+
describe('hydrating a right-to-left page', () => {
|
|
147
|
+
const sections = [{ title: 'Mail', items: [{ value: 'inbox', label: 'Inbox', icon: 'inbox' }] }]
|
|
148
|
+
|
|
149
|
+
/** Server HTML of an inline drawer, then hydrated on a page with dir="rtl" */
|
|
150
|
+
async function hydrateDrawer(dir?: 'ltr' | 'rtl') {
|
|
151
|
+
// The "server": no dir on the page to read; while it renders, only createM3UI({ dir }) says which way it reads
|
|
152
|
+
vi.resetModules()
|
|
153
|
+
const server = {
|
|
154
|
+
createM3UI: (await import('../plugin')).createM3UI,
|
|
155
|
+
MNavigationDrawer: (await import('../components/MNavigationDrawer.vue')).default,
|
|
156
|
+
}
|
|
157
|
+
const props = { modelValue: true, modal: false, sections }
|
|
158
|
+
const html = await renderToString(createSSRApp({ render: () => h(server.MNavigationDrawer, props) }).use(server.createM3UI({ dir, isHydrating: () => true })))
|
|
159
|
+
|
|
160
|
+
vi.resetModules()
|
|
161
|
+
document.documentElement.setAttribute('dir', 'rtl')
|
|
162
|
+
const { createM3UI } = await import('../plugin')
|
|
163
|
+
const MNavigationDrawer = (await import('../components/MNavigationDrawer.vue')).default
|
|
164
|
+
const container = document.createElement('div')
|
|
165
|
+
container.innerHTML = html
|
|
166
|
+
document.body.appendChild(container)
|
|
167
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
168
|
+
let hydrating = true
|
|
169
|
+
createSSRApp({ render: () => h(MNavigationDrawer, props) }).use(createM3UI({ dir, isHydrating: () => hydrating })).mount(container)
|
|
170
|
+
hydrating = false
|
|
171
|
+
await nextTick()
|
|
172
|
+
document.documentElement.removeAttribute('dir')
|
|
173
|
+
return warn.mock.calls.map((c) => String(c[0])).filter((m) => m.includes('Hydration'))
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
it('with createM3UI({ dir }), the server puts the drawer on the page\'s side, so hydration matches', async () => {
|
|
177
|
+
expect(await hydrateDrawer('rtl')).toEqual([])
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
it('without it, the server renders left to right and hydration mismatches (what dir fixes)', async () => {
|
|
181
|
+
expect((await hydrateDrawer()).length).toBeGreaterThan(0)
|
|
182
|
+
})
|
|
183
|
+
})
|
|
@@ -8,6 +8,7 @@ import { deLocale } from '../locales/de'
|
|
|
8
8
|
import { jaLocale } from '../locales/ja'
|
|
9
9
|
import { zhLocale } from '../locales/zh'
|
|
10
10
|
import { koLocale } from '../locales/ko'
|
|
11
|
+
import { arLocale } from '../locales/ar'
|
|
11
12
|
|
|
12
13
|
const allLocales: [string, M3Locale][] = [
|
|
13
14
|
['es', esLocale],
|
|
@@ -17,6 +18,7 @@ const allLocales: [string, M3Locale][] = [
|
|
|
17
18
|
['ja', jaLocale],
|
|
18
19
|
['zh', zhLocale],
|
|
19
20
|
['ko', koLocale],
|
|
21
|
+
['ar', arLocale],
|
|
20
22
|
]
|
|
21
23
|
|
|
22
24
|
const defaultKeys = Object.keys(defaultLocale) as (keyof M3Locale)[]
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest'
|
|
2
|
+
import { mount, type VueWrapper } from '@vue/test-utils'
|
|
3
|
+
import { nextTick } from 'vue'
|
|
4
|
+
import MIcon from '../components/MIcon.vue'
|
|
5
|
+
import MBadge from '../components/MBadge.vue'
|
|
6
|
+
import MSlider from '../components/MSlider.vue'
|
|
7
|
+
import MSwitch from '../components/MSwitch.vue'
|
|
8
|
+
import MNavigationDrawer from '../components/MNavigationDrawer.vue'
|
|
9
|
+
import { isRtl, logicalKey } from '../composables/_rtl'
|
|
10
|
+
import { dropdownX } from '../composables/_popupPosition'
|
|
11
|
+
import { readFileSync, readdirSync } from 'node:fs'
|
|
12
|
+
import { join } from 'node:path'
|
|
13
|
+
|
|
14
|
+
let wrapper: VueWrapper | undefined
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
wrapper?.unmount()
|
|
17
|
+
wrapper = undefined
|
|
18
|
+
document.documentElement.removeAttribute('dir')
|
|
19
|
+
document.body.innerHTML = ''
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const rtlPage = () => document.documentElement.setAttribute('dir', 'rtl')
|
|
23
|
+
|
|
24
|
+
describe('right to left', () => {
|
|
25
|
+
it('reads the direction from the nearest dir attribute', () => {
|
|
26
|
+
rtlPage()
|
|
27
|
+
const outer = document.createElement('div')
|
|
28
|
+
const inner = document.createElement('div')
|
|
29
|
+
inner.setAttribute('dir', 'ltr')
|
|
30
|
+
outer.appendChild(inner)
|
|
31
|
+
document.body.appendChild(outer)
|
|
32
|
+
expect(isRtl(outer)).toBe(true)
|
|
33
|
+
expect(isRtl(inner)).toBe(false)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('never scopes a style under :global([dir=rtl]) with more selector after it', () => {
|
|
37
|
+
// Vue compiles `:global(x) .y` to a bare `x`: `:global([dir='rtl']) .item { transform }` moved the whole
|
|
38
|
+
// <html> of a right-to-left page. Use `.item:dir(rtl)` instead.
|
|
39
|
+
const dir = join(__dirname, '../components')
|
|
40
|
+
const offenders = readdirSync(dir)
|
|
41
|
+
.filter((f) => f.endsWith('.vue'))
|
|
42
|
+
.filter((f) => /:global\([^)]*\)\s*[^\s{,]/.test(readFileSync(join(dir, f), 'utf8')))
|
|
43
|
+
expect(offenders).toEqual([])
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('swaps the horizontal arrow keys only in RTL', () => {
|
|
47
|
+
const right = new KeyboardEvent('keydown', { key: 'ArrowRight' })
|
|
48
|
+
expect(logicalKey(right)).toBe('ArrowRight')
|
|
49
|
+
rtlPage()
|
|
50
|
+
expect(logicalKey(right)).toBe('ArrowLeft')
|
|
51
|
+
expect(logicalKey(new KeyboardEvent('keydown', { key: 'ArrowUp' }))).toBe('ArrowUp')
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('aligns a dropdown with the right edge of its anchor as its start, in RTL', () => {
|
|
55
|
+
const anchor = { left: 300, right: 400 }
|
|
56
|
+
expect(dropdownX(anchor, 150, 1000, 'start')).toBe(300)
|
|
57
|
+
expect(dropdownX(anchor, 150, 1000, 'start', undefined, true)).toBe(250)
|
|
58
|
+
expect(dropdownX(anchor, 150, 1000, 'end', undefined, true)).toBe(300)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('mirrors directional icons, and only those, unless told otherwise', () => {
|
|
62
|
+
const cls = (props: Record<string, unknown>) => mount(MIcon, { props: props as { name: string } }).classes()
|
|
63
|
+
expect(cls({ name: 'chevron_right' })).toContain('m3-rtl:-scale-x-100')
|
|
64
|
+
expect(cls({ name: 'arrow_back' })).toContain('m3-rtl:-scale-x-100')
|
|
65
|
+
expect(cls({ name: 'settings' })).not.toContain('m3-rtl:-scale-x-100')
|
|
66
|
+
expect(cls({ name: 'play_arrow' })).not.toContain('m3-rtl:-scale-x-100')
|
|
67
|
+
expect(cls({ name: 'chevron_right', mirror: false })).not.toContain('m3-rtl:-scale-x-100')
|
|
68
|
+
expect(cls({ name: 'star', mirror: true })).toContain('m3-rtl:-scale-x-100')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('places a badge at the top end by default, mirrored through --m3-dir', () => {
|
|
72
|
+
wrapper = mount(MBadge, { props: { count: 3 }, slots: { default: '<span />' } })
|
|
73
|
+
const style = wrapper.find('span.absolute').attributes('style')!
|
|
74
|
+
expect(style).toContain('inset-inline-end')
|
|
75
|
+
expect(style).toContain('var(--m3-dir, 1)')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('moves the switch thumb by the reading direction', () => {
|
|
79
|
+
wrapper = mount(MSwitch, { props: { modelValue: true } })
|
|
80
|
+
expect(wrapper.html()).toContain('translateX(calc(18px * var(--m3-dir, 1)))')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
describe('MSlider', () => {
|
|
84
|
+
const mountSlider = () => {
|
|
85
|
+
const w = mount(MSlider, {
|
|
86
|
+
props: { modelValue: 50, min: 0, max: 100, 'onUpdate:modelValue': (v: unknown) => w.setProps({ modelValue: v as number }) },
|
|
87
|
+
attachTo: document.body,
|
|
88
|
+
})
|
|
89
|
+
;(w.find('.touch-none').element as HTMLElement).getBoundingClientRect = () =>
|
|
90
|
+
({ left: 0, top: 0, width: 100, height: 46, right: 100, bottom: 46, x: 0, y: 0, toJSON() {} })
|
|
91
|
+
return w
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
it('draws the horizontal track mirrored', () => {
|
|
95
|
+
wrapper = mountSlider()
|
|
96
|
+
expect(wrapper.find('.touch-none').classes()).toContain('m3-rtl:-scale-x-100')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('reads the pointer from the right edge', async () => {
|
|
100
|
+
rtlPage()
|
|
101
|
+
wrapper = mountSlider()
|
|
102
|
+
const track = wrapper.find('.touch-none').element
|
|
103
|
+
track.dispatchEvent(new PointerEvent('pointerdown', { clientX: 20, bubbles: true }))
|
|
104
|
+
window.dispatchEvent(new PointerEvent('pointerup', { clientX: 20 }))
|
|
105
|
+
await nextTick()
|
|
106
|
+
expect(wrapper.props('modelValue')).toBe(80)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('swaps ArrowLeft and ArrowRight', async () => {
|
|
110
|
+
rtlPage()
|
|
111
|
+
wrapper = mountSlider()
|
|
112
|
+
await wrapper.find('.touch-none').trigger('keydown', { key: 'ArrowRight' })
|
|
113
|
+
expect(wrapper.props('modelValue')).toBe(49)
|
|
114
|
+
await wrapper.find('.touch-none').trigger('keydown', { key: 'ArrowLeft' })
|
|
115
|
+
await wrapper.find('.touch-none').trigger('keydown', { key: 'ArrowLeft' })
|
|
116
|
+
expect(wrapper.props('modelValue')).toBe(51)
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
describe('MNavigationDrawer', () => {
|
|
121
|
+
const sections = [{ items: [{ value: 'inbox', label: 'Inbox', icon: 'inbox' }] }]
|
|
122
|
+
const open = (props: Record<string, unknown> = {}) => {
|
|
123
|
+
wrapper = mount(MNavigationDrawer, {
|
|
124
|
+
props: { modelValue: true, sections, ...props },
|
|
125
|
+
attachTo: document.body,
|
|
126
|
+
global: { stubs: { transition: false } },
|
|
127
|
+
})
|
|
128
|
+
const panel = document.body.querySelector<HTMLElement>('.nd-panel')!
|
|
129
|
+
panel.getAnimations().forEach((a) => a.finish())
|
|
130
|
+
Object.defineProperty(panel, 'offsetWidth', { value: 300 })
|
|
131
|
+
return panel
|
|
132
|
+
}
|
|
133
|
+
const swipe = (panel: HTMLElement, from: number, to: number) => {
|
|
134
|
+
let t = 1000
|
|
135
|
+
const send = (type: string, x: number) => {
|
|
136
|
+
const e = new PointerEvent(type, { pointerId: 1, button: 0, bubbles: true, clientX: x, clientY: 300 })
|
|
137
|
+
Object.defineProperty(e, 'timeStamp', { value: (t += 400) })
|
|
138
|
+
panel.dispatchEvent(e)
|
|
139
|
+
}
|
|
140
|
+
send('pointerdown', from)
|
|
141
|
+
const dir = Math.sign(to - from)
|
|
142
|
+
for (let x = from; dir * (to - x) >= 0; x += dir * 25) send('pointermove', x)
|
|
143
|
+
send('pointerup', to)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
it('opens from the start edge: the left one, or the right one in RTL', () => {
|
|
147
|
+
let panel = open()
|
|
148
|
+
expect(panel.classList.contains('rounded-r-lg')).toBe(true)
|
|
149
|
+
wrapper!.unmount()
|
|
150
|
+
wrapper = undefined
|
|
151
|
+
rtlPage()
|
|
152
|
+
panel = open()
|
|
153
|
+
expect(panel.classList.contains('rounded-l-lg')).toBe(true)
|
|
154
|
+
// Swiped toward its own (right) edge to close
|
|
155
|
+
swipe(panel, 100, 25)
|
|
156
|
+
expect(wrapper!.emitted('update:modelValue')).toBeUndefined()
|
|
157
|
+
swipe(panel, 100, 300)
|
|
158
|
+
expect(wrapper!.emitted('update:modelValue')).toEqual([[false]])
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('keeps left and right physical', () => {
|
|
162
|
+
rtlPage()
|
|
163
|
+
const panel = open({ side: 'left' })
|
|
164
|
+
expect(panel.classList.contains('rounded-r-lg')).toBe(true)
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
})
|
|
@@ -118,6 +118,12 @@ describe('SSR', () => {
|
|
|
118
118
|
await expect(render(lib.MButton, {}, options)).resolves.toContain('button')
|
|
119
119
|
})
|
|
120
120
|
|
|
121
|
+
it('places a drawer by createM3UI({ dir }): the server has no page to read the direction from', async () => {
|
|
122
|
+
const props = { modelValue: true, modal: false, sections: [{ items: [{ value: 'a', label: 'A', icon: 'home' }] }] }
|
|
123
|
+
expect(await render(lib.MNavigationDrawer, props, {})).toContain('border-r ')
|
|
124
|
+
expect(await render(lib.MNavigationDrawer, props, { dir: 'rtl' })).toContain('border-l ')
|
|
125
|
+
})
|
|
126
|
+
|
|
121
127
|
it('applies the app locale', async () => {
|
|
122
128
|
expect(await render(lib.MPagination, { modelValue: 1, total: 50 }, { locale: lib.defaultLocale })).toBeTruthy()
|
|
123
129
|
})
|
|
@@ -75,7 +75,7 @@ const config = {
|
|
|
75
75
|
<button
|
|
76
76
|
v-if="closeable"
|
|
77
77
|
type="button"
|
|
78
|
-
class="-
|
|
78
|
+
class="-me-1 flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-on-surface/8"
|
|
79
79
|
:aria-label="closeAriaLabel ?? locale.close"
|
|
80
80
|
@click="emit('close')"
|
|
81
81
|
>
|