@m3ui-vue/m3ui-vue 1.8.1 → 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 +26 -11
- package/dist/{MButton-B6eZTfFV.js → MButton-LiZRRP4h.js} +4 -4
- package/dist/{MButton-B6eZTfFV.js.map → MButton-LiZRRP4h.js.map} +1 -1
- package/dist/{MColorPickerModal-Dajjf6tH.js → MColorPickerModal-IjciC8zh.js} +185 -185
- package/dist/MColorPickerModal-IjciC8zh.js.map +1 -0
- package/dist/{MDialog-DQvE_JBv.js → MDialog-BLpfgIA3.js} +7 -7
- package/dist/{MDialog-DQvE_JBv.js.map → MDialog-BLpfgIA3.js.map} +1 -1
- 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-C5ngKPRM.js → MPdfViewer-B5Q9Xs9d.js} +9 -9
- package/dist/{MPdfViewer-C5ngKPRM.js.map → MPdfViewer-B5Q9Xs9d.js.map} +1 -1
- package/dist/{MProgressBar-BWly1UKN.js → MProgressBar-CPrZhQbA.js} +3 -3
- package/dist/{MProgressBar-BWly1UKN.js.map → MProgressBar-CPrZhQbA.js.map} +1 -1
- 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-CxOtelzE.js → MSignaturePad-Bqr-1R9f.js} +2 -2
- package/dist/{MSignaturePad-CxOtelzE.js.map → MSignaturePad-Bqr-1R9f.js.map} +1 -1
- 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/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 +11961 -12040
- 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.js +9 -9
- package/dist/pdf.js +1 -1
- package/dist/plugin.d.ts +8 -0
- package/dist/rich-text-editor.js +79 -78
- 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 +1 -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/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/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/plugin.ts +10 -0
- package/src/styles/theme.css +13 -0
- package/dist/MColorPickerModal-Dajjf6tH.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/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/useLocale-DL96OFgr.js.map +0 -1
|
@@ -7,7 +7,7 @@ import type { Directive } from 'vue'
|
|
|
7
7
|
* edge (filled) or onto the border (outlined), an optional leading icon and trailing buttons. The rules that
|
|
8
8
|
* keep long content from running over those pieces live here, so a new field gets them by reusing this:
|
|
9
9
|
*
|
|
10
|
-
* - The label is inset from the
|
|
10
|
+
* - The label is inset from the end by as much as the box's own end padding (`right`), so it never runs
|
|
11
11
|
* under a trailing button, floated (filled) or not. Floated on an outlined border, it shrinks to its own
|
|
12
12
|
* text but stops 12px before the far corner, whatever its left offset (a leading icon moves it to 44px).
|
|
13
13
|
* - A value shown as text in a fixed-height box (`FIELD_VALUE`) stays on one line and ends in "…", and
|
|
@@ -18,19 +18,19 @@ import type { Directive } from 'vue'
|
|
|
18
18
|
export type FieldVariant = 'filled' | 'outlined'
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* `
|
|
23
|
-
* an arrow, `
|
|
21
|
+
* End inset of the label (right in LTR, left in RTL), which must equal the field's end padding: `end-4` with nothing trailing,
|
|
22
|
+
* `end-10` with a dropdown arrow, `end-12` with one trailing button, `end-16` with a clear button and
|
|
23
|
+
* an arrow, `end-24` with two 32px buttons (MNumberField's stepper).
|
|
24
24
|
*/
|
|
25
|
-
export type
|
|
25
|
+
export type FieldEndInset = 'end-4' | 'end-10' | 'end-12' | 'end-16' | 'end-24'
|
|
26
26
|
|
|
27
27
|
/** Padding matching each inset, for the box itself */
|
|
28
|
-
export const
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
28
|
+
export const FIELD_PADDING_END: Record<FieldEndInset, string> = {
|
|
29
|
+
'end-4': 'pe-4',
|
|
30
|
+
'end-10': 'pe-10',
|
|
31
|
+
'end-12': 'pe-12',
|
|
32
|
+
'end-16': 'pe-16',
|
|
33
|
+
'end-24': 'pe-24',
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/** One line, cut with "…", allowed to shrink inside its flex row */
|
|
@@ -40,7 +40,7 @@ export interface FieldLabelOptions {
|
|
|
40
40
|
variant: FieldVariant
|
|
41
41
|
/** There is a leading icon (the label starts after it) */
|
|
42
42
|
leading?: boolean
|
|
43
|
-
right:
|
|
43
|
+
right: FieldEndInset
|
|
44
44
|
/**
|
|
45
45
|
* `true`/`false` when the component knows whether the label floats; `'peer'` to float it with CSS from
|
|
46
46
|
* the preceding `.peer` input (focused, or its `placeholder=" "` not shown because it has a value)
|
|
@@ -52,7 +52,7 @@ export interface FieldLabelOptions {
|
|
|
52
52
|
|
|
53
53
|
export function fieldLabelClasses(o: FieldLabelOptions): string {
|
|
54
54
|
const outlined = o.variant === 'outlined'
|
|
55
|
-
const left = o.leading ? (outlined ? '
|
|
55
|
+
const left = o.leading ? (outlined ? 'start-11' : 'start-12') : outlined ? 'start-3' : 'start-4'
|
|
56
56
|
const base = ['pointer-events-none absolute truncate transition-all duration-200', left, o.right]
|
|
57
57
|
const rest = outlined ? 'top-1/2 -translate-y-1/2 text-body-large' : 'top-[53%] -translate-y-1/2 text-body-large'
|
|
58
58
|
|
|
@@ -60,24 +60,24 @@ export function fieldLabelClasses(o: FieldLabelOptions): string {
|
|
|
60
60
|
// Literal class names (Tailwind only sees complete strings)
|
|
61
61
|
const floatedPeer = outlined
|
|
62
62
|
? o.leading
|
|
63
|
-
? 'peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:
|
|
64
|
-
'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:
|
|
65
|
-
: 'peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:
|
|
66
|
-
'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:
|
|
63
|
+
? 'peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:end-auto peer-focus:max-w-[calc(100%-3.5rem)] peer-focus:bg-[var(--field-bg)] peer-focus:px-1 ' +
|
|
64
|
+
'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:end-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-3.5rem)] peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1'
|
|
65
|
+
: 'peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:end-auto peer-focus:max-w-[calc(100%-1.5rem)] peer-focus:bg-[var(--field-bg)] peer-focus:px-1 ' +
|
|
66
|
+
'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:end-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-1.5rem)] peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1'
|
|
67
67
|
: 'peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small ' +
|
|
68
68
|
'peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small'
|
|
69
69
|
return [...base, rest, floatedPeer, o.color].join(' ')
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const floated = outlined
|
|
73
|
-
? `-top-2.5 translate-y-0 text-label-small bg-[var(--field-bg)] px-1
|
|
73
|
+
? `-top-2.5 translate-y-0 text-label-small bg-[var(--field-bg)] px-1 end-auto ${o.leading ? 'max-w-[calc(100%-3.5rem)]' : 'max-w-[calc(100%-1.5rem)]'}`
|
|
74
74
|
: 'top-2 translate-y-0 text-label-small'
|
|
75
75
|
return [...base, o.floated ? floated : rest, o.color].join(' ')
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/** A label always floated on an outlined border (the picker triggers): cut before the far corner */
|
|
79
79
|
export const OUTLINED_FLOATED_LABEL =
|
|
80
|
-
'pointer-events-none absolute -top-2.5
|
|
80
|
+
'pointer-events-none absolute -top-2.5 start-3 max-w-[calc(100%-1.5rem)] truncate bg-(--field-bg) px-1 text-label-small'
|
|
81
81
|
|
|
82
82
|
function fullText(el: HTMLElement): string {
|
|
83
83
|
// By tag, not instanceof: the element may come from another realm (an iframe, a test DOM)
|
|
@@ -23,7 +23,8 @@ export function fitPopup(candidates: number[], size: number, viewport: number, m
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* A dropdown's left edge: aligned with the anchor's start or end edge (`align` picks which is tried first), else
|
|
26
|
-
* against the window edge on the anchor's side (MenuAnchorPosition.Below's xCandidates).
|
|
26
|
+
* against the window edge on the anchor's side (MenuAnchorPosition.Below's xCandidates). Right to left (`rtl`),
|
|
27
|
+
* the start edge is the anchor's right one, as in Compose.
|
|
27
28
|
*/
|
|
28
29
|
export function dropdownX(
|
|
29
30
|
anchor: { left: number; right: number },
|
|
@@ -31,9 +32,10 @@ export function dropdownX(
|
|
|
31
32
|
viewport: number,
|
|
32
33
|
align: 'start' | 'end',
|
|
33
34
|
margin = POPUP_MARGIN,
|
|
35
|
+
rtl = false,
|
|
34
36
|
): number {
|
|
35
|
-
const start = anchor.left
|
|
36
|
-
const end = anchor.right - width
|
|
37
|
+
const start = rtl ? anchor.right - width : anchor.left
|
|
38
|
+
const end = rtl ? anchor.left : anchor.right - width
|
|
37
39
|
const windowSide = (anchor.left + anchor.right) / 2 < viewport / 2 ? margin : viewport - margin - width
|
|
38
40
|
return fitPopup(align === 'start' ? [start, end, windowSide] : [end, start, windowSide], width, viewport, margin)
|
|
39
41
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getCurrentInstance, hasInjectionContext, inject, onBeforeUnmount, readonly, ref, type InjectionKey, type Ref } from 'vue'
|
|
2
|
+
import { ssrValue } from './_ssrState'
|
|
3
|
+
|
|
4
|
+
// Internal: `createM3UI({ dir })`, the page's direction as a server renders it
|
|
5
|
+
export const M3_DIR_KEY: InjectionKey<'ltr' | 'rtl'> = Symbol('m3-dir')
|
|
6
|
+
/**
|
|
7
|
+
* Right-to-left helpers (internal). Layout mirrors through CSS logical properties (`ms-*`, `start-*`,
|
|
8
|
+
* `text-start`…); what CSS can't mirror on its own (pointer math, `translateX`, directional icons) asks
|
|
9
|
+
* `isRtl()` or uses the `m3-rtl:` variant (theme.css; unlike Tailwind's `rtl:`, it respects a nested `dir="ltr"`).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Material Symbols that point along the reading direction, mirrored in RTL like Android's auto-mirrored icons.
|
|
14
|
+
* Media transport icons (play, skip, fast forward) are deliberately left out: M3 never mirrors those.
|
|
15
|
+
*/
|
|
16
|
+
export const MIRRORED_ICONS: ReadonlySet<string> = new Set([
|
|
17
|
+
'arrow_back', 'arrow_back_ios', 'arrow_back_ios_new', 'arrow_forward', 'arrow_forward_ios',
|
|
18
|
+
'arrow_left', 'arrow_right', 'arrow_left_alt', 'arrow_right_alt', 'trending_flat',
|
|
19
|
+
'chevron_left', 'chevron_right', 'navigate_before', 'navigate_next', 'first_page', 'last_page',
|
|
20
|
+
'keyboard_arrow_left', 'keyboard_arrow_right', 'keyboard_double_arrow_left', 'keyboard_double_arrow_right',
|
|
21
|
+
'keyboard_tab', 'keyboard_backspace', 'backspace', 'subdirectory_arrow_left', 'subdirectory_arrow_right',
|
|
22
|
+
'send', 'reply', 'reply_all', 'forward', 'undo', 'redo', 'menu_open', 'read_more',
|
|
23
|
+
'format_indent_increase', 'format_indent_decrease', 'format_list_bulleted', 'format_list_numbered',
|
|
24
|
+
'toc', 'notes', 'short_text', 'wrap_text', 'list', 'segment',
|
|
25
|
+
'login', 'logout', 'exit_to_app', 'input', 'output', 'label', 'label_important',
|
|
26
|
+
'call_made', 'call_received', 'call_missed_outgoing', 'start', 'help', 'help_outline',
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
/** Whether `el` (or the document, without one) lays out right to left */
|
|
30
|
+
export function isRtl(el?: Element | null): boolean {
|
|
31
|
+
if (typeof window === 'undefined') return false
|
|
32
|
+
const target = el ?? document.documentElement
|
|
33
|
+
if (getComputedStyle(target).direction === 'rtl') return true
|
|
34
|
+
// DOMs without a style engine (happy-dom) report ltr whatever dir says: go by the nearest dir attribute
|
|
35
|
+
return target.closest('[dir]')?.getAttribute('dir') === 'rtl'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const docRtl = ref(false)
|
|
40
|
+
let observer: MutationObserver | null = null
|
|
41
|
+
let users = 0
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Whether the page reads right to left, kept up to date when the `dir` attribute of `<html>` or `<body>`
|
|
45
|
+
* changes. For things decided at render time (which edge a drawer sits on); pointer math should ask
|
|
46
|
+
* `isRtl(el)` at the event instead, which also sees a `dir` set on a closer ancestor. Server-rendered apps pass
|
|
47
|
+
* `createM3UI({ dir })`, which the server renders and hydration starts from.
|
|
48
|
+
*/
|
|
49
|
+
export function useDocumentRtl(): Readonly<Ref<boolean>> {
|
|
50
|
+
// With `createM3UI({ dir })`: what the server renders, and the client's first frame while hydrating
|
|
51
|
+
const dir = hasInjectionContext() ? inject(M3_DIR_KEY, undefined) : undefined
|
|
52
|
+
const initial = dir === undefined ? undefined : dir === 'rtl'
|
|
53
|
+
if (typeof window === 'undefined') return ssrValue(docRtl, initial)
|
|
54
|
+
const update = () => { docRtl.value = isRtl(document.body ?? document.documentElement) }
|
|
55
|
+
if (users++ === 0) {
|
|
56
|
+
update()
|
|
57
|
+
observer = new MutationObserver(update)
|
|
58
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['dir'] })
|
|
59
|
+
if (document.body) observer.observe(document.body, { attributes: true, attributeFilter: ['dir'] })
|
|
60
|
+
}
|
|
61
|
+
if (getCurrentInstance()) {
|
|
62
|
+
onBeforeUnmount(() => {
|
|
63
|
+
if (--users === 0) { observer?.disconnect(); observer = null }
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
return ssrValue(readonly(docRtl) as Ref<boolean>, initial)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The key as if the layout were left to right: ArrowLeft and ArrowRight swap when `el` lays out right to left,
|
|
71
|
+
* so "ArrowRight" keeps meaning "next" in a row of items that flex has mirrored
|
|
72
|
+
*/
|
|
73
|
+
export function logicalKey(e: KeyboardEvent, el?: Element | null): string {
|
|
74
|
+
if ((e.key === 'ArrowLeft' || e.key === 'ArrowRight') && isRtl(el)) return e.key === 'ArrowLeft' ? 'ArrowRight' : 'ArrowLeft'
|
|
75
|
+
return e.key
|
|
76
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computed, nextTick, onUnmounted, ref } from 'vue'
|
|
2
2
|
import { motionSprings } from './motion'
|
|
3
3
|
import { playSamples, prefersReducedMotion, sampleSpring } from './_springAnimation'
|
|
4
|
+
import { isRtl } from './_rtl'
|
|
4
5
|
|
|
5
6
|
/*
|
|
6
7
|
* Internal (not exported from index.ts): the `submenuMode="push"` navigation shared by MMenu and MContextMenu.
|
|
@@ -13,6 +14,7 @@ import { playSamples, prefersReducedMotion, sampleSpring } from './_springAnimat
|
|
|
13
14
|
* after the swap, with no scrollbar while the levels cross.
|
|
14
15
|
* - swipe right to go back on touch: the level follows the finger and, released past a third of the panel
|
|
15
16
|
* (or flung), leaves from where it is; otherwise it springs back.
|
|
17
|
+
* Right to left, everything is mirrored: levels push in from the left and swipe back to the left.
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
export type MenuNavEntry = { icon?: string, header?: () => any, content?: () => any }
|
|
@@ -34,9 +36,11 @@ export function useMenuNav(focusFirst: () => void) {
|
|
|
34
36
|
// Where a swiped level was released, so its leave starts there instead of jumping back to 0
|
|
35
37
|
let leaveFromX = 0
|
|
36
38
|
let leaveFromOpacity = 1
|
|
39
|
+
// 1, or -1 in a right-to-left menu: multiplies every horizontal offset
|
|
40
|
+
const sign = () => (isRtl(navBox.value) ? -1 : 1)
|
|
37
41
|
|
|
38
42
|
function navSlideEnter(el: Element, done: () => void) {
|
|
39
|
-
const dir = navDirection.value === 'forward' ? 1 : -1
|
|
43
|
+
const dir = (navDirection.value === 'forward' ? 1 : -1) * sign()
|
|
40
44
|
const anim = (el as HTMLElement).animate(
|
|
41
45
|
[
|
|
42
46
|
{ transform: `translateX(${dir * SHARED_AXIS_OFFSET}px)`, opacity: 0 },
|
|
@@ -48,7 +52,7 @@ export function useMenuNav(focusFirst: () => void) {
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
function navSlideLeave(el: Element, done: () => void) {
|
|
51
|
-
const dir = navDirection.value === 'forward' ? -1 : 1
|
|
55
|
+
const dir = (navDirection.value === 'forward' ? -1 : 1) * sign()
|
|
52
56
|
const htmlEl = el as HTMLElement
|
|
53
57
|
htmlEl.style.position = 'absolute'
|
|
54
58
|
htmlEl.style.insetInline = '0'
|
|
@@ -103,7 +107,8 @@ export function useMenuNav(focusFirst: () => void) {
|
|
|
103
107
|
|
|
104
108
|
// Swipe back. The wrapper has `touch-action: pan-y` while a level is pushed, so a sideways drag reaches us
|
|
105
109
|
// as pointer events while vertical ones still scroll the list
|
|
106
|
-
|
|
110
|
+
// Positions are along the reading direction (clientX times `sign`), so a swipe back is always a positive dx
|
|
111
|
+
let swipe: { id: number, x: number, y: number, level: HTMLElement, width: number, active: boolean, lastX: number, lastT: number, vel: number, sign: number } | null = null
|
|
107
112
|
|
|
108
113
|
function levelEl() {
|
|
109
114
|
// The level on screen (a level still leaving has another depth)
|
|
@@ -114,7 +119,8 @@ export function useMenuNav(focusFirst: () => void) {
|
|
|
114
119
|
if (e.pointerType !== 'touch' || !navStack.value.length || swipe) return
|
|
115
120
|
const level = levelEl()
|
|
116
121
|
if (!level) return
|
|
117
|
-
|
|
122
|
+
const sg = sign()
|
|
123
|
+
swipe = { id: e.pointerId, x: e.clientX * sg, y: e.clientY, level, width: navBox.value!.clientWidth, active: false, lastX: e.clientX * sg, lastT: e.timeStamp, vel: 0, sign: sg }
|
|
118
124
|
window.addEventListener('pointermove', onMove)
|
|
119
125
|
window.addEventListener('pointerup', onUp)
|
|
120
126
|
window.addEventListener('pointercancel', onCancel)
|
|
@@ -122,27 +128,28 @@ export function useMenuNav(focusFirst: () => void) {
|
|
|
122
128
|
|
|
123
129
|
function writeDrag(dx: number) {
|
|
124
130
|
if (!swipe) return
|
|
125
|
-
swipe.level.style.transform = `translateX(${dx}px)`
|
|
131
|
+
swipe.level.style.transform = `translateX(${dx * swipe.sign}px)`
|
|
126
132
|
swipe.level.style.opacity = String(1 - 0.5 * Math.min(1, dx / swipe.width))
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
function onMove(e: PointerEvent) {
|
|
130
136
|
if (!swipe || e.pointerId !== swipe.id) return
|
|
131
|
-
const
|
|
137
|
+
const x = e.clientX * swipe.sign
|
|
138
|
+
const dx = x - swipe.x
|
|
132
139
|
const dy = e.clientY - swipe.y
|
|
133
140
|
if (!swipe.active) {
|
|
134
141
|
if (Math.hypot(dx, dy) < SWIPE_SLOP) return
|
|
135
|
-
// Vertical (a scroll) or
|
|
142
|
+
// Vertical (a scroll) or against the reading direction: not ours
|
|
136
143
|
if (Math.abs(dy) > Math.abs(dx) || dx < 0) return stopListening()
|
|
137
144
|
swipe.active = true
|
|
138
|
-
swipe.x =
|
|
145
|
+
swipe.x = x
|
|
139
146
|
swipe.level.getAnimations().forEach((a) => a.finish())
|
|
140
147
|
}
|
|
141
148
|
const dt = e.timeStamp - swipe.lastT
|
|
142
|
-
if (dt > 0) swipe.vel = 0.8 * ((
|
|
143
|
-
swipe.lastX =
|
|
149
|
+
if (dt > 0) swipe.vel = 0.8 * ((x - swipe.lastX) / dt) + 0.2 * swipe.vel
|
|
150
|
+
swipe.lastX = x
|
|
144
151
|
swipe.lastT = e.timeStamp
|
|
145
|
-
writeDrag(Math.max(0,
|
|
152
|
+
writeDrag(Math.max(0, x - swipe.x))
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
function onUp(e: PointerEvent) {
|
|
@@ -155,29 +162,29 @@ export function useMenuNav(focusFirst: () => void) {
|
|
|
155
162
|
window.addEventListener('click', swallowClick, { capture: true, once: true })
|
|
156
163
|
clearTimeout(swallowTimer)
|
|
157
164
|
swallowTimer = setTimeout(stopSwallowing, 400)
|
|
158
|
-
const dx = Math.max(0, e.clientX - s.x)
|
|
165
|
+
const dx = Math.max(0, e.clientX * s.sign - s.x)
|
|
159
166
|
if (dx > s.width * SWIPE_DISTANCE || s.vel > SWIPE_VELOCITY) {
|
|
160
|
-
leaveFromX = dx
|
|
167
|
+
leaveFromX = dx * s.sign
|
|
161
168
|
leaveFromOpacity = Number(s.level.style.opacity || 1)
|
|
162
169
|
popNav()
|
|
163
170
|
}
|
|
164
|
-
else settleBack(s.level, dx)
|
|
171
|
+
else settleBack(s.level, dx, s.sign)
|
|
165
172
|
}
|
|
166
173
|
|
|
167
174
|
function onCancel(e: PointerEvent) {
|
|
168
175
|
if (!swipe || e.pointerId !== swipe.id) return
|
|
169
176
|
const s = swipe
|
|
170
177
|
stopListening()
|
|
171
|
-
if (s.active) settleBack(s.level, Math.max(0, s.lastX - s.x))
|
|
178
|
+
if (s.active) settleBack(s.level, Math.max(0, s.lastX - s.x), s.sign)
|
|
172
179
|
}
|
|
173
180
|
|
|
174
|
-
function settleBack(level: HTMLElement, dx: number) {
|
|
181
|
+
function settleBack(level: HTMLElement, dx: number, sg: number) {
|
|
175
182
|
level.style.transform = ''
|
|
176
183
|
level.style.opacity = ''
|
|
177
184
|
if (prefersReducedMotion() || dx < 1) return
|
|
178
185
|
const width = navBox.value?.clientWidth || 1
|
|
179
186
|
playSamples(level, sampleSpring(dx, 0, 0, motionSprings.standard.defaultSpatial, 0.5), (x) => ({
|
|
180
|
-
transform: `translateX(${x}px)`,
|
|
187
|
+
transform: `translateX(${x * sg}px)`,
|
|
181
188
|
opacity: String(1 - 0.5 * Math.min(1, x / width)),
|
|
182
189
|
}))
|
|
183
190
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { onBeforeUnmount } from 'vue'
|
|
2
2
|
import { motionSprings, type SpringSpec } from './motion'
|
|
3
3
|
import { sampleSpring, sampleAt, playSamples, prefersReducedMotion } from './_springAnimation'
|
|
4
|
+
import { isRtl } from './_rtl'
|
|
4
5
|
|
|
5
6
|
/*
|
|
6
7
|
* Internal (not exported from index.ts): enter/exit/drag motion for modal sheets
|
|
@@ -24,6 +25,9 @@ import { sampleSpring, sampleAt, playSamples, prefersReducedMotion } from './_sp
|
|
|
24
25
|
* DISMISS_DISTANCE (or halfway to the next anchor, if closer) to the anchor nearest where it was
|
|
25
26
|
* dropped on that side, else back to the one it started from; off-screen (1) is always the last
|
|
26
27
|
* one and dismisses.
|
|
28
|
+
*
|
|
29
|
+
* On x, a right-to-left page puts the sheet at the left edge (its root is `justify-end`): `dir` is -1 there, so
|
|
30
|
+
* the panel slides out to the left and drags are read mirrored.
|
|
27
31
|
*/
|
|
28
32
|
|
|
29
33
|
const DEFAULT_SPATIAL = motionSprings.standard.defaultSpatial
|
|
@@ -65,8 +69,10 @@ export function useSheetMotion(axis: 'x' | 'y', onDismiss: () => void, opts: She
|
|
|
65
69
|
let size = 1
|
|
66
70
|
let lastMove = { at: 0, pos: 0 }
|
|
67
71
|
let dragVelocity = 0
|
|
72
|
+
// 1, or -1 for a sheet on x in a right-to-left page (read when it binds its elements)
|
|
73
|
+
let dir = 1
|
|
68
74
|
|
|
69
|
-
const translate = (f: number) => (axis === 'y' ? `translateY(${f * 100}%)` : `translateX(${f * 100}%)`)
|
|
75
|
+
const translate = (f: number) => (axis === 'y' ? `translateY(${f * 100}%)` : `translateX(${f * dir * 100}%)`)
|
|
70
76
|
|
|
71
77
|
function write() {
|
|
72
78
|
if (panel) panel.style.transform = translate(offset)
|
|
@@ -140,6 +146,7 @@ export function useSheetMotion(axis: 'x' | 'y', onDismiss: () => void, opts: She
|
|
|
140
146
|
function bind(el: Element) {
|
|
141
147
|
panel = el.querySelector<HTMLElement>('[data-sheet-panel]')
|
|
142
148
|
scrim = el.querySelector<HTMLElement>('[data-sheet-scrim]')
|
|
149
|
+
dir = axis === 'x' && isRtl(panel ?? el) ? -1 : 1
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
function onEnter(el: Element, done: () => void) {
|
|
@@ -174,7 +181,7 @@ export function useSheetMotion(axis: 'x' | 'y', onDismiss: () => void, opts: She
|
|
|
174
181
|
stopOffset()
|
|
175
182
|
dragging = true
|
|
176
183
|
size = (panel ? (axis === 'y' ? panel.offsetHeight : panel.offsetWidth) : 0) || 1
|
|
177
|
-
dragStart0 = pos
|
|
184
|
+
dragStart0 = pos * dir
|
|
178
185
|
dragOrigin = offset * size
|
|
179
186
|
dragVelocity = 0
|
|
180
187
|
lastMove = { at: performance.now(), pos: dragOrigin }
|
|
@@ -185,7 +192,7 @@ export function useSheetMotion(axis: 'x' | 'y', onDismiss: () => void, opts: She
|
|
|
185
192
|
function dragMove(pos: number): number {
|
|
186
193
|
if (!dragging) return 0
|
|
187
194
|
const now = performance.now()
|
|
188
|
-
const raw = dragOrigin + pos - dragStart0
|
|
195
|
+
const raw = dragOrigin + pos * dir - dragStart0
|
|
189
196
|
const p = Math.max(0, raw)
|
|
190
197
|
const dt = (now - lastMove.at) / 1000
|
|
191
198
|
if (dt > 0) dragVelocity = (p - lastMove.pos) / dt
|
|
@@ -345,6 +345,10 @@ export interface M3Locale {
|
|
|
345
345
|
formBuilderCopy: string
|
|
346
346
|
/** MFormBuilder */
|
|
347
347
|
formBuilderCopied: string
|
|
348
|
+
/** MCodeEditor: copy button's tooltip and label */
|
|
349
|
+
codeCopy: string
|
|
350
|
+
/** MCodeEditor: shown once the code is copied */
|
|
351
|
+
codeCopied: string
|
|
348
352
|
/** MFormBuilder: what the preview submitted */
|
|
349
353
|
formBuilderSubmitted: string
|
|
350
354
|
/** MFormBuilder: the inspector with nothing selected */
|
|
@@ -1182,6 +1186,8 @@ export const defaultLocale: M3Locale = {
|
|
|
1182
1186
|
formBuilderDelete: 'Delete',
|
|
1183
1187
|
formBuilderCopy: 'Copy',
|
|
1184
1188
|
formBuilderCopied: 'Copied',
|
|
1189
|
+
codeCopy: 'Copy code',
|
|
1190
|
+
codeCopied: 'Copied',
|
|
1185
1191
|
formBuilderSubmitted: 'Submitted values',
|
|
1186
1192
|
formBuilderSelectField: 'Select a field to edit it',
|
|
1187
1193
|
formFieldText: 'Text',
|