@m3ui-vue/m3ui-vue 1.2.0 → 1.2.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 +152 -11
- package/dist/{MMenuItem-DI351kIf.js → MMenuItem-D4Gx_l3F.js} +2 -2
- package/dist/{MMenuItem-DI351kIf.js.map → MMenuItem-D4Gx_l3F.js.map} +1 -1
- package/dist/{MSlider-BnEy5ieZ.js → MSlider-Dx_S3vJ9.js} +227 -221
- package/dist/{MSlider-BnEy5ieZ.js.map → MSlider-Dx_S3vJ9.js.map} +1 -1
- package/dist/{MTextField-BBmkaIbO.js → MTextField-Bz8JIsnl.js} +4 -4
- package/dist/{MTextField-BBmkaIbO.js.map → MTextField-Bz8JIsnl.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/chart.js +1 -1
- package/dist/components/MMap.vue.d.ts +1 -1
- package/dist/components/MSlider.vue.d.ts +2 -2
- package/dist/composables/_effectCanvas.d.ts +23 -0
- package/dist/composables/_storageKeys.d.ts +9 -0
- package/dist/composables/themeInitScript.d.ts +2 -0
- package/dist/composables/useConfetti.d.ts +19 -8
- package/dist/composables/useFireworks.d.ts +37 -0
- package/dist/composables/useReactions.d.ts +32 -0
- package/dist/composables/viewportHints.d.ts +2 -0
- package/dist/directives/vSparkle.d.ts +27 -0
- package/dist/index.d.ts +7 -1
- package/dist/m3ui.js +5404 -5023
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +572 -572
- package/dist/map.js.map +1 -1
- package/dist/plugin.d.ts +10 -0
- package/dist/rich-text-editor.js +2 -2
- package/dist/{useThemeTokens-Bv-Uv8eX.js → useThemeTokens-y0HZpyhL.js} +23 -8
- package/dist/useThemeTokens-y0HZpyhL.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MSegmentedButton.test.ts +10 -0
- package/src/__tests__/MSlider.test.ts +36 -0
- package/src/__tests__/plugin.test.ts +56 -1
- package/src/__tests__/ssr.test.ts +1 -1
- package/src/__tests__/themeInitScript.test.ts +10 -0
- package/src/__tests__/useConfetti.test.ts +33 -2
- package/src/__tests__/useFireworks.test.ts +104 -0
- package/src/__tests__/useReactions.test.ts +51 -0
- package/src/__tests__/vSparkle.test.ts +83 -0
- package/src/components/MEmojiSelector.vue +3 -2
- package/src/components/MMap.vue +3 -2
- package/src/components/MSegmentedButton.vue +1 -1
- package/src/components/MSlider.vue +22 -4
- package/src/components/MTextField.vue +8 -4
- package/src/composables/_colorUtils.ts +4 -2
- package/src/composables/_effectCanvas.ts +109 -0
- package/src/composables/_ssrState.ts +2 -2
- package/src/composables/_storageKeys.ts +28 -0
- package/src/composables/themeInitScript.ts +5 -2
- package/src/composables/useColorPalette.ts +36 -8
- package/src/composables/useConfetti.ts +84 -107
- package/src/composables/useFireworks.ts +360 -0
- package/src/composables/useReactions.ts +131 -0
- package/src/composables/useTheme.ts +21 -4
- package/src/composables/viewportHints.ts +6 -5
- package/src/directives/vSparkle.ts +180 -0
- package/src/index.ts +7 -1
- package/src/plugin.ts +21 -5
- package/dist/useThemeTokens-Bv-Uv8eX.js.map +0 -1
package/dist/chart.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./useThemeTokens-
|
|
1
|
+
import { t as e } from "./useThemeTokens-y0HZpyhL.js";
|
|
2
2
|
import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, defineComponent as a, normalizeStyle as o, onMounted as s, openBlock as c, ref as l, resolveDynamicComponent as u, shallowRef as d, watch as f } from "vue";
|
|
3
3
|
//#endregion
|
|
4
4
|
//#region src/components/MChart.vue
|
|
@@ -29,7 +29,7 @@ type __VLS_Props = {
|
|
|
29
29
|
pitch?: number;
|
|
30
30
|
/**
|
|
31
31
|
* Remember the view (center, zoom, bearing, pitch) in localStorage and start from it on the next visit: `true`
|
|
32
|
-
* under `m3-map-view`, or your own key (one per map)
|
|
32
|
+
* under `m3-map-view` (after `createM3UI`'s `storagePrefix`, if any), or your own key (one per map)
|
|
33
33
|
*/
|
|
34
34
|
persist?: boolean | string;
|
|
35
35
|
/** Zoom and compass buttons: `false`, or a corner (`true` is top-right) */
|
|
@@ -5,7 +5,7 @@ type __VLS_Props = {
|
|
|
5
5
|
min?: number;
|
|
6
6
|
/** Maximum value */
|
|
7
7
|
max?: number;
|
|
8
|
-
/** Step increment */
|
|
8
|
+
/** Step increment: the values emitted snap to it; while dragging (without stops) the thumb still follows the pointer smoothly and settles on its step when released */
|
|
9
9
|
step?: number;
|
|
10
10
|
/** Disables the slider */
|
|
11
11
|
disabled?: boolean;
|
|
@@ -21,7 +21,7 @@ type __VLS_Props = {
|
|
|
21
21
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
22
22
|
/** Standard, centered (from middle), or range (two thumbs) */
|
|
23
23
|
variant?: 'standard' | 'centered' | 'range';
|
|
24
|
-
/** Show stop dots at each step (max 30 visible) */
|
|
24
|
+
/** Show stop dots at each step (max 30 visible), and make a dragged thumb snap from step to step instead of following the pointer smoothly (a discrete slider) */
|
|
25
25
|
stops?: boolean;
|
|
26
26
|
/** Material Symbol icon shown before the slider — hides once the fill reaches it */
|
|
27
27
|
icon?: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface EffectLayer {
|
|
2
|
+
/** Advances and draws one frame (`dt` in seconds, `dpr` the canvas' pixel ratio); false once it has nothing left. */
|
|
3
|
+
step(ctx: CanvasRenderingContext2D, dt: number, dpr: number, now: number): boolean;
|
|
4
|
+
}
|
|
5
|
+
/** Makes sure a layer is drawn (it stays until its `step` returns false). False when there's no 2D canvas. */
|
|
6
|
+
export declare function runLayer(layer: EffectLayer): boolean;
|
|
7
|
+
/** Stops every effect and removes the canvas. Internal, for tests. */
|
|
8
|
+
export declare function __resetEffectCanvas(): void;
|
|
9
|
+
/** The theme's colors for effects, read at an element (so an MScheme around it gives its scheme's). */
|
|
10
|
+
export declare function themeColors(el: Element, roles: string[]): string[];
|
|
11
|
+
/** Whether the system asks for reduced motion. */
|
|
12
|
+
export declare function reducedMotion(): boolean;
|
|
13
|
+
/** Where an effect starts: the pointer of an event, an element's center, or a point in viewport pixels */
|
|
14
|
+
export type EffectOrigin = MouseEvent | PointerEvent | Element | {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
};
|
|
18
|
+
/** The point an effect starts from (viewport px) and the element whose theme colors it takes. */
|
|
19
|
+
export declare function originPoint(origin: EffectOrigin | undefined): {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
el: Element;
|
|
23
|
+
};
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export declare const THEME_KEY = "m3-theme";
|
|
2
2
|
export declare const STYLE_ID = "m3-dynamic-palette";
|
|
3
3
|
export declare const VIEWPORT_KEY = "m3-viewport";
|
|
4
|
+
/** The name a key is stored under: the base key with the app's prefix, if any. */
|
|
5
|
+
export declare function storageKey(base: string, storagePrefix?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Sets the prefix and has every module that read its stored state on load (theme, palette, recent colors…) read
|
|
8
|
+
* it again under the new keys. `createM3UI` calls it before applying anything else.
|
|
9
|
+
*/
|
|
10
|
+
export declare function setStoragePrefix(next: string): void;
|
|
11
|
+
/** Registers what a module does to read its stored state again when the prefix changes. */
|
|
12
|
+
export declare function onStoragePrefix(reload: () => void): void;
|
|
@@ -6,6 +6,8 @@ export interface ThemeInitOptions {
|
|
|
6
6
|
contrast?: ContrastLevel;
|
|
7
7
|
/** `createM3UI`'s `persistPalette`. */
|
|
8
8
|
persistPalette?: boolean;
|
|
9
|
+
/** `createM3UI`'s `storagePrefix`. */
|
|
10
|
+
storagePrefix?: string;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* A script to inline in `<head>` of a server-rendered page (Nuxt, Vite SSR), so dark mode, the palette and the
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ShapeName } from 'shape-morph';
|
|
2
|
+
import { type EffectOrigin } from './_effectCanvas';
|
|
2
3
|
export interface ConfettiOptions {
|
|
3
4
|
/** How many pieces (default 80; 160 for `from: 'top'`) */
|
|
4
5
|
count?: number;
|
|
@@ -16,17 +17,27 @@ export interface ConfettiOptions {
|
|
|
16
17
|
velocity?: number;
|
|
17
18
|
/** Piece size in px (default 14) */
|
|
18
19
|
size?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Keep it going for this long, in ms: a rain that keeps falling (`from: 'top'`) or a fountain from the point,
|
|
22
|
+
* `count` then being pieces per second. `Infinity` runs until the returned `stop()`. Unset: one burst
|
|
23
|
+
*/
|
|
24
|
+
duration?: number;
|
|
19
25
|
}
|
|
26
|
+
/** Stops a running confetti before its `duration` ends; the pieces already out finish falling. */
|
|
27
|
+
export type StopConfetti = () => void;
|
|
20
28
|
/** Where a burst starts: the pointer of an event, an element's center, or a point in viewport pixels */
|
|
21
|
-
export type ConfettiOrigin =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export declare function fireConfetti(origin?: ConfettiOrigin, options?: ConfettiOptions):
|
|
27
|
-
/**
|
|
29
|
+
export type ConfettiOrigin = EffectOrigin;
|
|
30
|
+
/**
|
|
31
|
+
* Fires confetti: one burst, or with `duration` a rain or fountain that keeps going (stop it early with the returned
|
|
32
|
+
* function). Browser only; does nothing under reduced motion.
|
|
33
|
+
*/
|
|
34
|
+
export declare function fireConfetti(origin?: ConfettiOrigin, options?: ConfettiOptions): StopConfetti;
|
|
35
|
+
/**
|
|
36
|
+
* Confetti for a component: `fire(event)` from the pointer, `fire(el)` from an element, `fire({ from: 'top' })`,
|
|
37
|
+
* `fire({ from: 'top', duration: 5000 })` for a rain that lasts. Returns a function that stops it early.
|
|
38
|
+
*/
|
|
28
39
|
export declare function useConfetti(): {
|
|
29
|
-
fire: (origin?: ConfettiOrigin | ConfettiOptions, options?: ConfettiOptions) =>
|
|
40
|
+
fire: (origin?: ConfettiOrigin | ConfettiOptions, options?: ConfettiOptions) => StopConfetti;
|
|
30
41
|
};
|
|
31
42
|
/** Stops every burst and removes the canvas. Internal, for tests; not exported from index.ts. */
|
|
32
43
|
export declare function __resetConfetti(): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ShapeName } from 'shape-morph';
|
|
2
|
+
export interface FireworksOptions {
|
|
3
|
+
/** How many rockets (default 6, launched over about a second and a half); with `duration`, rockets per second */
|
|
4
|
+
count?: number;
|
|
5
|
+
/**
|
|
6
|
+
* What the bursts look like, one picked per burst: `'classic'` (sparks thrown out from the center that fall as they
|
|
7
|
+
* fade) or an MShape's name the sparks are laid out along (`'Circle'` is a ring). Default: mostly classic, with a
|
|
8
|
+
* ring, a heart, a flower… now and then
|
|
9
|
+
*/
|
|
10
|
+
shapes?: FireworkShape[];
|
|
11
|
+
/** Any CSS colors. Default: the theme's primary, secondary and tertiary roles and their containers */
|
|
12
|
+
colors?: string[];
|
|
13
|
+
/** Burst radius in px. Default: a sixth of the screen's smaller side, between 70 and 180 */
|
|
14
|
+
size?: number;
|
|
15
|
+
/** Keep launching for this long, in ms (`count` then being rockets per second); `Infinity` runs until `stop()` */
|
|
16
|
+
duration?: number;
|
|
17
|
+
}
|
|
18
|
+
/** A burst's look: `'classic'`, or an MShape's name its sparks are laid out along. */
|
|
19
|
+
export type FireworkShape = 'classic' | ShapeName;
|
|
20
|
+
/** Stops launching before `duration` ends; what's already in the air finishes. */
|
|
21
|
+
export type StopFireworks = () => void;
|
|
22
|
+
/**
|
|
23
|
+
* `n` points evenly spaced along a shape's outline, as offsets from its center scaled so the farthest is at 1
|
|
24
|
+
* (`[x0, y0, x1, y1, …]`). Exported for tests.
|
|
25
|
+
*/
|
|
26
|
+
export declare function shapeOutline(shape: ShapeName, n?: number): Float32Array;
|
|
27
|
+
/**
|
|
28
|
+
* Launches fireworks: a few rockets, or with `duration` a show that keeps going (stop it early with the returned
|
|
29
|
+
* function). Browser only; does nothing under reduced motion.
|
|
30
|
+
*/
|
|
31
|
+
export declare function launchFireworks(options?: FireworksOptions): StopFireworks;
|
|
32
|
+
/** Fireworks for a component: `launch()`, `launch({ shapes: ['classic'] })`, `launch({ shapes: ['Heart'] })`, `launch({ duration: 10000 })`. */
|
|
33
|
+
export declare function useFireworks(): {
|
|
34
|
+
launch: typeof launchFireworks;
|
|
35
|
+
};
|
|
36
|
+
/** Stops every firework and removes the canvas. Internal, for tests; not exported from index.ts. */
|
|
37
|
+
export declare function __resetFireworks(): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type EffectOrigin } from './_effectCanvas';
|
|
2
|
+
/** What floats up: any text (an emoji, `'+1'`), or a Material Symbol (`{ icon: 'favorite' }`, filled by default). */
|
|
3
|
+
export type ReactionContent = string | {
|
|
4
|
+
icon: string;
|
|
5
|
+
filled?: boolean;
|
|
6
|
+
color?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface ReactionOptions {
|
|
9
|
+
/** How many float up together, a little apart (default 1) */
|
|
10
|
+
count?: number;
|
|
11
|
+
/** Size in px (default 32) */
|
|
12
|
+
size?: number;
|
|
13
|
+
/** How far it rises, in px (default 260) */
|
|
14
|
+
distance?: number;
|
|
15
|
+
/** How long it floats, in ms (default 2200) */
|
|
16
|
+
duration?: number;
|
|
17
|
+
/** How far it sways to each side, in px (default 20) */
|
|
18
|
+
sway?: number;
|
|
19
|
+
}
|
|
20
|
+
/** Where a reaction starts: the pointer of an event, an element's center, or a point in viewport pixels */
|
|
21
|
+
export type ReactionOrigin = EffectOrigin;
|
|
22
|
+
/** Sends a reaction floating up from a point. Browser only. */
|
|
23
|
+
export declare function fireReaction(origin: ReactionOrigin | undefined, content: ReactionContent, options?: ReactionOptions): void;
|
|
24
|
+
/**
|
|
25
|
+
* Floating reactions for a component: `react(event, '🎉')` from the pointer, `react(el, { icon: 'favorite' })` from
|
|
26
|
+
* an element, `react(el, '👏', { count: 5 })` for a handful.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useReactions(): {
|
|
29
|
+
react: typeof fireReaction;
|
|
30
|
+
};
|
|
31
|
+
/** Removes every reaction at once. Internal, for tests; not exported from index.ts. */
|
|
32
|
+
export declare function __resetReactions(): void;
|
|
@@ -16,6 +16,7 @@ export declare const VIEWPORT_HINTS = "Sec-CH-Viewport-Width, Sec-CH-Viewport-He
|
|
|
16
16
|
* cookies: true })` keeps in the `m3-viewport` cookie (any visit after the first); the viewport client hints
|
|
17
17
|
* (Chromium, once the server asked for them with `VIEWPORT_HINTS`); or, on a first visit, a size standing for the
|
|
18
18
|
* kind of device (`Sec-CH-UA-Mobile`, then the user agent: a phone, a tablet or a desktop), unless `guess: false`.
|
|
19
|
+
* With `createM3UI({ storagePrefix })`, pass the same `storagePrefix` so the right cookie is read.
|
|
19
20
|
* Undefined when nothing tells: the layouts then render compact.
|
|
20
21
|
*
|
|
21
22
|
* ```ts
|
|
@@ -24,4 +25,5 @@ export declare const VIEWPORT_HINTS = "Sec-CH-Viewport-Width, Sec-CH-Viewport-He
|
|
|
24
25
|
*/
|
|
25
26
|
export declare function viewportFromHeaders(headers: RequestHeaders, options?: {
|
|
26
27
|
guess?: boolean;
|
|
28
|
+
storagePrefix?: string;
|
|
27
29
|
}): ViewportSize | undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Directive } from 'vue';
|
|
2
|
+
import { type ShapeName } from 'shape-morph';
|
|
3
|
+
/** Options for `v-sparkle`. */
|
|
4
|
+
export interface SparkleOptions {
|
|
5
|
+
/** No sparkles while true */
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
/** `'always'` (default) sparkles all the time; `'hover'` only while the pointer is over it or focus is in it */
|
|
8
|
+
trigger?: 'always' | 'hover';
|
|
9
|
+
/** Any CSS colors, one picked per sparkle. Default: the theme's primary and tertiary where the element is */
|
|
10
|
+
color?: string | string[];
|
|
11
|
+
/** Sparkle size in px, each one a bit bigger or smaller (default 14) */
|
|
12
|
+
size?: number;
|
|
13
|
+
/** Sparkles per second (default 3) */
|
|
14
|
+
rate?: number;
|
|
15
|
+
/** MShape's shapes instead of the four-pointed star */
|
|
16
|
+
shapes?: ShapeName[];
|
|
17
|
+
}
|
|
18
|
+
/** `v-sparkle` value: nothing or `true` (on), `false` (off), `'hover'`, a CSS color, or an options object. */
|
|
19
|
+
export type SparkleValue = boolean | string | SparkleOptions | null | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Sparkles that twinkle over an element, to draw the eye to something new or special: `v-sparkle`,
|
|
22
|
+
* `v-sparkle="'hover'"`, `v-sparkle="'#f5b400'"` or `v-sparkle="{ trigger, color, size, rate, shapes, disabled }"`.
|
|
23
|
+
* They're drawn in a layer over the element (a statically positioned one is made `position: relative`), hidden from
|
|
24
|
+
* assistive technology, and pause while it's off screen or the tab is hidden; none under reduced motion.
|
|
25
|
+
* Registered globally as `v-sparkle` by `createM3UI()`; import `vSparkle` to use it without the plugin.
|
|
26
|
+
*/
|
|
27
|
+
export declare const vSparkle: Directive<HTMLElement, SparkleValue>;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,11 @@ export { useTheme } from './composables/useTheme';
|
|
|
5
5
|
export type { Theme } from './composables/useTheme';
|
|
6
6
|
export { useColorPalette, palettes } from './composables/useColorPalette';
|
|
7
7
|
export { useConfetti, fireConfetti } from './composables/useConfetti';
|
|
8
|
-
export type { ConfettiOptions, ConfettiOrigin } from './composables/useConfetti';
|
|
8
|
+
export type { ConfettiOptions, ConfettiOrigin, StopConfetti } from './composables/useConfetti';
|
|
9
|
+
export { useFireworks, launchFireworks } from './composables/useFireworks';
|
|
10
|
+
export type { FireworkShape, FireworksOptions, StopFireworks } from './composables/useFireworks';
|
|
11
|
+
export { useReactions, fireReaction } from './composables/useReactions';
|
|
12
|
+
export type { ReactionContent, ReactionOptions, ReactionOrigin } from './composables/useReactions';
|
|
9
13
|
export { useContainerTransform } from './composables/useContainerTransform';
|
|
10
14
|
export type { ContainerTransformController, ContainerTransformOrigin } from './composables/useContainerTransform';
|
|
11
15
|
export type { Palette, PaletteId, ActiveSeed, ContrastLevel } from './composables/useColorPalette';
|
|
@@ -57,6 +61,8 @@ export { vClickOutside } from './directives/vClickOutside';
|
|
|
57
61
|
export type { ClickOutsideOptions, ClickOutsideValue } from './directives/vClickOutside';
|
|
58
62
|
export { vSkeleton } from './directives/vSkeleton';
|
|
59
63
|
export type { SkeletonOptions, SkeletonValue } from './directives/vSkeleton';
|
|
64
|
+
export { vSparkle } from './directives/vSparkle';
|
|
65
|
+
export type { SparkleOptions, SparkleValue } from './directives/vSparkle';
|
|
60
66
|
export { default as MAbsolute } from './components/MAbsolute.vue';
|
|
61
67
|
export { default as MAlert } from './components/MAlert.vue';
|
|
62
68
|
export { default as MAnimatedNumber } from './components/MAnimatedNumber.vue';
|