@m3ui-vue/m3ui-vue 1.2.1 → 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.
Files changed (56) hide show
  1. package/dist/API.md +152 -11
  2. package/dist/{MMenuItem-DI351kIf.js → MMenuItem-D4Gx_l3F.js} +2 -2
  3. package/dist/{MMenuItem-DI351kIf.js.map → MMenuItem-D4Gx_l3F.js.map} +1 -1
  4. package/dist/{MSlider-BnEy5ieZ.js → MSlider-Dx_S3vJ9.js} +227 -221
  5. package/dist/{MSlider-BnEy5ieZ.js.map → MSlider-Dx_S3vJ9.js.map} +1 -1
  6. package/dist/{MTextField-BBmkaIbO.js → MTextField-Bz8JIsnl.js} +4 -4
  7. package/dist/{MTextField-BBmkaIbO.js.map → MTextField-Bz8JIsnl.js.map} +1 -1
  8. package/dist/api.json +1 -1
  9. package/dist/chart.js +1 -1
  10. package/dist/components/MMap.vue.d.ts +1 -1
  11. package/dist/components/MSlider.vue.d.ts +2 -2
  12. package/dist/composables/_effectCanvas.d.ts +23 -0
  13. package/dist/composables/_storageKeys.d.ts +9 -0
  14. package/dist/composables/themeInitScript.d.ts +2 -0
  15. package/dist/composables/useConfetti.d.ts +19 -8
  16. package/dist/composables/useFireworks.d.ts +37 -0
  17. package/dist/composables/useReactions.d.ts +32 -0
  18. package/dist/composables/viewportHints.d.ts +2 -0
  19. package/dist/directives/vSparkle.d.ts +27 -0
  20. package/dist/index.d.ts +7 -1
  21. package/dist/m3ui.js +5403 -5022
  22. package/dist/m3ui.js.map +1 -1
  23. package/dist/map.js +572 -572
  24. package/dist/map.js.map +1 -1
  25. package/dist/plugin.d.ts +10 -0
  26. package/dist/rich-text-editor.js +2 -2
  27. package/dist/{useThemeTokens-Bv-Uv8eX.js → useThemeTokens-y0HZpyhL.js} +23 -8
  28. package/dist/useThemeTokens-y0HZpyhL.js.map +1 -0
  29. package/package.json +1 -1
  30. package/src/__tests__/MSlider.test.ts +36 -0
  31. package/src/__tests__/plugin.test.ts +56 -1
  32. package/src/__tests__/ssr.test.ts +1 -1
  33. package/src/__tests__/themeInitScript.test.ts +10 -0
  34. package/src/__tests__/useConfetti.test.ts +33 -2
  35. package/src/__tests__/useFireworks.test.ts +104 -0
  36. package/src/__tests__/useReactions.test.ts +51 -0
  37. package/src/__tests__/vSparkle.test.ts +83 -0
  38. package/src/components/MEmojiSelector.vue +3 -2
  39. package/src/components/MMap.vue +3 -2
  40. package/src/components/MSlider.vue +22 -4
  41. package/src/components/MTextField.vue +8 -4
  42. package/src/composables/_colorUtils.ts +4 -2
  43. package/src/composables/_effectCanvas.ts +109 -0
  44. package/src/composables/_ssrState.ts +2 -2
  45. package/src/composables/_storageKeys.ts +28 -0
  46. package/src/composables/themeInitScript.ts +5 -2
  47. package/src/composables/useColorPalette.ts +36 -8
  48. package/src/composables/useConfetti.ts +84 -107
  49. package/src/composables/useFireworks.ts +360 -0
  50. package/src/composables/useReactions.ts +131 -0
  51. package/src/composables/useTheme.ts +21 -4
  52. package/src/composables/viewportHints.ts +6 -5
  53. package/src/directives/vSparkle.ts +180 -0
  54. package/src/index.ts +7 -1
  55. package/src/plugin.ts +21 -5
  56. package/dist/useThemeTokens-Bv-Uv8eX.js.map +0 -1
package/dist/API.md CHANGED
@@ -1,4 +1,4 @@
1
- # @m3ui-vue/m3ui-vue 1.2.1 — API reference
1
+ # @m3ui-vue/m3ui-vue 1.2.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.
@@ -1630,7 +1630,7 @@ Props:
1630
1630
  - `zoom?: number` (v-model:zoom) — Zoom level (v-model)
