@m3ui-vue/m3ui-vue 0.9.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -29
- package/dist/API.md +177 -18
- package/dist/{MTextField-DKtgPymd.js → MTextField-TZ7lfr09.js} +233 -108
- package/dist/MTextField-TZ7lfr09.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MAppBarWithSearch.vue.d.ts +70 -0
- package/dist/components/MBottomAppBar.vue.d.ts +37 -0
- package/dist/components/MBottomSheetScaffold.vue.d.ts +40 -0
- package/dist/components/MChatBubble.vue.d.ts +1 -1
- package/dist/components/MChip.vue.d.ts +19 -2
- package/dist/components/MContainer.vue.d.ts +1 -1
- package/dist/components/MDataTable.vue.d.ts +1 -1
- package/dist/components/MDialog.vue.d.ts +1 -1
- package/dist/components/MFab.vue.d.ts +13 -4
- package/dist/components/MListItem.vue.d.ts +2 -2
- package/dist/components/MLoadingOverlay.vue.d.ts +1 -1
- package/dist/components/MNavigationRail.vue.d.ts +6 -0
- package/dist/components/MSearchBar.vue.d.ts +5 -3
- package/dist/components/MShortNavigationBar.vue.d.ts +1 -1
- package/dist/components/MTable.vue.d.ts +1 -1
- package/dist/components/MTopAppBar.vue.d.ts +33 -2
- package/dist/composables/_searchAppBar.d.ts +6 -0
- package/dist/composables/_themeTransition.d.ts +2 -0
- package/dist/composables/_useSpring.d.ts +3 -5
- package/dist/composables/motion.d.ts +101 -0
- package/dist/composables/useColorPalette.d.ts +10 -0
- package/dist/composables/useLocale.d.ts +3 -0
- package/dist/index.d.ts +8 -1
- package/dist/locales/index.js +21 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +6772 -5931
- package/dist/m3ui.js.map +1 -1
- package/dist/plugin.d.ts +7 -0
- package/dist/rich-text-editor.js +2 -2
- package/dist/styles/palettes-contrast.css +7764 -0
- package/dist/styles/theme.css +46 -2
- package/dist/styles.css +1 -1
- package/dist/{useLocale-Cn9MVIdw.js → useLocale-CuvWRZ1h.js} +4 -1
- package/dist/useLocale-CuvWRZ1h.js.map +1 -0
- package/package.json +3 -1
- package/src/__tests__/MAppBarWithSearch.test.ts +96 -0
- package/src/__tests__/MBottomAppBar.test.ts +71 -0
- package/src/__tests__/MBottomSheetScaffold.test.ts +101 -0
- package/src/__tests__/MChip.test.ts +63 -0
- package/src/__tests__/MFab.test.ts +36 -0
- package/src/__tests__/MNavigationRail.test.ts +77 -0
- package/src/__tests__/MTopAppBar.test.ts +99 -0
- package/src/__tests__/contrast.test.ts +64 -0
- package/src/__tests__/dynamicColor.test.ts +17 -0
- package/src/__tests__/motion.test.ts +37 -0
- package/src/__tests__/themeTransition.test.ts +119 -0
- package/src/components/MAppBarWithSearch.vue +236 -0
- package/src/components/MBottomAppBar.vue +181 -0
- package/src/components/MBottomSheetScaffold.vue +296 -0
- package/src/components/MBreadcrumbs.vue +1 -1
- package/src/components/MChip.vue +137 -5
- package/src/components/MFab.vue +73 -12
- package/src/components/MNavigationDrawer.vue +2 -2
- package/src/components/MNavigationRail.vue +135 -8
- package/src/components/MSearchBar.vue +28 -12
- package/src/components/MTopAppBar.vue +252 -28
- package/src/composables/_searchAppBar.ts +9 -0
- package/src/composables/_themeColor.ts +11 -4
- package/src/composables/_themeTransition.ts +71 -0
- package/src/composables/_useSpring.ts +11 -21
- package/src/composables/motion.ts +73 -0
- package/src/composables/useColorPalette.ts +103 -20
- package/src/composables/useLocale.ts +6 -0
- package/src/composables/useTheme.ts +4 -12
- package/src/index.ts +8 -1
- package/src/locales/de.ts +3 -0
- package/src/locales/es.ts +3 -0
- package/src/locales/fr.ts +3 -0
- package/src/locales/ja.ts +3 -0
- package/src/locales/ko.ts +3 -0
- package/src/locales/pt.ts +3 -0
- package/src/locales/zh.ts +3 -0
- package/src/plugin.ts +9 -1
- package/src/styles/palettes-contrast.css +7764 -0
- package/src/styles/theme.css +46 -2
- package/dist/MTextField-DKtgPymd.js.map +0 -1
- package/dist/useLocale-Cn9MVIdw.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { readonly, ref, watchEffect } from 'vue'
|
|
1
|
+
import { computed, readonly, ref, watch, watchEffect } from 'vue'
|
|
2
2
|
import { generateScheme, schemeToCss, type SeedOptions } from './dynamicColor'
|
|
3
|
+
import { themeTransition } from './_themeTransition'
|
|
3
4
|
|
|
4
5
|
export interface Palette {
|
|
5
6
|
id: string
|
|
@@ -66,13 +67,14 @@ export interface ActiveSeed extends SeedOptions {
|
|
|
66
67
|
|
|
67
68
|
const PALETTE_KEY = 'm3-palette'
|
|
68
69
|
const SEED_KEY = 'm3-seed'
|
|
70
|
+
const CONTRAST_KEY = 'm3-contrast'
|
|
69
71
|
// The generated CSS of the active palette, so a reload applies it before the generator has loaded
|
|
70
72
|
const CSS_KEY = 'm3-palette-css'
|
|
71
73
|
|
|
72
74
|
function read<T>(key: string): T | null {
|
|
73
75
|
try {
|
|
74
76
|
const v = localStorage.getItem(key)
|
|
75
|
-
return v == null ? null : (key === PALETTE_KEY ? v : JSON.parse(v)) as T
|
|
77
|
+
return v == null ? null : (key === PALETTE_KEY || key === CONTRAST_KEY ? v : JSON.parse(v)) as T
|
|
76
78
|
} catch {
|
|
77
79
|
return null
|
|
78
80
|
}
|
|
@@ -87,6 +89,37 @@ function write(key: string, value: unknown) {
|
|
|
87
89
|
const current = ref(read<string>(PALETTE_KEY) ?? 'purple')
|
|
88
90
|
const activeSeed = ref<ActiveSeed | null>(read<ActiveSeed>(SEED_KEY))
|
|
89
91
|
|
|
92
|
+
// ── Contrast ─────────────────────────────────────────────────────────────────────────────────────
|
|
93
|
+
/**
|
|
94
|
+
* M3's contrast levels. `system` follows the OS (`prefers-contrast: more` → high). Built-in palettes need
|
|
95
|
+
* `@m3ui-vue/m3ui-vue/palettes-contrast` imported for medium and high; seed palettes are regenerated.
|
|
96
|
+
*/
|
|
97
|
+
export type ContrastLevel = 'standard' | 'medium' | 'high' | 'system'
|
|
98
|
+
const CONTRAST_LEVELS: readonly ContrastLevel[] = ['standard', 'medium', 'high', 'system']
|
|
99
|
+
const storedContrast = read<string>(CONTRAST_KEY)
|
|
100
|
+
const contrast = ref<ContrastLevel>(CONTRAST_LEVELS.includes(storedContrast as ContrastLevel) ? storedContrast as ContrastLevel : 'standard')
|
|
101
|
+
const systemMore = ref(false)
|
|
102
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
103
|
+
const mq = window.matchMedia('(prefers-contrast: more)')
|
|
104
|
+
systemMore.value = mq.matches
|
|
105
|
+
mq.addEventListener?.('change', (e) => { systemMore.value = e.matches })
|
|
106
|
+
}
|
|
107
|
+
/** The level in effect: `system` resolved to standard or high. */
|
|
108
|
+
const activeContrast = computed<Exclude<ContrastLevel, 'system'>>(() =>
|
|
109
|
+
contrast.value === 'system' ? (systemMore.value ? 'high' : 'standard') : contrast.value)
|
|
110
|
+
const CONTRAST_AMOUNT = { standard: 0, medium: 0.5, high: 1 } as const
|
|
111
|
+
|
|
112
|
+
/** A seed's options with the active contrast level applied (standard keeps the seed's own `contrast`). */
|
|
113
|
+
function withContrast(seed: ActiveSeed): ActiveSeed {
|
|
114
|
+
return activeContrast.value === 'standard' ? seed : { ...seed, contrast: CONTRAST_AMOUNT[activeContrast.value] }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function applyContrast(level: Exclude<ContrastLevel, 'system'>) {
|
|
118
|
+
if (typeof document === 'undefined') return
|
|
119
|
+
if (level === 'standard') document.documentElement.removeAttribute('data-contrast')
|
|
120
|
+
else document.documentElement.setAttribute('data-contrast', level)
|
|
121
|
+
}
|
|
122
|
+
|
|
90
123
|
// Whether palette changes are written to localStorage. Defaults to true (existing behavior).
|
|
91
124
|
// An app can disable it via `createM3UI({ persistPalette: false })` or `useColorPalette().setPersistPalette(false)`
|
|
92
125
|
// so its chosen palette can't be overridden by a stored value on the next boot.
|
|
@@ -136,25 +169,30 @@ function hasPaletteCss(id: string): boolean {
|
|
|
136
169
|
|
|
137
170
|
let generation = 0
|
|
138
171
|
|
|
139
|
-
/** Generates
|
|
140
|
-
async function
|
|
172
|
+
/** Generates the CSS for a palette id from a seed. Resolves null if a newer request won. */
|
|
173
|
+
async function generateCss(id: string, seed: ActiveSeed): Promise<string | null> {
|
|
141
174
|
const mine = ++generation
|
|
142
|
-
const
|
|
143
|
-
|
|
175
|
+
const options = withContrast(seed)
|
|
176
|
+
const css = schemeToCss(await generateScheme(options.seed, options), id)
|
|
177
|
+
return mine === generation ? css : null
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Puts a generated palette's CSS in the page and caches it for the next load. */
|
|
181
|
+
function applyCss(id: string, css: string) {
|
|
144
182
|
injectCss(css)
|
|
145
183
|
if (persistEnabled.value) write(CSS_KEY, { id, css })
|
|
146
|
-
return true
|
|
147
184
|
}
|
|
148
185
|
|
|
149
|
-
/** Switches to a palette id with the theme transition
|
|
150
|
-
* watcher, so it also works when no component uses the composable
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
void document.documentElement.offsetHeight
|
|
154
|
-
current.value = id
|
|
155
|
-
applyAttribute(id)
|
|
186
|
+
/** Switches to a palette id with the theme transition, injecting its generated CSS (if any) inside it. Applied
|
|
187
|
+
* directly, not only through useColorPalette()'s watcher, so it also works when no component uses the composable
|
|
188
|
+
* (createM3UI's defaults). */
|
|
189
|
+
function switchTo(id: string, css?: string) {
|
|
156
190
|
if (persistEnabled.value) write(PALETTE_KEY, id)
|
|
157
|
-
|
|
191
|
+
themeTransition(() => {
|
|
192
|
+
if (css) applyCss(id, css)
|
|
193
|
+
current.value = id
|
|
194
|
+
applyAttribute(id)
|
|
195
|
+
})
|
|
158
196
|
}
|
|
159
197
|
|
|
160
198
|
/** Picks a palette by id; a custom one with a seed and no CSS of its own is generated first. */
|
|
@@ -162,20 +200,46 @@ async function selectPalette(id: string) {
|
|
|
162
200
|
generation++
|
|
163
201
|
const custom = palettes.find((p) => p.id === id)
|
|
164
202
|
if (custom && !builtInIds.has(id) && custom.seed && !hasPaletteCss(id)) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
203
|
+
const css = await generateCss(id, { seed: custom.seed })
|
|
204
|
+
if (css === null) return
|
|
205
|
+
switchTo(id, css)
|
|
206
|
+
} else switchTo(id)
|
|
168
207
|
}
|
|
169
208
|
|
|
170
209
|
/** Activates a seed color: generates its scheme and switches to it. */
|
|
171
210
|
async function selectSeed(seed: string, options: SeedOptions = {}) {
|
|
172
211
|
const next: ActiveSeed = { seed, ...options }
|
|
173
|
-
|
|
212
|
+
const css = await generateCss(SEED_PALETTE, next)
|
|
213
|
+
if (css === null) return
|
|
174
214
|
activeSeed.value = next
|
|
175
215
|
if (persistEnabled.value) write(SEED_KEY, next)
|
|
176
|
-
switchTo(SEED_PALETTE)
|
|
216
|
+
switchTo(SEED_PALETTE, css)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Sets the contrast level, with the theme transition; a generated palette (seed, custom) is regenerated. */
|
|
220
|
+
async function selectContrast(level: ContrastLevel, persist = persistEnabled.value) {
|
|
221
|
+
contrast.value = level
|
|
222
|
+
if (persist) write(CONTRAST_KEY, level)
|
|
177
223
|
}
|
|
178
224
|
|
|
225
|
+
// Applied on every change of the effective level (a setting or the OS preference), for every palette kind. A
|
|
226
|
+
// generated palette is regenerated first, then swapped in with the attribute in one transition.
|
|
227
|
+
watch(activeContrast, async () => {
|
|
228
|
+
const id = current.value
|
|
229
|
+
let css: string | null | undefined
|
|
230
|
+
if (id === SEED_PALETTE && activeSeed.value) css = await generateCss(SEED_PALETTE, activeSeed.value)
|
|
231
|
+
else {
|
|
232
|
+
const custom = palettes.find((p) => p.id === id)
|
|
233
|
+
if (custom && !builtInIds.has(id) && custom.seed && !hasPaletteCss(id)) css = await generateCss(id, { seed: custom.seed })
|
|
234
|
+
}
|
|
235
|
+
// A newer request (a palette, a seed, another level) superseded the generation: it generates at the active
|
|
236
|
+
// level itself, but the attribute still has to follow
|
|
237
|
+
themeTransition(() => {
|
|
238
|
+
applyContrast(activeContrast.value)
|
|
239
|
+
if (css) applyCss(id, css)
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
|
|
179
243
|
export function useColorPalette() {
|
|
180
244
|
watchEffect(() => {
|
|
181
245
|
const id = current.value
|
|
@@ -202,12 +266,24 @@ export function useColorPalette() {
|
|
|
202
266
|
if (enabled) write(PALETTE_KEY, current.value)
|
|
203
267
|
}
|
|
204
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Sets M3's contrast level: `standard`, `medium`, `high`, or `system` (follows `prefers-contrast`). Built-in
|
|
271
|
+
* palettes need `@m3ui-vue/m3ui-vue/palettes-contrast` imported; a seed palette is regenerated at that level.
|
|
272
|
+
* Remembered like the palette.
|
|
273
|
+
*/
|
|
274
|
+
function setContrast(level: ContrastLevel) {
|
|
275
|
+
void selectContrast(level)
|
|
276
|
+
}
|
|
277
|
+
|
|
205
278
|
return {
|
|
206
279
|
palette: current,
|
|
207
280
|
palettes,
|
|
208
281
|
set,
|
|
209
282
|
seed: readonly(activeSeed),
|
|
210
283
|
setSeed,
|
|
284
|
+
contrast: readonly(contrast),
|
|
285
|
+
activeContrast,
|
|
286
|
+
setContrast,
|
|
211
287
|
persistPalette: persistEnabled,
|
|
212
288
|
setPersistPalette,
|
|
213
289
|
}
|
|
@@ -219,6 +295,7 @@ export function useColorPalette() {
|
|
|
219
295
|
const cached = read<{ id: string; css: string }>(CSS_KEY)
|
|
220
296
|
if (saved && cached && cached.id === saved) injectCss(cached.css)
|
|
221
297
|
if (saved && saved !== 'purple') document.documentElement.setAttribute('data-palette', saved)
|
|
298
|
+
applyContrast(activeContrast.value)
|
|
222
299
|
}
|
|
223
300
|
|
|
224
301
|
/**
|
|
@@ -251,3 +328,9 @@ export function __defaultSeed(seed: string, options: SeedOptions | undefined, pe
|
|
|
251
328
|
persistEnabled.value = persist
|
|
252
329
|
return selectSeed(seed, options)
|
|
253
330
|
}
|
|
331
|
+
|
|
332
|
+
/** Internal: `createM3UI({ contrast })`, the first-visit default (or forced with `persistPalette: false`). */
|
|
333
|
+
export function __defaultContrast(level: ContrastLevel, persist: boolean) {
|
|
334
|
+
if (persist && read<string>(CONTRAST_KEY)) return
|
|
335
|
+
void selectContrast(level, persist)
|
|
336
|
+
}
|
|
@@ -45,6 +45,9 @@ export interface M3Locale {
|
|
|
45
45
|
timeToggleKeyboard: string
|
|
46
46
|
timeToggleDial: string
|
|
47
47
|
timeToggleScroll: string
|
|
48
|
+
sheetExpand: string
|
|
49
|
+
sheetCollapse: string
|
|
50
|
+
sheetDismiss: string
|
|
48
51
|
selectRange: string
|
|
49
52
|
pickStart: string
|
|
50
53
|
pickEnd: string
|
|
@@ -224,6 +227,9 @@ export const defaultLocale: M3Locale = {
|
|
|
224
227
|
timeToggleKeyboard: 'Switch to text input mode',
|
|
225
228
|
timeToggleDial: 'Switch to clock mode',
|
|
226
229
|
timeToggleScroll: 'Switch to scroll mode',
|
|
230
|
+
sheetExpand: 'Expand bottom sheet',
|
|
231
|
+
sheetCollapse: 'Collapse bottom sheet',
|
|
232
|
+
sheetDismiss: 'Dismiss bottom sheet',
|
|
227
233
|
selectRange: 'Select range',
|
|
228
234
|
pickStart: 'Select start',
|
|
229
235
|
pickEnd: 'Select end',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ref, watchEffect, onMounted, onUnmounted } from 'vue'
|
|
2
|
+
import { themeTransition } from './_themeTransition'
|
|
2
3
|
|
|
3
4
|
export type Theme = 'light' | 'dark' | 'system'
|
|
4
5
|
|
|
@@ -11,18 +12,9 @@ function applyTheme(t: Theme) {
|
|
|
11
12
|
const isDark = t === 'dark' || (t === 'system' && prefersDark)
|
|
12
13
|
|
|
13
14
|
const isChange = _appliedDark !== null && _appliedDark !== isDark
|
|
14
|
-
|
|
15
|
-
if (isChange)
|
|
16
|
-
|
|
17
|
-
document.documentElement.classList.add('theme-transitioning')
|
|
18
|
-
void document.documentElement.offsetHeight
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
document.documentElement.classList.toggle('dark', isDark)
|
|
22
|
-
|
|
23
|
-
if (isChange) {
|
|
24
|
-
setTimeout(() => document.documentElement.classList.remove('theme-transitioning'), 300)
|
|
25
|
-
}
|
|
15
|
+
const apply = () => document.documentElement.classList.toggle('dark', isDark)
|
|
16
|
+
if (isChange) themeTransition(apply)
|
|
17
|
+
else apply()
|
|
26
18
|
|
|
27
19
|
_appliedDark = isDark
|
|
28
20
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { M3UIOptions } from './plugin'
|
|
|
6
6
|
export { useTheme } from './composables/useTheme'
|
|
7
7
|
export type { Theme } from './composables/useTheme'
|
|
8
8
|
export { useColorPalette, palettes } from './composables/useColorPalette'
|
|
9
|
-
export type { Palette, ActiveSeed } from './composables/useColorPalette'
|
|
9
|
+
export type { Palette, ActiveSeed, ContrastLevel } from './composables/useColorPalette'
|
|
10
10
|
export { SEED_PALETTE } from './composables/useColorPalette'
|
|
11
11
|
export { generateScheme, schemeToCss, schemeRoles } from './composables/dynamicColor'
|
|
12
12
|
export type { SchemeVariant, SeedOptions, GeneratedScheme } from './composables/dynamicColor'
|
|
@@ -22,6 +22,9 @@ export { useNotification } from './composables/useNotification'
|
|
|
22
22
|
export type { Notification, NotificationVariant, NotificationPosition, NotificationOptions } from './composables/useNotification'
|
|
23
23
|
export { useDebounce } from './composables/useDebounce'
|
|
24
24
|
export { usePageProgress } from './composables/usePageProgress'
|
|
25
|
+
export { useSpring } from './composables/_useSpring'
|
|
26
|
+
export { motionSprings, motionEasings, motionDurations, cubicBezier } from './composables/motion'
|
|
27
|
+
export type { SpringSpec } from './composables/motion'
|
|
25
28
|
|
|
26
29
|
// Directives
|
|
27
30
|
export { vRipple } from './directives/vRipple'
|
|
@@ -32,12 +35,16 @@ export { default as MAbsolute } from './components/MAbsolute.vue'
|
|
|
32
35
|
export { default as MAlert } from './components/MAlert.vue'
|
|
33
36
|
export { default as MAutocomplete } from './components/MAutocomplete.vue'
|
|
34
37
|
export { default as MAppBar } from './components/MAppBar.vue'
|
|
38
|
+
export { default as MAppBarWithSearch } from './components/MAppBarWithSearch.vue'
|
|
39
|
+
export { default as MBottomAppBar } from './components/MBottomAppBar.vue'
|
|
35
40
|
export { default as MAppLayout } from './components/MAppLayout.vue'
|
|
36
41
|
export { default as MAspectRatio } from './components/MAspectRatio.vue'
|
|
37
42
|
export { default as MAvatar } from './components/MAvatar.vue'
|
|
38
43
|
export { default as MBadge } from './components/MBadge.vue'
|
|
39
44
|
export { default as MBar } from './components/MBar.vue'
|
|
40
45
|
export { default as MBottomSheet } from './components/MBottomSheet.vue'
|
|
46
|
+
export { default as MBottomSheetScaffold } from './components/MBottomSheetScaffold.vue'
|
|
47
|
+
export type { BottomSheetValue } from './components/MBottomSheetScaffold.vue'
|
|
41
48
|
export { default as MBox } from './components/MBox.vue'
|
|
42
49
|
export { default as MBreadcrumbs } from './components/MBreadcrumbs.vue'
|
|
43
50
|
export { default as MButton } from './components/MButton.vue'
|
package/src/locales/de.ts
CHANGED
|
@@ -44,6 +44,9 @@ export const deLocale: M3Locale = {
|
|
|
44
44
|
timeToggleKeyboard: 'Zur Texteingabe wechseln',
|
|
45
45
|
timeToggleDial: 'Zum Uhrmodus wechseln',
|
|
46
46
|
timeToggleScroll: 'Zum Scrollmodus wechseln',
|
|
47
|
+
sheetExpand: 'Ansicht am unteren Rand maximieren',
|
|
48
|
+
sheetCollapse: 'Ansicht am unteren Rand minimieren',
|
|
49
|
+
sheetDismiss: 'Ansicht am unteren Rand schließen',
|
|
47
50
|
selectRange: 'Bereich auswählen',
|
|
48
51
|
pickStart: 'Anfang auswählen',
|
|
49
52
|
pickEnd: 'Ende auswählen',
|
package/src/locales/es.ts
CHANGED
|
@@ -44,6 +44,9 @@ export const esLocale: M3Locale = {
|
|
|
44
44
|
timeToggleKeyboard: 'Cambiar a entrada de texto',
|
|
45
45
|
timeToggleDial: 'Cambiar a modo reloj',
|
|
46
46
|
timeToggleScroll: 'Cambiar a modo desplazamiento',
|
|
47
|
+
sheetExpand: 'Expandir hoja inferior',
|
|
48
|
+
sheetCollapse: 'Contraer hoja inferior',
|
|
49
|
+
sheetDismiss: 'Cerrar hoja inferior',
|
|
47
50
|
selectRange: 'Seleccionar rango',
|
|
48
51
|
pickStart: 'Seleccionar inicio',
|
|
49
52
|
pickEnd: 'Seleccionar fin',
|
package/src/locales/fr.ts
CHANGED
|
@@ -44,6 +44,9 @@ export const frLocale: M3Locale = {
|
|
|
44
44
|
timeToggleKeyboard: 'Passer à la saisie de texte',
|
|
45
45
|
timeToggleDial: 'Passer au mode horloge',
|
|
46
46
|
timeToggleScroll: 'Passer au mode défilement',
|
|
47
|
+
sheetExpand: 'Développer la feuille inférieure',
|
|
48
|
+
sheetCollapse: 'Réduire la feuille inférieure',
|
|
49
|
+
sheetDismiss: 'Fermer la feuille inférieure',
|
|
47
50
|
selectRange: 'Sélectionner la plage',
|
|
48
51
|
pickStart: 'Sélectionner le début',
|
|
49
52
|
pickEnd: 'Sélectionner la fin',
|
package/src/locales/ja.ts
CHANGED
|
@@ -44,6 +44,9 @@ export const jaLocale: M3Locale = {
|
|
|
44
44
|
timeToggleKeyboard: 'テキスト入力モードに切り替え',
|
|
45
45
|
timeToggleDial: '時計モードに切り替え',
|
|
46
46
|
timeToggleScroll: 'スクロールモードに切り替え',
|
|
47
|
+
sheetExpand: 'ボトムシートを開く',
|
|
48
|
+
sheetCollapse: 'ボトムシートを折りたたむ',
|
|
49
|
+
sheetDismiss: 'ボトムシートを閉じる',
|
|
47
50
|
selectRange: '範囲を選択',
|
|
48
51
|
pickStart: '開始を選択',
|
|
49
52
|
pickEnd: '終了を選択',
|
package/src/locales/ko.ts
CHANGED
|
@@ -44,6 +44,9 @@ export const koLocale: M3Locale = {
|
|
|
44
44
|
timeToggleKeyboard: '텍스트 입력 모드로 전환',
|
|
45
45
|
timeToggleDial: '시계 모드로 전환',
|
|
46
46
|
timeToggleScroll: '스크롤 모드로 전환',
|
|
47
|
+
sheetExpand: '하단 시트 펼치기',
|
|
48
|
+
sheetCollapse: '하단 시트 접기',
|
|
49
|
+
sheetDismiss: '하단 시트 닫기',
|
|
47
50
|
selectRange: '범위 선택',
|
|
48
51
|
pickStart: '시작 선택',
|
|
49
52
|
pickEnd: '종료 선택',
|
package/src/locales/pt.ts
CHANGED
|
@@ -44,6 +44,9 @@ export const ptLocale: M3Locale = {
|
|
|
44
44
|
timeToggleKeyboard: 'Mudar para entrada de texto',
|
|
45
45
|
timeToggleDial: 'Mudar para o modo relógio',
|
|
46
46
|
timeToggleScroll: 'Mudar para o modo de rolagem',
|
|
47
|
+
sheetExpand: 'Expandir página inferior',
|
|
48
|
+
sheetCollapse: 'Recolher página inferior',
|
|
49
|
+
sheetDismiss: 'Dispensar página inferior',
|
|
47
50
|
selectRange: 'Selecionar intervalo',
|
|
48
51
|
pickStart: 'Selecionar início',
|
|
49
52
|
pickEnd: 'Selecionar fim',
|
package/src/locales/zh.ts
CHANGED
|
@@ -44,6 +44,9 @@ export const zhLocale: M3Locale = {
|
|
|
44
44
|
timeToggleKeyboard: '切换到文本输入模式',
|
|
45
45
|
timeToggleDial: '切换到时钟模式',
|
|
46
46
|
timeToggleScroll: '切换到滚动模式',
|
|
47
|
+
sheetExpand: '展开底部动作条',
|
|
48
|
+
sheetCollapse: '收起底部动作条',
|
|
49
|
+
sheetDismiss: '关闭底部动作条',
|
|
47
50
|
selectRange: '选择范围',
|
|
48
51
|
pickStart: '选择开始',
|
|
49
52
|
pickEnd: '选择结束',
|
package/src/plugin.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { App, MaybeRef } from 'vue'
|
|
2
2
|
import type { Palette } from './composables/useColorPalette'
|
|
3
|
-
import { __defaultPalette, __defaultSeed, __forcePalette, palettes } from './composables/useColorPalette'
|
|
3
|
+
import { __defaultContrast, __defaultPalette, __defaultSeed, __forcePalette, palettes } from './composables/useColorPalette'
|
|
4
|
+
import type { ContrastLevel } from './composables/useColorPalette'
|
|
4
5
|
import type { SeedOptions } from './composables/dynamicColor'
|
|
5
6
|
import { syncThemeColor } from './composables/_themeColor'
|
|
6
7
|
import type { M3Locale } from './composables/useLocale'
|
|
@@ -33,6 +34,12 @@ export interface M3UIOptions {
|
|
|
33
34
|
seed?: string
|
|
34
35
|
/** How `seed` becomes a scheme: `variant` (`'tonal-spot'` by default) and `contrast` (0 standard, 0.5 medium, 1 high). */
|
|
35
36
|
seedOptions?: SeedOptions
|
|
37
|
+
/**
|
|
38
|
+
* M3's contrast level: `'standard'`, `'medium'`, `'high'`, or `'system'` (follows the OS's `prefers-contrast`).
|
|
39
|
+
* Like `palette`, only the first-visit default unless `persistPalette` is `false`. Built-in palettes need
|
|
40
|
+
* `@m3ui-vue/m3ui-vue/palettes-contrast` imported for medium and high; seed palettes are regenerated.
|
|
41
|
+
*/
|
|
42
|
+
contrast?: ContrastLevel
|
|
36
43
|
locale?: MaybeRef<Partial<M3Locale>>
|
|
37
44
|
/**
|
|
38
45
|
* Keep `<meta name="theme-color">` (the color phones give the browser bar and status bar) in sync with a color
|
|
@@ -64,6 +71,7 @@ export function createM3UI(options: M3UIOptions = {}) {
|
|
|
64
71
|
if (options.palette && options.palette !== 'purple') __defaultPalette(options.palette)
|
|
65
72
|
else if (!options.palette && options.seed) void __defaultSeed(options.seed, options.seedOptions, true)
|
|
66
73
|
}
|
|
74
|
+
if (options.contrast) __defaultContrast(options.contrast, options.persistPalette !== false)
|
|
67
75
|
if (options.themeColor) syncThemeColor(options.themeColor)
|
|
68
76
|
if (options.locale) {
|
|
69
77
|
app.provide(M3_LOCALE_KEY, options.locale)
|