@m3ui-vue/m3ui-vue 1.0.1 → 1.0.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/dist/API.md +40 -14
- package/dist/api.json +1 -1
- package/dist/chart.js +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/components/MShader.vue.d.ts +9 -3
- package/dist/composables/_hydration.d.ts +4 -0
- package/dist/composables/themeInitScript.d.ts +21 -0
- package/dist/composables/useColorPalette.d.ts +4 -0
- package/dist/composables/useTheme.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +1868 -1820
- package/dist/m3ui.js.map +1 -1
- package/dist/plugin.d.ts +7 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/__tests__/MShader.test.ts +16 -0
- package/src/__tests__/hydration.test.ts +86 -0
- package/src/__tests__/ssr.test.ts +109 -0
- package/src/__tests__/themeInitScript.test.ts +104 -0
- package/src/components/MChart.vue +3 -2
- package/src/components/MLightbox.vue +6 -1
- package/src/components/MSearchBar.vue +4 -1
- package/src/components/MShader.vue +11 -3
- package/src/composables/_hydration.ts +10 -0
- package/src/composables/themeInitScript.ts +49 -0
- package/src/composables/useColorPalette.ts +10 -6
- package/src/composables/useTheme.ts +12 -6
- package/src/composables/useWindowSizeClass.ts +14 -4
- package/src/index.ts +2 -0
- package/src/plugin.ts +24 -11
package/dist/API.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @m3ui-vue/m3ui-vue 1.0.
|
|
1
|
+
# @m3ui-vue/m3ui-vue 1.0.2 — API reference
|
|
2
2
|
|
|
3
3
|
Material Design 3 components for Vue 3 + Tailwind CSS v4. Generated from the source by
|
|
4
4
|
`scripts/generate-api.mjs`; full docs with live demos at https://m3ui.dev.
|
|
@@ -169,7 +169,7 @@ Props:
|
|
|
169
169
|
- `clearable?: boolean = false` — Show a clear button
|
|
170
170
|
- `fieldBg?: string` — Overrides the auto-detected background color used to cut the floating label out of the outlined border
|
|
171
171
|
- `noResultsText?: string` — Text when no options match
|
|
172
|
-
- `debounce?: number = 0` — Delay (ms) before filtering and firing
|
|
172
|
+
- `debounce?: number = 0` — Delay (ms) before filtering and firing @debounced. Selection is always instant
|
|
173
173
|
|
|
174
174
|
Events:
|
|
175
175
|
- `update:modelValue(unknown)` — Emitted on selection — powers v-model
|
|
@@ -1496,7 +1496,7 @@ Props:
|
|
|
1496
1496
|
- `value?: string | number` — Selection value — compared against the parent MList selected prop
|
|
1497
1497
|
- `active?: boolean = false` — Force the active/highlighted state regardless of parent list selection
|
|
1498
1498
|
- `disabled?: boolean = false` — Disabled state (38% opacity, blocks interaction)
|
|
1499
|
-
- `clickable?: boolean` — Force interactive styling/behavior (auto-true when href, to,
|
|
1499
|
+
- `clickable?: boolean` — Force interactive styling/behavior (auto-true when href, to, @click, selectable, or expandable apply)
|
|
1500
1500
|
- `href?: string` — Link URL — renders the item as an `<a>`
|
|
1501
1501
|
- `to?: string | object` — Vue Router destination — renders the item as a router-link
|
|
1502
1502
|
- `expandable?: boolean = false` — Show an expand/collapse chevron revealing the #children slot
|
|
@@ -1585,7 +1585,7 @@ Props:
|
|
|
1585
1585
|
- `leadingIcon?: string` — Material Symbol icon
|
|
1586
1586
|
- `clearable?: boolean = false` — Show clear button
|
|
1587
1587
|
- `fieldBg?: string` — Overrides the auto-detected background color used to cut the floating label out of the outlined border
|
|
1588
|
-
- `debounce?: number = 0` — Delay (ms) before firing the
|
|
1588
|
+
- `debounce?: number = 0` — Delay (ms) before firing the @debounced event
|
|
1589
1589
|
|
|
1590
1590
|
Events:
|
|
1591
1591
|
- `update:modelValue(string)` — Emitted on every keystroke — powers v-model
|
|
@@ -1678,7 +1678,7 @@ Props:
|
|
|
1678
1678
|
- `maxChips?: number = 3` — Max visible chips before "+N"
|
|
1679
1679
|
- `noResultsText?: string` — Text when no options match
|
|
1680
1680
|
- `hideSelected?: boolean = false` — Remove already-selected options from the dropdown
|
|
1681
|
-
- `debounce?: number = 0` — Delay (ms) before filtering and firing
|
|
1681
|
+
- `debounce?: number = 0` — Delay (ms) before filtering and firing @debounced. Selection is always instant
|
|
1682
1682
|
|
|
1683
1683
|
Events:
|
|
1684
1684
|
- `update:modelValue(unknown[])` — Emitted on selection change — powers v-model
|
|
@@ -1881,7 +1881,7 @@ Props:
|
|
|
1881
1881
|
- `leadingIcon?: string` — Material Symbol icon
|
|
1882
1882
|
- `stepper?: boolean = true` — Show +/- buttons
|
|
1883
1883
|
- `fieldBg?: string` — Overrides the auto-detected background color used to cut the floating label out of the outlined border
|
|
1884
|
-
- `debounce?: number = 0` — Delay (ms) before firing the
|
|
1884
|
+
- `debounce?: number = 0` — Delay (ms) before firing the @debounced event
|
|
1885
1885
|
|
|
1886
1886
|
Events:
|
|
1887
1887
|
- `update:modelValue(number | null)` — Emitted on every change — typing, stepper clicks, or arrow keys — powers v-model
|
|
@@ -1976,7 +1976,7 @@ Props:
|
|
|
1976
1976
|
Wraps its own scrollable container and fires a refresh event when the user pulls past a threshold at the very top of the scroll.
|
|
1977
1977
|
|
|
1978
1978
|
Props:
|
|
1979
|
-
- `refreshing?: boolean = false` — Controlled loading state — set it to true in your
|
|
1979
|
+
- `refreshing?: boolean = false` — Controlled loading state — set it to true in your @refresh handler and back to false once the fetch resolves; the indicator settles and releases accordingly, same pattern as MInfiniteScroll's loading prop
|
|
1980
1980
|
- `disabled?: boolean = false` — Disables the pull gesture
|
|
1981
1981
|
- `threshold?: number = 64` — Pull distance in px required to trigger a refresh on release
|
|
1982
1982
|
- `size?: number = 36` — Indicator size in px
|
|
@@ -2233,7 +2233,7 @@ Slots:
|
|
|
2233
2233
|
|
|
2234
2234
|
### MSearchBar
|
|
2235
2235
|
|
|
2236
|
-
A collapsed search field that expands into a docked panel or a fullscreen overlay, with results shown below the input.
|
|
2236
|
+
A collapsed search field that expands into a docked panel or a fullscreen overlay, with results shown below the input. The expanded panel is teleported to `<body>`; `class`, `style` and other attributes you pass land on the collapsed bar. So with a fullscreen variant you can hide the bar (e.g. `class="hidden"` on phones) and open search from your own icon button through `v-model:expanded`. The docked panel is placed under the bar, so it needs the bar visible.
|
|
2237
2237
|
|
|
2238
2238
|
Props:
|
|
2239
2239
|
- `modelValue?: string = ""` (v-model) — Search query (v-model)
|
|
@@ -2334,12 +2334,12 @@ export interface SelectOption {
|
|
|
2334
2334
|
A canvas container for hand-written shaders. Give it a GLSL fragment shader (Shadertoy-style — it runs on WebGL2 and works everywhere) and, optionally, a WGSL fragment shader that runs on WebGPU when the browser supports it. `renderer="auto"` picks WebGPU whenever both a `wgsl` source and browser support are present, otherwise it falls back to WebGL2 — so the same component works as a drop-in on old and new browsers alike.
|
|
2335
2335
|
|
|
2336
2336
|
Props:
|
|
2337
|
-
- `code: string` — GLSL fragment shader body (Shadertoy-style): must define `mainImage(out vec4 fragColor, in vec2 fragCoord)`. Runs on WebGL2. Always required as the compatible baseline.
|
|
2338
|
-
- `wgsl?: string` — Optional WGSL fragment shader module, e.g. `@fragment fn fs_main(@builtin(position) pos: vec4f) ->
|
|
2337
|
+
- `code: string` — GLSL fragment shader body (Shadertoy-style): must define `mainImage(out vec4 fragColor, in vec2 fragCoord)`. Runs on WebGL2. Always required as the compatible baseline. Don't write the `#version`, the precision or any uniform: the component puts them in front of your code, with Shadertoy's `iTime` (seconds, stops while paused), `iResolution` (canvas size in device pixels), `iMouse` and `iFrame`, plus one per `uniforms` key.
|
|
2338
|
+
- `wgsl?: string` — Optional WGSL fragment shader module, e.g. `@fragment fn fs_main(@builtin(position) pos: vec4f) -> @location(0) vec4f`. Runs on WebGPU when available. Must declare its own bindings — see docs for the required uniform buffer layout.
|
|
2339
2339
|
- `renderer?: ShaderRenderer = "auto"` — Which backend to use. 'auto' picks WebGPU when `wgsl` is set and supported, else WebGL2.
|
|
2340
|
-
- `uniforms?: Record<string, number | number[]>` — Custom uniforms. Keys
|
|
2340
|
+
- `uniforms?: Record<string, number | number[]>` — Custom uniforms, read every frame. In GLSL each key is declared for you, as a `float` for a number or a `vec2`–`vec4` for an array; in WGSL they're binding 1, one `vec4f` per key in this order. Keys and shapes are fixed when the shader compiles (on mount, or when `code`/`wgsl`/`renderer` change); values can change freely, e.g. to drive the shader from your own clock instead of `iTime`.
|
|
2341
2341
|
- `paused?: boolean` — Freezes the render loop and the shader clock
|
|
2342
|
-
- `pixelRatio?: number` — Device pixel
|
|
2342
|
+
- `pixelRatio?: number` — Device pixels per CSS pixel to render at. Defaults to devicePixelRatio, capped at 2 for performance. Lower it to render fewer pixels (a "quality" setting); the canvas is resized when it changes.
|
|
2343
2343
|
|
|
2344
2344
|
Events:
|
|
2345
2345
|
- `error(message: string)` — Emitted on a shader compile/link error, or a WebGPU runtime error
|
|
@@ -2844,7 +2844,7 @@ Props:
|
|
|
2844
2844
|
- `maxTags?: number` — Max number of tags allowed
|
|
2845
2845
|
- `duplicates?: boolean = false` — Allow duplicate tags
|
|
2846
2846
|
- `clearable?: boolean = false` — Show a clear-all button
|
|
2847
|
-
- `debounce?: number = 0` — Delay (ms) before firing the
|
|
2847
|
+
- `debounce?: number = 0` — Delay (ms) before firing the @debounced event
|
|
2848
2848
|
|
|
2849
2849
|
Events:
|
|
2850
2850
|
- `update:modelValue(string[])` — Emitted whenever a tag is added or removed — powers v-model
|
|
@@ -2917,7 +2917,7 @@ Props:
|
|
|
2917
2917
|
- `leadingIcon?: string` — Material Symbol shown before the input
|
|
2918
2918
|
- `clearable?: boolean = false` — Show a clear button when the field has a value
|
|
2919
2919
|
- `fieldBg?: string` — Overrides the auto-detected background color used to cut the floating label out of the outlined border
|
|
2920
|
-
- `debounce?: number = 0` — Delay (ms) before firing the
|
|
2920
|
+
- `debounce?: number = 0` — Delay (ms) before firing the @debounced event. v-model always updates immediately
|
|
2921
2921
|
|
|
2922
2922
|
Events:
|
|
2923
2923
|
- `update:modelValue(string)` — Emitted on every keystroke — powers v-model
|
|
@@ -3350,6 +3350,14 @@ The palette id used while a seed color is active (`useColorPalette().setSeed()`)
|
|
|
3350
3350
|
SEED_PALETTE: "seed"
|
|
3351
3351
|
```
|
|
3352
3352
|
|
|
3353
|
+
### themeInitScript
|
|
3354
|
+
|
|
3355
|
+
A script to inline in `<head>` of a server-rendered page (Nuxt, Vite SSR), so dark mode, the palette and the contrast level are on `<html>` before the first paint instead of when the app's JS loads. It does what `useTheme` and `useColorPalette` do when they load in the browser (the stored choice, or the given `createM3UI` defaults), so pass it the same options as the plugin. A `seed` default can't be generated this early: its first visit still shows the baseline until the app loads (later visits use the cached CSS). ```ts useHead({ script: [{ innerHTML: themeInitScript({ palette: 'red' }) }] }) ```
|
|
3356
|
+
|
|
3357
|
+
```ts
|
|
3358
|
+
themeInitScript(options: ThemeInitOptions = {}): string
|
|
3359
|
+
```
|
|
3360
|
+
|
|
3353
3361
|
### generateScheme
|
|
3354
3362
|
|
|
3355
3363
|
Generates the light and dark schemes for a seed color (`#rrggbb`).
|
|
@@ -3616,6 +3624,13 @@ export interface M3UIOptions {
|
|
|
3616
3624
|
* mode (they keep their own dark bar); installed apps (PWA) still get it.
|
|
3617
3625
|
*/
|
|
3618
3626
|
themeColor?: 'surface' | 'surface-container' | 'primary' | (string & {})
|
|
3627
|
+
/**
|
|
3628
|
+
* Server-side rendering: tells the components whether the app is still hydrating the server's HTML (Nuxt's
|
|
3629
|
+
* `() => nuxtApp.isHydrating`, which `@m3ui-vue/nuxt` passes). The adaptive layouts (`MNavigationSuite`,
|
|
3630
|
+
* `MListDetail`, `MSupportingPane`) and `useWindowSizeClass()` then render their first frame at the server's size
|
|
3631
|
+
* (compact: it has no window) so it matches the HTML, and adapt once mounted.
|
|
3632
|
+
*/
|
|
3633
|
+
isHydrating?: () => boolean
|
|
3619
3634
|
}
|
|
3620
3635
|
```
|
|
3621
3636
|
|
|
@@ -3650,6 +3665,17 @@ export interface ActiveSeed extends SeedOptions {
|
|
|
3650
3665
|
export type ContrastLevel = 'standard' | 'medium' | 'high' | 'system'
|
|
3651
3666
|
```
|
|
3652
3667
|
|
|
3668
|
+
```ts
|
|
3669
|
+
export interface ThemeInitOptions {
|
|
3670
|
+
/** `createM3UI`'s `palette`: the first-visit default, or forced with `persistPalette: false`. */
|
|
3671
|
+
palette?: string
|
|
3672
|
+
/** `createM3UI`'s `contrast`, with the same rules as `palette`. */
|
|
3673
|
+
contrast?: ContrastLevel
|
|
3674
|
+
/** `createM3UI`'s `persistPalette`. */
|
|
3675
|
+
persistPalette?: boolean
|
|
3676
|
+
}
|
|
3677
|
+
```
|
|
3678
|
+
|
|
3653
3679
|
```ts
|
|
3654
3680
|
// Dynamic color: a full M3 color scheme (light and dark) generated from one seed color with Google's
|
|
3655
3681
|
// material-color-utilities (HCT, DynamicScheme). The package is loaded with a dynamic import, so apps that
|