1631
1631
  - `bearing?: number` (v-model:bearing) — Rotation in degrees (v-model)
1632
1632
  - `pitch?: number` (v-model:pitch) — Tilt in degrees (v-model)
1633
- - `persist?: string | boolean = false` — Remember the view (center, zoom, bearing, pitch) in localStorage and start from it on the next visit: `true` under `m3-map-view`, or your own key (one per map)
1633
+ - `persist?: string | boolean = false` — Remember the view (center, zoom, bearing, pitch) in localStorage and start from it on the next visit: `true` under `m3-map-view` (after `createM3UI`'s `storagePrefix`, if any), or your own key (one per map)
1634
1634
  - `navigation?: boolean | MapControlPosition = true` — Zoom and compass buttons: `false`, or a corner (`true` is top-right)
1635
1635
  - `geolocate?: boolean | MapControlPosition = false` — A button that centers the map on the user's location and follows it: `false`, or a corner (`true` is top-right)
1636
1636
  - `fullscreen?: boolean | MapControlPosition = false` — A fullscreen button: `false`, or a corner (`true` is top-right)
@@ -2930,7 +2930,7 @@ Props:
2930
2930
  - `modelValue: number | [number, number]` (v-model) — Current value — a tuple when variant is range
2931
2931
  - `min?: number = 0` — Minimum value
2932
2932
  - `max?: number = 100` — Maximum value
2933
- - `step?: number = 1` — Step increment
2933
+ - `step?: number = 1` — 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
2934
2934
  - `disabled?: boolean = false` — Disables the slider
2935
2935
  - `label?: string` — Label text
2936
2936
  - `showValue?: boolean = false` — Show current value beside label
@@ -2938,7 +2938,7 @@ Props:
2938
2938
  - `orientation?: "horizontal" | "vertical" = "horizontal"` — Slider orientation
2939
2939
  - `size?: "xs" | "sm" | "md" | "lg" | "xl" = "xs"` — Track and thumb size
2940
2940
  - `variant?: "standard" | "centered" | "range" = "standard"` — Standard, centered (from middle), or range (two thumbs)
2941
- - `stops?: boolean = false` — Show stop dots at each step (max 30 visible)
2941
+ - `stops?: boolean = false` — 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)
2942
2942
  - `icon?: string` — Material Symbol icon shown before the slider — hides once the fill reaches it
2943
2943
  - `color?: "error" | "primary" | "secondary" | "tertiary" = "primary"` — Base color — used for the fill and thumb unless overridden by fillColor/thumbColor
2944
2944
  - `fillColor?: string` — Custom color (hex, rgb(), a CSS var, etc.) for the filled/active portion of the track and the corner dot. Defaults to `color`'s M3 token.
@@ -3954,20 +3954,56 @@ palettes: Palette[]
3954
3954
 
3955
3955
  ### useConfetti
3956
3956
 
3957
- Confetti for a component: `fire(event)` from the pointer, `fire(el)` from an element, `fire({ from: 'top' })`.
3957
+ Confetti for a component: `fire(event)` from the pointer, `fire(el)` from an element, `fire({ from: 'top' })`, `fire({ from: 'top', duration: 5000 })` for a rain that lasts. Returns a function that stops it early.
3958
3958
 
3959
3959
  ```ts
3960
3960
  useConfetti(): {
3961
- fire: (origin?: ConfettiOrigin | ConfettiOptions, options?: ConfettiOptions) => void
3961
+ fire: (origin?: ConfettiOrigin | ConfettiOptions, options?: ConfettiOptions) => StopConfetti
3962
3962
  }
3963
3963
  ```
3964
3964
 
3965
3965
  ### fireConfetti
3966
3966
 
3967
- Fires a burst of confetti. Browser only; does nothing under reduced motion.
3967
+ Fires confetti: one burst, or with `duration` a rain or fountain that keeps going (stop it early with the returned function). Browser only; does nothing under reduced motion.
3968
3968
 
