@m3ui-vue/m3ui-vue 1.5.0 → 1.6.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 +43 -32
- package/dist/{MButton-D_uxtJa-.js → MButton-CPghlKb0.js} +8 -9
- package/dist/MButton-CPghlKb0.js.map +1 -0
- package/dist/{MDialog-DT4KAPmn.js → MDialog-X50At1Gk.js} +38 -44
- package/dist/MDialog-X50At1Gk.js.map +1 -0
- package/dist/{MIcon-Bxh9j135.js → MIcon-DpajuUTJ.js} +2 -3
- package/dist/MIcon-DpajuUTJ.js.map +1 -0
- package/dist/{MIconButton-DoNotQ9v.js → MIconButton-BBggVwBV.js} +5 -6
- package/dist/MIconButton-BBggVwBV.js.map +1 -0
- package/dist/{MListItem-CwYrxpPZ.js → MListItem-DVi1j1QI.js} +8 -14
- package/dist/MListItem-DVi1j1QI.js.map +1 -0
- package/dist/{MLoadingIndicator-DhzECYRI.js → MLoadingIndicator-vooA3110.js} +3 -4
- package/dist/MLoadingIndicator-vooA3110.js.map +1 -0
- package/dist/{MMenuItem-Bih0h4-n.js → MMenuItem-CRNZkVVr.js} +13 -25
- package/dist/MMenuItem-CRNZkVVr.js.map +1 -0
- package/dist/{MProgressBar-BCoruxA-.js → MProgressBar-BWly1UKN.js} +3 -8
- package/dist/MProgressBar-BWly1UKN.js.map +1 -0
- package/dist/{MSeekBar-DQPF5FTp.js → MSeekBar-BL2W5_rD.js} +4 -5
- package/dist/MSeekBar-BL2W5_rD.js.map +1 -0
- package/dist/{MSegmentedButton-DL9JtJFX.js → MSegmentedButton-BEB4gXLA.js} +3 -4
- package/dist/MSegmentedButton-BEB4gXLA.js.map +1 -0
- package/dist/{MSlider-BvoMZTy9.js → MSlider-B9NcKTmZ.js} +22 -23
- package/dist/MSlider-B9NcKTmZ.js.map +1 -0
- package/dist/{MSpinner-CgcCQhS9.js → MSpinner-_XpTRkAg.js} +3 -4
- package/dist/MSpinner-_XpTRkAg.js.map +1 -0
- package/dist/{MTextField-B72dwF6V.js → MTextField-DpcPmR5B.js} +119 -89
- package/dist/MTextField-DpcPmR5B.js.map +1 -0
- package/dist/{MTooltip-YyF1CO75.js → MTooltip-BL3jPYPT.js} +10 -12
- package/dist/MTooltip-BL3jPYPT.js.map +1 -0
- package/dist/THIRD_PARTY_LICENSES.md +2 -2
- package/dist/{_plugin-vue_export-helper-B3ysoDQm.js → _plugin-vue_export-helper-Djzt4Yr7.js} +1 -2
- package/dist/{_storageKeys-CYXsUBwK.js → _storageKeys-C4W_4xK4.js} +2 -3
- package/dist/_storageKeys-C4W_4xK4.js.map +1 -0
- package/dist/{_useEscapeStack-CjndQhqg.js → _useEscapeStack-C5-BYr8y.js} +2 -3
- package/dist/_useEscapeStack-C5-BYr8y.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/barcode.js +1 -2
- package/dist/barcode.js.map +1 -1
- package/dist/chart.js +2 -4
- package/dist/chart.js.map +1 -1
- package/dist/code-editor.js +22 -23
- package/dist/code-editor.js.map +1 -1
- package/dist/{common-0dgrgaPL.js → common-kIb6A2Qu.js} +8 -37
- package/dist/common-kIb6A2Qu.js.map +1 -0
- package/dist/components/MAbsolute.vue.d.ts +5 -3
- package/dist/components/MAlert.vue.d.ts +8 -6
- package/dist/components/MAppBar.vue.d.ts +9 -7
- package/dist/components/MAppBarWithSearch.vue.d.ts +15 -13
- package/dist/components/MAppLayout.vue.d.ts +13 -11
- package/dist/components/MAspectRatio.vue.d.ts +5 -3
- package/dist/components/MAudioPlayer.vue.d.ts +22 -20
- package/dist/components/MAutocomplete.vue.d.ts +1 -1
- package/dist/components/MAvailabilityCalendar.vue.d.ts +19 -17
- package/dist/components/MBadge.vue.d.ts +6 -4
- package/dist/components/MBar.vue.d.ts +14 -12
- package/dist/components/MBarcode.vue.d.ts +5 -3
- package/dist/components/MBeforeAfter.vue.d.ts +12 -10
- package/dist/components/MBodyMap.vue.d.ts +1 -1
- package/dist/components/MBottomAppBar.vue.d.ts +10 -8
- package/dist/components/MBottomSheet.vue.d.ts +8 -6
- package/dist/components/MBottomSheetScaffold.vue.d.ts +9 -7
- package/dist/components/MBox.vue.d.ts +6 -4
- package/dist/components/MButton.vue.d.ts +7 -5
- package/dist/components/MCard.vue.d.ts +12 -10
- package/dist/components/MCenter.vue.d.ts +5 -3
- package/dist/components/MChatBubble.vue.d.ts +6 -4
- package/dist/components/MCheckbox.vue.d.ts +5 -3
- package/dist/components/MChip.vue.d.ts +9 -7
- package/dist/components/MCircleProgressBar.vue.d.ts +6 -4
- package/dist/components/MCodeEditor.vue.d.ts +5 -3
- package/dist/components/MContainer.vue.d.ts +6 -4
- package/dist/components/MContextMenu.vue.d.ts +8 -6
- package/dist/components/MCopyButton.vue.d.ts +1 -1
- package/dist/components/MDataTable.vue.d.ts +21 -19
- package/dist/components/MDialog.vue.d.ts +21 -19
- package/dist/components/MDragHandle.vue.d.ts +1 -1
- package/dist/components/MDrawCanvas.vue.d.ts +5 -3
- package/dist/components/MDrawToolbar.vue.d.ts +7 -5
- package/dist/components/MEmptyState.vue.d.ts +5 -3
- package/dist/components/MExpansionPanel.vue.d.ts +6 -4
- package/dist/components/MExportButton.vue.d.ts +7 -5
- package/dist/components/MFab.vue.d.ts +11 -9
- package/dist/components/MFabMenu.vue.d.ts +3 -3
- package/dist/components/MFixed.vue.d.ts +5 -3
- package/dist/components/MFlex.vue.d.ts +7 -5
- package/dist/components/MFloorPlan.vue.d.ts +3 -3
- package/dist/components/MFloorPlanInspector.vue.d.ts +32 -30
- package/dist/components/MFloorPlanToolbar.vue.d.ts +2 -2
- package/dist/components/MFlow.vue.d.ts +4 -4
- package/dist/components/MFlowControls.vue.d.ts +6 -4
- package/dist/components/MFlowHandle.vue.d.ts +1 -1
- package/dist/components/MFlowNode.vue.d.ts +11 -9
- package/dist/components/MFooter.vue.d.ts +12 -10
- package/dist/components/MFullscreen.vue.d.ts +5 -3
- package/dist/components/MGantt.vue.d.ts +33 -31
- package/dist/components/MGanttControls.vue.d.ts +8 -6
- package/dist/components/MGrid.vue.d.ts +6 -4
- package/dist/components/MIcon.vue.d.ts +5 -0
- package/dist/components/MIconButton.vue.d.ts +1 -1
- package/dist/components/MImageCropper.vue.d.ts +14 -12
- package/dist/components/MInfiniteScroll.vue.d.ts +11 -9
- package/dist/components/MList.vue.d.ts +5 -3
- package/dist/components/MListGroup.vue.d.ts +7 -5
- package/dist/components/MListItem.vue.d.ts +21 -19
- package/dist/components/MListSubheader.vue.d.ts +5 -3
- package/dist/components/MLoadingOverlay.vue.d.ts +10 -8
- package/dist/components/MMap.vue.d.ts +14 -6
- package/dist/components/MMapControl.vue.d.ts +12 -10
- package/dist/components/MMapFeatureInfo.vue.d.ts +11 -9
- package/dist/components/MMapIdentify.vue.d.ts +9 -7
- package/dist/components/MMapLayers.vue.d.ts +13 -11
- package/dist/components/MMapMarker.vue.d.ts +7 -5
- package/dist/components/MMapPopup.vue.d.ts +5 -3
- package/dist/components/MMasonry.vue.d.ts +5 -3
- package/dist/components/MMenu.vue.d.ts +12 -10
- package/dist/components/MMenuItem.vue.d.ts +11 -9
- package/dist/components/MMultiAutocomplete.vue.d.ts +1 -1
- package/dist/components/MMultiSelect.vue.d.ts +6 -4
- package/dist/components/MNavigationDrawer.vue.d.ts +14 -12
- package/dist/components/MNavigationRail.vue.d.ts +7 -5
- package/dist/components/MOdontogram.vue.d.ts +1 -1
- package/dist/components/MOrderBook.vue.d.ts +1 -1
- package/dist/components/MOverlay.vue.d.ts +5 -3
- package/dist/components/MPdfViewer.vue.d.ts +4 -4
- package/dist/components/MPhoneInput.vue.d.ts +11 -9
- package/dist/components/MPosKeypad.vue.d.ts +18 -16
- package/dist/components/MProgressBar.vue.d.ts +1 -1
- package/dist/components/MPullToRefresh.vue.d.ts +5 -3
- package/dist/components/MQRCode.vue.d.ts +7 -5
- package/dist/components/MRadioGroup.vue.d.ts +1 -1
- package/dist/components/MReceipt.vue.d.ts +2 -2
- package/dist/components/MRelative.vue.d.ts +5 -3
- package/dist/components/MResourceTimeline.vue.d.ts +31 -29
- package/dist/components/MResponsive.vue.d.ts +5 -3
- package/dist/components/MResult.vue.d.ts +7 -5
- package/dist/components/MScrollable.vue.d.ts +7 -5
- package/dist/components/MSearchBar.vue.d.ts +13 -11
- package/dist/components/MSearchField.vue.d.ts +7 -5
- package/dist/components/MSection.vue.d.ts +11 -9
- package/dist/components/MSeekBar.vue.d.ts +3 -3
- package/dist/components/MSelect.vue.d.ts +1 -1
- package/dist/components/MShader.vue.d.ts +11 -9
- package/dist/components/MShortNavigationBar.vue.d.ts +1 -1
- package/dist/components/MSideSheet.vue.d.ts +9 -7
- package/dist/components/MSimpleCarousel.vue.d.ts +1 -1
- package/dist/components/MSkeleton.vue.d.ts +2 -2
- package/dist/components/MSlider.vue.d.ts +3 -3
- package/dist/components/MSparkline.vue.d.ts +1 -1
- package/dist/components/MSplitButton.vue.d.ts +7 -5
- package/dist/components/MSplitter.vue.d.ts +9 -7
- package/dist/components/MSpotlightSearch.vue.d.ts +1 -1
- package/dist/components/MStack.vue.d.ts +8 -6
- package/dist/components/MStatCard.vue.d.ts +5 -3
- package/dist/components/MStepper.vue.d.ts +5 -3
- package/dist/components/MSticky.vue.d.ts +5 -3
- package/dist/components/MSubtitle.vue.d.ts +6 -4
- package/dist/components/MSwipeToDismiss.vue.d.ts +11 -9
- package/dist/components/MTable.vue.d.ts +17 -15
- package/dist/components/MText.vue.d.ts +5 -3
- package/dist/components/MTextField.vue.d.ts +6 -4
- package/dist/components/MTimePickerModal.vue.d.ts +1 -1
- package/dist/components/MTitle.vue.d.ts +6 -4
- package/dist/components/MToggleButton.vue.d.ts +5 -3
- package/dist/components/MToolbar.vue.d.ts +24 -22
- package/dist/components/MTooltip.vue.d.ts +10 -8
- package/dist/components/MTopAppBar.vue.d.ts +22 -20
- package/dist/components/MTour.vue.d.ts +28 -26
- package/dist/components/MTransition.vue.d.ts +5 -3
- package/dist/components/MTree.vue.d.ts +6 -4
- package/dist/components/MTreeTable.vue.d.ts +21 -19
- package/dist/components/MTypewriter.vue.d.ts +6 -4
- package/dist/components/MVirtualTable.vue.d.ts +8 -6
- package/dist/components/_MMapLayerItem.vue.d.ts +8 -6
- package/dist/components/_MPdfPage.vue.d.ts +2 -2
- package/dist/components/_MToolbarFab.vue.d.ts +5 -3
- package/dist/components/_MTreeNode.vue.d.ts +13 -11
- package/dist/composables/_fieldLayout.d.ts +47 -0
- package/dist/composables/useMap.d.ts +8 -0
- package/dist/{dist-CrjSW5DN.js → dist-Bj5kEq8G.js} +4 -6
- package/dist/dist-Bj5kEq8G.js.map +1 -0
- package/dist/draw.js +62 -82
- package/dist/draw.js.map +1 -1
- package/dist/{emoji-names-de-BphO5XpV.js → emoji-names-de-Cu3OSpp6.js} +2 -3
- package/dist/emoji-names-de-Cu3OSpp6.js.map +1 -0
- package/dist/{emoji-names-en-9ZvMRvzi.js → emoji-names-en-BNX1pM9h.js} +2 -3
- package/dist/emoji-names-en-BNX1pM9h.js.map +1 -0
- package/dist/{emoji-names-es-DvfWU3Pj.js → emoji-names-es-C_Dafg4D.js} +2 -3
- package/dist/emoji-names-es-C_Dafg4D.js.map +1 -0
- package/dist/{emoji-names-fr-B-jhUlsP.js → emoji-names-fr-D4HTMFuM.js} +2 -3
- package/dist/emoji-names-fr-D4HTMFuM.js.map +1 -0
- package/dist/{emoji-names-ja-l8cMFJo1.js → emoji-names-ja-BCql-Sj6.js} +2 -3
- package/dist/emoji-names-ja-BCql-Sj6.js.map +1 -0
- package/dist/{emoji-names-ko-YP-o9G0c.js → emoji-names-ko-CT8L52nn.js} +2 -3
- package/dist/emoji-names-ko-CT8L52nn.js.map +1 -0
- package/dist/{emoji-names-pt-DGj_Js4M.js → emoji-names-pt-DHiwPiL-.js} +2 -3
- package/dist/emoji-names-pt-DHiwPiL-.js.map +1 -0
- package/dist/{emoji-names-zh-Dzecwtw_.js → emoji-names-zh-L3FXVief.js} +2 -3
- package/dist/emoji-names-zh-L3FXVief.js.map +1 -0
- package/dist/flow.js +351 -374
- package/dist/flow.js.map +1 -1
- package/dist/{flowPaths-CcWOKY4Z.js → flowPaths-BaH7yaUM.js} +3 -8
- package/dist/flowPaths-BaH7yaUM.js.map +1 -0
- package/dist/gantt.js +272 -333
- package/dist/gantt.js.map +1 -1
- package/dist/locales/index.js +1 -2
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +4085 -4277
- package/dist/m3ui.js.map +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.js +521 -520
- package/dist/map.js.map +1 -1
- package/dist/markdown.js +3 -4
- package/dist/markdown.js.map +1 -1
- package/dist/{material-color-utilities-C_iikgRm.js → material-color-utilities-CEFytLsr.js} +15 -32
- package/dist/material-color-utilities-CEFytLsr.js.map +1 -0
- package/dist/media.js +80 -94
- package/dist/media.js.map +1 -1
- package/dist/{motion-DZiXG09o.js → motion-BcejVTeX.js} +2 -3
- package/dist/motion-BcejVTeX.js.map +1 -0
- package/dist/pdf.js +103 -115
- package/dist/pdf.js.map +1 -1
- package/dist/qrcode.js +1 -2
- package/dist/qrcode.js.map +1 -1
- package/dist/rich-text-editor.js +33 -34
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/terminal.js +2 -3
- package/dist/terminal.js.map +1 -1
- package/dist/{useLocale-DLcG3qPC.js → useLocale-COav9m8C.js} +2 -3
- package/dist/useLocale-COav9m8C.js.map +1 -0
- package/dist/{useThemeTokens-DQQcaWbE.js → useThemeTokens-DyAdPQB0.js} +6 -10
- package/dist/useThemeTokens-DyAdPQB0.js.map +1 -0
- package/package.json +32 -32
- package/src/__tests__/MFab.test.ts +10 -1
- package/src/__tests__/MMap.test.ts +16 -1
- package/src/__tests__/_fakeMaplibre.ts +2 -0
- package/src/__tests__/fieldOverflow.test.ts +118 -0
- package/src/components/MAutocomplete.vue +21 -24
- package/src/components/MColorPicker.vue +3 -3
- package/src/components/MDatePicker.vue +4 -4
- package/src/components/MDateRangePicker.vue +4 -4
- package/src/components/MMap.vue +12 -3
- package/src/components/MMapMeasure.vue +3 -1
- package/src/components/MMaskField.vue +16 -24
- package/src/components/MMultiAutocomplete.vue +19 -25
- package/src/components/MMultiSelect.vue +20 -27
- package/src/components/MNumberField.vue +16 -26
- package/src/components/MPinInput.vue +3 -2
- package/src/components/MSearchBar.vue +2 -2
- package/src/components/MSelect.vue +16 -22
- package/src/components/MTagInput.vue +19 -26
- package/src/components/MTextField.vue +18 -46
- package/src/components/MTimePicker.vue +4 -4
- package/src/composables/_fieldLayout.ts +117 -0
- package/src/composables/useMap.ts +17 -0
- package/src/composables/useMapLayers.ts +4 -1
- package/src/map.ts +1 -1
- package/dist/MButton-D_uxtJa-.js.map +0 -1
- package/dist/MDialog-DT4KAPmn.js.map +0 -1
- package/dist/MIcon-Bxh9j135.js.map +0 -1
- package/dist/MIconButton-DoNotQ9v.js.map +0 -1
- package/dist/MListItem-CwYrxpPZ.js.map +0 -1
- package/dist/MLoadingIndicator-DhzECYRI.js.map +0 -1
- package/dist/MMenuItem-Bih0h4-n.js.map +0 -1
- package/dist/MProgressBar-BCoruxA-.js.map +0 -1
- package/dist/MSeekBar-DQPF5FTp.js.map +0 -1
- package/dist/MSegmentedButton-DL9JtJFX.js.map +0 -1
- package/dist/MSlider-BvoMZTy9.js.map +0 -1
- package/dist/MSpinner-CgcCQhS9.js.map +0 -1
- package/dist/MTextField-B72dwF6V.js.map +0 -1
- package/dist/MTooltip-YyF1CO75.js.map +0 -1
- package/dist/_storageKeys-CYXsUBwK.js.map +0 -1
- package/dist/_useEscapeStack-CjndQhqg.js.map +0 -1
- package/dist/common-0dgrgaPL.js.map +0 -1
- package/dist/dist-CrjSW5DN.js.map +0 -1
- package/dist/emoji-names-de-BphO5XpV.js.map +0 -1
- package/dist/emoji-names-en-9ZvMRvzi.js.map +0 -1
- package/dist/emoji-names-es-DvfWU3Pj.js.map +0 -1
- package/dist/emoji-names-fr-B-jhUlsP.js.map +0 -1
- package/dist/emoji-names-ja-l8cMFJo1.js.map +0 -1
- package/dist/emoji-names-ko-YP-o9G0c.js.map +0 -1
- package/dist/emoji-names-pt-DGj_Js4M.js.map +0 -1
- package/dist/emoji-names-zh-Dzecwtw_.js.map +0 -1
- package/dist/flowPaths-CcWOKY4Z.js.map +0 -1
- package/dist/material-color-utilities-C_iikgRm.js.map +0 -1
- package/dist/motion-DZiXG09o.js.map +0 -1
- package/dist/useLocale-DLcG3qPC.js.map +0 -1
- package/dist/useThemeTokens-DQQcaWbE.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeTokens-DyAdPQB0.js","names":["STYLE_ID","STYLE_ID$1","COLOR_TOKENS","c","t","DURATION","STYLE_ID","css","isGecko","hasProperty","timer","themeTransition","apply","root","style","ease","cubicBezier","parseColor","v","value","hex","full","n","i","fn","parts","channel","p","alpha","rgba","mix","a","from","b","to","r","g","bl","al","x","useThemeTokens","read","names","tokens","ref","observer","settle","frame","set","next","update","follow","native","start","step","now","onMounted","isPaletteStyle","node","records","options","onBeforeUnmount"],"sources":["../src/composables/_themeTransition.ts","../src/composables/useThemeTokens.ts"],"sourcesContent":["// Internal: animates a theme change (dark mode, palette, contrast).\n//\n// Firefox (and any browser without @property) transitions six color properties on every element\n// (`.theme-transitioning` in theme.css): smooth there, but in Chromium it recalculates every element's transitions\n// each frame and stutters. Chromium and WebKit instead transition the color tokens themselves, once, on <html>:\n// registered as <color> with @property they interpolate, and every element follows them through var(). Components'\n// own color transitions (transition-colors) are turned off meanwhile, or they would restart on every frame of the\n// token's change and trail behind the rest (the navbar and buttons did). A view transition was tried first: it\n// cross-fades two snapshots, which looks washed out midway compared to the colors moving.\n\n// The tokens of theme.css, palettes.css and generated palettes\nconst COLOR_TOKENS = [\n 'background', 'on-background', 'surface', 'surface-dim', 'surface-bright', 'surface-variant', 'on-surface',\n 'on-surface-variant', 'surface-container-lowest', 'surface-container-low', 'surface-container',\n 'surface-container-high', 'surface-container-highest', 'inverse-surface', 'inverse-on-surface', 'inverse-primary',\n 'outline', 'outline-variant', 'shadow', 'scrim',\n ...['primary', 'secondary', 'tertiary', 'error', 'success'].flatMap((c) => [c, `on-${c}`, `${c}-container`, `on-${c}-container`]),\n ...['primary', 'secondary', 'tertiary'].flatMap((c) => [`${c}-fixed`, `${c}-fixed-dim`, `on-${c}-fixed`, `on-${c}-fixed-variant`]),\n].map((t) => `--color-${t}`)\n\nconst DURATION = 250\n/** How long a theme switch's color transition takes, in ms (both paths) */\nexport const THEME_TRANSITION_MS = DURATION\nconst STYLE_ID = 'm3-theme-transition'\n\n// Injected only while switching: a registered <color> computes to rgb(), and code reading a token with\n// getPropertyValue() expects it as written\nconst css = COLOR_TOKENS.map((t) => `@property ${t} { syntax: '<color>'; inherits: true; initial-value: transparent; }`).join('\\n')\n + `\\nhtml.theme-switching { transition: ${COLOR_TOKENS.map((t) => `${t} ${DURATION}ms ease`).join(', ')}; }`\n + '\\nhtml.theme-switching *, html.theme-switching *::before, html.theme-switching *::after { transition: none !important; }'\n\n// Gecko: a CSS feature only it has, or its user agent (\"Gecko/<version>\" or \"Firefox/\"; Chromium and WebKit only\n// say \"like Gecko\", and Firefox on iOS is WebKit and says \"FxiOS\")\nconst isGecko = () =>\n (typeof CSS !== 'undefined' && !!CSS.supports?.('-moz-appearance', 'none'))\n || (typeof navigator !== 'undefined' && /\\bGecko\\/\\d|\\bFirefox\\//.test(navigator.userAgent))\nconst hasProperty = () => typeof CSS !== 'undefined' && typeof CSS.registerProperty === 'function'\n\nlet timer: ReturnType<typeof setTimeout> | undefined\n\n/** Runs `apply` (the DOM writes of a theme change) with the theme transition. */\nexport function themeTransition(apply: () => void) {\n if (typeof document === 'undefined') return apply()\n const reduced = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches\n if (reduced) return apply()\n const root = document.documentElement\n\n if (!isGecko() && hasProperty()) {\n if (!document.getElementById(STYLE_ID)) {\n const style = document.createElement('style')\n style.id = STYLE_ID\n style.textContent = css\n document.head.appendChild(style)\n }\n root.classList.add('theme-switching')\n // Style flush: the tokens' current values are computed as registered colors and the transition is in place\n // before they change\n void root.offsetHeight\n apply()\n clearTimeout(timer)\n timer = setTimeout(() => {\n root.classList.remove('theme-switching')\n document.getElementById(STYLE_ID)?.remove()\n }, DURATION + 50)\n return\n }\n\n root.classList.add('theme-transitioning')\n // Force a style flush so the transition is in place before the colors change\n void root.offsetHeight\n apply()\n setTimeout(() => root.classList.remove('theme-transitioning'), 300)\n}\n","import { onBeforeUnmount, onMounted, ref, type Ref } from 'vue'\nimport { STYLE_ID } from './_storageKeys'\nimport { THEME_TRANSITION_MS } from './_themeTransition'\nimport { cubicBezier } from './motion'\n\nexport interface ThemeTokensOptions {\n /**\n * Updates every animation frame while the theme switch's colors fade, so a canvas redrawn on change fades with\n * the page instead of jumping to the new colors. Off by default: what animates color changes itself (Chart.js,\n * MChart, maps) only needs the final values, and would otherwise redraw ~15 times per switch.\n */\n live?: boolean\n}\n\n// The CSS `ease` the switch uses (_themeTransition.ts, and `.theme-transitioning` in theme.css)\nconst ease = cubicBezier(0.25, 0.1, 0.25, 1)\n\ntype Rgba = [number, number, number, number]\n\n// Hex (#rgb, #rgba, #rrggbb, #rrggbbaa) or rgb()/rgba(), the forms tokens are written in or computed to; null for\n// anything else (that token then switches at once)\nfunction parseColor(value: string): Rgba | null {\n const v = value.trim()\n const hex = /^#([0-9a-f]{3,8})$/i.exec(v)?.[1]\n if (hex && hex.length !== 5 && hex.length !== 7) {\n const full = hex.length <= 4 ? [...hex].map((c) => c + c).join('') : hex\n const n = (i: number) => parseInt(full.slice(i, i + 2), 16)\n return [n(0), n(2), n(4), full.length === 8 ? n(6) / 255 : 1]\n }\n const fn = /^rgba?\\(([^)]+)\\)$/i.exec(v)?.[1]\n if (!fn) return null\n const parts = fn.split(/[\\s,/]+/).filter(Boolean)\n if (parts.length < 3) return null\n const channel = (p: string) => (p.endsWith('%') ? parseFloat(p) * 2.55 : parseFloat(p))\n const alpha = parts[3] == null ? 1 : parts[3].endsWith('%') ? parseFloat(parts[3]) / 100 : parseFloat(parts[3])\n const rgba = [channel(parts[0]!), channel(parts[1]!), channel(parts[2]!), alpha] as Rgba\n return rgba.every(Number.isFinite) ? rgba : null\n}\n\nfunction mix(from: string, to: string, t: number): string {\n const a = parseColor(from)\n const b = parseColor(to)\n if (!a || !b) return t < 1 ? from : to\n const [r, g, bl, al] = a.map((x, i) => x + (b[i]! - x) * t)\n return `rgba(${Math.round(r!)}, ${Math.round(g!)}, ${Math.round(bl!)}, ${+al!.toFixed(3)})`\n}\n\n/**\n * The current values of some color tokens (`['primary', 'surface']` → `--color-primary`…), kept up to date across\n * light/dark, palette, contrast and generated (seed) palette changes: for what can't use CSS variables, like a\n * Chart.js dataset, a canvas or a MapLibre layer's paint. Values settle after the theme switch's color transition;\n * with `{ live: true }` they also follow it frame by frame (as `rgba()` midway). Empty strings on the server.\n *\n * ```ts\n * const colors = useThemeTokens(['primary', 'tertiary', 'outline-variant'] as const)\n * const data = computed(() => ({ datasets: [{ data: sales, borderColor: colors.value.primary }] }))\n * ```\n */\nexport function useThemeTokens<T extends string>(names: readonly T[], options: ThemeTokensOptions = {}): Ref<Record<T, string>> {\n const read = () => {\n const style = getComputedStyle(document.documentElement)\n return Object.fromEntries(names.map((n) => [n, style.getPropertyValue(`--color-${n}`).trim()])) as Record<T, string>\n }\n const tokens = ref(typeof document === 'undefined' ? Object.fromEntries(names.map((n) => [n, ''])) as Record<T, string> : read()) as Ref<Record<T, string>>\n let observer: MutationObserver | undefined\n let settle: ReturnType<typeof setTimeout> | undefined\n let frame = 0\n\n const set = (next: Record<T, string>) => {\n if (names.some((n) => next[n] !== tokens.value[n])) tokens.value = next\n }\n const update = () => set(read())\n\n // Follows a switch already under way. Chromium/WebKit animate the tokens themselves (`theme-switching`), so\n // reading them each frame gives the page's own colors; Firefox fades each element's colors instead\n // (`theme-transitioning`) while the tokens jump, so the same `ease` is replayed here from the old values\n function follow(root: HTMLElement) {\n cancelAnimationFrame(frame)\n const native = root.classList.contains('theme-switching')\n const from = { ...tokens.value }\n const to = native ? null : read()\n const start = performance.now()\n const step = (now: number) => {\n const t = Math.min(1, (now - start) / THEME_TRANSITION_MS)\n // The last frame lands on the values as written, not their rgba() form\n if (to) set(t < 1 ? Object.fromEntries(names.map((n) => [n, mix(from[n], to[n], ease(t))])) as Record<T, string> : to)\n else update()\n if (t < 1) frame = requestAnimationFrame(step)\n }\n frame = requestAnimationFrame(step)\n }\n\n onMounted(() => {\n const root = document.documentElement\n // Dark mode (class), a palette or contrast (attributes), or a generated palette rewriting its <style> in <head>\n const isPaletteStyle = (node: Node | null) => (node instanceof Element ? node : node?.parentElement)?.id === STYLE_ID\n observer = new MutationObserver((records) => {\n if (!records.some((r) => r.target === root || isPaletteStyle(r.target)\n || Array.from(r.addedNodes).some(isPaletteStyle))) return\n if (options.live && (root.classList.contains('theme-switching') || root.classList.contains('theme-transitioning'))) follow(root)\n else update()\n // Chromium animates the tokens on a theme switch (_themeTransition, 250ms): read the settled values too\n clearTimeout(settle)\n settle = setTimeout(update, THEME_TRANSITION_MS + 50)\n })\n observer.observe(root, { attributes: true, attributeFilter: ['class', 'style', 'data-palette', 'data-contrast'] })\n observer.observe(document.head, { childList: true, characterData: true, subtree: true })\n })\n onBeforeUnmount(() => {\n observer?.disconnect()\n clearTimeout(settle)\n cancelAnimationFrame(frame)\n })\n\n return tokens\n}\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m3ui-vue/m3ui-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Material 3 component library for Vue 3 + Tailwind CSS v4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"prepublishOnly": "pnpm build"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"maplibre-gl": "^5.0.0",
|
|
108
|
+
"maplibre-gl": "^5.0.0 || ^6.0.0",
|
|
109
109
|
"tailwindcss": "^4.0.0",
|
|
110
110
|
"vue": "^3.5.0"
|
|
111
111
|
},
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
}
|
|
221
221
|
},
|
|
222
222
|
"devDependencies": {
|
|
223
|
-
"@codemirror/commands": "^6.11.
|
|
223
|
+
"@codemirror/commands": "^6.11.1",
|
|
224
224
|
"@codemirror/lang-cpp": "^6.0.3",
|
|
225
225
|
"@codemirror/lang-css": "^6.3.1",
|
|
226
226
|
"@codemirror/lang-html": "^6.4.12",
|
|
@@ -229,47 +229,47 @@
|
|
|
229
229
|
"@codemirror/lang-python": "^6.2.1",
|
|
230
230
|
"@codemirror/lang-rust": "^6.0.2",
|
|
231
231
|
"@codemirror/lang-vue": "^0.1.3",
|
|
232
|
-
"@codemirror/language": "^6.
|
|
233
|
-
"@codemirror/legacy-modes": "^6.5.
|
|
234
|
-
"@codemirror/state": "^6.7.
|
|
232
|
+
"@codemirror/language": "^6.13.1",
|
|
233
|
+
"@codemirror/legacy-modes": "^6.5.5",
|
|
234
|
+
"@codemirror/state": "^6.7.6",
|
|
235
235
|
"@codemirror/theme-one-dark": "^6.1.3",
|
|
236
|
-
"@codemirror/view": "^6.43.
|
|
237
|
-
"@lezer/highlight": "^1.2.
|
|
236
|
+
"@codemirror/view": "^6.43.15",
|
|
237
|
+
"@lezer/highlight": "^1.2.5",
|
|
238
238
|
"@material/material-color-utilities": "^0.4.0",
|
|
239
|
-
"@tiptap/extension-color": "^3.
|
|
240
|
-
"@tiptap/extension-highlight": "^3.
|
|
241
|
-
"@tiptap/extension-image": "^3.
|
|
242
|
-
"@tiptap/extension-link": "^3.
|
|
243
|
-
"@tiptap/extension-placeholder": "^3.
|
|
244
|
-
"@tiptap/extension-text-align": "^3.
|
|
245
|
-
"@tiptap/extension-text-style": "^3.
|
|
246
|
-
"@tiptap/extension-underline": "^3.
|
|
247
|
-
"@tiptap/starter-kit": "^3.
|
|
248
|
-
"@tiptap/vue-3": "^3.
|
|
239
|
+
"@tiptap/extension-color": "^3.35.0",
|
|
240
|
+
"@tiptap/extension-highlight": "^3.35.0",
|
|
241
|
+
"@tiptap/extension-image": "^3.35.0",
|
|
242
|
+
"@tiptap/extension-link": "^3.35.0",
|
|
243
|
+
"@tiptap/extension-placeholder": "^3.35.0",
|
|
244
|
+
"@tiptap/extension-text-align": "^3.35.0",
|
|
245
|
+
"@tiptap/extension-text-style": "^3.35.0",
|
|
246
|
+
"@tiptap/extension-underline": "^3.35.0",
|
|
247
|
+
"@tiptap/starter-kit": "^3.35.0",
|
|
248
|
+
"@tiptap/vue-3": "^3.35.0",
|
|
249
249
|
"@types/jsbarcode": "^3.11.4",
|
|
250
250
|
"@types/markdown-it": "^14.2.0",
|
|
251
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
252
|
-
"@vue/test-utils": "^2.
|
|
251
|
+
"@vitejs/plugin-vue": "^6.0.11",
|
|
252
|
+
"@vue/test-utils": "^2.6.0",
|
|
253
253
|
"@vue/tsconfig": "^0.9.1",
|
|
254
|
-
"@webgpu/types": "^0.1.
|
|
254
|
+
"@webgpu/types": "^0.1.74",
|
|
255
255
|
"@xterm/addon-fit": "^0.11.0",
|
|
256
256
|
"@xterm/xterm": "^6.0.0",
|
|
257
|
-
"chart.js": "^4.
|
|
257
|
+
"chart.js": "^4.6.1",
|
|
258
258
|
"codemirror": "^6.0.2",
|
|
259
|
-
"happy-dom": "^
|
|
259
|
+
"happy-dom": "^21.0.4",
|
|
260
260
|
"highlight.js": "^11.12.0",
|
|
261
261
|
"jsbarcode": "^3.12.3",
|
|
262
|
-
"maplibre-gl": "^
|
|
263
|
-
"markdown-it": "^15.0.
|
|
264
|
-
"pdfjs-dist": "^6.
|
|
262
|
+
"maplibre-gl": "^6.19.0",
|
|
263
|
+
"markdown-it": "^15.0.3",
|
|
264
|
+
"pdfjs-dist": "^6.5.438",
|
|
265
265
|
"qrcode-generator": "^2.0.4",
|
|
266
266
|
"typescript": "~6.0.3",
|
|
267
|
-
"vite": "^8.3.
|
|
268
|
-
"vitest": "^5.
|
|
269
|
-
"vue": "^3.5.
|
|
270
|
-
"vue-chartjs": "^5.3.
|
|
271
|
-
"vue-component-meta": "3.3.
|
|
272
|
-
"vue-tsc": "^3.3.
|
|
267
|
+
"vite": "^8.3.8",
|
|
268
|
+
"vitest": "^5.1.1",
|
|
269
|
+
"vue": "^3.5.46",
|
|
270
|
+
"vue-chartjs": "^5.3.7",
|
|
271
|
+
"vue-component-meta": "3.3.14",
|
|
272
|
+
"vue-tsc": "^3.3.14"
|
|
273
273
|
},
|
|
274
274
|
"publishConfig": {
|
|
275
275
|
"access": "public"
|
|
@@ -60,8 +60,16 @@ describe('MFab', () => {
|
|
|
60
60
|
|
|
61
61
|
it('hydrates collapsed without mismatches, and still expands', async () => {
|
|
62
62
|
const container = document.createElement('div')
|
|
63
|
-
|
|
63
|
+
// Hydration claims <body> as the teleport target, so leftovers of earlier tests can't be in it
|
|
64
|
+
document.body.innerHTML = ''
|
|
65
|
+
// Like a real SSR page: the teleported markup (the content panel's placeholders) ends up in <body>
|
|
66
|
+
const ctx: { teleports?: Record<string, string> } = {}
|
|
67
|
+
container.innerHTML = await renderToString(createSSRApp({ render: () => h(MFab, { icon: 'edit', label: 'Compose', expanded: false }) }), ctx)
|
|
64
68
|
document.body.appendChild(container)
|
|
69
|
+
const teleported = document.createElement('template')
|
|
70
|
+
teleported.innerHTML = ctx.teleports?.body ?? ''
|
|
71
|
+
const teleportedNodes = [...teleported.content.childNodes]
|
|
72
|
+
document.body.append(...teleportedNodes)
|
|
65
73
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
66
74
|
const expanded = { value: false }
|
|
67
75
|
const app = createSSRApp({ render: () => h(MFab, { icon: 'edit', label: 'Compose', expanded: expanded.value }) })
|
|
@@ -78,5 +86,6 @@ describe('MFab', () => {
|
|
|
78
86
|
expect((container.querySelector('button') as HTMLElement).style.width).toBe('')
|
|
79
87
|
})
|
|
80
88
|
container.remove()
|
|
89
|
+
for (const node of teleportedNodes) node.remove()
|
|
81
90
|
})
|
|
82
91
|
})
|
|
@@ -6,7 +6,7 @@ import { defineComponent, h, nextTick } from 'vue'
|
|
|
6
6
|
import { created, FakeMap } from './_fakeMaplibre'
|
|
7
7
|
vi.mock('maplibre-gl', async () => (await import('./_fakeMaplibre')).fakeModule)
|
|
8
8
|
|
|
9
|
-
const { MMap, MMapMarker, MMapPopup, MMapGeoJson, MMapControl, useMap } = await import('../map')
|
|
9
|
+
const { MMap, MMapMarker, MMapPopup, MMapGeoJson, MMapControl, useMap, setMapWorker } = await import('../map')
|
|
10
10
|
|
|
11
11
|
beforeEach(() => {
|
|
12
12
|
created.maps = []
|
|
@@ -44,6 +44,21 @@ describe('MMap', () => {
|
|
|
44
44
|
expect(wrapper.emitted('ready')?.[0]?.[0]).toBe(map)
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
+
it('hands workerUrl (or setMapWorker) to setWorkerUrl before creating the map (maplibre-gl 6 under a bundler)', async () => {
|
|
48
|
+
const { fakeModule } = await import('./_fakeMaplibre')
|
|
49
|
+
fakeModule.workerUrl = undefined
|
|
50
|
+
await mountMap()
|
|
51
|
+
expect(fakeModule.workerUrl).toBeUndefined()
|
|
52
|
+
await mountMap({ workerUrl: '/assets/maplibre-gl-worker.js' })
|
|
53
|
+
expect(fakeModule.workerUrl).toBe('/assets/maplibre-gl-worker.js')
|
|
54
|
+
setMapWorker('/assets/global-worker.js')
|
|
55
|
+
await mountMap()
|
|
56
|
+
expect(fakeModule.workerUrl).toBe('/assets/global-worker.js')
|
|
57
|
+
await mountMap({ workerUrl: '/assets/own-worker.js' })
|
|
58
|
+
expect(fakeModule.workerUrl).toBe('/assets/own-worker.js')
|
|
59
|
+
setMapWorker(undefined)
|
|
60
|
+
})
|
|
61
|
+
|
|
47
62
|
it('leaves the view to the style when none is given', async () => {
|
|
48
63
|
const { map } = await mountMap()
|
|
49
64
|
expect('center' in map.options).toBe(false)
|
|
@@ -160,4 +160,6 @@ export const fakeModule = {
|
|
|
160
160
|
FullscreenControl: class FullscreenControl extends Control {},
|
|
161
161
|
ScaleControl: class ScaleControl extends Control {},
|
|
162
162
|
AttributionControl: class AttributionControl extends Control {},
|
|
163
|
+
workerUrl: undefined as string | undefined,
|
|
164
|
+
setWorkerUrl(url: string) { fakeModule.workerUrl = url },
|
|
163
165
|
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import { nextTick } from 'vue'
|
|
4
|
+
import MSelect from '../components/MSelect.vue'
|
|
5
|
+
import MTextField from '../components/MTextField.vue'
|
|
6
|
+
import MAutocomplete from '../components/MAutocomplete.vue'
|
|
7
|
+
import MMultiSelect from '../components/MMultiSelect.vue'
|
|
8
|
+
import MTagInput from '../components/MTagInput.vue'
|
|
9
|
+
import MDatePicker from '../components/MDatePicker.vue'
|
|
10
|
+
import MDateRangePicker from '../components/MDateRangePicker.vue'
|
|
11
|
+
|
|
12
|
+
const LONG = 'No cumple, pendientes y en proceso (P, EP)'
|
|
13
|
+
const options = [{ value: 'x', label: LONG }]
|
|
14
|
+
|
|
15
|
+
function cls(el: Element | null | undefined) {
|
|
16
|
+
return (el?.getAttribute('class') ?? '').split(/\s+/)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Simulates a value cut by overflow (happy-dom has no layout) */
|
|
20
|
+
function fakeOverflow(el: HTMLElement, cut: boolean) {
|
|
21
|
+
Object.defineProperty(el, 'scrollWidth', { configurable: true, value: cut ? 300 : 100 })
|
|
22
|
+
Object.defineProperty(el, 'clientWidth', { configurable: true, value: 100 })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('long content in narrow fields', () => {
|
|
26
|
+
it('MSelect keeps a long value on one line, cut with an ellipsis', () => {
|
|
27
|
+
const w = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options } })
|
|
28
|
+
const value = w.find('[role="combobox"] span')
|
|
29
|
+
expect(value.text()).toBe(LONG)
|
|
30
|
+
expect(cls(value.element)).toEqual(expect.arrayContaining(['truncate', 'min-w-0']))
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('MSelect reserves room for the clear button as well as the arrow', () => {
|
|
34
|
+
const plain = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options } })
|
|
35
|
+
expect(cls(plain.find('[role="combobox"]').element)).toContain('pr-10')
|
|
36
|
+
const clearable = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options, clearable: true } })
|
|
37
|
+
const trigger = clearable.find('[role="combobox"]')
|
|
38
|
+
expect(cls(trigger.element)).toContain('pr-16')
|
|
39
|
+
expect(cls(trigger.element)).not.toContain('pr-10')
|
|
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('right-16')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('MSelect puts the whole value in a title only when it is cut', async () => {
|
|
45
|
+
const w = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options }, attachTo: document.body })
|
|
46
|
+
const value = w.find('[role="combobox"] span').element as HTMLElement
|
|
47
|
+
fakeOverflow(value, false)
|
|
48
|
+
value.dispatchEvent(new Event('pointerenter'))
|
|
49
|
+
expect(value.hasAttribute('title')).toBe(false)
|
|
50
|
+
fakeOverflow(value, true)
|
|
51
|
+
value.dispatchEvent(new Event('pointerenter'))
|
|
52
|
+
expect(value.getAttribute('title')).toBe(LONG)
|
|
53
|
+
w.unmount()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('MTextField: the label stops before a trailing button, and the outlined floated label before the corner', () => {
|
|
57
|
+
const w = mount(MTextField, { props: { modelValue: '', label: 'Etiqueta larga', clearable: true } })
|
|
58
|
+
expect(cls(w.find('label').element)).toContain('right-12')
|
|
59
|
+
expect(cls(w.find('input').element)).toContain('pr-12')
|
|
60
|
+
|
|
61
|
+
const icon = mount(MTextField, { props: { modelValue: '', label: 'Etiqueta', variant: 'outlined', leadingIcon: 'search' } })
|
|
62
|
+
const label = cls(icon.find('label').element)
|
|
63
|
+
expect(label).toContain('left-11')
|
|
64
|
+
// left-11 (44px) + 12px from the far corner
|
|
65
|
+
expect(label).toContain('peer-focus:max-w-[calc(100%-3.5rem)]')
|
|
66
|
+
expect(label).not.toContain('peer-focus:max-w-[calc(100%-1.5rem)]')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('MTextField puts a cut value in a title', () => {
|
|
70
|
+
const w = mount(MTextField, { props: { modelValue: LONG, label: 'Nombre' }, attachTo: document.body })
|
|
71
|
+
const input = w.find('input').element as HTMLInputElement
|
|
72
|
+
fakeOverflow(input, true)
|
|
73
|
+
input.dispatchEvent(new Event('pointerenter'))
|
|
74
|
+
expect(input.getAttribute('title')).toBe(LONG)
|
|
75
|
+
w.unmount()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('MAutocomplete reserves room for the clear button', () => {
|
|
79
|
+
const w = mount(MAutocomplete, { props: { modelValue: 'x', label: 'Estado', options, clearable: true } })
|
|
80
|
+
expect(cls(w.find('input').element)).toContain('pr-16')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('chip fields cut a long chip instead of overflowing the field', () => {
|
|
84
|
+
const multi = mount(MMultiSelect, { props: { modelValue: ['x'], label: 'Estados', options } })
|
|
85
|
+
const chip = multi.find('[role="button"] > span')
|
|
86
|
+
expect(cls(chip.element)).toEqual(expect.arrayContaining(['max-w-full', 'min-w-0']))
|
|
87
|
+
expect(cls(chip.find('span').element)).toContain('truncate')
|
|
88
|
+
|
|
89
|
+
const tags = mount(MTagInput, { props: { modelValue: [LONG], label: 'Etiquetas' } })
|
|
90
|
+
const tag = tags.find('span.rounded-full')
|
|
91
|
+
expect(cls(tag.element)).toContain('max-w-full')
|
|
92
|
+
expect(cls(tag.find('span').element)).toContain('truncate')
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('date pickers cut a long value and a long label', () => {
|
|
96
|
+
for (const w of [
|
|
97
|
+
mount(MDatePicker, { props: { modelValue: '2026-11-22', label: 'Fecha de inicio del período' } }),
|
|
98
|
+
mount(MDateRangePicker, { props: { modelValue: { start: '2026-11-01', end: '2026-11-22' }, label: 'Período' } }),
|
|
99
|
+
]) {
|
|
100
|
+
expect(cls(w.find('button span.flex-1').element)).toEqual(expect.arrayContaining(['truncate', 'min-w-0']))
|
|
101
|
+
expect(cls(w.find('label').element)).toEqual(expect.arrayContaining(['truncate', 'max-w-[calc(100%-1.5rem)]']))
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('keeps the title in step when the value changes while it is shown', async () => {
|
|
106
|
+
const w = mount(MSelect, {
|
|
107
|
+
props: { modelValue: 'x', label: 'Estado', options: [...options, { value: 'y', label: `${LONG} (2)` }] },
|
|
108
|
+
attachTo: document.body,
|
|
109
|
+
})
|
|
110
|
+
const value = w.find('[role="combobox"] span').element as HTMLElement
|
|
111
|
+
fakeOverflow(value, true)
|
|
112
|
+
value.dispatchEvent(new Event('pointerenter'))
|
|
113
|
+
await w.setProps({ modelValue: 'y' })
|
|
114
|
+
await nextTick()
|
|
115
|
+
expect(value.getAttribute('title')).toBe(`${LONG} (2)`)
|
|
116
|
+
w.unmount()
|
|
117
|
+
})
|
|
118
|
+
})
|
|
@@ -14,6 +14,7 @@ import { useDebounce } from '../composables/useDebounce'
|
|
|
14
14
|
import type { SelectOption } from './MSelect.vue'
|
|
15
15
|
import { useScrollLock } from '../composables/_useScrollLock'
|
|
16
16
|
import { useEscapeStack } from '../composables/_useEscapeStack'
|
|
17
|
+
import { FIELD_PADDING_RIGHT, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'
|
|
17
18
|
|
|
18
19
|
// Root is a fragment (field div + a sibling Teleport for the dropdown panel), so Vue can't
|
|
19
20
|
// auto-apply a consumer's class/attrs to either one — forward them onto the field div below.
|
|
@@ -279,11 +280,15 @@ const displayValue = computed(() => {
|
|
|
279
280
|
return selectedLabel.value
|
|
280
281
|
})
|
|
281
282
|
|
|
283
|
+
// The text and the label stop before the clear button and the arrow
|
|
284
|
+
const rightInset = computed<FieldRightInset>(() => (props.clearable ? 'right-16' : 'right-10'))
|
|
285
|
+
|
|
282
286
|
const triggerClasses = computed(() => {
|
|
283
287
|
const pl = props.leadingIcon ? 'pl-12' : 'pl-4'
|
|
284
288
|
const base = [
|
|
285
|
-
'flex w-full items-center
|
|
289
|
+
'flex w-full min-w-0 items-center text-body-large transition-[border-color,border-width] duration-150',
|
|
286
290
|
pl,
|
|
291
|
+
FIELD_PADDING_RIGHT[rightInset.value],
|
|
287
292
|
]
|
|
288
293
|
|
|
289
294
|
if (props.variant === 'outlined') {
|
|
@@ -308,29 +313,20 @@ const triggerClasses = computed(() => {
|
|
|
308
313
|
|
|
309
314
|
const isFloated = computed(() => hasValue.value || open.value)
|
|
310
315
|
|
|
311
|
-
const labelClasses = computed(() =>
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
'pointer-events-none absolute right-10 truncate transition-all duration-200',
|
|
326
|
-
left,
|
|
327
|
-
isFloated.value ? floated : unFloated,
|
|
328
|
-
open.value
|
|
329
|
-
? (props.error ? 'text-error' : 'text-primary')
|
|
330
|
-
: (props.error ? 'text-error' : 'text-on-surface-variant'),
|
|
331
|
-
'peer-disabled:text-on-surface/38',
|
|
332
|
-
].join(' ')
|
|
333
|
-
})
|
|
316
|
+
const labelClasses = computed(() =>
|
|
317
|
+
fieldLabelClasses({
|
|
318
|
+
variant: props.variant,
|
|
319
|
+
leading: !!props.leadingIcon,
|
|
320
|
+
right: rightInset.value,
|
|
321
|
+
floated: isFloated.value,
|
|
322
|
+
color: [
|
|
323
|
+
open.value
|
|
324
|
+
? (props.error ? 'text-error' : 'text-primary')
|
|
325
|
+
: (props.error ? 'text-error' : 'text-on-surface-variant'),
|
|
326
|
+
'peer-disabled:text-on-surface/38',
|
|
327
|
+
].join(' '),
|
|
328
|
+
}),
|
|
329
|
+
)
|
|
334
330
|
</script>
|
|
335
331
|
|
|
336
332
|
<template>
|
|
@@ -370,6 +366,7 @@ const labelClasses = computed(() => {
|
|
|
370
366
|
:aria-required="required || undefined"
|
|
371
367
|
:aria-invalid="error || undefined"
|
|
372
368
|
:aria-disabled="disabled"
|
|
369
|
+
v-overflow-title
|
|
373
370
|
:class="[
|
|
374
371
|
triggerClasses,
|
|
375
372
|
'peer outline-none text-on-surface cursor-text',
|
|
@@ -12,6 +12,7 @@ import MColorPanel from './_MColorPanel.vue'
|
|
|
12
12
|
import { useFieldBg } from '../composables/useFieldBg'
|
|
13
13
|
import { useLocale } from '../composables/useLocale'
|
|
14
14
|
import { defaultColorPresets, normalizeHex, pushRecentColor } from '../composables/_colorUtils'
|
|
15
|
+
import { OUTLINED_FLOATED_LABEL, vOverflowTitle } from '../composables/_fieldLayout'
|
|
15
16
|
|
|
16
17
|
const props = withDefaults(defineProps<{
|
|
17
18
|
/** Selected color in hex format (v-model). `#rrggbb`, or `#rrggbbaa` when `alpha` is on and the color isn't opaque. */
|
|
@@ -156,7 +157,7 @@ onUnmounted(() => {
|
|
|
156
157
|
:class="disabled ? 'opacity-38' : ''"
|
|
157
158
|
:style="{ background: `linear-gradient(${modelValue}, ${modelValue}), repeating-conic-gradient(#d4d4d4 0 25%, #fff 0 50%) 0 0 / 8px 8px` }"
|
|
158
159
|
/>
|
|
159
|
-
<span class="flex-1 font-mono" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ modelValue }}</span>
|
|
160
|
+
<span v-overflow-title class="min-w-0 truncate flex-1 font-mono" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ modelValue }}</span>
|
|
160
161
|
<MIcon
|
|
161
162
|
name="palette"
|
|
162
163
|
:size="24"
|
|
@@ -166,8 +167,7 @@ onUnmounted(() => {
|
|
|
166
167
|
</button>
|
|
167
168
|
<label
|
|
168
169
|
v-if="label"
|
|
169
|
-
class="
|
|
170
|
-
:class="disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
|
|
170
|
+
:class="[OUTLINED_FLOATED_LABEL, 'transition-colors', disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant']"
|
|
171
171
|
>
|
|
172
172
|
{{ label }}
|
|
173
173
|
</label>
|
|
@@ -13,6 +13,7 @@ import { useFieldBg } from '../composables/useFieldBg'
|
|
|
13
13
|
import { useLocale } from '../composables/useLocale'
|
|
14
14
|
import { POPUP_MARGIN, dropdownX, fitPopup } from '../composables/_popupPosition'
|
|
15
15
|
import { useCalendarMonth } from '../composables/_useCalendarMonth'
|
|
16
|
+
import { OUTLINED_FLOATED_LABEL, vOverflowTitle } from '../composables/_fieldLayout'
|
|
16
17
|
|
|
17
18
|
const props = defineProps<{
|
|
18
19
|
/** Selected date (YYYY-MM-DD, v-model) */
|
|
@@ -179,8 +180,8 @@ onUnmounted(() => {
|
|
|
179
180
|
@click="!disabled && (open = !open)"
|
|
180
181
|
>
|
|
181
182
|
<MIcon name="calendar_today" :size="24" class="shrink-0" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'" />
|
|
182
|
-
<span v-if="displayValue" class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
|
|
183
|
-
<span v-else class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ placeholder || label || localeStrings.selectDate }}</span>
|
|
183
|
+
<span v-overflow-title v-if="displayValue" class="min-w-0 truncate flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
|
|
184
|
+
<span v-overflow-title v-else class="min-w-0 truncate flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ placeholder || label || localeStrings.selectDate }}</span>
|
|
184
185
|
<MIcon
|
|
185
186
|
v-if="modelValue"
|
|
186
187
|
name="close"
|
|
@@ -191,8 +192,7 @@ onUnmounted(() => {
|
|
|
191
192
|
</button>
|
|
192
193
|
<label
|
|
193
194
|
v-if="label"
|
|
194
|
-
class="
|
|
195
|
-
:class="disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
|
|
195
|
+
:class="[OUTLINED_FLOATED_LABEL, 'transition-colors', disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant']"
|
|
196
196
|
>
|
|
197
197
|
{{ label }}
|
|
198
198
|
</label>
|
|
@@ -13,6 +13,7 @@ import { useFieldBg } from '../composables/useFieldBg'
|
|
|
13
13
|
import { useLocale } from '../composables/useLocale'
|
|
14
14
|
import { POPUP_MARGIN, dropdownX, fitPopup } from '../composables/_popupPosition'
|
|
15
15
|
import { isoDate as fmt, useCalendarMonth } from '../composables/_useCalendarMonth'
|
|
16
|
+
import { OUTLINED_FLOATED_LABEL, vOverflowTitle } from '../composables/_fieldLayout'
|
|
16
17
|
|
|
17
18
|
export interface DateRange {
|
|
18
19
|
start: string | null
|
|
@@ -214,8 +215,8 @@ onUnmounted(() => {
|
|
|
214
215
|
@click="!disabled && (open = !open)"
|
|
215
216
|
>
|
|
216
217
|
<MIcon name="date_range" :size="24" class="shrink-0" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'" />
|
|
217
|
-
<span v-if="displayValue" class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
|
|
218
|
-
<span v-else class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ label || placeholder || localeStrings.selectRange }}</span>
|
|
218
|
+
<span v-overflow-title v-if="displayValue" class="min-w-0 truncate flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
|
|
219
|
+
<span v-overflow-title v-else class="min-w-0 truncate flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ label || placeholder || localeStrings.selectRange }}</span>
|
|
219
220
|
<MIcon
|
|
220
221
|
v-if="modelValue.start || modelValue.end"
|
|
221
222
|
name="close"
|
|
@@ -226,8 +227,7 @@ onUnmounted(() => {
|
|
|
226
227
|
</button>
|
|
227
228
|
<label
|
|
228
229
|
v-if="label"
|
|
229
|
-
class="
|
|
230
|
-
:class="disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
|
|
230
|
+
:class="[OUTLINED_FLOATED_LABEL, 'transition-colors', disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant']"
|
|
231
231
|
>
|
|
232
232
|
{{ label }}
|
|
233
233
|
</label>
|
package/src/components/MMap.vue
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* MapLibre map itself is the `ready` event's argument and the `map` of `useMap()` in components placed inside.
|
|
7
7
|
* Available from the `/map` entry point; needs `maplibre-gl` installed and its CSS imported
|
|
8
8
|
* (`maplibre-gl/dist/maplibre-gl.css`). Give it a height. Server-side rendering renders the empty container: MapLibre
|
|
9
|
-
* loads in the browser.
|
|
9
|
+
* loads in the browser. With maplibre-gl 6 and a bundler, give it MapLibre's worker URL (`setMapWorker()` once
|
|
10
|
+
* at startup, or the `workerUrl` prop), or the map stays blank.
|
|
10
11
|
*
|
|
11
12
|
* @slot default Map components (`MMapMarker`, `MMapPopup`, `MMapGeoJson`, `MMapControl`) and anything to show over
|
|
12
13
|
* the map, rendered once the map exists
|
|
@@ -21,7 +22,7 @@ import { markRaw, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallow
|
|
|
21
22
|
import type * as Maplibre from 'maplibre-gl'
|
|
22
23
|
import MMapAttribution from './_MMapAttribution.vue'
|
|
23
24
|
import { useLocale } from '../composables/useLocale'
|
|
24
|
-
import { MAP_KEY, type MapContext, type MaplibreModule } from '../composables/useMap'
|
|
25
|
+
import { MAP_KEY, mapWorkerUrl, type MapContext, type MaplibreModule } from '../composables/useMap'
|
|
25
26
|
import { createLayerState, readLayerState } from '../composables/useMapLayers'
|
|
26
27
|
import { storageKey } from '../composables/_storageKeys'
|
|
27
28
|
import type { MapAdapter, MapLayerModel } from '../composables/mapAdapters'
|
|
@@ -60,6 +61,12 @@ const props = withDefaults(
|
|
|
60
61
|
* under `m3-map-view` (after `createM3UI`'s `storagePrefix`, if any), or your own key (one per map)
|
|
61
62
|
*/
|
|
62
63
|
persist?: boolean | string
|
|
64
|
+
/**
|
|
65
|
+
* The URL of MapLibre's worker, handed to maplibre's `setWorkerUrl()` before the map is created. maplibre-gl 6
|
|
66
|
+
* needs it under a bundler; with Vite: `import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'`.
|
|
67
|
+
* Overrides `setMapWorker()`; the setting is global to maplibre, so the last one applied wins
|
|
68
|
+
*/
|
|
69
|
+
workerUrl?: string
|
|
63
70
|
/** Zoom and compass buttons: `false`, or a corner (`true` is top-right) */
|
|
64
71
|
navigation?: boolean | MapControlPosition
|
|
65
72
|
/** A button that centers the map on the user's location and follows it: `false`, or a corner (`true` is top-right) */
|
|
@@ -273,10 +280,12 @@ onBeforeUnmount(() => {
|
|
|
273
280
|
let destroyed = false
|
|
274
281
|
|
|
275
282
|
onMounted(async () => {
|
|
276
|
-
// maplibre-gl ships a UMD build: depending on the bundler its classes are on the namespace or on `default`
|
|
283
|
+
// maplibre-gl 5 ships a UMD build: depending on the bundler its classes are on the namespace or on `default`
|
|
277
284
|
const mod = await import('maplibre-gl')
|
|
278
285
|
const ml = ('Map' in mod ? mod : (mod as { default: MaplibreModule }).default) as MaplibreModule
|
|
279
286
|
if (destroyed || !container.value) return
|
|
287
|
+
const workerUrl = props.workerUrl ?? mapWorkerUrl()
|
|
288
|
+
if (workerUrl) ml.setWorkerUrl(workerUrl)
|
|
280
289
|
const saved = readView()
|
|
281
290
|
const view = {
|
|
282
291
|
center: saved.center ?? props.center,
|
|
@@ -166,11 +166,13 @@ function ensureLayers() {
|
|
|
166
166
|
add({ id: VERTEX, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'vertex'], paint: { ...p.vertices, 'circle-radius': 7, 'circle-stroke-width': 2.5 } })
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
type SetPaint = Parameters<Maplibre.Map['setPaintProperty']>
|
|
170
|
+
|
|
169
171
|
watch(theme, () => {
|
|
170
172
|
if (!map) return
|
|
171
173
|
const p = paints()
|
|
172
174
|
const set = (layer: string, paint: Record<string, unknown>) => {
|
|
173
|
-
if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k, v)
|
|
175
|
+
if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k as SetPaint[1], v as SetPaint[2])
|
|
174
176
|
}
|
|
175
177
|
for (const source of [SRC.done, SRC.draft]) {
|
|
176
178
|
set(`${source}-fill`, p.fill)
|
|
@@ -10,6 +10,7 @@ import MIcon from './MIcon.vue'
|
|
|
10
10
|
import { useFieldBg } from '../composables/useFieldBg'
|
|
11
11
|
import { useDebounce } from '../composables/useDebounce'
|
|
12
12
|
import { useLocale } from '../composables/useLocale'
|
|
13
|
+
import { FIELD_PADDING_RIGHT, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'
|
|
13
14
|
|
|
14
15
|
export type MaskPreset = 'credit-card' | 'phone' | 'date' | 'time' | 'cpf' | 'cnpj' | 'zip'
|
|
15
16
|
|
|
@@ -128,9 +129,12 @@ function onKeydown(e: KeyboardEvent) {
|
|
|
128
129
|
|
|
129
130
|
const hasTrailing = computed(() => props.clearable)
|
|
130
131
|
|
|
132
|
+
// The label and the text both stop before the trailing controls
|
|
133
|
+
const rightInset = computed<FieldRightInset>(() => (hasTrailing.value ? 'right-12' : 'right-4'))
|
|
134
|
+
|
|
131
135
|
const inputClasses = computed(() => {
|
|
132
136
|
const pl = props.leadingIcon ? 'pl-12' : 'pl-4'
|
|
133
|
-
const pr =
|
|
137
|
+
const pr = FIELD_PADDING_RIGHT[rightInset.value]
|
|
134
138
|
const base = [
|
|
135
139
|
'peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent',
|
|
136
140
|
'transition-[border-color,border-width] duration-150',
|
|
@@ -156,31 +160,18 @@ const inputClasses = computed(() => {
|
|
|
156
160
|
].join(' ')
|
|
157
161
|
})
|
|
158
162
|
|
|
159
|
-
const labelClasses = computed(() =>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
left, 'right-4', `${unfloatedTop} -translate-y-1/2 text-body-large`,
|
|
167
|
-
]
|
|
168
|
-
if (props.variant === 'outlined') {
|
|
169
|
-
return [...base,
|
|
170
|
-
'peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:right-auto peer-focus:max-w-[calc(100%-1.5rem)] peer-focus:bg-[var(--field-bg)] peer-focus:px-1',
|
|
171
|
-
'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:right-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-1.5rem)]',
|
|
172
|
-
'peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1',
|
|
163
|
+
const labelClasses = computed(() =>
|
|
164
|
+
fieldLabelClasses({
|
|
165
|
+
variant: props.variant,
|
|
166
|
+
leading: !!props.leadingIcon,
|
|
167
|
+
right: rightInset.value,
|
|
168
|
+
floated: 'peer',
|
|
169
|
+
color: [
|
|
173
170
|
props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
174
171
|
'peer-disabled:text-on-surface/38',
|
|
175
|
-
].join(' ')
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
'peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small',
|
|
179
|
-
'peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small',
|
|
180
|
-
props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
181
|
-
'peer-disabled:text-on-surface/38',
|
|
182
|
-
].join(' ')
|
|
183
|
-
})
|
|
172
|
+
].join(' '),
|
|
173
|
+
}),
|
|
174
|
+
)
|
|
184
175
|
|
|
185
176
|
defineExpose({
|
|
186
177
|
/** The `<input>` (or `<textarea>`) element */
|
|
@@ -225,6 +216,7 @@ defineExpose({
|
|
|
225
216
|
:required="required"
|
|
226
217
|
placeholder=" "
|
|
227
218
|
:class="inputClasses"
|
|
219
|
+
v-overflow-title
|
|
228
220
|
@input="onInput"
|
|
229
221
|
@keydown="onKeydown"
|
|
230
222
|
/>
|