@m3ui-vue/m3ui-vue 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/API.md +199 -54
- package/dist/{MTextField-pJU1vFaR.js → MTextField-Ck0oWDMk.js} +8 -2
- package/dist/MTextField-Ck0oWDMk.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MBox.vue.d.ts +3 -3
- package/dist/components/MColorPicker.vue.d.ts +13 -1
- package/dist/components/MColorPickerModal.vue.d.ts +14 -2
- package/dist/components/MDragHandle.vue.d.ts +12 -0
- package/dist/components/MEmojiSelector.vue.d.ts +1 -1
- package/dist/components/MFab.vue.d.ts +1 -1
- package/dist/components/MFabMenu.vue.d.ts +1 -1
- package/dist/components/MListItem.vue.d.ts +5 -5
- package/dist/components/MOverlay.vue.d.ts +1 -1
- package/dist/components/MScrollField.vue.d.ts +40 -0
- package/dist/components/MScrollable.vue.d.ts +9 -0
- package/dist/components/MSplitter.vue.d.ts +2 -2
- package/dist/components/MSwipeToDismiss.vue.d.ts +49 -0
- package/dist/components/MTransition.vue.d.ts +34 -0
- package/dist/components/MWindow.vue.d.ts +1 -1
- package/dist/components/_MColorPanel.vue.d.ts +18 -0
- package/dist/composables/_colorUtils.d.ts +34 -0
- package/dist/composables/_themeColor.d.ts +1 -0
- package/dist/composables/_useSpring.d.ts +15 -0
- package/dist/composables/dynamicColor.d.ts +18 -0
- package/dist/composables/useColorPalette.d.ts +27 -0
- package/dist/composables/useLocale.d.ts +10 -0
- package/dist/index.d.ts +9 -1
- package/dist/locales/index.js +70 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +4808 -3622
- package/dist/m3ui.js.map +1 -1
- package/dist/material-color-utilities-Cktu8DBU.js +3160 -0
- package/dist/material-color-utilities-Cktu8DBU.js.map +1 -0
- package/dist/plugin.d.ts +18 -0
- package/dist/rich-text-editor.js +2 -2
- package/dist/styles/palettes.css +546 -0
- package/dist/styles/theme.css +77 -0
- package/dist/styles.css +1 -1
- package/dist/{useLocale-Drihe5G2.js → useLocale-CFW8cIzL.js} +11 -1
- package/dist/useLocale-CFW8cIzL.js.map +1 -0
- package/package.json +2 -1
- package/src/__tests__/MButtonGroup.test.ts +51 -0
- package/src/__tests__/MColorPicker.test.ts +141 -0
- package/src/__tests__/MDragHandle.test.ts +57 -0
- package/src/__tests__/MListItemShape.test.ts +76 -0
- package/src/__tests__/MScrollField.test.ts +41 -0
- package/src/__tests__/MScrollable.test.ts +42 -0
- package/src/__tests__/MSwipeToDismiss.test.ts +104 -0
- package/src/__tests__/MTransition.test.ts +27 -0
- package/src/__tests__/dynamicColor.test.ts +191 -0
- package/src/components/MBox.vue +4 -2
- package/src/components/MButtonGroup.vue +116 -35
- package/src/components/MColorPicker.vue +114 -210
- package/src/components/MColorPickerModal.vue +50 -251
- package/src/components/MDragHandle.vue +54 -0
- package/src/components/MList.vue +33 -3
- package/src/components/MListItem.vue +75 -5
- package/src/components/MScrollField.vue +302 -0
- package/src/components/MScrollable.vue +160 -5
- package/src/components/MSplitter.vue +33 -10
- package/src/components/MSwipeToDismiss.vue +247 -0
- package/src/components/MTransition.vue +149 -0
- package/src/components/_MColorPanel.vue +478 -0
- package/src/composables/_colorUtils.ts +107 -0
- package/src/composables/_themeColor.ts +33 -0
- package/src/composables/_useSpring.ts +89 -0
- package/src/composables/dynamicColor.ts +85 -0
- package/src/composables/useColorPalette.ts +171 -25
- package/src/composables/useFieldBg.ts +6 -0
- package/src/composables/useLocale.ts +22 -0
- package/src/index.ts +9 -1
- package/src/locales/de.ts +10 -0
- package/src/locales/es.ts +10 -0
- package/src/locales/fr.ts +10 -0
- package/src/locales/ja.ts +10 -0
- package/src/locales/ko.ts +10 -0
- package/src/locales/pt.ts +10 -0
- package/src/locales/zh.ts +10 -0
- package/src/plugin.ts +28 -7
- package/src/styles/palettes.css +546 -0
- package/src/styles/theme.css +77 -0
- package/dist/MTextField-pJU1vFaR.js.map +0 -1
- package/dist/useLocale-Drihe5G2.js.map +0 -1
package/src/plugin.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { App, MaybeRef } from 'vue'
|
|
2
2
|
import type { Palette } from './composables/useColorPalette'
|
|
3
|
-
import { __forcePalette, palettes } from './composables/useColorPalette'
|
|
3
|
+
import { __defaultPalette, __defaultSeed, __forcePalette, palettes } from './composables/useColorPalette'
|
|
4
|
+
import type { SeedOptions } from './composables/dynamicColor'
|
|
5
|
+
import { syncThemeColor } from './composables/_themeColor'
|
|
4
6
|
import type { M3Locale } from './composables/useLocale'
|
|
5
7
|
import { M3_LOCALE_KEY, __setAppLocale } from './composables/useLocale'
|
|
6
8
|
|
|
@@ -22,7 +24,24 @@ export interface M3UIOptions {
|
|
|
22
24
|
* `[data-palette='<id>'].dark { ... }` block, overriding the same tokens as `palettes.css`.
|
|
23
25
|
*/
|
|
24
26
|
customPalettes?: Palette[]
|
|
27
|
+
/**
|
|
28
|
+
* Generate the whole color scheme (light and dark) from one color instead of using a named palette: Google's
|
|
29
|
+
* dynamic color, the way Android builds a theme from a wallpaper. `palette` wins when both are given, and like
|
|
30
|
+
* `palette` it's only the first-visit default unless `persistPalette` is `false`.
|
|
31
|
+
*/
|
|
32
|
+
seed?: string
|
|
33
|
+
/** How `seed` becomes a scheme: `variant` (`'tonal-spot'` by default) and `contrast` (0 standard, 0.5 medium, 1 high). */
|
|
34
|
+
seedOptions?: SeedOptions
|
|
25
35
|
locale?: MaybeRef<Partial<M3Locale>>
|
|
36
|
+
/**
|
|
37
|
+
* Keep `<meta name="theme-color">` (the color phones give the browser bar and status bar) in sync with a color
|
|
38
|
+
* role of the active palette, following palette, seed and dark mode changes. `'surface'` matches a top app
|
|
39
|
+
* bar, as Material apps on Android do; any role name works (`'primary'`, `'surface-container'`…). Off by default:
|
|
40
|
+
* when set, the library owns that meta (it's created if missing, and a light/dark `media` pair becomes one).
|
|
41
|
+
* Note that Chrome and Samsung Internet on Android ignore it in a regular tab while the system is in dark
|
|
42
|
+
* mode (they keep their own dark bar); installed apps (PWA) still get it.
|
|
43
|
+
*/
|
|
44
|
+
themeColor?: 'surface' | 'surface-container' | 'primary' | (string & {})
|
|
26
45
|
}
|
|
27
46
|
|
|
28
47
|
export function createM3UI(options: M3UIOptions = {}) {
|
|
@@ -35,13 +54,15 @@ export function createM3UI(options: M3UIOptions = {}) {
|
|
|
35
54
|
}
|
|
36
55
|
if (options.persistPalette === false) {
|
|
37
56
|
if (options.palette) __forcePalette(options.palette, false)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// `
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
else if (options.seed) void __defaultSeed(options.seed, options.seedOptions, false)
|
|
58
|
+
} else if (!localStorage.getItem('m3-palette')) {
|
|
59
|
+
// `palette`/`seed` are only the first-visit default — once the user picks a palette via
|
|
60
|
+
// `useColorPalette().set()` (or a seed via `setSeed()`) it's persisted to localStorage, and that choice
|
|
61
|
+
// must win on every later boot instead of being clobbered back to the plugin's static default.
|
|
62
|
+
if (options.palette && options.palette !== 'purple') __defaultPalette(options.palette)
|
|
63
|
+
else if (!options.palette && options.seed) void __defaultSeed(options.seed, options.seedOptions, true)
|
|
44
64
|
}
|
|
65
|
+
if (options.themeColor) syncThemeColor(options.themeColor)
|
|
45
66
|
if (options.locale) {
|
|
46
67
|
app.provide(M3_LOCALE_KEY, options.locale)
|
|
47
68
|
__setAppLocale(options.locale)
|