3969
3969
  ```ts
3970
- fireConfetti(origin?: ConfettiOrigin, options: ConfettiOptions = {}): void
3970
+ fireConfetti(origin?: ConfettiOrigin, options: ConfettiOptions = {}): StopConfetti
3971
+ ```
3972
+
3973
+ ### useFireworks
3974
+
3975
+ Fireworks for a component: `launch()`, `launch({ shapes: ['classic'] })`, `launch({ shapes: ['Heart'] })`, `launch({ duration: 10000 })`.
3976
+
3977
+ ```ts
3978
+ useFireworks(): {
3979
+ launch: (options: FireworksOptions = {}) => StopFireworks
3980
+ }
3981
+ ```
3982
+
3983
+ ### launchFireworks
3984
+
3985
+ Launches fireworks: a few rockets, or with `duration` a show that keeps going (stop it early with the returned function). Browser only; does nothing under reduced motion.
3986
+
3987
+ ```ts
3988
+ launchFireworks(options: FireworksOptions = {}): StopFireworks
3989
+ ```
3990
+
3991
+ ### useReactions
3992
+
3993
+ Floating reactions for a component: `react(event, '🎉')` from the pointer, `react(el, { icon: 'favorite' })` from an element, `react(el, '👏', { count: 5 })` for a handful.
3994
+
3995
+ ```ts
3996
+ useReactions(): {
3997
+ react: (origin: ReactionOrigin | undefined, content: ReactionContent, options: ReactionOptions = {}) => void
3998
+ }
3999
+ ```
4000
+
4001
+ ### fireReaction
4002
+
4003
+ Sends a reaction floating up from a point. Browser only.
4004
+
4005
+ ```ts
4006
+ fireReaction(origin: ReactionOrigin | undefined, content: ReactionContent, options: ReactionOptions = {}): void
3971
4007
  ```
3972
4008
 
3973
4009
  ### useContainerTransform
@@ -3996,10 +4032,10 @@ themeInitScript(options: ThemeInitOptions = {}): string
3996
4032
 
3997
4033
  ### viewportFromHeaders
3998
4034
 
3999
- The window size to server-render the adaptive layouts at, from a request's headers: the size `createM3UI({ cookies: true })` keeps in the `m3-viewport` cookie (any visit after the first); the viewport client hints (Chromium, once the server asked for them with `VIEWPORT_HINTS`); or, on a first visit, a size standing for the kind of device (`Sec-CH-UA-Mobile`, then the user agent: a phone, a tablet or a desktop), unless `guess: false`. Undefined when nothing tells: the layouts then render compact. ```ts createM3UI({ cookies: true, initialState: { viewport: viewportFromHeaders(request.headers) } }) ```
4035
+ The window size to server-render the adaptive layouts at, from a request's headers: the size `createM3UI({ cookies: true })` keeps in the `m3-viewport` cookie (any visit after the first); the viewport client hints (Chromium, once the server asked for them with `VIEWPORT_HINTS`); or, on a first visit, a size standing for the kind of device (`Sec-CH-UA-Mobile`, then the user agent: a phone, a tablet or a desktop), unless `guess: false`. With `createM3UI({ storagePrefix })`, pass the same `storagePrefix` so the right cookie is read. Undefined when nothing tells: the layouts then render compact. ```ts createM3UI({ cookies: true, initialState: { viewport: viewportFromHeaders(request.headers) } }) ```
4000
4036
 
4001
4037
  ```ts
4002
- viewportFromHeaders(headers: RequestHeaders, options: { guess?: boolean } = {}): ViewportSize | undefined
4038
+ viewportFromHeaders(headers: RequestHeaders, options: { guess?: boolean; storagePrefix?: string } = {}): ViewportSize | undefined
4003
4039
  ```
4004
4040
 
4005
4041
  ### VIEWPORT_HINTS
@@ -4305,6 +4341,14 @@ Turns an element into its own loading placeholder: `v-skeleton="loading"` or `v-
4305
4341
  vSkeleton: Directive<HTMLElement, SkeletonValue>
4306
4342
  ```
4307
4343
 
4344
+ ### vSparkle
4345
+
4346
+ Sparkles that twinkle over an element, to draw the eye to something new or special: `v-sparkle`, `v-sparkle="'hover'"`, `v-sparkle="'#f5b400'"` or `v-sparkle="{ trigger, color, size, rate, shapes, disabled }"`. They're drawn in a layer over the element (a statically positioned one is made `position: relative`), hidden from assistive technology, and pause while it's off screen or the tab is hidden; none under reduced motion. Registered globally as `v-sparkle` by `createM3UI()`; import `vSparkle` to use it without the plugin.
4347
+
4348
+ ```ts
4349
+ vSparkle: Directive<HTMLElement, SparkleValue>
4350
+ ```
4351
+
4308
4352
  ### emojiCategories
4309
4353
 
4310
4354
  ```ts
@@ -4571,6 +4615,14 @@ export interface M3UIOptions {
4571
4615
  * and render with the user's choice and for their screen through `initialState`.
4572
4616
  */
4573
4617
  cookies?: boolean
4618
+ /**
4619
+ * A prefix for every key the library stores in localStorage and cookies (`'admin'` → `admin-m3-theme`,
4620
+ * `admin-m3-palette`…), so apps served from the same origin under different paths (`example.com/admin`,
4621
+ * `example.com/shop`) each keep their own theme, palette, contrast and recent colors/emoji instead of sharing them.
4622
+ * Letters, digits, `-` and `_` (it's also part of the cookie names). Pass the same one to `themeInitScript()` and
4623
+ * `viewportFromHeaders()` when you use them.
4624
+ */
4625
+ storagePrefix?: string
4574
4626
  /**
4575
4627
  * Server-side rendering: the user's theme, palette and contrast as the server knows them (from the cookies that
4576
4628
  * `cookies` writes), on the server and on the client alike. `useTheme()` and `useColorPalette()` report them on
@@ -4616,12 +4668,76 @@ export interface ConfettiOptions {
4616
4668
  velocity?: number
4617
4669
  /** Piece size in px (default 14) */
4618
4670
  size?: number
4671
+ /**
4672
+ * Keep it going for this long, in ms: a rain that keeps falling (`from: 'top'`) or a fountain from the point,
4673
+ * `count` then being pieces per second. `Infinity` runs until the returned `stop()`. Unset: one burst
4674
+ */
4675
+ duration?: number
4619
4676
  }
4620
4677
  ```
4621
4678
 
4622
4679
  ```ts
4623
4680
  /** Where a burst starts: the pointer of an event, an element's center, or a point in viewport pixels */
4624
- export type ConfettiOrigin = MouseEvent | PointerEvent | Element | { x: number; y: number }
4681
+ export type ConfettiOrigin = EffectOrigin
4682
+ ```
4683
+
4684
+ ```ts
4685
+ /** Stops a running confetti before its `duration` ends; the pieces already out finish falling. */
4686
+ export type StopConfetti = () => void
4687
+ ```
4688
+
4689
+ ```ts
4690
+ /** A burst's look: `'classic'`, or an MShape's name its sparks are laid out along. */
4691
+ export type FireworkShape = 'classic' | ShapeName
4692
+ ```
4693
+
4694
+ ```ts
4695
+ export interface FireworksOptions {
4696
+ /** How many rockets (default 6, launched over about a second and a half); with `duration`, rockets per second */
4697
+ count?: number
4698
+ /**
4699
+ * What the bursts look like, one picked per burst: `'classic'` (sparks thrown out from the center that fall as they
4700
+ * fade) or an MShape's name the sparks are laid out along (`'Circle'` is a ring). Default: mostly classic, with a
4701
+ * ring, a heart, a flower… now and then
4702
+ */
4703
+ shapes?: FireworkShape[]
4704
+ /** Any CSS colors. Default: the theme's primary, secondary and tertiary roles and their containers */
4705
+ colors?: string[]
4706
+ /** Burst radius in px. Default: a sixth of the screen's smaller side, between 70 and 180 */
4707
+ size?: number
4708
+ /** Keep launching for this long, in ms (`count` then being rockets per second); `Infinity` runs until `stop()` */
4709
+ duration?: number
4710
+ }
4711
+ ```
4712
+
4713
+ ```ts
4714
+ /** Stops launching before `duration` ends; what's already in the air finishes. */
4715
+ export type StopFireworks = () => void
4716
+ ```
4717
+
4718
+ ```ts
4719
+ /** What floats up: any text (an emoji, `'+1'`), or a Material Symbol (`{ icon: 'favorite' }`, filled by default). */
4720
+ export type ReactionContent = string | { icon: string; filled?: boolean; color?: string }
4721
+ ```
4722
+
4723
+ ```ts
4724
+ export interface ReactionOptions {
4725
+ /** How many float up together, a little apart (default 1) */
4726
+ count?: number
4727
+ /** Size in px (default 32) */
4728
+ size?: number
4729
+ /** How far it rises, in px (default 260) */
4730
+ distance?: number
4731
+ /** How long it floats, in ms (default 2200) */
4732
+ duration?: number
4733
+ /** How far it sways to each side, in px (default 20) */
4734
+ sway?: number
4735
+ }
4736
+ ```
4737
+
4738
+ ```ts
4739
+ /** Where a reaction starts: the pointer of an event, an element's center, or a point in viewport pixels */
4740
+ export type ReactionOrigin = EffectOrigin
4625
4741
  ```
4626
4742
 
4627
4743
  ```ts
@@ -4685,6 +4801,8 @@ export interface ThemeInitOptions {
4685
4801
  contrast?: ContrastLevel
4686
4802
  /** `createM3UI`'s `persistPalette`. */
4687
4803
  persistPalette?: boolean
4804
+ /** `createM3UI`'s `storagePrefix`. */
4805
+ storagePrefix?: string
4688
4806
  }
4689
4807
  ```
4690
4808
 
@@ -5344,6 +5462,29 @@ export interface SkeletonOptions {
5344
5462
  export type SkeletonValue = boolean | SkeletonOptions | null | undefined
5345
5463
  ```
5346
5464
 
5465
+ ```ts
5466
+ /** Options for `v-sparkle`. */
5467
+ export interface SparkleOptions {
5468
+ /** No sparkles while true */
5469
+ disabled?: boolean
5470
+ /** `'always'` (default) sparkles all the time; `'hover'` only while the pointer is over it or focus is in it */
5471
+ trigger?: 'always' | 'hover'
5472
+ /** Any CSS colors, one picked per sparkle. Default: the theme's primary and tertiary where the element is */
5473
+ color?: string | string[]
5474
+ /** Sparkle size in px, each one a bit bigger or smaller (default 14) */
5475
+ size?: number
5476
+ /** Sparkles per second (default 3) */
5477
+ rate?: number
5478
+ /** MShape's shapes instead of the four-pointed star */
5479
+ shapes?: ShapeName[]
5480
+ }
5481
+ ```
5482
+
5483
+ ```ts
5484
+ /** `v-sparkle` value: nothing or `true` (on), `false` (off), `'hover'`, a CSS color, or an options object. */
5485
+ export type SparkleValue = boolean | string | SparkleOptions | null | undefined
5486
+ ```
5487
+
5347
5488
  ```ts
5348
5489
  // Generated by scripts/generate-emoji-data.mjs from Unicode emoji-test.txt (Emoji 15). Don't edit by hand.
5349
5490
  // Emoji data © Unicode, Inc., under the Unicode License v3 (dist/THIRD_PARTY_LICENSES.md, scripts/licenses/unicode-license-v3.txt).
@@ -1,5 +1,5 @@
1
1
  import { i as e } from "./useLocale-JYxDDeXC.js";
2
- import { g as t, h as n, l as r, n as i, o as a, p as o, r as s, s as c, v as l, y as u } from "./MTextField-BBmkaIbO.js";
2
+ import { g as t, h as n, l as r, n as i, o as a, p as o, r as s, s as c, v as l, y as u } from "./MTextField-Bz8JIsnl.js";
3
3
  import { i as d } from "./motion-DZiXG09o.js";
4
4
  import { t as f } from "./MIcon-Bxh9j135.js";
5
5
  import { t as p } from "./_plugin-vue_export-helper-B3ysoDQm.js";
@@ -926,4 +926,4 @@ var Te = ["data-menu-level"], Ee = { class: "flex-1 truncate" }, De = { key: "ro
926
926
  //#endregion
927
927
  export { Se as a, K as c, Ce as i, W as l, Ae as n, ge as o, we as r, Q as s, Ie as t };
928
928
 
929
- //# sourceMappingURL=MMenuItem-DI351kIf.js.map
929
+ //# sourceMappingURL=MMenuItem-D4Gx_l3F.js.map